@jinntec/fore 2.3.0 → 2.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/fore.js CHANGED
@@ -5,5 +5,5 @@ function e(e,t,n,r){const a={op:t,func:n,data:r};return e.push(a),a}function t(e
5
5
  * @license MIT licensed
6
6
  *
7
7
  * Copyright (C) 2018 Varun A P
8
- */;class Lt{constructor(e){this.defaults={oldestFirst:!0,text:"Toastify is awesome!",node:void 0,duration:3e3,selector:void 0,callback:function(){},destination:void 0,newWindow:!1,close:!1,gravity:"toastify-top",positionLeft:!1,position:"",backgroundColor:"",avatar:"",className:"",stopOnFocus:!0,onClick:function(){},offset:{x:0,y:0},escapeMarkup:!0,style:{background:""}},this.version="1.11.2",this.options={},this.toastElement=null,this._rootElement=document.body,this._init(e)}showToast(){if(this.toastElement=this._buildToast(),"string"==typeof this.options.selector?this._rootElement=document.getElementById(this.options.selector):this.options.selector instanceof HTMLElement||this.options.selector instanceof ShadowRoot?this._rootElement=this.options.selector:this._rootElement=document.body,!this._rootElement)throw"Root element is not defined";return this._rootElement.insertBefore(this.toastElement,this._rootElement.firstChild),this._reposition(),this.options.duration>0&&(this.toastElement.timeOutValue=window.setTimeout((()=>{this._removeElement(this.toastElement)}),this.options.duration)),this}hideToast(){this.toastElement.timeOutValue&&clearTimeout(this.toastElement.timeOutValue),this._removeElement(this.toastElement)}_init(e){this.options=Object.assign(this.defaults,e),this.options.backgroundColor,this.toastElement=null,this.options.gravity="bottom"===e.gravity?"toastify-bottom":"toastify-top",this.options.stopOnFocus=void 0===e.stopOnFocus||e.stopOnFocus,e.backgroundColor&&(this.options.style.background=e.backgroundColor)}_buildToast(){if(!this.options)throw"Toastify is not initialized";let e=document.createElement("div");e.className=`toastify on ${this.options.className}`,e.className+=` toastify-${this.options.position}`,e.className+=` ${this.options.gravity}`;for(const t in this.options.style)e.style[t]=this.options.style[t];if(this.options.node&&this.options.node.nodeType===Node.ELEMENT_NODE)e.appendChild(this.options.node);else if(this.options.escapeMarkup?e.innerText=this.options.text:e.innerHTML=this.options.text,""!==this.options.avatar){let t=document.createElement("img");t.src=this.options.avatar,t.className="toastify-avatar","left"==this.options.position?e.appendChild(t):e.insertAdjacentElement("afterbegin",t)}if(!0===this.options.close){let t=document.createElement("span");t.innerHTML="&#10006;",t.className="toast-close",t.addEventListener("click",(e=>{e.stopPropagation(),this._removeElement(this.toastElement),window.clearTimeout(this.toastElement.timeOutValue)}));const n=window.innerWidth>0?window.innerWidth:screen.width;"left"==this.options.position&&n>360?e.insertAdjacentElement("afterbegin",t):e.appendChild(t)}if(this.options.stopOnFocus&&this.options.duration>0&&(e.addEventListener("mouseover",(t=>{window.clearTimeout(e.timeOutValue)})),e.addEventListener("mouseleave",(()=>{e.timeOutValue=window.setTimeout((()=>{this._removeElement(e)}),this.options.duration)}))),void 0!==this.options.destination&&e.addEventListener("click",(e=>{e.stopPropagation(),!0===this.options.newWindow?window.open(this.options.destination,"_blank"):window.location=this.options.destination})),"function"==typeof this.options.onClick&&void 0===this.options.destination&&e.addEventListener("click",(e=>{e.stopPropagation(),this.options.onClick()})),"object"==typeof this.options.offset){const t=this._getAxisOffsetAValue("x",this.options),n=this._getAxisOffsetAValue("y",this.options),r="left"==this.options.position?t:`-${t}`,a="toastify-top"==this.options.gravity?n:`-${n}`;e.style.transform=`translate(${r},${a})`}return e}_removeElement(e){e.className=e.className.replace(" on",""),window.setTimeout((()=>{this.options.node&&this.options.node.parentNode&&this.options.node.parentNode.removeChild(this.options.node),e.parentNode&&e.parentNode.removeChild(e),this.options.callback.call(e),this._reposition()}),400)}_reposition(){let e,t={top:15,bottom:15},n={top:15,bottom:15},r={top:15,bottom:15},a=this._rootElement.querySelectorAll(".toastify");for(let s=0;s<a.length;s++){e=!0===a[s].classList.contains("toastify-top")?"toastify-top":"toastify-bottom";let o=a[s].offsetHeight;e=e.substr(9,e.length-1);let i=15;(window.innerWidth>0?window.innerWidth:screen.width)<=360?(a[s].style[e]=`${r[e]}px`,r[e]+=o+i):!0===a[s].classList.contains("toastify-left")?(a[s].style[e]=`${t[e]}px`,t[e]+=o+i):(a[s].style[e]=`${n[e]}px`,n[e]+=o+i)}}_getAxisOffsetAValue(e,t){return t.offset[e]?isNaN(t.offset[e])?t.offset[e]:`${t.offset[e]}px`:"0px"}}function $t(e){return new Lt(e)}class Pt extends HTMLElement{static get properties(){return{avatar:{type:String},backgroundColor:{type:String},callback:{type:String},classProp:{type:String},close:{type:Boolean},destination:{type:String},duration:{type:Number},escapeMarkup:{type:Boolean},gravity:{type:String},newWindow:{type:Boolean},oldestFirst:{type:Boolean},position:{type:String},selector:{type:String},stopOnFocus:{type:Boolean},text:{type:String}}}constructor(){super(),this.attachShadow({mode:"open"})}_initVar(e,t){return this.hasAttribute(e)?this.getAttribute(e):t}connectedCallback(){this.avatar=this._initVar("avatar",""),this.backgroundColor=this._initVar("backgroundColor",""),this.callback=this._initVar("callback",{}),this.classProp=this._initVar("data-class",""),this.close="true"===this._initVar("close",!1),this.destination=this._initVar("destination",void 0),this.duration=Number(this._initVar("duration",3e3)),this.escapeMarkup="true"===this._initVar("escapeMarkup","true"),this.gravity=this._initVar("gravity","top"),this.newWindow="true"===this._initVar("newWindow","false"),this.offSet=this._initVar("offSet",{}),this.oldestFirst="true"===this._initVar("oldestFirst","true"),this.position=this._initVar("position","right"),this.stopOnFocus="true"===this._initVar("stopOnFocus","true"),this.text=this._initVar("text","");this.shadowRoot.innerHTML=`\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n ${this.renderHTML}\n `,this.addEventListener("jinn-toast",(e=>{this.showToast(e.detail.text)}))}disconnectedCallback(){this.removeEventListener("jinn-toast",this.showToast)}showToast(e){new $t({avatar:this.avatar,className:this.classProp,close:this.close,destination:this.destination,duration:this.duration,escapeMarkup:this.escapeMarkup,gravity:this.gravity,newWindow:!1,offset:this.offset,oldestFirst:this.oldestFirst,position:this.position,node:this.shadowRoot,stopOnFocus:this.stopOnFocus,text:e}).showToast()}renderHTML(){return"\n <slot></slot>\n "}}customElements.get("jinn-toast")||window.customElements.define("jinn-toast",Pt);const _t=(e,t)=>class extends e{static get properties(){return{...e.properties,dnd:{type:Boolean}}}constructor(){super()}connectedCallback(){this.drop=e=>this._drop(e),this.addEventListener("drop",this.drop),this.dragOver=e=>this._dragOver(e),this.addEventListener("dragover",this.dragOver),this.dragLeave=e=>this._dragLeave(e),this.addEventListener("dragleave",this.dragLeave),this.dragEnd=e=>this._dragEnd(e),this.addEventListener("dragend",this._dragEnd)}disconnectedCallback(){this.removeEventListener("drop",this.drop),this.removeEventListener("dragover",this.dragOver),this.removeEventListener("dragleave",this.dragLeave),this.removeEventListener("dragend",this.dragEnd)}_dragOver(e){if(e.target.classList.contains("no-drop"))return!1;e.stopPropagation();const t=e.target.closest("fx-repeatitem");if(!this.getOwnerForm().draggedItem)return;if(this===this.getOwnerForm().draggedItem)return;const{draggedItem:n}=this.getOwnerForm();this.accepts(n)?this.classList.remove("no-drop"):this.classList.add("no-drop");const r=this.hasAttribute("id")?this:this.closest("[id]"),a=n.hasAttribute("id")?n:n.closest("[id]");r?.id===a?.id&&(t!==this.getOwnerForm().draggedItem&&this.classList.add("drag-over"),e.preventDefault())}_dragLeave(e){this.classList.remove("drag-over"),this.classList.remove("no-drop")}_dragEnd(e){const t=this.getOwnerForm().draggedItem;"copy"===t.getAttribute("drop-action")&&t.remove(),this.classList.remove("drag-over")}_getDataNode(){const e=this.getOwnerForm().draggedItem?.getModelItem()?.node;if(!e)return null;const{draggedItem:t}=this.getOwnerForm(),n=this.hasAttribute("id")?this:this.closest("[id]"),r=t.hasAttribute("id")?t:t.closest("[id]");return n?.id!==r?.id?null:e}accepts(e){if(!this.hasAttribute("accept"))return;const t=this.getAttribute("accept");return e.matches(t)}_drop(e){if(this.classList.remove("drag-over"),e.stopPropagation(),"fx-droptarget"===this.localName){this.children.length;let{draggedItem:t}=this.getOwnerForm();if("copy"===t.getAttribute("drop-action")&&(t=t.cloneNode(!0)),!this.accepts(t))return void this.classList.remove("no-drop");if(t===this)return;if("fx-droptarget"===t.localName){if(this.hasAttribute("drop-position"))return this.replaceChildren(t),void e.preventDefault();this.parentNode.lastElementChild===this?(this.parentNode.append(t),e.stopImmediatePropagation()):t===this.previousElementSibling?this.parentNode.insertBefore(t,this.nextElementSibling):this.parentNode.insertBefore(t,this)}else this.appendChild(t);return e.preventDefault(),this.getOwnerForm().getModel().updateModel(),void this.getOwnerForm().refresh(!0)}const t=this._getDataNode();if(t){if("fx-repeat"===this.localName){e.preventDefault();let n=this.nodeset;if(Array.isArray(n)&&!n.length){Ot(this.getAttributeNode("ref")||this,this.ref).append(t)}else n=n[n.length-1],n.after(t)}else if("fx-repeatitem"===this.localName){const e=this.getModelItem().node;e.previousSibling===t?e.after(t):e.before(t)}this.getOwnerForm().getModel().updateModel(),this.getOwnerForm().refresh(!0)}}};class Ht extends(_t(Mt)){static get properties(){return{...super.properties,index:{type:Number},template:{type:Object},focusOnCreate:{type:String},initDone:{type:Boolean},repeatIndex:{type:Number},repeatSize:{type:Number},nodeset:{type:Array}}}constructor(){super(),this.ref="",this.dataTemplate=[],this.isDraggable=null,this.focusOnCreate="",this.initDone=!1,this.repeatIndex=1,this.nodeset=[],this.inited=!1,this.host={},this.index=1,this.repeatSize=0,this.attachShadow({mode:"open",delegatesFocus:!0})}get repeatSize(){return this.querySelectorAll(":scope > .fx-repeatitem").length}set repeatSize(e){super.repeatSize=e}setIndex(e){this.index=e;const t=this.querySelector("[data-ref]").querySelectorAll(":scope > *");this.applyIndex(t[this.index-1])}applyIndex(e){this._removeIndexMarker(),e&&e.setAttribute("repeat-index","")}get index(){return parseInt(this.getAttribute("index"),10)}set index(e){this.setAttribute("index",e)}_getRepeatedItems(){return this.querySelector("[data-ref]").children}async connectedCallback(){this.ref=this.getAttribute("ref"),this.addEventListener("item-changed",(e=>{const{item:t}=e.detail,n=this._getRepeatedItems(),r=Array.from(n).indexOf(t);this.applyIndex(n[r]),this.index=r+1})),document.addEventListener("index-changed",(e=>{if(e.stopPropagation(),!e.target===this)return;const{index:t}=e.detail;this.index=Number(t),this.applyIndex(this.children[t-1])})),this.mutationObserver=new MutationObserver((e=>{if("childList"===e[0].type){const t=e[0].addedNodes[0];if(t){const e=nt.resolveInstance(this,this.ref),n=nt.getPath(t,e);Ft.dispatch(this,"path-mutated",{path:n,index:this.index})}}})),this.getOwnerForm().registerLazyElement(this);this.shadowRoot.innerHTML="\n <style>\n \n :host{\n }\n .fade-out-bottom {\n -webkit-animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n }\n .fade-out-bottom {\n -webkit-animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n }\n \n </style>\n \n <slot></slot>\n \n "}async init(){return new Promise((e=>{this._evalNodeset(),this._initTemplate(),this.setAttribute("index",this.index),this.inited=!0,e("done")}))}_getRef(){return this.getAttribute("ref")}_evalNodeset(){const e=Ot(this.getAttributeNode("ref")||this,this.ref);this.mutationObserver&&e.nodeName&&this.mutationObserver.observe(e,{childList:!0,subtree:!0});const t=wt(this.ref,e,this);1===t.length&&Array.isArray(t[0])?this.nodeset=t[0]:this.nodeset=t}async refresh(e){this.inited||this.init(),this._evalNodeset();let t=this.querySelectorAll(".fx-repeatitem"),n=t.length,r=1;Array.isArray(this.nodeset)&&(r=this.nodeset.length);const a=r;if(a<n)for(let e=n;e>a;e-=1){const n=t[e-1];n.parentNode.removeChild(n),this.getOwnerForm().unRegisterLazyElement(n),this.getOwnerForm().someInstanceDataStructureChanged=!0}if(a>n)for(let e=n+1;e<=a;e+=1){const t=this._clone();if(!t)return;this.querySelector("[data-ref]").appendChild(t),t.classList.add("fx-repeatitem"),t.setAttribute("index",e),t.addEventListener("click",this._dispatchIndexChange),t.addEventListener("focusin",this._dispatchIndexChange),this.getOwnerForm().someInstanceDataStructureChanged=!0}t=this.querySelectorAll(":scope > .fx-repeatitem"),n=t.length;for(let e=0;e<n;e+=1){const n=t[e];this.getOwnerForm().registerLazyElement(n),n.nodeset!==this.nodeset[e]&&(n.nodeset=this.nodeset[e])}this.getOwnerForm().lazyRefresh&&!e||Ft.refreshChildren(this,e),this.setIndex(this.index)}_dispatchIndexChange(){this.dispatchEvent(new CustomEvent("item-changed",{composed:!1,bubbles:!0,detail:{item:this,index:this.index}}))}_fadeOut(e){e.style.opacity=1,function t(){(e.style.opacity-=.1)<0?e.style.display="none":requestAnimationFrame(t)}()}_fadeIn(e){e&&(e.style.opacity=0,e.style.display=this.display,function t(){let n=parseFloat(e.style.opacity);(n+=.1)>1||(e.style.opacity=n,requestAnimationFrame(t))}())}async _initTemplate(){this.template=this.querySelector("template"),this.template&&this.shadowRoot.appendChild(this.template)}_initVariables(e){const t=new Map(this.inScopeVariables);e.setInScopeVariables(t),function e(n){for(const r of n.children)"setInScopeVariables"in r&&r.setInScopeVariables(t),e(r)}(e)}_clone(){if(this.template=this.shadowRoot.querySelector("template"),this.template)return this.template.content.firstElementChild.cloneNode(!0)}_removeIndexMarker(){const e=this.querySelector("[data-ref]");Array.from(e.children).forEach((e=>{e.removeAttribute("repeat-index")}))}setInScopeVariables(e){this.inScopeVariables=new Map(e)}}customElements.get("fx-repeat-attributes")||window.customElements.define("fx-repeat-attributes",Ht);const jt="clean",Xt="dirty";class qt extends HTMLElement{static get properties(){return{ignoreExpressions:{type:String},mergePartial:{type:Boolean},lazyRefresh:{type:Boolean},model:{type:Object},ready:{type:Boolean},strict:{type:Boolean},validateOn:{type:String},version:{type:String}}}constructor(){super(),this.version="Version: 2.3.0 - built on September 18, 2024 16:21:26",this.model={},this.inited=!1,this.addEventListener("message",this._displayMessage),this.addEventListener("error",this._logError),this.addEventListener("warn",this._displayWarning),window.addEventListener("compute-exception",(e=>{})),this.ready=!1,this.storedTemplateExpressionByNode=new Map,this.outermostHandler=null,this.copiedElements=new WeakSet,this.dirtyState=jt,this.showConfirmation=!1;this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML='\n <style>\n \n :host {\n display: block;\n }\n :host ::slotted(fx-model){\n display:none;\n }\n\n #modalMessage .dialogActions{\n text-align:center;\n }\n .overlay {\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n background: rgba(0, 0, 0, 0.7);\n transition: all 500ms;\n visibility: hidden;\n opacity: 0;\n z-index:10;\n }\n .overlay.show {\n visibility: visible;\n opacity: 1;\n }\n\n .popup {\n margin: 70px auto;\n background: #fff;\n border-radius: 5px;\n width: 30%;\n position: relative;\n transition: all 5s ease-in-out;\n padding: 20px;\n\n }\n .popup h2 {\n margin-top: 0;\n width:100%;\n background:#eee;\n position:absolute;\n top:0;\n right:0;\n left:0;\n height:40px;\n border-radius: 5px;\n\n }\n .popup .close {\n position: absolute;\n top: 3px;\n right: 10px;\n transition: all 200ms;\n font-size: 30px;\n font-weight: bold;\n text-decoration: none;\n color: #333;\n }\n .popup .close:focus{\n outline:none;\n }\n\n .popup .close:hover {\n color: #06D85F;\n }\n #messageContent{\n margin-top:40px;\n }\n .warning{\n background:orange;\n }\n \n </style>\n \n\x3c!-- <slot name="errors"></slot> --\x3e\n <jinn-toast id="message" gravity="bottom" position="left"></jinn-toast>\n <jinn-toast id="sticky" gravity="bottom" position="left" duration="-1" close="true" data-class="sticky-message"></jinn-toast>\n <jinn-toast id="error" text="error" duration="-1" data-class="error" close="true" position="right" gravity="top" escape-markup="false"></jinn-toast>\n <jinn-toast id="warn" text="warning" duration="5000" data-class="warning" position="left" gravity="top"></jinn-toast>\n <slot id="default"></slot>\n <slot name="messages"></slot>\n <div id="modalMessage" class="overlay">\n <div class="popup">\n <h2></h2>\n <a class="close" href="#" onclick="event.target.parentNode.parentNode.classList.remove(\'show\')" autofocus>&times;</a>\n <div id="messageContent"></div>\n </div>\n </div>\n <slot name="event"></slot>\n \n ',this.toRefresh=[],this.initialRun=!0,this._scanForNewTemplateExpressionsNextRefresh=!1,this.repeatsFromAttributesCreated=!1,this.validateOn=this.hasAttribute("validate-on")?this.getAttribute("validate-on"):"update",this.mergePartial=!1}connectedCallback(){if(this.style.visibility="hidden",this.strict=!!this.hasAttribute("strict"),this.ignoreExpressions=this.hasAttribute("ignore-expressions")?this.getAttribute("ignore-expressions"):null,this.lazyRefresh=this.hasAttribute("refresh-on-view"),this.lazyRefresh){const e={root:null,rootMargin:"0px",threshold:.3};this.intersectionObserver=new IntersectionObserver(this.handleIntersect,e)}if(this.src=this.hasAttribute("src")?this.getAttribute("src"):null,this.src)return void this._loadFromSrc();this._injectDevtools();this.shadowRoot.querySelector("slot#default").addEventListener("slotchange",(async e=>{if(this.inited)return;if(this.hasAttribute("convert"))return void this.replaceWith(Ft.copyDom(this));this.ignoreExpressions&&(this.ignoredNodes=Array.from(this.querySelectorAll(this.ignoreExpressions)));let t=e.target.assignedElements().find((e=>"FX-MODEL"===e.nodeName.toUpperCase()));if(!t){const e=document.createElement("fx-model");return this.appendChild(e),void(t=e)}if(!t.inited){const e=new Map;!function t(n){for(const r of n.children)"setInScopeVariables"in r&&r.setInScopeVariables(e),t(r)}(this),await t.modelConstruct(),this._handleModelConstructDone()}this.model=t,this._createRepeatsFromAttributes(),this.inited=!0})),this.addEventListener("path-mutated",(()=>{this.someInstanceDataStructureChanged=!0})),this.addEventListener("refresh",(()=>{this.refresh(!0)})),this.hasAttribute("show-confirmation")&&(this.showConfirmation=!0)}_injectDevtools(){if(this.ownerDocument.querySelector("fx-devtools"))return;const{search:e}=window.location;if(new URLSearchParams(e).has("inspect")){const e=document.createElement("fx-devtools");document.body.appendChild(e)}}addToRefresh(e){this.toRefresh.find((t=>t.path===e.path))||this.toRefresh.push(e)}scanForNewTemplateExpressionsNextRefresh(){this._scanForNewTemplateExpressionsNextRefresh=!0}markAsClean(){this.addEventListener("value-changed",(()=>{this.dirtyState=Xt}),{once:!0}),this.dirtyState=jt}async _loadFromSrc(){await Ft.loadForeFromSrc(this,this.src,"fx-fore")}handleIntersect(e,t){e.forEach((e=>{const{target:t}=e;Ft.getFore(t).initialRun||e.isIntersecting&&(t.classList.add("loaded"),"function"==typeof t.refresh?t.refresh(t,!0):Ft.refreshChildren(t,!0))})),e[0].target.getOwnerForm().dispatchEvent(new CustomEvent("refresh-done"))}evaluateToNodes(e,t){return bt(e,t,this)}disconnectedCallback(){this.removeEventListener("dragstart",this.dragstart)}async forceRefresh(){Ft.refreshChildren(this,!0),this._updateTemplateExpressions(),this._scanForNewTemplateExpressionsNextRefresh=!1,this._processTemplateExpressions(),Ft.dispatch(this,"refresh-done",{})}async refresh(e){if(this.isRefreshing)return;this.isRefreshing=!0,e||this.initialRun||0===this.toRefresh.length?this.inited&&Ft.refreshChildren(this,!0):(this.toRefresh.forEach((t=>{const n=t.boundControls;n&&n.forEach((t=>{t.refresh(e)}));const{mainGraph:r}=this.getModel();if(r&&r.hasNode(t.path)){const n=this.getModel().mainGraph.dependentsOf(t.path,!1);0!==n.length&&n.forEach((t=>{const n=nt.getBasePath(t);this.getModel().modelItems.find((e=>e.path===n)).boundControls.forEach((t=>{t.refresh(e)}))}))}})),this.toRefresh=[]),(this.initialRun||this._scanForNewTemplateExpressionsNextRefresh)&&(this._updateTemplateExpressions(),this._scanForNewTemplateExpressionsNextRefresh=!1),this._processTemplateExpressions(),this.style.visibility="visible",Ft.dispatch(this,"refresh-done",{});const t=Array.from(this.querySelectorAll("fx-fore"));for(const e of t)e.ready&&await e.refresh(!1);this.isRefreshing=!1}_updateTemplateExpressions(){const e=bt("(descendant-or-self::*!(text(), @*))[contains(., '{')][substring-after(., '{') => contains('}')][not(ancestor-or-self::fx-model)]",this,this);this.storedTemplateExpressions||(this.storedTemplateExpressions=[]),Array.from(e).forEach((e=>{if((e.nodeType===Node.ATTRIBUTE_NODE?e.ownerElement:e.parentNode).closest("fx-fore")!==this)return;if(this.storedTemplateExpressionByNode.has(e))return;const t=this._getTemplateExpression(e);t&&this.storedTemplateExpressionByNode.set(e,t)})),this._processTemplateExpressions()}_processTemplateExpressions(){for(const e of Array.from(this.storedTemplateExpressionByNode.keys())){if(e.nodeType===Node.ATTRIBUTE_NODE){if(!nt.contains(this,e.ownerElement)){this.storedTemplateExpressionByNode.delete(e);continue}}else if(!nt.contains(this,e)){this.storedTemplateExpressionByNode.delete(e);continue}this._processTemplateExpression({node:e,expr:this.storedTemplateExpressionByNode.get(e)})}}_processTemplateExpression(e){const{expr:t}=e,{node:n}=e;this.evaluateTemplateExpression(t,n)}evaluateTemplateExpression(e,t){if(t.nodeType===Node.ATTRIBUTE_NODE&&t.ownerElement.closest("[nonrelevant]"))return;if(t.nodeType===Node.TEXT_NODE&&t.parentNode.closest("[nonrelevant]"))return;if(t.nodeType===Node.ELEMENT_NODE&&t.closest("[nonrelevant]"))return;const n=e.replace(/{[^}]*}/g,(e=>{if("{}"===e)return e;const n=e.substring(1,e.length-1),r=Ot(t,n);if(!r)return(t.nodeType===Node.TEXT_NODE||t.nodeType===Node.ATTRIBUTE_NODE)&&t.parentNode,e;const a=nt.getInstanceId(n);a?this.getModel().getInstance(a):this.getModel().getDefaultInstance();try{return At(n,r,t,null)}catch(t){return e}}));if(t.nodeType===Node.ATTRIBUTE_NODE){const e=t.ownerElement;e.getAttribute(t.nodeName)!==n&&e.setAttribute(t.nodeName,n)}else t.nodeType===Node.TEXT_NODE&&t.textContent!==n&&(t.textContent=n)}_getTemplateExpression(e){if(this.ignoredNodes){e.nodeType===Node.ATTRIBUTE_NODE&&(e=e.ownerElement);const t=this.ignoredNodes.find((t=>t.contains(e)));if(t)return null}return e.nodeType===Node.ATTRIBUTE_NODE?e.value:e.nodeType===Node.TEXT_NODE?e.textContent.trim():null}_handleModelConstructDone(){this.markAsClean(),this.showConfirmation&&window.addEventListener("beforeunload",(e=>this.dirtyState===Xt&&(e.preventDefault(),!0))),this._initUI()}async _lazyCreateInstance(){const e=this.querySelector("fx-model"),t=this.parentNode.nodeType!==Node.DOCUMENT_FRAGMENT_NODE?this.parentNode.closest("fx-fore"):null;if(this.parentNode.nodeType,Node.DOCUMENT_FRAGMENT_NODE,t){if(0!==t.getModel().instances.filter((e=>e.hasAttribute("shared"))).length)return}try{if(0===e.instances.length){const t=document.createElement("fx-instance");e.appendChild(t);const n=document.implementation.createDocument(null,"data",null);this._generateInstance(this,n.firstElementChild),t.instanceData=n,e.instances.push(t),Ft.dispatch(this,"instance-loaded",{instance:this})}}catch(e){}}_generateInstance(e,t){if(e.hasAttribute("ref")&&!Ft.isActionElement(e.nodeName)){const n=e.getAttribute("ref");if(n.includes("/")){n.split("/").forEach((n=>{t=this._generateNode(t,n,e)}))}else t=this._generateNode(t,n,e)}if(e.hasChildNodes()){const n=e.children;for(let e=0;e<n.length;e+=1)this._generateInstance(n[e],t)}return t}_generateNode(e,t,n){const r=e.ownerDocument.createElement(t);return 0===n.children.length&&(r.textContent=n.textContent),e.appendChild(r),e=r}async _initUI(){this.initialRun&&(this.classList.add("initialRun"),await this._lazyCreateInstance(),await this.refresh(!0),this.classList.add("fx-ready"),document.body.classList.add("fx-ready"),this.ready=!0,this.initialRun=!1,Ft.dispatch(this,"ready",{}),this.addEventListener("dragstart",this._handleDragStart),this.handleDrop=e=>this._handleDrop(e),this.ownerDocument.body.addEventListener("drop",this.handleDrop),this.ownerDocument.body.addEventListener("dragover",(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move"})))}_handleDragStart(e){const t=e.target.closest('[draggable="true"]');this.originalDraggedItem=t,"copy"===t.getAttribute("drop-action")?(e.dataTransfer.dropEffect="copy",e.dataTransfer.effectAllowed="copy",this.draggedItem=t.cloneNode(!0),this.draggedItem.setAttribute("drop-action","move"),this.copiedElements.add(this.draggedItem)):(e.dataTransfer.dropEffect="move",e.dataTransfer.effectAllowed="move",this.draggedItem=t)}_handleDrop(e){this.draggedItem&&("none"===e.dataTransfer.dropEffect&&this.copiedElements.has(this.originalDraggedItem)&&this.originalDraggedItem.remove(),this.originalDraggedItem=null,this.draggedItem=null,e.stopPropagation())}registerLazyElement(e){this.intersectionObserver&&this.intersectionObserver.observe(e)}unRegisterLazyElement(e){this.intersectionObserver&&this.intersectionObserver.unobserve(e)}getModel(){return this.querySelector("fx-model")}_displayMessage(e){const{level:t}=e.detail,n=e.detail.message;this._showMessage(t,n),e.stopPropagation()}_displayError(e){const t=e.detail.message;this.shadowRoot.querySelector("#error").showToast(t)}_displayWarning(e){const t=e.detail.message,n=nt.shortenPath(At("path()",e.target,this));this.shadowRoot.querySelector("#warn").showToast(`WARN: ${n}:${t}`)}_logError(e){e.stopPropagation(),e.preventDefault(),e.detail.expr,this.strict&&this._displayError(e)}_copyToClipboard(e){navigator.clipboard.writeText(e.value)}_showMessage(e,t){if("modal"===e)this.shadowRoot.getElementById("messageContent").innerText=t,this.shadowRoot.getElementById("modalMessage").classList.add("show");else if("sticky"===e||"error"===e||"warn"===e)this.shadowRoot.querySelector(`#${e}`).showToast(t);else{this.shadowRoot.querySelector("#message").showToast(t)}}_createRepeatsFromAttributes(){if(this.repeatsFromAttributesCreated)return;const e=this.querySelectorAll("[data-ref]");e&&Array.from(e).forEach((e=>{if(e.closest("fx-control"))return;const t=e.parentNode.closest("table");let n;n=t?t.cloneNode(!0):e.cloneNode(!0);const r=new Ht;r.setAttribute("ref",e.getAttribute("data-ref")),r.appendChild(n),t?(t.parentNode.insertBefore(r,t),t.parentNode.removeChild(t)):(e.parentNode.insertBefore(r,e),e.parentNode.removeChild(e)),e.setAttribute("insertPoint","")})),this.repeatsFromAttributesCreated=!0}}qt.outermostHandler=null,qt.draggedItem=null,customElements.get("fx-fore")||customElements.define("fx-fore",qt);class Vt{static handleRelevance(e){const t=e.getModelItem();t&&t.relevant?(e.removeAttribute("nonrelevant"),e.setAttribute("relevant",""),Ft.dispatch(this,"relevant",{})):(e.removeAttribute("relevant"),e.setAttribute("nonrelevant",""),Ft.dispatch(this,"nonrelevant",{}))}static selectRelevant(e,t){return"xml"===t?Vt._relevantXmlNodes(e):e.nodeset}static _relevantXmlNodes(e){if("keep"===e.getAttribute("nonrelevant"))return e.nodeset;const t=e.getModel().getModelItem(e.nodeset);if(t&&!t.relevant)return null;const n=e.nodeset.cloneNode(!1);return 0===e.nodeset.children.length&&Vt._isRelevant(e,e.nodeset)?e.nodeset:Vt._filterRelevant(e,e.nodeset,n)}static _filterRelevant(e,t,n){const{childNodes:r}=t;return Array.from(r).forEach((t=>{if(Vt._isRelevant(e,t)){const r=t.cloneNode(!1);n.appendChild(r);const{attributes:a}=t;return a&&Array.from(a).forEach((t=>{"empty"!==e.nonrelevant||Vt._isRelevant(e,t)?Vt._isRelevant(e,t)?r.setAttribute(t.nodeName,t.value):r.removeAttribute(t.nodeName):r.setAttribute(t.nodeName,"")})),Vt._filterRelevant(e,t,r)}return null})),n}static _isRelevant(e,t){const n=e.getModel().getModelItem(t);return(t.nodeType!==Node.ATTRIBUTE_NODE||""!==t.nodeValue)&&(!n||!!n.relevant)}}class Yt extends Mt{constructor(){super(),this.attachShadow({mode:"open"}),this.credentials="",this.parameters=new Map}connectedCallback(){this.methods=["get","put","post","delete","head","urlencoded-post"],this.model=this.parentNode,this.hasAttribute("id"),this.id=this.getAttribute("id"),this.instance=this.hasAttribute("instance")?this.getAttribute("instance"):null,this.into=this.hasAttribute("into")?this.getAttribute("into"):null,this.method=this.hasAttribute("method")?this.getAttribute("method"):"get",this.nonrelevant=this.hasAttribute("nonrelevant")?this.getAttribute("nonrelevant"):"remove",this.replace=this.hasAttribute("replace")?this.getAttribute("replace"):"all",this.serialization=this.hasAttribute("serialization")?this.getAttribute("serialization"):"xml",this.mediatype=this.hasAttribute("mediatype")?this.getAttribute("mediatype"):"application/xml",this.responseMediatype=this.hasAttribute("response-mediatype")?this.getAttribute("response-mediatype"):this.mediatype,this.url=this.hasAttribute("url")?this.getAttribute("url"):null,this.targetref=this.hasAttribute("targetref")?this.getAttribute("targetref"):null,this.validate=this.getAttribute("validate")?this.getAttribute("validate"):"true",this.credentials=this.hasAttribute("credentials")?this.getAttribute("credentials"):"same-origin",["same-origin","include","omit"].includes(this.credentials),this.shadowRoot.innerHTML=this.renderHTML()}renderHTML(){return"\n <slot></slot>\n "}async submit(){await Ft.dispatch(this,"submit",{submission:this}),await this._submit()}async _submit(){this.evalInContext();const e=this.getModel();if(e.recalculate(),"true"===this.validate&&"get"!==this.method){if(!e.revalidate())return this.getOwnerForm().classList.add("submit-validation-failed"),Ft.dispatch(this,"submit-error",{}),void this.getModel().parentNode.refresh(!0)}await this._serializeAndSend()}_getProperty(e){return this.parameters.has(e)?this.parameters.get(e):this.getAttribute(e)}async _serializeAndSend(){const e=this._getProperty("url"),t=this.evaluateAttributeTemplateExpression(e,this),n=this.getInstance();n||Ft.dispatch(this,"warn",{message:`instance not found ${n.getAttribute("id")}`});const r=n.getAttribute("type");let a;if("none"===this.serialization)a=void 0;else{const e=Vt.selectRelevant(this,r);a=this._serialize(r,e)}if("get"===this.method.toLowerCase()&&(a=void 0),t.startsWith("#echo")){const e=this._parse(a,n);return this._handleResponse(e),Ft.dispatch(this,"submit-done",{}),void this.parameters.clear()}if(t.startsWith("localStore:")){if("get"===this.method||"consume"===this.method){this.replace="instance";const e=t.substring(t.indexOf(":")+1),r=localStorage.getItem(e);if(!r)return Ft.dispatch(this,"submit-error",{message:`Error reading key ${e} from localstorage`}),void this.parameters.clear();const a=this._parse(r,n);this._handleResponse(a),"consume"===this.method&&localStorage.removeItem(e),Ft.dispatch(this,"submit-done",{})}if("post"===this.method){const e=t.substring(t.indexOf(":")+1);localStorage.setItem(e,a),this._handleResponse(n.instanceData),Ft.dispatch(this,"submit-done",{})}if("delete"===this.method){const e=t.substring(t.indexOf(":")+1);localStorage.removeItem(e);const n=(new DOMParser).parseFromString("<data></data>","application/xml");this.replace="instance",this._handleResponse(n),Ft.dispatch(this,"submit-done",{})}return}const s=this._getHeaders();if(this.methods.includes(this.method.toLowerCase()))try{const e=await fetch(t,{method:this.method,credentials:this.credentials,mode:"cors",headers:s,body:a});if(!e.ok||e.status>400)return void Ft.dispatch(this,"submit-error",{message:`Error while submitting ${this.id}`});const n=e.headers.get("content-type").toLowerCase();if(n.startsWith("text/")){const r=await e.text();this._handleResponse(r,t,n)}else if(n.startsWith("application/json")){const r=await e.json();this._handleResponse(r,t,n)}else if(n.startsWith("application/xml")){const r=await e.text(),a=(new DOMParser).parseFromString(r,"application/xml");this._handleResponse(a,t,n)}else{const r=await e.blob();this._handleResponse(r,t,n)}Ft.dispatch(this,"submit-done",{})}catch(e){Ft.dispatch(this,"submit-error",{error:e.message})}finally{this.parameters.clear();const e=document.querySelector("[download]");e&&document.body.removeChild(e)}else Ft.dispatch(this,"error",{message:`Unknown method ${this.method}`})}_parse(e,t){let n=null;return e&&"xml"===t.getAttribute("type")&&(n=(new DOMParser).parseFromString(e,"application/xml")),e&&"json"===t.getAttribute("type")&&(n=JSON.parse(e)),e&&"text"===t.getAttribute("type")&&(n=e),n}_serialize(e,t){if("application/x-www-form-urlencoded"===this.serialization){const e=new URLSearchParams;return Array.from(t.children).forEach((t=>{e.append(t.nodeName,t.textContent)})),e}if("xml"===e){return(new XMLSerializer).serializeToString(t)}if("json"===e)return JSON.stringify(t);if("text"===e)return t;throw new Error("unknown instance type ",e)}_getHeaders(){const e=new Headers,t=this.getInstance(),n=Ft.getContentType(t,this.serialization);e.append("Content-Type",n),e.has("Accept")&&e.delete("Accept");const r=this.querySelectorAll("fx-header");return Array.from(r).forEach((t=>{const{name:n}=t,r=t.getValue();e.append(n,r)})),e}_getUrlExpr(){return this.storedTemplateExpressions.find((e=>"url"===e.node.nodeName))}_getTargetInstance(){let e;if(e=this.instance?this.model.getInstance(this.instance):this.model.getInstance("default"),!e)throw new Error(`target instance not found: ${e}`);return e}_handleResponse(e,t,n){const r=this._getTargetInstance();if("instance"===this.replace){if(!r)throw new Error(`target instance not found: ${r}`);if(this.targetref){const[t]=wt(this.targetref,r.instanceData.firstElementChild,this),n=e.firstElementChild;t.parentNode.replaceChild(n,t)}else if(this.into){const[t]=wt(this.into,r.instanceData.firstElementChild,this);e.nodeType===Node.DOCUMENT_NODE?t.appendChild(e.firstElementChild):t.innerHTML=e}else{const t=e;r.instanceData=t}this.model.inited&&(this.model.updateModel(),this.getOwnerForm().refresh(!0))}if("download"===this.replace){const t=this._getProperty("target"),r=document.createElement("a");r.setAttribute("download",t),r.setAttribute("href",`data:${n},${e}`),document.body.appendChild(r),r.click()}if("all"===this.replace){const n=this._getProperty("target");if(n&&"_blank"===n){const t=window.open("","_blank");t.document.write(`<pre>${e}</pre>`),t.document.close()}else document.open(),document.write(e),document.close(),window.location.href=t}if("target"===this.replace&&n.startsWith("text/html")){const t=this._getProperty("target"),n=document.querySelector(t);n?n.innerHTML=e:Ft.dispatch(this,"submit-error",{message:`targetNode for selector ${t} not found`})}"redirect"===this.replace&&(window.location.href=e)}_handleError(){Ft.dispatch(this,"submit-error",{})}}customElements.get("fx-submission")||customElements.define("fx-submission",Yt);class zt extends Mt{constructor(){if(super(),this.style.display="none",this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML="",!this.hasAttribute("name"))throw new Error('required attribute "name" missing');this.name=this.getAttribute("name")}connectedCallback(){this.shadowRoot.innerHTML=""}}customElements.get("fx-header")||customElements.define("fx-header",zt);const Jt=He("item()*");class Qt extends Mt{constructor(){super(),this.attachShadow({mode:"open"}),this.name="",this.valueQuery="",this.value=null,this.precedingVariables=[]}connectedCallback(){this.name=this.getAttribute("name"),this.valueQuery=this.getAttribute("value")}refresh(){const e=Ot(this,this.valueQuery),t=wt(this.valueQuery,e,this,this.precedingVariables);this.value=Jt(t,je)}setInScopeVariables(e){e.has(this.name)?Ft.dispatch(this,"xforms-binding-error",{}):(e.set(this.name,this),this.inScopeVariables=new Map(e))}}customElements.get("fx-var")||customElements.define("fx-var",Qt);class Kt extends Mt{constructor(){super(),this.value=null,this.display=this.style.display,this.required=!1,this.readonly=!1,this.widget=null,this.visited=!1,this.force=!1}getWidget(){throw new Error("You have to implement the method getWidget!")}async refresh(e){e&&(this.force=!0);const t=this.value;var n,r,a;if(!this.isNotBound()&&(this.oldVal=this.nodeset?this.nodeset:null,this.evalInContext(),this.isBound())){if(!this.nodeset){if(this.closest("[create]")){let e,t,n;if(this.ref.includes("/")){t=this.ref.substring(0,this.ref.indexOf("/"));n=vt(t,Ot(this.parentNode,this.ref),this),n&&n.nodeType===Node.ELEMENT_NODE&&(this.ref.includes("@")?(e=this.ref.substring(this.ref.indexOf("/")+2),n.setAttribute(e,"")):Ft.dispatch(this,"warn",{message:'"create" is not implemented for elements'}))}else{const t=Ot(this,this.ref);this.ref.includes("@")?(e=this.ref.substring(this.ref.indexOf("@")+1),t.setAttribute(e,"")):Ft.dispatch(this,"warn",{message:'"create" is not implemented for elements'})}}else this.setAttribute("nonrelevant","");return}if(this.modelItem=this.getModelItem(),this.modelItem instanceof kt){if(this.hasAttribute("as")&&"node"===this.getAttribute("as")?(this.modelItem.node=this.nodeset,this.value=this.modelItem.node):this.value=this.modelItem.value,this.modelItem.boundControls.includes(this)||this.modelItem.boundControls.push(this),await this.updateWidgetValue(),this.handleModelItemProperties(),this.getOwnerForm().initialRun&&Ft.dispatch(this,"init",{}),!this.getOwnerForm().ready)return;if("fx-control"!==this.localName)return;n=this.oldVal,r=this.value,a=t,null!==n&&(a&&r&&a.nodeType&&r.nodeType?a.outerHTML!==r.outerHTML:r!==a)&&Ft.dispatch(this,"value-changed",{path:this.modelItem.path,value:this.modelItem.value,oldvalue:this.oldVal})}}}refreshFromModelItem(e){}async updateWidgetValue(){throw new Error("You have to implement the method updateWidgetValue!")}handleModelItemProperties(){this.handleRequired(),this.handleReadonly(),this.getOwnerForm().ready&&this.handleValid(),this.handleRelevant()}_getForm(){return this.getModel().parentNode}_dispatchEvent(e){this.getOwnerForm().ready&&Ft.dispatch(this,e,{})}handleRequired(){this.widget=this.getWidget();const e=this.isRequired();if(!this.modelItem.required)return this.widget.removeAttribute("required"),this.removeAttribute("required"),void(e!==this.modelItem.required&&this._dispatchEvent("optional"));(this.visited||this.force)&&(""===this.modelItem.value?(this.classList.add("isEmpty"),this._toggleValid(!1)):(this.classList.remove("isEmpty"),this._toggleValid(!0))),this.widget.setAttribute("required",""),this.setAttribute("required",""),e!==this.modelItem.required&&this._dispatchEvent("required")}_updateRequired(){this.modelItem.required?((this.visited||this.force)&&(""===this.modelItem.value?(this.classList.add("isEmpty"),this._toggleValid(!1)):(this.classList.remove("isEmpty"),this._toggleValid(!0))),this.widget.setAttribute("required",""),this.setAttribute("required",""),this._dispatchEvent("required")):(this.widget.removeAttribute("required"),this.removeAttribute("required"),this._dispatchEvent("optional"))}_toggleValid(e){e?(this.removeAttribute("invalid"),this.setAttribute("valid","")):(this.removeAttribute("valid"),this.setAttribute("invalid",""))}handleReadonly(){this.isReadonly()!==this.modelItem.readonly&&(this.modelItem.readonly&&(this.widget.setAttribute("readonly",""),this.setAttribute("readonly",""),this._dispatchEvent("readonly")),this.modelItem.readonly||(this.widget.removeAttribute("readonly"),this.removeAttribute("readonly"),this._dispatchEvent("readwrite")))}handleValid(){if(this.isValid()!==this.modelItem.constraint)if(this.modelItem.constraint)this._dispatchEvent("valid"),this.setAttribute("valid",""),this.removeAttribute("invalid");else{if(this.setAttribute("invalid",""),this.removeAttribute("valid"),0!==this.modelItem.alerts.length){if(!this.querySelector("fx-alert")){const{alerts:e}=this.modelItem;e.forEach((e=>{const t=document.createElement("fx-alert");t.innerHTML=e,this.appendChild(t)}))}}this._dispatchEvent("invalid")}}handleRelevant(){const e=this.modelItem.node;if(this.removeAttribute("relevant"),this.removeAttribute("nonrelevant"),Array.isArray(e)&&0===e.length)return this._dispatchEvent("nonrelevant"),void this.setAttribute("nonrelevant","");this.isEnabled()!==this.modelItem.relevant&&(this.modelItem.relevant?(this._dispatchEvent("relevant"),this.setAttribute("relevant","")):(this._dispatchEvent("nonrelevant"),this.setAttribute("nonrelevant","")))}isRequired(){return this.hasAttribute("required")}isValid(){return!this.hasAttribute("invalid")}isReadonly(){return this.hasAttribute("readonly")}isEnabled(){return!this.hasAttribute("nonrelevant")}_fadeOut(e){e.style.opacity=1,function t(){(e.style.opacity-=.1)<0?e.style.display="none":requestAnimationFrame(t)}()}_fadeIn(e,t){e.style.opacity=0,e.style.display=t||"block",function t(){let n=parseFloat(e.style.opacity);(n+=.1)>1||(e.style.opacity=n,requestAnimationFrame(t))}()}}customElements.get("fx-abstract-control")||window.customElements.define("fx-abstract-control",Kt);class Wt extends Kt{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.shadowRoot.innerHTML="\n <style>\n \n :host {\n height: auto;\n font-size: 0.8em;\n font-weight: 400;\n color: red;\n }\n \n </style>\n \n <slot></slot>\n \n "}getWidget(){return this}async updateWidgetValue(){this.innerHTML=this.value}}customElements.get("fx-alert")||customElements.define("fx-alert",Wt);class Zt extends Kt{constructor(){super(),this.inited=!1,this.attachShadow({mode:"open"})}static get properties(){return{...Kt.properties,credentials:{type:String},initial:{type:Boolean},src:{type:String}}}_getValueFromHtmlDom(){return"selectedOptions"===this.valueProp?[...this.widget.selectedOptions].map((e=>e.value)).join(" "):this.widget[this.valueProp]}connectedCallback(){this.initial=this.hasAttribute("initial")?this.getAttribute("initial"):null,this.src=this.hasAttribute("src")?this.getAttribute("src"):null,this.loaded=!1,this.initialNode=null,this.debounceDelay=this.hasAttribute("debounce")?this.getAttribute("debounce"):null,this.updateEvent=this.hasAttribute("update-event")?this.getAttribute("update-event"):"blur",this.label=this.hasAttribute("label")?this.getAttribute("label"):null;this.credentials=this.hasAttribute("credentials")?this.getAttribute("credentials"):"same-origin",["same-origin","include","omit"].includes(this.credentials),this.shadowRoot.innerHTML=`\n <style>\n \n :host{\n display:inline-block;\n }\n \n </style>\n ${this.renderHTML(this.ref)}\n `,this.widget=this.getWidget(),this.addEventListener("mousedown",(e=>{Ft.isWidget(e.target)||e.target?.classList.contains("fx-hint")||e.preventDefault(),this.widget.focus()}));const e=this.widget.hasAttribute("multiple")?"selectedOptions":"value";this.valueProp=this.hasAttribute("value-prop")?this.getAttribute("value-prop"):e;let t=this.widget;if(this.hasAttribute("listen-on")){const e=this.getAttribute("listen-on"),n=this.querySelector(e);n&&(t=n)}this.addEventListener("keyup",(()=>{Rt.dataChanged=!0})),"enter"===this.updateEvent&&(this.widget.addEventListener("keyup",(e=>{13===e.keyCode&&(e.preventDefault(),this.setValue(this._getValueFromHtmlDom()))})),this.updateEvent="blur"),this.debounceDelay?t.addEventListener(this.updateEvent,function(e,t,n=300){let r;return(...a)=>{clearTimeout(r),r=setTimeout((()=>{t.apply(e,a)}),n)}}(this,(()=>{this.setValue(this._getValueFromHtmlDom())}),this.debounceDelay)):(t.addEventListener(this.updateEvent,(e=>{this.setValue(this._getValueFromHtmlDom())})),t.addEventListener("blur",(e=>{this.setValue(this._getValueFromHtmlDom())}),{once:!0})),this.addEventListener("return",(e=>{const t=e.detail.nodeset;e.stopPropagation(),this._replaceNode(t)})),this.widget.addEventListener("focus",(()=>{})),this.template=this.querySelector("template"),this.boundInitialized=!1,this.static=!!this.widget.hasAttribute("static")}_debounce(e,t=300){let n;return(...r)=>{const a=this;clearTimeout(n),n=setTimeout((()=>{e.apply(a,r)}),t)}}setValue(e){const t=this.getModelItem();if(this.getAttribute("class")?this.classList.add("visited"):this.setAttribute("class","visited"),t?.readonly)return;if("node"===this.getAttribute("as")){const e=this.shadowRoot.getElementById("replace"),n=this.getWidget()[this.valueProp];return e.replace(this.nodeset,n),void(t&&n&&n!==t.value&&(t.value=n,Rt.dataChanged=!0,e.actionPerformed()))}const n=this.shadowRoot.getElementById("setvalue");n.setValue(t,e),this.modelItem instanceof kt&&!this.modelItem?.boundControls.includes(this)&&this.modelItem.boundControls.push(this),n.actionPerformed()}_replaceNode(e){e.nodeType===Node.ATTRIBUTE_NODE?this.modelItem.node.nodeValue=e.nodeValue:e.nodeType===Node.ELEMENT_NODE?this.modelItem.node.replaceWith(e.cloneNode(!0)):e.nodeType===Node.TEXT_NODE?this.modelItem.node.nodeValue=e.textContent:Ft.dispatch(this,"warn",{message:"trying to replace a node that is neither an Attribute, Elemment or Text node"})}renderHTML(e){return`\n ${this.label?`${this.label}`:""}\n <slot></slot>\n ${this.hasAttribute("as")&&"node"===this.getAttribute("as")?'<fx-replace id="replace" ref=".">':`<fx-setvalue id="setvalue" ref="${e}"></fx-setvalue>`}\n\n `}getWidget(){if(this.widget)return this.widget;let e=this.querySelector(".widget");if(e||(e=this.querySelector("input"),e&&!e.classList.contains("widget")&&e.classList.add("widget")),!e){const e=document.createElement("input");return e.classList.add("widget"),e.setAttribute("type","text"),this.appendChild(e),e}return e}async updateWidgetValue(){let{widget:e}=this;if(e||(e=this),"checked"!==this.valueProp)if("radio"!==this.widget.type)if("selectedOptions"!==this.valueProp)if(this.hasAttribute("as")){const t=this.getAttribute("as");if("text"===t){const t=new XMLSerializer,n=Ft.prettifyXml(t.serializeToString(this.nodeset));e.value=n}if("node"===t&&this.nodeset!==e.value){const t=this.nodeset;if(e.value&&t!==this.widget.value)return void(e.value=this.nodeset.cloneNode(!0));e.value=this.nodeset.cloneNode(!0)}}else{if(this.src&&!this.loaded&&this.modelItem.relevant)return this.initial&&(this.initialNode=vt(this.initial,this.nodeset,this)),await this._loadForeFromSrc(),void(this.loaded=!0);e.value!==this.value&&(e.value=this.value)}else{const e=new Set(this.value.split(" "));for(const t of[...this.widget.querySelectorAll("option")])e.has(t.value)?t.selected=!0:t.selected=!1}else{const e=this.querySelector(`input[value=${this.value}]`);e&&(e.checked=!0)}else"true"===this.value?e.checked=!0:e.checked=!1}async _loadForeFromSrc(){try{const e=await fetch(this.src,{method:"GET",credentials:this.credentials,mode:"cors",headers:{"Content-Type":"text/html"}});let t;t=e.headers.get("content-type").toLowerCase().startsWith("text/html")?await e.text().then((e=>(new DOMParser).parseFromString(e,"text/html"))):"done";const n=t.querySelector("fx-fore"),r=document.importNode(n,!0);r.classList.add("widget"),r.addEventListener("model-construct-done",(e=>{const t=r.querySelector("fx-instance");if(this.initial){const e=(new DOMParser).parseFromString("<data></data>","application/xml");this.initialNode=vt(this.initial,this.nodeset,this),e.firstElementChild.appendChild(this.initialNode.cloneNode(!0)),t.instanceData=e}r.model=r.querySelector("fx-model"),r.model.updateModel(),r.refresh(!0)}),{once:!0});const a=this.querySelector("input");this.hasAttribute("shadow")?(a.parentNode.removeChild(a),this.shadowRoot.appendChild(r)):this.loaded||a.replaceWith(r),n||Ft.dispatch("error",{detail:{message:`Fore element not found in '${this.src}'. Maybe wrapped within 'template' element?`}}),Ft.dispatch("loaded",{detail:{fore:n}})}catch(e){Ft.dispatch(this,"error",{origin:this,message:`control couldn't be loaded from src '${this.src}'`,level:"Error"})}}getTemplate(){return this.querySelector("template")}async refresh(e){super.refresh(e);const t=this.getWidget();this._handleBoundWidget(t),this._handleDataAttributeBinding(),Ft.refreshChildren(this,e)}_handleDataAttributeBinding(){const e=this.querySelector("[data-ref]");e&&e.closest("fx-control")===this&&(this.boundList=e,e.getAttribute("data-ref"),this._handleBoundWidget(e))}_handleBoundWidget(e){if(this.boundInitialized&&this.static)return;const t=e.hasAttribute("ref")?e.getAttribute("ref"):e.getAttribute("data-ref");if(e&&t){const n=wt(t,Ot(this,t),this),{children:r}=e;if(Array.from(r).forEach((e=>{"template"!==e.nodeName.toLowerCase()&&e.parentNode.removeChild(e)})),Array.isArray(n)&&0===n.length)return;const{template:a}=this;if(a){if("SELECT"===this.widget.nodeName&&this.widget.hasAttribute("selection")&&"open"===this.widget.getAttribute("selection")){const e=this.template.firstElementChild,t=document.createElement("option");this.widget.insertBefore(t,e)}if(0!==n.length){const e=document.createDocumentFragment();Array.from(n).forEach((t=>{const n=this.createEntry();e.appendChild(n),this.updateEntry(n,t)})),this.template.parentNode.appendChild(e)}else{const e=this.createEntry();this.template.parentNode.appendChild(e),this.updateEntry(e,n)}this.boundInitialized=!0}if("selectedOptions"===this.valueProp){const e=new Set(this.value.split(" ")),t=this.getWidget().querySelectorAll("option");for(const n of[...t])e.has(n.value)?n.selected=!0:n.selected=!1}}}updateEntry(e,t){const n=this._getValueAttribute(e);if(!n)return;const r=n.value,a=At(r.substring(1,r.length-1),t,e);n.value=a,this.value===a&&e.setAttribute("selected","selected");const s=e.textContent;this.evalLabel(s,t,e)}evalLabel(e,t,n){const r=e.substring(1,e.length-1);if(!r)return;const a=At(r,t,this);n.textContent=a}createEntry(){return this.template.content.firstElementChild.cloneNode(!0)}_getValueAttribute(e){let t;return Array.from(e.attributes).forEach((e=>{-1!==e.value.indexOf("{")&&(t=e)})),t}}customElements.get("fx-control")||window.customElements.define("fx-control",Zt);class en extends Mt{static get properties(){return{...super.properties}}constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.src=this.hasAttribute("src")?this.getAttribute("src"):null;this.shadowRoot.innerHTML="\n <style>\n \n :host {\n display: block;\n }\n \n </style>\n \n <slot></slot>\n \n ",this.getOwnerForm().registerLazyElement(this)}async refresh(e){!e&&this.hasAttribute("refresh-on-view")||this.isBound()&&(this.evalInContext(),this.modelItem=this.getModelItem(),this.modelItem&&!this.modelItem.boundControls.includes(this)&&this.modelItem.boundControls.push(this),this.handleModelItemProperties())}handleModelItemProperties(){this.handleRelevant()}_getForm(){return this.getModel().parentNode}handleRelevant(){if(!this.modelItem)return this.removeAttribute("relevant",""),this.setAttribute("nonrelevant",""),void this.dispatchEvent(new CustomEvent("disabled",{}));this.isEnabled()!==this.modelItem.enabled&&(this.modelItem.relevant?(this.removeAttribute("nonrelevant",""),this.setAttribute("relevant",""),this.dispatchEvent(new CustomEvent("enabled",{}))):(this.removeAttribute("relevant",""),this.setAttribute("nonrelevant",""),this.dispatchEvent(new CustomEvent("disabled",{}))))}isReadonly(){return!!this.hasAttribute("readonly")}isEnabled(){return"none"!==this.style.display}}customElements.get("fx-container")||window.customElements.define("fx-container",en);class tn extends en{static get properties(){return{...super.properties,collapse:{type:Boolean,reflect:!0}}}constructor(){super(),this.collapse=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","group")}render(){return"\n <slot></slot>\n "}handleModelItemProperties(){this.handleRelevant()}initializeChildren(e){Array.from(e.children).forEach((e=>{if(Ft.isUiElement(e.nodeName))e.init(this.model);else if(0!==e.children.length){Array.from(e.children).forEach((e=>{this.initializeChildren(e)}))}}))}async refresh(e){super.refresh(e),Ft.refreshChildren(this,e)}}customElements.get("fx-group")||window.customElements.define("fx-group",tn);class nn extends Kt{static get styles(){return"\n :host {\n display: block;\n height: auto;\n font-size: 0.8em;\n font-weight: 400;\n font-style: italic;\n }\n "}static get properties(){return{...super.properties}}render(){return"\n <slot></slot>\n "}}customElements.get("fx-hint")||customElements.define("fx-hint",nn);class rn extends Kt{constructor(){super(),this.attachShadow({mode:"open"}),this.valueAttr=this.hasAttribute("value")?this.getAttribute("value"):null,this.readonly=!0}connectedCallback(){this.shadowRoot.innerHTML='\n <style>\n \n :host {\n display: inline-block;\n max-width:100%;\n }\n #widget {\n display: inline-block;\n }\n .label{\n display: inline-block;\n }\n #value{\n max-width:100%;\n }\n \n </style>\n \n <slot name="label"></slot>\n \n <span id="value">\n <slot name="default"></slot>\n </span>\n \n ',this.mediatype=this.hasAttribute("mediatype")?this.getAttribute("mediatype"):null}async refresh(){this.ref&&await super.refresh(),this.valueAttr&&(this.value=this.getValue(),await this.updateWidgetValue())}getValue(){try{const e=Ot(this,this.valueAttr);return this.hasAttribute("html")?wt(this.valueAttr,e,this)[0]:function(e,t,n,r=null){try{const a=ft(e,t,n);return Qe(e,t,r,{},{currentContext:{formElement:n},functionNameResolver:gt,moduleImports:{xf:ot},namespaceResolver:a})}catch(t){n.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,detail:{origin:n,message:`Expression '${e}' failed`,expr:e,level:"Error"}}))}}(this.valueAttr,e,this)[0]}catch(e){Ft.dispatch(this,"error",{message:e})}return null}getWidget(){return this.shadowRoot.getElementById("value")}handleReadonly(){this.setAttribute("readonly","readonly")}async updateWidgetValue(){const e=this.shadowRoot.getElementById("value");if(e.innerHTML="","html"!==this.mediatype){if("image"===this.mediatype){const t=document.createElement("img");return t.setAttribute("src",this.value),this.innerHTML="",void e.appendChild(t)}e.innerHTML=this.value}else if(this.modelItem.node){this.shadowRoot.querySelector("#default");const{node:t}=this.modelItem;if(t.nodeType)return void e.append(t);const n=(new DOMParser).parseFromString(t,"text/html").body.childNodes;return void Array.from(n).forEach((t=>{e.append(t)}))}}isReadonly(){return!0}}customElements.get("fx-output")||customElements.define("fx-output",rn);class an extends(_t(Mt)){static get properties(){return{inited:{type:Boolean}}}constructor(){super(),this.inited=!1,this.addEventListener("click",this._dispatchIndexChange),this.addEventListener("focusin",this._dispatchIndexChange),this.attachShadow({mode:"open",delegatesFocus:!0}),this.dropTarget=null}connectedCallback(){super.connectedCallback(),this.display=this.style.display;this.shadowRoot.innerHTML="\n \n <slot></slot>\n \n ",this.getOwnerForm().registerLazyElement(this),this.ref=`${this.parentNode.ref}`,this.tabindex=0}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this._dispatchIndexChange),this.removeEventListener("focusin",this._handleFocus)}init(){this.inited=!0}_dispatchIndexChange(){this.parentNode.index!==this.index&&this.dispatchEvent(new CustomEvent("item-changed",{composed:!1,bubbles:!0,detail:{item:this,index:this.index}}))}refresh(e){this.modelItem=this.getModelItem(),this.modelItem.boundControls.includes(this)||(this.modelItem.boundControls.push(this),this.modelItem&&!this.modelItem.relevant?(this.removeAttribute("relevant"),this.setAttribute("nonrelevant","")):(this.removeAttribute("nonrelevant"),this.setAttribute("relevant",""))),Ft.refreshChildren(this,e)}}customElements.get("fx-repeatitem")||window.customElements.define("fx-repeatitem",an);class sn extends(_t(Mt)){static get properties(){return{...super.properties,index:{type:Number},template:{type:Object},focusOnCreate:{type:String},initDone:{type:Boolean},repeatIndex:{type:Number},nodeset:{type:Array}}}constructor(){super(),this.ref="",this.dataTemplate=[],this.isDraggable=null,this.dropTarget=null,this.focusOnCreate="",this.initDone=!1,this.repeatIndex=1,this.nodeset=[],this.inited=!1,this.index=1,this.repeatSize=0,this.attachShadow({mode:"open",delegatesFocus:!0})}get repeatSize(){return this.querySelectorAll(":scope > fx-repeatitem").length}set repeatSize(e){this.size=e}setIndex(e){this.index=e;const t=this.querySelectorAll(":scope > fx-repeatitem");this.applyIndex(t[this.index-1]),this.getOwnerForm().refresh(!0)}applyIndex(e){this._removeIndexMarker(),e&&e.setAttribute("repeat-index","")}get index(){return parseInt(this.getAttribute("index"),10)}set index(e){this.setAttribute("index",e)}_getRef(){return this.getAttribute("ref")}connectedCallback(){super.connectedCallback(),this.ref=this.getAttribute("ref"),this.addEventListener("item-changed",(e=>{const{item:t}=e.detail,n=Array.from(this.children).indexOf(t);this.setIndex(n+1)})),document.addEventListener("index-changed",(e=>{if(e.stopPropagation(),!e.target===this)return;const{index:t}=e.detail;this.index=parseInt(t,10),this.applyIndex(this.children[t-1])})),this.mutationObserver=new MutationObserver((e=>{if("childList"===e[0].type){const t=e[0].addedNodes[0];if(t){const e=nt.resolveInstance(this,this.ref),n=nt.getPath(t,e);Ft.dispatch(this,"path-mutated",{path:n,index:this.index})}}})),this.getOwnerForm().registerLazyElement(this);this.shadowRoot.innerHTML='\n <style>\n \n :host{\n }\n .fade-out-bottom {\n -webkit-animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n }\n .fade-out-bottom {\n -webkit-animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n }\n \n </style>\n \n <slot name="header"></slot>\n <slot></slot>\n \n '}_createNewRepeatItem(){const e=document.createElement("fx-repeatitem");this.isDraggable&&(e.setAttribute("draggable","true"),e.setAttribute("tabindex",0));const t=this._clone();return e.appendChild(t),e}init(){this._evalNodeset(),this._initTemplate(),this._initRepeatItems(),this.setAttribute("index",this.index),this.inited=!0}_evalNodeset(){const e=Ot(this.getAttributeNode("ref")||this,this.ref);this.mutationObserver&&e.nodeName&&this.mutationObserver.observe(e,{childList:!0,subtree:!0});const t=wt(this.ref,e,this);1===t.length&&Array.isArray(t[0])?this.nodeset=t[0]:this.nodeset=t}async refresh(e){this.inited||this.init(),this._evalNodeset();const t=this.querySelectorAll(":scope > fx-repeatitem"),n=t.length;let r=1;Array.isArray(this.nodeset)&&(r=this.nodeset.length);const a=r;if(a<n)for(let e=n;e>a;e-=1){const n=t[e-1];n.parentNode.removeChild(n),this.getOwnerForm().unRegisterLazyElement(n)}if(a>n)for(let e=n+1;e<=a;e+=1){const t=this._createNewRepeatItem();this.appendChild(t),this._initVariables(t),t.nodeset=this.nodeset[e-1],t.index=e,this.getOwnerForm().scanForNewTemplateExpressionsNextRefresh()}for(let e=0;e<n;e+=1){const n=t[e];this.getOwnerForm().registerLazyElement(n),n.nodeset!==this.nodeset[e]&&(n.nodeset=this.nodeset[e])}this.getOwnerForm().lazyRefresh&&!e||Ft.refreshChildren(this,e),this.setIndex(this.index)}_fadeOut(e){e.style.opacity=1,function t(){(e.style.opacity-=.1)<0?e.style.display="none":requestAnimationFrame(t)}()}_fadeIn(e){e&&(e.style.opacity=0,e.style.display=this.display,function t(){let n=parseFloat(e.style.opacity);(n+=.1)>1||(e.style.opacity=n,requestAnimationFrame(t))}())}_initTemplate(){this.template=this.querySelector("template"),this.dropTarget=this.template.getAttribute("drop-target"),this.isDraggable=this.template.hasAttribute("draggable")?this.template.getAttribute("draggable"):null,null===this.template&&this.dispatchEvent(new CustomEvent("no-template-error",{composed:!0,bubbles:!0,detail:{message:`no template found for repeat:${this.id}`}})),this.shadowRoot.appendChild(this.template)}_initRepeatItems(){this.nodeset.forEach(((e,t)=>{const n=this._createNewRepeatItem();n.nodeset=this.nodeset[t],n.index=t+1,this.appendChild(n),1===n.index&&this.applyIndex(n),Ft.dispatch(this,"item-created",{nodeset:n.nodeset,pos:t+1}),this._initVariables(n)}))}_initVariables(e){const t=new Map(this.inScopeVariables);e.setInScopeVariables(t),function e(n){for(const r of n.children)"setInScopeVariables"in r&&r.setInScopeVariables(t),e(r)}(e)}_clone(){this.template=this.shadowRoot.querySelector("template");const e=this.template.content.cloneNode(!0);return document.importNode(e,!0)}_removeIndexMarker(){Array.from(this.children).forEach((e=>{e.removeAttribute("repeat-index")}))}setInScopeVariables(e){this.inScopeVariables=new Map(e)}}customElements.get("fx-repeat")||window.customElements.define("fx-repeat",sn);class on extends en{constructor(){super(),this.formerCase={},this.selectedCase=null,this.cases=null}connectedCallback(){super.connectedCallback&&super.connectedCallback();this.shadowRoot.innerHTML="\n <style>\n \n :host ::slotted(fx-case.selected-case){\n display: block !important;\n }\n \n </style>\n \n <slot></slot>\n \n ",this.cases=[],this.formerCase=null,this.selectedCase=null}async refresh(e){super.refresh(e),0===this.cases.length&&(this.cases=Array.from(this.querySelectorAll(":scope > fx-case"))),this.isBound()&&this._handleBoundSwitch(),this.selectedCase||(this.selectedCase=this.cases[0],this.toggle(this.selectedCase)),Ft.refreshChildren(this.selectedCase,e)}_dispatchEvents(){this.selectedCase!==this.formerCase&&(this.formerCase&&this.formerCase!==this.selectedCase&&Ft.dispatch(this.formerCase,"deselect",{}),this.selectedCase.classList.contains("selected-case")&&Ft.dispatch(this.selectedCase,"select",{}))}_resetVisited(){const e=this.selectedCase.querySelectorAll(".visited");Array.from(e).forEach((e=>{e.classList.remove("visited")}))}_handleBoundSwitch(){Array.from(this.cases).forEach((e=>{e.getAttribute("name")===this.modelItem?.value&&this.toggle(e)}))}async replaceCase(e,t){this.cases.splice(this.cases.indexOf(e),1,t),e===this.selectedCase?(this.selectedCase=t,this.formerCase=t,t.classList.add("selected-case"),t.classList.remove("deselected-case"),t.inert=!1,this.getOwnerForm().scanForNewTemplateExpressionsNextRefresh()):(t.classList.add("deselected-case"),t.classList.remove("selected-case"),t.inert=!0)}toggle(e){this.selectedCase=e,Array.from(this.cases).forEach((e=>{e===this.selectedCase?(e.classList.remove("deselected-case"),e.classList.add("selected-case"),e.inert=!1):(e.classList.remove("selected-case"),e.classList.add("deselected-case"),e.inert=!0,this._resetVisited())})),this.selectedCase!==e&&(this.selectedCase=e),this._dispatchEvents(),this.formerCase=this.selectedCase,this.getOwnerForm().scanForNewTemplateExpressionsNextRefresh(),this.getOwnerForm().getModel().updateModel()}}customElements.get("fx-switch")||window.customElements.define("fx-switch",on);class ln extends Kt{connectedCallback(){this.attachShadow({mode:"open"}),this.ref=this.hasAttribute("ref")?this.getAttribute("ref"):null,this.debounceDelay=this.hasAttribute("debounce")?this.getAttribute("debounce"):null;this.shadowRoot.innerHTML=`\n <style>\n \n :host {\n cursor:pointer;\n }\n \n </style>\n ${this.renderHTML()}\n `;const e=this.shadowRoot.querySelector("slot");e.addEventListener("slotchange",(()=>{const t=e.assignedElements({flatten:!0});t[0].getAttribute("tabindex")||t[0].setAttribute("tabindex","0"),"BUTTON"!==t[0].nodeName&&t[0].setAttribute("role","button");const n=t[0];this.addEventListener("mousedown",(e=>{e.target.focus()})),this.debounceDelay?this.addEventListener("click",function(e,t,n=300){let r;return(...a)=>{r||t.apply(e,a),clearTimeout(r),r=setTimeout((()=>(r=void 0,null)),n)}}(this,(e=>{this.performActions(e)}),this.debounceDelay)):n.addEventListener("click",(e=>this.performActions(e))),this.widget=n,"BUTTON"!==n.nodeName&&n.addEventListener("keypress",(e=>{"Space"!==e.code&&"Enter"!==e.code||this.performActions(e)}))}))}renderHTML(){return"\n <slot></slot>\n "}getWidget(){return this.widget}async updateWidgetValue(){return null}handleReadonly(){super.handleReadonly(),this.widget.hasAttribute("readonly")?this.widget.setAttribute("disabled","disabled"):this.widget.removeAttribute("disabled")}async performActions(e){const t=this.closest("fx-repeatitem");t&&t.click(),this.querySelectorAll("fx-var").forEach((e=>e.refresh()));for(let t=0;t<this.children.length;t+=1){const n=this.children[t];if("function"==typeof n.execute){if(e&&(e.preventDefault(),e.stopPropagation(),e.type&&n.event&&e.type!==n.event))return;await n.execute(e)}}}async refresh(){super.refresh()}}customElements.get("fx-trigger")||customElements.define("fx-trigger",ln);class cn extends en{static get properties(){return{...super.properties,label:{type:String},name:{type:String},selected:{type:String},selector:{type:String},src:{type:String}}}connectedCallback(){this.hasAttribute("label")&&(this.label=this.getAttribute("label")),this.hasAttribute("name")&&(this.name=this.getAttribute("name")),this.hasAttribute("selected")&&(this.selected=this.getAttribute("selected")),this.selector=this.hasAttribute("selector")?this.getAttribute("selector"):"fx-case",this.hasAttribute("src")&&(this.src=this.getAttribute("src"));const e=`\n ${this.label?`<span>${this.label}</span>`:""}\n <slot></slot>\n `;this.shadowRoot.innerHTML=`\n <style>\n \n :host {\n visibility: none;\n }\n \n </style>\n ${e}\n `,this.addEventListener("select",(async()=>{const e=this.getOwnerForm();if(this.src){const{parentNode:e}=this,t=await this._loadFromSrc();if(!t)return void Ft.dispatch(this,"error",{detail:{message:"HTML page couldn't be loaded"}});await e.replaceCase(this,t)}e.getModel().updateModel(),e.refresh(!0)}))}async _loadFromSrc(){return Ft.loadForeFromSrc(this,this.src,this.selector)}}customElements.get("fx-case")||window.customElements.define("fx-case",cn);class un extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){const e=this.closest("fx-fore");this.render("\n :host {\n position:absolute;\n display: block;\n width:var(--inspector-handle-width);\n background:var(--inspector-bg);\n top:0;\n right:0;\n bottom:0;\n height: 100%;\n background: var(--inspector-bg);\n color: white;\n /*max-height: 33%;*/\n overflow: scroll;\n transition:width 0.3s ease;\n z-index:100;\n }\n :host([open]){\n width: 30%;\n }\n details{\n margin:1rem;\n }\n .main{\n padding-left:var(--inspector-handle-width);\n color:var(--inspector-color);\n overflow:scroll;\n height:100%;\n }\n pre{\n background:var(--inspector-pre-bg);\n color:var(--inspector-color);\n overflow:scroll;\n padding:0.2rem;\n }\n .handle{\n display:block;\n height:100%;\n width:var(--inspector-handle-width);\n background:var(--inspector-handle-bg);\n opacity:0.7;\n position:absolute;\n left:0;\n color:white;\n cursor:pointer;\n }\n .handle:hover{\n opacity:1;\n }\n .handle::before{\n content: 'Data Inspector';\n white-space: nowrap;\n transform: rotate(-90deg);\n display: inline-block;\n position: absolute;\n left: -85px;\n width: 200px;\n top: 40px;\n }\n summary{\n cursor:pointer;\n }\n "),e.addEventListener("refresh-done",(()=>{this.update()}))}update(){try{const e=this.shadowRoot.querySelectorAll("pre"),t=this.closest("fx-fore");Array.from(e).forEach((e=>{const n=t.getModel().getInstance(e.getAttribute("id"));"xml"===n.getAttribute("type")&&(e.innerText=this.serializeDOM(n.instanceData)),"json"===n.getAttribute("type")&&(e.innerText=JSON.stringify(n.instanceData,void 0,2))}))}catch(e){}}render(e){const t=this.closest("fx-fore"),n=Array.from(t.querySelectorAll("fx-instance"));this.shadowRoot.innerHTML=`\n <style>\n ${e}\n </style>\n <div class="main">\n <slot></slot>\n <span class="handle"></span>\n ${n.map((e=>`\n <details>\n <summary>${e.id}</summary>\n <pre id="${e.id}"></pre>\n </details>\n `))}\n </div>\n `;this.shadowRoot.querySelector(".handle").addEventListener("click",(e=>{this.hasAttribute("open")?this.removeAttribute("open"):this.setAttribute("open","open")}))}serializeDOM(e){if(!e)return;return st((new XMLSerializer).serializeToString(e))}}customElements.get("fx-inspector")||customElements.define("fx-inspector",un);class hn extends HTMLElement{static get properties(){return{id:String}}constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.shadowRoot.innerHTML=this.render("\n :host {\n display:none;\n height: 100vh;\n width:100vw;\n position:fixed;\n left:0;\n top:0;\n right:0;\n bottom:0;\n transition:opacity 0.4s linear;\n }\n\n "),this.id=this.getAttribute("id");const e=this.querySelector(".close-dialog");e&&e.addEventListener("click",(()=>{this.classList.remove("show")})),this.setAttribute("role","dialog"),this.setAttribute("aria-modal","false"),this.focus()}render(e){return`\n <style>\n ${e}\n </style>\n <slot></slot>\n `}open(){window.addEventListener("keyup",(e=>{"Escape"===e.key&&this.hide()}),{once:!0}),this.classList.add("show")}async hide(){await Ft.fadeOutElement(this,400),this.classList.remove("show")}}customElements.get("fx-dialog")||customElements.define("fx-dialog",hn);class dn extends Zt{static get properties(){return{...super.properties,valueAttr:{type:String}}}constructor(){super(),this.valueAttr=this.hasAttribute("value")?this.getAttribute("value"):null}connectedCallback(){super.connectedCallback(),this.addEventListener("mousedown",(e=>{if(Ft.isWidget(e.target)||(e.preventDefault(),e.stopImmediatePropagation()),"LABEL"===e.target.nodeName){ht(e.target.getAttribute("for"),this).focus()}})),this.addEventListener("mousedown",(e=>{if(this.querySelectorAll("[value]"),"LABEL"===e.target.nodeName){ht(e.target.getAttribute("for"),this).focus()}})),this.addEventListener("click",(e=>{e.preventDefault,e.stopPropagation();const t=this.querySelectorAll("[value]");let n;"LABEL"===e.target.nodeName&&(n=ht(e.target.getAttribute("for"),this),n.checked=!n.checked);let r="";Array.from(t).forEach((e=>{e.checked&&(r+=` ${e.getAttribute("value")}`)})),this.setAttribute("value",r.trim());const a=nt.getClosest("[ref]",this.parentNode);if(!a)return;const s=a.getModelItem(),o=this.shadowRoot.getElementById("setvalue");o.setValue(s,r.trim()),o.actionPerformed()}))}getWidget(){return this}async updateWidgetValue(){const e=nt.getClosest("[ref]",this.parentNode);e&&(this.value=e.value),this.setAttribute("value",this.value)}updateEntry(e,t){const n=Ft.createUUID(),r=e.querySelector("label"),a=Ft.getExpression(r.textContent);if(t.nodeType){const e=At(a,t,this);r.textContent=e}else{const e=Ft.getExpression(a);r.textContent=t[e]}r.setAttribute("for",n);const s=e.querySelector("[value]"),o=s.value,i=Ft.getExpression(o);let l;l=t.nodeType?At(i,t,e):t[i];const c=` ${l} `,u=` ${this.getAttribute("value")} `;s.value=l,s.setAttribute("id",n),-1!==u.indexOf(c)&&(s.checked=!0)}}customElements.get("fx-items")||customElements.define("fx-items",dn);class pn extends(_t(Mt)){}customElements.get("fx-droptarget")||window.customElements.define("fx-droptarget",pn);class mn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.eventName="",this.shortName="",this.shortInfo="",this.shortPath="",this.xpath=""}connectedCallback(){this.eventName=this.getAttribute("event-name"),this.shortName=this.getAttribute("short-name"),this.shortInfo=this.hasAttribute("short-info")?this.getAttribute("short-info"):"",this.xpath=this.getAttribute("xpath");const e=`\n <details class="info send">\n <summary>\n <span class="log-name"><a href="#" title="${`/${this.xpath.substring(this.xpath.indexOf("/fx-fore"),this.xpath.length)}`.replaceAll("fx-","")}" data-path="${this.xpath}">${this.shortName}</a></span>\n <span class="short-info">${this.shortInfo}</span>\n <span class="event-name">${this.eventName}</span> \n </summary>\n <slot></slot>\n </details>\n `;this.shadowRoot.innerHTML=`\n <style>\n \n :host {\n height: auto;\n font-size: 0.8em;\n font-weight: 400;\n\n }\n\n a,a:link,a:visited{\n color:black;\n }\n a{\n position:relative;\n }\n a[alt]:hover::after {\n content:attr(alt);\n position:absolute; \n left:0;\n top:1em;\n border.thin solid;\n padding:0.5em;\n background:white;\n z-index:1;\n min-width:5em;\n border:thin solid;\n white-space:nowrap;\n overflow-wrap:break-word;\n }\n\n .info{\n padding:0 0.5em;\n margin:0.1rem 0;\n background:white;\n position:relative;\n border:1px solid #ddd;\n border-radius:1em; \n box-shadow: 1px 1px 5px 0px rgba(79, 136, 183, 0.8);\n }\n :host(.action) .info{\n border-radius:0;\n border-color:steelblue;\n }\n\n .info label{\n grid-area:left;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n .info a{\n grid-area:right;\n justify-self:end;\n }\n .info:hover{\n outline:3px solid lightblue; \n transition:height 0.4s;\n }\n\n summary{\n padding:1em;\n display:flex;\n flex-wrap:wrap;\n padding:0.5em 0;\n cursor:pointer;\n gap:0.25em;\n }\n/*\n .log-name{\n font-size:1.2em;\n }\n .log-name, .short-info{\n width:10em;\n }\n*/\n .event-name{\n width:12em;\n text-align:right;\n }\n .short-info{\n flex:3;\n overflow:hidden;\n white-space:nowrap;\n text-overflow:ellipsis;\n }\n \n </style>\n ${e}\n `}}customElements.get("fx-log-item")||customElements.define("fx-log-item",mn);class fn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.listenTo=[],this.listeners=[]}connectedCallback(){localStorage.getItem("fx-log-settings")?this.listenTo=JSON.parse(localStorage.getItem("fx-log-settings")):this.listenTo=fn.defaultSettings();this.shadowRoot.innerHTML='\n <style>\n \n :host {\n display:block;\n position:relative;\n width:100%;\n border:thin solid #efefef;\n font-family: Verdana, Sans;\n\n margin:0;\n border:thin solid #ddd;\n }\n .boxes{\n column-width:14rem;\n overflow:auto;\n margin-bottom:5em;\n padding:1em;\n }\n .boxes > span{\n display:inline-block;\n width:14rem;\n }\n \n .buttons{\n position:absolute;\n top:0;\n right:0;\n }\n .buttons button{\n padding:0;\n }\n button{\n float:right;\n }\n button{\n border:none;\n background:transparent;\n width:2.25rem;\n height:2.25rem;\n cursor:pointer;\n }\n button#reset{\n padding:0;\n height:1rem;\n }\n header{\n padding:0.5rem;\n margin:0;\n border-bottom:2px solid #ddd;\n }\n #settings{\n padding:1em;\n }\n \n \n </style>\n \n <section id="settings">\n <header>log settings <button id="reset">reset</button></header>\n <div class="boxes"></div>\n </section>\n \n ',window.document.querySelector("fx-fore");const e=this.shadowRoot.querySelector(".boxes");this.listenTo.forEach((t=>{const n=document.createElement("span");e.append(n);const r=document.createElement("label");r.setAttribute("title",t.description),r.setAttribute("for",t.name),r.innerText=t.name;const a=document.createElement("input");a.setAttribute("type","checkbox"),a.setAttribute("name",t.name),a.setAttribute("id",t.name),t.show&&a.setAttribute("checked",""),n.append(a),n.append(r),a.addEventListener("click",(e=>{if(!e.target.checked){document.querySelector("fx-fore").removeEventListener(t.name,this._log)}const n=this.listenTo.find((e=>e.name===t.name));e.target.checked?n.show=!0:n.show=!1,localStorage.setItem("fx-log-settings",JSON.stringify(this.listenTo))}))}));this.shadowRoot.querySelector("#reset").addEventListener("click",(e=>{localStorage.removeItem("fx-log-settings"),window.location.reload()}))}static defaultSettings(){return[{name:"action-performed",show:!1,description:"fires after an action has been performed"},{name:"click",show:!1,description:""},{name:"deleted",show:!1,description:"fires after a delete action has been executed"},{name:"deselect",show:!1,description:"fires when fx-case is deselected"},{name:"dialog-hidden",show:!1,description:"fires after fx-dialog has been hidden"},{name:"dialog-shown",show:!1,description:"fired when a dialog has been shown"},{name:"error",show:!1,description:"fires after an error occurred"},{name:"execute-action",show:!0,description:"fires when an action executes"},{name:"init",show:!1,description:"fires when a control initializes"},{name:"index-changed",show:!1,description:"fires when the repeat index changes"},{name:"insert",show:!1,description:"fires when an fx-insert is executed"},{name:"instance-loaded",show:!1,description:"fires after an fx-instance has been loaded"},{name:"invalid",show:!1,description:"fires after a control became invalid"},{name:"item-changed",show:!1,description:"fires when a repeat item was changed"},{name:"item-created",show:!1,description:"fires when a repeat item was created"},{name:"loaded",show:!1,description:"fires after a fx-load has loaded"},{name:"model-construct",show:!1,description:"fires when a model gets constructed"},{name:"model-construct-done",show:!1,description:"fires after model initialization"},{name:"nonrelevant",show:!1,description:"fires after an fx-control became nonrelevant"},{name:"optional",show:!1,description:"fires after an fx-control became optional"},{name:"outermost-action-end",show:!1,description:"fires when an outermost action block is finished"},{name:"outermost-action-start",show:!1,description:"fires when an outermost action block is started"},{name:"path-mutated",show:!1,description:"fires when a path in a repeat has been mutated"},{name:"readonly",show:!1,description:"fires after an fx-control became readonly"},{name:"readwrite",show:!1,description:"fires after an fx-control became readwrite"},{name:"ready",show:!1,description:"fires after a fx-fore page has been completely initialized"},{name:"rebuild-done",show:!1,description:"fires after a rebuild has taken place"},{name:"recalculate-done",show:!1,description:"fires after a recalculate has taken place"},{name:"refresh-done",show:!1,description:"fires after a refresh has been done"},{name:"relevant",show:!1,description:"fires after a fx-control has become relevant"},{name:"reload",show:!1,description:"fires when a fx-reload action executes"},{name:"required",show:!1,description:"fires after an fx-control has become required"},{name:"return",show:!1,description:"fires after a fx-return returned"},{name:"select",show:!1,description:"fires when an fx-case has been selected"},{name:"submit",show:!1,description:"fires before a submission takes place"},{name:"submit-done",show:!1,description:"fires after a submission has successfully been executed"},{name:"submit-error",show:!1,description:"fires when a submission returned an error"},{name:"valid",show:!1,description:"fires after a fx-control has become valid"},{name:"value-changed",show:!1,description:"fires after a fx-control has changed its value"}]}_log(e,t){const n=e.target.nodeName;if("FX-ACTION-LOG"===n)return;const r=document.createElement("div");r.classList.add("log-row");const a=this._logDetails(e);if(e.detail&&0===Object.keys(e.detail).length&&Object.getPrototypeOf(e.detail)===Object.prototype&&r.classList.add("no-detail"),r.innerHTML=a,this.outermost){if("outermost-action-start"===e.type)return;this.outermostAppender||(this.outermostAppender=document.createElement("ul"),t.append(this.outermostAppender));const n=document.createElement("li");n.append(r),this.outermostAppender.append(n)}else t.append(r);this.parentPath&&"FX-ACTION"!==n&&r.classList.add("nested");const s=e.target;r.addEventListener("click",(e=>{this._highlight(s)}));const o=r.querySelector(".event-target");o&&o.addEventListener("click",(e=>{document.querySelectorAll(".fx-action-log-debug").forEach((e=>{e.classList.remove("fx-action-log-debug")})),s.dispatchEvent(new CustomEvent("log-action",{composed:!1,bubbles:!0,cancelable:!0,detail:{target:s}})),s.classList.add("fx-action-log-debug"),s.setAttribute("data-name",s.nodeName),this._highlight(s)}))}_logDetails(e){const t=e.type,n=nt.getPath(e.target),r=n.substring(n.indexOf("/fx-fore"),n.length),a=`/${r}`,s=r.replaceAll("fx-","");switch(this.parentPath&&!a.startsWith(this.parentPath)&&(this.parentPath=null),t){case"deleted":const{deletedNodes:n}=e.detail,r=new XMLSerializer;let o="";return n.forEach((e=>{o+=r.serializeToString(e)})),`\n <fx-log-item event-name="${t}"\n xpath="${a}"\n short-info="${e.detail.ref}"\n short-name="${e.target.nodeName.toLowerCase()}">\n <section class="details">\n <header>Details</header>\n <section>\n <span class="key">Deleted Nodes</span>\n <textarea class="value" rows="5">${o.trim()}</textarea>\n </section>\n </section>\n </fx-log-item>\n `;case"outermost-action-start":return"start";case"outermost-action-end":return"";case"execute-action":const i=e.detail.action;return this._renderAction(i,a,s,e);default:return`\n <fx-log-item event-name="${t}"\n xpath="${a}"\n short-name="${e.target.nodeName.toLowerCase()}">\n \n <section class="details">\n ${this._listEventDetails(e)}\n </section>\n </fx-log-item>\n `}}_renderAction(e,t,n,r){switch(e.nodeName.split("-")[1],e.nodeName){case"FX-ACTION":return this.parentPath=t,`\n <fx-log-item event-name="${r.detail.event}"\n xpath="${t}"\n short-name="ACTION" class="action">\n <section class="details">\n <header>Attributes</header>\n <section>\n ${Array.from(e.attributes).map((e=>`\n <span class="key">${e.nodeName}</span>\n <span class="value">${e.nodeValue}</span>\n `)).join("")} \n </section>\n </section>\n </fx-log-item> \n `;case"FX-MESSAGE":const n=r.detail.action.messageTextContent;return`\n <fx-log-item event-name="${r.detail.event}"\n xpath="${t}"\n short-name="MESSAGE"\n short-info="${n}" class="action">\n <section class="details">\n <span>${n}</span>\n </section>\n </fx-log-item>\n `;case"FX-SEND":const a=document.querySelector(`#${r.detail.action.getAttribute("submission")}`);return`\n <fx-log-item short-name="SEND"\n short-info="${a.id}"\n event-name="${r.detail.event}"\n xpath="${t}" class="action">\n <section class="details">\n <header>Submission</header>\n <section class="attributes">\n ${Array.from(a.attributes).map((e=>`\n <span class="key">${e.nodeName}</span>\n <span class="value">${e.nodeValue}</span>\n `)).join("")} \n </section> \n </section>\n </fx-log-item>\n `;case"FX-SETVALUE":return`\n <fx-log-item short-name="SETVALUE"\n short-info="${nt.getPath(r.target.nodeset)}"\n event-name="${"FX-CONTROL"===r.target.nodeName?r.target.updateEvent:r.detail.event}"\n xpath="${t}" class="action">\n <section class="details">\n <span class="key">value</span>\n <span class="value">${r.detail.value}</span>\n </section>\n </fx-log-item>\n `;default:return`\n <fx-log-item event-name="${r.detail.event}" \n short-name="${r.target.nodeName}"\n xpath="${t}"\n class="action">\n <section class="details">\n </section>\n </fx-log-item>\n `}}_listEventDetails(e){return e.detail&&0===Object.keys(e.detail).length&&Object.getPrototypeOf(e.detail)===Object.prototype?"":`${Object.keys(e.detail).map((e=>`<span>${e}</span>`))}`}_listAttributes(e){return""}_highlight(e){const t=e.style.backgroundColor,n=e.style.transition;e.style.transition="background 1s",e.style.backgroundColor="#FFA500",setTimeout((()=>{e.style.backgroundColor=t,setTimeout((()=>{e.style.transition=n}),400)}),400),window.document.dispatchEvent(new CustomEvent("log-active-element",{detail:{target:e}}))}}customElements.get("fx-log-settings")||customElements.define("fx-log-settings",fn);class gn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.listenTo=[],this.listeners=[]}connectedCallback(){localStorage.getItem("fx-action-log-filters")?this.listenTo=JSON.parse(localStorage.getItem("fx-action-log-filters")):this.listenTo=fn.defaultSettings(),localStorage.getItem("fx-log-settings")?this.listenTo=JSON.parse(localStorage.getItem("fx-log-settings")):this.listenTo=fn.defaultSettings();this.shadowRoot.innerHTML='\n <style>\n \n :host {\n display:block;\n position:relative;\n width:100%;\n border:thin solid #efefef;\n background:transparent;\n font-family: Verdana, Sans;\n margin:0;\n padding:0.25rem;\n }\n a,a:link,a:visited{\n color:black;\n }\n a{\n position:relative;\n }\n a[alt]:hover::after {\n content:attr(alt);\n position:absolute; \n left:0;\n bottom:-0.5em;\n border:thin solid;\n padding:0.5em;\n background:white;\n z-index:1;\n min-width:5em;\n border:thin solid;\n max-width:90%;\n }\n .details{\n padding:0.25em 0;\n }\n\n .key{\n width:20%;\n display:inline-block;\n min-width:5rem;\n border-bottom:1px solid #ddd;\n background:#efefef;\n vertical-align:top;\n }\n .value{\n display:inline-block;\n width:60%;\n \n }\n \n .buttons{\n position:absolute;\n top:0;\n right:0;\n }\n .buttons button{\n padding:0;\n }\n button{\n float:right;\n }\n button{\n border:none;\n background:transparent;\n width:2.25rem;\n height:2.25rem;\n cursor:pointer;\n }\n button#reset{\n padding:0;\n height:1rem;\n }\n .info{\n padding:0 0.5em;\n margin:0.1rem 0;\n background:white;\n position:relative;\n display:grid;\n grid-template-areas: "left right"\n "bottom .";\n grid-template-columns: 75% 25%;\n }\n .info a{\n grid-area:right;\n justify-self:end;\n }\n .details > section{\n display:flex;\n flex-wrap:wrap;\n padding:0.5em 0;\n }\n fx-log-item{\n }\n header{\n padding:0.5rem;\n margin:0;\n border-bottom:2px solid #ddd;\n }\n \n .info:hover{\n outline:3px solid lightblue; \n transition:height 0.4s;\n }\n\n ol{\n background: #efefef;\n padding: 0.5em 0 0 2em;\n border-left:3px solid red;\n }\n \n .event-name{\n display:inline-block;\n }\n #log{\n margin-bottom:10em;\n margin-right:2em;\n }\n .log-row{\n margin:0;\n padding:0;\n position:relative;\n font-size:0.8em;\n border-left:4px solid transparent;\n padding-left:5px;\n width:calc(100% - 2em);\n margin-bottom:0.25em;\n }\n .log-row summary{\n display:flex;\n flex-wrap:wrap;\n padding:0.5em 0;\n cursor:pointer;\n }\n .log-row summary > span {\n width:calc(90% div 3);\n }\n\n .log-name{\n position:relative;\n }\n .short-info{\n flex:3;\n overflow:hidden;\n white-space:nowrap;\n text-overflow:ellipsis;\n }\n .log-row.no-detail summary{\n position:relative;\n }\n .log-row.no-detail summary{\n list-style:none;\n padding-left:1rem;\n }\n .log-row.no-detail summary::-webkit-details-marker {\n display: none;\n }\n .log-row.nested{\n margin-left:1em;\n }\n .nested .event-name{\n display:none;\n }\n \n .setvalue .value{\n background:lightyellow;\n }\n summary{\n padding:1em;\n border-bottom:2px solid #ddd;\n }\n .outer-details{\n height:100%;\n overflow:auto;\n margin-top:2rem;\n background:rgba(250, 250, 250, 0.9);\n }\n \n .outer-details > header{\n position:absolute;\n top:-1px;\n width:calc(100% - 2rem);\n border-bottom:2px solid #ddd;\n font-size:1rem;\n height:1rem;\n }\n .outer-details > summary{\n font-size:1em;\n }\n ul{\n list-style:none;\n padding:0;\n margin:0.1em 0;\n border-left:3px solid steelblue;\n padding:0.1em 0;\n }\n ul .log-row{\n padding-left:3px;\n width:calc(100% - 1em);\n }\n \n </style>\n \n <section open class="outer-details">\n <header>Log \n <span class="buttons">\n <button id="del"" title="empty log - Ctrl+d">\n <svg viewBox="0 0 24 24" style="width:24px;height:24px;" preserveAspectRatio="xMidYMid meet" focusable="true"><g><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zm2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12zM15.5 4l-1-1h-5l-1 1H5v2h14V4z"></path></g></svg></a>\n </button>\n </span>\n </header>\n <div id="log"></div>\n </section>\n \n ',window.document.querySelector("fx-fore");const e=this.shadowRoot.querySelector("#log");this.listenTo.forEach((t=>{t.show&&document.addEventListener(t.name,(t=>{this._log(t,e)}))})),document.addEventListener("outermost-action-start",(e=>{this.outermost=!0}),{capture:!0}),document.addEventListener("outermost-action-end",(e=>{this.outermost=!1,this.outermostAppender=null}),{capture:!0});this.shadowRoot.querySelector("#del").addEventListener("click",(e=>{this.shadowRoot.querySelector("#log").innerHTML=""})),document.addEventListener("keydown",(e=>{e.ctrlKey&&"d"===e.key&&(this.shadowRoot.querySelector("#log").innerHTML="")}))}_defaultSettings(){this.listenTo=[{name:"action-performed",show:!1,description:"fires after an action has been performed"},{name:"click",show:!1,description:""},{name:"deleted",show:!1,description:"fires after a delete action has been executed"},{name:"deselect",show:!1,description:"fires when fx-case is deselected"},{name:"dialog-hidden",show:!1,description:"fires after fx-dialog has been hidden"},{name:"dialog-shown",show:!1,description:"fired when a dialog has been shown"},{name:"error",show:!1,description:"fires after an error occurred"},{name:"execute-action",show:!0,description:"fires when an action executes"},{name:"init",show:!1,description:"fires when a control initializes"},{name:"index-changed",show:!1,description:"fires when the repeat index changes"},{name:"insert",show:!1,description:"fires when an fx-insert is executed"},{name:"instance-loaded",show:!1,description:"fires after an fx-instance has been loaded"},{name:"invalid",show:!1,description:"fires after a control became invalid"},{name:"item-changed",show:!1,description:"fires when a repeat item was changed"},{name:"item-created",show:!1,description:"fires when a repeat item was created"},{name:"loaded",show:!1,description:"fires after a fx-load has loaded"},{name:"model-construct",show:!1,description:"fires when a model gets constructed"},{name:"model-construct-done",show:!1,description:"fires after model initialization"},{name:"nonrelevant",show:!1,description:"fires after an fx-control became nonrelevant"},{name:"optional",show:!1,description:"fires after an fx-control became optional"},{name:"outermost-action-end",show:!1,description:"fires when an outermost action block is finished"},{name:"outermost-action-start",show:!1,description:"fires when an outermost action block is started"},{name:"path-mutated",show:!1,description:"fires when a path in a repeat has been mutated"},{name:"readonly",show:!1,description:"fires after an fx-control became readonly"},{name:"readwrite",show:!1,description:"fires after an fx-control became readwrite"},{name:"ready",show:!1,description:"fires after a fx-fore page has been completely initialized"},{name:"rebuild-done",show:!1,description:"fires after a rebuild has taken place"},{name:"recalculate-done",show:!1,description:"fires after a recalculate has taken place"},{name:"refresh-done",show:!1,description:"fires after a refresh has been done"},{name:"relevant",show:!1,description:"fires after a fx-control has become relevant"},{name:"reload",show:!1,description:"fires when a fx-reload action executes"},{name:"required",show:!1,description:"fires after an fx-control has become required"},{name:"return",show:!1,description:"fired by embedded Fore controls to return their bound value"},{name:"select",show:!1,description:"fires when an fx-case has been selected"},{name:"submit",show:!1,description:"fires before a submission takes place"},{name:"submit-done",show:!1,description:"fires after a submission has successfully been executed"},{name:"submit-error",show:!1,description:"fires when a submission returned an error"},{name:"valid",show:!1,description:"fires after a fx-control has become valid"},{name:"value-changed",show:!1,description:"fires after a fx-control has changed its value"}]}_log(e,t){const n=e.target.nodeName;if("FX-ACTION-LOG"===n)return;const r=document.createElement("div");r.classList.add("log-row");const a=this._logDetails(e);if(e.detail&&0===Object.keys(e.detail).length&&Object.getPrototypeOf(e.detail)===Object.prototype&&r.classList.add("no-detail"),r.innerHTML=a,this.outermost){if("outermost-action-start"===e.type)return;this.outermostAppender||(this.outermostAppender=document.createElement("ul"),t.append(this.outermostAppender));const n=document.createElement("li");n.append(r),this.outermostAppender.append(n)}else t.append(r);this.parentPath&&"FX-ACTION"!==n&&r.classList.add("nested");const s=e.target;r.addEventListener("click",(e=>{this._highlight(s)}));const o=r.querySelector(".event-target");o&&o.addEventListener("click",(e=>{document.querySelectorAll(".fx-action-log-debug").forEach((e=>{e.classList.remove("fx-action-log-debug")})),s.dispatchEvent(new CustomEvent("log-action",{composed:!1,bubbles:!0,cancelable:!0,detail:{target:s}})),s.classList.add("fx-action-log-debug"),s.setAttribute("data-name",s.nodeName),this._highlight(s)}))}_logDetails(e){const t=e.type,n=nt.getDocPath(e.target),r=n.substring(n.indexOf("/fx-fore"),n.length),a=`/${r}`,s=r.replaceAll("fx-","");switch(this.parentPath&&!a.startsWith(this.parentPath)&&(this.parentPath=null),t){case"deleted":const{deletedNodes:n}=e.detail,r=new XMLSerializer;let o="";return n.forEach((e=>{o+=r.serializeToString(e)})),`\n <fx-log-item event-name="${t}"\n xpath="${a}"\n short-info="${e.detail.ref}"\n short-name="${e.target.nodeName.toLowerCase()}">\n <section class="details">\n <header>Details</header>\n <section>\n <span class="key">Deleted Nodes</span>\n <textarea class="value" rows="5">${o.trim()}</textarea>\n </section>\n </section>\n </fx-log-item>\n `;case"outermost-action-start":return"start";case"outermost-action-end":return"";case"execute-action":const i=e.detail.action;return this._renderAction(i,a,s,e);default:return`\n <fx-log-item event-name="${t}"\n xpath="${a}"\n short-name="${e.target.nodeName.toLowerCase()}">\n \n <section class="details">\n ${this._listEventDetails(e)}\n </section>\n </fx-log-item>\n `}}_renderAction(e,t,n,r){let a;switch(e.nodeName.split("-")[1],e.nodeName){case"FX-ACTION":return this.parentPath=t,a=r.target.currentEvent?r.target.currentEvent.type:r.detail.event?r.detail.event:"",`\n <fx-log-item event-name="${a}"\n xpath="${t}"\n short-name="ACTION"\n data-path="${r.detail.path}" \n class="action">\n <section class="details">\n <header>Attributes</header>\n <section>\n ${Array.from(e.attributes).map((e=>`\n <span class="key">${e.nodeName}</span>\n <span class="value">${e.nodeValue}</span>\n `)).join("")} \n </section>\n </section>\n </fx-log-item> \n `;case"FX-MESSAGE":const n=r.detail.action.messageTextContent;return`\n <fx-log-item event-name="${r.detail.event}"\n xpath="${t}"\n short-name="MESSAGE"\n short-info="${n}" class="action">\n <section class="details">\n <span>${n}</span>\n </section>\n </fx-log-item>\n `;case"FX-SEND":const s=document.querySelector(`#${r.detail.action.getAttribute("submission")}`),o=r.detail.event?r.detail.event:"";return`\n <fx-log-item short-name="SEND"\n short-info="${s.getAttribute("id")}"\n event-name="${o}"\n xpath="${t}" class="action"\n data-path="${r.detail.path}" >\n <section class="details">\n <header>Submission</header>\n <section class="attributes">\n ${Array.from(s.attributes).map((e=>`\n <span class="key">${e.nodeName}</span>\n <span class="value">${e.nodeValue}</span>\n `)).join("")} \n </section> \n </section>\n </fx-log-item>\n `;case"FX-SETVALUE":return`\n <fx-log-item short-name="SETVALUE"\n short-info="${nt.getPath(r.target.nodeset)}"\n event-name="${"FX-CONTROL"===r.target.nodeName?r.target.updateEvent:r.detail.event?r.detail.event:""}"\n xpath="${t}"\n data-path="${r.detail.path}" class="action">\n <section class="details">\n <span class="key">value</span>\n <span class="value">${r.detail.value}</span>\n </section>\n </fx-log-item>\n `;default:return a=r.target.currentEvent?r.target.currentEvent.type:r.detail.event?r.detail.event:"",`\n <fx-log-item event-name="${a}" \n short-name="${r.target.nodeName}"\n xpath="${t}"\n data-path="${r.detail.path}" \n class="action">\n <section class="details">\n </section>\n </fx-log-item>\n `}}_listEventDetails(e){return e.detail&&0===Object.keys(e.detail).length&&Object.getPrototypeOf(e.detail)===Object.prototype?"":`${Object.keys(e.detail).map((e=>`<span>${e}</span>`))}`}_listAttributes(e){return""}_highlight(e){const t=e.style.backgroundColor,n=e.style.transition;e.style.transition="background 1s",e.style.backgroundColor="#FFA500",setTimeout((()=>{e.style.backgroundColor=t,setTimeout((()=>{e.style.transition=n}),400)}),400),window.document.dispatchEvent(new CustomEvent("log-active-element",{detail:{target:e}}))}}function yn(e,t){e.classList.add(t)}function wn(e,t){e.classList.remove(t)}function vn(e,t){if("object"!=typeof e)throw new Error(`containsOnlyText: Expected argument node of type object, ${typeof e} given.`);let n=!1,r=null;if(t=t||!1)for(let t=0,a=e.childNodes.length;t<a&&(r=e.childNodes[t],n=r.nodeType===Node.TEXT_NODE||r.nodeType===Node.COMMENT_NODE||r.nodeType===Node.CDATA_SECTION_NODE,n);t+=1);else n=e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE||e.nodeType===Node.CDATA_SECTION_NODE;return n}function bn(e,t){const n=document.createElement(e);t=t||{};for(const e of Object.keys(t))n.setAttribute(e,t[e]);return n}function xn(e,t){const n=bn("span",{class:"adi-opt"});return n.innerHTML=`<label><input type="checkbox" data-opt="${e}">${t}</label>`,n}customElements.get("fx-action-log")||customElements.define("fx-action-log",gn);class An{constructor(e,t){this.sourceNodeByInspectorNodeLookup=new Map,this.uiView=null,this.menuView=null,this.domView=null,this.attrView=null,this.optsView=null,this.activeElement=null,this.vertResizing=!1,this.horizResizing=!1,this.pathScrolling=null,this.elemLookup=!1,this.styleBackup="",this.xPos=0,this.delegatedEvents=[],this.options={align:"right",split:50,minSplit:30,visible:!0,saving:!1,transparent:!0,omitEmptyText:!0,makeVisible:!0,foldText:!0,nodeTypes:[Node.ELEMENT_NODE,Node.TEXT_NODE,Node.COMMENT_NODE,Node.DOCUMENT_NODE]},"#document"===t?(this.instanceId="#document",this.document=window.document,this.isInstanceViewer=!1):(this.instanceId=t.id,!t||t.localName,this.document=t.getInstanceData(),this.isInstanceViewer=!0,this.options.foldText=!1),this.drawUI(e),this.registerEvents(),this.drawDOM(this.document,this.domView.querySelector(".adi-tree-view"),!0),document.addEventListener("execute-action",(e=>this.processExecuteAction))}getSelected(){if(!this.activeElement)return null;let e=document;return e=this.sourceNodeByInspectorNodeLookup.get(this.activeElement),e}loadOptions(){let e={};e=JSON.parse(window.localStorage.getItem("ADI.options"))||{};for(const t of Object.keys(e))this.options[t]=e[t]}saveOptions(){this.options.saving&&window.localStorage.setItem("ADI.options",JSON.stringify(this.options))}hasRequiredNodes(e){if("object"!=typeof e)throw new Error(`hasRequiredNodes: Expected argument node of type object, ${typeof e} given.`);if(e.hasChildNodes())for(let t=0,n=e.childNodes.length;t<n;t+=1){const n=e.childNodes[t];if(this.options.nodeTypes.includes(n.nodeType))return!0}return!1}newTreeNode(e){if("object"!=typeof e)throw new Error(`newTreeNode: Expected argument node of type object, ${typeof e} given.`);const t=this.hasRequiredNodes(e);let n=!1,r=e.nodeName.startsWith("FX-")?`adi-node ${e.nodeName.toLowerCase()}`:"";e.nodeName.startsWith("FX-")&&(r=`adi-node ${e.nodeName.toLowerCase()}`,r+=Ft.isActionElement(e.nodeName)?" action":"");const a=bn("li",{class:r});if(e===this.uiView)return null;if(t&&a.appendChild(bn("span",{class:"adi-trigger"})),this.options.omitEmptyText&&e.nodeType===Node.TEXT_NODE&&(n=function(e){if("object"!=typeof e)throw new Error(`isEmptyTextNode: Expected argument node of type object, ${typeof e} given.`);return/^\s*$/.test(e.textContent)}(e)),!n){const n=bn("span");this.sourceNodeByInspectorNodeLookup.set(n,e),this.sourceNodeByInspectorNodeLookup.set(e,n);let r=null;if(vn(e))e.nodeType===Node.COMMENT_NODE?(yn(n,"adi-comment-node"),"string"==typeof n.innerText&&(n.innerText=`\x3c!-- ${e.textContent} --\x3e`)):(yn(n,"adi-text-node"),n.textContent=e.textContent);else if(yn(n,"adi-normal-node"),e.nodeType!==Node.DOCUMENT_NODE){const a=Array.from(e.attributes).filter((e=>!!this.isInstanceViewer||"style"!==e.name)).map((e=>`${e.name}="${e.value}"`)).join(" ");n.textContent=`<${e.nodeName.toLowerCase()}${a?` ${a}`:""}>`,t&&(r=bn("span"),yn(r,"adi-end-node"),r.textContent=`</${e.nodeName.toLowerCase()}>`)}else n.textContent=e.nodeName.toLowerCase();return a.appendChild(n),e.nodeName.startsWith("FX-")&&(n.classList.add("fore-node"),n.classList.add(e.nodeName.toLowerCase())),r&&(a.appendChild(r),e.nodeName.startsWith("FX-")&&r.classList.add("fore-node")),a}return null}drawDOM(e,t,n){if("object"!=typeof e)throw new Error(`drawDOM: Expected argument root of type object, ${typeof e} given.`);let r=null,a=!0;const s=t.nodeName.startsWith("FX-")?`adi-node ${node.nodeName.toLowerCase()}`:"";n&&-1!==this.options.nodeTypes.indexOf(e.nodeType)&&(t.innerHTML="",r=this.newTreeNode(e),this.hasRequiredNodes(e)&&(r.appendChild(bn("ul",{"data-open":!0,class:s})),yn(r.querySelector(".adi-trigger"),"opened")),t.appendChild(r),t=t.querySelector("ul"));for(let n=0,o=e.childNodes.length;n<o;n+=1){const o=e.childNodes[n],i=this.hasRequiredNodes(o);if(-1!==this.options.nodeTypes.indexOf(o.nodeType)&&(r=this.newTreeNode(o),r)){if(i&&(a=!this.options.foldText||!vn(o,!0),"HEAD"===o.nodeName&&(a=!1),"SELECT"===o.nodeName&&(a=!1),"FX-INSTANCE"===o.nodeName&&(a=!1),o.nodeType===Node.DOCUMENT_NODE?r.appendChild(bn("ul",{"data-open":a,class:s})):r.insertBefore(bn("ul",{"data-open":a,class:s}),r.lastChild),yn(r.querySelector(".adi-trigger"),a?"opened":"closed")),t.appendChild(r),this.getSelected()===o){const e=r.querySelector("span.adi-normal-node");e?.classList?.add("adi-active-node"),this.activeElement=e,r.scrollIntoView({block:"nearest",behavior:"instant"})}i&&this.drawDOM(o,r.querySelector("ul"),!1)}}}toggleOptions(){-1!==this.optsView.className.indexOf("adi-hidden")?wn(this.optsView,"adi-hidden"):(yn(this.optsView,"adi-hidden"),this.attrView.querySelector(".adi-content").innerHTML="",this.refreshUI(),this.drawDOM(document,this.domView.querySelector(".adi-tree-view"),!0),this.options.saving?this.saveOptions():window.localStorage.removeItem("ADI.options"))}drawUI(e){this.uiView=bn("div",{id:"adi-wrapper",class:this.options.transparent?"transparent":""}),this.domView=bn("div",{id:"adi-dom-view"});const t=bn("div",{class:"adi-content",id:"detailsView"}),n=bn("ul",{class:"adi-tree-view"}),r=bn("div",{class:"adi-path-wrap"}),a=bn("span",{class:"adi-path-left"}),s=bn("span",{class:"adi-path-right"});this.menuView=bn("div",{id:"adi-panel"});const o=bn("div",{class:"adi-menu-wrap"}),i=bn("a",{class:"adi-menu-config",title:"Settings"}),l=bn("a",{class:"adi-menu-lookup",title:"Lookup tool"});if(this.optsView=function(){const e=bn("div",{id:"adi-opts-view",class:"adi-hidden"}),t=bn("span",{class:"adi-opt-heading"}),n=bn("span",{class:"adi-opt-heading"}),r=bn("span",{class:"adi-opt-close"});return t.textContent="General options",n.textContent="Observed nodes",e.appendChild(t),e.appendChild(xn("saving","Enable saving of settings")),e.appendChild(xn("makeVisible","Scroll to the active element in DOM View")),e.appendChild(xn("omitEmptyText","Hide empty text nodes")),e.appendChild(xn("foldText","Fold the text nodes")),e.appendChild(xn("transparent","Enable transparent background")),e.appendChild(n),e.appendChild(xn("nodeTypes-3","Text node")),e.appendChild(xn("nodeTypes-8","Comment node")),e.appendChild(r),e}(),t.appendChild(n),this.domView.appendChild(this.menuView),this.domView.appendChild(t),r.appendChild(a),r.appendChild(s),o.appendChild(l),o.appendChild(i),this.menuView.appendChild(r),this.menuView.appendChild(o),this.uiView.appendChild(this.optsView),this.uiView.appendChild(this.domView),!this.isInstanceViewer){this.attrView=bn("div",{id:"adi-attr-view"});const e=bn("div",{class:"adi-content"});this.attrView.appendChild(e),this.uiView.appendChild(this.attrView)}e.appendChild(this.uiView),this.refreshUI(!0)}refreshUI(e){null!==this.uiView&&(e&&this.loadOptions(),e&&(this.optsView.querySelector('[data-opt="transparent"]').checked=this.options.transparent,this.optsView.querySelector('[data-opt="saving"]').checked=this.options.saving,this.optsView.querySelector('[data-opt="omitEmptyText"]').checked=this.options.omitEmptyText,this.optsView.querySelector('[data-opt="makeVisible"]').checked=this.options.makeVisible,this.optsView.querySelector('[data-opt="foldText"]').checked=this.options.foldText,this.optsView.querySelector('[data-opt="nodeTypes-3"]').checked=-1!==this.options.nodeTypes.indexOf(3),this.optsView.querySelector('[data-opt="nodeTypes-8"]').checked=-1!==this.options.nodeTypes.indexOf(8)),this.uiView.className=this.options.transparent?"transparent":"",this.domView.querySelector(".adi-content").style.height=`${this.domView.clientHeight}px`,this.isInstanceViewer||(this.attrView.querySelector(".adi-content").style.height=this.attrView.clientHeight-this.menuView.clientHeight+"px"),yn(this.uiView,this.options.align))}toggleVisibilityUI(){null!==this.uiView&&(this.uiView.style.display=this.options.visible?"none":"block",this.options.visible=!this.options.visible,this.saveOptions())}drawAttrs(e){if(this.isInstanceViewer)return;const t=this.attrView.querySelector(".adi-content");t.innerHTML="";const n=document.createElement("header");n.innerText="Attributes",t.appendChild(n),[...e.attributes].forEach((e=>{"style"!==e.name&&t.appendChild(function(e,t){const n=bn("span",{class:"adi-attr"});switch(e.toLowerCase()){case"defaultaction":n.innerHTML=`<label>${e}: <select data-attr="${e}" value="${t}"><option>perform</option><option>cancel</option></label>`;break;case"delay":n.innerHTML=`<label>${e}: <input type="number" data-attr="${e}" value="${t}" readonly="readonly"></label>`;break;default:n.innerHTML=`<label>${e}: <input type="text" data-attr="${e}" value="${t}" readonly="readonly"></label>`}return n}(e.name,e.value))}))}changeAttribute(e){const t=e?e.target:window.event.srcElement,n=t.getAttribute("data-attr"),r=t.value,a=this.getSelected();""===r?a.removeAttribute(n):a.setAttribute(n,r)}changeOption(e){const t=e?e.target:window.event.srcElement,n=t.getAttribute("data-opt"),r=t.checked;if(-1!==n.indexOf("nodeTypes")){const e=parseInt(n.match(/\d+/)[0],10);r?this.options.nodeTypes.push(e):this.options.nodeTypes.splice(this.options.nodeTypes.indexOf(e),1)}else this.options[n]=r}processKey(e){if(272===((e=e||window.event).keyCode||e.which))this.toggleVisibilityUI()}verticalResize(e){if(!this.vertResizing)return;e=e||window.event,document.documentElement.style.cursor="e-resize";const t=this.options.width+this.xPos-e.clientX;t>=this.options.minWidth&&(this.options.width=t,this.xPos=e.clientX,this.refreshUI(),this.saveOptions())}horizontalResize(e){if(!this.horizResizing)return;e=e||window.event,document.documentElement.style.cursor="n-resize";const t=Math.floor(e.clientY/this.uiView.clientHeight*100);t>=this.options.minSplit&&t<=100-this.options.minSplit&&(this.options.split=t,this.refreshUI(),this.saveOptions())}processExecuteAction(e){this.refreshUI()}handleActive(e){let t=e?e.detail?.target||e.target:window.event.srcElement;const n=this.domView.querySelector(".adi-active-node");if(n&&wn(n,"adi-active-node"),!t||t.nodeType===Node.DOCUMENT_NODE)return;if(t&&t.classList&&t.classList.contains("adi-end-node")&&(t=t.parentNode.querySelector(".adi-normal-node")),this.activeElement=t,yn(t,"adi-active-node"),this.options.makeVisible){this.domView.querySelector(".adi-content").scrollIntoView({block:"center",behavior:"instant"})}const r=this.getSelected();if(this.drawAttrs(r),r&&"function"==typeof r.getModelItem&&r.getModelItem()?.node){let e=r.modelItem.node;e?.nodeType===Node.ATTRIBUTE_NODE&&(e=e.ownerElement),window.document.dispatchEvent(new CustomEvent("log-active-element",{detail:{target:e}}))}}highlightElement(e){let t=e?e.target:window.event.srcElement;t.classList.contains("adi-end-node")&&(t=t.parentNode.querySelector(".adi-normal-node"));const n=this.sourceNodeByInspectorNodeLookup.get(t);n&&n.ownerDocument===window.document&&n&&("mouseover"===e.type?(this.styleBackup=n.getAttribute("style")||"",n.setAttribute("style",`outline: 2px solid blue; ${this.styleBackup}`)):""===this.styleBackup?n.removeAttribute("style"):n.setAttribute("style",this.styleBackup))}handleLookup(e){const t=e?e.detail?.target||e.target:window.event.srcElement;if(!this.document.contains(t))return;if(t.nodeType===Node.DOCUMENT_NODE)return;if(-1!==t.className.indexOf("adi-menu-lookup"))return this.elemLookup?(wn(t,"adi-active"),this.elemLookup=!1,this.removeEvent(document.body,"mouseover",this.handleLookup,!0),this.removeEvent(document.body,"mouseout",this.handleLookup,!0),void this.removeEvent(document.body,"click",this.handleLookup,!0)):(yn(t,"adi-active"),this.elemLookup=!0,this.addEventDelegate(document.body,"mouseover",this.handleLookup,!1,"*",!0,"adi-wrapper"),this.addEventDelegate(document.body,"mouseout",this.handleLookup,!1,"*",!0,"adi-wrapper"),void this.addEventDelegate(document.body,"click",this.handleLookup,!1,"*",!0,"adi-wrapper"));if("mouseover"===e.type)return this.styleBackup=t.getAttribute("style")||"",void t.setAttribute("style",`outline: 1px dashed red; ${this.styleBackup}`);if("mouseout"===e.type)return void t.setAttribute("style",this.styleBackup);this.elemLookup=!1,wn(this.menuView.querySelector(".adi-menu-lookup"),"adi-active"),t.setAttribute("style",this.styleBackup),this.removeEvent(document.body,"mouseover",this.handleLookup,!0),this.removeEvent(document.body,"mouseout",this.handleLookup,!0),this.removeEvent(document.body,"click",this.handleLookup,!0),function(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault(),e.cancelBubble=!0,e.returnValue=!1}(e);const n=this.sourceNodeByInspectorNodeLookup.get(t);if(!n)return;if(n&&n.click(),!n.parentNode)return;let r,a=n.parentNode;for(a.querySelector("ul")&&a.querySelector("ul").setAttribute("data-open","true");a!==this.domView.querySelector(".adi-content");)-1!==a.className.indexOf("adi-node")&&(r=a.querySelector(".adi-trigger"),r&&(wn(r,"closed"),yn(r,"opened")),a=a.parentNode,a.setAttribute("data-open","true")),a=a.parentNode;this.options.makeVisible&&n.scrollIntoView({behavior:"instant",block:"nearest",inline:"nearest"}),t.scrollIntoView({behavior:"instant",block:"nearest",inline:"nearest"})}addEventDelegate(e,t,n,r,a,s,o){const i=e=>{const t=e?e.target:window.event.srcElement,r=a.substr(1);let s=!1;if(o){let e=t;for(;e!==document;){if(e.id===o)return;e=e.parentNode}}s=0===a.indexOf("#")?t.id===r:0===a.indexOf(".")?-1!==t.className.indexOf(r):"*"===a||t.nodeName.toLowerCase()===a,s&&n(e)};s&&this.delegatedEvents.push({handle:i,elem:e,fn:n,evt:t}),e.addEventListener(t,i,r)}removeEvent(e,t,n,r){if("object"!=typeof e)throw new Error(`addEvent: Expected argument elem of type object, ${typeof e} given.`);let a=null;if(r)for(let r=0,s=this.delegatedEvents.length;r<s;r+=1)if(a=this.delegatedEvents[r],a.elem===e&&a.evt===t&&a.fn===n){n=a.handle,this.delegatedEvents.splice(r,1);break}}registerEvents(){const e=()=>{if("#document"!==this.instanceId){const e=window.document.querySelector(`#${this.instanceId}`);this.document=e.getInstanceData()}this.drawDOM(this.document,this.domView.querySelector(".adi-tree-view"),!0)};document.addEventListener("instance-loaded",e),document.addEventListener("value-changed",e),document.addEventListener("ready",e),document.addEventListener("mouseup",(()=>{document.documentElement.style.cursor="default",this.vertResizing=!1,this.horizResizing=!1}),!1),document.addEventListener("mousemove",(e=>this.verticalResize(e)),!1),document.addEventListener("mousemove",(e=>this.horizontalResize(e)),!1),window.addEventListener("resize",(e=>this.refreshUI(e)),!1),document.addEventListener("keypress",(e=>this.processKey(e)),!1),document.addEventListener("log-active-element",(e=>this.handleLookup(e)),!1);this.addEventDelegate(this.domView,"click",(e=>{const t=e?e.target:window.event.srcElement,n=t.parentNode.querySelector("ul");"true"===n.getAttribute("data-open")?(wn(t,"opened"),yn(t,"closed"),n.setAttribute("data-open","false")):(wn(t,"closed"),yn(t,"opened"),n.setAttribute("data-open","true"))}),!1,".adi-trigger"),this.addEventDelegate(this.domView,"click",(e=>this.handleActive(e)),!1,".adi-normal-node"),this.addEventDelegate(this.domView,"click",(e=>this.handleActive(e)),!1,".adi-end-node"),this.addEventDelegate(this.domView,"mouseover",(e=>{yn((e?e.target:window.event.srcElement).parentNode.querySelector(".adi-normal-node"),"hover")}),!1,".adi-end-node"),this.addEventDelegate(this.domView,"mouseout",(e=>{wn((e?e.target:window.event.srcElement).parentNode.querySelector(".adi-normal-node"),"hover")}),!1,".adi-end-node"),this.addEventDelegate(this.domView,"mouseover",(e=>this.highlightElement(e)),!1,".adi-end-node"),this.addEventDelegate(this.domView,"mouseover",(e=>this.highlightElement(e)),!1,".adi-normal-node"),this.addEventDelegate(this.domView,"mouseout",(e=>this.highlightElement(e)),!1,".adi-end-node"),this.addEventDelegate(this.domView,"mouseout",(e=>this.highlightElement(e)),!1,".adi-normal-node"),this.menuView.querySelector(".adi-menu-lookup").addEventListener("click",(e=>this.handleLookup(e)),!1),document.addEventListener("handle-active",(e=>{if(e.detail.selected===this.getSelected())return;const{selected:t}=e.detail,n=this.sourceNodeByInspectorNodeLookup.get(t);if(this.options.makeVisible){const e=this.domView.querySelector(".adi-content");(n.offsetTop>=e.clientHeight||n.offsetTop<=e.scrollTop)&&(e.scrollTop=n.offsetTop-Math.floor(e.clientHeight/2))}this.drawAttrs(this.getSelected())})),document.addEventListener("execute-action",(e=>this.processExecuteAction(event)),{capture:!0}),this.addEventDelegate(this.optsView,"change",(e=>this.changeOption(e)),!1,"input"),this.addEventDelegate(this.optsView,"click",(e=>this.toggleOptions(e)),!1,".adi-opt-close"),this.menuView.querySelector(".adi-menu-config").addEventListener("click",(e=>this.toggleOptions(e)),!1),this.isInstanceViewer||this.addEventDelegate(this.attrView,"change",this.changeAttribute,!1,"input")}}class En extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.instanceName=null,this.instance=null}connectedCallback(){this.render(),this.instance?this.shadowRoot.querySelector("#focus-button").style="display: none":this.setupFocusButton()}setInstance(e){this.instance=e}disconnectedCallback(){this.adiInstance=null}setupFocusButton(){let e="",t=null;const n=()=>{""===e?t.removeAttribute("style"):t.setAttribute("style",e),t=null},r=r=>{const{target:a}=r;if("mouseover"===r.type)return e=a.getAttribute("style")||"",a.setAttribute("style",`outline: 2px solid blue; ${e}`),void(t=a);t&&n()},a=this.shadowRoot.querySelector("#focus-button");let s=!1;const o=window.document.head.appendChild(document.createElement("style")),i=()=>{s=!1,window.document.body.removeEventListener("click",l),a.classList.remove("selected-btn"),o.innerHTML="",document.body.style.cursor="auto",window.document.body.removeEventListener("mouseover",r),window.document.body.removeEventListener("mouseout",r),t&&n()},l=e=>{i(),e.preventDefault(),e.stopPropagation(),e.target!==a&&window.document.dispatchEvent(new CustomEvent("log-active-element",{detail:{target:e.target}}))},c=()=>{s=!0,a.classList.add("selected-btn"),document.body.style.cursor="crosshair",window.document.body.removeEventListener("click",l),o.innerHTML='fx-fore::before { color:blue; content: "Sub fore!" } fx-fore {border: solid 1px blue}',window.document.body.addEventListener("click",l),window.document.body.addEventListener("mouseover",r),window.document.body.addEventListener("mouseout",r)};window.document.addEventListener("keyup",(e=>{s&&"Escape"===e.code?i():!s&&"KeyI"===e.code&&e.ctrlKey&&c()})),a.addEventListener("click",(e=>{s?i():c(),e.preventDefault(),e.stopPropagation()}))}render(){this.shadowRoot.innerHTML="\n <style>\n \n @import '../../resources/fore.css';\n \n :host {\n display:block;\n background:transparent;\n }\n body {\n -webkit-animation: bugfix infinite 1s;\n font-size:1rem;\n }\n \n @-webkit-keyframes bugfix {\n from {\n padding: 0\n }\n to {\n padding: 0\n }\n }\n .adi-content {\n position: relative;\n overflow: auto;\n box-sizing: border-box;\n -moz-box-sizing: border-box;\n height: 100% !important;\n padding:0;\n font-size:0.8em;\n }\n .adi-content header{\n padding:0.5rem;\n // background:rgba(255, 255, 255, 0.2);\n border-bottom:2px solid #ddd;\n border-collapse:collapse;\n }\n .adi-content > * {\n padding:0 0.25em;\n }\n \n #adi-wrapper {\n top: 0;\n font-family: \"Segoe UI\", Arial;\n font-size: 1.1rem;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n position:relative;\n height:calc(100% - 8rem);\n display:flex;\n }\n \n #adi-wrapper.left {\n left: 0\n }\n \n #adi-wrapper.right {\n right: 0\n }\n \n #adi-wrapper.transparent {\n background: rgba(250, 250, 250, 0.9)\n }\n \n #adi-panel {\n position:fixed;\n top:0;\n /*bottom: 0;*/\n right: 0;\n height: 24px;\n background: #d4d4d4;\n border-top: 1px solid #bbc5c9\n }\n \n #adi-panel .adi-path-wrap {\n position:absolute;\n bottom: 0;\n left: 0;\n width: 80%;\n height: 24px;\n padding: 0 13px 0 18px;\n line-height: 24px;\n overflow: hidden;\n box-sizing: border-box;\n -moz-box-sizing: border-box\n }\n \n #adi-panel .adi-path-wrap.adi-overflowing .adi-path-left, \n #adi-panel .adi-path-wrap.adi-overflowing .adi-path-right {\n display: block\n }\n \n #adi-panel .adi-path {\n height: 24px;\n overflow: hidden;\n white-space: nowrap\n }\n \n #adi-panel .adi-path-left, #adi-panel .adi-path-right {\n display: none;\n position: absolute;\n top: 0;\n width: 8px;\n height: 24px;\n background-repeat: no-repeat;\n background-position: center center;\n opacity: .7\n }\n \n #adi-panel .adi-path-left:hover, #adi-panel .adi-path-right:hover {\n opacity: 1\n }\n \n #adi-panel .adi-path-left {\n left: 7px;\n background-image: url('img/left_shift.png')\n }\n \n #adi-panel .adi-path-right {\n position:absolute;\n right: 2px;\n background-image: url('/resources/scripts/dom-inspector/img/right_shift.png')\n }\n \n #adi-panel .adi-menu-wrap {\n bottom: 0;\n right: 24px;\n width: 50px;\n height: 24px\n }\n \n #adi-panel .adi-menu-lookup, #adi-panel .adi-menu-config {\n display: block;\n float: left;\n width: 24px;\n height: 24px;\n border-left: 1px solid #bbc5c9;\n background-position: center center;\n background-repeat: no-repeat;\n opacity: .7;\n border-radius: 0\n }\n \n #adi-panel .adi-menu-lookup:hover, #adi-panel .adi-menu-config:hover {\n background-color: #c5d9d8;\n opacity: 1\n }\n \n #adi-panel .adi-menu-lookup.adi-active, #adi-panel .adi-menu-config.adi-active {\n background-color: #fafafa;\n opacity: 1\n }\n \n #adi-panel .adi-menu-lookup {\n background-image: url('/resources/scripts/dom-inspector/img/lookup.png')\n }\n \n #adi-panel .adi-menu-config {\n background-image: url('/resources/scripts/dom-inspector/img/config.png')\n }\n \n \n \n #adi-vert-split {\n position: fixed;\n top: 0;\n width: 4px;\n height: 100%;\n cursor: e-resize;\n border-width: 0 1px 0 0;\n background: #bbc5c9;\n border-color: #768285;\n border-style: solid;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n }\n \n #adi-vert-split:hover {\n background: #c5d9d8;\n }\n \n \n #adi-dom-view {\n border-right:2px solid #ddd;\n overflow:auto;\n flex-grow:3;\n }\n \n #adi-dom-view ul {\n margin: 0;\n padding: 0;\n list-style: none\n }\n \n #adi-dom-view ul[data-open=true] {\n display: block\n }\n \n #adi-dom-view ul[data-open=false] {\n display: none\n }\n \n #adi-dom-view ul ul {\n margin: 4px 0\n }\n \n #adi-dom-view ul li {\n padding-left: 1em;\n padding-bottom: 0.125em;\n margin: 0;\n padding-top: 0.125em; \n }\n \n \n \n \n \n \n \n #adi-dom-view .adi-normal-node, \n #adi-dom-view .adi-end-node {\n margin-right: 5px;\n padding: 0 6px 0px;\n background: #d2e8ff;\n border-radius: 8px;\n cursor: default;\n font-size:0.8rem;\n }\n #adi-dom-view .adi-text-node:after, #adi-dom-view .adi-comment-node:after {\n content: '\"'\n }\n \n #adi-dom-view .adi-text-node:before, #adi-dom-view .adi-comment-node:before {\n content: '\"'\n }\n \n #adi-dom-view .adi-comment-node {\n color: #999;\n font-style: italic\n }\n \n #adi-dom-view .adi-text-node, #adi-dom-view .adi-comment-node {\n display: block;\n padding: 3px 8px;\n color: #444;\n background: #fff;\n border-radius: 8px\n }\n \n #adi-dom-view .adi-normal-node:hover, \n #adi-dom-view .adi-normal-node.hover, \n #adi-dom-view .adi-end-node:hover, \n #adi-dom-view .adi-end-node.hover {\n background: var(--paper-grey-700);\n color:white;\n }\n \n #adi-dom-view .adi-normal-node:hover ~ span,\n #adi-dom-view .adi-normal-node.hover ~ span,\n #adi-dom-view .adi-end-node:hover ~ span,\n #adi-dom-view .adi-end-node.hover ~ span {\n background: var(--paper-grey-700);\n color:white;\n }\n \n #adi-dom-view .adi-normal-node.adi-active-node, \n #adi-dom-view .adi-end-node.adi-active-node {\n background: var(--paper-grey-700);\n color:white;\n }\n \n #adi-dom-view .adi-normal-node.adi-active-node ~ span,\n #adi-dom-view .adi-end-node.adi-active-node ~ span {\n background: var(--paper-grey-700);\n color:white;\n }\n \n \n \n \n \n \n #adi-dom-view .adi-trigger {\n display: inline-block;\n width: 10px;\n height: 10px;\n margin: 0 5px 0 -13px;\n opacity: .7\n }\n \n #adi-dom-view .adi-trigger.closed {\n // background: url('/resources/scripts/dom-inspector/img/node_closed.png') no-repeat;\n } \n #adi-dom-view .adi-trigger.closed::before {\n content:'\\25B8';\n }\n \n #adi-dom-view .adi-trigger.opened {\n // background: url('/resources/scripts/dom-inspector/img/node_opened.png') no-repeat\n }\n #adi-dom-view .adi-trigger.opened::before{\n content:'\\25BE';\n }\n \n #adi-dom-view .adi-trigger:hover {\n opacity: 1\n }\n \n #adi-opts-view {\n position: relative;\n height: 100%;\n padding: 0 15px;\n background: #fff\n }\n \n #adi-opts-view.adi-hidden {\n display: none\n }\n \n #adi-opts-view .adi-opt-heading, #adi-opts-view .adi-opt {\n display: block;\n padding: 5px 0\n }\n \n #adi-opts-view .adi-opt-heading {\n padding: 20px 0 10px;\n font-size: 1rem;\n }\n \n #adi-opts-view .adi-opt-heading:first-child {\n padding-top: 10px\n }\n \n #adi-opts-view .adi-opt input {\n margin-right: 6px\n }\n \n #adi-opts-view .adi-opt-close {\n position: absolute;\n top: 5px;\n right: 28px;\n width: 16px;\n height: 16px;\n background: url('/resources/scripts/dom-inspector/img/options_close.png') no-repeat;\n opacity: .7;\n }\n \n #adi-opts-view .adi-opt-close:hover {\n opacity: 1;\n }\n \n #adi-attr-view {\n top: 0.5rem;\n border: 1px solid #ddd;\n overflow: auto;\n padding: 0.25em;\n height: calc(90% - 1em);\n min-width: 10rem;\n position: absolute;\n z-index: 10;\n right: 0.5rem;\n background:rgba(255,255,255,0.85);\n }\n #adi-attr-view > .adi-content{\n height:calc(100% - 5em);\n overflow:auto;\n }\n \n #adi-attr-view .adi-attr {\n display: block;\n padding: 0.25em;\n }\n \n #adi-attr-view hr {\n height: 1px;\n border: none\n }\n \n #adi-attr-view input[type=text] {\n width: calc(100% - 0.5em);\n margin-top: 3px;\n padding: 2px;\n }\n \n #adi-horiz-split {\n height: 4px;\n cursor: n-resize;\n border-width: 0 0 1px 0;\n background: #bbc5c9;\n border-color: #768285;\n border-style: solid;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n }\n \n #adi-horiz-split:hover {\n background: #c5d9d8;\n }\n \n #adi-dom-view .fore-node{\n background: var(--paper-blue-700);\n font-size:1.1em;\n color:white;\n }\n #adi-dom-view .adi-normal-node.fore-node:hover {\n background: var(--paper-grey-700);\n color:white;\n }\n #adi-dom-view .adi-end-node.fore-node{\n background: var(--paper-blue-700);\n font-size:1em;\n color:white;\n }\n\n #adi-dom-view .adi-node .adi-active-node.fore-node,\n #adi-dom-view .adi-node.action .adi-active-node.fore-node,\n #adi-dom-view .adi-node.action .adi-active-node.fore-node ~ .adi-end-node\n {\n background: var(--paper-grey-700);\n color:white;\n }\n \n #adi-dom-view .adi-node.fx-fore{\n background:var(--paper-blue-grey-50); \n }\n #adi-dom-view .adi-node.fx-model{\n background:var(--paper-blue-grey-100); \n padding:0.25em 0;\n } \n \n #adi-dom-view .adi-node.action .fore-node {\n background:var(--paper-blue-grey-100);\n color:black;\n font-family:monospace;\n }\n \n .toggleView{\n /*width:20px;*/\n /*height: 20px;*/\n }\n input, select{\n display: block;\n }\n header{\n background:rgba(255, 255, 255, 0.2);\n }\n\n .selected-btn { color: orange }\n \n </style>\n \n <slot name=\"header\"></slot>\n <button id=\"focus-button\">Focus</button>\n <slot></slot>\n \n ",!this.hasAttribute("instance")||this.getAttribute("instance"),this.adiInstance=new An(this.shadowRoot,this.hasAttribute("instance")?this.instance:"#document")}verticalResize(e){if(!this.vertResizing)return;e=e||window.event,document.documentElement.style.cursor="e-resize";const t=this.options.width+this.xPos-e.clientX;t>=this.options.minWidth&&(this.options.width=t,this.xPos=e.clientX,this.refreshUI(),this.saveOptions())}}customElements.get("fx-dom-inspector")||customElements.define("fx-dom-inspector",En);class Nn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.instanceElement=null,this.foreSelector=null}connectedCallback(){this.container=this.querySelector(".json-path-picker-container"),this.foreSelector=this.hasAttribute("fore")?this.getAttribute("fore"):"fx-fore",this.render()}render(){const e=this.hasAttribute("instance")?this.getAttribute("instance"):"default";if(!document.querySelector(this.foreSelector))throw new Error(`this '${this.foreSelector}' does not match a fx-fore element`);this.shadowRoot.innerHTML=`\n <style>\n \n @import '../../resources/fore.css';\n \n :host {\n display:block;\n font-size:0.8em;\n background:rgba(250, 250, 250, 0.9);\n }\n .container{\n margin-left:1em;\n }\n .header{\n margin-left:0;\n }\n\n ::slot[name='header']{\n margin-left:-1em;\n }\n /* Syntax highlighting for JSON objects */\n ul.json-dict, ol.json-array {\n list-style-type: none;\n margin: 0 0 0 1px;\n border-left: 1px dotted #ccc;\n padding-left: 2em;\n }\n .json-string {\n // color: #0B7500;\n }\n .json-literal {\n color: #1A01CC;\n font-weight: bold;\n }\n \n /* Toggle button */\n a.json-toggle {\n position: relative;\n color: inherit;\n text-decoration: none;\n }\n a.json-toggle:focus {\n outline: none;\n }\n a.json-toggle:before {\n content: "\\25BC"; /* down arrow */\n position: absolute;\n display: inline-block;\n width: 1em;\n left: -1.2em;\n font-size:0.8em;\n }\n a.json-toggle.collapsed:before {\n content: "\\25B6"; /* left arrow */\n }\n \n /* Collapsable placeholder links */\n a.json-placeholder {\n color: #aaa;\n padding: 0 1em;\n text-decoration: none;\n }\n a.json-placeholder:hover {\n text-decoration: underline;\n }\n \n /* Copy path icon */\n .pick-path {\n color: lightgray;\n cursor: pointer;\n margin-left: 3px;\n }\n \n .pick-path:hover {\n color: darkgray;\n }\n \n \n </style>\n <slot name="header">\n <header class="header">${e}</header>\n </slot>\n <slot></slot>\n \n <div class="container"></div>\n \n `;const t=document.querySelector(`#${e}`);if(!t||"FX-INSTANCE"!==t.nodeName||"json"!==t.getAttribute("type"))throw new Error(`this '${e}' does not match an fx-instance element or is not of type JSON`);const n=this.shadowRoot.querySelector(".container"),r=t.instanceData;let a=this.json2html(r,{outputWithQuotes:!0});this.isCollapsable(r)&&(a="<a href='#' class=\"json-toggle\"></a>".concat(a)),n.innerHTML=a;this.shadowRoot.querySelectorAll(".json-toggle").forEach((e=>{e.addEventListener("click",this._handleToggleEvent.bind(this))}))}disconnectedCallback(){}_isHidden(e){const t=e.offsetWidth,n=e.offsetHeight;return 0===t&&0===n||"none"===window.getComputedStyle(e).display}_handleToggleEvent(e){const t=e.target;t.classList.toggle("collapsed");const n=this._siblings(t,"ul.json-dict, ol.json-array",(e=>{e.style.display=""===e.style.display||"block"===e.style.display?"none":"block"}));for(let e=0;e<n.length;e+=1)if(this._isHidden(n[e])){const t=n[e].children;let r=0;for(let e=0;e<t.length;e+=1)"LI"===t[e].tagName&&(r+=1);const a=r+(r>1?" items":" item");n[e].insertAdjacentHTML("afterend",'<a href class="json-placeholder">'.concat(a,"</a>"))}else this._siblings(n[e],".json-placeholder",(e=>e.parentNode.removeChild(e)));e.stopPropagation(),e.preventDefault()}_siblings(e,t,n){const r=[];for(let n=0;n<e.parentNode.children.length;n+=1){const a=e.parentNode.children[n];a!==e&&"string"==typeof t&&a.matches(t)&&r.push(a)}if(n&&"function"==typeof n)for(let e=0;e<r.length;e+=1)n(r[e]);return r}json2html(e,t){let n="";if("string"==typeof e){const t=e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");this.isUrl(t)?n+='<a href="'.concat(t,'" class="json-string">').concat(t,"</a>"):n+='<span class="json-string">"'.concat(t,'"</span>')}else if("number"==typeof e)n+='<span class="json-literal">'.concat(e,"</span>");else if("boolean"==typeof e)n+='<span class="json-literal">'.concat(e,"</span>");else if(null===e)n+='<span class="json-literal">null</span>';else if(e instanceof Array)if(e.length>0){n+='[<ol class="json-array">';for(let r=0;r<e.length;r+=1)n+='<li data-key-type="array" data-key="'.concat(r,'">'),this.isCollapsable(e[r])&&(n+='<a href="#" class="json-toggle"></a>'),n+=this.json2html(e[r],t),r<e.length-1&&(n+=","),n+="</li>";n+="</ol>]"}else n+="[]";else if("object"===this._typeof(e)){let r=Object.keys(e).length;if(r>0){n+='{<ul class="json-dict">';for(const a in e)if(e.hasOwnProperty(a)){n+='<li data-key-type="object" data-key="'.concat(a,'">');const s=t.outputWithQuotes?'<span class="json-string">"'.concat(a,'"</span>'):a;this.isCollapsable(e[a])?n+="<a href='#' class=\"json-toggle\">".concat(s,"</a>"):n+=s,n+=": ".concat(this.json2html(e[a],t)),r-=1,r>0&&(n+=","),n+="</li>"}n+="</ul>}"}else n+="{}"}return n}isUrl(e){return/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#:.?+=&%@!\-/]))?/.test(e)}_typeof(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?this._typeof=function(e){return typeof e}:this._typeof=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},this._typeof(e)}isCollapsable(e){return e instanceof Object&&Object.keys(e).length>0}static get observedAttributes(){return["data"]}attributeChangedCallback(e,t,n){"data"===e&&(this.jsonTextarea.value=n,this.updateTree(n))}updateTree(e){try{this.data=JSON.parse(e),this.treeView.innerHTML="",this.treeView.appendChild(this.createTreeView(this.data,""))}catch(e){alert("Invalid JSON")}}createTreeView(e,t){const n=document.createElement("ul");if(n.classList.add("jp-ul"),Array.isArray(e))e.forEach(((e,r)=>{const a=document.createElement("li");a.classList.add("jp-li");const s=`${t}[${r}]`;a.appendChild(this.createItemView(s,e)),n.appendChild(a)}));else if("object"==typeof e&&null!==e)Object.keys(e).forEach((r=>{const a=document.createElement("li");a.classList.add("jp-li");const s=`${t}.${r}`;a.appendChild(this.createItemView(s,e[r])),n.appendChild(a)}));else{const r=document.createElement("li");r.classList.add("jp-li"),r.appendChild(this.createItemView(t,e)),n.appendChild(r)}return n}}customElements.get("fx-json-instance")||customElements.define("fx-json-instance",Nn);class Tn extends HTMLElement{static get properties(){return{fore:{type:Object,description:"The fx-fore element the devtools are attached to"},instances:{type:Array,description:"Instances of selected Fore element"},selector:{type:String,description:"optional selector to attach to a certain fx-fore element with given id"}}}constructor(){super(),this.attachShadow({mode:"open"}),Object.keys(this.constructor.properties).forEach((e=>{const t=this.constructor.properties[e],n=t.attribute||e,r=this.getAttribute(n)||t.default,a=t.type(r);this[e]=a})),this.isResizing=!1,this.lastY=0,this.defaultHeight="40vh",this.buttonByInstanceId=new Map;const e=e=>{this.fore=e,this.instances=[...this.fore.getModel().instances];const t=this.shadowRoot.querySelector(".instances header");t.textContent="Data ",this.instances.forEach((e=>{const n=document.createElement("button");n.setAttribute("type","button"),n.textContent=e.id,t.appendChild(n),this.buttonByInstanceId.set(e.id,n),n.addEventListener("click",(()=>this.selectInstance(e.id)))})),this.instances.length&&this.selectInstance(this.instances[0].id)},t=document.querySelector("fx-fore");t&&(t.inited?e(t):t.addEventListener("model-construct-done",(()=>e(t)))),window.document.addEventListener("log-active-element",(t=>{const n=t?t.detail?.target||t.target:window.event.srcElement,r=n.nodeType===Node.DOCUMENT_NODE?null:n.closest("fx-fore");r&&e(r);const a=this.instances.find((e=>"xml"===e.type&&e.instanceData.contains(n)));a&&this.selectInstance(a.id)}))}_getInstanceForTarget(e){this.instances.forEach((t=>"xml"===t.type&&t.instanceData.contains(e)||"json"===t.type?t:void 0))}selectInstance(e){const t=this.buttonByInstanceId.get(e);if(!t)return;if(t.classList.contains("selected-btn"))return;const n=this.shadowRoot.querySelector(".selected-btn");n&&n.classList.remove("selected-btn"),t.classList.add("selected-btn");const r=this.shadowRoot.querySelector(".instance-panel");r.innerHTML="",this.instances=[...this.fore.querySelectorAll("fx-instance")];const a=Array.from(this.instances).find((t=>t.id===e)),s=this._renderInstancePanel(a);r.append(s)}connectedCallback(){this.render()}_startResize(e){this.isResizing=!0,this.lastY=e.clientY}_resizePanel(e){if(!this.isResizing)return;const t=e.clientY-this.lastY;this.style.height=this.offsetHeight-t+"px",this.lastHeight=this.style.height,this.lastY=e.clientY}_stopResize(e){e.preventDefault(),e.stopPropagation(),this.isResizing=!1,document.body.style.height="inherit",document.body.style.width="inherit";const t=document.body.scrollHeight+this.offsetHeight;document.body.style.height=`${t}px`}render(){const e=`\n <section class="wrapper">\n <slot></slot>\n <details class="fx-devtools" open>\n <div class="resizer"></div>\n <summary>Fore Glass \n <div>\n <svg preserveAspectRatio="xMidYMid meet" focusable="true" style="width: 24px;height: 24px; margin-bottom:-1px;" width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg">\n <g role="button" id="find-in-page"><path d="M20 19.59V8l-6-6H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c.45 0 .85-.15 1.19-.4l-4.43-4.43c-.8.52-1.74.83-2.76.83-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5c0 1.02-.31 1.96-.83 2.75L20 19.59zM9 13c0 1.66 1.34 3 3 3s3-1.34 3-3-1.34-3-3-3-3 1.34-3 3z"></path></g>\n </svg>\n <button class="optionsBtn" id="optionsTrigger">&#9881;</button> \n </div>\n </summary>\n <section class="panels">\n <section class="log">\n <fx-action-log selector="${this.selector}"></fx-action-log>\n </section>\n <section class="dom">\n <fx-dom-inspector>\n <header slot="header">Document</header>\n </fx-dom-inspector>\n </section>\n <section class="instances">\n <header></header>\n <div class="instance-panel">\n </div>\n </section>\n <section id="options">\n <fx-log-settings></fx-log-settings>\n </section>\n </section>\n </details>\n </section>\n `;this.shadowRoot.innerHTML=`\n <style>\n \n @import '../../resources/fore.css';\n \n :host {\n display:block;\n position:fixed;\n bottom:0;\n left:0;\n width:100vw;\n height:var(--fx-devtools-height);\n font-style:inherit;\n font-family: 'Verdana' , 'Sans';\n font-size:1em;\n max-width:100vw;\n height:3em;\n }\n :host(.open){\n height:40vh;\n }\n \n fx-action-log{\n height:100%;\n }\n fx-dom-inspector{\n max-height:100%;\n height:100%;\n position:relative;\n }\n body {\n }\n details{\n height:100%;\n background:#ebf6ff;\n }\n .dom{\n width:45%;\n border-left:1px solid #999;\n position:relative\n }\n .dom fx-minimap{\n position:absolute;\n right:0;\n top:0;\n width:5rem;\n height:6rem;\n }\n header{\n padding:0.5rem;\n border-bottom:2px solid #ddd;\n font-size:1rem;\n }\n header button{\n margin:0 0.5em;\n border:thin solid #999;\n padding:0 0.5em;\n cursor:pointer;\n }\n header button:hover{\n background:white;\n }\n \n header button.selected-btn{\n background:steelblue;\n color:white;\n }\n .instances{\n width:35%;\n border-left:1px solid #999;\n }\n .instance-panel{\n height:100%;\n overflow:auto;\n }\n .panels{\n display:grid;\n grid-template-columns:20% 50% 30%;\n height:100%;\n width:100%;\n max-height:100%;\n border-top:thin solid #ddd;\n }\n .panels > section {\n min-height:20rem;\n/*\n background:#efefef;\n*/\n position:relative;\n display:inline-block;\n height:100%;\n width:auto;\n }\n #options{\n display:none;\n }\n #options.open{\n position:absolute;\n z-index:10;\n left:0;\n top:3em;\n height:100%;\n display:block;\n padding:0;\n background:rgba(255,255,255,0.95);\n width:100%;\n }\n .optionsBtn{\n font-size:2rem;\n }\n details[open] .optionsBtn{\n display:inline;\n }\n .resizer{\n width:100vw;\n height:6px;\n background:rgba(215,220,235,0.3);\n cursor: ns-resize;\n position:absolute;\n top:0;\n \n }\n summary{\n height:3rem;\n padding:0 1em;\n border-bottom:2px solid #ddd;\n display:flex;\n justify-content:space-between;\n align-items:center;\n color:rgba(0,0,0,0.7);\n background: rgba(235, 255, 255, 0.2);\n box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);\n backdrop-filter: blur(5px);\n -webkit-backdrop-filter: blur(5px);\n border: 1px solid rgba(255, 255, 255, 0.3);\n \n color:white;\n font-weight:300;\n background: rgb(119,119,119);\n background: linear-gradient(90deg, rgba(0,85,159,0.75) 0%, rgba(56,154,252,0.5) 50%, rgba(255,255,255,0.1) 100%);\n\n }\n summary button{\n padding:0;\n border:0;\n background:transparent;\n }\n .wrapper{\n height:100%;\n }\n .vertDevider{\n background:#ddd;\n width:4px;\n height:100%;\n cursor: ew-resize;\n }\n \n </style>\n ${e}\n `,this.resizer=this.shadowRoot.querySelector(".resizer"),this.resizer.addEventListener("mousedown",this._startResize.bind(this)),document.addEventListener("mousemove",this._resizePanel.bind(this)),document.addEventListener("mouseup",this._stopResize.bind(this));const t=this.shadowRoot.querySelector("#optionsTrigger");t.addEventListener("click",(()=>{const e=this.shadowRoot.querySelector("#options");e.classList.toggle("open"),e.classList.contains("open")?t.style.background="lightsteelblue":t.style.background="transparent"}));this.shadowRoot.querySelector(".fx-devtools").addEventListener("click",(e=>{"DIV"===e.target.nodeName&&e.target.classList.contains("resizer")||(e.target.parentNode.open?(this.removeAttribute("open"),this.lastHeight=this.style.height,this.style.height="3em"):(this.setAttribute("open",""),this.style.height=this.lastHeight?this.lastHeight:"40vh"))})),this.classList.add("open")}_handleOpen(e){document.body.style.height=""}_renderInstancePanel(e){if("xml"===e.type){const t=document.createElement("fx-dom-inspector");return t.setInstance(e),t.setAttribute("instance",e.id),t}if("json"===e.type){const t=document.createElement("fx-json-instance");t.setAttribute("instance",e.id);const n=document.createElement("span");return n.setAttribute("slot","header"),t.append(n),t}}}customElements.get("fx-devtools")||customElements.define("fx-devtools",Tn);class Bn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.src=""}connectedCallback(){this.src=this.getAttribute("src");const e=`\n <fx-fore src="${this.src}">\n </fx-fore>\n <slot id="default"></slot>\n `;this.shadowRoot.innerHTML=`\n <style>\n \n :host {\n display:block;\n }\n \n </style>\n ${e}\n `;this.shadowRoot.querySelector("#default").addEventListener("slotchange",(async e=>{const t=e.target.assignedElements().filter((e=>"LINK"===e.nodeName.toUpperCase()));if(!t)return;const n=[...document.styleSheets].map((e=>{if(t.find((t=>t.href===e.href)))try{return[...e.cssRules].map((e=>e.cssText)).join("")}catch(e){}})).filter(Boolean).join("\n"),r=new CSSStyleSheet;r.replaceSync(n),this.shadowRoot.adoptedStyleSheets=[r]}));const t=this.querySelector("fx-action");if(t){const e=t.cloneNode(!0);this.removeChild(t);this.shadowRoot.querySelector("fx-fore").appendChild(e)}}}async function In(e){return new Promise((t=>setTimeout((()=>t()),e)))}customElements.get("fore-component")||customElements.define("fore-component",Bn);class Cn extends Mt{static get properties(){return{...super.properties,defaultAction:{type:String},delay:{type:Number},detail:{type:Object},event:{type:Object},handler:{type:Object},ifExpr:{type:String},iterateExpr:{type:String},needsUpdate:{type:Boolean},observer:{type:Object},phase:{type:String},propagate:{type:String},target:{type:String},whileExpr:{type:String}}}constructor(){super(),this.detail={},this.needsUpdate=!1}disconnectedCallback(){}connectedCallback(){this.setAttribute("inert","true"),this.style.display="none",this.propagate=this.hasAttribute("propagate")?this.getAttribute("propagate"):"continue",this.repeatContext=void 0,this.hasAttribute("event")&&(this.event=this.getAttribute("event")),this.hasAttribute("defaultAction")?this.defaultAction=this.getAttribute("defaultAction"):this.defaultAction="perform",this.hasAttribute("phase")?this.phase=this.getAttribute("phase"):this.phase="default",this.ifExpr=this.hasAttribute("if")?this.getAttribute("if"):null,this.whileExpr=this.hasAttribute("while")?this.getAttribute("while"):null,this.delay=this.hasAttribute("delay")?Number(this.getAttribute("delay")):0,this.iterateExpr=this.hasAttribute("iterate")?this.getAttribute("iterate"):null,this._addUpdateListener()}_addUpdateListener(){if(this.target=this.getAttribute("target"),this.target)if("#window"===this.target)window.addEventListener(this.event,(e=>this.execute(e)),{capture:"capture"===this.phase});else if("#document"===this.target)document.addEventListener(this.event,(e=>this.execute(e)),{capture:"capture"===this.phase});else{if(this.targetElement=ht(this.target,this),!this.targetElement)return;this?.targetElement.addEventListener(this.event,(e=>this.execute(e)),{capture:"capture"===this.phase})}else this.targetElement=this.parentNode,this.targetElement.addEventListener(this.event,(e=>this.execute(e)),{capture:"capture"===this.phase})}async performSafe(){try{return await this.perform(),!0}catch(e){return await Ft.dispatch(this,"error",{origin:this,message:"Action execution failed",expr:nt.getDocPath(this),level:"Error"}),!1}}async execute(e){if(!this.getModel().modelConstructed)return;if(e&&e.target.nodeType!==Node.DOCUMENT_NODE&&e.target!==window&&e.target.closest("fx-fore")&&e.target.closest("fx-fore")!==this.closest("fx-fore"))return;"stop"===this.propagate&&e.stopPropagation(),"cancel"===this.defaultAction&&e.preventDefault();let t=()=>{};e&&e.listenerPromises&&e.listenerPromises.push(new Promise((e=>{t=e}))),null===qt.outermostHandler&&(qt.outermostHandler=this,this.dispatchEvent(new CustomEvent("outermost-action-start",{composed:!0,bubbles:!0,cancelable:!0,detail:{cause:e?.type}}))),e&&(this.currentEvent=e),this.needsUpdate=!1;try{this.evalInContext()}catch(e){}if(this.targetElement&&this.targetElement.nodeset&&(this.nodeset=this.targetElement.nodeset),this.iterateExpr)return await this.handleIterateExpr(),void this._finalizePerform(t);if(!this.ifExpr||xt(this.ifExpr,Ot(this),this)){if(this.whileExpr)return await this.handleWhileExpr(),void this._finalizePerform(t);if(this.delay&&(await In(this.delay),!nt.contains(this.getOwnerForm(),this)))return this.actionPerformed(),void t();await this.performSafe(),this._finalizePerform(t)}else this._finalizePerform(t)}async handleWhileExpr(){await In(this.delay||0),nt.contains(this.getOwnerForm(),this)&&xt(this.whileExpr,Ot(this),this)&&this.performSafe()&&(this.delay?this.handleWhileExpr():await this.handleWhileExpr())}async handleIterateExpr(){try{const e=wt(this.iterateExpr,Ot(this),this);if(0===e.length)return;if(!nt.contains(this.getOwnerForm(),this))return;for(const t of e)if(this.delay&&await In(this.delay||0),this.currentContext=t,!await this.performSafe())return}finally{this.currentContext=null}}_finalizePerform(e){this.currentEvent=null,this.actionPerformed(),qt.outermostHandler===this&&(qt.outermostHandler=null,this.dispatchEvent(new CustomEvent("outermost-action-end",{composed:!0,bubbles:!0,cancelable:!0}))),e()}async perform(){(this.isBound()||"FX-ACTION"===this.nodeName)&&this.evalInContext(),this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}}))}actionPerformed(){const e=this.getModel();e&&e.inited&&(qt.outermostHandler&&!nt.contains(qt.outermostHandler.ownerDocument,qt.outermostHandler)&&(qt.outermostHandler=null),!this.needsUpdate||qt.outermostHandler!==this&&qt.outermostHandler?this.needsUpdate&&(qt.outermostHandler.needsUpdate=!0):(e.recalculate(),e.revalidate(),e.parentNode.refresh(!0),this.dispatchActionPerformed()))}dispatchActionPerformed(){Ft.dispatch(this,"action-performed",{})}}Cn.dataChanged=!1,customElements.get("abstract-action")||window.customElements.define("abstract-action",Cn);class Sn extends Cn{static get properties(){return{...Cn.properties,ref:{type:String},repeat:{type:String},clear:{type:String}}}constructor(){super(),this.repeat=""}connectedCallback(){super.connectedCallback(),this.ref=this.getAttribute("ref"),this.repeat=this.getAttribute("repeat")}async perform(){super.perform(),this._dataFromTemplate(),this.needsUpdate=!0}actionPerformed(){super.actionPerformed(),this._dispatch()}_dataFromTemplate(){const e=this.getInScopeContext(),t=this.getOwnerForm().querySelector(`#${this.repeat}`),n=t.shadowRoot.querySelector("template"),r=e.ownerDocument.createElement(t.ref),a=this._generateInstance(n.content,r);e.appendChild(a)}_dispatch(){const e=ht(this.repeat,this);Ft.dispatch(e,"index-changed",{index:e.nodeset.length})}_clear(e){let t=e.firstChild;const n=e.attributes;for(let e=0;e<n.length;e+=1)n[e].value="";for(;t;)1===t.nodeType&&t.hasAttributes()&&(t.textContent=""),this._clear(t),t=t.nextSibling}_generateInstance(e,t){if(1===e.nodeType&&e.hasAttribute("ref")){const n=e.getAttribute("ref");let r;"."===n||(n.startsWith("@")?t.setAttribute(n.substring(1),""):(r=document.createElement(n),t.appendChild(r),0===e.children.length&&(r.textContent=e.textContent)))}if(e.hasChildNodes()){const n=e.children;for(let e=0;e<n.length;e+=1)this._generateInstance(n[e],t)}return t}getInstanceId(){return this.ref.startsWith("instance(")?"not implemented":"default"}}customElements.get("fx-append")||window.customElements.define("fx-append",Sn);class On extends Cn{static get properties(){return{...super.properties,ref:{type:String}}}async perform(){const e=Ot(this.getAttributeNode("ref")||this,this.ref);this.nodeset=bt(this.ref,e,this);const t=nt.resolveInstance(this,this.ref),n=this.getModel().getInstance(t),r=Ft.getDomNodeIndexString(this.nodeset),a=this.nodeset;let s;if(this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event,path:r}})),Array.isArray(a)){if(0===a.length)return;s=a[0].parentNode,a.forEach((e=>{this._deleteNode(s,e)}))}else s=a.parentNode,this._deleteNode(s,a);await Ft.dispatch(n,"deleted",{ref:r,deletedNodes:a}),this.needsUpdate=!0}_deleteNode(e,t){if(e.nodeType===Node.DOCUMENT_NODE)return;if(t.nodeType===Node.DOCUMENT_NODE)return;if(t.nodeType===Node.DOCUMENT_FRAGMENT_NODE)return;if(null===t.parentNode)return;this.getModelItem().readonly||e.removeChild(t)}actionPerformed(){this.getModel().rebuild(),super.actionPerformed()}}customElements.get("fx-delete")||window.customElements.define("fx-delete",On);class Fn extends Cn{connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.control=this.hasAttribute("control")?this.getAttribute("control"):null}async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}}));const e=`#${this.control}`;let t=document.querySelector(e);if(!t)return void Ft.dispatch(this,"error",{origin:this,message:`Instance '${this.control}' not found`,level:"Error"});const n=t.closest("fx-repeatitem");n&&(t=n.querySelector(e),this._focus(t));const r=t.closest("fx-repeatitem, .fx-repeatitem");if(r){t=r.parentNode.querySelector(`[repeat-index] ${e}`)}this._focus(t),this.hasAttribute("select")&&this._select(t)}_focus(e){e&&"function"==typeof e.getWidget&&e.getWidget().focus(),e&&e.nodeType===Node.ELEMENT_NODE&&e.click()}_select(e){e&&e.getWidget().select()}}customElements.get("fx-setfocus")||window.customElements.define("fx-setfocus",Fn);class Dn extends Cn{static get properties(){return{...super.properties,at:{type:Number},position:{type:Number},origin:{type:Object},keepValues:{type:Boolean}}}constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){super.connectedCallback&&super.connectedCallback();this.shadowRoot.innerHTML="\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n <slot></slot>\n ",this.at=Number(this.hasAttribute("at")?this.getAttribute("at"):0),this.position=this.hasAttribute("position")?this.getAttribute("position"):"after",this.origin=this.hasAttribute("origin")?this.getAttribute("origin"):null,this.keepValues=!!this.hasAttribute("keep-values")}_getOriginSequence(e,t){let n;if(this.origin){let t;try{t=vt(this.origin,e,this),Array.isArray(t)&&0===t.length&&(n=null),n=t}catch(e){}}else t&&(n=t,n&&!this.keepValues&&this._clear(n));return n}_cloneOriginSequence(e,t){let n;if(this.origin){let t;try{t=vt(this.origin,e,this),Array.isArray(t)&&0===t.length&&(n=null),n=t.cloneNode(!0)}catch(e){}}else t&&(n=this._cloneTargetSequence(t),n&&!this.keepValues&&this._clear(n));return n}_getInsertIndex(e,t){return 0===t.length?null:this.hasAttribute("at")?Et(this.getAttribute("at"),e,this):t.length}async perform(){let e,t,n=[];const r=Ot(this);this.hasAttribute("context")&&([t]=bt(this.getAttribute("context"),r,this.getOwnerForm()),e=r),this.hasAttribute("ref")&&(e||(e=Ot(this.getAttributeNode("ref"),this.ref)),n=bt(this.ref,e,this));const a=this._cloneOriginSequence(e,n);if(!a)return;let s,o;if(0===n.length)t?(s=t,t.appendChild(a),o=1):(s=e,e.appendChild(a),o=1);else{if(this.hasAttribute("at")?(o=Et(this.getAttribute("at"),e,this),s=n[o-1]):(o=n.length,s=n[n.length-1]),!s){o=1,s=n;o=Et("count(preceding::*)",n,this.getOwnerForm())+1}this.position&&"before"===this.position&&s.parentNode.insertBefore(a,s),this.position&&"after"===this.position&&(o+=1,this.hasAttribute("context")&&this.hasAttribute("ref")?e.append(a):this.hasAttribute("context")?(o=1,s.prepend(a)):s.insertAdjacentElement("afterend",a))}const i=nt.resolveInstance(this,this.ref),l=this.getModel().getInstance(i),c=nt.getPath(s.parentNode,i),u=Ft.getDomNodeIndexString(a);return this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event,path:u}})),Ft.dispatch(l,"insert",{"inserted-nodes":a,"insert-location-node":s,position:this.position}),document.dispatchEvent(new CustomEvent("index-changed",{composed:!0,bubbles:!0,detail:{insertedNodes:a,index:o}})),this.needsUpdate=!0,[c]}_cloneTargetSequence(e){return Array.isArray(e)&&0!==e.length?e[e.length-1].cloneNode(!0):!Array.isArray(e)&&e?e.cloneNode(!0):null}actionPerformed(e){this.getModel().rebuild(),super.actionPerformed()}_clear(e){const t=e.attributes;for(let e=0;e<t.length;e+=1)t[e].value="";e.textContent&&(e.textContent="");let n=e.firstChild;for(;n;)1===n.nodeType&&n.hasAttributes()&&(n.textContent=""),this._clear(n),n=n.nextSibling}}customElements.get("fx-insert")||window.customElements.define("fx-insert",Dn);class kn extends Cn{constructor(){super(),this.attachShadow({mode:"open"})}static get properties(){return{...Cn.properties,modelItem:void 0,messageTextContent:{type:String,get value(){return"here!"}}}}connectedCallback(){super.connectedCallback(),this.event=this.hasAttribute("event")?this.getAttribute("event"):"",this.level=this.hasAttribute("level")?this.getAttribute("level"):"ephemeral",this.message="",this.messageTextContent=this.textContent;this.shadowRoot.innerHTML=`\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n ${this.renderHTML()}\n `}renderHTML(){return"\n <slot></slot>\n "}async perform(){super.perform(),this.hasAttribute("value")?this.message=this._getValue():(this.getOwnerForm().evaluateTemplateExpression(this.messageTextContent,this.firstChild),this.message=this.textContent),this.dispatchEvent(new CustomEvent("message",{composed:!1,bubbles:!0,detail:{level:this.level,message:this.message}}))}_getValue(){if(this.hasAttribute("value")){const e=this.getAttribute("value");try{return At(e,Ot(this,e),this)}catch(e){Ft.dispatch(this,"error",{message:e})}}return this.textContent?this.textContent:null}}customElements.get("fx-message")||window.customElements.define("fx-message",kn);class Rn extends Cn{static get properties(){return{...super.properties,ref:{type:String},valueAttr:{type:String}}}constructor(){super(),this.ref="",this.valueAttr=""}connectedCallback(){if(super.connectedCallback&&super.connectedCallback(),!this.hasAttribute("ref"))throw new Error('fx-setvalue must specify a "ref" attribute');this.ref=this.getAttribute("ref"),this.valueAttr=this.getAttribute("value")}async perform(){super.perform();let{value:e}=this;null!==this.valueAttr?[e]=wt(this.valueAttr,this.nodeset,this,this.detail):e=""!==this.textContent?this.textContent:"",e?.nodeType&&e.nodeType===Node.ATTRIBUTE_NODE&&(e=e.nodeValue);const t=this.getModelItem();this.setValue(t,e)}dispatchExecute(){}setValue(e,t){const n=e;if(n&&n.value!==t){const r=Ft.getDomNodeIndexString(e.node),a=this.event,s=this;this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:s,event:a,value:t,path:r}})),t?.nodeType?(t.nodeType===Node.ELEMENT_NODE&&(n.value=t.textContent),t.nodeType===Node.ATTRIBUTE_NODE&&(n.value=t.getValue())):n.value=t,this.getModel().changed.push(e),this.needsUpdate=!0}}}customElements.get("fx-setvalue")||window.customElements.define("fx-setvalue",Rn);class Mn extends Cn{constructor(){super(),this.value="",this.url=null,this.target=null}connectedCallback(){super.connectedCallback(),this.submission=this.getAttribute("submission"),this.url=this.hasAttribute("url")?this.getAttribute("url"):null,this.target=this.hasAttribute("target")?this.getAttribute("target"):null,this.connection=this.hasAttribute("connection")?this.getAttribute("connection"):null}async perform(){if(super.perform(),this.getOwnerForm().classList.remove("submit-validation-failed"),this.connection){return null===this.getModel().querySelector(`#${this.connection}`)?void this.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,cancelable:!0,detail:{id:this.id,origin:this,message:`<fx-connection id="${this.connection}"> not found`,expr:nt.getDocPath(this),level:"Error"}})):void this._emitToChannel()}const e=this.getModel().querySelector(`#${this.submission}`);if(null!==e){if(this.url){const t=this.evaluateAttributeTemplateExpression(this.url,this);e.parameters.set("url",t)}if(this.target){const t=this.evaluateAttributeTemplateExpression(this.target,this);e.parameters.set("target",t)}await e.submit()}else this.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,cancelable:!0,detail:{id:this.id,origin:this,message:`<fx-submission id="${this.submission}"> not found`,expr:nt.getDocPath(this),level:"Error"}}))}_emitToChannel(){const e=this.getModel().querySelector(`#${this.connection}`);null!==e&&e.send()}}customElements.get("fx-send")||window.customElements.define("fx-send",Mn);class Un extends Cn{connectedCallback(){super.connectedCallback(),this.hasAttribute("case")&&(this.case=this.getAttribute("case"))}async perform(){if(super.perform(),this.case){const e=this.getOwnerForm().querySelector(`#${this.case}`);if(!e)return void Ft.dispatch(this,"error",{message:`fx-case id not found: ${this.case}`});e.parentNode.toggle(e)}this.needsUpdate=!0}}customElements.get("fx-toggle")||window.customElements.define("fx-toggle",Un);class Gn extends Cn{static get properties(){return{...super.properties,name:{type:String},targetid:{type:String},details:{type:String}}}constructor(){super(),this.name=null,this.targetid=null,this.details=null,this.attachShadow({mode:"open"})}connectedCallback(){if(super.connectedCallback(),this.name=this.getAttribute("name"),!this.name)throw new Error("no event specified for dispatch",this);this.targetid=this.hasAttribute("targetid")?this.getAttribute("targetid"):null}async perform(){super.perform();const e=this.querySelectorAll("fx-property"),t={};if(Array.from(e).forEach((e=>{const n=e.getAttribute("name"),r=e.getAttribute("value"),a=e.getAttribute("expr");if(a){if(r)throw new Error('if "expr" is given there must not be a "value" attribute');const[e]=wt(a,this.getInScopeContext(),this);let s=null;if(e.nodeName){s=(new XMLSerializer).serializeToString(e)}t[n]=s||e}r&&(t[n]=r)})),this.targetid){let e=ht(this.targetid,this.parentNode,null);if(e||(e=document.getElementById(this.targetid)),!e)throw new Error(`targetid ${this.targetid} does not exist in document`);e.dispatchEvent(new CustomEvent(this.name,{composed:!0,bubbles:!0,detail:t}))}else document.dispatchEvent(new CustomEvent(this.name,{composed:!0,bubbles:!0,detail:t}))}}customElements.get("fx-dispatch")||window.customElements.define("fx-dispatch",Gn);class Ln extends Cn{async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}})),this.getModel().updateModel()}}customElements.get("fx-update")||window.customElements.define("fx-update",Ln);class $n extends Cn{async perform(){if(this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}})),this.hasAttribute("self")){const e=nt.getClosest("fx-control",this);if(e)return void e.refresh()}if(this.hasAttribute("force"))this.getOwnerForm().forceRefresh();else if(this.hasAttribute("control")){const e=ht(this.getAttribute("control"),this);e&&Ft.isUiElement(e.nodeName)&&"function"==typeof e.refresh&&e.refresh()}else this.getOwnerForm().refresh()}}customElements.get("fx-refresh")||window.customElements.define("fx-refresh",$n);class Pn extends Cn{static get properties(){return{...super.properties,with:{type:String},replaceNode:Object}}constructor(){super(),this.with=""}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.with=this.getAttribute("with")}async perform(){super.perform();const e=vt(this.with,this.nodeset,this);e&&this.replace(this.nodeset,e)}actionPerformed(){this.getModel().rebuild(),super.actionPerformed()}replace(e,t){if(e&&t&&e.nodeName&&t.nodeName){if(e.nodeType===Node.ATTRIBUTE_NODE){const{ownerElement:n}=e;n.setAttribute(t.nodeName,t.textContent),n.removeAttribute(e.nodeName)}else if(e.nodeType===Node.ELEMENT_NODE){const n=t.cloneNode(!0);e.replaceWith(n)}this.needsUpdate=!0}}}customElements.get("fx-replace")||window.customElements.define("fx-replace",Pn);class _n extends Cn{connectedCallback(){super.connectedCallback&&super.connectedCallback()}async perform(){super.perform();const e=new CustomEvent("return",{composed:!0,bubbles:!0,detail:{nodeset:this.nodeset}});this.getOwnerForm().dispatchEvent(e)}}customElements.get("fx-return")||window.customElements.define("fx-return",_n);class Hn extends Cn{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.src=this.hasAttribute("src")?this.getAttribute("src"):null;this.shadowRoot.innerHTML="\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n <slot></slot>\n "}async perform(){super.perform();const{children:e}=this;if(this.src){this.innerHTML="";const e=document.createElement("script");e.src=this.src,this.appendChild(e)}else{for(const t of e){if("fx-var"===t.localName)continue;const e=t;e.detail=this.detail,await e.execute()}this.dispatchActionPerformed(),this.needsUpdate=!0}}}customElements.get("fx-action")||window.customElements.define("fx-action",Hn);class jn extends Hn{static get properties(){return{...Hn.properties,message:{type:String}}}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.message=this.hasAttribute("message")?this.getAttribute("message"):null}async perform(){window.confirm(this.message)&&await super.perform()}}customElements.get("fx-confirm")||window.customElements.define("fx-confirm",jn);class Xn extends Hn{connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.dialog=this.getAttribute("dialog"),this.dialog||Ft.dispatch(this,"error",{message:"dialog does not exist"})}async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}}));const e=ht(this.dialog,this);e.open(),Ft.dispatch(e,"dialog-shown",{})}}customElements.get("fx-show")||window.customElements.define("fx-show",Xn);class qn extends Cn{static get properties(){return{...super.properties,dialog:{type:String}}}connectedCallback(){super.connectedCallback(),this.dialog=this.getAttribute("dialog"),this.dialog||Ft.dispatch(this,"error",{message:"dialog does not exist"})}async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}}));const e=ht(this.dialog,this);e.hide(),Ft.dispatch(e,"dialog-hidden",{})}}customElements.get("fx-hide")||window.customElements.define("fx-hide",qn);class Vn extends Cn{connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.addEventListener("reload",(()=>{window.location.reload()}),{once:!0})}async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}})),Ft.dispatch(this,"reload",{})}}customElements.get("fx-reload")||window.customElements.define("fx-reload",Vn);class Yn extends Cn{static get properties(){return{...super.properties,instance:{type:String}}}connectedCallback(){super.connectedCallback(),this.instance=this.getAttribute("instance"),this.instance||Ft.dispatch(this,"error",{message:"instance does not exist"})}async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}}));this.getModel().getInstance(this.instance).reset(),this.needsUpdate=!0}}customElements.get("fx-reset")||window.customElements.define("fx-reset",Yn);class zn extends Cn{static get properties(){return{...super.properties,attachTo:{type:String},url:{type:String}}}constructor(){super(),this.attachShadow({mode:"open"}),this.url=""}connectedCallback(){super.connectedCallback(),this.attachTo=this.hasAttribute("attach-to")?this.getAttribute("attach-to"):"_self",this.awaitEvent=this.hasAttribute("await")?this.getAttribute("await"):"",this.url=this.hasAttribute("url")?this.getAttribute("url"):"";this.shadowRoot.innerHTML=`\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n ${this.renderHTML()}`}disconnectedCallback(){this.targetElement.removeEventListener(this.event,(e=>this.execute(e)))}renderHTML(){return"\n <slot></slot>\n "}async perform(){await super.perform();const e=this.querySelector("template");if(e){const t=e.content.cloneNode(!0),n=document.importNode(t,!0);if(this.attachTo.startsWith("#")){const e=ht(this.attachTo.substring(1),this);for(;e.firstChild;)e.removeChild(e.firstChild);if(this.awaitEvent){let t;const r=new Promise((e=>{t=e})),a=()=>{t(),e.removeEventListener(this.awaitEvent,a)};return e.appendChild(n),e.addEventListener(this.awaitEvent,a),await r,this.needsUpdate=!0,void Ft.dispatch(this,"loaded",{attachPoint:this.attachTo,content:n})}e.appendChild(n),this.needsUpdate=!0}return void Ft.dispatch(this,"loaded",{})}if(!this.url)return void this.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,cancelable:!0,detail:{origin:this,message:"neither template element nor Url was specified.",level:"Error"}}));const t=this.evaluateAttributeTemplateExpression(this.url,this);"_blank"===this.attachTo&&window.open(this.url),"_self"===this.attachTo&&(window.location.href=this.url);try{const e=await fetch(t,{method:"GET",mode:"cors",credentials:"same-origin",headers:{"Content-Type":"text/html"}}),n=await e.text();this.attachTo||(this.innerHtml=n),this._attachToElement(n),Ft.dispatch(this,"loaded",{url:this.url})}catch(e){throw new Error(`failed loading data ${e}`)}}_attachToElement(e){let t;if(e.nodeType)t=e;else try{t=(new DOMParser).parseFromString(e,"text/html").firstElementChild}catch(e){Ft.dispatch(this,"error",{message:"parsing of content as HTML failed"})}if(this.attachTo.startsWith("_")||this.attachTo.startsWith("#")||Ft.dispatch(this,"error",{message:'valid values for "attach-to" start with "_" or "#"'}),this.attachTo.startsWith("#")){const e=ht(this.attachTo.substring(1),this);if(e.innerHTML="",t.querySelector("fx-fore"))return void e.append(t.querySelector("fx-fore").cloneNode(!0));const n=t.querySelector("body").cloneNode(!0);e.appendChild(n.firstElementChild)}}_evaluateUrlExpression(){const e=this.getAttribute("url");if(!e)throw new Error("url not specified");return e.replace(/{[^}]*}/g,(e=>{if("{}"===e)return e;const t=e.substring(1,e.length-1),n=Ot(this,t);if(!n)return e;const r=nt.getInstanceId(t);r?this.getModel().getInstance(r):this.getModel().getDefaultInstance();try{return At(t,n,this,null)}catch(t){return e}}))}}customElements.get("fx-load")||window.customElements.define("fx-load",zn);class Jn extends Cn{static get properties(){return{...super.properties,ref:{type:String},valueAttr:{type:String},value:{type:Boolean}}}constructor(){super(),this.ref="",this.valueAttr="",this.value=!1}connectedCallback(){if(super.connectedCallback&&super.connectedCallback(),!this.hasAttribute("ref"))throw new Error('fx-togglealue must specify a "ref" attribute');this.ref=this.getAttribute("ref")}async perform(){super.perform();const e=this.getModelItem();"true"===e.value?e.node.textContent="false":e.node.textContent="true",this.needsUpdate=!0}}customElements.get("fx-toggleboolean")||window.customElements.define("fx-toggleboolean",Jn);class Qn extends Cn{static get properties(){return{...super.properties,action:{type:String},fn:{type:String}}}constructor(){super(),this.action="",this.fn=""}connectedCallback(){if(super.connectedCallback&&super.connectedCallback(),this.hasAttribute("action"))this.action=this.getAttribute("action");else{if(!this.hasAttribute("function"))throw new Error('fx-call must specify an "action" or "function" attribute');this.fn=this.getAttribute("function")}}async perform(){super.perform(),this.action&&await this._callAction(),this.fn&&this._callFunction()}async _callAction(){const e=document.querySelector(`#${this.action}`);e?await e.perform():Ft.dispatch(this,"error",{origin:this,message:`Action '${this.action}' not found`,expr:nt.getDocPath(this),level:"Error"})}_callFunction(){const e=Ot(this,"instance()");wt(this.fn,e,this)}}customElements.get("fx-call")||window.customElements.define("fx-call",Qn);class Kn extends Cn{static get properties(){return{...super.properties,ref:{type:String},attrName:{type:String},attrValue:{type:String}}}constructor(){super(),this.ref="",this.attrName="",this.attrValue=""}connectedCallback(){if(super.connectedCallback&&super.connectedCallback(),!this.hasAttribute("ref"))throw new Error('fx-setvalue must specify a "ref" attribute');this.ref=this.getAttribute("ref"),this.attrName=this.hasAttribute("name")?this.getAttribute("name"):null,this.attrValue=this.hasAttribute("value")?this.getAttribute("value"):"",this.attrName||Ft.dispatch("this","error",{message:"name or value not specified"})}async perform(){super.perform();const e=this.getModelItem();e.node.nodeType===Node.ELEMENT_NODE?(e.node.setAttribute(this.attrName,this.attrValue),this.needsUpdate=!0):Ft.dispatch("this","error",{message:"referenced item is not an element"})}}customElements.get("fx-setattribute")||window.customElements.define("fx-setattribute",Kn);class Wn extends Hn{connectedCallback(){super.connectedCallback(),"FX-MODEL"===this.parentNode.nodeName?this.parentNode.addEventListener("model-construct-done",(e=>{super.perform()})):Ft.dispatch(this,"error",{message:"parent is not a model"})}}customElements.get("fx-construct-done")||window.customElements.define("fx-construct-done",Wn);class Zn extends Cn{constructor(){super()}async perform(){this.getOwnerForm().markAsClean()}}function er(e,t){e.signature;const n=e.type??"text/xpath",r=e.signature.match(/(?:(?<prefix>[a-zA-Z_\-][a-zA-Z0-9_\-]*):)?(?<localName>[a-zA-Z_\-][a-zA-Z0-9_\-]*\s*)\((?<params>(?:[^()]*|\([^()]*\))*)\)\s*(?:as\s+(?<returnType>.*))?/);if(!r)throw new Error(`Function signature ${e.signature} could not be parsed`);const{prefix:a,localName:s,params:o,returnType:i}=r.groups,l="local"!==a&&a?`${a}:${s}`:{namespaceURI:"http://www.w3.org/2005/xquery-local-functions",localName:s};a||lt.push(s);const c=o?o.split(",").map((e=>{const t=e.match(/(?<variableName>\$[^\s]+)(?:\sas\s(?<varType>[^\s]+))/);if(!t)throw new Error(`Param ${e} could not be parsed`);const{variableName:n,varType:r}=t.groups;return{variableName:n,variableType:r||"item()*"}})):[];switch(n){case"text/javascript":{const n=new Function("_domFacade",...c.map((e=>e.variableName)),"form",e.functionBody);Ze(l,c.map((e=>e.variableType)),i||"item()*",((...e)=>n.apply(t.getInScopeContext(),[...e,t.getOwnerForm()])));break}case"text/xquf":case"text/xquery":case"text/xpath":{const r=c.map((e=>He(e.variableType))),a="text/xpath"===n?"XPath3.1":"text/xquery"===n?"XQuery3.1":"XQueryUpdate3.1",s=(n,...s)=>wt(e.functionBody,t.getInScopeContext(),t.getOwnerForm(),c.reduce(((e,t,a)=>(e[t.variableName.replace("$","")]=r[a](s[a],n),e)),{}),{language:a});Ze(l,c.map((e=>e.variableType)),i||"item()*",s);break}default:throw new Error(`Unexpected mimetype ${n} for function`)}}customElements.get("fx-unmodified")||window.customElements.define("fx-unmodified",Zn);class tr extends Mt{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.style.display="none",this.signature=this.hasAttribute("signature")?this.getAttribute("signature"):null,this.type=this.hasAttribute("type")?this.getAttribute("type"):null,this.shadowRoot.innerHTML="<slot></slot>",this.override=this.hasAttribute("override")?this.getAttribute("override"):"true",this.functionBody=this.innerText,er(this,this)}}customElements.get("fx-function")||customElements.define("fx-function",tr);class nr extends Mt{constructor(){super(),this._resolve=null,this.readyPromise=new Promise((e=>this._resolveLoading=e))}async connectedCallback(){this.style.display="none";const e=this.getAttribute("src"),t=await fetch(e);t.ok;const n=await t.text(),r=(new DOMParser).parseFromString(n,"text/html"),a=Array.from(r.querySelectorAll("fx-function"));for(const e of a){er({type:e.getAttribute("type"),signature:e.getAttribute("signature"),functionBody:e.innerText},this)}this._resolveLoading(void 0)}}customElements.get("fx-functionlib")||customElements.define("fx-functionlib",nr);
8
+ */;class Lt{constructor(e){this.defaults={oldestFirst:!0,text:"Toastify is awesome!",node:void 0,duration:3e3,selector:void 0,callback:function(){},destination:void 0,newWindow:!1,close:!1,gravity:"toastify-top",positionLeft:!1,position:"",backgroundColor:"",avatar:"",className:"",stopOnFocus:!0,onClick:function(){},offset:{x:0,y:0},escapeMarkup:!0,style:{background:""}},this.version="1.11.2",this.options={},this.toastElement=null,this._rootElement=document.body,this._init(e)}showToast(){if(this.toastElement=this._buildToast(),"string"==typeof this.options.selector?this._rootElement=document.getElementById(this.options.selector):this.options.selector instanceof HTMLElement||this.options.selector instanceof ShadowRoot?this._rootElement=this.options.selector:this._rootElement=document.body,!this._rootElement)throw"Root element is not defined";return this._rootElement.insertBefore(this.toastElement,this._rootElement.firstChild),this._reposition(),this.options.duration>0&&(this.toastElement.timeOutValue=window.setTimeout((()=>{this._removeElement(this.toastElement)}),this.options.duration)),this}hideToast(){this.toastElement.timeOutValue&&clearTimeout(this.toastElement.timeOutValue),this._removeElement(this.toastElement)}_init(e){this.options=Object.assign(this.defaults,e),this.options.backgroundColor,this.toastElement=null,this.options.gravity="bottom"===e.gravity?"toastify-bottom":"toastify-top",this.options.stopOnFocus=void 0===e.stopOnFocus||e.stopOnFocus,e.backgroundColor&&(this.options.style.background=e.backgroundColor)}_buildToast(){if(!this.options)throw"Toastify is not initialized";let e=document.createElement("div");e.className=`toastify on ${this.options.className}`,e.className+=` toastify-${this.options.position}`,e.className+=` ${this.options.gravity}`;for(const t in this.options.style)e.style[t]=this.options.style[t];if(this.options.node&&this.options.node.nodeType===Node.ELEMENT_NODE)e.appendChild(this.options.node);else if(this.options.escapeMarkup?e.innerText=this.options.text:e.innerHTML=this.options.text,""!==this.options.avatar){let t=document.createElement("img");t.src=this.options.avatar,t.className="toastify-avatar","left"==this.options.position?e.appendChild(t):e.insertAdjacentElement("afterbegin",t)}if(!0===this.options.close){let t=document.createElement("span");t.innerHTML="&#10006;",t.className="toast-close",t.addEventListener("click",(e=>{e.stopPropagation(),this._removeElement(this.toastElement),window.clearTimeout(this.toastElement.timeOutValue)}));const n=window.innerWidth>0?window.innerWidth:screen.width;"left"==this.options.position&&n>360?e.insertAdjacentElement("afterbegin",t):e.appendChild(t)}if(this.options.stopOnFocus&&this.options.duration>0&&(e.addEventListener("mouseover",(t=>{window.clearTimeout(e.timeOutValue)})),e.addEventListener("mouseleave",(()=>{e.timeOutValue=window.setTimeout((()=>{this._removeElement(e)}),this.options.duration)}))),void 0!==this.options.destination&&e.addEventListener("click",(e=>{e.stopPropagation(),!0===this.options.newWindow?window.open(this.options.destination,"_blank"):window.location=this.options.destination})),"function"==typeof this.options.onClick&&void 0===this.options.destination&&e.addEventListener("click",(e=>{e.stopPropagation(),this.options.onClick()})),"object"==typeof this.options.offset){const t=this._getAxisOffsetAValue("x",this.options),n=this._getAxisOffsetAValue("y",this.options),r="left"==this.options.position?t:`-${t}`,a="toastify-top"==this.options.gravity?n:`-${n}`;e.style.transform=`translate(${r},${a})`}return e}_removeElement(e){e.className=e.className.replace(" on",""),window.setTimeout((()=>{this.options.node&&this.options.node.parentNode&&this.options.node.parentNode.removeChild(this.options.node),e.parentNode&&e.parentNode.removeChild(e),this.options.callback.call(e),this._reposition()}),400)}_reposition(){let e,t={top:15,bottom:15},n={top:15,bottom:15},r={top:15,bottom:15},a=this._rootElement.querySelectorAll(".toastify");for(let s=0;s<a.length;s++){e=!0===a[s].classList.contains("toastify-top")?"toastify-top":"toastify-bottom";let o=a[s].offsetHeight;e=e.substr(9,e.length-1);let i=15;(window.innerWidth>0?window.innerWidth:screen.width)<=360?(a[s].style[e]=`${r[e]}px`,r[e]+=o+i):!0===a[s].classList.contains("toastify-left")?(a[s].style[e]=`${t[e]}px`,t[e]+=o+i):(a[s].style[e]=`${n[e]}px`,n[e]+=o+i)}}_getAxisOffsetAValue(e,t){return t.offset[e]?isNaN(t.offset[e])?t.offset[e]:`${t.offset[e]}px`:"0px"}}function $t(e){return new Lt(e)}class Pt extends HTMLElement{static get properties(){return{avatar:{type:String},backgroundColor:{type:String},callback:{type:String},classProp:{type:String},close:{type:Boolean},destination:{type:String},duration:{type:Number},escapeMarkup:{type:Boolean},gravity:{type:String},newWindow:{type:Boolean},oldestFirst:{type:Boolean},position:{type:String},selector:{type:String},stopOnFocus:{type:Boolean},text:{type:String}}}constructor(){super(),this.attachShadow({mode:"open"})}_initVar(e,t){return this.hasAttribute(e)?this.getAttribute(e):t}connectedCallback(){this.avatar=this._initVar("avatar",""),this.backgroundColor=this._initVar("backgroundColor",""),this.callback=this._initVar("callback",{}),this.classProp=this._initVar("data-class",""),this.close="true"===this._initVar("close",!1),this.destination=this._initVar("destination",void 0),this.duration=Number(this._initVar("duration",3e3)),this.escapeMarkup="true"===this._initVar("escapeMarkup","true"),this.gravity=this._initVar("gravity","top"),this.newWindow="true"===this._initVar("newWindow","false"),this.offSet=this._initVar("offSet",{}),this.oldestFirst="true"===this._initVar("oldestFirst","true"),this.position=this._initVar("position","right"),this.stopOnFocus="true"===this._initVar("stopOnFocus","true"),this.text=this._initVar("text","");this.shadowRoot.innerHTML=`\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n ${this.renderHTML}\n `,this.addEventListener("jinn-toast",(e=>{this.showToast(e.detail.text)}))}disconnectedCallback(){this.removeEventListener("jinn-toast",this.showToast)}showToast(e){new $t({avatar:this.avatar,className:this.classProp,close:this.close,destination:this.destination,duration:this.duration,escapeMarkup:this.escapeMarkup,gravity:this.gravity,newWindow:!1,offset:this.offset,oldestFirst:this.oldestFirst,position:this.position,node:this.shadowRoot,stopOnFocus:this.stopOnFocus,text:e}).showToast()}renderHTML(){return"\n <slot></slot>\n "}}customElements.get("jinn-toast")||window.customElements.define("jinn-toast",Pt);const _t=(e,t)=>class extends e{static get properties(){return{...e.properties,dnd:{type:Boolean}}}constructor(){super()}connectedCallback(){this.drop=e=>this._drop(e),this.addEventListener("drop",this.drop),this.dragOver=e=>this._dragOver(e),this.addEventListener("dragover",this.dragOver),this.dragLeave=e=>this._dragLeave(e),this.addEventListener("dragleave",this.dragLeave),this.dragEnd=e=>this._dragEnd(e),this.addEventListener("dragend",this._dragEnd)}disconnectedCallback(){this.removeEventListener("drop",this.drop),this.removeEventListener("dragover",this.dragOver),this.removeEventListener("dragleave",this.dragLeave),this.removeEventListener("dragend",this.dragEnd)}_dragOver(e){if(e.target.classList.contains("no-drop"))return!1;e.stopPropagation();const t=e.target.closest("fx-repeatitem");if(!this.getOwnerForm().draggedItem)return;if(this===this.getOwnerForm().draggedItem)return;const{draggedItem:n}=this.getOwnerForm();this.accepts(n)?this.classList.remove("no-drop"):this.classList.add("no-drop");const r=this.hasAttribute("id")?this:this.closest("[id]"),a=n.hasAttribute("id")?n:n.closest("[id]");r?.id===a?.id&&(t!==this.getOwnerForm().draggedItem&&this.classList.add("drag-over"),e.preventDefault())}_dragLeave(e){this.classList.remove("drag-over"),this.classList.remove("no-drop")}_dragEnd(e){const t=this.getOwnerForm().draggedItem;"copy"===t.getAttribute("drop-action")&&t.remove(),this.classList.remove("drag-over")}_getDataNode(){const e=this.getOwnerForm().draggedItem?.getModelItem()?.node;if(!e)return null;const{draggedItem:t}=this.getOwnerForm(),n=this.hasAttribute("id")?this:this.closest("[id]"),r=t.hasAttribute("id")?t:t.closest("[id]");return n?.id!==r?.id?null:e}accepts(e){if(!this.hasAttribute("accept"))return;const t=this.getAttribute("accept");return e.matches(t)}_drop(e){if(this.classList.remove("drag-over"),e.stopPropagation(),"fx-droptarget"===this.localName){this.children.length;let{draggedItem:t}=this.getOwnerForm();if("copy"===t.getAttribute("drop-action")&&(t=t.cloneNode(!0)),!this.accepts(t))return void this.classList.remove("no-drop");if(t===this)return;if("fx-droptarget"===t.localName){if(this.hasAttribute("drop-position"))return this.replaceChildren(t),void e.preventDefault();this.parentNode.lastElementChild===this?(this.parentNode.append(t),e.stopImmediatePropagation()):t===this.previousElementSibling?this.parentNode.insertBefore(t,this.nextElementSibling):this.parentNode.insertBefore(t,this)}else this.appendChild(t);return e.preventDefault(),this.getOwnerForm().getModel().updateModel(),void this.getOwnerForm().refresh(!0)}const t=this._getDataNode();if(t){if("fx-repeat"===this.localName){e.preventDefault();let n=this.nodeset;if(Array.isArray(n)&&!n.length){Ot(this.getAttributeNode("ref")||this,this.ref).append(t)}else n=n[n.length-1],n.after(t)}else if("fx-repeatitem"===this.localName){const e=this.getModelItem().node;e.previousSibling===t?e.after(t):e.before(t)}this.getOwnerForm().getModel().updateModel(),this.getOwnerForm().refresh(!0)}}};class Ht extends(_t(Mt)){static get properties(){return{...super.properties,index:{type:Number},template:{type:Object},focusOnCreate:{type:String},initDone:{type:Boolean},repeatIndex:{type:Number},repeatSize:{type:Number},nodeset:{type:Array}}}constructor(){super(),this.ref="",this.dataTemplate=[],this.isDraggable=null,this.focusOnCreate="",this.initDone=!1,this.repeatIndex=1,this.nodeset=[],this.inited=!1,this.host={},this.index=1,this.repeatSize=0,this.attachShadow({mode:"open",delegatesFocus:!0})}get repeatSize(){return this.querySelectorAll(":scope > .fx-repeatitem").length}set repeatSize(e){super.repeatSize=e}setIndex(e){this.index=e;const t=this.querySelector("[data-ref]").querySelectorAll(":scope > *");this.applyIndex(t[this.index-1])}applyIndex(e){this._removeIndexMarker(),e&&e.setAttribute("repeat-index","")}get index(){return parseInt(this.getAttribute("index"),10)}set index(e){this.setAttribute("index",e)}_getRepeatedItems(){return this.querySelector("[data-ref]").children}async connectedCallback(){this.ref=this.getAttribute("ref"),this.addEventListener("item-changed",(e=>{const{item:t}=e.detail,n=this._getRepeatedItems(),r=Array.from(n).indexOf(t);this.applyIndex(n[r]),this.index=r+1})),document.addEventListener("index-changed",(e=>{if(e.stopPropagation(),!e.target===this)return;const{index:t}=e.detail;this.index=Number(t),this.applyIndex(this.children[t-1])})),this.mutationObserver=new MutationObserver((e=>{if("childList"===e[0].type){const t=e[0].addedNodes[0];if(t){const e=nt.resolveInstance(this,this.ref),n=nt.getPath(t,e);Ft.dispatch(this,"path-mutated",{path:n,index:this.index})}}})),this.getOwnerForm().registerLazyElement(this);this.shadowRoot.innerHTML="\n <style>\n \n :host{\n }\n .fade-out-bottom {\n -webkit-animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n }\n .fade-out-bottom {\n -webkit-animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n }\n \n </style>\n \n <slot></slot>\n \n "}async init(){return new Promise((e=>{this._evalNodeset(),this._initTemplate(),this.setAttribute("index",this.index),this.inited=!0,e("done")}))}_getRef(){return this.getAttribute("ref")}_evalNodeset(){const e=Ot(this.getAttributeNode("ref")||this,this.ref);this.mutationObserver&&e.nodeName&&this.mutationObserver.observe(e,{childList:!0,subtree:!0});const t=wt(this.ref,e,this);1===t.length&&Array.isArray(t[0])?this.nodeset=t[0]:this.nodeset=t}async refresh(e){this.inited||this.init(),this._evalNodeset();let t=this.querySelectorAll(".fx-repeatitem"),n=t.length,r=1;Array.isArray(this.nodeset)&&(r=this.nodeset.length);const a=r;if(a<n)for(let e=n;e>a;e-=1){const n=t[e-1];n.parentNode.removeChild(n),this.getOwnerForm().unRegisterLazyElement(n),this.getOwnerForm().someInstanceDataStructureChanged=!0}if(a>n)for(let e=n+1;e<=a;e+=1){const t=this._clone();if(!t)return;this.querySelector("[data-ref]").appendChild(t),t.classList.add("fx-repeatitem"),t.setAttribute("index",e),t.addEventListener("click",this._dispatchIndexChange),t.addEventListener("focusin",this._dispatchIndexChange),this.getOwnerForm().someInstanceDataStructureChanged=!0}t=this.querySelectorAll(":scope > .fx-repeatitem"),n=t.length;for(let e=0;e<n;e+=1){const n=t[e];this.getOwnerForm().registerLazyElement(n),n.nodeset!==this.nodeset[e]&&(n.nodeset=this.nodeset[e])}this.getOwnerForm().lazyRefresh&&!e||Ft.refreshChildren(this,e),this.setIndex(this.index)}_dispatchIndexChange(){this.dispatchEvent(new CustomEvent("item-changed",{composed:!1,bubbles:!0,detail:{item:this,index:this.index}}))}_fadeOut(e){e.style.opacity=1,function t(){(e.style.opacity-=.1)<0?e.style.display="none":requestAnimationFrame(t)}()}_fadeIn(e){e&&(e.style.opacity=0,e.style.display=this.display,function t(){let n=parseFloat(e.style.opacity);(n+=.1)>1||(e.style.opacity=n,requestAnimationFrame(t))}())}async _initTemplate(){this.template=this.querySelector("template"),this.template&&this.shadowRoot.appendChild(this.template)}_initVariables(e){const t=new Map(this.inScopeVariables);e.setInScopeVariables(t),function e(n){for(const r of n.children)"setInScopeVariables"in r&&r.setInScopeVariables(t),e(r)}(e)}_clone(){if(this.template=this.shadowRoot.querySelector("template"),this.template)return this.template.content.firstElementChild.cloneNode(!0)}_removeIndexMarker(){const e=this.querySelector("[data-ref]");Array.from(e.children).forEach((e=>{e.removeAttribute("repeat-index")}))}setInScopeVariables(e){this.inScopeVariables=new Map(e)}}customElements.get("fx-repeat-attributes")||window.customElements.define("fx-repeat-attributes",Ht);const jt="clean",Xt="dirty";class qt extends HTMLElement{static get properties(){return{ignoreExpressions:{type:String},mergePartial:{type:Boolean},lazyRefresh:{type:Boolean},model:{type:Object},ready:{type:Boolean},strict:{type:Boolean},validateOn:{type:String},version:{type:String}}}constructor(){super(),this.version="Version: 2.3.2 - built on September 25, 2024 13:48:35",this.model={},this.inited=!1,this.addEventListener("message",this._displayMessage),this.addEventListener("error",this._logError),this.addEventListener("warn",this._displayWarning),window.addEventListener("compute-exception",(e=>{})),this.ready=!1,this.storedTemplateExpressionByNode=new Map,this.outermostHandler=null,this.copiedElements=new WeakSet,this.dirtyState=jt,this.showConfirmation=!1;this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML='\n <style>\n \n :host {\n display: block;\n }\n :host ::slotted(fx-model){\n display:none;\n }\n\n #modalMessage .dialogActions{\n text-align:center;\n }\n .overlay {\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n background: rgba(0, 0, 0, 0.7);\n transition: all 500ms;\n visibility: hidden;\n opacity: 0;\n z-index:10;\n }\n .overlay.show {\n visibility: visible;\n opacity: 1;\n }\n\n .popup {\n margin: 70px auto;\n background: #fff;\n border-radius: 5px;\n width: 30%;\n position: relative;\n transition: all 5s ease-in-out;\n padding: 20px;\n\n }\n .popup h2 {\n margin-top: 0;\n width:100%;\n background:#eee;\n position:absolute;\n top:0;\n right:0;\n left:0;\n height:40px;\n border-radius: 5px;\n\n }\n .popup .close {\n position: absolute;\n top: 3px;\n right: 10px;\n transition: all 200ms;\n font-size: 30px;\n font-weight: bold;\n text-decoration: none;\n color: #333;\n }\n .popup .close:focus{\n outline:none;\n }\n\n .popup .close:hover {\n color: #06D85F;\n }\n #messageContent{\n margin-top:40px;\n }\n .warning{\n background:orange;\n }\n \n </style>\n \n\x3c!-- <slot name="errors"></slot> --\x3e\n <jinn-toast id="message" gravity="bottom" position="left"></jinn-toast>\n <jinn-toast id="sticky" gravity="bottom" position="left" duration="-1" close="true" data-class="sticky-message"></jinn-toast>\n <jinn-toast id="error" text="error" duration="-1" data-class="error" close="true" position="right" gravity="top" escape-markup="false"></jinn-toast>\n <jinn-toast id="warn" text="warning" duration="5000" data-class="warning" position="left" gravity="top"></jinn-toast>\n <slot id="default"></slot>\n <slot name="messages"></slot>\n <div id="modalMessage" class="overlay">\n <div class="popup">\n <h2></h2>\n <a class="close" href="#" onclick="event.target.parentNode.parentNode.classList.remove(\'show\')" autofocus>&times;</a>\n <div id="messageContent"></div>\n </div>\n </div>\n <slot name="event"></slot>\n \n ',this.toRefresh=[],this.initialRun=!0,this._scanForNewTemplateExpressionsNextRefresh=!1,this.repeatsFromAttributesCreated=!1,this.validateOn=this.hasAttribute("validate-on")?this.getAttribute("validate-on"):"update",this.mergePartial=!1}connectedCallback(){if(this.style.visibility="hidden",this.strict=!!this.hasAttribute("strict"),this.ignoreExpressions=this.hasAttribute("ignore-expressions")?this.getAttribute("ignore-expressions"):null,this.lazyRefresh=this.hasAttribute("refresh-on-view"),this.lazyRefresh){const e={root:null,rootMargin:"0px",threshold:.3};this.intersectionObserver=new IntersectionObserver(this.handleIntersect,e)}if(this.src=this.hasAttribute("src")?this.getAttribute("src"):null,this.src)return void this._loadFromSrc();this._injectDevtools();this.shadowRoot.querySelector("slot#default").addEventListener("slotchange",(async e=>{if(this.inited)return;if(this.hasAttribute("convert"))return void this.replaceWith(Ft.copyDom(this));this.ignoreExpressions&&(this.ignoredNodes=Array.from(this.querySelectorAll(this.ignoreExpressions)));let t=e.target.assignedElements().find((e=>"FX-MODEL"===e.nodeName.toUpperCase()));if(!t){const e=document.createElement("fx-model");return this.appendChild(e),void(t=e)}if(!t.inited){const e=new Map;!function t(n){for(const r of n.children)"setInScopeVariables"in r&&r.setInScopeVariables(e),t(r)}(this),await t.modelConstruct(),this._handleModelConstructDone()}this.model=t,this._createRepeatsFromAttributes(),this.inited=!0})),this.addEventListener("path-mutated",(()=>{this.someInstanceDataStructureChanged=!0})),this.addEventListener("refresh",(()=>{this.refresh(!0)})),this.hasAttribute("show-confirmation")&&(this.showConfirmation=!0)}_injectDevtools(){if(this.ownerDocument.querySelector("fx-devtools"))return;const{search:e}=window.location;if(new URLSearchParams(e).has("inspect")){const e=document.createElement("fx-devtools");document.body.appendChild(e)}}addToRefresh(e){this.toRefresh.find((t=>t.path===e.path))||this.toRefresh.push(e)}scanForNewTemplateExpressionsNextRefresh(){this._scanForNewTemplateExpressionsNextRefresh=!0}markAsClean(){this.addEventListener("value-changed",(()=>{this.dirtyState=Xt}),{once:!0}),this.dirtyState=jt}async _loadFromSrc(){await Ft.loadForeFromSrc(this,this.src,"fx-fore")}handleIntersect(e,t){e.forEach((e=>{const{target:t}=e;Ft.getFore(t).initialRun||e.isIntersecting&&(t.classList.add("loaded"),"function"==typeof t.refresh?t.refresh(t,!0):Ft.refreshChildren(t,!0))})),e[0].target.getOwnerForm().dispatchEvent(new CustomEvent("refresh-done"))}evaluateToNodes(e,t){return bt(e,t,this)}disconnectedCallback(){this.removeEventListener("dragstart",this.dragstart)}async forceRefresh(){Ft.refreshChildren(this,!0),this._updateTemplateExpressions(),this._scanForNewTemplateExpressionsNextRefresh=!1,this._processTemplateExpressions(),Ft.dispatch(this,"refresh-done",{})}async refresh(e){if(this.isRefreshing)return;this.isRefreshing=!0,e||this.initialRun||0===this.toRefresh.length?this.inited&&Ft.refreshChildren(this,!0):(this.toRefresh.forEach((t=>{const n=t.boundControls;n&&n.forEach((t=>{t.refresh(e)}));const{mainGraph:r}=this.getModel();if(r&&r.hasNode(t.path)){const n=this.getModel().mainGraph.dependentsOf(t.path,!1);0!==n.length&&n.forEach((t=>{const n=nt.getBasePath(t);this.getModel().modelItems.find((e=>e.path===n)).boundControls.forEach((t=>{t.refresh(e)}))}))}})),this.toRefresh=[]),(this.initialRun||this._scanForNewTemplateExpressionsNextRefresh)&&(this._updateTemplateExpressions(),this._scanForNewTemplateExpressionsNextRefresh=!1),this._processTemplateExpressions(),this.style.visibility="visible",Ft.dispatch(this,"refresh-done",{});const t=Array.from(this.querySelectorAll("fx-fore"));for(const e of t)e.ready&&await e.refresh(!1);this.isRefreshing=!1}_updateTemplateExpressions(){const e=bt("(descendant-or-self::*!(text(), @*))[contains(., '{')][substring-after(., '{') => contains('}')][not(ancestor-or-self::fx-model)]",this,this);this.storedTemplateExpressions||(this.storedTemplateExpressions=[]),Array.from(e).forEach((e=>{if((e.nodeType===Node.ATTRIBUTE_NODE?e.ownerElement:e.parentNode).closest("fx-fore")!==this)return;if(this.storedTemplateExpressionByNode.has(e))return;const t=this._getTemplateExpression(e);t&&this.storedTemplateExpressionByNode.set(e,t)})),this._processTemplateExpressions()}_processTemplateExpressions(){for(const e of Array.from(this.storedTemplateExpressionByNode.keys())){if(e.nodeType===Node.ATTRIBUTE_NODE){if(!nt.contains(this,e.ownerElement)){this.storedTemplateExpressionByNode.delete(e);continue}}else if(!nt.contains(this,e)){this.storedTemplateExpressionByNode.delete(e);continue}this._processTemplateExpression({node:e,expr:this.storedTemplateExpressionByNode.get(e)})}}_processTemplateExpression(e){const{expr:t}=e,{node:n}=e;this.evaluateTemplateExpression(t,n)}evaluateTemplateExpression(e,t){if(t.nodeType===Node.ATTRIBUTE_NODE&&t.ownerElement.closest("[nonrelevant]"))return;if(t.nodeType===Node.TEXT_NODE&&t.parentNode.closest("[nonrelevant]"))return;if(t.nodeType===Node.ELEMENT_NODE&&t.closest("[nonrelevant]"))return;const n=e.replace(/{[^}]*}/g,(e=>{if("{}"===e)return e;const n=e.substring(1,e.length-1),r=Ot(t,n);if(!r)return(t.nodeType===Node.TEXT_NODE||t.nodeType===Node.ATTRIBUTE_NODE)&&t.parentNode,e;const a=nt.getInstanceId(n);a?this.getModel().getInstance(a):this.getModel().getDefaultInstance();try{return At(n,r,t,null)}catch(t){return e}}));if(t.nodeType===Node.ATTRIBUTE_NODE){const e=t.ownerElement;e.getAttribute(t.nodeName)!==n&&e.setAttribute(t.nodeName,n)}else t.nodeType===Node.TEXT_NODE&&t.textContent!==n&&(t.textContent=n)}_getTemplateExpression(e){if(this.ignoredNodes){e.nodeType===Node.ATTRIBUTE_NODE&&(e=e.ownerElement);const t=this.ignoredNodes.find((t=>t.contains(e)));if(t)return null}return e.nodeType===Node.ATTRIBUTE_NODE?e.value:e.nodeType===Node.TEXT_NODE?e.textContent.trim():null}_handleModelConstructDone(){this.markAsClean(),this.showConfirmation&&window.addEventListener("beforeunload",(e=>this.dirtyState===Xt&&(e.preventDefault(),!0))),this._initUI()}async _lazyCreateInstance(){const e=this.querySelector("fx-model"),t=this.parentNode.nodeType!==Node.DOCUMENT_FRAGMENT_NODE?this.parentNode.closest("fx-fore"):null;if(this.parentNode.nodeType,Node.DOCUMENT_FRAGMENT_NODE,t){if(0!==t.getModel().instances.filter((e=>e.hasAttribute("shared"))).length)return}try{if(0===e.instances.length){const t=document.createElement("fx-instance");e.appendChild(t);const n=document.implementation.createDocument(null,"data",null);this._generateInstance(this,n.firstElementChild),t.instanceData=n,e.instances.push(t),Ft.dispatch(this,"instance-loaded",{instance:this})}}catch(e){}}_generateInstance(e,t){if(e.hasAttribute("ref")&&!Ft.isActionElement(e.nodeName)){const n=e.getAttribute("ref");if(n.includes("/")){n.split("/").forEach((n=>{t=this._generateNode(t,n,e)}))}else t=this._generateNode(t,n,e)}if(e.hasChildNodes()){const n=e.children;for(let e=0;e<n.length;e+=1)this._generateInstance(n[e],t)}return t}_generateNode(e,t,n){const r=e.ownerDocument.createElement(t);return 0===n.children.length&&(r.textContent=n.textContent),e.appendChild(r),e=r}async _initUI(){this.initialRun&&(this.classList.add("initialRun"),await this._lazyCreateInstance(),await this.refresh(!0),this.classList.add("fx-ready"),document.body.classList.add("fx-ready"),this.ready=!0,this.initialRun=!1,Ft.dispatch(this,"ready",{}),this.addEventListener("dragstart",this._handleDragStart),this.handleDrop=e=>this._handleDrop(e),this.ownerDocument.body.addEventListener("drop",this.handleDrop),this.ownerDocument.body.addEventListener("dragover",(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move"})))}_handleDragStart(e){const t=e.target.closest('[draggable="true"]');this.originalDraggedItem=t,"copy"===t.getAttribute("drop-action")?(e.dataTransfer.dropEffect="copy",e.dataTransfer.effectAllowed="copy",this.draggedItem=t.cloneNode(!0),this.draggedItem.setAttribute("drop-action","move"),this.copiedElements.add(this.draggedItem)):(e.dataTransfer.dropEffect="move",e.dataTransfer.effectAllowed="move",this.draggedItem=t)}_handleDrop(e){this.draggedItem&&("none"===e.dataTransfer.dropEffect&&this.copiedElements.has(this.originalDraggedItem)&&this.originalDraggedItem.remove(),this.originalDraggedItem=null,this.draggedItem=null,e.stopPropagation())}registerLazyElement(e){this.intersectionObserver&&this.intersectionObserver.observe(e)}unRegisterLazyElement(e){this.intersectionObserver&&this.intersectionObserver.unobserve(e)}getModel(){return this.querySelector("fx-model")}_displayMessage(e){const{level:t}=e.detail,n=e.detail.message;this._showMessage(t,n),e.stopPropagation()}_displayError(e){const t=e.detail.message;this.shadowRoot.querySelector("#error").showToast(t)}_displayWarning(e){const t=e.detail.message,n=nt.shortenPath(At("path()",e.target,this));this.shadowRoot.querySelector("#warn").showToast(`WARN: ${n}:${t}`)}_logError(e){e.stopPropagation(),e.preventDefault(),e.detail.expr,this.strict&&this._displayError(e)}_copyToClipboard(e){navigator.clipboard.writeText(e.value)}_showMessage(e,t){if("modal"===e)this.shadowRoot.getElementById("messageContent").innerText=t,this.shadowRoot.getElementById("modalMessage").classList.add("show");else if("sticky"===e||"error"===e||"warn"===e)this.shadowRoot.querySelector(`#${e}`).showToast(t);else{this.shadowRoot.querySelector("#message").showToast(t)}}_createRepeatsFromAttributes(){if(this.repeatsFromAttributesCreated)return;const e=this.querySelectorAll("[data-ref]");e&&Array.from(e).forEach((e=>{if(e.closest("fx-control"))return;const t=e.parentNode.closest("table");let n;n=t?t.cloneNode(!0):e.cloneNode(!0);const r=new Ht;r.setAttribute("ref",e.getAttribute("data-ref")),r.appendChild(n),t?(t.parentNode.insertBefore(r,t),t.parentNode.removeChild(t)):(e.parentNode.insertBefore(r,e),e.parentNode.removeChild(e)),e.setAttribute("insertPoint","")})),this.repeatsFromAttributesCreated=!0}}qt.outermostHandler=null,qt.draggedItem=null,customElements.get("fx-fore")||customElements.define("fx-fore",qt);class Vt{static handleRelevance(e){const t=e.getModelItem();t&&t.relevant?(e.removeAttribute("nonrelevant"),e.setAttribute("relevant",""),Ft.dispatch(this,"relevant",{})):(e.removeAttribute("relevant"),e.setAttribute("nonrelevant",""),Ft.dispatch(this,"nonrelevant",{}))}static selectRelevant(e,t){return"xml"===t?Vt._relevantXmlNodes(e):e.nodeset}static _relevantXmlNodes(e){if("keep"===e.getAttribute("nonrelevant"))return e.nodeset;const t=e.getModel().getModelItem(e.nodeset);if(t&&!t.relevant)return null;const n=e.nodeset.cloneNode(!1);return 0===e.nodeset.children.length&&Vt._isRelevant(e,e.nodeset)?e.nodeset:Vt._filterRelevant(e,e.nodeset,n)}static _filterRelevant(e,t,n){const{childNodes:r}=t;return Array.from(r).forEach((t=>{if(Vt._isRelevant(e,t)){const r=t.cloneNode(!1);n.appendChild(r);const{attributes:a}=t;return a&&Array.from(a).forEach((t=>{"empty"!==e.nonrelevant||Vt._isRelevant(e,t)?Vt._isRelevant(e,t)?r.setAttribute(t.nodeName,t.value):r.removeAttribute(t.nodeName):r.setAttribute(t.nodeName,"")})),Vt._filterRelevant(e,t,r)}return null})),n}static _isRelevant(e,t){const n=e.getModel().getModelItem(t);return(t.nodeType!==Node.ATTRIBUTE_NODE||""!==t.nodeValue)&&(!n||!!n.relevant)}}class Yt extends Mt{constructor(){super(),this.attachShadow({mode:"open"}),this.credentials="",this.parameters=new Map}connectedCallback(){this.methods=["get","put","post","delete","head","urlencoded-post"],this.model=this.parentNode,this.hasAttribute("id"),this.id=this.getAttribute("id"),this.instance=this.hasAttribute("instance")?this.getAttribute("instance"):null,this.into=this.hasAttribute("into")?this.getAttribute("into"):null,this.method=this.hasAttribute("method")?this.getAttribute("method"):"get",this.nonrelevant=this.hasAttribute("nonrelevant")?this.getAttribute("nonrelevant"):"remove",this.replace=this.hasAttribute("replace")?this.getAttribute("replace"):"all",this.serialization=this.hasAttribute("serialization")?this.getAttribute("serialization"):"xml",this.mediatype=this.hasAttribute("mediatype")?this.getAttribute("mediatype"):"application/xml",this.responseMediatype=this.hasAttribute("response-mediatype")?this.getAttribute("response-mediatype"):this.mediatype,this.url=this.hasAttribute("url")?this.getAttribute("url"):null,this.targetref=this.hasAttribute("targetref")?this.getAttribute("targetref"):null,this.validate=this.getAttribute("validate")?this.getAttribute("validate"):"true",this.credentials=this.hasAttribute("credentials")?this.getAttribute("credentials"):"same-origin",["same-origin","include","omit"].includes(this.credentials),this.shadowRoot.innerHTML=this.renderHTML()}renderHTML(){return"\n <slot></slot>\n "}async submit(){await Ft.dispatch(this,"submit",{submission:this}),await this._submit()}async _submit(){this.evalInContext();const e=this.getModel();if(e.recalculate(),"true"===this.validate&&"get"!==this.method){if(!e.revalidate())return this.getOwnerForm().classList.add("submit-validation-failed"),Ft.dispatch(this,"submit-error",{}),void this.getModel().parentNode.refresh(!0)}await this._serializeAndSend()}_getProperty(e){return this.parameters.has(e)?this.parameters.get(e):this.getAttribute(e)}async _serializeAndSend(){const e=this._getProperty("url"),t=this.evaluateAttributeTemplateExpression(e,this),n=this.getInstance();n||Ft.dispatch(this,"warn",{message:`instance not found ${n.getAttribute("id")}`});const r=n.getAttribute("type");let a;if("none"===this.serialization)a=void 0;else{const e=Vt.selectRelevant(this,r);a=this._serialize(r,e)}if("get"===this.method.toLowerCase()&&(a=void 0),t.startsWith("#echo")){const e=this._parse(a,n);return this._handleResponse(e),Ft.dispatch(this,"submit-done",{}),void this.parameters.clear()}if(t.startsWith("localStore:")){if("get"===this.method||"consume"===this.method){this.replace="instance";const e=t.substring(t.indexOf(":")+1),r=localStorage.getItem(e);if(!r)return Ft.dispatch(this,"submit-error",{message:`Error reading key ${e} from localstorage`}),void this.parameters.clear();const a=this._parse(r,n);this._handleResponse(a),"consume"===this.method&&localStorage.removeItem(e),Ft.dispatch(this,"submit-done",{})}if("post"===this.method){const e=t.substring(t.indexOf(":")+1);localStorage.setItem(e,a),this._handleResponse(n.instanceData),Ft.dispatch(this,"submit-done",{})}if("delete"===this.method){const e=t.substring(t.indexOf(":")+1);localStorage.removeItem(e);const n=(new DOMParser).parseFromString("<data></data>","application/xml");this.replace="instance",this._handleResponse(n),Ft.dispatch(this,"submit-done",{})}return}const s=this._getHeaders();if(this.methods.includes(this.method.toLowerCase()))try{const e=await fetch(t,{method:this.method,credentials:this.credentials,mode:"cors",headers:s,body:a});if(!e.ok||e.status>400)return void Ft.dispatch(this,"submit-error",{message:`Error while submitting ${this.id}`});const n=e.headers.get("content-type").toLowerCase();if(n.startsWith("text/")){const r=await e.text();this._handleResponse(r,t,n)}else if(n.startsWith("application/json")){const r=await e.json();this._handleResponse(r,t,n)}else if(n.startsWith("application/xml")){const r=await e.text(),a=(new DOMParser).parseFromString(r,"application/xml");this._handleResponse(a,t,n)}else{const r=await e.blob();this._handleResponse(r,t,n)}Ft.dispatch(this,"submit-done",{})}catch(e){Ft.dispatch(this,"submit-error",{error:e.message})}finally{this.parameters.clear();const e=document.querySelector("[download]");e&&document.body.removeChild(e)}else Ft.dispatch(this,"error",{message:`Unknown method ${this.method}`})}_parse(e,t){let n=null;return e&&"xml"===t.getAttribute("type")&&(n=(new DOMParser).parseFromString(e,"application/xml")),e&&"json"===t.getAttribute("type")&&(n=JSON.parse(e)),e&&"text"===t.getAttribute("type")&&(n=e),n}_serialize(e,t){if("application/x-www-form-urlencoded"===this.serialization){const e=new URLSearchParams;return Array.from(t.children).forEach((t=>{e.append(t.nodeName,t.textContent)})),e}if("xml"===e){return(new XMLSerializer).serializeToString(t)}if("json"===e)return JSON.stringify(t);if("text"===e)return t;throw new Error("unknown instance type ",e)}_getHeaders(){const e=new Headers,t=this.getInstance(),n=Ft.getContentType(t,this.serialization);e.append("Content-Type",n),e.has("Accept")&&e.delete("Accept");const r=this.querySelectorAll("fx-header");return Array.from(r).forEach((t=>{const{name:n}=t,r=t.getValue();e.append(n,r)})),e}_getUrlExpr(){return this.storedTemplateExpressions.find((e=>"url"===e.node.nodeName))}_getTargetInstance(){let e;if(e=this.instance?this.model.getInstance(this.instance):this.model.getInstance("default"),!e)throw new Error(`target instance not found: ${e}`);return e}_handleResponse(e,t,n){const r=this._getTargetInstance();if("instance"===this.replace){if(!r)throw new Error(`target instance not found: ${r}`);if(this.targetref){const[t]=wt(this.targetref,r.instanceData.firstElementChild,this),n=e.firstElementChild;t.parentNode.replaceChild(n,t)}else if(this.into){const[t]=wt(this.into,r.instanceData.firstElementChild,this);e.nodeType===Node.DOCUMENT_NODE?t.appendChild(e.firstElementChild):t.innerHTML=e}else{const t=e;r.instanceData=t}this.model.inited&&(this.model.updateModel(),this.getOwnerForm().refresh(!0))}if("download"===this.replace){const t=this._getProperty("target"),r=document.createElement("a");r.setAttribute("download",t),r.setAttribute("href",`data:${n},${e}`),document.body.appendChild(r),r.click()}if("all"===this.replace){const n=this._getProperty("target");if(n&&"_blank"===n){const t=window.open("","_blank");t.document.write(`<pre>${e}</pre>`),t.document.close()}else document.open(),document.write(e),document.close(),window.location.href=t}if("target"===this.replace&&n.startsWith("text/html")){const t=this._getProperty("target"),n=document.querySelector(t);n?n.innerHTML=e:Ft.dispatch(this,"submit-error",{message:`targetNode for selector ${t} not found`})}"redirect"===this.replace&&(window.location.href=e)}_handleError(){Ft.dispatch(this,"submit-error",{})}}customElements.get("fx-submission")||customElements.define("fx-submission",Yt);class zt extends Mt{constructor(){if(super(),this.style.display="none",this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML="",!this.hasAttribute("name"))throw new Error('required attribute "name" missing');this.name=this.getAttribute("name")}connectedCallback(){this.shadowRoot.innerHTML=""}}customElements.get("fx-header")||customElements.define("fx-header",zt);const Jt=He("item()*");class Qt extends Mt{constructor(){super(),this.attachShadow({mode:"open"}),this.name="",this.valueQuery="",this.value=null,this.precedingVariables=[]}connectedCallback(){this.name=this.getAttribute("name"),this.valueQuery=this.getAttribute("value")}refresh(){const e=Ot(this,this.valueQuery),t=wt(this.valueQuery,e,this,this.precedingVariables);this.value=Jt(t,je)}setInScopeVariables(e){e.has(this.name)?Ft.dispatch(this,"xforms-binding-error",{}):(e.set(this.name,this),this.inScopeVariables=new Map(e))}}customElements.get("fx-var")||customElements.define("fx-var",Qt);class Kt extends Mt{constructor(){super(),this.value=null,this.display=this.style.display,this.required=!1,this.readonly=!1,this.widget=null,this.visited=!1,this.force=!1}getWidget(){throw new Error("You have to implement the method getWidget!")}async refresh(e){e&&(this.force=!0);const t=this.value;var n,r,a;if(!this.isNotBound()&&(this.oldVal=this.nodeset?this.nodeset:null,this.evalInContext(),this.isBound())){if(!this.nodeset){if(this.closest("[create]")){let e,t,n;if(this.ref.includes("/")){t=this.ref.substring(0,this.ref.indexOf("/"));n=vt(t,Ot(this.parentNode,this.ref),this),n&&n.nodeType===Node.ELEMENT_NODE&&(this.ref.includes("@")?(e=this.ref.substring(this.ref.indexOf("/")+2),n.setAttribute(e,"")):Ft.dispatch(this,"warn",{message:'"create" is not implemented for elements'}))}else{const t=Ot(this,this.ref);this.ref.includes("@")?(e=this.ref.substring(this.ref.indexOf("@")+1),t.setAttribute(e,"")):Ft.dispatch(this,"warn",{message:'"create" is not implemented for elements'})}}else this.setAttribute("nonrelevant","");return}if(this.modelItem=this.getModelItem(),this.modelItem instanceof kt){if(this.hasAttribute("as")&&"node"===this.getAttribute("as")?(this.modelItem.node=this.nodeset,this.value=this.modelItem.node):this.value=this.modelItem.value,this.modelItem.boundControls.includes(this)||this.modelItem.boundControls.push(this),await this.updateWidgetValue(),this.handleModelItemProperties(),this.getOwnerForm().initialRun&&Ft.dispatch(this,"init",{}),!this.getOwnerForm().ready)return;if("fx-control"!==this.localName)return;n=this.oldVal,r=this.value,a=t,null!==n&&(a&&r&&a.nodeType&&r.nodeType?a.outerHTML!==r.outerHTML:r!==a)&&Ft.dispatch(this,"value-changed",{path:this.modelItem.path,value:this.modelItem.value,oldvalue:this.oldVal})}}}refreshFromModelItem(e){}async updateWidgetValue(){throw new Error("You have to implement the method updateWidgetValue!")}handleModelItemProperties(){this.handleRequired(),this.handleReadonly(),this.getOwnerForm().ready&&this.handleValid(),this.handleRelevant()}_getForm(){return this.getModel().parentNode}_dispatchEvent(e){this.getOwnerForm().ready&&Ft.dispatch(this,e,{})}handleRequired(){this.widget=this.getWidget();const e=this.isRequired();if(!this.modelItem.required)return this.widget.removeAttribute("required"),this.removeAttribute("required"),void(e!==this.modelItem.required&&this._dispatchEvent("optional"));(this.visited||this.force)&&(""===this.modelItem.value?(this.classList.add("isEmpty"),this._toggleValid(!1)):(this.classList.remove("isEmpty"),this._toggleValid(!0))),this.widget.setAttribute("required",""),this.setAttribute("required",""),e!==this.modelItem.required&&this._dispatchEvent("required")}_updateRequired(){this.modelItem.required?((this.visited||this.force)&&(""===this.modelItem.value?(this.classList.add("isEmpty"),this._toggleValid(!1)):(this.classList.remove("isEmpty"),this._toggleValid(!0))),this.widget.setAttribute("required",""),this.setAttribute("required",""),this._dispatchEvent("required")):(this.widget.removeAttribute("required"),this.removeAttribute("required"),this._dispatchEvent("optional"))}_toggleValid(e){e?(this.removeAttribute("invalid"),this.setAttribute("valid","")):(this.removeAttribute("valid"),this.setAttribute("invalid",""))}handleReadonly(){this.isReadonly()!==this.modelItem.readonly&&(this.modelItem.readonly&&(this.widget.setAttribute("readonly",""),this.setAttribute("readonly",""),this._dispatchEvent("readonly")),this.modelItem.readonly||(this.widget.removeAttribute("readonly"),this.removeAttribute("readonly"),this._dispatchEvent("readwrite")))}handleValid(){if(this.isValid()!==this.modelItem.constraint)if(this.modelItem.constraint)this._dispatchEvent("valid"),this.setAttribute("valid",""),this.removeAttribute("invalid");else{if(this.setAttribute("invalid",""),this.removeAttribute("valid"),0!==this.modelItem.alerts.length){if(!this.querySelector("fx-alert")){const{alerts:e}=this.modelItem;e.forEach((e=>{const t=document.createElement("fx-alert");t.innerHTML=e,this.appendChild(t)}))}}this._dispatchEvent("invalid")}}handleRelevant(){const e=this.modelItem.node;if(this.removeAttribute("relevant"),this.removeAttribute("nonrelevant"),Array.isArray(e)&&0===e.length)return this._dispatchEvent("nonrelevant"),void this.setAttribute("nonrelevant","");this.isEnabled()!==this.modelItem.relevant&&(this.modelItem.relevant?(this._dispatchEvent("relevant"),this.setAttribute("relevant","")):(this._dispatchEvent("nonrelevant"),this.setAttribute("nonrelevant","")))}isRequired(){return this.hasAttribute("required")}isValid(){return!this.hasAttribute("invalid")}isReadonly(){return this.hasAttribute("readonly")}isEnabled(){return!this.hasAttribute("nonrelevant")}_fadeOut(e){e.style.opacity=1,function t(){(e.style.opacity-=.1)<0?e.style.display="none":requestAnimationFrame(t)}()}_fadeIn(e,t){e.style.opacity=0,e.style.display=t||"block",function t(){let n=parseFloat(e.style.opacity);(n+=.1)>1||(e.style.opacity=n,requestAnimationFrame(t))}()}}customElements.get("fx-abstract-control")||window.customElements.define("fx-abstract-control",Kt);class Wt extends Kt{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.shadowRoot.innerHTML="\n <style>\n \n :host {\n height: auto;\n font-size: 0.8em;\n font-weight: 400;\n color: red;\n }\n \n </style>\n \n <slot></slot>\n \n "}getWidget(){return this}async updateWidgetValue(){this.innerHTML=this.value}}customElements.get("fx-alert")||customElements.define("fx-alert",Wt);class Zt extends Kt{constructor(){super(),this.inited=!1,this.attachShadow({mode:"open"})}static get properties(){return{...Kt.properties,credentials:{type:String},initial:{type:Boolean},src:{type:String}}}_getValueFromHtmlDom(){return"selectedOptions"===this.valueProp?[...this.widget.selectedOptions].map((e=>e.value)).join(" "):this.widget[this.valueProp]}connectedCallback(){this.initial=this.hasAttribute("initial")?this.getAttribute("initial"):null,this.src=this.hasAttribute("src")?this.getAttribute("src"):null,this.loaded=!1,this.initialNode=null,this.debounceDelay=this.hasAttribute("debounce")?this.getAttribute("debounce"):null,this.updateEvent=this.hasAttribute("update-event")?this.getAttribute("update-event"):"blur",this.label=this.hasAttribute("label")?this.getAttribute("label"):null;this.credentials=this.hasAttribute("credentials")?this.getAttribute("credentials"):"same-origin",["same-origin","include","omit"].includes(this.credentials),this.shadowRoot.innerHTML=`\n <style>\n \n :host{\n display:inline-block;\n }\n \n </style>\n ${this.renderHTML(this.ref)}\n `,this.widget=this.getWidget(),this.addEventListener("mousedown",(e=>{Ft.isWidget(e.target)||e.target?.classList.contains("fx-hint")||e.preventDefault(),this.widget.focus()}));const e=this.widget.hasAttribute("multiple")?"selectedOptions":"value";this.valueProp=this.hasAttribute("value-prop")?this.getAttribute("value-prop"):e;let t=this.widget;if(this.hasAttribute("listen-on")){const e=this.getAttribute("listen-on"),n=this.querySelector(e);n&&(t=n)}this.addEventListener("keyup",(()=>{Rt.dataChanged=!0})),"enter"===this.updateEvent&&(this.widget.addEventListener("keyup",(e=>{13===e.keyCode&&(e.preventDefault(),this.setValue(this._getValueFromHtmlDom()))})),this.updateEvent="blur"),this.debounceDelay?t.addEventListener(this.updateEvent,function(e,t,n=300){let r;return(...a)=>{clearTimeout(r),r=setTimeout((()=>{t.apply(e,a)}),n)}}(this,(()=>{this.setValue(this._getValueFromHtmlDom())}),this.debounceDelay)):(t.addEventListener(this.updateEvent,(e=>{this.setValue(this._getValueFromHtmlDom())})),t.addEventListener("blur",(e=>{this.setValue(this._getValueFromHtmlDom())}),{once:!0})),this.addEventListener("return",(e=>{const t=e.detail.nodeset;e.stopPropagation(),this._replaceNode(t)})),this.widget.addEventListener("focus",(()=>{})),this.template=this.querySelector("template"),this.boundInitialized=!1,this.static=!!this.widget.hasAttribute("static")}_debounce(e,t=300){let n;return(...r)=>{const a=this;clearTimeout(n),n=setTimeout((()=>{e.apply(a,r)}),t)}}setValue(e){const t=this.getModelItem();if(this.getAttribute("class")?this.classList.add("visited"):this.setAttribute("class","visited"),t?.readonly)return;if("node"===this.getAttribute("as")){const e=this.shadowRoot.getElementById("replace"),n=this.getWidget()[this.valueProp];return e.replace(this.nodeset,n),void(t&&n&&n!==t.value&&(t.value=n,Rt.dataChanged=!0,e.actionPerformed()))}const n=this.shadowRoot.getElementById("setvalue");n.setValue(t,e),this.modelItem instanceof kt&&!this.modelItem?.boundControls.includes(this)&&this.modelItem.boundControls.push(this),n.actionPerformed()}_replaceNode(e){e.nodeType===Node.ATTRIBUTE_NODE?this.modelItem.node.nodeValue=e.nodeValue:e.nodeType===Node.ELEMENT_NODE?this.modelItem.node.replaceWith(e.cloneNode(!0)):e.nodeType===Node.TEXT_NODE?this.modelItem.node.nodeValue=e.textContent:Ft.dispatch(this,"warn",{message:"trying to replace a node that is neither an Attribute, Elemment or Text node"})}renderHTML(e){return`\n ${this.label?`${this.label}`:""}\n <slot></slot>\n ${this.hasAttribute("as")&&"node"===this.getAttribute("as")?'<fx-replace id="replace" ref=".">':`<fx-setvalue id="setvalue" ref="${e}"></fx-setvalue>`}\n\n `}getWidget(){if(this.widget)return this.widget;let e=this.querySelector(".widget");if(e||(e=this.querySelector("input"),e&&!e.classList.contains("widget")&&e.classList.add("widget")),!e){const e=document.createElement("input");return e.classList.add("widget"),e.setAttribute("type","text"),this.appendChild(e),e}return e}async updateWidgetValue(){let{widget:e}=this;if(e||(e=this),"checked"!==this.valueProp)if("radio"!==this.widget.type)if("selectedOptions"!==this.valueProp)if(this.hasAttribute("as")){const t=this.getAttribute("as");if("text"===t){const t=new XMLSerializer,n=Ft.prettifyXml(t.serializeToString(this.nodeset));e.value=n}if("node"===t&&this.nodeset!==e.value){const t=this.nodeset;if(e.value&&t!==this.widget.value)return void(e.value=this.nodeset.cloneNode(!0));e.value=this.nodeset.cloneNode(!0)}}else{if(this.src&&!this.loaded&&this.modelItem.relevant)return this.initial&&(this.initialNode=vt(this.initial,this.nodeset,this)),await this._loadForeFromSrc(),void(this.loaded=!0);e.value!==this.value&&(e.value=this.value)}else{const e=new Set(this.value.split(" "));for(const t of[...this.widget.querySelectorAll("option")])e.has(t.value)?t.selected=!0:t.selected=!1}else{const e=this.querySelector(`input[value=${this.value}]`);e&&(e.checked=!0)}else"true"===this.value?e.checked=!0:e.checked=!1}async _loadForeFromSrc(){try{const e=await fetch(this.src,{method:"GET",credentials:this.credentials,mode:"cors",headers:{"Content-Type":"text/html"}});let t;t=e.headers.get("content-type").toLowerCase().startsWith("text/html")?await e.text().then((e=>(new DOMParser).parseFromString(e,"text/html"))):"done";const n=t.querySelector("fx-fore"),r=document.importNode(n,!0);r.classList.add("widget"),r.addEventListener("model-construct-done",(e=>{const t=r.querySelector("fx-instance");if(this.initial){const e=(new DOMParser).parseFromString("<data></data>","application/xml");this.initialNode=vt(this.initial,this.nodeset,this),e.firstElementChild.appendChild(this.initialNode.cloneNode(!0)),t.instanceData=e}r.model=r.querySelector("fx-model"),r.model.updateModel(),r.refresh(!0)}),{once:!0});const a=this.querySelector("input");this.hasAttribute("shadow")?(a.parentNode.removeChild(a),this.shadowRoot.appendChild(r)):this.loaded||a.replaceWith(r),n||Ft.dispatch("error",{detail:{message:`Fore element not found in '${this.src}'. Maybe wrapped within 'template' element?`}}),Ft.dispatch("loaded",{detail:{fore:n}})}catch(e){Ft.dispatch(this,"error",{origin:this,message:`control couldn't be loaded from src '${this.src}'`,level:"Error"})}}getTemplate(){return this.querySelector("template")}async refresh(e){super.refresh(e);const t=this.getWidget();this._handleBoundWidget(t),this._handleDataAttributeBinding(),Ft.refreshChildren(this,e)}_handleDataAttributeBinding(){const e=this.querySelector("[data-ref]");e&&e.closest("fx-control")===this&&(this.boundList=e,e.getAttribute("data-ref"),this._handleBoundWidget(e))}_handleBoundWidget(e){if(this.boundInitialized&&this.static)return;const t=e.hasAttribute("ref")?e.getAttribute("ref"):e.getAttribute("data-ref");if(e&&t){const n=wt(t,Ot(this,t),this),{children:r}=e;if(Array.from(r).forEach((e=>{"template"!==e.nodeName.toLowerCase()&&e.parentNode.removeChild(e)})),Array.isArray(n)&&0===n.length)return;const{template:a}=this;if(a){if("SELECT"===this.widget.nodeName&&this.widget.hasAttribute("selection")&&"open"===this.widget.getAttribute("selection")){const e=this.template.firstElementChild,t=document.createElement("option");this.widget.insertBefore(t,e)}if(0!==n.length){const e=document.createDocumentFragment();Array.from(n).forEach((t=>{const n=this.createEntry();e.appendChild(n),this.updateEntry(n,t)})),this.template.parentNode.appendChild(e)}else{const e=this.createEntry();this.template.parentNode.appendChild(e),this.updateEntry(e,n)}this.boundInitialized=!0}if("selectedOptions"===this.valueProp){const e=new Set(this.value.split(" ")),t=this.getWidget().querySelectorAll("option");for(const n of[...t])e.has(n.value)?n.selected=!0:n.selected=!1}}}updateEntry(e,t){const n=this._getValueAttribute(e);if(!n)return;const r=n.value,a=At(r.substring(1,r.length-1),t,e);n.value=a,this.value===a&&e.setAttribute("selected","selected");const s=e.textContent;this.evalLabel(s,t,e)}evalLabel(e,t,n){const r=e.substring(1,e.length-1);if(!r)return;const a=At(r,t,this);n.textContent=a}createEntry(){return this.template.content.firstElementChild.cloneNode(!0)}_getValueAttribute(e){let t;return Array.from(e.attributes).forEach((e=>{-1!==e.value.indexOf("{")&&(t=e)})),t}}customElements.get("fx-control")||window.customElements.define("fx-control",Zt);class en extends Mt{static get properties(){return{...super.properties}}constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.src=this.hasAttribute("src")?this.getAttribute("src"):null;this.shadowRoot.innerHTML="\n <style>\n \n :host {\n display: block;\n }\n \n </style>\n \n <slot></slot>\n \n ",this.getOwnerForm().registerLazyElement(this)}async refresh(e){!e&&this.hasAttribute("refresh-on-view")||this.isBound()&&(this.evalInContext(),this.modelItem=this.getModelItem(),this.modelItem&&!this.modelItem.boundControls.includes(this)&&this.modelItem.boundControls.push(this),this.handleModelItemProperties())}handleModelItemProperties(){this.handleRelevant()}_getForm(){return this.getModel().parentNode}handleRelevant(){if(!this.modelItem)return this.removeAttribute("relevant",""),this.setAttribute("nonrelevant",""),void this.dispatchEvent(new CustomEvent("disabled",{}));this.isEnabled()!==this.modelItem.enabled&&(this.modelItem.relevant?(this.removeAttribute("nonrelevant",""),this.setAttribute("relevant",""),this.dispatchEvent(new CustomEvent("enabled",{}))):(this.removeAttribute("relevant",""),this.setAttribute("nonrelevant",""),this.dispatchEvent(new CustomEvent("disabled",{}))))}isReadonly(){return!!this.hasAttribute("readonly")}isEnabled(){return"none"!==this.style.display}}customElements.get("fx-container")||window.customElements.define("fx-container",en);class tn extends en{static get properties(){return{...super.properties,collapse:{type:Boolean,reflect:!0}}}constructor(){super(),this.collapse=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","group")}render(){return"\n <slot></slot>\n "}handleModelItemProperties(){this.handleRelevant()}initializeChildren(e){Array.from(e.children).forEach((e=>{if(Ft.isUiElement(e.nodeName))e.init(this.model);else if(0!==e.children.length){Array.from(e.children).forEach((e=>{this.initializeChildren(e)}))}}))}async refresh(e){super.refresh(e),Ft.refreshChildren(this,e)}}customElements.get("fx-group")||window.customElements.define("fx-group",tn);class nn extends Kt{static get styles(){return"\n :host {\n display: block;\n height: auto;\n font-size: 0.8em;\n font-weight: 400;\n font-style: italic;\n }\n "}static get properties(){return{...super.properties}}render(){return"\n <slot></slot>\n "}}customElements.get("fx-hint")||customElements.define("fx-hint",nn);class rn extends Kt{constructor(){super(),this.attachShadow({mode:"open"}),this.valueAttr=this.hasAttribute("value")?this.getAttribute("value"):null,this.readonly=!0}connectedCallback(){this.shadowRoot.innerHTML='\n <style>\n \n :host {\n display: inline-block;\n max-width:100%;\n }\n #widget {\n display: inline-block;\n }\n .label{\n display: inline-block;\n }\n #value{\n max-width:100%;\n }\n \n </style>\n \n <slot name="label"></slot>\n \n <span id="value">\n <slot name="default"></slot>\n </span>\n \n ',this.mediatype=this.hasAttribute("mediatype")?this.getAttribute("mediatype"):null}async refresh(){this.ref&&await super.refresh(),this.valueAttr&&(this.value=this.getValue(),await this.updateWidgetValue())}getValue(){try{const e=Ot(this,this.valueAttr);return this.hasAttribute("html")?wt(this.valueAttr,e,this)[0]:function(e,t,n,r=null){try{const a=ft(e,t,n);return Qe(e,t,r,{},{currentContext:{formElement:n},functionNameResolver:gt,moduleImports:{xf:ot},namespaceResolver:a})}catch(t){n.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,detail:{origin:n,message:`Expression '${e}' failed`,expr:e,level:"Error"}}))}}(this.valueAttr,e,this)[0]}catch(e){Ft.dispatch(this,"error",{message:e})}return null}getWidget(){return this.shadowRoot.getElementById("value")}handleReadonly(){this.setAttribute("readonly","readonly")}async updateWidgetValue(){const e=this.shadowRoot.getElementById("value");if(e.innerHTML="","html"!==this.mediatype){if("image"===this.mediatype){const t=document.createElement("img");return t.setAttribute("src",this.value),this.innerHTML="",void e.appendChild(t)}e.innerHTML=this.value}else if(this.modelItem.node){this.shadowRoot.querySelector("#default");const{node:t}=this.modelItem;if(t.nodeType)return void e.append(t);const n=(new DOMParser).parseFromString(t,"text/html").body.childNodes;return void Array.from(n).forEach((t=>{e.append(t)}))}}isReadonly(){return!0}}customElements.get("fx-output")||customElements.define("fx-output",rn);class an extends(_t(Mt)){static get properties(){return{inited:{type:Boolean}}}constructor(){super(),this.inited=!1,this.addEventListener("click",this._dispatchIndexChange),this.addEventListener("focusin",this._dispatchIndexChange),this.attachShadow({mode:"open",delegatesFocus:!0}),this.dropTarget=null}connectedCallback(){super.connectedCallback(),this.display=this.style.display;this.shadowRoot.innerHTML="\n \n <slot></slot>\n \n ",this.getOwnerForm().registerLazyElement(this),this.ref=`${this.parentNode.ref}`,this.tabindex=0}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this._dispatchIndexChange),this.removeEventListener("focusin",this._handleFocus)}init(){this.inited=!0}_dispatchIndexChange(){this.parentNode.index!==this.index&&this.dispatchEvent(new CustomEvent("item-changed",{composed:!1,bubbles:!0,detail:{item:this,index:this.index}}))}refresh(e){this.modelItem=this.getModelItem(),this.modelItem.boundControls.includes(this)||(this.modelItem.boundControls.push(this),this.modelItem&&!this.modelItem.relevant?(this.removeAttribute("relevant"),this.setAttribute("nonrelevant","")):(this.removeAttribute("nonrelevant"),this.setAttribute("relevant",""))),Ft.refreshChildren(this,e)}}customElements.get("fx-repeatitem")||window.customElements.define("fx-repeatitem",an);class sn extends(_t(Mt)){static get properties(){return{...super.properties,index:{type:Number},template:{type:Object},focusOnCreate:{type:String},initDone:{type:Boolean},repeatIndex:{type:Number},nodeset:{type:Array}}}constructor(){super(),this.ref="",this.dataTemplate=[],this.isDraggable=null,this.dropTarget=null,this.focusOnCreate="",this.initDone=!1,this.repeatIndex=1,this.nodeset=[],this.inited=!1,this.index=1,this.repeatSize=0,this.attachShadow({mode:"open",delegatesFocus:!0})}get repeatSize(){return this.querySelectorAll(":scope > fx-repeatitem").length}set repeatSize(e){this.size=e}setIndex(e){this.index=e;const t=this.querySelectorAll(":scope > fx-repeatitem");this.applyIndex(t[this.index-1]),this.getOwnerForm().refresh(!0)}applyIndex(e){this._removeIndexMarker(),e&&e.setAttribute("repeat-index","")}get index(){return parseInt(this.getAttribute("index"),10)}set index(e){this.setAttribute("index",e)}_getRef(){return this.getAttribute("ref")}connectedCallback(){super.connectedCallback(),this.ref=this.getAttribute("ref"),this.addEventListener("item-changed",(e=>{const{item:t}=e.detail,n=Array.from(this.children).indexOf(t);this.setIndex(n+1)})),document.addEventListener("index-changed",(e=>{if(e.stopPropagation(),!e.target===this)return;const{index:t}=e.detail;this.index=parseInt(t,10),this.applyIndex(this.children[t-1])})),this.mutationObserver=new MutationObserver((e=>{if("childList"===e[0].type){const t=e[0].addedNodes[0];if(t){const e=nt.resolveInstance(this,this.ref),n=nt.getPath(t,e);Ft.dispatch(this,"path-mutated",{path:n,index:this.index})}}})),this.getOwnerForm().registerLazyElement(this);this.shadowRoot.innerHTML='\n <style>\n \n :host{\n }\n .fade-out-bottom {\n -webkit-animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n }\n .fade-out-bottom {\n -webkit-animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n }\n \n </style>\n \n <slot name="header"></slot>\n <slot></slot>\n \n '}_createNewRepeatItem(){const e=document.createElement("fx-repeatitem");this.isDraggable&&(e.setAttribute("draggable","true"),e.setAttribute("tabindex",0));const t=this._clone();return e.appendChild(t),e}init(){this._evalNodeset(),this._initTemplate(),this._initRepeatItems(),this.setAttribute("index",this.index),this.inited=!0}_evalNodeset(){const e=Ot(this.getAttributeNode("ref")||this,this.ref);this.mutationObserver&&e.nodeName&&this.mutationObserver.observe(e,{childList:!0,subtree:!0});const t=wt(this.ref,e,this);1===t.length&&Array.isArray(t[0])?this.nodeset=t[0]:this.nodeset=t}async refresh(e){this.inited||this.init(),this._evalNodeset();const t=this.querySelectorAll(":scope > fx-repeatitem"),n=t.length;let r=1;Array.isArray(this.nodeset)&&(r=this.nodeset.length);const a=r;if(a<n)for(let e=n;e>a;e-=1){const n=t[e-1];n.parentNode.removeChild(n),this.getOwnerForm().unRegisterLazyElement(n)}if(a>n)for(let e=n+1;e<=a;e+=1){const t=this._createNewRepeatItem();this.appendChild(t),this._initVariables(t),t.nodeset=this.nodeset[e-1],t.index=e,this.getOwnerForm().scanForNewTemplateExpressionsNextRefresh()}for(let e=0;e<n;e+=1){const n=t[e];this.getOwnerForm().registerLazyElement(n),n.nodeset!==this.nodeset[e]&&(n.nodeset=this.nodeset[e])}this.getOwnerForm().lazyRefresh&&!e||Ft.refreshChildren(this,e),this.setIndex(this.index)}_fadeOut(e){e.style.opacity=1,function t(){(e.style.opacity-=.1)<0?e.style.display="none":requestAnimationFrame(t)}()}_fadeIn(e){e&&(e.style.opacity=0,e.style.display=this.display,function t(){let n=parseFloat(e.style.opacity);(n+=.1)>1||(e.style.opacity=n,requestAnimationFrame(t))}())}_initTemplate(){this.template=this.querySelector("template"),this.dropTarget=this.template.getAttribute("drop-target"),this.isDraggable=this.template.hasAttribute("draggable")?this.template.getAttribute("draggable"):null,null===this.template&&this.dispatchEvent(new CustomEvent("no-template-error",{composed:!0,bubbles:!0,detail:{message:`no template found for repeat:${this.id}`}})),this.shadowRoot.appendChild(this.template)}_initRepeatItems(){this.nodeset.forEach(((e,t)=>{const n=this._createNewRepeatItem();n.nodeset=this.nodeset[t],n.index=t+1,this.appendChild(n),1===n.index&&this.applyIndex(n),Ft.dispatch(this,"item-created",{nodeset:n.nodeset,pos:t+1}),this._initVariables(n)}))}_initVariables(e){const t=new Map(this.inScopeVariables);e.setInScopeVariables(t),function e(n){for(const r of n.children)"setInScopeVariables"in r&&r.setInScopeVariables(t),e(r)}(e)}_clone(){this.template=this.shadowRoot.querySelector("template");const e=this.template.content.cloneNode(!0);return document.importNode(e,!0)}_removeIndexMarker(){Array.from(this.children).forEach((e=>{e.removeAttribute("repeat-index")}))}setInScopeVariables(e){this.inScopeVariables=new Map(e)}}customElements.get("fx-repeat")||window.customElements.define("fx-repeat",sn);class on extends en{constructor(){super(),this.formerCase={},this.selectedCase=null,this.cases=null}connectedCallback(){super.connectedCallback&&super.connectedCallback();this.shadowRoot.innerHTML="\n <style>\n \n :host ::slotted(fx-case.selected-case){\n display: block;\n }\n \n </style>\n \n <slot></slot>\n \n ",this.cases=[],this.formerCase=null,this.selectedCase=null}async refresh(e){super.refresh(e),0===this.cases.length&&(this.cases=Array.from(this.querySelectorAll(":scope > fx-case"))),this.isBound()&&this._handleBoundSwitch(),this.selectedCase||(this.selectedCase=this.cases[0],this.toggle(this.selectedCase)),Ft.refreshChildren(this.selectedCase,e)}_dispatchEvents(){this.selectedCase!==this.formerCase&&(this.formerCase&&this.formerCase!==this.selectedCase&&Ft.dispatch(this.formerCase,"deselect",{}),this.selectedCase.classList.contains("selected-case")&&Ft.dispatch(this.selectedCase,"select",{}))}_resetVisited(){const e=this.selectedCase.querySelectorAll(".visited");Array.from(e).forEach((e=>{e.classList.remove("visited")}))}_handleBoundSwitch(){Array.from(this.cases).forEach((e=>{e.getAttribute("name")===this.modelItem?.value&&this.toggle(e)}))}async replaceCase(e,t){this.cases.splice(this.cases.indexOf(e),1,t),e===this.selectedCase?(this.selectedCase=t,this.formerCase=t,t.classList.add("selected-case"),t.classList.remove("deselected-case"),t.inert=!1,this.getOwnerForm().scanForNewTemplateExpressionsNextRefresh()):(t.classList.add("deselected-case"),t.classList.remove("selected-case"),t.inert=!0)}toggle(e){this.selectedCase=e,Array.from(this.cases).forEach((e=>{e===this.selectedCase?(e.classList.remove("deselected-case"),e.classList.add("selected-case"),e.inert=!1):(e.classList.remove("selected-case"),e.classList.add("deselected-case"),e.inert=!0,this._resetVisited())})),this.selectedCase!==e&&(this.selectedCase=e),this._dispatchEvents(),this.formerCase=this.selectedCase,this.getOwnerForm().scanForNewTemplateExpressionsNextRefresh(),this.getOwnerForm().getModel().updateModel()}}customElements.get("fx-switch")||window.customElements.define("fx-switch",on);class ln extends Kt{connectedCallback(){this.attachShadow({mode:"open"}),this.ref=this.hasAttribute("ref")?this.getAttribute("ref"):null,this.debounceDelay=this.hasAttribute("debounce")?this.getAttribute("debounce"):null;this.shadowRoot.innerHTML=`\n <style>\n \n :host {\n cursor:pointer;\n }\n \n </style>\n ${this.renderHTML()}\n `;const e=this.shadowRoot.querySelector("slot");e.addEventListener("slotchange",(()=>{const t=e.assignedElements({flatten:!0});t[0].getAttribute("tabindex")||t[0].setAttribute("tabindex","0"),"BUTTON"!==t[0].nodeName&&t[0].setAttribute("role","button");const n=t[0];this.addEventListener("mousedown",(e=>{e.target.focus()})),this.debounceDelay?this.addEventListener("click",function(e,t,n=300){let r;return(...a)=>{r||t.apply(e,a),clearTimeout(r),r=setTimeout((()=>(r=void 0,null)),n)}}(this,(e=>{this.performActions(e)}),this.debounceDelay)):n.addEventListener("click",(e=>this.performActions(e))),this.widget=n,"BUTTON"!==n.nodeName&&n.addEventListener("keypress",(e=>{"Space"!==e.code&&"Enter"!==e.code||this.performActions(e)}))}))}renderHTML(){return"\n <slot></slot>\n "}getWidget(){return this.widget}async updateWidgetValue(){return null}handleReadonly(){super.handleReadonly(),this.widget.hasAttribute("readonly")?this.widget.setAttribute("disabled","disabled"):this.widget.removeAttribute("disabled")}async performActions(e){const t=this.closest("fx-repeatitem");t&&t.click(),this.querySelectorAll("fx-var").forEach((e=>e.refresh()));for(let t=0;t<this.children.length;t+=1){const n=this.children[t];if("function"==typeof n.execute){if(e&&(e.preventDefault(),e.stopPropagation(),e.type&&n.event&&e.type!==n.event))return;await n.execute(e)}}}async refresh(){super.refresh()}}customElements.get("fx-trigger")||customElements.define("fx-trigger",ln);class cn extends en{static get properties(){return{...super.properties,label:{type:String},name:{type:String},selected:{type:String},selector:{type:String},src:{type:String}}}connectedCallback(){this.hasAttribute("label")&&(this.label=this.getAttribute("label")),this.hasAttribute("name")&&(this.name=this.getAttribute("name")),this.hasAttribute("selected")&&(this.selected=this.getAttribute("selected")),this.selector=this.hasAttribute("selector")?this.getAttribute("selector"):"fx-case",this.hasAttribute("src")&&(this.src=this.getAttribute("src"));const e=`\n ${this.label?`<span>${this.label}</span>`:""}\n <slot></slot>\n `;this.shadowRoot.innerHTML=`\n <style>\n \n :host {\n visibility: none;\n }\n \n </style>\n ${e}\n `,this.addEventListener("select",(async()=>{const e=this.getOwnerForm();if(this.src){const{parentNode:e}=this,t=await this._loadFromSrc();if(!t)return void Ft.dispatch(this,"error",{detail:{message:"HTML page couldn't be loaded"}});await e.replaceCase(this,t)}e.getModel().updateModel(),e.refresh(!0)}))}async _loadFromSrc(){return Ft.loadForeFromSrc(this,this.src,this.selector)}}customElements.get("fx-case")||window.customElements.define("fx-case",cn);class un extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){const e=this.closest("fx-fore");this.render("\n :host {\n position:absolute;\n display: block;\n width:var(--inspector-handle-width);\n background:var(--inspector-bg);\n top:0;\n right:0;\n bottom:0;\n height: 100%;\n background: var(--inspector-bg);\n color: white;\n /*max-height: 33%;*/\n overflow: scroll;\n transition:width 0.3s ease;\n z-index:100;\n }\n :host([open]){\n width: 30%;\n }\n details{\n margin:1rem;\n }\n .main{\n padding-left:var(--inspector-handle-width);\n color:var(--inspector-color);\n overflow:scroll;\n height:100%;\n }\n pre{\n background:var(--inspector-pre-bg);\n color:var(--inspector-color);\n overflow:scroll;\n padding:0.2rem;\n }\n .handle{\n display:block;\n height:100%;\n width:var(--inspector-handle-width);\n background:var(--inspector-handle-bg);\n opacity:0.7;\n position:absolute;\n left:0;\n color:white;\n cursor:pointer;\n }\n .handle:hover{\n opacity:1;\n }\n .handle::before{\n content: 'Data Inspector';\n white-space: nowrap;\n transform: rotate(-90deg);\n display: inline-block;\n position: absolute;\n left: -85px;\n width: 200px;\n top: 40px;\n }\n summary{\n cursor:pointer;\n }\n "),e.addEventListener("refresh-done",(()=>{this.update()}))}update(){try{const e=this.shadowRoot.querySelectorAll("pre"),t=this.closest("fx-fore");Array.from(e).forEach((e=>{const n=t.getModel().getInstance(e.getAttribute("id"));"xml"===n.getAttribute("type")&&(e.innerText=this.serializeDOM(n.instanceData)),"json"===n.getAttribute("type")&&(e.innerText=JSON.stringify(n.instanceData,void 0,2))}))}catch(e){}}render(e){const t=this.closest("fx-fore"),n=Array.from(t.querySelectorAll("fx-instance"));this.shadowRoot.innerHTML=`\n <style>\n ${e}\n </style>\n <div class="main">\n <slot></slot>\n <span class="handle"></span>\n ${n.map((e=>`\n <details>\n <summary>${e.id}</summary>\n <pre id="${e.id}"></pre>\n </details>\n `))}\n </div>\n `;this.shadowRoot.querySelector(".handle").addEventListener("click",(e=>{this.hasAttribute("open")?this.removeAttribute("open"):this.setAttribute("open","open")}))}serializeDOM(e){if(!e)return;return st((new XMLSerializer).serializeToString(e))}}customElements.get("fx-inspector")||customElements.define("fx-inspector",un);class hn extends HTMLElement{static get properties(){return{id:String}}constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.shadowRoot.innerHTML=this.render("\n :host {\n display:none;\n height: 100vh;\n width:100vw;\n position:fixed;\n left:0;\n top:0;\n right:0;\n bottom:0;\n transition:opacity 0.4s linear;\n }\n\n "),this.id=this.getAttribute("id");const e=this.querySelector(".close-dialog");e&&e.addEventListener("click",(()=>{this.classList.remove("show")})),this.setAttribute("role","dialog"),this.setAttribute("aria-modal","false"),this.focus()}render(e){return`\n <style>\n ${e}\n </style>\n <slot></slot>\n `}open(){window.addEventListener("keyup",(e=>{"Escape"===e.key&&this.hide()}),{once:!0}),this.classList.add("show")}async hide(){await Ft.fadeOutElement(this,400),this.classList.remove("show")}}customElements.get("fx-dialog")||customElements.define("fx-dialog",hn);class dn extends Zt{static get properties(){return{...super.properties,valueAttr:{type:String}}}constructor(){super(),this.valueAttr=this.hasAttribute("value")?this.getAttribute("value"):null}connectedCallback(){super.connectedCallback(),this.addEventListener("mousedown",(e=>{if(Ft.isWidget(e.target)||(e.preventDefault(),e.stopImmediatePropagation()),"LABEL"===e.target.nodeName){ht(e.target.getAttribute("for"),this).focus()}})),this.addEventListener("mousedown",(e=>{if(this.querySelectorAll("[value]"),"LABEL"===e.target.nodeName){ht(e.target.getAttribute("for"),this).focus()}})),this.addEventListener("click",(e=>{e.preventDefault,e.stopPropagation();const t=this.querySelectorAll("[value]");let n;"LABEL"===e.target.nodeName&&(n=ht(e.target.getAttribute("for"),this),n.checked=!n.checked);let r="";Array.from(t).forEach((e=>{e.checked&&(r+=` ${e.getAttribute("value")}`)})),this.setAttribute("value",r.trim());const a=nt.getClosest("[ref]",this.parentNode);if(!a)return;const s=a.getModelItem(),o=this.shadowRoot.getElementById("setvalue");o.setValue(s,r.trim()),o.actionPerformed()}))}getWidget(){return this}async updateWidgetValue(){const e=nt.getClosest("[ref]",this.parentNode);e&&(this.value=e.value),this.setAttribute("value",this.value)}updateEntry(e,t){const n=Ft.createUUID(),r=e.querySelector("label"),a=Ft.getExpression(r.textContent);if(t.nodeType){const e=At(a,t,this);r.textContent=e}else{const e=Ft.getExpression(a);r.textContent=t[e]}r.setAttribute("for",n);const s=e.querySelector("[value]"),o=s.value,i=Ft.getExpression(o);let l;l=t.nodeType?At(i,t,e):t[i];const c=` ${l} `,u=` ${this.getAttribute("value")} `;s.value=l,s.setAttribute("id",n),-1!==u.indexOf(c)&&(s.checked=!0)}}customElements.get("fx-items")||customElements.define("fx-items",dn);class pn extends(_t(Mt)){}customElements.get("fx-droptarget")||window.customElements.define("fx-droptarget",pn);class mn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.eventName="",this.shortName="",this.shortInfo="",this.shortPath="",this.xpath=""}connectedCallback(){this.eventName=this.getAttribute("event-name"),this.shortName=this.getAttribute("short-name"),this.shortInfo=this.hasAttribute("short-info")?this.getAttribute("short-info"):"",this.xpath=this.getAttribute("xpath");const e=`\n <details class="info send">\n <summary>\n <span class="log-name"><a href="#" title="${`/${this.xpath.substring(this.xpath.indexOf("/fx-fore"),this.xpath.length)}`.replaceAll("fx-","")}" data-path="${this.xpath}">${this.shortName}</a></span>\n <span class="short-info">${this.shortInfo}</span>\n <span class="event-name">${this.eventName}</span> \n </summary>\n <slot></slot>\n </details>\n `;this.shadowRoot.innerHTML=`\n <style>\n \n :host {\n height: auto;\n font-size: 0.8em;\n font-weight: 400;\n\n }\n\n a,a:link,a:visited{\n color:black;\n }\n a{\n position:relative;\n }\n a[alt]:hover::after {\n content:attr(alt);\n position:absolute; \n left:0;\n top:1em;\n border.thin solid;\n padding:0.5em;\n background:white;\n z-index:1;\n min-width:5em;\n border:thin solid;\n white-space:nowrap;\n overflow-wrap:break-word;\n }\n\n .info{\n padding:0 0.5em;\n margin:0.1rem 0;\n background:white;\n position:relative;\n border:1px solid #ddd;\n border-radius:1em; \n box-shadow: 1px 1px 5px 0px rgba(79, 136, 183, 0.8);\n }\n :host(.action) .info{\n border-radius:0;\n border-color:steelblue;\n }\n\n .info label{\n grid-area:left;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n .info a{\n grid-area:right;\n justify-self:end;\n }\n .info:hover{\n outline:3px solid lightblue; \n transition:height 0.4s;\n }\n\n summary{\n padding:1em;\n display:flex;\n flex-wrap:wrap;\n padding:0.5em 0;\n cursor:pointer;\n gap:0.25em;\n }\n/*\n .log-name{\n font-size:1.2em;\n }\n .log-name, .short-info{\n width:10em;\n }\n*/\n .event-name{\n width:12em;\n text-align:right;\n }\n .short-info{\n flex:3;\n overflow:hidden;\n white-space:nowrap;\n text-overflow:ellipsis;\n }\n \n </style>\n ${e}\n `}}customElements.get("fx-log-item")||customElements.define("fx-log-item",mn);class fn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.listenTo=[],this.listeners=[]}connectedCallback(){localStorage.getItem("fx-log-settings")?this.listenTo=JSON.parse(localStorage.getItem("fx-log-settings")):this.listenTo=fn.defaultSettings();this.shadowRoot.innerHTML='\n <style>\n \n :host {\n display:block;\n position:relative;\n width:100%;\n border:thin solid #efefef;\n font-family: Verdana, Sans;\n\n margin:0;\n border:thin solid #ddd;\n }\n .boxes{\n column-width:14rem;\n overflow:auto;\n margin-bottom:5em;\n padding:1em;\n }\n .boxes > span{\n display:inline-block;\n width:14rem;\n }\n \n .buttons{\n position:absolute;\n top:0;\n right:0;\n }\n .buttons button{\n padding:0;\n }\n button{\n float:right;\n }\n button{\n border:none;\n background:transparent;\n width:2.25rem;\n height:2.25rem;\n cursor:pointer;\n }\n button#reset{\n padding:0;\n height:1rem;\n }\n header{\n padding:0.5rem;\n margin:0;\n border-bottom:2px solid #ddd;\n }\n #settings{\n padding:1em;\n }\n \n \n </style>\n \n <section id="settings">\n <header>log settings <button id="reset">reset</button></header>\n <div class="boxes"></div>\n </section>\n \n ',window.document.querySelector("fx-fore");const e=this.shadowRoot.querySelector(".boxes");this.listenTo.forEach((t=>{const n=document.createElement("span");e.append(n);const r=document.createElement("label");r.setAttribute("title",t.description),r.setAttribute("for",t.name),r.innerText=t.name;const a=document.createElement("input");a.setAttribute("type","checkbox"),a.setAttribute("name",t.name),a.setAttribute("id",t.name),t.show&&a.setAttribute("checked",""),n.append(a),n.append(r),a.addEventListener("click",(e=>{if(!e.target.checked){document.querySelector("fx-fore").removeEventListener(t.name,this._log)}const n=this.listenTo.find((e=>e.name===t.name));e.target.checked?n.show=!0:n.show=!1,localStorage.setItem("fx-log-settings",JSON.stringify(this.listenTo))}))}));this.shadowRoot.querySelector("#reset").addEventListener("click",(e=>{localStorage.removeItem("fx-log-settings"),window.location.reload()}))}static defaultSettings(){return[{name:"action-performed",show:!1,description:"fires after an action has been performed"},{name:"click",show:!1,description:""},{name:"deleted",show:!1,description:"fires after a delete action has been executed"},{name:"deselect",show:!1,description:"fires when fx-case is deselected"},{name:"dialog-hidden",show:!1,description:"fires after fx-dialog has been hidden"},{name:"dialog-shown",show:!1,description:"fired when a dialog has been shown"},{name:"error",show:!1,description:"fires after an error occurred"},{name:"execute-action",show:!0,description:"fires when an action executes"},{name:"init",show:!1,description:"fires when a control initializes"},{name:"index-changed",show:!1,description:"fires when the repeat index changes"},{name:"insert",show:!1,description:"fires when an fx-insert is executed"},{name:"instance-loaded",show:!1,description:"fires after an fx-instance has been loaded"},{name:"invalid",show:!1,description:"fires after a control became invalid"},{name:"item-changed",show:!1,description:"fires when a repeat item was changed"},{name:"item-created",show:!1,description:"fires when a repeat item was created"},{name:"loaded",show:!1,description:"fires after a fx-load has loaded"},{name:"model-construct",show:!1,description:"fires when a model gets constructed"},{name:"model-construct-done",show:!1,description:"fires after model initialization"},{name:"nonrelevant",show:!1,description:"fires after an fx-control became nonrelevant"},{name:"optional",show:!1,description:"fires after an fx-control became optional"},{name:"outermost-action-end",show:!1,description:"fires when an outermost action block is finished"},{name:"outermost-action-start",show:!1,description:"fires when an outermost action block is started"},{name:"path-mutated",show:!1,description:"fires when a path in a repeat has been mutated"},{name:"readonly",show:!1,description:"fires after an fx-control became readonly"},{name:"readwrite",show:!1,description:"fires after an fx-control became readwrite"},{name:"ready",show:!1,description:"fires after a fx-fore page has been completely initialized"},{name:"rebuild-done",show:!1,description:"fires after a rebuild has taken place"},{name:"recalculate-done",show:!1,description:"fires after a recalculate has taken place"},{name:"refresh-done",show:!1,description:"fires after a refresh has been done"},{name:"relevant",show:!1,description:"fires after a fx-control has become relevant"},{name:"reload",show:!1,description:"fires when a fx-reload action executes"},{name:"required",show:!1,description:"fires after an fx-control has become required"},{name:"return",show:!1,description:"fires after a fx-return returned"},{name:"select",show:!1,description:"fires when an fx-case has been selected"},{name:"submit",show:!1,description:"fires before a submission takes place"},{name:"submit-done",show:!1,description:"fires after a submission has successfully been executed"},{name:"submit-error",show:!1,description:"fires when a submission returned an error"},{name:"valid",show:!1,description:"fires after a fx-control has become valid"},{name:"value-changed",show:!1,description:"fires after a fx-control has changed its value"}]}_log(e,t){const n=e.target.nodeName;if("FX-ACTION-LOG"===n)return;const r=document.createElement("div");r.classList.add("log-row");const a=this._logDetails(e);if(e.detail&&0===Object.keys(e.detail).length&&Object.getPrototypeOf(e.detail)===Object.prototype&&r.classList.add("no-detail"),r.innerHTML=a,this.outermost){if("outermost-action-start"===e.type)return;this.outermostAppender||(this.outermostAppender=document.createElement("ul"),t.append(this.outermostAppender));const n=document.createElement("li");n.append(r),this.outermostAppender.append(n)}else t.append(r);this.parentPath&&"FX-ACTION"!==n&&r.classList.add("nested");const s=e.target;r.addEventListener("click",(e=>{this._highlight(s)}));const o=r.querySelector(".event-target");o&&o.addEventListener("click",(e=>{document.querySelectorAll(".fx-action-log-debug").forEach((e=>{e.classList.remove("fx-action-log-debug")})),s.dispatchEvent(new CustomEvent("log-action",{composed:!1,bubbles:!0,cancelable:!0,detail:{target:s}})),s.classList.add("fx-action-log-debug"),s.setAttribute("data-name",s.nodeName),this._highlight(s)}))}_logDetails(e){const t=e.type,n=nt.getPath(e.target),r=n.substring(n.indexOf("/fx-fore"),n.length),a=`/${r}`,s=r.replaceAll("fx-","");switch(this.parentPath&&!a.startsWith(this.parentPath)&&(this.parentPath=null),t){case"deleted":const{deletedNodes:n}=e.detail,r=new XMLSerializer;let o="";return n.forEach((e=>{o+=r.serializeToString(e)})),`\n <fx-log-item event-name="${t}"\n xpath="${a}"\n short-info="${e.detail.ref}"\n short-name="${e.target.nodeName.toLowerCase()}">\n <section class="details">\n <header>Details</header>\n <section>\n <span class="key">Deleted Nodes</span>\n <textarea class="value" rows="5">${o.trim()}</textarea>\n </section>\n </section>\n </fx-log-item>\n `;case"outermost-action-start":return"start";case"outermost-action-end":return"";case"execute-action":const i=e.detail.action;return this._renderAction(i,a,s,e);default:return`\n <fx-log-item event-name="${t}"\n xpath="${a}"\n short-name="${e.target.nodeName.toLowerCase()}">\n \n <section class="details">\n ${this._listEventDetails(e)}\n </section>\n </fx-log-item>\n `}}_renderAction(e,t,n,r){switch(e.nodeName.split("-")[1],e.nodeName){case"FX-ACTION":return this.parentPath=t,`\n <fx-log-item event-name="${r.detail.event}"\n xpath="${t}"\n short-name="ACTION" class="action">\n <section class="details">\n <header>Attributes</header>\n <section>\n ${Array.from(e.attributes).map((e=>`\n <span class="key">${e.nodeName}</span>\n <span class="value">${e.nodeValue}</span>\n `)).join("")} \n </section>\n </section>\n </fx-log-item> \n `;case"FX-MESSAGE":const n=r.detail.action.messageTextContent;return`\n <fx-log-item event-name="${r.detail.event}"\n xpath="${t}"\n short-name="MESSAGE"\n short-info="${n}" class="action">\n <section class="details">\n <span>${n}</span>\n </section>\n </fx-log-item>\n `;case"FX-SEND":const a=document.querySelector(`#${r.detail.action.getAttribute("submission")}`);return`\n <fx-log-item short-name="SEND"\n short-info="${a.id}"\n event-name="${r.detail.event}"\n xpath="${t}" class="action">\n <section class="details">\n <header>Submission</header>\n <section class="attributes">\n ${Array.from(a.attributes).map((e=>`\n <span class="key">${e.nodeName}</span>\n <span class="value">${e.nodeValue}</span>\n `)).join("")} \n </section> \n </section>\n </fx-log-item>\n `;case"FX-SETVALUE":return`\n <fx-log-item short-name="SETVALUE"\n short-info="${nt.getPath(r.target.nodeset)}"\n event-name="${"FX-CONTROL"===r.target.nodeName?r.target.updateEvent:r.detail.event}"\n xpath="${t}" class="action">\n <section class="details">\n <span class="key">value</span>\n <span class="value">${r.detail.value}</span>\n </section>\n </fx-log-item>\n `;default:return`\n <fx-log-item event-name="${r.detail.event}" \n short-name="${r.target.nodeName}"\n xpath="${t}"\n class="action">\n <section class="details">\n </section>\n </fx-log-item>\n `}}_listEventDetails(e){return e.detail&&0===Object.keys(e.detail).length&&Object.getPrototypeOf(e.detail)===Object.prototype?"":`${Object.keys(e.detail).map((e=>`<span>${e}</span>`))}`}_listAttributes(e){return""}_highlight(e){const t=e.style.backgroundColor,n=e.style.transition;e.style.transition="background 1s",e.style.backgroundColor="#FFA500",setTimeout((()=>{e.style.backgroundColor=t,setTimeout((()=>{e.style.transition=n}),400)}),400),window.document.dispatchEvent(new CustomEvent("log-active-element",{detail:{target:e}}))}}customElements.get("fx-log-settings")||customElements.define("fx-log-settings",fn);class gn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.listenTo=[],this.listeners=[]}connectedCallback(){localStorage.getItem("fx-action-log-filters")?this.listenTo=JSON.parse(localStorage.getItem("fx-action-log-filters")):this.listenTo=fn.defaultSettings(),localStorage.getItem("fx-log-settings")?this.listenTo=JSON.parse(localStorage.getItem("fx-log-settings")):this.listenTo=fn.defaultSettings();this.shadowRoot.innerHTML='\n <style>\n \n :host {\n display:block;\n position:relative;\n width:100%;\n border:thin solid #efefef;\n background:transparent;\n font-family: Verdana, Sans;\n margin:0;\n padding:0.25rem;\n }\n a,a:link,a:visited{\n color:black;\n }\n a{\n position:relative;\n }\n a[alt]:hover::after {\n content:attr(alt);\n position:absolute; \n left:0;\n bottom:-0.5em;\n border:thin solid;\n padding:0.5em;\n background:white;\n z-index:1;\n min-width:5em;\n border:thin solid;\n max-width:90%;\n }\n .details{\n padding:0.25em 0;\n }\n\n .key{\n width:20%;\n display:inline-block;\n min-width:5rem;\n border-bottom:1px solid #ddd;\n background:#efefef;\n vertical-align:top;\n }\n .value{\n display:inline-block;\n width:60%;\n \n }\n \n .buttons{\n position:absolute;\n top:0;\n right:0;\n }\n .buttons button{\n padding:0;\n }\n button{\n float:right;\n }\n button{\n border:none;\n background:transparent;\n width:2.25rem;\n height:2.25rem;\n cursor:pointer;\n }\n button#reset{\n padding:0;\n height:1rem;\n }\n .info{\n padding:0 0.5em;\n margin:0.1rem 0;\n background:white;\n position:relative;\n display:grid;\n grid-template-areas: "left right"\n "bottom .";\n grid-template-columns: 75% 25%;\n }\n .info a{\n grid-area:right;\n justify-self:end;\n }\n .details > section{\n display:flex;\n flex-wrap:wrap;\n padding:0.5em 0;\n }\n fx-log-item{\n }\n header{\n padding:0.5rem;\n margin:0;\n border-bottom:2px solid #ddd;\n }\n \n .info:hover{\n outline:3px solid lightblue; \n transition:height 0.4s;\n }\n\n ol{\n background: #efefef;\n padding: 0.5em 0 0 2em;\n border-left:3px solid red;\n }\n \n .event-name{\n display:inline-block;\n }\n #log{\n margin-bottom:10em;\n margin-right:2em;\n }\n .log-row{\n margin:0;\n padding:0;\n position:relative;\n font-size:0.8em;\n border-left:4px solid transparent;\n padding-left:5px;\n width:calc(100% - 2em);\n margin-bottom:0.25em;\n }\n .log-row summary{\n display:flex;\n flex-wrap:wrap;\n padding:0.5em 0;\n cursor:pointer;\n }\n .log-row summary > span {\n width:calc(90% div 3);\n }\n\n .log-name{\n position:relative;\n }\n .short-info{\n flex:3;\n overflow:hidden;\n white-space:nowrap;\n text-overflow:ellipsis;\n }\n .log-row.no-detail summary{\n position:relative;\n }\n .log-row.no-detail summary{\n list-style:none;\n padding-left:1rem;\n }\n .log-row.no-detail summary::-webkit-details-marker {\n display: none;\n }\n .log-row.nested{\n margin-left:1em;\n }\n .nested .event-name{\n display:none;\n }\n \n .setvalue .value{\n background:lightyellow;\n }\n summary{\n padding:1em;\n border-bottom:2px solid #ddd;\n }\n .outer-details{\n height:100%;\n overflow:auto;\n margin-top:2rem;\n background:rgba(250, 250, 250, 0.9);\n }\n \n .outer-details > header{\n position:absolute;\n top:-1px;\n width:calc(100% - 2rem);\n border-bottom:2px solid #ddd;\n font-size:1rem;\n height:1rem;\n }\n .outer-details > summary{\n font-size:1em;\n }\n ul{\n list-style:none;\n padding:0;\n margin:0.1em 0;\n border-left:3px solid steelblue;\n padding:0.1em 0;\n }\n ul .log-row{\n padding-left:3px;\n width:calc(100% - 1em);\n }\n \n </style>\n \n <section open class="outer-details">\n <header>Log \n <span class="buttons">\n <button id="del"" title="empty log - Ctrl+d">\n <svg viewBox="0 0 24 24" style="width:24px;height:24px;" preserveAspectRatio="xMidYMid meet" focusable="true"><g><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zm2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12zM15.5 4l-1-1h-5l-1 1H5v2h14V4z"></path></g></svg></a>\n </button>\n </span>\n </header>\n <div id="log"></div>\n </section>\n \n ',window.document.querySelector("fx-fore");const e=this.shadowRoot.querySelector("#log");this.listenTo.forEach((t=>{t.show&&document.addEventListener(t.name,(t=>{this._log(t,e)}))})),document.addEventListener("outermost-action-start",(e=>{this.outermost=!0}),{capture:!0}),document.addEventListener("outermost-action-end",(e=>{this.outermost=!1,this.outermostAppender=null}),{capture:!0});this.shadowRoot.querySelector("#del").addEventListener("click",(e=>{this.shadowRoot.querySelector("#log").innerHTML=""})),document.addEventListener("keydown",(e=>{e.ctrlKey&&"d"===e.key&&(this.shadowRoot.querySelector("#log").innerHTML="")}))}_defaultSettings(){this.listenTo=[{name:"action-performed",show:!1,description:"fires after an action has been performed"},{name:"click",show:!1,description:""},{name:"deleted",show:!1,description:"fires after a delete action has been executed"},{name:"deselect",show:!1,description:"fires when fx-case is deselected"},{name:"dialog-hidden",show:!1,description:"fires after fx-dialog has been hidden"},{name:"dialog-shown",show:!1,description:"fired when a dialog has been shown"},{name:"error",show:!1,description:"fires after an error occurred"},{name:"execute-action",show:!0,description:"fires when an action executes"},{name:"init",show:!1,description:"fires when a control initializes"},{name:"index-changed",show:!1,description:"fires when the repeat index changes"},{name:"insert",show:!1,description:"fires when an fx-insert is executed"},{name:"instance-loaded",show:!1,description:"fires after an fx-instance has been loaded"},{name:"invalid",show:!1,description:"fires after a control became invalid"},{name:"item-changed",show:!1,description:"fires when a repeat item was changed"},{name:"item-created",show:!1,description:"fires when a repeat item was created"},{name:"loaded",show:!1,description:"fires after a fx-load has loaded"},{name:"model-construct",show:!1,description:"fires when a model gets constructed"},{name:"model-construct-done",show:!1,description:"fires after model initialization"},{name:"nonrelevant",show:!1,description:"fires after an fx-control became nonrelevant"},{name:"optional",show:!1,description:"fires after an fx-control became optional"},{name:"outermost-action-end",show:!1,description:"fires when an outermost action block is finished"},{name:"outermost-action-start",show:!1,description:"fires when an outermost action block is started"},{name:"path-mutated",show:!1,description:"fires when a path in a repeat has been mutated"},{name:"readonly",show:!1,description:"fires after an fx-control became readonly"},{name:"readwrite",show:!1,description:"fires after an fx-control became readwrite"},{name:"ready",show:!1,description:"fires after a fx-fore page has been completely initialized"},{name:"rebuild-done",show:!1,description:"fires after a rebuild has taken place"},{name:"recalculate-done",show:!1,description:"fires after a recalculate has taken place"},{name:"refresh-done",show:!1,description:"fires after a refresh has been done"},{name:"relevant",show:!1,description:"fires after a fx-control has become relevant"},{name:"reload",show:!1,description:"fires when a fx-reload action executes"},{name:"required",show:!1,description:"fires after an fx-control has become required"},{name:"return",show:!1,description:"fired by embedded Fore controls to return their bound value"},{name:"select",show:!1,description:"fires when an fx-case has been selected"},{name:"submit",show:!1,description:"fires before a submission takes place"},{name:"submit-done",show:!1,description:"fires after a submission has successfully been executed"},{name:"submit-error",show:!1,description:"fires when a submission returned an error"},{name:"valid",show:!1,description:"fires after a fx-control has become valid"},{name:"value-changed",show:!1,description:"fires after a fx-control has changed its value"}]}_log(e,t){const n=e.target.nodeName;if("FX-ACTION-LOG"===n)return;const r=document.createElement("div");r.classList.add("log-row");const a=this._logDetails(e);if(e.detail&&0===Object.keys(e.detail).length&&Object.getPrototypeOf(e.detail)===Object.prototype&&r.classList.add("no-detail"),r.innerHTML=a,this.outermost){if("outermost-action-start"===e.type)return;this.outermostAppender||(this.outermostAppender=document.createElement("ul"),t.append(this.outermostAppender));const n=document.createElement("li");n.append(r),this.outermostAppender.append(n)}else t.append(r);this.parentPath&&"FX-ACTION"!==n&&r.classList.add("nested");const s=e.target;r.addEventListener("click",(e=>{this._highlight(s)}));const o=r.querySelector(".event-target");o&&o.addEventListener("click",(e=>{document.querySelectorAll(".fx-action-log-debug").forEach((e=>{e.classList.remove("fx-action-log-debug")})),s.dispatchEvent(new CustomEvent("log-action",{composed:!1,bubbles:!0,cancelable:!0,detail:{target:s}})),s.classList.add("fx-action-log-debug"),s.setAttribute("data-name",s.nodeName),this._highlight(s)}))}_logDetails(e){const t=e.type,n=nt.getDocPath(e.target),r=n.substring(n.indexOf("/fx-fore"),n.length),a=`/${r}`,s=r.replaceAll("fx-","");switch(this.parentPath&&!a.startsWith(this.parentPath)&&(this.parentPath=null),t){case"deleted":const{deletedNodes:n}=e.detail,r=new XMLSerializer;let o="";return n.forEach((e=>{o+=r.serializeToString(e)})),`\n <fx-log-item event-name="${t}"\n xpath="${a}"\n short-info="${e.detail.ref}"\n short-name="${e.target.nodeName.toLowerCase()}">\n <section class="details">\n <header>Details</header>\n <section>\n <span class="key">Deleted Nodes</span>\n <textarea class="value" rows="5">${o.trim()}</textarea>\n </section>\n </section>\n </fx-log-item>\n `;case"outermost-action-start":return"start";case"outermost-action-end":return"";case"execute-action":const i=e.detail.action;return this._renderAction(i,a,s,e);default:return`\n <fx-log-item event-name="${t}"\n xpath="${a}"\n short-name="${e.target.nodeName.toLowerCase()}">\n \n <section class="details">\n ${this._listEventDetails(e)}\n </section>\n </fx-log-item>\n `}}_renderAction(e,t,n,r){let a;switch(e.nodeName.split("-")[1],e.nodeName){case"FX-ACTION":return this.parentPath=t,a=r.target.currentEvent?r.target.currentEvent.type:r.detail.event?r.detail.event:"",`\n <fx-log-item event-name="${a}"\n xpath="${t}"\n short-name="ACTION"\n data-path="${r.detail.path}" \n class="action">\n <section class="details">\n <header>Attributes</header>\n <section>\n ${Array.from(e.attributes).map((e=>`\n <span class="key">${e.nodeName}</span>\n <span class="value">${e.nodeValue}</span>\n `)).join("")} \n </section>\n </section>\n </fx-log-item> \n `;case"FX-MESSAGE":const n=r.detail.action.messageTextContent;return`\n <fx-log-item event-name="${r.detail.event}"\n xpath="${t}"\n short-name="MESSAGE"\n short-info="${n}" class="action">\n <section class="details">\n <span>${n}</span>\n </section>\n </fx-log-item>\n `;case"FX-SEND":const s=document.querySelector(`#${r.detail.action.getAttribute("submission")}`),o=r.detail.event?r.detail.event:"";return`\n <fx-log-item short-name="SEND"\n short-info="${s.getAttribute("id")}"\n event-name="${o}"\n xpath="${t}" class="action"\n data-path="${r.detail.path}" >\n <section class="details">\n <header>Submission</header>\n <section class="attributes">\n ${Array.from(s.attributes).map((e=>`\n <span class="key">${e.nodeName}</span>\n <span class="value">${e.nodeValue}</span>\n `)).join("")} \n </section> \n </section>\n </fx-log-item>\n `;case"FX-SETVALUE":return`\n <fx-log-item short-name="SETVALUE"\n short-info="${nt.getPath(r.target.nodeset)}"\n event-name="${"FX-CONTROL"===r.target.nodeName?r.target.updateEvent:r.detail.event?r.detail.event:""}"\n xpath="${t}"\n data-path="${r.detail.path}" class="action">\n <section class="details">\n <span class="key">value</span>\n <span class="value">${r.detail.value}</span>\n </section>\n </fx-log-item>\n `;default:return a=r.target.currentEvent?r.target.currentEvent.type:r.detail.event?r.detail.event:"",`\n <fx-log-item event-name="${a}" \n short-name="${r.target.nodeName}"\n xpath="${t}"\n data-path="${r.detail.path}" \n class="action">\n <section class="details">\n </section>\n </fx-log-item>\n `}}_listEventDetails(e){return e.detail&&0===Object.keys(e.detail).length&&Object.getPrototypeOf(e.detail)===Object.prototype?"":`${Object.keys(e.detail).map((e=>`<span>${e}</span>`))}`}_listAttributes(e){return""}_highlight(e){const t=e.style.backgroundColor,n=e.style.transition;e.style.transition="background 1s",e.style.backgroundColor="#FFA500",setTimeout((()=>{e.style.backgroundColor=t,setTimeout((()=>{e.style.transition=n}),400)}),400),window.document.dispatchEvent(new CustomEvent("log-active-element",{detail:{target:e}}))}}function yn(e,t){e.classList.add(t)}function wn(e,t){e.classList.remove(t)}function vn(e,t){if("object"!=typeof e)throw new Error(`containsOnlyText: Expected argument node of type object, ${typeof e} given.`);let n=!1,r=null;if(t=t||!1)for(let t=0,a=e.childNodes.length;t<a&&(r=e.childNodes[t],n=r.nodeType===Node.TEXT_NODE||r.nodeType===Node.COMMENT_NODE||r.nodeType===Node.CDATA_SECTION_NODE,n);t+=1);else n=e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE||e.nodeType===Node.CDATA_SECTION_NODE;return n}function bn(e,t){const n=document.createElement(e);t=t||{};for(const e of Object.keys(t))n.setAttribute(e,t[e]);return n}function xn(e,t){const n=bn("span",{class:"adi-opt"});return n.innerHTML=`<label><input type="checkbox" data-opt="${e}">${t}</label>`,n}customElements.get("fx-action-log")||customElements.define("fx-action-log",gn);class An{constructor(e,t){this.sourceNodeByInspectorNodeLookup=new Map,this.uiView=null,this.menuView=null,this.domView=null,this.attrView=null,this.optsView=null,this.activeElement=null,this.vertResizing=!1,this.horizResizing=!1,this.pathScrolling=null,this.elemLookup=!1,this.styleBackup="",this.xPos=0,this.delegatedEvents=[],this.options={align:"right",split:50,minSplit:30,visible:!0,saving:!1,transparent:!0,omitEmptyText:!0,makeVisible:!0,foldText:!0,nodeTypes:[Node.ELEMENT_NODE,Node.TEXT_NODE,Node.COMMENT_NODE,Node.DOCUMENT_NODE]},"#document"===t?(this.instanceId="#document",this.document=window.document,this.isInstanceViewer=!1):(this.instanceId=t.id,!t||t.localName,this.document=t.getInstanceData(),this.isInstanceViewer=!0,this.options.foldText=!1),this.drawUI(e),this.registerEvents(),this.drawDOM(this.document,this.domView.querySelector(".adi-tree-view"),!0),document.addEventListener("execute-action",(e=>this.processExecuteAction))}getSelected(){if(!this.activeElement)return null;let e=document;return e=this.sourceNodeByInspectorNodeLookup.get(this.activeElement),e}loadOptions(){let e={};e=JSON.parse(window.localStorage.getItem("ADI.options"))||{};for(const t of Object.keys(e))this.options[t]=e[t]}saveOptions(){this.options.saving&&window.localStorage.setItem("ADI.options",JSON.stringify(this.options))}hasRequiredNodes(e){if("object"!=typeof e)throw new Error(`hasRequiredNodes: Expected argument node of type object, ${typeof e} given.`);if(e.hasChildNodes())for(let t=0,n=e.childNodes.length;t<n;t+=1){const n=e.childNodes[t];if(this.options.nodeTypes.includes(n.nodeType))return!0}return!1}newTreeNode(e){if("object"!=typeof e)throw new Error(`newTreeNode: Expected argument node of type object, ${typeof e} given.`);const t=this.hasRequiredNodes(e);let n=!1,r=e.nodeName.startsWith("FX-")?`adi-node ${e.nodeName.toLowerCase()}`:"";e.nodeName.startsWith("FX-")&&(r=`adi-node ${e.nodeName.toLowerCase()}`,r+=Ft.isActionElement(e.nodeName)?" action":"");const a=bn("li",{class:r});if(e===this.uiView)return null;if(t&&a.appendChild(bn("span",{class:"adi-trigger"})),this.options.omitEmptyText&&e.nodeType===Node.TEXT_NODE&&(n=function(e){if("object"!=typeof e)throw new Error(`isEmptyTextNode: Expected argument node of type object, ${typeof e} given.`);return/^\s*$/.test(e.textContent)}(e)),!n){const n=bn("span");this.sourceNodeByInspectorNodeLookup.set(n,e),this.sourceNodeByInspectorNodeLookup.set(e,n);let r=null;if(vn(e))e.nodeType===Node.COMMENT_NODE?(yn(n,"adi-comment-node"),"string"==typeof n.innerText&&(n.innerText=`\x3c!-- ${e.textContent} --\x3e`)):(yn(n,"adi-text-node"),n.textContent=e.textContent);else if(yn(n,"adi-normal-node"),e.nodeType!==Node.DOCUMENT_NODE){const a=Array.from(e.attributes).filter((e=>!!this.isInstanceViewer||"style"!==e.name)).map((e=>`${e.name}="${e.value}"`)).join(" ");n.textContent=`<${e.nodeName.toLowerCase()}${a?` ${a}`:""}>`,t&&(r=bn("span"),yn(r,"adi-end-node"),r.textContent=`</${e.nodeName.toLowerCase()}>`)}else n.textContent=e.nodeName.toLowerCase();return a.appendChild(n),e.nodeName.startsWith("FX-")&&(n.classList.add("fore-node"),n.classList.add(e.nodeName.toLowerCase())),r&&(a.appendChild(r),e.nodeName.startsWith("FX-")&&r.classList.add("fore-node")),a}return null}drawDOM(e,t,n){if("object"!=typeof e)throw new Error(`drawDOM: Expected argument root of type object, ${typeof e} given.`);let r=null,a=!0;const s=t.nodeName.startsWith("FX-")?`adi-node ${node.nodeName.toLowerCase()}`:"";n&&-1!==this.options.nodeTypes.indexOf(e.nodeType)&&(t.innerHTML="",r=this.newTreeNode(e),this.hasRequiredNodes(e)&&(r.appendChild(bn("ul",{"data-open":!0,class:s})),yn(r.querySelector(".adi-trigger"),"opened")),t.appendChild(r),t=t.querySelector("ul"));for(let n=0,o=e.childNodes.length;n<o;n+=1){const o=e.childNodes[n],i=this.hasRequiredNodes(o);if(-1!==this.options.nodeTypes.indexOf(o.nodeType)&&(r=this.newTreeNode(o),r)){if(i&&(a=!this.options.foldText||!vn(o,!0),"HEAD"===o.nodeName&&(a=!1),"SELECT"===o.nodeName&&(a=!1),"FX-INSTANCE"===o.nodeName&&(a=!1),o.nodeType===Node.DOCUMENT_NODE?r.appendChild(bn("ul",{"data-open":a,class:s})):r.insertBefore(bn("ul",{"data-open":a,class:s}),r.lastChild),yn(r.querySelector(".adi-trigger"),a?"opened":"closed")),t.appendChild(r),this.getSelected()===o){const e=r.querySelector("span.adi-normal-node");e?.classList?.add("adi-active-node"),this.activeElement=e,r.scrollIntoView({block:"nearest",behavior:"instant"})}i&&this.drawDOM(o,r.querySelector("ul"),!1)}}}toggleOptions(){-1!==this.optsView.className.indexOf("adi-hidden")?wn(this.optsView,"adi-hidden"):(yn(this.optsView,"adi-hidden"),this.attrView.querySelector(".adi-content").innerHTML="",this.refreshUI(),this.drawDOM(document,this.domView.querySelector(".adi-tree-view"),!0),this.options.saving?this.saveOptions():window.localStorage.removeItem("ADI.options"))}drawUI(e){this.uiView=bn("div",{id:"adi-wrapper",class:this.options.transparent?"transparent":""}),this.domView=bn("div",{id:"adi-dom-view"});const t=bn("div",{class:"adi-content",id:"detailsView"}),n=bn("ul",{class:"adi-tree-view"}),r=bn("div",{class:"adi-path-wrap"}),a=bn("span",{class:"adi-path-left"}),s=bn("span",{class:"adi-path-right"});this.menuView=bn("div",{id:"adi-panel"});const o=bn("div",{class:"adi-menu-wrap"}),i=bn("a",{class:"adi-menu-config",title:"Settings"}),l=bn("a",{class:"adi-menu-lookup",title:"Lookup tool"});if(this.optsView=function(){const e=bn("div",{id:"adi-opts-view",class:"adi-hidden"}),t=bn("span",{class:"adi-opt-heading"}),n=bn("span",{class:"adi-opt-heading"}),r=bn("span",{class:"adi-opt-close"});return t.textContent="General options",n.textContent="Observed nodes",e.appendChild(t),e.appendChild(xn("saving","Enable saving of settings")),e.appendChild(xn("makeVisible","Scroll to the active element in DOM View")),e.appendChild(xn("omitEmptyText","Hide empty text nodes")),e.appendChild(xn("foldText","Fold the text nodes")),e.appendChild(xn("transparent","Enable transparent background")),e.appendChild(n),e.appendChild(xn("nodeTypes-3","Text node")),e.appendChild(xn("nodeTypes-8","Comment node")),e.appendChild(r),e}(),t.appendChild(n),this.domView.appendChild(this.menuView),this.domView.appendChild(t),r.appendChild(a),r.appendChild(s),o.appendChild(l),o.appendChild(i),this.menuView.appendChild(r),this.menuView.appendChild(o),this.uiView.appendChild(this.optsView),this.uiView.appendChild(this.domView),!this.isInstanceViewer){this.attrView=bn("div",{id:"adi-attr-view"});const e=bn("div",{class:"adi-content"});this.attrView.appendChild(e),this.uiView.appendChild(this.attrView)}e.appendChild(this.uiView),this.refreshUI(!0)}refreshUI(e){null!==this.uiView&&(e&&this.loadOptions(),e&&(this.optsView.querySelector('[data-opt="transparent"]').checked=this.options.transparent,this.optsView.querySelector('[data-opt="saving"]').checked=this.options.saving,this.optsView.querySelector('[data-opt="omitEmptyText"]').checked=this.options.omitEmptyText,this.optsView.querySelector('[data-opt="makeVisible"]').checked=this.options.makeVisible,this.optsView.querySelector('[data-opt="foldText"]').checked=this.options.foldText,this.optsView.querySelector('[data-opt="nodeTypes-3"]').checked=-1!==this.options.nodeTypes.indexOf(3),this.optsView.querySelector('[data-opt="nodeTypes-8"]').checked=-1!==this.options.nodeTypes.indexOf(8)),this.uiView.className=this.options.transparent?"transparent":"",this.domView.querySelector(".adi-content").style.height=`${this.domView.clientHeight}px`,this.isInstanceViewer||(this.attrView.querySelector(".adi-content").style.height=this.attrView.clientHeight-this.menuView.clientHeight+"px"),yn(this.uiView,this.options.align))}toggleVisibilityUI(){null!==this.uiView&&(this.uiView.style.display=this.options.visible?"none":"block",this.options.visible=!this.options.visible,this.saveOptions())}drawAttrs(e){if(this.isInstanceViewer)return;const t=this.attrView.querySelector(".adi-content");t.innerHTML="";const n=document.createElement("header");n.innerText="Attributes",t.appendChild(n),[...e.attributes].forEach((e=>{"style"!==e.name&&t.appendChild(function(e,t){const n=bn("span",{class:"adi-attr"});switch(e.toLowerCase()){case"defaultaction":n.innerHTML=`<label>${e}: <select data-attr="${e}" value="${t}"><option>perform</option><option>cancel</option></label>`;break;case"delay":n.innerHTML=`<label>${e}: <input type="number" data-attr="${e}" value="${t}" readonly="readonly"></label>`;break;default:n.innerHTML=`<label>${e}: <input type="text" data-attr="${e}" value="${t}" readonly="readonly"></label>`}return n}(e.name,e.value))}))}changeAttribute(e){const t=e?e.target:window.event.srcElement,n=t.getAttribute("data-attr"),r=t.value,a=this.getSelected();""===r?a.removeAttribute(n):a.setAttribute(n,r)}changeOption(e){const t=e?e.target:window.event.srcElement,n=t.getAttribute("data-opt"),r=t.checked;if(-1!==n.indexOf("nodeTypes")){const e=parseInt(n.match(/\d+/)[0],10);r?this.options.nodeTypes.push(e):this.options.nodeTypes.splice(this.options.nodeTypes.indexOf(e),1)}else this.options[n]=r}processKey(e){if(272===((e=e||window.event).keyCode||e.which))this.toggleVisibilityUI()}verticalResize(e){if(!this.vertResizing)return;e=e||window.event,document.documentElement.style.cursor="e-resize";const t=this.options.width+this.xPos-e.clientX;t>=this.options.minWidth&&(this.options.width=t,this.xPos=e.clientX,this.refreshUI(),this.saveOptions())}horizontalResize(e){if(!this.horizResizing)return;e=e||window.event,document.documentElement.style.cursor="n-resize";const t=Math.floor(e.clientY/this.uiView.clientHeight*100);t>=this.options.minSplit&&t<=100-this.options.minSplit&&(this.options.split=t,this.refreshUI(),this.saveOptions())}processExecuteAction(e){this.refreshUI()}handleActive(e){let t=e?e.detail?.target||e.target:window.event.srcElement;const n=this.domView.querySelector(".adi-active-node");if(n&&wn(n,"adi-active-node"),!t||t.nodeType===Node.DOCUMENT_NODE)return;if(t&&t.classList&&t.classList.contains("adi-end-node")&&(t=t.parentNode.querySelector(".adi-normal-node")),this.activeElement=t,yn(t,"adi-active-node"),this.options.makeVisible){this.domView.querySelector(".adi-content").scrollIntoView({block:"center",behavior:"instant"})}const r=this.getSelected();if(this.drawAttrs(r),r&&"function"==typeof r.getModelItem&&r.getModelItem()?.node){let e=r.modelItem.node;e?.nodeType===Node.ATTRIBUTE_NODE&&(e=e.ownerElement),window.document.dispatchEvent(new CustomEvent("log-active-element",{detail:{target:e}}))}}highlightElement(e){let t=e?e.target:window.event.srcElement;t.classList.contains("adi-end-node")&&(t=t.parentNode.querySelector(".adi-normal-node"));const n=this.sourceNodeByInspectorNodeLookup.get(t);n&&n.ownerDocument===window.document&&n&&("mouseover"===e.type?(this.styleBackup=n.getAttribute("style")||"",n.setAttribute("style",`outline: 2px solid blue; ${this.styleBackup}`)):""===this.styleBackup?n.removeAttribute("style"):n.setAttribute("style",this.styleBackup))}handleLookup(e){const t=e?e.detail?.target||e.target:window.event.srcElement;if(!this.document.contains(t))return;if(t.nodeType===Node.DOCUMENT_NODE)return;if(-1!==t.className.indexOf("adi-menu-lookup"))return this.elemLookup?(wn(t,"adi-active"),this.elemLookup=!1,this.removeEvent(document.body,"mouseover",this.handleLookup,!0),this.removeEvent(document.body,"mouseout",this.handleLookup,!0),void this.removeEvent(document.body,"click",this.handleLookup,!0)):(yn(t,"adi-active"),this.elemLookup=!0,this.addEventDelegate(document.body,"mouseover",this.handleLookup,!1,"*",!0,"adi-wrapper"),this.addEventDelegate(document.body,"mouseout",this.handleLookup,!1,"*",!0,"adi-wrapper"),void this.addEventDelegate(document.body,"click",this.handleLookup,!1,"*",!0,"adi-wrapper"));if("mouseover"===e.type)return this.styleBackup=t.getAttribute("style")||"",void t.setAttribute("style",`outline: 1px dashed red; ${this.styleBackup}`);if("mouseout"===e.type)return void t.setAttribute("style",this.styleBackup);this.elemLookup=!1,wn(this.menuView.querySelector(".adi-menu-lookup"),"adi-active"),t.setAttribute("style",this.styleBackup),this.removeEvent(document.body,"mouseover",this.handleLookup,!0),this.removeEvent(document.body,"mouseout",this.handleLookup,!0),this.removeEvent(document.body,"click",this.handleLookup,!0),function(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault(),e.cancelBubble=!0,e.returnValue=!1}(e);const n=this.sourceNodeByInspectorNodeLookup.get(t);if(!n)return;if(n&&n.click(),!n.parentNode)return;let r,a=n.parentNode;for(a.querySelector("ul")&&a.querySelector("ul").setAttribute("data-open","true");a!==this.domView.querySelector(".adi-content");)-1!==a.className.indexOf("adi-node")&&(r=a.querySelector(".adi-trigger"),r&&(wn(r,"closed"),yn(r,"opened")),a=a.parentNode,a.setAttribute("data-open","true")),a=a.parentNode;this.options.makeVisible&&n.scrollIntoView({behavior:"instant",block:"nearest",inline:"nearest"}),t.scrollIntoView({behavior:"instant",block:"nearest",inline:"nearest"})}addEventDelegate(e,t,n,r,a,s,o){const i=e=>{const t=e?e.target:window.event.srcElement,r=a.substr(1);let s=!1;if(o){let e=t;for(;e!==document;){if(e.id===o)return;e=e.parentNode}}s=0===a.indexOf("#")?t.id===r:0===a.indexOf(".")?-1!==t.className.indexOf(r):"*"===a||t.nodeName.toLowerCase()===a,s&&n(e)};s&&this.delegatedEvents.push({handle:i,elem:e,fn:n,evt:t}),e.addEventListener(t,i,r)}removeEvent(e,t,n,r){if("object"!=typeof e)throw new Error(`addEvent: Expected argument elem of type object, ${typeof e} given.`);let a=null;if(r)for(let r=0,s=this.delegatedEvents.length;r<s;r+=1)if(a=this.delegatedEvents[r],a.elem===e&&a.evt===t&&a.fn===n){n=a.handle,this.delegatedEvents.splice(r,1);break}}registerEvents(){const e=()=>{if("#document"!==this.instanceId){const e=window.document.querySelector(`#${this.instanceId}`);this.document=e.getInstanceData()}this.drawDOM(this.document,this.domView.querySelector(".adi-tree-view"),!0)};document.addEventListener("instance-loaded",e),document.addEventListener("value-changed",e),document.addEventListener("ready",e),document.addEventListener("mouseup",(()=>{document.documentElement.style.cursor="default",this.vertResizing=!1,this.horizResizing=!1}),!1),document.addEventListener("mousemove",(e=>this.verticalResize(e)),!1),document.addEventListener("mousemove",(e=>this.horizontalResize(e)),!1),window.addEventListener("resize",(e=>this.refreshUI(e)),!1),document.addEventListener("keypress",(e=>this.processKey(e)),!1),document.addEventListener("log-active-element",(e=>this.handleLookup(e)),!1);this.addEventDelegate(this.domView,"click",(e=>{const t=e?e.target:window.event.srcElement,n=t.parentNode.querySelector("ul");"true"===n.getAttribute("data-open")?(wn(t,"opened"),yn(t,"closed"),n.setAttribute("data-open","false")):(wn(t,"closed"),yn(t,"opened"),n.setAttribute("data-open","true"))}),!1,".adi-trigger"),this.addEventDelegate(this.domView,"click",(e=>this.handleActive(e)),!1,".adi-normal-node"),this.addEventDelegate(this.domView,"click",(e=>this.handleActive(e)),!1,".adi-end-node"),this.addEventDelegate(this.domView,"mouseover",(e=>{yn((e?e.target:window.event.srcElement).parentNode.querySelector(".adi-normal-node"),"hover")}),!1,".adi-end-node"),this.addEventDelegate(this.domView,"mouseout",(e=>{wn((e?e.target:window.event.srcElement).parentNode.querySelector(".adi-normal-node"),"hover")}),!1,".adi-end-node"),this.addEventDelegate(this.domView,"mouseover",(e=>this.highlightElement(e)),!1,".adi-end-node"),this.addEventDelegate(this.domView,"mouseover",(e=>this.highlightElement(e)),!1,".adi-normal-node"),this.addEventDelegate(this.domView,"mouseout",(e=>this.highlightElement(e)),!1,".adi-end-node"),this.addEventDelegate(this.domView,"mouseout",(e=>this.highlightElement(e)),!1,".adi-normal-node"),this.menuView.querySelector(".adi-menu-lookup").addEventListener("click",(e=>this.handleLookup(e)),!1),document.addEventListener("handle-active",(e=>{if(e.detail.selected===this.getSelected())return;const{selected:t}=e.detail,n=this.sourceNodeByInspectorNodeLookup.get(t);if(this.options.makeVisible){const e=this.domView.querySelector(".adi-content");(n.offsetTop>=e.clientHeight||n.offsetTop<=e.scrollTop)&&(e.scrollTop=n.offsetTop-Math.floor(e.clientHeight/2))}this.drawAttrs(this.getSelected())})),document.addEventListener("execute-action",(e=>this.processExecuteAction(event)),{capture:!0}),this.addEventDelegate(this.optsView,"change",(e=>this.changeOption(e)),!1,"input"),this.addEventDelegate(this.optsView,"click",(e=>this.toggleOptions(e)),!1,".adi-opt-close"),this.menuView.querySelector(".adi-menu-config").addEventListener("click",(e=>this.toggleOptions(e)),!1),this.isInstanceViewer||this.addEventDelegate(this.attrView,"change",this.changeAttribute,!1,"input")}}class En extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.instanceName=null,this.instance=null}connectedCallback(){this.render(),this.instance?this.shadowRoot.querySelector("#focus-button").style="display: none":this.setupFocusButton()}setInstance(e){this.instance=e}disconnectedCallback(){this.adiInstance=null}setupFocusButton(){let e="",t=null;const n=()=>{""===e?t.removeAttribute("style"):t.setAttribute("style",e),t=null},r=r=>{const{target:a}=r;if("mouseover"===r.type)return e=a.getAttribute("style")||"",a.setAttribute("style",`outline: 2px solid blue; ${e}`),void(t=a);t&&n()},a=this.shadowRoot.querySelector("#focus-button");let s=!1;const o=window.document.head.appendChild(document.createElement("style")),i=()=>{s=!1,window.document.body.removeEventListener("click",l),a.classList.remove("selected-btn"),o.innerHTML="",document.body.style.cursor="auto",window.document.body.removeEventListener("mouseover",r),window.document.body.removeEventListener("mouseout",r),t&&n()},l=e=>{i(),e.preventDefault(),e.stopPropagation(),e.target!==a&&window.document.dispatchEvent(new CustomEvent("log-active-element",{detail:{target:e.target}}))},c=()=>{s=!0,a.classList.add("selected-btn"),document.body.style.cursor="crosshair",window.document.body.removeEventListener("click",l),o.innerHTML='fx-fore::before { color:blue; content: "Sub fore!" } fx-fore {border: solid 1px blue}',window.document.body.addEventListener("click",l),window.document.body.addEventListener("mouseover",r),window.document.body.addEventListener("mouseout",r)};window.document.addEventListener("keyup",(e=>{s&&"Escape"===e.code?i():!s&&"KeyI"===e.code&&e.ctrlKey&&c()})),a.addEventListener("click",(e=>{s?i():c(),e.preventDefault(),e.stopPropagation()}))}render(){this.shadowRoot.innerHTML="\n <style>\n \n @import '../../resources/fore.css';\n \n :host {\n display:block;\n background:transparent;\n }\n body {\n -webkit-animation: bugfix infinite 1s;\n font-size:1rem;\n }\n \n @-webkit-keyframes bugfix {\n from {\n padding: 0\n }\n to {\n padding: 0\n }\n }\n .adi-content {\n position: relative;\n overflow: auto;\n box-sizing: border-box;\n -moz-box-sizing: border-box;\n height: 100% !important;\n padding:0;\n font-size:0.8em;\n }\n .adi-content header{\n padding:0.5rem;\n // background:rgba(255, 255, 255, 0.2);\n border-bottom:2px solid #ddd;\n border-collapse:collapse;\n }\n .adi-content > * {\n padding:0 0.25em;\n }\n \n #adi-wrapper {\n top: 0;\n font-family: \"Segoe UI\", Arial;\n font-size: 1.1rem;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n position:relative;\n height:calc(100% - 8rem);\n display:flex;\n }\n \n #adi-wrapper.left {\n left: 0\n }\n \n #adi-wrapper.right {\n right: 0\n }\n \n #adi-wrapper.transparent {\n background: rgba(250, 250, 250, 0.9)\n }\n \n #adi-panel {\n position:fixed;\n top:0;\n /*bottom: 0;*/\n right: 0;\n height: 24px;\n background: #d4d4d4;\n border-top: 1px solid #bbc5c9\n }\n \n #adi-panel .adi-path-wrap {\n position:absolute;\n bottom: 0;\n left: 0;\n width: 80%;\n height: 24px;\n padding: 0 13px 0 18px;\n line-height: 24px;\n overflow: hidden;\n box-sizing: border-box;\n -moz-box-sizing: border-box\n }\n \n #adi-panel .adi-path-wrap.adi-overflowing .adi-path-left, \n #adi-panel .adi-path-wrap.adi-overflowing .adi-path-right {\n display: block\n }\n \n #adi-panel .adi-path {\n height: 24px;\n overflow: hidden;\n white-space: nowrap\n }\n \n #adi-panel .adi-path-left, #adi-panel .adi-path-right {\n display: none;\n position: absolute;\n top: 0;\n width: 8px;\n height: 24px;\n background-repeat: no-repeat;\n background-position: center center;\n opacity: .7\n }\n \n #adi-panel .adi-path-left:hover, #adi-panel .adi-path-right:hover {\n opacity: 1\n }\n \n #adi-panel .adi-path-left {\n left: 7px;\n background-image: url('img/left_shift.png')\n }\n \n #adi-panel .adi-path-right {\n position:absolute;\n right: 2px;\n background-image: url('/resources/scripts/dom-inspector/img/right_shift.png')\n }\n \n #adi-panel .adi-menu-wrap {\n bottom: 0;\n right: 24px;\n width: 50px;\n height: 24px\n }\n \n #adi-panel .adi-menu-lookup, #adi-panel .adi-menu-config {\n display: block;\n float: left;\n width: 24px;\n height: 24px;\n border-left: 1px solid #bbc5c9;\n background-position: center center;\n background-repeat: no-repeat;\n opacity: .7;\n border-radius: 0\n }\n \n #adi-panel .adi-menu-lookup:hover, #adi-panel .adi-menu-config:hover {\n background-color: #c5d9d8;\n opacity: 1\n }\n \n #adi-panel .adi-menu-lookup.adi-active, #adi-panel .adi-menu-config.adi-active {\n background-color: #fafafa;\n opacity: 1\n }\n \n #adi-panel .adi-menu-lookup {\n background-image: url('/resources/scripts/dom-inspector/img/lookup.png')\n }\n \n #adi-panel .adi-menu-config {\n background-image: url('/resources/scripts/dom-inspector/img/config.png')\n }\n \n \n \n #adi-vert-split {\n position: fixed;\n top: 0;\n width: 4px;\n height: 100%;\n cursor: e-resize;\n border-width: 0 1px 0 0;\n background: #bbc5c9;\n border-color: #768285;\n border-style: solid;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n }\n \n #adi-vert-split:hover {\n background: #c5d9d8;\n }\n \n \n #adi-dom-view {\n border-right:2px solid #ddd;\n overflow:auto;\n flex-grow:3;\n }\n \n #adi-dom-view ul {\n margin: 0;\n padding: 0;\n list-style: none\n }\n \n #adi-dom-view ul[data-open=true] {\n display: block\n }\n \n #adi-dom-view ul[data-open=false] {\n display: none\n }\n \n #adi-dom-view ul ul {\n margin: 4px 0\n }\n \n #adi-dom-view ul li {\n padding-left: 1em;\n padding-bottom: 0.125em;\n margin: 0;\n padding-top: 0.125em; \n }\n \n \n \n \n \n \n \n #adi-dom-view .adi-normal-node, \n #adi-dom-view .adi-end-node {\n margin-right: 5px;\n padding: 0 6px 0px;\n background: #d2e8ff;\n border-radius: 8px;\n cursor: default;\n font-size:0.8rem;\n }\n #adi-dom-view .adi-text-node:after, #adi-dom-view .adi-comment-node:after {\n content: '\"'\n }\n \n #adi-dom-view .adi-text-node:before, #adi-dom-view .adi-comment-node:before {\n content: '\"'\n }\n \n #adi-dom-view .adi-comment-node {\n color: #999;\n font-style: italic\n }\n \n #adi-dom-view .adi-text-node, #adi-dom-view .adi-comment-node {\n display: block;\n padding: 3px 8px;\n color: #444;\n background: #fff;\n border-radius: 8px\n }\n \n #adi-dom-view .adi-normal-node:hover, \n #adi-dom-view .adi-normal-node.hover, \n #adi-dom-view .adi-end-node:hover, \n #adi-dom-view .adi-end-node.hover {\n background: var(--paper-grey-700);\n color:white;\n }\n \n #adi-dom-view .adi-normal-node:hover ~ span,\n #adi-dom-view .adi-normal-node.hover ~ span,\n #adi-dom-view .adi-end-node:hover ~ span,\n #adi-dom-view .adi-end-node.hover ~ span {\n background: var(--paper-grey-700);\n color:white;\n }\n \n #adi-dom-view .adi-normal-node.adi-active-node, \n #adi-dom-view .adi-end-node.adi-active-node {\n background: var(--paper-grey-700);\n color:white;\n }\n \n #adi-dom-view .adi-normal-node.adi-active-node ~ span,\n #adi-dom-view .adi-end-node.adi-active-node ~ span {\n background: var(--paper-grey-700);\n color:white;\n }\n \n \n \n \n \n \n #adi-dom-view .adi-trigger {\n display: inline-block;\n width: 10px;\n height: 10px;\n margin: 0 5px 0 -13px;\n opacity: .7\n }\n \n #adi-dom-view .adi-trigger.closed {\n // background: url('/resources/scripts/dom-inspector/img/node_closed.png') no-repeat;\n } \n #adi-dom-view .adi-trigger.closed::before {\n content:'\\25B8';\n }\n \n #adi-dom-view .adi-trigger.opened {\n // background: url('/resources/scripts/dom-inspector/img/node_opened.png') no-repeat\n }\n #adi-dom-view .adi-trigger.opened::before{\n content:'\\25BE';\n }\n \n #adi-dom-view .adi-trigger:hover {\n opacity: 1\n }\n \n #adi-opts-view {\n position: relative;\n height: 100%;\n padding: 0 15px;\n background: #fff\n }\n \n #adi-opts-view.adi-hidden {\n display: none\n }\n \n #adi-opts-view .adi-opt-heading, #adi-opts-view .adi-opt {\n display: block;\n padding: 5px 0\n }\n \n #adi-opts-view .adi-opt-heading {\n padding: 20px 0 10px;\n font-size: 1rem;\n }\n \n #adi-opts-view .adi-opt-heading:first-child {\n padding-top: 10px\n }\n \n #adi-opts-view .adi-opt input {\n margin-right: 6px\n }\n \n #adi-opts-view .adi-opt-close {\n position: absolute;\n top: 5px;\n right: 28px;\n width: 16px;\n height: 16px;\n background: url('/resources/scripts/dom-inspector/img/options_close.png') no-repeat;\n opacity: .7;\n }\n \n #adi-opts-view .adi-opt-close:hover {\n opacity: 1;\n }\n \n #adi-attr-view {\n top: 0.5rem;\n border: 1px solid #ddd;\n overflow: auto;\n padding: 0.25em;\n height: calc(90% - 1em);\n min-width: 10rem;\n position: absolute;\n z-index: 10;\n right: 0.5rem;\n background:rgba(255,255,255,0.85);\n }\n #adi-attr-view > .adi-content{\n height:calc(100% - 5em);\n overflow:auto;\n }\n \n #adi-attr-view .adi-attr {\n display: block;\n padding: 0.25em;\n }\n \n #adi-attr-view hr {\n height: 1px;\n border: none\n }\n \n #adi-attr-view input[type=text] {\n width: calc(100% - 0.5em);\n margin-top: 3px;\n padding: 2px;\n }\n \n #adi-horiz-split {\n height: 4px;\n cursor: n-resize;\n border-width: 0 0 1px 0;\n background: #bbc5c9;\n border-color: #768285;\n border-style: solid;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n }\n \n #adi-horiz-split:hover {\n background: #c5d9d8;\n }\n \n #adi-dom-view .fore-node{\n background: var(--paper-blue-700);\n font-size:1.1em;\n color:white;\n }\n #adi-dom-view .adi-normal-node.fore-node:hover {\n background: var(--paper-grey-700);\n color:white;\n }\n #adi-dom-view .adi-end-node.fore-node{\n background: var(--paper-blue-700);\n font-size:1em;\n color:white;\n }\n\n #adi-dom-view .adi-node .adi-active-node.fore-node,\n #adi-dom-view .adi-node.action .adi-active-node.fore-node,\n #adi-dom-view .adi-node.action .adi-active-node.fore-node ~ .adi-end-node\n {\n background: var(--paper-grey-700);\n color:white;\n }\n \n #adi-dom-view .adi-node.fx-fore{\n background:var(--paper-blue-grey-50); \n }\n #adi-dom-view .adi-node.fx-model{\n background:var(--paper-blue-grey-100); \n padding:0.25em 0;\n } \n \n #adi-dom-view .adi-node.action .fore-node {\n background:var(--paper-blue-grey-100);\n color:black;\n font-family:monospace;\n }\n \n .toggleView{\n /*width:20px;*/\n /*height: 20px;*/\n }\n input, select{\n display: block;\n }\n header{\n background:rgba(255, 255, 255, 0.2);\n }\n\n .selected-btn { color: orange }\n \n </style>\n \n <slot name=\"header\"></slot>\n <button id=\"focus-button\">Focus</button>\n <slot></slot>\n \n ",!this.hasAttribute("instance")||this.getAttribute("instance"),this.adiInstance=new An(this.shadowRoot,this.hasAttribute("instance")?this.instance:"#document")}verticalResize(e){if(!this.vertResizing)return;e=e||window.event,document.documentElement.style.cursor="e-resize";const t=this.options.width+this.xPos-e.clientX;t>=this.options.minWidth&&(this.options.width=t,this.xPos=e.clientX,this.refreshUI(),this.saveOptions())}}customElements.get("fx-dom-inspector")||customElements.define("fx-dom-inspector",En);class Nn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.instanceElement=null,this.foreSelector=null}connectedCallback(){this.container=this.querySelector(".json-path-picker-container"),this.foreSelector=this.hasAttribute("fore")?this.getAttribute("fore"):"fx-fore",this.render()}render(){const e=this.hasAttribute("instance")?this.getAttribute("instance"):"default";if(!document.querySelector(this.foreSelector))throw new Error(`this '${this.foreSelector}' does not match a fx-fore element`);this.shadowRoot.innerHTML=`\n <style>\n \n @import '../../resources/fore.css';\n \n :host {\n display:block;\n font-size:0.8em;\n background:rgba(250, 250, 250, 0.9);\n }\n .container{\n margin-left:1em;\n }\n .header{\n margin-left:0;\n }\n\n ::slot[name='header']{\n margin-left:-1em;\n }\n /* Syntax highlighting for JSON objects */\n ul.json-dict, ol.json-array {\n list-style-type: none;\n margin: 0 0 0 1px;\n border-left: 1px dotted #ccc;\n padding-left: 2em;\n }\n .json-string {\n // color: #0B7500;\n }\n .json-literal {\n color: #1A01CC;\n font-weight: bold;\n }\n \n /* Toggle button */\n a.json-toggle {\n position: relative;\n color: inherit;\n text-decoration: none;\n }\n a.json-toggle:focus {\n outline: none;\n }\n a.json-toggle:before {\n content: "\\25BC"; /* down arrow */\n position: absolute;\n display: inline-block;\n width: 1em;\n left: -1.2em;\n font-size:0.8em;\n }\n a.json-toggle.collapsed:before {\n content: "\\25B6"; /* left arrow */\n }\n \n /* Collapsable placeholder links */\n a.json-placeholder {\n color: #aaa;\n padding: 0 1em;\n text-decoration: none;\n }\n a.json-placeholder:hover {\n text-decoration: underline;\n }\n \n /* Copy path icon */\n .pick-path {\n color: lightgray;\n cursor: pointer;\n margin-left: 3px;\n }\n \n .pick-path:hover {\n color: darkgray;\n }\n \n \n </style>\n <slot name="header">\n <header class="header">${e}</header>\n </slot>\n <slot></slot>\n \n <div class="container"></div>\n \n `;const t=document.querySelector(`#${e}`);if(!t||"FX-INSTANCE"!==t.nodeName||"json"!==t.getAttribute("type"))throw new Error(`this '${e}' does not match an fx-instance element or is not of type JSON`);const n=this.shadowRoot.querySelector(".container"),r=t.instanceData;let a=this.json2html(r,{outputWithQuotes:!0});this.isCollapsable(r)&&(a="<a href='#' class=\"json-toggle\"></a>".concat(a)),n.innerHTML=a;this.shadowRoot.querySelectorAll(".json-toggle").forEach((e=>{e.addEventListener("click",this._handleToggleEvent.bind(this))}))}disconnectedCallback(){}_isHidden(e){const t=e.offsetWidth,n=e.offsetHeight;return 0===t&&0===n||"none"===window.getComputedStyle(e).display}_handleToggleEvent(e){const t=e.target;t.classList.toggle("collapsed");const n=this._siblings(t,"ul.json-dict, ol.json-array",(e=>{e.style.display=""===e.style.display||"block"===e.style.display?"none":"block"}));for(let e=0;e<n.length;e+=1)if(this._isHidden(n[e])){const t=n[e].children;let r=0;for(let e=0;e<t.length;e+=1)"LI"===t[e].tagName&&(r+=1);const a=r+(r>1?" items":" item");n[e].insertAdjacentHTML("afterend",'<a href class="json-placeholder">'.concat(a,"</a>"))}else this._siblings(n[e],".json-placeholder",(e=>e.parentNode.removeChild(e)));e.stopPropagation(),e.preventDefault()}_siblings(e,t,n){const r=[];for(let n=0;n<e.parentNode.children.length;n+=1){const a=e.parentNode.children[n];a!==e&&"string"==typeof t&&a.matches(t)&&r.push(a)}if(n&&"function"==typeof n)for(let e=0;e<r.length;e+=1)n(r[e]);return r}json2html(e,t){let n="";if("string"==typeof e){const t=e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");this.isUrl(t)?n+='<a href="'.concat(t,'" class="json-string">').concat(t,"</a>"):n+='<span class="json-string">"'.concat(t,'"</span>')}else if("number"==typeof e)n+='<span class="json-literal">'.concat(e,"</span>");else if("boolean"==typeof e)n+='<span class="json-literal">'.concat(e,"</span>");else if(null===e)n+='<span class="json-literal">null</span>';else if(e instanceof Array)if(e.length>0){n+='[<ol class="json-array">';for(let r=0;r<e.length;r+=1)n+='<li data-key-type="array" data-key="'.concat(r,'">'),this.isCollapsable(e[r])&&(n+='<a href="#" class="json-toggle"></a>'),n+=this.json2html(e[r],t),r<e.length-1&&(n+=","),n+="</li>";n+="</ol>]"}else n+="[]";else if("object"===this._typeof(e)){let r=Object.keys(e).length;if(r>0){n+='{<ul class="json-dict">';for(const a in e)if(e.hasOwnProperty(a)){n+='<li data-key-type="object" data-key="'.concat(a,'">');const s=t.outputWithQuotes?'<span class="json-string">"'.concat(a,'"</span>'):a;this.isCollapsable(e[a])?n+="<a href='#' class=\"json-toggle\">".concat(s,"</a>"):n+=s,n+=": ".concat(this.json2html(e[a],t)),r-=1,r>0&&(n+=","),n+="</li>"}n+="</ul>}"}else n+="{}"}return n}isUrl(e){return/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#:.?+=&%@!\-/]))?/.test(e)}_typeof(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?this._typeof=function(e){return typeof e}:this._typeof=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},this._typeof(e)}isCollapsable(e){return e instanceof Object&&Object.keys(e).length>0}static get observedAttributes(){return["data"]}attributeChangedCallback(e,t,n){"data"===e&&(this.jsonTextarea.value=n,this.updateTree(n))}updateTree(e){try{this.data=JSON.parse(e),this.treeView.innerHTML="",this.treeView.appendChild(this.createTreeView(this.data,""))}catch(e){alert("Invalid JSON")}}createTreeView(e,t){const n=document.createElement("ul");if(n.classList.add("jp-ul"),Array.isArray(e))e.forEach(((e,r)=>{const a=document.createElement("li");a.classList.add("jp-li");const s=`${t}[${r}]`;a.appendChild(this.createItemView(s,e)),n.appendChild(a)}));else if("object"==typeof e&&null!==e)Object.keys(e).forEach((r=>{const a=document.createElement("li");a.classList.add("jp-li");const s=`${t}.${r}`;a.appendChild(this.createItemView(s,e[r])),n.appendChild(a)}));else{const r=document.createElement("li");r.classList.add("jp-li"),r.appendChild(this.createItemView(t,e)),n.appendChild(r)}return n}}customElements.get("fx-json-instance")||customElements.define("fx-json-instance",Nn);class Tn extends HTMLElement{static get properties(){return{fore:{type:Object,description:"The fx-fore element the devtools are attached to"},instances:{type:Array,description:"Instances of selected Fore element"},selector:{type:String,description:"optional selector to attach to a certain fx-fore element with given id"}}}constructor(){super(),this.attachShadow({mode:"open"}),Object.keys(this.constructor.properties).forEach((e=>{const t=this.constructor.properties[e],n=t.attribute||e,r=this.getAttribute(n)||t.default,a=t.type(r);this[e]=a})),this.isResizing=!1,this.lastY=0,this.defaultHeight="40vh",this.buttonByInstanceId=new Map;const e=e=>{this.fore=e,this.instances=[...this.fore.getModel().instances];const t=this.shadowRoot.querySelector(".instances header");t.textContent="Data ",this.instances.forEach((e=>{const n=document.createElement("button");n.setAttribute("type","button"),n.textContent=e.id,t.appendChild(n),this.buttonByInstanceId.set(e.id,n),n.addEventListener("click",(()=>this.selectInstance(e.id)))})),this.instances.length&&this.selectInstance(this.instances[0].id)},t=document.querySelector("fx-fore");t&&(t.inited?e(t):t.addEventListener("model-construct-done",(()=>e(t)))),window.document.addEventListener("log-active-element",(t=>{const n=t?t.detail?.target||t.target:window.event.srcElement,r=n.nodeType===Node.DOCUMENT_NODE?null:n.closest("fx-fore");r&&e(r);const a=this.instances.find((e=>"xml"===e.type&&e.instanceData.contains(n)));a&&this.selectInstance(a.id)}))}_getInstanceForTarget(e){this.instances.forEach((t=>"xml"===t.type&&t.instanceData.contains(e)||"json"===t.type?t:void 0))}selectInstance(e){const t=this.buttonByInstanceId.get(e);if(!t)return;if(t.classList.contains("selected-btn"))return;const n=this.shadowRoot.querySelector(".selected-btn");n&&n.classList.remove("selected-btn"),t.classList.add("selected-btn");const r=this.shadowRoot.querySelector(".instance-panel");r.innerHTML="",this.instances=[...this.fore.querySelectorAll("fx-instance")];const a=Array.from(this.instances).find((t=>t.id===e)),s=this._renderInstancePanel(a);r.append(s)}connectedCallback(){this.render()}_startResize(e){this.isResizing=!0,this.lastY=e.clientY}_resizePanel(e){if(!this.isResizing)return;const t=e.clientY-this.lastY;this.style.height=this.offsetHeight-t+"px",this.lastHeight=this.style.height,this.lastY=e.clientY}_stopResize(e){e.preventDefault(),e.stopPropagation(),this.isResizing=!1,document.body.style.height="inherit",document.body.style.width="inherit";const t=document.body.scrollHeight+this.offsetHeight;document.body.style.height=`${t}px`}render(){const e=`\n <section class="wrapper">\n <slot></slot>\n <details class="fx-devtools" open>\n <div class="resizer"></div>\n <summary>Fore Glass \n <div>\n <svg preserveAspectRatio="xMidYMid meet" focusable="true" style="width: 24px;height: 24px; margin-bottom:-1px;" width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg">\n <g role="button" id="find-in-page"><path d="M20 19.59V8l-6-6H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c.45 0 .85-.15 1.19-.4l-4.43-4.43c-.8.52-1.74.83-2.76.83-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5c0 1.02-.31 1.96-.83 2.75L20 19.59zM9 13c0 1.66 1.34 3 3 3s3-1.34 3-3-1.34-3-3-3-3 1.34-3 3z"></path></g>\n </svg>\n <button class="optionsBtn" id="optionsTrigger">&#9881;</button> \n </div>\n </summary>\n <section class="panels">\n <section class="log">\n <fx-action-log selector="${this.selector}"></fx-action-log>\n </section>\n <section class="dom">\n <fx-dom-inspector>\n <header slot="header">Document</header>\n </fx-dom-inspector>\n </section>\n <section class="instances">\n <header></header>\n <div class="instance-panel">\n </div>\n </section>\n <section id="options">\n <fx-log-settings></fx-log-settings>\n </section>\n </section>\n </details>\n </section>\n `;this.shadowRoot.innerHTML=`\n <style>\n \n @import '../../resources/fore.css';\n \n :host {\n display:block;\n position:fixed;\n bottom:0;\n left:0;\n width:100vw;\n height:var(--fx-devtools-height);\n font-style:inherit;\n font-family: 'Verdana' , 'Sans';\n font-size:1em;\n max-width:100vw;\n height:3em;\n }\n :host(.open){\n height:40vh;\n }\n \n fx-action-log{\n height:100%;\n }\n fx-dom-inspector{\n max-height:100%;\n height:100%;\n position:relative;\n }\n body {\n }\n details{\n height:100%;\n background:#ebf6ff;\n }\n .dom{\n width:45%;\n border-left:1px solid #999;\n position:relative\n }\n .dom fx-minimap{\n position:absolute;\n right:0;\n top:0;\n width:5rem;\n height:6rem;\n }\n header{\n padding:0.5rem;\n border-bottom:2px solid #ddd;\n font-size:1rem;\n }\n header button{\n margin:0 0.5em;\n border:thin solid #999;\n padding:0 0.5em;\n cursor:pointer;\n }\n header button:hover{\n background:white;\n }\n \n header button.selected-btn{\n background:steelblue;\n color:white;\n }\n .instances{\n width:35%;\n border-left:1px solid #999;\n }\n .instance-panel{\n height:100%;\n overflow:auto;\n }\n .panels{\n display:grid;\n grid-template-columns:20% 50% 30%;\n height:100%;\n width:100%;\n max-height:100%;\n border-top:thin solid #ddd;\n }\n .panels > section {\n min-height:20rem;\n/*\n background:#efefef;\n*/\n position:relative;\n display:inline-block;\n height:100%;\n width:auto;\n }\n #options{\n display:none;\n }\n #options.open{\n position:absolute;\n z-index:10;\n left:0;\n top:3em;\n height:100%;\n display:block;\n padding:0;\n background:rgba(255,255,255,0.95);\n width:100%;\n }\n .optionsBtn{\n font-size:2rem;\n }\n details[open] .optionsBtn{\n display:inline;\n }\n .resizer{\n width:100vw;\n height:6px;\n background:rgba(215,220,235,0.3);\n cursor: ns-resize;\n position:absolute;\n top:0;\n \n }\n summary{\n height:3rem;\n padding:0 1em;\n border-bottom:2px solid #ddd;\n display:flex;\n justify-content:space-between;\n align-items:center;\n color:rgba(0,0,0,0.7);\n background: rgba(235, 255, 255, 0.2);\n box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);\n backdrop-filter: blur(5px);\n -webkit-backdrop-filter: blur(5px);\n border: 1px solid rgba(255, 255, 255, 0.3);\n \n color:white;\n font-weight:300;\n background: rgb(119,119,119);\n background: linear-gradient(90deg, rgba(0,85,159,0.75) 0%, rgba(56,154,252,0.5) 50%, rgba(255,255,255,0.1) 100%);\n\n }\n summary button{\n padding:0;\n border:0;\n background:transparent;\n }\n .wrapper{\n height:100%;\n }\n .vertDevider{\n background:#ddd;\n width:4px;\n height:100%;\n cursor: ew-resize;\n }\n \n </style>\n ${e}\n `,this.resizer=this.shadowRoot.querySelector(".resizer"),this.resizer.addEventListener("mousedown",this._startResize.bind(this)),document.addEventListener("mousemove",this._resizePanel.bind(this)),document.addEventListener("mouseup",this._stopResize.bind(this));const t=this.shadowRoot.querySelector("#optionsTrigger");t.addEventListener("click",(()=>{const e=this.shadowRoot.querySelector("#options");e.classList.toggle("open"),e.classList.contains("open")?t.style.background="lightsteelblue":t.style.background="transparent"}));this.shadowRoot.querySelector(".fx-devtools").addEventListener("click",(e=>{"DIV"===e.target.nodeName&&e.target.classList.contains("resizer")||(e.target.parentNode.open?(this.removeAttribute("open"),this.lastHeight=this.style.height,this.style.height="3em"):(this.setAttribute("open",""),this.style.height=this.lastHeight?this.lastHeight:"40vh"))})),this.classList.add("open")}_handleOpen(e){document.body.style.height=""}_renderInstancePanel(e){if("xml"===e.type){const t=document.createElement("fx-dom-inspector");return t.setInstance(e),t.setAttribute("instance",e.id),t}if("json"===e.type){const t=document.createElement("fx-json-instance");t.setAttribute("instance",e.id);const n=document.createElement("span");return n.setAttribute("slot","header"),t.append(n),t}}}customElements.get("fx-devtools")||customElements.define("fx-devtools",Tn);class Bn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.src=""}connectedCallback(){this.src=this.getAttribute("src");const e=`\n <fx-fore src="${this.src}">\n </fx-fore>\n <slot id="default"></slot>\n `;this.shadowRoot.innerHTML=`\n <style>\n \n :host {\n display:block;\n }\n \n </style>\n ${e}\n `;this.shadowRoot.querySelector("#default").addEventListener("slotchange",(async e=>{const t=e.target.assignedElements().filter((e=>"LINK"===e.nodeName.toUpperCase()));if(!t)return;const n=[...document.styleSheets].map((e=>{if(t.find((t=>t.href===e.href)))try{return[...e.cssRules].map((e=>e.cssText)).join("")}catch(e){}})).filter(Boolean).join("\n"),r=new CSSStyleSheet;r.replaceSync(n),this.shadowRoot.adoptedStyleSheets=[r]}));const t=this.querySelector("fx-action");if(t){const e=t.cloneNode(!0);this.removeChild(t);this.shadowRoot.querySelector("fx-fore").appendChild(e)}}}async function In(e){return new Promise((t=>setTimeout((()=>t()),e)))}customElements.get("fore-component")||customElements.define("fore-component",Bn);class Cn extends Mt{static get properties(){return{...super.properties,defaultAction:{type:String},delay:{type:Number},detail:{type:Object},event:{type:Object},handler:{type:Object},ifExpr:{type:String},iterateExpr:{type:String},needsUpdate:{type:Boolean},observer:{type:Object},phase:{type:String},propagate:{type:String},target:{type:String},whileExpr:{type:String}}}constructor(){super(),this.detail={},this.needsUpdate=!1}disconnectedCallback(){}connectedCallback(){this.setAttribute("inert","true"),this.style.display="none",this.propagate=this.hasAttribute("propagate")?this.getAttribute("propagate"):"continue",this.repeatContext=void 0,this.hasAttribute("event")&&(this.event=this.getAttribute("event")),this.hasAttribute("defaultAction")?this.defaultAction=this.getAttribute("defaultAction"):this.defaultAction="perform",this.hasAttribute("phase")?this.phase=this.getAttribute("phase"):this.phase="default",this.ifExpr=this.hasAttribute("if")?this.getAttribute("if"):null,this.whileExpr=this.hasAttribute("while")?this.getAttribute("while"):null,this.delay=this.hasAttribute("delay")?Number(this.getAttribute("delay")):0,this.iterateExpr=this.hasAttribute("iterate")?this.getAttribute("iterate"):null,this._addUpdateListener()}_addUpdateListener(){if(this.target=this.getAttribute("target"),this.target)if("#window"===this.target)window.addEventListener(this.event,(e=>this.execute(e)),{capture:"capture"===this.phase});else if("#document"===this.target)document.addEventListener(this.event,(e=>this.execute(e)),{capture:"capture"===this.phase});else{if(this.targetElement=ht(this.target,this),!this.targetElement)return;this?.targetElement.addEventListener(this.event,(e=>this.execute(e)),{capture:"capture"===this.phase})}else this.targetElement=this.parentNode,this.targetElement.addEventListener(this.event,(e=>this.execute(e)),{capture:"capture"===this.phase})}async performSafe(){try{return await this.perform(),!0}catch(e){return await Ft.dispatch(this,"error",{origin:this,message:"Action execution failed",expr:nt.getDocPath(this),level:"Error"}),!1}}async execute(e){if(!this.getModel().modelConstructed)return;if(e&&e.target.nodeType!==Node.DOCUMENT_NODE&&e.target!==window&&e.target.closest("fx-fore")&&e.target.closest("fx-fore")!==this.closest("fx-fore"))return;"stop"===this.propagate&&e.stopPropagation(),"cancel"===this.defaultAction&&e.preventDefault();let t=()=>{};e&&e.listenerPromises&&e.listenerPromises.push(new Promise((e=>{t=e}))),null===qt.outermostHandler&&(qt.outermostHandler=this,this.dispatchEvent(new CustomEvent("outermost-action-start",{composed:!0,bubbles:!0,cancelable:!0,detail:{cause:e?.type}}))),e&&(this.currentEvent=e),this.needsUpdate=!1;try{this.evalInContext()}catch(e){}if(this.targetElement&&this.targetElement.nodeset&&(this.nodeset=this.targetElement.nodeset),this.iterateExpr)return await this.handleIterateExpr(),void this._finalizePerform(t);if(!this.ifExpr||xt(this.ifExpr,Ot(this),this)){if(this.whileExpr)return await this.handleWhileExpr(),void this._finalizePerform(t);if(this.delay&&(await In(this.delay),!nt.contains(this.getOwnerForm(),this)))return this.actionPerformed(),void t();await this.performSafe(),this._finalizePerform(t)}else this._finalizePerform(t)}async handleWhileExpr(){await In(this.delay||0),nt.contains(this.getOwnerForm(),this)&&xt(this.whileExpr,Ot(this),this)&&this.performSafe()&&(this.delay?this.handleWhileExpr():await this.handleWhileExpr())}async handleIterateExpr(){try{const e=wt(this.iterateExpr,Ot(this),this);if(0===e.length)return;if(!nt.contains(this.getOwnerForm(),this))return;for(const t of e)if(this.delay&&await In(this.delay||0),this.currentContext=t,!await this.performSafe())return}finally{this.currentContext=null}}_finalizePerform(e){this.currentEvent=null,this.actionPerformed(),qt.outermostHandler===this&&(qt.outermostHandler=null,this.dispatchEvent(new CustomEvent("outermost-action-end",{composed:!0,bubbles:!0,cancelable:!0}))),e()}async perform(){(this.isBound()||"FX-ACTION"===this.nodeName)&&this.evalInContext(),this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}}))}actionPerformed(){const e=this.getModel();e&&e.inited&&(qt.outermostHandler&&!nt.contains(qt.outermostHandler.ownerDocument,qt.outermostHandler)&&(qt.outermostHandler=null),!this.needsUpdate||qt.outermostHandler!==this&&qt.outermostHandler?this.needsUpdate&&(qt.outermostHandler.needsUpdate=!0):(e.recalculate(),e.revalidate(),e.parentNode.refresh(!0),this.dispatchActionPerformed()))}dispatchActionPerformed(){Ft.dispatch(this,"action-performed",{})}}Cn.dataChanged=!1,customElements.get("abstract-action")||window.customElements.define("abstract-action",Cn);class Sn extends Cn{static get properties(){return{...Cn.properties,ref:{type:String},repeat:{type:String},clear:{type:String}}}constructor(){super(),this.repeat=""}connectedCallback(){super.connectedCallback(),this.ref=this.getAttribute("ref"),this.repeat=this.getAttribute("repeat")}async perform(){super.perform(),this._dataFromTemplate(),this.needsUpdate=!0}actionPerformed(){super.actionPerformed(),this._dispatch()}_dataFromTemplate(){const e=this.getInScopeContext(),t=this.getOwnerForm().querySelector(`#${this.repeat}`),n=t.shadowRoot.querySelector("template"),r=e.ownerDocument.createElement(t.ref),a=this._generateInstance(n.content,r);e.appendChild(a)}_dispatch(){const e=ht(this.repeat,this);Ft.dispatch(e,"index-changed",{index:e.nodeset.length})}_clear(e){let t=e.firstChild;const n=e.attributes;for(let e=0;e<n.length;e+=1)n[e].value="";for(;t;)1===t.nodeType&&t.hasAttributes()&&(t.textContent=""),this._clear(t),t=t.nextSibling}_generateInstance(e,t){if(1===e.nodeType&&e.hasAttribute("ref")){const n=e.getAttribute("ref");let r;"."===n||(n.startsWith("@")?t.setAttribute(n.substring(1),""):(r=document.createElement(n),t.appendChild(r),0===e.children.length&&(r.textContent=e.textContent)))}if(e.hasChildNodes()){const n=e.children;for(let e=0;e<n.length;e+=1)this._generateInstance(n[e],t)}return t}getInstanceId(){return this.ref.startsWith("instance(")?"not implemented":"default"}}customElements.get("fx-append")||window.customElements.define("fx-append",Sn);class On extends Cn{static get properties(){return{...super.properties,ref:{type:String}}}async perform(){const e=Ot(this.getAttributeNode("ref")||this,this.ref);this.nodeset=bt(this.ref,e,this);const t=nt.resolveInstance(this,this.ref),n=this.getModel().getInstance(t),r=Ft.getDomNodeIndexString(this.nodeset),a=this.nodeset;let s;if(this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event,path:r}})),Array.isArray(a)){if(0===a.length)return;s=a[0].parentNode,a.forEach((e=>{this._deleteNode(s,e)}))}else s=a.parentNode,this._deleteNode(s,a);await Ft.dispatch(n,"deleted",{ref:r,deletedNodes:a}),this.needsUpdate=!0}_deleteNode(e,t){if(e.nodeType===Node.DOCUMENT_NODE)return;if(t.nodeType===Node.DOCUMENT_NODE)return;if(t.nodeType===Node.DOCUMENT_FRAGMENT_NODE)return;if(null===t.parentNode)return;this.getModelItem().readonly||e.removeChild(t)}actionPerformed(){this.getModel().rebuild(),super.actionPerformed()}}customElements.get("fx-delete")||window.customElements.define("fx-delete",On);class Fn extends Cn{connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.control=this.hasAttribute("control")?this.getAttribute("control"):null}async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}}));const e=`#${this.control}`;let t=document.querySelector(e);if(!t)return void Ft.dispatch(this,"error",{origin:this,message:`Instance '${this.control}' not found`,level:"Error"});const n=t.closest("fx-repeatitem");n&&(t=n.querySelector(e),this._focus(t));const r=t.closest("fx-repeatitem, .fx-repeatitem");if(r){t=r.parentNode.querySelector(`[repeat-index] ${e}`)}this._focus(t),this.hasAttribute("select")&&this._select(t)}_focus(e){e&&"function"==typeof e.getWidget&&e.getWidget().focus(),e&&e.nodeType===Node.ELEMENT_NODE&&e.click()}_select(e){e&&e.getWidget().select()}}customElements.get("fx-setfocus")||window.customElements.define("fx-setfocus",Fn);class Dn extends Cn{static get properties(){return{...super.properties,at:{type:Number},position:{type:Number},origin:{type:Object},keepValues:{type:Boolean}}}constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){super.connectedCallback&&super.connectedCallback();this.shadowRoot.innerHTML="\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n <slot></slot>\n ",this.at=Number(this.hasAttribute("at")?this.getAttribute("at"):0),this.position=this.hasAttribute("position")?this.getAttribute("position"):"after",this.origin=this.hasAttribute("origin")?this.getAttribute("origin"):null,this.keepValues=!!this.hasAttribute("keep-values")}_getOriginSequence(e,t){let n;if(this.origin){let t;try{t=vt(this.origin,e,this),Array.isArray(t)&&0===t.length&&(n=null),n=t}catch(e){}}else t&&(n=t,n&&!this.keepValues&&this._clear(n));return n}_cloneOriginSequence(e,t){let n;if(this.origin){let t;try{t=vt(this.origin,e,this),Array.isArray(t)&&0===t.length&&(n=null),n=t.cloneNode(!0)}catch(e){}}else t&&(n=this._cloneTargetSequence(t),n&&!this.keepValues&&this._clear(n));return n}_getInsertIndex(e,t){return 0===t.length?null:this.hasAttribute("at")?Et(this.getAttribute("at"),e,this):t.length}async perform(){let e,t,n=[];const r=Ot(this);this.hasAttribute("context")&&([t]=bt(this.getAttribute("context"),r,this.getOwnerForm()),e=r),this.hasAttribute("ref")&&(e||(e=Ot(this.getAttributeNode("ref"),this.ref)),n=bt(this.ref,e,this));const a=this._cloneOriginSequence(e,n);if(!a)return;let s,o;if(0===n.length)t?(s=t,t.appendChild(a),o=1):(s=e,e.appendChild(a),o=1);else{if(this.hasAttribute("at")?(o=Et(this.getAttribute("at"),e,this),s=n[o-1]):(o=n.length,s=n[n.length-1]),!s){o=1,s=n;o=Et("count(preceding::*)",n,this.getOwnerForm())+1}this.position&&"before"===this.position&&s.parentNode.insertBefore(a,s),this.position&&"after"===this.position&&(o+=1,this.hasAttribute("context")&&this.hasAttribute("ref")?e.append(a):this.hasAttribute("context")?(o=1,s.prepend(a)):s.insertAdjacentElement("afterend",a))}const i=nt.resolveInstance(this,this.ref),l=this.getModel().getInstance(i),c=nt.getPath(s.parentNode,i),u=Ft.getDomNodeIndexString(a);return this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event,path:u}})),Ft.dispatch(l,"insert",{"inserted-nodes":a,"insert-location-node":s,position:this.position}),document.dispatchEvent(new CustomEvent("index-changed",{composed:!0,bubbles:!0,detail:{insertedNodes:a,index:o}})),this.needsUpdate=!0,[c]}_cloneTargetSequence(e){return Array.isArray(e)&&0!==e.length?e[e.length-1].cloneNode(!0):!Array.isArray(e)&&e?e.cloneNode(!0):null}actionPerformed(e){this.getModel().rebuild(),super.actionPerformed()}_clear(e){const t=e.attributes;for(let e=0;e<t.length;e+=1)t[e].value="";e.textContent&&(e.textContent="");let n=e.firstChild;for(;n;)1===n.nodeType&&n.hasAttributes()&&(n.textContent=""),this._clear(n),n=n.nextSibling}}customElements.get("fx-insert")||window.customElements.define("fx-insert",Dn);class kn extends Cn{constructor(){super(),this.attachShadow({mode:"open"})}static get properties(){return{...Cn.properties,modelItem:void 0,messageTextContent:{type:String,get value(){return"here!"}}}}connectedCallback(){super.connectedCallback(),this.event=this.hasAttribute("event")?this.getAttribute("event"):"",this.level=this.hasAttribute("level")?this.getAttribute("level"):"ephemeral",this.message="",this.messageTextContent=this.textContent;this.shadowRoot.innerHTML=`\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n ${this.renderHTML()}\n `}renderHTML(){return"\n <slot></slot>\n "}async perform(){super.perform(),this.hasAttribute("value")?this.message=this._getValue():(this.getOwnerForm().evaluateTemplateExpression(this.messageTextContent,this.firstChild),this.message=this.textContent),this.dispatchEvent(new CustomEvent("message",{composed:!1,bubbles:!0,detail:{level:this.level,message:this.message}}))}_getValue(){if(this.hasAttribute("value")){const e=this.getAttribute("value");try{return At(e,Ot(this,e),this)}catch(e){Ft.dispatch(this,"error",{message:e})}}return this.textContent?this.textContent:null}}customElements.get("fx-message")||window.customElements.define("fx-message",kn);class Rn extends Cn{static get properties(){return{...super.properties,ref:{type:String},valueAttr:{type:String}}}constructor(){super(),this.ref="",this.valueAttr=""}connectedCallback(){if(super.connectedCallback&&super.connectedCallback(),!this.hasAttribute("ref"))throw new Error('fx-setvalue must specify a "ref" attribute');this.ref=this.getAttribute("ref"),this.valueAttr=this.getAttribute("value")}async perform(){super.perform();let{value:e}=this;null!==this.valueAttr?[e]=wt(this.valueAttr,this.nodeset,this,this.detail):e=""!==this.textContent?this.textContent:"",e?.nodeType&&e.nodeType===Node.ATTRIBUTE_NODE&&(e=e.nodeValue);const t=this.getModelItem();this.setValue(t,e)}dispatchExecute(){}setValue(e,t){const n=e;if(n&&n.value!==t){const r=Ft.getDomNodeIndexString(e.node),a=this.event,s=this;this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:s,event:a,value:t,path:r}})),t?.nodeType?(t.nodeType===Node.ELEMENT_NODE&&(n.value=t.textContent),t.nodeType===Node.ATTRIBUTE_NODE&&(n.value=t.getValue())):n.value=t,this.getModel().changed.push(e),this.needsUpdate=!0}}}customElements.get("fx-setvalue")||window.customElements.define("fx-setvalue",Rn);class Mn extends Cn{constructor(){super(),this.value="",this.url=null,this.target=null}connectedCallback(){super.connectedCallback(),this.submission=this.getAttribute("submission"),this.url=this.hasAttribute("url")?this.getAttribute("url"):null,this.target=this.hasAttribute("target")?this.getAttribute("target"):null,this.connection=this.hasAttribute("connection")?this.getAttribute("connection"):null}async perform(){if(super.perform(),this.getOwnerForm().classList.remove("submit-validation-failed"),this.connection){return null===this.getModel().querySelector(`#${this.connection}`)?void this.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,cancelable:!0,detail:{id:this.id,origin:this,message:`<fx-connection id="${this.connection}"> not found`,expr:nt.getDocPath(this),level:"Error"}})):void this._emitToChannel()}const e=this.getModel().querySelector(`#${this.submission}`);if(null!==e){if(this.url){const t=this.evaluateAttributeTemplateExpression(this.url,this);e.parameters.set("url",t)}if(this.target){const t=this.evaluateAttributeTemplateExpression(this.target,this);e.parameters.set("target",t)}await e.submit()}else this.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,cancelable:!0,detail:{id:this.id,origin:this,message:`<fx-submission id="${this.submission}"> not found`,expr:nt.getDocPath(this),level:"Error"}}))}_emitToChannel(){const e=this.getModel().querySelector(`#${this.connection}`);null!==e&&e.send()}}customElements.get("fx-send")||window.customElements.define("fx-send",Mn);class Un extends Cn{connectedCallback(){super.connectedCallback(),this.hasAttribute("case")&&(this.case=this.getAttribute("case"))}async perform(){if(super.perform(),this.case){const e=this.getOwnerForm().querySelector(`#${this.case}`);if(!e)return void Ft.dispatch(this,"error",{message:`fx-case id not found: ${this.case}`});e.parentNode.toggle(e)}this.needsUpdate=!0}}customElements.get("fx-toggle")||window.customElements.define("fx-toggle",Un);class Gn extends Cn{static get properties(){return{...super.properties,name:{type:String},targetid:{type:String},details:{type:String}}}constructor(){super(),this.name=null,this.targetid=null,this.details=null,this.attachShadow({mode:"open"})}connectedCallback(){if(super.connectedCallback(),this.name=this.getAttribute("name"),!this.name)throw new Error("no event specified for dispatch",this);this.targetid=this.hasAttribute("targetid")?this.getAttribute("targetid"):null}async perform(){super.perform();const e=this.querySelectorAll("fx-property"),t={};if(Array.from(e).forEach((e=>{const n=e.getAttribute("name"),r=e.getAttribute("value"),a=e.getAttribute("expr");if(a){if(r)throw new Error('if "expr" is given there must not be a "value" attribute');const[e]=wt(a,this.getInScopeContext(),this);let s=null;if(e.nodeName){s=(new XMLSerializer).serializeToString(e)}t[n]=s||e}r&&(t[n]=r)})),this.targetid){let e=ht(this.targetid,this.parentNode,null);if(e||(e=document.getElementById(this.targetid)),!e)throw new Error(`targetid ${this.targetid} does not exist in document`);e.dispatchEvent(new CustomEvent(this.name,{composed:!0,bubbles:!0,detail:t}))}else document.dispatchEvent(new CustomEvent(this.name,{composed:!0,bubbles:!0,detail:t}))}}customElements.get("fx-dispatch")||window.customElements.define("fx-dispatch",Gn);class Ln extends Cn{async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}})),this.getModel().updateModel()}}customElements.get("fx-update")||window.customElements.define("fx-update",Ln);class $n extends Cn{async perform(){if(this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}})),this.hasAttribute("self")){const e=nt.getClosest("fx-control",this);if(e)return void e.refresh()}if(this.hasAttribute("force"))this.getOwnerForm().forceRefresh();else if(this.hasAttribute("control")){const e=ht(this.getAttribute("control"),this);e&&Ft.isUiElement(e.nodeName)&&"function"==typeof e.refresh&&e.refresh()}else this.getOwnerForm().refresh()}}customElements.get("fx-refresh")||window.customElements.define("fx-refresh",$n);class Pn extends Cn{static get properties(){return{...super.properties,with:{type:String},replaceNode:Object}}constructor(){super(),this.with=""}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.with=this.getAttribute("with")}async perform(){super.perform();const e=vt(this.with,this.nodeset,this);e&&this.replace(this.nodeset,e)}actionPerformed(){this.getModel().rebuild(),super.actionPerformed()}replace(e,t){if(e&&t&&e.nodeName&&t.nodeName){if(e.nodeType===Node.ATTRIBUTE_NODE){const{ownerElement:n}=e;n.setAttribute(t.nodeName,t.textContent),n.removeAttribute(e.nodeName)}else if(e.nodeType===Node.ELEMENT_NODE){const n=t.cloneNode(!0);e.replaceWith(n)}this.needsUpdate=!0}}}customElements.get("fx-replace")||window.customElements.define("fx-replace",Pn);class _n extends Cn{connectedCallback(){super.connectedCallback&&super.connectedCallback()}async perform(){super.perform();const e=new CustomEvent("return",{composed:!0,bubbles:!0,detail:{nodeset:this.nodeset}});this.getOwnerForm().dispatchEvent(e)}}customElements.get("fx-return")||window.customElements.define("fx-return",_n);class Hn extends Cn{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.src=this.hasAttribute("src")?this.getAttribute("src"):null;this.shadowRoot.innerHTML="\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n <slot></slot>\n "}async perform(){super.perform();const{children:e}=this;if(this.src){this.innerHTML="";const e=document.createElement("script");e.src=this.src,this.appendChild(e)}else{for(const t of e){if("fx-var"===t.localName)continue;const e=t;e.detail=this.detail,await e.execute()}this.dispatchActionPerformed(),this.needsUpdate=!0}}}customElements.get("fx-action")||window.customElements.define("fx-action",Hn);class jn extends Hn{static get properties(){return{...Hn.properties,message:{type:String}}}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.message=this.hasAttribute("message")?this.getAttribute("message"):null}async perform(){window.confirm(this.message)&&await super.perform()}}customElements.get("fx-confirm")||window.customElements.define("fx-confirm",jn);class Xn extends Hn{connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.dialog=this.getAttribute("dialog"),this.dialog||Ft.dispatch(this,"error",{message:"dialog does not exist"})}async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}}));const e=ht(this.dialog,this);e.open(),Ft.dispatch(e,"dialog-shown",{})}}customElements.get("fx-show")||window.customElements.define("fx-show",Xn);class qn extends Cn{static get properties(){return{...super.properties,dialog:{type:String}}}connectedCallback(){super.connectedCallback(),this.dialog=this.getAttribute("dialog"),this.dialog||Ft.dispatch(this,"error",{message:"dialog does not exist"})}async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}}));const e=ht(this.dialog,this);e.hide(),Ft.dispatch(e,"dialog-hidden",{})}}customElements.get("fx-hide")||window.customElements.define("fx-hide",qn);class Vn extends Cn{connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.addEventListener("reload",(()=>{window.location.reload()}),{once:!0})}async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}})),Ft.dispatch(this,"reload",{})}}customElements.get("fx-reload")||window.customElements.define("fx-reload",Vn);class Yn extends Cn{static get properties(){return{...super.properties,instance:{type:String}}}connectedCallback(){super.connectedCallback(),this.instance=this.getAttribute("instance"),this.instance||Ft.dispatch(this,"error",{message:"instance does not exist"})}async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}}));this.getModel().getInstance(this.instance).reset(),this.needsUpdate=!0}}customElements.get("fx-reset")||window.customElements.define("fx-reset",Yn);class zn extends Cn{static get properties(){return{...super.properties,attachTo:{type:String},url:{type:String}}}constructor(){super(),this.attachShadow({mode:"open"}),this.url=""}connectedCallback(){super.connectedCallback(),this.attachTo=this.hasAttribute("attach-to")?this.getAttribute("attach-to"):"_self",this.awaitEvent=this.hasAttribute("await")?this.getAttribute("await"):"",this.url=this.hasAttribute("url")?this.getAttribute("url"):"";this.shadowRoot.innerHTML=`\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n ${this.renderHTML()}`}disconnectedCallback(){this.targetElement.removeEventListener(this.event,(e=>this.execute(e)))}renderHTML(){return"\n <slot></slot>\n "}async perform(){await super.perform();const e=this.querySelector("template");if(e){const t=e.content.cloneNode(!0),n=document.importNode(t,!0);if(this.attachTo.startsWith("#")){const e=ht(this.attachTo.substring(1),this);for(;e.firstChild;)e.removeChild(e.firstChild);if(this.awaitEvent){let t;const r=new Promise((e=>{t=e})),a=()=>{t(),e.removeEventListener(this.awaitEvent,a)};return e.appendChild(n),e.addEventListener(this.awaitEvent,a),await r,this.needsUpdate=!0,void Ft.dispatch(this,"loaded",{attachPoint:this.attachTo,content:n})}e.appendChild(n),this.needsUpdate=!0}return void Ft.dispatch(this,"loaded",{})}if(!this.url)return void this.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,cancelable:!0,detail:{origin:this,message:"neither template element nor Url was specified.",level:"Error"}}));const t=this.evaluateAttributeTemplateExpression(this.url,this);"_blank"===this.attachTo&&window.open(this.url),"_self"===this.attachTo&&(window.location.href=this.url);try{const e=await fetch(t,{method:"GET",mode:"cors",credentials:"same-origin",headers:{"Content-Type":"text/html"}}),n=await e.text();this.attachTo||(this.innerHtml=n),this._attachToElement(n),Ft.dispatch(this,"loaded",{url:this.url})}catch(e){throw new Error(`failed loading data ${e}`)}}_attachToElement(e){let t;if(e.nodeType)t=e;else try{t=(new DOMParser).parseFromString(e,"text/html").firstElementChild}catch(e){Ft.dispatch(this,"error",{message:"parsing of content as HTML failed"})}if(this.attachTo.startsWith("_")||this.attachTo.startsWith("#")||Ft.dispatch(this,"error",{message:'valid values for "attach-to" start with "_" or "#"'}),this.attachTo.startsWith("#")){const e=ht(this.attachTo.substring(1),this);if(e.innerHTML="",t.querySelector("fx-fore"))return void e.append(t.querySelector("fx-fore").cloneNode(!0));const n=t.querySelector("body").cloneNode(!0);e.appendChild(n.firstElementChild)}}_evaluateUrlExpression(){const e=this.getAttribute("url");if(!e)throw new Error("url not specified");return e.replace(/{[^}]*}/g,(e=>{if("{}"===e)return e;const t=e.substring(1,e.length-1),n=Ot(this,t);if(!n)return e;const r=nt.getInstanceId(t);r?this.getModel().getInstance(r):this.getModel().getDefaultInstance();try{return At(t,n,this,null)}catch(t){return e}}))}}customElements.get("fx-load")||window.customElements.define("fx-load",zn);class Jn extends Cn{static get properties(){return{...super.properties,ref:{type:String},valueAttr:{type:String},value:{type:Boolean}}}constructor(){super(),this.ref="",this.valueAttr="",this.value=!1}connectedCallback(){if(super.connectedCallback&&super.connectedCallback(),!this.hasAttribute("ref"))throw new Error('fx-togglealue must specify a "ref" attribute');this.ref=this.getAttribute("ref")}async perform(){super.perform();const e=this.getModelItem();"true"===e.value?e.node.textContent="false":e.node.textContent="true",this.needsUpdate=!0}}customElements.get("fx-toggleboolean")||window.customElements.define("fx-toggleboolean",Jn);class Qn extends Cn{static get properties(){return{...super.properties,action:{type:String},fn:{type:String}}}constructor(){super(),this.action="",this.fn=""}connectedCallback(){if(super.connectedCallback&&super.connectedCallback(),this.hasAttribute("action"))this.action=this.getAttribute("action");else{if(!this.hasAttribute("function"))throw new Error('fx-call must specify an "action" or "function" attribute');this.fn=this.getAttribute("function")}}async perform(){super.perform(),this.action&&await this._callAction(),this.fn&&this._callFunction()}async _callAction(){const e=document.querySelector(`#${this.action}`);e?await e.perform():Ft.dispatch(this,"error",{origin:this,message:`Action '${this.action}' not found`,expr:nt.getDocPath(this),level:"Error"})}_callFunction(){const e=Ot(this,"instance()");wt(this.fn,e,this)}}customElements.get("fx-call")||window.customElements.define("fx-call",Qn);class Kn extends Cn{static get properties(){return{...super.properties,ref:{type:String},attrName:{type:String},attrValue:{type:String}}}constructor(){super(),this.ref="",this.attrName="",this.attrValue=""}connectedCallback(){if(super.connectedCallback&&super.connectedCallback(),!this.hasAttribute("ref"))throw new Error('fx-setvalue must specify a "ref" attribute');this.ref=this.getAttribute("ref"),this.attrName=this.hasAttribute("name")?this.getAttribute("name"):null,this.attrValue=this.hasAttribute("value")?this.getAttribute("value"):"",this.attrName||Ft.dispatch("this","error",{message:"name or value not specified"})}async perform(){super.perform();const e=this.getModelItem();e.node.nodeType===Node.ELEMENT_NODE?(e.node.setAttribute(this.attrName,this.attrValue),this.needsUpdate=!0):Ft.dispatch("this","error",{message:"referenced item is not an element"})}}customElements.get("fx-setattribute")||window.customElements.define("fx-setattribute",Kn);class Wn extends Hn{connectedCallback(){super.connectedCallback(),"FX-MODEL"===this.parentNode.nodeName?this.parentNode.addEventListener("model-construct-done",(e=>{super.perform()})):Ft.dispatch(this,"error",{message:"parent is not a model"})}}customElements.get("fx-construct-done")||window.customElements.define("fx-construct-done",Wn);class Zn extends Cn{constructor(){super()}async perform(){this.getOwnerForm().markAsClean()}}function er(e,t){e.signature;const n=e.type??"text/xpath",r=e.signature.match(/(?:(?<prefix>[a-zA-Z_\-][a-zA-Z0-9_\-]*):)?(?<localName>[a-zA-Z_\-][a-zA-Z0-9_\-]*\s*)\((?<params>(?:[^()]*|\([^()]*\))*)\)\s*(?:as\s+(?<returnType>.*))?/);if(!r)throw new Error(`Function signature ${e.signature} could not be parsed`);const{prefix:a,localName:s,params:o,returnType:i}=r.groups,l="local"!==a&&a?`${a}:${s}`:{namespaceURI:"http://www.w3.org/2005/xquery-local-functions",localName:s};a||lt.push(s);const c=o?o.split(",").map((e=>{const t=e.match(/(?<variableName>\$[^\s]+)(?:\sas\s(?<varType>[^\s]+))/);if(!t)throw new Error(`Param ${e} could not be parsed`);const{variableName:n,varType:r}=t.groups;return{variableName:n,variableType:r||"item()*"}})):[];switch(n){case"text/javascript":{const n=new Function("_domFacade",...c.map((e=>e.variableName)),"form",e.functionBody);Ze(l,c.map((e=>e.variableType)),i||"item()*",((...e)=>n.apply(t.getInScopeContext(),[...e,t.getOwnerForm()])));break}case"text/xquf":case"text/xquery":case"text/xpath":{const r=c.map((e=>He(e.variableType))),a="text/xpath"===n?"XPath3.1":"text/xquery"===n?"XQuery3.1":"XQueryUpdate3.1",s=(n,...s)=>wt(e.functionBody,t.getInScopeContext(),t.getOwnerForm(),c.reduce(((e,t,a)=>(e[t.variableName.replace("$","")]=r[a](s[a],n),e)),{}),{language:a});Ze(l,c.map((e=>e.variableType)),i||"item()*",s);break}default:throw new Error(`Unexpected mimetype ${n} for function`)}}customElements.get("fx-unmodified")||window.customElements.define("fx-unmodified",Zn);class tr extends Mt{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.style.display="none",this.signature=this.hasAttribute("signature")?this.getAttribute("signature"):null,this.type=this.hasAttribute("type")?this.getAttribute("type"):null,this.shadowRoot.innerHTML="<slot></slot>",this.override=this.hasAttribute("override")?this.getAttribute("override"):"true",this.functionBody=this.innerText,er(this,this)}}customElements.get("fx-function")||customElements.define("fx-function",tr);class nr extends Mt{constructor(){super(),this._resolve=null,this.readyPromise=new Promise((e=>this._resolveLoading=e))}async connectedCallback(){this.style.display="none";const e=this.getAttribute("src"),t=await fetch(e);t.ok;const n=await t.text(),r=(new DOMParser).parseFromString(n,"text/html"),a=Array.from(r.querySelectorAll("fx-function"));for(const e of a){er({type:e.getAttribute("type"),signature:e.getAttribute("signature"),functionBody:e.innerText},this)}this._resolveLoading(void 0)}}customElements.get("fx-functionlib")||customElements.define("fx-functionlib",nr);
9
9
  //# sourceMappingURL=fore.js.map