@mundorum/oid
Version:
Web components based on the Digital Content Component (DCC) model for the Mundorum space.
110 lines • 70.7 kB
JavaScript
(function(b,w){typeof exports=="object"&&typeof module<"u"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(b=typeof globalThis<"u"?globalThis:b||self,w(b.oidlib={}))})(this,function(b){"use strict";var Zs=Object.defineProperty;var Ys=(b,w,F)=>w in b?Zs(b,w,{enumerable:!0,configurable:!0,writable:!0,value:F}):b[w]=F;var j=(b,w,F)=>Ys(b,typeof w!="symbol"?w+"":w,F);const w=(s,...e)=>String.raw({raw:s},...e),F=(s,...e)=>String.raw({raw:s},...e);class M{constructor(){this._listeners={},this._listenersRgx=[],this._providers={},this._pendingCnx={}}subscribe(e,t){if(e!=null){let i={};typeof e=="string"&&t!=null?i[e]=t:typeof e=="object"&&(i=e);const n=this._listenersRgx.slice(),r={...this._listeners};for(const o in i)i[o]!=null&&(o.includes("+")||o.includes("#")?n.push([M._convertRegExp(o),i[o],o]):(r[o]==null?r[o]=[]:r[o]=r[o].slice(),r[o].push(i[o])));this._listenersRgx=n,this._listeners=r}}unsubscribe(e){if(e!=null){let t={};typeof e=="string"&&handler!=null?t[e]=handler:typeof e=="object"&&(t=e);const i=this._listenersRgx.slice(),n={...this._listeners};for(const r in t)if(r.includes("+")||r.includes("#")){for(const o in i)if(i[o][1]===t[r]&&i[o][2]==r){i.splice(o,1);break}}else if(n[r]!=null){for(const o in n[r])if(n[r][o]===t[r]){n[r]=n[r].toSplice(o,1);break}}this._listenersRgx=i,this._listeners=n}}async publish(e,t){if(this._listeners[e]!=null)for(const n of this._listeners[e])n(e,t);const i=this._listenersRgx;for(const n of i){const r=n[0].exec(e);r!=null&&r[0]===e&&n[1](e,t)}}static _convertRegExp(e){return new RegExp(e.replace(/\//g,"\\/").replace(/\+/g,"[^/]+").replace(/#/g,".+"))}provide(e,t,i){let n=!1;if(t!=null&&e!=null&&i!=null){const r=e+"#"+t;if(this._providers[r]==null&&(n=!0,this._providers[r]=i,this._pendingCnx[r]!=null)){for(let o of this._pendingCnx[r])o.connectionReady(e,t,i);delete this._pendingCnx[r]}}return n}withhold(e,t){let i=!1;if(t!=null&&e!=null){const n=e+"#"+t;this._providers[n]&&(i=!0,delete this._providers[n])}return i}connect(e,t,i){let n=!1;if(t!=null&&e!=null&&i!=null){const r=`${e}#${t}`;this._providers[r]?i.connectionReady(e,t,this._providers[r]):this._pendingCnx[r]?this._pendingCnx[r].push(i):this._pendingCnx[r]=[i],n=!0}return n}async invoke(e,t,i,n){const r=`${e}#${t}`;return this._providers[r]!=null?await this._providers[r].handleInvoke(e,i,n):null}}M.i=new M;const X={id:"default",bus:M.i,stylesheets:"<auto>",stydefault:["stylesheets:oid.min.css"],assets:"/assets/"};class R{constructor(e,t,i,n,r){if(this._id=e||null,this._bus=t||R.i.bus,this._stydefault=n||R.i.stydefault,this._stylesheets=i||R.i.stylesheets,this._stylesheets==="<auto>"&&this._stydefault){const o=this._stydefault[0].split(/[:\/]/).pop(),l=document.querySelectorAll('link[rel="stylesheet"]');for(const u of l)if(u.href&&u.href.endsWith(o)){this._stylesheets=u.href.slice(0,-o.length);break}}this._assets=r||R.i.assets}static create(e,t,i,n,r){if(e!=null&&R._spheres[e]!=null)throw new Error(`Sphere with id ${e} already exists`);const o=new R(e,t,i,n,r);return e!=null&&(R._spheres[e]=o),o}static get(e){return e&&R._spheres[e]||null}get id(){return this._id}get bus(){return this._bus}set stylesheets(e){this._stylesheets=e}get stylesheets(){return this._stylesheets}set stydefault(e){this._stydefault=e}get stydefault(){return this._stydefault}set assets(e){this._assets=e}get assets(){return this._assets}}R._spheres={},R.i=R.create(X.id,X.bus,X.stylesheets,X.stydefault,X.assets);class z extends HTMLElement{connectedCallback(){if(this.hasAttribute("global"))this._sphere=R.i,this.hasAttribute("stylesheets")&&(R.i.stydefault=this.getAttribute("stylesheets")),this.hasAttribute("stydefault")&&(R.i.stydefault=this.getAttribute("stydefault")),this.hasAttribute("assets")&&(R.i.assets=this.getAttribute("assets"));else{const e=this.getAttribute("id");R.get(e)?this._sphere=R.get(e):this._sphere=R.create(this.getAttribute("id"),new M,this.getAttribute("stylesheets"),this.getAttribute("stydefault"),this.getAttribute("assets"))}}get id(){return this._sphere.id}get stylesheets(){return this._sphere.stylesheets}get stydefault(){return this._sphere.stydefault}get assets(){return this._sphere.assets}get sphere(){return this._sphere}}z.elementTag="oid-sphere",customElements.define(z.elementTag,z);class ke extends HTMLElement{constructor(){super(),this._sphere=null}get _bus(){return this._sphere==null?null:this._sphere.bus}connectedCallback(){let e=this._findAggregator(z);e!=null?this._sphere=e.sphere:this._sphere=R.i}_findAggregator(e){let t=this.parentNode!=null?this.parentNode:this instanceof DocumentFragment?this.host:null;for(;t!=null&&!(t instanceof e);)t=t.parentNode!=null?t.parentNode:t instanceof DocumentFragment?t.host:null;return t}_subscribe(e,t){this._bus!=null&&this._bus.subscribe(e,t)}_unsubscribe(e,t){this._bus.unsubscribe(e,t)}async _publish(e,t){await this._bus.publish(e,t)}_provide(e,t,i){this._bus.provide(e,t,i)}_withhold(e,t){this._bus.withhold(e,t)}_connect(e,t,i){this._bus.connect(e,t,i)}async _invoke(e,t,i,n){return await this._bus.invoke(e,t,i,n)}}class ye extends ke{constructor(){super(),this._mapTopicNotice={},this._rgxTopicNotice=[],this._mapNoticeTopic={},this._receiveHandler={},this._provideHandler={},this._connected={},this._convertNotice=this._convertNotice.bind(this),this.handleNotice=this.handleNotice.bind(this)}async connectedCallback(){super.connectedCallback(),await this._initialize()}disconnectedCallback(){this._finalize()}async _initialize(){const e=this.constructor.spec;if(e&&(this._buildHandlers(this._receiveHandler,e.receive),this._buildProviders(),this._buildProvidersHandlers(),this._buildEventDispatchers(e.dispatcher)),e&&e.properties)for(const[t,i]of Object.entries(e.properties))i.default!=null&&!this.hasAttribute(t)&&(this[t]=i.default);this.hasAttribute("custom")&&(this._custom=await v.getCustom(e.id,this.getAttribute("custom"))),this.hasAttribute("publish")&&this._publishNoticeTopic(this.getAttribute("publish")),this.hasAttribute("subscribe")&&this._subscribeTopicNotice(this.getAttribute("subscribe")),this.hasAttribute("connect")&&this._connectInterface(this.getAttribute("connect"))}_buildProviders(){const e=this.constructor.spec;if(e.provide!=null&&this.id)for(const t in e.provide)this._provide(t,this.id,this)}_buildProvidersHandlers(){const e=this.constructor.spec;if(e.provide!=null)for(const t in e.provide)this._buildHandlers(this._provideHandler,e.provide[t].operations,t)}_removeProviders(){const e=this.constructor.spec;if(e.provide!=null&&this.id)for(const t in e.provide)this._withhold(t,this.id)}_buildHandlers(e,t,i){if(t!=null){const n=i==null?"":i+".";if(Array.isArray(t))for(const r of t)e[n+r]==null&&(e[n+r]=this["handle"+r[0].toUpperCase()+r.slice(1)].bind(this));else for(const[r,o]of Object.entries(t))if(e[n+r]==null){const l=typeof o=="string"?o:o.handler!=null?o.handler:"handle"+r[0].toUpperCase()+r.slice(1);e[n+r]=this[l].bind(this)}}}_buildEventDispatchers(e){if(e){this._dispatcher=[];for(const[t,i,n]of e)this._dispatcher.push([t,i,n.bind(this)])}}_finalize(){this._removeProviders();for(const e in this._mapTopicNotice)this._mapTopicNotice[e]!=e?this._unsubscribe(e,this._convertNotice):this._unsubscribe(e,this.handleNotice)}attributeChangedCallback(e,t,i){const n=e.replace(/-([a-z])/g,(r,o)=>o.toUpperCase());this[n]=i}static get observedAttributes(){return["id"]}get id(){return this._id}set id(e){this._id!=null&&this._bus!=null&&this._removeProviders(),this._id=e,this._bus!=null&&this._buildProviders()}get publish(){return this.getAttribute("publish")}get subscribe(){return this.getAttribute("subscribe")}get connect(){return this.getAttribute("connect")}handleGet(e,t){return t.property!=null?this[t.property]:null}handleSet(e,t){t.property!=null&&t.value!=null&&(this[t.property]=t.value)}_subscribeTopicNotice(e){const t=e.split(";");for(const i of t){const n=i.split("~");if(n.length>1){const r=n[0].trim();r.includes("+")||r.includes("#")?this._rgxTopicNotice.push([M._convertRegExp(r),n[1].trim(),r]):this._mapTopicNotice[r]=n[1].trim(),this._subscribe(r,this._convertNotice)}else{const r=i.trim();this._mapTopicNotice[r]=r,this._subscribe(r,this.handleNotice)}}}_publishNoticeTopic(e){const t=e.split(";");for(const i of t){const n=i.split("~");n.length>1?this._mapNoticeTopic[n[0].trim()]=n[1].trim():this._mapNoticeTopic[i.trim()]=i.trim()}}_connectInterface(e){let t=!0;const i=e.split(";");for(const n of i){const r=n.split("#");r.length>1?this._connect(r[0].trim(),r[1].trim(),this):t=!1}return t}_notify(e,t){this._mapNoticeTopic[e]!=null&&this._publish(this._mapNoticeTopic[e],t)}_convertNotice(e,t){if(this._mapTopicNotice[e]!=null)this.handleNotice(this._mapTopicNotice[e],t);else for(const[i,n]of this._rgxTopicNotice){const r=i.exec(e);if(r!=null&&r[0]===e){this.handleNotice(n,t);break}}}connectTo(e,t){t.id&&this._connect(e,t.id,this)}connectionReady(e,t,i){this._connected[e]==null&&(this._connected[e]=[]),this._connected[e].push(t)}async _invoke(e,t,i){const n=v.getInterface(e);if(this._connected[e]!=null)if(n.response!=null&&n.response===!0){const r=[];for(const o of this._connected[e])r.push(await this._bus.invoke(e,o,t,i));return r}else for(const r of this._connected[e])return await this._bus.invoke(e,r,t,i)}handleNotice(e,t){const i=e&&e.includes("/")?e.split("/")[0]:e;this._receiveHandler[i]!=null&&this._receiveHandler[i](e,t)}async handleInvoke(e,t,i){let n=null;return this._provideHandler[`${e}.${t}`]!=null&&(n=await this._provideHandler[`${e}.${t}`](t,i)),n}_customExists(e){return this._custom!=null&&this._custom.hasOwnProperty(e)}_getCustomField(e){return this._custom==null||this._custom[e]==null?null:this._custom[e]}_callCustom(e,t){if(this._custom!=null&&this._custom[e]!=null)return this._custom[e](this,t)}}class q extends ye{}class k extends q{async connectedCallback(){await super.connectedCallback(),this._stylesheets=this.constructor.spec.stylesheets.replace('href="default"','href="'+this._sphere.stydefault+'"').replace('href="stylesheets:','href="'+this._sphere.stylesheets),this.render()}render(){const e=this.constructor.spec;let t=e!=null?e.template:null;if(this.template){const i=this.template();if(i!=this._template){this._template=i;const n=v.prepareDispatchers(i,this.constructor);this._templatePre=n.template,this._buildEventDispatchers(n.dispatcher,this)}t=this._templatePre}if(this._presentation=null,e!=null&&t!=null){let i=this._getCustomField("style");i=i?`<style>${i}</style>`:"";const n=(this._stylesheets+e.styles+i+t).replace(/{{[ \t]*(url:)?[ \t]*this\.([^}]*)}}/g,(r,o,l)=>{l=l?l.trim():"";let u=this[l]?this[l]:"";return o==="url:"&&(u=u.replace("assets:",this._sphere.assets)),u});if(e.shadow===!1?(this.innerHTML=n,this._presentation=this.querySelector("#oid-prs")||this):this._presentation=this._shadowHTML(n),this._dispatcher){const r=e.shadow===!1?this:this.shadowRoot;for(const[o,l,u]of this._dispatcher)r.querySelector("["+o+"]").addEventListener(l,u)}}}_shadowHTML(e){const t=k.prepareShadow(this,e);return this.shadowRoot.querySelector("#oid-prs")||t}static prepareShadow(e,t){const i=document.createElement("template");i.innerHTML=t;const n=document.importNode(i.content,!0);return e.shadowRoot?e.shadowRoot.innerHTML="":e.attachShadow({mode:"open"}),e.shadowRoot.appendChild(n),n}}const _=class _{static cInterface(e){e!=null&&(_._interfaceReg[e.id]=e)}static getInterface(e){return _._interfaceReg[e]}static component(e){e=Object.assign({},_._defaultSpec,e);let t=e.implementation;if(t==null){const r=e.ui===!1||e.template==null?e.element==null?ye:q:k,o=e.element[0].toUpperCase()+e.element.slice(1).replace(/-([a-z])/g,(l,u)=>u.toUpperCase());t=class extends r{},Object.defineProperty(t,"name",{value:o})}const i=t.observedAttributes.slice();if(e.properties){Object.defineProperty(t,"observedAttributes",{get:function(){return this.observed}});for(const r in e.properties){const o=e.properties[r],l=r.replace(/-([a-z])/g,(u,c)=>c.toUpperCase());Object.defineProperty(t.prototype,l,o.readonly?{get:function(){return this["_"+l]}}:t.prototype.render==null?{get:function(){return this["_"+l]},set:function(u){this["_"+l]=u}}:{get:function(){return this["_"+l]},set:function(u){const c=this["_"+l];this["_"+l]=u,c!=u&&this._sphere&&this.render()}}),(o.attribute==null||o.attribute!==!1)&&i.push(r)}}if(e.provide=e.provide==null?_.defaultInterface:e.provide.concat(_.defaultInterface),e.provide){const r={};for(const o of e.provide){const l=_._interfaceReg[o];if(l==null)throw new Error("Unknown interface id: "+o);r[o]=l}e.provide=r}_.stylePreprocess(e);const n=_.prepareDispatchers(e.template,t);e.template=n.template,n.dispatcher&&(e.dispatcher=n.dispatcher),Object.assign(t,{spec:e,observed:i}),e.element==null&&(e.element="internal-"+e.id.replace(":","-")),customElements.define(e.element,t),_._oidReg[e.id]=t}static componentSet(e,t){if(e!=null&&_._oidReg[e]!=null){const i=_._oidReg[e].spec;for(const n in t)i[n]=t[n];_.stylePreprocess(i)}}static stylePreprocess(e){let t="";if(e.stylesheets){let i=e.stylesheets;Array.isArray(i)||(i=[i]);for(const n of i)t+=`<link href="${n}" rel="stylesheet">`}e.stylesheets=t,e.styles=e.styles?`<style>${e.styles}</style>`:""}static prepareDispatchers(e,t){let i=null;if(e){let n=1;const r=e.split(/@([^= >]*)[ \t]*(?:=[ \t]*{{[ \t]*this\.([^}]*)[ \t]*}})?/);if(r.length>1){i=[];let o="";for(let l=0;l+2<r.length;l+=3){o+=r[l]+_.eventAttribute+n+" ";const u=r[l+1].trim(),c=r[l+2]!=null?r[l+2].trim():"_on"+u[0].toUpperCase()+u.substring(1);i.push([_.eventAttribute+n,u,t.prototype[c]]),n++}e=o+r[r.length-1]}}return{template:e,dispatcher:i}}static create(e,t){const i=_._oidReg[e];if(i==null)throw new Error("Unknown component id: "+e);const n=document.createElement(i.spec.element);if(t!=null)for(const r in t)n.setAttribute(r,t[r]);return n}static customize(e,t){e!=null&&_._oidReg[e]!=null&&t!=null&&t.cid!=null&&(_._oidCustom[e+"."+t.cid]=t,_._customQueue[e+"."+t.cid]!=null&&(_._customQueue[e+"."+t.cid](),delete _._customQueue[e+"."+t.cid]))}static async getCustom(e,t){return e==null||t==null?null:(_._oidCustom[e+"."+t]==null&&await new Promise((n,r)=>{const o=function(){n()};_._customQueue[e+"."+t]=o}),_._oidCustom[e+"."+t])}static setDefault(e){this._defaultSpec=e}static addDefault(e){for(const t in e)this._defaultSpec[t]==null?this._defaultSpec[t]=e[t]:Array.isArray(this._defaultSpec[t])?this._defaultSpec[t]=this._defaultSpec[t].concat(e[t]):typeof this._defaultSpec[t]=="object"?Object.assign(this._defaultSpec[t],e[t]):this._defaultSpec[t]=e[t]}};j(_,"eventAttribute","oidevent_"),j(_,"defaultInterface",["itf:oid"]),j(_,"_interfaceReg",{}),j(_,"_oidReg",{}),j(_,"_oidCustom",{}),j(_,"_customQueue",{}),j(_,"_defaultSpec",{});let v=_;v.cInterface({id:"itf:oid",operations:{get:{response:!0},set:{response:!1}},flow:"pull"}),v.cInterface({id:"itf:transfer",operations:["send"],flow:"push"}),v.cInterface({id:"itf:storage",operations:["store","load"],flow:"pull"}),v.cInterface({id:"itf:iterate",operations:{first:{response:!0},next:{response:!0}},flow:"pull",connections:"1"});class L extends z{connectedCallback(){super.connectedCallback();const e=this._prepareHTML(),t=L.template.replace("{stylesheet}",this.stylesheet).replace("{code}",L.code.replace("{html}",e).replace("{rows}",this._rows(e))).replace("{console}",this.messages?L.console.replace("{rows}",this.rows?this.rows:L.rows):"");k.prepareShadow(this,t),this._scriptPanel=this.shadowRoot.querySelector("#script"),this._unlockScript=this._unlockScript.bind(this),this._scriptPanel.addEventListener("click",this._unlockScript),this._buttonRender=this.shadowRoot.querySelector("#btn-render"),this._buttonRender.addEventListener("click",this._computeRender.bind(this)),this._observer=new MutationObserver(this._scriptUpdated.bind(this)),this._observer.observe(this,{attributes:!0,childList:!0,subtree:!0}),this.sphere.bus.subscribe("#",this._busMonitor.bind(this))}static get observedAttributes(){return z.observedAttributes.concat(["messages","rows"])}get messages(){return this.hasAttribute("messages")}set messages(e){this.setAttribute("messages",e)}get rows(){return this.getAttribute("rows")}set rows(e){this.setAttribute("rows",e)}_scriptUpdated(e,t){const i=this._prepareHTML();this._scriptPanel.value=i,this._scriptPanel.rows=this._rows(i)}_rows(e){const t=e.split(/\r\n|\r|\n/);let i=0;return t.forEach(n=>{i+=Math.floor(n.length/45)+1}),i}_prepareHTML(){let e=this.innerHTML.replace('=""',"").replace(/^[\r\n]+/,"").replace(/[\r\n]+$/,"");if(e.startsWith(" ")||e.startsWith(" ")){const t=e.match(/^[ \t]+/);e=e.replace(new RegExp("^"+t,"gm"),"")}return e}_unlockScript(){this._scriptPanel.removeEventListener("click",this._unlockScript),this._scriptPanel.readOnly=!1,this._buttonRender.style.display="initial"}_computeRender(){this.shadowRoot.querySelector("#render").innerHTML=this._scriptPanel.value}_busMonitor(e,t){e!="bus/monitor"&&this.sphere.bus.publish("bus/monitor",{value:`[${e}] ${JSON.stringify(t)}`})}}L.rows=5,L.code=w`<div style="width:100%;display:flex">
<textarea id="script" class="code" style="width:100%;cursor:pointer" rows="{rows}" readonly>{html}</textarea>
<button id="btn-render" class="btn btn-secondary" style="width:auto;display:none">Render</button>
</div>`,L.template=w`<link rel="stylesheet" href="{stylesheet}">
{code}
<div id="render"><slot></slot></div>
{console}`,L.console=w`<div id="msg-pnl" style="width:100%">
<b>Messages on the Bus</b><br>
<console-oid rows="{rows}" class="code" prompt="" subscribe="bus/monitor~display"></console-oid>
</div>`,L.elementTag="oid-play",customElements.define(L.elementTag,L);class Ce extends q{async handleSubmit(e,t){const i={},n=this._getCustomField("schema");let r=null;if(n!=null)for(const o of Object.keys(n)){const l=document.querySelector(`#${o}`);l!=null&&(i[o]=l.value)}else{for(r=this.parentNode;r!=null&&r.nodeName.toLowerCase()!=="form";)r=r.parentNode;if(r!=null)for(const o of r)o.type==="radio"||o.type==="checkbox"?o.checked&&(o.type==="checkbox"||!o.hasAttribute("name")?i[o.id]=o.value:i[o.name]=o.value):i[o.id]=o.value}(!this._customExists("pre")||this._callCustom("pre",i)===!0)&&(this._notify("submit",i),this._notify("dispatch",{value:i}),this._invoke("itf:transfer","send",{value:i}))}handleUpdate(e,t){if(t.value){let i=this.parentNode;for(;i!=null&&i.nodeName.toLowerCase()!=="form";)i=i.parentNode;if(i!=null)for(const n of i)n.type==="radio"||n.type==="checkbox"?n.checked&&(n.type==="checkbox"||!n.hasAttribute("name")?n.value=t.value[n.id]:n.value=t.value[n.name]):n.value=t.value[n.id]}}}v.component({id:"oid:submit",element:"submit-oid",receive:["submit","update"],implementation:Ce});class Ne extends k{template(){let e=this.selection==="both"?w`<div class="group">`:"";return(this.selection==="drop"||this.selection==="both")&&(e+=w`<div class="drop" @dragover @drop>{{this.dropLabel}}</div>`),(this.selection==="dialog"||this.selection==="both")&&(e+=w`<input type="file" class="selector" @change></input>`),this.selection==="both"&&(e+="</div>"),e}_onDragover(e){this.pre&&(this._presentation.innerHTML=this.dropPre),e.preventDefault()}async _onDrop(e){e.preventDefault(),this.post&&(this._presentation.innerHTML=this.dropPost);let t=null;if(e.dataTransfer.items)for(const n of e.dataTransfer.items)n.kind==="file"&&(t=n.getAsFile());else t=e.dataTransfer.files[0];let i=await t.text();this.filetype==="json"&&(i=JSON.parse(i)),this._notify("dispatch",{value:i}),this._invoke("itf:transfer","send",{value:i})}_onChange(e){const t={},i=e.target.files[0];if(!i)t.error="No file selected";else{const n=new FileReader;n.onload=r=>{t.value=r.target.result,this.filetype==="json"&&(t.value=JSON.parse(t.value))},n.onerror=r=>{t.error=`Error reading file: ${r.target.error}`},n.readAsText(i)}this._notify("dispatch",t),this._invoke("itf:transfer","send",t)}handleRetrieve(e,t){}handleStore(e,t){let i=t.value||"";this.filetype==="json"&&(i=JSON.stringify(i));const n=document.createElement("a");n.style.display="none",document.body.appendChild(n),n.href=window.URL.createObjectURL(new Blob([i],{type:"text/plain"})),n.setAttribute("download",t.filename||this.filename),n.click(),window.URL.revokeObjectURL(n.href),document.body.removeChild(n)}}v.component({id:"oid:file",element:"file-oid",properties:{selection:{default:"both"},dropLabel:{default:"Drop Zone"},dropPre:{default:"Drop your file here"},dropPost:{default:"File loaded"},filename:{default:"file.txt"},filetype:{default:"plain"}},receive:["retrieve","store"],implementation:Ne,styles:F`
.group {
display: flex;
width: 100%;
height: 100%;
}
.drop {
width: 50%;
border: 5px solid;
}
.selector {
flex: 1;
}`});class Pe extends q{async handleLoad(e,t){const i=`${this.dataset}:${t.collection||this.collection}:${t.key||this.key}`,n=JSON.parse(localStorage.getItem(i));return this._notify("dispatch",{value:n}),this._invoke("itf:transfer","send",{value:n}),{value:n}}async handleStore(e,t){let i=!1;if(t.value){const n=`${this.dataset}:${t.collection||this.collection}:${t.key||this.key}`;localStorage.setItem(n,JSON.stringify(t.value)),i=!0}return i}}v.component({id:"oid:local-storage",element:"local-storage-oid",receive:["load","store"],provide:["itf:storage"],properties:{dataset:{default:"default-mundorum-oid"},collection:{default:"default"},key:{default:"default"}},implementation:Pe});class Le extends q{async handleLoad(e,t){const i={};if(t.filename==null&&this.filename==null)i.error="No file name provided";else{const n=t.filename||this.filename,r=await fetch(`${n}`);r.ok?i.value=await r.json():i.error="Failed to load JSON"}return this._notify("dispatch",i),this._invoke("itf:transfer","send",i),i}}v.component({id:"oid:json-file",element:"json-file-oid",receive:["load"],properties:{filename:{}},implementation:Le});class Fe extends k{_onClick(){this._notify("click",{value:this.label||this.source})}_onMouseenter(){this._notify("mouseenter",{value:this.label||this.source})}_onMouseleave(){this._notify("mouseleave",{value:this.label||this.source})}}v.component({id:"oid:image",element:"image-oid",properties:{source:{default:"assets:images/image.svg"},label:{}},implementation:Fe,stylesheets:"default",template:w`
<image id="oid-prs" src="{{url:this.source}}" alt="{{this.label}}"
@click @mouseenter @mouseleave>`});class Ue extends k{_onClick(){this._callCustom("click"),this._notify("click",{value:this.value||this.label}),this._invoke("itf:transfer","send",{value:this.value||this.label})}_onMouseenter(){this._notify("mouseenter",{value:this.value||this.label})}_onMouseleave(){this._notify("mouseleave",{value:this.value||this.label})}}v.component({id:"oid:button",element:"button-oid",properties:{label:{},value:{}},implementation:Ue,stylesheets:"default",template:w`
<button id="oid-prs" class="btn btn-primary"
@click @mouseenter @mouseleave>
{{this.label}}
</button>`});class De extends k{handleSend(e,t){this._presentation&&t&&t.value&&typeof t.value=="object"&&(t.value=JSON.stringify(t.value)),this._presentation.value+=(this.prompt.length>0?`${this.prompt} `:"")+`${t.value}
`}}v.component({id:"oid:console",element:"console-oid",properties:{prompt:{default:">"},rows:{default:10}},receive:{display:"handleSend"},provide:["itf:transfer"],implementation:De,styles:F`
.console {
width: 100%;
font-family: "Courier New", monospace;
font-size: 1em;
background-color: lightgray
}`,template:w`
<textarea class="console" rows="{{this.rows}}" id="oid-prs" readonly></textarea>`});class Be extends k{connectedCallback(){this._value=this.getAttribute("value")||!1,super.connectedCallback()}static get observedAttributes(){return k.observedAttributes.concat(["variable","value"])}get variable(){return this._variable}set variable(e){this._variable=e}get value(){return this._value}set value(e){this._value=e}}class je extends Be{connectedCallback(){super.connectedCallback(),this.hasAttribute("value")&&(this.value=this.getAttribute("value")!=="off",this.render()),this._notify("initial",{value:this.value?this.on:this.off})}render(){super.render(),this._input=this._presentation.querySelector("#oid-input"),this._input.checked=this.value}handleInvert(e,t){this.value=!this.value,this.value?this._input.checked=!0:this._input.checked=!1,this._notifyState()}handleOn(){this.value=!0,this._input.checked=!0,this._notifyState()}handleOff(){this.value=!1,this._input.checked=!1,this._notifyState()}handleRepublish(e,t){this.value&&this._notify("republish",t)}_onInput(){this._value=this._input.checked,this._notifyState()}_notifyState(){const e=this._value?this.on:this.off;this._notify("change",{value:e}),this._notify(e,{value:e})}}v.component({id:"oid:switch",element:"switch-oid",properties:{on:{default:"on"},off:{default:"off"}},receive:["invert","on","off","republish"],implementation:je,styles:F`
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #2196F3;
}
input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
}
input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}`,template:w`
<label id="oid-prs" class="switch">
<input id="oid-input" type="checkbox" @input>
<span class="slider round"></span>
</label>`});class Me extends Be{connectedCallback(){super.connectedCallback(),this.hasAttribute("value")||(this.value=Math.round((parseInt(""+this.min)+parseInt(""+this.max))/2),this.render()),this._notify("initial",{value:this.value})}render(){super.render(),this._input=this._presentation.querySelector("#oid-input"),this.hasAttribute("index")&&(this._index=this._presentation.querySelector("#index"),this._index.innerHTML=this.value)}_onInput(){this._value=this._input.value,this.hasAttribute("index")&&(this._index.innerHTML=this.value),this._notify("change",{value:this.value})}}v.component({id:"oid:slider",element:"slider-oid",properties:{min:{default:0},max:{default:100},index:{default:!1}},implementation:Me,stylesheets:"default",template:w`
<div id="oid-prs" style="width:100%; display:flex; flex-direction:row">
<span id="index" style="flex:initial"></span>
<input type="range" id="oid-input" min="{{this.min}}" max="{{this.max}}"
value="{{this.value}}" style="flex:auto" @input>
</div>`});class qe extends k{constructor(){super(),this._x=0,this._y=0,this._sideASize=0,this._onMousemove=this._onMousemove.bind(this),this._onMouseup=this._onMouseup.bind(this)}async connectedCallback(){await super.connectedCallback(),this._horz=this.split!=="vertical",this._resizer=this.shadowRoot.getElementById("resizer"),this._sidea=this.shadowRoot.getElementById("sidea"),this._sideb=this.shadowRoot.getElementById("sideb"),this._horz?(this._resizer.style.cursor="ew-resize",this._resizer.style.height="100%",this._resizer.classList.add("divide-x"),this._sidea.style.width=this.proportion):(this._resizer.style.cursor="ns-resize",this._presentation.style.flexDirection="column",this._resizer.style.width="100%",this._resizer.classList.add("divide-y"),this._sidea.style.height=this.proportion)}_onMousedown(e){this._x=e.clientX,this._y=e.clientY,this._sideASize=this._horz?this._sidea.getBoundingClientRect().width:this._sidea.getBoundingClientRect().height,this.shadowRoot.addEventListener("mousemove",this._onMousemove),this.shadowRoot.addEventListener("mouseup",this._onMouseup)}_onMousemove(e){const t=e.clientX-this._x,i=e.clientY-this._y;if(this._horz){const n=(this._sideASize+t)*100/this._presentation.getBoundingClientRect().width;this._sidea.style.width=n+"%",this._resizer.style.cursor="col-resize",document.body.style.cursor="col-resize"}else{const n=(this._sideASize+i)*100/this._presentation.getBoundingClientRect().height;this._sidea.style.height=n+"%",this._resizer.style.cursor="row-resize",document.body.style.cursor="row-resize"}this._sidea.style.userSelect="none",this._sidea.style.pointerEvents="none",this._sideb.style.userSelect="none",this._sideb.style.pointerEvents="none"}_onMouseup(e){this.shadowRoot.removeEventListener("mousemove",this._onMousemove),this.shadowRoot.removeEventListener("mouseup",this._onMouseup),this._resizer.style.cursor=this._horz?"ew-resize":"ns-resize",document.body.style.removeProperty("cursor"),this._sidea.style.removeProperty("user-select"),this._sidea.style.removeProperty("pointer-events"),this._sideb.style.removeProperty("user-select"),this._sideb.style.removeProperty("pointer-events"),this._notify("resize",{awidth:this._sidea.style.width,aheight:this._sidea.style.height,bwidth:this._sideb.style.width,bheight:this._sideb.style.height})}}v.component({id:"oid:split-pane",element:"split-pane-oid",properties:{split:{default:"horizontal"},proportion:{default:"50%"}},implementation:qe,stylesheets:"default",styles:F`
.group {
display: flex;
width: 100%;
height: 100%;
}
.pane-b {
flex: 1;
}`,template:w`
<div id="oid-prs" class="group">
<div class="bg-base" id="sidea"><slot name="side-a"></slot></div>
<div class="divide" id="resizer" @mousedown></div>
<div class="pane-b bg-base" id="sideb"><slot name="side-b"></slot></div>
</div>`});class He extends k{async connectedCallback(){super.connectedCallback(),this._toInitial=this.initial,this._updateVisualState(),this._observer=new MutationObserver(this._updateVisualState.bind(this)),this._observer.observe(this,{childList:!0,subtree:!0})}_updateVisualState(){this._toInitial!=null&&(this._state=this.querySelector(`#${this._toInitial}`),this._state!=null&&(this._toInitial=null));const e=this.querySelectorAll("*");for(let t=0;t<e.length;t++){const i=e[t];this._state==null&&(this._state=i),i===this._state&&i.style.display!=null?i.style.removeProperty("display"):(i.style.display==null||i.style.display!=="none")&&(i.style.display="none")}}handleFirst(){this._state=this.firstElementChild,this._updateVisualState()}handleNext(){if(this._state!=null){let e=this._state.nextElementSibling;e==null&&(e=this.firstElementChild),this._state=e,this._updateVisualState()}}handlePrev(){if(this._state!=null){let e=this._state.previousElementSibling;e==null&&(e=this.lastElementChild),this._state=e,this._updateVisualState()}}handleLast(){this._state=this.lastElementChild,this._updateVisualState()}handleState(e,t){this._state=this.querySelector(`#${t.value}`),this._updateVisualState()}}v.component({id:"oid:state-pane",element:"state-pane-oid",properties:{initial:{}},receive:["first","next","prev","last","state"],implementation:He,stylesheets:"default"});function ze(s,e){return function(){return s.apply(e,arguments)}}const{toString:kt}=Object.prototype,{getPrototypeOf:be}=Object,{iterator:ie,toStringTag:Ie}=Symbol,ne=(s=>e=>{const t=kt.call(e);return s[t]||(s[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),U=s=>(s=s.toLowerCase(),e=>ne(e)===s),re=s=>e=>typeof e===s,{isArray:W}=Array,G=re("undefined");function Q(s){return s!==null&&!G(s)&&s.constructor!==null&&!G(s.constructor)&&C(s.constructor.isBuffer)&&s.constructor.isBuffer(s)}const $e=U("ArrayBuffer");function Ct(s){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(s):e=s&&s.buffer&&$e(s.buffer),e}const Nt=re("string"),C=re("function"),Je=re("number"),Z=s=>s!==null&&typeof s=="object",Pt=s=>s===!0||s===!1,oe=s=>{if(ne(s)!=="object")return!1;const e=be(s);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Ie in s)&&!(ie in s)},Lt=s=>{if(!Z(s)||Q(s))return!1;try{return Object.keys(s).length===0&&Object.getPrototypeOf(s)===Object.prototype}catch{return!1}},Ft=U("Date"),Ut=U("File"),Dt=U("Blob"),Bt=U("FileList"),jt=s=>Z(s)&&C(s.pipe),Mt=s=>{let e;return s&&(typeof FormData=="function"&&s instanceof FormData||C(s.append)&&((e=ne(s))==="formdata"||e==="object"&&C(s.toString)&&s.toString()==="[object FormData]"))},qt=U("URLSearchParams"),[Ht,zt,It,$t]=["ReadableStream","Request","Response","Headers"].map(U),Jt=s=>s.trim?s.trim():s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Y(s,e,{allOwnKeys:t=!1}={}){if(s===null||typeof s>"u")return;let i,n;if(typeof s!="object"&&(s=[s]),W(s))for(i=0,n=s.length;i<n;i++)e.call(null,s[i],i,s);else{if(Q(s))return;const r=t?Object.getOwnPropertyNames(s):Object.keys(s),o=r.length;let l;for(i=0;i<o;i++)l=r[i],e.call(null,s[l],l,s)}}function Ve(s,e){if(Q(s))return null;e=e.toLowerCase();const t=Object.keys(s);let i=t.length,n;for(;i-- >0;)if(n=t[i],e===n.toLowerCase())return n;return null}const I=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,We=s=>!G(s)&&s!==I;function _e(){const{caseless:s}=We(this)&&this||{},e={},t=(i,n)=>{const r=s&&Ve(e,n)||n;oe(e[r])&&oe(i)?e[r]=_e(e[r],i):oe(i)?e[r]=_e({},i):W(i)?e[r]=i.slice():e[r]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&Y(arguments[i],t);return e}const Vt=(s,e,t,{allOwnKeys:i}={})=>(Y(e,(n,r)=>{t&&C(n)?s[r]=ze(n,t):s[r]=n},{allOwnKeys:i}),s),Wt=s=>(s.charCodeAt(0)===65279&&(s=s.slice(1)),s),Kt=(s,e,t,i)=>{s.prototype=Object.create(e.prototype,i),s.prototype.constructor=s,Object.defineProperty(s,"super",{value:e.prototype}),t&&Object.assign(s.prototype,t)},Xt=(s,e,t,i)=>{let n,r,o;const l={};if(e=e||{},s==null)return e;do{for(n=Object.getOwnPropertyNames(s),r=n.length;r-- >0;)o=n[r],(!i||i(o,s,e))&&!l[o]&&(e[o]=s[o],l[o]=!0);s=t!==!1&&be(s)}while(s&&(!t||t(s,e))&&s!==Object.prototype);return e},Gt=(s,e,t)=>{s=String(s),(t===void 0||t>s.length)&&(t=s.length),t-=e.length;const i=s.indexOf(e,t);return i!==-1&&i===t},Qt=s=>{if(!s)return null;if(W(s))return s;let e=s.length;if(!Je(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=s[e];return t},Zt=(s=>e=>s&&e instanceof s)(typeof Uint8Array<"u"&&be(Uint8Array)),Yt=(s,e)=>{const i=(s&&s[ie]).call(s);let n;for(;(n=i.next())&&!n.done;){const r=n.value;e.call(s,r[0],r[1])}},es=(s,e)=>{let t;const i=[];for(;(t=s.exec(e))!==null;)i.push(t);return i},ts=U("HTMLFormElement"),ss=s=>s.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,i,n){return i.toUpperCase()+n}),Ke=(({hasOwnProperty:s})=>(e,t)=>s.call(e,t))(Object.prototype),is=U("RegExp"),Xe=(s,e)=>{const t=Object.getOwnPropertyDescriptors(s),i={};Y(t,(n,r)=>{let o;(o=e(n,r,s))!==!1&&(i[r]=o||n)}),Object.defineProperties(s,i)},ns=s=>{Xe(s,(e,t)=>{if(C(s)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const i=s[t];if(C(i)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},rs=(s,e)=>{const t={},i=n=>{n.forEach(r=>{t[r]=!0})};return W(s)?i(s):i(String(s).split(e)),t},os=()=>{},ls=(s,e)=>s!=null&&Number.isFinite(s=+s)?s:e;function as(s){return!!(s&&C(s.append)&&s[Ie]==="FormData"&&s[ie])}const cs=s=>{const e=new Array(10),t=(i,n)=>{if(Z(i)){if(e.indexOf(i)>=0)return;if(Q(i))return i;if(!("toJSON"in i)){e[n]=i;const r=W(i)?[]:{};return Y(i,(o,l)=>{const u=t(o,n+1);!G(u)&&(r[l]=u)}),e[n]=void 0,r}}return i};return t(s,0)},us=U("AsyncFunction"),hs=s=>s&&(Z(s)||C(s))&&C(s.then)&&C(s.catch),Ge=((s,e)=>s?setImmediate:e?((t,i)=>(I.addEventListener("message",({source:n,data:r})=>{n===I&&r===t&&i.length&&i.shift()()},!1),n=>{i.push(n),I.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",C(I.postMessage)),ds=typeof queueMicrotask<"u"?queueMicrotask.bind(I):typeof process<"u"&&process.nextTick||Ge,a={isArray:W,isArrayBuffer:$e,isBuffer:Q,isFormData:Mt,isArrayBufferView:Ct,isString:Nt,isNumber:Je,isBoolean:Pt,isObject:Z,isPlainObject:oe,isEmptyObject:Lt,isReadableStream:Ht,isRequest:zt,isResponse:It,isHeaders:$t,isUndefined:G,isDate:Ft,isFile:Ut,isBlob:Dt,isRegExp:is,isFunction:C,isStream:jt,isURLSearchParams:qt,isTypedArray:Zt,isFileList:Bt,forEach:Y,merge:_e,extend:Vt,trim:Jt,stripBOM:Wt,inherits:Kt,toFlatObject:Xt,kindOf:ne,kindOfTest:U,endsWith:Gt,toArray:Qt,forEachEntry:Yt,matchAll:es,isHTMLForm:ts,hasOwnProperty:Ke,hasOwnProp:Ke,reduceDescriptors:Xe,freezeMethods:ns,toObjectSet:rs,toCamelCase:ss,noop:os,toFiniteNumber:ls,findKey:Ve,global:I,isContextDefined:We,isSpecCompliantForm:as,toJSONObject:cs,isAsyncFn:us,isThenable:hs,setImmediate:Ge,asap:ds,isIterable:s=>s!=null&&C(s[ie])};function y(s,e,t,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=s,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}a.inherits(y,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.status}}});const Qe=y.prototype,Ze={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(s=>{Ze[s]={value:s}}),Object.defineProperties(y,Ze),Object.defineProperty(Qe,"isAxiosError",{value:!0}),y.from=(s,e,t,i,n,r)=>{const o=Object.create(Qe);return a.toFlatObject(s,o,function(u){return u!==Error.prototype},l=>l!=="isAxiosError"),y.call(o,s.message,e,t,i,n),o.cause=s,o.name=s.name,r&&Object.assign(o,r),o};const fs=null;function ge(s){return a.isPlainObject(s)||a.isArray(s)}function Ye(s){return a.endsWith(s,"[]")?s.slice(0,-2):s}function et(s,e,t){return s?s.concat(e).map(function(n,r){return n=Ye(n),!t&&r?"["+n+"]":n}).join(t?".":""):e}function ps(s){return a.isArray(s)&&!s.some(ge)}const ms=a.toFlatObject(a,{},null,function(e){return/^is[A-Z]/.test(e)});function le(s,e,t){if(!a.isObject(s))throw new TypeError("target must be an object");e=e||new FormData,t=a.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,p){return!a.isUndefined(p[m])});const i=t.metaTokens,n=t.visitor||h,r=t.dots,o=t.indexes,u=(t.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(e);if(!a.isFunction(n))throw new TypeError("visitor must be a function");function c(d){if(d===null)return"";if(a.isDate(d))return d.toISOString();if(a.isBoolean(d))return d.toString();if(!u&&a.isBlob(d))throw new y("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(d)||a.isTypedArray(d)?u&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function h(d,m,p){let A=d;if(d&&!p&&typeof d=="object"){if(a.endsWith(m,"{}"))m=i?m:m.slice(0,-2),d=JSON.stringify(d);else if(a.isArray(d)&&ps(d)||(a.isFileList(d)||a.endsWith(m,"[]"))&&(A=a.toArray(d)))return m=Ye(m),A.forEach(function(O,B){!(a.isUndefined(O)||O===null)&&e.append(o===!0?et([m],B,r):o===null?m:m+"[]",c(O))}),!1}return ge(d)?!0:(e.append(et(p,m,r),c(d)),!1)}const f=[],g=Object.assign(ms,{defaultVisitor:h,convertValue:c,isVisitable:ge});function S(d,m){if(!a.isUndefined(d)){if(f.indexOf(d)!==-1)throw Error("Circular reference detected in "+m.join("."));f.push(d),a.forEach(d,function(A,x){(!(a.isUndefined(A)||A===null)&&n.call(e,A,a.isString(x)?x.trim():x,m,g))===!0&&S(A,m?m.concat(x):[x])}),f.pop()}}if(!a.isObject(s))throw new TypeError("data must be an object");return S(s),e}function tt(s){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(s).replace(/[!'()~]|%20|%00/g,function(i){return e[i]})}function we(s,e){this._pairs=[],s&&le(s,this,e)}const st=we.prototype;st.append=function(e,t){this._pairs.push([e,t])},st.toString=function(e){const t=e?function(i){return e.call(this,i,tt)}:tt;return this._pairs.map(function(n){return t(n[0])+"="+t(n[1])},"").join("&")};function ys(s){return encodeURIComponent(s).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function it(s,e,t){if(!e)return s;const i=t&&t.encode||ys;a.isFunction(t)&&(t={serialize:t});const n=t&&t.serialize;let r;if(n?r=n(e,t):r=a.isURLSearchParams(e)?e.toString():new we(e,t).toString(i),r){const o=s.indexOf("#");o!==-1&&(s=s.slice(0,o)),s+=(s.indexOf("?")===-1?"?":"&")+r}return s}class nt{constructor(){this.handlers=[]}use(e,t,i){return this.handlers.push({fulfilled:e,rejected:t,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){a.forEach(this.handlers,function(i){i!==null&&e(i)})}}const rt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},bs={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:we,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},ve=typeof window<"u"&&typeof document<"u",Se=typeof navigator=="object"&&navigator||void 0,_s=ve&&(!Se||["ReactNative","NativeScript","NS"].indexOf(Se.product)<0),gs=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",ws=ve&&window.location.href||"http://localhost",T={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ve,hasStandardBrowserEnv:_s,hasStandardBrowserWebWorkerEnv:gs,navigator:Se,origin:ws},Symbol.toStringTag,{value:"Module"})),...bs};function vs(s,e){return le(s,new T.classes.URLSearchParams,{visitor:function(t,i,n,r){return T.isNode&&a.isBuffer(t)?(this.append(i,t.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...e})}function Ss(s){return a.matchAll(/\w+|\[(\w*)]/g,s).map(e=>e[0]==="[]"?"":e[1]||e[0])}function Rs(s){const e={},t=Object.keys(s);let i;const n=t.length;let r;for(i=0;i<n;i++)r=t[i],e[r]=s[r];return e}function ot(s){function e(t,i,n,r){let o=t[r++];if(o==="__proto__")return!0;const l=Number.isFinite(+o),u=r>=t.length;return o=!o&&a.isArray(n)?n.length:o,u?(a.hasOwnProp(n,o)?n[o]=[n[o],i]:n[o]=i,!l):((!n[o]||!a.isObject(n[o]))&&(n[o]=[]),e(t,i,n[o],r)&&a.isArray(n[o])&&(n[o]=Rs(n[o])),!l)}if(a.isFormData(s)&&a.isFunction(s.entries)){const t={};return a.forEachEntry(s,(i,n)=>{e(Ss(i),n,t,0)}),t}return null}function Es(s,e,t){if(a.isString(s))try{return(e||JSON.parse)(s),a.trim(s)}catch(i){if(i.name!=="SyntaxError")throw i}return(t||JSON.stringify)(s)}const ee={transitional:rt,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const i=t.getContentType()||"",n=i.indexOf("application/json")>-1,r=a.isObject(e);if(r&&a.isHTMLForm(e)&&(e=new FormData(e)),a.isFormData(e))return n?JSON.stringify(ot(e)):e;if(a.isArrayBuffer(e)||a.isBuffer(e)||a.isStream(e)||a.isFile(e)||a.isBlob(e)||a.isReadableStream(e))return e;if(a.isArrayBufferView(e))return e.buffer;if(a.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let l;if(r){if(i.indexOf("application/x-www-form-urlencoded")>-1)return vs(e,this.formSerializer).toString();if((l=a.isFileList(e))||i.indexOf("multipart/form-data")>-1){const u=this.env&&this.env.FormData;return le(l?{"files[]":e}:e,u&&new u,this.formSerializer)}}return r||n?(t.setContentType("application/json",!1),Es(e)):e}],transformResponse:[function(e){const t=this.transitional||ee.transitional,i=t&&t.forcedJSONParsing,n=this.responseType==="json";if(a.isResponse(e)||a.isReadableStream(e))return e;if(e&&a.isString(e)&&(i&&!this.responseType||n)){const o=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(l){if(o)throw l.name==="SyntaxError"?y.from(l,y.ERR_BAD_RESPONSE,this,null,this.response):l}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:T.classes.FormData,Blob:T.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};a.forEach(["delete","get","head","post","put","patch"],s=>{ee.headers[s]={}});const As=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),xs=s=>{const e={};let t,i,n;return s&&s.split(`
`).forEach(function(o){n=o.indexOf(":"),t=o.substring(0,n).trim().toLowerCase(),i=o.substring(n+1).trim(),!(!t||e[t]&&As[t])&&(t==="set-cookie"?e[t]?e[t].push(i):e[t]=[i]:e[t]=e[t]?e[t]+", "+i:i)}),e},lt=Symbol("internals");function te(s){return s&&String(s).trim().toLowerCase()}function ae(s){return s===!1||s==null?s:a.isArray(s)?s.map(ae):String(s)}function Os(s){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let i;for(;i=t.exec(s);)e[i[1]]=i[2];return e}const Ts=s=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(s.trim());function Re(s,e,t,i,n){if(a.isFunction(i))return i.call(this,e,t);if(n&&(e=t),!!a.isString(e)){if(a.isString(i))return e.indexOf(i)!==-1;if(a.isRegExp(i))return i.test(e)}}function ks(s){return s.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,i)=>t.toUpperCase()+i)}function Cs(s,e){const t=a.toCamelCase(" "+e);["get","set","has"].forEach(i=>{Object.defineProperty(s,i+t,{value:function(n,r,o){return this[i].call(this,e,n,r,o)},configurable:!0})})}let N=class{constructor(e){e&&this.set(e)}set(e,t,i){const n=this;function r(l,u,c){const h=te(u);if(!h)throw new Error("header name must be a non-empty string");const f=a.findKey(n,h);(!f||n[f]===void 0||c===!0||c===void 0&&n[f]!==!1)&&(n[f||u]=ae(l))}const o=(l,u)=>a.forEach(l,(c,h)=>r(c,h,u));if(a.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(a.isString(e)&&(e=e.trim())&&!Ts(e))o(xs(e),t);else if(a.isObject(e)&&a.isIterable(e)){let l={},u,c;for(const h of e){if(!a.isArray(h))throw TypeError("Object iterator must return a key-value pair");l[c=h[0]]=(u=l[c])?a.isArray(u)?[...u,h[1]]:[u,h[1]]:h[1]}o(l,t)}else e!=null&&r(t,e,i);return this}get(e,t){if(e=te(e),e){const i=a.findKey(this,e);if(i){const n=this[i];if(!t)return n;if(t===!0)return Os(n);if(a.isFunction(t))return t.call(this,n,i);if(a.isRegExp(t))return t.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=te(e),e){const i=a.findKey(this,e);return!!(i&&this[i]!==void 0&&(!t||Re(this,this[i],i,t)))}return!1}delete(e,t){const i=this;let n=!1;function r(o){if(o=te(o),o){const l=a.findKey(i,o);l&&(!t||Re(i,i[l],l,t))&&(delete i[l],n=!0)}}return a.isArray(e)?e.forEach(r):r(e),n}clear(e){const t=Object.keys(this);let i=t.length,n=!1;for(;i--;){const r=t[i];(!e||Re(this,this[r],r,e,!0))&&(delete this[r],n=!0)}return n}normalize(e){const t=this,i={};return a.forEach(this,(n,r)=>{const o=a.findKey(i,r);if(o){t[o]=ae(n),delete t[r];return}const l=e?ks(r):String(r).trim();l!==r&&delete t[r],t[l]=ae(n),i[l]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return a.forEach(this,(i,n)=>{i!=null&&i!==!1&&(t[n]=e&&a.isArray(i)?i.join(", "):i)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const i=new this(e);return t.forEach(n=>i.set(n)),i}static accessor(e){const i=(this[lt]=this[lt]={accessors:{}}).accessors,n=this.prototype;function r(o){const l=te(o);i[l]||(Cs(n,o),i[l]=!0)}return a.isArray(e)?e.forEach(r):r(e),this}};N.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),a.reduceDescriptors(N.prototype,({value:s},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>s,set(i){this[t]=i}}}),a.freezeMethods(N);function Ee(s,e){const t=this||ee,i=e||t,n=N.from(i.headers);let r=i.data;return a.forEach(s,function(l){r=l.call(t,r,n.normalize(),e?e.status:void 0)}),n.normalize(),r}function at(s){return!!(s&&s.__CANCEL__)}function K(s,e,t){y.call(this,s??"canceled",y.ERR_CANCELED,e,t),this.name="CanceledError"}a.inherits(K,y,{__CANCEL__:!0});function ct(s,e,t){const i=t.config.validateStatus;!t.status||!i||i(t.status)?s(t):e(new y("Request failed with status code "+t.status,[y.ERR_BAD_REQUEST,y.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function Ns(s){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(s);return e&&e[1]||""}function Ps(s,e){s=s||10;const t=new Array(s),i=new Array(s);let n=0,r=0,o;return e=e!==void 0?e:1e3,function(u){const c=Date.now(),h=i[r];o||(o=c),t[n]=u,i[n]=c;let f=r,g=0;for(;f!==n;)g+=t[f++],f=f%s;if(n=(n+1)%s,n===r&&(r=(r+1)%s),c-o<e)return;const S=h&&c-h;return S?Math.round(g*1e3/S):void 0}}function Ls(s,e){let t=0,i=1e3/e,n,r;const o=(c,h=Date.now())=>{t=h,n=null,r&&(clearTimeout(r),r=null),s(...c)};return[(...c)=>{const h=Date.now(),f=h-t;f>=i?o(c,h):(n=c,r||(r=setTimeout(()=>{r=null,o(n)},i-f)))},()=>n&&o(n)]}const ce=(s,e,t=3)=>{let i=0;const n=Ps(50,250);return Ls(r=>{const o=r.loaded,l=r.lengthComputable?r.total:void 0,u=o-i,c=n(u),h=o<=l;i=o;const f={loaded:o,total:l,progress:l?o/l:void 0,bytes:u,rate:c||void 0,estimated:c&&l&&h?(l-o)/c:void 0,event:r,lengthComputable:l!=null,[e?"download":"upload"]:!0};s(f)},t)},ut=(s,e)=>{const t=s!=null;return[i=>e[0]({lengthComputable:t,total:s,loaded:i}),e[1]]},ht=s=>(...e)=>a.asap(()=>s(...e)),Fs=T.hasStandardBrowserEnv?((s,e)=>t=>(t=new URL(t,T.origin),s.protocol===t.protocol&&s.host===t.host&&(e||s.port===t.port)))(new URL(T.origin),T.navigator&&/(msie|trident)/i.test(T.navigator.userAgent)):()=>!0,U