diff --git a/README.md b/README.md index b06de2b5..c5dbfa84 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ To join the discussion relating to using revIgniter subscribe and review archive ### Meta -- Version: 2.4.4 +- Version: 2.4.5 - Web Site: - User Guide: - Author: [Ralf Bitter](mailto:rabit@revigniter.com) diff --git a/assets/js/ASYNergy/asynergy.js b/assets/js/ASYNergy/asynergy.js index d5130f13..ac2b8703 100644 --- a/assets/js/ASYNergy/asynergy.js +++ b/assets/js/ASYNergy/asynergy.js @@ -1,4 +1,4 @@ -var _asynergy=function(){"use strict";function e(t,s){if(!1===s(t))return;let a=t.firstElementChild;for(;a;)e(a,s),a=a.nextElementSibling}function t(e,t,s){var a;return function(){var i=this,n=arguments,l=function(){a=null,s||e.apply(i,n)},r=s&&!a;clearTimeout(a),a=setTimeout(l,t),r&&e.apply(i,n)}}function s(e){return new a(e)}class a{constructor(e){this.el=e,this.directives=this.extractTypeModifiersAndValue()}all(){return this.directives}has(e){return this.directives.map(e=>e.type).includes(e)}missing(e){return!this.has(e)}get(e){return this.directives.find(t=>t.type===e)}extractTypeModifiersAndValue(){return Array.from(this.el.getAttributeNames().filter(e=>e.match(new RegExp("asyn:"))).map(e=>{const[t,...s]=e.replace(new RegExp("asyn:"),"").split(".");return new i(t,s,e,this.el)}))}}class i{constructor(e,t,s,a){this.type=e,this.modifiers=t,this.fullName=s,this.el=a,this.eventContext,this.lcFunc=null,this.emitEvent=!1}setEventContext(e){this.eventContext=e}get isEmitEvent(){return emitEvent}set isEmitEvent(e){"boolean"==typeof e&&(this.emitEvent=e)}get value(){return this.el.getAttribute(this.fullName)}get lcFunction(){if("asyn:mutable"===this.fullName){const e=this.el.getAttribute(this.fullName);-1!==e.search(/\./)&&(this.lcFunc=e.split(".")[1])}return this.lcFunc}get modelValue(){return void 0!==this.el.value?this.el.value:this.el.innerText}get handler(){const{handler:e}=this.parseOutHandlerAndParams(this.value);return e}get params(){const{params:e}=this.parseOutHandlerAndParams(this.value);return e}durationOr(e){let t;const s=this.modifiers.find(e=>e.match(/([0-9]+)ms/)),a=this.modifiers.find(e=>e.match(/([0-9]+)s/));return s?t=Number(s.replace("ms","")):a&&(t=1e3*Number(a.replace("s",""))),t||e}parseOutHandlerAndParams(e){let t=e,s=[];const a=t.match(/(.*?)\((.*)\)/s);if(a){t=a[1],s=new Function("$event",`return (function () {\n for (var l=arguments.length, p=new Array(l), k=0; k{}};var a;return this.modelDebounceCallbacks.push(s),i=>{clearTimeout(a),a=setTimeout(()=>{e(i),a=void 0,s.callback=()=>{}},t),s.callback=()=>{clearTimeout(a),e(i)}}}}class n{constructor(e,t=!1){this.el=e,this.skipWatcher=t,this.updateQueue=[]}}class l extends n{constructor(e,t,s,a,i){super(i),this.isCustomEvent=a,this.type="fireEvent",this.name=e,this.payload={modelAttrVal:e,params:t,modelVal:s}}toId(){return btoa(encodeURIComponent(this.type,this.payload.event,JSON.stringify(this.payload.params)))}}function r(e,t,s,a){const i=new CustomEvent(t,s);e.addEventListener(t,a),e.dispatchEvent(i)}class o{constructor(){this.listeners={}}register(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)}call(e,...t){(this.listeners[e]||[]).forEach(e=>{e(...t)})}has(e){return Object.keys(this.listeners).includes(e)}}var d={availableHooks:["agent.initialized","element.initialized","element.updating","element.updated","element.removed","message.sent","message.failed","message.received","message.processed","allMessages.processed","request","interceptAsynModelSetValue","interceptAsynModelAttachListener","beforeReplaceState","beforePushState"],bus:new o,register(e,t){if(!this.availableHooks.includes(e))throw`ASYNergy: Referencing unknown hook: [${e}]`;this.bus.register(e,t)},call(e,...t){this.bus.call(e,...t)}};const u={csrf:{},transmissionEls:[],mutables:[],directives:{directives:new o,register(e,t){if(this.has(e))throw`ASYNergy: Directive already registered: [${e}]`;this.directives.register(e,t)},call(e,t,s,a,i){this.directives.call(e,t,s,a,i)},has(e){return this.directives.has(e)}},asynergyIsInBackground:!1,asynergyIsOffline:!1,hooks:d,agents:[],listeners:new o,nodesSetToDisabled:[],nodesSetToReadOnly:[],mutableIncludesModel:!1,theAgents(){return Object.keys(this.agents).map(e=>this.agents[e])},registerHook(e,t){this.hooks.register(e,t)},callHook(e,...t){this.hooks.call(e,...t)},addAgent(e){return this.agents.push(e),this.agents[this.agents.length-1]},getAgentsByID(e){return this.agents.filter(t=>t.agentID===e)},tearDownAgents(){let e=this.agents.length;for(let t=0;t{s.addAction(new l(e,t))})},agentsListeningForEvent(e){return this.theAgents().filter(t=>t.listeners.includes(e))},addEmitEvent(e,t,s,a){let i={};this.on(s,(...n)=>{const l=[];let o;if(l[0]=[],void 0!==n&0!==n.length){if(void 0!==n[0]&0!==n[0].length&&(l[0]=n[0].split(",")),Array.isArray(n)&l[0].toString()===t.toString()){switch(e.type){case"text":void 0!==n[1]&&(e.value=n[1]);break;case"checkbox":case"radio":void 0!==n[2]&&(e.checked=n[2]);break;case"select-multiple":void 0!==n[1]&&(o=n[1].split(",")),void 0!==o&&(i.detail=o);for(const t of e.options)-1!==o.indexOf(t.value)?t.setAttribute("selected","selected"):t.removeAttribute("selected");break;case"submit":if(void 0!==n[1]){const e=n[1].split(",");void 0!==e&&(i.detail=e)}}r(e,s,i,a)}}else r(e,s,i,a)})},on(e,t){this.listeners.register(e,t)},removeAgent(e,t){e.tearDown(),this.agents.splice(t,1)},transmissionElsData(e,t,s){if(void 0!==this.transmissionEls[0]){let a;for(a=0;a=0;if(i){const t=this.transmissionEls[a].checked;e.transmissionElsData[this.transmissionEls[a].getAttribute("asyn:transmit")]=t?this.transmissionEls[a].value:"false"}else if(n){this.transmissionEls[a].checked&&(e.transmissionElsData[this.transmissionEls[a].getAttribute("asyn:transmit")]=this.transmissionEls[a].value)}else e.transmissionElsData[this.transmissionEls[a].getAttribute("asyn:transmit")]="INPUT"===this.transmissionEls[a].tagName||"TEXTAREA"===this.transmissionEls[a].tagName||"SELECT"===this.transmissionEls[a].tagName?this.transmissionEls[a].value:this.transmissionEls[a].innerHTML,"checkbox"===t&&l&&(e.modelData[s]=this.transmissionEls[a].innerHTML)}}return e},addDisabledNode(e){this.nodesSetToDisabled.push(e)},addReadOnlyNode(e){this.nodesSetToReadOnly.push(e)},clearDisabledReadOnlyNodesArrays(){let e;for(e=0;e{void 0===e.url?((null===e.mutableVal||"object"==typeof e.mutableVal&&0===Object.keys(e.mutableVal).length)&&(e.mutableVal=""),"string"==typeof e.mutableVal&&-1!==e.mutableVal.search(/asyn:/)&&(this.reregisterEvLis=!0),this.updateEl.updated=0,this.updateMutablesByID(e),this.updateMutablesByAttrVal(e),0===this.updateEl.updated&&(this.updateEl.innerHTML=e.mutableVal),u.callHook("element.updated",this.updateEl,t,this.event),this.syncModels(e),u.callHook("message.processed",this.updateEl,t,this.event)):location=e.url}),!0===this.reregisterEvLis&&ASYNergy.reregisterEventListeners()}completed_callback(e){u.clearDisabledReadOnlyNodesArrays(),u.callHook("allMessages.processed",e)}ajax(e){const t=e.payload(),s=t.updates[0].payload.modelVal,a=e.agent.el.type,i=t.updates[0].payload.params;if(this.asynPayload={},this.asynPayload.modelData={modelAttrVal:this.modelAttrVal,modelVal:s,modelParams:i},void 0!==u.csrf.tokenName&&""!==u.csrf.token&&(this.asynPayload[u.csrf.tokenName]=u.csrf.token),this.asynPayload.mutablesData=[],this.asynPayload=u.mutabelsData(this.asynPayload),this.mutablesData=this.asynPayload.mutablesData,null!==this.mutablesData){null===this.updateEl&&(this.updateEl=this.mutablesData[0].el);this.mutablesData[0].mutableAttrVal;this.asynPayload.transmissionElsData={},this.asynPayload=u.transmissionElsData(this.asynPayload,a,"modelVal"),this.asynPayload.deferredModelData=h.deferredActionsData,this.asynPayload.actionType=e.updateQueue[0].type,this.actionType=this.asynPayload.actionType,this.asynPayload.isCustomEvent=e.updateQueue[0].isCustomEvent,this.isCustomEvent=this.asynPayload.isCustomEvent,u.callHook("request",this.options,this.mutablesData,this.asynPayload.modelData),this.asynPayload=JSON.stringify(this.asynPayload),fetch(this.url,{method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest",Accept:"text/html, application/xhtml+xml","X-ASYNergy":!0,...this.options.headers,Referer:window.location.href},body:this.asynPayload}).then(t=>{t.ok&&t.text().then(t=>{const s=JSON.parse(t);this.onMessage(e,s);this.handleResponse(event,e.agent,s,!0),this.callback(e)})}).catch(e=>{console.error(e)})}else console.warn("Missing data of any mutable element!")}updateMutablesByID(e){if(""!==e.mutableID&&null!==e.mutableID){const t=e.mutableID;"object"==typeof t?Object.values(t).forEach(t=>{this.updateEl=document.getElementById(`${t}`),"INPUT"===this.updateEl.nodeName?this.updateEl.value=e.mutableVal:this.updateEl.innerHTML=e.mutableVal,this.updateEl.updated=1}):(this.updateEl=document.getElementById(`${t}`),"INPUT"===this.updateEl.nodeName?this.updateEl.value=e.mutableVal:this.updateEl.innerHTML=e.mutableVal,this.updateEl.updated=1)}}updateMutablesByAttrVal(e){if(""!==e.mutableAttrVal&&this.mutablesData.length>0){let t=[],s="";this.mutablesData.forEach(a=>{-1!==a.mutableAttrVal.search(/[.]/)&&(t=/^.+(?=(\.))/.exec(a.mutableAttrVal),s=t[0]),(a.mutableAttrVal===e.mutableAttrVal||a.mutableAttrVal===s||Object.values(e.mutableAttrVal).indexOf(a.mutableAttrVal)>-1)&&(this.updateEl=a.el,"INPUT"===this.updateEl.nodeName?this.updateEl.value=e.mutableVal:this.updateEl.innerHTML=e.mutableVal,this.updateEl.updated=1)})}}syncModels(e){if(""!==e.syncModelID&&null!==e.syncModelID){let t=e.syncModelID;if("syncInput"===this.actionType){let e;const s=document.getElementById(`${t}`),a=this.updateEl,i=this.modelSyncTimeout;"true"!==s.getAttribute("listener")&&(s.value=a.innerHTML),s.addEventListener("input",(function(t){s.setAttribute("listener","true"),clearTimeout(e),e=setTimeout(()=>{s.value=a.innerHTML,s.removeAttribute("listener")},i)}))}else{const t=e.syncModelID;"object"==typeof t?Object.values(t).forEach(t=>{document.getElementById(`${t}`).value=e.mutableVal}):document.getElementById(`${t}`).value=e.mutableVal}}}}var p={allModelElementsInside:e=>Array.from(e.querySelectorAll("[asyn\\:model]")),getByAttributeAndValue:(e,t)=>document.querySelector(`[asyn\\:${e}="${t}"]`),hasAttribute:(e,t)=>e.hasAttribute(`asyn:${t}`),getAttribute:(e,t)=>e.getAttribute(`asyn:${t}`),removeAttribute:(e,t)=>e.removeAttribute(`asyn:${t}`),setAttribute:(e,t,s)=>e.setAttribute(`asyn:${t}`,s),hasFocus:e=>e===document.activeElement,isInput:e=>["INPUT","TEXTAREA","SELECT"].includes(e.tagName.toUpperCase()),isTextInput:e=>["INPUT","TEXTAREA"].includes(e.tagName.toUpperCase())&&!["checkbox","radio"].includes(e.type),valueFromInput(e,t){if("checkbox"===e.type){let a=s(e).get("model").value,i=t.deferredActions[a]?t.deferredActions[a].asynPayload.value:e.checked;return Array.isArray(i)?this.mergeCheckboxValueIntoArray(e,i):!!e.checked&&(e.getAttribute("value")||!0)}return"SELECT"===e.tagName&&e.multiple?this.getSelectValues(e):e.value},mergeCheckboxValueIntoArray:(e,t)=>e.checked?t.includes(e.value)?t:t.concat(e.value):t.filter(t=>t!=e.value),setInputValueFromModel(e,t){const a=s(e).get("model").value,i=get(t.data,a);"input"===e.tagName.toLowerCase()&&"file"===e.type||this.setInputValue(e,i)},setInputValue(e,t){if("radio"===e.type)e.checked=e.value==t;else if("checkbox"===e.type)if(Array.isArray(t)){let s=!1;t.forEach(t=>{t==e.value&&(s=!0)}),e.checked=s}else e.checked=!!t;else"SELECT"===e.tagName?this.updateSelect(e,t):(t=void 0===t?"":t,e.value=t)},getSelectValues:e=>Array.from(e.options).filter(e=>e.selected).map(e=>e.value||e.text),updateSelect(e,t){const s=[].concat(t).map(e=>e+"");Array.from(e.options).forEach(e=>{e.selected=s.includes(e.value)})}};class y extends n{constructor(e,t,s,a,i,n=!1){super(i,n),this.isCustomEvent=a,this.type="callHandler",this.name=e,this.payload={modelAttrVal:e,params:t,modelVal:s}}}class g extends n{constructor(e,t,s,a,i){super(i),this.isCustomEvent=a,this.type="syncInput",this.name=e,this.payload={modelAttrVal:e,params:t,modelVal:s}}}class f{constructor(e,t){this.agent=e,this.updateQueue=t}payload(){return{updates:this.updateQueue.map(e=>({type:e.type,payload:e.payload}))}}storeResponse(e){return this.response=e}}class b{constructor(e,t,s,a){this.el=e,this.updateQueue=[],this.deferredActions={},this.messageInTransit=void 0,this.connection=t,this.postValue=s,this.agentID=a,this.tearDownCallbacks=[],this.scopedListeners=new o,this.listeners=[],u.callHook("agent.initialized",this)}on(e,t){this.scopedListeners.register(e,t)}addAction(e){e instanceof c?this.deferredActions[e.name]=e:(this.updateQueue.push(e),t(this.fireMessage,5).apply(this))}fireMessage(){Object.entries(this.deferredActions).forEach(([e,t])=>{this.updateQueue.unshift(t)}),this.deferredActions={},this.messageInTransit=new f(this,this.updateQueue);(()=>{this.connection.action(this.messageInTransit),u.callHook("message.sent",this,this.messageInTransit),this.updateQueue=[]})()}receiveMessage(e,t){e.storeResponse(t),this.updateQueue.length>0&&this.fireMessage()}doReplayResponse(e,t,s){this.connection.handleResponse(e,t,s)}walk(t,s=(e=>{})){e(this.el,e=>{if(!e.isSameNode(this.el))return!1!==t(e)&&void 0;t(e)})}callAfterModelDebounce(e){this.modelDebounceCallbacks&&this.modelDebounceCallbacks.forEach(e=>{e.callback(),e.callback=()=>{}}),e()}addListenerForTeardown(e){this.tearDownCallbacks.push(e)}tearDown(){this.tearDownCallbacks.forEach(e=>e())}}var v={initialize(e,t,a){let i=!1;if(s(e).all().forEach(s=>{let n;switch(s.type){case"model":{if(!s.value){console.warn("ASYNergy: [asyn:model] is missing a value.",e);break}let a="",n=s.value.search(/[.]/);if(-1!==n){a=/^.+(?=(\.))/.exec(s.value)[0]}else a=s.value;if(-1!==(n=s.value.search(/[\(]/))){a=/^.+(?=(\())/.exec(s.value)[0]}let l=document.querySelector(`[asyn\\:mutable=${a}]`),r=this.modelAttr(s.fullName,a),o=document.querySelector(`[${r}]`);null!==l?this.attachModelListener(e,s,l,t,o,a):null!==(l=document.querySelector(`[asyn\\:mutable^=${a}\\.]`))?this.attachModelListener(e,s,l,t,o,a):console.warn("ASYNergy: [asyn:model] is missing a corresponding [asyn:mutable] element.",e),i=!0;break}case"mutable":!0!==a&&("string"==typeof s.el.innerHTML&&-1!==s.el.innerHTML.search(/asyn:/)&&(u.mutableIncludesModel=!0),n=s.lcFunction,u.mutables.push(s),i=!1);break;case"transmit":s.el.mutable=e.getAttributeNames().indexOf("asyn:mutable"),u.transmissionEls.push(s.el),i=!0;break;case"csrf":u.csrf.tokenName=s.value,u.csrf.token=e.value,i=!1;break;default:const l=s.params;let r=s.value;0!==l.length&&(r=s.handler);let o=document.querySelector(`[asyn\\:mutable=${r}]`);null===o&&(o=document.querySelector(`[asyn\\:mutable^=${r}\\.]`));let d=this.modelAttr(s.fullName,s.value),c=document.querySelector(`[${d}]`);u.directives.has(s.type)&&u.directives.call(s.type,e,s,o,t),this.attachDomListener(e,s,o,t,c),i=!0}}),!0===i){let t=u.agents.length-1,s=u.agents[t],a=s.connection.event;u.callHook("element.initialized",e,s,a)}i=!1},attachModelListener(e,t,s,a,i,n){const l=t.modifiers.includes("lazy"),r=t.modifiers.includes("debounce");u.callHook("interceptAsynModelAttachListener",t,e,s);let o="select"===e.tagName.toLowerCase()||["checkbox","radio"].includes(e.type)||t.modifiers.includes("lazy")?"change":"input";"input"===e.tagName.toLowerCase()&&t.modifiers.includes("blur")&&(o="blur");const d=new m(a+"/"+n,s,n,i,o);let y=u.agents.length+1,f=u.addAgent(new b(e,d,e.value,y));t.modifiers.includes("defer")&&h.addAction(t.value,e.value,e);let v=((e,s,a)=>e?t.modelSyncDebounce(s,a):s)(r||p.isTextInput(e)&&!l,e=>{let s=t.value,a=t.params,i=e.target;const n=e instanceof CustomEvent;t.emitEvent=!!n;let l=e instanceof CustomEvent&&void 0!==e.detail&&void 0===window.document.documentMode?e.detail||e.target.value:p.valueFromInput(i,f);t.modifiers.includes("defer")?f.addAction(new c(s,a,l,n,i)):f.addAction(new g(s,a,l,n,i))},t.durationOr(150));u.addEmitEvent(e,t.params,t.handler,v),e.addEventListener(o,v),f.addListenerForTeardown(()=>{e.removeEventListener(o,v)}),/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&e.addEventListener("animationstart",e=>{"asynergyAutofill"===e.animationName&&(e.target.dispatchEvent(new Event("change",{bubbles:!0})),e.target.dispatchEvent(new Event("input",{bubbles:!0})))})},attachDomListener(e,t,s,a,i){switch(t.type){case"keydown":case"keyup":this.attachListener(e,t,e=>{const s=["ctrl","shift","alt","meta","cmd","super"].filter(e=>t.modifiers.includes(e));if(s.length>0){if(s.filter(t=>("cmd"!==t&&"super"!==t||(t="meta"),!e[`${t}Key`])).length>0)return!1}if(32===e.keyCode||" "===e.key||"Spacebar"===e.key)return t.modifiers.includes("space");let a=t.modifiers.filter(e=>!e.match(/^debounce$/)&&!e.match(/^[0-9]+m?s$/));return Boolean(0===a.length||e.key&&a.includes(function(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[_\s]/,"-").toLowerCase()}(e.key)))},s,a,i);break;case"click":this.attachListener(e,t,s=>{if(t.modifiers.includes("self"))return e.isSameNode(s.target)},s,a,i);break;default:this.attachListener(e,t,t=>e===t.target,s,a,i)}},attachListener(e,s,a,i,n,l){const r=s.type,o=s.handler,d=new m(n+"/"+o,i,o,l,r);let c=u.agents.length+1,h=u.addAgent(new b(e,d,(()=>void 0!==e.value?e.value:e.innerText)(),c));const p=e=>{if(a&&!1===a(e))return;const t=e instanceof CustomEvent;h.callAfterModelDebounce(()=>{const a=e.target;s.setEventContext(e),this.preventAndStop(e,s.modifiers);const i=s.handler;let n=s.params,l=s.modelValue;t?(s.emitEvent=!0,void 0!==e.detail&&(l=e.detail)):s.emitEvent=!1,0===n.length&&t&&e.detail&&n.push(e.detail),s.value&&h.addAction(new y(i,n,l,t,a))})},g=((e,s,a)=>e?t(s,a):s)(s.modifiers.includes("debounce"),p,s.durationOr(150));u.addEmitEvent(e,s.params,s.handler,p),e.addEventListener(r,g),h.addListenerForTeardown(()=>{e.removeEventListener(r,g)})},preventAndStop(e,t){t.includes("prevent")&&e.preventDefault(),t.includes("stop")&&e.stopPropagation()},modelAttr(e,t){return this.escapedStr(e)+'="'+this.escapedStr(t)+'"'},escapedStr(e){let t=e;return t=t.replace(/\:|\.|"|'/gi,(function(e){return"\\"+e}))}};let A={};function E(e){if(A[e.agentID])for(;A[e.agentID].length>0;)A[e.agentID].shift()()}let S={replaceState(e,t,s){this.updateState("replaceState",e,t,s)},pushState(e,t,s){this.updateState("pushState",e,t,s)},updateState(e,t,s,a){let i=this.currentState();i.storeResponse(s,a);let n=i.toStateArray(),l=Object.assign(history.state||{},{ASYNergy:n});u.callHook("before"+(e=>e.charAt(0).toUpperCase()+e.slice(1))(e),l,t,a);try{"undefined"!=decodeURI(t)&&(t=decodeURI(t).replaceAll(" ","+").replaceAll("\\","%5C")),history[e](l,"",t)}catch(s){if("NS_ERROR_ILLEGAL_VALUE"===s.name){let s=this.storeInSession(n);l.asynergy=s,history[e](l,"",t)}else console.error("history."+e+": "+s)}},replayResponses(e,t){if(!e.state.ASYNergy)return;("string"==typeof e.state.ASYNergy?new k(this.getFromSession(e.state.ASYNergy)):new k(e.state.ASYNergy)).replayResponses(t)},currentState(){if(!history.state)return new k;if(!history.state.ASYNergy)return new k;return"string"==typeof history.state.ASYNergy?new k(this.getFromSession(history.state.ASYNergy)):new k(history.state.ASYNergy)},missingState:e=>!(e.state&&e.state.ASYNergy),clearState(){window.history.state&&(window.history.state.ASYNergy=(new k).toStateArray())},storeInSession(e){let t="asynergy:"+(new Date).getTime(),s=JSON.stringify(e);return this.tryToStoreInSession(t,s),t},tryToStoreInSession(e,t){try{sessionStorage.setItem(e,t)}catch(s){if(![22,1,2,3,4,5,6,7,8,9,10,11,12,13,14].includes(s.code))return;let a=Object.keys(sessionStorage).map(e=>Number(e.replace("asynergy:",""))).sort().shift();if(!a)return;sessionStorage.removeItem("asynergy:"+a),this.tryToStoreInSession(e,t)}},getFromSession(e){let t=sessionStorage.getItem(e);if(t)return JSON.parse(t)}};class k{constructor(e=[]){this.items=e}toStateArray(){return this.items}pushItemInProperOrder(e,t,s){let a={signature:e,response:t},i=this.items.findIndex(t=>t.signature===e);return-1!==i?this.items[i]=a:this.items.unshift(a)}storeResponse(e,t){let s=t.agentID;this.pushItemInProperOrder(s,e,t)}replayResponses(e){let t=S.currentState(),s=t.items[0].signature,a=t.items[0].response,i=this.findAgentBySignature(s);i&&e(a,i)}findAgentBySignature(e){return u.getAgentsByID(e)[0]||u.agents[0]||console.warn(`ASYNergy: couldn't find agent with ID: ${e}`)}} +!function(){function e(t,s){if(!1===s(t))return;let a=t.firstElementChild;for(;a;)e(a,s),a=a.nextElementSibling}function t(e,t,s){var a;return function(){var s=this,i=arguments;clearTimeout(a),a=setTimeout((function(){a=null,e.apply(s,i)}),t)}}function s(e){return new a(e)}let a=class{constructor(e){this.el=e,this.directives=this.extractTypeModifiersAndValue()}all(){return this.directives}has(e){return this.directives.map((e=>e.type)).includes(e)}missing(e){return!this.has(e)}get(e){return this.directives.find((t=>t.type===e))}extractTypeModifiersAndValue(){return Array.from(this.el.getAttributeNames().filter((e=>e.match(new RegExp("asyn:")))).map((e=>{const[t,...s]=e.replace(new RegExp("asyn:"),"").split(".");return new i(t,s,e,this.el)})))}};class i{constructor(e,t,s,a){this.type=e,this.modifiers=t,this.fullName=s,this.el=a,this.eventContext,this.lcFunc=null,this.emitEvent=!1}setEventContext(e){this.eventContext=e}get isEmitEvent(){return emitEvent}set isEmitEvent(e){"boolean"==typeof e&&(this.emitEvent=e)}get value(){return this.el.getAttribute(this.fullName)}get lcFunction(){if("asyn:mutable"===this.fullName){const e=this.el.getAttribute(this.fullName);-1!==e.search(/\./)&&(this.lcFunc=e.split(".")[1])}return this.lcFunc}get modelValue(){return void 0!==this.el.value?this.el.value:this.el.innerText}get handler(){const{handler:e}=this.parseOutHandlerAndParams(this.value);return e}get params(){const{params:e}=this.parseOutHandlerAndParams(this.value);return e}durationOr(e){let t;const s=this.modifiers.find((e=>e.match(/([0-9]+)ms/))),a=this.modifiers.find((e=>e.match(/([0-9]+)s/)));return s?t=Number(s.replace("ms","")):a&&(t=1e3*Number(a.replace("s",""))),t||e}parseOutHandlerAndParams(e){let t=e,s=[];const a=t.match(/(.*?)\((.*)\)/s);if(a){t=a[1],s=new Function("$event",`return (function () {\n for (var l=arguments.length, p=new Array(l), k=0; k{}};var a;return this.modelDebounceCallbacks.push(s),i=>{clearTimeout(a),a=setTimeout((()=>{e(i),a=void 0,s.callback=()=>{}}),t),s.callback=()=>{clearTimeout(a),e(i)}}}}class n{constructor(e,t=!1){this.el=e,this.skipWatcher=t,this.updateQueue=[]}}class l extends n{constructor(e,t,s,a,i){super(i),this.isCustomEvent=a,this.type="fireEvent",this.name=e,this.payload={modelAttrVal:e,params:t,modelVal:s}}toId(){return btoa(encodeURIComponent(this.type,this.payload.event,JSON.stringify(this.payload.params)))}}function r(e,t,s,a){const i=new CustomEvent(t,s);e.addEventListener(t,a),e.dispatchEvent(i)}class o{constructor(){this.listeners={}}register(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)}call(e,...t){(this.listeners[e]||[]).forEach((e=>{e(...t)}))}has(e){return Object.keys(this.listeners).includes(e)}}var d={availableHooks:["agent.initialized","element.initialized","element.updating","element.updated","element.removed","message.sent","message.failed","message.received","message.processed","allMessages.processed","request","interceptAsynModelSetValue","interceptAsynModelAttachListener","beforeReplaceState","beforePushState"],bus:new o,register(e,t){if(!this.availableHooks.includes(e))throw`ASYNergy: Referencing unknown hook: [${e}]`;this.bus.register(e,t)},call(e,...t){this.bus.call(e,...t)}};const u={csrf:{},transmissionEls:[],mutables:[],directives:{directives:new o,register(e,t){if(this.has(e))throw`ASYNergy: Directive already registered: [${e}]`;this.directives.register(e,t)},call(e,t,s,a,i){this.directives.call(e,t,s,a,i)},has(e){return this.directives.has(e)}},asynergyIsInBackground:!1,asynergyIsOffline:!1,hooks:d,agents:[],listeners:new o,nodesSetToDisabled:[],nodesSetToReadOnly:[],mutableIncludesModel:!1,theAgents(){return Object.keys(this.agents).map((e=>this.agents[e]))},registerHook(e,t){this.hooks.register(e,t)},callHook(e,...t){this.hooks.call(e,...t)},addAgent(e){return this.agents.push(e),this.agents[this.agents.length-1]},getAgentsByID(e){return this.agents.filter((t=>t.agentID===e))},tearDownAgents(){let e=this.agents.length;for(let t=0;t{s.addAction(new l(e,t))}))},agentsListeningForEvent(e){return this.theAgents().filter((t=>t.listeners.includes(e)))},addEmitEvent(e,t,s,a){let i={};this.on(s,((...n)=>{const l=[];let o;if(l[0]=[],void 0!==n&0!==n.length){if(void 0!==n[0]&0!==n[0].length&&(l[0]=n[0].split(",")),Array.isArray(n)&l[0].toString()===t.toString()){switch(e.type){case"text":case"range":void 0!==n[1]&&(e.value=n[1]);break;case"checkbox":case"radio":void 0!==n[2]&&(e.checked=n[2]);break;case"select-multiple":void 0!==n[1]&&(o=n[1].split(",")),void 0!==o&&(i.detail=o);for(const t of e.options)-1!==o.indexOf(t.value)?t.setAttribute("selected","selected"):t.removeAttribute("selected");break;case"submit":if(void 0!==n[1]){const e=n[1].split(",");void 0!==e&&(i.detail=e)}}r(e,s,i,a)}}else r(e,s,i,a)}))},on(e,t){this.listeners.register(e,t)},removeAgent(e,t){e.tearDown(),this.agents.splice(t,1)},transmissionElsData(e,t,s){if(void 0!==this.transmissionEls[0]){let a;for(a=0;a=0;if(i){const t=this.transmissionEls[a].checked;e.transmissionElsData[this.transmissionEls[a].getAttribute("asyn:transmit")]=t?this.transmissionEls[a].value:"false"}else if(n){this.transmissionEls[a].checked&&(e.transmissionElsData[this.transmissionEls[a].getAttribute("asyn:transmit")]=this.transmissionEls[a].value)}else e.transmissionElsData[this.transmissionEls[a].getAttribute("asyn:transmit")]="INPUT"===this.transmissionEls[a].tagName||"TEXTAREA"===this.transmissionEls[a].tagName||"SELECT"===this.transmissionEls[a].tagName?this.transmissionEls[a].value:this.transmissionEls[a].innerHTML,"checkbox"===t&&l&&(e.modelData[s]=this.transmissionEls[a].innerHTML)}}return e},addDisabledNode(e){this.nodesSetToDisabled.push(e)},addReadOnlyNode(e){this.nodesSetToReadOnly.push(e)},clearDisabledReadOnlyNodesArrays(){let e;for(e=0;e{void 0===e.url?((null===e.mutableVal||"object"==typeof e.mutableVal&&0===Object.keys(e.mutableVal).length)&&(e.mutableVal=""),"string"==typeof e.mutableVal&&-1!==e.mutableVal.search(/asyn:/)&&(this.reregisterEvLis=!0),this.updateEl.updated=0,this.updateMutablesByID(e),this.updateMutablesByAttrVal(e),0===this.updateEl.updated&&(this.updateEl.innerHTML=e.mutableVal),u.callHook("element.updated",this.updateEl,t,this.event),this.syncModels(e),u.callHook("message.processed",this.updateEl,t,this.event)):location=e.url})),!0===this.reregisterEvLis&&ASYNergy.reregisterEventListeners()}completed_callback(e){u.clearDisabledReadOnlyNodesArrays(),u.callHook("allMessages.processed",e)}ajax(e){const t=e.payload(),s=t.updates[0].payload.modelVal,a=e.agent.el.type,i=t.updates[0].payload.params;this.asynPayload={},this.asynPayload.modelData={modelAttrVal:this.modelAttrVal,modelVal:s,modelParams:i},void 0!==u.csrf.tokenName&&""!==u.csrf.token&&(this.asynPayload[u.csrf.tokenName]=u.csrf.token),this.asynPayload.mutablesData=[],this.asynPayload=u.mutabelsData(this.asynPayload),this.mutablesData=this.asynPayload.mutablesData,null!==this.mutablesData?(null===this.updateEl&&(this.updateEl=this.mutablesData[0].el),this.mutablesData[0].mutableAttrVal,this.asynPayload.transmissionElsData={},this.asynPayload=u.transmissionElsData(this.asynPayload,a,"modelVal"),this.asynPayload.deferredModelData=h.deferredActionsData,this.asynPayload.actionType=e.updateQueue[0].type,this.actionType=this.asynPayload.actionType,this.asynPayload.isCustomEvent=e.updateQueue[0].isCustomEvent,this.isCustomEvent=this.asynPayload.isCustomEvent,u.callHook("request",this.options,this.mutablesData,this.asynPayload.modelData),this.asynPayload=JSON.stringify(this.asynPayload),fetch(this.url,{method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest",Accept:"text/html, application/xhtml+xml","X-ASYNergy":!0,...this.options.headers,Referer:window.location.href},body:this.asynPayload}).then((t=>{t.ok&&t.text().then((t=>{const s=JSON.parse(t);this.onMessage(e,s);this.handleResponse(event,e.agent,s,!0),this.callback(e)}))})).catch((e=>{console.error(e)}))):console.warn("Missing data of any mutable element!")}updateMutablesByID(e){if(""!==e.mutableID&&null!==e.mutableID){const t=e.mutableID;"object"==typeof t?Object.values(t).forEach((t=>{this.updateEl=document.getElementById(`${t}`),"INPUT"===this.updateEl.nodeName?this.updateEl.value=e.mutableVal:this.updateEl.innerHTML=e.mutableVal,this.updateEl.updated=1})):(this.updateEl=document.getElementById(`${t}`),"INPUT"===this.updateEl.nodeName?this.updateEl.value=e.mutableVal:this.updateEl.innerHTML=e.mutableVal,this.updateEl.updated=1)}}updateMutablesByAttrVal(e){if(""!==e.mutableAttrVal&&this.mutablesData.length>0){let t=[],s="";this.mutablesData.forEach((a=>{-1!==a.mutableAttrVal.search(/[.]/)&&(t=/^.+(?=(\.))/.exec(a.mutableAttrVal),s=t[0]),(a.mutableAttrVal===e.mutableAttrVal||a.mutableAttrVal===s||Object.values(e.mutableAttrVal).indexOf(a.mutableAttrVal)>-1)&&(this.updateEl=a.el,"INPUT"===this.updateEl.nodeName?this.updateEl.value=e.mutableVal:this.updateEl.innerHTML=e.mutableVal,this.updateEl.updated=1)}))}}syncModels(e){if(""!==e.syncModelID&&null!==e.syncModelID){let t=e.syncModelID;if("syncInput"===this.actionType){let e;const s=document.getElementById(`${t}`),a=this.updateEl,i=this.modelSyncTimeout;"true"!==s.getAttribute("listener")&&(s.value=a.innerHTML),s.addEventListener("input",(function(t){s.setAttribute("listener","true"),clearTimeout(e),e=setTimeout((()=>{s.value=a.innerHTML,s.removeAttribute("listener")}),i)}))}else{const t=e.syncModelID;"object"==typeof t?Object.values(t).forEach((t=>{document.getElementById(`${t}`).value=e.mutableVal})):document.getElementById(`${t}`).value=e.mutableVal}}}}var p={allModelElementsInside:e=>Array.from(e.querySelectorAll("[asyn\\:model]")),getByAttributeAndValue:(e,t)=>document.querySelector(`[asyn\\:${e}="${t}"]`),hasAttribute:(e,t)=>e.hasAttribute(`asyn:${t}`),getAttribute:(e,t)=>e.getAttribute(`asyn:${t}`),removeAttribute:(e,t)=>e.removeAttribute(`asyn:${t}`),setAttribute:(e,t,s)=>e.setAttribute(`asyn:${t}`,s),hasFocus:e=>e===document.activeElement,isInput:e=>["INPUT","TEXTAREA","SELECT"].includes(e.tagName.toUpperCase()),isTextInput:e=>["INPUT","TEXTAREA"].includes(e.tagName.toUpperCase())&&!["checkbox","radio"].includes(e.type),valueFromInput(e,t){if("checkbox"===e.type){let a=s(e).get("model").value,i=t.deferredActions[a]?t.deferredActions[a].asynPayload.value:e.checked;return Array.isArray(i)?this.mergeCheckboxValueIntoArray(e,i):!!e.checked&&(e.getAttribute("value")||!0)}return"SELECT"===e.tagName&&e.multiple?this.getSelectValues(e):e.value},mergeCheckboxValueIntoArray:(e,t)=>e.checked?t.includes(e.value)?t:t.concat(e.value):t.filter((t=>t!=e.value)),setInputValueFromModel(e,t){const a=s(e).get("model").value,i=get(t.data,a);"input"===e.tagName.toLowerCase()&&"file"===e.type||this.setInputValue(e,i)},setInputValue(e,t){if("radio"===e.type)e.checked=e.value==t;else if("checkbox"===e.type)if(Array.isArray(t)){let s=!1;t.forEach((t=>{t==e.value&&(s=!0)})),e.checked=s}else e.checked=!!t;else"SELECT"===e.tagName?this.updateSelect(e,t):(t=void 0===t?"":t,e.value=t)},getSelectValues:e=>Array.from(e.options).filter((e=>e.selected)).map((e=>e.value||e.text)),updateSelect(e,t){const s=[].concat(t).map((e=>e+""));Array.from(e.options).forEach((e=>{e.selected=s.includes(e.value)}))}};class y extends n{constructor(e,t,s,a,i,n=!1){super(i,n),this.isCustomEvent=a,this.type="callHandler",this.name=e,this.payload={modelAttrVal:e,params:t,modelVal:s}}}class g extends n{constructor(e,t,s,a,i){super(i),this.isCustomEvent=a,this.type="syncInput",this.name=e,this.payload={modelAttrVal:e,params:t,modelVal:s}}}class f{constructor(e,t){this.agent=e,this.updateQueue=t}payload(){return{updates:this.updateQueue.map((e=>({type:e.type,payload:e.payload})))}}storeResponse(e){return this.response=e}}class b{constructor(e,t,s,a){this.el=e,this.updateQueue=[],this.deferredActions={},this.messageInTransit=void 0,this.connection=t,this.postValue=s,this.agentID=a,this.tearDownCallbacks=[],this.scopedListeners=new o,this.listeners=[],u.callHook("agent.initialized",this)}on(e,t){this.scopedListeners.register(e,t)}addAction(e){e instanceof c?this.deferredActions[e.name]=e:(this.updateQueue.push(e),t(this.fireMessage,5).apply(this))}fireMessage(){Object.entries(this.deferredActions).forEach((([e,t])=>{this.updateQueue.unshift(t)})),this.deferredActions={},this.messageInTransit=new f(this,this.updateQueue);(()=>{this.connection.action(this.messageInTransit),u.callHook("message.sent",this,this.messageInTransit),this.updateQueue=[]})()}receiveMessage(e,t){e.storeResponse(t),this.updateQueue.length>0&&this.fireMessage()}doReplayResponse(e,t,s){this.connection.handleResponse(e,t,s)}walk(t,s=e=>{}){e(this.el,(e=>{if(!e.isSameNode(this.el))return!1!==t(e)&&void 0;t(e)}))}callAfterModelDebounce(e){this.modelDebounceCallbacks&&this.modelDebounceCallbacks.forEach((e=>{e.callback(),e.callback=()=>{}})),e()}addListenerForTeardown(e){this.tearDownCallbacks.push(e)}tearDown(){this.tearDownCallbacks.forEach((e=>e()))}}var v={initialize(e,t,a){let i=!1;if(s(e).all().forEach((s=>{switch(s.type){case"model":{if(!s.value){console.warn("ASYNergy: [asyn:model] is missing a value.",e);break}let a="",n=s.value.search(/[.]/);if(-1!==n){a=/^.+(?=(\.))/.exec(s.value)[0]}else a=s.value;if(n=s.value.search(/[\(]/),-1!==n){a=/^.+(?=(\())/.exec(s.value)[0]}let l=document.querySelector(`[asyn\\:mutable=${a}]`),r=this.modelAttr(s.fullName,a),o=document.querySelector(`[${r}]`);null!==l?this.attachModelListener(e,s,l,t,o,a):(l=document.querySelector(`[asyn\\:mutable^=${a}\\.]`),null!==l?this.attachModelListener(e,s,l,t,o,a):console.warn("ASYNergy: [asyn:model] is missing a corresponding [asyn:mutable] element.",e)),i=!0;break}case"mutable":!0!==a&&("string"==typeof s.el.innerHTML&&-1!==s.el.innerHTML.search(/asyn:/)&&(u.mutableIncludesModel=!0),s.lcFunction,u.mutables.push(s),i=!1);break;case"transmit":s.el.mutable=e.getAttributeNames().indexOf("asyn:mutable"),u.transmissionEls.push(s.el),i=!0;break;case"csrf":u.csrf.tokenName=s.value,u.csrf.token=e.value,i=!1;break;default:const n=s.params;let l=s.value;0!==n.length&&(l=s.handler);let r=document.querySelector(`[asyn\\:mutable=${l}]`);null===r&&(r=document.querySelector(`[asyn\\:mutable^=${l}\\.]`));let o=this.modelAttr(s.fullName,s.value),d=document.querySelector(`[${o}]`);u.directives.has(s.type)&&u.directives.call(s.type,e,s,r,t),this.attachDomListener(e,s,r,t,d),i=!0}})),!0===i){let t=u.agents.length-1,s=u.agents[t],a=s.connection.event;u.callHook("element.initialized",e,s,a)}i=!1},attachModelListener(e,t,s,a,i,n){const l=t.modifiers.includes("lazy");if("range"===e.type&&l&&null!==t.value.match(/\bdisplayValue\b/)){let a,i=e,n=s,l="",r=t.value,o=/'(.*?)'/g,d=[];for(;a=o.exec(r);)d.push(a[1]);void 0!==d[1]&&(l=d[1]),i.oninput=()=>{n.innerHTML=i.value+l}}const r=t.modifiers.includes("debounce");u.callHook("interceptAsynModelAttachListener",t,e,s);let o="select"===e.tagName.toLowerCase()||["checkbox","radio"].includes(e.type)||t.modifiers.includes("lazy")?"change":"input";"input"===e.tagName.toLowerCase()&&t.modifiers.includes("blur")&&(o="blur");const d=new m(a+"/"+n,s,n,i,o);let y=u.agents.length+1,f=u.addAgent(new b(e,d,e.value,y));t.modifiers.includes("defer")&&h.addAction(t.value,e.value,e);let v=(A=r||p.isTextInput(e)&&!l,E=e=>{let s=t.value,a=t.params,i=e.target;const n=e instanceof CustomEvent;t.emitEvent=!!n;let l=e instanceof CustomEvent&&void 0!==e.detail&&void 0===window.document.documentMode?e.detail||e.target.value:p.valueFromInput(i,f);t.modifiers.includes("defer")?f.addAction(new c(s,a,l,n,i)):f.addAction(new g(s,a,l,n,i))},S=t.durationOr(150),A?t.modelSyncDebounce(E,S):E);var A,E,S;u.addEmitEvent(e,t.params,t.handler,v),e.addEventListener(o,v),f.addListenerForTeardown((()=>{e.removeEventListener(o,v)})),/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&e.addEventListener("animationstart",(e=>{"asynergyAutofill"===e.animationName&&(e.target.dispatchEvent(new Event("change",{bubbles:!0})),e.target.dispatchEvent(new Event("input",{bubbles:!0})))}))},attachDomListener(e,t,s,a,i){switch(t.type){case"keydown":case"keyup":this.attachListener(e,t,(e=>{const s=["ctrl","shift","alt","meta","cmd","super"].filter((e=>t.modifiers.includes(e)));if(s.length>0){if(s.filter((t=>("cmd"!==t&&"super"!==t||(t="meta"),!e[`${t}Key`]))).length>0)return!1}if(32===e.keyCode||" "===e.key||"Spacebar"===e.key)return t.modifiers.includes("space");let a=t.modifiers.filter((e=>!e.match(/^debounce$/)&&!e.match(/^[0-9]+m?s$/)));return Boolean(0===a.length||e.key&&a.includes(e.key.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[_\s]/,"-").toLowerCase()))}),s,a,i);break;case"click":this.attachListener(e,t,(s=>{if(t.modifiers.includes("self"))return e.isSameNode(s.target)}),s,a,i);break;default:this.attachListener(e,t,(t=>e===t.target),s,a,i)}},attachListener(e,s,a,i,n,l){const r=s.type,o=s.handler,d=new m(n+"/"+o,i,o,l,r);let c=u.agents.length+1,h=u.addAgent(new b(e,d,void 0!==e.value?e.value:e.innerText,c));const p=e=>{if(a&&!1===a(e))return;const t=e instanceof CustomEvent;h.callAfterModelDebounce((()=>{const a=e.target;s.setEventContext(e),this.preventAndStop(e,s.modifiers);const i=s.handler;let n=s.params,l=s.modelValue;t?(s.emitEvent=!0,void 0!==e.detail&&(l=e.detail)):s.emitEvent=!1,0===n.length&&t&&e.detail&&n.push(e.detail),s.value&&h.addAction(new y(i,n,l,t,a))}))},g=((e,s,a)=>e?t(s,a):s)(s.modifiers.includes("debounce"),p,s.durationOr(150));u.addEmitEvent(e,s.params,s.handler,p),e.addEventListener(r,g),h.addListenerForTeardown((()=>{e.removeEventListener(r,g)}))},preventAndStop(e,t){t.includes("prevent")&&e.preventDefault(),t.includes("stop")&&e.stopPropagation()},modelAttr(e,t){return this.escapedStr(e)+'="'+this.escapedStr(t)+'"'},escapedStr(e){let t=e;return t=t.replace(/\:|\.|"|'/gi,(function(e){return"\\"+e})),t}};let A={};function E(e){if(A[e.agentID])for(;A[e.agentID].length>0;)A[e.agentID].shift()()}let S={replaceState(e,t,s){this.updateState("replaceState",e,t,s)},pushState(e,t,s){this.updateState("pushState",e,t,s)},updateState(e,t,s,a){let i=this.currentState();i.storeResponse(s,a);let n=i.toStateArray(),l=Object.assign(history.state||{},{ASYNergy:n});var r;u.callHook("before"+((r=e).charAt(0).toUpperCase()+r.slice(1)),l,t,a);try{"undefined"!=decodeURI(t)&&(t=decodeURI(t).replaceAll(" ","+").replaceAll("\\","%5C")),history[e](l,"",t)}catch(s){if("NS_ERROR_ILLEGAL_VALUE"===s.name){let s=this.storeInSession(n);l.asynergy=s,history[e](l,"",t)}else console.error("history."+e+": "+s)}},replayResponses(e,t){if(!e.state.ASYNergy)return;("string"==typeof e.state.ASYNergy?new k(this.getFromSession(e.state.ASYNergy)):new k(e.state.ASYNergy)).replayResponses(t)},currentState(){if(!history.state)return new k;if(!history.state.ASYNergy)return new k;return"string"==typeof history.state.ASYNergy?new k(this.getFromSession(history.state.ASYNergy)):new k(history.state.ASYNergy)},missingState:e=>!(e.state&&e.state.ASYNergy),clearState(){window.history.state&&(window.history.state.ASYNergy=(new k).toStateArray())},storeInSession(e){let t="asynergy:"+(new Date).getTime(),s=JSON.stringify(e);return this.tryToStoreInSession(t,s),t},tryToStoreInSession(e,t){try{sessionStorage.setItem(e,t)}catch(s){if(![22,1,2,3,4,5,6,7,8,9,10,11,12,13,14].includes(s.code))return;let a=Object.keys(sessionStorage).map((e=>Number(e.replace("asynergy:","")))).sort().shift();if(!a)return;sessionStorage.removeItem("asynergy:"+a),this.tryToStoreInSession(e,t)}},getFromSession(e){let t=sessionStorage.getItem(e);if(t)return JSON.parse(t)}};class k{constructor(e=[]){this.items=e}toStateArray(){return this.items}pushItemInProperOrder(e,t,s){let a={signature:e,response:t},i=this.items.findIndex((t=>t.signature===e));return-1!==i?this.items[i]=a:this.items.unshift(a)}storeResponse(e,t){let s=t.agentID;this.pushItemInProperOrder(s,e,t)}replayResponses(e){let t=S.currentState(),s=t.items[0].signature,a=t.items[0].response,i=this.findAgentBySignature(s);i&&e(a,i)}findAgentBySignature(e){return u.getAgentsByID(e)[0]||u.agents[0]||console.warn(`ASYNergy: couldn't find agent with ID: ${e}`)}} /*! * ASYNergy * @@ -6,9 +6,9 @@ var _asynergy=function(){"use strict";function e(t,s){if(!1===s(t))return;let a= * inspired by and adopted from Livewire * * a framework for making network requests * * and changing things on the page * - * Version 0.2.1 * + * Version 0.3.0 * * * Author: Ralf Bitter, rabit@revigniter.com * - */class w{constructor(){this.appVersion="0.2.1",this.agents=u,this.URL=""}get version(){return this.appVersion}set theURL(e){this.URL=e}get theURL(){return this.URL}hook(e,t){this.agents.registerHook(e,t)}emit(e,...t){this.agents.emit(e,...t)}on(e,t){this.agents.on(e,t)}stop(){this.agents.tearDownAgents()}reregisterEventListeners(){const t=""!==this.URL?this.URL:window.location.href;e(document.body,e=>{v.initialize(e,t,!0)})}start(){const t=""!==this.URL?this.URL:window.location.href,s=document.body;document.addEventListener("visibilitychange",()=>{u.asynergyIsInBackground=document.hidden},!1),window.addEventListener("offline",()=>{u.asynergyIsOffline=!0}),window.addEventListener("online",()=>{u.asynergyIsOffline=!1}),e(s,e=>{v.initialize(e,t)})}}return window.ASYNergy||(window.ASYNergy=w),function(){let e=!1,t=new Set;S.clearState();let s=!1;u.registerHook("agent.initialized",a=>{if(!0===u.mutableIncludesModel&&!1===e){let i=window.location.href,n=0,l={};for(const e in u.mutables)l[n+=1]={mutableID:u.mutables[e].el.id,syncModelID:"",mutableVal:u.mutables[e].el.innerHTML,mutableAttrVal:u.mutables[e].el.getAttribute("asyn:mutable")};let r={asynergyResponse:l};S.replaceState(i,r,a),t.add(a.agentID),e=!0,s=!0}}),u.registerHook("allMessages.processed",e=>{if(!0===s){if(e.replaying)return;let{response:t}=e,s=(t.effects,window.location.href);S.pushState(s,t,e.agent)}}),window.addEventListener("popstate",e=>{if(!0===s){if(S.missingState(e))return;S.replayResponses(e,(t,s)=>{s.connection.updateEl;let a=new f(s,[]);a.storeResponse(t),a.replaying=!0,s.doReplayResponse(e,s,t)})}})}(),u.registerHook("agent.initialized",e=>{e.targetedLoadingElsByAction={},e.genericLoadingEls=[],e.currentlyActiveLoadingEls=[],e.currentlyActiveUploadLoadingEls=[]}),u.registerHook("element.initialized",(e,t)=>{let a=s(e);a.missing("loading")||a.directives.filter(e=>"loading"===e.type)}),u.registerHook("message.sent",(e,t)=>{t.updateQueue.filter(e=>"callHandler"===e.type).map(e=>e.payload.modelAttrVal),t.updateQueue.filter(e=>"callHandler"===e.type).map(e=>(function(e,t){return e+btoa(encodeURIComponent(e.toString()))})(e.payload.modelAttrVal,e.payload.params)),t.updateQueue.filter(e=>"syncInput"===e.type).map(e=>{let t=e.payload.modelAttrVal;if(!t.includes("."))return t;let s=[];return s.push(t.split(".").reduce((e,t)=>(s.push(e),e+"."+t))),s}).flat()}),u.registerHook("element.initialized",(e,t)=>{s(e).missing("submit")||e.addEventListener("submit",()=>{A[t.agentID]=[],t.walk(s=>{if(e.contains(s))return!s.hasAttribute("asyn:ignore")&&void("button"===s.tagName.toLowerCase()&&"submit"===s.type||"select"===s.tagName.toLowerCase()||"input"===s.tagName.toLowerCase()&&("checkbox"===s.type||"radio"===s.type)?(s.disabled||A[t.agentID].push(()=>s.disabled=!1),s.disabled=!0,u.addDisabledNode(s)):"input"!==s.tagName.toLowerCase()&&"textarea"!==s.tagName.toLowerCase()||(s.readOnly||A[t.agentID].push(()=>s.readOnly=!1),s.readOnly=!0,u.addReadOnlyNode(s)))})})}),u.registerHook("message.failed",(e,t)=>E(t)),u.registerHook("message.received",(e,t)=>E(t)),u.registerHook("element.initialized",(e,t)=>{if(void 0===s(e).get("poll"))return;let a=function(e,t){let a=s(e).get("poll").durationOr(2e3);return setInterval(()=>{if(!1===e.isConnected)return;const a=s(e).get("poll");if(void 0===a)return;const i=a.handler||"refresh";u.asynergyIsInBackground&&!a.modifiers.includes("keep-alive")&&Math.random()<.95||a.modifiers.includes("visible")&&!function(e){var t=e.getBoundingClientRect();return t.top<(window.innerHeight||document.documentElement.clientHeight)&&t.left<(window.innerWidth||document.documentElement.clientWidth)&&t.bottom>0&&t.right>0}(a.el)||u.asynergyIsOffline||t.addAction(new y(i,a.params,a.modelValue,a.emitEvent,e))},a)}(e,t);t.addListenerForTeardown(()=>{clearInterval(a)}),e.__asynergy_polling_interval=a}),w}(); + */let w=class{constructor(){this.appVersion="0.3.0",this.agents=u,this.URL=""}get version(){return this.appVersion}set theURL(e){this.URL=e}get theURL(){return this.URL}hook(e,t){this.agents.registerHook(e,t)}emit(e,...t){this.agents.emit(e,...t)}on(e,t){this.agents.on(e,t)}stop(){this.agents.tearDownAgents()}reregisterEventListeners(){const t=""!==this.URL?this.URL:window.location.href;e(document.body,(e=>{v.initialize(e,t,true)}))}start(){const t=""!==this.URL?this.URL:window.location.href,s=document.body;document.addEventListener("visibilitychange",(()=>{u.asynergyIsInBackground=document.hidden}),!1),window.addEventListener("offline",(()=>{u.asynergyIsOffline=!0})),window.addEventListener("online",(()=>{u.asynergyIsOffline=!1})),e(s,(e=>{v.initialize(e,t)}))}};window.ASYNergy||(window.ASYNergy=w),function(){let e=!1,t=new Set;S.clearState();let s=!1;u.registerHook("agent.initialized",(a=>{if(!0===u.mutableIncludesModel&&!1===e){let i=window.location.href,n=0,l={};for(const e in u.mutables)n+=1,l[n]={mutableID:u.mutables[e].el.id,syncModelID:"",mutableVal:u.mutables[e].el.innerHTML,mutableAttrVal:u.mutables[e].el.getAttribute("asyn:mutable")};let r={asynergyResponse:l};S.replaceState(i,r,a),t.add(a.agentID),e=!0,s=!0}})),u.registerHook("allMessages.processed",(e=>{if(!0===s){if(e.replaying)return;let{response:t}=e;t.effects;let s=window.location.href;S.pushState(s,t,e.agent)}})),window.addEventListener("popstate",(e=>{if(!0===s){if(S.missingState(e))return;S.replayResponses(e,((t,s)=>{s.connection.updateEl;let a=new f(s,[]);a.storeResponse(t),a.replaying=!0,s.doReplayResponse(e,s,t)}))}}))}(),u.registerHook("agent.initialized",(e=>{e.targetedLoadingElsByAction={},e.genericLoadingEls=[],e.currentlyActiveLoadingEls=[],e.currentlyActiveUploadLoadingEls=[]})),u.registerHook("element.initialized",((e,t)=>{let a=s(e);a.missing("loading")||a.directives.filter((e=>"loading"===e.type))})),u.registerHook("message.sent",((e,t)=>{t.updateQueue.filter((e=>"callHandler"===e.type)).map((e=>e.payload.modelAttrVal)),t.updateQueue.filter((e=>"callHandler"===e.type)).map((e=>{return t=e.payload.modelAttrVal,e.payload.params,t+btoa(encodeURIComponent(t.toString()));var t})),t.updateQueue.filter((e=>"syncInput"===e.type)).map((e=>{let t=e.payload.modelAttrVal;if(!t.includes("."))return t;let s=[];return s.push(t.split(".").reduce(((e,t)=>(s.push(e),e+"."+t)))),s})).flat()})),u.registerHook("element.initialized",((e,t)=>{s(e).missing("submit")||e.addEventListener("submit",(()=>{A[t.agentID]=[],t.walk((s=>{if(e.contains(s))return!s.hasAttribute("asyn:ignore")&&void("button"===s.tagName.toLowerCase()&&"submit"===s.type||"select"===s.tagName.toLowerCase()||"input"===s.tagName.toLowerCase()&&("checkbox"===s.type||"radio"===s.type)?(s.disabled||A[t.agentID].push((()=>s.disabled=!1)),s.disabled=!0,u.addDisabledNode(s)):"input"!==s.tagName.toLowerCase()&&"textarea"!==s.tagName.toLowerCase()||(s.readOnly||A[t.agentID].push((()=>s.readOnly=!1)),s.readOnly=!0,u.addReadOnlyNode(s)))}))}))})),u.registerHook("message.failed",((e,t)=>E(t))),u.registerHook("message.received",((e,t)=>E(t))),u.registerHook("element.initialized",((e,t)=>{if(void 0===s(e).get("poll"))return;let a=function(e,t){let a=s(e).get("poll").durationOr(2e3);return setInterval((()=>{if(!1===e.isConnected)return;const a=s(e).get("poll");if(void 0===a)return;const i=a.handler||"refresh";u.asynergyIsInBackground&&!a.modifiers.includes("keep-alive")&&Math.random()<.95||a.modifiers.includes("visible")&&!function(e){var t=e.getBoundingClientRect();return t.top<(window.innerHeight||document.documentElement.clientHeight)&&t.left<(window.innerWidth||document.documentElement.clientWidth)&&t.bottom>0&&t.right>0}(a.el)||u.asynergyIsOffline||t.addAction(new y(i,a.params,a.modelValue,a.emitEvent,e))}),a)}(e,t);t.addListenerForTeardown((()=>{clearInterval(a)})),e.__asynergy_polling_interval=a}))}(); //# sourceMappingURL=asynergy.js.map \ No newline at end of file diff --git a/assets/js/ASYNergy/asynergy.js.map b/assets/js/ASYNergy/asynergy.js.map index 94b83399..2dca9c02 100644 --- a/assets/js/ASYNergy/asynergy.js.map +++ b/assets/js/ASYNergy/asynergy.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/util/walkDOM.js","../src/util/debounce.js","../src/util/asynDirectives.js","../src/action/index.js","../src/action/event.js","../src/util/dispatch.js","../src/MessageBus.js","../src/HookManager.js","../src/Store.js","../src/DirectiveManager.js","../src/action/deferred-model.js","../src/action/Deferred.js","../src/connection/index.js","../src/dom/dom.js","../src/action/handler.js","../src/action/model.js","../src/Message.js","../src/agent/index.js","../src/init_tasks.js","../src/util/index.js","../src/agent/DisableForms.js","../src/agent/SyncBrowserHistory.js","../src/index.js","../src/agent/LoadingStates.js","../src/agent/Polling.js"],"names":["walkDOM","rootEl","callback","node","firstElementChild","nextElementSibling","debounce","func","wait","immediate","timeout","context","this","args","arguments","later","apply","callNow","clearTimeout","setTimeout","asynDirectives","el","DirectiveManager","[object Object]","directives","extractTypeModifiersAndValue","type","map","directive","includes","has","find","Array","from","getAttributeNames","filter","name","match","RegExp","modifiers","replace","split","Directive","fullName","eventContext","lcFunc","emitEvent","isEmitEvent","theBool","value","getAttribute","lcFunction","fullVal","search","modelValue","undefined","innerText","handler","parseOutHandlerAndParams","params","defaultDuration","durationInMilliSeconds","durationInMilliSecondsString","mod","durationInSecondsString","Number","rawHandler","handlerAndParamString","Function","fallback","time","modelDebounceCallbacks","callbackRegister","push","e","Action","skipWatcher","updateQueue","EventAction","modelAttrVal","modelVal","isCustomEvent","super","payload","btoa","encodeURIComponent","event","JSON","stringify","dispatch","eventName","options","theHandler","CustomEvent","addEventListener","dispatchEvent","MessageBus","listeners","forEach","Object","keys","HookManager","availableHooks","bus","register","call","store","csrf","transmissionEls","mutables","mutableElem","url","asynergyIsInBackground","asynergyIsOffline","hooks","agents","nodesSetToDisabled","nodesSetToReadOnly","mutableIncludesModel","key","agent","length","agentID","agentsLength","i","index","removeAgent","agentsListeningForEvent","addAction","theAgents","directiveParams","handlerName","on","paramsA","modelParams","selectValues","isArray","toString","checked","detail","option","indexOf","setAttribute","removeAttribute","tearDown","splice","listenerType","modelValueKey","transmissionElIsCheckbox","transmissionElIsRadio","transmissionElIsMutable","mutable","isChecked","transmissionElsData","tagName","innerHTML","modelData","theNode","disabled","readOnly","mutablesData","mutableAttrVal","mutableInnerHTML","id","DeferredModelAction","Deferred","deferredActions","deferredActionsData","payloadDeferred","action","hasOwnProperty","actionData","exec","substr","Connection","URL","updateEl","modelEl","ajax","completed_callback","headers","asynPayload","actionType","modelSyncTimeout","reregisterEvLis","message","receiveMessage","responseObj","fetchedResponse","connection","callHook","values","asynergyResponse","respItem","mutableVal","updated","updateMutablesByID","updateMutablesByAttrVal","syncModels","location","ASYNergy","reregisterEventListeners","msg","clearDisabledReadOnlyNodesArrays","updates","tokenName","token","mutabelsData","deferredModelData","fetch","method","Content-Type","X-Requested-With","Accept","X-ASYNergy","Referer","window","href","body","then","response","ok","text","parse","onMessage","handleResponse","catch","error","console","warn","mutableID","theID","document","getElementById","nodeName","attrValFragments","attrValPrefix","syncModelID","modelID","timer","model","mutableEl","timeOut","DOM","allModelElementsInside","root","querySelectorAll","getByAttributeAndValue","attribute","querySelector","hasAttribute","hasFocus","activeElement","isInput","toUpperCase","isTextInput","modelName","get","mergeCheckboxValueIntoArray","multiple","getSelectValues","arrayValue","concat","item","modelString","data","toLowerCase","setInputValue","valueFound","val","updateSelect","selected","arrayWrappedValue","HandlerAction","ModelAction","Message","update","Agent","postValue","messageInTransit","tearDownCallbacks","scopedListeners","fireMessage","entries","unshift","sendMessage","storeResponse","callbackWhenNewComponentIsEncountered","isSameNode","teardownCallback","nodeInitializer","reregisterEvl","isAgent","all","directiveVal","compoundAttrVal","attr","modelAttr","modelElem","attachModelListener","attachDomListener","theAgent","eventType","isLazy","hasDebounceModifier","initConnection","addAgent","condition","modelSyncDebounce","debounceIf","target","documentMode","valueFromInput","durationOr","addEmitEvent","addListenerForTeardown","removeEventListener","test","navigator","userAgent","animationName","Event","bubbles","attachListener","selectedSystemKeyModifiers","keyCode","modifier","Boolean","subject","kebabCase","callAfterModelDebounce","setEventContext","preventAndStop","debouncedHandler","preventDefault","stopPropagation","attrVal","escapedStr","str","x","cleanupStackByAgentId","cleanup","shift","ASYNergyStateManager","updateState","state","currentState","stateArray","toStateArray","fullstateObject","assign","history","charAt","slice","capitalize","decodeURI","replaceAll","storeInSession","asynergy","ASYNergyState","getFromSession","replayResponses","missingState","Date","getTime","stringifiedValue","tryToStoreInSession","sessionStorage","setItem","code","oldestTimestamp","sort","removeItem","getItem","items","signature","targetItem","existingIndex","findIndex","pushItemInProperOrder","findAgentBySignature","getAgentsByID","appVersion","version","theURL","registerHook","emit","tearDownAgents","initialize","bodyEl","hidden","initializedPath","agentIdsThatAreWritingToHistoryState","Set","clearState","browserHistoryOn","responseItemNum","mutablesItem","replaceState","add","replaying","effects","pushState","doReplayResponse","SyncBrowserHistory","targetedLoadingElsByAction","genericLoadingEls","currentlyActiveLoadingEls","currentlyActiveUploadLoadingEls","missing","generateSignatureFromHandlerAndParams","modelActions","reduce","fullAction","part","flat","walk","contains","addDisabledNode","addReadOnlyNode","intervalId","interval","setInterval","isConnected","Math","random","bounding","getBoundingClientRect","top","innerHeight","documentElement","clientHeight","left","innerWidth","clientWidth","bottom","right","inViewport","fireActionOnInterval","clearInterval","__asynergy_polling_interval"],"mappings":"sCAAO,SAASA,EAAQC,EAAQC,GAC5B,IAAyB,IAArBA,EAASD,GACT,OAGJ,IAAIE,EAAOF,EAAOG,kBAElB,KAAOD,GACHH,EAAQG,EAAMD,GACdC,EAAOA,EAAKE,mBCTb,SAASC,EAASC,EAAMC,EAAMC,GACjC,IAAIC,EACJ,OAAO,WACH,IAAIC,EAAUC,KACVC,EAAOC,UACPC,EAAQ,WACRL,EAAU,KACLD,GACDF,EAAKS,MAAML,EAASE,IAIxBI,EAAUR,IAAcC,EAC5BQ,aAAaR,GACbA,EAAUS,WAAWJ,EAAOP,GACxBS,GACAV,EAAKS,MAAML,EAASE,IChBzB,SAASO,EAAeC,GAC3B,OAAO,IAAIC,EAAiBD,GAGhC,MAAMC,EACFC,YAAYF,GACRT,KAAKS,GAAKA,EACVT,KAAKY,WAAaZ,KAAKa,+BAG3BF,MACI,OAAOX,KAAKY,WAGhBD,IAAIG,GACA,OAAOd,KAAKY,WAAWG,IAAIC,GAAaA,EAAUF,MAAMG,SAASH,GAGrEH,QAAQG,GACJ,OAAQd,KAAKkB,IAAIJ,GAGrBH,IAAIG,GACA,OAAOd,KAAKY,WAAWO,KAAKH,GAAaA,EAAUF,OAASA,GAGhEH,+BACI,OAAOS,MAAMC,KAAKrB,KAAKS,GAAGa,oBAGzBC,OAAOC,GAAQA,EAAKC,MAAM,IAAIC,OAAO,WAGrCX,IAAIS,IACG,MAAOV,KAASa,GAAaH,EAAKI,QAAQ,IAAIF,OAAO,SAAU,IAAIG,MAAM,KAEzE,OAA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B+BC,CAAWzZ,EAAUP,KAKjEqF,EAAMO,mBAGVO,EAAMQ,UAAU,IAAIiJ,EAAcxN,EAAS7B,EAAU+B,OAAQ/B,EAAU0B,WAAY1B,EAAUkB,UAAW3C,KACzGka,GA/CkBiB,CAAqBja,EAAImG,GAE1CA,EAAMmM,uBAAuB,KAC3B4H,cAAcnB,KAGhB/Y,EAAGma,4BAA8BpB","sourcesContent":["export function walkDOM(rootEl, callback) {\n if (callback(rootEl) === false) {\n return;\n }\n\n let node = rootEl.firstElementChild;\n\n while (node) {\n walkDOM(node, callback);\n node = node.nextElementSibling;\n }\n}\n","export function debounce(func, wait, immediate) {\n var timeout;\n return function () {\n var context = this;\n var args = arguments;\n var later = function () {\n timeout = null;\n if (!immediate) {\n func.apply(context, args);\n }\n };\n\n var callNow = immediate && !timeout;\n clearTimeout(timeout);\n timeout = setTimeout(later, wait);\n if (callNow) {\n func.apply(context, args);\n }\n };\n}\n","export function asynDirectives(el) {\n return new DirectiveManager(el);\n}\n\nclass DirectiveManager {\n constructor(el) {\n this.el = el;\n this.directives = this.extractTypeModifiersAndValue();\n }\n\n all() {\n return this.directives;\n }\n\n has(type) {\n return this.directives.map(directive => directive.type).includes(type);\n }\n\n missing(type) {\n return !this.has(type);\n }\n\n get(type) {\n return this.directives.find(directive => directive.type === type);\n }\n\n extractTypeModifiersAndValue() {\n return Array.from(this.el.getAttributeNames()\n\n // FILTER ONLY THE ASYNergy DIRECTIVES\n .filter(name => name.match(new RegExp('asyn:')))\n\n // PARSE OUT THE TYPE, MODIFIERS, AND VALUE FROM IT\n .map(name => {\n const [type, ...modifiers] = name.replace(new RegExp('asyn:'), '').split('.');\n\n return new Directive(type, modifiers, name, this.el);\n }));\n }\n}\n\nclass Directive {\n constructor(type, modifiers, fullName, el) {\n this.type = type;\n this.modifiers = modifiers;\n this.fullName = fullName;\n this.el = el;\n this.eventContext;\n this.lcFunc = null;\n this.emitEvent = false;\n }\n\n setEventContext(context) {\n this.eventContext = context;\n }\n \n get isEmitEvent() {\n return emitEvent;\n }\n \n set isEmitEvent(theBool) {\n if (typeof theBool == \"boolean\") {\n this.emitEvent = theBool;\n }\n }\n\n get value() {\n return this.el.getAttribute(this.fullName);\n }\n \n get lcFunction() {\n if (this.fullName === \"asyn:mutable\") {\n const fullVal = this.el.getAttribute(this.fullName);\n\n // GET LIVECODE FUNCTION TO BE CALLED\n const pos = fullVal.search(/\\./);\n if (pos !== -1) {\n this.lcFunc = fullVal.split(\".\")[1];\n }\n }\n return this.lcFunc;\n }\n \n get modelValue() {\n return this.el.value !== undefined ? this.el.value : this.el.innerText;\n }\n\n get handler() {\n const { handler } = this.parseOutHandlerAndParams(this.value);\n return handler;\n }\n\n get params() {\n const { params } = this.parseOutHandlerAndParams(this.value);\n\n return params;\n }\n\n durationOr(defaultDuration) {\n let durationInMilliSeconds;\n const durationInMilliSecondsString = this.modifiers.find(mod => mod.match(/([0-9]+)ms/));\n const durationInSecondsString = this.modifiers.find(mod => mod.match(/([0-9]+)s/));\n\n if (durationInMilliSecondsString) {\n durationInMilliSeconds = Number(durationInMilliSecondsString.replace('ms', ''));\n } else if (durationInSecondsString) {\n durationInMilliSeconds = Number(durationInSecondsString.replace('s', '')) * 1000;\n }\n\n return durationInMilliSeconds || defaultDuration;\n }\n\n parseOutHandlerAndParams(rawHandler) {\n let handler = rawHandler;\n let params = [];\n const handlerAndParamString = handler.match(/(.*?)\\((.*)\\)/s);\n\n if (handlerAndParamString) {\n handler = handlerAndParamString[1];\n\n // USE A FUNCTION THAT RETURNS IT'S ARGUMENTS TO PARSE AND EVAL ALL PARAMS\n // THIS \"$EVENT\" IS FOR USE INSIDE THE ASYNergy EVENT HANDLER\n // ---------------- $event NOT USED ----------------------- //\n let func = new Function('$event', `return (function () {\n for (var l=arguments.length, p=new Array(l), k=0; k { } };\n\n this.modelDebounceCallbacks.push(callbackRegister);\n\n // This is a normal \"timeout\" for a debounce function.\n var timeout;\n\n return e => {\n clearTimeout(timeout);\n\n timeout = setTimeout(() => {\n callback(e);\n timeout = undefined;\n\n // Because we just called the callback, let's return the\n // callback register to it's normal \"null\" state.\n callbackRegister.callback = () => { };\n }, time);\n\n // Register the current callback in the register as a kind-of \"escape-hatch\".\n callbackRegister.callback = () => {\n clearTimeout(timeout);\n callback(e);\n };\n };\n }\n}\n","export default class {\n constructor(el, skipWatcher = false) {\n this.el = el;\n this.skipWatcher = skipWatcher;\n this.updateQueue = [];\n }\n}\n","import Action from '.';\n\nexport default class extends Action {\n constructor(modelAttrVal, params, modelVal, isCustomEvent, el) {\n super(el);\n\n this.isCustomEvent = isCustomEvent;\n this.type = 'fireEvent';\n this.name = modelAttrVal;\n this.payload = {\n modelAttrVal,\n params,\n modelVal\n };\n }\n\n // Overriding toId() becuase some EventActions don't have an \"el\"\n toId() {\n return btoa(encodeURIComponent(this.type, this.payload.event, JSON.stringify(this.payload.params)));\n }\n}\n","export function dispatch(el, eventName, options, theHandler) {\n const event = new CustomEvent(eventName, options);\n el.addEventListener(eventName, theHandler);\n el.dispatchEvent(event);\n}","\nexport default class MessageBus {\n constructor() {\n this.listeners = {};\n }\n\n register(name, callback) {\n if (!this.listeners[name]) {\n this.listeners[name] = [];\n }\n\n this.listeners[name].push(callback);\n }\n\n call(name, ...params) {\n (this.listeners[name] || []).forEach(callback => {\n callback(...params);\n });\n }\n\n has(name) {\n return Object.keys(this.listeners).includes(name);\n }\n}\n","import MessageBus from './MessageBus';\n\nexport default {\n\tavailableHooks: [\n\t\t/**\n\t\t* Public Hooks\n\t\t*/\n\t\t'agent.initialized',\n\t\t'element.initialized',\n\t\t'element.updating',\n\t\t'element.updated',\n\t\t'element.removed',\n\t\t'message.sent',\n\t\t'message.failed',\n\t\t'message.received',\n\t\t'message.processed',\n\t\t'allMessages.processed',\n\t\t'request',\n\n\t\t/**\n\t\t* Private Hooks\n\t\t*/\n\t\t'interceptAsynModelSetValue',\n\t\t'interceptAsynModelAttachListener',\n\t\t'beforeReplaceState',\n\t\t'beforePushState'\n\t],\n\n bus: new MessageBus(),\n\n register(name, callback) {\n if (!this.availableHooks.includes(name)) {\n throw `ASYNergy: Referencing unknown hook: [${name}]`;\n }\n\n this.bus.register(name, callback);\n },\n\n call(name, ...params) {\n this.bus.call(name, ...params);\n }\n};\n","import EventAction from './action/event'; // ----------------------- temp test events\nimport { dispatch } from './util/dispatch'; // ------------------------------ temp test events\nimport HookManager from './HookManager';\nimport MessageBus from './MessageBus'; // -------- temp test events\nimport DirectiveManager from './DirectiveManager';\n// import Agent from './agent/index';\n\nconst store = {\n csrf: {},\n transmissionEls: [],\n mutables: [],\n directives: DirectiveManager,\n asynergyIsInBackground: false,\n asynergyIsOffline: false,\n hooks: HookManager,\n agents: [],\n listeners: new MessageBus(),\n nodesSetToDisabled: [],\n nodesSetToReadOnly: [],\n mutableIncludesModel: false,\n\n theAgents() {\n return Object.keys(this.agents).map(key => {\n return this.agents[key];\n });\n },\n\n registerHook(name, callback) {\n this.hooks.register(name, callback);\n },\n\n callHook(name, ...params) {\n this.hooks.call(name, ...params);\n },\n\n addAgent(agent) {\n this.agents.push(agent);\n return this.agents[this.agents.length - 1];\n },\n\n getAgentsByID(agentID) {\n return this.agents.filter(agent => {\n return agent.agentID === agentID;\n });\n },\n\n tearDownAgents() {\n let agentsLength = this.agents.length;\n for (let i = 0; i < agentsLength; i++) {\n let index = this.agents.length - 1;\n this.removeAgent(this.agents[index], index);\n }\n },\n\n emit(event, ...params) {\n this.listeners.call(event, ...params);\n this.agentsListeningForEvent(event).forEach(agent => {\n agent.addAction(new EventAction(event, params));\n });\n },\n\n agentsListeningForEvent(event) {\n return this.theAgents().filter(agent => {\n return agent.listeners.includes(event);\n });\n },\n \n addEmitEvent(el, directiveParams, handlerName, handler) {\n let options = {};\n const eventHandler = (...paramsA) => {\n \n const modelParams = [];\n modelParams[0] = [];\n let selectValues;\n \n if (paramsA !== undefined & paramsA.length !== 0) {\n if (paramsA[0] !== undefined & paramsA[0].length !== 0) {\n modelParams[0] = paramsA[0].split(',');\n }\n\n if (Array.isArray(paramsA) & (modelParams[0].toString() === directiveParams.toString())) {\n \n switch(el.type) { \n case 'text':\n if (paramsA[1] !== undefined) {\n el.value = paramsA[1];\n }\n\n break;\n \n case 'checkbox':\n if (paramsA[2] !== undefined) {\n el.checked = paramsA[2];\n }\n \n break;\n\t\t\t\t\t\t\n case 'radio':\n if (paramsA[2] !== undefined) {\n el.checked = paramsA[2];\n }\n \n break;\n \n case 'select-multiple':\n if (paramsA[1] !== undefined) {\n selectValues = paramsA[1].split(',');\n }\n \n if (selectValues !== undefined) {\n options.detail = selectValues;\n }\n\n for (const option of el.options) {\n if (selectValues.indexOf(option.value) !== -1) {\n option.setAttribute('selected', 'selected');\n } else {\n option.removeAttribute('selected');\n }\n }\n \n break;\n\n case 'submit':\n if ( paramsA[1] !== undefined) {\n const modelValue = paramsA[1].split(',');\n \n if (modelValue !== undefined) {\n options.detail = modelValue;\n }\n }\n \n break;\n }\n\n dispatch(el, handlerName, options, handler);\n }\n } else { // if (paramsA !== undefined)\n dispatch(el, handlerName, options, handler);\n }\n };\n this.on(handlerName, eventHandler);\n },\n\n on(event, callback) {\n this.listeners.register(event, callback);\n },\n\n removeAgent(agent, index) {\n // Remove event listeners attached to the DOM.\n agent.tearDown();\n // Remove the component from the store.\n // delete this.agents[index];\n this.agents.splice(index, 1);\n },\n\n transmissionElsData(payload, listenerType, modelValueKey) {\n if (this.transmissionEls[0] !== undefined) {\n let index;\n for (index = 0; index < this.transmissionEls.length; index++) {\n if (this.transmissionEls[index].getAttribute('asyn:transmit') !== null) {\n\n const transmissionElIsCheckbox = this.transmissionEls[index].type === 'checkbox';\n\t\t\t\t\t\t\tconst transmissionElIsRadio = this.transmissionEls[index].type === 'radio';\n const transmissionElIsMutable = this.transmissionEls[index].mutable >= 0;\n\t\t\t\t\t\t\t\n if (transmissionElIsCheckbox) {\n const isChecked = this.transmissionEls[index].checked;\n payload.transmissionElsData[this.transmissionEls[index].getAttribute('asyn:transmit')] = isChecked ? this.transmissionEls[index].value : 'false';\n\t\t\t\t\t\t\t\n\t } else if (transmissionElIsRadio) {\n\t const isChecked = this.transmissionEls[index].checked;\n\t if (isChecked) {\n\t payload.transmissionElsData[this.transmissionEls[index].getAttribute('asyn:transmit')] = this.transmissionEls[index].value;\n\t }\n\t\t\t\t\t\t\t\n } else {\n payload.transmissionElsData[this.transmissionEls[index].getAttribute('asyn:transmit')] = (this.transmissionEls[index].tagName === 'INPUT') || (this.transmissionEls[index].tagName === 'TEXTAREA') || (this.transmissionEls[index].tagName === 'SELECT') ? this.transmissionEls[index].value : this.transmissionEls[index].innerHTML;\n\n // REPLACE CHECKBOX MODEL VALUE WITH MUTABLE ELEMENT DATA\n if (listenerType === 'checkbox' && transmissionElIsMutable) {\n payload.modelData[modelValueKey] = this.transmissionEls[index].innerHTML;\n }\n\n }\n }\n }\n }\n return payload;\n },\n\n addDisabledNode(theNode) {\n this.nodesSetToDisabled.push(theNode);\n },\n\n addReadOnlyNode(theNode) {\n this.nodesSetToReadOnly.push(theNode);\n },\n\n clearDisabledReadOnlyNodesArrays() {\n let index;\n\n for (index = 0; index < this.nodesSetToDisabled.length; index++) {\n this.nodesSetToDisabled[index].disabled = false;\n }\n this.nodesSetToDisabled.length = 0;\n\n for (index = 0; index < this.nodesSetToReadOnly.length; index++) {\n this.nodesSetToReadOnly[index].readOnly = false;\n }\n this.nodesSetToReadOnly.length = 0;\n },\n\n mutabelsData(payload) {\n if (this.mutables[0] !== undefined) {\n let index;\n for (index = 0; index < this.mutables.length; index++) {\n\n payload.mutablesData[index] = {};\n payload.mutablesData[index].mutableAttrVal = this.mutables[index].value;\n payload.mutablesData[index].el = this.mutables[index].el;\n payload.mutablesData[index].mutableInnerHTML = this.mutables[index].el.innerHTML;\n payload.mutablesData[index].lcFunc = this.mutables[index].lcFunc;\n payload.mutablesData[index].id = this.mutables[index].el.id;\n }\n } else {\n payload.mutablesData = null;\n }\n \n return payload;\n }\n};\n\nexport default store;\n","import MessageBus from './MessageBus';\n\nexport default {\n directives: new MessageBus(),\n\n register(name, callback) {\n if (this.has(name)) {\n throw `ASYNergy: Directive already registered: [${name}]`;\n }\n\n this.directives.register(name, callback);\n },\n\n call(name, el, directive, mutableElem, url) {\n this.directives.call(name, el, directive, mutableElem, url);\n },\n\n has(name) {\n return this.directives.has(name);\n }\n};\n","import Action from '.';\n\nexport default class extends Action {\n constructor(modelAttrVal, params, modelVal, isCustomEvent, el, skipWatcher = false) {\n super(el, skipWatcher);\n\n this.isCustomEvent = isCustomEvent;\n this.type = 'syncInput';\n this.name = modelAttrVal;\n this.payload = {\n modelAttrVal,\n params,\n modelVal\n };\n }\n}\n","import DeferredModelAction from './deferred-model';\n\nexport default {\n deferredActions: {},\n\n addAction(name, value, el) {\n if (!this.deferredActions[name]) {\n new DeferredModelAction(name, value, el);\n this.deferredActions[name] = [];\n }\n\n this.deferredActions[name].push(value);\n this.deferredActions[name].push(el);\n },\n\n get deferredActionsData() {\n let payloadDeferred = {};\n\n if (this.deferredActions.length !== 0) {\n\n // GET NAMES AND VALUES OF DEFERRED ACTIONS\n for (let action in this.deferredActions) {\n if (this.deferredActions.hasOwnProperty(action)) {\n let actionData = this.deferredActions[action];\n\n // actionData[0], IS THE INITIAL VALUE actionData[1] IS THE ELEMENT\n // this.asynPayload[action] = actionData[1].value;\n // USE THE ACTION SUFFIX AS PAYLOAD KEY\n\n // REGULAR EXPRESSION (?<=(\\.)).+$ DOES NOT WORK WITH WEBKIT\n // DUE TO LOOKBEHIND. WE USE (?:(\\.)).+$ AND STRIP THE FIRST\n // CHARACTER, A DOT IN THIS CASE\n // const actionSuffix = /(?<=(\\.)).+$/.exec(action);\n // this.asynPayload[actionSuffix[0]] = actionData[1].value;\n const actionExecResult = /(?:(\\.)).+$/.exec(action);\n const actionSuffix = actionExecResult[0].substr(1);\n payloadDeferred[actionSuffix] = actionData[1].value;\n }\n }\n }\n return payloadDeferred;\n }\n};\n","import store from '../Store';\nimport Deferred from '../action/Deferred';\n\nexport default class Connection {\n\tconstructor(URL, updateEl, modelAttrVal, modelEl, event) {\n\t\tthis.url = URL;\n\t\tthis.updateEl = updateEl;\n\t\t// this.postKey = postKey;\n\t\tthis.modelAttrVal = modelAttrVal;\n\t\tthis.event = event;\n\t\tthis.action = this.ajax;\n\t\tthis.callback = this.completed_callback;\n\t\tthis.headers = {};\n\t\tthis.options = {};\n\t\tthis.options.headers = this.headers;\n\t\tthis.asynPayload = {};\n\t\tthis.mutablesData = [];\n\t\tthis.modelEl = modelEl;\n\t\tthis.actionType = '';\n\t\tthis.modelSyncTimeout = 1000;\n\t\tthis.isCustomEvent = undefined;\n\t\tthis.reregisterEvLis = false;\n\t}\n\t\t\n\t\t\n onMessage(message, payload) {\n message.agent.receiveMessage(message, payload);\n }\n \n handleResponse(event, agent, responseObj, fetchedResponse) {\n if (fetchedResponse !== true) {\n this.event = event;\n this.updateEl = agent.connection.updateEl;\n };\n \n store.callHook('element.updating', this.updateEl, agent, event);\n\n Object.values(responseObj.asynergyResponse).forEach(respItem => {\n if (respItem.url !== undefined) {\n location = respItem.url;\n return;\n }\n\n if ((respItem.mutableVal === null) || (typeof(respItem.mutableVal) === \"object\") &&\n (Object.keys(respItem.mutableVal).length === 0)) {\n respItem.mutableVal = \"\";\n }\n\n if ((typeof respItem.mutableVal === \"string\") && (respItem.mutableVal.search(/asyn:/)) !== -1) {\n this.reregisterEvLis = true;\n }\n\n this.updateEl.updated = 0;\n\n this.updateMutablesByID(respItem);\n \n this.updateMutablesByAttrVal(respItem);\n \n if (this.updateEl.updated === 0) {\n this.updateEl.innerHTML = respItem.mutableVal;\n }\n \n store.callHook('element.updated', this.updateEl, agent, this.event);\n \n this.syncModels(respItem);\n\n store.callHook('message.processed', this.updateEl, agent, this.event);\n\n });\n\n if (this.reregisterEvLis === true) {\n ASYNergy.reregisterEventListeners();\n };\n\n }\n\t\t\n\n // FETCH COMPLETED ACTION //\n completed_callback(msg) {\n\t\t\tstore.clearDisabledReadOnlyNodesArrays();\n\t\t\tstore.callHook('allMessages.processed', msg);\n }\n \n\n ajax(message) {\n const payload = message.payload();\n const modelVal = payload.updates[0].payload.modelVal;\n const listenerType = message.agent.el.type;\n const modelParams = payload.updates[0].payload.params;\n\n this.asynPayload = {};\n\n this.asynPayload.modelData = {'modelAttrVal': this.modelAttrVal, 'modelVal': modelVal, 'modelParams': modelParams};\n\n // CSRF\n if (store.csrf.tokenName !== undefined && store.csrf.token !== '') {\n this.asynPayload[store.csrf.tokenName] = store.csrf.token;\n }\n \n // GET MUTABLE ELEMENTS DATA\n this.asynPayload.mutablesData = [];\n this.asynPayload = store.mutabelsData(this.asynPayload);\n this.mutablesData = this.asynPayload.mutablesData;\n \n if (this.mutablesData === null) {\n console.warn(\"Missing data of any mutable element!\");\n return;\n }\n \n if (this.updateEl === null) {\n this.updateEl = this.mutablesData[0].el;\n }\n let index;\n\n var mutableAttrVal = this.mutablesData[0].mutableAttrVal;\n\n // GET TRANSMISSION ELEMENTS DATA\n this.asynPayload.transmissionElsData = {};\n this.asynPayload = store.transmissionElsData(this.asynPayload, listenerType, 'modelVal');\n\n // GET DEFERRED MODEL ACTIONS\n this.asynPayload.deferredModelData = Deferred.deferredActionsData;\n\n this.asynPayload.actionType = message.updateQueue[0].type;\n this.actionType = this.asynPayload.actionType;\n \n this.asynPayload.isCustomEvent = message.updateQueue[0].isCustomEvent;\n this.isCustomEvent = this.asynPayload.isCustomEvent;\n\t\t\t\t\n\t\t\t store.callHook('request', this.options, this.mutablesData, this.asynPayload.modelData);\n\n this.asynPayload = JSON.stringify(this.asynPayload);\n\n\n fetch(this.url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'X-Requested-With': 'XMLHttpRequest',\n 'Accept': 'text/html, application/xhtml+xml',\n 'X-ASYNergy': true,\n\n // SET CUSTOM HEADERS\n ...(this.options.headers),\n\n // WE'LL SET THIS EXPLICITLY TO MITIGATE POTENTIAL\n // INTERFERENCE FROM AD-BLOCKERS/ETC.\n 'Referer': window.location.href\n },\n body: this.asynPayload\n }) \n .then(response => {\n if (response.ok) {\n\n response.text().then(response => {\n\n const responseObj = JSON.parse(response);\n\n this.onMessage(message, responseObj);\n \n const fetchedResponse = true;\n \n this.handleResponse(event, message.agent, responseObj, fetchedResponse);\n\n this.callback(message);\n\n });\n }\n })\n \n .catch((error) => {\n console.error(error);\n });\n }\n \n // IF THE RESPONSE INCLUDES IDs OF MUTABLE ELEMENTS\n // UPDATE ALL APPROPRIATE ELEMENTS\n updateMutablesByID (responseObj) {\n if ((responseObj.mutableID !== \"\") && \n (responseObj.mutableID !== null)) {\n const mutableID = responseObj.mutableID;\n \n if (typeof(mutableID) === \"object\") {\n Object.values(mutableID).forEach(theID => {\n this.updateEl = document.getElementById(`${theID}`);\n\n this.updateEl.nodeName === \"INPUT\" ? this.updateEl.value = responseObj.mutableVal : this.updateEl.innerHTML = responseObj.mutableVal;\n this.updateEl.updated = 1;\n });\n } else {\n this.updateEl = document.getElementById(`${mutableID}`);\n this.updateEl.nodeName === \"INPUT\" ? this.updateEl.value = responseObj.mutableVal : this.updateEl.innerHTML = responseObj.mutableVal;\n\n this.updateEl.updated = 1;\n }\n }\n }\n\n // IF MULTIPLE MUTABLE ELEMENTS ARE SPECIFIED BY MUTABLE\n // ATTRIBUTE VALUES IN THE RESPONSE, UPDATE ALL MUTABLE\n // ELEMENTS THAT HAVE THE APPROPRIATE MUTABLE ATTRIBUTE VALUE\n updateMutablesByAttrVal(responseObj) {\n if (responseObj.mutableAttrVal !== \"\") {\n if (this.mutablesData.length > 0) {\n let attrValFragments = [];\n let attrValPrefix = '';\n this.mutablesData.forEach(mutable => {\n const compoundAttrVal = mutable.mutableAttrVal.search(/[.]/);\n if (compoundAttrVal !== -1) {\n attrValFragments = /^.+(?=(\\.))/.exec(mutable.mutableAttrVal);\n attrValPrefix = attrValFragments[0];\n }\n\n if ((mutable.mutableAttrVal === responseObj.mutableAttrVal) || \n (mutable.mutableAttrVal === attrValPrefix) || \n (Object.values(responseObj.mutableAttrVal).indexOf(mutable.mutableAttrVal) > -1)) {\n this.updateEl = mutable.el;\n\n this.updateEl.nodeName === \"INPUT\" ? this.updateEl.value = responseObj.mutableVal : this.updateEl.innerHTML = responseObj.mutableVal;\n this.updateEl.updated = 1;\n }\n \n });\n }\n }\n }\n \n // SYNCHRONIZE ANY MODEL TO THE DATA OF THE MUTABLE ELEMENT\n syncModels(responseObj) {\n if ((responseObj.syncModelID !== \"\") && \n (responseObj.syncModelID !== null)) {\n let modelID = responseObj.syncModelID;\n\n if (this.actionType === \"syncInput\") {\n // SYNCHRONIZING NEEDS A DELAY, OTHERWISE SOME INPUT MAY BE LOST\n let timer;\n const model = document.getElementById(`${modelID}`);\n const mutableEl = this.updateEl;\n const timeOut = this.modelSyncTimeout;\n\n if (model.getAttribute('listener') !== 'true') {\n model.value = mutableEl.innerHTML;\n }\n\n model.addEventListener(\"input\", function (e) {\n model.setAttribute('listener', 'true');\n clearTimeout(timer);\n timer = setTimeout(() => {\n model.value = mutableEl.innerHTML;\n model.removeAttribute('listener');\n }, timeOut);\n });\n \n } else {\n \n const modelID = responseObj.syncModelID;\n \n // IF modelID IS AN OBJECT, THEN THERE ARE MULTIPLE OBJECTS TO BE SYNCED\n if (typeof(modelID) === \"object\") {\n Object.values(modelID).forEach(theID => {\n document.getElementById(`${theID}`).value = responseObj.mutableVal;\n });\n } else {\n // THERE IS ONLY ONE MODEL TO BE SYNCED\n document.getElementById(`${modelID}`).value = responseObj.mutableVal; // ?????????????\n }\n }\n }\n }\n}\n","import { asynDirectives } from '../util/asynDirectives';\n\n/**\n * This is intended to isolate all native DOM operations. The operations that happen\n * one specific element will be instance methods, the operations you would normally\n * perform on the \"document\" (like \"document.querySelector\") will be static methods.\n */\nexport default {\n allModelElementsInside(root) {\n return Array.from(root.querySelectorAll(`[asyn\\\\:model]`));\n },\n\n getByAttributeAndValue(attribute, value) {\n return document.querySelector(`[asyn\\\\:${attribute}=\"${value}\"]`);\n },\n\n hasAttribute(el, attribute) {\n return el.hasAttribute(`asyn:${attribute}`);\n },\n\n getAttribute(el, attribute) {\n return el.getAttribute(`asyn:${attribute}`);\n },\n\n removeAttribute(el, attribute) {\n return el.removeAttribute(`asyn:${attribute}`);\n },\n\n setAttribute(el, attribute, value) {\n return el.setAttribute(`asyn:${attribute}`, value);\n },\n\n hasFocus(el) {\n return el === document.activeElement;\n },\n\n isInput(el) {\n return ['INPUT', 'TEXTAREA', 'SELECT'].includes(\n el.tagName.toUpperCase()\n );\n },\n\n isTextInput(el) {\n return (\n ['INPUT', 'TEXTAREA'].includes(el.tagName.toUpperCase()) &&\n !['checkbox', 'radio'].includes(el.type)\n );\n },\n\n valueFromInput(el, agent) {\n if (el.type === 'checkbox') {\n let modelName = asynDirectives(el).get('model').value;\n // If there is an update from asyn:model.defer in the chamber,\n // we need to pretend that is the actual data from the server.\n let modelValue = agent.deferredActions[modelName]\n ? agent.deferredActions[modelName].asynPayload.value\n // : get(agent.data, modelName);\n : el.checked;\n\n if (Array.isArray(modelValue)) {\n return this.mergeCheckboxValueIntoArray(el, modelValue);\n }\n\n if (el.checked) {\n return el.getAttribute('value') || true;\n } else {\n return false;\n }\n } else if (el.tagName === 'SELECT' && el.multiple) {\n return this.getSelectValues(el);\n }\n\n return el.value;\n },\n\n mergeCheckboxValueIntoArray(el, arrayValue) {\n if (el.checked) {\n return arrayValue.includes(el.value)\n ? arrayValue\n : arrayValue.concat(el.value);\n }\n\n return arrayValue.filter(item => item != el.value);\n },\n \n setInputValueFromModel(el, agent) {\n const modelString = asynDirectives(el).get('model').value;\n const modelValue = get(agent.data, modelString);\n\n // Don't manually set file input's values.\n if (\n el.tagName.toLowerCase() === 'input' &&\n el.type === 'file'\n )\n return;\n\n this.setInputValue(el, modelValue);\n },\n\n setInputValue(el, value) {\n if (el.type === 'radio') {\n el.checked = el.value == value;\n } else if (el.type === 'checkbox') {\n if (Array.isArray(value)) {\n // I'm purposely not using Array.includes here because it's\n // strict, and because of Numeric/String mis-casting, I\n // want the \"includes\" to be \"fuzzy\".\n let valueFound = false;\n value.forEach(val => {\n if (val == el.value) {\n valueFound = true;\n }\n });\n\n el.checked = valueFound;\n } else {\n el.checked = !!value;\n }\n } else if (el.tagName === 'SELECT') {\n this.updateSelect(el, value);\n } else {\n value = value === undefined ? '' : value;\n\n el.value = value;\n }\n },\n\n getSelectValues(el) {\n return Array.from(el.options)\n .filter(option => option.selected)\n .map(option => option.value || option.text);\n },\n\n updateSelect(el, value) {\n const arrayWrappedValue = [].concat(value).map(value => value + '');\n\n Array.from(el.options).forEach(option => {\n option.selected = arrayWrappedValue.includes(option.value);\n });\n }\n};\n","import Action from '.';\n\nexport default class extends Action {\n constructor(modelAttrVal, params, modelVal, isCustomEvent, el, skipWatcher = false) {\n super(el, skipWatcher);\n\n this.isCustomEvent = isCustomEvent;\n this.type = 'callHandler';\n this.name = modelAttrVal;\n this.payload = {\n modelAttrVal,\n params,\n modelVal\n };\n }\n\n}","import Action from '.';\n\nexport default class extends Action {\n constructor(modelAttrVal, params, modelVal, isCustomEvent, el) {\n super(el);\n\n this.isCustomEvent = isCustomEvent;\n this.type = 'syncInput';\n this.name = modelAttrVal;\n this.payload = {\n // id: this.signature,\n modelAttrVal,\n params,\n modelVal\n };\n }\n}\n","export default class {\n constructor(agent, updateQueue) {\n this.agent = agent;\n this.updateQueue = updateQueue;\n }\n\n payload() {\n return {\n // This ensures only the type & payload properties only get sent over.\n updates: this.updateQueue.map(update => ({\n type: update.type,\n payload: update.payload\n }))\n };\n }\n\n storeResponse(payload) {\n return (this.response = payload);\n }\n\n}\n","import Message from '../Message';\nimport { debounce } from '../util/debounce';\nimport store from '../Store';\nimport DeferredModelAction from '../action/deferred-model';\nimport { walkDOM } from '../util/walkDOM';\nimport MessageBus from '../MessageBus';\n\nexport default class {\n constructor(el, connection, postValue, agentID) {\n this.el = el;\n this.updateQueue = [];\n this.deferredActions = {}; // temp test\n this.messageInTransit = undefined;\n this.connection = connection;\n this.postValue = postValue;\n this.agentID = agentID;\n this.tearDownCallbacks = [];\n this.scopedListeners = new MessageBus();\n this.listeners = [];\n store.callHook('agent.initialized', this);\n }\n\n on(event, callback) {\n this.scopedListeners.register(event, callback);\n }\n\n addAction(action) {\n if (action instanceof DeferredModelAction) {\n this.deferredActions[action.name] = action;\n\n return;\n }\n\n this.updateQueue.push(action);\n\n // This debounce is here in-case two events fire at the \"same\" time:\n // For example: if you are listening for a click on element A,\n // and a \"blur\" on element B. If element B has focus, and then,\n // you click on element A, the blur event will fire before the \"click\"\n // event. This debounce captures them both in the actionsQueue and sends\n // them off at the same time.\n // Note: currently, it's set to 5ms, that might not be the right amount, we'll see.\n debounce(this.fireMessage, 5).apply(this);\n\n // Clear prefetches.\n // this.prefetchManager.clearPrefetches()\n }\n\n fireMessage() {\n Object.entries(this.deferredActions).forEach(([modelName, action]) => {\n this.updateQueue.unshift(action);\n });\n this.deferredActions = {};\n\n this.messageInTransit = new Message(this, this.updateQueue);\n\n let sendMessage = () => {\n this.connection.action(this.messageInTransit);\n\n store.callHook('message.sent', this, this.messageInTransit);\n\n this.updateQueue = [];\n };\n sendMessage();\n }\n\n receiveMessage(message, payload) {\n message.storeResponse(payload);\n\n // This bit of logic ensures that if actions were queued while a request was\n // out to the server, they are sent when the request comes back.\n if (this.updateQueue.length > 0) {\n this.fireMessage();\n }\n }\n \n doReplayResponse(event, agent, response) {\n this.connection.handleResponse(event, agent, response);\n }\n\n walk(callback, callbackWhenNewComponentIsEncountered = el => { }) {\n walkDOM(this.el, el => {\n // Skip the root component element.\n if (el.isSameNode(this.el)) {\n callback(el);\n return;\n }\n\n if (callback(el) === false) {\n return false;\n }\n });\n }\n\n callAfterModelDebounce(callback) {\n // This is to protect against the following scenario:\n // A user is typing into a debounced input, and hits the enter key.\n // If the enter key submits a form or something, the submission\n // will happen BEFORE the model input finishes syncing because\n // of the debounce. This makes sure to clear anything in the debounce queue.\n\n if (this.modelDebounceCallbacks) {\n this.modelDebounceCallbacks.forEach(callbackRegister => {\n callbackRegister.callback();\n callbackRegister.callback = () => { };\n });\n }\n\n callback();\n }\n\n addListenerForTeardown(teardownCallback) {\n this.tearDownCallbacks.push(teardownCallback);\n }\n\n tearDown() {\n this.tearDownCallbacks.forEach(callback => callback());\n }\n}\n","import { debounce } from './util/debounce';\nimport { kebabCase } from './util';\nimport { asynDirectives } from './util/asynDirectives';\nimport Connection from './connection/index';\nimport DOM from './dom/dom';\nimport HandlerAction from './action/handler';\nimport store from './Store';\nimport ModelAction from './action/model';\nimport DeferredModelAction from './action/deferred-model';\nimport Deferred from './action/Deferred';\nimport Agent from './agent/index';\n\nexport default {\n\n initialize(el, url, reregisterEvl) {\n let isAgent = false;\n asynDirectives(el).all().forEach(directive => {\n let test;\n let lcFunc;\n switch (directive.type) {\n\n case 'model': {\n if (!directive.value) {\n console.warn('ASYNergy: [asyn:model] is missing a value.', el);\n\n break;\n }\n\n // CHECK FOR COMPUND MODEL ATTRIBUTE VALUE, USE THE PREFIX\n // TO CHECK IF THERE IS A CORRESPONDING MUTABLE ELEMENT\n let directiveVal = '';\n let compoundAttrVal = directive.value.search(/[.]/);\n if (compoundAttrVal !== -1) {\n const dirValPrefix = /^.+(?=(\\.))/.exec(directive.value);\n directiveVal = dirValPrefix[0];\n } else {\n directiveVal = directive.value;\n }\n\t\t\t\t\t\t\t\n // GET RID OF THE MODEL PARAMETERS\n compoundAttrVal = directive.value.search(/[\\(]/);\n \n if (compoundAttrVal !== -1) {\n const dirVal = /^.+(?=(\\())/.exec(directive.value);\n directiveVal = dirVal[0];\n }\n\n let mutableElem = document.querySelector(`[asyn\\\\:mutable=${directiveVal}]`);\n\n // GET ATTRIBUTE\n let attr = this.modelAttr(directive.fullName, directiveVal); \n let modelElem = document.querySelector(`[${attr}]`);\n\n if (mutableElem !== null) {\n this.attachModelListener(el, directive, mutableElem, url, modelElem, directiveVal);\n } else {\n mutableElem = document.querySelector(`[asyn\\\\:mutable^=${directiveVal}\\\\.]`);\n if (mutableElem !== null) {\n this.attachModelListener(el, directive, mutableElem, url, modelElem, directiveVal);\n } else {\n console.warn(\n 'ASYNergy: [asyn:model] is missing a corresponding [asyn:mutable] element.',\n el);\n }\n }\n\n test = 'model';\n isAgent = true;\n break;\n }\n\n case 'mutable':\n if (reregisterEvl !== true) {\n\n if ((typeof directive.el.innerHTML === \"string\") && (directive.el.innerHTML.search(/asyn:/)) !== -1) {\n store.mutableIncludesModel = true;\n }\n\n lcFunc = directive.lcFunction;\n store.mutables.push(directive);\n\n test = 'mutable';\n isAgent = false;\n }\n break;\n\n case 'transmit':\n // CHECK IF ELEMENT IS A MUTABLE ELEMENT, NEEDED TO\n // REPLACE A MODEL CHECKBOX VALUE WITH THE MODEL INPUT VALUE\n directive.el.mutable = el.getAttributeNames().indexOf('asyn:mutable');\n\n store.transmissionEls.push(directive.el);\n\n test = 'transmit';\n isAgent = true;\n break;\n\n case 'csrf':\n store.csrf.tokenName = directive.value;\n store.csrf.token = el.value;\n\n test = 'csrf';\n isAgent = false;\n break;\n\n default:\n const params = directive.params;\n let handler = directive.value;\n if (params.length !== 0) {\n handler = directive.handler;\n }\n\n let mutableElem = document.querySelector(`[asyn\\\\:mutable=${handler}]`);\n if (mutableElem === null) {\n mutableElem = document.querySelector(`[asyn\\\\:mutable^=${handler}\\\\.]`);\n }\n\n // GET ATTRIBUTE\n let attr = this.modelAttr(directive.fullName, directive.value);\n let modelElem = document.querySelector(`[${attr}]`);\n\n if (store.directives.has(directive.type)) {\n store.directives.call(\n directive.type,\n el,\n directive,\n mutableElem,\n url\n );\n }\n\n this.attachDomListener(el, directive, mutableElem, url, modelElem);\n\n test = 'default';\n isAgent = true;\n break;\n }\n\n });\n\n if (isAgent === true) {\n let index = store.agents.length - 1;\n let theAgent = store.agents[index];\n let eventType = theAgent.connection.event;\n store.callHook('element.initialized', el, theAgent, eventType);\n }\n isAgent = false;\n },\n\n attachModelListener(el, directive, mutableEl, url, modelEl, modelAttrVal) {\n const isLazy = directive.modifiers.includes('lazy');\n\n const debounceIf = (condition, callback, time) =>\n condition ? directive.modelSyncDebounce(callback, time) : callback;\n\n const hasDebounceModifier = directive.modifiers.includes('debounce');\n\n store.callHook('interceptAsynModelAttachListener', directive, el, mutableEl);\n\n let event = el.tagName.toLowerCase() === 'select'\n || ['checkbox', 'radio'].includes(el.type)\n || directive.modifiers.includes('lazy') ? 'change' : 'input';\n \n if (el.tagName.toLowerCase() === 'input' && directive.modifiers.includes('blur')) {\n event = 'blur';\n }\n\n let model = modelAttrVal;\n\n // TODO check for trailing slashes\n const handlerURL = url + '/' + model;\n const initConnection = new Connection(handlerURL, mutableEl, model, modelEl, event);\n\n const connect = {\n sendMessage: function () {\n // INPUT FIELD VALUE\n let postValue = el.value;\n initConnection.action(postValue);\n }\n };\n\n let agentID = store.agents.length + 1;\n let agent = store.addAgent(new Agent(el, initConnection, el.value, agentID));\n\n if (directive.modifiers.includes('defer')) {\n Deferred.addAction(directive.value, el.value, el);\n }\n\n // If it's a text input and not .lazy, debounce, otherwise fire immediately.\n let handler = debounceIf(hasDebounceModifier || (DOM.isTextInput(el) && !isLazy), e => {\n let model = directive.value;\n let params = directive.params;\n let el = e.target;\n\n const isCustomEvent = e instanceof CustomEvent;\n\n isCustomEvent ? directive.emitEvent = true : directive.emitEvent = false;\n\n let modelVal = e instanceof CustomEvent\n // We have to check for typeof e.detail here for IE 11.\n && typeof e.detail != 'undefined'\n && typeof window.document.documentMode == 'undefined'\n // With autofill in Safari, Safari triggers a custom event and assigns\n // the value to e.target.value, so we need to check for that value as well.\n ? e.detail || e.target.value\n : DOM.valueFromInput(el, agent);\n\n if (directive.modifiers.includes('defer')) {\n agent.addAction(new DeferredModelAction(model, params, modelVal, isCustomEvent, el));\n } else {\n agent.addAction(new ModelAction(model, params, modelVal, isCustomEvent, el));\n }\n }, directive.durationOr(150));\n\n store.addEmitEvent(el, directive.params, directive.handler, handler);\n\n el.addEventListener(event, handler);\n\n agent.addListenerForTeardown(() => {\n el.removeEventListener(event, handler);\n });\n\n // Taken from: https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser\n let isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);\n\n // Safari is weird and doesn't properly fire input events when\n // a user \"autofills\" a asyn:model(.lazy) field. So we are\n // firing them manually for assurance.\n isSafari && el.addEventListener('animationstart', e => {\n if (e.animationName !== 'asynergyAutofill') {\n return;\n }\n\n e.target.dispatchEvent(new Event('change', { bubbles: true }));\n e.target.dispatchEvent(new Event('input', { bubbles: true }));\n });\n },\n\n attachDomListener(el, directive, mutableEl, url, modelEl) {\n switch (directive.type) {\n case 'keydown':\n case 'keyup':\n\n this.attachListener(el, directive, e => {\n // Detect system modifier key combinations if specified.\n const systemKeyModifiers = [\n 'ctrl',\n 'shift',\n 'alt',\n 'meta',\n 'cmd',\n 'super'\n ];\n const selectedSystemKeyModifiers = systemKeyModifiers.filter(\n key => directive.modifiers.includes(key)\n );\n\n if (selectedSystemKeyModifiers.length > 0) {\n const selectedButNotPressedKeyModifiers = selectedSystemKeyModifiers.filter(\n key => {\n // Alias \"cmd\" and \"super\" to \"meta\"\n if (key === 'cmd' || key === 'super') {\n key = 'meta';\n }\n return !e[`${key}Key`];\n }\n );\n\n if (selectedButNotPressedKeyModifiers.length > 0) {\n return false;\n }\n }\n\n // Handle spacebar\n if (e.keyCode === 32 || (e.key === ' ' || e.key === 'Spacebar')) {\n return directive.modifiers.includes('space');\n }\n\n // Strip 'debounce' modifier and time modifiers from modifiers list\n let modifiers = directive.modifiers.filter(modifier =>\n (\n !modifier.match(/^debounce$/) &&\n !modifier.match(/^[0-9]+m?s$/)\n )\n );\n\n // Only handle listener if no, or matching key modifiers are passed.\n // It's important to check that e.key exists - OnePassword's extension\n // does weird things.\n return Boolean(modifiers.length ===\n 0 || (e.key && modifiers.includes(kebabCase(e.key))));\n }, mutableEl, url, modelEl);\n\n break;\n case 'click':\n\n this.attachListener(el, directive, e => {\n // We only care about elements that have the .self modifier on them.\n if (!directive.modifiers.includes('self')) {\n return;\n }\n\n // This ensures a listener is only run if the event originated\n // on the elemenet that registered it (not children).\n // This is useful for things like modal back-drop listeners.\n return el.isSameNode(e.target);\n }, mutableEl, url, modelEl);\n\n break;\n default:\n this.attachListener(el, directive, e => el === e.target, mutableEl, url, modelEl);\n break;\n \t\t\t}\n },\n\n attachListener(el, directive, callback, mutableEl, url, modelEl) {\n const event = directive.type;\n const model = directive.handler;\n\n // TODO check for trailing slashes\n const handlerURL = url + '/' + model;\n\n const initConnection = new Connection(handlerURL, mutableEl, model, modelEl, event);\n\n let postValue = () => {\n return el.value !== undefined ? el.value : el.innerText;\n };\n\n let agentID = store.agents.length + 1;\n let agent = store.addAgent(new Agent(el, initConnection, postValue(), agentID));\n\n const handler = e => {\n if (callback && callback(e) === false) {\n return;\n }\n \n const isCustomEvent = e instanceof CustomEvent;\n\n agent.callAfterModelDebounce(() => {\n const el = e.target;\n\n directive.setEventContext(e);\n\n // This is outside the conditional below so \"asyn:click.prevent\"\n // without a value still prevents default.\n this.preventAndStop(e, directive.modifiers);\n const handler = directive.handler;\n let params = directive.params;\n let modelVal = directive.modelValue;\n\n if (isCustomEvent) {\n directive.emitEvent = true;\n if (e.detail !== undefined) {\n modelVal = e.detail;\n }\n } else {\n directive.emitEvent = false;\n }\n\n if (\n params.length === 0 &&\n isCustomEvent &&\n e.detail\n ) {\n params.push(e.detail);\n }\n\n if (directive.value) {\n agent.addAction(new HandlerAction(handler, params, modelVal, isCustomEvent, el));\n }\n\n });\n };\n\n const debounceIf = (condition, callback, time) =>\n condition ? debounce(callback, time) : callback;\n\n const hasDebounceModifier = directive.modifiers.includes('debounce');\n const debouncedHandler = debounceIf(\n hasDebounceModifier,\n handler,\n directive.durationOr(150)\n );\n\n store.addEmitEvent(el, directive.params, directive.handler, handler);\n\n el.addEventListener(event, debouncedHandler);\n\n agent.addListenerForTeardown(() => {\n el.removeEventListener(event, debouncedHandler);\n });\n },\n \n preventAndStop(event, modifiers) {\n modifiers.includes('prevent') && event.preventDefault();\n modifiers.includes('stop') && event.stopPropagation();\n },\n\n modelAttr(fullName, attrVal) {\n let escFullName = this.escapedStr(fullName);\n let escAttrVal = this.escapedStr(attrVal);\n let attr = escFullName + \"=\" + \"\\\"\" + escAttrVal + \"\\\"\";\n return attr;\n },\n \n escapedStr(str) {\n let escapedStr = str;\n escapedStr = escapedStr.replace(/\\:|\\.|\"|'/gi, function (x) {\n return \"\\\\\" + x;\n });\n return escapedStr;\n }\n};\n","\nexport * from './debounce';\nexport * from './asynDirectives';\nexport * from './walkDOM';\n\nexport function kebabCase(subject) {\n return subject.replace(/([a-z])([A-Z])/g, '$1-$2').replace(/[_\\s]/, '-').toLowerCase();\n}\n\nexport function tap(output, callback) {\n callback(output);\n\n return output;\n}\n","import store from '../Store';\nimport { asynDirectives } from '../util/asynDirectives';\n\nlet cleanupStackByAgentId = {};\n\nexport default function () {\n store.registerHook('element.initialized', (el, agent) => {\n let directives = asynDirectives(el);\n\n if (directives.missing('submit')) return;\n\n // Set a forms \"disabled\" state on inputs and buttons.\n // ASYNergy will clean it all up automatically submitting the form.\n el.addEventListener('submit', () => {\n cleanupStackByAgentId[agent.agentID] = [];\n\n agent.walk(node => {\n if (!el.contains(node)) return;\n\n if (node.hasAttribute('asyn:ignore')) return false;\n\n if (\n //