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