; (self.AMP=self.AMP||[]).push({m:1,v:"2302171719000",n:"amp-form",ev:"0.1",l:!0,f:function(t,i){(()=>{var i;function e(){return i||(i=Promise.resolve(void 0))}var s=class{constructor(){this.promise=new Promise(((t,i)=>{this.resolve=t,this.reject=i}))}};function n(t){return new Promise((i=>{i(t())}))}function r(t){return t?Array.prototype.slice.call(t):[]}var{isArray:o}=Array,{hasOwnProperty:c,toString:u}=Object.prototype;function a(t){return"[object Object]"===u.call(t)}function h(t){const i=Object.create(null);return t&&Object.assign(i,t),i}function l(t,i){return c.call(t,i)}function f(t,i,e,s,n,r,o,c,u,a,h){return t}var d="amp:dom-update",m="amp:form-value-change",p="name";function _(t){return(t.ownerDocument||t).defaultView}function b(t){return CSS.escape(t)}function A(t){f(/^[\w-]+$/.test(t))}function P(t,i){return A(i),i=i.toUpperCase(),function(t,e){const s=[];for(let e=t.parentElement;e;e=e.parentElement)e.tagName==i&&s.push(e);return s}(t)}function v(t){var i;null===(i=t.parentElement)||void 0===i||i.removeChild(t)}function E(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function T(t,i){const{length:e}=t;for(let s=0;s{t.selected&&e[a].push(t.value)})):e[a].push(d))}const o=R(t);if(null!=o&&o.name){const{name:t,value:i}=o;void 0===e[t]&&(e[t]=[]),e[t].push(i)}return Object.keys(e).forEach((t=>{0==e[t].length&&delete e[t]})),e}function R(t){const{elements:i}=t,{activeElement:e}=t.ownerDocument,s=r(i).filter(g);return s.includes(e)?e:s[0]||null}function g(t){const{tagName:i,type:e}=t;return"BUTTON"==i||"submit"==e}function V(t){return t.disabled||P(t,"fieldset").some((t=>t.disabled))}function w(t){const i=t,e=t;switch(t.type){case"select-multiple":case"select-one":return r(i.options).every((({defaultSelected:t,selected:i})=>i===t));case"checkbox":case"radio":const{checked:t,defaultChecked:s}=e;return t===s;default:const{defaultValue:n,value:o}=e;return o===n}}var M=/(?:^[#?]?|&)([^=&]+)(?:=([^&]*))?/g;function x(t,i=""){try{return decodeURIComponent(t)}catch(t){return i}}function S(t){const i=h();if(!t)return i;let e;for(;e=M.exec(t);){const t=x(e[1],e[1]),s=e[2]?x(e[2].replace(/\+/g," "),e[2]):"";i[t]=s}return i}self.__AMP_LOG=self.__AMP_LOG||{user:null,dev:null,userForEmbed:null};var O=self.__AMP_LOG;function F(t,i){throw new Error("failed to call initLogConstructor")}function $(t){return O.user||(O.user=j()),function(t,i){return i&&i.ownerDocument.defaultView!=t}(O.user.win,t)?O.userForEmbed||(O.userForEmbed=j()):O.user}function j(t){return F()}function k(){return O.dev||(O.dev=F())}function N(t,i,e,s,n,r,o,c,u,a,h){return t}function X(t,i,e,s,n,r,o,c,u,a,h){return $().assert(t,i,e,s,n,r,o,c,u,a,h)}function D(t,i){return q(t=function(t){return t.__AMP_TOP||(t.__AMP_TOP=t)}(t),i)}function C(t,i){return q(G(z(t)),i)}function U(t,i){const e=G(z(t));return W(e,i)?q(e,i):null}function H(t,i){return function(t,i){const e=B(t,i);if(e)return e;const n=J(t);return n[i]=function(){const t=new s,{promise:i,reject:e,resolve:n}=t;return i.catch((()=>{})),{obj:null,promise:i,resolve:n,reject:e,context:null,ctor:null}}(),n[i].promise}(G(t),i)}function L(t,i){return B(G(t),i)}function z(t){return t.nodeType?(i=_(t),D(i,"ampdoc")).getAmpDoc(t):t;var i}function G(t){const i=z(t);return i.isSingleDoc()?i.win:i}function q(t,i){N(W(t,i));const e=J(t)[i];return e.obj||(N(e.ctor),N(e.context),e.obj=new e.ctor(e.context),N(e.obj),e.context=null,e.resolve&&e.resolve(e.obj)),e.obj}function B(t,i){const e=J(t)[i];return e?e.promise?e.promise:(q(t,i),e.promise=Promise.resolve(e.obj)):null}function J(t){let i=t.__AMP_SERVICES;return i||(i=t.__AMP_SERVICES={}),i}function W(t,i){const e=t.__AMP_SERVICES&&t.__AMP_SERVICES[i];return!(!e||!e.ctor)}function K(t,i,e,s){const n=L(t,i);if(n)return n;const r=z(t);return r.whenExtensionsKnown().then((()=>{const t=r.getExtensionVersion(e);return t?D(r.win,"extensions").waitForExtension(e,t):null})).then((e=>e?s?L(t,i):H(t,i):null))}var Y,Z=t=>z(t),Q=t=>C(t,"mutator"),tt=t=>U(t,"url"),it=t=>C(t,"viewport");function et(t,i,e,s){let n=t,r=e,o=t=>{try{return r(t)}catch(t){var i,e;throw null===(i=(e=self).__AMP_REPORT_ERROR)||void 0===i||i.call(e,t),t}};const c=function(){if(void 0!==Y)return Y;Y=!1;try{const t={get capture(){return Y=!0,!1}};self.addEventListener("test-options",null,t),self.removeEventListener("test-options",null,t)}catch(t){}return Y}(),u=!(null==s||!s.capture);return n.addEventListener(i,o,c?s:u),()=>{null==n||n.removeEventListener(i,o,c?s:u),r=null,n=null,o=null}}function st(t,i,e,s){const n={detail:e};return Object.assign(n,s),new t.CustomEvent(i,n)}function nt(t,i,e,s){return et(t,i,e,s)}function rt(t,i,e,s){let n;const r=new Promise((s=>{n=function(t,i,e,s){let n=e;const r=et(t,i,(t=>{try{n(t)}finally{n=null,r()}}),s);return r}(t,i,s,e)}));return r.then(n,n),s&&s(n),r}function ot(t,i,e){return i in t?Object.defineProperty(t,i,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[i]=e,t}function ct(t,i){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);i&&(s=s.filter((function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable}))),e.push.apply(e,s)}return e}function ut(t,i){const e=D(t,"platform");return e.isIos()&&11==e.getMajorVersion()?new ft(i):FormData.prototype.entries&&FormData.prototype.delete?new lt(i):new ht(i)}var at,ht=class{constructor(t){this.XF=t?y(t):h()}append(t,i,e){const s=String(t);this.XF[s]=this.XF[s]||[],this.XF[s].push(String(i))}delete(t){delete this.XF[t]}entries(){const t=[];Object.keys(this.XF).forEach((i=>{this.XF[i].forEach((e=>t.push([i,e])))}));let i=0;return{next:()=>i{this.XF[i].forEach((e=>t.append(i,e)))})),t}},lt=class{constructor(t){this.zF=new FormData(t),this.GF(t)}GF(t){if(!t)return;const i=R(t);i&&i.name&&this.append(i.name,i.value)}append(t,i,e){this.zF.append(t,i)}delete(t){this.zF.delete(t)}entries(){return this.zF.entries()}getFormData(){return this.zF}},ft=class extends lt{constructor(t){super(t),t&&T(t.elements,(t=>{"file"==t.type&&0==t.files.length&&(this.zF.delete(t.name),this.zF.append(t.name,new Blob([]),""))}))}append(t,i,e){var s;i&&"object"==typeof i&&""==(s=i).name&&0==s.size?this.zF.append(t,new Blob([]),e||""):this.zF.append(t,i)}},dt=(()=>self.AMP.config.urls)(),mt=new Set(["c","v","a","ad"]),pt="__amp_source_origin",_t=t=>"string"==typeof t?bt(t):t;function bt(t,i){return at||(at=self.document.createElement("a")),function(t,i,e){return t.href="",new URL(i,t.href)}(at,t)}function At(t,i,e){if(!i)return t;const s=t.split("#",2),n=s[0].split("?",2);let r=n[0]+(n[1]?e?`?${i}&${n[1]}`:`?${n[1]}&${i}`:`?${i}`);return r+=s[1]?`#${s[1]}`:"",r}function Pt(t,i){return`${encodeURIComponent(t)}=${encodeURIComponent(i)}`}function vt(t){const i=[];for(const s in t){let n=t[s];if(null!=n){n=o(e=n)?e:[e];for(let t=0;t"","getPropertyValue":()=>""};function Vt(t,i,e,s,n){const r=function(t,i,e){if(i.startsWith("--"))return i;Tt||(Tt=h());let s=Tt[i];if(!s||e){if(s=i,void 0===t[i]){const e=function(t){return t.charAt(0).toUpperCase()+t.slice(1)}(i),n=function(t,i){for(let e=0;e"-"+t.toLowerCase()));return Rt.some((t=>i.startsWith(t+"-")))?`-${i}`:i}(r),o)}function wt(t,i){void 0===i&&(i=t.hasAttribute("hidden")),i?t.removeAttribute("hidden"):t.setAttribute("hidden","")}function Mt(t){return`${t}px`}function xt(t,i){return t.getComputedStyle(i)||gt}var St="autoexpand",Ot=class{static install(t){const i=t.getRootNode();let e=null;const s=()=>{const s=i.querySelector("textarea[autoexpand]");if(!s||e)return!s&&e?(e.dispose(),void(e=null)):void 0;e=new Ot(t)};nt(i,d,s),s()}constructor(t){const i=t.getRootNode();this.nm=i.ownerDocument||i,this.i=N(this.nm.defaultView),this.nc=it(t),this.V_=[],this.V_.push(nt(i,"input",(t=>{const i=t.target;"TEXTAREA"==i.tagName&&i.hasAttribute(St)&&Ft(i)}))),this.V_.push(nt(i,"mousedown",(t=>{if(1!=t.which)return;const i=t.target;"TEXTAREA"==i.tagName&&function(t){const i=Q(t);Promise.all([i.measureElement((()=>t.scrollHeight)),rt(t,"mouseup")]).then((e=>{const s=e[0];let n=0;return i.measureMutateElement(t,(()=>{n=t.scrollHeight}),(()=>{!function(t,i,e){i!=e&&t.removeAttribute(St)}(t,s,n)}))}))}(i)})));let e=i.querySelectorAll("textarea");this.V_.push(nt(i,d,(()=>{e=i.querySelectorAll("textarea")})));const s=function(t,i,e){let s=0,n=null;function r(e){n=null,s=t.setTimeout(o,100),i.apply(null,e)}function o(){s=0,n&&r(n)}return function(...t){s?n=t:r(t)}}(this.i,(t=>{t.relayoutAll&&e.forEach((t=>{"TEXTAREA"==t.tagName&&t.hasAttribute(St)&&Ft(t)}))}));var n;this.V_.push(this.nc.onResize(s)),n=e,Promise.all(r(n).map((t=>function(t){return Q(t).measureElement((()=>t.scrollHeight>t.clientHeight))}(t).then((i=>{i&&t.removeAttribute(St)})))))}dispose(){this.V_.forEach((t=>t()))}};function Ft(t){const i=Q(t),e=N(t.ownerDocument.defaultView);let s=0,n=0,r=0;const o=function(t){const i=N(t.ownerDocument),e=N(i.defaultView),s=N(i.body),n=Q(t),r=t.cloneNode(!1);r.classList.add("i-amphtml-textarea-clone");let o=0,c=0,u=!1;return n.measureMutateElement(s,(()=>{const i=xt(e,t),s=parseInt(i.getPropertyValue("max-height"),10);o=parseInt(i.getPropertyValue("width"),10),u=isNaN(s)||t.scrollHeight{u&&(t.scrollTop=0),Vt(r,"width",Mt(o)),i.body.appendChild(r)})).then((()=>n.measureMutateElement(s,(()=>{c=r.scrollHeight}),(()=>{v(r)})))).then((()=>c))}(t);return i.measureMutateElement(t,(()=>{const i=xt(e,t);n=t.scrollHeight;const o=parseInt(i.getPropertyValue("max-height"),10);r=isNaN(o)?1/0:o,s="content-box"==i.getPropertyValue("box-sizing")?-parseInt(i.getPropertyValue("padding-top"),10)-parseInt(i.getPropertyValue("padding-bottom"),10):parseInt(i.getPropertyValue("border-top-width"),10)+parseInt(i.getPropertyValue("border-bottom-width"),10)}),(()=>o.then((i=>{const o=i+s;t.classList.toggle("i-amphtml-textarea-max",o>r);const c="iAmphtmlHasExpanded"in t.dataset,u=/google/i.test(e.navigator.vendor)?3:0;(c||n<=i+u)&&(t.dataset.iAmphtmlHasExpanded="",Vt(t,"height",Mt(i+s)))}))))}var $t={"INPUT":!0,"SELECT":!0,"TEXTAREA":!0},jt="submit",kt=1,Nt=2,Xt=1,Dt=2,Ct=3,Ut={"acceptCharset":{access:kt,attr:"accept-charset"},"accessKey":{access:kt,attr:"accesskey"},"action":{access:kt,type:Xt},"attributes":{access:Nt},"autocomplete":{access:kt,def:"on"},"children":{access:Nt},"dataset":{access:Nt},"dir":{access:kt},"draggable":{access:kt,type:Dt,def:!1},"elements":{access:Nt},"encoding":{access:Nt},"enctype":{access:kt},"hidden":{access:kt,type:Ct,def:!1},"id":{access:kt,def:""},"lang":{access:kt},"localName":{access:Nt},"method":{access:kt,def:"get"},"name":{access:kt},"noValidate":{access:kt,attr:"novalidate",type:Ct,def:!1},"prefix":{access:Nt},"spellcheck":{access:kt},"style":{access:Nt},"target":{access:kt,def:""},"title":{access:kt},"translate":{access:kt}};function Ht(t){t.bubbleElement.removeAttribute("aria-alert"),t.bubbleElement.removeAttribute("role"),E(t.bubbleElement),wt(t.bubbleElement,!1)}function Lt(t){t.targetRect=t.viewport.getLayoutRect(t.targetElement)}function zt(t){E(t.bubbleElement);const i=t.bubbleElement.ownerDocument.createElement("div");i.id=`bubble-message-${t.id}`,i.textContent=t.message,t.bubbleElement.setAttribute("aria-labeledby",i.id),t.bubbleElement.setAttribute("role","alert"),t.bubbleElement.setAttribute("aria-live","assertive"),t.bubbleElement.appendChild(i),wt(t.bubbleElement,!0),function(t,i){for(const e in i)Vt(t,e,i[e])}(t.bubbleElement,{top:t.targetRect.top-10+"px",left:`${t.targetRect.left+t.targetRect.width/2}px`})}var Gt,qt,Bt="Please match the requested format.",Jt=0,Wt=class{constructor(t){this.form=t,this.ampdoc=Z(t),this.mutator=Q(t),this.root=this.ampdoc.getRootNode(),this.WF=null}report(){}onBlur(t){}onInput(t){}inputs(){return this.form.querySelectorAll("input,select,textarea")}checkInputValidity(t){if("TEXTAREA"===t.tagName&&t.hasAttribute("pattern")&&(t.checkValidity()||t.validationMessage===Bt)){const i=t.getAttribute("pattern"),e=new RegExp(`^${i}$`,"m").test(t.value);t.setCustomValidity(e?"":Bt)}return t.checkValidity()}checkFormValidity(t){return this.KF(t),t.checkValidity()}reportFormValidity(t){return this.KF(t),t.reportValidity()}KF(t){T(t.elements,(t=>{"TEXTAREA"==t.tagName&&this.checkInputValidity(t)}))}fireValidityEventIfNecessary(){const t=this.WF;if(this.WF=this.checkFormValidity(this.form),t!==this.WF){const t=st(_(this.form),this.WF?"valid":"invalid",null,{bubbles:!0});this.form.dispatchEvent(t)}}},Kt=class extends Wt{report(){this.reportFormValidity(this.form),this.fireValidityEventIfNecessary()}},Yt=class extends Wt{constructor(t){super(t);const i="i-amphtml-validation-bubble-"+Jt++;this.YF=new class{constructor(t,i){this.Ei=i,this.nc=it(t),this.kh=D(t.win,"vsync"),this.QF=null,this.IN="",this._s=!1,this.RN=t.win.document.createElement("div"),wt(this.RN,!1),this.RN.classList.add("i-amphtml-validation-bubble"),this.RN.__BUBBLE_OBJ=this,t.getBody().appendChild(this.RN)}isActiveOn(t){return this._s&&t==this.QF}hide(){this._s&&(this._s=!1,this.QF=null,this.IN="",this.kh.run({measure:void 0,mutate:Ht},{bubbleElement:this.RN}))}show(t,i){if(this.isActiveOn(t)&&i==this.IN)return;this._s=!0,this.QF=t,this.IN=i;const e={message:i,targetElement:t,bubbleElement:this.RN,viewport:this.nc,id:this.Ei};this.kh.run({measure:Lt,mutate:zt},e)}}(this.ampdoc,i)}report(){const t=this.inputs();for(let i=0;i!0===t.validity[i]));return e.length?e[0]:null}(t);i&&this.showValidationFor(t,i)}MN(){return`i-amphtml-aria-desc-${this.VN}-${this.wN++}`}hideAllValidations(){const t=this.inputs();for(let i=0;ie.classList.add("visible")))}hideValidationFor(t){const i=this.getVisibleValidationFor(t);i&&(delete t.__AMP_VISIBLE_VALIDATION,t.removeAttribute("aria-invalid"),t.removeAttribute("aria-describedby"),this.mutator.mutateElement(i,(()=>i.classList.remove("visible"))))}getVisibleValidationFor(t){return t.__AMP_VISIBLE_VALIDATION}shouldValidateOnInteraction(t){throw Error("Not Implemented")}onInteraction(t){const i=t.target,e=!!i.checkValidity&&this.shouldValidateOnInteraction(i);this.hideValidationFor(i),e&&!this.checkInputValidity(i)&&this.reportInput(i)}onBlur(t){this.onInteraction(t)}onInput(t){this.onInteraction(t)}},Qt=class extends Zt{report(){this.hideAllValidations();const t=this.inputs();for(let i=0;i{t.setCustomValidity("")}))}},ri=class extends ni{},oi=class extends ni{constructor(t,i){super(t),this.kN=i,this.NN=null,this.XN=[]}jN(){const t=this.kN().then((()=>[]),(t=>function(t){const{response:i}=t;return i?i.json().then((t=>t.verifyErrors||[]),(()=>[])):Promise.resolve([])}(t)));return this.DN(t).then((t=>this.CN(t)))}DN(t){if(!this.NN){this.NN=new class{constructor(t){if(this.UN=new s,this.HN=0,t)for(const i of t)this.add(i)}add(t){const i=++this.HN;return t.then((t=>{this.HN===i&&this.UN.resolve(t)}),(t=>{this.HN===i&&this.UN.reject(t)})),this.UN.promise}then(t,i){return this.UN.promise.then(t,i)}};const t=()=>this.NN=null;this.NN.then(t,t)}return this.NN.add(t)}CN(t){const i=[],e=this.XN;this.XN=t;for(let e=0;et.every((t=>i.name!==t.name)))).map((t=>this.ON.querySelector(`[name="${t.name}"]`)));return{updatedElements:i.concat(s),errors:t}}};function ci(t,i,e){if(i[e])return i[e];const s=t.querySelector(`style[${e}], link[${e}]`);return s?(i[e]=s,s):null}function ui(t,i){const e=t.styleSheets;for(let t=0;t{this.remove(t)}}remove(t){this.$n&&function(t,i){const e=t.indexOf(i);-1!=e&&t.splice(e,1)}(this.$n,t)}removeAll(){this.$n&&(this.$n.length=0)}fire(t){if(this.$n)for(const i of this.$n.slice())i(t)}getHandlerCount(){var t,i;return null!==(t=null===(i=this.$n)||void 0===i?void 0:i.length)&&void 0!==t?t:0}}}beforeSubmit(t){return this.Dl.add(t)}fire(t){this.Dl.fire(t)}}),t.registerServiceForDoc(ai,class{constructor(t){this.LN=this.zN(t).then((()=>this.GN(t)))}whenInitialized(){return this.LN}zN(t){const i=new s;return function(t,i,e,s,n){const r=t.getHeadNode(),o=function(t,i,e,s){let n=t.__AMP_CSS_SM;n||(n=t.__AMP_CSS_SM=h());const r=`amp-extension=${s}`;if(r){const e=ci(t,n,r);if(e)return"STYLE"==e.tagName&&e.textContent!==i&&(e.textContent=i),e}const o=(t.ownerDocument||t).createElement("style");o.textContent=i;let c=null;return o.setAttribute("amp-extension",s),c=ci(t,n,"amp-runtime"),function(t,i,e=null){if(!e)return void function(t,i){t.insertBefore(i,t.firstChild)}(t,i);const s=e.nextSibling;t.insertBefore(i,s)}(t,o,c),r&&(n[r]=o),o}(r,function(t,i){const e=t.__AMP_CSS_TR;return e?e(i):i}(r,'form.amp-form-submit-error [submit-error],form.amp-form-submit-success [submit-success],form.amp-form-submitting [submitting]{display:block}textarea[autoexpand]:not(.i-amphtml-textarea-max){overflow:hidden!important}.i-amphtml-textarea-clone{visibility:hidden;position:absolute;top:-9999px;left:-9999px;height:0!important}.i-amphtml-validation-bubble{transform:translate(-50%,-100%);background-color:#fff;box-shadow:0 5px 15px 0 rgba(0,0,0,.5);max-width:200px;position:absolute;display:block;box-sizing:border-box;padding:10px;border-radius:5px}.i-amphtml-validation-bubble:after{content:" ";position:absolute;bottom:-8px;left:30px;width:0;height:0;border-left:8px solid transparent;border-right:8px solid transparent;border-top:8px solid #fff}[visible-when-invalid]{color:red}\n/*# sourceURL=/extensions/amp-form/0.1/amp-form.css*/'),0,"amp-form");if(e){const i=t.getRootNode();if(ui(i,o))return e(o),o;const s=setInterval((()=>{ui(i,o)&&(clearInterval(s),e(o))}),4)}}(t,0,i.resolve),i.promise}GN(t){return t.whenReady().then((()=>{const i=t.getRootNode();this.qN(i.querySelectorAll("form")),Ot.install(t),this.BN(i),this.JN(i)}))}qN(t){t&&t.forEach(((t,i)=>{I(t)||new class{constructor(t,i){try{!function(t){const i=((s=_(t)).FormProxy||(s.FormProxy=function(t){function i(t){this.ON=t}const e=i.prototype,{Object:s}=t,n=s.prototype;return[t.HTMLFormElement,t.EventTarget].reduce(((t,i)=>{let e=i&&i.prototype;for(;e&&e!==n&&!(t.indexOf(e)>=0);)t.push(e),e=s.getPrototypeOf(e);return t}),[]).forEach((i=>{for(const s in i){const r=t.Object.getOwnPropertyDescriptor(i,s);if(r&&s.toUpperCase()!=s&&!s.startsWith("on")&&!n.hasOwnProperty.call(e,s))if("function"==typeof r.value){const t=r.value;e[s]=function(){return t.apply(this.ON,arguments)}}else{const i={};r.get&&(i.get=function(){return r.get.call(this.ON)}),r.set&&(i.set=function(t){return r.set.call(this.ON,t)}),t.Object.defineProperty(e,s,i)}}})),i}(s)),s.FormProxy),e=new i(t);var s;"action"in e||function(t,i){const e=t.ownerDocument.defaultView.HTMLFormElement.prototype.cloneNode.call(t,!1);for(const s in e){if(s in i||s.toUpperCase()==s||s.startsWith("on"))continue;const e=Ut[s],n=t[s];if(e)if(e.access==Nt){let e;if(n&&n.nodeType){const i=n,{nextSibling:r,parentNode:o}=i;o.removeChild(i);try{e=t[s]}finally{o.insertBefore(i,r)}}else e=n;Object.defineProperty(i,s,{get:()=>e})}else if(e.access==kt){const n=e.attr||s;Object.defineProperty(i,s,{get(){const s=i.getAttribute(n);if(null==s&&void 0!==e.def)return e.def;if(e.type==Dt)return"true"===s;if(e.type==Ct)return null!=s;if(e.type==Xt){const i=s||"";return tt(t).parse(i).href}return s},set(t){e.type==Ct&&(t=t?"":null),null!=t?i.setAttribute(n,t):i.removeAttribute(n)}})}else N(!1);else Object.defineProperty(i,s,{get:()=>t[s],set(i){t[s]=i}})}}(t,e),t.$p=e}(t)}catch(t){k().error(ai,"form proxy failed to install",t)}!function(t,i){t.__AMP_FORM=i}(t,this),this.Ei=i,this.nm=t.ownerDocument,this.i=this.nm.defaultView,this.Gn=q(this.i,"timer"),this.ON=t,this.zi=Z(this.ON),this.WN=null,this.KN=(t=>U(this.zi,"url-replace"))(),this.g_=C(this.zi,"templates"),this.m$=(t=>D(this.i,"xhr"))(),this.yP=(t=>U(this.zi,"action"))(),this.ya=Q(this.zi),this.lr=(t=>C(this.zi,"viewer"))(),this.YN=new class{constructor(t,i,e){this.lr=i,this.g_=e,this.ZN=t}isEnabled(){const t=this.lr.getAmpDoc();return!(!t.isSingleDoc()||!t.getRootNode().documentElement.hasAttribute("allow-viewer-render-template"))&&this.lr.hasCapability("viewerRenderTemplate")}assertTrustedViewer(t){return this.lr.isTrustedViewer().then((i=>{X(i,"Refused to attempt SSR in untrusted viewer: ",t)}))}ssr(t,i,e=null,s={}){let n;return e||(n=this.g_.maybeFindTemplate(t)),this.assertTrustedViewer(t).then((()=>this.lr.sendMessageAwaitResponse("viewerRenderTemplate",this.QN(i,n,e,s))))}applySsrOrCsrTemplate(t,i){let e;return this.isEnabled()?(X("string"==typeof i.html,"Skipping template rendering due to failed fetch"),e=this.assertTrustedViewer(t).then((()=>this.g_.findAndSetHtmlForTemplate(t,i.html)))):e=o(i)?this.g_.findAndRenderTemplateArray(t,i):this.g_.findAndRenderTemplate(t,i),e}QN(t,i,e,s={}){const n={"type":this.ZN},r=e&&e.successTemplate?e.successTemplate:i;r&&(n.successTemplate={"type":"amp-mustache","payload":r.innerHTML});const o=e&&e.errorTemplate?e.errorTemplate:null;return o&&(n.errorTemplate={"type":"amp-mustache","payload":o.innerHTML}),s&&Object.assign(n,s),{"originalRequest":yt(t.xhrUrl,t.fetchOpt),"ampComponent":n}}}(ai,this.lr,this.g_),this.Zb=(this.ON.getAttribute("method")||"GET").toUpperCase(),this.o=this.ON.getAttribute("target"),this.XU=this.HU("action-xhr"),this.KU=this.HU("verify-xhr"),this.YU=this.QU("enctype"),this.XL=!this.ON.hasAttribute("novalidate"),this.ON.setAttribute("novalidate",""),this.XL||this.ON.setAttribute("amp-novalidate",""),this.ON.classList.add("i-amphtml-form"),this.yi=li;const e=this.ON.elements;for(let t=0;t0&&!this.KL;if(t!==this.YL){this.ON.classList.toggle("amp-form-dirty",t);const i=st(this.i,"amp:form-dirtiness-change",{"isDirty":t},{bubbles:!0});this.ON.dispatchEvent(i)}this.YL=t}qM(){this.ON.addEventListener("input",this.$G.bind(this)),this.ON.addEventListener("reset",this.jG.bind(this)),this.ON.addEventListener(m,this.$G.bind(this))}ZL(){for(let t=0;tthis.BG(),(s=this.ON).hasAttribute("verify-xhr")?new oi(s,n):new ri(s)),this.yP.addToAllowlist("FORM",["clear","submit"],["email"]),this.yP.installActionHandler(this.ON,this.JG.bind(this)),this.qM(),this.WG(),this.KG(),this.YG=null,this.ZG=null,this.QG=null,(r=t,H(r,"form-submit-service")).then((t=>{this.QG=t})),this.eq=this.nm&&function(t,i){const e=i.documentElement;return["⚡4email","amp4email"].some((t=>e.hasAttribute(t)))}(0,this.nm)}HU(t){const i=this.ON.getAttribute(t);if(i){const e=tt(this.zi);e.assertHttpsUrl(i,this.ON,t),X(!e.isProxyOrigin(i),"form %s should not be on AMP CDN: %s",t,this.ON)}return i}QU(t){const i=this.ON.getAttribute(t);return"application/x-www-form-urlencoded"===i||"multipart/form-data"===i?i:"multipart/form-data"}getXssiPrefix(){return this.ON.getAttribute("xssi-prefix")}requestForFormFetch(t,i,e,s){let n,r,o={"Accept":"application/json"};if("GET"==i||"HEAD"==i){this.sq();const i=this.rq();s&&s.forEach((t=>delete i[t])),e&&function(t,i,e=10){const s=[],n=[];for(n.push({t:t,s:i,d:0});n.length>0;){const{d:t,s:i,t:r}=n.shift();if(s.includes(i))throw new Error("Source object has a circular reference.");if(s.push(i),r!==i)if(t>e)Object.assign(r,i);else for(const e of Object.keys(i)){const s=i[e];if(l(r,e)){const i=r[e];if(a(s)&&a(i)){n.push({t:i,s:s,d:t+1});continue}}r[e]=s}}}(i,e),n=function(t,i){return At(t,vt(i))}(t,i)}else{n=t,"application/x-www-form-urlencoded"===this.YU?(r=vt(this.rq()),o={"Accept":"application/json","Content-Type":"application/x-www-form-urlencoded"}):(N("multipart/form-data"===this.YU),r=ut(this.i,this.ON)),s&&s.forEach((t=>r.delete(t)));for(const t in e)r.append(t,e[t])}return{xhrUrl:n,fetchOpt:{"body":r,"method":i,"credentials":"include","headers":o}}}setXhrAction(t){this.XU=t}JG(t){return t.satisfiesTrust(2)?"submit"==t.method?this.oq().then((()=>this.cq(t))):("clear"===t.method&&this.uq(),null):null}oq(){if(this.WN)return this.WN;const t=r(this.ON.querySelectorAll(hi.join(","))).map((t=>t.build()));return this.WN=this.aq(t,2e3)}qM(){this.zi.whenNextVisible().then((()=>{const t=this.ON.querySelector("[autofocus]");t&&function(t){try{t.focus()}catch(t){}}(t)})),this.ON.addEventListener("submit",this.hq.bind(this),!0),this.ON.addEventListener("blur",(t=>{Ai(t.target),this.LG.onBlur(t)}),!0),this.ON.addEventListener(m,(t=>{Ai(t.target),this.LG.onInput(t)}),!0),this.YN.isEnabled()||this.ON.addEventListener("change",(t=>{this.qG.onCommit().then((i=>{const{errors:e,updatedElements:s}=i;s.forEach(Ai),this.LG.onBlur(t),this.yi===fi&&(e.length?(this.IO("verify-error"),this.lq({"verifyErrors":e}).then((()=>{this.fq("verify-error",e,2)}))):this.IO(li))}))})),this.ON.addEventListener("input",(t=>{Ai(t.target),this.LG.onInput(t)}))}WG(){var t;(t=this.zi,K(t,"inputmask","amp-inputmask")).then((t=>{t&&t.install()}))}dq(t){this.mq(!1,"Form analytics not supported");const i={},e=this.rq();for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(i["formFields["+t+"]"]=e[t].join(","));i.formId=this.ON.id;try{this.pq(t,i)}catch(t){k().error(ai,"Sending analytics failed:",t)}}cq(t){return this.yi!=di&&this._q()?this.bq(t.trust,null):Promise.resolve(null)}uq(){this.ON.reset(),this.IO(li),this.ON.classList.remove("user-valid"),this.ON.classList.remove("user-invalid"),this.ON.querySelectorAll(".user-valid, .user-invalid").forEach((t=>{t.classList.remove("user-valid"),t.classList.remove("user-invalid")})),this.ON.querySelectorAll(".visible[validation-for]").forEach((t=>{t.classList.remove("visible")})),function(t){const i=document.createElement("input");for(const e in i.validity)t.querySelectorAll(`.${b(e)}`).forEach((t=>{t.classList.remove(e)}))}(this.ON)}hq(t){return this.yi!=di&&this._q()?((this.XU||"POST"==this.Zb)&&t.preventDefault(),this.bq(3,t)):(t.stopImmediatePropagation(),t.preventDefault(),Promise.resolve(null))}bq(t,i){try{const t={form:this.ON,actionXhrMutator:this.setXhrAction.bind(this)};N(this.QG).fire(t)}catch(t){k().error(ai,"Form submit service failed: %s",t)}const s=this.Aq(),n=this.ON.getElementsByClassName("i-amphtml-async-input");if(this.HL.onSubmitting(),!this.XU&&"GET"==this.Zb){if(this.mq(!1,"Non-XHR GETs not supported."),this.sq(),0===n.length){for(let t=0;t{const i=this.Eq(t);t.classList.contains("i-async-require-action")?r.push(i):o.push(i)})),Promise.all(r).then((()=>this.aq(o,1e4).then((()=>this.Tq(t)),(i=>this.Iq(i,t)))),(i=>this.Iq(i,t)))}Iq(t,i){const e={};return t&&t.message&&(e.error=t.message),this.yq(t,e,i)}Aq(){return this.ON.querySelectorAll('[type="hidden"][data-amp-replace]')}Tq(t){return this.XU?this.Rq(t):("POST"==this.Zb?this.gq():"GET"==this.Zb&&this.Pq(!0),e())}BG(){return this.yi===di?e():(this.IO(fi),this.fq("verify",null,3),this.vq(this.Aq()).then((()=>this.Vq())))}Rq(t){let i;return this.YN.isEnabled()?i=this.wq(t):(this.Mq(t),i=this.xq().then((i=>this.Sq(i,t)),(i=>this.Oq(i,t)))),i}wq(t){const i=this.rq();return this.lq(i).then((()=>this.yP.trigger(this.ON,jt,null,t))).then((()=>{const t=this.requestForFormFetch(this.XU,this.Zb);var i,e,s;return t.fetchOpt=function(t,i){const e=t||{},s=e.credentials;return f(void 0===s||"include"==s||"omit"==s),e.method=void 0===(n=e.method)?"GET":(n=n.toUpperCase(),f(It.includes(n)),n),e.headers=e.headers||{},f(null!==e.body),e;var n}(t.fetchOpt),t.fetchOpt=function(t,i,e){e=e||{};const s=function(t){return t.origin||bt(t.location.href).origin}(t);return s==bt(i).origin&&(e.headers=e.headers||{},e.headers["AMP-Same-Origin"]="true"),e}(this.i,t.xhrUrl,t.fetchOpt),t.xhrUrl=(i=this.i,e=t.xhrUrl,s=t.fetchOpt,f("string"==typeof e),!1!==s.ampCors&&(e=function(t,i){return function(t){const i=S(bt(t).search);X(!(pt in i),"Source origin is not allowed in %s",t)}(i),function(t,i,e,s){return At(t,Pt("__amp_source_origin",e),void 0)}(i,0,function(t){return bt(function(t){if(!Et(t=_t(t)))return t.href;const i=t.pathname.split("/"),e=i[1];X(mt.has(e),"Unknown path prefix in url %s",t.href);const s=i[2],n="s"==s?"https://"+decodeURIComponent(i[3]):"http://"+decodeURIComponent(s);return X(n.indexOf(".")>0,"Expected a . in origin %s",n),i.splice(1,"s"==s?3:2),n+i.join("/")+function(t,i){if(!t||"?"==t)return"";const e=new RegExp("[?&](amp_(js[^&=]*|gsa|r|kit)|usqp)\\b[^&]*","g"),s=t.replace(e,"").replace(/^[?&]/,"");return s?"?"+s:""}(t.search)+(t.hash||"")}(t)).origin}(t.location.href))}(i,e)),e),this.YN.ssr(this.ON,t,this.Fq())})).then((i=>this.$q(i,t)),(i=>{const e={};return i&&i.message&&(e.error=i.message),this.yq(i,e,t)}))}Fq(){let t;const i=this.ON.querySelector("[submit-success]");let e;i&&(t=this.g_.maybeFindTemplate(i));const s=this.ON.querySelector("[submit-error]");return s&&(e=this.g_.maybeFindTemplate(s)),{successTemplate:t,errorTemplate:e}}$q(t,i){const e=t.init,s=function(t,i){try{return function(t){return JSON.parse(t)}(t)}catch(t){return null==i||i(t),null}}(t.body,(t=>$().error(ai,"Failed to parse response JSON: %s",t)));if(e){const n=e.status;if(n>=300)return this.yq(n,t,i,s)}return this.jq(t,i,s)}Mq(t){this.dq("amp-form-submit");const i=this.rq();this.lq(i).then((()=>{this.yP.trigger(this.ON,jt,null,t)}))}vq(t){const i=[];for(let e=0;et.getValue())).then((i=>{const e=t.getAttribute(p);let s=this.ON.querySelector(`input[name=${b(e)}]`);var n,r;s||(n=this.i.document,r={"name":t.getAttribute(p),"hidden":"true"},s=function(t,i){for(const e in i)t.setAttribute(e,i[e]);return t}(n.createElement("input"),r)),s.setAttribute("value",i),this.ON.appendChild(s)}))}xq(){return this.kN(this.XU,this.Zb)}Vq(){const t=r(this.ON.querySelectorAll(`[${b("no-verify")}]`)).map((t=>t.name||t.id));return this.kN(this.KU,this.Zb,{[si]:!0},t)}kN(t,i,e,s){this.mq(!1,"XHRs should be proxied.");const n=this.requestForFormFetch(t,i,e,s);return this.m$.fetch(n.xhrUrl,n.fetchOpt)}kq(t){return t-1}Sq(t,i){return this.m$.xssiJson(t,this.getXssiPrefix()).then((t=>this.jq(t,i)),(t=>$().error(ai,"Failed to parse response JSON: %s",t))).then((()=>{this.dq("amp-form-submit-success"),this.Nq(t)}))}jq(t,i,e){return this.IO("submit-success"),n((()=>{this.lq(t||{}).then((()=>{const s=this.kq(i);this.fq("submit-success",void 0===e?t:e,s),this.HL.onSubmitSuccess()}))}))}Oq(t,i){let e;if(t&&t.response){const i=t;e=this.m$.xssiJson(i.response,this.getXssiPrefix()).catch((()=>null))}else e=Promise.resolve(null);return e.then((e=>{this.yq(t,e,i),this.dq("amp-form-submit-error"),this.Nq(t.response)}))}yq(t,i,e,s){return this.IO("submit-error"),$().error(ai,"Form submission failed: %s",t),n((()=>{this.lq(i).then((()=>{const t=this.kq(e);this.fq("submit-error",void 0===s?i:s,t),this.HL.onSubmitError()}))}))}gq(){X(!1,"Only XHR based (via action-xhr attribute) submissions are supported for POST requests. %s",this.ON)}Pq(t){this.dq("amp-form-submit"),t&&this.ON.submit(),this.IO(li)}mq(t,i){X(this.YN.isEnabled()===t,"[amp-form]: viewerRenderTemplate | %s",i)}sq(){X(0==this.ON.querySelectorAll("input[type=password],input[type=file]").length,"input[type=password] or input[type=file] may only appear in form[method=post]")}_q(){if(i=this.i.document,void 0===qt&&(qt=!!i.createElement("input").checkValidity),qt){const i=((t=this.ON).querySelectorAll("input,select,textarea,fieldset").forEach((t=>bi(t))),bi(t));if(this.XL)return this.LG.report(),i}var t,i;return!0}Nq(t){if(this.mq(!1,"Redirects not supported."),!t||!t.headers)return;const i=t.headers.get(_i);if(i){X(!this.eq,"Redirects not supported in AMP4Email.",this.ON),X("_blank"!=this.o,"Redirecting to target=_blank using AMP-Redirect-To is currently not supported, use target=_top instead. %s",this.ON);try{const t=tt(this.zi);t.assertAbsoluteHttpOrHttpsUrl(i),t.assertHttpsUrl(i,"AMP-Redirect-To","Url")}catch(t){X(!1,"The `AMP-Redirect-To` header value must be an absolute URL starting with https://. Found %s",i)}(e=this.zi,C(e,"navigation")).navigateTo(this.i,i,_i)}var e}fq(t,i,e){const s=st(this.i,`${ai}.${t}`,{"response":i});this.yP.trigger(this.ON,t,s,e)}aq(t,i){return Promise.race([Promise.all(t),this.Gn.promise(i)])}pq(t,i){!function(t,i,e={},s=!0){var n;(n=t,K(n,"amp-analytics-instrumentation","amp-analytics")).then((n=>{n&&n.triggerEventForTarget(t,i,e,s)}))}(this.ON,t,i)}rq(){return y(this.ON)}IO(t){const i=this.yi;this.ON.classList.remove(`amp-form-${i}`),this.ON.classList.add(`amp-form-${t}`),this.Xq(i),this.yi=t}lq(t){o(t)&&(t={});const i=this.ON.querySelector(`[${this.yi}]`);let s=e();if(i){const e=`rendered-message-${this.Ei}`;i.setAttribute("role","alert"),i.setAttribute("aria-labeledby",e),i.setAttribute("aria-live","assertive"),this.g_.hasTemplate(i)?s=this.YN.applySsrOrCsrTemplate(N(i),t).then((t=>{let s;return o(t)?1===t.length?s=t[0]:(s=document.createElement("div"),t.forEach((t=>s.appendChild(t)))):s=t,s.id=e,s.setAttribute("i-amphtml-rendered",""),this.ya.mutateElement(i,(()=>{i.appendChild(s);const t=st(this.i,d,null,{bubbles:!0});i.dispatchEvent(t)}))})):this.ya.mutateElement(i,(()=>{}))}return s}Xq(t){const i=this.ON.querySelector(`[${t}]`);if(!i)return;const e=(s=i,A("i-amphtml-rendered"),"> [i-amphtml-rendered]",s.querySelector(function(t,i){return t.replace(/^|,/g,"$&:scope ")}("> [i-amphtml-rendered]")));var s;e&&v(e)}KG(){if(Et(this.i.location)||!this.ON.hasAttribute("data-initialize-from-url"))return;const t=["SELECT","TEXTAREA"],i=["color","date","datetime-local","email","hidden","month","number","range","search","tel","text","time","url","week"],e=["checkbox","radio"],s=(s,r)=>{if(s.hasAttribute("data-amp-replace"))return;if(!s.hasAttribute("data-allow-initialization"))return;const o=n[r]||"",c=s.getAttribute("type")||"text",u=s.tagName;if("INPUT"===u){if(i.includes(c.toLocaleLowerCase()))s.value!==o&&(s.value=o);else if(e.includes(c)){const t=s.value===o;s.checked!==t&&(s.checked=t)}}else t.includes(u)&&s.value!==o&&(s.value=o)},n=S(this.i.location.search);Object.keys(n).forEach((t=>{const i=this.ON.elements[t];i&&(i.nodeType===Node.ELEMENT_NODE?s(i,t):i.length&&i.forEach((i=>s(i,t))))}))}renderTemplatePromiseForTesting(){return this.ZG}xhrSubmitPromiseForTesting(){return this.YG}}(t,`amp-form-${i}`)}))}BN(t){t.addEventListener(d,(()=>{this.qN(t.querySelectorAll("form"))}))}JN(t){t.addEventListener("keydown",(t=>{if(t.defaultPrevented||"Enter"!=t.key||!t.ctrlKey&&!t.metaKey||"TEXTAREA"!==t.target.tagName)return;const{form:i}=t.target,e=i?I(i):null;e&&(e.hq(t),t.preventDefault())}))}})})(); /*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */}}); //# sourceMappingURL=amp-form-0.1.mjs.map