@es-joy/jsoe 0.23.0 → 0.23.1
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/CHANGES.md +4 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/subTypes/blobHTMLType.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/subTypes/blobHTMLType.js +3 -1
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"react";let e;"undefined"!=typeof window&&window&&(e=window);let t="undefined"!=typeof document&&document||e?.document;const a=["$plugins","$map"],r="http://www.w3.org/1999/xhtml",n=/-([a-z])/gu,i=new Map([["maxlength","maxLength"],["minlength","minLength"],["readonly","readOnly"]]),s=["checked","defaultChecked","defaultSelected","disabled","indeterminate","open","readOnly","selected","accessKey","async","autocapitalize","autofocus","contentEditable","defaultValue","defer","draggable","formnovalidate","hidden","innerText","inputMode","ismap","multiple","novalidate","pattern","required","spellcheck","translate","value","willvalidate"],o=["autocomplete","dir","integrity","lang","max","min","minLength","maxLength","title"],$$2=e=>{if(!t)throw new Error("No document object");return t.querySelector(e)};function _appendNode(e,t){"template"!==function _getHTMLNodeName(e){return e.nodeName&&e.nodeName.toLowerCase()}(e)?e.append(t):e.content.append(t)}function _createSafeReference(e,a,r){if(!t)throw new Error("No document defined");if(!/^\w+$/u.test(r))throw new TypeError(`Bad ${e} reference; with prefix "${a}" and arg "${r}"`);const n=t.createElement("div");return n.innerHTML="&"+a+r+";",t.createTextNode(n.innerHTML)}function _upperCase(e,t){return t.toUpperCase()}function _isNullish(e){return null==e}function _getType(e){const t=typeof e;if("string"==typeof e||void 0===e)return"string";if("object"===t){if(null===e)return"null";if(Array.isArray(e))return"array";if("nodeType"in e)switch(e.nodeType){case 1:return"element";case 9:return"document";case 11:return"fragment";default:return"non-container node"}}return t}function _fragReducer(e,t){return e.append(t),e}function _replaceDefiner(e){return function(...t){const a=t[0];let r=e[""]?' xmlns="'+e[""]+'"':a;for(const[t,a]of Object.entries(e))""!==t&&(r+=" xmlns:"+t+'="'+a+'"');return r}}function _childrenToJML(e){return function(t,a){const r=e.childNodes[a],n=Array.isArray(t)?c(...t):c(t);r.replaceWith(n)}}function _appendJML(e){return function(t){if("string"==typeof t||"number"==typeof t)throw new TypeError("Unexpected text string/number in the head");Array.isArray(t)?e.append(c(...t)):"object"==typeof t&&"nodeType"in t?e.append(t):e.append(c(t))}}function _appendJMLOrText(e){return function(t){"string"==typeof t||"number"==typeof t?e.append(String(t)):Array.isArray(t)?e.append(c(...t)):"object"==typeof t&&"nodeType"in t?e.append(t):e.append(c(t))}}function checkPluginValue(e,t,a,r,n){if(r.$state=n??"attributeValue",a&&"object"==typeof a){const n=getMatchingPlugin(r,Object.keys(a)[0]);if(n)return n.set({opts:r,element:e,attribute:{name:t,value:a}})}return a}function getMatchingPlugin(e,t){return e.$plugins&&e.$plugins.find((e=>e.name===t))}const c=function jml(...c){if(!e)throw new Error("No window object");if(!t)throw new Error("No document object");let l=t.createDocumentFragment();function _checkAtts(e){if(!t)throw new Error("No document object");for(let[h,f]of Object.entries(e))if(h=i.get(h)??h,o.includes(h))f=checkPluginValue(l,h,f,p),_isNullish(f)||(l[h]=f);else if(s.includes(h))f=checkPluginValue(l,h,f,p),l[h]=f;else switch(h){case"#":p.$state="fragmentChildren",u[u.length]=jml(p,f);break;case"$shadow":{const{open:e,closed:a}=f;let{content:r,template:n}=f;const i=l.attachShadow({mode:a||!1===e?"closed":"open"});n?(Array.isArray(n)?n="object"===_getType(n[0])?jml("template",...n,t.body):jml("template",n,t.body):"string"==typeof n&&(n=$$2(n)),jml(n.content.cloneNode(!0),i)):(r||!0!==e&&(r=e||"boolean"==typeof a?r:a),r&&"boolean"!=typeof r&&(Array.isArray(r)?jml({"#":r},i):jml(r,i)));break}case"$state":case"is":case"xmlns":break;case"$custom":Object.assign(l,f);break;case"$define":{if(!("localName"in l))throw new Error("Element expected for `$define`");const a=l.localName.toLowerCase(),r=!a.includes("-");let n;if(r&&(n=l.getAttribute("is"),!n)){if(!Object.hasOwn(e,"is"))throw new TypeError(`Expected \`is\` with \`$define\` on built-in; args: ${JSON.stringify(c)}`);e.is=checkPluginValue(l,"is",e.is,p),l.setAttribute("is",e.is),({is:n}=e)}const i=r?n:a;if(window.customElements.get(i))break;const getConstructor=e=>{if(!t)throw new Error("No document object");const n="object"==typeof o&&"string"==typeof o.extends?t.createElement(o.extends).constructor:r?t.createElement(a).constructor:window.HTMLElement;return e?class extends n{constructor(){super(),e.call(this)}}:class extends n{}};let s,o,u;const d=f;Array.isArray(d)?d.length<=2?([s,o]=d,"string"==typeof o?o={extends:o}:o&&!Object.hasOwn(o,"extends")&&(u=o),"object"==typeof s&&(u=s,s=getConstructor())):([s,u,o]=d,"string"==typeof o&&(o={extends:o})):"function"==typeof d?s=d:(u=d,s=getConstructor()),s.toString().startsWith("class")||(s=getConstructor(s)),!o&&r&&(o={extends:a}),u&&Object.entries(u).forEach((([e,t])=>{s.prototype[e]=t})),window.customElements.define(i,s,"object"==typeof o?o:void 0);break}case"$symbol":{const[e,t]=f;if("function"==typeof t){const a=t.bind(l);"string"==typeof e?l[Symbol.for(e)]=a:l[e]=a}else{const a=t;a.elem=l,"string"==typeof e?l[Symbol.for(e)]=a:l[e]=a}break}case"$data":setMap(f);break;case"$attribute":{const e=f,a=3===e.length?t.createAttributeNS(e[0],e[1]):t.createAttribute(e[0]);a.value=e[e.length-1],u[u.length]=a;break}case"$text":{const e=t.createTextNode(f);u[u.length]=e;break}case"$document":{const e=t.implementation.createHTMLDocument();if(!f)throw new Error("Bad attribute value");const a=f;if(a.childNodes){const t=a.childNodes.length;for(;e.childNodes[t];){e.childNodes[t].remove()}a.childNodes.forEach(_childrenToJML(e))}else{if(a.$DOCTYPE){const t={$DOCTYPE:a.$DOCTYPE},r=jml(t);e.firstChild?.replaceWith(r)}const r=e.querySelector("html"),n=r?.querySelector("head"),i=r?.querySelector("body");if(a.title||a.head){const r=t.createElement("meta");r.setAttribute("charset","utf-8"),n?.append(r),a.title&&(e.title=a.title),a.head&&n&&a.head.forEach(_appendJML(n))}a.body&&i&&a.body.forEach(_appendJMLOrText(i))}u[u.length]=e;break}case"$DOCTYPE":{const e=f,a=t.implementation.createDocumentType(e.name,e.publicId||"",e.systemId||"");u[u.length]=a;break}case"$on":for(let[e,t]of Object.entries(f||{})){if("function"==typeof t&&(t=[t,!1]),"function"!=typeof t[0])throw new TypeError(`Expect a function for \`$on\`; args: ${JSON.stringify(c)}`);a=l,r=e,m=t[0],y=t[1],a.addEventListener(r,m,Boolean(y))}break;case"className":case"class":f=checkPluginValue(l,h,f,p),_isNullish(f)||(l.className=f);break;case"dataset":{const recurse=(e,t)=>{let a="";const r=""!==t;Object.keys(e).forEach((i=>{const s=e[i];if(a=r?t+i.replace(n,_upperCase).replace(/^([a-z])/u,_upperCase):t+i.replace(n,_upperCase),null===s||"object"!=typeof s)return _isNullish(s)||(l.dataset[a]=s),void(a=t);recurse(s,a)}))};recurse(f,"");break}case"innerHTML":_isNullish(f)||(l.innerHTML=f);break;case"htmlFor":case"for":if("label"===d){f=checkPluginValue(l,h,f,p),_isNullish(f)||(l.htmlFor=f);break}f=checkPluginValue(l,h,f,p),l.setAttribute(h,f);break;default:{if(h.startsWith("on")){f=checkPluginValue(l,h,f,p),l[h]=f;break}if("style"===h){if(f=checkPluginValue(l,h,f,p),_isNullish(f))break;if("object"==typeof f){for(const[e,t]of Object.entries(f))_isNullish(t)||("float"===e?(l.style.cssFloat=t,l.style.styleFloat=t):l.style[e.replace(n,_upperCase)]=t);break}l.setAttribute(h,f);break}const e=h,t=getMatchingPlugin(p,e);if(t){t.set({opts:p,element:u[0],attribute:{name:e,value:f}});break}f=checkPluginValue(l,h,f,p),l.setAttribute(h,f);break}}var a,r,m,y}const u=[];let d,p,m=!1,y=0;if("object"===_getType(c[0])&&Object.keys(c[0]).some((e=>a.includes(e)))){if(p=c[0],void 0===p.$state&&(m=!0,p.$state="root"),Array.isArray(p.$map)&&(p.$map={root:p.$map}),"$plugins"in p){if(!Array.isArray(p.$plugins))throw new TypeError(`\`$plugins\` must be an array; args: ${JSON.stringify(c)}`);p.$plugins.forEach((e=>{if(!e||"object"!=typeof e)throw new TypeError(`Plugin must be an object; args: ${JSON.stringify(c)}`);if(!e.name||!e.name.startsWith("$_"))throw new TypeError(`Plugin object name must be present and begin with \`$_\`; args: ${JSON.stringify(c)}`);if("function"!=typeof e.set)throw new TypeError(`Plugin object must have a \`set\` method; args: ${JSON.stringify(c)}`)}))}y=1}else p={$state:void 0};const h=c.length,f=p.$map&&p.$map.root,setMap=e=>{let t,a;const r=f;if(!0===e)[t,a]=r;else if(Array.isArray(e)){if("string"==typeof e[0])return void e.forEach((e=>{setMap(p.$map[e])}));t=e[0]||r[0],a=e[1]||r[1]}else/^\[object (?:Weak)?Map\]$/u.test([].toString.call(e))?(t=e,a=r[1]):(t=r[0],a=e);t.set(l,a)};for(let a=y;a<h;a++){let n=c[a];const i=_getType(n);switch(i){case"null":if(a===h-1)return u.length<=1?u[0]:u.reduce(_fragReducer,t.createDocumentFragment());throw new TypeError(`\`null\` values not allowed except as final Jamilih argument; index ${a} on args: ${JSON.stringify(c)}`);case"string":switch(n){case"!":u[u.length]=t.createComment(c[++a]);break;case"?":{n=c[++a];let e=c[++a];const r=e;if(r&&"object"==typeof r){const t=[];for(const[e,a]of Object.entries(r))t.push(e+'="'+a.replace(/"/gu,""")+'"');e=t.join(" ")}try{u[u.length]=t.createProcessingInstruction(n,e)}catch(a){u[u.length]=t.createComment("?"+n+" "+e+"?")}break}case"&":u[u.length]=_createSafeReference("entity","",c[++a]);break;case"#":u[u.length]=_createSafeReference("decimal",n,String(c[++a]));break;case"#x":u[u.length]=_createSafeReference("hexadecimal",n,c[++a]);break;case"![":try{u[u.length]=t.createCDATASection(c[++a])}catch(e){u[u.length]=t.createTextNode(c[a])}break;case"":u[u.length]=l=t.createDocumentFragment(),p.$state="fragment";break;default:{d=n;const e=c[a+1];if(e&&"object"===_getType(e)&&e.is){const{is:a}=e;l=t.createElementNS?t.createElementNS(r,d,{is:a}):t.createElement(d,{is:a})}else l=t.createElementNS?t.createElementNS(r,d):t.createElement(d);p.$state="element",u[u.length]=l;break}}break;case"object":{if(!n||"object"!=typeof n)throw new Error("Null should not reach here");const t=n;if("xmlns"in t){const a=t,n=a.xmlns&&"object"==typeof a.xmlns?_replaceDefiner(a.xmlns):' xmlns="'+a.xmlns+'"';l=u[u.length-1]=(new e.DOMParser).parseFromString((new e.XMLSerializer).serializeToString(l).replace(' xmlns="'+r+'"',n),"application/xml").documentElement,p.$state="element"}_checkAtts(t);break}case"document":case"fragment":case"element":if(0===a&&(l=n,p.$state="element"),a===h-1||a===h-2&&null===c[a+1]){const e=u.length;for(let t=0;t<e;t++)_appendNode(n,u[t])}else u[u.length]=n;break;case"array":{const e=n,a=e.length;for(let r=0;r<a;r++){const a=e[r],n=typeof a;if(null===a||_isNullish(a))throw new TypeError(`Bad children (parent array: ${JSON.stringify(c)}; index ${r} of child: ${JSON.stringify(e)})`);switch(n){case"string":case"number":case"boolean":_appendNode(l,t.createTextNode(String(a)));break;default:if("object"!=typeof a)throw new TypeError(`Bad children (parent array: ${JSON.stringify(c)}; index ${r} of child: ${JSON.stringify(e)})`);if(Array.isArray(a))p.$state="children",_appendNode(l,jml(p,...a));else if("#"in a)p.$state="fragmentChildren",_appendNode(l,jml(p,a["#"]));else{let e;"nodeType"in a||(e=checkPluginValue(l,null,a,p,"children")),_appendNode(l,e||a)}}}break}default:throw new TypeError(`Unexpected type: ${i}; arg: ${n}; index ${a} on args: ${JSON.stringify(c)}`)}}const g=u[0]||l;return m&&p.$map&&p.$map.root&&setMap(!0),g};let l,u=class DOMException extends Error{constructor(e,t){super(e),this.code=0,this.name=t}};c.toJML=function(t,{stringOutput:a=!1,reportInvalidState:r=!0,stripWhitespace:n=!1}={}){if(!e)throw new Error("No window object set");"string"==typeof t&&(t=(new e.DOMParser).parseFromString(t,"text/html"));const i=[];let s=i,o=0;function invalidStateError(e){if(r){const t=new u(e,"INVALID_STATE_ERR");throw t.code=11,t}}function set(e){s[o]=e,o++}function setChildren(){set([]),s=s[o-1],o=0}function setObj(e,t){s=s[o-1][e],o=0,t&&(s=s[t])}return function parseDOM(e,t){const a="nodeType"in e?e.nodeType:null;if(!a)throw new TypeError("Not an XML type");if(5===a)return void set(["&",e.nodeName]);let r,i;function setTemp(){r=s,i=o}function resetTemp(){s=r,o=i,o++}switch(t={...t},[2,3,4,7,8].includes(a)&&e.nodeValue&&!/^([\u0009\u000A\u000D\u0020-\uD7FF\uE000-\uFFFD]|[\uD800-\uDBFF][\uDC00-\uDFFF])*$/u.test(e.nodeValue)&&invalidStateError("Node has bad XML character value"),a){case 1:{const a=e;setTemp();const r=a.nodeName.toLowerCase();setChildren(),set(r);const n={};let i=!1;t[a.prefix||""]!==a.namespaceURI&&(t[a.prefix||""]=a.namespaceURI,a.prefix?n["xmlns:"+a.prefix]=a.namespaceURI:a.namespaceURI?n.xmlns=a.namespaceURI:n.xmlns=null,i=!0),a.attributes.length?set([...a.attributes].reduce((function(e,t){return e[t.name]=t.value,e}),n)):i&&set(n);const{childNodes:s}=a;s.length&&(setChildren(),[...s].forEach((function(e){parseDOM(e,t)}))),resetTemp();break}case 2:{const t=e;set({$attribute:[t.namespaceURI,t.name,t.value]});break}case 3:{const t=e;if(!t.nodeValue)throw new Error("Unexpected null comment value");if(n&&/^\s+$/u.test(t.nodeValue))return void set("");set(t.nodeValue);break}case 4:{const t=e;t.nodeValue?.includes("]]>")&&invalidStateError("CDATA cannot end with closing ]]>"),set(["![",t.nodeValue]);break}case 7:{const t=e;/^xml$/iu.test(t.target)&&invalidStateError('Processing instructions cannot be "xml".'),t.target.includes("?>")&&invalidStateError("Processing instruction targets cannot include ?>"),t.target.includes(":")&&invalidStateError('The processing instruction target cannot include ":"'),t.data.includes("?>")&&invalidStateError("Processing instruction data cannot include ?>"),set(["?",t.target,t.data]);break}case 8:{const t=e;if(!t.nodeValue)throw new Error("Unexpected null comment value");(t.nodeValue.includes("--")||t.nodeValue.length&&t.nodeValue.lastIndexOf("-")===t.nodeValue.length-1)&&invalidStateError("Comments cannot include --"),set(["!",t.nodeValue]);break}case 9:{const a=e;setTemp();set({$document:{childNodes:[]}}),setObj("$document","childNodes");const{childNodes:r}=a;r.length||invalidStateError("Documents must have a child node"),[...r].forEach((function(e){parseDOM(e,t)})),resetTemp();break}case 10:{const t=e;setTemp();const a={$DOCTYPE:{name:t.name}};/^(\u0020|\u000D|\u000A|[a-zA-Z0-9]|[-'()+,./:=?;!*#@$_%])*$/u.test(t.publicId)||invalidStateError("A publicId must have valid characters."),function addExternalID(e,t){t.systemId.includes('"')&&t.systemId.includes("'")&&invalidStateError("systemId cannot have both single and double quotes.");const{publicId:a,systemId:r}=t;r&&(e.systemId=r),a&&(e.publicId=a)}(a.$DOCTYPE,t),set(a),resetTemp();break}case 11:{const a=e;setTemp(),set({"#":[]}),setObj("#");const{childNodes:r}=a;[...r].forEach((function(e){parseDOM(e,t)})),resetTemp();break}default:throw new TypeError("Not an XML type")}}(t,{}),a?JSON.stringify(i[0]):i[0]},c.toJMLString=function(e,t){return c.toJML(e,Object.assign(t||{},{stringOutput:!0}))},c.toDOM=function(...e){return c(...e)},c.toHTML=function(...e){const t=c(...e);switch(t.nodeType){case 1:return t.outerHTML;case 2:return`${t.name}="${t.value.replace(/"/gu,""")}"`;case 3:if(!t.nodeValue)throw new TypeError("Unexpected null Text node");return t.nodeValue;case 9:case 11:return[...t.childNodes].map((e=>c.toHTML(e))).join("");case 10:{const e=t;return`<!DOCTYPE ${e.name}${e.publicId?` PUBLIC "${e.publicId}" "${e.systemId}"`:e.systemId?` SYSTEM "${e.systemId}"`:""}>`}default:throw new Error("Unexpected node type")}},c.toDOMString=function(...e){return c.toHTML(...e)},c.toXML=function(...t){if(!e)throw new Error("No window object set");const a=c(...t);return(new e.XMLSerializer).serializeToString(a)},c.toXMLDOMString=function(...e){return c.toXML(...e)};class JamilihMap extends Map{get(e){const t="string"==typeof e?$$2(e):e;return super.get.call(this,t)}set(e,t){const a="string"==typeof e?$$2(e):e;return super.set.call(this,a,t)}invoke(e,t,...a){const r="string"==typeof e?$$2(e):e;return this.get(r)[t](r,...a)}}class JamilihWeakMap extends WeakMap{get(e){const t="string"==typeof e?$$2(e):e;if(!t)throw new Error("Can't find the element");return super.get.call(this,t)}set(e,t){const a="string"==typeof e?$$2(e):e;if(!a)throw new Error("Can't find the element");return super.set.call(this,a,t)}invoke(e,t,...a){const r="string"==typeof e?$$2(e):e;if(!r)throw new Error("Can't find the element");return this.get(r)[t](r,...a)}}c.Map=JamilihMap,c.WeakMap=JamilihWeakMap,c.weak=function(e,...t){const a=new JamilihWeakMap;return[a,c({$map:[a,e]},...t)]},c.strong=function(e,...t){const a=new JamilihMap;return[a,c({$map:[a,e]},...t)]},c.symbol=c.sym=c.for=function(e,t){return("string"==typeof e?$$2(e):e)["symbol"==typeof t?t:Symbol.for(t)]},c.command=function(e,t,a,...r){if(!(e="string"==typeof e?$$2(e):e))throw new Error("No element found");let n;if(["symbol","string"].includes(typeof t))return n=c.sym(e,t),"function"==typeof n?n(a,...r):n[a](...r);if(n=t.get(e),!n)throw new Error("No map found");return"function"==typeof n?n.call(e,a,...r):n[a](e,...r)},c.setWindow=a=>{e=a,t=e?.document,t&&t.body&&(l=t.body)},c.getWindow=()=>{if(!e)throw new Error("No window object set");return e},t&&t.body&&(l=t.body);const d=" ";function ownKeys(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,r)}return a}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(a),!0).forEach((function(t){_defineProperty(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):ownKeys(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _createClass(e,t,a){return t&&function _defineProperties(e,t){for(var a=0;a<t.length;a++){var r=t[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,_toPropertyKey(r.key),r)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _defineProperty(e,t,a){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function _slicedToArray(e,t){return function _arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function _iterableToArrayLimit(e,t){var a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var r,n,i,s,o=[],c=!0,l=!1;try{if(i=(a=a.call(e)).next,0===t){if(Object(a)!==a)return;c=!1}else for(;!(c=(r=i.call(a)).done)&&(o.push(r.value),o.length!==t);c=!0);}catch(e){l=!0,n=e}finally{try{if(!c&&null!=a.return&&(s=a.return(),Object(s)!==s))return}finally{if(l)throw n}}return o}}(e,t)||_unsupportedIterableToArray(e,t)||function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,r=new Array(t);a<t;a++)r[a]=e[a];return r}function _toPropertyKey(e){var t=function _toPrimitive(e,t){if("object"!=typeof e||null===e)return e;var a=e[Symbol.toPrimitive];if(void 0!==a){var r=a.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:String(t)}var p=_createClass((function TypesonPromise(e){_classCallCheck(this,TypesonPromise),this.p=new Promise(e)}));p.__typeson__type__="TypesonPromise","undefined"!=typeof Symbol&&Object.defineProperty(p.prototype,Symbol.toStringTag,{get:function get(){return"TypesonPromise"}}),p.prototype.then=function(e,t){var a=this;return new p((function(r,n){a.p.then((function(t){r(e?e(t):t)})).catch((function(e){return t?t(e):Promise.reject(e)})).then(r,n)}))},p.prototype.catch=function(e){return this.then((function(){}),e)},p.resolve=function(e){return new p((function(t){t(e)}))},p.reject=function(e){return new p((function(t,a){a(e)}))},p.all=function(e){return new p((function(t,a){Promise.all(e.map((function(e){return null!=e&&e.constructor&&"__typeson__type__"in e.constructor&&"TypesonPromise"===e.constructor.__typeson__type__?e.p:e}))).then(t,a)}))},p.race=function(e){return new p((function(t,a){Promise.race(e.map((function(e){return null!=e&&e.constructor&&"__typeson__type__"in e.constructor&&"TypesonPromise"===e.constructor.__typeson__type__?e.p:e}))).then(t,a)}))},p.allSettled=function(e){return new p((function(t,a){Promise.allSettled(e.map((function(e){return null!=e&&e.constructor&&"__typeson__type__"in e.constructor&&"TypesonPromise"===e.constructor.__typeson__type__?e.p:e}))).then(t,a)}))};var m=Object.hasOwn,y=Object.getPrototypeOf;function isThenable(e,t){return isObject(e)&&"function"==typeof e.then&&!t}function toStringTag(e){return Object.prototype.toString.call(e).slice(8,-1)}function hasConstructorOf(e,t){if(!e||"object"!==_typeof(e))return!1;var a=y(e);if(!a)return null===t;var r=m(a,"constructor")&&a.constructor;return"function"!=typeof r?null===t:t===r||null!==t&&Function.prototype.toString.call(r)===Function.prototype.toString.call(t)||"function"==typeof t&&"string"==typeof r.__typeson__type__&&r.__typeson__type__===t.__typeson__type__}function isPlainObject(e){return!(!e||"Object"!==toStringTag(e))&&(!y(e)||hasConstructorOf(e,Object))}function isUserObject(e){if(!e||"Object"!==toStringTag(e))return!1;var t=y(e);return!t||hasConstructorOf(e,Object)||isUserObject(t)}function isObject(e){return null!==e&&"object"===_typeof(e)}function escapeKeyPathComponent(e){return e.replaceAll("''","''''").replace(/^$/,"''").replaceAll("~","~0").replaceAll(".","~1")}function unescapeKeyPathComponent(e){return e.replaceAll("~1",".").replaceAll("~0","~").replace(/^''$/,"").replaceAll("''''","''")}function getByKeyPath(e,t){if(""===t)return e;if(null===e||"object"!==_typeof(e))throw new TypeError("Unexpected non-object type");var a=t.indexOf(".");if(a>-1){var r=e[unescapeKeyPathComponent(t.slice(0,a))];return void 0===r?void 0:getByKeyPath(r,t.slice(a+1))}return e[unescapeKeyPathComponent(t)]}function setAtKeyPath(e,t,a){if(""===t)return a;if(!e||"object"!==_typeof(e))throw new TypeError("Unexpected non-object type");var r=t.indexOf(".");return r>-1?setAtKeyPath(e[unescapeKeyPathComponent(t.slice(0,r))],t.slice(r+1),a):(e[unescapeKeyPathComponent(t)]=a,e)}function getJSONType(e){return null===e?"null":Array.isArray(e)?"array":_typeof(e)}function _await(e,t,a){return e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e}var h=Object.keys,f=Object.hasOwn,g=Array.isArray,v=["type","replaced","iterateIn","iterateUnsetNumeric","addLength"];function _async(e){return function(){for(var t=[],a=0;a<arguments.length;a++)t[a]=arguments[a];try{return Promise.resolve(e.apply(this,t))}catch(e){return Promise.reject(e)}}}function nestedPathsFirst(e,t){var a,r;if(""===e.keypath)return-1;var n=null!==(a=e.keypath.match(/\./g))&&void 0!==a?a:0,i=null!==(r=t.keypath.match(/\./g))&&void 0!==r?r:0;return n&&(n=n.length),i&&(i=i.length),n>i?-1:n<i?1:e.keypath<t.keypath?-1:e.keypath>t.keypath?1:0}var b=function(){function Typeson(e){_classCallCheck(this,Typeson),this.options=e,this.plainObjectReplacers=[],this.nonplainObjectReplacers=[],this.revivers={},this.types={}}return _createClass(Typeson,[{key:"stringify",value:function stringify(e,t,a,r){r=_objectSpread2(_objectSpread2(_objectSpread2({},this.options),r),{},{stringification:!0});var n=this.encapsulate(e,null,r);return g(n)?JSON.stringify(n[0],t,a):n.then((function(e){return JSON.stringify(e,t,a)}))}},{key:"stringifySync",value:function stringifySync(e,t,a,r){return this.stringify(e,t,a,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},r),{},{sync:!0}))}},{key:"stringifyAsync",value:function stringifyAsync(e,t,a,r){return this.stringify(e,t,a,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},r),{},{sync:!1}))}},{key:"parse",value:function parse(e,t,a){return a=_objectSpread2(_objectSpread2(_objectSpread2({},this.options),a),{},{parse:!0}),this.revive(JSON.parse(e,t),a)}},{key:"parseSync",value:function parseSync(e,t,a){return this.parse(e,t,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},a),{},{sync:!0}))}},{key:"parseAsync",value:function parseAsync(e,t,a){return this.parse(e,t,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},a),{},{sync:!1}))}},{key:"specialTypeNames",value:function specialTypeNames(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return a.returnTypeNames=!0,this.encapsulate(e,t,a)}},{key:"rootTypeName",value:function rootTypeName(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return a.iterateNone=!0,this.encapsulate(e,t,a)}},{key:"encapsulate",value:function encapsulate(e,t,a){var r=this,n=_objectSpread2(_objectSpread2({sync:!0},this.options),a),i=n.sync,s={},o=[],c=[],l=[],u=!("cyclic"in n)||n.cyclic,d=n.encapsulateObserver,m=function finish(e){var t=Object.values(s);if(n.iterateNone)return t.length?t[0]:getJSONType(e);if(t.length){if(n.returnTypeNames)return function _toConsumableArray(e){return function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}(e)||function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||_unsupportedIterableToArray(e)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(new Set(t));e&&isPlainObject(e)&&!f(e,"$types")?e.$types=s:e={$:e,$types:{$:s}}}else isObject(e)&&f(e,"$types")&&(e={$:e,$types:!0});return!n.returnTypeNames&&e},y=_async((function(e,t){return _await(Promise.all(t.map((function(e){return e[1].p}))),(function(a){return _await(Promise.all(a.map(_async((function(a){var r=!1,n=[],i=_slicedToArray(t.splice(0,1),1),s=_slicedToArray(i[0],7),o=s[0],c=s[2],l=s[3],u=s[4],d=s[5],m=s[6],h=w(o,a,c,l,n,!0,m),f=hasConstructorOf(h,p);return function _invoke(e,t){var a=e();return a&&a.then?a.then(t):t(a)}((function(){if(o&&f)return _await(h.p,(function(t){u[d]=t;var a=y(e,n);return r=!0,a}))}),(function(t){return r?t:(o?u[d]=h:e=f?h.p:h,y(e,n))}))})))),(function(){return e}))}))})),b=function _adaptBuiltinStateObjectProperties(e,t,a){Object.assign(e,t);var r=v.map((function(t){var a=e[t];return delete e[t],a}));a(),v.forEach((function(t,a){e[t]=r[a]}))},w=function _encapsulate(e,t,a,i,l,u,m){var y,v={},w=_typeof(t),S=d?function(r){var n,s=null!==(n=null!=m?m:i.type)&&void 0!==n?n:getJSONType(t);d(Object.assign(null!=r?r:v,{keypath:e,value:t,cyclic:a,stateObj:i,promisesData:l,resolvingTypesonPromise:u,awaitingTypesonPromise:hasConstructorOf(t,p)},{type:s}))}:null;if(["string","boolean","number","undefined"].includes(w))return void 0===t||Number.isNaN(t)||t===Number.NEGATIVE_INFINITY||t===Number.POSITIVE_INFINITY||0===t?(y=i.replaced?t:x(e,t,i,l,!1,u,S))!==t&&(v={replaced:y}):y=t,S&&S(),y;if(null===t)return S&&S(),t;if(a&&!i.iterateIn&&!i.iterateUnsetNumeric&&t&&"object"===_typeof(t)){var I=o.indexOf(t);if(!(I<0))return s[e]="#",S&&S({cyclicKeypath:c[I]}),"#"+c[I];!0===a&&(o.push(t),c.push(e))}var T,E,N=isPlainObject(t),_=g(t),O=(N||_)&&(!r.plainObjectReplacers.length||i.replaced)||i.iterateIn?t:x(e,t,i,l,N||_,null,S);if(O!==t?(y=O,v={replaced:O}):""===e&&hasConstructorOf(t,p)?(l.push([e,t,a,i,void 0,void 0,i.type]),y=t):_&&"object"!==i.iterateIn||"array"===i.iterateIn?(T=new Array(t.length),v={clone:T}):(["function","symbol"].includes(_typeof(t))||"toJSON"in t||hasConstructorOf(t,p)||hasConstructorOf(t,Promise)||hasConstructorOf(t,ArrayBuffer))&&!N&&"object"!==i.iterateIn?y=t:(T={},i.addLength&&(T.length=t.length),v={clone:T}),S&&S(),n.iterateNone)return null!==(E=T)&&void 0!==E?E:y;if(!T)return y;if(i.iterateIn){var k=function _loop(r){var n={ownKeys:f(t,r)};b(i,n,(function(){var n=e+(e?".":"")+escapeKeyPathComponent(r),s=_encapsulate(n,t[r],Boolean(a),i,l,u);hasConstructorOf(s,p)?l.push([n,s,Boolean(a),i,T,r,i.type]):void 0!==s&&(T[r]=s)}))};for(var A in t)k(A);S&&S({endIterateIn:!0,end:!0})}else h(t).forEach((function(r){var n=e+(e?".":"")+escapeKeyPathComponent(r);b(i,{ownKeys:!0},(function(){var e=_encapsulate(n,t[r],Boolean(a),i,l,u);hasConstructorOf(e,p)?l.push([n,e,Boolean(a),i,T,r,i.type]):void 0!==e&&(T[r]=e)}))})),S&&S({endIterateOwn:!0,end:!0});if(i.iterateUnsetNumeric){for(var C=t.length,j=function _loop2(r){if(!(r in t)){var n="".concat(e).concat(e?".":"").concat(r);b(i,{ownKeys:!1},(function(){var e=_encapsulate(n,void 0,Boolean(a),i,l,u);hasConstructorOf(e,p)?l.push([n,e,Boolean(a),i,T,r,i.type]):void 0!==e&&(T[r]=e)}))}},Z=0;Z<C;Z++)j(Z);S&&S({endIterateUnsetNumeric:!0,end:!0})}return T},x=function replace(e,t,a,n,o,c,l){for(var d=o?r.plainObjectReplacers:r.nonplainObjectReplacers,p=d.length;p--;){var m=d[p];if(m.test(t,a)){var y=m.type;if(r.revivers[y]){var h=s[e];s[e]=h?[y].concat(h):y}if(Object.assign(a,{type:y,replaced:!0}),(i||!m.replaceAsync)&&!m.replace)return l&&l({typeDetected:!0}),w(e,t,u&&"readonly",a,n,c,y);l&&l({replacing:!0});var f=void 0;if(i||!m.replaceAsync){if(void 0===m.replace)throw new TypeError("Missing replacer");f=m.replace(t,a)}else f=m.replaceAsync(t,a);return w(e,f,u&&"readonly",a,n,c,y)}}return t},S=w("",e,u,null!=t?t:{},l);if(l.length)return i&&n.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():Promise.resolve(y(S,l)).then(m);if(!i&&n.throwOnBadSyncType)throw new TypeError("Async method requested but sync result obtained");return n.stringification&&i?[m(S)]:i?m(S):Promise.resolve(m(S))}},{key:"encapsulateSync",value:function encapsulateSync(e,t,a){return this.encapsulate(e,t,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},a),{},{sync:!0}))}},{key:"encapsulateAsync",value:function encapsulateAsync(e,t,a){return this.encapsulate(e,t,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},a),{},{sync:!1}))}},{key:"revive",value:function revive(e,t){var a=this,r=_objectSpread2(_objectSpread2({sync:!0},this.options),t),n=r.sync;function finishRevival(e){if(n)return e;if(r.throwOnBadSyncType)throw new TypeError("Async method requested but sync result obtained");return Promise.resolve(e)}if(!e||"object"!==_typeof(e)||Array.isArray(e))return finishRevival(e);var i=e.$types;if(!0===i)return finishRevival(e.$);if(!i||"object"!==_typeof(i)||Array.isArray(i))return finishRevival(e);var s=[],o={},c=!0;i.$&&isPlainObject(i.$)&&(e=e.$,i=i.$,c=!1);var l=function executeReviver(e,t){var r,i=_slicedToArray(null!==(r=a.revivers[e])&&void 0!==r?r:[],1)[0];if(!i)throw new Error("Unregistered type: "+e);if(n&&!("revive"in i))return t;if(!n&&i.reviveAsync)return i.reviveAsync(t,o);if(i.revive)return i.revive(t,o);throw new Error("Missing reviver")},u=[];function checkUndefined(e){return hasConstructorOf(e,w)?void 0:e}var d,m=function revivePlainObjects(){var t=[];if(!i)throw new Error("Found bad `types`");if(Object.entries(i).forEach((function(e){var r=_slicedToArray(e,2),n=r[0],s=r[1];"#"!==s&&[].concat(s).forEach((function(e){var r;_slicedToArray(null!==(r=a.revivers[e])&&void 0!==r?r:[null,{}],2)[1].plain&&(t.push({keypath:n,type:e}),delete i[n])}))})),t.length)return t.sort(nestedPathsFirst).reduce((function reducer(t,a){var r=a.keypath,n=a.type;if(isThenable(t))return t.then((function(e){return reducer(e,{keypath:r,type:n})}));var i=getByKeyPath(e,r);if(hasConstructorOf(i=l(n,i),p))return i.then((function(t){var a=setAtKeyPath(e,r,t);a===t&&(e=a)}));var s=setAtKeyPath(e,r,i);s===i&&(e=s)}),void 0)}();return hasConstructorOf(m,p)?d=m.then((function(){return e})):(d=function _revive(e,t,a,r,n){if(!c||"$types"!==e){var o=i[e],d=g(t);if(d||isPlainObject(t)){var m=d?new Array(t.length):{};for(h(t).forEach((function(r){var n=_revive(e+(e?".":"")+escapeKeyPathComponent(r),t[r],null!=a?a:m,m,r),i=function set(e){return hasConstructorOf(e,w)?m[r]=void 0:void 0!==e&&(m[r]=e),e};hasConstructorOf(n,p)?u.push(n.then((function(e){return i(e)}))):i(n)})),t=m;s.length;){var y=_slicedToArray(s[0],4),f=y[0],v=y[1],b=y[2],x=y[3],S=getByKeyPath(f,v);if(void 0===S)break;b[x]=S,s.splice(0,1)}}if(!o)return t;if("#"===o){var I=getByKeyPath(a,t.slice(1));return void 0===I&&s.push([a,t.slice(1),r,n]),I}return[].concat(o).reduce((function reducer(e,t){if(hasConstructorOf(e,p))return e.then((function(e){return reducer(e,t)}));if("string"!=typeof t)throw new TypeError("Bad type JSON");return l(t,e)}),t)}}("",e,null),u.length&&(d=p.resolve(d).then((function(e){return p.all([e].concat(u))})).then((function(e){return _slicedToArray(e,1)[0]})))),isThenable(d)?n&&r.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():hasConstructorOf(d,p)?d.p.then(checkUndefined):d:!n&&r.throwOnBadSyncType?function(){throw new TypeError("Async method requested but sync result obtained")}():n?checkUndefined(d):Promise.resolve(checkUndefined(d))}},{key:"reviveSync",value:function reviveSync(e,t){return this.revive(e,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},t),{},{sync:!0}))}},{key:"reviveAsync",value:function reviveAsync(e,t){return this.revive(e,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},t),{},{sync:!1}))}},{key:"register",value:function register(e,t){var a=this,r=null!=t?t:{},n=function R(e){g(e)?e.forEach((function(e){return R(e)})):h(e).forEach((function(t){var n;if("#"===t)throw new TypeError("# cannot be used as a type name as it is reserved for cyclic objects");if(x.includes(t))throw new TypeError("Plain JSON object types are reserved as type names");var i=e[t],s=i&&"function"!=typeof i&&!Array.isArray(i)&&i.testPlainObjects?a.plainObjectReplacers:a.nonplainObjectReplacers,o=s.filter((function(e){return e.type===t}));if(o.length&&(s.splice(s.indexOf(o[0]),1),delete a.revivers[t],delete a.types[t]),"function"==typeof i){var c=i;i={test:function test(e){return e&&e.constructor===c},replace:function replace(e){return _objectSpread2({},e)},revive:function revive(e){return Object.assign(Object.create(c.prototype),e)}}}else if(g(i)){var l=_slicedToArray(i,3);i={test:l[0],replace:l[1],revive:l[2]}}if(null!==(n=i)&&void 0!==n&&n.test){var u={type:t,test:i.test.bind(i)};i.replace&&(u.replace=i.replace.bind(i)),i.replaceAsync&&(u.replaceAsync=i.replaceAsync.bind(i));var d="number"==typeof r.fallback?r.fallback:r.fallback?0:Number.POSITIVE_INFINITY;if(i.testPlainObjects?a.plainObjectReplacers.splice(d,0,u):a.nonplainObjectReplacers.splice(d,0,u),i.revive||i.reviveAsync){var p={};i.revive&&(p.revive=i.revive.bind(i)),i.reviveAsync&&(p.reviveAsync=i.reviveAsync.bind(i)),a.revivers[t]=[p,{plain:i.testPlainObjects}]}a.types[t]=i}}))};return[].concat(e).forEach((function(e){return n(e)})),this}}]),Typeson}(),w=_createClass((function Undefined(){_classCallCheck(this,Undefined)}));w.__typeson__type__="TypesonUndefined";for(var x=["null","boolean","number","string","array","object"],S="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",I=new Uint8Array(256),T=0;T<64;T++)I[S.codePointAt(T)]=T;var E=function encode(e,t,a){null==a&&(a=e.byteLength);for(var r=new Uint8Array(e,0,a),n=r.length,i="",s=0;s<n;s+=3)i+=S[r[s]>>2],i+=S[(3&r[s])<<4|r[s+1]>>4],i+=S[(15&r[s+1])<<2|r[s+2]>>6],i+=S[63&r[s+2]];return n%3==2?i=i.slice(0,-1)+"=":n%3==1&&(i=i.slice(0,-2)+"=="),i},N=function decode(e,t){var a=e.length;if(a%4)throw new Error("Bad base64 length: not divisible by four");var r,n,i,s,o=.75*e.length,c=0;"="===e[e.length-1]&&(o--,"="===e[e.length-2]&&o--);for(var l=new ArrayBuffer(o,t),u=new Uint8Array(l),d=0;d<a;d+=4)r=I[e.codePointAt(d)],n=I[e.codePointAt(d+1)],i=I[e.codePointAt(d+2)],s=I[e.codePointAt(d+3)],u[c++]=r<<2|n>>4,u[c++]=(15&n)<<4|i>>2,u[c++]=(3&i)<<6|63&s;return l};const _={arraybuffer:{test:e=>"ArrayBuffer"===toStringTag(e),replace(e,t){t.buffers||(t.buffers=[]);const a=t.buffers.indexOf(e);return a>-1?{index:a}:(t.buffers.push(e),{s:E(e),maxByteLength:e.maxByteLength})},revive(e,t){if(t.buffers||(t.buffers=[]),Object.hasOwn(e,"index"))return t.buffers[e.index];const a=N(e.s,{maxByteLength:e.maxByteLength});return t.buffers.push(a),a}}},O={bigintObject:{test:e=>"object"==typeof e&&hasConstructorOf(e,BigInt),replace:String,revive:e=>new Object(BigInt(e))}},k={bigint:{test:e=>"bigint"==typeof e,replace:String,revive:e=>BigInt(e)}};function arraybuffer2string(e){return new Uint8Array(e).reduce(((e,t)=>e+String.fromCodePoint(t)),"")}function string2arraybuffer(e){const t=new Uint8Array(e.length);for(let a=0;a<e.length;a++)t[a]=e.charCodeAt(a);return t.buffer}const A={blob:{test:e=>"Blob"===toStringTag(e),replace(e){const t=new XMLHttpRequest;if(t.overrideMimeType("text/plain; charset=x-user-defined"),t.open("GET",URL.createObjectURL(e),!1),t.send(),200!==t.status&&0!==t.status)throw new Error("Bad Blob access: "+t.status);return{type:e.type,stringContents:t.responseText}},revive(e){const{type:t,stringContents:a}=e;return new Blob([string2arraybuffer(a)],{type:t})},replaceAsync:e=>new p(((t,a)=>{const r=new FileReader;r.addEventListener("load",(()=>{t({type:e.type,stringContents:arraybuffer2string(r.result)})})),r.addEventListener("error",(()=>{a(r.error)})),r.readAsArrayBuffer(e)}))}};const C={cryptokey:{test:e=>"CryptoKey"===toStringTag(e)&&e.extractable,replaceAsync:e=>new p((async(t,a)=>{let r;try{r=await crypto.subtle.exportKey("jwk",e)}catch(t){return void a(t)}t({jwk:r,algorithm:e.algorithm,usages:e.usages})})),revive(e){const{jwk:t,algorithm:a,usages:r}=e;return crypto.subtle.importKey("jwk",t,a,!0,r)}}},j={dataview:{test:e=>"DataView"===toStringTag(e),replace({buffer:e,byteOffset:t,byteLength:a},r){r.buffers||(r.buffers=[]);const n=r.buffers.indexOf(e);return n>-1?{index:n,byteOffset:t,byteLength:a}:(r.buffers.push(e),{encoded:E(e),maxByteLength:e.maxByteLength,byteOffset:t,byteLength:a})},revive(e,t){t.buffers||(t.buffers=[]);const{byteOffset:a,byteLength:r,encoded:n,index:i,maxByteLength:s}=e;let o;return"index"in e?o=t.buffers[i]:(o=N(n,void 0===s?s:{maxByteLength:s}),t.buffers.push(o)),new DataView(o,a,r)}}},Z={date:{test:e=>"Date"===toStringTag(e),replace(e){const t=e.getTime();return Number.isNaN(t)?"NaN":t},revive:e=>"NaN"===e?new Date(Number.NaN):new Date(e)}},V={domexception:{test:e=>"DOMException"===toStringTag(e),replace:e=>({name:e.name,message:e.message}),revive:({message:e,name:t})=>new DOMException(e,t)}},M={};function create$5(e){M[e.name.toLowerCase()]={test:t=>toStringTag(t)===e.name,replace:e=>e.is2D?{a:e.a,b:e.b,c:e.c,d:e.d,e:e.e,f:e.f}:{m11:e.m11,m12:e.m12,m13:e.m13,m14:e.m14,m21:e.m21,m22:e.m22,m23:e.m23,m24:e.m24,m31:e.m31,m32:e.m32,m33:e.m33,m34:e.m34,m41:e.m41,m42:e.m42,m43:e.m43,m44:e.m44},revive:t=>Object.hasOwn(t,"a")?new e([t.a,t.b,t.c,t.d,t.e,t.f]):new e([t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44])}}"undefined"!=typeof DOMMatrix&&create$5(DOMMatrix),"undefined"!=typeof DOMMatrixReadOnly&&create$5(DOMMatrixReadOnly);const P={};function create$4(e){P[e.name.toLowerCase()]={test:t=>toStringTag(t)===e.name,replace:e=>({x:e.x,y:e.y,z:e.z,w:e.w}),revive:({x:t,y:a,z:r,w:n})=>new e(t,a,r,n)}}"undefined"!=typeof DOMPoint&&create$4(DOMPoint),"undefined"!=typeof DOMPointReadOnly&&create$4(DOMPointReadOnly);const U={domquad:{test:e=>"DOMQuad"===toStringTag(e),replace:e=>({p1:e.p1,p2:e.p2,p3:e.p3,p4:e.p4}),revive:({p1:e,p2:t,p3:a,p4:r})=>new DOMQuad(e,t,a,r)}},B={};function create$3(e){B[e.name.toLowerCase()]={test:t=>toStringTag(t)===e.name,replace:e=>({x:e.x,y:e.y,width:e.width,height:e.height}),revive:({x:t,y:a,width:r,height:n})=>new e(t,a,r,n)}}"undefined"!=typeof DOMRect&&create$3(DOMRect),"undefined"!=typeof DOMRectReadOnly&&create$3(DOMRectReadOnly);const D={error:{test:e=>"Error"===toStringTag(e),replace:({name:e,message:t,cause:a,stack:r,fileName:n,lineNumber:i,columnNumber:s})=>({name:e,message:t,cause:a,stack:r,fileName:n,lineNumber:i,columnNumber:s}),revive(e){const t=new Error(e.message);return t.name=e.name,t.cause=e.cause,t.stack=e.stack,t.fileName=e.fileName,t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}}},L={};function create$2(e){L[e.name.toLowerCase()]={test:t=>hasConstructorOf(t,e),replace:({name:e,message:t,cause:a,stack:r,fileName:n,lineNumber:i,columnNumber:s,errors:o})=>({name:e,message:t,cause:a,stack:r,fileName:n,lineNumber:i,columnNumber:s,errors:o}),revive(t){const a="undefined"!=typeof AggregateError&&e===AggregateError?new e(t.errors,t.message):new e(t.message);return a.name=t.name,a.cause=t.cause,a.stack=t.stack,a.fileName=t.fileName,a.lineNumber=t.lineNumber,a.columnNumber=t.columnNumber,a}}}[TypeError,RangeError,SyntaxError,ReferenceError,EvalError,URIError].forEach((e=>create$2(e))),"undefined"!=typeof AggregateError&&create$2(AggregateError),"function"==typeof InternalError&&create$2(InternalError);const F={file:{test:e=>"File"===toStringTag(e),replace(e){const t=new XMLHttpRequest;if(t.overrideMimeType("text/plain; charset=x-user-defined"),t.open("GET",URL.createObjectURL(e),!1),t.send(),200!==t.status&&0!==t.status)throw new Error("Bad File access: "+t.status);return{type:e.type,stringContents:t.responseText,name:e.name,lastModified:e.lastModified}},revive:({name:e,type:t,stringContents:a,lastModified:r})=>new File([string2arraybuffer(a)],e,{type:t,lastModified:r}),replaceAsync:e=>new p((function(t,a){const r=new FileReader;r.addEventListener("load",(function(){t({type:e.type,stringContents:arraybuffer2string(r.result),name:e.name,lastModified:e.lastModified})})),r.addEventListener("error",(function(){a(r.error)})),r.readAsArrayBuffer(e)}))}},z={file:F.file,filelist:{test:e=>"FileList"===toStringTag(e),replace(e){const t=[];for(let a=0;a<e.length;a++)t[a]=e.item(a);return t},revive(e){class FileList{constructor(){this._files=arguments[0],this.length=this._files.length}item(e){return this._files[e]}get[Symbol.toStringTag](){return"FileList"}}return new FileList(e)}}},K={imagebitmap:{test:e=>"ImageBitmap"===toStringTag(e)||e&&e.dataset&&"ImageBitmap"===e.dataset.toStringTag,replace(e){const t=document.createElement("canvas");return t.getContext("2d").drawImage(e,0,0),{width:e.width,height:e.height,dataURL:t.toDataURL()}},revive(e){const t="undefined"==typeof OffscreenCanvas?document.createElement("canvas"):new OffscreenCanvas(e.width,e.height),a=t.getContext("2d"),r=document.createElement("img");return r.addEventListener("load",(function(){a.drawImage(r,0,0)})),r.src=e.dataURL,"undefined"==typeof OffscreenCanvas?t:t.transferToImageBitmap()},reviveAsync(e){const t=document.createElement("canvas"),a=t.getContext("2d"),r=document.createElement("img");return r.addEventListener("load",(function(){a.drawImage(r,0,0)})),r.src=e.dataURL,new p((async(e,a)=>{try{e(await createImageBitmap(t))}catch(e){a(e)}}))}}},W={imagedata:{test:e=>"ImageData"===toStringTag(e),replace:e=>({array:[...e.data],width:e.width,height:e.height}),revive:e=>new ImageData(new Uint8ClampedArray(e.array),e.width,e.height)}},J={infinity:{test:e=>e===Number.POSITIVE_INFINITY,replace:()=>"Infinity",revive:()=>Number.POSITIVE_INFINITY}},H={map:{test:e=>"Map"===toStringTag(e),replace:e=>[...e.entries()],revive:e=>new Map(e)}},q={nan:{test:e=>Number.isNaN(e),replace:()=>"NaN",revive:()=>Number.NaN}},Y={negativeInfinity:{test:e=>e===Number.NEGATIVE_INFINITY,replace:()=>"-Infinity",revive:()=>Number.NEGATIVE_INFINITY}},G={negativeZero:{test:e=>Object.is(e,-0),replace:()=>0,revive:()=>-0}},X={StringObject:{test:e=>"String"===toStringTag(e)&&"object"==typeof e,replace:String,revive:e=>new String(e)},BooleanObject:{test:e=>"Boolean"===toStringTag(e)&&"object"==typeof e,replace:Boolean,revive:e=>new Boolean(e)},NumberObject:{test:e=>"Number"===toStringTag(e)&&"object"==typeof e,replace:Number,revive:e=>new Number(e)}},Q={regexp:{test:e=>"RegExp"===toStringTag(e),replace:e=>({source:e.source,flags:(e.global?"g":"")+(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.sticky?"y":"")+(e.unicode?"u":"")}),revive:({source:e,flags:t})=>new RegExp(e,t)}},ee={},te={resurrectable:{test:e=>e&&!Array.isArray(e)&&["object","function","symbol"].includes(typeof e),replace(e){const t=function generateUUID(){let e=Date.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replaceAll(/[xy]/gu,(function(t){const a=Math.trunc((e+16*Math.random())%16);return e=Math.floor(e/16),("x"===t?a:3&a|8).toString(16)}))}();return ee[t]=e,t},revive:e=>ee[e]}},ae={set:{test:e=>"Set"===toStringTag(e),replace:e=>[...e.values()],revive:e=>new Set(e)}},re={};"function"==typeof Int8Array&&[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,..."function"==typeof BigInt64Array?[BigInt64Array,BigUint64Array]:[]].forEach((e=>function create$1(e){const t=e.name;re[t.toLowerCase()]={test:e=>toStringTag(e)===t,replace:e=>(0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e:e.slice(0)).buffer,revive:t=>"ArrayBuffer"===toStringTag(t)?new e(t):t}}(e)));const ne={};"function"==typeof Int8Array&&[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,..."function"==typeof BigInt64Array?[BigInt64Array,BigUint64Array]:[]].forEach((e=>function create(e){const t=e.name;ne[t.toLowerCase()]={test:e=>toStringTag(e)===t,replace({buffer:e,byteOffset:t,length:a},r){r.buffers||(r.buffers=[]);const n=r.buffers.indexOf(e);return n>-1?{index:n,byteOffset:t,length:a}:(r.buffers.push(e),{maxByteLength:e.maxByteLength,encoded:E(e),byteOffset:t,length:a})},revive(t,a){a.buffers||(a.buffers=[]);const{byteOffset:r,length:n,encoded:i,index:s,maxByteLength:o}=t;let c;return"index"in t?c=a.buffers[s]:(c=N(i,void 0===o?void 0:{maxByteLength:o}),a.buffers.push(c)),new e(c,r,n)}}}(e)));const ie={undef:{test:(e,t)=>void 0===e&&(t.ownKeys||!("ownKeys"in t)),replace:()=>0,revive:()=>new w}},se={userObject:{test:e=>isUserObject(e),replace:e=>({...e}),revive:e=>e}},oe=[{arrayNonindexKeys:{testPlainObjects:!0,test:(e,t)=>!!Array.isArray(e)&&(Object.keys(e).some((e=>String(Number.parseInt(e))!==e))&&(t.iterateIn="object",t.addLength=!0),!0),replace:(e,t)=>(t.iterateUnsetNumeric=!0,e),revive(e){if(Array.isArray(e))return e;const t=[];return Object.entries(e).forEach((([e,a])=>{t[e]=a})),t}}},{sparseUndefined:{test:(e,t)=>void 0===e&&!1===t.ownKeys,replace:()=>0,revive(){}}}],ce=[se,ie,oe,X,[q,J,Y,G],Z,Q,W,K,F,z,A,D,L].concat("function"==typeof Map?H:[],"function"==typeof Set?ae:[],"function"==typeof ArrayBuffer?_:[],"function"==typeof Uint8Array?ne:[],"function"==typeof DataView?j:[],"undefined"!=typeof crypto?C:[],"undefined"!=typeof BigInt?[k,O]:[],"undefined"!=typeof DOMException?V:[],"undefined"!=typeof DOMRect?B:[],"undefined"!=typeof DOMPoint?P:[],"undefined"!=typeof DOMQuad?U:[],"undefined"!=typeof DOMMatrix?M:[]).concat({checkDataCloneException:{test(e){const t={}.toString.call(e).slice(8,-1);if(["symbol","function"].includes(typeof e)||["Arguments","Module","Promise","WeakMap","WeakSet","Event","MessageChannel"].includes(t)||e&&"object"==typeof e&&"number"==typeof e.nodeType&&"function"==typeof e.insertBefore)throw new DOMException("The object cannot be cloned.","DataCloneError");return!1}}}),le="↑",ue="↓",$=e=>document.querySelector(e),$e=(e,t)=>{const a="string"==typeof e?$(e):e;return a?a.querySelector(t):null},$$e=(e,t)=>{const a="string"==typeof e?$(e):e;return a?[...a.querySelectorAll(t)]:[]},DOM_removeChildren=e=>{const t="string"==typeof e?$(e):e;if(!t)throw new Error("Node not found!");for(;t.hasChildNodes();)t.lastChild?.remove()},DOM_filterChildElements=(e,t)=>{const a="string"==typeof e?$(e):e;if(!a)throw new Error("Element not found!");let r=[a];return(t=Array.isArray(t)?t:[t]).forEach((e=>{r=r.reduce(((t,a)=>a?(t.push(...((e,t)=>{const a=[...e.children].filter((e=>e.matches(t)));return a})(a,e)),t):t),[])})),r},DOM_initialCaps=e=>e.charAt(0).toUpperCase()+e.slice(1),de={submit:"Submit",cancel:"Cancel",ok:"Ok"},pe={localeStrings:{},setLocale(e={}){this.localeStrings={...de,...e}},makeDialog({atts:e={},children:t=[],close:a,remove:r=!0}={}){a&&(e.$on||(e.$on={}),"close"in e.$on||(e.$on.close=a));const n=c("dialog",e,t,l);return n.showModal(),r&&n.addEventListener("close",(()=>{n.remove()})),n},makeCancelDialog({cancel:e,cancelClass:t="cancel",submitClass:a="submit",...r}){const n=this.makeDialog(r);return c("div",{class:a},[["br"],["br"],["button",{class:t,$on:{click(t){t.preventDefault(),e&&!1===e.call(this,{e:t,dialog:n})||n.close()}}},[this.localeStrings.cancel]]],n),n},makeSubmitDialog({submit:e,submitText:t,submitClass:a="submit",...r}){const n=this.makeCancelDialog(r);return $e(n,`button.${r.cancelClass||"cancel"}`)?.before(c("button",{class:a,$on:{click(t){e.call(this,{e:t,dialog:n})}}},[t??this.localeStrings.submit]),d.repeat(2)),n},alert(e){e="string"==typeof e?{message:e}:e;const{submitClass:t="submit"}=e,{message:a}=e;return new Promise((e=>{const r=c("dialog",[a,["br"],["br"],["div",{class:t},[["button",{$on:{click(){r.close(),e()}}},[this.localeStrings.ok]]]]],l);r.showModal()}))},confirm({atts:e={},message:t,submitClass:a="submit"}){return({message:t}="string"==typeof t?{message:t}:t),new Promise(((r,n)=>{const i=c("dialog",e,[t,["br"],["br"],["div",{class:a},[["button",{$on:{click(){i.close(),r()}}},[this.localeStrings.ok]],d.repeat(2),["button",{$on:{click(){i.close(),n(new Error("cancelled"))}}},[this.localeStrings.cancel]]]]],l);i.showModal()}))}};pe.setLocale();const buildTypeChoices=({autoTrigger:e=!0,format:t,typeNamespace:a,value:r,setValue:n=!1,state:i,keySelectClass:s,requireObject:o,objectHasValue:l,topRoot:u,formats:d=new Formats,types:p=new Types,schema:m,schemaIdx:y,schemaOriginal:h,schemaContent:f})=>{const g=o&&!f?{typeOptions:[p.getOptionForType("object")],schemaObjects:void 0}:p.getTypeOptionsForFormatAndState(t,i,f,h),{typeOptions:v}=g,b=g.schemaObjects;let w;const $getValue=(e,r)=>{const n=$e(S,"div[data-type]");return p.getValueForRoot(n,{typeNamespace:a,formats:d,format:t,types:p,...e},r)},x=c("select",{hidden:o||1===v.length,class:`typeChoices-${a}${s?" "+s:""}`,$custom:{$getValue:$getValue,$setType({type:e,baseValue:t,bringIntoFocus:a,avoidReport:r,specificSchema:n}){if(b&&n){const t=b.map((e=>JSON.stringify(e))).indexOf(JSON.stringify(n));-1===t?this.value=e:this.selectedIndex=t+1}else this.value=e;this.$setStyles(),this.$addAndValidateEditUI({baseValue:t,bringIntoFocus:a,avoidReport:r})},$setTypeNoEditUI({type:e,specificSchema:t}){if(b&&t){const e=b.map((e=>JSON.stringify(e))).indexOf(JSON.stringify(t));this.selectedIndex=e+1}else this.value=e;this.$setStyles()},$setStyles(){const{value:e}=this;this.dataset.type=e;let t=this.parentElement;"fieldset"!==t.nodeName.toLowerCase()&&(t=this.parentElement.parentElement),"fieldset"===t.nodeName.toLowerCase()&&(t.dataset.type=e,DOM_filterChildElements(t,"legend").forEach((t=>{t.dataset.type=e})))},$getTypeRoot(){const e=this.$getContainer();return!!e&&$e(e,"div[data-type]")},$addAndValidateEditUI({baseValue:e,bringIntoFocus:r,schemaObject:n,avoidReport:i}={}){const{value:s}=this;if(!s)return;let o=this.$getTopRoot();w=p.getUIForModeAndType({readonly:!1,typeNamespace:a,type:s,bringIntoFocus:r,hasValue:"arrayNonindexKeys"===s&&e,value:e,buildTypeChoices:buildTypeChoices,format:t,topRoot:o,schemaContent:h??("union"===f?.type&&void 0!==y?f.options[y]:f),specificSchemaObject:n??b?.[x.selectedIndex-1]??("union"===f?.type&&void 0!==y?f.options[y]:f),schemaFallingBack:Boolean(!n&&f)}),this.$addEditUI({editUI:w}),this.$validate({avoidReport:i}),o=this.$getTopRoot(),p.validateAllReferences({topRoot:o})},$addTypeAndEditUI({type:e,editUI:t,specificSchema:a}){this.$setTypeNoEditUI({type:e,specificSchema:a}),this.$addEditUI({editUI:t})},$addEditUI({editUI:e}){const t=this.$getContainer();DOM_removeChildren(t),c(e,t)},$getContainer(){return this.nextElementSibling},$getTopRoot(){return u||this.$getTypeRoot()},$validate({avoidReport:e}={}){const{value:t}=this,a=this.$getContainer();if(!a.firstElementChild)return!1;const r=a.firstElementChild;return p.validate({type:t,root:r,topRoot:this.$getTopRoot(),avoidReport:e})}},$on:{change(e){e?.stopPropagation(),this.$addAndValidateEditUI({schemaObject:b?b[Number(e.target.selectedOptions[0].dataset.idx)]:void 0}),this.$setStyles()}}},[["option",{value:""},["(Choose a type)"]],...v.map((([e,t],a)=>["option",{...t,dataset:b?{idx:a}:{}},[e]]))]);e&&1===v.length&&!n?setTimeout((()=>{x.selectedIndex=1,x.dispatchEvent(new Event("change"))})):(n||o&&!l)&&setTimeout((async()=>{n||(r={});try{const{rootUI:e,specificSchemas:n}=await d.getControlsForFormatAndValue(p,t,r,{readonly:!1,typeNamespace:a,schema:m,schemaContent:f,formats:d,types:p}),i=Types.getTypeForRoot(e);x.$addTypeAndEditUI({type:i,editUI:e,specificSchema:n?.[0]})}catch(e){pe.alert({message:"The object to be added had types not supported by the current format."}),console.log("err",e)}}));const S=c("div",{class:"typeContainer"});return{domArray:[x,S],getValue:$getValue,getType(){const e=$e(S,"div[data-type]");return Types.getTypeForRoot(e)},validValuesSet(){const e=$e(S,"div[data-type]").closest("form");return Types.validValuesSet({form:e,typeNamespace:a})},async setValue(e,a){const r=(await d.getControlsForFormatAndValue(p,t,e,a)).rootUI,n=Types.getTypeForRoot(r);x.$addTypeAndEditUI({type:n,editUI:r})}}},getJSONPointerParts=e=>e.split("/").slice(1).map((e=>(e=>e.replaceAll(/~([01])/gu,((e,t)=>"0"===t?"~":"/")))(e))),reduceJSONPointerParts=(e,t)=>{if(!(t in e))throw new TypeError("Path part not found in object");return e=e[t]},resolveJSONPointer=({path:e,obj:t})=>getJSONPointerParts(e).reduce(((e,t)=>reduceJSONPointerParts(e,t)),t),me=new Map([["arrayNonindexKeys","array"]]),ye={types:()=>["null","true","false","number","string","array","object"],iterate(e,t){const a=e;return t.format="json",he.iterate(a,t)},convertFromTypeson:e=>({type:me.get(e)}),testInvalid(e,t){if("array"===e)return Object.keys(t).length!==t.length},getTypesAndSchemasForState(e,t){if(!t||["array","object"].includes(t))return{types:this.types(),schemaObjects:[]}}};te.resurrectable.test=e=>e&&"object"==typeof e&&!Array.isArray(e)&&"Object"!==toStringTag(e);const encapsulateObserver=e=>{const{typeNamespace:t,readonly:a,format:r,schemaContent:n,formats:i,types:s}=e,o=r,c={},l={},u=[];return r=>{const{type:d,cyclic:p,keypath:m,value:y,replaced:h,cyclicKeypath:f,endIterateIn:g,endIterateOwn:v,endIterateUnsetNumeric:b,clone:w}=r;if("replaced"in r)return;if("readonly"===p&&!Array.isArray(r.value))return;if("readonly"===p&&("set"===d||"filelist"===d))return;if(g||v)return;if(b||void 0===w&&void 0===f&&Array.isArray(y))return;if(r.replacing&&"negativeZero"===d)return;if("sparseUndefined"===d)return;let x,S=y;const I="structuredCloning"===o?"arrayNonindexKeys":"array",T=m.lastIndexOf("."),E=unescapeKeyPathComponent(m.slice(T+1)),N=-1===T?"":m.slice(0,T);let _,O,k;if("string"==typeof f)S=(A=f)?"/"+A.split(".").map((e=>e.replaceAll("~1",".").replaceAll("/","~1"))).join("/"):A,x="array"===d?"arrayReference":"objectReference",({newType:x,schema:_,schemaIdx:O,mustBeOptional:k}=canonicalTypeToAvailableTypeAndSchema(s,i,o,I,x,y,E,l[N],e));else try{({newType:x,schema:_,schemaIdx:O,mustBeOptional:k}=canonicalTypeToAvailableTypeAndSchema(s,i,o,I,d,y,E,l[N],e))}catch(t){return console.log("err",d,t),void(e.error=t)}var A;const C=["array","object","set","map","tuple","record","filelist","arrayNonindexKeys"].includes(x),j="map"===d&&"[object Map]"===Object.prototype.toString.call(y);if(j&&u.push(m),_&&(e.specificSchema=_,e.specificSchemas||(e.specificSchemas=[]),e.specificSchemas.push(_)),!e.rootUI)return e.rootUI=s?.getUIForModeAndType({readonly:a,typeNamespace:t,type:x,bringIntoFocus:!1,buildTypeChoices:buildTypeChoices,format:o,specificSchemaObject:_,schemaContent:n,value:S,hasValue:!0,replaced:h}),c[""]=e.rootUI,_&&(l[""]=[_,O]),void(j&&[...y].forEach(((t,a)=>{c[a]=e.rootUI})));_&&(l[m]=[_,O]),setTimeout((()=>{const t=c[N];if(!t||!("$addAndSetArrayElement"in t))return;if(!j&&u.some((e=>{if(e===m||""===e&&/^\d+$/u.test(m))return!0;const t=m.match(/\.\d+$/u);return t&&""!==e&&m.slice(0,-t[0].length)===e})))return;const r=t.$addAndSetArrayElement({mustBeOptional:k,propName:E,type:x,value:S,bringIntoFocus:!1,schemaIdx:O,schemaContent:_??n});r&&(a||(s?.setValue({type:x,root:r,value:S}),s?.validate({type:x,root:r,topRoot:e.rootUI,avoidReport:!0})),C&&(c[m]=r,j&&[...y].forEach(((e,t)=>{c[`${m}.${t}`]=r}))))}))}},canonicalTypeToAvailableTypeAndSchema=(e,t,a,r,n,i,s,o,c)=>{const l=t.getAvailableFormat(a),{getTypesAndSchemasForState:u,convertFromTypeson:d,testInvalid:p}=l,m=u.call(l,e,r,c.schemaContent)?.types;if(!m)throw new Error("Unexpected undefined type for state");let y;const isInvalid=e=>{const t=new Error("Invalid");throw t.newValType=e,t};let h;if(d){let t,a,r;if(({type:t,schema:h,schemaIdx:r,mustBeOptional:a}=d(n,e,i,s,o,c)),"string"==typeof t){if(p&&p(t,i))return isInvalid(t);if(n=t,h)return{newType:n,schema:h,schemaIdx:r,mustBeOptional:a}}}return m.some((t=>{const a=e.getTypeObject(t),{valueMatch:r,superType:s,childTypes:o}=a;return!!(s&&r&&s===n&&r(i)||o&&o.includes(n))&&(y=t,!0)})),void 0===y&&(m.some((e=>e===n&&(y=e,!0))),void 0===y)?(console.log("AALLLowableTypes",r,m,"::",n),isInvalid(n)):{newType:y,schema:h}},he={async iterate(e,t){t.format||(t.format="structuredCloning");const a=ce.filter((e=>!["imagedata","imagebitmap","cryptokey","domquad"].some((t=>Object.hasOwn(e,t)))));a.splice(1,0,te);const r=new b({encapsulateObserver:encapsulateObserver(t)}).register(a);if(await r.encapsulateAsync(e,null,{throwOnBadSyncType:!1}),t.error)throw t.error;return t},getTypesAndSchemasForState(e,t){if(t&&e.getContextInfo("structuredCloning",t)){const a=this.getTypesAndSchemasForState(e)?.types||[];return e.getContextInfo("structuredCloning",t).forEach((({type:e,after:t})=>{const r=a.indexOf(t);a.splice(r+1,0,e)})),{types:a,schemaObjects:[]}}return"errorsArray"===t?{types:["error","errors"],schemaObjects:[]}:"filelistArray"===t?{types:["file"],schemaObjects:[]}:{types:this.types(),schemaObjects:[]}},types(){const e=ye.types();var t;return t=e,[["array","arrayNonindexKeys"]].forEach((([e,a])=>{t.splice(t.indexOf(e),1,a)})),[...e,"undef","bigint","bigintObject","SpecialNumber","date","regexp","BooleanObject","NumberObject","StringObject","error","errors","blob","blobHTML","file","set","map","filelist","domexception","domrect","dompoint","dommatrix","buffersource","resurrectable"]}},fe={types:()=>["number","SpecialRealNumber","string","ValidDate","array","buffersource"],testInvalid(e,t){switch(e){case"SpecialRealNumber":return Number.isNaN(t);case"ValidDate":return Number.isNaN(t.getTime());case"array":return Object.keys(t).length!==t.length;default:return!1}},convertFromTypeson:e=>({type:ge.get(e)}),iterate:(e,t)=>(t.format="indexedDBKey",he.iterate(e,t)),getTypesAndSchemasForState(e,t){if(!t||["array"].includes(t))return{types:this.types(),schemaObjects:[]}}},ge=new Map([["SpecialNumber","SpecialRealNumber"],["date","ValidDate"],["arrayNonindexKeys","array"]]);var ve,be;!function(e){e.assertEqual=e=>e,e.assertIs=function assertIs(e){},e.assertNever=function assertNever(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const a of e)t[a]=a;return t},e.getValidEnumValues=t=>{const a=e.objectKeys(t).filter((e=>"number"!=typeof t[t[e]])),r={};for(const e of a)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map((function(e){return t[e]})),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.push(a);return t},e.find=(e,t)=>{for(const a of e)if(t(a))return a},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&isFinite(e)&&Math.floor(e)===e,e.joinValues=function joinValues(e,t=" | "){return e.map((e=>"string"==typeof e?`'${e}'`:e)).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(ve||(ve={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(be||(be={}));const we=ve.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),getParsedType=e=>{switch(typeof e){case"undefined":return we.undefined;case"string":return we.string;case"number":return isNaN(e)?we.nan:we.number;case"boolean":return we.boolean;case"function":return we.function;case"bigint":return we.bigint;case"symbol":return we.symbol;case"object":return Array.isArray(e)?we.array:null===e?we.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?we.promise:"undefined"!=typeof Map&&e instanceof Map?we.map:"undefined"!=typeof Set&&e instanceof Set?we.set:"undefined"!=typeof Date&&e instanceof Date?we.date:we.object;default:return we.unknown}},xe=ve.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class ZodError extends Error{constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(e){return e.message},a={_errors:[]},processError=e=>{for(const r of e.issues)if("invalid_union"===r.code)r.unionErrors.map(processError);else if("invalid_return_type"===r.code)processError(r.returnTypeError);else if("invalid_arguments"===r.code)processError(r.argumentsError);else if(0===r.path.length)a._errors.push(t(r));else{let e=a,n=0;for(;n<r.path.length;){const a=r.path[n];n===r.path.length-1?(e[a]=e[a]||{_errors:[]},e[a]._errors.push(t(r))):e[a]=e[a]||{_errors:[]},e=e[a],n++}}};return processError(this),a}static assert(e){if(!(e instanceof ZodError))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ve.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},a=[];for(const r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):a.push(e(r));return{formErrors:a,fieldErrors:t}}get formErrors(){return this.flatten()}}ZodError.create=e=>new ZodError(e);const errorMap=(e,t)=>{let a;switch(e.code){case xe.invalid_type:a=e.received===we.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case xe.invalid_literal:a=`Invalid literal value, expected ${JSON.stringify(e.expected,ve.jsonStringifyReplacer)}`;break;case xe.unrecognized_keys:a=`Unrecognized key(s) in object: ${ve.joinValues(e.keys,", ")}`;break;case xe.invalid_union:a="Invalid input";break;case xe.invalid_union_discriminator:a=`Invalid discriminator value. Expected ${ve.joinValues(e.options)}`;break;case xe.invalid_enum_value:a=`Invalid enum value. Expected ${ve.joinValues(e.options)}, received '${e.received}'`;break;case xe.invalid_arguments:a="Invalid function arguments";break;case xe.invalid_return_type:a="Invalid function return type";break;case xe.invalid_date:a="Invalid date";break;case xe.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(a=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(a=`${a} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?a=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?a=`Invalid input: must end with "${e.validation.endsWith}"`:ve.assertNever(e.validation):a="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case xe.too_small:a="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case xe.too_big:a="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case xe.custom:a="Invalid input";break;case xe.invalid_intersection_types:a="Intersection results could not be merged";break;case xe.not_multiple_of:a=`Number must be a multiple of ${e.multipleOf}`;break;case xe.not_finite:a="Number must be finite";break;default:a=t.defaultError,ve.assertNever(e)}return{message:a}};let Se=errorMap;function getErrorMap(){return Se}const makeIssue=e=>{const{data:t,path:a,errorMaps:r,issueData:n}=e,i=[...a,...n.path||[]],s={...n,path:i};if(void 0!==n.message)return{...n,path:i,message:n.message};let o="";const c=r.filter((e=>!!e)).slice().reverse();for(const e of c)o=e(s,{data:t,defaultError:o}).message;return{...n,path:i,message:o}};function addIssueToContext(e,t){const a=getErrorMap(),r=makeIssue({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,a,a===errorMap?void 0:errorMap].filter((e=>!!e))});e.common.issues.push(r)}class ParseStatus{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const a=[];for(const r of t){if("aborted"===r.status)return Ie;"dirty"===r.status&&e.dirty(),a.push(r.value)}return{status:e.value,value:a}}static async mergeObjectAsync(e,t){const a=[];for(const e of t){const t=await e.key,r=await e.value;a.push({key:t,value:r})}return ParseStatus.mergeObjectSync(e,a)}static mergeObjectSync(e,t){const a={};for(const r of t){const{key:t,value:n}=r;if("aborted"===t.status)return Ie;if("aborted"===n.status)return Ie;"dirty"===t.status&&e.dirty(),"dirty"===n.status&&e.dirty(),"__proto__"===t.value||void 0===n.value&&!r.alwaysSet||(a[t.value]=n.value)}return{status:e.value,value:a}}}const Ie=Object.freeze({status:"aborted"}),DIRTY=e=>({status:"dirty",value:e}),OK=e=>({status:"valid",value:e}),isAborted=e=>"aborted"===e.status,isDirty=e=>"dirty"===e.status,isValid=e=>"valid"===e.status,isAsync=e=>"undefined"!=typeof Promise&&e instanceof Promise;function __classPrivateFieldGet(e,t,a,r){if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t.get(e)}function __classPrivateFieldSet(e,t,a,r,n){if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,a),a}var Te,Ee,Ne;"function"==typeof SuppressedError&&SuppressedError,function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:null==e?void 0:e.message}(Te||(Te={}));class ParseInputLazyPath{constructor(e,t,a,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=a,this._key=r}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const handleResult=(e,t)=>{if(isValid(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new ZodError(e.common.issues);return this._error=t,this._error}}};function processCreateParams(e){if(!e)return{};const{errorMap:t,invalid_type_error:a,required_error:r,description:n}=e;if(t&&(a||r))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:n};return{errorMap:(t,n)=>{var i,s;const{message:o}=e;return"invalid_enum_value"===t.code?{message:null!=o?o:n.defaultError}:void 0===n.data?{message:null!==(i=null!=o?o:r)&&void 0!==i?i:n.defaultError}:"invalid_type"!==t.code?{message:n.defaultError}:{message:null!==(s=null!=o?o:a)&&void 0!==s?s:n.defaultError}},description:n}}class ZodType{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return getParsedType(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:getParsedType(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ParseStatus,ctx:{common:e.parent.common,data:e.data,parsedType:getParsedType(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(isAsync(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const a=this.safeParse(e,t);if(a.success)return a.data;throw a.error}safeParse(e,t){var a;const r={common:{issues:[],async:null!==(a=null==t?void 0:t.async)&&void 0!==a&&a,contextualErrorMap:null==t?void 0:t.errorMap},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:getParsedType(e)},n=this._parseSync({data:e,path:r.path,parent:r});return handleResult(r,n)}async parseAsync(e,t){const a=await this.safeParseAsync(e,t);if(a.success)return a.data;throw a.error}async safeParseAsync(e,t){const a={common:{issues:[],contextualErrorMap:null==t?void 0:t.errorMap,async:!0},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:getParsedType(e)},r=this._parse({data:e,path:a.path,parent:a}),n=await(isAsync(r)?r:Promise.resolve(r));return handleResult(a,n)}refine(e,t){const getIssueProperties=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,a)=>{const r=e(t),setError=()=>a.addIssue({code:xe.custom,...getIssueProperties(t)});return"undefined"!=typeof Promise&&r instanceof Promise?r.then((e=>!!e||(setError(),!1))):!!r||(setError(),!1)}))}refinement(e,t){return this._refinement(((a,r)=>!!e(a)||(r.addIssue("function"==typeof t?t(a,r):t),!1)))}_refinement(e){return new ZodEffects({schema:this,typeName:Fe.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ZodOptional.create(this,this._def)}nullable(){return ZodNullable.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ZodArray.create(this,this._def)}promise(){return ZodPromise.create(this,this._def)}or(e){return ZodUnion.create([this,e],this._def)}and(e){return ZodIntersection.create(this,e,this._def)}transform(e){return new ZodEffects({...processCreateParams(this._def),schema:this,typeName:Fe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new ZodDefault({...processCreateParams(this._def),innerType:this,defaultValue:t,typeName:Fe.ZodDefault})}brand(){return new ZodBranded({typeName:Fe.ZodBranded,type:this,...processCreateParams(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new ZodCatch({...processCreateParams(this._def),innerType:this,catchValue:t,typeName:Fe.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return ZodPipeline.create(this,e)}readonly(){return ZodReadonly.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const _e=/^c[^\s-]{8,}$/i,Oe=/^[0-9a-z]+$/,ke=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ae=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Ce=/^[a-z0-9_-]{21}$/i,je=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Re=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let Ze;const Ve=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Me=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Pe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ue="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Be=new RegExp(`^${Ue}$`);function timeRegexSource$1(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`),t}function datetimeRegex(e){let t=`${Ue}T${timeRegexSource$1(e)}`;const a=[];return a.push(e.local?"Z?":"Z"),e.offset&&a.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${a.join("|")})`,new RegExp(`^${t}$`)}class ZodString extends ZodType{_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==we.string){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:xe.invalid_type,expected:we.string,received:t.parsedType}),Ie}const t=new ParseStatus;let a;for(const i of this._def.checks)if("min"===i.kind)e.data.length<i.value&&(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{code:xe.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if("max"===i.kind)e.data.length>i.value&&(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{code:xe.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if("length"===i.kind){const r=e.data.length>i.value,n=e.data.length<i.value;(r||n)&&(a=this._getOrReturnCtx(e,a),r?addIssueToContext(a,{code:xe.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):n&&addIssueToContext(a,{code:xe.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),t.dirty())}else if("email"===i.kind)Re.test(e.data)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{validation:"email",code:xe.invalid_string,message:i.message}),t.dirty());else if("emoji"===i.kind)Ze||(Ze=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Ze.test(e.data)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{validation:"emoji",code:xe.invalid_string,message:i.message}),t.dirty());else if("uuid"===i.kind)Ae.test(e.data)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{validation:"uuid",code:xe.invalid_string,message:i.message}),t.dirty());else if("nanoid"===i.kind)Ce.test(e.data)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{validation:"nanoid",code:xe.invalid_string,message:i.message}),t.dirty());else if("cuid"===i.kind)_e.test(e.data)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{validation:"cuid",code:xe.invalid_string,message:i.message}),t.dirty());else if("cuid2"===i.kind)Oe.test(e.data)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{validation:"cuid2",code:xe.invalid_string,message:i.message}),t.dirty());else if("ulid"===i.kind)ke.test(e.data)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{validation:"ulid",code:xe.invalid_string,message:i.message}),t.dirty());else if("url"===i.kind)try{new URL(e.data)}catch(r){a=this._getOrReturnCtx(e,a),addIssueToContext(a,{validation:"url",code:xe.invalid_string,message:i.message}),t.dirty()}else if("regex"===i.kind){i.regex.lastIndex=0;i.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{validation:"regex",code:xe.invalid_string,message:i.message}),t.dirty())}else if("trim"===i.kind)e.data=e.data.trim();else if("includes"===i.kind)e.data.includes(i.value,i.position)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{code:xe.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),t.dirty());else if("toLowerCase"===i.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===i.kind)e.data=e.data.toUpperCase();else if("startsWith"===i.kind)e.data.startsWith(i.value)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{code:xe.invalid_string,validation:{startsWith:i.value},message:i.message}),t.dirty());else if("endsWith"===i.kind)e.data.endsWith(i.value)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{code:xe.invalid_string,validation:{endsWith:i.value},message:i.message}),t.dirty());else if("datetime"===i.kind){datetimeRegex(i).test(e.data)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{code:xe.invalid_string,validation:"datetime",message:i.message}),t.dirty())}else if("date"===i.kind){Be.test(e.data)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{code:xe.invalid_string,validation:"date",message:i.message}),t.dirty())}else if("time"===i.kind){new RegExp(`^${timeRegexSource$1(i)}$`).test(e.data)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{code:xe.invalid_string,validation:"time",message:i.message}),t.dirty())}else"duration"===i.kind?je.test(e.data)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{validation:"duration",code:xe.invalid_string,message:i.message}),t.dirty()):"ip"===i.kind?(r=e.data,("v4"!==(n=i.version)&&n||!Ve.test(r))&&("v6"!==n&&n||!Me.test(r))&&(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{validation:"ip",code:xe.invalid_string,message:i.message}),t.dirty())):"base64"===i.kind?Pe.test(e.data)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{validation:"base64",code:xe.invalid_string,message:i.message}),t.dirty()):ve.assertNever(i);var r,n;return{status:t.value,value:e.data}}_regex(e,t,a){return this.refinement((t=>e.test(t)),{validation:t,code:xe.invalid_string,...Te.errToObj(a)})}_addCheck(e){return new ZodString({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Te.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Te.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Te.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Te.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Te.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Te.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Te.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Te.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Te.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Te.errToObj(e)})}datetime(e){var t,a;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,offset:null!==(t=null==e?void 0:e.offset)&&void 0!==t&&t,local:null!==(a=null==e?void 0:e.local)&&void 0!==a&&a,...Te.errToObj(null==e?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,...Te.errToObj(null==e?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Te.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Te.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:null==t?void 0:t.position,...Te.errToObj(null==t?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Te.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Te.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Te.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Te.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Te.errToObj(t)})}nonempty(e){return this.min(1,Te.errToObj(e))}trim(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e=>"datetime"===e.kind))}get isDate(){return!!this._def.checks.find((e=>"date"===e.kind))}get isTime(){return!!this._def.checks.find((e=>"time"===e.kind))}get isDuration(){return!!this._def.checks.find((e=>"duration"===e.kind))}get isEmail(){return!!this._def.checks.find((e=>"email"===e.kind))}get isURL(){return!!this._def.checks.find((e=>"url"===e.kind))}get isEmoji(){return!!this._def.checks.find((e=>"emoji"===e.kind))}get isUUID(){return!!this._def.checks.find((e=>"uuid"===e.kind))}get isNANOID(){return!!this._def.checks.find((e=>"nanoid"===e.kind))}get isCUID(){return!!this._def.checks.find((e=>"cuid"===e.kind))}get isCUID2(){return!!this._def.checks.find((e=>"cuid2"===e.kind))}get isULID(){return!!this._def.checks.find((e=>"ulid"===e.kind))}get isIP(){return!!this._def.checks.find((e=>"ip"===e.kind))}get isBase64(){return!!this._def.checks.find((e=>"base64"===e.kind))}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function floatSafeRemainder(e,t){const a=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,n=a>r?a:r;return parseInt(e.toFixed(n).replace(".",""))%parseInt(t.toFixed(n).replace(".",""))/Math.pow(10,n)}ZodString.create=e=>{var t;return new ZodString({checks:[],typeName:Fe.ZodString,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...processCreateParams(e)})};class ZodNumber extends ZodType{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){this._def.coerce&&(e.data=Number(e.data));if(this._getType(e)!==we.number){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:xe.invalid_type,expected:we.number,received:t.parsedType}),Ie}let t;const a=new ParseStatus;for(const r of this._def.checks)if("int"===r.kind)ve.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:xe.invalid_type,expected:"integer",received:"float",message:r.message}),a.dirty());else if("min"===r.kind){(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:xe.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty())}else if("max"===r.kind){(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:xe.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty())}else"multipleOf"===r.kind?0!==floatSafeRemainder(e.data,r.value)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:xe.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):"finite"===r.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:xe.not_finite,message:r.message}),a.dirty()):ve.assertNever(r);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Te.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Te.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Te.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Te.toString(t))}setLimit(e,t,a,r){return new ZodNumber({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:Te.toString(r)}]})}_addCheck(e){return new ZodNumber({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Te.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Te.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Te.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Te.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Te.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Te.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Te.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Te.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Te.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find((e=>"int"===e.kind||"multipleOf"===e.kind&&ve.isInteger(e.value)))}get isFinite(){let e=null,t=null;for(const a of this._def.checks){if("finite"===a.kind||"int"===a.kind||"multipleOf"===a.kind)return!0;"min"===a.kind?(null===t||a.value>t)&&(t=a.value):"max"===a.kind&&(null===e||a.value<e)&&(e=a.value)}return Number.isFinite(t)&&Number.isFinite(e)}}ZodNumber.create=e=>new ZodNumber({checks:[],typeName:Fe.ZodNumber,coerce:(null==e?void 0:e.coerce)||!1,...processCreateParams(e)});class ZodBigInt extends ZodType{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){this._def.coerce&&(e.data=BigInt(e.data));if(this._getType(e)!==we.bigint){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:xe.invalid_type,expected:we.bigint,received:t.parsedType}),Ie}let t;const a=new ParseStatus;for(const r of this._def.checks)if("min"===r.kind){(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:xe.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty())}else if("max"===r.kind){(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:xe.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty())}else"multipleOf"===r.kind?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:xe.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):ve.assertNever(r);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Te.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Te.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Te.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Te.toString(t))}setLimit(e,t,a,r){return new ZodBigInt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:Te.toString(r)}]})}_addCheck(e){return new ZodBigInt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Te.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Te.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Te.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Te.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Te.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}ZodBigInt.create=e=>{var t;return new ZodBigInt({checks:[],typeName:Fe.ZodBigInt,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...processCreateParams(e)})};class ZodBoolean extends ZodType{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==we.boolean){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:xe.invalid_type,expected:we.boolean,received:t.parsedType}),Ie}return OK(e.data)}}ZodBoolean.create=e=>new ZodBoolean({typeName:Fe.ZodBoolean,coerce:(null==e?void 0:e.coerce)||!1,...processCreateParams(e)});class ZodDate extends ZodType{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==we.date){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:xe.invalid_type,expected:we.date,received:t.parsedType}),Ie}if(isNaN(e.data.getTime())){return addIssueToContext(this._getOrReturnCtx(e),{code:xe.invalid_date}),Ie}const t=new ParseStatus;let a;for(const r of this._def.checks)"min"===r.kind?e.data.getTime()<r.value&&(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{code:xe.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),t.dirty()):"max"===r.kind?e.data.getTime()>r.value&&(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{code:xe.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),t.dirty()):ve.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ZodDate({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Te.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Te.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}ZodDate.create=e=>new ZodDate({checks:[],coerce:(null==e?void 0:e.coerce)||!1,typeName:Fe.ZodDate,...processCreateParams(e)});class ZodSymbol extends ZodType{_parse(e){if(this._getType(e)!==we.symbol){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:xe.invalid_type,expected:we.symbol,received:t.parsedType}),Ie}return OK(e.data)}}ZodSymbol.create=e=>new ZodSymbol({typeName:Fe.ZodSymbol,...processCreateParams(e)});class ZodUndefined extends ZodType{_parse(e){if(this._getType(e)!==we.undefined){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:xe.invalid_type,expected:we.undefined,received:t.parsedType}),Ie}return OK(e.data)}}ZodUndefined.create=e=>new ZodUndefined({typeName:Fe.ZodUndefined,...processCreateParams(e)});class ZodNull extends ZodType{_parse(e){if(this._getType(e)!==we.null){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:xe.invalid_type,expected:we.null,received:t.parsedType}),Ie}return OK(e.data)}}ZodNull.create=e=>new ZodNull({typeName:Fe.ZodNull,...processCreateParams(e)});class ZodAny extends ZodType{constructor(){super(...arguments),this._any=!0}_parse(e){return OK(e.data)}}ZodAny.create=e=>new ZodAny({typeName:Fe.ZodAny,...processCreateParams(e)});class ZodUnknown extends ZodType{constructor(){super(...arguments),this._unknown=!0}_parse(e){return OK(e.data)}}ZodUnknown.create=e=>new ZodUnknown({typeName:Fe.ZodUnknown,...processCreateParams(e)});class ZodNever extends ZodType{_parse(e){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:xe.invalid_type,expected:we.never,received:t.parsedType}),Ie}}ZodNever.create=e=>new ZodNever({typeName:Fe.ZodNever,...processCreateParams(e)});class ZodVoid extends ZodType{_parse(e){if(this._getType(e)!==we.undefined){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:xe.invalid_type,expected:we.void,received:t.parsedType}),Ie}return OK(e.data)}}ZodVoid.create=e=>new ZodVoid({typeName:Fe.ZodVoid,...processCreateParams(e)});class ZodArray extends ZodType{_parse(e){const{ctx:t,status:a}=this._processInputParams(e),r=this._def;if(t.parsedType!==we.array)return addIssueToContext(t,{code:xe.invalid_type,expected:we.array,received:t.parsedType}),Ie;if(null!==r.exactLength){const e=t.data.length>r.exactLength.value,n=t.data.length<r.exactLength.value;(e||n)&&(addIssueToContext(t,{code:e?xe.too_big:xe.too_small,minimum:n?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),a.dirty())}if(null!==r.minLength&&t.data.length<r.minLength.value&&(addIssueToContext(t,{code:xe.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),a.dirty()),null!==r.maxLength&&t.data.length>r.maxLength.value&&(addIssueToContext(t,{code:xe.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),a.dirty()),t.common.async)return Promise.all([...t.data].map(((e,a)=>r.type._parseAsync(new ParseInputLazyPath(t,e,t.path,a))))).then((e=>ParseStatus.mergeArray(a,e)));const n=[...t.data].map(((e,a)=>r.type._parseSync(new ParseInputLazyPath(t,e,t.path,a))));return ParseStatus.mergeArray(a,n)}get element(){return this._def.type}min(e,t){return new ZodArray({...this._def,minLength:{value:e,message:Te.toString(t)}})}max(e,t){return new ZodArray({...this._def,maxLength:{value:e,message:Te.toString(t)}})}length(e,t){return new ZodArray({...this._def,exactLength:{value:e,message:Te.toString(t)}})}nonempty(e){return this.min(1,e)}}function deepPartialify(e){if(e instanceof ZodObject){const t={};for(const a in e.shape){const r=e.shape[a];t[a]=ZodOptional.create(deepPartialify(r))}return new ZodObject({...e._def,shape:()=>t})}return e instanceof ZodArray?new ZodArray({...e._def,type:deepPartialify(e.element)}):e instanceof ZodOptional?ZodOptional.create(deepPartialify(e.unwrap())):e instanceof ZodNullable?ZodNullable.create(deepPartialify(e.unwrap())):e instanceof ZodTuple?ZodTuple.create(e.items.map((e=>deepPartialify(e)))):e}ZodArray.create=(e,t)=>new ZodArray({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Fe.ZodArray,...processCreateParams(t)});class ZodObject extends ZodType{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=ve.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==we.object){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:xe.invalid_type,expected:we.object,received:t.parsedType}),Ie}const{status:t,ctx:a}=this._processInputParams(e),{shape:r,keys:n}=this._getCached(),i=[];if(!(this._def.catchall instanceof ZodNever&&"strip"===this._def.unknownKeys))for(const e in a.data)n.includes(e)||i.push(e);const s=[];for(const e of n){const t=r[e],n=a.data[e];s.push({key:{status:"valid",value:e},value:t._parse(new ParseInputLazyPath(a,n,a.path,e)),alwaysSet:e in a.data})}if(this._def.catchall instanceof ZodNever){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of i)s.push({key:{status:"valid",value:e},value:{status:"valid",value:a.data[e]}});else if("strict"===e)i.length>0&&(addIssueToContext(a,{code:xe.unrecognized_keys,keys:i}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of i){const r=a.data[t];s.push({key:{status:"valid",value:t},value:e._parse(new ParseInputLazyPath(a,r,a.path,t)),alwaysSet:t in a.data})}}return a.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of s){const a=await t.key,r=await t.value;e.push({key:a,value:r,alwaysSet:t.alwaysSet})}return e})).then((e=>ParseStatus.mergeObjectSync(t,e))):ParseStatus.mergeObjectSync(t,s)}get shape(){return this._def.shape()}strict(e){return Te.errToObj,new ZodObject({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,a)=>{var r,n,i,s;const o=null!==(i=null===(n=(r=this._def).errorMap)||void 0===n?void 0:n.call(r,t,a).message)&&void 0!==i?i:a.defaultError;return"unrecognized_keys"===t.code?{message:null!==(s=Te.errToObj(e).message)&&void 0!==s?s:o}:{message:o}}}:{}})}strip(){return new ZodObject({...this._def,unknownKeys:"strip"})}passthrough(){return new ZodObject({...this._def,unknownKeys:"passthrough"})}extend(e){return new ZodObject({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ZodObject({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Fe.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ZodObject({...this._def,catchall:e})}pick(e){const t={};return ve.objectKeys(e).forEach((a=>{e[a]&&this.shape[a]&&(t[a]=this.shape[a])})),new ZodObject({...this._def,shape:()=>t})}omit(e){const t={};return ve.objectKeys(this.shape).forEach((a=>{e[a]||(t[a]=this.shape[a])})),new ZodObject({...this._def,shape:()=>t})}deepPartial(){return deepPartialify(this)}partial(e){const t={};return ve.objectKeys(this.shape).forEach((a=>{const r=this.shape[a];e&&!e[a]?t[a]=r:t[a]=r.optional()})),new ZodObject({...this._def,shape:()=>t})}required(e){const t={};return ve.objectKeys(this.shape).forEach((a=>{if(e&&!e[a])t[a]=this.shape[a];else{let e=this.shape[a];for(;e instanceof ZodOptional;)e=e._def.innerType;t[a]=e}})),new ZodObject({...this._def,shape:()=>t})}keyof(){return createZodEnum(ve.objectKeys(this.shape))}}ZodObject.create=(e,t)=>new ZodObject({shape:()=>e,unknownKeys:"strip",catchall:ZodNever.create(),typeName:Fe.ZodObject,...processCreateParams(t)}),ZodObject.strictCreate=(e,t)=>new ZodObject({shape:()=>e,unknownKeys:"strict",catchall:ZodNever.create(),typeName:Fe.ZodObject,...processCreateParams(t)}),ZodObject.lazycreate=(e,t)=>new ZodObject({shape:e,unknownKeys:"strip",catchall:ZodNever.create(),typeName:Fe.ZodObject,...processCreateParams(t)});class ZodUnion extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e),a=this._def.options;if(t.common.async)return Promise.all(a.map((async e=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}}))).then((function handleResults(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const a of e)if("dirty"===a.result.status)return t.common.issues.push(...a.ctx.common.issues),a.result;const a=e.map((e=>new ZodError(e.ctx.common.issues)));return addIssueToContext(t,{code:xe.invalid_union,unionErrors:a}),Ie}));{let e;const r=[];for(const n of a){const a={...t,common:{...t.common,issues:[]},parent:null},i=n._parseSync({data:t.data,path:t.path,parent:a});if("valid"===i.status)return i;"dirty"!==i.status||e||(e={result:i,ctx:a}),a.common.issues.length&&r.push(a.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const n=r.map((e=>new ZodError(e)));return addIssueToContext(t,{code:xe.invalid_union,unionErrors:n}),Ie}}get options(){return this._def.options}}ZodUnion.create=(e,t)=>new ZodUnion({options:e,typeName:Fe.ZodUnion,...processCreateParams(t)});const getDiscriminator=e=>e instanceof ZodLazy?getDiscriminator(e.schema):e instanceof ZodEffects?getDiscriminator(e.innerType()):e instanceof ZodLiteral?[e.value]:e instanceof ZodEnum?e.options:e instanceof ZodNativeEnum?ve.objectValues(e.enum):e instanceof ZodDefault?getDiscriminator(e._def.innerType):e instanceof ZodUndefined?[void 0]:e instanceof ZodNull?[null]:e instanceof ZodOptional?[void 0,...getDiscriminator(e.unwrap())]:e instanceof ZodNullable?[null,...getDiscriminator(e.unwrap())]:e instanceof ZodBranded||e instanceof ZodReadonly?getDiscriminator(e.unwrap()):e instanceof ZodCatch?getDiscriminator(e._def.innerType):[];class ZodDiscriminatedUnion extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==we.object)return addIssueToContext(t,{code:xe.invalid_type,expected:we.object,received:t.parsedType}),Ie;const a=this.discriminator,r=t.data[a],n=this.optionsMap.get(r);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(addIssueToContext(t,{code:xe.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),Ie)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,a){const r=new Map;for(const a of t){const t=getDiscriminator(a.shape[e]);if(!t.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const n of t){if(r.has(n))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(n)}`);r.set(n,a)}}return new ZodDiscriminatedUnion({typeName:Fe.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...processCreateParams(a)})}}function mergeValues(e,t){const a=getParsedType(e),r=getParsedType(t);if(e===t)return{valid:!0,data:e};if(a===we.object&&r===we.object){const a=ve.objectKeys(t),r=ve.objectKeys(e).filter((e=>-1!==a.indexOf(e))),n={...e,...t};for(const a of r){const r=mergeValues(e[a],t[a]);if(!r.valid)return{valid:!1};n[a]=r.data}return{valid:!0,data:n}}if(a===we.array&&r===we.array){if(e.length!==t.length)return{valid:!1};const a=[];for(let r=0;r<e.length;r++){const n=mergeValues(e[r],t[r]);if(!n.valid)return{valid:!1};a.push(n.data)}return{valid:!0,data:a}}return a===we.date&&r===we.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class ZodIntersection extends ZodType{_parse(e){const{status:t,ctx:a}=this._processInputParams(e),handleParsed=(e,r)=>{if(isAborted(e)||isAborted(r))return Ie;const n=mergeValues(e.value,r.value);return n.valid?((isDirty(e)||isDirty(r))&&t.dirty(),{status:t.value,value:n.data}):(addIssueToContext(a,{code:xe.invalid_intersection_types}),Ie)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then((([e,t])=>handleParsed(e,t))):handleParsed(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}}ZodIntersection.create=(e,t,a)=>new ZodIntersection({left:e,right:t,typeName:Fe.ZodIntersection,...processCreateParams(a)});class ZodTuple extends ZodType{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==we.array)return addIssueToContext(a,{code:xe.invalid_type,expected:we.array,received:a.parsedType}),Ie;if(a.data.length<this._def.items.length)return addIssueToContext(a,{code:xe.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Ie;!this._def.rest&&a.data.length>this._def.items.length&&(addIssueToContext(a,{code:xe.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...a.data].map(((e,t)=>{const r=this._def.items[t]||this._def.rest;return r?r._parse(new ParseInputLazyPath(a,e,a.path,t)):null})).filter((e=>!!e));return a.common.async?Promise.all(r).then((e=>ParseStatus.mergeArray(t,e))):ParseStatus.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new ZodTuple({...this._def,rest:e})}}ZodTuple.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ZodTuple({items:e,typeName:Fe.ZodTuple,rest:null,...processCreateParams(t)})};class ZodRecord extends ZodType{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==we.object)return addIssueToContext(a,{code:xe.invalid_type,expected:we.object,received:a.parsedType}),Ie;const r=[],n=this._def.keyType,i=this._def.valueType;for(const e in a.data)r.push({key:n._parse(new ParseInputLazyPath(a,e,a.path,e)),value:i._parse(new ParseInputLazyPath(a,a.data[e],a.path,e)),alwaysSet:e in a.data});return a.common.async?ParseStatus.mergeObjectAsync(t,r):ParseStatus.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,a){return new ZodRecord(t instanceof ZodType?{keyType:e,valueType:t,typeName:Fe.ZodRecord,...processCreateParams(a)}:{keyType:ZodString.create(),valueType:e,typeName:Fe.ZodRecord,...processCreateParams(t)})}}class ZodMap extends ZodType{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==we.map)return addIssueToContext(a,{code:xe.invalid_type,expected:we.map,received:a.parsedType}),Ie;const r=this._def.keyType,n=this._def.valueType,i=[...a.data.entries()].map((([e,t],i)=>({key:r._parse(new ParseInputLazyPath(a,e,a.path,[i,"key"])),value:n._parse(new ParseInputLazyPath(a,t,a.path,[i,"value"]))})));if(a.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const a of i){const r=await a.key,n=await a.value;if("aborted"===r.status||"aborted"===n.status)return Ie;"dirty"!==r.status&&"dirty"!==n.status||t.dirty(),e.set(r.value,n.value)}return{status:t.value,value:e}}))}{const e=new Map;for(const a of i){const r=a.key,n=a.value;if("aborted"===r.status||"aborted"===n.status)return Ie;"dirty"!==r.status&&"dirty"!==n.status||t.dirty(),e.set(r.value,n.value)}return{status:t.value,value:e}}}}ZodMap.create=(e,t,a)=>new ZodMap({valueType:t,keyType:e,typeName:Fe.ZodMap,...processCreateParams(a)});class ZodSet extends ZodType{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==we.set)return addIssueToContext(a,{code:xe.invalid_type,expected:we.set,received:a.parsedType}),Ie;const r=this._def;null!==r.minSize&&a.data.size<r.minSize.value&&(addIssueToContext(a,{code:xe.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),null!==r.maxSize&&a.data.size>r.maxSize.value&&(addIssueToContext(a,{code:xe.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const n=this._def.valueType;function finalizeSet(e){const a=new Set;for(const r of e){if("aborted"===r.status)return Ie;"dirty"===r.status&&t.dirty(),a.add(r.value)}return{status:t.value,value:a}}const i=[...a.data.values()].map(((e,t)=>n._parse(new ParseInputLazyPath(a,e,a.path,t))));return a.common.async?Promise.all(i).then((e=>finalizeSet(e))):finalizeSet(i)}min(e,t){return new ZodSet({...this._def,minSize:{value:e,message:Te.toString(t)}})}max(e,t){return new ZodSet({...this._def,maxSize:{value:e,message:Te.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ZodSet.create=(e,t)=>new ZodSet({valueType:e,minSize:null,maxSize:null,typeName:Fe.ZodSet,...processCreateParams(t)});class ZodFunction extends ZodType{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==we.function)return addIssueToContext(t,{code:xe.invalid_type,expected:we.function,received:t.parsedType}),Ie;function makeArgsIssue(e,a){return makeIssue({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,getErrorMap(),errorMap].filter((e=>!!e)),issueData:{code:xe.invalid_arguments,argumentsError:a}})}function makeReturnsIssue(e,a){return makeIssue({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,getErrorMap(),errorMap].filter((e=>!!e)),issueData:{code:xe.invalid_return_type,returnTypeError:a}})}const a={errorMap:t.common.contextualErrorMap},r=t.data;if(this._def.returns instanceof ZodPromise){const e=this;return OK((async function(...t){const n=new ZodError([]),i=await e._def.args.parseAsync(t,a).catch((e=>{throw n.addIssue(makeArgsIssue(t,e)),n})),s=await Reflect.apply(r,this,i),o=await e._def.returns._def.type.parseAsync(s,a).catch((e=>{throw n.addIssue(makeReturnsIssue(s,e)),n}));return o}))}{const e=this;return OK((function(...t){const n=e._def.args.safeParse(t,a);if(!n.success)throw new ZodError([makeArgsIssue(t,n.error)]);const i=Reflect.apply(r,this,n.data),s=e._def.returns.safeParse(i,a);if(!s.success)throw new ZodError([makeReturnsIssue(i,s.error)]);return s.data}))}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ZodFunction({...this._def,args:ZodTuple.create(e).rest(ZodUnknown.create())})}returns(e){return new ZodFunction({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,a){return new ZodFunction({args:e||ZodTuple.create([]).rest(ZodUnknown.create()),returns:t||ZodUnknown.create(),typeName:Fe.ZodFunction,...processCreateParams(a)})}}class ZodLazy extends ZodType{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ZodLazy.create=(e,t)=>new ZodLazy({getter:e,typeName:Fe.ZodLazy,...processCreateParams(t)});class ZodLiteral extends ZodType{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{received:t.data,code:xe.invalid_literal,expected:this._def.value}),Ie}return{status:"valid",value:e.data}}get value(){return this._def.value}}function createZodEnum(e,t){return new ZodEnum({values:e,typeName:Fe.ZodEnum,...processCreateParams(t)})}ZodLiteral.create=(e,t)=>new ZodLiteral({value:e,typeName:Fe.ZodLiteral,...processCreateParams(t)});class ZodEnum extends ZodType{constructor(){super(...arguments),Ee.set(this,void 0)}_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),a=this._def.values;return addIssueToContext(t,{expected:ve.joinValues(a),received:t.parsedType,code:xe.invalid_type}),Ie}if(__classPrivateFieldGet(this,Ee)||__classPrivateFieldSet(this,Ee,new Set(this._def.values)),!__classPrivateFieldGet(this,Ee).has(e.data)){const t=this._getOrReturnCtx(e),a=this._def.values;return addIssueToContext(t,{received:t.data,code:xe.invalid_enum_value,options:a}),Ie}return OK(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return ZodEnum.create(e,{...this._def,...t})}exclude(e,t=this._def){return ZodEnum.create(this.options.filter((t=>!e.includes(t))),{...this._def,...t})}}Ee=new WeakMap,ZodEnum.create=createZodEnum;class ZodNativeEnum extends ZodType{constructor(){super(...arguments),Ne.set(this,void 0)}_parse(e){const t=ve.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==we.string&&a.parsedType!==we.number){const e=ve.objectValues(t);return addIssueToContext(a,{expected:ve.joinValues(e),received:a.parsedType,code:xe.invalid_type}),Ie}if(__classPrivateFieldGet(this,Ne)||__classPrivateFieldSet(this,Ne,new Set(ve.getValidEnumValues(this._def.values))),!__classPrivateFieldGet(this,Ne).has(e.data)){const e=ve.objectValues(t);return addIssueToContext(a,{received:a.data,code:xe.invalid_enum_value,options:e}),Ie}return OK(e.data)}get enum(){return this._def.values}}Ne=new WeakMap,ZodNativeEnum.create=(e,t)=>new ZodNativeEnum({values:e,typeName:Fe.ZodNativeEnum,...processCreateParams(t)});class ZodPromise extends ZodType{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==we.promise&&!1===t.common.async)return addIssueToContext(t,{code:xe.invalid_type,expected:we.promise,received:t.parsedType}),Ie;const a=t.parsedType===we.promise?t.data:Promise.resolve(t.data);return OK(a.then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}}ZodPromise.create=(e,t)=>new ZodPromise({type:e,typeName:Fe.ZodPromise,...processCreateParams(t)});class ZodEffects extends ZodType{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Fe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:a}=this._processInputParams(e),r=this._def.effect||null,n={addIssue:e=>{addIssueToContext(a,e),e.fatal?t.abort():t.dirty()},get path(){return a.path}};if(n.addIssue=n.addIssue.bind(n),"preprocess"===r.type){const e=r.transform(a.data,n);if(a.common.async)return Promise.resolve(e).then((async e=>{if("aborted"===t.value)return Ie;const r=await this._def.schema._parseAsync({data:e,path:a.path,parent:a});return"aborted"===r.status?Ie:"dirty"===r.status||"dirty"===t.value?DIRTY(r.value):r}));{if("aborted"===t.value)return Ie;const r=this._def.schema._parseSync({data:e,path:a.path,parent:a});return"aborted"===r.status?Ie:"dirty"===r.status||"dirty"===t.value?DIRTY(r.value):r}}if("refinement"===r.type){const executeRefinement=e=>{const t=r.refinement(e,n);if(a.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===a.common.async){const e=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return"aborted"===e.status?Ie:("dirty"===e.status&&t.dirty(),executeRefinement(e.value),{status:t.value,value:e.value})}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then((e=>"aborted"===e.status?Ie:("dirty"===e.status&&t.dirty(),executeRefinement(e.value).then((()=>({status:t.value,value:e.value}))))))}if("transform"===r.type){if(!1===a.common.async){const e=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!isValid(e))return e;const i=r.transform(e.value,n);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:i}}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then((e=>isValid(e)?Promise.resolve(r.transform(e.value,n)).then((e=>({status:t.value,value:e}))):e))}ve.assertNever(r)}}ZodEffects.create=(e,t,a)=>new ZodEffects({schema:e,typeName:Fe.ZodEffects,effect:t,...processCreateParams(a)}),ZodEffects.createWithPreprocess=(e,t,a)=>new ZodEffects({schema:t,effect:{type:"preprocess",transform:e},typeName:Fe.ZodEffects,...processCreateParams(a)});class ZodOptional extends ZodType{_parse(e){return this._getType(e)===we.undefined?OK(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ZodOptional.create=(e,t)=>new ZodOptional({innerType:e,typeName:Fe.ZodOptional,...processCreateParams(t)});class ZodNullable extends ZodType{_parse(e){return this._getType(e)===we.null?OK(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ZodNullable.create=(e,t)=>new ZodNullable({innerType:e,typeName:Fe.ZodNullable,...processCreateParams(t)});class ZodDefault extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e);let a=t.data;return t.parsedType===we.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ZodDefault.create=(e,t)=>new ZodDefault({innerType:e,typeName:Fe.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...processCreateParams(t)});class ZodCatch extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e),a={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return isAsync(r)?r.then((e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new ZodError(a.common.issues)},input:a.data})}))):{status:"valid",value:"valid"===r.status?r.value:this._def.catchValue({get error(){return new ZodError(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}}ZodCatch.create=(e,t)=>new ZodCatch({innerType:e,typeName:Fe.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...processCreateParams(t)});class ZodNaN extends ZodType{_parse(e){if(this._getType(e)!==we.nan){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:xe.invalid_type,expected:we.nan,received:t.parsedType}),Ie}return{status:"valid",value:e.data}}}ZodNaN.create=e=>new ZodNaN({typeName:Fe.ZodNaN,...processCreateParams(e)});const De=Symbol("zod_brand");class ZodBranded extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e),a=t.data;return this._def.type._parse({data:a,path:t.path,parent:t})}unwrap(){return this._def.type}}class ZodPipeline extends ZodType{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.common.async){return(async()=>{const e=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return"aborted"===e.status?Ie:"dirty"===e.status?(t.dirty(),DIRTY(e.value)):this._def.out._parseAsync({data:e.value,path:a.path,parent:a})})()}{const e=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return"aborted"===e.status?Ie:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:a.path,parent:a})}}static create(e,t){return new ZodPipeline({in:e,out:t,typeName:Fe.ZodPipeline})}}class ZodReadonly extends ZodType{_parse(e){const t=this._def.innerType._parse(e),freeze=e=>(isValid(e)&&(e.value=Object.freeze(e.value)),e);return isAsync(t)?t.then((e=>freeze(e))):freeze(t)}unwrap(){return this._def.innerType}}function custom(e,t={},a){return e?ZodAny.create().superRefine(((r,n)=>{var i,s;if(!e(r)){const e="function"==typeof t?t(r):"string"==typeof t?{message:t}:t,o=null===(s=null!==(i=e.fatal)&&void 0!==i?i:a)||void 0===s||s,c="string"==typeof e?{message:e}:e;n.addIssue({code:"custom",...c,fatal:o})}})):ZodAny.create()}ZodReadonly.create=(e,t)=>new ZodReadonly({innerType:e,typeName:Fe.ZodReadonly,...processCreateParams(t)});const Le={object:ZodObject.lazycreate};var Fe;!function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"}(Fe||(Fe={}));const ze=ZodString.create,Ke=ZodNumber.create,We=ZodNaN.create,Je=ZodBigInt.create,He=ZodBoolean.create,qe=ZodDate.create,Ye=ZodSymbol.create,Ge=ZodUndefined.create,Xe=ZodNull.create,Qe=ZodAny.create,et=ZodUnknown.create,tt=ZodNever.create,at=ZodVoid.create,rt=ZodArray.create,nt=ZodObject.create,it=ZodObject.strictCreate,st=ZodUnion.create,ot=ZodDiscriminatedUnion.create,ct=ZodIntersection.create,lt=ZodTuple.create,ut=ZodRecord.create,dt=ZodMap.create,pt=ZodSet.create,mt=ZodFunction.create,yt=ZodLazy.create,ht=ZodLiteral.create,ft=ZodEnum.create,gt=ZodNativeEnum.create,vt=ZodPromise.create,bt=ZodEffects.create,wt=ZodOptional.create,xt=ZodNullable.create,St=ZodEffects.createWithPreprocess,It=ZodPipeline.create,Tt={string:e=>ZodString.create({...e,coerce:!0}),number:e=>ZodNumber.create({...e,coerce:!0}),boolean:e=>ZodBoolean.create({...e,coerce:!0}),bigint:e=>ZodBigInt.create({...e,coerce:!0}),date:e=>ZodDate.create({...e,coerce:!0})},Et=Ie;var Nt=Object.freeze({__proto__:null,defaultErrorMap:errorMap,setErrorMap:function setErrorMap(e){Se=e},getErrorMap:getErrorMap,makeIssue:makeIssue,EMPTY_PATH:[],addIssueToContext:addIssueToContext,ParseStatus:ParseStatus,INVALID:Ie,DIRTY:DIRTY,OK:OK,isAborted:isAborted,isDirty:isDirty,isValid:isValid,isAsync:isAsync,get util(){return ve},get objectUtil(){return be},ZodParsedType:we,getParsedType:getParsedType,ZodType:ZodType,datetimeRegex:datetimeRegex,ZodString:ZodString,ZodNumber:ZodNumber,ZodBigInt:ZodBigInt,ZodBoolean:ZodBoolean,ZodDate:ZodDate,ZodSymbol:ZodSymbol,ZodUndefined:ZodUndefined,ZodNull:ZodNull,ZodAny:ZodAny,ZodUnknown:ZodUnknown,ZodNever:ZodNever,ZodVoid:ZodVoid,ZodArray:ZodArray,ZodObject:ZodObject,ZodUnion:ZodUnion,ZodDiscriminatedUnion:ZodDiscriminatedUnion,ZodIntersection:ZodIntersection,ZodTuple:ZodTuple,ZodRecord:ZodRecord,ZodMap:ZodMap,ZodSet:ZodSet,ZodFunction:ZodFunction,ZodLazy:ZodLazy,ZodLiteral:ZodLiteral,ZodEnum:ZodEnum,ZodNativeEnum:ZodNativeEnum,ZodPromise:ZodPromise,ZodEffects:ZodEffects,ZodTransformer:ZodEffects,ZodOptional:ZodOptional,ZodNullable:ZodNullable,ZodDefault:ZodDefault,ZodCatch:ZodCatch,ZodNaN:ZodNaN,BRAND:De,ZodBranded:ZodBranded,ZodPipeline:ZodPipeline,ZodReadonly:ZodReadonly,custom:custom,Schema:ZodType,ZodSchema:ZodType,late:Le,get ZodFirstPartyTypeKind(){return Fe},coerce:Tt,any:Qe,array:rt,bigint:Je,boolean:He,date:qe,discriminatedUnion:ot,effect:bt,enum:ft,function:mt,instanceof:(e,t={message:`Input not instance of ${e.name}`})=>custom((t=>t instanceof e),t),intersection:ct,lazy:yt,literal:ht,map:dt,nan:We,nativeEnum:gt,never:tt,null:Xe,nullable:xt,number:Ke,object:nt,oboolean:()=>He().optional(),onumber:()=>Ke().optional(),optional:wt,ostring:()=>ze().optional(),pipeline:It,preprocess:St,promise:vt,record:ut,set:pt,strictObject:it,string:ze,symbol:Ye,transformer:bt,tuple:lt,undefined:Ge,union:st,unknown:et,void:at,NEVER:Et,ZodIssueCode:xe,quotelessJson:e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),ZodError:ZodError});function checkRef(e,t){if("$ref"in e){const a=Nt.lazy((()=>Nt.null()));return t.$refs.push([a,e.$ref]),a}return!1}const $t=dezerializeRefs,_t={number:e=>{let t=e.coerce?Nt.coerce.number():Nt.number();return void 0!==e.min&&(t=e.minInclusive?t.min(e.min):t.gt(e.min)),void 0!==e.max&&(t=e.maxInclusive?t.max(e.max):t.lt(e.max)),void 0!==e.multipleOf&&(t=t.multipleOf(e.multipleOf)),e.int&&(t=t.int()),e.finite&&(t=t.finite()),t},string:e=>{let t=e.coerce?Nt.coerce.string():Nt.string();return void 0!==e.min&&(t=t.min(e.min)),void 0!==e.max&&(t=t.max(e.max)),void 0!==e.length&&(t=t.length(e.length)),void 0!==e.startsWith&&(t=t.startsWith(e.startsWith)),void 0!==e.endsWith&&(t=t.endsWith(e.endsWith)),void 0!==e.toLowerCase&&(t=t.toLowerCase()),void 0!==e.toUpperCase&&(t=t.toUpperCase()),void 0!==e.trim&&(t=t.trim()),"includes"in e&&(t=t.includes(e.includes,{position:e.position})),"regex"in e&&(t=t.regex(new RegExp(e.regex,e.flags))),"kind"in e&&(t="ip"==e.kind?t.ip({version:e.version}):"datetime"==e.kind?t.datetime({offset:e.offset,precision:e.precision,local:e.local}):"time"==e.kind?t.time({precision:e.precision}):t[e.kind]()),t},boolean:e=>e.coerce?Nt.coerce.boolean():Nt.boolean(),nan:()=>Nt.nan(),bigInt:e=>{let t=e.coerce?Nt.coerce.bigint():Nt.bigint();if(void 0!==e.min){const a=BigInt(e.min);t=e.minInclusive?t.min(a):t.gt(a)}if(void 0!==e.max){const a=BigInt(e.max);t=e.maxInclusive?t.max(a):t.lt(a)}if(void 0!==e.multipleOf){const a=BigInt(e.multipleOf);t=t.multipleOf(a)}return t},date:e=>{let t=e.coerce?Nt.coerce.date():Nt.date();return void 0!==e.min&&(t=t.min(new Date(e.min))),void 0!==e.max&&(t=t.max(new Date(e.max))),t},undefined:()=>Nt.undefined(),null:()=>Nt.null(),any:()=>Nt.any(),unknown:()=>Nt.unknown(),never:()=>Nt.never(),void:()=>Nt.void(),literal:e=>Nt.literal(e.value),symbol:()=>Nt.symbol(),tuple:(e,t)=>{let a=Nt.tuple(e.items.map(((e,a)=>checkRef(e,t)||$t(e,{...t,path:t.path+"/items/"+a}))));if(e.rest){const r=checkRef(e.rest,t)||$t(e.rest,{...t,path:t.path+"/rest"});a=a.rest(r)}return t.pathToSchema.set(t.path,a),a},set:(e,t)=>{let a=Nt.set(checkRef(e.value,t)||$t(e.value,{...t,path:t.path+"/value"}));return void 0!==e.minSize&&(a=a.min(e.minSize)),void 0!==e.maxSize&&(a=a.max(e.maxSize)),t.pathToSchema.set(t.path,a),a},array:(e,t)=>{let a=Nt.array(checkRef(e.element,t)||$t(e.element,{...t,path:t.path+"/element"}));return void 0!==e.minLength&&(a=a.min(e.minLength)),void 0!==e.maxLength&&(a=a.max(e.maxLength)),t.pathToSchema.set(t.path,a),a},object:(e,t)=>{let a=Nt.object(Object.fromEntries(Object.entries(e.properties).map((([e,a])=>[e,checkRef(a,t)||$t(a,{...t,path:t.path+"/properties/"+e})]))));return e.catchall?a=a.catchall($t(e.catchall,t)):"strict"===e.unknownKeys?a=a.strict():"passthrough"===e.unknownKeys&&(a=a.passthrough()),t.pathToSchema.set(t.path,a),a},record:(e,t)=>{const a=Nt.record(checkRef(e.key,t)||$t(e.key,{...t,path:t.path+"/key"}),checkRef(e.value,t)||$t(e.value,{...t,path:t.path+"/value"}));return t.pathToSchema.set(t.path,a),a},map:(e,t)=>{const a=Nt.map(checkRef(e.key,t)||$t(e.key,{...t,path:t.path+"/key"}),checkRef(e.value,t)||$t(e.value,{...t,path:t.path+"/value"}));return t.pathToSchema.set(t.path,a),a},nativeEnum:e=>Nt.nativeEnum(e.values),enum:e=>Nt.enum(e.values),union:(e,t)=>{const a=Nt.union(e.options.map(((e,a)=>checkRef(e,t)||$t(e,{...t,path:t.path+"/options/"+a}))));return t.pathToSchema.set(t.path,a),a},discriminatedUnion:(e,t)=>{const a=Nt.discriminatedUnion(e.discriminator,e.options.map(((e,a)=>checkRef(e,t)||$t(e,{...t,path:t.path+"/options/"+a}))));return t.pathToSchema.set(t.path,a),a},intersection:(e,t)=>{const a=Nt.intersection(checkRef(e.left,t)||$t(e.left,{...t,path:t.path+"/left"}),checkRef(e.right,t)||$t(e.right,{...t,path:t.path+"/right"}));return t.pathToSchema.set(t.path,a),a},function:(e,t)=>{const a=Nt.function(checkRef(e.args,t)||$t(e.args,{...t,path:t.path+"/args"}),checkRef(e.returns,t)||$t(e.returns,{...t,path:t.path+"/returns"}));return t.pathToSchema.set(t.path,a),a},promise:(e,t)=>{const a=Nt.promise(checkRef(e.value,t)||$t(e.value,{...t,path:t.path+"/value"}));return t.pathToSchema.set(t.path,a),a},catch:(e,t)=>{let a=checkRef(e.innerType,t)||$t(e.innerType,{...t,path:t.path+"/innerType"});return a=a.catch(e.value),t.pathToSchema.set(t.path,a),a},effect:(e,t)=>{let a=checkRef(e.inner,t)||$t(e.inner,{...t,path:t.path+"/inner"});if(!("superRefinements"in t||"transforms"in t||"preprocesses"in t))return t.pathToSchema.set(t.path,a),a;for(const{name:r,type:n}of e.effects)"refinement"===n&&t.superRefinements?.[r]?a=a.superRefine(t.superRefinements[r]):"transform"===n&&t.transforms?.[r]?a=a.transform(t.transforms[r]):"preprocess"===n&&t.preprocesses?.[r]&&(a=Nt.preprocess(t.preprocesses[r],a));return t.pathToSchema.set(t.path,a),a}};function dezerializeRefs(e,t){if("isOptional"in e){const{isOptional:a,...r}=e,n=$t(r,t),i=a?n.optional():n;return t.pathToSchema.set(t.path,i),i}if("isNullable"in e){const{isNullable:a,...r}=e,n=$t(r,t),i=a?n.nullable():n;return t.pathToSchema.set(t.path,i),i}if("defaultValue"in e){const{defaultValue:a,...r}=e,n=$t(r,t).default("bigInt"===e.type?BigInt(a):"date"===e.type?new Date(a):a);return t.pathToSchema.set(t.path,n),n}if("readonly"in e){const{readonly:a,...r}=e,n=$t(r,t),i=a?n.readonly():n;return t.pathToSchema.set(t.path,i),i}if("description"in e&&"string"==typeof e.description){const{description:a,...r}=e,n=$t(r,t).describe(a);return t.pathToSchema.set(t.path,n),n}return _t[e.type](e,t)}function resolvePointer(e,t){return t.split("/").slice(1).reduce(((e,t)=>void 0===e?e:e[t.replace(/~1/g,"/").replace(/~0/g,"~")]),e)}function dezerialize(e,t={}){"path"in t||(t.path="#"),"pathToSchema"in t||(t.pathToSchema=new Map),"$refs"in t||(t.$refs=[]),"originalShape"in t||(t.originalShape=e);const a=t,r=dezerializeRefs(e,a);for(const[e,t]of a.$refs)e._def.getter=()=>{const e=a.pathToSchema.get(t);if(e)return e;const r=dezerialize(resolvePointer(a.originalShape,t),a);return a.pathToSchema.set(t,r),r};return r}function copyObject(e){const t=Array.isArray(e)?[]:{};for(const[a,r]of Object.entries(e))t[a]=r&&"object"==typeof r?copyObject(r):r;return t}const Ot=new Map([["boolean","boolean"],["number","number"],["nan","nan"],["bigInt","bigint"],["string","string"],["date","date"],["undefined","undef"],["void","void"],["null","null"],["array","arrayNonindexKeys"],["object","object"],["enum","enum"],["literal","literal"],["tuple","tuple"],["record","record"],["map","map"],["set","set"],["never","never"],["catch","catch"],["nativeEnum","nativeEnum"]]);function mergeSchema(e,t){if("object"!==e.type)throw console.log("leftItem",e),new Error("Unexpected leftItem of type "+e.type);if("object"!==t.type)throw console.log("rightItem",t),new Error("Unexpected rightItem of type "+t.type);const a=copyObject(e);for(const[e,r]of Object.entries(t))if("type"!==e&&"properties"!==e)if("description"===e)"Modifiers"!==r&&(a[e]=a[e]?a[e]+" and "+r:r);else{if(e in a)throw new Error("Duplicate property "+e+" of value "+JSON.stringify(r)+" and "+JSON.stringify(a[e]));a[e]=r&&"object"==typeof r?copyObject(r):r}for(const[e,r]of Object.entries(t.properties)){if("string"!=typeof a.properties&&e in a.properties)throw new Error("Duplicate property "+e+" of value "+JSON.stringify(r)+" and "+JSON.stringify(a.properties[e]));a.properties[e]=r&&"object"==typeof r?copyObject(r):r}return a}let kt=0;function addModifiers(e,t){if("defaultValue"in e){kt++;for(const a of t)a.$unionGroupID=kt,a.$defaultValue=e.defaultValue}if(e.isNullable&&t.push({type:"null"}),e.isOptional)for(const a of t)"isOptional"in a||(a.isOptional=e.isOptional);if(e.readonly)for(const a of t)"readonly"in a||(a.$readonlyParent=e.readonly);if(e.description)for(const a of t)a.description=a.description?a.description+" and "+e.description:e.description}function getTypesForSchema(e,t){switch(e.type){case"never":return new Set;case"object":{const t=new Set;return t.add(e),t}case"discriminatedUnion":case"union":{let a=[];for(const r of e.options)a=[...a,...getTypesForSchema(r,t)];if("discriminatedUnion"===e.type)for(const t of a)t.$discriminator=e.discriminator;return addModifiers(e,a),new Set(a)}case"intersection":{const a=function flattenIntersection(e,t){const a=[...e],r=[...t],n=[];for(const e of a)for(const t of r)n.push(mergeSchema(e,t));return n}(getTypesForSchema(e.left,t),getTypesForSchema(e.right,t));return addModifiers(e,a),new Set(a)}case"any":case"unknown":return new Set([{type:"boolean"},{type:"number"},{type:"nan"},{type:"bigInt"},{type:"string"},{description:"Email",type:"string",kind:"email"},{description:"URL",type:"string",kind:"url"},{description:"Date",type:"string",kind:"date"},{type:"date"},{type:"undefined"},{type:"null"},{type:"object",properties:{},unknownKeys:"passthrough"},{type:"nativeEnum",values:{type:"union",options:[{description:"Numeric",type:"record",key:{type:"number"},value:{type:"string"}},{description:"String",type:"record",key:{type:"string"},value:{type:"union",options:[{type:"string"},{type:"number"}]}}]}},{type:"array",element:{type:"any"}},{type:"set",value:{type:"any"}},{type:"map",key:{type:"any"},value:{type:"any"}},{type:"never"},{type:"effect",effects:[{name:"regexp",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"blob",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"BooleanObject",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"NumberObject",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"StringObject",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"SpecialRealNumber",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"domexception",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"error",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"filelist",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"file",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"resurrectable",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"blobHTML",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"buffersource",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"dommatrix",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"dompoint",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"domrect",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"errors",type:"refinement"}],inner:{type:"any"}},{description:"JSON Reference",type:"object",properties:{$ref:{type:"string"}}}]);default:if("$ref"in e){return getTypesForSchema(resolveJSONPointer({obj:t,path:e.$ref}),t)}return new Set([e])}}const At={iterate:(e,t)=>(t.format="schema",he.iterate(e,t)),convertFromTypeson(e,t,a,r,n,i){let[s,o]=n??[];if(!i)throw new Error("State object expected for schema");let c=i.schemaContent,l=!1;switch("number"==typeof o&&"union"===s?.type&&(s=s.options[o]),s?.type){case"object":c=s.properties[r],c||(c=s.catchall,l=!0);break;case"array":c=s.element;break;case"set":c=s.value;break;case"effect":c=s.inner;break;case"tuple":c=s.items[Number(r)]??s.rest}if(!c)return{type:e};const u=[...getTypesForSchema(c,i.schemaContent)];for(const[e,r]of u.entries()){let n;"object"===r.type&&(({unknownKeys:n}=r),r.unknownKeys="strict");const s=dezerialize(r,{originalShape:i.schemaContent}).safeParse(a);if("object"===r.type&&(r.unknownKeys=n),s.success){let n=Ot.get(r.type);n||"effect"!==r.type||(n=r.effects[0].name);const s=t.getTypeObject(n);if(s.valueMatch&&s.valueMatch(a))return{type:n,schemaIdx:e,schema:!i.rootUI||i.readonly||1===u.length?r:{type:"union",options:u},mustBeOptional:l}}}return{type:e}},types:()=>he.types(),getTypesAndSchemasForState(e,t,a,r){if(!a)throw new Error("Missing schema object");if("array"===t)return he.getTypesAndSchemasForState(e,t,a,r);const n=[...getTypesForSchema(a,r??a)],i=n.map((({type:e})=>e));return{schemaObjects:n,types:i.map(((e,t)=>"effect"===e?n[t].effects[0].name:Ot.get(e)))}}};class Formats{constructor(){this.availableFormats={indexedDBKey:fe,json:ye,schema:At,structuredCloning:he}}async getControlsForFormatAndValue(e,t,a,r){return await this.availableFormats[t].iterate(a,{...r,types:e,formats:this,format:t})}getTypesAndSchemasForFormatAndState(e,t,a,r,n){return this.availableFormats[t].getTypesAndSchemasForState(e,a,r,n)}getAvailableFormat(e){return this.availableFormats[e]}}const Ct={option:["Null"],stringRegex:/^null$/u,valueMatch:e=>null===e,toValue:()=>({value:null}),getValue:()=>null,getInput:({root:e})=>$e(e,"input"),viewUI:({specificSchemaObject:e})=>["i",{dataset:{type:"null"},title:e?.description??"(a `null`)"},["null"]],editUI:({typeNamespace:e,specificSchemaObject:t})=>["div",{dataset:{type:"null"},title:t?.description??"Null"},[["label",["Null",["input",{type:"checkbox",name:`${e}-null`,checked:!0,disabled:!0}]]]]]},jt={option:["Boolean (true)",{value:"true"}],stringRegex:/^true$/u,toValue:()=>({value:!0}),valueMatch:e=>!0===e,superType:"boolean",getValue:()=>!0,viewUI:()=>["i",{dataset:{type:"true"}},["true"]],ct:0,getInput:({root:e})=>$e(e,"input"),editUI({typeNamespace:e}){return this.ct++,["div",{dataset:{type:"true"}},[["label",["True",["input",{type:"radio",name:`${e}-true${this.ct}`,value:"true",checked:!0}]]],["label",["False",["input",{type:"radio",name:`${e}-true${this.ct}`,value:"false",disabled:!0}]]]]]}},Rt={option:["Boolean (false)",{value:"false"}],stringRegex:/^false$/u,toValue:()=>({value:!1}),valueMatch:e=>!1===e,superType:"boolean",getValue:()=>!1,viewUI:()=>["i",{dataset:{type:"false"}},["false"]],ct:0,getInput:({root:e})=>$e(e,"input[value=false]"),editUI({typeNamespace:e}){return this.ct++,["div",{dataset:{type:"false"}},[["label",["True",["input",{type:"radio",name:`${e}-false${this.ct}`,value:"true",disabled:!0}]]],["label",["False",["input",{type:"radio",name:`${e}-false${this.ct}`,value:"false",checked:!0}]]]]]}},Zt={option:["NaN"],stringRegex:/^NaN$/u,valueMatch:e=>Number.isNaN(e),toValue:()=>({value:Number.NaN}),getValue:()=>Number.NaN,getInput:({root:e})=>$e(e,"input"),viewUI:({specificSchemaObject:e})=>["i",{dataset:{type:"nan"},title:e?.description??"(a `NaN`)"},["NaN"]],editUI:({typeNamespace:e,specificSchemaObject:t})=>["div",{dataset:{type:"nan"},title:t?.description??"NaN"},[["label",["NaN",["input",{type:"checkbox",name:`${e}-nan`,checked:!0}]]]]]},Vt={option:["Blob (text/html)"],stringRegex:/^data:text\/html(?:;base64)?,.*$/u,valueMatch:e=>e&&"text/html"===e.type,superType:"blob",toValue:e=>({value:function dataURIToBlob(e){const[t,a]=e.split(","),[r,n]=t.split(":")[1].split(";");let i;if("base64"===n){const e=atob(a);i=new ArrayBuffer(e.length);const t=new Uint8Array(i);for(let a=0;a<e.length;a++)t[a]=e.charCodeAt(a)}else i=a;return new Blob([i],{type:r})}(e)}),getInput:({root:e})=>$e(e,"textarea[name$=-blobHTML]"),getValue({root:e}){return this.toValue("data:text/html,"+this.getInput({root:e}).sceditorInstance.val()).value},loadBlob:async e=>await e.text(),async setValue({root:e,value:t}){const a=await this.loadBlob(t);this.getInput({root:e}).sceditorInstance.val(a)},viewUI({value:e,specificSchemaObject:t}){let a;const r=c("div",{dataset:{type:"blobHTML"},title:t?.description?"HTML":void 0},[t?.description??"HTML",": ",["button",{$on:{click(){pe.alert({message:["div",["Source: ",["textarea",{class:"view-source"},[a]]]]})}}},["View source"]]]);return this.loadBlob(e).then((e=>{a=e,c("iframe",{sandbox:"",srcdoc:a},r)})).catch((e=>{console.error("Err",e)})),[r]},editUI({typeNamespace:e,specificSchemaObject:t,value:a}){const r=c("textarea",{name:`${e}-blobHTML`});r.sceditorInstance={val(){throw new Error("Not yet instantiated")}};const n=c("div",{dataset:{type:"blobHTML"},title:t?.description??"Blob (HTML)"},[r]);return setTimeout((()=>{sceditor.create(r,{width:"1000px",height:"225px",autoUpdate:!0,resizeMaxHeight:-1,resizeMaxWidth:-1,plugins:"xhtml,plaintext,undo",emoticonsRoot:"node_modules/sceditor/",style:"node_modules/sceditor/minified/themes/content/default.min.css"}),r.sceditorInstance=sceditor.instance(r),null!=a&&this.setValue({root:n,value:a})})),[n]}},Mt={option:["Boolean",{value:"boolean"}],stringRegex:/^(?:true|false)$/u,valueMatch:e=>"boolean"==typeof e,toValue:e=>({value:"true"===e}),getValue({root:e}){return this.getInput({root:e}).checked},getInput:({root:e})=>$e(e,"input[value=true]"),setValue({root:e,value:t}){$e(e,t?"input[value=true]":"input[value=false]").checked=!0},viewUI:({value:e,specificSchemaObject:t})=>["i",{dataset:{type:"boolean"},title:t?.description??"(a boolean)"},[e?"true":"false"]],ct:0,editUI({typeNamespace:e,specificSchemaObject:t,value:a}){this.ct++;const r="literal"===t?.type,n=r?t?.value:a??t?.defaultValue;return["div",{dataset:{type:"boolean"},title:t?.description??"Boolean"},[["label",["True",["input",{disabled:r,type:"radio",name:`${e}-boolean${this.ct}`,value:"true",checked:"boolean"!=typeof n||n}]]],["label",["False",["input",{disabled:r,type:"radio",name:`${e}-boolean${this.ct}`,value:"false",checked:"boolean"==typeof n&&!n}]]]]]}},Pt={option:["Number"],stringRegex:new RegExp("^[-+]?"+String.raw`(?:[0-9]{0,30}\.)?`+"[0-9]{1,30}(?:[Ee][-+]?[1-2]?[0-9])?$","u"),valueMatch:e=>"number"==typeof e&&!Number.isNaN(e)&&e!==Number.POSITIVE_INFINITY&&e!==Number.NEGATIVE_INFINITY&&!Object.is(e,-0),toValue:e=>({value:Number(e)}),getInput:({root:e})=>$e(e,"input"),setValue({root:e,value:t}){this.getInput({root:e}).value=String(t)},validate({root:e}){const t=this.getInput({root:e}).value;return{message:"Not a valid (finite) number",valid:Boolean(t&&/^-?(\d+|\d*\.\d+)$/u.test(t))}},getValue({root:e}){return Number.parseFloat(this.getInput({root:e}).value)},viewUI:({value:e,specificSchemaObject:t})=>["i",{dataset:{type:"number"},title:t?.description??"(a number)"},[String(e)]],editUI({typeNamespace:e,specificSchemaObject:t,value:a}){const r="literal"===t?.type,n=t,i=150*Number.EPSILON,s=300*Number.EPSILON;return["div",{dataset:{type:"number"},title:t?.description??"Number"},[["input",{disabled:r,name:`${e}-number`,type:"number",min:n?.min?n?.minInclusive?n?.min:n?.min+(n?.int?1:i):void 0,max:n?.max?n?.maxInclusive?n?.max:n?.max-(n?.int?1:s):void 0,step:n?.multipleOf??(n?.int?"1":"any"),value:r?t?.value:a??t?.defaultValue??""}]]]}},Ut={option:["BigInt"],stringRegex:new RegExp("^-?[0-9]{1,}n$","u"),valueMatch:e=>"bigint"==typeof e,toValue:e=>({value:BigInt(e.slice(0,-1))}),getInput:({root:e})=>$e(e,"input"),setValue({root:e,value:t}){this.getInput({root:e}).value=String(t)},validate({root:e}){const t=this.getInput({root:e}).value;return{message:"Not a valid BigInt",valid:Boolean(t&&/^-?(\d+)$/u.test(t))}},getValue({root:e}){return BigInt(this.getInput({root:e}).value)},viewUI:({value:e,specificSchemaObject:t})=>["i",{dataset:{type:"bigint"},title:t?.description??"(a BigInt)"},[`${String(e)}n`]],editUI({typeNamespace:e,specificSchemaObject:t,value:a}){const r=t;return["div",{dataset:{type:"bigint"},title:t?.description??"BigInt"},[["input",{name:`${e}-bigint`,type:"number",value:a??t?.defaultValue??"",min:r?.min?r?.minInclusive?r?.min:String(BigInt(r?.min)+1n):void 0,max:r?.max?r?.maxInclusive?r?.max:String(BigInt(r?.max)-1n):void 0,step:r?.multipleOf??"1"}]]]}},Bt={option:["BigInt Object"],stringRegex:new RegExp("^BigIntObject-?[0-9]{1,}n$","u"),valueMatch:e=>"object"==typeof e&&hasConstructorOf(e,BigInt),toValue:e=>({value:new Object(BigInt(e.slice(12,-1)))}),getInput:({root:e})=>$e(e,"input"),setValue({root:e,value:t}){this.getInput({root:e}).value=String(t)},validate({root:e}){const t=this.getInput({root:e}).value;return{message:"Not a valid BigInt",valid:Boolean(t&&/^-?(\d+)$/u.test(t))}},getValue({root:e}){return new Object(BigInt(this.getInput({root:e}).value))},viewUI:({value:e,specificSchemaObject:t})=>["i",{dataset:{type:"bigintObject"},title:t?.description??"(a BigInt Object)"},[`${String(e)}n`]],editUI:({typeNamespace:e,specificSchemaObject:t,value:a=""})=>["div",{dataset:{type:"bigintObject"},title:t?.description??"BigInt object"},[["input",{name:`${e}-bigintObject`,type:"number",step:"1",value:a}]]]},Dt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/u,Lt=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/u,Ft=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/u,zt=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u"),Kt=/^c[^\s-]{8,}$/iu,Wt=/^[0-9a-z]+$/u,Jt=/^[0-9A-HJKMNP-TV-Z]{26}$/iu,Ht=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/iu,qt=/^[a-z0-9_-]{21}$/iu,Yt=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/u;const Gt={option:["String"],stringRegex:/^"(?:[^\\"]|\\\\|\\")*"$/u,valueMatch:e=>"string"==typeof e,toValue:e=>({value:e.slice(1,-1)}),getInput:({root:e})=>$e(e,'[data-type="string"] > textarea,input'),setValue({root:e,value:t}){this.getInput({root:e}).value=t},getValue({root:e}){return this.getInput({root:e}).value},viewUI({value:e,specificSchemaObject:t}){const a=t?.kind;return["span",{dataset:{type:"string"},title:t?.description??("email"===a?`(an ${a} string)`:a?`(a ${a} string)`:"(a string)")},[e]]},editUI({typeNamespace:e,specificSchemaObject:t,value:a}){const r=t,n=r?.kind,i="literal"===t?.type,s=r?.min??r?.length,o=r?.max??r?.length,c=r?.startsWith,l=r?.endsWith,u=r?.toLowerCase,d=r?.toUpperCase,p=r?.trim,m=r?.includes,y=r?.position,h=r?.regex,f=r?.flags,checkValue=e=>{if(c&&!e.startsWith(c))return`Value doesn't start with expected: ${c}`;if(l&&!e.endsWith(l))return`Value doesn't end with expected: ${l}`;if(m&&!e.includes(m,y??0))return`Value doesn't include the expected: ${m}${y?` after position: ${y}`:""}`;if(h&&!new RegExp(h,f??"").test(e))return`Value doesn't match regular expression: ${h}${f?` with flags: ${f}`:""}`;if(n)switch(n){case"ip":if("v4"===r?.version){if(!Dt.test(e))return"Value doesn't match IP v4 pattern."}else if(!Lt.test(e))return"Value doesn't match IP v6 pattern.";break;case"time":if(!function timeRegex(e){return new RegExp(`^${function timeRegexSource(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:null!==e.precision&&void 0!==e.precision||(t=`${t}(\\.\\d+)?`),t}(e)}$`,"u")}(r).test(e))return"Value does not match time/precision.";break;case"datetime":if(!datetimeRegex(r).test(e))return"Value does not match datetime/precision/offset/local";break;case"emoji":if(!zt.test(e))return"Value does not match emoji pattern";break;case"uuid":if(!Ht.test(e))return"Value does not match uuid pattern";break;case"nanoid":if(!qt.test(e))return"Value does not match nanoid pattern";break;case"cuid":if(!Kt.test(e))return"Value does not match cuid pattern";break;case"cuid2":if(!Wt.test(e))return"Value does not match cuid2 pattern";break;case"ulid":if(!Jt.test(e))return"Value does not match ulid pattern";break;case"duration":if(!Yt.test(e))return"Value does not match duration pattern";break;case"base64":if(!Ft.test(e))return"Value does not match base64 pattern"}return null},transform=e=>(u&&(e=e.toLowerCase()),d&&(e=e.toUpperCase()),p&&(e=e.trim()),e);return["div",{dataset:{type:"string"},title:t?.description??"String"},[["email","url","date"].includes(n)?["input",{$on:{change(){const e=this;e.value=transform(e.value);const t=checkValue(e.value);e.setCustomValidity(t??""),e.reportValidity()}},name:`${e}-string`,type:n,value:a??t?.defaultValue??"",minlength:"date"===n?void 0:s,maxlength:"date"===n?void 0:o}]:["textarea",{$on:{change(){const e=this;e.value=transform(e.value);const t=checkValue(e.value);e.setCustomValidity(t??""),e.reportValidity()}},name:`${e}-string`,disabled:i,minlength:s,maxlength:o},[i?t?.value:a??t?.defaultValue??""]]]]}},Xt={option:["Array reference"],type:"array",stringRegex:/^arrayRef\((?:|\/[^)]*)\)$/u,toValue(e,t){const{rootHolder:a,parent:r,parentPath:n}=t,i=e.slice(`${this.type}Ref(`.length,-1);return a.push([this.type,r,n,i]),{assign:!1}},resolveReference(e,t){let a=t;return""!==e&&getJSONPointerParts(e).forEach((e=>{if(a=a[e],!a)throw new Error("Bad path")})),a},stateDependent:{structuredCloning:{after:"arrayNonindexKeys",contexts:["arrayNonindexKeys","object","set"]}},getInput:({root:e})=>$e(e,"input"),setValue({root:e,value:t}){this.getInput({root:e}).value=t},getValue({root:e,stateObj:t,currentPath:a}){const r=this.getInput({root:e}).value;t&&(t.paths||(t.paths={}),t.paths[a]={referentPath:r,expectArrayReferent:"array"===this.type},t.handlingReference=!0),console.log(r)},validate({root:e,topRoot:t}){const{type:a}=this,r=this.getInput({root:e}),n=r.value,invalidMessage=e=>({valid:!1,message:e});if(r.validity.patternMismatch)return invalidMessage('You must use a path beginning with "/" (or the empty string)');if(/~([^01]|$)/u.test(n))return invalidMessage("You must use a valid JSON Pointer (with tildes followed by 0 or 1)");let i=t||e;let s;if(""!==n&&getJSONPointerParts(n).some(((t,a)=>{const r=DOM_filterChildElements($e(i,".arrayItems"),["fieldset","legend"]),n=r.map((e=>getPropertyValueFromLegend(e))).indexOf(t);return-1===n?(s="Specified path doesn't exist",!0):(i=$e(r[n].parentElement,"div[data-type]"),i===e?(s="Can't reference self",!0):!["array","object","arrayNonindexKeys"].includes(Types.getTypeForRoot(i))&&(s=`Referent portion (at segment ${a}) is not an object or array`,!0))})))return invalidMessage(s);const o=Types.getTypeForRoot(i);return(["array","arrayNonindexKeys"].includes(o)?"array":"object"===o?"object":null)!==a?invalidMessage("Reference must match expected reference type (array or object)"):{valid:!0}},validateAll({types:e,topRoot:t}){const a=`${this.type}Reference`;$$e(t,`div[data-type="${a}"]`).forEach((r=>{e.validate({type:a,root:r,topRoot:t})}))},viewUI({value:e}){return["i",{dataset:{type:`${this.type}Reference`}},[`${this.type}Ref(${e})`]]},editUI({typeNamespace:e,value:t=""}){const{type:a}=this;return["div",{dataset:{type:`${a}Reference`}},[["label",[`JSON Pointer path to ${a} (leave blank for path to root) `,["input",{name:`${e}-${a}Reference`,type:"text",pattern:"^(|/.*)$",value:t}]]]]]}},Qt={option:["Object reference"],type:"object",stringRegex:/^objectRef\((?:|\/[^)]*)\)$/u,toValue(...e){return Xt.toValue.apply(this,e)},resolveReference(...e){return Xt.resolveReference?.apply(this,e)},stateDependent:{structuredCloning:{after:"object",contexts:["arrayNonindexKeys","object","set"]}},getInput(...e){return Xt.getInput.apply(this,e)},setValue(...e){return Xt.setValue?.apply(this,e)},getValue(...e){return Xt.getValue.apply(this,e)},validate(...e){return Xt.validate?.apply(this,e)},validateAll(...e){return Xt.validateAll?.apply(this,e)},viewUI(...e){return Xt.viewUI.apply(this,e)},editUI(...e){return Xt.editUI.apply(this,e)}};class FileList{constructor(){this._files=arguments[0],this.length=this._files.length}item(e){return this._files[e]}get[Symbol.toStringTag](){return"FileList"}}let ea=0;const ta={option:["Array"],array:!0,regexEndings:[",","]"],stringRegexBegin:/^\[/u,stringRegexEnd:/^\]/u,valueMatch:e=>Array.isArray(e),toValue(e,t){const{endMatchTypeObjs:a=[],remnant:r,rootHolder:n,schemaObject:i}=t,s=t.format,o=t.types,{sparse:c}=this,l=c?"arrayNonindexKeys":this.array&&!this.record?"array":"object",u=this.array&&!this.record?[]:{};let d=void 0!==r?r:e;const checkEnd=e=>{if(e&&a.length){const e=d.match(a.at(-1).stringRegexEnd);if(e)return a.pop(),d=d.slice(e[0].length),!0}return!1};if(this.array&&!this.record){let e=0;const parse=()=>{if(!d)return;const t=d.match(c?/^[,\s]+/u:/^\s*,?\s*/u);if(t){const a=t[0].match(/\s/gu);if(e+=t[0].length-(a?a.length:0),d=d.slice(t[0].length),!d)return}let r,p,m;try{[r,d,p,m]=o.getValueForString(d,{firstRun:!1,format:s,state:l,schemaObject:i,endMatchTypeObjs:a,rootHolder:n,parent:u,parentPath:e})}catch(e){return void console.log("e",e)}m&&(u[e]=r),checkEnd(p)||parse()};return parse(),c&&e&&e>u.length-1&&(u.length=e+1),{value:this.set&&Array.isArray(u)?new Set(u):this.map?new Map(u):this.filelist?new FileList(u):u,remnant:d}}const parse=e=>{if(!d)return;e&&","===d[0]&&(d=d.slice(1));const t=d.match(/^\s*(?:([^:"}]+)|"((?:[^\\"]|\\\\|\\")*)")(\s*:\s*)/u);if(!t)return;const[,r,c]=t,p=void 0!==r?r:c;let m,y,h;d=d.slice(t[0].length);try{[m,d,y,h]=o.getValueForString(d,{firstRun:!1,format:s,state:l,schemaObject:i,endMatchTypeObjs:a,rootHolder:n,parent:u,parentPath:p})}catch{return}h&&(u[p]=m),checkEnd(y)||parse(!0)};return parse(),{value:u,remnant:d}},getValue({root:e,stateObj:t,currentPath:a=""}){if(!t)throw new Error("TS guard");const r=t.types,n=""===a,i=$e(e,".arrayItems"),s=[...i.children],o="object"===e.dataset.type?{}:this.sparse?Array.from({length:Number.parseInt(DOM_filterChildElements(e,["div","div","label","input"])[0].value)}):[];return s.forEach((e=>{const n=e.firstElementChild,i=getPropertyValueFromLegend(n),s=DOM_filterChildElements(e,[".typeContainer","div[data-type]"])[0]||DOM_filterChildElements(e,["[class^=optionalProperties-placeholder]",".typeContainer","div[data-type]"])[0];if(!s)return;const c=DOM_filterChildElements(n,["input"]),[l,u]=((e,n)=>{const i=r.getValueForRoot(e,t,a+"/"+n);return"handlingReference"in t&&t.handlingReference?(t.handlingReference=!1,[!1]):[!0,i]})(s,i);l&&(c.length?o[i]=u:o.push(u))})),n&&Object.entries(t.paths||[]).forEach((([e,{referentPath:t}])=>{const a=""===t?o:resolveJSONPointer({path:t,obj:o}),r=getJSONPointerParts(e),n=r.pop();r.reduce(((e,t)=>reduceJSONPointerParts(e,t)),o)[n]=a})),this.filelist?new FileList(o):this.set&&Array.isArray(o)?new Set(o):this.map?new Map(i.$getMapKeySelects().map(((e,t)=>[e.$getValue(),o[t]]))):this.record?i.$getMapKeySelects().reduce(((e,t,a)=>{const r=t.$getValue(),n=o[a];return e[r]=n,e}),{}):o},viewUI({typeNamespace:e,type:t,types:a,value:r,topRoot:n,resultType:i,format:s,specificSchemaObject:o}){let l=-1;const u=t,buildLegend=({itemIndex:e,typeNamespace:a,propName:r})=>{const n=o?.items?.[e],i=o?.rest;return["legend",[this.array&&"record"!==t?o?.element?.description??("set"===t&&o?.value?.description?o?.value?.description:n?.description??i?.description)??"Item":o?"":"Property",o?"":":",d.repeat(2),["span",{class:`propertyName-${a}`,title:"record"===t&&o?.key?.description?o?.key?.description:o?r:void 0},[void 0!==r?o?.properties?.[r]?.description??r:e]]]]},p=c("div",{class:"arrayHolder",dataset:{type:t},$custom:{$addAndSetArrayElement({propName:t,type:r,value:l,bringIntoFocus:d,schemaContent:p}){if("map"===u){const u=a.getUIForModeAndType({resultType:i,readonly:!0,typeNamespace:e,type:r,topRoot:n,bringIntoFocus:d,format:s,schemaContent:p,value:l,hasValue:!0});if("0"===t){const e=this.$addMapElement();this._lastFieldset=e;const t=c("fieldset",[["legend",{title:o?.key?.description?"(map key)":void 0},[o?.key?.description??"Key"]]],e);c(u,t)}else{const e=c("fieldset",[["legend",{title:o?.value?.description?"(map value)":void 0},[o?.value?.description??"Value"]]],this._lastFieldset);this._lastFieldset=null,c(u,e)}return u}const m=this.$addArrayElement({propName:t}),y=a.getUIForModeAndType({resultType:i,readonly:!0,typeNamespace:e,type:r,topRoot:n,bringIntoFocus:d,format:s,schemaContent:p,specificSchemaObject:p,value:l,hasValue:!0});return c(y,m),y},$addMapElement(){l++;const t=this.$getArrayItems();return c("fieldset",[buildLegend({itemIndex:l,typeNamespace:e,propName:void 0})],t)},$addArrayElement({propName:t}){l++;const a=this.$getArrayItems();return c("fieldset",[buildLegend({itemIndex:l,typeNamespace:e,propName:t})],a)},$getArrayItems(){return this.lastElementChild.lastElementChild}}},[["span",{title:o?.description},[o?"—":DOM_initialCaps(t).replace(/s$/u,"")]],d.repeat(2),["button",{$on:{click(e){e.preventDefault();const{target:t}=e,a=$e(t.closest(".arrayHolder"),".arrayContents");a.hidden=!a.hidden,t.textContent=a.hidden?"+":"-"}}},["-"]],["div",{class:"arrayContents"},[this.array&&"record"!==t?["div",{title:o?"filelist"===t?"(a FileList)":"set"===t?"(a Set)":"map"===t?"(a Map)":"tuple"===t?"(a tuple)":"(an Array)":void 0},["filelist"===t?(o?.description??"FileList")+" length: ":"set"===t?(o?.description??"Set")+" size: ":"map"===t?(o?.description??"Map")+" size: ":(o?.description??"Array")+" length: ",["span",[(!r||"set"!==t&&"map"!==t?r.length:r.size)||0]]]]:"record"===t?o?.description??"Record":"",["div",{class:"arrayItems"}]]]]);return[p]},getInput:({root:e})=>$e(e,"button"),editUI({typeNamespace:e,buildTypeChoices:t,format:a,formats:r,types:n,specificSchemaObject:i,schemaFallingBack:s,schemaContent:o,type:l,forcedState:u,topRoot:p,value:m,bringIntoFocus:y=!0}){const{sparse:h}=this,f=this,g="object"===l?1:0;let v=g-1;const b="array"!==l&&"set"!==l&&"map"!==l&&"filelist"!==l&&"tuple"!==l&&"record"!==l,w="map"===l||"record"===l,x=i?.element?.description??("set"===l?i?.value?.description:void 0),bringFocus=(e,t)=>{(y||t)&&(e.scrollIntoView(),e.focus())},$validateLegend=function(){const e=this.$arrayItems.$getPropertyInputs(),t=e.some((e=>this!==e&&e.value===this.value))?"Duplicate property name":"";t&&(this.setCustomValidity(t),this.reportValidity()),e.some(((e,t,a)=>{const r=a.some((t=>e!==t&&e.value===t.value))?"Duplicate property name":"";return(e.validity.valid||"Invalid length"!==e.validationMessage)&&(e.setCustomValidity(r),r&&e.reportValidity()),r}))},buildLegend=({className:e,splice:r,itemIndex:s,typeNamespace:u,arrayItems:m,propName:y,required:g,schema:v})=>{const $validateLength=async function(e){if(!h)return;const t=m.$inputsExceedingLength(),a=t.length;if(e||!a||!/^\d+$/u.test(this.value))return;await pe.confirm({message:'You are attempting to add an (integer-based) array item beyond the length. Click "Ok" to allow to permit and extend the array length or "Cancel" otherwise.'});const r=$e(m.previousElementSibling,"input"),n=t.map((e=>Number.parseInt(e.value))).sort().at(-1);r.value=String(n+1),r.$oldvalue=String(n+1),this.$validateLength(!0)};if(w){const r=t({value:void 0!==y&&"record"===l?y:void 0,setValue:void 0!==y&&"record"===l,autoTrigger:void 0===y||"record"===l,format:a,schemaOriginal:o,schemaContent:i?.key,typeNamespace:"key-type-choices-only"});return["legend",[["span",{class:"mapKey",title:"map"===l&&i?.key?.description?"(map key)":"record"===l&&i?.key?.description?"(record key)":void 0},["map"===l?i?.key?.description??"Map key":i?.key?.description??"Record key"," "]],["span",{dataset:{prop:"true"},className:e},[String(s)]],":",d.repeat(2),["span",{class:"mapKeyHolder",$on:{change:[function(){this.$validateMapKey(),n.validateAllReferences({topRoot:p})},!0]},$custom:{$validateMapKey(){const e=m.$getMapKeySelects();setTimeout((()=>{const t=e.map((e=>e.$getValue())),a=t.findLastIndex(((e,a)=>t.some(((t,r)=>a!==r&&function sameValueZero(e,t){return"number"==typeof e&&"number"==typeof t?e===t||e!=e&&t!=t:e===t}(e,t)))));if(-1===a)return;const r=e[a];if(!r)return;const n=r.hidden?$e(r.nextElementSibling,"input,textarea"):r;n.setCustomValidity(`Duplicate ${"map"===l?"Map":"Record"} key value`),n.reportValidity()}))}}},r.domArray]]]}if(b){const t=i?.properties?.[y]?.description,a=Object.entries(i?.properties??{}).map((([e,t])=>t.isOptional?e:null)).filter(Boolean);ea++;const o=h?"append"===r?"":void 0!==y?y:s:y||"";return["legend",[h?x??"Item":{"#":g?[["b",{className:e,title:x??t?y:void 0},[x??t??y]]]:[["span",{className:`${e}_propertyHolder${ea}`},[...i&&y?[["b",[i?.properties?.[y]?i?.properties?.[y]?.description??y:i?.catchall?.description??y]]]:["Property ",["span",{className:e},[String(s)]],":"]]]]},d.repeat(2),i&&!g?["datalist",{id:`optionalProperties_${ea}`},a.map((e=>["option",{value:e}]))]:"",["input",{list:i&&!g?`optionalProperties_${ea}`:void 0,style:{display:g&&"arrayNonindexKeys"!==l?"none":"block"},disabled:g&&"arrayNonindexKeys"===l,value:o,dataset:{prop:!0,object:!0,optionalPropertyId:ea},$custom:{async $validate(){try{try{await this.$validateLength()}catch{}this.$validateLegend(),n.validateAllReferences({topRoot:p})}catch{}},$parseInt(){return!!/^\d+$/u.test(this.value)&&Number.parseInt(this.value)},$validateLegend:$validateLegend,$arrayItems:m,$validateLength:$validateLength,$resort({alwaysFocus:e}){const t=this.$arrayItems.$getPropertyInputs();if(1===t.length)return;const getFieldset=e=>e.closest("fieldset"),a=getFieldset(this),r=this.$parseInt();if(!1===r)return void t.reverse().some((t=>{if(t===this)return!0;return"number"==typeof t.$parseInt()&&(getFieldset(t).after(a),bringFocus(this,e),m.$redrawMoveArrows(),!0)}));const getNearest=n=>{let i;if(t.some((e=>{if(e===this)return!1;const t=e.$parseInt();if("number"!=typeof t)return i||(i=e),!1;const cmp=(e,t)=>n?e>t:e<t;return!(!cmp(r,t)||i&&!cmp(t,Number.parseInt(i.value)))&&(i=e,r+(n?-1:1)===t)})),!i)return!1;const s=n?"after":"before";return setTimeout((()=>{i&&(getFieldset(i)[s](a),bringFocus(this,e),m.$redrawMoveArrows())})),!0};getNearest()||getNearest(!0)}},$on:{input(){if(!i&&!v)return;const t=$e(m,`.${e}_propertyHolder${this.dataset.optionalPropertyId}`);DOM_removeChildren(t),c("b",[i?.properties?.[this.value]?i?.properties?.[this.value]?.description??this.value:i?.catchall?.description??this.value],t)},change(e){let t=!1;if("never"===i?.properties?.[this.value]?.type)this.setCustomValidity("Never value"),this.reportValidity(),this.style.backgroundColor="pink",t=!0;else if(this.list&&!f.array){if([...this.list.options].map((({value:e})=>e)).includes(this.value)||"strict"!==i.unknownKeys){this.style.backgroundColor="revert-layer",this.setCustomValidity(""),this.reportValidity();const{optionalPropertyId:e}=this.dataset;let t=$e(m,`.optionalProperties-placeholder${e}`);t||(t=$e(this.parentElement?.parentElement,".property-placeholder")?.previousElementSibling,t.previousElementSibling?.remove()),t.replaceWith(c("div",{className:`optionalProperties-placeholder${e}`},[...buildTypeChoicesForProperty({propName:this.value,schema:i?.properties?.[this.value]??i?.catchall??{type:"any"}})]))}else this.setCustomValidity("Bad value"),this.reportValidity(),this.style.backgroundColor="pink",t=!0}if(t){const e=$e(m,`.optionalProperties-placeholder${ea}`);DOM_removeChildren(e)}else this.$validate();e.stopPropagation(),this.$resort({alwaysFocus:!0})}},class:`propertyName-${u}`}]]]}const S=i?.inner?.description;return["legend",[x?"":S?`${S} `:v?.description?`${v?.description} `:"tuple"===l&&i?.rest?.description?`${i?.rest?.description} `:"Item ",["span",{dataset:{prop:!0,array:!0},className:e},[x?`${x} ${s+1}`:void 0!==y?y:String(s)]]]]},decrementItemIndex=e=>{h?v=e.$getPropertyInputs().reduce(((e,t)=>{const a=t.$parseInt();return!1!==a&&a>e?a:e}),-1):v--},buildTypeChoicesForProperty=({propName:r,schema:n,schemaIdx:s,autoTrigger:c})=>t({autoTrigger:c,topRoot:p,format:a,schemaOriginal:o,schemaIdx:s,schemaContent:n||"tuple"===l?n??i.rest:w||"set"===l?i?.value:"filelist"===l?i?.inner:"array"===l||"arrayNonindexKeys"===l?i?.element:i?.properties?.[r],state:f.filelist?"filelistArray":u??l,typeNamespace:e}).domArray;function preventAdding(e=0){switch(l){case"tuple":if("never"===i?.rest?.type)return pe.alert('Tuple has rest type "never", so one cannot add to it.'),!0;if("never"===i?.items?.[0]?.type)return pe.alert('Tuple has items type "never", so one cannot add to it.'),!0;break;case"set":{if("never"===i?.value?.type)return pe.alert('Set has type "never", so one cannot add to it.'),!0;const{maxSize:t}=i??{};if(void 0!==t&&[...T.children].length+e>t)return pe.alert("You cannot add beyond the `maxSize` of the Set"),!0;break}case"array":case"arrayNonindexKeys":{if("never"===i?.element?.type)return pe.alert('Array has type "never", so one cannot add to it.'),!0;const{maxLength:t}=i??{};if(void 0!==t&&T.$getArrayLength()+e>t)return pe.alert("You cannot add beyond the `maxLength` of the array"),!0;break}}return!1}const S=["button",{class:"addArrayElement",$custom:{$addArrayElement:function({propName:t,splice:a,alwaysFocus:s,required:o,schema:u,schemaIdx:m,autoTrigger:y}){const w=this.$getArrayItems();if(h)if(t){const e=t.match(/^\d+$/u)&&Number.parseInt(t);"number"==typeof e&&(v=e)}else"number"==typeof a?v=a+1:"string"!=typeof a&&(v=w.$getPropertyInputs().reduce(((e,t)=>{const a=t.$parseInt();return!1!==a&&a>e?a:e}),-1)+1);else v++;const S=this,I=`${l}Item`,T=c("fieldset",{dataset:o?{required:"required"}:{},$on:{change:[()=>{"set"===l&&setTimeout((()=>{const e=O,t=f.getValue.call({...f,set:!1},{root:e,stateObj:{types:n,formats:r}}),a=t.findLastIndex(((e,a)=>t.some(((t,r)=>a!==r&&e===t))));if(-1===a)return;const i=[...w.children].map((e=>{const t=$e(e,"div[data-type]");return t?n.getFormControlForRoot(t):null})),s=i[a];s&&(s.setCustomValidity("Duplicate Set value"),s.reportValidity())}))},!0]},$custom:{$getPropertyInput(){return DOM_filterChildElements(this,["legend",`input.propertyName-${e}`]).pop()}}},[buildLegend({className:I,splice:a,itemIndex:v,typeNamespace:e,arrayItems:w,propName:t,required:o,schema:u})],w);if(c({"#":[["span",{class:"mapValue",title:"map"===l&&i?.value?.description?"(map value)":"record"===l&&i?.value?.description?"(record value)":void 0},["map"===l?i?.value?.description??"Map value":"record"===l?i?.value?.description??"Record value":""," "]],...!i||t||f.array?buildTypeChoicesForProperty({propName:t,schema:u,schemaIdx:m,autoTrigger:y}):[c("span",{className:`optionalProperties-placeholder${ea}`})],["span",{className:"property-placeholder"}],d.repeat(2),["button",{disabled:"tuple"===l&&o&&i?.items?.length-1>v,$on:{click(e){if(e.preventDefault(),preventAdding(1))return;let t;if(h){const e=T.$getPropertyInput().$parseInt();t=!1===e?"append":e}S.$addArrayElement({splice:t,alwaysFocus:!0,schema:u});const a=w.lastElementChild;if(T.after(a),h||(i||u)&&!f.array){const e=a.$getPropertyInput();bringFocus(e,!0)}else DOM_filterChildElements(w,["fieldset","legend","."+I]).forEach(((e,t)=>{e.textContent=x?`${x} ${t+g+1}`:String(t+g)}));n.validateAllReferences({topRoot:p}),w.$redrawMoveArrows()}}},["+"]],["button",{disabled:o,$on:{click(e){e.preventDefault(),T.remove(),decrementItemIndex(w),h||i&&!f.array||DOM_filterChildElements(w,["fieldset","legend","."+I]).forEach(((e,t)=>{e.textContent=x?`${x} ${t+g+1}`:String(t+g)})),n.validateAllReferences({topRoot:p}),w.$redrawMoveArrows()}}},["x"]],["span",{class:`${l}Item-arrowHolder-${e}`},[]]]},T),b){const e=w.$getPropertyInputs();if(e.length){const t=e.pop();t.$validate(),t.$resort({alwaysFocus:s}),bringFocus(t,s)}}w.$redrawMoveArrows()},$getArrayItems(){return this.previousElementSibling}},$on:{click(){preventAdding(1)||(this.$addArrayElement({alwaysFocus:!0}),n.validateAllReferences({topRoot:p}))}}},["+ Item"]],I=h?["div",[["label",["Array length: ",["input",{type:"number",value:m&&m.length||0,step:1,size:4,class:"arrayLength",pattern:String.raw`\d`,$on:{async change(){if(preventAdding())return void(this.value=this.$oldvalue??this.defaultValue);const e=$e(this.closest(".arrayContents"),".arrayItems").$inputsExceedingLength();try{if(e.length)await pe.confirm({message:"Your new length will truncate the array causing items to be removed. Continue?"}),e.forEach((e=>{const t=e.closest("fieldset");if(t.matches("[data-required]")){const e=$e(O,".arrayLength");e.value=String(Number.parseInt(e.value)+1)}else t.remove()})),n.validateAllReferences({topRoot:p});else{const e=i?.element;if(!["void","undefined"].includes(e?.type)&&("union"!==e?.type||e?.options?.every((e=>!["void","undefined"].includes(e.type))))){const e=Number.parseInt(this.value)-Number.parseInt(this.$oldvalue??this.defaultValue);for(let t=0;t<e;t++)setTimeout((()=>{O.$addArrayElement({})}))}}this.$oldvalue=this.value}catch{this.value=this.$oldvalue}}}}]]]]]:"",T=c("div",{class:"arrayItems",$custom:{$swapGroup:function(e,t){const a=e.parentElement,r=a["up"===t?"previousElementSibling":"nextElementSibling"];if(r&&"fieldset"===r.nodeName.toLowerCase()){if(h||i&&!f.array){const e=a.$getPropertyInput(),t=r.$getPropertyInput();if("number"==typeof e.$parseInt()||"number"==typeof t.$parseInt()){const a=e.value,r=t.value;e.value=r,t.value=a}}else{const e=DOM_filterChildElements(r,["legend",`.${l}Item`])[0],t=DOM_filterChildElements(a,["legend",`.${l}Item`])[0],n=e.textContent,i=t.textContent;e.textContent=i,t.textContent=n}"up"===t?r.before(a):a.before(r),n.validateAllReferences({topRoot:p}),this.$redrawMoveArrows()}},$redrawMoveArrows:function(){"tuple"!==l&&DOM_filterChildElements(this,["fieldset",`.${l}Item-arrowHolder-${e}`]).forEach(((e,t,a)=>{DOM_removeChildren(e);let r=!0,n=!0;1!==a.length&&(0===t?r=!1:t===a.length-1&&(n=!1),r&&c("button",{$on:{click:()=>{this.$swapGroup(e,"up")}}},[le],e),n&&c("button",{$on:{click:()=>{this.$swapGroup(e,"down")}}},[ue],e))}))},$getArrayLength:function(){return Number($e(this.previousElementSibling,"input").value)},$inputsExceedingLength:function(){const e=this.$getArrayLength()-1;return this.$getPropertyInputs().filter((e=>e.value.match(/^\d+$/u))).filter((t=>{const a=Number.parseInt(t.value)>e;return t.setCustomValidity(a?"Invalid length":""),t.reportValidity(),a}))},$getMapKeySelects(){return DOM_filterChildElements(this,["fieldset","legend:first-child","span.mapKeyHolder","select.typeChoices-key-type-choices-only"])},$getPropertyInputs(){return DOM_filterChildElements(this,["fieldset","legend",`input.propertyName-${e}`])}}}),E=["button",{$on:{click(e){e.preventDefault();const{target:t}=e,a=$e(O,".arrayContents");a.hidden=!a.hidden,t.textContent=a.hidden?"+":"-"}}},["-"]],N=["div",{class:"arrayContents"},[I,T,S,["button",{$on:{click(){const e=this.closest(".arrayContents"),t=$e(e,".arrayItems"),a=t.lastElementChild;a&&!a.matches("[data-required]")&&(a.remove(),decrementItemIndex(t),$e(e,".arrayItems").$redrawMoveArrows()),n.validateAllReferences({topRoot:p})}}},["- Last item"]],["button",{$on:{click(){const e=this.closest(".arrayContents"),t=$e(e,".arrayItems"),a=$$e(e,".arrayItems > fieldset:not([data-required])");for(const e of a)e.remove();h?decrementItemIndex(t):v=-1,n.validateAllReferences({topRoot:p})}}},["x All"]]]],_=l,O=c("div",{dataset:{type:l},$custom:{$addAndSetArrayElement({propName:e,type:t,value:a,bringIntoFocus:r,setAValue:i,schemaContent:s,schemaIdx:o,mustBeOptional:c}){if("map"===_){if("0"===e){this.$addArrayElement({propName:e,autoTrigger:!1});const n=this.$getArrayItems(),i=DOM_filterChildElements(n,["fieldset:last-of-type","legend",".mapKeyHolder","select"])[0];return i.$setType({type:t,baseValue:a,bringIntoFocus:r,avoidReport:!0}),i.$getTypeRoot()}}else"record"===_?this.$addArrayElement({propName:e,autoTrigger:!1,required:!1}):this.$addArrayElement({propName:e,schema:s,autoTrigger:!1,schemaIdx:o,required:!c&&s&&!s.isOptional&&"never"!==s.type});const l=this.$getTypeChoices();l.$setType({type:t,baseValue:a,bringIntoFocus:r,specificSchema:"union"===s?.type&&void 0!==o?s.options[o]:s,avoidReport:!0});const u=l.$getTypeRoot();if(i){const e=n.getTypeObject(t);e.setValue&&e.setValue({root:u,value:a})}return n.validate({type:t,root:u,topRoot:p,avoidReport:!0}),u},$getAddArrayElement(){const e=this.lastElementChild.firstElementChild.nextElementSibling;return h?e.nextElementSibling:e},$addArrayElement({propName:e,splice:t,alwaysFocus:a,required:r,schema:n,schemaIdx:i,autoTrigger:s}){this.$getAddArrayElement().$addArrayElement({propName:e,splice:t,alwaysFocus:a,required:r,schema:n,schemaIdx:i,autoTrigger:s})},$getArrayItems(){return this.$getAddArrayElement().previousElementSibling},$getTypeChoices(){const t=this.$getArrayItems();return $e(t.lastElementChild,`fieldset > .typeChoices-${e}`)}},$on:{click(e){const t=e,a=t.target;["checkbox","radio","file","datetime-local",void 0].includes(a.type)||t.preventDefault()}}},[[i?"span":"b",{title:i?.description??DOM_initialCaps(l).replace(/s$/u,"")},[i?"—":DOM_initialCaps(l).replace(/s$/u,"")]],d.repeat(2),"filelist"===l?["input",{name:e+"-filelist",multiple:!0,type:"file",$on:{change(){if(this.files)for(let e=0;e<this.files.length;e++){const t=this.files.item(e);O.$addAndSetArrayElement({propName:String(e),type:"file",value:t,bringIntoFocus:!1,setAValue:!0})}}}}]:"",E,N]);if(p=p||O,!m&&i)switch(l){case"object":if(!s)for(const[e,t]of Object.entries(i.properties??{}))t.isOptional||"never"===t.type||O.$addArrayElement({propName:e,required:!0});break;case"tuple":if(!s){const e=i;if("never"!==i?.items?.[0]?.type)for(const t of e.items)O.$addArrayElement({schema:t,required:!0})}break;case"arrayNonindexKeys":{const{minLength:e=0}=i,t=$e(O,".arrayLength");t.value=String(e),t.$oldvalue=String(e);for(let t=0;t<e;t++)O.$addArrayElement({required:!0});break}case"set":if(!s){const{minSize:e=0}=i;for(let t=0;t<e;t++)O.$addArrayElement({required:!0})}}return[O]}},aa={option:["Tuple"],array:!0,regexEndings:[",","]"],stringRegexBegin:/^Tuple\[/u,stringRegexEnd:/^\]/u,tuple:!0,valueMatch:e=>Array.isArray(e),toValue(...e){return ta.toValue.apply(this,e)},getValue(...e){return ta.getValue.apply(this,e)},getInput(...e){return ta.getInput.apply(this,e)},viewUI({...e}){return ta.viewUI.call(this,{...e,type:"tuple"})},editUI({...e}){return ta.editUI.call(this,{...e,type:"tuple"})}},ra={option:["Object"],regexEndings:[",","}"],stringRegexBegin:/^\{/u,stringRegexEnd:/^\}/u,valueMatch:e=>e&&"object"==typeof e&&"Object"===toStringTag(e),toValue(...e){return ta.toValue.apply(this,e)},getValue(...e){return ta.getValue.apply(this,e)},getInput(...e){return ta.getInput.apply(this,e)},viewUI({...e}){return ta.viewUI.call(this,{...e,type:"object"})},editUI({...e}){return ta.editUI.call(this,{...e,type:"object"})}},na={option:["Record"],regexEndings:[",","}"],stringRegexBegin:/^Record\{/u,stringRegexEnd:/^\}/u,array:!0,record:!0,valueMatch:e=>e&&"object"==typeof e&&"Object"===toStringTag(e),toValue(...e){return ta.toValue.apply(this,e)},getValue(...e){return ta.getValue.apply(this,e)},getInput(...e){return ta.getInput.apply(this,e)},viewUI({...e}){return ta.viewUI.call(this,{...e,type:"record"})},editUI({...e}){return ta.editUI.call(this,{...e,type:"record"})}},ia={option:["Date"],dateRegex:/^(?:\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d)$/u,stringRegex(){const e=this.dateRegex;if(!this.valid){const{source:t}=e;return new RegExp("^(?:InvalidDate)|"+t.slice(1),"u")}return new RegExp(e,"u")},valueMatch:e=>"Date"===toStringTag(e),toValue:e=>({value:new Date(e)}),getInput:({root:e})=>$e(e,'input[type="datetime-local"]'),setValue({root:e,value:t}){if(t&&Number.isNaN(t.getTime()))return void $e(e,".invalidDate").$setValidity(!0);const a=new Date(Date.parse(t)).toISOString();this.getInput({root:e}).value=24===a.length?a.slice(0,-8):a.slice(3,13)},validate({root:e}){if(this.isInvalid({root:e}))return{valid:!0};const t=this.getInput({root:e}).value;return t?{valid:new RegExp(this.dateRegex,"u").test(t),message:"Must match a valid date"}:{valid:!1,message:"Must not be empty`"}},isInvalid({root:e}){return!this.valid&&$e(e,".invalidDate").checked},getValue({root:e}){return this.isInvalid({root:e})?this.toValue("NaN").value:this.toValue(this.getInput({root:e}).value).value},isValueInvalid:e=>e&&Number.isNaN(e.getTime()),viewUI({value:e,specificSchemaObject:t}){return!this.valid&&this.isValueInvalid(e)?["i",{dataset:{type:"date"},class:"InvalidDate",title:t?.description??"(an InvalidDate)"},["InvalidDate"]]:["i",{dataset:{type:"date"},class:"ValidDate",title:t?.description??"(a `Date`)"},[e.toISOString().slice(0,-8)]]},editUI({typeNamespace:e,specificSchemaObject:t,types:a,value:r}){const n=t,i=r??(t?.defaultValue?new Date(t?.defaultValue):""),s=this.isValueInvalid(i),o=this.valid?"":c("div",[["label",["Invalid date",["input",{type:"checkbox",class:"invalidDate",checked:s,name:`${e}-invalidDate`,$custom:{$setValidity(e){!0===e&&(this.checked=!0);const t=o.previousElementSibling;t.hidden=Boolean(e);const r=t.parentElement;a.validate({type:"date",root:r})}},$on:{click(){this.$setValidity(this.checked)}}}]]]]);return["div",{dataset:{type:this.valid?"ValidDate":"date"},title:t?.description??"Date"},[["label",{hidden:s},["Date: ",["input",{name:`${e}-date`,type:"datetime-local",value:!i||s?"":i.toISOString().slice(0,-8),min:n?.min?new Date(n.min).toISOString().slice(0,-8):void 0,max:n?.max?new Date(n.max).toISOString().slice(0,-8):void 0}]]],o]]}},sa={option:["Enum"],stringRegex:/^Enum\((.*)\)$/u,valueMatch:e=>"string"==typeof e,toValue:e=>({value:e.slice(1,-1)}),getInput:({root:e})=>$e(e,"select"),setValue({root:e,value:t}){this.getInput({root:e}).value=t},getValue({root:e}){return this.getInput({root:e}).value},viewUI:({value:e,specificSchemaObject:t})=>["span",{dataset:{type:"enum"},title:t?.description??"(an enum)"},[e]],editUI:({typeNamespace:e,specificSchemaObject:t,value:a=""})=>["div",{dataset:{type:"enum"},title:t?.description??"Enum"},[["select",{name:`${e}-enum`},t?.values.map((e=>["option",{selected:a?a===e:t?.defaultValue===e},[e]]))]]]},oa={option:["Set"],array:!0,set:!0,regexEndings:[",",")"],stringRegexBegin:/^Set\(/u,stringRegexEnd:/^\)/u,valueMatch:e=>"Set"===toStringTag(e),toValue(...e){return ta.toValue.apply(this,e)},getValue(...e){return ta.getValue.apply(this,e)},getInput(...e){return ta.getInput.apply(this,e)},viewUI({...e}){return ta.viewUI.call(this,{...e,type:"set"})},editUI({...e}){return ta.editUI.call(this,{...e,type:"set"})}},ca={option:["Map"],array:!0,map:!0,regexEndings:[",",")"],stringRegexBegin:/^Map\(/u,stringRegexEnd:/^\)/u,valueMatch:e=>"Map"===toStringTag(e),toValue(...e){return ta.toValue.apply(this,e)},getValue(...e){return ta.getValue.apply(this,e)},getInput(...e){return ta.getInput.apply(this,e)},viewUI({...e}){return ta.viewUI.call(this,{...e,type:"map"})},editUI({...e}){return ta.editUI.call(this,{...e,type:"map"})}},la={option:["Literal"],stringRegex:/^Literal\((.*)\)$/u,valueMatch:e=>"boolean"==typeof e||"number"==typeof e||"string"==typeof e,toValue:e=>({value:"true"===e||"false"!==e&&('"'===e.charAt(0)?e.slice(1,-1):Number(e))}),getInput:({root:e})=>$e(e,"input,textarea"),setValue({root:e,value:t}){this.getInput({root:e}).value=t},getValue({root:e,stateObj:t}){const a=$e(e,"[data-type]"),r=t?.types?.getTypeObject?.(a?.dataset.type);return r?.getValue({root:e,stateObj:t})},viewUI:({value:e,specificSchemaObject:t})=>["span",{dataset:{type:"literal"},title:t?.description??`(a literal ${typeof e})`},[`${e}`]],editUI(e){const{specificSchemaObject:t}=e,{value:a}=t;let r;switch(typeof a){case"boolean":r=Mt.editUI(e);break;case"number":r=Pt.editUI(e);break;default:r=Gt.editUI(e)}return["div",{dataset:{type:"literal"}},[r]]}},ua={stringRegex:/^undefined$/u,option:["Explicit undefined"],valueMatch:e=>void 0===e,toValue:()=>({value:void 0}),getValue(){return this.toValue("").value},viewUI:({specificSchemaObject:e})=>["i",{dataset:{type:"undef"},title:e?.description??"(an `undefined`)"},["undefined"]],getInput:({root:e})=>$e(e,"input"),editUI:({typeNamespace:e,specificSchemaObject:t})=>["div",{dataset:{type:"undef"},title:t?.description??"Undefined"},[["label",["Undefined",["input",{type:"checkbox",name:`${e}-undef`,disabled:!0,checked:!0}]]]]]},da={stringRegex:/^void$/u,option:["Void"],valueMatch:e=>void 0===e,toValue:()=>({value:void 0}),getValue(){return this.toValue("").value},getInput:({root:e})=>$e(e,"input"),viewUI:({specificSchemaObject:e})=>["i",{dataset:{type:"void"},title:e?.description??"(a `void`)"},["void"]],editUI:({typeNamespace:e,specificSchemaObject:t})=>["div",{dataset:{type:"void"},title:t?.description??"Void"},[["label",["Void",["input",{type:"checkbox",name:`${e}-void`,checked:!0,disabled:!0}]]]]]},pa={option:["RegExp"],stringRegex(e){const t=e?"(?:":"(";return new RegExp(`^/${t}.*)/${t}[${this.allowedFlags.join("")}]{0,${this.allowedFlags.length}})$`,"u")},valueMatch:e=>"RegExp"===toStringTag(e),toValue(e){if("function"!=typeof this.stringRegex)throw new TypeError("Guard for TS");const[,t,a]=e.match(this.stringRegex());return{value:new RegExp(t,a)}},getInput:({root:e})=>$e(e,"input"),setValue({root:e,value:t}){this.getInput({root:e}).value=t.source,this.getSelect({root:e}).$set([...t.flags])},getSelect:({root:e})=>$e(e,"select"),validate({root:e}){try{return this.getValue({root:e}),{valid:!0}}catch(e){return{valid:!1,message:e.message}}},getValue({root:e}){return new RegExp(this.getInput({root:e}).value,[...this.getSelect({root:e}).selectedOptions].reduce(((e,t)=>e+t.value),""))},allowedFlags:["g","i","m","u","y","s","v"],viewUI:({value:e,specificSchemaObject:t})=>["i",{dataset:{type:"regexp"},title:t?.description??"(a `RegExp`)"},[String(e)]],editUI({typeNamespace:e,specificSchemaObject:t,types:a,value:r={source:"",flags:""}}){const n=c("select",{multiple:!0,size:5,$custom:{$set(e){[...this.options].forEach((t=>{t.selected=e.includes(t.value)}))}}},this.allowedFlags.map((e=>["option",{selected:r.flags.includes(e)},[e]]))),i=c("div",{dataset:{type:"regexp"},title:t?.description??"RegExp"},[["label",["Source ",["input",{name:`${e}-regexp`,type:"text",value:r.source}]]],["br"],["label",["Flags ",n]]]);return n.addEventListener("change",(()=>{a.validate({type:"regexp",root:i})})),[i]}},ma={option:["BooleanObject"],stringRegex:/^Boolean\((.*)\)$/u,valueMatch:e=>"Boolean"===toStringTag(e)&&"object"==typeof e,toValue:e=>({value:new Boolean("true"===e)}),getInput:({root:e})=>$e(e,"input"),getValue({root:e}){return this.toValue(String(this.getInput({root:e}).checked)).value},setValue({root:e,value:t}){$$e(e,"input")[t.valueOf()?0:1].checked=!0},viewUI:({value:e,specificSchemaObject:t})=>["i",{dataset:{type:"BooleanObject"},title:t?.description??"(a Boolean Object)"},[t?`${e}`:`Boolean(${e})`]],ct:0,editUI({typeNamespace:e,specificSchemaObject:t,value:a=new Boolean(!0)}){return this.ct++,["div",{dataset:{type:"BooleanObject"},title:t?.description??"Boolean object"},[["label",["True",["input",{type:"radio",name:`${e}-BooleanObject${this.ct}`,value:"true",checked:a.valueOf()}]]],["label",["False",["input",{type:"radio",name:`${e}-BooleanObject${this.ct}`,value:"false",checked:!a.valueOf()}]]]]]}},ya={option:["NumberObject"],stringRegex:/^Number\((.*)\)$/u,valueMatch:e=>"Number"===toStringTag(e)&&"object"==typeof e,toValue:e=>({value:new Number(e)}),validate:({root:e})=>Pt.validate({root:e}),getInput:({root:e})=>$e(e,"input"),getValue({root:e}){return this.toValue(this.getInput({root:e}).value).value},setValue({root:e,value:t}){this.getInput({root:e}).value=String(t)},viewUI:({value:e,specificSchemaObject:t})=>["i",{dataset:{type:"NumberObject"},title:t?.description??"(a Number Object)"},[t?`${e}`:`Number(${e})`]],editUI:({typeNamespace:e,specificSchemaObject:t,value:a})=>["div",{dataset:{type:"NumberObject"},title:t?.description??"Number object"},[["input",{name:`${e}-NumberObject`,type:"number",value:a,step:"any"}]]]},ha={stringRegex:/^String\(([^)]*)\)$/u,valueMatch:e=>"String"===toStringTag(e)&&"object"==typeof e,toValue:e=>({value:new String(e)}),option:["StringObject"],getInput:({root:e})=>$e(e,"textarea"),getValue({root:e}){return this.toValue(this.getInput({root:e}).value).value},setValue({root:e,value:t}){this.getInput({root:e}).value=t},viewUI:({value:e,specificSchemaObject:t})=>["span",{dataset:{type:"StringObject"},title:t?.description??"(a String Object)"},[t?"":["i",["String("]],["span",[e.valueOf()]],t?"":["i",[")"]]]],editUI:({typeNamespace:e,specificSchemaObject:t,value:a=""})=>["div",{dataset:{type:"StringObject"},title:t?.description??"String object"},[["textarea",{name:`${e}-StringObject`},[a]]]]},fa={option:["Special Real Number",{title:"`Infinity`, `-Infinity`, `-0`"}],childTypes:["infinity","negativeInfinity","negativeZero"],stringRegex:/^(?:-?Infinity|-0)$/u,valueMatch:e=>Object.is(e,-0)||e===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY,toValue:e=>({value:"-0"===e?-0:"Infinity"===e?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY}),getSelect:({root:e})=>$e(e,"select"),getValue({root:e}){return this.toValue(this.getSelect({root:e}).value).value},setValue({root:e,value:t}){this.getSelect({root:e}).value=Object.is(t,-0)?"-0":String(t)},viewUI({value:e,specificSchemaObject:t}){const a=Object.is(e,-0);return["i",{dataset:{type:"SpecialRealNumber"},title:t?.description??(a?"(negative zero)":`(${String(e)})`)},[a?"-0":String(e)]]},getInput:({root:e})=>$e(e,"select"),editUI:({typeNamespace:e,specificSchemaObject:t,value:a=Number.POSITIVE_INFINITY})=>["div",{dataset:{type:"SpecialRealNumber"},title:t?.description??"Special Real Number"},[["label",[["select",{name:`${e}-SpecialRealNumber`},[["option",{value:"Infinity",selected:a===Number.POSITIVE_INFINITY},["Infinity"]],["option",{value:"-Infinity",selected:a===Number.NEGATIVE_INFINITY},["-Infinity"]],["option",{value:"-0",selected:Object.is(a,-0)},["-0"]]]]]]]]},ga={option:["Special Number",{title:"`NaN`, `Infinity`, `-Infinity`, `-0`"}],childTypes:["infinity","negativeInfinity","nan","negativeZero"],stringRegex:/^(?:NaN|-?Infinity|-0)$/u,toValue:e=>({value:"-0"===e?-0:"NaN"===e?Number.NaN:"Infinity"===e?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY}),getSelect:({root:e})=>$e(e,"select"),getInput:({root:e})=>$e(e,"select"),getValue({root:e}){return this.toValue(this.getSelect({root:e}).value).value},setValue({root:e,value:t}){this.getSelect({root:e}).value=Object.is(t,-0)?"-0":String(t)},viewUI:({value:e})=>["i",{dataset:{type:"SpecialNumber"}},[Object.is(e,-0)?"-0":String(e)]],editUI:({typeNamespace:e,value:t=Number.NaN})=>["div",{dataset:{type:"SpecialNumber"}},[["label",["Special number: ",["select",{name:`${e}-SpecialNumber`},[["option",{value:"NaN",selected:Number.isNaN(t)},["NaN"]],["option",{value:"Infinity",selected:t===Number.POSITIVE_INFINITY},["Infinity"]],["option",{value:"-Infinity",selected:t===Number.NEGATIVE_INFINITY},["-Infinity"]],["option",{value:"-0",selected:Object.is(t,-0)},["-0"]]]]]]]]},va={option:["Error"],stringRegex:/^Error\((.*)\)$/u,valueMatch:e=>"Error"===toStringTag(e)&&hasConstructorOf(e,Error),toValue(e){const t=JSON.parse(e);return{value:D.error.revive(t,{})}},getInput:({root:e})=>$e(e,"input:not([type])"),setValue({root:e,value:t}){"string"==typeof t.message?$e(e,"input.message:not([type])").value=t.message:$e(e,"input.message[type=checkbox]").click(),"string"==typeof t.name?$e(e,"input.name:not([type])").value=t.name:$e(e,"input.name[type=checkbox]").click(),"string"==typeof t.fileName?$e(e,"input.fileName:not([type])").value=t.fileName:$e(e,"input.fileName[type=checkbox]").click(),"number"==typeof t.lineNumber?$e(e,"input.lineNumber[type=number]").value=t.lineNumber:$e(e,"input.lineNumber[type=number]").value="","number"==typeof t.columnNumber?$e(e,"input.columnNumber[type=number]").value=t.columnNumber:$e(e,"input.columnNumber[type=number]").value="","string"==typeof t.stack?$e(e,"textarea.stack:not([type])").value=t.stack:$e(e,"input.stack[type=checkbox]").click(),setTimeout((()=>{"object"==typeof t.cause&&($e(e,".cause").click(),this.setValue({root:$e(e,".causeContents"),value:t.cause}))}))},getValue({root:e}){let t;if($e(e,"input.message[type=checkbox]").checked){const a=$e(e,"input.message:not([type])").value;t=new Error(a)}else t=new Error,t.message=void 0;if($e(e,"input.name[type=checkbox]").checked){const a=$e(e,"input.name:not([type])").value;t.name=a}else t.name=void 0;if($e(e,"input.fileName[type=checkbox]").checked){const a=$e(e,"input.fileName:not([type])").value;t.fileName=a}else t.fileName=void 0;if($e(e,"input.stack[type=checkbox]").checked){const a=$e(e,"textarea.stack:not([type])").value;t.stack=a}else t.stack=void 0;const a=$e(e,"input.lineNumber[type=number]").value;t.lineNumber=""===a?void 0:Number(a);const r=$e(e,"input.columnNumber[type=number]").value;t.columnNumber=""===r?void 0:Number(r);const n=$e(e,".causeContents");return n.children.length&&(t.cause=this.getValue({root:n})),t},viewUI({value:e,specificSchemaObject:t,types:a,format:r}){return["div",{dataset:{type:"error"}},[["b",{class:"emphasis",title:t?.description?"(an Error)":void 0},[t?.description??"Error"]],"string"==typeof e.message?["div",[["b",["Message: "]],["span",[e.message]]]]:[],"string"==typeof e.name?["div",[["b",["Name: "]],["span",[e.name]]]]:[],"string"==typeof e.fileName?["div",[["b",["File name: "]],["span",[e.fileName]]]]:[],"number"==typeof e.lineNumber?["div",[["b",["Line number: "]],["span",[e.lineNumber]]]]:[],"number"==typeof e.columnNumber?["div",[["b",["Column number: "]],["span",[e.columnNumber]]]]:[],"string"==typeof e.stack?["div",[["b",["Stack: "]],["span",[e.stack]]]]:[],["b",["Cause: "]],["div",{class:"causeHolder"},[["button",{$on:{click(e){e.preventDefault();const{target:t}=e,a=t.nextElementSibling;a.hidden=!a.hidden,t.textContent=a.hidden?"+":"-"}}},["-"]],["div",{class:"causeContents"},[e.cause?this.viewUI({format:r,value:e.cause,types:a}):""]]]]]]},editUI({typeNamespace:e,types:t,specificSchemaObject:a,value:r={message:"",name:"",fileName:"",lineNumber:"",columnNumber:"",stack:"",cause:void 0}}){const click=function(e){this.parentNode.nextElementSibling.hidden=!e.target.checked},n=this;"object"==typeof r.cause&&setTimeout((()=>{$e(i,".cause").click()}));const i=c("div",{dataset:{type:"error"},title:a?.description??"Error"},[["div",[["label",["Message? ",["input",{class:"message",type:"checkbox",checked:"string"==typeof r.message,$on:{click:click}}]]]," ",["label",{hidden:"string"!=typeof r.message},["Message ",["input",{class:"message",name:`${e}-error-message`,value:r.message}]]]]],["div",[["label",["Name? ",["input",{class:"name",type:"checkbox",checked:"string"==typeof r.name,$on:{click:click}}]]]," ",["label",{hidden:"string"!=typeof r.name},["Name ",["input",{class:"name",name:`${e}-error-name`,value:r.name}]]]]],["br"],["div",[["label",["File name? ",["input",{class:"fileName",type:"checkbox",checked:"string"==typeof r.fileName,$on:{click:click}}]]]," ",["label",{hidden:"string"!=typeof r.fileName},["File name ",["input",{class:"fileName",name:`${e}-error-fileName`,value:r.fileName}]]]]],["label",["Line number ",["input",{class:"lineNumber",name:`${e}-error-lineNumber`,type:"number",step:"any",value:r.lineNumber}]]],["br"],["label",["Column number ",["input",{class:"columnNumber",name:`${e}-error-columnNumber`,type:"number",step:"any",value:r.columnNumber}]]],["div",[["label",["Stack? ",["input",{class:"stack",type:"checkbox",checked:"string"==typeof r.stack,$on:{click:click}}]]],["label",{hidden:"string"!=typeof r.stack},["Stack ",["textarea",{class:"stack",name:`${e}-error-stack`},[r.stack]]]]]],["label",["Cause? ",["input",{class:"cause",type:"checkbox",$on:{click(a){click.call(this,a);const i=this.parentElement.nextElementSibling,s=$e(i,".causeContents");if(!s?.children.length){const a=n.editUI({typeNamespace:e,types:t,value:r.cause});c(...a,s)}}}}]]],["div",{class:"causeHolder",hidden:!0},[["label",["Cause "]],["button",{$on:{click(e){e.preventDefault();const{target:t}=e,a=$e(t.closest(".causeHolder"),".causeContents");a.hidden=!a.hidden,t.textContent=a.hidden?"+":"-"}}},["-"]],["div",{class:"causeContents"}]]]]);return[i]}};function getConstructor(e){const t=Function.prototype.toString.call(e);return t.slice(9,t.indexOf("("))}const ba=new Map([["TypeError",TypeError],["RangeError",RangeError],["SyntaxError",SyntaxError],["ReferenceError",ReferenceError],["EvalError",EvalError],["URIError",URIError]]);"undefined"!=typeof AggregateError&&ba.set("AggregateError",AggregateError),"undefined"!=typeof InternalError&&ba.set("InternalError",InternalError);const wa=[...ba.keys()],xa={option:["Special errors"],valueMatch:e=>[TypeError,RangeError,SyntaxError,ReferenceError,EvalError,URIError,AggregateError].some((t=>hasConstructorOf(e,t))),childTypes:wa.map((e=>e.toLowerCase())),stringRegex:new RegExp("^(?<errorClass>"+wa.join("|")+String.raw`)\((?<innerContent>.*)\)$`,"u"),toValue(e,t){const{groups:{errorClass:a}={}}=t.match,r=JSON.parse(e);return{value:L[a.toLowerCase()].revive(r,{})}},getInput:({root:e})=>$e(e,"input:not([type])"),setValue({root:e,value:t}){const a=$e(e,".errorType");a.value=getConstructor(t.constructor),a.$hideAggregateErrorsLabel(),"string"==typeof t.message?$e(e,"input.message:not([type])").value=t.message:$e(e,"input.message[type=checkbox]").click(),"string"==typeof t.name?$e(e,"input.name:not([type])").value=t.name:$e(e,"input.name[type=checkbox]").click(),"string"==typeof t.fileName?$e(e,"input.fileName:not([type])").value=t.fileName:$e(e,"input.fileName[type=checkbox]").click(),"number"==typeof t.lineNumber?$e(e,"input.lineNumber[type=number]").value=t.lineNumber:$e(e,"input.lineNumber[type=number]").value="","number"==typeof t.columnNumber?$e(e,"input.columnNumber[type=number]").value=t.columnNumber:$e(e,"input.columnNumber[type=number]").value="","string"==typeof t.stack?$e(e,"textarea.stack:not([type])").value=t.stack:$e(e,"input.stack[type=checkbox]").click(),setTimeout((()=>{if("object"==typeof t.cause&&($e(e,".cause").click(),this.setValue({root:$e(e,".causeContents"),value:t.cause})),Array.isArray(t.errors)){const a=$e(e,"input.aggregateErrors");a.click(),a.$emptyAggregateErrorsContents(),a.$populateContents(t.errors)}}))},getValue({root:e,stateObj:t}){const a=ba.get($e(e,".errorType").value);if(!a)throw new Error("Bad error type");let r;if($e(e,"input.message[type=checkbox]").checked){const n=$e(e,"input.message:not([type])").value;if("AggregateError"===getConstructor(a)){const i=a,s=$e(e,".aggregateErrorsContents").firstElementChild;r=new i(ta.getValue({stateObj:t,root:s}),n)}else{r=new a(n)}}else{if("AggregateError"===getConstructor(a)){const n=a,i=$e(e,".aggregateErrorsContents").firstElementChild;r=new n(ta.getValue({stateObj:t,root:i}))}else{r=new a}r.message=void 0}if($e(e,"input.name[type=checkbox]").checked){const t=$e(e,"input.name:not([type])").value;r.name=t}else r.name=void 0;if($e(e,"input.fileName[type=checkbox]").checked){const t=$e(e,"input.fileName:not([type])").value;r.fileName=t}else r.fileName=void 0;if($e(e,"input.stack[type=checkbox]").checked){const t=$e(e,"textarea.stack:not([type])").value;r.stack=t}else r.stack=void 0;const n=$e(e,"input.lineNumber[type=number]").value;r.lineNumber=""===n?void 0:Number(n);const i=$e(e,"input.columnNumber[type=number]").value;r.columnNumber=""===i?void 0:Number(i);const s=$e(e,".causeContents");return s.children.length&&(r.cause=this.getValue({stateObj:t,root:s})),r},viewUI({value:e,types:t,format:a,specificSchemaObject:r,typeNamespace:n,resultType:i}){const s=getConstructor(e.constructor);return["div",{dataset:{type:"errors"},title:r?.description?`(an Error ${s})`:void 0},[r?.description??["div",[["b",["Error type: "]],["span",[s]]]],"string"==typeof e.message?["div",[["b",["Message: "]],["span",[e.message]]]]:[],"string"==typeof e.name?["div",[["b",["Name: "]],["span",[e.name]]]]:[],"string"==typeof e.fileName?["div",[["b",["File name: "]],["span",[e.fileName]]]]:[],"number"==typeof e.lineNumber?["div",[["b",["Line number: "]],["span",[e.lineNumber]]]]:[],"number"==typeof e.columnNumber?["div",[["b",["Column number: "]],["span",[e.columnNumber]]]]:[],"string"==typeof e.stack?["div",[["b",["Stack: "]],["span",[e.stack]]]]:[],["b",["Cause: "]],["div",{class:"causeHolder"},[["button",{$on:{click(e){e.preventDefault();const{target:t}=e,a=t.nextElementSibling;a.hidden=!a.hidden,t.textContent=a.hidden?"+":"-"}}},["-"]],["div",{class:"causeContents"},[e.cause?this.viewUI({format:a,value:e.cause,types:t}):""]]]],"AggregateError"===s?["div",[["b",["Errors "]],["div",{class:"aggregateErrorsHolder"},[["button",{$on:{click(e){e.preventDefault();const{target:t}=e,a=t.nextElementSibling;a.hidden=!a.hidden,t.textContent=a.hidden?"+":"-"}}},["-"]],["div",{class:"aggregateErrorsContents"},[e.errors?(()=>{const[r]=ta.viewUI({typeNamespace:n,resultType:i,format:a,type:"arrayNonindexKeys",value:[],types:t});return e.errors.forEach(((e,t)=>{r.$addAndSetArrayElement({propName:String(t),type:"Error"===getConstructor(e.constructor)?"error":"errors",value:e,bringIntoFocus:!1})})),r})():""]]]]]]:""]]},editUI({typeNamespace:e,specificSchemaObject:t,types:a,buildTypeChoices:r,format:n,topRoot:i,bringIntoFocus:s,value:o={message:"",name:"",fileName:"",lineNumber:"",columnNumber:"",stack:"",cause:void 0,errors:void 0}}){const click=function(e){this.parentNode.nextElementSibling.hidden=!e.target.checked},l=this;"object"==typeof o.cause&&setTimeout((()=>{$e(u,".cause").click()})),Array.isArray(o.errors)&&setTimeout((()=>{$e(u,"input.aggregateErrors").click()}));const u=c("div",{dataset:{type:"errors"},title:t?.description??"Special error"},[["div",[["label",["Special error type ",["select",{class:"errorType",$custom:{$hideAggregateErrorsLabel(){$e(this.parentElement?.closest("div[data-type=errors]"),"label.aggregateErrors").hidden="AggregateError"!==this.value}},$on:{change(){this.$hideAggregateErrorsLabel()}}},[["option",{value:""},["Select an error type"]],...wa.map((e=>["option",{selected:e===getConstructor(o.constructor)?"selected":void 0},[e]]))]]]],["br"],["label",["Message? ",["input",{class:"message",type:"checkbox",checked:"string"==typeof o.message,$on:{click:click}}]]]," ",["label",{hidden:"string"!=typeof o.message},["Message ",["input",{class:"message",name:`${e}-errors-message`,value:o.message}]]]]],["div",[["label",["Name? ",["input",{class:"name",type:"checkbox",checked:"string"==typeof o.name,$on:{click:click}}]]]," ",["label",{hidden:"string"!=typeof o.name},["Name ",["input",{class:"name",name:`${e}-errors-name`,value:o.name}]]]]],["br"],["div",[["label",["File name? ",["input",{class:"fileName",type:"checkbox",checked:"string"==typeof o.fileName,$on:{click:click}}]]]," ",["label",{hidden:"string"!=typeof o.fileName},["File name ",["input",{class:"fileName",name:`${e}-errors-fileName`,value:o.fileName}]]]]],["label",["Line number ",["input",{class:"lineNumber",name:`${e}-errors-lineNumber`,type:"number",step:"any",value:o.lineNumber}]]],["br"],["label",["Column number ",["input",{class:"columnNumber",name:`${e}-errors-columnNumber`,type:"number",step:"any",value:o.columnNumber}]]],["div",[["label",["Stack? ",["input",{class:"stack",type:"checkbox",checked:"string"==typeof o.stack,$on:{click:click}}]]],["label",{hidden:"string"!=typeof o.stack},["Stack ",["textarea",{class:"stack",name:`${e}-errors-stack`},[o.stack??""]]]]]],["label",["Cause? ",["input",{class:"cause",type:"checkbox",$on:{click(t){click.call(this,t);const n=this.parentElement.nextElementSibling,i=$e(n,".causeContents");if(!i?.children.length){const t=l.editUI({buildTypeChoices:r,typeNamespace:e,types:a,value:o.cause});c(...t,i)}}}}]]],["div",{class:"causeHolder",hidden:!0},[["label",["Cause "]],["button",{$on:{click(e){e.preventDefault();const{target:t}=e,a=$e(t.closest(".causeHolder"),".causeContents");a.hidden=!a.hidden,t.textContent=a.hidden?"+":"-"}}},["-"]],["div",{class:"causeContents"}]]],["br"],["label",{class:"aggregateErrors"},{hidden:!o.errors},["Aggregate errors? ",["input",{class:"aggregateErrors",type:"checkbox",$custom:{$emptyAggregateErrorsContents(){const e=this.parentElement.nextElementSibling,t=$e(e,".aggregateErrorsContents");for(;t?.firstChild;)t?.firstChild.remove()},$populateContents(t){const o=this.parentElement.nextElementSibling,l=$e(o,".aggregateErrorsContents");if(!l?.children.length){const[o]=ta.editUI({typeNamespace:e,types:a,buildTypeChoices:r,format:n,type:"array",topRoot:i,bringIntoFocus:s,forcedState:"errorsArray",value:[]});t.forEach(((e,t)=>{o.$addAndSetArrayElement({propName:String(t),type:"Error"===getConstructor(e.constructor)?"error":"errors",value:e,bringIntoFocus:!1,setAValue:!0})})),c(o,l)}}},$on:{click(e){click.call(this,e);const t=this;o.errors?t.$populateContents(o.errors):t.$populateContents([{message:"",name:"",stack:""}])}}}]]],["div",{class:"aggregateErrorsHolder",hidden:!0},[["label",["Aggregate errors "]],["button",{$on:{click(e){e.preventDefault();const{target:t}=e,a=$e(t.closest(".aggregateErrorsHolder"),".aggregateErrorsContents");a.hidden=!a.hidden,t.textContent=a.hidden?"+":"-"}}},["-"]],["div",{class:"aggregateErrorsContents"}]]]]);return[u]}};let Sa;function visualize(e,t){Sa||(Sa=new AudioContext);const a=t.getContext("2d"),r=Sa.createMediaStreamSource(e),n=Sa.createAnalyser();n.fftSize=2048;const i=n.frequencyBinCount,s=new Uint8Array(i);r.connect(n),function draw(){const e=t.width,r=t.height;requestAnimationFrame(draw),n.getByteTimeDomainData(s),a.fillStyle="rgb(200, 200, 200)",a.fillRect(0,0,e,r),a.lineWidth=2,a.strokeStyle="rgb(0, 0, 0)",a.beginPath();const o=1*e/i;let c=0;for(let e=0;e<i;e++){const t=s[e]/128*r/2;0===e?a.moveTo(c,t):a.lineTo(c,t),c+=o}a.lineTo(t.width,t.height/2),a.stroke()}()}async function getUserMedia(e){let t=null;try{t=await navigator.mediaDevices.getUserMedia(e)}catch(e){return console.error("err",e),null}return t}async function startScreenCapture(e){let t=null;try{t=await navigator.mediaDevices.getDisplayMedia(e)}catch(e){console.error(`Error: ${e}`)}return t}function getDateString(e){const t=new Date(e);return new Date(t.getTime()-6e4*t.getTimezoneOffset()).toISOString().slice(0,-1)}function newFileForBinary(e,t){const a=e.$value,r=new File([void 0===t.stringContents?a&&"File"===Object.prototype.toString.call(a).slice(8,-1)?a:"":t.stringContents],void 0===t.name?a?.name??"":t.name,{type:void 0===t.type?a?.type??"":t.type,lastModified:void 0===t.lastModified?a?.lastModified??0:t.lastModified});e.$value=r}function binaryButton$1(e,t){return["button",{class:"viewBinary",$custom:{$value:e},$on:{click(e){const t=this;e.preventDefault(),this.$value&&"File"===Object.prototype.toString.call(this.$value).slice(8,-1)||newFileForBinary(t,{});const a=new FileReader;a.addEventListener("load",(async function(){const e=await pe.makeSubmitDialog({submitText:"Save",submit(){const a=$e(e,".view-binary");newFileForBinary(t,{stringContents:a.value}),e.close()},children:[["div",["Binary source",["br"],["textarea",{class:"view-binary"},[a.result??""]]]]]})})),a.addEventListener("error",(async function(){console.error(a.error),await pe.alert(a.error.message)})),a.readAsBinaryString(this.$value)}}},[t?"Edit binary data":"View binary data"]]}const Ia={option:["File"],stringRegex:/^File\((.*)\)$/u,valueMatch:e=>"File"===toStringTag(e),toValue(e){const t=JSON.parse(e);return{value:new File([t.stringContents],t.name,{type:t.type,lastModified:t.lastModified})}},getInput:({root:e})=>$e(e,"button.viewBinary"),setValue({root:e,value:t}){$e(e,"fieldset.fileMetaData").$setValue(t)},getValue({root:e}){return this.getInput({root:e}).$value},viewUI:({value:e,specificSchemaObject:t})=>["div",{dataset:{type:"file"}},[["b",{class:"emphasis",title:t?.description?"(a File)":void 0},[t?.description??"File"]],["br"],["br"],["b",["Name "]],e.name,["br"],["b",["Size (in bytes) "]],String(e.size),["br"],["b",["Content type "]],e.type,["br"],["b",["Last modified date "]],getDateString(e.lastModified),["br"],e.type.startsWith("text/")||"application/json"===e.type?(()=>{const t=c("div"),a=new FileReader;return a.addEventListener("load",(function(){t.append(c("div",["Text source",["br"],["textarea",{class:"view-text"},[a.result??""]]]))})),a.addEventListener("error",(function(){console.error(a.error),t.append(a.error.message)})),a.readAsBinaryString(e),t})():binaryButton$1(e),e.type.startsWith("video/")?(()=>{const t=URL.createObjectURL(e),a=c("video",{src:t,class:"video",$on:{loadeddata(){URL.revokeObjectURL(t)}}});return["div",[a,["button",{class:"play",$on:{click(e){e.preventDefault(),a.play()}}},["Play"]],["button",{class:"pause",$on:{click(e){e.preventDefault(),a.pause()}}},["Pause"]],["button",{class:"replay",$on:{click(e){e.preventDefault(),a.pause(),a.currentTime=0,a.play()}}},["Replay"]]]]})():"",e.type.startsWith("audio/")?(()=>{const t=URL.createObjectURL(e),a=c("audio",{src:t,class:"audio",$on:{loadeddata(){URL.revokeObjectURL(t)}}});return["div",[a,["button",{class:"play",$on:{click(e){e.preventDefault(),a.play()}}},["Play"]],["button",{class:"pause",$on:{click(e){e.preventDefault(),a.pause()}}},["Pause"]],["button",{class:"replay",$on:{click(e){e.preventDefault(),a.pause(),a.currentTime=0,a.play()}}},["Replay"]]]]})():"","application/pdf"===e.type?(()=>{const t=URL.createObjectURL(e);return c("iframe",{class:"PDF",src:t,$on:{load(){URL.revokeObjectURL(t)}}})})():"",e.type.startsWith("image/")?["img",{class:"imageView",src:URL.createObjectURL(e),$on:{load(){URL.revokeObjectURL(this.src)}}}]:""]],editUI:({typeNamespace:e,specificSchemaObject:t,value:a={}})=>["div",{dataset:{type:"file"},title:t?.description??"File"},[["fieldset",{class:"fileMetaData",$custom:{$setValue(e){const t=this;$e(t,".fileName").value=e.name,$e(t,".size").value=String(e.size),$e(t,".contentType").value=e.type,$e(t,".lastModified").value="number"==typeof e.lastModified?getDateString(e.lastModified):"",$e(t,"button.viewBinary").$value="number"==typeof e.lastModified?e:void 0}}},[["legend",["Current file data"]],["label",["Name ",["input",{size:50,class:"fileName",value:a.name??"",$on:{change(){newFileForBinary($e(this.parentElement?.parentElement,"button.viewBinary"),{name:this.value})}}}]]],["br"],["label",["Size (in bytes) ",["input",{type:"number",step:"1",disabled:!0,class:"size",value:String(a.size)}]]],["br"],["label",["Content type ",["input",{class:"contentType",value:a.type??"",$on:{change(){newFileForBinary($e(this.parentElement?.parentElement,"button.viewBinary"),{type:this.value})}}}]]],["br"],["label",["Last modified date ",["input",{type:"datetime-local",class:"lastModified",step:.001,value:a.lastModified?getDateString(a.lastModified):void 0,$on:{change(){const e=$e(this.parentElement?.parentElement,"button.viewBinary"),t=this.value;newFileForBinary(e,{lastModified:new Date(t).getTime()})}}}]]],["br"],binaryButton$1(a,!0),["button",{class:"clearData",$on:{click(e){e.preventDefault(),this.parentElement.$setValue({name:"",size:"",type:"",lastModified:""})}}},["Clear data"]]]],["fieldset",[["legend",["Supply file through upload"]],["label",["File ",["input",{$on:{change(){if(!this.files)return;const e=this.files[0],t=(this.parentElement?.parentElement)?.previousElementSibling;t.$setValue(e)}},name:`${e}-file`,type:"file"}]]]]],["fieldset",[["legend",["Supply file through recording"]],(()=>{const e=c("select",{class:"device",$on:{async change(){const t=this.nextElementSibling?.nextElementSibling;$e(t,"img.photo").hidden=!0;const a=$e(t,"video.previewMedia"),r=c("video",{class:"previewMedia"});if(a.$stream){a.$stream.getTracks().forEach((e=>{e.stop()})),a.srcObject=null}a.replaceWith(r);const n=$e(e.nextElementSibling,".takeSnapshot"),i=$e(e.nextElementSibling,".recordMedia");$e(e.nextElementSibling?.nextElementSibling,"div.recordedMedia").hidden=!0;const s=$e(t,"canvas.visualizer");let o,l;switch(r.$screenShare=!1,e.value){case"audio-and-video":o={video:!0,audio:!0},r.hidden=!1,n.hidden=!1,i.textContent="Record video/audio";break;case"video":o={video:!0},r.hidden=!1,n.hidden=!1,i.textContent="Record video";break;case"audio":o={audio:!0},r.hidden=!0,n.hidden=!0,i.textContent="Record audio";break;case"screenShare":l={video:!0};case"screenShareAndVideo":l||(l={video:!0,audio:!0}),r.$screenShare=!0,r.hidden=!0,n.hidden=!0,s.hidden=!0;break;default:return}if(o){const e=await getUserMedia(o);if(!e)return void await pe.alert("Error getting user media");if(t.hidden=!1,r.srcObject=e,r.$stream=e,o.video){const e=$e(t,"canvas.recordedImage");r.addEventListener("canplay",(()=>{e.setAttribute("width",String(r.videoWidth)),e.setAttribute("height",String(r.videoHeight))}))}r.addEventListener("loadedmetadata",(()=>{r.play(),o?.audio?(s.hidden=!1,visualize(e,s)):s.hidden=!0}))}else if(l){const e=await startScreenCapture(l);if(!e)return void await pe.alert("Error getting user media");t.hidden=!1,r.srcObject=e,r.$stream=e}}}},[["option",{value:""},["Please choose a device"]]]);return(async()=>{const t=await navigator.mediaDevices.enumerateDevices();let a=!1,r=!1;t.forEach((e=>{switch(e.kind){case"audioinput":a=!0;break;case"videoinput":r=!0}})),a&&c("option",{value:"audio"},["Microphone only"],e),r&&c("option",{value:"video"},["Video camera only"],e),a&&r&&c("option",{value:"audio-and-video"},["Video camera and microphone"],e),c("option",{value:"screenShare"},["Screen share"],e),c("option",{value:"screenShareAndVideo"},["Screen share and microphone"],e)})(),e})()," ",["div",[["button",{class:"recordMedia",$on:{click(e){e.preventDefault();const t=$e(this.parentElement?.nextElementSibling,"video.previewMedia");if(!t.srcObject)return void pe.alert("No stream found to record");const a=this.parentElement?.nextElementSibling;$e(a,"img.photo").hidden=!0;const r="video/webm",n=new MediaRecorder(t.$stream,{mimeType:r});let i=[];n.addEventListener("dataavailable",(e=>{i.push(e.data)}));try{n.start()}catch{return void pe.alert("Error starting media recorder")}n.addEventListener("stop",(()=>{const e=new Blob(i,{type:r}),t=URL.createObjectURL(e),a=$e(this.parentElement?.nextElementSibling,"video.recordedMedia");a.parentElement.hidden=!1,a.src=t,a.addEventListener("loadeddata",(()=>{URL.revokeObjectURL(t)}));const n=new File([e],"placeholder.webm",{type:r});console.log("file",n);const s=this.closest('[data-type="file"]');$e(s,"fieldset.fileMetaData").$setValue(n),i=[]})),this.$mediaRecorder=n}}},["Record media"]],["button",{class:"stopRecording",$on:{click(e){e.preventDefault(),this.previousElementSibling.$mediaRecorder.stop()}}},["Stop recording"]],["button",{class:"takeSnapshot",hidden:!0},{$on:{click(e){e.preventDefault();const t=this.parentElement?.nextElementSibling;$e(t,".recordedMedia").hidden=!0;const a=$e(t,"canvas.recordedImage"),r=a.getContext("2d"),n=$e(t,"video.previewMedia");r.drawImage(n,0,0,a.width,a.height);const i=$e(t,"img.photo");a.toBlob((e=>{if(!e)return void pe.alert("Error converting canvas to Blob");const t=c("img",{class:"photo"}),a=URL.createObjectURL(e);t.addEventListener("load",(()=>{URL.revokeObjectURL(a)}));const r=new File([e],"placeholder.png",{type:e.type});console.log("file",r);const n=this.closest('[data-type="file"]');$e(n,"fieldset.fileMetaData").$setValue(r),t.src=a,i.replaceWith(t)}))}}},["Take and use snapshot as file"]]]],["div",{class:"videoContainer",hidden:!0},[["canvas",{class:"visualizer",hidden:!0}],["br"],["video",{class:"previewMedia"}],["div",[["canvas",{hidden:!0,class:"recordedImage"}],["img",{class:"photo"}]]],["div",{class:"recordedMedia"},[...(()=>{const e=c("video",{class:"recordedMedia"});return[e,["br"],c("button",{class:"play",$on:{click(t){t.preventDefault(),e.play()}}},["Play"]),c("button",{class:"pause",$on:{click(t){t.preventDefault(),e.pause()}}},["Pause"]),c("button",{class:"replay",$on:{click(t){t.preventDefault(),e.pause(),e.currentTime=0,e.play()}}},["Replay"])]})()]]]]]]]]},Ta={option:["FileList"],array:!0,filelist:!0,regexEndings:[",",")"],stringRegexBegin:/^FileList\(/u,stringRegexEnd:/^\)/u,valueMatch:e=>"FileList"===toStringTag(e),toValue(...e){return ta.toValue.apply(this,e)},getValue(...e){return ta.getValue.apply(this,e)},getInput(...e){return ta.getInput.apply(this,e)},viewUI({...e}){return ta.viewUI.call(this,{...e,type:"filelist"})},editUI({...e}){return ta.editUI.call(this,{...e,type:"filelist"})}};function newBlobForBinary(e,t){const a=e.$value,r=new Blob([void 0===t.stringContents?a&&"Blob"===Object.prototype.toString.call(a).slice(8,-1)?a:"":t.stringContents],{type:void 0===t.type?a?.type??"":t.type});return e.$value=r,r}function binaryButton(e,t){return["button",{class:"viewBinary",$custom:{$value:e},$on:{click(e){const t=this;e.preventDefault(),this.$value&&"Blob"===Object.prototype.toString.call(this.$value).slice(8,-1)||newBlobForBinary(t,{});const a=new FileReader;a.addEventListener("load",(async function(){const e=await pe.makeSubmitDialog({submitText:"Save",submit(){const a=$e(e,".view-binary"),r=newBlobForBinary(t,{stringContents:a.value});t.parentElement.$setValue(r),e.close()},children:[["div",["Binary source",["br"],["textarea",{class:"view-binary"},[a.result??""]]]]]})})),a.addEventListener("error",(async function(){console.error(a.error),await pe.alert(a.error.message)})),a.readAsBinaryString(this.$value)}}},[t?"Edit binary data":"View binary data"]]}const Ea={option:["Blob"],stringRegex:/^Blob\((.*)\)$/u,valueMatch:e=>"Blob"===toStringTag(e),toValue(e){const t=JSON.parse(e);return{value:new Blob([t.stringContents],{type:t.type})}},getInput:({root:e})=>$e(e,"button.viewBinary"),setValue({root:e,value:t}){$e(e,"fieldset.blobMetaData").$setValue(t)},getValue({root:e}){return this.getInput({root:e}).$value},viewUI:({value:e,specificSchemaObject:t})=>["div",{dataset:{type:"blob"}},[["b",{class:"emphasis",title:t?.description?"(a Blob)":void 0},[t?.description??"Blob"]],["br"],["br"],["b",["Size (in bytes) "]],String(e.size),["br"],["b",["Content type "]],e.type,["br"],e.type.startsWith("text/")||"application/json"===e.type?(()=>{const t=c("div"),a=new FileReader;return a.addEventListener("load",(function(){t.append(c("div",["Text source",["br"],["textarea",{class:"view-text"},[a.result??""]]]))})),a.addEventListener("error",(function(){console.error(a.error),t.append(a.error.message)})),a.readAsBinaryString(e),t})():binaryButton(e),e.type.startsWith("video/")?(()=>{const t=URL.createObjectURL(e),a=c("video",{src:t,class:"video",$on:{loadeddata(){URL.revokeObjectURL(t)}}});return["div",[a,["button",{class:"play",$on:{click(e){e.preventDefault(),a.play()}}},["Play"]],["button",{class:"pause",$on:{click(e){e.preventDefault(),a.pause()}}},["Pause"]],["button",{class:"replay",$on:{click(e){e.preventDefault(),a.pause(),a.currentTime=0,a.play()}}},["Replay"]]]]})():"",e.type.startsWith("audio/")?(()=>{const t=URL.createObjectURL(e),a=c("audio",{src:t,class:"audio",$on:{loadeddata(){URL.revokeObjectURL(t)}}});return["div",[a,["button",{class:"play",$on:{click(e){e.preventDefault(),a.play()}}},["Play"]],["button",{class:"pause",$on:{click(e){e.preventDefault(),a.pause()}}},["Pause"]],["button",{class:"replay",$on:{click(e){e.preventDefault(),a.pause(),a.currentTime=0,a.play()}}},["Replay"]]]]})():"","application/pdf"===e.type?(()=>{const t=URL.createObjectURL(e);return c("iframe",{class:"PDF",src:t,$on:{load(){URL.revokeObjectURL(t)}}})})():"",e.type.startsWith("image/")?["img",{class:"imageView",src:URL.createObjectURL(e),$on:{load(){URL.revokeObjectURL(this.src)}}}]:""]],editUI:({typeNamespace:e,specificSchemaObject:t,value:a={}})=>["div",{dataset:{type:"blob"},title:t?.description??"Blob"},[["fieldset",{class:"blobMetaData",$custom:{$setValue(e){const t=this;$e(t,".size").value=String(e.size),$e(t,".contentType").value=e.type,$e(t,"button.viewBinary").$value="Blob"===Object.prototype.toString.call(e).slice(8,-1)?e:void 0}}},[["legend",["Current blob data"]],["label",["Size (in bytes) ",["input",{type:"number",step:"1",disabled:!0,class:"size",value:String(a.size)}]]],["br"],["label",["Content type ",["input",{class:"contentType",value:a.type??"",$on:{change(){newBlobForBinary($e(this.parentElement?.parentElement,"button.viewBinary"),{type:this.value})}}}]]],["br"],binaryButton(a,!0),["button",{class:"clearData",$on:{click(e){e.preventDefault(),this.parentElement.$setValue({size:"",type:""})}}},["Clear data"]]]],["fieldset",[["legend",["Supply blob through upload"]],["label",["Blob ",["input",{$on:{change(){if(!this.files)return;const e=this.files[0],t=new Blob([e],{type:e.type}),a=(this.parentElement?.parentElement)?.previousElementSibling;a.$setValue(t)}},name:`${e}-blob`,type:"file"}]]]]],["fieldset",[["legend",["Supply blob through recording"]],(()=>{const e=c("select",{class:"device",$on:{async change(){const t=this.nextElementSibling?.nextElementSibling;$e(t,"img.photo").hidden=!0;const a=$e(t,"video.previewMedia"),r=c("video",{class:"previewMedia"});if(a.$stream){a.$stream.getTracks().forEach((e=>{e.stop()})),a.srcObject=null}a.replaceWith(r);const n=$e(e.nextElementSibling,".takeSnapshot"),i=$e(e.nextElementSibling,".recordMedia");$e(e.nextElementSibling?.nextElementSibling,"div.recordedMedia").hidden=!0;const s=$e(t,"canvas.visualizer");let o,l;switch(r.$screenShare=!1,e.value){case"audio-and-video":o={video:!0,audio:!0},r.hidden=!1,n.hidden=!1,i.textContent="Record video/audio";break;case"video":o={video:!0},r.hidden=!1,n.hidden=!1,i.textContent="Record video";break;case"audio":o={audio:!0},r.hidden=!0,n.hidden=!0,i.textContent="Record audio";break;case"screenShare":l={video:!0};case"screenShareAndVideo":l||(l={video:!0,audio:!0}),r.$screenShare=!0,r.hidden=!0,n.hidden=!0,s.hidden=!0;break;default:return}if(o){const e=await getUserMedia(o);if(!e)return void await pe.alert("Error getting user media");if(t.hidden=!1,r.srcObject=e,r.$stream=e,o.video){const e=$e(t,"canvas.recordedImage");r.addEventListener("canplay",(()=>{e.setAttribute("width",String(r.videoWidth)),e.setAttribute("height",String(r.videoHeight))}))}r.addEventListener("loadedmetadata",(()=>{r.play(),o?.audio?(s.hidden=!1,visualize(e,s)):s.hidden=!0}))}else if(l){const e=await startScreenCapture(l);if(!e)return void await pe.alert("Error getting user media");t.hidden=!1,r.srcObject=e,r.$stream=e}}}},[["option",{value:""},["Please choose a device"]]]);return(async()=>{const t=await navigator.mediaDevices.enumerateDevices();let a=!1,r=!1;t.forEach((e=>{switch(e.kind){case"audioinput":a=!0;break;case"videoinput":r=!0}})),a&&c("option",{value:"audio"},["Microphone only"],e),r&&c("option",{value:"video"},["Video camera only"],e),a&&r&&c("option",{value:"audio-and-video"},["Video camera and microphone"],e),c("option",{value:"screenShare"},["Screen share"],e),c("option",{value:"screenShareAndVideo"},["Screen share and microphone"],e)})(),e})()," ",["div",[["button",{class:"recordMedia",$on:{click(e){e.preventDefault();const t=$e(this.parentElement?.nextElementSibling,"video.previewMedia");if(!t.srcObject)return void pe.alert("No stream found to record");const a=this.parentElement?.nextElementSibling;$e(a,"img.photo").hidden=!0;const r="video/webm",n=new MediaRecorder(t.$stream,{mimeType:r});let i=[];n.addEventListener("dataavailable",(e=>{i.push(e.data)}));try{n.start()}catch{return void pe.alert("Error starting media recorder")}n.addEventListener("stop",(()=>{const e=new Blob(i,{type:r}),t=URL.createObjectURL(e),a=$e(this.parentElement?.nextElementSibling,"video.recordedMedia");a.parentElement.hidden=!1,a.src=t,a.addEventListener("loadeddata",(()=>{URL.revokeObjectURL(t)}));const n=this.closest('[data-type="blob"]');$e(n,"fieldset.blobMetaData").$setValue(e),i=[]})),this.$mediaRecorder=n}}},["Record media"]],["button",{class:"stopRecording",$on:{click(e){e.preventDefault(),this.previousElementSibling.$mediaRecorder.stop()}}},["Stop recording"]],["button",{class:"takeSnapshot",hidden:!0},{$on:{click(e){e.preventDefault();const t=this.parentElement?.nextElementSibling;$e(t,".recordedMedia").hidden=!0;const a=$e(t,"canvas.recordedImage"),r=a.getContext("2d"),n=$e(t,"video.previewMedia");r.drawImage(n,0,0,a.width,a.height);const i=$e(t,"img.photo");a.toBlob((e=>{if(!e)return void pe.alert("Error converting canvas to Blob");const t=c("img",{class:"photo"}),a=URL.createObjectURL(e);t.addEventListener("load",(()=>{URL.revokeObjectURL(a)}));const r=this.closest('[data-type="blob"]');$e(r,"fieldset.blobMetaData").$setValue(e),t.src=a,i.replaceWith(t)}))}}},["Take and use snapshot as blob"]]]],["div",{class:"videoContainer",hidden:!0},[["canvas",{class:"visualizer",hidden:!0}],["br"],["video",{class:"previewMedia"}],["div",[["canvas",{hidden:!0,class:"recordedImage"}],["img",{class:"photo"}]]],["div",{class:"recordedMedia"},[...(()=>{const e=c("video",{class:"recordedMedia"});return[e,["br"],c("button",{class:"play",$on:{click(t){t.preventDefault(),e.play()}}},["Play"]),c("button",{class:"pause",$on:{click(t){t.preventDefault(),e.pause()}}},["Pause"]),c("button",{class:"replay",$on:{click(t){t.preventDefault(),e.pause(),e.currentTime=0,e.play()}}},["Replay"])]})()]]]]]]]]};let Na=0;const $a={option:["DOMException"],stringRegex:/^DOMException\((.*)\)$/u,valueMatch:e=>"DOMException"===toStringTag(e),toValue(e){const{message:t,name:a}=JSON.parse(e);return{value:new DOMException(t,a)}},getInput:({root:e})=>$e(e,"input"),setValue({root:e,value:t}){$e(e,".message").value=t.message,$e(e,".name").value=t.name},getValue({root:e}){const t=$e(e,".message").value,a=$e(e,".name").value;return new DOMException(t,a)},viewUI:({value:e,specificSchemaObject:t})=>["div",{dataset:{type:"domexception"},title:t?.description??"(a `DOMException`)"},[["b",["Message "]],e.message,["br"],["b",["Name "]],e.name,["br"],["b",["Code "]],e.code]],editUI:({typeNamespace:e,specificSchemaObject:t,value:a=""})=>(Na++,["div",{dataset:{type:"domexception"},title:t?.description??"DOMException"},[["label",["Name: ",["input",{class:"name",list:`domExceptionNames-${Na}`,name:`${e}-domexception-name`,value:a?.name??"",size:30,placeholder:"(Optional predefined name)"}]]],["datalist",{id:`domExceptionNames-${Na}`,class:"predefinedNames"},["IndexSizeError","HierarchyRequestError","WrongDocumentError","InvalidCharacterError","NoModificationAllowedError","NotFoundError","NotSupportedError","InvalidStateError","InUseAttributeError","SyntaxError","InvalidModificationError","NamespaceError","InvalidAccessError","TypeMismatchError","SecurityError","NetworkError","AbortError","URLMismatchError","QuotaExceededError","TimeoutError","InvalidNodeTypeError","DataCloneError","EncodingError","NotReadableError","UnknownError","ConstraintError","DataError","TransactionInactiveError","ReadOnlyErrorVersionError","OperationError","NotAllowedError"].map((e=>["option",[e]]))],["br"],["label",["Message: ",["input",{class:"message",name:`${e}-domexception-message`,value:a?.message??""}]]]]])};let _a=0;const Oa={option:["DOMRect"],childTypes:["domrectreadonly"],stringRegex:/^(?<domRectClass>DOMRect|DOMRectReadOnly)\((?<innerContent>.*)\)$/u,valueMatch:e=>["DOMRect","DOMRectReadOnly"].includes(toStringTag(e)),toValue(e,t){const{groups:{domRectClass:a}={}}=t.match,{x:r,y:n,width:i,height:s}=JSON.parse(e);return{value:new("DOMRect"===a?DOMRect:DOMRectReadOnly)(r,n,i,s)}},getInput:({root:e})=>$e(e,"input"),setValue({root:e,value:t}){$e(e,".x").value=String(t.x),$e(e,".y").value=String(t.y),$e(e,".width").value=String(t.width),$e(e,".height").value=String(t.height),"DOMRect"===toStringTag(t)?$e(e,".domrect-readonly-readwrite").checked=!0:$e(e,".domrect-readonly-readonly").checked=!0},getValue({root:e}){const t=Number($e(e,".x").value),a=Number($e(e,".y").value),r=Number($e(e,".width").value),n=Number($e(e,".height").value);return new($e(e,".domrect-readonly-readwrite").checked?DOMRect:DOMRectReadOnly)(t,a,r,n)},viewUI({value:e,specificSchemaObject:t}){const a="DOMRect"===toStringTag(e);return["div",{dataset:{type:"domrect"},title:t?.description?`(a \`${a?"DOMRect":"DOMRectReadOnly"}\`)`:void 0},[["b",{class:"emphasis"},[t?.description??(a?"DOMRect":"DOMRectReadOnly")]],["br"],["b",["x "]],e.x,["br"],["b",["y "]],e.y,["br"],["b",["width "]],e.width,["br"],["b",["height "]],e.height]]},editUI({typeNamespace:e,specificSchemaObject:t,value:a={x:"",y:"",width:"",height:""}}){_a++;const r="any";return["div",{dataset:{type:"domrect"},title:t?.description??"DOMRect"},[["div",[["label",[["input",{type:"radio",class:"domrect-readonly-readwrite",name:`${e}-domrect-readonly-${_a}`,value:"readwrite",checked:"DOMRectReadOnly"!==toStringTag(a)}],"Readwrite"]]," ",["label",[["input",{type:"radio",class:"domrect-readonly-readonly",name:`${e}-domrect-readonly-${_a}`,value:"readonly",checked:"DOMRectReadOnly"===toStringTag(a)}],"Read-only"]]]],["label",["x: ",["input",{type:"number",step:r,class:"x",name:`${e}-domrect-x`,value:a.x}]]],["br"],["label",["y: ",["input",{type:"number",step:r,class:"y",name:`${e}-domrect-y`,value:a.y}]]],["br"],["label",["width: ",["input",{type:"number",step:r,class:"width",name:`${e}-domrect-width`,value:a.width}]]],["br"],["label",["height: ",["input",{type:"number",step:r,class:"height",name:`${e}-domrect-height`,value:a.height}]]]]]}};let ka=0;const Aa={option:["DOMPoint"],childTypes:["dompointreadonly"],stringRegex:/^(?<domPointClass>DOMPoint|DOMPointReadOnly)\((?<innerContent>.*)\)$/u,valueMatch:e=>["DOMPoint","DOMPointReadOnly"].includes(toStringTag(e)),toValue(e,t){const{groups:{domPointClass:a}={}}=t.match,{x:r,y:n,z:i,w:s}=JSON.parse(e);return{value:new("DOMPoint"===a?DOMPoint:DOMPointReadOnly)(r,n,i,s)}},getInput:({root:e})=>$e(e,"input"),setValue({root:e,value:t}){$e(e,".x").value=String(t.x),$e(e,".y").value=String(t.y),$e(e,".z").value=String(t.z),$e(e,".w").value=String(t.w),"DOMPoint"===toStringTag(t)?$e(e,".dompoint-readonly-readwrite").checked=!0:$e(e,".dompoint-readonly-readonly").checked=!0},getValue({root:e}){const t=Number($e(e,".x").value),a=Number($e(e,".y").value),r=Number($e(e,".z").value),n=Number($e(e,".w").value);return new($e(e,".dompoint-readonly-readwrite").checked?DOMPoint:DOMPointReadOnly)(t,a,r,n)},viewUI({value:e,specificSchemaObject:t}){const a="DOMPoint"===toStringTag(e);return["div",{dataset:{type:"dompoint"},title:t?.description?`(a \`${a?"DOMPoint":"DOMPointReadOnly"}\`)`:void 0},[["b",{class:"emphasis"},[t?.description??(a?"DOMPoint":"DOMPointReadOnly")]],["br"],["b",["x "]],e.x,["br"],["b",["y "]],e.y,["br"],["b",["z "]],e.z,["br"],["b",["w "]],e.w]]},editUI({typeNamespace:e,specificSchemaObject:t,value:a={x:"",y:"",z:"",w:""}}){ka++;const r="any";return["div",{dataset:{type:"dompoint"},title:t?.description??"DOMPoint"},[["div",[["label",[["input",{type:"radio",class:"dompoint-readonly-readwrite",name:`${e}-dompoint-readonly-${ka}`,value:"readwrite",checked:"DOMPointReadOnly"!==toStringTag(a)}],"Readwrite"]]," ",["label",[["input",{type:"radio",class:"dompoint-readonly-readonly",name:`${e}-dompoint-readonly-${ka}`,value:"readonly",checked:"DOMPointReadOnly"===toStringTag(a)}],"Read-only"]]]],["label",["x: ",["input",{type:"number",step:r,class:"x",name:`${e}-dompoint-x`,value:a.x}]]],["br"],["label",["y: ",["input",{type:"number",step:r,class:"y",name:`${e}-dompoint-y`,value:a.y}]]],["br"],["label",["z: ",["input",{type:"number",step:r,class:"z",name:`${e}-dompoint-z`,value:a.z}]]],["br"],["label",["w: ",["input",{type:"number",step:r,class:"w",name:`${e}-dompoint-w`,value:a.w}]]]]]}};let Ca=0;const ja={option:["DOMMatrix"],childTypes:["dommatrixreadonly"],stringRegex:/^(?<domMatrixClass>DOMMatrix|DOMMatrixReadOnly)\((?<innerContent>.*)\)$/u,valueMatch:e=>["DOMMatrix","DOMMatrixReadOnly"].includes(toStringTag(e)),toValue(e,t){const{groups:{domMatrixClass:a}={}}=t.match,r=JSON.parse(e),n="DOMMatrix"===a?DOMMatrix:DOMMatrixReadOnly;return{value:Object.hasOwn(r,"a")?new n([r.a,r.b,r.c,r.d,r.e,r.f]):new n([r.m11,r.m12,r.m13,r.m14,r.m21,r.m22,r.m23,r.m24,r.m31,r.m32,r.m33,r.m34,r.m41,r.m42,r.m43,r.m44])}},getInput:({root:e})=>$e(e,"input"),setValue({root:e,value:t}){const{is2D:a}=t;$e(e,".d2").checked=a,$e(e,".d3").checked=!a,$e(e,".holder2d").hidden=!a,$e(e,".holder3d").hidden=a,a?($e(e,".a").value=t.a,$e(e,".b").value=t.b,$e(e,".c").value=t.c,$e(e,".d").value=t.d,$e(e,".e").value=t.e,$e(e,".f").value=t.f):($e(e,".m11").value=t.m11,$e(e,".m12").value=t.m12,$e(e,".m13").value=t.m13,$e(e,".m14").value=t.m14,$e(e,".m21").value=t.m21,$e(e,".m22").value=t.m22,$e(e,".m23").value=t.m23,$e(e,".m24").value=t.m24,$e(e,".m31").value=t.m31,$e(e,".m32").value=t.m32,$e(e,".m33").value=t.m33,$e(e,".m34").value=t.m34,$e(e,".m41").value=t.m41,$e(e,".m42").value=t.m42,$e(e,".m43").value=t.m43,$e(e,".m44").value=t.m44),"DOMMatrix"===toStringTag(t)?$e(e,".dommatrix-readonly-readwrite").checked=!0:$e(e,".dommatrix-readonly-readonly").checked=!0},getValue({root:e}){const t=$e(e,".dommatrix-readonly-readwrite").checked?DOMMatrix:DOMMatrixReadOnly,a=$e(e,".a").value;if(a){return new t([Number(a),Number($e(e,".b").value),Number($e(e,".c").value),Number($e(e,".d").value),Number($e(e,".e").value),Number($e(e,".f").value)])}return new t([Number($e(e,".m11").value),Number($e(e,".m12").value),Number($e(e,".m13").value),Number($e(e,".m14").value),Number($e(e,".m21").value),Number($e(e,".m22").value),Number($e(e,".m23").value),Number($e(e,".m24").value),Number($e(e,".m31").value),Number($e(e,".m32").value),Number($e(e,".m33").value),Number($e(e,".m34").value),Number($e(e,".m41").value),Number($e(e,".m42").value),Number($e(e,".m43").value),Number($e(e,".m44").value)])},viewUI({value:e,specificSchemaObject:t}){const a="DOMMatrix"===toStringTag(e);return["div",{dataset:{type:"dommatrix"}},[["b",{class:"emphasis",title:t?.description?`(a \`${a?"DOMMatrix":"DOMMatrixReadOnly"}\`)`:void 0},[t?.description??(a?"DOMMatrix":"DOMMatrixReadOnly")]],e.is2D?["div",[["b",["a "]],e.a,["br"],["b",["b "]],e.b,["br"],["b",["c "]],e.c,["br"],["b",["d "]],e.d,["br"],["b",["e "]],e.e,["br"],["b",["f "]],e.f]]:["div",[["b",["m11 "]],e.m11,["br"],["b",["m12 "]],e.m12,["br"],["b",["m13 "]],e.m13,["br"],["b",["m14 "]],e.m14,["br"],["b",["m21 "]],e.m21,["br"],["b",["m22 "]],e.m22,["br"],["b",["m23 "]],e.m23,["br"],["b",["m24 "]],e.m24,["br"],["b",["m31 "]],e.m31,["br"],["b",["m32 "]],e.m32,["br"],["b",["m33 "]],e.m33,["br"],["b",["m34 "]],e.m34,["br"],["b",["m41 "]],e.m41,["br"],["b",["m42 "]],e.m42,["br"],["b",["m43 "]],e.m43,["br"],["b",["m44 "]],e.m44]]]]},editUI({typeNamespace:e,specificSchemaObject:t,value:a={}}){Ca++;const{is2D:r}=a;return["div",{dataset:{type:"dommatrix"},title:t?.description??"DOMMatrix"},[["div",[["label",[["input",{type:"radio",class:"dommatrix-readonly-readwrite",name:`${e}-dommatrix-readonly-${Ca}`,value:"readwrite",checked:"DOMMatrixReadOnly"!==toStringTag(a)}],"Readwrite"]]," ",["label",[["input",{type:"radio",class:"dommatrix-readonly-readonly",name:`${e}-dommatrix-readonly-${Ca}`,value:"readonly",checked:"DOMMatrixReadOnly"===toStringTag(a)}],"Read-only"]]]],["div",{$on:{click(e){const{target:t}=e;if("radio"!==t.type)return;const a=this.parentElement;$e(a,".holder2d").hidden="3d"===t.value,$e(a,".holder3d").hidden="2d"===t.value}}},[["label",["2d",["input",{class:"d2",type:"radio",name:`${e}-dommatrix-dimension-${Ca}`,value:"2d",checked:Boolean(r)}]]]," ",["label",["3d",["input",{class:"d3",type:"radio",name:`${e}-dommatrix-dimension-${Ca}`,value:"3d",checked:!r}]]]]],["div",{class:"holder2d",hidden:!r},["a","b","c","d","e","f"].flatMap((t=>[["br"],["label",[t+": ",["input",{type:"number",step:"any",class:t,name:`${e}-dommatrix-${t}`,value:a[t]??""}]]]])).slice(1)],["div",{class:"holder3d",hidden:Boolean(r)},["m11","m12","m13","m14","m21","m22","m23","m24","m31","m32","m33","m34","m41","m42","m43","m44"].flatMap((t=>[["br"],["label",[t+": ",["input",{type:"number",step:"any",class:t,name:`${e}-dommatrix-${t}`,value:a[t]??""}]]]])).slice(1)]]]}},Ra=["setInt8","setUint8","setInt16","setUint16","setInt32","setUint32","setFloat32","setFloat64","setBigInt64","setBigUint64"],Za=["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"],getMinMaxForTypedArray=e=>{switch(e){case"Int8Array":return{min:-128,max:127};case"Uint8Array":case"Uint8ClampedArray":return{min:0,max:255};case"Int16Array":return{min:-32768,max:32767};case"Uint16Array":return{min:0,max:65535};case"Int32Array":return{min:-2147483648,max:2147483647};case"Uint32Array":return{min:0,max:4294967295};case"Float32Array":return{min:-34e37,max:34e37};case"Float64Array":return{min:-Infinity,max:Infinity};case"BigInt64Array":return{min:-(2**63),max:2**63-1};case"BigUint64Array":return{min:0,max:2**64-1};default:throw new Error("Unexpected typed array type")}},getTypedArray=e=>{switch(e){case"Int8Array":return Int8Array;case"Uint8Array":return Uint8Array;case"Uint8ClampedArray":return Uint8ClampedArray;case"Int16Array":return Int16Array;case"Uint16Array":return Uint16Array;case"Int32Array":return Int32Array;case"Uint32Array":return Uint32Array;case"Float32Array":return Float32Array;case"Float64Array":return Float64Array;case"BigInt64Array":return BigInt64Array;case"BigUint64Array":return BigUint64Array;default:throw new Error("Unexpected type")}},Va=new Set(["ArrayBuffer","DataView","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"]);let Ma=0;const Pa={option:["Buffer source (ArrayBuffer, DataView, TypedArrays)"],childTypes:["arraybuffer","dataview","int8array","uint8array","uint8clampedarray","int16array","uint16array","int32array","uint32array","float32array","float64array","bigint64array","biguint64array"],stringRegex:/^(?<bufferSourceClass>ArrayBuffer|DataView|(?:Int8|Uint8|Uint8Clamped|Int16|Uint16|Int32|Uint32|Float32|Float64|BigInt64|BigUint64)Array)\((?<innerContent>.*)\)$/u,valueMatch:e=>Va.has(toStringTag(e)),toValue(e,t){const{groups:{bufferSourceClass:a}={}}=t.match,r=JSON.parse(e),{byteLength:n,maxByteLength:i,byteOffset:s,dataViewByteOffset:o,dataViewByteLength:c,length:l}=r,u=new ArrayBuffer(n,{maxByteLength:i});let d,p,m;return(a.endsWith("Array")||"typedArray"in r)&&(p=getTypedArray(r.typedArray??a),d=new p(u,s,l),"set"in r&&(r.set[0].forEach(((e,t)=>{"string"==typeof e&&(r.set[0][t]=BigInt(e))})),d.set(...r.set))),("DataView"===a||Ra.some((e=>e in r)))&&(m=new DataView(u,o,c),Ra.forEach((e=>{r[e]?.forEach((t=>{"string"==typeof t[1]&&(t[1]=BigInt(t[1])),m[e](...t)}))}))),{value:"ArrayBuffer"===a?u:"DataView"===a?m:d}},getInput:({root:e})=>$e(e,".byteLength"),setValue({root:e,value:t}){const a=toStringTag(t);if("ArrayBuffer"===a||"DataView"===a)$e(e,`[value=${a}].buffersource-returnType`)?.click();else{$e(e,"[value=TypedArray].buffersource-returnType")?.click();const t=$e(e,".buffersource-typedArrays");t.value=a,t.dispatchEvent(new Event("change"))}const r=$e(e,".byteLength");r.$value=t;const n="ArrayBuffer"===a?t:t.buffer;r.value=n.byteLength,r.dispatchEvent(new Event("change"));const i=$e(e,".maxByteLength");if(i.value=n.maxByteLength,i.dispatchEvent(new Event("change")),"DataView"===a){const a=$e(e,".dataViewByteLength");a.value=t.byteLength,a.dispatchEvent(new Event("change"));const r=$e(e,".dataViewByteOffset");r.value=t.byteOffset,r.dispatchEvent(new Event("change"))}else if("ArrayBuffer"!==a){const a=$e(e,".typedArrayByteOffset");a.value=t.byteOffset,a.dispatchEvent(new Event("change"));const r=$e(e,".typedArrayLength");r.value=t.length,r.dispatchEvent(new Event("change"))}},getValue({root:e}){return this.getInput({root:e}).$value},viewUI({value:e,specificSchemaObject:t}){const a=toStringTag(e),r="ArrayBuffer"===a?e:e.buffer;return["div",{dataset:{type:"buffersource"}},[["b",{class:"emphasis",title:t?.description?/^[aeiou]/iu.test(a)?`(an ${a})`:`(a ${a})`:void 0},[t?.description??a]],["br"],["b",["Buffer byte length: "]],r.byteLength,["br"],["b",["Buffer max byte length: "]],r.maxByteLength,..."DataView"===a?[["br"],["b",["Data View byte length: "]],e.byteLength,["br"],["b",["Data View byte offset: "]],e.byteOffset]:[""],..."DataView"!==a&&"ArrayBuffer"!==a?[["br"],["b",["Typed Array byte offset: "]],e.byteOffset,["br"],["b",["Typed Array length: "]],e.length]:[""],["br"],["button",{class:"buffersource-viewData",$on:{async click(e){e.preventDefault();const t=await pe.makeCancelDialog({children:[["select",{class:"buffersource-typedArrays-view","aria-label":"Typed Arrays",$on:{change(){const e=this.value,t=new(getTypedArray(e))(r),a=$e(this.parentElement,".typedArrayArea");a.textContent="",a.append(...Array.from({length:t.length},((e,a)=>c("span",[["b",[a]]," ",["span",[t[a]?String(t[a]):"0"]]," "]))))}}},Za.map((e=>["option",{selected:a===e||void 0},[e]]))],["div",{class:"typedArrayArea"}]]});$e(t,".buffersource-typedArrays-view").dispatchEvent(new Event("change"))}}},["View data"]]]]},editUI({typeNamespace:e,specificSchemaObject:t,value:a}){Ma++;const r=c("div",{dataset:{type:"buffersource"},title:t?.description??"BufferSource"},[["fieldset",{class:"returnType",$on:{change(){this.$buildInstances()}},$custom:{$buildInstances(){const t=this.parentElement,{value:a}=$e(this,`[name=${e}-buffersource-returnType-${Ma}]:checked`),r=$e(t,".byteLength"),n=Number.parseInt(r.value),i=Number.parseInt($e(t,".maxByteLength").value),s=new ArrayBuffer(n,i?{maxByteLength:i}:void 0),o=$e(t,".dataViewByteOffset").value,c=o?Number.parseInt(o):0,l=$e(t,".dataViewByteLength").value,u=l?Number.parseInt(l):void 0,d=new DataView(s,c,u),{value:p}=$e(t,".buffersource-typedArrays-init"),m=getTypedArray(p),y=$e(t,".typedArrayByteOffset").value,h=y?Number.parseInt(y):0,f=$e(t,".typedArrayLength").value,g=f?Number.parseInt(f):n,v=new m(s,h,g);r.$dataView=d,r.$typedArray=v;const b=$$e(t,".typedArrayArea .typedArrayValue").map((e=>m.name.startsWith("Big")?BigInt(e.value):Number(e.value)));switch(r.$typedArray.set(b,0),a){case"ArrayBuffer":r.$value=s;break;case"DataView":r.$value=d;break;default:r.$value=v}}}},[["legend",["Return type"]],["label",{$on:{click(){$e(this.parentElement,".buffersource-typedArrays").hidden=!0,$e(this?.parentElement?.parentElement,".buffersource-typedArrays-init").hidden=!1}}},[["input",{type:"radio",class:"buffersource-returnType buffersource-returnType-arraybuffer",name:`${e}-buffersource-returnType-${Ma}`,checked:!0,value:"ArrayBuffer"}],"ArrayBuffer"]]," ",["label",{$on:{click(){$e(this.parentElement,".buffersource-typedArrays").hidden=!0,$e(this?.parentElement?.parentElement,".buffersource-typedArrays-init").hidden=!1}}},[["input",{type:"radio",class:"buffersource-returnType buffersource-returnType-dataview",name:`${e}-buffersource-returnType-${Ma}`,value:"DataView"}],"DataView"]]," ",["label",{$on:{click(){$e(this.parentElement,".buffersource-typedArrays").hidden=!1,$e(this?.parentElement?.parentElement,".buffersource-typedArrays-init").hidden=!0}}},[["input",{type:"radio",class:"buffersource-returnType buffersource-returnType-typedarray",name:`${e}-buffersource-returnType-${Ma}`,value:"TypedArray"}],"Typed Array"]]," ",["select",{hidden:!0,class:"buffersource-typedArrays","aria-label":"Typed Arrays",$on:{change(e){const t=this.parentElement?.parentElement,a=$e(t,".buffersource-typedArrays-init");a.value=this.value;if(!$e(t,".typedArrayLength").$checkBufferBounds(e))return;a.$setMinsAndMaxes(this.value),a.$checkTypedArrayByteLength(e);$e(this?.parentElement?.parentElement,".typedArrayByteOffset").$checkByteOffsetMultiple(e)}}},Za.map((e=>["option",[e]]))]]],["fieldset",{$on:{change(){this.previousElementSibling.$buildInstances()}}},[["legend",["Construction options"]],["fieldset",[["legend",["ArrayBuffer"]],["label",["Byte length ",["input",{class:"byteLength",type:"number",step:"1",size:"4",pattern:String.raw`\d+`,min:0,$custom:{$value:a??new ArrayBuffer(0)},$on:{change(e){const t=this,a=t.parentElement?.parentElement?.parentElement?.parentElement;if(!$e(a,".typedArrayLength").$checkBufferBounds(e))return;const r=$e(t.parentElement?.parentElement,".maxByteLength"),n=t.value;if(Number.parseInt(n)>Number.MAX_SAFE_INTEGER)return t.setCustomValidity("The ArrayBuffer length exceeds the maximum allowable size"),e.stopPropagation(),void t.reportValidity();t.setCustomValidity(""),t.reportValidity(),Number.parseInt(n)>Number.parseInt(r.value)&&(r.value=n);const i=t.parentElement?.parentElement?.parentElement;$e(i,".dataViewByteLength").$checkDataViewByteLength(e),$e(i.parentElement,".buffersource-typedArrays-init").$checkTypedArrayByteLength(e)}}}]]]," ",["label",["Max byte length ",["input",{class:"maxByteLength",type:"number",step:"1",size:"4",pattern:String.raw`\d+`,min:0,$on:{change(e){const t=this,a=$e(t.parentElement?.parentElement,".byteLength"),r=t.value;Number.parseInt(r)<Number.parseInt(a.value)?(t.setCustomValidity("The max value cannot be less than the byte length"),e.stopPropagation()):t.setCustomValidity(""),t.reportValidity()}}}]]]]],["fieldset",[["legend",["DataView"]],["label",["Byte length ",["input",{class:"dataViewByteLength",type:"number",step:"1",size:"4",pattern:String.raw`\d+`,min:0,$custom:{$checkDataViewByteLength(e){const t=this,a=t.parentElement?.parentElement?.parentElement,r=Number.parseInt($e(a,".dataViewByteOffset").value)||0,n=$e(a,".byteLength").value,i=n?Number.parseInt(n):0;r+(t.value?Number.parseInt(t.value):i)>i?(t.setCustomValidity("The DataView byte length and offset exceed the buffer's byte length"),e.stopPropagation()):t.setCustomValidity(""),t.reportValidity()}},$on:{change(e){this.$checkDataViewByteLength(e)}}}]]]," ",["label",["Byte offset ",["input",{class:"dataViewByteOffset",type:"number",step:"1",size:"4",pattern:String.raw`\d+`,min:0,$on:{change(e){const t=this.parentElement?.parentElement?.parentElement;$e(t,".dataViewByteLength").$checkDataViewByteLength(e)}}}]]]]],["fieldset",[["legend",["Typed array"]],["label",["Byte offset ",["input",{class:"typedArrayByteOffset",type:"number",step:"1",size:"4",pattern:String.raw`\d+`,min:0,max:2**53-1,$custom:{$checkByteOffsetMultiple(e){const t=this,a=t.parentElement?.parentElement?.parentElement?.parentElement,{value:r}=$e(a,".buffersource-typedArrays-init"),n=getTypedArray(r);Number.parseInt(t.value)%n.BYTES_PER_ELEMENT?(t.setCustomValidity(`Byte offset must be a multiple of the typed array's bytes-per-element size (${n.BYTES_PER_ELEMENT})`),e.stopPropagation()):t.setCustomValidity(""),t.reportValidity()}},$on:{change(e){const t=this.parentElement?.parentElement?.parentElement?.parentElement;$e(t,".typedArrayLength").$checkBufferBounds(e)&&this.$checkByteOffsetMultiple(e)}}}]]]]]]],["fieldset",[["legend",["Typed Array initialization (optional)"]],["select",{class:"buffersource-typedArrays-init","aria-label":"Typed Arrays",$custom:{$setMinsAndMaxes(e){const{min:t,max:a}=getMinMaxForTypedArray(e);$$e(this.parentElement,".typedArrayValue").forEach((r=>{r.className="typedArrayValue typedArray-"+e,r.min=String(t),r.max=String(a)}))},$checkTypedArrayByteLength(e){const t=getTypedArray(this.value),a=$e(this.parentElement?.parentElement,".byteLength");(a.value?Number.parseInt(a.value):0)%t.BYTES_PER_ELEMENT?(a.setCustomValidity(`Array buffer must be a multiple of the typed array's bytes-per-element size (${t.BYTES_PER_ELEMENT})`),e.stopPropagation()):a.setCustomValidity(""),a.reportValidity()}},$on:{change(e){const t=this,a=t.parentElement?.parentElement?.parentElement;$e(this.parentElement?.parentElement,".buffersource-typedArrays").value=t.value;if(!$e(a,".typedArrayLength").$checkBufferBounds(e))return;t.$checkTypedArrayByteLength(e),t.$setMinsAndMaxes(t.value);$e(t?.parentElement?.parentElement,".typedArrayByteOffset").$checkByteOffsetMultiple(e),$e(this.parentElement?.parentElement,".returnType").$buildInstances()}}},Za.map((e=>["option",[e]]))]," ",["label",["Array length: ",["input",{class:"typedArrayLength",type:"number",step:"1",size:"4",pattern:String.raw`\d+`,min:0,$custom:{$checkBufferBounds(e){const t=this,a=t.parentElement?.parentElement?.parentElement,r=$e(a,".byteLength").value,n=r?Number.parseInt(r):0,i=t.value?Number.parseInt(t.value):n,{value:s}=$e(a,".buffersource-typedArrays-init"),o=getTypedArray(s),c=$e(a,".typedArrayByteOffset").value;return(c?Number.parseInt(c):0)+i*o.BYTES_PER_ELEMENT>n?(t.setCustomValidity("The byte offset and the length times bytes per element is greater than the buffer length"),e.stopPropagation(),t.reportValidity(),!1):(t.setCustomValidity(""),t.reportValidity(),!0)},$buildTypedArray(){const e=this,t=Number.parseInt(e.value),a=e.parentElement?.parentElement,r=e.parentElement?.parentElement?.parentElement,n=$e(r,".byteLength"),i=$e(a,".typedArrayArea");i.addEventListener("change",(e=>{const t=e.target;n.$typedArray.set(["true"===t.dataset.bigint?BigInt(t.value):Number(t.value)],Number.parseInt(t.dataset.key))}));const{value:s}=$e(a,".buffersource-typedArrays-init"),{min:o,max:l}=getMinMaxForTypedArray(s);i.textContent="",i.append(...Array.from({length:t},((e,t)=>c("label",[t," ",["input",{class:"typedArrayValue typedArray-"+s,dataset:{key:t,bigint:String(s.startsWith("BigInt"))},type:"number",step:"1",pattern:s.startsWith("Float")?String.raw`\d+(?:\.\d+)?`:String.raw`\d+`,value:n.$typedArray[t]?String(n.$typedArray[t]):"0",min:o,max:l}]," "]))))}},$on:{change(e){const t=this,a=this.parentElement?.parentElement;if(!t.$checkBufferBounds(e))return;const{value:r}=$e(a,".buffersource-typedArrays-init"),n=Number.parseInt(t.value);try{new(getTypedArray(r))(n)}catch{return t.setCustomValidity("Typed Array length is too long"),e.stopPropagation(),void t.reportValidity()}t.setCustomValidity(""),t.reportValidity(),$e(this.parentElement?.parentElement?.parentElement,".returnType").$buildInstances(),t.$buildTypedArray()}}}],["div",{class:"typedArrayArea"}]]]]],["fieldset",[["legend",["DataView initialization (optional)"]],["select",{class:"dataViewMethod","aria-label":"Data View methods",$on:{change(){const e=$e(this.parentElement,".dataViewArea"),t=this.value,a=t.slice(3)+"Array";e.textContent="",e.append(c("label",["Byte offset ",["input",{type:"number",class:"dataViewSetByteOffset",step:"1",size:"4",pattern:String.raw`\d+`}]])," ",c("label",["Value ",["input",{type:"number",step:"1",size:"4",pattern:String.raw`\d+`,class:"typedArrayValue typedArray-"+a,...getMinMaxForTypedArray(a)}]]),"setInt8"===t||"setUint8"===t?"":c("label",[["input",{class:"littleEndian",type:"checkbox"}],"Little endian"])," ",c("button",{$on:{click(e){e.preventDefault();const t=this.parentElement,a=t.previousElementSibling?.value,r=Number.parseInt($e(t,".dataViewSetByteOffset").value),n=$e(t,".typedArrayValue").value,i=$e(t,".littleEndian")?.checked,s=$e(t?.parentElement?.parentElement,".byteLength");"setBigInt64"===a||"setBigUint64"===a?s.$dataView[a](r,BigInt(n),i):s.$dataView[a](r,Number(n),i);$e(t.parentElement?.parentElement,".typedArrayLength").$buildTypedArray()}}},["Set"]))}}},[["option",{value:""},["(Select a data view method)"]],...Ra.map((e=>["option",[e]]))]]," ",["div",{class:"dataViewArea"}]]]]);if(this.setValue&&a)this.setValue({root:r,value:a});else{$e(r,".byteLength").$value=new ArrayBuffer(0)}return[r]}},Ua={option:["Non-editable"],valueMatch:()=>!0,getInput:({root:e})=>$e(e,"button"),setValue({root:e,value:t}){this.getInput({root:e}).$value=t,$e(e,".stringTag").textContent=void 0===t?"(None)":toStringTag(t)},getValue({root:e}){return this.getInput({root:e}).$value},validate({root:e}){return{message:"The non-editable type is only for passing on pre-existing content that is unknown or currently unsupported",valid:void 0!==this.getInput({root:e}).$value}},viewUI({value:e,specificSchemaObject:t}){const a=toStringTag(e);return["div",{dataset:{type:"resurrectable"}},[["b",{class:"emphasis",title:t?.description?`(a non-editable ${a})`:void 0},[t?.description??"Non-editable"]],["span",{title:"There is no current support for editing this element's type, but its contents will be passed on transparently."},["?"]],["b",["String tag: "]],a]]},editUI:({typeNamespace:e,specificSchemaObject:t,value:a})=>["div",{dataset:{type:"resurrectable"},title:t?.description??"Non-editable"},[["a",{href:"javascript:void(0)",$on:{click(e){e.preventDefault()}},title:"There is no current support for editing this element's type, but its contents will be passed on transparently."},["?"]]," ",["button",{$on:{click(e){e.preventDefault(),console.log(this.$value)}},name:`${e}-resurrectable`,$custom:{$value:a}},["Non-editable"]],["br"],["b",["String tag: "]],["span",{class:"stringTag"},[a?toStringTag(a):"(None)"]]]]},Ba={stringRegex:/^never$/u,option:["Never"],valueMatch:()=>!1,toValue(){throw new Error("Cannot convert to value")},getValue(){return this.toValue("")},viewUI:({specificSchemaObject:e})=>["i",{dataset:{type:"never"},title:e?.description??"(a `never`)"},["never"]],getInput:({root:e})=>$e(e,"input"),editUI:({typeNamespace:e})=>["div",{dataset:{type:"never"}},[["label",["Never (no value present here)",["input",{type:"checkbox",name:`${e}-never`,hidden:!0}]]]]]},Da={option:["Catch"],stringRegex:/^catch\((.*)\)$/u,valueMatch:e=>["number","string"].includes(typeof e),toValue:e=>({value:'"'===e.charAt(0)?e.slice(1,-1):Number(e)}),getInput:({root:e})=>$e(e,"input,textarea"),setValue({root:e,value:t}){setTimeout((()=>{this.getInput({root:e}).value=t}))},getValue({root:e}){return this.getInput({root:e}).value},viewUI:({specificSchemaObject:e,types:t,resultType:a,typeNamespace:r,topRoot:n,format:i,bringIntoFocus:s,buildTypeChoices:o,replaced:c,value:l})=>["span",{dataset:{type:"catch"},title:e?.description??"(a catch)"},[["b",["Catch"]],["br"],"Default value",["br"],["div",{class:"defaultValue"},[t.getUIForModeAndType({readonly:!0,specificSchemaObject:e?.innerType,hasValue:!0,value:l,resultType:a,typeNamespace:r,type:e?.innerType?.type,topRoot:n,bringIntoFocus:s,buildTypeChoices:o,format:i,replaced:c})]],"Catch value",["br"],["div",{class:"catchValue"},[t.getUIForModeAndType({readonly:!0,specificSchemaObject:{...e?.innerType,description:"(catch value)"},hasValue:!0,value:e.value,resultType:a,typeNamespace:r,type:e?.innerType?.type,topRoot:n,bringIntoFocus:s,buildTypeChoices:o,format:i,replaced:c})]]]],editUI({format:e,type:t,buildTypeChoices:a,specificSchemaObject:r,topRoot:n,schemaContent:i,typeNamespace:s,value:o}){const c=r?.value;return["div",{dataset:{type:"catch"},title:r?.description??"(a `catch`)"},[["label",[["b",{title:String(c)},["Value"]]," ",...a({topRoot:n,format:e,setValue:!0,value:o??c,schemaOriginal:i,schemaContent:r?.innerType,state:t,typeNamespace:s}).domArray]]]]}},La={option:["Native enum"],stringRegex:/^nativeEnum\((.*)\)$/u,valueMatch:e=>["number","string"].includes(typeof e),toValue(e,t){const a='"'===e.charAt(0)?e.slice(1,-1):Number(e);let r=t?.schemaObject;if("union"===t?.schemaObject?.type){r=t.schemaObject.options.filter((e=>"nativeEnum"===e.type)).find((e=>a in e.values))}const n=r?.values[a];return{value:n}},getInput:({root:e})=>$e(e,"input.nativeEnumKey"),setValue({root:e,value:t}){const a=this.getInput({root:e});a.value=Object.entries(a.$schemaNativeEnumValues).find((([,e])=>e===t))?.[0]??"",a.value&&($e(e,".enumeratedValue").textContent=t)},getValue({root:e}){const{value:t,$schemaNativeEnumValues:a}=this.getInput({root:e});return a[t]},viewUI:({value:e,specificSchemaObject:t})=>["div",["Native enum: ",["span",{dataset:{type:"nativeEnum"},title:t?.description??"(a native enum)"},[e]]]],editUI(e){const{specificSchemaObject:t,value:a}=e,r=t?.values,n=Object.keys(r);let i;r&&"value"in e&&(i=Object.entries(r).find((([,e])=>e===a))?.[0]);const s=n.map((e=>/^\d$/u.test(e)&&Object.values(r).includes(Number.parseInt(e))?null:escapeRegex(e))).filter(Boolean).join("|"),o=c("input",{class:"nativeEnumKey",placeholder:s,title:s,pattern:s,value:i??"",$on:{input(){const e=this.parentElement?.parentElement?.querySelector(".enumeratedValue");e.textContent=String(r[this.value]??"")}}});return o.$schemaNativeEnumValues=r,["div",{dataset:{type:"nativeEnum"},title:t?.description??"Native Enum"},[["label",["Enumerated key ",o]],["br"],"Enumerated value: ",["span",{class:"enumeratedValue"},[a??""]]]]}},getPropertyValueFromLegend=e=>{const t=$e(e,'*[data-prop="true"]');if(!t)throw new Error("No property on the supplied legend element");if("input"===t.nodeName.toLowerCase())return t.value;if(!t.textContent)throw new Error("No property with text present on the supplied legend element");return String(Number.parseInt(t.textContent)-1)};class Types{constructor(){this.formats=new Formats,this.customValidateAllReferences=void 0,this.availableTypes={null:Ct,true:jt,false:Rt,nan:Zt,boolean:Mt,number:Pt,bigint:Ut,bigintObject:Bt,string:Gt,arrayReference:Xt,objectReference:Qt,array:ta,tuple:aa,object:ra,record:na,date:ia,enum:sa,userObject:["User objects"],undef:ua,void:da,SpecialRealNumber:fa,SpecialNumber:ga,error:va,errors:xa,regexp:pa,BooleanObject:ma,NumberObject:ya,StringObject:ha,literal:la,map:ca,set:oa,file:Ia,filelist:Ta,blob:Ea,blobHTML:Vt,domexception:$a,domrect:Oa,dompoint:Aa,dommatrix:ja,resurrectable:Ua,never:Ba,catch:Da,nativeEnum:La,buffersource:Pa,dataview:{option:["DataView"]},imagedata:{option:["ImageData"]},imagebitmap:{option:["ImageBitmap"]},int8array:{option:["Int8Array"]},uint8array:{option:["Uint8Array"]},uint8clampedarray:{option:["Uint8ClampedArray"]},int16array:{option:["Int16Array"]},uint16array:{option:["Uint16Array"]},int32array:{option:["Int32Array"]},uint32array:{option:["Uint32Array"]},float32array:{option:["Float32Array"]},float64array:{option:["Float64Array"]},ValidDate:{valid:!0},arrayNonindexKeys:{sparse:!0}};(e=>{e.forEach((([e,t])=>{Object.assign(this.availableTypes[t],this.availableTypes[e])}))})([["date","ValidDate"],["array","arrayNonindexKeys"]]),this.contexts={},Object.entries(this.availableTypes).forEach((([e,t])=>{const a=e,{stateDependent:r}=t;r&&Object.entries(r).forEach((([e,t])=>{this.contexts[e]||(this.contexts[e]={});const{contexts:r,after:n}=t;r.forEach((t=>{this.contexts[e][t]||(this.contexts[e][t]=[]),this.contexts[e][t].push({type:a,after:n})}))}))}))}async getControlsForFormatAndValue(e,t,a){return(await this.formats.getControlsForFormatAndValue(this,e,t,a)).rootUI}getContextInfo(e,t){return this.contexts[e][t]}getValueForRoot(e,t,a){return this.availableTypes[Types.getTypeForRoot(e)].getValue({root:e,stateObj:t??{types:this},currentPath:a})}getFormControlForRoot(e){const t=this.availableTypes[Types.getTypeForRoot(e)];return t.getInput?t.getInput({root:e}):null}getValueFromRootAncestor(e,t){return this.getValueForRoot($e(e,"div[data-type]"),{...t,types:this,formats:this.formats})}getFormControlFromRootAncestor(e){const t=$e(e,"div[data-type]");return t?this.getFormControlForRoot(t):null}getOptionForType(e,t=void 0){const a=[...this.availableTypes[e].option];return t&&t.description&&(a[0]=`${a[0]} (${t.description})`),a[1]={value:e,...a[1]},a}getTypeOptionsForFormatAndState(e,t,a,r){const n=this.formats.getTypesAndSchemasForFormatAndState(this,e,t,a,r);if(!n)throw new Error("Unexpected type for format and state");return{typeOptions:n.types.map(((e,t)=>this.getOptionForType(e,n.schemaObjects[t]))),schemaObjects:n.schemaObjects}}getUIForModeAndType({readonly:e,resultType:t,typeNamespace:a,type:r,topRoot:n,bringIntoFocus:i,buildTypeChoices:s,format:o,schemaContent:l,value:u,hasValue:d,replaced:p,specificSchemaObject:m,schemaFallingBack:y}){const h=this.availableTypes[r],f=d?{typeNamespace:a,type:r,buildTypeChoices:s,format:o,schemaContent:l,resultType:t,topRoot:n,bringIntoFocus:i,value:u,replaced:p,specificSchemaObject:m,schemaFallingBack:y,types:this}:{typeNamespace:a,type:r,buildTypeChoices:s,format:o,schemaContent:l,resultType:t,topRoot:n,bringIntoFocus:i,replaced:p,specificSchemaObject:m,schemaFallingBack:y,types:this},g=c(...e?h.viewUI(f):h.editUI(f));if(!e&&h.validate){h.getInput({root:g}).addEventListener("input",(()=>{this.validate({type:r,root:g,topRoot:n})}))}return g}validateAllReferences({topRoot:e}){e?(Object.values(this.availableTypes).forEach((t=>{const a=t;a.validateAll&&a.validateAll({topRoot:e,types:this})})),this.customValidateAllReferences&&this.customValidateAllReferences({topRoot:e})):console.log("No references present")}validate({type:e,root:t,topRoot:a,avoidReport:r}){const n=this.availableTypes[e];if(n.validate){const{valid:e,message:i}=n.validate({root:t,topRoot:a}),s=n.getInput({root:t});return s.setCustomValidity(e?"":i||"Invalid"),r||s.reportValidity(),e}return!0}setValue({type:e,root:t,value:a}){const r=this.availableTypes[e];r.setValue&&r.setValue({root:t,value:a})}getValueForString(e,{format:t,state:a,endMatchTypeObjs:r=[],firstRun:n=!0,rootHolder:i=[],parent:s,parentPath:o,schemaObject:c,schemaOriginal:l}){const u=this.formats.getTypesAndSchemasForFormatAndState(this,t,a,c,l)?.types;if(!u)throw new Error("Could not get types for format and state");const d=Object.entries(this.availableTypes).filter((([e])=>u.includes(e))),p="|"+d.map((([,e])=>e)).reduce(((e,t)=>{const a=t;let r=e;return a.regexEndings&&(r.push(...a.regexEndings),r=[...new Set(r)]),r}),[]).map((e=>escapeRegex(e))).join("|");let m=null,y=d.find((([,t])=>{const a=t;let{stringRegex:r}=a;return"function"==typeof a.stringRegex&&(r=a.stringRegex(!0)),r=r?new RegExp(r.source.slice(0,-1)+"(?=$"+p+")","u"):r,m=Boolean(r&&e)&&e.match(r),m})),h=!1;void 0===y&&(y=d.find((([,t])=>{const a=t,{stringRegexBegin:n}=a;return m=Boolean(n&&e)&&e.match(n),m&&(h=!0,r.push(a)),m})));let f=!0;if(void 0!==y){const a=m,[l,u]=a;let d,p=e.slice(l.length);e=e.slice(0,l.length);try{const n=y[1];if(!n.toValue)throw new Error("Type has no `toValue` method");d=n.toValue(a.groups?.innerContent||u||e,{types:this,format:t,match:m,endMatchTypeObjs:r,remnant:p,rootHolder:i,parent:s,parentPath:o,schemaObject:c})}catch(e){throw console.log("eee",e),e}!1===d.assign&&(f=!1);const{value:g}=d;if(void 0!==d.remnant&&({remnant:p}=d),h&&r.length){const e=p.match(r.at(-1).stringRegexEnd);e&&(r.pop(),p=p.slice(e[0].length))}if(n){const e=(new b).register(ce);try{const t=e.revive(g);return i.forEach((([e,a,r,n])=>{const i=this.availableTypes[e+"Reference"].resolveReference(n,t),s=getJSONType(i);["array","object"].includes(e)&&s===e&&(a[r]=i)})),[t,p,h,f]}catch(e){console.log("failed Typeson revival",e)}}return[g,p,h,f]}throw new Error("Bad parsing data")}getTypeObject(e){return this.availableTypes[e]}}function escapeRegex(e){return String(e).replaceAll(/[.\\+*?^[\]$(){}=!<>|:-]/gu,String.raw`\$&`)}Types.getTypeForRoot=e=>String(e?e.dataset.type:e),Types.validValuesSet=({form:e,typeNamespace:t,keySelectClass:a})=>{if(!e.offsetParent||!e.checkValidity())return!1;return $$e(e,a?`.${a}`:`.typeChoices-${t}`).every((e=>!e.offsetParent||""!==e.value&&e.$validate()))};const getFormatAndSchemaChoices=({schemas:e,selectedSchema:t,hasKeyPath:a}={})=>{const r=e&&e.length;return[["JSON only",{value:"json"}],...a?[]:[["IndexedDB key",{value:"indexedDBKey"}]],["Structured Clone (via Typeson JSON)",{value:"structuredCloning",selected:!r}],...r?e.map(((e,a)=>[`Schema: ${e}`,{value:"schema",dataset:{schema:e},selected:t?e===t:0===a}])):[]].map((([e,t])=>c("option",t,[e]))).reduce(((e,t)=>(e.append(t),e)),document.createDocumentFragment())};async function formatAndTypeChoices({schemas:e,getSchemaContent:t,hasValue:a,singleValue:r,hasKeyPath:n,typeNamespace:i,selectedSchema:s,formats:o=new Formats,types:l=new Types}){const u=e&&e.length?"schema":"structuredCloning",d=c("select",{class:"formatChoices",hidden:r,$custom:{async $setFormat({valueFormat:e,autoTrigger:t,schema:a}){if(a){const e=[...this.options].findIndex((e=>e.dataset.schema===a));this.selectedIndex=-1===e?0:e}else e&&(this.value=e);await this.$buildTypeChoices(t)},async $buildTypeChoices(e){DOM_removeChildren(p);const{schema:r}=this.selectedOptions[0].dataset;c({"#":buildTypeChoices({autoTrigger:e,topRoot:$e(p,"div[data-type]"),format:this.value,formats:o,types:l,typeNamespace:i,requireObject:n,objectHasValue:a,schema:r,schemaContent:r?await(t?.(r)):void 0}).domArray},p)}},$on:{async change(){await this.$buildTypeChoices()}}},[getFormatAndSchemaChoices({schemas:e,hasKeyPath:n,selectedSchema:s})]),p=c("div",{class:"typesHolder",$custom:{$getTypeRoot(){return $e(this,"div[data-type]")},$getTypeSelect(){return $e(this,`.typeChoices-${i}`)}}}),m="schema"===u?d.selectedOptions[0].dataset.schema:void 0;return c({"#":buildTypeChoices({topRoot:$e(p,"div[data-type]"),format:u,formats:o,types:l,typeNamespace:i,requireObject:n,objectHasValue:a,schema:m,schemaContent:await(t?.(m))}).domArray},p),{formats:o,types:l,formatChoices:d,typesHolder:p,domArray:[d,p],getValue(e,t){const a=p.$getTypeRoot();return l.getValueForRoot(a,{typeNamespace:i,format:d.value,formats:o,types:l,...e},t)},getType(){const e=p.$getTypeRoot();return Types.getTypeForRoot(e)},validValuesSet(){const e=p.$getTypeRoot().closest("form");return Types.validValuesSet({form:e,typeNamespace:i})},async setValue(e,t){const a=(await o.getControlsForFormatAndValue(l,d.value,e,t)).rootUI,r=Types.getTypeForRoot(a);p.$getTypeSelect().$addTypeAndEditUI({type:r,editUI:a})}}}export{Formats,Types,formatAndTypeChoices,getFormatAndSchemaChoices,getTypesForSchema,buildTypeChoices as typeChoices};
|
|
1
|
+
import"react";let e;"undefined"!=typeof window&&window&&(e=window);let t="undefined"!=typeof document&&document||e?.document;const a=["$plugins","$map"],r="http://www.w3.org/1999/xhtml",n=/-([a-z])/gu,i=new Map([["maxlength","maxLength"],["minlength","minLength"],["readonly","readOnly"]]),s=["checked","defaultChecked","defaultSelected","disabled","indeterminate","open","readOnly","selected","accessKey","async","autocapitalize","autofocus","contentEditable","defaultValue","defer","draggable","formnovalidate","hidden","innerText","inputMode","ismap","multiple","novalidate","pattern","required","spellcheck","translate","value","willvalidate"],o=["autocomplete","dir","integrity","lang","max","min","minLength","maxLength","title"],$$2=e=>{if(!t)throw new Error("No document object");return t.querySelector(e)};function _appendNode(e,t){"template"!==function _getHTMLNodeName(e){return e.nodeName&&e.nodeName.toLowerCase()}(e)?e.append(t):e.content.append(t)}function _createSafeReference(e,a,r){if(!t)throw new Error("No document defined");if(!/^\w+$/u.test(r))throw new TypeError(`Bad ${e} reference; with prefix "${a}" and arg "${r}"`);const n=t.createElement("div");return n.innerHTML="&"+a+r+";",t.createTextNode(n.innerHTML)}function _upperCase(e,t){return t.toUpperCase()}function _isNullish(e){return null==e}function _getType(e){const t=typeof e;if("string"==typeof e||void 0===e)return"string";if("object"===t){if(null===e)return"null";if(Array.isArray(e))return"array";if("nodeType"in e)switch(e.nodeType){case 1:return"element";case 9:return"document";case 11:return"fragment";default:return"non-container node"}}return t}function _fragReducer(e,t){return e.append(t),e}function _replaceDefiner(e){return function(...t){const a=t[0];let r=e[""]?' xmlns="'+e[""]+'"':a;for(const[t,a]of Object.entries(e))""!==t&&(r+=" xmlns:"+t+'="'+a+'"');return r}}function _childrenToJML(e){return function(t,a){const r=e.childNodes[a],n=Array.isArray(t)?c(...t):c(t);r.replaceWith(n)}}function _appendJML(e){return function(t){if("string"==typeof t||"number"==typeof t)throw new TypeError("Unexpected text string/number in the head");Array.isArray(t)?e.append(c(...t)):"object"==typeof t&&"nodeType"in t?e.append(t):e.append(c(t))}}function _appendJMLOrText(e){return function(t){"string"==typeof t||"number"==typeof t?e.append(String(t)):Array.isArray(t)?e.append(c(...t)):"object"==typeof t&&"nodeType"in t?e.append(t):e.append(c(t))}}function checkPluginValue(e,t,a,r,n){if(r.$state=n??"attributeValue",a&&"object"==typeof a){const n=getMatchingPlugin(r,Object.keys(a)[0]);if(n)return n.set({opts:r,element:e,attribute:{name:t,value:a}})}return a}function getMatchingPlugin(e,t){return e.$plugins&&e.$plugins.find((e=>e.name===t))}const c=function jml(...c){if(!e)throw new Error("No window object");if(!t)throw new Error("No document object");let l=t.createDocumentFragment();function _checkAtts(e){if(!t)throw new Error("No document object");for(let[h,f]of Object.entries(e))if(h=i.get(h)??h,o.includes(h))f=checkPluginValue(l,h,f,p),_isNullish(f)||(l[h]=f);else if(s.includes(h))f=checkPluginValue(l,h,f,p),l[h]=f;else switch(h){case"#":p.$state="fragmentChildren",u[u.length]=jml(p,f);break;case"$shadow":{const{open:e,closed:a}=f;let{content:r,template:n}=f;const i=l.attachShadow({mode:a||!1===e?"closed":"open"});n?(Array.isArray(n)?n="object"===_getType(n[0])?jml("template",...n,t.body):jml("template",n,t.body):"string"==typeof n&&(n=$$2(n)),jml(n.content.cloneNode(!0),i)):(r||!0!==e&&(r=e||"boolean"==typeof a?r:a),r&&"boolean"!=typeof r&&(Array.isArray(r)?jml({"#":r},i):jml(r,i)));break}case"$state":case"is":case"xmlns":break;case"$custom":Object.assign(l,f);break;case"$define":{if(!("localName"in l))throw new Error("Element expected for `$define`");const a=l.localName.toLowerCase(),r=!a.includes("-");let n;if(r&&(n=l.getAttribute("is"),!n)){if(!Object.hasOwn(e,"is"))throw new TypeError(`Expected \`is\` with \`$define\` on built-in; args: ${JSON.stringify(c)}`);e.is=checkPluginValue(l,"is",e.is,p),l.setAttribute("is",e.is),({is:n}=e)}const i=r?n:a;if(window.customElements.get(i))break;const getConstructor=e=>{if(!t)throw new Error("No document object");const n="object"==typeof o&&"string"==typeof o.extends?t.createElement(o.extends).constructor:r?t.createElement(a).constructor:window.HTMLElement;return e?class extends n{constructor(){super(),e.call(this)}}:class extends n{}};let s,o,u;const d=f;Array.isArray(d)?d.length<=2?([s,o]=d,"string"==typeof o?o={extends:o}:o&&!Object.hasOwn(o,"extends")&&(u=o),"object"==typeof s&&(u=s,s=getConstructor())):([s,u,o]=d,"string"==typeof o&&(o={extends:o})):"function"==typeof d?s=d:(u=d,s=getConstructor()),s.toString().startsWith("class")||(s=getConstructor(s)),!o&&r&&(o={extends:a}),u&&Object.entries(u).forEach((([e,t])=>{s.prototype[e]=t})),window.customElements.define(i,s,"object"==typeof o?o:void 0);break}case"$symbol":{const[e,t]=f;if("function"==typeof t){const a=t.bind(l);"string"==typeof e?l[Symbol.for(e)]=a:l[e]=a}else{const a=t;a.elem=l,"string"==typeof e?l[Symbol.for(e)]=a:l[e]=a}break}case"$data":setMap(f);break;case"$attribute":{const e=f,a=3===e.length?t.createAttributeNS(e[0],e[1]):t.createAttribute(e[0]);a.value=e[e.length-1],u[u.length]=a;break}case"$text":{const e=t.createTextNode(f);u[u.length]=e;break}case"$document":{const e=t.implementation.createHTMLDocument();if(!f)throw new Error("Bad attribute value");const a=f;if(a.childNodes){const t=a.childNodes.length;for(;e.childNodes[t];){e.childNodes[t].remove()}a.childNodes.forEach(_childrenToJML(e))}else{if(a.$DOCTYPE){const t={$DOCTYPE:a.$DOCTYPE},r=jml(t);e.firstChild?.replaceWith(r)}const r=e.querySelector("html"),n=r?.querySelector("head"),i=r?.querySelector("body");if(a.title||a.head){const r=t.createElement("meta");r.setAttribute("charset","utf-8"),n?.append(r),a.title&&(e.title=a.title),a.head&&n&&a.head.forEach(_appendJML(n))}a.body&&i&&a.body.forEach(_appendJMLOrText(i))}u[u.length]=e;break}case"$DOCTYPE":{const e=f,a=t.implementation.createDocumentType(e.name,e.publicId||"",e.systemId||"");u[u.length]=a;break}case"$on":for(let[e,t]of Object.entries(f||{})){if("function"==typeof t&&(t=[t,!1]),"function"!=typeof t[0])throw new TypeError(`Expect a function for \`$on\`; args: ${JSON.stringify(c)}`);a=l,r=e,m=t[0],y=t[1],a.addEventListener(r,m,Boolean(y))}break;case"className":case"class":f=checkPluginValue(l,h,f,p),_isNullish(f)||(l.className=f);break;case"dataset":{const recurse=(e,t)=>{let a="";const r=""!==t;Object.keys(e).forEach((i=>{const s=e[i];if(a=r?t+i.replace(n,_upperCase).replace(/^([a-z])/u,_upperCase):t+i.replace(n,_upperCase),null===s||"object"!=typeof s)return _isNullish(s)||(l.dataset[a]=s),void(a=t);recurse(s,a)}))};recurse(f,"");break}case"innerHTML":_isNullish(f)||(l.innerHTML=f);break;case"htmlFor":case"for":if("label"===d){f=checkPluginValue(l,h,f,p),_isNullish(f)||(l.htmlFor=f);break}f=checkPluginValue(l,h,f,p),l.setAttribute(h,f);break;default:{if(h.startsWith("on")){f=checkPluginValue(l,h,f,p),l[h]=f;break}if("style"===h){if(f=checkPluginValue(l,h,f,p),_isNullish(f))break;if("object"==typeof f){for(const[e,t]of Object.entries(f))_isNullish(t)||("float"===e?(l.style.cssFloat=t,l.style.styleFloat=t):l.style[e.replace(n,_upperCase)]=t);break}l.setAttribute(h,f);break}const e=h,t=getMatchingPlugin(p,e);if(t){t.set({opts:p,element:u[0],attribute:{name:e,value:f}});break}f=checkPluginValue(l,h,f,p),l.setAttribute(h,f);break}}var a,r,m,y}const u=[];let d,p,m=!1,y=0;if("object"===_getType(c[0])&&Object.keys(c[0]).some((e=>a.includes(e)))){if(p=c[0],void 0===p.$state&&(m=!0,p.$state="root"),Array.isArray(p.$map)&&(p.$map={root:p.$map}),"$plugins"in p){if(!Array.isArray(p.$plugins))throw new TypeError(`\`$plugins\` must be an array; args: ${JSON.stringify(c)}`);p.$plugins.forEach((e=>{if(!e||"object"!=typeof e)throw new TypeError(`Plugin must be an object; args: ${JSON.stringify(c)}`);if(!e.name||!e.name.startsWith("$_"))throw new TypeError(`Plugin object name must be present and begin with \`$_\`; args: ${JSON.stringify(c)}`);if("function"!=typeof e.set)throw new TypeError(`Plugin object must have a \`set\` method; args: ${JSON.stringify(c)}`)}))}y=1}else p={$state:void 0};const h=c.length,f=p.$map&&p.$map.root,setMap=e=>{let t,a;const r=f;if(!0===e)[t,a]=r;else if(Array.isArray(e)){if("string"==typeof e[0])return void e.forEach((e=>{setMap(p.$map[e])}));t=e[0]||r[0],a=e[1]||r[1]}else/^\[object (?:Weak)?Map\]$/u.test([].toString.call(e))?(t=e,a=r[1]):(t=r[0],a=e);t.set(l,a)};for(let a=y;a<h;a++){let n=c[a];const i=_getType(n);switch(i){case"null":if(a===h-1)return u.length<=1?u[0]:u.reduce(_fragReducer,t.createDocumentFragment());throw new TypeError(`\`null\` values not allowed except as final Jamilih argument; index ${a} on args: ${JSON.stringify(c)}`);case"string":switch(n){case"!":u[u.length]=t.createComment(c[++a]);break;case"?":{n=c[++a];let e=c[++a];const r=e;if(r&&"object"==typeof r){const t=[];for(const[e,a]of Object.entries(r))t.push(e+'="'+a.replace(/"/gu,""")+'"');e=t.join(" ")}try{u[u.length]=t.createProcessingInstruction(n,e)}catch(a){u[u.length]=t.createComment("?"+n+" "+e+"?")}break}case"&":u[u.length]=_createSafeReference("entity","",c[++a]);break;case"#":u[u.length]=_createSafeReference("decimal",n,String(c[++a]));break;case"#x":u[u.length]=_createSafeReference("hexadecimal",n,c[++a]);break;case"![":try{u[u.length]=t.createCDATASection(c[++a])}catch(e){u[u.length]=t.createTextNode(c[a])}break;case"":u[u.length]=l=t.createDocumentFragment(),p.$state="fragment";break;default:{d=n;const e=c[a+1];if(e&&"object"===_getType(e)&&e.is){const{is:a}=e;l=t.createElementNS?t.createElementNS(r,d,{is:a}):t.createElement(d,{is:a})}else l=t.createElementNS?t.createElementNS(r,d):t.createElement(d);p.$state="element",u[u.length]=l;break}}break;case"object":{if(!n||"object"!=typeof n)throw new Error("Null should not reach here");const t=n;if("xmlns"in t){const a=t,n=a.xmlns&&"object"==typeof a.xmlns?_replaceDefiner(a.xmlns):' xmlns="'+a.xmlns+'"';l=u[u.length-1]=(new e.DOMParser).parseFromString((new e.XMLSerializer).serializeToString(l).replace(' xmlns="'+r+'"',n),"application/xml").documentElement,p.$state="element"}_checkAtts(t);break}case"document":case"fragment":case"element":if(0===a&&(l=n,p.$state="element"),a===h-1||a===h-2&&null===c[a+1]){const e=u.length;for(let t=0;t<e;t++)_appendNode(n,u[t])}else u[u.length]=n;break;case"array":{const e=n,a=e.length;for(let r=0;r<a;r++){const a=e[r],n=typeof a;if(null===a||_isNullish(a))throw new TypeError(`Bad children (parent array: ${JSON.stringify(c)}; index ${r} of child: ${JSON.stringify(e)})`);switch(n){case"string":case"number":case"boolean":_appendNode(l,t.createTextNode(String(a)));break;default:if("object"!=typeof a)throw new TypeError(`Bad children (parent array: ${JSON.stringify(c)}; index ${r} of child: ${JSON.stringify(e)})`);if(Array.isArray(a))p.$state="children",_appendNode(l,jml(p,...a));else if("#"in a)p.$state="fragmentChildren",_appendNode(l,jml(p,a["#"]));else{let e;"nodeType"in a||(e=checkPluginValue(l,null,a,p,"children")),_appendNode(l,e||a)}}}break}default:throw new TypeError(`Unexpected type: ${i}; arg: ${n}; index ${a} on args: ${JSON.stringify(c)}`)}}const g=u[0]||l;return m&&p.$map&&p.$map.root&&setMap(!0),g};let l,u=class DOMException extends Error{constructor(e,t){super(e),this.code=0,this.name=t}};c.toJML=function(t,{stringOutput:a=!1,reportInvalidState:r=!0,stripWhitespace:n=!1}={}){if(!e)throw new Error("No window object set");"string"==typeof t&&(t=(new e.DOMParser).parseFromString(t,"text/html"));const i=[];let s=i,o=0;function invalidStateError(e){if(r){const t=new u(e,"INVALID_STATE_ERR");throw t.code=11,t}}function set(e){s[o]=e,o++}function setChildren(){set([]),s=s[o-1],o=0}function setObj(e,t){s=s[o-1][e],o=0,t&&(s=s[t])}return function parseDOM(e,t){const a="nodeType"in e?e.nodeType:null;if(!a)throw new TypeError("Not an XML type");if(5===a)return void set(["&",e.nodeName]);let r,i;function setTemp(){r=s,i=o}function resetTemp(){s=r,o=i,o++}switch(t={...t},[2,3,4,7,8].includes(a)&&e.nodeValue&&!/^([\u0009\u000A\u000D\u0020-\uD7FF\uE000-\uFFFD]|[\uD800-\uDBFF][\uDC00-\uDFFF])*$/u.test(e.nodeValue)&&invalidStateError("Node has bad XML character value"),a){case 1:{const a=e;setTemp();const r=a.nodeName.toLowerCase();setChildren(),set(r);const n={};let i=!1;t[a.prefix||""]!==a.namespaceURI&&(t[a.prefix||""]=a.namespaceURI,a.prefix?n["xmlns:"+a.prefix]=a.namespaceURI:a.namespaceURI?n.xmlns=a.namespaceURI:n.xmlns=null,i=!0),a.attributes.length?set([...a.attributes].reduce((function(e,t){return e[t.name]=t.value,e}),n)):i&&set(n);const{childNodes:s}=a;s.length&&(setChildren(),[...s].forEach((function(e){parseDOM(e,t)}))),resetTemp();break}case 2:{const t=e;set({$attribute:[t.namespaceURI,t.name,t.value]});break}case 3:{const t=e;if(!t.nodeValue)throw new Error("Unexpected null comment value");if(n&&/^\s+$/u.test(t.nodeValue))return void set("");set(t.nodeValue);break}case 4:{const t=e;t.nodeValue?.includes("]]>")&&invalidStateError("CDATA cannot end with closing ]]>"),set(["![",t.nodeValue]);break}case 7:{const t=e;/^xml$/iu.test(t.target)&&invalidStateError('Processing instructions cannot be "xml".'),t.target.includes("?>")&&invalidStateError("Processing instruction targets cannot include ?>"),t.target.includes(":")&&invalidStateError('The processing instruction target cannot include ":"'),t.data.includes("?>")&&invalidStateError("Processing instruction data cannot include ?>"),set(["?",t.target,t.data]);break}case 8:{const t=e;if(!t.nodeValue)throw new Error("Unexpected null comment value");(t.nodeValue.includes("--")||t.nodeValue.length&&t.nodeValue.lastIndexOf("-")===t.nodeValue.length-1)&&invalidStateError("Comments cannot include --"),set(["!",t.nodeValue]);break}case 9:{const a=e;setTemp();set({$document:{childNodes:[]}}),setObj("$document","childNodes");const{childNodes:r}=a;r.length||invalidStateError("Documents must have a child node"),[...r].forEach((function(e){parseDOM(e,t)})),resetTemp();break}case 10:{const t=e;setTemp();const a={$DOCTYPE:{name:t.name}};/^(\u0020|\u000D|\u000A|[a-zA-Z0-9]|[-'()+,./:=?;!*#@$_%])*$/u.test(t.publicId)||invalidStateError("A publicId must have valid characters."),function addExternalID(e,t){t.systemId.includes('"')&&t.systemId.includes("'")&&invalidStateError("systemId cannot have both single and double quotes.");const{publicId:a,systemId:r}=t;r&&(e.systemId=r),a&&(e.publicId=a)}(a.$DOCTYPE,t),set(a),resetTemp();break}case 11:{const a=e;setTemp(),set({"#":[]}),setObj("#");const{childNodes:r}=a;[...r].forEach((function(e){parseDOM(e,t)})),resetTemp();break}default:throw new TypeError("Not an XML type")}}(t,{}),a?JSON.stringify(i[0]):i[0]},c.toJMLString=function(e,t){return c.toJML(e,Object.assign(t||{},{stringOutput:!0}))},c.toDOM=function(...e){return c(...e)},c.toHTML=function(...e){const t=c(...e);switch(t.nodeType){case 1:return t.outerHTML;case 2:return`${t.name}="${t.value.replace(/"/gu,""")}"`;case 3:if(!t.nodeValue)throw new TypeError("Unexpected null Text node");return t.nodeValue;case 9:case 11:return[...t.childNodes].map((e=>c.toHTML(e))).join("");case 10:{const e=t;return`<!DOCTYPE ${e.name}${e.publicId?` PUBLIC "${e.publicId}" "${e.systemId}"`:e.systemId?` SYSTEM "${e.systemId}"`:""}>`}default:throw new Error("Unexpected node type")}},c.toDOMString=function(...e){return c.toHTML(...e)},c.toXML=function(...t){if(!e)throw new Error("No window object set");const a=c(...t);return(new e.XMLSerializer).serializeToString(a)},c.toXMLDOMString=function(...e){return c.toXML(...e)};class JamilihMap extends Map{get(e){const t="string"==typeof e?$$2(e):e;return super.get.call(this,t)}set(e,t){const a="string"==typeof e?$$2(e):e;return super.set.call(this,a,t)}invoke(e,t,...a){const r="string"==typeof e?$$2(e):e;return this.get(r)[t](r,...a)}}class JamilihWeakMap extends WeakMap{get(e){const t="string"==typeof e?$$2(e):e;if(!t)throw new Error("Can't find the element");return super.get.call(this,t)}set(e,t){const a="string"==typeof e?$$2(e):e;if(!a)throw new Error("Can't find the element");return super.set.call(this,a,t)}invoke(e,t,...a){const r="string"==typeof e?$$2(e):e;if(!r)throw new Error("Can't find the element");return this.get(r)[t](r,...a)}}c.Map=JamilihMap,c.WeakMap=JamilihWeakMap,c.weak=function(e,...t){const a=new JamilihWeakMap;return[a,c({$map:[a,e]},...t)]},c.strong=function(e,...t){const a=new JamilihMap;return[a,c({$map:[a,e]},...t)]},c.symbol=c.sym=c.for=function(e,t){return("string"==typeof e?$$2(e):e)["symbol"==typeof t?t:Symbol.for(t)]},c.command=function(e,t,a,...r){if(!(e="string"==typeof e?$$2(e):e))throw new Error("No element found");let n;if(["symbol","string"].includes(typeof t))return n=c.sym(e,t),"function"==typeof n?n(a,...r):n[a](...r);if(n=t.get(e),!n)throw new Error("No map found");return"function"==typeof n?n.call(e,a,...r):n[a](e,...r)},c.setWindow=a=>{e=a,t=e?.document,t&&t.body&&(l=t.body)},c.getWindow=()=>{if(!e)throw new Error("No window object set");return e},t&&t.body&&(l=t.body);const d=" ";function ownKeys(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,r)}return a}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(a),!0).forEach((function(t){_defineProperty(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):ownKeys(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _createClass(e,t,a){return t&&function _defineProperties(e,t){for(var a=0;a<t.length;a++){var r=t[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,_toPropertyKey(r.key),r)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _defineProperty(e,t,a){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function _slicedToArray(e,t){return function _arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function _iterableToArrayLimit(e,t){var a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var r,n,i,s,o=[],c=!0,l=!1;try{if(i=(a=a.call(e)).next,0===t){if(Object(a)!==a)return;c=!1}else for(;!(c=(r=i.call(a)).done)&&(o.push(r.value),o.length!==t);c=!0);}catch(e){l=!0,n=e}finally{try{if(!c&&null!=a.return&&(s=a.return(),Object(s)!==s))return}finally{if(l)throw n}}return o}}(e,t)||_unsupportedIterableToArray(e,t)||function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,r=new Array(t);a<t;a++)r[a]=e[a];return r}function _toPropertyKey(e){var t=function _toPrimitive(e,t){if("object"!=typeof e||null===e)return e;var a=e[Symbol.toPrimitive];if(void 0!==a){var r=a.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:String(t)}var p=_createClass((function TypesonPromise(e){_classCallCheck(this,TypesonPromise),this.p=new Promise(e)}));p.__typeson__type__="TypesonPromise","undefined"!=typeof Symbol&&Object.defineProperty(p.prototype,Symbol.toStringTag,{get:function get(){return"TypesonPromise"}}),p.prototype.then=function(e,t){var a=this;return new p((function(r,n){a.p.then((function(t){r(e?e(t):t)})).catch((function(e){return t?t(e):Promise.reject(e)})).then(r,n)}))},p.prototype.catch=function(e){return this.then((function(){}),e)},p.resolve=function(e){return new p((function(t){t(e)}))},p.reject=function(e){return new p((function(t,a){a(e)}))},p.all=function(e){return new p((function(t,a){Promise.all(e.map((function(e){return null!=e&&e.constructor&&"__typeson__type__"in e.constructor&&"TypesonPromise"===e.constructor.__typeson__type__?e.p:e}))).then(t,a)}))},p.race=function(e){return new p((function(t,a){Promise.race(e.map((function(e){return null!=e&&e.constructor&&"__typeson__type__"in e.constructor&&"TypesonPromise"===e.constructor.__typeson__type__?e.p:e}))).then(t,a)}))},p.allSettled=function(e){return new p((function(t,a){Promise.allSettled(e.map((function(e){return null!=e&&e.constructor&&"__typeson__type__"in e.constructor&&"TypesonPromise"===e.constructor.__typeson__type__?e.p:e}))).then(t,a)}))};var m=Object.hasOwn,y=Object.getPrototypeOf;function isThenable(e,t){return isObject(e)&&"function"==typeof e.then&&!t}function toStringTag(e){return Object.prototype.toString.call(e).slice(8,-1)}function hasConstructorOf(e,t){if(!e||"object"!==_typeof(e))return!1;var a=y(e);if(!a)return null===t;var r=m(a,"constructor")&&a.constructor;return"function"!=typeof r?null===t:t===r||null!==t&&Function.prototype.toString.call(r)===Function.prototype.toString.call(t)||"function"==typeof t&&"string"==typeof r.__typeson__type__&&r.__typeson__type__===t.__typeson__type__}function isPlainObject(e){return!(!e||"Object"!==toStringTag(e))&&(!y(e)||hasConstructorOf(e,Object))}function isUserObject(e){if(!e||"Object"!==toStringTag(e))return!1;var t=y(e);return!t||hasConstructorOf(e,Object)||isUserObject(t)}function isObject(e){return null!==e&&"object"===_typeof(e)}function escapeKeyPathComponent(e){return e.replaceAll("''","''''").replace(/^$/,"''").replaceAll("~","~0").replaceAll(".","~1")}function unescapeKeyPathComponent(e){return e.replaceAll("~1",".").replaceAll("~0","~").replace(/^''$/,"").replaceAll("''''","''")}function getByKeyPath(e,t){if(""===t)return e;if(null===e||"object"!==_typeof(e))throw new TypeError("Unexpected non-object type");var a=t.indexOf(".");if(a>-1){var r=e[unescapeKeyPathComponent(t.slice(0,a))];return void 0===r?void 0:getByKeyPath(r,t.slice(a+1))}return e[unescapeKeyPathComponent(t)]}function setAtKeyPath(e,t,a){if(""===t)return a;if(!e||"object"!==_typeof(e))throw new TypeError("Unexpected non-object type");var r=t.indexOf(".");return r>-1?setAtKeyPath(e[unescapeKeyPathComponent(t.slice(0,r))],t.slice(r+1),a):(e[unescapeKeyPathComponent(t)]=a,e)}function getJSONType(e){return null===e?"null":Array.isArray(e)?"array":_typeof(e)}function _await(e,t,a){return e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e}var h=Object.keys,f=Object.hasOwn,g=Array.isArray,v=["type","replaced","iterateIn","iterateUnsetNumeric","addLength"];function _async(e){return function(){for(var t=[],a=0;a<arguments.length;a++)t[a]=arguments[a];try{return Promise.resolve(e.apply(this,t))}catch(e){return Promise.reject(e)}}}function nestedPathsFirst(e,t){var a,r;if(""===e.keypath)return-1;var n=null!==(a=e.keypath.match(/\./g))&&void 0!==a?a:0,i=null!==(r=t.keypath.match(/\./g))&&void 0!==r?r:0;return n&&(n=n.length),i&&(i=i.length),n>i?-1:n<i?1:e.keypath<t.keypath?-1:e.keypath>t.keypath?1:0}var b=function(){function Typeson(e){_classCallCheck(this,Typeson),this.options=e,this.plainObjectReplacers=[],this.nonplainObjectReplacers=[],this.revivers={},this.types={}}return _createClass(Typeson,[{key:"stringify",value:function stringify(e,t,a,r){r=_objectSpread2(_objectSpread2(_objectSpread2({},this.options),r),{},{stringification:!0});var n=this.encapsulate(e,null,r);return g(n)?JSON.stringify(n[0],t,a):n.then((function(e){return JSON.stringify(e,t,a)}))}},{key:"stringifySync",value:function stringifySync(e,t,a,r){return this.stringify(e,t,a,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},r),{},{sync:!0}))}},{key:"stringifyAsync",value:function stringifyAsync(e,t,a,r){return this.stringify(e,t,a,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},r),{},{sync:!1}))}},{key:"parse",value:function parse(e,t,a){return a=_objectSpread2(_objectSpread2(_objectSpread2({},this.options),a),{},{parse:!0}),this.revive(JSON.parse(e,t),a)}},{key:"parseSync",value:function parseSync(e,t,a){return this.parse(e,t,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},a),{},{sync:!0}))}},{key:"parseAsync",value:function parseAsync(e,t,a){return this.parse(e,t,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},a),{},{sync:!1}))}},{key:"specialTypeNames",value:function specialTypeNames(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return a.returnTypeNames=!0,this.encapsulate(e,t,a)}},{key:"rootTypeName",value:function rootTypeName(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return a.iterateNone=!0,this.encapsulate(e,t,a)}},{key:"encapsulate",value:function encapsulate(e,t,a){var r=this,n=_objectSpread2(_objectSpread2({sync:!0},this.options),a),i=n.sync,s={},o=[],c=[],l=[],u=!("cyclic"in n)||n.cyclic,d=n.encapsulateObserver,m=function finish(e){var t=Object.values(s);if(n.iterateNone)return t.length?t[0]:getJSONType(e);if(t.length){if(n.returnTypeNames)return function _toConsumableArray(e){return function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}(e)||function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||_unsupportedIterableToArray(e)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(new Set(t));e&&isPlainObject(e)&&!f(e,"$types")?e.$types=s:e={$:e,$types:{$:s}}}else isObject(e)&&f(e,"$types")&&(e={$:e,$types:!0});return!n.returnTypeNames&&e},y=_async((function(e,t){return _await(Promise.all(t.map((function(e){return e[1].p}))),(function(a){return _await(Promise.all(a.map(_async((function(a){var r=!1,n=[],i=_slicedToArray(t.splice(0,1),1),s=_slicedToArray(i[0],7),o=s[0],c=s[2],l=s[3],u=s[4],d=s[5],m=s[6],h=w(o,a,c,l,n,!0,m),f=hasConstructorOf(h,p);return function _invoke(e,t){var a=e();return a&&a.then?a.then(t):t(a)}((function(){if(o&&f)return _await(h.p,(function(t){u[d]=t;var a=y(e,n);return r=!0,a}))}),(function(t){return r?t:(o?u[d]=h:e=f?h.p:h,y(e,n))}))})))),(function(){return e}))}))})),b=function _adaptBuiltinStateObjectProperties(e,t,a){Object.assign(e,t);var r=v.map((function(t){var a=e[t];return delete e[t],a}));a(),v.forEach((function(t,a){e[t]=r[a]}))},w=function _encapsulate(e,t,a,i,l,u,m){var y,v={},w=_typeof(t),S=d?function(r){var n,s=null!==(n=null!=m?m:i.type)&&void 0!==n?n:getJSONType(t);d(Object.assign(null!=r?r:v,{keypath:e,value:t,cyclic:a,stateObj:i,promisesData:l,resolvingTypesonPromise:u,awaitingTypesonPromise:hasConstructorOf(t,p)},{type:s}))}:null;if(["string","boolean","number","undefined"].includes(w))return void 0===t||Number.isNaN(t)||t===Number.NEGATIVE_INFINITY||t===Number.POSITIVE_INFINITY||0===t?(y=i.replaced?t:x(e,t,i,l,!1,u,S))!==t&&(v={replaced:y}):y=t,S&&S(),y;if(null===t)return S&&S(),t;if(a&&!i.iterateIn&&!i.iterateUnsetNumeric&&t&&"object"===_typeof(t)){var I=o.indexOf(t);if(!(I<0))return s[e]="#",S&&S({cyclicKeypath:c[I]}),"#"+c[I];!0===a&&(o.push(t),c.push(e))}var T,E,N=isPlainObject(t),_=g(t),O=(N||_)&&(!r.plainObjectReplacers.length||i.replaced)||i.iterateIn?t:x(e,t,i,l,N||_,null,S);if(O!==t?(y=O,v={replaced:O}):""===e&&hasConstructorOf(t,p)?(l.push([e,t,a,i,void 0,void 0,i.type]),y=t):_&&"object"!==i.iterateIn||"array"===i.iterateIn?(T=new Array(t.length),v={clone:T}):(["function","symbol"].includes(_typeof(t))||"toJSON"in t||hasConstructorOf(t,p)||hasConstructorOf(t,Promise)||hasConstructorOf(t,ArrayBuffer))&&!N&&"object"!==i.iterateIn?y=t:(T={},i.addLength&&(T.length=t.length),v={clone:T}),S&&S(),n.iterateNone)return null!==(E=T)&&void 0!==E?E:y;if(!T)return y;if(i.iterateIn){var k=function _loop(r){var n={ownKeys:f(t,r)};b(i,n,(function(){var n=e+(e?".":"")+escapeKeyPathComponent(r),s=_encapsulate(n,t[r],Boolean(a),i,l,u);hasConstructorOf(s,p)?l.push([n,s,Boolean(a),i,T,r,i.type]):void 0!==s&&(T[r]=s)}))};for(var A in t)k(A);S&&S({endIterateIn:!0,end:!0})}else h(t).forEach((function(r){var n=e+(e?".":"")+escapeKeyPathComponent(r);b(i,{ownKeys:!0},(function(){var e=_encapsulate(n,t[r],Boolean(a),i,l,u);hasConstructorOf(e,p)?l.push([n,e,Boolean(a),i,T,r,i.type]):void 0!==e&&(T[r]=e)}))})),S&&S({endIterateOwn:!0,end:!0});if(i.iterateUnsetNumeric){for(var C=t.length,j=function _loop2(r){if(!(r in t)){var n="".concat(e).concat(e?".":"").concat(r);b(i,{ownKeys:!1},(function(){var e=_encapsulate(n,void 0,Boolean(a),i,l,u);hasConstructorOf(e,p)?l.push([n,e,Boolean(a),i,T,r,i.type]):void 0!==e&&(T[r]=e)}))}},Z=0;Z<C;Z++)j(Z);S&&S({endIterateUnsetNumeric:!0,end:!0})}return T},x=function replace(e,t,a,n,o,c,l){for(var d=o?r.plainObjectReplacers:r.nonplainObjectReplacers,p=d.length;p--;){var m=d[p];if(m.test(t,a)){var y=m.type;if(r.revivers[y]){var h=s[e];s[e]=h?[y].concat(h):y}if(Object.assign(a,{type:y,replaced:!0}),(i||!m.replaceAsync)&&!m.replace)return l&&l({typeDetected:!0}),w(e,t,u&&"readonly",a,n,c,y);l&&l({replacing:!0});var f=void 0;if(i||!m.replaceAsync){if(void 0===m.replace)throw new TypeError("Missing replacer");f=m.replace(t,a)}else f=m.replaceAsync(t,a);return w(e,f,u&&"readonly",a,n,c,y)}}return t},S=w("",e,u,null!=t?t:{},l);if(l.length)return i&&n.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():Promise.resolve(y(S,l)).then(m);if(!i&&n.throwOnBadSyncType)throw new TypeError("Async method requested but sync result obtained");return n.stringification&&i?[m(S)]:i?m(S):Promise.resolve(m(S))}},{key:"encapsulateSync",value:function encapsulateSync(e,t,a){return this.encapsulate(e,t,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},a),{},{sync:!0}))}},{key:"encapsulateAsync",value:function encapsulateAsync(e,t,a){return this.encapsulate(e,t,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},a),{},{sync:!1}))}},{key:"revive",value:function revive(e,t){var a=this,r=_objectSpread2(_objectSpread2({sync:!0},this.options),t),n=r.sync;function finishRevival(e){if(n)return e;if(r.throwOnBadSyncType)throw new TypeError("Async method requested but sync result obtained");return Promise.resolve(e)}if(!e||"object"!==_typeof(e)||Array.isArray(e))return finishRevival(e);var i=e.$types;if(!0===i)return finishRevival(e.$);if(!i||"object"!==_typeof(i)||Array.isArray(i))return finishRevival(e);var s=[],o={},c=!0;i.$&&isPlainObject(i.$)&&(e=e.$,i=i.$,c=!1);var l=function executeReviver(e,t){var r,i=_slicedToArray(null!==(r=a.revivers[e])&&void 0!==r?r:[],1)[0];if(!i)throw new Error("Unregistered type: "+e);if(n&&!("revive"in i))return t;if(!n&&i.reviveAsync)return i.reviveAsync(t,o);if(i.revive)return i.revive(t,o);throw new Error("Missing reviver")},u=[];function checkUndefined(e){return hasConstructorOf(e,w)?void 0:e}var d,m=function revivePlainObjects(){var t=[];if(!i)throw new Error("Found bad `types`");if(Object.entries(i).forEach((function(e){var r=_slicedToArray(e,2),n=r[0],s=r[1];"#"!==s&&[].concat(s).forEach((function(e){var r;_slicedToArray(null!==(r=a.revivers[e])&&void 0!==r?r:[null,{}],2)[1].plain&&(t.push({keypath:n,type:e}),delete i[n])}))})),t.length)return t.sort(nestedPathsFirst).reduce((function reducer(t,a){var r=a.keypath,n=a.type;if(isThenable(t))return t.then((function(e){return reducer(e,{keypath:r,type:n})}));var i=getByKeyPath(e,r);if(hasConstructorOf(i=l(n,i),p))return i.then((function(t){var a=setAtKeyPath(e,r,t);a===t&&(e=a)}));var s=setAtKeyPath(e,r,i);s===i&&(e=s)}),void 0)}();return hasConstructorOf(m,p)?d=m.then((function(){return e})):(d=function _revive(e,t,a,r,n){if(!c||"$types"!==e){var o=i[e],d=g(t);if(d||isPlainObject(t)){var m=d?new Array(t.length):{};for(h(t).forEach((function(r){var n=_revive(e+(e?".":"")+escapeKeyPathComponent(r),t[r],null!=a?a:m,m,r),i=function set(e){return hasConstructorOf(e,w)?m[r]=void 0:void 0!==e&&(m[r]=e),e};hasConstructorOf(n,p)?u.push(n.then((function(e){return i(e)}))):i(n)})),t=m;s.length;){var y=_slicedToArray(s[0],4),f=y[0],v=y[1],b=y[2],x=y[3],S=getByKeyPath(f,v);if(void 0===S)break;b[x]=S,s.splice(0,1)}}if(!o)return t;if("#"===o){var I=getByKeyPath(a,t.slice(1));return void 0===I&&s.push([a,t.slice(1),r,n]),I}return[].concat(o).reduce((function reducer(e,t){if(hasConstructorOf(e,p))return e.then((function(e){return reducer(e,t)}));if("string"!=typeof t)throw new TypeError("Bad type JSON");return l(t,e)}),t)}}("",e,null),u.length&&(d=p.resolve(d).then((function(e){return p.all([e].concat(u))})).then((function(e){return _slicedToArray(e,1)[0]})))),isThenable(d)?n&&r.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():hasConstructorOf(d,p)?d.p.then(checkUndefined):d:!n&&r.throwOnBadSyncType?function(){throw new TypeError("Async method requested but sync result obtained")}():n?checkUndefined(d):Promise.resolve(checkUndefined(d))}},{key:"reviveSync",value:function reviveSync(e,t){return this.revive(e,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},t),{},{sync:!0}))}},{key:"reviveAsync",value:function reviveAsync(e,t){return this.revive(e,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},t),{},{sync:!1}))}},{key:"register",value:function register(e,t){var a=this,r=null!=t?t:{},n=function R(e){g(e)?e.forEach((function(e){return R(e)})):h(e).forEach((function(t){var n;if("#"===t)throw new TypeError("# cannot be used as a type name as it is reserved for cyclic objects");if(x.includes(t))throw new TypeError("Plain JSON object types are reserved as type names");var i=e[t],s=i&&"function"!=typeof i&&!Array.isArray(i)&&i.testPlainObjects?a.plainObjectReplacers:a.nonplainObjectReplacers,o=s.filter((function(e){return e.type===t}));if(o.length&&(s.splice(s.indexOf(o[0]),1),delete a.revivers[t],delete a.types[t]),"function"==typeof i){var c=i;i={test:function test(e){return e&&e.constructor===c},replace:function replace(e){return _objectSpread2({},e)},revive:function revive(e){return Object.assign(Object.create(c.prototype),e)}}}else if(g(i)){var l=_slicedToArray(i,3);i={test:l[0],replace:l[1],revive:l[2]}}if(null!==(n=i)&&void 0!==n&&n.test){var u={type:t,test:i.test.bind(i)};i.replace&&(u.replace=i.replace.bind(i)),i.replaceAsync&&(u.replaceAsync=i.replaceAsync.bind(i));var d="number"==typeof r.fallback?r.fallback:r.fallback?0:Number.POSITIVE_INFINITY;if(i.testPlainObjects?a.plainObjectReplacers.splice(d,0,u):a.nonplainObjectReplacers.splice(d,0,u),i.revive||i.reviveAsync){var p={};i.revive&&(p.revive=i.revive.bind(i)),i.reviveAsync&&(p.reviveAsync=i.reviveAsync.bind(i)),a.revivers[t]=[p,{plain:i.testPlainObjects}]}a.types[t]=i}}))};return[].concat(e).forEach((function(e){return n(e)})),this}}]),Typeson}(),w=_createClass((function Undefined(){_classCallCheck(this,Undefined)}));w.__typeson__type__="TypesonUndefined";for(var x=["null","boolean","number","string","array","object"],S="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",I=new Uint8Array(256),T=0;T<64;T++)I[S.codePointAt(T)]=T;var E=function encode(e,t,a){null==a&&(a=e.byteLength);for(var r=new Uint8Array(e,0,a),n=r.length,i="",s=0;s<n;s+=3)i+=S[r[s]>>2],i+=S[(3&r[s])<<4|r[s+1]>>4],i+=S[(15&r[s+1])<<2|r[s+2]>>6],i+=S[63&r[s+2]];return n%3==2?i=i.slice(0,-1)+"=":n%3==1&&(i=i.slice(0,-2)+"=="),i},N=function decode(e,t){var a=e.length;if(a%4)throw new Error("Bad base64 length: not divisible by four");var r,n,i,s,o=.75*e.length,c=0;"="===e[e.length-1]&&(o--,"="===e[e.length-2]&&o--);for(var l=new ArrayBuffer(o,t),u=new Uint8Array(l),d=0;d<a;d+=4)r=I[e.codePointAt(d)],n=I[e.codePointAt(d+1)],i=I[e.codePointAt(d+2)],s=I[e.codePointAt(d+3)],u[c++]=r<<2|n>>4,u[c++]=(15&n)<<4|i>>2,u[c++]=(3&i)<<6|63&s;return l};const _={arraybuffer:{test:e=>"ArrayBuffer"===toStringTag(e),replace(e,t){t.buffers||(t.buffers=[]);const a=t.buffers.indexOf(e);return a>-1?{index:a}:(t.buffers.push(e),{s:E(e),maxByteLength:e.maxByteLength})},revive(e,t){if(t.buffers||(t.buffers=[]),Object.hasOwn(e,"index"))return t.buffers[e.index];const a=N(e.s,{maxByteLength:e.maxByteLength});return t.buffers.push(a),a}}},O={bigintObject:{test:e=>"object"==typeof e&&hasConstructorOf(e,BigInt),replace:String,revive:e=>new Object(BigInt(e))}},k={bigint:{test:e=>"bigint"==typeof e,replace:String,revive:e=>BigInt(e)}};function arraybuffer2string(e){return new Uint8Array(e).reduce(((e,t)=>e+String.fromCodePoint(t)),"")}function string2arraybuffer(e){const t=new Uint8Array(e.length);for(let a=0;a<e.length;a++)t[a]=e.charCodeAt(a);return t.buffer}const A={blob:{test:e=>"Blob"===toStringTag(e),replace(e){const t=new XMLHttpRequest;if(t.overrideMimeType("text/plain; charset=x-user-defined"),t.open("GET",URL.createObjectURL(e),!1),t.send(),200!==t.status&&0!==t.status)throw new Error("Bad Blob access: "+t.status);return{type:e.type,stringContents:t.responseText}},revive(e){const{type:t,stringContents:a}=e;return new Blob([string2arraybuffer(a)],{type:t})},replaceAsync:e=>new p(((t,a)=>{const r=new FileReader;r.addEventListener("load",(()=>{t({type:e.type,stringContents:arraybuffer2string(r.result)})})),r.addEventListener("error",(()=>{a(r.error)})),r.readAsArrayBuffer(e)}))}};const C={cryptokey:{test:e=>"CryptoKey"===toStringTag(e)&&e.extractable,replaceAsync:e=>new p((async(t,a)=>{let r;try{r=await crypto.subtle.exportKey("jwk",e)}catch(t){return void a(t)}t({jwk:r,algorithm:e.algorithm,usages:e.usages})})),revive(e){const{jwk:t,algorithm:a,usages:r}=e;return crypto.subtle.importKey("jwk",t,a,!0,r)}}},j={dataview:{test:e=>"DataView"===toStringTag(e),replace({buffer:e,byteOffset:t,byteLength:a},r){r.buffers||(r.buffers=[]);const n=r.buffers.indexOf(e);return n>-1?{index:n,byteOffset:t,byteLength:a}:(r.buffers.push(e),{encoded:E(e),maxByteLength:e.maxByteLength,byteOffset:t,byteLength:a})},revive(e,t){t.buffers||(t.buffers=[]);const{byteOffset:a,byteLength:r,encoded:n,index:i,maxByteLength:s}=e;let o;return"index"in e?o=t.buffers[i]:(o=N(n,void 0===s?s:{maxByteLength:s}),t.buffers.push(o)),new DataView(o,a,r)}}},Z={date:{test:e=>"Date"===toStringTag(e),replace(e){const t=e.getTime();return Number.isNaN(t)?"NaN":t},revive:e=>"NaN"===e?new Date(Number.NaN):new Date(e)}},V={domexception:{test:e=>"DOMException"===toStringTag(e),replace:e=>({name:e.name,message:e.message}),revive:({message:e,name:t})=>new DOMException(e,t)}},M={};function create$5(e){M[e.name.toLowerCase()]={test:t=>toStringTag(t)===e.name,replace:e=>e.is2D?{a:e.a,b:e.b,c:e.c,d:e.d,e:e.e,f:e.f}:{m11:e.m11,m12:e.m12,m13:e.m13,m14:e.m14,m21:e.m21,m22:e.m22,m23:e.m23,m24:e.m24,m31:e.m31,m32:e.m32,m33:e.m33,m34:e.m34,m41:e.m41,m42:e.m42,m43:e.m43,m44:e.m44},revive:t=>Object.hasOwn(t,"a")?new e([t.a,t.b,t.c,t.d,t.e,t.f]):new e([t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44])}}"undefined"!=typeof DOMMatrix&&create$5(DOMMatrix),"undefined"!=typeof DOMMatrixReadOnly&&create$5(DOMMatrixReadOnly);const P={};function create$4(e){P[e.name.toLowerCase()]={test:t=>toStringTag(t)===e.name,replace:e=>({x:e.x,y:e.y,z:e.z,w:e.w}),revive:({x:t,y:a,z:r,w:n})=>new e(t,a,r,n)}}"undefined"!=typeof DOMPoint&&create$4(DOMPoint),"undefined"!=typeof DOMPointReadOnly&&create$4(DOMPointReadOnly);const U={domquad:{test:e=>"DOMQuad"===toStringTag(e),replace:e=>({p1:e.p1,p2:e.p2,p3:e.p3,p4:e.p4}),revive:({p1:e,p2:t,p3:a,p4:r})=>new DOMQuad(e,t,a,r)}},B={};function create$3(e){B[e.name.toLowerCase()]={test:t=>toStringTag(t)===e.name,replace:e=>({x:e.x,y:e.y,width:e.width,height:e.height}),revive:({x:t,y:a,width:r,height:n})=>new e(t,a,r,n)}}"undefined"!=typeof DOMRect&&create$3(DOMRect),"undefined"!=typeof DOMRectReadOnly&&create$3(DOMRectReadOnly);const D={error:{test:e=>"Error"===toStringTag(e),replace:({name:e,message:t,cause:a,stack:r,fileName:n,lineNumber:i,columnNumber:s})=>({name:e,message:t,cause:a,stack:r,fileName:n,lineNumber:i,columnNumber:s}),revive(e){const t=new Error(e.message);return t.name=e.name,t.cause=e.cause,t.stack=e.stack,t.fileName=e.fileName,t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}}},L={};function create$2(e){L[e.name.toLowerCase()]={test:t=>hasConstructorOf(t,e),replace:({name:e,message:t,cause:a,stack:r,fileName:n,lineNumber:i,columnNumber:s,errors:o})=>({name:e,message:t,cause:a,stack:r,fileName:n,lineNumber:i,columnNumber:s,errors:o}),revive(t){const a="undefined"!=typeof AggregateError&&e===AggregateError?new e(t.errors,t.message):new e(t.message);return a.name=t.name,a.cause=t.cause,a.stack=t.stack,a.fileName=t.fileName,a.lineNumber=t.lineNumber,a.columnNumber=t.columnNumber,a}}}[TypeError,RangeError,SyntaxError,ReferenceError,EvalError,URIError].forEach((e=>create$2(e))),"undefined"!=typeof AggregateError&&create$2(AggregateError),"function"==typeof InternalError&&create$2(InternalError);const F={file:{test:e=>"File"===toStringTag(e),replace(e){const t=new XMLHttpRequest;if(t.overrideMimeType("text/plain; charset=x-user-defined"),t.open("GET",URL.createObjectURL(e),!1),t.send(),200!==t.status&&0!==t.status)throw new Error("Bad File access: "+t.status);return{type:e.type,stringContents:t.responseText,name:e.name,lastModified:e.lastModified}},revive:({name:e,type:t,stringContents:a,lastModified:r})=>new File([string2arraybuffer(a)],e,{type:t,lastModified:r}),replaceAsync:e=>new p((function(t,a){const r=new FileReader;r.addEventListener("load",(function(){t({type:e.type,stringContents:arraybuffer2string(r.result),name:e.name,lastModified:e.lastModified})})),r.addEventListener("error",(function(){a(r.error)})),r.readAsArrayBuffer(e)}))}},z={file:F.file,filelist:{test:e=>"FileList"===toStringTag(e),replace(e){const t=[];for(let a=0;a<e.length;a++)t[a]=e.item(a);return t},revive(e){class FileList{constructor(){this._files=arguments[0],this.length=this._files.length}item(e){return this._files[e]}get[Symbol.toStringTag](){return"FileList"}}return new FileList(e)}}},K={imagebitmap:{test:e=>"ImageBitmap"===toStringTag(e)||e&&e.dataset&&"ImageBitmap"===e.dataset.toStringTag,replace(e){const t=document.createElement("canvas");return t.getContext("2d").drawImage(e,0,0),{width:e.width,height:e.height,dataURL:t.toDataURL()}},revive(e){const t="undefined"==typeof OffscreenCanvas?document.createElement("canvas"):new OffscreenCanvas(e.width,e.height),a=t.getContext("2d"),r=document.createElement("img");return r.addEventListener("load",(function(){a.drawImage(r,0,0)})),r.src=e.dataURL,"undefined"==typeof OffscreenCanvas?t:t.transferToImageBitmap()},reviveAsync(e){const t=document.createElement("canvas"),a=t.getContext("2d"),r=document.createElement("img");return r.addEventListener("load",(function(){a.drawImage(r,0,0)})),r.src=e.dataURL,new p((async(e,a)=>{try{e(await createImageBitmap(t))}catch(e){a(e)}}))}}},W={imagedata:{test:e=>"ImageData"===toStringTag(e),replace:e=>({array:[...e.data],width:e.width,height:e.height}),revive:e=>new ImageData(new Uint8ClampedArray(e.array),e.width,e.height)}},J={infinity:{test:e=>e===Number.POSITIVE_INFINITY,replace:()=>"Infinity",revive:()=>Number.POSITIVE_INFINITY}},H={map:{test:e=>"Map"===toStringTag(e),replace:e=>[...e.entries()],revive:e=>new Map(e)}},q={nan:{test:e=>Number.isNaN(e),replace:()=>"NaN",revive:()=>Number.NaN}},Y={negativeInfinity:{test:e=>e===Number.NEGATIVE_INFINITY,replace:()=>"-Infinity",revive:()=>Number.NEGATIVE_INFINITY}},G={negativeZero:{test:e=>Object.is(e,-0),replace:()=>0,revive:()=>-0}},X={StringObject:{test:e=>"String"===toStringTag(e)&&"object"==typeof e,replace:String,revive:e=>new String(e)},BooleanObject:{test:e=>"Boolean"===toStringTag(e)&&"object"==typeof e,replace:Boolean,revive:e=>new Boolean(e)},NumberObject:{test:e=>"Number"===toStringTag(e)&&"object"==typeof e,replace:Number,revive:e=>new Number(e)}},Q={regexp:{test:e=>"RegExp"===toStringTag(e),replace:e=>({source:e.source,flags:(e.global?"g":"")+(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.sticky?"y":"")+(e.unicode?"u":"")}),revive:({source:e,flags:t})=>new RegExp(e,t)}},ee={},te={resurrectable:{test:e=>e&&!Array.isArray(e)&&["object","function","symbol"].includes(typeof e),replace(e){const t=function generateUUID(){let e=Date.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replaceAll(/[xy]/gu,(function(t){const a=Math.trunc((e+16*Math.random())%16);return e=Math.floor(e/16),("x"===t?a:3&a|8).toString(16)}))}();return ee[t]=e,t},revive:e=>ee[e]}},ae={set:{test:e=>"Set"===toStringTag(e),replace:e=>[...e.values()],revive:e=>new Set(e)}},re={};"function"==typeof Int8Array&&[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,..."function"==typeof BigInt64Array?[BigInt64Array,BigUint64Array]:[]].forEach((e=>function create$1(e){const t=e.name;re[t.toLowerCase()]={test:e=>toStringTag(e)===t,replace:e=>(0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e:e.slice(0)).buffer,revive:t=>"ArrayBuffer"===toStringTag(t)?new e(t):t}}(e)));const ne={};"function"==typeof Int8Array&&[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,..."function"==typeof BigInt64Array?[BigInt64Array,BigUint64Array]:[]].forEach((e=>function create(e){const t=e.name;ne[t.toLowerCase()]={test:e=>toStringTag(e)===t,replace({buffer:e,byteOffset:t,length:a},r){r.buffers||(r.buffers=[]);const n=r.buffers.indexOf(e);return n>-1?{index:n,byteOffset:t,length:a}:(r.buffers.push(e),{maxByteLength:e.maxByteLength,encoded:E(e),byteOffset:t,length:a})},revive(t,a){a.buffers||(a.buffers=[]);const{byteOffset:r,length:n,encoded:i,index:s,maxByteLength:o}=t;let c;return"index"in t?c=a.buffers[s]:(c=N(i,void 0===o?void 0:{maxByteLength:o}),a.buffers.push(c)),new e(c,r,n)}}}(e)));const ie={undef:{test:(e,t)=>void 0===e&&(t.ownKeys||!("ownKeys"in t)),replace:()=>0,revive:()=>new w}},se={userObject:{test:e=>isUserObject(e),replace:e=>({...e}),revive:e=>e}},oe=[{arrayNonindexKeys:{testPlainObjects:!0,test:(e,t)=>!!Array.isArray(e)&&(Object.keys(e).some((e=>String(Number.parseInt(e))!==e))&&(t.iterateIn="object",t.addLength=!0),!0),replace:(e,t)=>(t.iterateUnsetNumeric=!0,e),revive(e){if(Array.isArray(e))return e;const t=[];return Object.entries(e).forEach((([e,a])=>{t[e]=a})),t}}},{sparseUndefined:{test:(e,t)=>void 0===e&&!1===t.ownKeys,replace:()=>0,revive(){}}}],ce=[se,ie,oe,X,[q,J,Y,G],Z,Q,W,K,F,z,A,D,L].concat("function"==typeof Map?H:[],"function"==typeof Set?ae:[],"function"==typeof ArrayBuffer?_:[],"function"==typeof Uint8Array?ne:[],"function"==typeof DataView?j:[],"undefined"!=typeof crypto?C:[],"undefined"!=typeof BigInt?[k,O]:[],"undefined"!=typeof DOMException?V:[],"undefined"!=typeof DOMRect?B:[],"undefined"!=typeof DOMPoint?P:[],"undefined"!=typeof DOMQuad?U:[],"undefined"!=typeof DOMMatrix?M:[]).concat({checkDataCloneException:{test(e){const t={}.toString.call(e).slice(8,-1);if(["symbol","function"].includes(typeof e)||["Arguments","Module","Promise","WeakMap","WeakSet","Event","MessageChannel"].includes(t)||e&&"object"==typeof e&&"number"==typeof e.nodeType&&"function"==typeof e.insertBefore)throw new DOMException("The object cannot be cloned.","DataCloneError");return!1}}}),le="↑",ue="↓",$=e=>document.querySelector(e),$e=(e,t)=>{const a="string"==typeof e?$(e):e;return a?a.querySelector(t):null},$$e=(e,t)=>{const a="string"==typeof e?$(e):e;return a?[...a.querySelectorAll(t)]:[]},DOM_removeChildren=e=>{const t="string"==typeof e?$(e):e;if(!t)throw new Error("Node not found!");for(;t.hasChildNodes();)t.lastChild?.remove()},DOM_filterChildElements=(e,t)=>{const a="string"==typeof e?$(e):e;if(!a)throw new Error("Element not found!");let r=[a];return(t=Array.isArray(t)?t:[t]).forEach((e=>{r=r.reduce(((t,a)=>a?(t.push(...((e,t)=>{const a=[...e.children].filter((e=>e.matches(t)));return a})(a,e)),t):t),[])})),r},DOM_initialCaps=e=>e.charAt(0).toUpperCase()+e.slice(1),de={submit:"Submit",cancel:"Cancel",ok:"Ok"},pe={localeStrings:{},setLocale(e={}){this.localeStrings={...de,...e}},makeDialog({atts:e={},children:t=[],close:a,remove:r=!0}={}){a&&(e.$on||(e.$on={}),"close"in e.$on||(e.$on.close=a));const n=c("dialog",e,t,l);return n.showModal(),r&&n.addEventListener("close",(()=>{n.remove()})),n},makeCancelDialog({cancel:e,cancelClass:t="cancel",submitClass:a="submit",...r}){const n=this.makeDialog(r);return c("div",{class:a},[["br"],["br"],["button",{class:t,$on:{click(t){t.preventDefault(),e&&!1===e.call(this,{e:t,dialog:n})||n.close()}}},[this.localeStrings.cancel]]],n),n},makeSubmitDialog({submit:e,submitText:t,submitClass:a="submit",...r}){const n=this.makeCancelDialog(r);return $e(n,`button.${r.cancelClass||"cancel"}`)?.before(c("button",{class:a,$on:{click(t){e.call(this,{e:t,dialog:n})}}},[t??this.localeStrings.submit]),d.repeat(2)),n},alert(e){e="string"==typeof e?{message:e}:e;const{submitClass:t="submit"}=e,{message:a}=e;return new Promise((e=>{const r=c("dialog",[a,["br"],["br"],["div",{class:t},[["button",{$on:{click(){r.close(),e()}}},[this.localeStrings.ok]]]]],l);r.showModal()}))},confirm({atts:e={},message:t,submitClass:a="submit"}){return({message:t}="string"==typeof t?{message:t}:t),new Promise(((r,n)=>{const i=c("dialog",e,[t,["br"],["br"],["div",{class:a},[["button",{$on:{click(){i.close(),r()}}},[this.localeStrings.ok]],d.repeat(2),["button",{$on:{click(){i.close(),n(new Error("cancelled"))}}},[this.localeStrings.cancel]]]]],l);i.showModal()}))}};pe.setLocale();const buildTypeChoices=({autoTrigger:e=!0,format:t,typeNamespace:a,value:r,setValue:n=!1,state:i,keySelectClass:s,requireObject:o,objectHasValue:l,topRoot:u,formats:d=new Formats,types:p=new Types,schema:m,schemaIdx:y,schemaOriginal:h,schemaContent:f})=>{const g=o&&!f?{typeOptions:[p.getOptionForType("object")],schemaObjects:void 0}:p.getTypeOptionsForFormatAndState(t,i,f,h),{typeOptions:v}=g,b=g.schemaObjects;let w;const $getValue=(e,r)=>{const n=$e(S,"div[data-type]");return p.getValueForRoot(n,{typeNamespace:a,formats:d,format:t,types:p,...e},r)},x=c("select",{hidden:o||1===v.length,class:`typeChoices-${a}${s?" "+s:""}`,$custom:{$getValue:$getValue,$setType({type:e,baseValue:t,bringIntoFocus:a,avoidReport:r,specificSchema:n}){if(b&&n){const t=b.map((e=>JSON.stringify(e))).indexOf(JSON.stringify(n));-1===t?this.value=e:this.selectedIndex=t+1}else this.value=e;this.$setStyles(),this.$addAndValidateEditUI({baseValue:t,bringIntoFocus:a,avoidReport:r})},$setTypeNoEditUI({type:e,specificSchema:t}){if(b&&t){const e=b.map((e=>JSON.stringify(e))).indexOf(JSON.stringify(t));this.selectedIndex=e+1}else this.value=e;this.$setStyles()},$setStyles(){const{value:e}=this;this.dataset.type=e;let t=this.parentElement;"fieldset"!==t.nodeName.toLowerCase()&&(t=this.parentElement.parentElement),"fieldset"===t.nodeName.toLowerCase()&&(t.dataset.type=e,DOM_filterChildElements(t,"legend").forEach((t=>{t.dataset.type=e})))},$getTypeRoot(){const e=this.$getContainer();return!!e&&$e(e,"div[data-type]")},$addAndValidateEditUI({baseValue:e,bringIntoFocus:r,schemaObject:n,avoidReport:i}={}){const{value:s}=this;if(!s)return;let o=this.$getTopRoot();w=p.getUIForModeAndType({readonly:!1,typeNamespace:a,type:s,bringIntoFocus:r,hasValue:"arrayNonindexKeys"===s&&e,value:e,buildTypeChoices:buildTypeChoices,format:t,topRoot:o,schemaContent:h??("union"===f?.type&&void 0!==y?f.options[y]:f),specificSchemaObject:n??b?.[x.selectedIndex-1]??("union"===f?.type&&void 0!==y?f.options[y]:f),schemaFallingBack:Boolean(!n&&f)}),this.$addEditUI({editUI:w}),this.$validate({avoidReport:i}),o=this.$getTopRoot(),p.validateAllReferences({topRoot:o})},$addTypeAndEditUI({type:e,editUI:t,specificSchema:a}){this.$setTypeNoEditUI({type:e,specificSchema:a}),this.$addEditUI({editUI:t})},$addEditUI({editUI:e}){const t=this.$getContainer();DOM_removeChildren(t),c(e,t)},$getContainer(){return this.nextElementSibling},$getTopRoot(){return u||this.$getTypeRoot()},$validate({avoidReport:e}={}){const{value:t}=this,a=this.$getContainer();if(!a.firstElementChild)return!1;const r=a.firstElementChild;return p.validate({type:t,root:r,topRoot:this.$getTopRoot(),avoidReport:e})}},$on:{change(e){e?.stopPropagation(),this.$addAndValidateEditUI({schemaObject:b?b[Number(e.target.selectedOptions[0].dataset.idx)]:void 0}),this.$setStyles()}}},[["option",{value:""},["(Choose a type)"]],...v.map((([e,t],a)=>["option",{...t,dataset:b?{idx:a}:{}},[e]]))]);e&&1===v.length&&!n?setTimeout((()=>{x.selectedIndex=1,x.dispatchEvent(new Event("change"))})):(n||o&&!l)&&setTimeout((async()=>{n||(r={});try{const{rootUI:e,specificSchemas:n}=await d.getControlsForFormatAndValue(p,t,r,{readonly:!1,typeNamespace:a,schema:m,schemaContent:f,formats:d,types:p}),i=Types.getTypeForRoot(e);x.$addTypeAndEditUI({type:i,editUI:e,specificSchema:n?.[0]})}catch(e){pe.alert({message:"The object to be added had types not supported by the current format."}),console.log("err",e)}}));const S=c("div",{class:"typeContainer"});return{domArray:[x,S],getValue:$getValue,getType(){const e=$e(S,"div[data-type]");return Types.getTypeForRoot(e)},validValuesSet(){const e=$e(S,"div[data-type]").closest("form");return Types.validValuesSet({form:e,typeNamespace:a})},async setValue(e,a){const r=(await d.getControlsForFormatAndValue(p,t,e,a)).rootUI,n=Types.getTypeForRoot(r);x.$addTypeAndEditUI({type:n,editUI:r})}}},getJSONPointerParts=e=>e.split("/").slice(1).map((e=>(e=>e.replaceAll(/~([01])/gu,((e,t)=>"0"===t?"~":"/")))(e))),reduceJSONPointerParts=(e,t)=>{if(!(t in e))throw new TypeError("Path part not found in object");return e=e[t]},resolveJSONPointer=({path:e,obj:t})=>getJSONPointerParts(e).reduce(((e,t)=>reduceJSONPointerParts(e,t)),t),me=new Map([["arrayNonindexKeys","array"]]),ye={types:()=>["null","true","false","number","string","array","object"],iterate(e,t){const a=e;return t.format="json",he.iterate(a,t)},convertFromTypeson:e=>({type:me.get(e)}),testInvalid(e,t){if("array"===e)return Object.keys(t).length!==t.length},getTypesAndSchemasForState(e,t){if(!t||["array","object"].includes(t))return{types:this.types(),schemaObjects:[]}}};te.resurrectable.test=e=>e&&"object"==typeof e&&!Array.isArray(e)&&"Object"!==toStringTag(e);const encapsulateObserver=e=>{const{typeNamespace:t,readonly:a,format:r,schemaContent:n,formats:i,types:s}=e,o=r,c={},l={},u=[];return r=>{const{type:d,cyclic:p,keypath:m,value:y,replaced:h,cyclicKeypath:f,endIterateIn:g,endIterateOwn:v,endIterateUnsetNumeric:b,clone:w}=r;if("replaced"in r)return;if("readonly"===p&&!Array.isArray(r.value))return;if("readonly"===p&&("set"===d||"filelist"===d))return;if(g||v)return;if(b||void 0===w&&void 0===f&&Array.isArray(y))return;if(r.replacing&&"negativeZero"===d)return;if("sparseUndefined"===d)return;let x,S=y;const I="structuredCloning"===o?"arrayNonindexKeys":"array",T=m.lastIndexOf("."),E=unescapeKeyPathComponent(m.slice(T+1)),N=-1===T?"":m.slice(0,T);let _,O,k;if("string"==typeof f)S=(A=f)?"/"+A.split(".").map((e=>e.replaceAll("~1",".").replaceAll("/","~1"))).join("/"):A,x="array"===d?"arrayReference":"objectReference",({newType:x,schema:_,schemaIdx:O,mustBeOptional:k}=canonicalTypeToAvailableTypeAndSchema(s,i,o,I,x,y,E,l[N],e));else try{({newType:x,schema:_,schemaIdx:O,mustBeOptional:k}=canonicalTypeToAvailableTypeAndSchema(s,i,o,I,d,y,E,l[N],e))}catch(t){return console.log("err",d,t),void(e.error=t)}var A;const C=["array","object","set","map","tuple","record","filelist","arrayNonindexKeys"].includes(x),j="map"===d&&"[object Map]"===Object.prototype.toString.call(y);if(j&&u.push(m),_&&(e.specificSchema=_,e.specificSchemas||(e.specificSchemas=[]),e.specificSchemas.push(_)),!e.rootUI)return e.rootUI=s?.getUIForModeAndType({readonly:a,typeNamespace:t,type:x,bringIntoFocus:!1,buildTypeChoices:buildTypeChoices,format:o,specificSchemaObject:_,schemaContent:n,value:S,hasValue:!0,replaced:h}),c[""]=e.rootUI,_&&(l[""]=[_,O]),void(j&&[...y].forEach(((t,a)=>{c[a]=e.rootUI})));_&&(l[m]=[_,O]),setTimeout((()=>{const t=c[N];if(!t||!("$addAndSetArrayElement"in t))return;if(!j&&u.some((e=>{if(e===m||""===e&&/^\d+$/u.test(m))return!0;const t=m.match(/\.\d+$/u);return t&&""!==e&&m.slice(0,-t[0].length)===e})))return;const r=t.$addAndSetArrayElement({mustBeOptional:k,propName:E,type:x,value:S,bringIntoFocus:!1,schemaIdx:O,schemaContent:_??n});r&&(a||(s?.setValue({type:x,root:r,value:S}),s?.validate({type:x,root:r,topRoot:e.rootUI,avoidReport:!0})),C&&(c[m]=r,j&&[...y].forEach(((e,t)=>{c[`${m}.${t}`]=r}))))}))}},canonicalTypeToAvailableTypeAndSchema=(e,t,a,r,n,i,s,o,c)=>{const l=t.getAvailableFormat(a),{getTypesAndSchemasForState:u,convertFromTypeson:d,testInvalid:p}=l,m=u.call(l,e,r,c.schemaContent)?.types;if(!m)throw new Error("Unexpected undefined type for state");let y;const isInvalid=e=>{const t=new Error("Invalid");throw t.newValType=e,t};let h;if(d){let t,a,r;if(({type:t,schema:h,schemaIdx:r,mustBeOptional:a}=d(n,e,i,s,o,c)),"string"==typeof t){if(p&&p(t,i))return isInvalid(t);if(n=t,h)return{newType:n,schema:h,schemaIdx:r,mustBeOptional:a}}}return m.some((t=>{const a=e.getTypeObject(t),{valueMatch:r,superType:s,childTypes:o}=a;return!!(s&&r&&s===n&&r(i)||o&&o.includes(n))&&(y=t,!0)})),void 0===y&&(m.some((e=>e===n&&(y=e,!0))),void 0===y)?(console.log("AALLLowableTypes",r,m,"::",n),isInvalid(n)):{newType:y,schema:h}},he={async iterate(e,t){t.format||(t.format="structuredCloning");const a=ce.filter((e=>!["imagedata","imagebitmap","cryptokey","domquad"].some((t=>Object.hasOwn(e,t)))));a.splice(1,0,te);const r=new b({encapsulateObserver:encapsulateObserver(t)}).register(a);if(await r.encapsulateAsync(e,null,{throwOnBadSyncType:!1}),t.error)throw t.error;return t},getTypesAndSchemasForState(e,t){if(t&&e.getContextInfo("structuredCloning",t)){const a=this.getTypesAndSchemasForState(e)?.types||[];return e.getContextInfo("structuredCloning",t).forEach((({type:e,after:t})=>{const r=a.indexOf(t);a.splice(r+1,0,e)})),{types:a,schemaObjects:[]}}return"errorsArray"===t?{types:["error","errors"],schemaObjects:[]}:"filelistArray"===t?{types:["file"],schemaObjects:[]}:{types:this.types(),schemaObjects:[]}},types(){const e=ye.types();var t;return t=e,[["array","arrayNonindexKeys"]].forEach((([e,a])=>{t.splice(t.indexOf(e),1,a)})),[...e,"undef","bigint","bigintObject","SpecialNumber","date","regexp","BooleanObject","NumberObject","StringObject","error","errors","blob","blobHTML","file","set","map","filelist","domexception","domrect","dompoint","dommatrix","buffersource","resurrectable"]}},fe={types:()=>["number","SpecialRealNumber","string","ValidDate","array","buffersource"],testInvalid(e,t){switch(e){case"SpecialRealNumber":return Number.isNaN(t);case"ValidDate":return Number.isNaN(t.getTime());case"array":return Object.keys(t).length!==t.length;default:return!1}},convertFromTypeson:e=>({type:ge.get(e)}),iterate:(e,t)=>(t.format="indexedDBKey",he.iterate(e,t)),getTypesAndSchemasForState(e,t){if(!t||["array"].includes(t))return{types:this.types(),schemaObjects:[]}}},ge=new Map([["SpecialNumber","SpecialRealNumber"],["date","ValidDate"],["arrayNonindexKeys","array"]]);var ve,be;!function(e){e.assertEqual=e=>e,e.assertIs=function assertIs(e){},e.assertNever=function assertNever(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const a of e)t[a]=a;return t},e.getValidEnumValues=t=>{const a=e.objectKeys(t).filter((e=>"number"!=typeof t[t[e]])),r={};for(const e of a)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map((function(e){return t[e]})),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.push(a);return t},e.find=(e,t)=>{for(const a of e)if(t(a))return a},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&isFinite(e)&&Math.floor(e)===e,e.joinValues=function joinValues(e,t=" | "){return e.map((e=>"string"==typeof e?`'${e}'`:e)).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(ve||(ve={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(be||(be={}));const we=ve.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),getParsedType=e=>{switch(typeof e){case"undefined":return we.undefined;case"string":return we.string;case"number":return isNaN(e)?we.nan:we.number;case"boolean":return we.boolean;case"function":return we.function;case"bigint":return we.bigint;case"symbol":return we.symbol;case"object":return Array.isArray(e)?we.array:null===e?we.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?we.promise:"undefined"!=typeof Map&&e instanceof Map?we.map:"undefined"!=typeof Set&&e instanceof Set?we.set:"undefined"!=typeof Date&&e instanceof Date?we.date:we.object;default:return we.unknown}},xe=ve.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class ZodError extends Error{constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(e){return e.message},a={_errors:[]},processError=e=>{for(const r of e.issues)if("invalid_union"===r.code)r.unionErrors.map(processError);else if("invalid_return_type"===r.code)processError(r.returnTypeError);else if("invalid_arguments"===r.code)processError(r.argumentsError);else if(0===r.path.length)a._errors.push(t(r));else{let e=a,n=0;for(;n<r.path.length;){const a=r.path[n];n===r.path.length-1?(e[a]=e[a]||{_errors:[]},e[a]._errors.push(t(r))):e[a]=e[a]||{_errors:[]},e=e[a],n++}}};return processError(this),a}static assert(e){if(!(e instanceof ZodError))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ve.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},a=[];for(const r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):a.push(e(r));return{formErrors:a,fieldErrors:t}}get formErrors(){return this.flatten()}}ZodError.create=e=>new ZodError(e);const errorMap=(e,t)=>{let a;switch(e.code){case xe.invalid_type:a=e.received===we.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case xe.invalid_literal:a=`Invalid literal value, expected ${JSON.stringify(e.expected,ve.jsonStringifyReplacer)}`;break;case xe.unrecognized_keys:a=`Unrecognized key(s) in object: ${ve.joinValues(e.keys,", ")}`;break;case xe.invalid_union:a="Invalid input";break;case xe.invalid_union_discriminator:a=`Invalid discriminator value. Expected ${ve.joinValues(e.options)}`;break;case xe.invalid_enum_value:a=`Invalid enum value. Expected ${ve.joinValues(e.options)}, received '${e.received}'`;break;case xe.invalid_arguments:a="Invalid function arguments";break;case xe.invalid_return_type:a="Invalid function return type";break;case xe.invalid_date:a="Invalid date";break;case xe.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(a=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(a=`${a} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?a=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?a=`Invalid input: must end with "${e.validation.endsWith}"`:ve.assertNever(e.validation):a="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case xe.too_small:a="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case xe.too_big:a="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case xe.custom:a="Invalid input";break;case xe.invalid_intersection_types:a="Intersection results could not be merged";break;case xe.not_multiple_of:a=`Number must be a multiple of ${e.multipleOf}`;break;case xe.not_finite:a="Number must be finite";break;default:a=t.defaultError,ve.assertNever(e)}return{message:a}};let Se=errorMap;function getErrorMap(){return Se}const makeIssue=e=>{const{data:t,path:a,errorMaps:r,issueData:n}=e,i=[...a,...n.path||[]],s={...n,path:i};if(void 0!==n.message)return{...n,path:i,message:n.message};let o="";const c=r.filter((e=>!!e)).slice().reverse();for(const e of c)o=e(s,{data:t,defaultError:o}).message;return{...n,path:i,message:o}};function addIssueToContext(e,t){const a=getErrorMap(),r=makeIssue({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,a,a===errorMap?void 0:errorMap].filter((e=>!!e))});e.common.issues.push(r)}class ParseStatus{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const a=[];for(const r of t){if("aborted"===r.status)return Ie;"dirty"===r.status&&e.dirty(),a.push(r.value)}return{status:e.value,value:a}}static async mergeObjectAsync(e,t){const a=[];for(const e of t){const t=await e.key,r=await e.value;a.push({key:t,value:r})}return ParseStatus.mergeObjectSync(e,a)}static mergeObjectSync(e,t){const a={};for(const r of t){const{key:t,value:n}=r;if("aborted"===t.status)return Ie;if("aborted"===n.status)return Ie;"dirty"===t.status&&e.dirty(),"dirty"===n.status&&e.dirty(),"__proto__"===t.value||void 0===n.value&&!r.alwaysSet||(a[t.value]=n.value)}return{status:e.value,value:a}}}const Ie=Object.freeze({status:"aborted"}),DIRTY=e=>({status:"dirty",value:e}),OK=e=>({status:"valid",value:e}),isAborted=e=>"aborted"===e.status,isDirty=e=>"dirty"===e.status,isValid=e=>"valid"===e.status,isAsync=e=>"undefined"!=typeof Promise&&e instanceof Promise;function __classPrivateFieldGet(e,t,a,r){if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t.get(e)}function __classPrivateFieldSet(e,t,a,r,n){if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,a),a}var Te,Ee,Ne;"function"==typeof SuppressedError&&SuppressedError,function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:null==e?void 0:e.message}(Te||(Te={}));class ParseInputLazyPath{constructor(e,t,a,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=a,this._key=r}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const handleResult=(e,t)=>{if(isValid(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new ZodError(e.common.issues);return this._error=t,this._error}}};function processCreateParams(e){if(!e)return{};const{errorMap:t,invalid_type_error:a,required_error:r,description:n}=e;if(t&&(a||r))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:n};return{errorMap:(t,n)=>{var i,s;const{message:o}=e;return"invalid_enum_value"===t.code?{message:null!=o?o:n.defaultError}:void 0===n.data?{message:null!==(i=null!=o?o:r)&&void 0!==i?i:n.defaultError}:"invalid_type"!==t.code?{message:n.defaultError}:{message:null!==(s=null!=o?o:a)&&void 0!==s?s:n.defaultError}},description:n}}class ZodType{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return getParsedType(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:getParsedType(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ParseStatus,ctx:{common:e.parent.common,data:e.data,parsedType:getParsedType(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(isAsync(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const a=this.safeParse(e,t);if(a.success)return a.data;throw a.error}safeParse(e,t){var a;const r={common:{issues:[],async:null!==(a=null==t?void 0:t.async)&&void 0!==a&&a,contextualErrorMap:null==t?void 0:t.errorMap},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:getParsedType(e)},n=this._parseSync({data:e,path:r.path,parent:r});return handleResult(r,n)}async parseAsync(e,t){const a=await this.safeParseAsync(e,t);if(a.success)return a.data;throw a.error}async safeParseAsync(e,t){const a={common:{issues:[],contextualErrorMap:null==t?void 0:t.errorMap,async:!0},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:getParsedType(e)},r=this._parse({data:e,path:a.path,parent:a}),n=await(isAsync(r)?r:Promise.resolve(r));return handleResult(a,n)}refine(e,t){const getIssueProperties=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,a)=>{const r=e(t),setError=()=>a.addIssue({code:xe.custom,...getIssueProperties(t)});return"undefined"!=typeof Promise&&r instanceof Promise?r.then((e=>!!e||(setError(),!1))):!!r||(setError(),!1)}))}refinement(e,t){return this._refinement(((a,r)=>!!e(a)||(r.addIssue("function"==typeof t?t(a,r):t),!1)))}_refinement(e){return new ZodEffects({schema:this,typeName:Fe.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ZodOptional.create(this,this._def)}nullable(){return ZodNullable.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ZodArray.create(this,this._def)}promise(){return ZodPromise.create(this,this._def)}or(e){return ZodUnion.create([this,e],this._def)}and(e){return ZodIntersection.create(this,e,this._def)}transform(e){return new ZodEffects({...processCreateParams(this._def),schema:this,typeName:Fe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new ZodDefault({...processCreateParams(this._def),innerType:this,defaultValue:t,typeName:Fe.ZodDefault})}brand(){return new ZodBranded({typeName:Fe.ZodBranded,type:this,...processCreateParams(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new ZodCatch({...processCreateParams(this._def),innerType:this,catchValue:t,typeName:Fe.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return ZodPipeline.create(this,e)}readonly(){return ZodReadonly.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const _e=/^c[^\s-]{8,}$/i,Oe=/^[0-9a-z]+$/,ke=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ae=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Ce=/^[a-z0-9_-]{21}$/i,je=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Re=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let Ze;const Ve=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Me=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Pe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ue="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Be=new RegExp(`^${Ue}$`);function timeRegexSource$1(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`),t}function datetimeRegex(e){let t=`${Ue}T${timeRegexSource$1(e)}`;const a=[];return a.push(e.local?"Z?":"Z"),e.offset&&a.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${a.join("|")})`,new RegExp(`^${t}$`)}class ZodString extends ZodType{_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==we.string){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:xe.invalid_type,expected:we.string,received:t.parsedType}),Ie}const t=new ParseStatus;let a;for(const i of this._def.checks)if("min"===i.kind)e.data.length<i.value&&(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{code:xe.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if("max"===i.kind)e.data.length>i.value&&(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{code:xe.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if("length"===i.kind){const r=e.data.length>i.value,n=e.data.length<i.value;(r||n)&&(a=this._getOrReturnCtx(e,a),r?addIssueToContext(a,{code:xe.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):n&&addIssueToContext(a,{code:xe.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),t.dirty())}else if("email"===i.kind)Re.test(e.data)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{validation:"email",code:xe.invalid_string,message:i.message}),t.dirty());else if("emoji"===i.kind)Ze||(Ze=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Ze.test(e.data)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{validation:"emoji",code:xe.invalid_string,message:i.message}),t.dirty());else if("uuid"===i.kind)Ae.test(e.data)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{validation:"uuid",code:xe.invalid_string,message:i.message}),t.dirty());else if("nanoid"===i.kind)Ce.test(e.data)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{validation:"nanoid",code:xe.invalid_string,message:i.message}),t.dirty());else if("cuid"===i.kind)_e.test(e.data)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{validation:"cuid",code:xe.invalid_string,message:i.message}),t.dirty());else if("cuid2"===i.kind)Oe.test(e.data)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{validation:"cuid2",code:xe.invalid_string,message:i.message}),t.dirty());else if("ulid"===i.kind)ke.test(e.data)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{validation:"ulid",code:xe.invalid_string,message:i.message}),t.dirty());else if("url"===i.kind)try{new URL(e.data)}catch(r){a=this._getOrReturnCtx(e,a),addIssueToContext(a,{validation:"url",code:xe.invalid_string,message:i.message}),t.dirty()}else if("regex"===i.kind){i.regex.lastIndex=0;i.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{validation:"regex",code:xe.invalid_string,message:i.message}),t.dirty())}else if("trim"===i.kind)e.data=e.data.trim();else if("includes"===i.kind)e.data.includes(i.value,i.position)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{code:xe.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),t.dirty());else if("toLowerCase"===i.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===i.kind)e.data=e.data.toUpperCase();else if("startsWith"===i.kind)e.data.startsWith(i.value)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{code:xe.invalid_string,validation:{startsWith:i.value},message:i.message}),t.dirty());else if("endsWith"===i.kind)e.data.endsWith(i.value)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{code:xe.invalid_string,validation:{endsWith:i.value},message:i.message}),t.dirty());else if("datetime"===i.kind){datetimeRegex(i).test(e.data)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{code:xe.invalid_string,validation:"datetime",message:i.message}),t.dirty())}else if("date"===i.kind){Be.test(e.data)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{code:xe.invalid_string,validation:"date",message:i.message}),t.dirty())}else if("time"===i.kind){new RegExp(`^${timeRegexSource$1(i)}$`).test(e.data)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{code:xe.invalid_string,validation:"time",message:i.message}),t.dirty())}else"duration"===i.kind?je.test(e.data)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{validation:"duration",code:xe.invalid_string,message:i.message}),t.dirty()):"ip"===i.kind?(r=e.data,("v4"!==(n=i.version)&&n||!Ve.test(r))&&("v6"!==n&&n||!Me.test(r))&&(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{validation:"ip",code:xe.invalid_string,message:i.message}),t.dirty())):"base64"===i.kind?Pe.test(e.data)||(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{validation:"base64",code:xe.invalid_string,message:i.message}),t.dirty()):ve.assertNever(i);var r,n;return{status:t.value,value:e.data}}_regex(e,t,a){return this.refinement((t=>e.test(t)),{validation:t,code:xe.invalid_string,...Te.errToObj(a)})}_addCheck(e){return new ZodString({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Te.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Te.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Te.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Te.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Te.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Te.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Te.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Te.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Te.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Te.errToObj(e)})}datetime(e){var t,a;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,offset:null!==(t=null==e?void 0:e.offset)&&void 0!==t&&t,local:null!==(a=null==e?void 0:e.local)&&void 0!==a&&a,...Te.errToObj(null==e?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,...Te.errToObj(null==e?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Te.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Te.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:null==t?void 0:t.position,...Te.errToObj(null==t?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Te.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Te.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Te.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Te.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Te.errToObj(t)})}nonempty(e){return this.min(1,Te.errToObj(e))}trim(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e=>"datetime"===e.kind))}get isDate(){return!!this._def.checks.find((e=>"date"===e.kind))}get isTime(){return!!this._def.checks.find((e=>"time"===e.kind))}get isDuration(){return!!this._def.checks.find((e=>"duration"===e.kind))}get isEmail(){return!!this._def.checks.find((e=>"email"===e.kind))}get isURL(){return!!this._def.checks.find((e=>"url"===e.kind))}get isEmoji(){return!!this._def.checks.find((e=>"emoji"===e.kind))}get isUUID(){return!!this._def.checks.find((e=>"uuid"===e.kind))}get isNANOID(){return!!this._def.checks.find((e=>"nanoid"===e.kind))}get isCUID(){return!!this._def.checks.find((e=>"cuid"===e.kind))}get isCUID2(){return!!this._def.checks.find((e=>"cuid2"===e.kind))}get isULID(){return!!this._def.checks.find((e=>"ulid"===e.kind))}get isIP(){return!!this._def.checks.find((e=>"ip"===e.kind))}get isBase64(){return!!this._def.checks.find((e=>"base64"===e.kind))}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function floatSafeRemainder(e,t){const a=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,n=a>r?a:r;return parseInt(e.toFixed(n).replace(".",""))%parseInt(t.toFixed(n).replace(".",""))/Math.pow(10,n)}ZodString.create=e=>{var t;return new ZodString({checks:[],typeName:Fe.ZodString,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...processCreateParams(e)})};class ZodNumber extends ZodType{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){this._def.coerce&&(e.data=Number(e.data));if(this._getType(e)!==we.number){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:xe.invalid_type,expected:we.number,received:t.parsedType}),Ie}let t;const a=new ParseStatus;for(const r of this._def.checks)if("int"===r.kind)ve.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:xe.invalid_type,expected:"integer",received:"float",message:r.message}),a.dirty());else if("min"===r.kind){(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:xe.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty())}else if("max"===r.kind){(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:xe.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty())}else"multipleOf"===r.kind?0!==floatSafeRemainder(e.data,r.value)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:xe.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):"finite"===r.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:xe.not_finite,message:r.message}),a.dirty()):ve.assertNever(r);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Te.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Te.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Te.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Te.toString(t))}setLimit(e,t,a,r){return new ZodNumber({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:Te.toString(r)}]})}_addCheck(e){return new ZodNumber({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Te.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Te.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Te.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Te.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Te.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Te.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Te.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Te.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Te.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find((e=>"int"===e.kind||"multipleOf"===e.kind&&ve.isInteger(e.value)))}get isFinite(){let e=null,t=null;for(const a of this._def.checks){if("finite"===a.kind||"int"===a.kind||"multipleOf"===a.kind)return!0;"min"===a.kind?(null===t||a.value>t)&&(t=a.value):"max"===a.kind&&(null===e||a.value<e)&&(e=a.value)}return Number.isFinite(t)&&Number.isFinite(e)}}ZodNumber.create=e=>new ZodNumber({checks:[],typeName:Fe.ZodNumber,coerce:(null==e?void 0:e.coerce)||!1,...processCreateParams(e)});class ZodBigInt extends ZodType{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){this._def.coerce&&(e.data=BigInt(e.data));if(this._getType(e)!==we.bigint){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:xe.invalid_type,expected:we.bigint,received:t.parsedType}),Ie}let t;const a=new ParseStatus;for(const r of this._def.checks)if("min"===r.kind){(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:xe.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty())}else if("max"===r.kind){(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:xe.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty())}else"multipleOf"===r.kind?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:xe.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):ve.assertNever(r);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Te.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Te.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Te.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Te.toString(t))}setLimit(e,t,a,r){return new ZodBigInt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:Te.toString(r)}]})}_addCheck(e){return new ZodBigInt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Te.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Te.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Te.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Te.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Te.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}ZodBigInt.create=e=>{var t;return new ZodBigInt({checks:[],typeName:Fe.ZodBigInt,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...processCreateParams(e)})};class ZodBoolean extends ZodType{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==we.boolean){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:xe.invalid_type,expected:we.boolean,received:t.parsedType}),Ie}return OK(e.data)}}ZodBoolean.create=e=>new ZodBoolean({typeName:Fe.ZodBoolean,coerce:(null==e?void 0:e.coerce)||!1,...processCreateParams(e)});class ZodDate extends ZodType{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==we.date){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:xe.invalid_type,expected:we.date,received:t.parsedType}),Ie}if(isNaN(e.data.getTime())){return addIssueToContext(this._getOrReturnCtx(e),{code:xe.invalid_date}),Ie}const t=new ParseStatus;let a;for(const r of this._def.checks)"min"===r.kind?e.data.getTime()<r.value&&(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{code:xe.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),t.dirty()):"max"===r.kind?e.data.getTime()>r.value&&(a=this._getOrReturnCtx(e,a),addIssueToContext(a,{code:xe.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),t.dirty()):ve.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ZodDate({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Te.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Te.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}ZodDate.create=e=>new ZodDate({checks:[],coerce:(null==e?void 0:e.coerce)||!1,typeName:Fe.ZodDate,...processCreateParams(e)});class ZodSymbol extends ZodType{_parse(e){if(this._getType(e)!==we.symbol){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:xe.invalid_type,expected:we.symbol,received:t.parsedType}),Ie}return OK(e.data)}}ZodSymbol.create=e=>new ZodSymbol({typeName:Fe.ZodSymbol,...processCreateParams(e)});class ZodUndefined extends ZodType{_parse(e){if(this._getType(e)!==we.undefined){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:xe.invalid_type,expected:we.undefined,received:t.parsedType}),Ie}return OK(e.data)}}ZodUndefined.create=e=>new ZodUndefined({typeName:Fe.ZodUndefined,...processCreateParams(e)});class ZodNull extends ZodType{_parse(e){if(this._getType(e)!==we.null){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:xe.invalid_type,expected:we.null,received:t.parsedType}),Ie}return OK(e.data)}}ZodNull.create=e=>new ZodNull({typeName:Fe.ZodNull,...processCreateParams(e)});class ZodAny extends ZodType{constructor(){super(...arguments),this._any=!0}_parse(e){return OK(e.data)}}ZodAny.create=e=>new ZodAny({typeName:Fe.ZodAny,...processCreateParams(e)});class ZodUnknown extends ZodType{constructor(){super(...arguments),this._unknown=!0}_parse(e){return OK(e.data)}}ZodUnknown.create=e=>new ZodUnknown({typeName:Fe.ZodUnknown,...processCreateParams(e)});class ZodNever extends ZodType{_parse(e){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:xe.invalid_type,expected:we.never,received:t.parsedType}),Ie}}ZodNever.create=e=>new ZodNever({typeName:Fe.ZodNever,...processCreateParams(e)});class ZodVoid extends ZodType{_parse(e){if(this._getType(e)!==we.undefined){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:xe.invalid_type,expected:we.void,received:t.parsedType}),Ie}return OK(e.data)}}ZodVoid.create=e=>new ZodVoid({typeName:Fe.ZodVoid,...processCreateParams(e)});class ZodArray extends ZodType{_parse(e){const{ctx:t,status:a}=this._processInputParams(e),r=this._def;if(t.parsedType!==we.array)return addIssueToContext(t,{code:xe.invalid_type,expected:we.array,received:t.parsedType}),Ie;if(null!==r.exactLength){const e=t.data.length>r.exactLength.value,n=t.data.length<r.exactLength.value;(e||n)&&(addIssueToContext(t,{code:e?xe.too_big:xe.too_small,minimum:n?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),a.dirty())}if(null!==r.minLength&&t.data.length<r.minLength.value&&(addIssueToContext(t,{code:xe.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),a.dirty()),null!==r.maxLength&&t.data.length>r.maxLength.value&&(addIssueToContext(t,{code:xe.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),a.dirty()),t.common.async)return Promise.all([...t.data].map(((e,a)=>r.type._parseAsync(new ParseInputLazyPath(t,e,t.path,a))))).then((e=>ParseStatus.mergeArray(a,e)));const n=[...t.data].map(((e,a)=>r.type._parseSync(new ParseInputLazyPath(t,e,t.path,a))));return ParseStatus.mergeArray(a,n)}get element(){return this._def.type}min(e,t){return new ZodArray({...this._def,minLength:{value:e,message:Te.toString(t)}})}max(e,t){return new ZodArray({...this._def,maxLength:{value:e,message:Te.toString(t)}})}length(e,t){return new ZodArray({...this._def,exactLength:{value:e,message:Te.toString(t)}})}nonempty(e){return this.min(1,e)}}function deepPartialify(e){if(e instanceof ZodObject){const t={};for(const a in e.shape){const r=e.shape[a];t[a]=ZodOptional.create(deepPartialify(r))}return new ZodObject({...e._def,shape:()=>t})}return e instanceof ZodArray?new ZodArray({...e._def,type:deepPartialify(e.element)}):e instanceof ZodOptional?ZodOptional.create(deepPartialify(e.unwrap())):e instanceof ZodNullable?ZodNullable.create(deepPartialify(e.unwrap())):e instanceof ZodTuple?ZodTuple.create(e.items.map((e=>deepPartialify(e)))):e}ZodArray.create=(e,t)=>new ZodArray({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Fe.ZodArray,...processCreateParams(t)});class ZodObject extends ZodType{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=ve.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==we.object){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:xe.invalid_type,expected:we.object,received:t.parsedType}),Ie}const{status:t,ctx:a}=this._processInputParams(e),{shape:r,keys:n}=this._getCached(),i=[];if(!(this._def.catchall instanceof ZodNever&&"strip"===this._def.unknownKeys))for(const e in a.data)n.includes(e)||i.push(e);const s=[];for(const e of n){const t=r[e],n=a.data[e];s.push({key:{status:"valid",value:e},value:t._parse(new ParseInputLazyPath(a,n,a.path,e)),alwaysSet:e in a.data})}if(this._def.catchall instanceof ZodNever){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of i)s.push({key:{status:"valid",value:e},value:{status:"valid",value:a.data[e]}});else if("strict"===e)i.length>0&&(addIssueToContext(a,{code:xe.unrecognized_keys,keys:i}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of i){const r=a.data[t];s.push({key:{status:"valid",value:t},value:e._parse(new ParseInputLazyPath(a,r,a.path,t)),alwaysSet:t in a.data})}}return a.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of s){const a=await t.key,r=await t.value;e.push({key:a,value:r,alwaysSet:t.alwaysSet})}return e})).then((e=>ParseStatus.mergeObjectSync(t,e))):ParseStatus.mergeObjectSync(t,s)}get shape(){return this._def.shape()}strict(e){return Te.errToObj,new ZodObject({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,a)=>{var r,n,i,s;const o=null!==(i=null===(n=(r=this._def).errorMap)||void 0===n?void 0:n.call(r,t,a).message)&&void 0!==i?i:a.defaultError;return"unrecognized_keys"===t.code?{message:null!==(s=Te.errToObj(e).message)&&void 0!==s?s:o}:{message:o}}}:{}})}strip(){return new ZodObject({...this._def,unknownKeys:"strip"})}passthrough(){return new ZodObject({...this._def,unknownKeys:"passthrough"})}extend(e){return new ZodObject({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ZodObject({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Fe.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ZodObject({...this._def,catchall:e})}pick(e){const t={};return ve.objectKeys(e).forEach((a=>{e[a]&&this.shape[a]&&(t[a]=this.shape[a])})),new ZodObject({...this._def,shape:()=>t})}omit(e){const t={};return ve.objectKeys(this.shape).forEach((a=>{e[a]||(t[a]=this.shape[a])})),new ZodObject({...this._def,shape:()=>t})}deepPartial(){return deepPartialify(this)}partial(e){const t={};return ve.objectKeys(this.shape).forEach((a=>{const r=this.shape[a];e&&!e[a]?t[a]=r:t[a]=r.optional()})),new ZodObject({...this._def,shape:()=>t})}required(e){const t={};return ve.objectKeys(this.shape).forEach((a=>{if(e&&!e[a])t[a]=this.shape[a];else{let e=this.shape[a];for(;e instanceof ZodOptional;)e=e._def.innerType;t[a]=e}})),new ZodObject({...this._def,shape:()=>t})}keyof(){return createZodEnum(ve.objectKeys(this.shape))}}ZodObject.create=(e,t)=>new ZodObject({shape:()=>e,unknownKeys:"strip",catchall:ZodNever.create(),typeName:Fe.ZodObject,...processCreateParams(t)}),ZodObject.strictCreate=(e,t)=>new ZodObject({shape:()=>e,unknownKeys:"strict",catchall:ZodNever.create(),typeName:Fe.ZodObject,...processCreateParams(t)}),ZodObject.lazycreate=(e,t)=>new ZodObject({shape:e,unknownKeys:"strip",catchall:ZodNever.create(),typeName:Fe.ZodObject,...processCreateParams(t)});class ZodUnion extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e),a=this._def.options;if(t.common.async)return Promise.all(a.map((async e=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}}))).then((function handleResults(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const a of e)if("dirty"===a.result.status)return t.common.issues.push(...a.ctx.common.issues),a.result;const a=e.map((e=>new ZodError(e.ctx.common.issues)));return addIssueToContext(t,{code:xe.invalid_union,unionErrors:a}),Ie}));{let e;const r=[];for(const n of a){const a={...t,common:{...t.common,issues:[]},parent:null},i=n._parseSync({data:t.data,path:t.path,parent:a});if("valid"===i.status)return i;"dirty"!==i.status||e||(e={result:i,ctx:a}),a.common.issues.length&&r.push(a.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const n=r.map((e=>new ZodError(e)));return addIssueToContext(t,{code:xe.invalid_union,unionErrors:n}),Ie}}get options(){return this._def.options}}ZodUnion.create=(e,t)=>new ZodUnion({options:e,typeName:Fe.ZodUnion,...processCreateParams(t)});const getDiscriminator=e=>e instanceof ZodLazy?getDiscriminator(e.schema):e instanceof ZodEffects?getDiscriminator(e.innerType()):e instanceof ZodLiteral?[e.value]:e instanceof ZodEnum?e.options:e instanceof ZodNativeEnum?ve.objectValues(e.enum):e instanceof ZodDefault?getDiscriminator(e._def.innerType):e instanceof ZodUndefined?[void 0]:e instanceof ZodNull?[null]:e instanceof ZodOptional?[void 0,...getDiscriminator(e.unwrap())]:e instanceof ZodNullable?[null,...getDiscriminator(e.unwrap())]:e instanceof ZodBranded||e instanceof ZodReadonly?getDiscriminator(e.unwrap()):e instanceof ZodCatch?getDiscriminator(e._def.innerType):[];class ZodDiscriminatedUnion extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==we.object)return addIssueToContext(t,{code:xe.invalid_type,expected:we.object,received:t.parsedType}),Ie;const a=this.discriminator,r=t.data[a],n=this.optionsMap.get(r);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(addIssueToContext(t,{code:xe.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),Ie)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,a){const r=new Map;for(const a of t){const t=getDiscriminator(a.shape[e]);if(!t.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const n of t){if(r.has(n))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(n)}`);r.set(n,a)}}return new ZodDiscriminatedUnion({typeName:Fe.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...processCreateParams(a)})}}function mergeValues(e,t){const a=getParsedType(e),r=getParsedType(t);if(e===t)return{valid:!0,data:e};if(a===we.object&&r===we.object){const a=ve.objectKeys(t),r=ve.objectKeys(e).filter((e=>-1!==a.indexOf(e))),n={...e,...t};for(const a of r){const r=mergeValues(e[a],t[a]);if(!r.valid)return{valid:!1};n[a]=r.data}return{valid:!0,data:n}}if(a===we.array&&r===we.array){if(e.length!==t.length)return{valid:!1};const a=[];for(let r=0;r<e.length;r++){const n=mergeValues(e[r],t[r]);if(!n.valid)return{valid:!1};a.push(n.data)}return{valid:!0,data:a}}return a===we.date&&r===we.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class ZodIntersection extends ZodType{_parse(e){const{status:t,ctx:a}=this._processInputParams(e),handleParsed=(e,r)=>{if(isAborted(e)||isAborted(r))return Ie;const n=mergeValues(e.value,r.value);return n.valid?((isDirty(e)||isDirty(r))&&t.dirty(),{status:t.value,value:n.data}):(addIssueToContext(a,{code:xe.invalid_intersection_types}),Ie)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then((([e,t])=>handleParsed(e,t))):handleParsed(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}}ZodIntersection.create=(e,t,a)=>new ZodIntersection({left:e,right:t,typeName:Fe.ZodIntersection,...processCreateParams(a)});class ZodTuple extends ZodType{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==we.array)return addIssueToContext(a,{code:xe.invalid_type,expected:we.array,received:a.parsedType}),Ie;if(a.data.length<this._def.items.length)return addIssueToContext(a,{code:xe.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Ie;!this._def.rest&&a.data.length>this._def.items.length&&(addIssueToContext(a,{code:xe.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...a.data].map(((e,t)=>{const r=this._def.items[t]||this._def.rest;return r?r._parse(new ParseInputLazyPath(a,e,a.path,t)):null})).filter((e=>!!e));return a.common.async?Promise.all(r).then((e=>ParseStatus.mergeArray(t,e))):ParseStatus.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new ZodTuple({...this._def,rest:e})}}ZodTuple.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ZodTuple({items:e,typeName:Fe.ZodTuple,rest:null,...processCreateParams(t)})};class ZodRecord extends ZodType{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==we.object)return addIssueToContext(a,{code:xe.invalid_type,expected:we.object,received:a.parsedType}),Ie;const r=[],n=this._def.keyType,i=this._def.valueType;for(const e in a.data)r.push({key:n._parse(new ParseInputLazyPath(a,e,a.path,e)),value:i._parse(new ParseInputLazyPath(a,a.data[e],a.path,e)),alwaysSet:e in a.data});return a.common.async?ParseStatus.mergeObjectAsync(t,r):ParseStatus.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,a){return new ZodRecord(t instanceof ZodType?{keyType:e,valueType:t,typeName:Fe.ZodRecord,...processCreateParams(a)}:{keyType:ZodString.create(),valueType:e,typeName:Fe.ZodRecord,...processCreateParams(t)})}}class ZodMap extends ZodType{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==we.map)return addIssueToContext(a,{code:xe.invalid_type,expected:we.map,received:a.parsedType}),Ie;const r=this._def.keyType,n=this._def.valueType,i=[...a.data.entries()].map((([e,t],i)=>({key:r._parse(new ParseInputLazyPath(a,e,a.path,[i,"key"])),value:n._parse(new ParseInputLazyPath(a,t,a.path,[i,"value"]))})));if(a.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const a of i){const r=await a.key,n=await a.value;if("aborted"===r.status||"aborted"===n.status)return Ie;"dirty"!==r.status&&"dirty"!==n.status||t.dirty(),e.set(r.value,n.value)}return{status:t.value,value:e}}))}{const e=new Map;for(const a of i){const r=a.key,n=a.value;if("aborted"===r.status||"aborted"===n.status)return Ie;"dirty"!==r.status&&"dirty"!==n.status||t.dirty(),e.set(r.value,n.value)}return{status:t.value,value:e}}}}ZodMap.create=(e,t,a)=>new ZodMap({valueType:t,keyType:e,typeName:Fe.ZodMap,...processCreateParams(a)});class ZodSet extends ZodType{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==we.set)return addIssueToContext(a,{code:xe.invalid_type,expected:we.set,received:a.parsedType}),Ie;const r=this._def;null!==r.minSize&&a.data.size<r.minSize.value&&(addIssueToContext(a,{code:xe.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),null!==r.maxSize&&a.data.size>r.maxSize.value&&(addIssueToContext(a,{code:xe.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const n=this._def.valueType;function finalizeSet(e){const a=new Set;for(const r of e){if("aborted"===r.status)return Ie;"dirty"===r.status&&t.dirty(),a.add(r.value)}return{status:t.value,value:a}}const i=[...a.data.values()].map(((e,t)=>n._parse(new ParseInputLazyPath(a,e,a.path,t))));return a.common.async?Promise.all(i).then((e=>finalizeSet(e))):finalizeSet(i)}min(e,t){return new ZodSet({...this._def,minSize:{value:e,message:Te.toString(t)}})}max(e,t){return new ZodSet({...this._def,maxSize:{value:e,message:Te.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ZodSet.create=(e,t)=>new ZodSet({valueType:e,minSize:null,maxSize:null,typeName:Fe.ZodSet,...processCreateParams(t)});class ZodFunction extends ZodType{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==we.function)return addIssueToContext(t,{code:xe.invalid_type,expected:we.function,received:t.parsedType}),Ie;function makeArgsIssue(e,a){return makeIssue({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,getErrorMap(),errorMap].filter((e=>!!e)),issueData:{code:xe.invalid_arguments,argumentsError:a}})}function makeReturnsIssue(e,a){return makeIssue({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,getErrorMap(),errorMap].filter((e=>!!e)),issueData:{code:xe.invalid_return_type,returnTypeError:a}})}const a={errorMap:t.common.contextualErrorMap},r=t.data;if(this._def.returns instanceof ZodPromise){const e=this;return OK((async function(...t){const n=new ZodError([]),i=await e._def.args.parseAsync(t,a).catch((e=>{throw n.addIssue(makeArgsIssue(t,e)),n})),s=await Reflect.apply(r,this,i),o=await e._def.returns._def.type.parseAsync(s,a).catch((e=>{throw n.addIssue(makeReturnsIssue(s,e)),n}));return o}))}{const e=this;return OK((function(...t){const n=e._def.args.safeParse(t,a);if(!n.success)throw new ZodError([makeArgsIssue(t,n.error)]);const i=Reflect.apply(r,this,n.data),s=e._def.returns.safeParse(i,a);if(!s.success)throw new ZodError([makeReturnsIssue(i,s.error)]);return s.data}))}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ZodFunction({...this._def,args:ZodTuple.create(e).rest(ZodUnknown.create())})}returns(e){return new ZodFunction({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,a){return new ZodFunction({args:e||ZodTuple.create([]).rest(ZodUnknown.create()),returns:t||ZodUnknown.create(),typeName:Fe.ZodFunction,...processCreateParams(a)})}}class ZodLazy extends ZodType{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ZodLazy.create=(e,t)=>new ZodLazy({getter:e,typeName:Fe.ZodLazy,...processCreateParams(t)});class ZodLiteral extends ZodType{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{received:t.data,code:xe.invalid_literal,expected:this._def.value}),Ie}return{status:"valid",value:e.data}}get value(){return this._def.value}}function createZodEnum(e,t){return new ZodEnum({values:e,typeName:Fe.ZodEnum,...processCreateParams(t)})}ZodLiteral.create=(e,t)=>new ZodLiteral({value:e,typeName:Fe.ZodLiteral,...processCreateParams(t)});class ZodEnum extends ZodType{constructor(){super(...arguments),Ee.set(this,void 0)}_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),a=this._def.values;return addIssueToContext(t,{expected:ve.joinValues(a),received:t.parsedType,code:xe.invalid_type}),Ie}if(__classPrivateFieldGet(this,Ee)||__classPrivateFieldSet(this,Ee,new Set(this._def.values)),!__classPrivateFieldGet(this,Ee).has(e.data)){const t=this._getOrReturnCtx(e),a=this._def.values;return addIssueToContext(t,{received:t.data,code:xe.invalid_enum_value,options:a}),Ie}return OK(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return ZodEnum.create(e,{...this._def,...t})}exclude(e,t=this._def){return ZodEnum.create(this.options.filter((t=>!e.includes(t))),{...this._def,...t})}}Ee=new WeakMap,ZodEnum.create=createZodEnum;class ZodNativeEnum extends ZodType{constructor(){super(...arguments),Ne.set(this,void 0)}_parse(e){const t=ve.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==we.string&&a.parsedType!==we.number){const e=ve.objectValues(t);return addIssueToContext(a,{expected:ve.joinValues(e),received:a.parsedType,code:xe.invalid_type}),Ie}if(__classPrivateFieldGet(this,Ne)||__classPrivateFieldSet(this,Ne,new Set(ve.getValidEnumValues(this._def.values))),!__classPrivateFieldGet(this,Ne).has(e.data)){const e=ve.objectValues(t);return addIssueToContext(a,{received:a.data,code:xe.invalid_enum_value,options:e}),Ie}return OK(e.data)}get enum(){return this._def.values}}Ne=new WeakMap,ZodNativeEnum.create=(e,t)=>new ZodNativeEnum({values:e,typeName:Fe.ZodNativeEnum,...processCreateParams(t)});class ZodPromise extends ZodType{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==we.promise&&!1===t.common.async)return addIssueToContext(t,{code:xe.invalid_type,expected:we.promise,received:t.parsedType}),Ie;const a=t.parsedType===we.promise?t.data:Promise.resolve(t.data);return OK(a.then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}}ZodPromise.create=(e,t)=>new ZodPromise({type:e,typeName:Fe.ZodPromise,...processCreateParams(t)});class ZodEffects extends ZodType{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Fe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:a}=this._processInputParams(e),r=this._def.effect||null,n={addIssue:e=>{addIssueToContext(a,e),e.fatal?t.abort():t.dirty()},get path(){return a.path}};if(n.addIssue=n.addIssue.bind(n),"preprocess"===r.type){const e=r.transform(a.data,n);if(a.common.async)return Promise.resolve(e).then((async e=>{if("aborted"===t.value)return Ie;const r=await this._def.schema._parseAsync({data:e,path:a.path,parent:a});return"aborted"===r.status?Ie:"dirty"===r.status||"dirty"===t.value?DIRTY(r.value):r}));{if("aborted"===t.value)return Ie;const r=this._def.schema._parseSync({data:e,path:a.path,parent:a});return"aborted"===r.status?Ie:"dirty"===r.status||"dirty"===t.value?DIRTY(r.value):r}}if("refinement"===r.type){const executeRefinement=e=>{const t=r.refinement(e,n);if(a.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===a.common.async){const e=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return"aborted"===e.status?Ie:("dirty"===e.status&&t.dirty(),executeRefinement(e.value),{status:t.value,value:e.value})}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then((e=>"aborted"===e.status?Ie:("dirty"===e.status&&t.dirty(),executeRefinement(e.value).then((()=>({status:t.value,value:e.value}))))))}if("transform"===r.type){if(!1===a.common.async){const e=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!isValid(e))return e;const i=r.transform(e.value,n);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:i}}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then((e=>isValid(e)?Promise.resolve(r.transform(e.value,n)).then((e=>({status:t.value,value:e}))):e))}ve.assertNever(r)}}ZodEffects.create=(e,t,a)=>new ZodEffects({schema:e,typeName:Fe.ZodEffects,effect:t,...processCreateParams(a)}),ZodEffects.createWithPreprocess=(e,t,a)=>new ZodEffects({schema:t,effect:{type:"preprocess",transform:e},typeName:Fe.ZodEffects,...processCreateParams(a)});class ZodOptional extends ZodType{_parse(e){return this._getType(e)===we.undefined?OK(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ZodOptional.create=(e,t)=>new ZodOptional({innerType:e,typeName:Fe.ZodOptional,...processCreateParams(t)});class ZodNullable extends ZodType{_parse(e){return this._getType(e)===we.null?OK(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ZodNullable.create=(e,t)=>new ZodNullable({innerType:e,typeName:Fe.ZodNullable,...processCreateParams(t)});class ZodDefault extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e);let a=t.data;return t.parsedType===we.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ZodDefault.create=(e,t)=>new ZodDefault({innerType:e,typeName:Fe.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...processCreateParams(t)});class ZodCatch extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e),a={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return isAsync(r)?r.then((e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new ZodError(a.common.issues)},input:a.data})}))):{status:"valid",value:"valid"===r.status?r.value:this._def.catchValue({get error(){return new ZodError(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}}ZodCatch.create=(e,t)=>new ZodCatch({innerType:e,typeName:Fe.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...processCreateParams(t)});class ZodNaN extends ZodType{_parse(e){if(this._getType(e)!==we.nan){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:xe.invalid_type,expected:we.nan,received:t.parsedType}),Ie}return{status:"valid",value:e.data}}}ZodNaN.create=e=>new ZodNaN({typeName:Fe.ZodNaN,...processCreateParams(e)});const De=Symbol("zod_brand");class ZodBranded extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e),a=t.data;return this._def.type._parse({data:a,path:t.path,parent:t})}unwrap(){return this._def.type}}class ZodPipeline extends ZodType{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.common.async){return(async()=>{const e=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return"aborted"===e.status?Ie:"dirty"===e.status?(t.dirty(),DIRTY(e.value)):this._def.out._parseAsync({data:e.value,path:a.path,parent:a})})()}{const e=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return"aborted"===e.status?Ie:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:a.path,parent:a})}}static create(e,t){return new ZodPipeline({in:e,out:t,typeName:Fe.ZodPipeline})}}class ZodReadonly extends ZodType{_parse(e){const t=this._def.innerType._parse(e),freeze=e=>(isValid(e)&&(e.value=Object.freeze(e.value)),e);return isAsync(t)?t.then((e=>freeze(e))):freeze(t)}unwrap(){return this._def.innerType}}function custom(e,t={},a){return e?ZodAny.create().superRefine(((r,n)=>{var i,s;if(!e(r)){const e="function"==typeof t?t(r):"string"==typeof t?{message:t}:t,o=null===(s=null!==(i=e.fatal)&&void 0!==i?i:a)||void 0===s||s,c="string"==typeof e?{message:e}:e;n.addIssue({code:"custom",...c,fatal:o})}})):ZodAny.create()}ZodReadonly.create=(e,t)=>new ZodReadonly({innerType:e,typeName:Fe.ZodReadonly,...processCreateParams(t)});const Le={object:ZodObject.lazycreate};var Fe;!function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"}(Fe||(Fe={}));const ze=ZodString.create,Ke=ZodNumber.create,We=ZodNaN.create,Je=ZodBigInt.create,He=ZodBoolean.create,qe=ZodDate.create,Ye=ZodSymbol.create,Ge=ZodUndefined.create,Xe=ZodNull.create,Qe=ZodAny.create,et=ZodUnknown.create,tt=ZodNever.create,at=ZodVoid.create,rt=ZodArray.create,nt=ZodObject.create,it=ZodObject.strictCreate,st=ZodUnion.create,ot=ZodDiscriminatedUnion.create,ct=ZodIntersection.create,lt=ZodTuple.create,ut=ZodRecord.create,dt=ZodMap.create,pt=ZodSet.create,mt=ZodFunction.create,yt=ZodLazy.create,ht=ZodLiteral.create,ft=ZodEnum.create,gt=ZodNativeEnum.create,vt=ZodPromise.create,bt=ZodEffects.create,wt=ZodOptional.create,xt=ZodNullable.create,St=ZodEffects.createWithPreprocess,It=ZodPipeline.create,Tt={string:e=>ZodString.create({...e,coerce:!0}),number:e=>ZodNumber.create({...e,coerce:!0}),boolean:e=>ZodBoolean.create({...e,coerce:!0}),bigint:e=>ZodBigInt.create({...e,coerce:!0}),date:e=>ZodDate.create({...e,coerce:!0})},Et=Ie;var Nt=Object.freeze({__proto__:null,defaultErrorMap:errorMap,setErrorMap:function setErrorMap(e){Se=e},getErrorMap:getErrorMap,makeIssue:makeIssue,EMPTY_PATH:[],addIssueToContext:addIssueToContext,ParseStatus:ParseStatus,INVALID:Ie,DIRTY:DIRTY,OK:OK,isAborted:isAborted,isDirty:isDirty,isValid:isValid,isAsync:isAsync,get util(){return ve},get objectUtil(){return be},ZodParsedType:we,getParsedType:getParsedType,ZodType:ZodType,datetimeRegex:datetimeRegex,ZodString:ZodString,ZodNumber:ZodNumber,ZodBigInt:ZodBigInt,ZodBoolean:ZodBoolean,ZodDate:ZodDate,ZodSymbol:ZodSymbol,ZodUndefined:ZodUndefined,ZodNull:ZodNull,ZodAny:ZodAny,ZodUnknown:ZodUnknown,ZodNever:ZodNever,ZodVoid:ZodVoid,ZodArray:ZodArray,ZodObject:ZodObject,ZodUnion:ZodUnion,ZodDiscriminatedUnion:ZodDiscriminatedUnion,ZodIntersection:ZodIntersection,ZodTuple:ZodTuple,ZodRecord:ZodRecord,ZodMap:ZodMap,ZodSet:ZodSet,ZodFunction:ZodFunction,ZodLazy:ZodLazy,ZodLiteral:ZodLiteral,ZodEnum:ZodEnum,ZodNativeEnum:ZodNativeEnum,ZodPromise:ZodPromise,ZodEffects:ZodEffects,ZodTransformer:ZodEffects,ZodOptional:ZodOptional,ZodNullable:ZodNullable,ZodDefault:ZodDefault,ZodCatch:ZodCatch,ZodNaN:ZodNaN,BRAND:De,ZodBranded:ZodBranded,ZodPipeline:ZodPipeline,ZodReadonly:ZodReadonly,custom:custom,Schema:ZodType,ZodSchema:ZodType,late:Le,get ZodFirstPartyTypeKind(){return Fe},coerce:Tt,any:Qe,array:rt,bigint:Je,boolean:He,date:qe,discriminatedUnion:ot,effect:bt,enum:ft,function:mt,instanceof:(e,t={message:`Input not instance of ${e.name}`})=>custom((t=>t instanceof e),t),intersection:ct,lazy:yt,literal:ht,map:dt,nan:We,nativeEnum:gt,never:tt,null:Xe,nullable:xt,number:Ke,object:nt,oboolean:()=>He().optional(),onumber:()=>Ke().optional(),optional:wt,ostring:()=>ze().optional(),pipeline:It,preprocess:St,promise:vt,record:ut,set:pt,strictObject:it,string:ze,symbol:Ye,transformer:bt,tuple:lt,undefined:Ge,union:st,unknown:et,void:at,NEVER:Et,ZodIssueCode:xe,quotelessJson:e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),ZodError:ZodError});function checkRef(e,t){if("$ref"in e){const a=Nt.lazy((()=>Nt.null()));return t.$refs.push([a,e.$ref]),a}return!1}const $t=dezerializeRefs,_t={number:e=>{let t=e.coerce?Nt.coerce.number():Nt.number();return void 0!==e.min&&(t=e.minInclusive?t.min(e.min):t.gt(e.min)),void 0!==e.max&&(t=e.maxInclusive?t.max(e.max):t.lt(e.max)),void 0!==e.multipleOf&&(t=t.multipleOf(e.multipleOf)),e.int&&(t=t.int()),e.finite&&(t=t.finite()),t},string:e=>{let t=e.coerce?Nt.coerce.string():Nt.string();return void 0!==e.min&&(t=t.min(e.min)),void 0!==e.max&&(t=t.max(e.max)),void 0!==e.length&&(t=t.length(e.length)),void 0!==e.startsWith&&(t=t.startsWith(e.startsWith)),void 0!==e.endsWith&&(t=t.endsWith(e.endsWith)),void 0!==e.toLowerCase&&(t=t.toLowerCase()),void 0!==e.toUpperCase&&(t=t.toUpperCase()),void 0!==e.trim&&(t=t.trim()),"includes"in e&&(t=t.includes(e.includes,{position:e.position})),"regex"in e&&(t=t.regex(new RegExp(e.regex,e.flags))),"kind"in e&&(t="ip"==e.kind?t.ip({version:e.version}):"datetime"==e.kind?t.datetime({offset:e.offset,precision:e.precision,local:e.local}):"time"==e.kind?t.time({precision:e.precision}):t[e.kind]()),t},boolean:e=>e.coerce?Nt.coerce.boolean():Nt.boolean(),nan:()=>Nt.nan(),bigInt:e=>{let t=e.coerce?Nt.coerce.bigint():Nt.bigint();if(void 0!==e.min){const a=BigInt(e.min);t=e.minInclusive?t.min(a):t.gt(a)}if(void 0!==e.max){const a=BigInt(e.max);t=e.maxInclusive?t.max(a):t.lt(a)}if(void 0!==e.multipleOf){const a=BigInt(e.multipleOf);t=t.multipleOf(a)}return t},date:e=>{let t=e.coerce?Nt.coerce.date():Nt.date();return void 0!==e.min&&(t=t.min(new Date(e.min))),void 0!==e.max&&(t=t.max(new Date(e.max))),t},undefined:()=>Nt.undefined(),null:()=>Nt.null(),any:()=>Nt.any(),unknown:()=>Nt.unknown(),never:()=>Nt.never(),void:()=>Nt.void(),literal:e=>Nt.literal(e.value),symbol:()=>Nt.symbol(),tuple:(e,t)=>{let a=Nt.tuple(e.items.map(((e,a)=>checkRef(e,t)||$t(e,{...t,path:t.path+"/items/"+a}))));if(e.rest){const r=checkRef(e.rest,t)||$t(e.rest,{...t,path:t.path+"/rest"});a=a.rest(r)}return t.pathToSchema.set(t.path,a),a},set:(e,t)=>{let a=Nt.set(checkRef(e.value,t)||$t(e.value,{...t,path:t.path+"/value"}));return void 0!==e.minSize&&(a=a.min(e.minSize)),void 0!==e.maxSize&&(a=a.max(e.maxSize)),t.pathToSchema.set(t.path,a),a},array:(e,t)=>{let a=Nt.array(checkRef(e.element,t)||$t(e.element,{...t,path:t.path+"/element"}));return void 0!==e.minLength&&(a=a.min(e.minLength)),void 0!==e.maxLength&&(a=a.max(e.maxLength)),t.pathToSchema.set(t.path,a),a},object:(e,t)=>{let a=Nt.object(Object.fromEntries(Object.entries(e.properties).map((([e,a])=>[e,checkRef(a,t)||$t(a,{...t,path:t.path+"/properties/"+e})]))));return e.catchall?a=a.catchall($t(e.catchall,t)):"strict"===e.unknownKeys?a=a.strict():"passthrough"===e.unknownKeys&&(a=a.passthrough()),t.pathToSchema.set(t.path,a),a},record:(e,t)=>{const a=Nt.record(checkRef(e.key,t)||$t(e.key,{...t,path:t.path+"/key"}),checkRef(e.value,t)||$t(e.value,{...t,path:t.path+"/value"}));return t.pathToSchema.set(t.path,a),a},map:(e,t)=>{const a=Nt.map(checkRef(e.key,t)||$t(e.key,{...t,path:t.path+"/key"}),checkRef(e.value,t)||$t(e.value,{...t,path:t.path+"/value"}));return t.pathToSchema.set(t.path,a),a},nativeEnum:e=>Nt.nativeEnum(e.values),enum:e=>Nt.enum(e.values),union:(e,t)=>{const a=Nt.union(e.options.map(((e,a)=>checkRef(e,t)||$t(e,{...t,path:t.path+"/options/"+a}))));return t.pathToSchema.set(t.path,a),a},discriminatedUnion:(e,t)=>{const a=Nt.discriminatedUnion(e.discriminator,e.options.map(((e,a)=>checkRef(e,t)||$t(e,{...t,path:t.path+"/options/"+a}))));return t.pathToSchema.set(t.path,a),a},intersection:(e,t)=>{const a=Nt.intersection(checkRef(e.left,t)||$t(e.left,{...t,path:t.path+"/left"}),checkRef(e.right,t)||$t(e.right,{...t,path:t.path+"/right"}));return t.pathToSchema.set(t.path,a),a},function:(e,t)=>{const a=Nt.function(checkRef(e.args,t)||$t(e.args,{...t,path:t.path+"/args"}),checkRef(e.returns,t)||$t(e.returns,{...t,path:t.path+"/returns"}));return t.pathToSchema.set(t.path,a),a},promise:(e,t)=>{const a=Nt.promise(checkRef(e.value,t)||$t(e.value,{...t,path:t.path+"/value"}));return t.pathToSchema.set(t.path,a),a},catch:(e,t)=>{let a=checkRef(e.innerType,t)||$t(e.innerType,{...t,path:t.path+"/innerType"});return a=a.catch(e.value),t.pathToSchema.set(t.path,a),a},effect:(e,t)=>{let a=checkRef(e.inner,t)||$t(e.inner,{...t,path:t.path+"/inner"});if(!("superRefinements"in t||"transforms"in t||"preprocesses"in t))return t.pathToSchema.set(t.path,a),a;for(const{name:r,type:n}of e.effects)"refinement"===n&&t.superRefinements?.[r]?a=a.superRefine(t.superRefinements[r]):"transform"===n&&t.transforms?.[r]?a=a.transform(t.transforms[r]):"preprocess"===n&&t.preprocesses?.[r]&&(a=Nt.preprocess(t.preprocesses[r],a));return t.pathToSchema.set(t.path,a),a}};function dezerializeRefs(e,t){if("isOptional"in e){const{isOptional:a,...r}=e,n=$t(r,t),i=a?n.optional():n;return t.pathToSchema.set(t.path,i),i}if("isNullable"in e){const{isNullable:a,...r}=e,n=$t(r,t),i=a?n.nullable():n;return t.pathToSchema.set(t.path,i),i}if("defaultValue"in e){const{defaultValue:a,...r}=e,n=$t(r,t).default("bigInt"===e.type?BigInt(a):"date"===e.type?new Date(a):a);return t.pathToSchema.set(t.path,n),n}if("readonly"in e){const{readonly:a,...r}=e,n=$t(r,t),i=a?n.readonly():n;return t.pathToSchema.set(t.path,i),i}if("description"in e&&"string"==typeof e.description){const{description:a,...r}=e,n=$t(r,t).describe(a);return t.pathToSchema.set(t.path,n),n}return _t[e.type](e,t)}function resolvePointer(e,t){return t.split("/").slice(1).reduce(((e,t)=>void 0===e?e:e[t.replace(/~1/g,"/").replace(/~0/g,"~")]),e)}function dezerialize(e,t={}){"path"in t||(t.path="#"),"pathToSchema"in t||(t.pathToSchema=new Map),"$refs"in t||(t.$refs=[]),"originalShape"in t||(t.originalShape=e);const a=t,r=dezerializeRefs(e,a);for(const[e,t]of a.$refs)e._def.getter=()=>{const e=a.pathToSchema.get(t);if(e)return e;const r=dezerialize(resolvePointer(a.originalShape,t),a);return a.pathToSchema.set(t,r),r};return r}function copyObject(e){const t=Array.isArray(e)?[]:{};for(const[a,r]of Object.entries(e))t[a]=r&&"object"==typeof r?copyObject(r):r;return t}const Ot=new Map([["boolean","boolean"],["number","number"],["nan","nan"],["bigInt","bigint"],["string","string"],["date","date"],["undefined","undef"],["void","void"],["null","null"],["array","arrayNonindexKeys"],["object","object"],["enum","enum"],["literal","literal"],["tuple","tuple"],["record","record"],["map","map"],["set","set"],["never","never"],["catch","catch"],["nativeEnum","nativeEnum"]]);function mergeSchema(e,t){if("object"!==e.type)throw console.log("leftItem",e),new Error("Unexpected leftItem of type "+e.type);if("object"!==t.type)throw console.log("rightItem",t),new Error("Unexpected rightItem of type "+t.type);const a=copyObject(e);for(const[e,r]of Object.entries(t))if("type"!==e&&"properties"!==e)if("description"===e)"Modifiers"!==r&&(a[e]=a[e]?a[e]+" and "+r:r);else{if(e in a)throw new Error("Duplicate property "+e+" of value "+JSON.stringify(r)+" and "+JSON.stringify(a[e]));a[e]=r&&"object"==typeof r?copyObject(r):r}for(const[e,r]of Object.entries(t.properties)){if("string"!=typeof a.properties&&e in a.properties)throw new Error("Duplicate property "+e+" of value "+JSON.stringify(r)+" and "+JSON.stringify(a.properties[e]));a.properties[e]=r&&"object"==typeof r?copyObject(r):r}return a}let kt=0;function addModifiers(e,t){if("defaultValue"in e){kt++;for(const a of t)a.$unionGroupID=kt,a.$defaultValue=e.defaultValue}if(e.isNullable&&t.push({type:"null"}),e.isOptional)for(const a of t)"isOptional"in a||(a.isOptional=e.isOptional);if(e.readonly)for(const a of t)"readonly"in a||(a.$readonlyParent=e.readonly);if(e.description)for(const a of t)a.description=a.description?a.description+" and "+e.description:e.description}function getTypesForSchema(e,t){switch(e.type){case"never":return new Set;case"object":{const t=new Set;return t.add(e),t}case"discriminatedUnion":case"union":{let a=[];for(const r of e.options)a=[...a,...getTypesForSchema(r,t)];if("discriminatedUnion"===e.type)for(const t of a)t.$discriminator=e.discriminator;return addModifiers(e,a),new Set(a)}case"intersection":{const a=function flattenIntersection(e,t){const a=[...e],r=[...t],n=[];for(const e of a)for(const t of r)n.push(mergeSchema(e,t));return n}(getTypesForSchema(e.left,t),getTypesForSchema(e.right,t));return addModifiers(e,a),new Set(a)}case"any":case"unknown":return new Set([{type:"boolean"},{type:"number"},{type:"nan"},{type:"bigInt"},{type:"string"},{description:"Email",type:"string",kind:"email"},{description:"URL",type:"string",kind:"url"},{description:"Date",type:"string",kind:"date"},{type:"date"},{type:"undefined"},{type:"null"},{type:"object",properties:{},unknownKeys:"passthrough"},{type:"nativeEnum",values:{type:"union",options:[{description:"Numeric",type:"record",key:{type:"number"},value:{type:"string"}},{description:"String",type:"record",key:{type:"string"},value:{type:"union",options:[{type:"string"},{type:"number"}]}}]}},{type:"array",element:{type:"any"}},{type:"set",value:{type:"any"}},{type:"map",key:{type:"any"},value:{type:"any"}},{type:"never"},{type:"effect",effects:[{name:"regexp",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"blob",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"BooleanObject",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"NumberObject",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"StringObject",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"SpecialRealNumber",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"domexception",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"error",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"filelist",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"file",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"resurrectable",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"blobHTML",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"buffersource",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"dommatrix",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"dompoint",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"domrect",type:"refinement"}],inner:{type:"any"}},{type:"effect",effects:[{name:"errors",type:"refinement"}],inner:{type:"any"}},{description:"JSON Reference",type:"object",properties:{$ref:{type:"string"}}}]);default:if("$ref"in e){return getTypesForSchema(resolveJSONPointer({obj:t,path:e.$ref}),t)}return new Set([e])}}const At={iterate:(e,t)=>(t.format="schema",he.iterate(e,t)),convertFromTypeson(e,t,a,r,n,i){let[s,o]=n??[];if(!i)throw new Error("State object expected for schema");let c=i.schemaContent,l=!1;switch("number"==typeof o&&"union"===s?.type&&(s=s.options[o]),s?.type){case"object":c=s.properties[r],c||(c=s.catchall,l=!0);break;case"array":c=s.element;break;case"set":c=s.value;break;case"effect":c=s.inner;break;case"tuple":c=s.items[Number(r)]??s.rest}if(!c)return{type:e};const u=[...getTypesForSchema(c,i.schemaContent)];for(const[e,r]of u.entries()){let n;"object"===r.type&&(({unknownKeys:n}=r),r.unknownKeys="strict");const s=dezerialize(r,{originalShape:i.schemaContent}).safeParse(a);if("object"===r.type&&(r.unknownKeys=n),s.success){let n=Ot.get(r.type);n||"effect"!==r.type||(n=r.effects[0].name);const s=t.getTypeObject(n);if(s.valueMatch&&s.valueMatch(a))return{type:n,schemaIdx:e,schema:!i.rootUI||i.readonly||1===u.length?r:{type:"union",options:u},mustBeOptional:l}}}return{type:e}},types:()=>he.types(),getTypesAndSchemasForState(e,t,a,r){if(!a)throw new Error("Missing schema object");if("array"===t)return he.getTypesAndSchemasForState(e,t,a,r);const n=[...getTypesForSchema(a,r??a)],i=n.map((({type:e})=>e));return{schemaObjects:n,types:i.map(((e,t)=>"effect"===e?n[t].effects[0].name:Ot.get(e)))}}};class Formats{constructor(){this.availableFormats={indexedDBKey:fe,json:ye,schema:At,structuredCloning:he}}async getControlsForFormatAndValue(e,t,a,r){return await this.availableFormats[t].iterate(a,{...r,types:e,formats:this,format:t})}getTypesAndSchemasForFormatAndState(e,t,a,r,n){return this.availableFormats[t].getTypesAndSchemasForState(e,a,r,n)}getAvailableFormat(e){return this.availableFormats[e]}}const Ct={option:["Null"],stringRegex:/^null$/u,valueMatch:e=>null===e,toValue:()=>({value:null}),getValue:()=>null,getInput:({root:e})=>$e(e,"input"),viewUI:({specificSchemaObject:e})=>["i",{dataset:{type:"null"},title:e?.description??"(a `null`)"},["null"]],editUI:({typeNamespace:e,specificSchemaObject:t})=>["div",{dataset:{type:"null"},title:t?.description??"Null"},[["label",["Null",["input",{type:"checkbox",name:`${e}-null`,checked:!0,disabled:!0}]]]]]},jt={option:["Boolean (true)",{value:"true"}],stringRegex:/^true$/u,toValue:()=>({value:!0}),valueMatch:e=>!0===e,superType:"boolean",getValue:()=>!0,viewUI:()=>["i",{dataset:{type:"true"}},["true"]],ct:0,getInput:({root:e})=>$e(e,"input"),editUI({typeNamespace:e}){return this.ct++,["div",{dataset:{type:"true"}},[["label",["True",["input",{type:"radio",name:`${e}-true${this.ct}`,value:"true",checked:!0}]]],["label",["False",["input",{type:"radio",name:`${e}-true${this.ct}`,value:"false",disabled:!0}]]]]]}},Rt={option:["Boolean (false)",{value:"false"}],stringRegex:/^false$/u,toValue:()=>({value:!1}),valueMatch:e=>!1===e,superType:"boolean",getValue:()=>!1,viewUI:()=>["i",{dataset:{type:"false"}},["false"]],ct:0,getInput:({root:e})=>$e(e,"input[value=false]"),editUI({typeNamespace:e}){return this.ct++,["div",{dataset:{type:"false"}},[["label",["True",["input",{type:"radio",name:`${e}-false${this.ct}`,value:"true",disabled:!0}]]],["label",["False",["input",{type:"radio",name:`${e}-false${this.ct}`,value:"false",checked:!0}]]]]]}},Zt={option:["NaN"],stringRegex:/^NaN$/u,valueMatch:e=>Number.isNaN(e),toValue:()=>({value:Number.NaN}),getValue:()=>Number.NaN,getInput:({root:e})=>$e(e,"input"),viewUI:({specificSchemaObject:e})=>["i",{dataset:{type:"nan"},title:e?.description??"(a `NaN`)"},["NaN"]],editUI:({typeNamespace:e,specificSchemaObject:t})=>["div",{dataset:{type:"nan"},title:t?.description??"NaN"},[["label",["NaN",["input",{type:"checkbox",name:`${e}-nan`,checked:!0}]]]]]},Vt={option:["Blob (text/html)"],stringRegex:/^data:text\/html(?:;base64)?,.*$/u,valueMatch:e=>e&&"text/html"===e.type,superType:"blob",toValue:e=>({value:function dataURIToBlob(e){const t=e.indexOf(","),a=e.slice(0,t),r=e.slice(t+1),[n,i]=a.split(":")[1].split(";");let s;if("base64"===i){const e=atob(r);s=new ArrayBuffer(e.length);const t=new Uint8Array(s);for(let a=0;a<e.length;a++)t[a]=e.charCodeAt(a)}else s=r;return new Blob([s],{type:n})}(e)}),getInput:({root:e})=>$e(e,"textarea[name$=-blobHTML]"),getValue({root:e}){return this.toValue("data:text/html,"+this.getInput({root:e}).sceditorInstance.val()).value},loadBlob:async e=>await e.text(),async setValue({root:e,value:t}){const a=await this.loadBlob(t);this.getInput({root:e}).sceditorInstance.val(a)},viewUI({value:e,specificSchemaObject:t}){let a;const r=c("div",{dataset:{type:"blobHTML"},title:t?.description?"HTML":void 0},[t?.description??"HTML",": ",["button",{$on:{click(){pe.alert({message:["div",["Source: ",["textarea",{class:"view-source"},[a]]]]})}}},["View source"]]]);return this.loadBlob(e).then((e=>{a=e,c("iframe",{sandbox:"",srcdoc:a},r)})).catch((e=>{console.error("Err",e)})),[r]},editUI({typeNamespace:e,specificSchemaObject:t,value:a}){const r=c("textarea",{name:`${e}-blobHTML`});r.sceditorInstance={val(){throw new Error("Not yet instantiated")}};const n=c("div",{dataset:{type:"blobHTML"},title:t?.description??"Blob (HTML)"},[r]);return setTimeout((()=>{sceditor.create(r,{width:"1000px",height:"225px",autoUpdate:!0,resizeMaxHeight:-1,resizeMaxWidth:-1,plugins:"xhtml,plaintext,undo",emoticonsRoot:"node_modules/sceditor/",style:"node_modules/sceditor/minified/themes/content/default.min.css"}),r.sceditorInstance=sceditor.instance(r),null!=a&&this.setValue({root:n,value:a})})),[n]}},Mt={option:["Boolean",{value:"boolean"}],stringRegex:/^(?:true|false)$/u,valueMatch:e=>"boolean"==typeof e,toValue:e=>({value:"true"===e}),getValue({root:e}){return this.getInput({root:e}).checked},getInput:({root:e})=>$e(e,"input[value=true]"),setValue({root:e,value:t}){$e(e,t?"input[value=true]":"input[value=false]").checked=!0},viewUI:({value:e,specificSchemaObject:t})=>["i",{dataset:{type:"boolean"},title:t?.description??"(a boolean)"},[e?"true":"false"]],ct:0,editUI({typeNamespace:e,specificSchemaObject:t,value:a}){this.ct++;const r="literal"===t?.type,n=r?t?.value:a??t?.defaultValue;return["div",{dataset:{type:"boolean"},title:t?.description??"Boolean"},[["label",["True",["input",{disabled:r,type:"radio",name:`${e}-boolean${this.ct}`,value:"true",checked:"boolean"!=typeof n||n}]]],["label",["False",["input",{disabled:r,type:"radio",name:`${e}-boolean${this.ct}`,value:"false",checked:"boolean"==typeof n&&!n}]]]]]}},Pt={option:["Number"],stringRegex:new RegExp("^[-+]?"+String.raw`(?:[0-9]{0,30}\.)?`+"[0-9]{1,30}(?:[Ee][-+]?[1-2]?[0-9])?$","u"),valueMatch:e=>"number"==typeof e&&!Number.isNaN(e)&&e!==Number.POSITIVE_INFINITY&&e!==Number.NEGATIVE_INFINITY&&!Object.is(e,-0),toValue:e=>({value:Number(e)}),getInput:({root:e})=>$e(e,"input"),setValue({root:e,value:t}){this.getInput({root:e}).value=String(t)},validate({root:e}){const t=this.getInput({root:e}).value;return{message:"Not a valid (finite) number",valid:Boolean(t&&/^-?(\d+|\d*\.\d+)$/u.test(t))}},getValue({root:e}){return Number.parseFloat(this.getInput({root:e}).value)},viewUI:({value:e,specificSchemaObject:t})=>["i",{dataset:{type:"number"},title:t?.description??"(a number)"},[String(e)]],editUI({typeNamespace:e,specificSchemaObject:t,value:a}){const r="literal"===t?.type,n=t,i=150*Number.EPSILON,s=300*Number.EPSILON;return["div",{dataset:{type:"number"},title:t?.description??"Number"},[["input",{disabled:r,name:`${e}-number`,type:"number",min:n?.min?n?.minInclusive?n?.min:n?.min+(n?.int?1:i):void 0,max:n?.max?n?.maxInclusive?n?.max:n?.max-(n?.int?1:s):void 0,step:n?.multipleOf??(n?.int?"1":"any"),value:r?t?.value:a??t?.defaultValue??""}]]]}},Ut={option:["BigInt"],stringRegex:new RegExp("^-?[0-9]{1,}n$","u"),valueMatch:e=>"bigint"==typeof e,toValue:e=>({value:BigInt(e.slice(0,-1))}),getInput:({root:e})=>$e(e,"input"),setValue({root:e,value:t}){this.getInput({root:e}).value=String(t)},validate({root:e}){const t=this.getInput({root:e}).value;return{message:"Not a valid BigInt",valid:Boolean(t&&/^-?(\d+)$/u.test(t))}},getValue({root:e}){return BigInt(this.getInput({root:e}).value)},viewUI:({value:e,specificSchemaObject:t})=>["i",{dataset:{type:"bigint"},title:t?.description??"(a BigInt)"},[`${String(e)}n`]],editUI({typeNamespace:e,specificSchemaObject:t,value:a}){const r=t;return["div",{dataset:{type:"bigint"},title:t?.description??"BigInt"},[["input",{name:`${e}-bigint`,type:"number",value:a??t?.defaultValue??"",min:r?.min?r?.minInclusive?r?.min:String(BigInt(r?.min)+1n):void 0,max:r?.max?r?.maxInclusive?r?.max:String(BigInt(r?.max)-1n):void 0,step:r?.multipleOf??"1"}]]]}},Bt={option:["BigInt Object"],stringRegex:new RegExp("^BigIntObject-?[0-9]{1,}n$","u"),valueMatch:e=>"object"==typeof e&&hasConstructorOf(e,BigInt),toValue:e=>({value:new Object(BigInt(e.slice(12,-1)))}),getInput:({root:e})=>$e(e,"input"),setValue({root:e,value:t}){this.getInput({root:e}).value=String(t)},validate({root:e}){const t=this.getInput({root:e}).value;return{message:"Not a valid BigInt",valid:Boolean(t&&/^-?(\d+)$/u.test(t))}},getValue({root:e}){return new Object(BigInt(this.getInput({root:e}).value))},viewUI:({value:e,specificSchemaObject:t})=>["i",{dataset:{type:"bigintObject"},title:t?.description??"(a BigInt Object)"},[`${String(e)}n`]],editUI:({typeNamespace:e,specificSchemaObject:t,value:a=""})=>["div",{dataset:{type:"bigintObject"},title:t?.description??"BigInt object"},[["input",{name:`${e}-bigintObject`,type:"number",step:"1",value:a}]]]},Dt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/u,Lt=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/u,Ft=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/u,zt=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u"),Kt=/^c[^\s-]{8,}$/iu,Wt=/^[0-9a-z]+$/u,Jt=/^[0-9A-HJKMNP-TV-Z]{26}$/iu,Ht=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/iu,qt=/^[a-z0-9_-]{21}$/iu,Yt=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/u;const Gt={option:["String"],stringRegex:/^"(?:[^\\"]|\\\\|\\")*"$/u,valueMatch:e=>"string"==typeof e,toValue:e=>({value:e.slice(1,-1)}),getInput:({root:e})=>$e(e,'[data-type="string"] > textarea,input'),setValue({root:e,value:t}){this.getInput({root:e}).value=t},getValue({root:e}){return this.getInput({root:e}).value},viewUI({value:e,specificSchemaObject:t}){const a=t?.kind;return["span",{dataset:{type:"string"},title:t?.description??("email"===a?`(an ${a} string)`:a?`(a ${a} string)`:"(a string)")},[e]]},editUI({typeNamespace:e,specificSchemaObject:t,value:a}){const r=t,n=r?.kind,i="literal"===t?.type,s=r?.min??r?.length,o=r?.max??r?.length,c=r?.startsWith,l=r?.endsWith,u=r?.toLowerCase,d=r?.toUpperCase,p=r?.trim,m=r?.includes,y=r?.position,h=r?.regex,f=r?.flags,checkValue=e=>{if(c&&!e.startsWith(c))return`Value doesn't start with expected: ${c}`;if(l&&!e.endsWith(l))return`Value doesn't end with expected: ${l}`;if(m&&!e.includes(m,y??0))return`Value doesn't include the expected: ${m}${y?` after position: ${y}`:""}`;if(h&&!new RegExp(h,f??"").test(e))return`Value doesn't match regular expression: ${h}${f?` with flags: ${f}`:""}`;if(n)switch(n){case"ip":if("v4"===r?.version){if(!Dt.test(e))return"Value doesn't match IP v4 pattern."}else if(!Lt.test(e))return"Value doesn't match IP v6 pattern.";break;case"time":if(!function timeRegex(e){return new RegExp(`^${function timeRegexSource(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:null!==e.precision&&void 0!==e.precision||(t=`${t}(\\.\\d+)?`),t}(e)}$`,"u")}(r).test(e))return"Value does not match time/precision.";break;case"datetime":if(!datetimeRegex(r).test(e))return"Value does not match datetime/precision/offset/local";break;case"emoji":if(!zt.test(e))return"Value does not match emoji pattern";break;case"uuid":if(!Ht.test(e))return"Value does not match uuid pattern";break;case"nanoid":if(!qt.test(e))return"Value does not match nanoid pattern";break;case"cuid":if(!Kt.test(e))return"Value does not match cuid pattern";break;case"cuid2":if(!Wt.test(e))return"Value does not match cuid2 pattern";break;case"ulid":if(!Jt.test(e))return"Value does not match ulid pattern";break;case"duration":if(!Yt.test(e))return"Value does not match duration pattern";break;case"base64":if(!Ft.test(e))return"Value does not match base64 pattern"}return null},transform=e=>(u&&(e=e.toLowerCase()),d&&(e=e.toUpperCase()),p&&(e=e.trim()),e);return["div",{dataset:{type:"string"},title:t?.description??"String"},[["email","url","date"].includes(n)?["input",{$on:{change(){const e=this;e.value=transform(e.value);const t=checkValue(e.value);e.setCustomValidity(t??""),e.reportValidity()}},name:`${e}-string`,type:n,value:a??t?.defaultValue??"",minlength:"date"===n?void 0:s,maxlength:"date"===n?void 0:o}]:["textarea",{$on:{change(){const e=this;e.value=transform(e.value);const t=checkValue(e.value);e.setCustomValidity(t??""),e.reportValidity()}},name:`${e}-string`,disabled:i,minlength:s,maxlength:o},[i?t?.value:a??t?.defaultValue??""]]]]}},Xt={option:["Array reference"],type:"array",stringRegex:/^arrayRef\((?:|\/[^)]*)\)$/u,toValue(e,t){const{rootHolder:a,parent:r,parentPath:n}=t,i=e.slice(`${this.type}Ref(`.length,-1);return a.push([this.type,r,n,i]),{assign:!1}},resolveReference(e,t){let a=t;return""!==e&&getJSONPointerParts(e).forEach((e=>{if(a=a[e],!a)throw new Error("Bad path")})),a},stateDependent:{structuredCloning:{after:"arrayNonindexKeys",contexts:["arrayNonindexKeys","object","set"]}},getInput:({root:e})=>$e(e,"input"),setValue({root:e,value:t}){this.getInput({root:e}).value=t},getValue({root:e,stateObj:t,currentPath:a}){const r=this.getInput({root:e}).value;t&&(t.paths||(t.paths={}),t.paths[a]={referentPath:r,expectArrayReferent:"array"===this.type},t.handlingReference=!0),console.log(r)},validate({root:e,topRoot:t}){const{type:a}=this,r=this.getInput({root:e}),n=r.value,invalidMessage=e=>({valid:!1,message:e});if(r.validity.patternMismatch)return invalidMessage('You must use a path beginning with "/" (or the empty string)');if(/~([^01]|$)/u.test(n))return invalidMessage("You must use a valid JSON Pointer (with tildes followed by 0 or 1)");let i=t||e;let s;if(""!==n&&getJSONPointerParts(n).some(((t,a)=>{const r=DOM_filterChildElements($e(i,".arrayItems"),["fieldset","legend"]),n=r.map((e=>getPropertyValueFromLegend(e))).indexOf(t);return-1===n?(s="Specified path doesn't exist",!0):(i=$e(r[n].parentElement,"div[data-type]"),i===e?(s="Can't reference self",!0):!["array","object","arrayNonindexKeys"].includes(Types.getTypeForRoot(i))&&(s=`Referent portion (at segment ${a}) is not an object or array`,!0))})))return invalidMessage(s);const o=Types.getTypeForRoot(i);return(["array","arrayNonindexKeys"].includes(o)?"array":"object"===o?"object":null)!==a?invalidMessage("Reference must match expected reference type (array or object)"):{valid:!0}},validateAll({types:e,topRoot:t}){const a=`${this.type}Reference`;$$e(t,`div[data-type="${a}"]`).forEach((r=>{e.validate({type:a,root:r,topRoot:t})}))},viewUI({value:e}){return["i",{dataset:{type:`${this.type}Reference`}},[`${this.type}Ref(${e})`]]},editUI({typeNamespace:e,value:t=""}){const{type:a}=this;return["div",{dataset:{type:`${a}Reference`}},[["label",[`JSON Pointer path to ${a} (leave blank for path to root) `,["input",{name:`${e}-${a}Reference`,type:"text",pattern:"^(|/.*)$",value:t}]]]]]}},Qt={option:["Object reference"],type:"object",stringRegex:/^objectRef\((?:|\/[^)]*)\)$/u,toValue(...e){return Xt.toValue.apply(this,e)},resolveReference(...e){return Xt.resolveReference?.apply(this,e)},stateDependent:{structuredCloning:{after:"object",contexts:["arrayNonindexKeys","object","set"]}},getInput(...e){return Xt.getInput.apply(this,e)},setValue(...e){return Xt.setValue?.apply(this,e)},getValue(...e){return Xt.getValue.apply(this,e)},validate(...e){return Xt.validate?.apply(this,e)},validateAll(...e){return Xt.validateAll?.apply(this,e)},viewUI(...e){return Xt.viewUI.apply(this,e)},editUI(...e){return Xt.editUI.apply(this,e)}};class FileList{constructor(){this._files=arguments[0],this.length=this._files.length}item(e){return this._files[e]}get[Symbol.toStringTag](){return"FileList"}}let ea=0;const ta={option:["Array"],array:!0,regexEndings:[",","]"],stringRegexBegin:/^\[/u,stringRegexEnd:/^\]/u,valueMatch:e=>Array.isArray(e),toValue(e,t){const{endMatchTypeObjs:a=[],remnant:r,rootHolder:n,schemaObject:i}=t,s=t.format,o=t.types,{sparse:c}=this,l=c?"arrayNonindexKeys":this.array&&!this.record?"array":"object",u=this.array&&!this.record?[]:{};let d=void 0!==r?r:e;const checkEnd=e=>{if(e&&a.length){const e=d.match(a.at(-1).stringRegexEnd);if(e)return a.pop(),d=d.slice(e[0].length),!0}return!1};if(this.array&&!this.record){let e=0;const parse=()=>{if(!d)return;const t=d.match(c?/^[,\s]+/u:/^\s*,?\s*/u);if(t){const a=t[0].match(/\s/gu);if(e+=t[0].length-(a?a.length:0),d=d.slice(t[0].length),!d)return}let r,p,m;try{[r,d,p,m]=o.getValueForString(d,{firstRun:!1,format:s,state:l,schemaObject:i,endMatchTypeObjs:a,rootHolder:n,parent:u,parentPath:e})}catch(e){return void console.log("e",e)}m&&(u[e]=r),checkEnd(p)||parse()};return parse(),c&&e&&e>u.length-1&&(u.length=e+1),{value:this.set&&Array.isArray(u)?new Set(u):this.map?new Map(u):this.filelist?new FileList(u):u,remnant:d}}const parse=e=>{if(!d)return;e&&","===d[0]&&(d=d.slice(1));const t=d.match(/^\s*(?:([^:"}]+)|"((?:[^\\"]|\\\\|\\")*)")(\s*:\s*)/u);if(!t)return;const[,r,c]=t,p=void 0!==r?r:c;let m,y,h;d=d.slice(t[0].length);try{[m,d,y,h]=o.getValueForString(d,{firstRun:!1,format:s,state:l,schemaObject:i,endMatchTypeObjs:a,rootHolder:n,parent:u,parentPath:p})}catch{return}h&&(u[p]=m),checkEnd(y)||parse(!0)};return parse(),{value:u,remnant:d}},getValue({root:e,stateObj:t,currentPath:a=""}){if(!t)throw new Error("TS guard");const r=t.types,n=""===a,i=$e(e,".arrayItems"),s=[...i.children],o="object"===e.dataset.type?{}:this.sparse?Array.from({length:Number.parseInt(DOM_filterChildElements(e,["div","div","label","input"])[0].value)}):[];return s.forEach((e=>{const n=e.firstElementChild,i=getPropertyValueFromLegend(n),s=DOM_filterChildElements(e,[".typeContainer","div[data-type]"])[0]||DOM_filterChildElements(e,["[class^=optionalProperties-placeholder]",".typeContainer","div[data-type]"])[0];if(!s)return;const c=DOM_filterChildElements(n,["input"]),[l,u]=((e,n)=>{const i=r.getValueForRoot(e,t,a+"/"+n);return"handlingReference"in t&&t.handlingReference?(t.handlingReference=!1,[!1]):[!0,i]})(s,i);l&&(c.length?o[i]=u:o.push(u))})),n&&Object.entries(t.paths||[]).forEach((([e,{referentPath:t}])=>{const a=""===t?o:resolveJSONPointer({path:t,obj:o}),r=getJSONPointerParts(e),n=r.pop();r.reduce(((e,t)=>reduceJSONPointerParts(e,t)),o)[n]=a})),this.filelist?new FileList(o):this.set&&Array.isArray(o)?new Set(o):this.map?new Map(i.$getMapKeySelects().map(((e,t)=>[e.$getValue(),o[t]]))):this.record?i.$getMapKeySelects().reduce(((e,t,a)=>{const r=t.$getValue(),n=o[a];return e[r]=n,e}),{}):o},viewUI({typeNamespace:e,type:t,types:a,value:r,topRoot:n,resultType:i,format:s,specificSchemaObject:o}){let l=-1;const u=t,buildLegend=({itemIndex:e,typeNamespace:a,propName:r})=>{const n=o?.items?.[e],i=o?.rest;return["legend",[this.array&&"record"!==t?o?.element?.description??("set"===t&&o?.value?.description?o?.value?.description:n?.description??i?.description)??"Item":o?"":"Property",o?"":":",d.repeat(2),["span",{class:`propertyName-${a}`,title:"record"===t&&o?.key?.description?o?.key?.description:o?r:void 0},[void 0!==r?o?.properties?.[r]?.description??r:e]]]]},p=c("div",{class:"arrayHolder",dataset:{type:t},$custom:{$addAndSetArrayElement({propName:t,type:r,value:l,bringIntoFocus:d,schemaContent:p}){if("map"===u){const u=a.getUIForModeAndType({resultType:i,readonly:!0,typeNamespace:e,type:r,topRoot:n,bringIntoFocus:d,format:s,schemaContent:p,value:l,hasValue:!0});if("0"===t){const e=this.$addMapElement();this._lastFieldset=e;const t=c("fieldset",[["legend",{title:o?.key?.description?"(map key)":void 0},[o?.key?.description??"Key"]]],e);c(u,t)}else{const e=c("fieldset",[["legend",{title:o?.value?.description?"(map value)":void 0},[o?.value?.description??"Value"]]],this._lastFieldset);this._lastFieldset=null,c(u,e)}return u}const m=this.$addArrayElement({propName:t}),y=a.getUIForModeAndType({resultType:i,readonly:!0,typeNamespace:e,type:r,topRoot:n,bringIntoFocus:d,format:s,schemaContent:p,specificSchemaObject:p,value:l,hasValue:!0});return c(y,m),y},$addMapElement(){l++;const t=this.$getArrayItems();return c("fieldset",[buildLegend({itemIndex:l,typeNamespace:e,propName:void 0})],t)},$addArrayElement({propName:t}){l++;const a=this.$getArrayItems();return c("fieldset",[buildLegend({itemIndex:l,typeNamespace:e,propName:t})],a)},$getArrayItems(){return this.lastElementChild.lastElementChild}}},[["span",{title:o?.description},[o?"—":DOM_initialCaps(t).replace(/s$/u,"")]],d.repeat(2),["button",{$on:{click(e){e.preventDefault();const{target:t}=e,a=$e(t.closest(".arrayHolder"),".arrayContents");a.hidden=!a.hidden,t.textContent=a.hidden?"+":"-"}}},["-"]],["div",{class:"arrayContents"},[this.array&&"record"!==t?["div",{title:o?"filelist"===t?"(a FileList)":"set"===t?"(a Set)":"map"===t?"(a Map)":"tuple"===t?"(a tuple)":"(an Array)":void 0},["filelist"===t?(o?.description??"FileList")+" length: ":"set"===t?(o?.description??"Set")+" size: ":"map"===t?(o?.description??"Map")+" size: ":(o?.description??"Array")+" length: ",["span",[(!r||"set"!==t&&"map"!==t?r.length:r.size)||0]]]]:"record"===t?o?.description??"Record":"",["div",{class:"arrayItems"}]]]]);return[p]},getInput:({root:e})=>$e(e,"button"),editUI({typeNamespace:e,buildTypeChoices:t,format:a,formats:r,types:n,specificSchemaObject:i,schemaFallingBack:s,schemaContent:o,type:l,forcedState:u,topRoot:p,value:m,bringIntoFocus:y=!0}){const{sparse:h}=this,f=this,g="object"===l?1:0;let v=g-1;const b="array"!==l&&"set"!==l&&"map"!==l&&"filelist"!==l&&"tuple"!==l&&"record"!==l,w="map"===l||"record"===l,x=i?.element?.description??("set"===l?i?.value?.description:void 0),bringFocus=(e,t)=>{(y||t)&&(e.scrollIntoView(),e.focus())},$validateLegend=function(){const e=this.$arrayItems.$getPropertyInputs(),t=e.some((e=>this!==e&&e.value===this.value))?"Duplicate property name":"";t&&(this.setCustomValidity(t),this.reportValidity()),e.some(((e,t,a)=>{const r=a.some((t=>e!==t&&e.value===t.value))?"Duplicate property name":"";return(e.validity.valid||"Invalid length"!==e.validationMessage)&&(e.setCustomValidity(r),r&&e.reportValidity()),r}))},buildLegend=({className:e,splice:r,itemIndex:s,typeNamespace:u,arrayItems:m,propName:y,required:g,schema:v})=>{const $validateLength=async function(e){if(!h)return;const t=m.$inputsExceedingLength(),a=t.length;if(e||!a||!/^\d+$/u.test(this.value))return;await pe.confirm({message:'You are attempting to add an (integer-based) array item beyond the length. Click "Ok" to allow to permit and extend the array length or "Cancel" otherwise.'});const r=$e(m.previousElementSibling,"input"),n=t.map((e=>Number.parseInt(e.value))).sort().at(-1);r.value=String(n+1),r.$oldvalue=String(n+1),this.$validateLength(!0)};if(w){const r=t({value:void 0!==y&&"record"===l?y:void 0,setValue:void 0!==y&&"record"===l,autoTrigger:void 0===y||"record"===l,format:a,schemaOriginal:o,schemaContent:i?.key,typeNamespace:"key-type-choices-only"});return["legend",[["span",{class:"mapKey",title:"map"===l&&i?.key?.description?"(map key)":"record"===l&&i?.key?.description?"(record key)":void 0},["map"===l?i?.key?.description??"Map key":i?.key?.description??"Record key"," "]],["span",{dataset:{prop:"true"},className:e},[String(s)]],":",d.repeat(2),["span",{class:"mapKeyHolder",$on:{change:[function(){this.$validateMapKey(),n.validateAllReferences({topRoot:p})},!0]},$custom:{$validateMapKey(){const e=m.$getMapKeySelects();setTimeout((()=>{const t=e.map((e=>e.$getValue())),a=t.findLastIndex(((e,a)=>t.some(((t,r)=>a!==r&&function sameValueZero(e,t){return"number"==typeof e&&"number"==typeof t?e===t||e!=e&&t!=t:e===t}(e,t)))));if(-1===a)return;const r=e[a];if(!r)return;const n=r.hidden?$e(r.nextElementSibling,"input,textarea"):r;n.setCustomValidity(`Duplicate ${"map"===l?"Map":"Record"} key value`),n.reportValidity()}))}}},r.domArray]]]}if(b){const t=i?.properties?.[y]?.description,a=Object.entries(i?.properties??{}).map((([e,t])=>t.isOptional?e:null)).filter(Boolean);ea++;const o=h?"append"===r?"":void 0!==y?y:s:y||"";return["legend",[h?x??"Item":{"#":g?[["b",{className:e,title:x??t?y:void 0},[x??t??y]]]:[["span",{className:`${e}_propertyHolder${ea}`},[...i&&y?[["b",[i?.properties?.[y]?i?.properties?.[y]?.description??y:i?.catchall?.description??y]]]:["Property ",["span",{className:e},[String(s)]],":"]]]]},d.repeat(2),i&&!g?["datalist",{id:`optionalProperties_${ea}`},a.map((e=>["option",{value:e}]))]:"",["input",{list:i&&!g?`optionalProperties_${ea}`:void 0,style:{display:g&&"arrayNonindexKeys"!==l?"none":"block"},disabled:g&&"arrayNonindexKeys"===l,value:o,dataset:{prop:!0,object:!0,optionalPropertyId:ea},$custom:{async $validate(){try{try{await this.$validateLength()}catch{}this.$validateLegend(),n.validateAllReferences({topRoot:p})}catch{}},$parseInt(){return!!/^\d+$/u.test(this.value)&&Number.parseInt(this.value)},$validateLegend:$validateLegend,$arrayItems:m,$validateLength:$validateLength,$resort({alwaysFocus:e}){const t=this.$arrayItems.$getPropertyInputs();if(1===t.length)return;const getFieldset=e=>e.closest("fieldset"),a=getFieldset(this),r=this.$parseInt();if(!1===r)return void t.reverse().some((t=>{if(t===this)return!0;return"number"==typeof t.$parseInt()&&(getFieldset(t).after(a),bringFocus(this,e),m.$redrawMoveArrows(),!0)}));const getNearest=n=>{let i;if(t.some((e=>{if(e===this)return!1;const t=e.$parseInt();if("number"!=typeof t)return i||(i=e),!1;const cmp=(e,t)=>n?e>t:e<t;return!(!cmp(r,t)||i&&!cmp(t,Number.parseInt(i.value)))&&(i=e,r+(n?-1:1)===t)})),!i)return!1;const s=n?"after":"before";return setTimeout((()=>{i&&(getFieldset(i)[s](a),bringFocus(this,e),m.$redrawMoveArrows())})),!0};getNearest()||getNearest(!0)}},$on:{input(){if(!i&&!v)return;const t=$e(m,`.${e}_propertyHolder${this.dataset.optionalPropertyId}`);DOM_removeChildren(t),c("b",[i?.properties?.[this.value]?i?.properties?.[this.value]?.description??this.value:i?.catchall?.description??this.value],t)},change(e){let t=!1;if("never"===i?.properties?.[this.value]?.type)this.setCustomValidity("Never value"),this.reportValidity(),this.style.backgroundColor="pink",t=!0;else if(this.list&&!f.array){if([...this.list.options].map((({value:e})=>e)).includes(this.value)||"strict"!==i.unknownKeys){this.style.backgroundColor="revert-layer",this.setCustomValidity(""),this.reportValidity();const{optionalPropertyId:e}=this.dataset;let t=$e(m,`.optionalProperties-placeholder${e}`);t||(t=$e(this.parentElement?.parentElement,".property-placeholder")?.previousElementSibling,t.previousElementSibling?.remove()),t.replaceWith(c("div",{className:`optionalProperties-placeholder${e}`},[...buildTypeChoicesForProperty({propName:this.value,schema:i?.properties?.[this.value]??i?.catchall??{type:"any"}})]))}else this.setCustomValidity("Bad value"),this.reportValidity(),this.style.backgroundColor="pink",t=!0}if(t){const e=$e(m,`.optionalProperties-placeholder${ea}`);DOM_removeChildren(e)}else this.$validate();e.stopPropagation(),this.$resort({alwaysFocus:!0})}},class:`propertyName-${u}`}]]]}const S=i?.inner?.description;return["legend",[x?"":S?`${S} `:v?.description?`${v?.description} `:"tuple"===l&&i?.rest?.description?`${i?.rest?.description} `:"Item ",["span",{dataset:{prop:!0,array:!0},className:e},[x?`${x} ${s+1}`:void 0!==y?y:String(s)]]]]},decrementItemIndex=e=>{h?v=e.$getPropertyInputs().reduce(((e,t)=>{const a=t.$parseInt();return!1!==a&&a>e?a:e}),-1):v--},buildTypeChoicesForProperty=({propName:r,schema:n,schemaIdx:s,autoTrigger:c})=>t({autoTrigger:c,topRoot:p,format:a,schemaOriginal:o,schemaIdx:s,schemaContent:n||"tuple"===l?n??i.rest:w||"set"===l?i?.value:"filelist"===l?i?.inner:"array"===l||"arrayNonindexKeys"===l?i?.element:i?.properties?.[r],state:f.filelist?"filelistArray":u??l,typeNamespace:e}).domArray;function preventAdding(e=0){switch(l){case"tuple":if("never"===i?.rest?.type)return pe.alert('Tuple has rest type "never", so one cannot add to it.'),!0;if("never"===i?.items?.[0]?.type)return pe.alert('Tuple has items type "never", so one cannot add to it.'),!0;break;case"set":{if("never"===i?.value?.type)return pe.alert('Set has type "never", so one cannot add to it.'),!0;const{maxSize:t}=i??{};if(void 0!==t&&[...T.children].length+e>t)return pe.alert("You cannot add beyond the `maxSize` of the Set"),!0;break}case"array":case"arrayNonindexKeys":{if("never"===i?.element?.type)return pe.alert('Array has type "never", so one cannot add to it.'),!0;const{maxLength:t}=i??{};if(void 0!==t&&T.$getArrayLength()+e>t)return pe.alert("You cannot add beyond the `maxLength` of the array"),!0;break}}return!1}const S=["button",{class:"addArrayElement",$custom:{$addArrayElement:function({propName:t,splice:a,alwaysFocus:s,required:o,schema:u,schemaIdx:m,autoTrigger:y}){const w=this.$getArrayItems();if(h)if(t){const e=t.match(/^\d+$/u)&&Number.parseInt(t);"number"==typeof e&&(v=e)}else"number"==typeof a?v=a+1:"string"!=typeof a&&(v=w.$getPropertyInputs().reduce(((e,t)=>{const a=t.$parseInt();return!1!==a&&a>e?a:e}),-1)+1);else v++;const S=this,I=`${l}Item`,T=c("fieldset",{dataset:o?{required:"required"}:{},$on:{change:[()=>{"set"===l&&setTimeout((()=>{const e=O,t=f.getValue.call({...f,set:!1},{root:e,stateObj:{types:n,formats:r}}),a=t.findLastIndex(((e,a)=>t.some(((t,r)=>a!==r&&e===t))));if(-1===a)return;const i=[...w.children].map((e=>{const t=$e(e,"div[data-type]");return t?n.getFormControlForRoot(t):null})),s=i[a];s&&(s.setCustomValidity("Duplicate Set value"),s.reportValidity())}))},!0]},$custom:{$getPropertyInput(){return DOM_filterChildElements(this,["legend",`input.propertyName-${e}`]).pop()}}},[buildLegend({className:I,splice:a,itemIndex:v,typeNamespace:e,arrayItems:w,propName:t,required:o,schema:u})],w);if(c({"#":[["span",{class:"mapValue",title:"map"===l&&i?.value?.description?"(map value)":"record"===l&&i?.value?.description?"(record value)":void 0},["map"===l?i?.value?.description??"Map value":"record"===l?i?.value?.description??"Record value":""," "]],...!i||t||f.array?buildTypeChoicesForProperty({propName:t,schema:u,schemaIdx:m,autoTrigger:y}):[c("span",{className:`optionalProperties-placeholder${ea}`})],["span",{className:"property-placeholder"}],d.repeat(2),["button",{disabled:"tuple"===l&&o&&i?.items?.length-1>v,$on:{click(e){if(e.preventDefault(),preventAdding(1))return;let t;if(h){const e=T.$getPropertyInput().$parseInt();t=!1===e?"append":e}S.$addArrayElement({splice:t,alwaysFocus:!0,schema:u});const a=w.lastElementChild;if(T.after(a),h||(i||u)&&!f.array){const e=a.$getPropertyInput();bringFocus(e,!0)}else DOM_filterChildElements(w,["fieldset","legend","."+I]).forEach(((e,t)=>{e.textContent=x?`${x} ${t+g+1}`:String(t+g)}));n.validateAllReferences({topRoot:p}),w.$redrawMoveArrows()}}},["+"]],["button",{disabled:o,$on:{click(e){e.preventDefault(),T.remove(),decrementItemIndex(w),h||i&&!f.array||DOM_filterChildElements(w,["fieldset","legend","."+I]).forEach(((e,t)=>{e.textContent=x?`${x} ${t+g+1}`:String(t+g)})),n.validateAllReferences({topRoot:p}),w.$redrawMoveArrows()}}},["x"]],["span",{class:`${l}Item-arrowHolder-${e}`},[]]]},T),b){const e=w.$getPropertyInputs();if(e.length){const t=e.pop();t.$validate(),t.$resort({alwaysFocus:s}),bringFocus(t,s)}}w.$redrawMoveArrows()},$getArrayItems(){return this.previousElementSibling}},$on:{click(){preventAdding(1)||(this.$addArrayElement({alwaysFocus:!0}),n.validateAllReferences({topRoot:p}))}}},["+ Item"]],I=h?["div",[["label",["Array length: ",["input",{type:"number",value:m&&m.length||0,step:1,size:4,class:"arrayLength",pattern:String.raw`\d`,$on:{async change(){if(preventAdding())return void(this.value=this.$oldvalue??this.defaultValue);const e=$e(this.closest(".arrayContents"),".arrayItems").$inputsExceedingLength();try{if(e.length)await pe.confirm({message:"Your new length will truncate the array causing items to be removed. Continue?"}),e.forEach((e=>{const t=e.closest("fieldset");if(t.matches("[data-required]")){const e=$e(O,".arrayLength");e.value=String(Number.parseInt(e.value)+1)}else t.remove()})),n.validateAllReferences({topRoot:p});else{const e=i?.element;if(!["void","undefined"].includes(e?.type)&&("union"!==e?.type||e?.options?.every((e=>!["void","undefined"].includes(e.type))))){const e=Number.parseInt(this.value)-Number.parseInt(this.$oldvalue??this.defaultValue);for(let t=0;t<e;t++)setTimeout((()=>{O.$addArrayElement({})}))}}this.$oldvalue=this.value}catch{this.value=this.$oldvalue}}}}]]]]]:"",T=c("div",{class:"arrayItems",$custom:{$swapGroup:function(e,t){const a=e.parentElement,r=a["up"===t?"previousElementSibling":"nextElementSibling"];if(r&&"fieldset"===r.nodeName.toLowerCase()){if(h||i&&!f.array){const e=a.$getPropertyInput(),t=r.$getPropertyInput();if("number"==typeof e.$parseInt()||"number"==typeof t.$parseInt()){const a=e.value,r=t.value;e.value=r,t.value=a}}else{const e=DOM_filterChildElements(r,["legend",`.${l}Item`])[0],t=DOM_filterChildElements(a,["legend",`.${l}Item`])[0],n=e.textContent,i=t.textContent;e.textContent=i,t.textContent=n}"up"===t?r.before(a):a.before(r),n.validateAllReferences({topRoot:p}),this.$redrawMoveArrows()}},$redrawMoveArrows:function(){"tuple"!==l&&DOM_filterChildElements(this,["fieldset",`.${l}Item-arrowHolder-${e}`]).forEach(((e,t,a)=>{DOM_removeChildren(e);let r=!0,n=!0;1!==a.length&&(0===t?r=!1:t===a.length-1&&(n=!1),r&&c("button",{$on:{click:()=>{this.$swapGroup(e,"up")}}},[le],e),n&&c("button",{$on:{click:()=>{this.$swapGroup(e,"down")}}},[ue],e))}))},$getArrayLength:function(){return Number($e(this.previousElementSibling,"input").value)},$inputsExceedingLength:function(){const e=this.$getArrayLength()-1;return this.$getPropertyInputs().filter((e=>e.value.match(/^\d+$/u))).filter((t=>{const a=Number.parseInt(t.value)>e;return t.setCustomValidity(a?"Invalid length":""),t.reportValidity(),a}))},$getMapKeySelects(){return DOM_filterChildElements(this,["fieldset","legend:first-child","span.mapKeyHolder","select.typeChoices-key-type-choices-only"])},$getPropertyInputs(){return DOM_filterChildElements(this,["fieldset","legend",`input.propertyName-${e}`])}}}),E=["button",{$on:{click(e){e.preventDefault();const{target:t}=e,a=$e(O,".arrayContents");a.hidden=!a.hidden,t.textContent=a.hidden?"+":"-"}}},["-"]],N=["div",{class:"arrayContents"},[I,T,S,["button",{$on:{click(){const e=this.closest(".arrayContents"),t=$e(e,".arrayItems"),a=t.lastElementChild;a&&!a.matches("[data-required]")&&(a.remove(),decrementItemIndex(t),$e(e,".arrayItems").$redrawMoveArrows()),n.validateAllReferences({topRoot:p})}}},["- Last item"]],["button",{$on:{click(){const e=this.closest(".arrayContents"),t=$e(e,".arrayItems"),a=$$e(e,".arrayItems > fieldset:not([data-required])");for(const e of a)e.remove();h?decrementItemIndex(t):v=-1,n.validateAllReferences({topRoot:p})}}},["x All"]]]],_=l,O=c("div",{dataset:{type:l},$custom:{$addAndSetArrayElement({propName:e,type:t,value:a,bringIntoFocus:r,setAValue:i,schemaContent:s,schemaIdx:o,mustBeOptional:c}){if("map"===_){if("0"===e){this.$addArrayElement({propName:e,autoTrigger:!1});const n=this.$getArrayItems(),i=DOM_filterChildElements(n,["fieldset:last-of-type","legend",".mapKeyHolder","select"])[0];return i.$setType({type:t,baseValue:a,bringIntoFocus:r,avoidReport:!0}),i.$getTypeRoot()}}else"record"===_?this.$addArrayElement({propName:e,autoTrigger:!1,required:!1}):this.$addArrayElement({propName:e,schema:s,autoTrigger:!1,schemaIdx:o,required:!c&&s&&!s.isOptional&&"never"!==s.type});const l=this.$getTypeChoices();l.$setType({type:t,baseValue:a,bringIntoFocus:r,specificSchema:"union"===s?.type&&void 0!==o?s.options[o]:s,avoidReport:!0});const u=l.$getTypeRoot();if(i){const e=n.getTypeObject(t);e.setValue&&e.setValue({root:u,value:a})}return n.validate({type:t,root:u,topRoot:p,avoidReport:!0}),u},$getAddArrayElement(){const e=this.lastElementChild.firstElementChild.nextElementSibling;return h?e.nextElementSibling:e},$addArrayElement({propName:e,splice:t,alwaysFocus:a,required:r,schema:n,schemaIdx:i,autoTrigger:s}){this.$getAddArrayElement().$addArrayElement({propName:e,splice:t,alwaysFocus:a,required:r,schema:n,schemaIdx:i,autoTrigger:s})},$getArrayItems(){return this.$getAddArrayElement().previousElementSibling},$getTypeChoices(){const t=this.$getArrayItems();return $e(t.lastElementChild,`fieldset > .typeChoices-${e}`)}},$on:{click(e){const t=e,a=t.target;["checkbox","radio","file","datetime-local",void 0].includes(a.type)||t.preventDefault()}}},[[i?"span":"b",{title:i?.description??DOM_initialCaps(l).replace(/s$/u,"")},[i?"—":DOM_initialCaps(l).replace(/s$/u,"")]],d.repeat(2),"filelist"===l?["input",{name:e+"-filelist",multiple:!0,type:"file",$on:{change(){if(this.files)for(let e=0;e<this.files.length;e++){const t=this.files.item(e);O.$addAndSetArrayElement({propName:String(e),type:"file",value:t,bringIntoFocus:!1,setAValue:!0})}}}}]:"",E,N]);if(p=p||O,!m&&i)switch(l){case"object":if(!s)for(const[e,t]of Object.entries(i.properties??{}))t.isOptional||"never"===t.type||O.$addArrayElement({propName:e,required:!0});break;case"tuple":if(!s){const e=i;if("never"!==i?.items?.[0]?.type)for(const t of e.items)O.$addArrayElement({schema:t,required:!0})}break;case"arrayNonindexKeys":{const{minLength:e=0}=i,t=$e(O,".arrayLength");t.value=String(e),t.$oldvalue=String(e);for(let t=0;t<e;t++)O.$addArrayElement({required:!0});break}case"set":if(!s){const{minSize:e=0}=i;for(let t=0;t<e;t++)O.$addArrayElement({required:!0})}}return[O]}},aa={option:["Tuple"],array:!0,regexEndings:[",","]"],stringRegexBegin:/^Tuple\[/u,stringRegexEnd:/^\]/u,tuple:!0,valueMatch:e=>Array.isArray(e),toValue(...e){return ta.toValue.apply(this,e)},getValue(...e){return ta.getValue.apply(this,e)},getInput(...e){return ta.getInput.apply(this,e)},viewUI({...e}){return ta.viewUI.call(this,{...e,type:"tuple"})},editUI({...e}){return ta.editUI.call(this,{...e,type:"tuple"})}},ra={option:["Object"],regexEndings:[",","}"],stringRegexBegin:/^\{/u,stringRegexEnd:/^\}/u,valueMatch:e=>e&&"object"==typeof e&&"Object"===toStringTag(e),toValue(...e){return ta.toValue.apply(this,e)},getValue(...e){return ta.getValue.apply(this,e)},getInput(...e){return ta.getInput.apply(this,e)},viewUI({...e}){return ta.viewUI.call(this,{...e,type:"object"})},editUI({...e}){return ta.editUI.call(this,{...e,type:"object"})}},na={option:["Record"],regexEndings:[",","}"],stringRegexBegin:/^Record\{/u,stringRegexEnd:/^\}/u,array:!0,record:!0,valueMatch:e=>e&&"object"==typeof e&&"Object"===toStringTag(e),toValue(...e){return ta.toValue.apply(this,e)},getValue(...e){return ta.getValue.apply(this,e)},getInput(...e){return ta.getInput.apply(this,e)},viewUI({...e}){return ta.viewUI.call(this,{...e,type:"record"})},editUI({...e}){return ta.editUI.call(this,{...e,type:"record"})}},ia={option:["Date"],dateRegex:/^(?:\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d)$/u,stringRegex(){const e=this.dateRegex;if(!this.valid){const{source:t}=e;return new RegExp("^(?:InvalidDate)|"+t.slice(1),"u")}return new RegExp(e,"u")},valueMatch:e=>"Date"===toStringTag(e),toValue:e=>({value:new Date(e)}),getInput:({root:e})=>$e(e,'input[type="datetime-local"]'),setValue({root:e,value:t}){if(t&&Number.isNaN(t.getTime()))return void $e(e,".invalidDate").$setValidity(!0);const a=new Date(Date.parse(t)).toISOString();this.getInput({root:e}).value=24===a.length?a.slice(0,-8):a.slice(3,13)},validate({root:e}){if(this.isInvalid({root:e}))return{valid:!0};const t=this.getInput({root:e}).value;return t?{valid:new RegExp(this.dateRegex,"u").test(t),message:"Must match a valid date"}:{valid:!1,message:"Must not be empty`"}},isInvalid({root:e}){return!this.valid&&$e(e,".invalidDate").checked},getValue({root:e}){return this.isInvalid({root:e})?this.toValue("NaN").value:this.toValue(this.getInput({root:e}).value).value},isValueInvalid:e=>e&&Number.isNaN(e.getTime()),viewUI({value:e,specificSchemaObject:t}){return!this.valid&&this.isValueInvalid(e)?["i",{dataset:{type:"date"},class:"InvalidDate",title:t?.description??"(an InvalidDate)"},["InvalidDate"]]:["i",{dataset:{type:"date"},class:"ValidDate",title:t?.description??"(a `Date`)"},[e.toISOString().slice(0,-8)]]},editUI({typeNamespace:e,specificSchemaObject:t,types:a,value:r}){const n=t,i=r??(t?.defaultValue?new Date(t?.defaultValue):""),s=this.isValueInvalid(i),o=this.valid?"":c("div",[["label",["Invalid date",["input",{type:"checkbox",class:"invalidDate",checked:s,name:`${e}-invalidDate`,$custom:{$setValidity(e){!0===e&&(this.checked=!0);const t=o.previousElementSibling;t.hidden=Boolean(e);const r=t.parentElement;a.validate({type:"date",root:r})}},$on:{click(){this.$setValidity(this.checked)}}}]]]]);return["div",{dataset:{type:this.valid?"ValidDate":"date"},title:t?.description??"Date"},[["label",{hidden:s},["Date: ",["input",{name:`${e}-date`,type:"datetime-local",value:!i||s?"":i.toISOString().slice(0,-8),min:n?.min?new Date(n.min).toISOString().slice(0,-8):void 0,max:n?.max?new Date(n.max).toISOString().slice(0,-8):void 0}]]],o]]}},sa={option:["Enum"],stringRegex:/^Enum\((.*)\)$/u,valueMatch:e=>"string"==typeof e,toValue:e=>({value:e.slice(1,-1)}),getInput:({root:e})=>$e(e,"select"),setValue({root:e,value:t}){this.getInput({root:e}).value=t},getValue({root:e}){return this.getInput({root:e}).value},viewUI:({value:e,specificSchemaObject:t})=>["span",{dataset:{type:"enum"},title:t?.description??"(an enum)"},[e]],editUI:({typeNamespace:e,specificSchemaObject:t,value:a=""})=>["div",{dataset:{type:"enum"},title:t?.description??"Enum"},[["select",{name:`${e}-enum`},t?.values.map((e=>["option",{selected:a?a===e:t?.defaultValue===e},[e]]))]]]},oa={option:["Set"],array:!0,set:!0,regexEndings:[",",")"],stringRegexBegin:/^Set\(/u,stringRegexEnd:/^\)/u,valueMatch:e=>"Set"===toStringTag(e),toValue(...e){return ta.toValue.apply(this,e)},getValue(...e){return ta.getValue.apply(this,e)},getInput(...e){return ta.getInput.apply(this,e)},viewUI({...e}){return ta.viewUI.call(this,{...e,type:"set"})},editUI({...e}){return ta.editUI.call(this,{...e,type:"set"})}},ca={option:["Map"],array:!0,map:!0,regexEndings:[",",")"],stringRegexBegin:/^Map\(/u,stringRegexEnd:/^\)/u,valueMatch:e=>"Map"===toStringTag(e),toValue(...e){return ta.toValue.apply(this,e)},getValue(...e){return ta.getValue.apply(this,e)},getInput(...e){return ta.getInput.apply(this,e)},viewUI({...e}){return ta.viewUI.call(this,{...e,type:"map"})},editUI({...e}){return ta.editUI.call(this,{...e,type:"map"})}},la={option:["Literal"],stringRegex:/^Literal\((.*)\)$/u,valueMatch:e=>"boolean"==typeof e||"number"==typeof e||"string"==typeof e,toValue:e=>({value:"true"===e||"false"!==e&&('"'===e.charAt(0)?e.slice(1,-1):Number(e))}),getInput:({root:e})=>$e(e,"input,textarea"),setValue({root:e,value:t}){this.getInput({root:e}).value=t},getValue({root:e,stateObj:t}){const a=$e(e,"[data-type]"),r=t?.types?.getTypeObject?.(a?.dataset.type);return r?.getValue({root:e,stateObj:t})},viewUI:({value:e,specificSchemaObject:t})=>["span",{dataset:{type:"literal"},title:t?.description??`(a literal ${typeof e})`},[`${e}`]],editUI(e){const{specificSchemaObject:t}=e,{value:a}=t;let r;switch(typeof a){case"boolean":r=Mt.editUI(e);break;case"number":r=Pt.editUI(e);break;default:r=Gt.editUI(e)}return["div",{dataset:{type:"literal"}},[r]]}},ua={stringRegex:/^undefined$/u,option:["Explicit undefined"],valueMatch:e=>void 0===e,toValue:()=>({value:void 0}),getValue(){return this.toValue("").value},viewUI:({specificSchemaObject:e})=>["i",{dataset:{type:"undef"},title:e?.description??"(an `undefined`)"},["undefined"]],getInput:({root:e})=>$e(e,"input"),editUI:({typeNamespace:e,specificSchemaObject:t})=>["div",{dataset:{type:"undef"},title:t?.description??"Undefined"},[["label",["Undefined",["input",{type:"checkbox",name:`${e}-undef`,disabled:!0,checked:!0}]]]]]},da={stringRegex:/^void$/u,option:["Void"],valueMatch:e=>void 0===e,toValue:()=>({value:void 0}),getValue(){return this.toValue("").value},getInput:({root:e})=>$e(e,"input"),viewUI:({specificSchemaObject:e})=>["i",{dataset:{type:"void"},title:e?.description??"(a `void`)"},["void"]],editUI:({typeNamespace:e,specificSchemaObject:t})=>["div",{dataset:{type:"void"},title:t?.description??"Void"},[["label",["Void",["input",{type:"checkbox",name:`${e}-void`,checked:!0,disabled:!0}]]]]]},pa={option:["RegExp"],stringRegex(e){const t=e?"(?:":"(";return new RegExp(`^/${t}.*)/${t}[${this.allowedFlags.join("")}]{0,${this.allowedFlags.length}})$`,"u")},valueMatch:e=>"RegExp"===toStringTag(e),toValue(e){if("function"!=typeof this.stringRegex)throw new TypeError("Guard for TS");const[,t,a]=e.match(this.stringRegex());return{value:new RegExp(t,a)}},getInput:({root:e})=>$e(e,"input"),setValue({root:e,value:t}){this.getInput({root:e}).value=t.source,this.getSelect({root:e}).$set([...t.flags])},getSelect:({root:e})=>$e(e,"select"),validate({root:e}){try{return this.getValue({root:e}),{valid:!0}}catch(e){return{valid:!1,message:e.message}}},getValue({root:e}){return new RegExp(this.getInput({root:e}).value,[...this.getSelect({root:e}).selectedOptions].reduce(((e,t)=>e+t.value),""))},allowedFlags:["g","i","m","u","y","s","v"],viewUI:({value:e,specificSchemaObject:t})=>["i",{dataset:{type:"regexp"},title:t?.description??"(a `RegExp`)"},[String(e)]],editUI({typeNamespace:e,specificSchemaObject:t,types:a,value:r={source:"",flags:""}}){const n=c("select",{multiple:!0,size:5,$custom:{$set(e){[...this.options].forEach((t=>{t.selected=e.includes(t.value)}))}}},this.allowedFlags.map((e=>["option",{selected:r.flags.includes(e)},[e]]))),i=c("div",{dataset:{type:"regexp"},title:t?.description??"RegExp"},[["label",["Source ",["input",{name:`${e}-regexp`,type:"text",value:r.source}]]],["br"],["label",["Flags ",n]]]);return n.addEventListener("change",(()=>{a.validate({type:"regexp",root:i})})),[i]}},ma={option:["BooleanObject"],stringRegex:/^Boolean\((.*)\)$/u,valueMatch:e=>"Boolean"===toStringTag(e)&&"object"==typeof e,toValue:e=>({value:new Boolean("true"===e)}),getInput:({root:e})=>$e(e,"input"),getValue({root:e}){return this.toValue(String(this.getInput({root:e}).checked)).value},setValue({root:e,value:t}){$$e(e,"input")[t.valueOf()?0:1].checked=!0},viewUI:({value:e,specificSchemaObject:t})=>["i",{dataset:{type:"BooleanObject"},title:t?.description??"(a Boolean Object)"},[t?`${e}`:`Boolean(${e})`]],ct:0,editUI({typeNamespace:e,specificSchemaObject:t,value:a=new Boolean(!0)}){return this.ct++,["div",{dataset:{type:"BooleanObject"},title:t?.description??"Boolean object"},[["label",["True",["input",{type:"radio",name:`${e}-BooleanObject${this.ct}`,value:"true",checked:a.valueOf()}]]],["label",["False",["input",{type:"radio",name:`${e}-BooleanObject${this.ct}`,value:"false",checked:!a.valueOf()}]]]]]}},ya={option:["NumberObject"],stringRegex:/^Number\((.*)\)$/u,valueMatch:e=>"Number"===toStringTag(e)&&"object"==typeof e,toValue:e=>({value:new Number(e)}),validate:({root:e})=>Pt.validate({root:e}),getInput:({root:e})=>$e(e,"input"),getValue({root:e}){return this.toValue(this.getInput({root:e}).value).value},setValue({root:e,value:t}){this.getInput({root:e}).value=String(t)},viewUI:({value:e,specificSchemaObject:t})=>["i",{dataset:{type:"NumberObject"},title:t?.description??"(a Number Object)"},[t?`${e}`:`Number(${e})`]],editUI:({typeNamespace:e,specificSchemaObject:t,value:a})=>["div",{dataset:{type:"NumberObject"},title:t?.description??"Number object"},[["input",{name:`${e}-NumberObject`,type:"number",value:a,step:"any"}]]]},ha={stringRegex:/^String\(([^)]*)\)$/u,valueMatch:e=>"String"===toStringTag(e)&&"object"==typeof e,toValue:e=>({value:new String(e)}),option:["StringObject"],getInput:({root:e})=>$e(e,"textarea"),getValue({root:e}){return this.toValue(this.getInput({root:e}).value).value},setValue({root:e,value:t}){this.getInput({root:e}).value=t},viewUI:({value:e,specificSchemaObject:t})=>["span",{dataset:{type:"StringObject"},title:t?.description??"(a String Object)"},[t?"":["i",["String("]],["span",[e.valueOf()]],t?"":["i",[")"]]]],editUI:({typeNamespace:e,specificSchemaObject:t,value:a=""})=>["div",{dataset:{type:"StringObject"},title:t?.description??"String object"},[["textarea",{name:`${e}-StringObject`},[a]]]]},fa={option:["Special Real Number",{title:"`Infinity`, `-Infinity`, `-0`"}],childTypes:["infinity","negativeInfinity","negativeZero"],stringRegex:/^(?:-?Infinity|-0)$/u,valueMatch:e=>Object.is(e,-0)||e===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY,toValue:e=>({value:"-0"===e?-0:"Infinity"===e?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY}),getSelect:({root:e})=>$e(e,"select"),getValue({root:e}){return this.toValue(this.getSelect({root:e}).value).value},setValue({root:e,value:t}){this.getSelect({root:e}).value=Object.is(t,-0)?"-0":String(t)},viewUI({value:e,specificSchemaObject:t}){const a=Object.is(e,-0);return["i",{dataset:{type:"SpecialRealNumber"},title:t?.description??(a?"(negative zero)":`(${String(e)})`)},[a?"-0":String(e)]]},getInput:({root:e})=>$e(e,"select"),editUI:({typeNamespace:e,specificSchemaObject:t,value:a=Number.POSITIVE_INFINITY})=>["div",{dataset:{type:"SpecialRealNumber"},title:t?.description??"Special Real Number"},[["label",[["select",{name:`${e}-SpecialRealNumber`},[["option",{value:"Infinity",selected:a===Number.POSITIVE_INFINITY},["Infinity"]],["option",{value:"-Infinity",selected:a===Number.NEGATIVE_INFINITY},["-Infinity"]],["option",{value:"-0",selected:Object.is(a,-0)},["-0"]]]]]]]]},ga={option:["Special Number",{title:"`NaN`, `Infinity`, `-Infinity`, `-0`"}],childTypes:["infinity","negativeInfinity","nan","negativeZero"],stringRegex:/^(?:NaN|-?Infinity|-0)$/u,toValue:e=>({value:"-0"===e?-0:"NaN"===e?Number.NaN:"Infinity"===e?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY}),getSelect:({root:e})=>$e(e,"select"),getInput:({root:e})=>$e(e,"select"),getValue({root:e}){return this.toValue(this.getSelect({root:e}).value).value},setValue({root:e,value:t}){this.getSelect({root:e}).value=Object.is(t,-0)?"-0":String(t)},viewUI:({value:e})=>["i",{dataset:{type:"SpecialNumber"}},[Object.is(e,-0)?"-0":String(e)]],editUI:({typeNamespace:e,value:t=Number.NaN})=>["div",{dataset:{type:"SpecialNumber"}},[["label",["Special number: ",["select",{name:`${e}-SpecialNumber`},[["option",{value:"NaN",selected:Number.isNaN(t)},["NaN"]],["option",{value:"Infinity",selected:t===Number.POSITIVE_INFINITY},["Infinity"]],["option",{value:"-Infinity",selected:t===Number.NEGATIVE_INFINITY},["-Infinity"]],["option",{value:"-0",selected:Object.is(t,-0)},["-0"]]]]]]]]},va={option:["Error"],stringRegex:/^Error\((.*)\)$/u,valueMatch:e=>"Error"===toStringTag(e)&&hasConstructorOf(e,Error),toValue(e){const t=JSON.parse(e);return{value:D.error.revive(t,{})}},getInput:({root:e})=>$e(e,"input:not([type])"),setValue({root:e,value:t}){"string"==typeof t.message?$e(e,"input.message:not([type])").value=t.message:$e(e,"input.message[type=checkbox]").click(),"string"==typeof t.name?$e(e,"input.name:not([type])").value=t.name:$e(e,"input.name[type=checkbox]").click(),"string"==typeof t.fileName?$e(e,"input.fileName:not([type])").value=t.fileName:$e(e,"input.fileName[type=checkbox]").click(),"number"==typeof t.lineNumber?$e(e,"input.lineNumber[type=number]").value=t.lineNumber:$e(e,"input.lineNumber[type=number]").value="","number"==typeof t.columnNumber?$e(e,"input.columnNumber[type=number]").value=t.columnNumber:$e(e,"input.columnNumber[type=number]").value="","string"==typeof t.stack?$e(e,"textarea.stack:not([type])").value=t.stack:$e(e,"input.stack[type=checkbox]").click(),setTimeout((()=>{"object"==typeof t.cause&&($e(e,".cause").click(),this.setValue({root:$e(e,".causeContents"),value:t.cause}))}))},getValue({root:e}){let t;if($e(e,"input.message[type=checkbox]").checked){const a=$e(e,"input.message:not([type])").value;t=new Error(a)}else t=new Error,t.message=void 0;if($e(e,"input.name[type=checkbox]").checked){const a=$e(e,"input.name:not([type])").value;t.name=a}else t.name=void 0;if($e(e,"input.fileName[type=checkbox]").checked){const a=$e(e,"input.fileName:not([type])").value;t.fileName=a}else t.fileName=void 0;if($e(e,"input.stack[type=checkbox]").checked){const a=$e(e,"textarea.stack:not([type])").value;t.stack=a}else t.stack=void 0;const a=$e(e,"input.lineNumber[type=number]").value;t.lineNumber=""===a?void 0:Number(a);const r=$e(e,"input.columnNumber[type=number]").value;t.columnNumber=""===r?void 0:Number(r);const n=$e(e,".causeContents");return n.children.length&&(t.cause=this.getValue({root:n})),t},viewUI({value:e,specificSchemaObject:t,types:a,format:r}){return["div",{dataset:{type:"error"}},[["b",{class:"emphasis",title:t?.description?"(an Error)":void 0},[t?.description??"Error"]],"string"==typeof e.message?["div",[["b",["Message: "]],["span",[e.message]]]]:[],"string"==typeof e.name?["div",[["b",["Name: "]],["span",[e.name]]]]:[],"string"==typeof e.fileName?["div",[["b",["File name: "]],["span",[e.fileName]]]]:[],"number"==typeof e.lineNumber?["div",[["b",["Line number: "]],["span",[e.lineNumber]]]]:[],"number"==typeof e.columnNumber?["div",[["b",["Column number: "]],["span",[e.columnNumber]]]]:[],"string"==typeof e.stack?["div",[["b",["Stack: "]],["span",[e.stack]]]]:[],["b",["Cause: "]],["div",{class:"causeHolder"},[["button",{$on:{click(e){e.preventDefault();const{target:t}=e,a=t.nextElementSibling;a.hidden=!a.hidden,t.textContent=a.hidden?"+":"-"}}},["-"]],["div",{class:"causeContents"},[e.cause?this.viewUI({format:r,value:e.cause,types:a}):""]]]]]]},editUI({typeNamespace:e,types:t,specificSchemaObject:a,value:r={message:"",name:"",fileName:"",lineNumber:"",columnNumber:"",stack:"",cause:void 0}}){const click=function(e){this.parentNode.nextElementSibling.hidden=!e.target.checked},n=this;"object"==typeof r.cause&&setTimeout((()=>{$e(i,".cause").click()}));const i=c("div",{dataset:{type:"error"},title:a?.description??"Error"},[["div",[["label",["Message? ",["input",{class:"message",type:"checkbox",checked:"string"==typeof r.message,$on:{click:click}}]]]," ",["label",{hidden:"string"!=typeof r.message},["Message ",["input",{class:"message",name:`${e}-error-message`,value:r.message}]]]]],["div",[["label",["Name? ",["input",{class:"name",type:"checkbox",checked:"string"==typeof r.name,$on:{click:click}}]]]," ",["label",{hidden:"string"!=typeof r.name},["Name ",["input",{class:"name",name:`${e}-error-name`,value:r.name}]]]]],["br"],["div",[["label",["File name? ",["input",{class:"fileName",type:"checkbox",checked:"string"==typeof r.fileName,$on:{click:click}}]]]," ",["label",{hidden:"string"!=typeof r.fileName},["File name ",["input",{class:"fileName",name:`${e}-error-fileName`,value:r.fileName}]]]]],["label",["Line number ",["input",{class:"lineNumber",name:`${e}-error-lineNumber`,type:"number",step:"any",value:r.lineNumber}]]],["br"],["label",["Column number ",["input",{class:"columnNumber",name:`${e}-error-columnNumber`,type:"number",step:"any",value:r.columnNumber}]]],["div",[["label",["Stack? ",["input",{class:"stack",type:"checkbox",checked:"string"==typeof r.stack,$on:{click:click}}]]],["label",{hidden:"string"!=typeof r.stack},["Stack ",["textarea",{class:"stack",name:`${e}-error-stack`},[r.stack]]]]]],["label",["Cause? ",["input",{class:"cause",type:"checkbox",$on:{click(a){click.call(this,a);const i=this.parentElement.nextElementSibling,s=$e(i,".causeContents");if(!s?.children.length){const a=n.editUI({typeNamespace:e,types:t,value:r.cause});c(...a,s)}}}}]]],["div",{class:"causeHolder",hidden:!0},[["label",["Cause "]],["button",{$on:{click(e){e.preventDefault();const{target:t}=e,a=$e(t.closest(".causeHolder"),".causeContents");a.hidden=!a.hidden,t.textContent=a.hidden?"+":"-"}}},["-"]],["div",{class:"causeContents"}]]]]);return[i]}};function getConstructor(e){const t=Function.prototype.toString.call(e);return t.slice(9,t.indexOf("("))}const ba=new Map([["TypeError",TypeError],["RangeError",RangeError],["SyntaxError",SyntaxError],["ReferenceError",ReferenceError],["EvalError",EvalError],["URIError",URIError]]);"undefined"!=typeof AggregateError&&ba.set("AggregateError",AggregateError),"undefined"!=typeof InternalError&&ba.set("InternalError",InternalError);const wa=[...ba.keys()],xa={option:["Special errors"],valueMatch:e=>[TypeError,RangeError,SyntaxError,ReferenceError,EvalError,URIError,AggregateError].some((t=>hasConstructorOf(e,t))),childTypes:wa.map((e=>e.toLowerCase())),stringRegex:new RegExp("^(?<errorClass>"+wa.join("|")+String.raw`)\((?<innerContent>.*)\)$`,"u"),toValue(e,t){const{groups:{errorClass:a}={}}=t.match,r=JSON.parse(e);return{value:L[a.toLowerCase()].revive(r,{})}},getInput:({root:e})=>$e(e,"input:not([type])"),setValue({root:e,value:t}){const a=$e(e,".errorType");a.value=getConstructor(t.constructor),a.$hideAggregateErrorsLabel(),"string"==typeof t.message?$e(e,"input.message:not([type])").value=t.message:$e(e,"input.message[type=checkbox]").click(),"string"==typeof t.name?$e(e,"input.name:not([type])").value=t.name:$e(e,"input.name[type=checkbox]").click(),"string"==typeof t.fileName?$e(e,"input.fileName:not([type])").value=t.fileName:$e(e,"input.fileName[type=checkbox]").click(),"number"==typeof t.lineNumber?$e(e,"input.lineNumber[type=number]").value=t.lineNumber:$e(e,"input.lineNumber[type=number]").value="","number"==typeof t.columnNumber?$e(e,"input.columnNumber[type=number]").value=t.columnNumber:$e(e,"input.columnNumber[type=number]").value="","string"==typeof t.stack?$e(e,"textarea.stack:not([type])").value=t.stack:$e(e,"input.stack[type=checkbox]").click(),setTimeout((()=>{if("object"==typeof t.cause&&($e(e,".cause").click(),this.setValue({root:$e(e,".causeContents"),value:t.cause})),Array.isArray(t.errors)){const a=$e(e,"input.aggregateErrors");a.click(),a.$emptyAggregateErrorsContents(),a.$populateContents(t.errors)}}))},getValue({root:e,stateObj:t}){const a=ba.get($e(e,".errorType").value);if(!a)throw new Error("Bad error type");let r;if($e(e,"input.message[type=checkbox]").checked){const n=$e(e,"input.message:not([type])").value;if("AggregateError"===getConstructor(a)){const i=a,s=$e(e,".aggregateErrorsContents").firstElementChild;r=new i(ta.getValue({stateObj:t,root:s}),n)}else{r=new a(n)}}else{if("AggregateError"===getConstructor(a)){const n=a,i=$e(e,".aggregateErrorsContents").firstElementChild;r=new n(ta.getValue({stateObj:t,root:i}))}else{r=new a}r.message=void 0}if($e(e,"input.name[type=checkbox]").checked){const t=$e(e,"input.name:not([type])").value;r.name=t}else r.name=void 0;if($e(e,"input.fileName[type=checkbox]").checked){const t=$e(e,"input.fileName:not([type])").value;r.fileName=t}else r.fileName=void 0;if($e(e,"input.stack[type=checkbox]").checked){const t=$e(e,"textarea.stack:not([type])").value;r.stack=t}else r.stack=void 0;const n=$e(e,"input.lineNumber[type=number]").value;r.lineNumber=""===n?void 0:Number(n);const i=$e(e,"input.columnNumber[type=number]").value;r.columnNumber=""===i?void 0:Number(i);const s=$e(e,".causeContents");return s.children.length&&(r.cause=this.getValue({stateObj:t,root:s})),r},viewUI({value:e,types:t,format:a,specificSchemaObject:r,typeNamespace:n,resultType:i}){const s=getConstructor(e.constructor);return["div",{dataset:{type:"errors"},title:r?.description?`(an Error ${s})`:void 0},[r?.description??["div",[["b",["Error type: "]],["span",[s]]]],"string"==typeof e.message?["div",[["b",["Message: "]],["span",[e.message]]]]:[],"string"==typeof e.name?["div",[["b",["Name: "]],["span",[e.name]]]]:[],"string"==typeof e.fileName?["div",[["b",["File name: "]],["span",[e.fileName]]]]:[],"number"==typeof e.lineNumber?["div",[["b",["Line number: "]],["span",[e.lineNumber]]]]:[],"number"==typeof e.columnNumber?["div",[["b",["Column number: "]],["span",[e.columnNumber]]]]:[],"string"==typeof e.stack?["div",[["b",["Stack: "]],["span",[e.stack]]]]:[],["b",["Cause: "]],["div",{class:"causeHolder"},[["button",{$on:{click(e){e.preventDefault();const{target:t}=e,a=t.nextElementSibling;a.hidden=!a.hidden,t.textContent=a.hidden?"+":"-"}}},["-"]],["div",{class:"causeContents"},[e.cause?this.viewUI({format:a,value:e.cause,types:t}):""]]]],"AggregateError"===s?["div",[["b",["Errors "]],["div",{class:"aggregateErrorsHolder"},[["button",{$on:{click(e){e.preventDefault();const{target:t}=e,a=t.nextElementSibling;a.hidden=!a.hidden,t.textContent=a.hidden?"+":"-"}}},["-"]],["div",{class:"aggregateErrorsContents"},[e.errors?(()=>{const[r]=ta.viewUI({typeNamespace:n,resultType:i,format:a,type:"arrayNonindexKeys",value:[],types:t});return e.errors.forEach(((e,t)=>{r.$addAndSetArrayElement({propName:String(t),type:"Error"===getConstructor(e.constructor)?"error":"errors",value:e,bringIntoFocus:!1})})),r})():""]]]]]]:""]]},editUI({typeNamespace:e,specificSchemaObject:t,types:a,buildTypeChoices:r,format:n,topRoot:i,bringIntoFocus:s,value:o={message:"",name:"",fileName:"",lineNumber:"",columnNumber:"",stack:"",cause:void 0,errors:void 0}}){const click=function(e){this.parentNode.nextElementSibling.hidden=!e.target.checked},l=this;"object"==typeof o.cause&&setTimeout((()=>{$e(u,".cause").click()})),Array.isArray(o.errors)&&setTimeout((()=>{$e(u,"input.aggregateErrors").click()}));const u=c("div",{dataset:{type:"errors"},title:t?.description??"Special error"},[["div",[["label",["Special error type ",["select",{class:"errorType",$custom:{$hideAggregateErrorsLabel(){$e(this.parentElement?.closest("div[data-type=errors]"),"label.aggregateErrors").hidden="AggregateError"!==this.value}},$on:{change(){this.$hideAggregateErrorsLabel()}}},[["option",{value:""},["Select an error type"]],...wa.map((e=>["option",{selected:e===getConstructor(o.constructor)?"selected":void 0},[e]]))]]]],["br"],["label",["Message? ",["input",{class:"message",type:"checkbox",checked:"string"==typeof o.message,$on:{click:click}}]]]," ",["label",{hidden:"string"!=typeof o.message},["Message ",["input",{class:"message",name:`${e}-errors-message`,value:o.message}]]]]],["div",[["label",["Name? ",["input",{class:"name",type:"checkbox",checked:"string"==typeof o.name,$on:{click:click}}]]]," ",["label",{hidden:"string"!=typeof o.name},["Name ",["input",{class:"name",name:`${e}-errors-name`,value:o.name}]]]]],["br"],["div",[["label",["File name? ",["input",{class:"fileName",type:"checkbox",checked:"string"==typeof o.fileName,$on:{click:click}}]]]," ",["label",{hidden:"string"!=typeof o.fileName},["File name ",["input",{class:"fileName",name:`${e}-errors-fileName`,value:o.fileName}]]]]],["label",["Line number ",["input",{class:"lineNumber",name:`${e}-errors-lineNumber`,type:"number",step:"any",value:o.lineNumber}]]],["br"],["label",["Column number ",["input",{class:"columnNumber",name:`${e}-errors-columnNumber`,type:"number",step:"any",value:o.columnNumber}]]],["div",[["label",["Stack? ",["input",{class:"stack",type:"checkbox",checked:"string"==typeof o.stack,$on:{click:click}}]]],["label",{hidden:"string"!=typeof o.stack},["Stack ",["textarea",{class:"stack",name:`${e}-errors-stack`},[o.stack??""]]]]]],["label",["Cause? ",["input",{class:"cause",type:"checkbox",$on:{click(t){click.call(this,t);const n=this.parentElement.nextElementSibling,i=$e(n,".causeContents");if(!i?.children.length){const t=l.editUI({buildTypeChoices:r,typeNamespace:e,types:a,value:o.cause});c(...t,i)}}}}]]],["div",{class:"causeHolder",hidden:!0},[["label",["Cause "]],["button",{$on:{click(e){e.preventDefault();const{target:t}=e,a=$e(t.closest(".causeHolder"),".causeContents");a.hidden=!a.hidden,t.textContent=a.hidden?"+":"-"}}},["-"]],["div",{class:"causeContents"}]]],["br"],["label",{class:"aggregateErrors"},{hidden:!o.errors},["Aggregate errors? ",["input",{class:"aggregateErrors",type:"checkbox",$custom:{$emptyAggregateErrorsContents(){const e=this.parentElement.nextElementSibling,t=$e(e,".aggregateErrorsContents");for(;t?.firstChild;)t?.firstChild.remove()},$populateContents(t){const o=this.parentElement.nextElementSibling,l=$e(o,".aggregateErrorsContents");if(!l?.children.length){const[o]=ta.editUI({typeNamespace:e,types:a,buildTypeChoices:r,format:n,type:"array",topRoot:i,bringIntoFocus:s,forcedState:"errorsArray",value:[]});t.forEach(((e,t)=>{o.$addAndSetArrayElement({propName:String(t),type:"Error"===getConstructor(e.constructor)?"error":"errors",value:e,bringIntoFocus:!1,setAValue:!0})})),c(o,l)}}},$on:{click(e){click.call(this,e);const t=this;o.errors?t.$populateContents(o.errors):t.$populateContents([{message:"",name:"",stack:""}])}}}]]],["div",{class:"aggregateErrorsHolder",hidden:!0},[["label",["Aggregate errors "]],["button",{$on:{click(e){e.preventDefault();const{target:t}=e,a=$e(t.closest(".aggregateErrorsHolder"),".aggregateErrorsContents");a.hidden=!a.hidden,t.textContent=a.hidden?"+":"-"}}},["-"]],["div",{class:"aggregateErrorsContents"}]]]]);return[u]}};let Sa;function visualize(e,t){Sa||(Sa=new AudioContext);const a=t.getContext("2d"),r=Sa.createMediaStreamSource(e),n=Sa.createAnalyser();n.fftSize=2048;const i=n.frequencyBinCount,s=new Uint8Array(i);r.connect(n),function draw(){const e=t.width,r=t.height;requestAnimationFrame(draw),n.getByteTimeDomainData(s),a.fillStyle="rgb(200, 200, 200)",a.fillRect(0,0,e,r),a.lineWidth=2,a.strokeStyle="rgb(0, 0, 0)",a.beginPath();const o=1*e/i;let c=0;for(let e=0;e<i;e++){const t=s[e]/128*r/2;0===e?a.moveTo(c,t):a.lineTo(c,t),c+=o}a.lineTo(t.width,t.height/2),a.stroke()}()}async function getUserMedia(e){let t=null;try{t=await navigator.mediaDevices.getUserMedia(e)}catch(e){return console.error("err",e),null}return t}async function startScreenCapture(e){let t=null;try{t=await navigator.mediaDevices.getDisplayMedia(e)}catch(e){console.error(`Error: ${e}`)}return t}function getDateString(e){const t=new Date(e);return new Date(t.getTime()-6e4*t.getTimezoneOffset()).toISOString().slice(0,-1)}function newFileForBinary(e,t){const a=e.$value,r=new File([void 0===t.stringContents?a&&"File"===Object.prototype.toString.call(a).slice(8,-1)?a:"":t.stringContents],void 0===t.name?a?.name??"":t.name,{type:void 0===t.type?a?.type??"":t.type,lastModified:void 0===t.lastModified?a?.lastModified??0:t.lastModified});e.$value=r}function binaryButton$1(e,t){return["button",{class:"viewBinary",$custom:{$value:e},$on:{click(e){const t=this;e.preventDefault(),this.$value&&"File"===Object.prototype.toString.call(this.$value).slice(8,-1)||newFileForBinary(t,{});const a=new FileReader;a.addEventListener("load",(async function(){const e=await pe.makeSubmitDialog({submitText:"Save",submit(){const a=$e(e,".view-binary");newFileForBinary(t,{stringContents:a.value}),e.close()},children:[["div",["Binary source",["br"],["textarea",{class:"view-binary"},[a.result??""]]]]]})})),a.addEventListener("error",(async function(){console.error(a.error),await pe.alert(a.error.message)})),a.readAsBinaryString(this.$value)}}},[t?"Edit binary data":"View binary data"]]}const Ia={option:["File"],stringRegex:/^File\((.*)\)$/u,valueMatch:e=>"File"===toStringTag(e),toValue(e){const t=JSON.parse(e);return{value:new File([t.stringContents],t.name,{type:t.type,lastModified:t.lastModified})}},getInput:({root:e})=>$e(e,"button.viewBinary"),setValue({root:e,value:t}){$e(e,"fieldset.fileMetaData").$setValue(t)},getValue({root:e}){return this.getInput({root:e}).$value},viewUI:({value:e,specificSchemaObject:t})=>["div",{dataset:{type:"file"}},[["b",{class:"emphasis",title:t?.description?"(a File)":void 0},[t?.description??"File"]],["br"],["br"],["b",["Name "]],e.name,["br"],["b",["Size (in bytes) "]],String(e.size),["br"],["b",["Content type "]],e.type,["br"],["b",["Last modified date "]],getDateString(e.lastModified),["br"],e.type.startsWith("text/")||"application/json"===e.type?(()=>{const t=c("div"),a=new FileReader;return a.addEventListener("load",(function(){t.append(c("div",["Text source",["br"],["textarea",{class:"view-text"},[a.result??""]]]))})),a.addEventListener("error",(function(){console.error(a.error),t.append(a.error.message)})),a.readAsBinaryString(e),t})():binaryButton$1(e),e.type.startsWith("video/")?(()=>{const t=URL.createObjectURL(e),a=c("video",{src:t,class:"video",$on:{loadeddata(){URL.revokeObjectURL(t)}}});return["div",[a,["button",{class:"play",$on:{click(e){e.preventDefault(),a.play()}}},["Play"]],["button",{class:"pause",$on:{click(e){e.preventDefault(),a.pause()}}},["Pause"]],["button",{class:"replay",$on:{click(e){e.preventDefault(),a.pause(),a.currentTime=0,a.play()}}},["Replay"]]]]})():"",e.type.startsWith("audio/")?(()=>{const t=URL.createObjectURL(e),a=c("audio",{src:t,class:"audio",$on:{loadeddata(){URL.revokeObjectURL(t)}}});return["div",[a,["button",{class:"play",$on:{click(e){e.preventDefault(),a.play()}}},["Play"]],["button",{class:"pause",$on:{click(e){e.preventDefault(),a.pause()}}},["Pause"]],["button",{class:"replay",$on:{click(e){e.preventDefault(),a.pause(),a.currentTime=0,a.play()}}},["Replay"]]]]})():"","application/pdf"===e.type?(()=>{const t=URL.createObjectURL(e);return c("iframe",{class:"PDF",src:t,$on:{load(){URL.revokeObjectURL(t)}}})})():"",e.type.startsWith("image/")?["img",{class:"imageView",src:URL.createObjectURL(e),$on:{load(){URL.revokeObjectURL(this.src)}}}]:""]],editUI:({typeNamespace:e,specificSchemaObject:t,value:a={}})=>["div",{dataset:{type:"file"},title:t?.description??"File"},[["fieldset",{class:"fileMetaData",$custom:{$setValue(e){const t=this;$e(t,".fileName").value=e.name,$e(t,".size").value=String(e.size),$e(t,".contentType").value=e.type,$e(t,".lastModified").value="number"==typeof e.lastModified?getDateString(e.lastModified):"",$e(t,"button.viewBinary").$value="number"==typeof e.lastModified?e:void 0}}},[["legend",["Current file data"]],["label",["Name ",["input",{size:50,class:"fileName",value:a.name??"",$on:{change(){newFileForBinary($e(this.parentElement?.parentElement,"button.viewBinary"),{name:this.value})}}}]]],["br"],["label",["Size (in bytes) ",["input",{type:"number",step:"1",disabled:!0,class:"size",value:String(a.size)}]]],["br"],["label",["Content type ",["input",{class:"contentType",value:a.type??"",$on:{change(){newFileForBinary($e(this.parentElement?.parentElement,"button.viewBinary"),{type:this.value})}}}]]],["br"],["label",["Last modified date ",["input",{type:"datetime-local",class:"lastModified",step:.001,value:a.lastModified?getDateString(a.lastModified):void 0,$on:{change(){const e=$e(this.parentElement?.parentElement,"button.viewBinary"),t=this.value;newFileForBinary(e,{lastModified:new Date(t).getTime()})}}}]]],["br"],binaryButton$1(a,!0),["button",{class:"clearData",$on:{click(e){e.preventDefault(),this.parentElement.$setValue({name:"",size:"",type:"",lastModified:""})}}},["Clear data"]]]],["fieldset",[["legend",["Supply file through upload"]],["label",["File ",["input",{$on:{change(){if(!this.files)return;const e=this.files[0],t=(this.parentElement?.parentElement)?.previousElementSibling;t.$setValue(e)}},name:`${e}-file`,type:"file"}]]]]],["fieldset",[["legend",["Supply file through recording"]],(()=>{const e=c("select",{class:"device",$on:{async change(){const t=this.nextElementSibling?.nextElementSibling;$e(t,"img.photo").hidden=!0;const a=$e(t,"video.previewMedia"),r=c("video",{class:"previewMedia"});if(a.$stream){a.$stream.getTracks().forEach((e=>{e.stop()})),a.srcObject=null}a.replaceWith(r);const n=$e(e.nextElementSibling,".takeSnapshot"),i=$e(e.nextElementSibling,".recordMedia");$e(e.nextElementSibling?.nextElementSibling,"div.recordedMedia").hidden=!0;const s=$e(t,"canvas.visualizer");let o,l;switch(r.$screenShare=!1,e.value){case"audio-and-video":o={video:!0,audio:!0},r.hidden=!1,n.hidden=!1,i.textContent="Record video/audio";break;case"video":o={video:!0},r.hidden=!1,n.hidden=!1,i.textContent="Record video";break;case"audio":o={audio:!0},r.hidden=!0,n.hidden=!0,i.textContent="Record audio";break;case"screenShare":l={video:!0};case"screenShareAndVideo":l||(l={video:!0,audio:!0}),r.$screenShare=!0,r.hidden=!0,n.hidden=!0,s.hidden=!0;break;default:return}if(o){const e=await getUserMedia(o);if(!e)return void await pe.alert("Error getting user media");if(t.hidden=!1,r.srcObject=e,r.$stream=e,o.video){const e=$e(t,"canvas.recordedImage");r.addEventListener("canplay",(()=>{e.setAttribute("width",String(r.videoWidth)),e.setAttribute("height",String(r.videoHeight))}))}r.addEventListener("loadedmetadata",(()=>{r.play(),o?.audio?(s.hidden=!1,visualize(e,s)):s.hidden=!0}))}else if(l){const e=await startScreenCapture(l);if(!e)return void await pe.alert("Error getting user media");t.hidden=!1,r.srcObject=e,r.$stream=e}}}},[["option",{value:""},["Please choose a device"]]]);return(async()=>{const t=await navigator.mediaDevices.enumerateDevices();let a=!1,r=!1;t.forEach((e=>{switch(e.kind){case"audioinput":a=!0;break;case"videoinput":r=!0}})),a&&c("option",{value:"audio"},["Microphone only"],e),r&&c("option",{value:"video"},["Video camera only"],e),a&&r&&c("option",{value:"audio-and-video"},["Video camera and microphone"],e),c("option",{value:"screenShare"},["Screen share"],e),c("option",{value:"screenShareAndVideo"},["Screen share and microphone"],e)})(),e})()," ",["div",[["button",{class:"recordMedia",$on:{click(e){e.preventDefault();const t=$e(this.parentElement?.nextElementSibling,"video.previewMedia");if(!t.srcObject)return void pe.alert("No stream found to record");const a=this.parentElement?.nextElementSibling;$e(a,"img.photo").hidden=!0;const r="video/webm",n=new MediaRecorder(t.$stream,{mimeType:r});let i=[];n.addEventListener("dataavailable",(e=>{i.push(e.data)}));try{n.start()}catch{return void pe.alert("Error starting media recorder")}n.addEventListener("stop",(()=>{const e=new Blob(i,{type:r}),t=URL.createObjectURL(e),a=$e(this.parentElement?.nextElementSibling,"video.recordedMedia");a.parentElement.hidden=!1,a.src=t,a.addEventListener("loadeddata",(()=>{URL.revokeObjectURL(t)}));const n=new File([e],"placeholder.webm",{type:r});console.log("file",n);const s=this.closest('[data-type="file"]');$e(s,"fieldset.fileMetaData").$setValue(n),i=[]})),this.$mediaRecorder=n}}},["Record media"]],["button",{class:"stopRecording",$on:{click(e){e.preventDefault(),this.previousElementSibling.$mediaRecorder.stop()}}},["Stop recording"]],["button",{class:"takeSnapshot",hidden:!0},{$on:{click(e){e.preventDefault();const t=this.parentElement?.nextElementSibling;$e(t,".recordedMedia").hidden=!0;const a=$e(t,"canvas.recordedImage"),r=a.getContext("2d"),n=$e(t,"video.previewMedia");r.drawImage(n,0,0,a.width,a.height);const i=$e(t,"img.photo");a.toBlob((e=>{if(!e)return void pe.alert("Error converting canvas to Blob");const t=c("img",{class:"photo"}),a=URL.createObjectURL(e);t.addEventListener("load",(()=>{URL.revokeObjectURL(a)}));const r=new File([e],"placeholder.png",{type:e.type});console.log("file",r);const n=this.closest('[data-type="file"]');$e(n,"fieldset.fileMetaData").$setValue(r),t.src=a,i.replaceWith(t)}))}}},["Take and use snapshot as file"]]]],["div",{class:"videoContainer",hidden:!0},[["canvas",{class:"visualizer",hidden:!0}],["br"],["video",{class:"previewMedia"}],["div",[["canvas",{hidden:!0,class:"recordedImage"}],["img",{class:"photo"}]]],["div",{class:"recordedMedia"},[...(()=>{const e=c("video",{class:"recordedMedia"});return[e,["br"],c("button",{class:"play",$on:{click(t){t.preventDefault(),e.play()}}},["Play"]),c("button",{class:"pause",$on:{click(t){t.preventDefault(),e.pause()}}},["Pause"]),c("button",{class:"replay",$on:{click(t){t.preventDefault(),e.pause(),e.currentTime=0,e.play()}}},["Replay"])]})()]]]]]]]]},Ta={option:["FileList"],array:!0,filelist:!0,regexEndings:[",",")"],stringRegexBegin:/^FileList\(/u,stringRegexEnd:/^\)/u,valueMatch:e=>"FileList"===toStringTag(e),toValue(...e){return ta.toValue.apply(this,e)},getValue(...e){return ta.getValue.apply(this,e)},getInput(...e){return ta.getInput.apply(this,e)},viewUI({...e}){return ta.viewUI.call(this,{...e,type:"filelist"})},editUI({...e}){return ta.editUI.call(this,{...e,type:"filelist"})}};function newBlobForBinary(e,t){const a=e.$value,r=new Blob([void 0===t.stringContents?a&&"Blob"===Object.prototype.toString.call(a).slice(8,-1)?a:"":t.stringContents],{type:void 0===t.type?a?.type??"":t.type});return e.$value=r,r}function binaryButton(e,t){return["button",{class:"viewBinary",$custom:{$value:e},$on:{click(e){const t=this;e.preventDefault(),this.$value&&"Blob"===Object.prototype.toString.call(this.$value).slice(8,-1)||newBlobForBinary(t,{});const a=new FileReader;a.addEventListener("load",(async function(){const e=await pe.makeSubmitDialog({submitText:"Save",submit(){const a=$e(e,".view-binary"),r=newBlobForBinary(t,{stringContents:a.value});t.parentElement.$setValue(r),e.close()},children:[["div",["Binary source",["br"],["textarea",{class:"view-binary"},[a.result??""]]]]]})})),a.addEventListener("error",(async function(){console.error(a.error),await pe.alert(a.error.message)})),a.readAsBinaryString(this.$value)}}},[t?"Edit binary data":"View binary data"]]}const Ea={option:["Blob"],stringRegex:/^Blob\((.*)\)$/u,valueMatch:e=>"Blob"===toStringTag(e),toValue(e){const t=JSON.parse(e);return{value:new Blob([t.stringContents],{type:t.type})}},getInput:({root:e})=>$e(e,"button.viewBinary"),setValue({root:e,value:t}){$e(e,"fieldset.blobMetaData").$setValue(t)},getValue({root:e}){return this.getInput({root:e}).$value},viewUI:({value:e,specificSchemaObject:t})=>["div",{dataset:{type:"blob"}},[["b",{class:"emphasis",title:t?.description?"(a Blob)":void 0},[t?.description??"Blob"]],["br"],["br"],["b",["Size (in bytes) "]],String(e.size),["br"],["b",["Content type "]],e.type,["br"],e.type.startsWith("text/")||"application/json"===e.type?(()=>{const t=c("div"),a=new FileReader;return a.addEventListener("load",(function(){t.append(c("div",["Text source",["br"],["textarea",{class:"view-text"},[a.result??""]]]))})),a.addEventListener("error",(function(){console.error(a.error),t.append(a.error.message)})),a.readAsBinaryString(e),t})():binaryButton(e),e.type.startsWith("video/")?(()=>{const t=URL.createObjectURL(e),a=c("video",{src:t,class:"video",$on:{loadeddata(){URL.revokeObjectURL(t)}}});return["div",[a,["button",{class:"play",$on:{click(e){e.preventDefault(),a.play()}}},["Play"]],["button",{class:"pause",$on:{click(e){e.preventDefault(),a.pause()}}},["Pause"]],["button",{class:"replay",$on:{click(e){e.preventDefault(),a.pause(),a.currentTime=0,a.play()}}},["Replay"]]]]})():"",e.type.startsWith("audio/")?(()=>{const t=URL.createObjectURL(e),a=c("audio",{src:t,class:"audio",$on:{loadeddata(){URL.revokeObjectURL(t)}}});return["div",[a,["button",{class:"play",$on:{click(e){e.preventDefault(),a.play()}}},["Play"]],["button",{class:"pause",$on:{click(e){e.preventDefault(),a.pause()}}},["Pause"]],["button",{class:"replay",$on:{click(e){e.preventDefault(),a.pause(),a.currentTime=0,a.play()}}},["Replay"]]]]})():"","application/pdf"===e.type?(()=>{const t=URL.createObjectURL(e);return c("iframe",{class:"PDF",src:t,$on:{load(){URL.revokeObjectURL(t)}}})})():"",e.type.startsWith("image/")?["img",{class:"imageView",src:URL.createObjectURL(e),$on:{load(){URL.revokeObjectURL(this.src)}}}]:""]],editUI:({typeNamespace:e,specificSchemaObject:t,value:a={}})=>["div",{dataset:{type:"blob"},title:t?.description??"Blob"},[["fieldset",{class:"blobMetaData",$custom:{$setValue(e){const t=this;$e(t,".size").value=String(e.size),$e(t,".contentType").value=e.type,$e(t,"button.viewBinary").$value="Blob"===Object.prototype.toString.call(e).slice(8,-1)?e:void 0}}},[["legend",["Current blob data"]],["label",["Size (in bytes) ",["input",{type:"number",step:"1",disabled:!0,class:"size",value:String(a.size)}]]],["br"],["label",["Content type ",["input",{class:"contentType",value:a.type??"",$on:{change(){newBlobForBinary($e(this.parentElement?.parentElement,"button.viewBinary"),{type:this.value})}}}]]],["br"],binaryButton(a,!0),["button",{class:"clearData",$on:{click(e){e.preventDefault(),this.parentElement.$setValue({size:"",type:""})}}},["Clear data"]]]],["fieldset",[["legend",["Supply blob through upload"]],["label",["Blob ",["input",{$on:{change(){if(!this.files)return;const e=this.files[0],t=new Blob([e],{type:e.type}),a=(this.parentElement?.parentElement)?.previousElementSibling;a.$setValue(t)}},name:`${e}-blob`,type:"file"}]]]]],["fieldset",[["legend",["Supply blob through recording"]],(()=>{const e=c("select",{class:"device",$on:{async change(){const t=this.nextElementSibling?.nextElementSibling;$e(t,"img.photo").hidden=!0;const a=$e(t,"video.previewMedia"),r=c("video",{class:"previewMedia"});if(a.$stream){a.$stream.getTracks().forEach((e=>{e.stop()})),a.srcObject=null}a.replaceWith(r);const n=$e(e.nextElementSibling,".takeSnapshot"),i=$e(e.nextElementSibling,".recordMedia");$e(e.nextElementSibling?.nextElementSibling,"div.recordedMedia").hidden=!0;const s=$e(t,"canvas.visualizer");let o,l;switch(r.$screenShare=!1,e.value){case"audio-and-video":o={video:!0,audio:!0},r.hidden=!1,n.hidden=!1,i.textContent="Record video/audio";break;case"video":o={video:!0},r.hidden=!1,n.hidden=!1,i.textContent="Record video";break;case"audio":o={audio:!0},r.hidden=!0,n.hidden=!0,i.textContent="Record audio";break;case"screenShare":l={video:!0};case"screenShareAndVideo":l||(l={video:!0,audio:!0}),r.$screenShare=!0,r.hidden=!0,n.hidden=!0,s.hidden=!0;break;default:return}if(o){const e=await getUserMedia(o);if(!e)return void await pe.alert("Error getting user media");if(t.hidden=!1,r.srcObject=e,r.$stream=e,o.video){const e=$e(t,"canvas.recordedImage");r.addEventListener("canplay",(()=>{e.setAttribute("width",String(r.videoWidth)),e.setAttribute("height",String(r.videoHeight))}))}r.addEventListener("loadedmetadata",(()=>{r.play(),o?.audio?(s.hidden=!1,visualize(e,s)):s.hidden=!0}))}else if(l){const e=await startScreenCapture(l);if(!e)return void await pe.alert("Error getting user media");t.hidden=!1,r.srcObject=e,r.$stream=e}}}},[["option",{value:""},["Please choose a device"]]]);return(async()=>{const t=await navigator.mediaDevices.enumerateDevices();let a=!1,r=!1;t.forEach((e=>{switch(e.kind){case"audioinput":a=!0;break;case"videoinput":r=!0}})),a&&c("option",{value:"audio"},["Microphone only"],e),r&&c("option",{value:"video"},["Video camera only"],e),a&&r&&c("option",{value:"audio-and-video"},["Video camera and microphone"],e),c("option",{value:"screenShare"},["Screen share"],e),c("option",{value:"screenShareAndVideo"},["Screen share and microphone"],e)})(),e})()," ",["div",[["button",{class:"recordMedia",$on:{click(e){e.preventDefault();const t=$e(this.parentElement?.nextElementSibling,"video.previewMedia");if(!t.srcObject)return void pe.alert("No stream found to record");const a=this.parentElement?.nextElementSibling;$e(a,"img.photo").hidden=!0;const r="video/webm",n=new MediaRecorder(t.$stream,{mimeType:r});let i=[];n.addEventListener("dataavailable",(e=>{i.push(e.data)}));try{n.start()}catch{return void pe.alert("Error starting media recorder")}n.addEventListener("stop",(()=>{const e=new Blob(i,{type:r}),t=URL.createObjectURL(e),a=$e(this.parentElement?.nextElementSibling,"video.recordedMedia");a.parentElement.hidden=!1,a.src=t,a.addEventListener("loadeddata",(()=>{URL.revokeObjectURL(t)}));const n=this.closest('[data-type="blob"]');$e(n,"fieldset.blobMetaData").$setValue(e),i=[]})),this.$mediaRecorder=n}}},["Record media"]],["button",{class:"stopRecording",$on:{click(e){e.preventDefault(),this.previousElementSibling.$mediaRecorder.stop()}}},["Stop recording"]],["button",{class:"takeSnapshot",hidden:!0},{$on:{click(e){e.preventDefault();const t=this.parentElement?.nextElementSibling;$e(t,".recordedMedia").hidden=!0;const a=$e(t,"canvas.recordedImage"),r=a.getContext("2d"),n=$e(t,"video.previewMedia");r.drawImage(n,0,0,a.width,a.height);const i=$e(t,"img.photo");a.toBlob((e=>{if(!e)return void pe.alert("Error converting canvas to Blob");const t=c("img",{class:"photo"}),a=URL.createObjectURL(e);t.addEventListener("load",(()=>{URL.revokeObjectURL(a)}));const r=this.closest('[data-type="blob"]');$e(r,"fieldset.blobMetaData").$setValue(e),t.src=a,i.replaceWith(t)}))}}},["Take and use snapshot as blob"]]]],["div",{class:"videoContainer",hidden:!0},[["canvas",{class:"visualizer",hidden:!0}],["br"],["video",{class:"previewMedia"}],["div",[["canvas",{hidden:!0,class:"recordedImage"}],["img",{class:"photo"}]]],["div",{class:"recordedMedia"},[...(()=>{const e=c("video",{class:"recordedMedia"});return[e,["br"],c("button",{class:"play",$on:{click(t){t.preventDefault(),e.play()}}},["Play"]),c("button",{class:"pause",$on:{click(t){t.preventDefault(),e.pause()}}},["Pause"]),c("button",{class:"replay",$on:{click(t){t.preventDefault(),e.pause(),e.currentTime=0,e.play()}}},["Replay"])]})()]]]]]]]]};let Na=0;const $a={option:["DOMException"],stringRegex:/^DOMException\((.*)\)$/u,valueMatch:e=>"DOMException"===toStringTag(e),toValue(e){const{message:t,name:a}=JSON.parse(e);return{value:new DOMException(t,a)}},getInput:({root:e})=>$e(e,"input"),setValue({root:e,value:t}){$e(e,".message").value=t.message,$e(e,".name").value=t.name},getValue({root:e}){const t=$e(e,".message").value,a=$e(e,".name").value;return new DOMException(t,a)},viewUI:({value:e,specificSchemaObject:t})=>["div",{dataset:{type:"domexception"},title:t?.description??"(a `DOMException`)"},[["b",["Message "]],e.message,["br"],["b",["Name "]],e.name,["br"],["b",["Code "]],e.code]],editUI:({typeNamespace:e,specificSchemaObject:t,value:a=""})=>(Na++,["div",{dataset:{type:"domexception"},title:t?.description??"DOMException"},[["label",["Name: ",["input",{class:"name",list:`domExceptionNames-${Na}`,name:`${e}-domexception-name`,value:a?.name??"",size:30,placeholder:"(Optional predefined name)"}]]],["datalist",{id:`domExceptionNames-${Na}`,class:"predefinedNames"},["IndexSizeError","HierarchyRequestError","WrongDocumentError","InvalidCharacterError","NoModificationAllowedError","NotFoundError","NotSupportedError","InvalidStateError","InUseAttributeError","SyntaxError","InvalidModificationError","NamespaceError","InvalidAccessError","TypeMismatchError","SecurityError","NetworkError","AbortError","URLMismatchError","QuotaExceededError","TimeoutError","InvalidNodeTypeError","DataCloneError","EncodingError","NotReadableError","UnknownError","ConstraintError","DataError","TransactionInactiveError","ReadOnlyErrorVersionError","OperationError","NotAllowedError"].map((e=>["option",[e]]))],["br"],["label",["Message: ",["input",{class:"message",name:`${e}-domexception-message`,value:a?.message??""}]]]]])};let _a=0;const Oa={option:["DOMRect"],childTypes:["domrectreadonly"],stringRegex:/^(?<domRectClass>DOMRect|DOMRectReadOnly)\((?<innerContent>.*)\)$/u,valueMatch:e=>["DOMRect","DOMRectReadOnly"].includes(toStringTag(e)),toValue(e,t){const{groups:{domRectClass:a}={}}=t.match,{x:r,y:n,width:i,height:s}=JSON.parse(e);return{value:new("DOMRect"===a?DOMRect:DOMRectReadOnly)(r,n,i,s)}},getInput:({root:e})=>$e(e,"input"),setValue({root:e,value:t}){$e(e,".x").value=String(t.x),$e(e,".y").value=String(t.y),$e(e,".width").value=String(t.width),$e(e,".height").value=String(t.height),"DOMRect"===toStringTag(t)?$e(e,".domrect-readonly-readwrite").checked=!0:$e(e,".domrect-readonly-readonly").checked=!0},getValue({root:e}){const t=Number($e(e,".x").value),a=Number($e(e,".y").value),r=Number($e(e,".width").value),n=Number($e(e,".height").value);return new($e(e,".domrect-readonly-readwrite").checked?DOMRect:DOMRectReadOnly)(t,a,r,n)},viewUI({value:e,specificSchemaObject:t}){const a="DOMRect"===toStringTag(e);return["div",{dataset:{type:"domrect"},title:t?.description?`(a \`${a?"DOMRect":"DOMRectReadOnly"}\`)`:void 0},[["b",{class:"emphasis"},[t?.description??(a?"DOMRect":"DOMRectReadOnly")]],["br"],["b",["x "]],e.x,["br"],["b",["y "]],e.y,["br"],["b",["width "]],e.width,["br"],["b",["height "]],e.height]]},editUI({typeNamespace:e,specificSchemaObject:t,value:a={x:"",y:"",width:"",height:""}}){_a++;const r="any";return["div",{dataset:{type:"domrect"},title:t?.description??"DOMRect"},[["div",[["label",[["input",{type:"radio",class:"domrect-readonly-readwrite",name:`${e}-domrect-readonly-${_a}`,value:"readwrite",checked:"DOMRectReadOnly"!==toStringTag(a)}],"Readwrite"]]," ",["label",[["input",{type:"radio",class:"domrect-readonly-readonly",name:`${e}-domrect-readonly-${_a}`,value:"readonly",checked:"DOMRectReadOnly"===toStringTag(a)}],"Read-only"]]]],["label",["x: ",["input",{type:"number",step:r,class:"x",name:`${e}-domrect-x`,value:a.x}]]],["br"],["label",["y: ",["input",{type:"number",step:r,class:"y",name:`${e}-domrect-y`,value:a.y}]]],["br"],["label",["width: ",["input",{type:"number",step:r,class:"width",name:`${e}-domrect-width`,value:a.width}]]],["br"],["label",["height: ",["input",{type:"number",step:r,class:"height",name:`${e}-domrect-height`,value:a.height}]]]]]}};let ka=0;const Aa={option:["DOMPoint"],childTypes:["dompointreadonly"],stringRegex:/^(?<domPointClass>DOMPoint|DOMPointReadOnly)\((?<innerContent>.*)\)$/u,valueMatch:e=>["DOMPoint","DOMPointReadOnly"].includes(toStringTag(e)),toValue(e,t){const{groups:{domPointClass:a}={}}=t.match,{x:r,y:n,z:i,w:s}=JSON.parse(e);return{value:new("DOMPoint"===a?DOMPoint:DOMPointReadOnly)(r,n,i,s)}},getInput:({root:e})=>$e(e,"input"),setValue({root:e,value:t}){$e(e,".x").value=String(t.x),$e(e,".y").value=String(t.y),$e(e,".z").value=String(t.z),$e(e,".w").value=String(t.w),"DOMPoint"===toStringTag(t)?$e(e,".dompoint-readonly-readwrite").checked=!0:$e(e,".dompoint-readonly-readonly").checked=!0},getValue({root:e}){const t=Number($e(e,".x").value),a=Number($e(e,".y").value),r=Number($e(e,".z").value),n=Number($e(e,".w").value);return new($e(e,".dompoint-readonly-readwrite").checked?DOMPoint:DOMPointReadOnly)(t,a,r,n)},viewUI({value:e,specificSchemaObject:t}){const a="DOMPoint"===toStringTag(e);return["div",{dataset:{type:"dompoint"},title:t?.description?`(a \`${a?"DOMPoint":"DOMPointReadOnly"}\`)`:void 0},[["b",{class:"emphasis"},[t?.description??(a?"DOMPoint":"DOMPointReadOnly")]],["br"],["b",["x "]],e.x,["br"],["b",["y "]],e.y,["br"],["b",["z "]],e.z,["br"],["b",["w "]],e.w]]},editUI({typeNamespace:e,specificSchemaObject:t,value:a={x:"",y:"",z:"",w:""}}){ka++;const r="any";return["div",{dataset:{type:"dompoint"},title:t?.description??"DOMPoint"},[["div",[["label",[["input",{type:"radio",class:"dompoint-readonly-readwrite",name:`${e}-dompoint-readonly-${ka}`,value:"readwrite",checked:"DOMPointReadOnly"!==toStringTag(a)}],"Readwrite"]]," ",["label",[["input",{type:"radio",class:"dompoint-readonly-readonly",name:`${e}-dompoint-readonly-${ka}`,value:"readonly",checked:"DOMPointReadOnly"===toStringTag(a)}],"Read-only"]]]],["label",["x: ",["input",{type:"number",step:r,class:"x",name:`${e}-dompoint-x`,value:a.x}]]],["br"],["label",["y: ",["input",{type:"number",step:r,class:"y",name:`${e}-dompoint-y`,value:a.y}]]],["br"],["label",["z: ",["input",{type:"number",step:r,class:"z",name:`${e}-dompoint-z`,value:a.z}]]],["br"],["label",["w: ",["input",{type:"number",step:r,class:"w",name:`${e}-dompoint-w`,value:a.w}]]]]]}};let Ca=0;const ja={option:["DOMMatrix"],childTypes:["dommatrixreadonly"],stringRegex:/^(?<domMatrixClass>DOMMatrix|DOMMatrixReadOnly)\((?<innerContent>.*)\)$/u,valueMatch:e=>["DOMMatrix","DOMMatrixReadOnly"].includes(toStringTag(e)),toValue(e,t){const{groups:{domMatrixClass:a}={}}=t.match,r=JSON.parse(e),n="DOMMatrix"===a?DOMMatrix:DOMMatrixReadOnly;return{value:Object.hasOwn(r,"a")?new n([r.a,r.b,r.c,r.d,r.e,r.f]):new n([r.m11,r.m12,r.m13,r.m14,r.m21,r.m22,r.m23,r.m24,r.m31,r.m32,r.m33,r.m34,r.m41,r.m42,r.m43,r.m44])}},getInput:({root:e})=>$e(e,"input"),setValue({root:e,value:t}){const{is2D:a}=t;$e(e,".d2").checked=a,$e(e,".d3").checked=!a,$e(e,".holder2d").hidden=!a,$e(e,".holder3d").hidden=a,a?($e(e,".a").value=t.a,$e(e,".b").value=t.b,$e(e,".c").value=t.c,$e(e,".d").value=t.d,$e(e,".e").value=t.e,$e(e,".f").value=t.f):($e(e,".m11").value=t.m11,$e(e,".m12").value=t.m12,$e(e,".m13").value=t.m13,$e(e,".m14").value=t.m14,$e(e,".m21").value=t.m21,$e(e,".m22").value=t.m22,$e(e,".m23").value=t.m23,$e(e,".m24").value=t.m24,$e(e,".m31").value=t.m31,$e(e,".m32").value=t.m32,$e(e,".m33").value=t.m33,$e(e,".m34").value=t.m34,$e(e,".m41").value=t.m41,$e(e,".m42").value=t.m42,$e(e,".m43").value=t.m43,$e(e,".m44").value=t.m44),"DOMMatrix"===toStringTag(t)?$e(e,".dommatrix-readonly-readwrite").checked=!0:$e(e,".dommatrix-readonly-readonly").checked=!0},getValue({root:e}){const t=$e(e,".dommatrix-readonly-readwrite").checked?DOMMatrix:DOMMatrixReadOnly,a=$e(e,".a").value;if(a){return new t([Number(a),Number($e(e,".b").value),Number($e(e,".c").value),Number($e(e,".d").value),Number($e(e,".e").value),Number($e(e,".f").value)])}return new t([Number($e(e,".m11").value),Number($e(e,".m12").value),Number($e(e,".m13").value),Number($e(e,".m14").value),Number($e(e,".m21").value),Number($e(e,".m22").value),Number($e(e,".m23").value),Number($e(e,".m24").value),Number($e(e,".m31").value),Number($e(e,".m32").value),Number($e(e,".m33").value),Number($e(e,".m34").value),Number($e(e,".m41").value),Number($e(e,".m42").value),Number($e(e,".m43").value),Number($e(e,".m44").value)])},viewUI({value:e,specificSchemaObject:t}){const a="DOMMatrix"===toStringTag(e);return["div",{dataset:{type:"dommatrix"}},[["b",{class:"emphasis",title:t?.description?`(a \`${a?"DOMMatrix":"DOMMatrixReadOnly"}\`)`:void 0},[t?.description??(a?"DOMMatrix":"DOMMatrixReadOnly")]],e.is2D?["div",[["b",["a "]],e.a,["br"],["b",["b "]],e.b,["br"],["b",["c "]],e.c,["br"],["b",["d "]],e.d,["br"],["b",["e "]],e.e,["br"],["b",["f "]],e.f]]:["div",[["b",["m11 "]],e.m11,["br"],["b",["m12 "]],e.m12,["br"],["b",["m13 "]],e.m13,["br"],["b",["m14 "]],e.m14,["br"],["b",["m21 "]],e.m21,["br"],["b",["m22 "]],e.m22,["br"],["b",["m23 "]],e.m23,["br"],["b",["m24 "]],e.m24,["br"],["b",["m31 "]],e.m31,["br"],["b",["m32 "]],e.m32,["br"],["b",["m33 "]],e.m33,["br"],["b",["m34 "]],e.m34,["br"],["b",["m41 "]],e.m41,["br"],["b",["m42 "]],e.m42,["br"],["b",["m43 "]],e.m43,["br"],["b",["m44 "]],e.m44]]]]},editUI({typeNamespace:e,specificSchemaObject:t,value:a={}}){Ca++;const{is2D:r}=a;return["div",{dataset:{type:"dommatrix"},title:t?.description??"DOMMatrix"},[["div",[["label",[["input",{type:"radio",class:"dommatrix-readonly-readwrite",name:`${e}-dommatrix-readonly-${Ca}`,value:"readwrite",checked:"DOMMatrixReadOnly"!==toStringTag(a)}],"Readwrite"]]," ",["label",[["input",{type:"radio",class:"dommatrix-readonly-readonly",name:`${e}-dommatrix-readonly-${Ca}`,value:"readonly",checked:"DOMMatrixReadOnly"===toStringTag(a)}],"Read-only"]]]],["div",{$on:{click(e){const{target:t}=e;if("radio"!==t.type)return;const a=this.parentElement;$e(a,".holder2d").hidden="3d"===t.value,$e(a,".holder3d").hidden="2d"===t.value}}},[["label",["2d",["input",{class:"d2",type:"radio",name:`${e}-dommatrix-dimension-${Ca}`,value:"2d",checked:Boolean(r)}]]]," ",["label",["3d",["input",{class:"d3",type:"radio",name:`${e}-dommatrix-dimension-${Ca}`,value:"3d",checked:!r}]]]]],["div",{class:"holder2d",hidden:!r},["a","b","c","d","e","f"].flatMap((t=>[["br"],["label",[t+": ",["input",{type:"number",step:"any",class:t,name:`${e}-dommatrix-${t}`,value:a[t]??""}]]]])).slice(1)],["div",{class:"holder3d",hidden:Boolean(r)},["m11","m12","m13","m14","m21","m22","m23","m24","m31","m32","m33","m34","m41","m42","m43","m44"].flatMap((t=>[["br"],["label",[t+": ",["input",{type:"number",step:"any",class:t,name:`${e}-dommatrix-${t}`,value:a[t]??""}]]]])).slice(1)]]]}},Ra=["setInt8","setUint8","setInt16","setUint16","setInt32","setUint32","setFloat32","setFloat64","setBigInt64","setBigUint64"],Za=["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"],getMinMaxForTypedArray=e=>{switch(e){case"Int8Array":return{min:-128,max:127};case"Uint8Array":case"Uint8ClampedArray":return{min:0,max:255};case"Int16Array":return{min:-32768,max:32767};case"Uint16Array":return{min:0,max:65535};case"Int32Array":return{min:-2147483648,max:2147483647};case"Uint32Array":return{min:0,max:4294967295};case"Float32Array":return{min:-34e37,max:34e37};case"Float64Array":return{min:-Infinity,max:Infinity};case"BigInt64Array":return{min:-(2**63),max:2**63-1};case"BigUint64Array":return{min:0,max:2**64-1};default:throw new Error("Unexpected typed array type")}},getTypedArray=e=>{switch(e){case"Int8Array":return Int8Array;case"Uint8Array":return Uint8Array;case"Uint8ClampedArray":return Uint8ClampedArray;case"Int16Array":return Int16Array;case"Uint16Array":return Uint16Array;case"Int32Array":return Int32Array;case"Uint32Array":return Uint32Array;case"Float32Array":return Float32Array;case"Float64Array":return Float64Array;case"BigInt64Array":return BigInt64Array;case"BigUint64Array":return BigUint64Array;default:throw new Error("Unexpected type")}},Va=new Set(["ArrayBuffer","DataView","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"]);let Ma=0;const Pa={option:["Buffer source (ArrayBuffer, DataView, TypedArrays)"],childTypes:["arraybuffer","dataview","int8array","uint8array","uint8clampedarray","int16array","uint16array","int32array","uint32array","float32array","float64array","bigint64array","biguint64array"],stringRegex:/^(?<bufferSourceClass>ArrayBuffer|DataView|(?:Int8|Uint8|Uint8Clamped|Int16|Uint16|Int32|Uint32|Float32|Float64|BigInt64|BigUint64)Array)\((?<innerContent>.*)\)$/u,valueMatch:e=>Va.has(toStringTag(e)),toValue(e,t){const{groups:{bufferSourceClass:a}={}}=t.match,r=JSON.parse(e),{byteLength:n,maxByteLength:i,byteOffset:s,dataViewByteOffset:o,dataViewByteLength:c,length:l}=r,u=new ArrayBuffer(n,{maxByteLength:i});let d,p,m;return(a.endsWith("Array")||"typedArray"in r)&&(p=getTypedArray(r.typedArray??a),d=new p(u,s,l),"set"in r&&(r.set[0].forEach(((e,t)=>{"string"==typeof e&&(r.set[0][t]=BigInt(e))})),d.set(...r.set))),("DataView"===a||Ra.some((e=>e in r)))&&(m=new DataView(u,o,c),Ra.forEach((e=>{r[e]?.forEach((t=>{"string"==typeof t[1]&&(t[1]=BigInt(t[1])),m[e](...t)}))}))),{value:"ArrayBuffer"===a?u:"DataView"===a?m:d}},getInput:({root:e})=>$e(e,".byteLength"),setValue({root:e,value:t}){const a=toStringTag(t);if("ArrayBuffer"===a||"DataView"===a)$e(e,`[value=${a}].buffersource-returnType`)?.click();else{$e(e,"[value=TypedArray].buffersource-returnType")?.click();const t=$e(e,".buffersource-typedArrays");t.value=a,t.dispatchEvent(new Event("change"))}const r=$e(e,".byteLength");r.$value=t;const n="ArrayBuffer"===a?t:t.buffer;r.value=n.byteLength,r.dispatchEvent(new Event("change"));const i=$e(e,".maxByteLength");if(i.value=n.maxByteLength,i.dispatchEvent(new Event("change")),"DataView"===a){const a=$e(e,".dataViewByteLength");a.value=t.byteLength,a.dispatchEvent(new Event("change"));const r=$e(e,".dataViewByteOffset");r.value=t.byteOffset,r.dispatchEvent(new Event("change"))}else if("ArrayBuffer"!==a){const a=$e(e,".typedArrayByteOffset");a.value=t.byteOffset,a.dispatchEvent(new Event("change"));const r=$e(e,".typedArrayLength");r.value=t.length,r.dispatchEvent(new Event("change"))}},getValue({root:e}){return this.getInput({root:e}).$value},viewUI({value:e,specificSchemaObject:t}){const a=toStringTag(e),r="ArrayBuffer"===a?e:e.buffer;return["div",{dataset:{type:"buffersource"}},[["b",{class:"emphasis",title:t?.description?/^[aeiou]/iu.test(a)?`(an ${a})`:`(a ${a})`:void 0},[t?.description??a]],["br"],["b",["Buffer byte length: "]],r.byteLength,["br"],["b",["Buffer max byte length: "]],r.maxByteLength,..."DataView"===a?[["br"],["b",["Data View byte length: "]],e.byteLength,["br"],["b",["Data View byte offset: "]],e.byteOffset]:[""],..."DataView"!==a&&"ArrayBuffer"!==a?[["br"],["b",["Typed Array byte offset: "]],e.byteOffset,["br"],["b",["Typed Array length: "]],e.length]:[""],["br"],["button",{class:"buffersource-viewData",$on:{async click(e){e.preventDefault();const t=await pe.makeCancelDialog({children:[["select",{class:"buffersource-typedArrays-view","aria-label":"Typed Arrays",$on:{change(){const e=this.value,t=new(getTypedArray(e))(r),a=$e(this.parentElement,".typedArrayArea");a.textContent="",a.append(...Array.from({length:t.length},((e,a)=>c("span",[["b",[a]]," ",["span",[t[a]?String(t[a]):"0"]]," "]))))}}},Za.map((e=>["option",{selected:a===e||void 0},[e]]))],["div",{class:"typedArrayArea"}]]});$e(t,".buffersource-typedArrays-view").dispatchEvent(new Event("change"))}}},["View data"]]]]},editUI({typeNamespace:e,specificSchemaObject:t,value:a}){Ma++;const r=c("div",{dataset:{type:"buffersource"},title:t?.description??"BufferSource"},[["fieldset",{class:"returnType",$on:{change(){this.$buildInstances()}},$custom:{$buildInstances(){const t=this.parentElement,{value:a}=$e(this,`[name=${e}-buffersource-returnType-${Ma}]:checked`),r=$e(t,".byteLength"),n=Number.parseInt(r.value),i=Number.parseInt($e(t,".maxByteLength").value),s=new ArrayBuffer(n,i?{maxByteLength:i}:void 0),o=$e(t,".dataViewByteOffset").value,c=o?Number.parseInt(o):0,l=$e(t,".dataViewByteLength").value,u=l?Number.parseInt(l):void 0,d=new DataView(s,c,u),{value:p}=$e(t,".buffersource-typedArrays-init"),m=getTypedArray(p),y=$e(t,".typedArrayByteOffset").value,h=y?Number.parseInt(y):0,f=$e(t,".typedArrayLength").value,g=f?Number.parseInt(f):n,v=new m(s,h,g);r.$dataView=d,r.$typedArray=v;const b=$$e(t,".typedArrayArea .typedArrayValue").map((e=>m.name.startsWith("Big")?BigInt(e.value):Number(e.value)));switch(r.$typedArray.set(b,0),a){case"ArrayBuffer":r.$value=s;break;case"DataView":r.$value=d;break;default:r.$value=v}}}},[["legend",["Return type"]],["label",{$on:{click(){$e(this.parentElement,".buffersource-typedArrays").hidden=!0,$e(this?.parentElement?.parentElement,".buffersource-typedArrays-init").hidden=!1}}},[["input",{type:"radio",class:"buffersource-returnType buffersource-returnType-arraybuffer",name:`${e}-buffersource-returnType-${Ma}`,checked:!0,value:"ArrayBuffer"}],"ArrayBuffer"]]," ",["label",{$on:{click(){$e(this.parentElement,".buffersource-typedArrays").hidden=!0,$e(this?.parentElement?.parentElement,".buffersource-typedArrays-init").hidden=!1}}},[["input",{type:"radio",class:"buffersource-returnType buffersource-returnType-dataview",name:`${e}-buffersource-returnType-${Ma}`,value:"DataView"}],"DataView"]]," ",["label",{$on:{click(){$e(this.parentElement,".buffersource-typedArrays").hidden=!1,$e(this?.parentElement?.parentElement,".buffersource-typedArrays-init").hidden=!0}}},[["input",{type:"radio",class:"buffersource-returnType buffersource-returnType-typedarray",name:`${e}-buffersource-returnType-${Ma}`,value:"TypedArray"}],"Typed Array"]]," ",["select",{hidden:!0,class:"buffersource-typedArrays","aria-label":"Typed Arrays",$on:{change(e){const t=this.parentElement?.parentElement,a=$e(t,".buffersource-typedArrays-init");a.value=this.value;if(!$e(t,".typedArrayLength").$checkBufferBounds(e))return;a.$setMinsAndMaxes(this.value),a.$checkTypedArrayByteLength(e);$e(this?.parentElement?.parentElement,".typedArrayByteOffset").$checkByteOffsetMultiple(e)}}},Za.map((e=>["option",[e]]))]]],["fieldset",{$on:{change(){this.previousElementSibling.$buildInstances()}}},[["legend",["Construction options"]],["fieldset",[["legend",["ArrayBuffer"]],["label",["Byte length ",["input",{class:"byteLength",type:"number",step:"1",size:"4",pattern:String.raw`\d+`,min:0,$custom:{$value:a??new ArrayBuffer(0)},$on:{change(e){const t=this,a=t.parentElement?.parentElement?.parentElement?.parentElement;if(!$e(a,".typedArrayLength").$checkBufferBounds(e))return;const r=$e(t.parentElement?.parentElement,".maxByteLength"),n=t.value;if(Number.parseInt(n)>Number.MAX_SAFE_INTEGER)return t.setCustomValidity("The ArrayBuffer length exceeds the maximum allowable size"),e.stopPropagation(),void t.reportValidity();t.setCustomValidity(""),t.reportValidity(),Number.parseInt(n)>Number.parseInt(r.value)&&(r.value=n);const i=t.parentElement?.parentElement?.parentElement;$e(i,".dataViewByteLength").$checkDataViewByteLength(e),$e(i.parentElement,".buffersource-typedArrays-init").$checkTypedArrayByteLength(e)}}}]]]," ",["label",["Max byte length ",["input",{class:"maxByteLength",type:"number",step:"1",size:"4",pattern:String.raw`\d+`,min:0,$on:{change(e){const t=this,a=$e(t.parentElement?.parentElement,".byteLength"),r=t.value;Number.parseInt(r)<Number.parseInt(a.value)?(t.setCustomValidity("The max value cannot be less than the byte length"),e.stopPropagation()):t.setCustomValidity(""),t.reportValidity()}}}]]]]],["fieldset",[["legend",["DataView"]],["label",["Byte length ",["input",{class:"dataViewByteLength",type:"number",step:"1",size:"4",pattern:String.raw`\d+`,min:0,$custom:{$checkDataViewByteLength(e){const t=this,a=t.parentElement?.parentElement?.parentElement,r=Number.parseInt($e(a,".dataViewByteOffset").value)||0,n=$e(a,".byteLength").value,i=n?Number.parseInt(n):0;r+(t.value?Number.parseInt(t.value):i)>i?(t.setCustomValidity("The DataView byte length and offset exceed the buffer's byte length"),e.stopPropagation()):t.setCustomValidity(""),t.reportValidity()}},$on:{change(e){this.$checkDataViewByteLength(e)}}}]]]," ",["label",["Byte offset ",["input",{class:"dataViewByteOffset",type:"number",step:"1",size:"4",pattern:String.raw`\d+`,min:0,$on:{change(e){const t=this.parentElement?.parentElement?.parentElement;$e(t,".dataViewByteLength").$checkDataViewByteLength(e)}}}]]]]],["fieldset",[["legend",["Typed array"]],["label",["Byte offset ",["input",{class:"typedArrayByteOffset",type:"number",step:"1",size:"4",pattern:String.raw`\d+`,min:0,max:2**53-1,$custom:{$checkByteOffsetMultiple(e){const t=this,a=t.parentElement?.parentElement?.parentElement?.parentElement,{value:r}=$e(a,".buffersource-typedArrays-init"),n=getTypedArray(r);Number.parseInt(t.value)%n.BYTES_PER_ELEMENT?(t.setCustomValidity(`Byte offset must be a multiple of the typed array's bytes-per-element size (${n.BYTES_PER_ELEMENT})`),e.stopPropagation()):t.setCustomValidity(""),t.reportValidity()}},$on:{change(e){const t=this.parentElement?.parentElement?.parentElement?.parentElement;$e(t,".typedArrayLength").$checkBufferBounds(e)&&this.$checkByteOffsetMultiple(e)}}}]]]]]]],["fieldset",[["legend",["Typed Array initialization (optional)"]],["select",{class:"buffersource-typedArrays-init","aria-label":"Typed Arrays",$custom:{$setMinsAndMaxes(e){const{min:t,max:a}=getMinMaxForTypedArray(e);$$e(this.parentElement,".typedArrayValue").forEach((r=>{r.className="typedArrayValue typedArray-"+e,r.min=String(t),r.max=String(a)}))},$checkTypedArrayByteLength(e){const t=getTypedArray(this.value),a=$e(this.parentElement?.parentElement,".byteLength");(a.value?Number.parseInt(a.value):0)%t.BYTES_PER_ELEMENT?(a.setCustomValidity(`Array buffer must be a multiple of the typed array's bytes-per-element size (${t.BYTES_PER_ELEMENT})`),e.stopPropagation()):a.setCustomValidity(""),a.reportValidity()}},$on:{change(e){const t=this,a=t.parentElement?.parentElement?.parentElement;$e(this.parentElement?.parentElement,".buffersource-typedArrays").value=t.value;if(!$e(a,".typedArrayLength").$checkBufferBounds(e))return;t.$checkTypedArrayByteLength(e),t.$setMinsAndMaxes(t.value);$e(t?.parentElement?.parentElement,".typedArrayByteOffset").$checkByteOffsetMultiple(e),$e(this.parentElement?.parentElement,".returnType").$buildInstances()}}},Za.map((e=>["option",[e]]))]," ",["label",["Array length: ",["input",{class:"typedArrayLength",type:"number",step:"1",size:"4",pattern:String.raw`\d+`,min:0,$custom:{$checkBufferBounds(e){const t=this,a=t.parentElement?.parentElement?.parentElement,r=$e(a,".byteLength").value,n=r?Number.parseInt(r):0,i=t.value?Number.parseInt(t.value):n,{value:s}=$e(a,".buffersource-typedArrays-init"),o=getTypedArray(s),c=$e(a,".typedArrayByteOffset").value;return(c?Number.parseInt(c):0)+i*o.BYTES_PER_ELEMENT>n?(t.setCustomValidity("The byte offset and the length times bytes per element is greater than the buffer length"),e.stopPropagation(),t.reportValidity(),!1):(t.setCustomValidity(""),t.reportValidity(),!0)},$buildTypedArray(){const e=this,t=Number.parseInt(e.value),a=e.parentElement?.parentElement,r=e.parentElement?.parentElement?.parentElement,n=$e(r,".byteLength"),i=$e(a,".typedArrayArea");i.addEventListener("change",(e=>{const t=e.target;n.$typedArray.set(["true"===t.dataset.bigint?BigInt(t.value):Number(t.value)],Number.parseInt(t.dataset.key))}));const{value:s}=$e(a,".buffersource-typedArrays-init"),{min:o,max:l}=getMinMaxForTypedArray(s);i.textContent="",i.append(...Array.from({length:t},((e,t)=>c("label",[t," ",["input",{class:"typedArrayValue typedArray-"+s,dataset:{key:t,bigint:String(s.startsWith("BigInt"))},type:"number",step:"1",pattern:s.startsWith("Float")?String.raw`\d+(?:\.\d+)?`:String.raw`\d+`,value:n.$typedArray[t]?String(n.$typedArray[t]):"0",min:o,max:l}]," "]))))}},$on:{change(e){const t=this,a=this.parentElement?.parentElement;if(!t.$checkBufferBounds(e))return;const{value:r}=$e(a,".buffersource-typedArrays-init"),n=Number.parseInt(t.value);try{new(getTypedArray(r))(n)}catch{return t.setCustomValidity("Typed Array length is too long"),e.stopPropagation(),void t.reportValidity()}t.setCustomValidity(""),t.reportValidity(),$e(this.parentElement?.parentElement?.parentElement,".returnType").$buildInstances(),t.$buildTypedArray()}}}],["div",{class:"typedArrayArea"}]]]]],["fieldset",[["legend",["DataView initialization (optional)"]],["select",{class:"dataViewMethod","aria-label":"Data View methods",$on:{change(){const e=$e(this.parentElement,".dataViewArea"),t=this.value,a=t.slice(3)+"Array";e.textContent="",e.append(c("label",["Byte offset ",["input",{type:"number",class:"dataViewSetByteOffset",step:"1",size:"4",pattern:String.raw`\d+`}]])," ",c("label",["Value ",["input",{type:"number",step:"1",size:"4",pattern:String.raw`\d+`,class:"typedArrayValue typedArray-"+a,...getMinMaxForTypedArray(a)}]]),"setInt8"===t||"setUint8"===t?"":c("label",[["input",{class:"littleEndian",type:"checkbox"}],"Little endian"])," ",c("button",{$on:{click(e){e.preventDefault();const t=this.parentElement,a=t.previousElementSibling?.value,r=Number.parseInt($e(t,".dataViewSetByteOffset").value),n=$e(t,".typedArrayValue").value,i=$e(t,".littleEndian")?.checked,s=$e(t?.parentElement?.parentElement,".byteLength");"setBigInt64"===a||"setBigUint64"===a?s.$dataView[a](r,BigInt(n),i):s.$dataView[a](r,Number(n),i);$e(t.parentElement?.parentElement,".typedArrayLength").$buildTypedArray()}}},["Set"]))}}},[["option",{value:""},["(Select a data view method)"]],...Ra.map((e=>["option",[e]]))]]," ",["div",{class:"dataViewArea"}]]]]);if(this.setValue&&a)this.setValue({root:r,value:a});else{$e(r,".byteLength").$value=new ArrayBuffer(0)}return[r]}},Ua={option:["Non-editable"],valueMatch:()=>!0,getInput:({root:e})=>$e(e,"button"),setValue({root:e,value:t}){this.getInput({root:e}).$value=t,$e(e,".stringTag").textContent=void 0===t?"(None)":toStringTag(t)},getValue({root:e}){return this.getInput({root:e}).$value},validate({root:e}){return{message:"The non-editable type is only for passing on pre-existing content that is unknown or currently unsupported",valid:void 0!==this.getInput({root:e}).$value}},viewUI({value:e,specificSchemaObject:t}){const a=toStringTag(e);return["div",{dataset:{type:"resurrectable"}},[["b",{class:"emphasis",title:t?.description?`(a non-editable ${a})`:void 0},[t?.description??"Non-editable"]],["span",{title:"There is no current support for editing this element's type, but its contents will be passed on transparently."},["?"]],["b",["String tag: "]],a]]},editUI:({typeNamespace:e,specificSchemaObject:t,value:a})=>["div",{dataset:{type:"resurrectable"},title:t?.description??"Non-editable"},[["a",{href:"javascript:void(0)",$on:{click(e){e.preventDefault()}},title:"There is no current support for editing this element's type, but its contents will be passed on transparently."},["?"]]," ",["button",{$on:{click(e){e.preventDefault(),console.log(this.$value)}},name:`${e}-resurrectable`,$custom:{$value:a}},["Non-editable"]],["br"],["b",["String tag: "]],["span",{class:"stringTag"},[a?toStringTag(a):"(None)"]]]]},Ba={stringRegex:/^never$/u,option:["Never"],valueMatch:()=>!1,toValue(){throw new Error("Cannot convert to value")},getValue(){return this.toValue("")},viewUI:({specificSchemaObject:e})=>["i",{dataset:{type:"never"},title:e?.description??"(a `never`)"},["never"]],getInput:({root:e})=>$e(e,"input"),editUI:({typeNamespace:e})=>["div",{dataset:{type:"never"}},[["label",["Never (no value present here)",["input",{type:"checkbox",name:`${e}-never`,hidden:!0}]]]]]},Da={option:["Catch"],stringRegex:/^catch\((.*)\)$/u,valueMatch:e=>["number","string"].includes(typeof e),toValue:e=>({value:'"'===e.charAt(0)?e.slice(1,-1):Number(e)}),getInput:({root:e})=>$e(e,"input,textarea"),setValue({root:e,value:t}){setTimeout((()=>{this.getInput({root:e}).value=t}))},getValue({root:e}){return this.getInput({root:e}).value},viewUI:({specificSchemaObject:e,types:t,resultType:a,typeNamespace:r,topRoot:n,format:i,bringIntoFocus:s,buildTypeChoices:o,replaced:c,value:l})=>["span",{dataset:{type:"catch"},title:e?.description??"(a catch)"},[["b",["Catch"]],["br"],"Default value",["br"],["div",{class:"defaultValue"},[t.getUIForModeAndType({readonly:!0,specificSchemaObject:e?.innerType,hasValue:!0,value:l,resultType:a,typeNamespace:r,type:e?.innerType?.type,topRoot:n,bringIntoFocus:s,buildTypeChoices:o,format:i,replaced:c})]],"Catch value",["br"],["div",{class:"catchValue"},[t.getUIForModeAndType({readonly:!0,specificSchemaObject:{...e?.innerType,description:"(catch value)"},hasValue:!0,value:e.value,resultType:a,typeNamespace:r,type:e?.innerType?.type,topRoot:n,bringIntoFocus:s,buildTypeChoices:o,format:i,replaced:c})]]]],editUI({format:e,type:t,buildTypeChoices:a,specificSchemaObject:r,topRoot:n,schemaContent:i,typeNamespace:s,value:o}){const c=r?.value;return["div",{dataset:{type:"catch"},title:r?.description??"(a `catch`)"},[["label",[["b",{title:String(c)},["Value"]]," ",...a({topRoot:n,format:e,setValue:!0,value:o??c,schemaOriginal:i,schemaContent:r?.innerType,state:t,typeNamespace:s}).domArray]]]]}},La={option:["Native enum"],stringRegex:/^nativeEnum\((.*)\)$/u,valueMatch:e=>["number","string"].includes(typeof e),toValue(e,t){const a='"'===e.charAt(0)?e.slice(1,-1):Number(e);let r=t?.schemaObject;if("union"===t?.schemaObject?.type){r=t.schemaObject.options.filter((e=>"nativeEnum"===e.type)).find((e=>a in e.values))}const n=r?.values[a];return{value:n}},getInput:({root:e})=>$e(e,"input.nativeEnumKey"),setValue({root:e,value:t}){const a=this.getInput({root:e});a.value=Object.entries(a.$schemaNativeEnumValues).find((([,e])=>e===t))?.[0]??"",a.value&&($e(e,".enumeratedValue").textContent=t)},getValue({root:e}){const{value:t,$schemaNativeEnumValues:a}=this.getInput({root:e});return a[t]},viewUI:({value:e,specificSchemaObject:t})=>["div",["Native enum: ",["span",{dataset:{type:"nativeEnum"},title:t?.description??"(a native enum)"},[e]]]],editUI(e){const{specificSchemaObject:t,value:a}=e,r=t?.values,n=Object.keys(r);let i;r&&"value"in e&&(i=Object.entries(r).find((([,e])=>e===a))?.[0]);const s=n.map((e=>/^\d$/u.test(e)&&Object.values(r).includes(Number.parseInt(e))?null:escapeRegex(e))).filter(Boolean).join("|"),o=c("input",{class:"nativeEnumKey",placeholder:s,title:s,pattern:s,value:i??"",$on:{input(){const e=this.parentElement?.parentElement?.querySelector(".enumeratedValue");e.textContent=String(r[this.value]??"")}}});return o.$schemaNativeEnumValues=r,["div",{dataset:{type:"nativeEnum"},title:t?.description??"Native Enum"},[["label",["Enumerated key ",o]],["br"],"Enumerated value: ",["span",{class:"enumeratedValue"},[a??""]]]]}},getPropertyValueFromLegend=e=>{const t=$e(e,'*[data-prop="true"]');if(!t)throw new Error("No property on the supplied legend element");if("input"===t.nodeName.toLowerCase())return t.value;if(!t.textContent)throw new Error("No property with text present on the supplied legend element");return String(Number.parseInt(t.textContent)-1)};class Types{constructor(){this.formats=new Formats,this.customValidateAllReferences=void 0,this.availableTypes={null:Ct,true:jt,false:Rt,nan:Zt,boolean:Mt,number:Pt,bigint:Ut,bigintObject:Bt,string:Gt,arrayReference:Xt,objectReference:Qt,array:ta,tuple:aa,object:ra,record:na,date:ia,enum:sa,userObject:["User objects"],undef:ua,void:da,SpecialRealNumber:fa,SpecialNumber:ga,error:va,errors:xa,regexp:pa,BooleanObject:ma,NumberObject:ya,StringObject:ha,literal:la,map:ca,set:oa,file:Ia,filelist:Ta,blob:Ea,blobHTML:Vt,domexception:$a,domrect:Oa,dompoint:Aa,dommatrix:ja,resurrectable:Ua,never:Ba,catch:Da,nativeEnum:La,buffersource:Pa,dataview:{option:["DataView"]},imagedata:{option:["ImageData"]},imagebitmap:{option:["ImageBitmap"]},int8array:{option:["Int8Array"]},uint8array:{option:["Uint8Array"]},uint8clampedarray:{option:["Uint8ClampedArray"]},int16array:{option:["Int16Array"]},uint16array:{option:["Uint16Array"]},int32array:{option:["Int32Array"]},uint32array:{option:["Uint32Array"]},float32array:{option:["Float32Array"]},float64array:{option:["Float64Array"]},ValidDate:{valid:!0},arrayNonindexKeys:{sparse:!0}};(e=>{e.forEach((([e,t])=>{Object.assign(this.availableTypes[t],this.availableTypes[e])}))})([["date","ValidDate"],["array","arrayNonindexKeys"]]),this.contexts={},Object.entries(this.availableTypes).forEach((([e,t])=>{const a=e,{stateDependent:r}=t;r&&Object.entries(r).forEach((([e,t])=>{this.contexts[e]||(this.contexts[e]={});const{contexts:r,after:n}=t;r.forEach((t=>{this.contexts[e][t]||(this.contexts[e][t]=[]),this.contexts[e][t].push({type:a,after:n})}))}))}))}async getControlsForFormatAndValue(e,t,a){return(await this.formats.getControlsForFormatAndValue(this,e,t,a)).rootUI}getContextInfo(e,t){return this.contexts[e][t]}getValueForRoot(e,t,a){return this.availableTypes[Types.getTypeForRoot(e)].getValue({root:e,stateObj:t??{types:this},currentPath:a})}getFormControlForRoot(e){const t=this.availableTypes[Types.getTypeForRoot(e)];return t.getInput?t.getInput({root:e}):null}getValueFromRootAncestor(e,t){return this.getValueForRoot($e(e,"div[data-type]"),{...t,types:this,formats:this.formats})}getFormControlFromRootAncestor(e){const t=$e(e,"div[data-type]");return t?this.getFormControlForRoot(t):null}getOptionForType(e,t=void 0){const a=[...this.availableTypes[e].option];return t&&t.description&&(a[0]=`${a[0]} (${t.description})`),a[1]={value:e,...a[1]},a}getTypeOptionsForFormatAndState(e,t,a,r){const n=this.formats.getTypesAndSchemasForFormatAndState(this,e,t,a,r);if(!n)throw new Error("Unexpected type for format and state");return{typeOptions:n.types.map(((e,t)=>this.getOptionForType(e,n.schemaObjects[t]))),schemaObjects:n.schemaObjects}}getUIForModeAndType({readonly:e,resultType:t,typeNamespace:a,type:r,topRoot:n,bringIntoFocus:i,buildTypeChoices:s,format:o,schemaContent:l,value:u,hasValue:d,replaced:p,specificSchemaObject:m,schemaFallingBack:y}){const h=this.availableTypes[r],f=d?{typeNamespace:a,type:r,buildTypeChoices:s,format:o,schemaContent:l,resultType:t,topRoot:n,bringIntoFocus:i,value:u,replaced:p,specificSchemaObject:m,schemaFallingBack:y,types:this}:{typeNamespace:a,type:r,buildTypeChoices:s,format:o,schemaContent:l,resultType:t,topRoot:n,bringIntoFocus:i,replaced:p,specificSchemaObject:m,schemaFallingBack:y,types:this},g=c(...e?h.viewUI(f):h.editUI(f));if(!e&&h.validate){h.getInput({root:g}).addEventListener("input",(()=>{this.validate({type:r,root:g,topRoot:n})}))}return g}validateAllReferences({topRoot:e}){e?(Object.values(this.availableTypes).forEach((t=>{const a=t;a.validateAll&&a.validateAll({topRoot:e,types:this})})),this.customValidateAllReferences&&this.customValidateAllReferences({topRoot:e})):console.log("No references present")}validate({type:e,root:t,topRoot:a,avoidReport:r}){const n=this.availableTypes[e];if(n.validate){const{valid:e,message:i}=n.validate({root:t,topRoot:a}),s=n.getInput({root:t});return s.setCustomValidity(e?"":i||"Invalid"),r||s.reportValidity(),e}return!0}setValue({type:e,root:t,value:a}){const r=this.availableTypes[e];r.setValue&&r.setValue({root:t,value:a})}getValueForString(e,{format:t,state:a,endMatchTypeObjs:r=[],firstRun:n=!0,rootHolder:i=[],parent:s,parentPath:o,schemaObject:c,schemaOriginal:l}){const u=this.formats.getTypesAndSchemasForFormatAndState(this,t,a,c,l)?.types;if(!u)throw new Error("Could not get types for format and state");const d=Object.entries(this.availableTypes).filter((([e])=>u.includes(e))),p="|"+d.map((([,e])=>e)).reduce(((e,t)=>{const a=t;let r=e;return a.regexEndings&&(r.push(...a.regexEndings),r=[...new Set(r)]),r}),[]).map((e=>escapeRegex(e))).join("|");let m=null,y=d.find((([,t])=>{const a=t;let{stringRegex:r}=a;return"function"==typeof a.stringRegex&&(r=a.stringRegex(!0)),r=r?new RegExp(r.source.slice(0,-1)+"(?=$"+p+")","u"):r,m=Boolean(r&&e)&&e.match(r),m})),h=!1;void 0===y&&(y=d.find((([,t])=>{const a=t,{stringRegexBegin:n}=a;return m=Boolean(n&&e)&&e.match(n),m&&(h=!0,r.push(a)),m})));let f=!0;if(void 0!==y){const a=m,[l,u]=a;let d,p=e.slice(l.length);e=e.slice(0,l.length);try{const n=y[1];if(!n.toValue)throw new Error("Type has no `toValue` method");d=n.toValue(a.groups?.innerContent||u||e,{types:this,format:t,match:m,endMatchTypeObjs:r,remnant:p,rootHolder:i,parent:s,parentPath:o,schemaObject:c})}catch(e){throw console.log("eee",e),e}!1===d.assign&&(f=!1);const{value:g}=d;if(void 0!==d.remnant&&({remnant:p}=d),h&&r.length){const e=p.match(r.at(-1).stringRegexEnd);e&&(r.pop(),p=p.slice(e[0].length))}if(n){const e=(new b).register(ce);try{const t=e.revive(g);return i.forEach((([e,a,r,n])=>{const i=this.availableTypes[e+"Reference"].resolveReference(n,t),s=getJSONType(i);["array","object"].includes(e)&&s===e&&(a[r]=i)})),[t,p,h,f]}catch(e){console.log("failed Typeson revival",e)}}return[g,p,h,f]}throw new Error("Bad parsing data")}getTypeObject(e){return this.availableTypes[e]}}function escapeRegex(e){return String(e).replaceAll(/[.\\+*?^[\]$(){}=!<>|:-]/gu,String.raw`\$&`)}Types.getTypeForRoot=e=>String(e?e.dataset.type:e),Types.validValuesSet=({form:e,typeNamespace:t,keySelectClass:a})=>{if(!e.offsetParent||!e.checkValidity())return!1;return $$e(e,a?`.${a}`:`.typeChoices-${t}`).every((e=>!e.offsetParent||""!==e.value&&e.$validate()))};const getFormatAndSchemaChoices=({schemas:e,selectedSchema:t,hasKeyPath:a}={})=>{const r=e&&e.length;return[["JSON only",{value:"json"}],...a?[]:[["IndexedDB key",{value:"indexedDBKey"}]],["Structured Clone (via Typeson JSON)",{value:"structuredCloning",selected:!r}],...r?e.map(((e,a)=>[`Schema: ${e}`,{value:"schema",dataset:{schema:e},selected:t?e===t:0===a}])):[]].map((([e,t])=>c("option",t,[e]))).reduce(((e,t)=>(e.append(t),e)),document.createDocumentFragment())};async function formatAndTypeChoices({schemas:e,getSchemaContent:t,hasValue:a,singleValue:r,hasKeyPath:n,typeNamespace:i,selectedSchema:s,formats:o=new Formats,types:l=new Types}){const u=e&&e.length?"schema":"structuredCloning",d=c("select",{class:"formatChoices",hidden:r,$custom:{async $setFormat({valueFormat:e,autoTrigger:t,schema:a}){if(a){const e=[...this.options].findIndex((e=>e.dataset.schema===a));this.selectedIndex=-1===e?0:e}else e&&(this.value=e);await this.$buildTypeChoices(t)},async $buildTypeChoices(e){DOM_removeChildren(p);const{schema:r}=this.selectedOptions[0].dataset;c({"#":buildTypeChoices({autoTrigger:e,topRoot:$e(p,"div[data-type]"),format:this.value,formats:o,types:l,typeNamespace:i,requireObject:n,objectHasValue:a,schema:r,schemaContent:r?await(t?.(r)):void 0}).domArray},p)}},$on:{async change(){await this.$buildTypeChoices()}}},[getFormatAndSchemaChoices({schemas:e,hasKeyPath:n,selectedSchema:s})]),p=c("div",{class:"typesHolder",$custom:{$getTypeRoot(){return $e(this,"div[data-type]")},$getTypeSelect(){return $e(this,`.typeChoices-${i}`)}}}),m="schema"===u?d.selectedOptions[0].dataset.schema:void 0;return c({"#":buildTypeChoices({topRoot:$e(p,"div[data-type]"),format:u,formats:o,types:l,typeNamespace:i,requireObject:n,objectHasValue:a,schema:m,schemaContent:await(t?.(m))}).domArray},p),{formats:o,types:l,formatChoices:d,typesHolder:p,domArray:[d,p],getValue(e,t){const a=p.$getTypeRoot();return l.getValueForRoot(a,{typeNamespace:i,format:d.value,formats:o,types:l,...e},t)},getType(){const e=p.$getTypeRoot();return Types.getTypeForRoot(e)},validValuesSet(){const e=p.$getTypeRoot().closest("form");return Types.validValuesSet({form:e,typeNamespace:i})},async setValue(e,t){const a=(await o.getControlsForFormatAndValue(l,d.value,e,t)).rootUI,r=Types.getTypeForRoot(a);p.$getTypeSelect().$addTypeAndEditUI({type:r,editUI:a})}}}export{Formats,Types,formatAndTypeChoices,getFormatAndSchemaChoices,getTypesForSchema,buildTypeChoices as typeChoices};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|