Current section
Files
Jump to
Current section
Files
priv/static/primer-live.min.js
"use strict";(()=>{var R=Object.defineProperty,M=Object.defineProperties,q=Object.getOwnPropertyDescriptors,D=Object.getOwnPropertySymbols,U=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable,I=(e,t,r)=>t in e?R(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,p=(e,t)=>{for(var r in t||(t={}))U.call(t,r)&&I(e,r,t[r]);if(D)for(var r of D(t))j.call(t,r)&&I(e,r,t[r]);return e},w=(e,t)=>M(e,q(t)),v=(e,t,r)=>new Promise((i,a)=>{var l=s=>{try{n(r.next(s))}catch(d){a(d)}},c=s=>{try{n(r.throw(s))}catch(d){a(d)}},n=s=>s.done?i(s.value):Promise.resolve(s.value).then(l,c);n((r=r.apply(e,t)).next())}),N=e=>new Promise(t=>setTimeout(t,e)),G=(e,t)=>t.reduce((r,i)=>r!=="0s"?r:e.getPropertyValue(i),"0s"),P=({domElement:e,props:t})=>{let r=document.defaultView;if(r){let i=r.getComputedStyle(e);if(i)return G(i,t)}},x=e=>{let t=parseFloat(e)*(e.indexOf("ms")===-1?1e3:1);return Number.isNaN(t)?0:t},V=e=>{let t=P({domElement:e,props:["animation-duration","transition-duration"]}),r=t!==void 0?x(t):0,i=P({domElement:e,props:["animation-delay","transition-delay"]}),a=i!==void 0?x(i):0;return r+a},J=e=>e.scrollTop,W=e=>{let t=typeof window<"u"?window.getComputedStyle(e):{};return t.opacity==="0"||t.display==="none"?!1:!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},$=(e,t)=>e instanceof HTMLAnchorElement&&e.rel!=="ignore"||e instanceof HTMLAreaElement&&e.href!==void 0||[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLButtonElement].some(r=>e instanceof r)&&!e.disabled||e instanceof HTMLIFrameElement||e.tabIndex>0||!t&&e.tabIndex===0&&e.getAttribute("tabindex")!==null&&e.getAttribute("aria-hidden")!=="true",B=e=>[].slice.call(e.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")).filter(r=>$(r,!0)).sort((r,i)=>r.tabIndex-i.tabIndex)[0],K=(e,t,r)=>{t&&(e[t]||(e[t]=JSON.stringify(r)))},z=(e,t)=>{if(t)return JSON.parse(e[t])},F=(e,t)=>{t&&delete e[t]},Q=(e,t)=>{!t||!e||Object.keys(e).forEach(r=>{t.dataset[r]=e[r]})},H="[data-prompt]",X="[data-content]",Y="[data-touch]",Z="[data-toggle]",ee="ismodal",te="isescapable",re="isfocusfirst",ie="focusfirst",L="isopen",k="isshowing",C="ishiding",T="islocked",ae=300,S={isOpen:!1,willShow:!1,didShow:!1,willHide:!1,didHide:!1},E=(e,...t)=>v(void 0,[e,...t],function*(r,i={}){var a,l,c,n;let{prompt:s,content:d,root:o,isDetails:y,isEscapable:_,escapeListener:f}=r;if(o.dataset[T]!==void 0&&!i.isIgnoreLockDuration)return;s.status=w(p({},S),{isOpen:!0,willHide:!0}),(a=i.willHide)==null||a.call(i,r),(l=i.getStatus)==null||l.call(i,s.status),delete o.dataset[k],o.dataset[C]="";let u=V(d);yield N(u),y&&o.removeAttribute("open"),delete o.dataset[C],delete o.dataset[L],s.status=w(p({},S),{didHide:!0}),(c=i.getStatus)==null||c.call(i,s.status),(n=i.didHide)==null||n.call(i,r),_&&typeof window<"u"&&window.removeEventListener("keydown",f)}),O=(e,...t)=>v(void 0,[e,...t],function*(r,i={}){var a,l,c,n;let{prompt:s,content:d,root:o,isDetails:y,isEscapable:_,isFocusFirst:f,focusFirstSelector:u,escapeListener:A}=r;if(o.dataset[T]!==void 0)return;o.dataset[T]="",setTimeout(()=>{o&&delete o.dataset[T]},ae),_&&typeof window<"u"&&window.addEventListener("keydown",A),y&&o.setAttribute("open",""),o.dataset[L]="",J(o),o.dataset[k]="",s.status=w(p({},S),{willShow:!0}),(a=i.willShow)==null||a.call(i,r),(l=i.getStatus)==null||l.call(i,s.status);let m=V(d);if(yield N(m),f){let h=B(d);h&&h.focus()}else if(u){let h=d.querySelector(u);h&&h.focus()}s.status=w(p({},S),{didShow:!0,isOpen:!0}),(c=i.didShow)==null||c.call(i,r),(n=i.getStatus)==null||n.call(i,s.status)}),b=(e,...t)=>v(void 0,[e,...t],function*(r,i=2,a){switch(i){case 0:return yield O(r,a);case 1:return yield E(r,a);default:return W(r.content)?yield E(r,a):yield O(r,a)}}),se=(e,t,r,i)=>{let a=null;if(!r&&t?a=t:typeof r=="string"?a=document.querySelector(r):r&&r.tagName&&(a=r.closest(H)),!a){console.error("Prompt element 'data-root' not found");return}let l=a.querySelector(X);if(!l){console.error("Prompt element 'data-content' not found");return}let c=a.querySelector(Z)||a.querySelector("summary"),n=a.querySelector(Y),s=a.tagName==="DETAILS",d=a.dataset[ee]!==void 0,o=a.dataset[te]!==void 0,y=a.dataset[re]!==void 0,_=a.dataset[ie],f={prompt:e,root:a,isDetails:s,isModal:d,isEscapable:o,isFocusFirst:y,focusFirstSelector:_,toggle:c,content:l,touchLayer:n,escapeListener:function(u){u.key==="Escape"&&[].slice.call(document.querySelectorAll(`${H}[data-${L}]`)).reverse()[0]===f.root&&E(f,w(p({},i),{isIgnoreLockDuration:!0}))},clickTouchLayerListener:function(u){u.target===n&&(u.stopPropagation(),d||b(f,1,i))},clickToggleListener:function(u){u.preventDefault(),u.stopPropagation(),b(f,void 0,i)}};return f},oe=e=>{let{toggle:t,clickToggleListener:r}=e;t&&t.dataset.registered!==""&&(t.addEventListener("click",r),t.dataset.registered="")},ne=e=>{let{clickTouchLayerListener:t,touchLayer:r}=e;r&&r.dataset.registered!==""&&(r.addEventListener("click",t),r.dataset.registered="")};function g(e,t,r,i){return v(this,null,function*(){e.options=p(p({},e.options),r);let a=se(e,e.el,t,e.options);if(a===void 0)return;e.el||(e.el=a==null?void 0:a.root),oe(a),ne(a);let{root:l,isDetails:c}=a;c&&l.getAttribute("open")!==null&&i!==1&&O(a,e.options),i!==void 0&&(yield b(a,i,e.options))})}var le={_cache:{},mounted(){},beforeUpdate(){var e,t;K(this._cache,(e=this.el)==null?void 0:e.id,(t=this.el)==null?void 0:t.dataset)},updated(){var e,t;let r=z(this._cache,(e=this.el)==null?void 0:e.id);Q(r,this.el),F(this._cache,(t=this.el)==null?void 0:t.id)},destroyed(){var e;F(this._cache,(e=this.el)==null?void 0:e.id)},status:S,init(e,t){return v(this,null,function*(){yield g(this,e,t)})},toggle(e,t){return v(this,null,function*(){yield g(this,e,t,2)})},show(e,t){return v(this,null,function*(){yield g(this,e,t,0)})},hide(e,t){return v(this,null,function*(){yield g(this,e,t,1)})}};typeof window<"u"&&(window.Prompt=le);var de={mounted(){window.addEventListener("phx:pl-session",e=>fetch(`/api/pl-session?payload=${JSON.stringify(e.detail)}`,{method:"post"}))}};window.Session=de;})();