From 541a90ec4e42af187eeecc34e0e7621280ca1ca8 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 11 Jun 2026 08:10:48 +0000 Subject: [PATCH 1/3] feat(tracking): tag OpenCart address lookups + differentiate AddressFinder/PostcodeLookup Co-Authored-By: Marcin Filip --- lib/extension.ts | 8 ++++++++ src/catalog/view/javascript/opencart.js | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/extension.ts b/lib/extension.ts index 822e472..851bf20 100644 --- a/lib/extension.ts +++ b/lib/extension.ts @@ -17,6 +17,10 @@ import { watch } from "@ideal-postcodes/postcode-lookup"; type SupportedCountry = string; +const tags = ["opencart"]; +const postcodeLookupTags = [...tags, "postcodelookup"]; +const addressFinderTags = [...tags, "addressfinder"].join(","); + const SUPPORTED_COUNTRIES: SupportedCountry[] = [ "England", "Scotland", @@ -147,6 +151,7 @@ export const setupShippingPostcodeLookup = ( watch({ context: "div.idpc_lookup", apiKey: config.apiKey, + tags: postcodeLookupTags, inputClass: "form-control", buttonClass: "btn btn-primary idpc-button", selectClass: "form-select", @@ -201,6 +206,7 @@ export const setupPostcodeLookup = (config: Config, targets: OutputFields, pageT watch({ context: "div.idpc_lookup", apiKey: config.apiKey, + tags: postcodeLookupTags, inputClass: "form-control", buttonClass: "btn btn-primary idpc-button", selectClass: "form-select", @@ -257,6 +263,8 @@ export const setupAutocomplete = (config: Config, targets: OutputFields, pageTes return AddressFinder.watch({ apiKey: config.apiKey, checkKey: true, + queryOptions: { tags: addressFinderTags }, + resolveOptions: { tags: addressFinderTags }, populateOrganisation: true, removeOrganisation: false, outputFields: targets, diff --git a/src/catalog/view/javascript/opencart.js b/src/catalog/view/javascript/opencart.js index 028d156..7918d5d 100644 --- a/src/catalog/view/javascript/opencart.js +++ b/src/catalog/view/javascript/opencart.js @@ -4,4 +4,4 @@ * OpenCart Integration * Copyright IDDQD Limited, all rights reserved */ -!function(){"use strict";const t=t=>"string"==typeof t,e=t=>Array.prototype.slice.call(t),n=(t,e="idpc")=>"true"===t.getAttribute(e),o=(t,e="idpc")=>t.setAttribute(e,"true"),i=()=>!0,s=(t,e,n=i)=>{let o=t;const s=e.toUpperCase();for(;"HTML"!==o.tagName;){if(o.tagName===s&&n(o))return o;if(null===o.parentNode)return null;o=o.parentNode}return null},r=(t,e)=>e?t.querySelector(e):null,a=({elem:t,target:e})=>{const n=e.parentNode;if(null!==n)return n.insertBefore(t,e),t},c=(e,n)=>t(e)?n.querySelector(e):e,u=()=>window.document,l=e=>t(e)?u().querySelector(e):null===e?u():e,d=t=>t instanceof Document||"HTMLDocument"===t.constructor.name?t:t.ownerDocument?t.ownerDocument:u(),h=(t,e)=>{const n=t.getAttribute("style");return Object.keys(e).forEach(n=>t.style[n]=e[n]),n},p=(t,e)=>{t.setAttribute("style",e||"")},f=t=>(t.style.display="none",t),m=t=>(t.style.display="",t),g=t=>{null!==t&&null!==t.parentNode&&t.parentNode.removeChild(t)},y=(t,e,n)=>{const o=t.querySelectorAll(e);for(let t=0;t{const e=(t=String(t)).length;let n,o=-1,i="";const s=t.charCodeAt(0);for(;++o=1&&n<=31||127==n||0==o&&n>=48&&n<=57||1==o&&n>=48&&n<=57&&45==s?"\\"+n.toString(16)+" ":(0!=o||1!=e||45!=n)&&(n>=128||45==n||95==n||n>=48&&n<=57||n>=65&&n<=90||n>=97&&n<=122)?t.charAt(o):"\\"+t.charAt(o):"οΏ½";return i},E=t=>void 0!==t.post_town,w=(t,e)=>t.dispatchEvent((({event:t,bubbles:e=!0,cancelable:n=!0})=>{if("function"==typeof window.Event)return new window.Event(t,{bubbles:e,cancelable:n});const o=document.createEvent("Event");return o.initEvent(t,e,n),o})({event:e})),C=t=>null!==t&&(t instanceof HTMLSelectElement||"HTMLSelectElement"===t.constructor.name),S=t=>null!==t&&(t instanceof HTMLInputElement||"HTMLInputElement"===t.constructor.name),x=t=>null!==t&&(t instanceof HTMLTextAreaElement||"HTMLTextAreaElement"===t.constructor.name),A=t=>S(t)||x(t)||C(t),T=(t,e,n=!1)=>{t&&(S(t)||x(t))&&L({e:t,value:e,skipTrigger:n})},_=(t,e)=>null!==e&&null!==t.querySelector(`[value="${e}"]`),O=(t,e)=>{if(null===e)return[];const n=t.querySelectorAll("option");return Array.from(n).filter(t=>(t.textContent?t.textContent.replace(/[\n\r]/g,"").replace(/\s+/g," ").trim():"")===e)},R=(t,e)=>{const n=Object.getOwnPropertyDescriptor(t.constructor.prototype,"value");if(void 0===n)return;if(void 0===n.set)return;n.set.call(t,e)},L=t=>{null!==t.value&&((({e:t,value:e,skipTrigger:n})=>{null!==e&&C(t)&&(R(t,e),n||w(t,"select"),w(t,"change"))})(t),(({e:t,value:e,skipTrigger:n})=>{null!==e&&(S(t)||x(t))&&(R(t,e),n||w(t,"input"),w(t,"change"))})(t))},k="United Kingdom",N="Isle of Man",F=t=>{const e=t.country;if("England"===e)return k;if("Scotland"===e)return k;if("Wales"===e)return k;if("Northern Ireland"===e)return k;if(e===N)return N;if(E(t)&&"Channel Islands"===e){if(/^GY/.test(t.postcode))return"Guernsey";if(/^JE/.test(t.postcode))return"Jersey"}return e};let U={};"undefined"!=typeof window&&(window.idpcGlobal?U=window.idpcGlobal:window.idpcGlobal=U);const P=()=>U,j=e=>e.filter(e=>t(e)?!!e.trim():!!e).join(", "),I=(t,e)=>{if(t.length<=e)return[t,""];const n=t.split(" ");let o="",i="";for(let t=0;te){i=n.slice(t).join(" ");break}o+=`${s} `}return[o.trim(),i.trim()]},D=(t,e)=>0===e.length?t:`${t}, ${e}`,B=(t,e,n)=>{const{line_1:o,line_2:i}=e,s="line_3"in e?e.line_3:"";return n.maxLineOne||n.maxLineTwo||n.maxLineThree?((t,e)=>{const{lineCount:n,maxLineOne:o,maxLineTwo:i,maxLineThree:s}=e,r=["","",""],a=[...t];if(o){const[t,e]=I(a[0],o);if(r[0]=t,e&&(a[1]=D(e,a[1])),1===n)return r}else if(r[0]=a[0],1===n)return[j(a),"",""];if(i){const[t,e]=I(a[1],i);if(r[1]=t,e&&(a[2]=D(e,a[2])),2===n)return r}else if(r[1]=a[1],2===n)return[r[0],j(a.slice(1)),""];if(s){const[t,e]=I(a[2],s);r[2]=t,e&&(a[3]=D(e,a[3]))}else r[2]=a[2];return r})([o,i,s],{lineCount:t,...n}):3===t?[o,i,s]:2===t?[o,j([i,s]),""]:[j([o,i,s]),"",""]},q=(t,e)=>{const n=t[e];return"number"==typeof n?n.toString():void 0===n?"":n},M=(t,e)=>{const n={};let o;for(o in t){const i=t[o];if(void 0===i)continue;const s=c(i,e);A(s)&&(n[o]=s)}return n},H=(t,e)=>{const n={};let o;for(o in t){if(!t.hasOwnProperty(o))continue;const i=t[o],s=c(`[name="${i}"]`,e);if(s){n[o]=s;continue}const r=c(`[aria-name="${i}"]`,e);r&&(n[o]=r)}return n},$=(t,e)=>{const n={};if(void 0===t)return t;let o;for(o in t){if(!t.hasOwnProperty(o))continue;const i=t[o];if(!i)continue;const s=y(e,"label",i),r=c(s,e);if(!r)continue;const a=r.getAttribute("for");if(a){const t=e.querySelector(`#${b(a)}`);if(t){n[o]=t;continue}}const u=r.querySelector("input");u&&(n[o]=u)}return n},z=["country","country_iso_2","country_iso"],K=t=>{const{config:e}=t,n={...M((o=t).outputFields||{},o.config.scope),...H(o.names||{},o.config.scope),...$(o.labels||{},o.config.scope)};var o;void 0===e.lines&&(e.lines=(t=>{const{line_2:e,line_3:n}=t;return e?n?3:2:1})(n));const i=((t,e)=>{E(t)&&e.removeOrganisation&&W(t);const[n,o,i]=B(e.lines||3,t,e);return t.line_1=n,t.line_2=o,E(t)&&(t.line_3=i),t})({...t.address},e),{scope:s,populateCounty:r}=e,a=[...z];E(i)&&(e.removeOrganisation&&W(i),!1===r&&a.push("county")),((t,e)=>{if(t){if(C(t)){const n=F(e);if(_(t,n))return void L({e:t,value:n});if(_(t,e.country_iso_2))return void L({e:t,value:e.country_iso_2});if(_(t,e.country_iso))return void L({e:t,value:e.country_iso});let o=O(t,n);if(o.length>0)return void L({e:t,value:o[0].value||""});if(o=O(t,e.country_iso_2),o.length>0)return void L({e:t,value:o[0].value||""});if(o=O(t,e.country_iso),o.length>0)return void L({e:t,value:o[0].value||""})}if(S(t)){const n=F(e);L({e:t,value:n})}}})(c(n.country||null,s),i);const u=c(n.country_iso_2||null,s);if(C(u))if(_(u,i.country_iso_2))L({e:u,value:i.country_iso_2});else{let t=O(u,i.country_iso_2);t.length>0?L({e:u,value:t[0].value||""}):(t=O(u,F(i)),t.length>0&&L({e:u,value:t[0].value||""}))}S(u)&&T(u,i.country_iso_2||"");const l=c(n.country_iso||null,s);if(C(l))if(_(l,i.country_iso))L({e:l,value:i.country_iso});else{let t=O(l,i.country_iso);t.length>0?L({e:l,value:t[0].value||""}):(t=O(l,F(i)),t.length>0&&L({e:l,value:t[0].value||""}))}S(l)&&T(l,i.country_iso||"");const d=c(V(n),s),h=J(i),p=Y(i);if(C(d))if(_(d,h))L({e:d,value:h});else if(_(d,p||""))L({e:d,value:p||""});else{let t=O(d,p);t.length>0?L({e:d,value:t[0].value||""}):(t=O(d,h),t&&L({e:d,value:t[0].value||""}))}let f;for(f in S(d)&&T(d,h),n)if(!a.includes(f))if(f.startsWith("native."))G(f,n,i,s);else if(void 0!==i[f]&&n.hasOwnProperty(f)){const t=n[f];if(!t)continue;T(c(t,s),q(i,f))}},G=(t,e,n,o)=>{const i=t.replace("native.",""),s=n.native;if(void 0===s)return;if(void 0!==s[i]&&e.hasOwnProperty(t)){const n=e[t];if(!n)return;T(c(n,o),q(s,i))}},W=t=>(0===t.organisation_name.length||0===t.line_2.length&&0===t.line_3.length||t.line_1===t.organisation_name&&(t.line_1=t.line_2,t.line_2=t.line_3,t.line_3=""),t),V=t=>(t=>t.hasOwnProperty("state_abbreviation"))(t)?t.state_abbreviation||null:t.county_code||null,J=t=>E(t)?t.county_code:t.state_abbreviation,Y=t=>E(t)?t.county:t.state,X={13:"Enter",38:"ArrowUp",40:"ArrowDown",36:"Home",35:"End",27:"Escape",8:"Backspace"},Q=["Enter","ArrowUp","ArrowDown","Home","End","Escape","Backspace"],Z=t=>{return t.keyCode?X[t.keyCode]||null:(e=t.key,-1!==Q.indexOf(e)?t.key:null);var e},tt=function(t,e,n){let o,i,s,r,a;if("function"!=typeof t)throw new TypeError("Expected a function");function c(t){const n=t-a;return void 0===a||n>=e||n<0||false}function u(){const n=Date.now();if(c(n))return function(){if(r=void 0,o)return function(){const e=o,n=i;return o=i=void 0,s=t.apply(n,e),s}();return o=i=void 0,s}();r=setTimeout(u,function(t){return e-(t-a)}(n))}function l(...t){const n=Date.now(),l=c(n);return o=t,i=this,a=n,l&&void 0===r?(r=setTimeout(u,e),s):(void 0===r&&(r=setTimeout(u,e)),s)}return e=+e||0,l.cancel=function(){void 0!==r&&clearTimeout(r),o=a=i=r=void 0},l.pending=function(){return void 0!==r},l},et=({bind:t,interval:e=1e3})=>{let n=null;const o=()=>{null!==n&&(window.clearInterval(n),n=null)};return{start:()=>(n=window.setInterval(()=>{try{t()}catch(t){o()}},e),n),stop:o}},nt=t=>window&&window.MutationObserver&&t.mutationObserver?(({bind:t,interval:e=1e3,target:n=window.document,observerConfig:o={subtree:!0,childList:!0}})=>{const i=new MutationObserver(tt(()=>{try{t()}catch(t){s()}},e)),s=()=>i.disconnect();return{start:()=>(i.observe(n,o),null),stop:s}})(t):et(t);var ot="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function it(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var st=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},rt="object"==typeof ot&&ot&&ot.Object===Object&&ot,at="object"==typeof self&&self&&self.Object===Object&&self,ct=rt||at||Function("return this")(),ut=ct,lt=function(){return ut.Date.now()},dt=/\s/;var ht=function(t){for(var e=t.length;e--&&dt.test(t.charAt(e)););return e},pt=/^\s+/;var ft=function(t){return t?t.slice(0,ht(t)+1).replace(pt,""):t},mt=ct.Symbol,gt=mt,yt=Object.prototype,vt=yt.hasOwnProperty,bt=yt.toString,Et=gt?gt.toStringTag:void 0;var wt=function(t){var e=vt.call(t,Et),n=t[Et];try{t[Et]=void 0;var o=!0}catch(t){}var i=bt.call(t);return o&&(e?t[Et]=n:delete t[Et]),i},Ct=Object.prototype.toString;var St=wt,xt=function(t){return Ct.call(t)},At=mt?mt.toStringTag:void 0;var Tt=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":At&&At in Object(t)?St(t):xt(t)},_t=function(t){return null!=t&&"object"==typeof t};var Ot=ft,Rt=st,Lt=function(t){return"symbol"==typeof t||_t(t)&&"[object Symbol]"==Tt(t)},kt=/^[-+]0x[0-9a-f]+$/i,Nt=/^0b[01]+$/i,Ft=/^0o[0-7]+$/i,Ut=parseInt;var Pt=st,jt=lt,It=function(t){if("number"==typeof t)return t;if(Lt(t))return NaN;if(Rt(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Rt(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Ot(t);var n=Nt.test(t);return n||Ft.test(t)?Ut(t.slice(2),n?2:8):kt.test(t)?NaN:+t},Dt=Math.max,Bt=Math.min;var qt=function(t,e,n){var o,i,s,r,a,c,u=0,l=!1,d=!1,h=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function p(e){var n=o,s=i;return o=i=void 0,u=e,r=t.apply(s,n)}function f(t){var n=t-c;return void 0===c||n>=e||n<0||d&&t-u>=s}function m(){var t=jt();if(f(t))return g(t);a=setTimeout(m,function(t){var n=e-(t-c);return d?Bt(n,s-(t-u)):n}(t))}function g(t){return a=void 0,h&&o?p(t):(o=i=void 0,r)}function y(){var t=jt(),n=f(t);if(o=arguments,i=this,c=t,n){if(void 0===a)return function(t){return u=t,a=setTimeout(m,e),l?p(t):r}(c);if(d)return clearTimeout(a),a=setTimeout(m,e),p(c)}return void 0===a&&(a=setTimeout(m,e)),r}return e=It(e)||0,Pt(n)&&(l=!!n.leading,s=(d="maxWait"in n)?Dt(It(n.maxWait)||0,e):s,h="trailing"in n?!!n.trailing:h),y.cancel=function(){void 0!==a&&clearTimeout(a),u=0,o=c=i=a=void 0},y.flush=function(){return void 0===a?r:g(jt())},y},Mt=it(qt);const Ht=(t,e)=>(t.id=e,t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t),$t=t=>{const e={};for(const n of t)e[n.iso_3]=n;return e},zt={tls:!0,api_key:"",baseUrl:"api.ideal-postcodes.co.uk",version:"v1",strictAuthorisation:!1,timeout:1e4,header:{Accept:"application/json","Content-Type":"application/json"},tags:[],agent:{}};let Kt=class{constructor(t){this.config={...zt,...t},this.config.header={...zt.header,...t.header&&t.header}}url(){const{baseUrl:t,version:e}=this.config;return`${this.protocol()}://${t}/${e}`}protocol(){return this.config.tls?"https":"http"}};const Gt=t=>void 0===t?{}:Object.keys(t).reduce((e,n)=>{const o=t[n],i=Vt(o);return i.length>0&&(e[n]=i),e},{}),Wt=t=>"string"==typeof t,Vt=t=>{const e=[];return(t=>Array.isArray(t))(t)?(t.forEach(t=>{Jt(t)&&e.push(t.toString()),Wt(t)&&e.push(t)}),e.join(",")):Jt(t)?t.toString():Wt(t)?t:""},Jt=t=>"number"==typeof t,Yt=({timeout:t},e)=>Jt(t)?t:e.config.timeout,Xt=({header:t={}},e)=>({...e.config.header,...Gt(t)}),Qt=({header:t,options:e,client:n})=>(t.Authorization=((t,e)=>{const n=[],o=e.api_key||t.config.api_key;n.push(["api_key",o]);const i=e.licensee;void 0!==i&&n.push(["licensee",i]);const s=e.user_token;return void 0!==s&&n.push(["user_token",s]),`IDEALPOSTCODES ${Zt(n)}`})(n,e),t),Zt=t=>t.map(([t,e])=>`${t}="${e}"`).join(" "),te=({header:t,options:e})=>{const{sourceIp:n}=e;return void 0!==n&&(t["IDPC-Source-IP"]=n),t},ee=({query:t,options:e})=>{const{filter:n}=e;return void 0!==n&&(t.filter=n.join(",")),t},ne=({client:t,query:e,options:n})=>{let o;return t.config.tags.length&&(o=t.config.tags),n.tags&&(o=n.tags),void 0!==o&&(e.tags=o.join(",")),e};let oe=class t extends Error{constructor(e){const n=new.target.prototype;super(),this.__proto__=n;const{message:o,httpStatus:i,metadata:s={}}=e;this.message=o,this.name="Ideal Postcodes Error",this.httpStatus=i,this.metadata=s,Error.captureStackTrace&&Error.captureStackTrace(this,t)}};class ie extends oe{constructor(t){super({httpStatus:t.httpStatus,message:t.body.message}),this.response=t}}class se extends ie{}class re extends ie{}class ae extends re{}class ce extends ie{}class ue extends ce{}class le extends ce{}class de extends ie{}class he extends de{}class pe extends de{}class fe extends de{}class me extends de{}class ge extends ie{}const ye=t=>{const{httpStatus:e,body:n}=t;if((o=e)<200||o>=300){var o;if((t=>{return null!==(e=t)&&"object"==typeof e&&"string"==typeof t.message&&"number"==typeof t.code;var e})(n)){const{code:o}=n;if(4010===o)return new ae(t);if(4040===o)return new he(t);if(4042===o)return new pe(t);if(4044===o)return new fe(t);if(4046===o)return new me(t);if(4020===o)return new ue(t);if(4021===o)return new le(t);if(404===e)return new de(t);if(400===e)return new se(t);if(402===e)return new ce(t);if(401===e)return new re(t);if(500===e)return new ge(t)}return new oe({httpStatus:e,message:JSON.stringify(n)})}};var ve=Object.freeze({__proto__:null,IdealPostcodesError:oe,IdpcApiError:ie,IdpcBadRequestError:se,IdpcBalanceDepletedError:ue,IdpcInvalidKeyError:ae,IdpcKeyNotFoundError:pe,IdpcLimitReachedError:le,IdpcPostcodeNotFoundError:he,IdpcRequestFailedError:ce,IdpcResourceNotFoundError:de,IdpcServerError:ge,IdpcUdprnNotFoundError:fe,IdpcUmprnNotFoundError:me,IdpcUnauthorisedError:re,parse:ye});const be=(t,e)=>[t.client.url(),t.resource,encodeURIComponent(e),t.action].filter(t=>void 0!==t).join("/"),Ee=t=>{const{client:e}=t;return(n,o)=>e.config.agent.http({method:"GET",url:be(t,n),query:Gt(o.query),header:Xt(o,e),timeout:Yt(o,e)}).then(t=>{const e=ye(t);if(e)throw e;return t})},we=t=>{const{client:e,resource:n}=t;return t=>e.config.agent.http({method:"GET",url:`${e.url()}/${n}`,query:Gt(t.query),header:Xt(t,e),timeout:Yt(t,e)}).then(t=>{const e=ye(t);if(e)throw e;return t})},Ce=t=>{const{client:e,timeout:n}=t,o=t.api_key||t.client.config.api_key,{licensee:i}=t;let s;s=void 0===i?{}:{licensee:i};const r={query:s,header:{}};return void 0!==n&&(r.timeout=n),((t,e,n)=>Ee({resource:"keys",client:t})(e,n))(e,o,r).then(t=>t.body.result)},Se="autocomplete/addresses";function xe(t,e){return function(){return t.apply(e,arguments)}}const{toString:Ae}=Object.prototype,{getPrototypeOf:Te}=Object,{iterator:_e,toStringTag:Oe}=Symbol,Re=(Le=Object.create(null),t=>{const e=Ae.call(t);return Le[e]||(Le[e]=e.slice(8,-1).toLowerCase())});var Le;const ke=t=>(t=t.toLowerCase(),e=>Re(e)===t),Ne=t=>e=>typeof e===t,{isArray:Fe}=Array,Ue=Ne("undefined");function Pe(t){return null!==t&&!Ue(t)&&null!==t.constructor&&!Ue(t.constructor)&&De(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const je=ke("ArrayBuffer");const Ie=Ne("string"),De=Ne("function"),Be=Ne("number"),qe=t=>null!==t&&"object"==typeof t,Me=t=>{if("object"!==Re(t))return!1;const e=Te(t);return!(null!==e&&e!==Object.prototype&&null!==Object.getPrototypeOf(e)||Oe in t||_e in t)},He=ke("Date"),$e=ke("File"),ze=ke("Blob"),Ke=ke("FileList"),Ge=ke("URLSearchParams"),[We,Ve,Je,Ye]=["ReadableStream","Request","Response","Headers"].map(ke);function Xe(t,e,{allOwnKeys:n=!1}={}){if(null==t)return;let o,i;if("object"!=typeof t&&(t=[t]),Fe(t))for(o=0,i=t.length;o0;)if(o=n[i],e===o.toLowerCase())return o;return null}const Ze="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,tn=t=>!Ue(t)&&t!==Ze;const en=(nn="undefined"!=typeof Uint8Array&&Te(Uint8Array),t=>nn&&t instanceof nn);var nn;const on=ke("HTMLFormElement"),sn=(({hasOwnProperty:t})=>(e,n)=>t.call(e,n))(Object.prototype),rn=ke("RegExp"),an=(t,e)=>{const n=Object.getOwnPropertyDescriptors(t),o={};Xe(n,(n,i)=>{let s;!1!==(s=e(n,i,t))&&(o[i]=s||n)}),Object.defineProperties(t,o)};const cn=ke("AsyncFunction"),un=(ln="function"==typeof setImmediate,dn=De(Ze.postMessage),ln?setImmediate:dn?(hn=`axios@${Math.random()}`,pn=[],Ze.addEventListener("message",({source:t,data:e})=>{t===Ze&&e===hn&&pn.length&&pn.shift()()},!1),t=>{pn.push(t),Ze.postMessage(hn,"*")}):t=>setTimeout(t));var ln,dn,hn,pn;const fn="undefined"!=typeof queueMicrotask?queueMicrotask.bind(Ze):"undefined"!=typeof process&&process.nextTick||un;var mn={isArray:Fe,isArrayBuffer:je,isBuffer:Pe,isFormData:t=>{let e;return t&&("function"==typeof FormData&&t instanceof FormData||De(t.append)&&("formdata"===(e=Re(t))||"object"===e&&De(t.toString)&&"[object FormData]"===t.toString()))},isArrayBufferView:function(t){let e;return e="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&je(t.buffer),e},isString:Ie,isNumber:Be,isBoolean:t=>!0===t||!1===t,isObject:qe,isPlainObject:Me,isEmptyObject:t=>{if(!qe(t)||Pe(t))return!1;try{return 0===Object.keys(t).length&&Object.getPrototypeOf(t)===Object.prototype}catch(t){return!1}},isReadableStream:We,isRequest:Ve,isResponse:Je,isHeaders:Ye,isUndefined:Ue,isDate:He,isFile:$e,isBlob:ze,isRegExp:rn,isFunction:De,isStream:t=>qe(t)&&De(t.pipe),isURLSearchParams:Ge,isTypedArray:en,isFileList:Ke,forEach:Xe,merge:function t(){const{caseless:e,skipUndefined:n}=tn(this)&&this||{},o={},i=(i,s)=>{const r=e&&Qe(o,s)||s;Me(o[r])&&Me(i)?o[r]=t(o[r],i):Me(i)?o[r]=t({},i):Fe(i)?o[r]=i.slice():n&&Ue(i)||(o[r]=i)};for(let t=0,e=arguments.length;t(Xe(e,(e,o)=>{n&&De(e)?t[o]=xe(e,n):t[o]=e},{allOwnKeys:o}),t),trim:t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:t=>(65279===t.charCodeAt(0)&&(t=t.slice(1)),t),inherits:(t,e,n,o)=>{t.prototype=Object.create(e.prototype,o),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),n&&Object.assign(t.prototype,n)},toFlatObject:(t,e,n,o)=>{let i,s,r;const a={};if(e=e||{},null==t)return e;do{for(i=Object.getOwnPropertyNames(t),s=i.length;s-- >0;)r=i[s],o&&!o(r,t,e)||a[r]||(e[r]=t[r],a[r]=!0);t=!1!==n&&Te(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e},kindOf:Re,kindOfTest:ke,endsWith:(t,e,n)=>{t=String(t),(void 0===n||n>t.length)&&(n=t.length),n-=e.length;const o=t.indexOf(e,n);return-1!==o&&o===n},toArray:t=>{if(!t)return null;if(Fe(t))return t;let e=t.length;if(!Be(e))return null;const n=new Array(e);for(;e-- >0;)n[e]=t[e];return n},forEachEntry:(t,e)=>{const n=(t&&t[_e]).call(t);let o;for(;(o=n.next())&&!o.done;){const n=o.value;e.call(t,n[0],n[1])}},matchAll:(t,e)=>{let n;const o=[];for(;null!==(n=t.exec(e));)o.push(n);return o},isHTMLForm:on,hasOwnProperty:sn,hasOwnProp:sn,reduceDescriptors:an,freezeMethods:t=>{an(t,(e,n)=>{if(De(t)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const o=t[n];De(o)&&(e.enumerable=!1,"writable"in e?e.writable=!1:e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))})},toObjectSet:(t,e)=>{const n={},o=t=>{t.forEach(t=>{n[t]=!0})};return Fe(t)?o(t):o(String(t).split(e)),n},toCamelCase:t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,e,n){return e.toUpperCase()+n}),noop:()=>{},toFiniteNumber:(t,e)=>null!=t&&Number.isFinite(t=+t)?t:e,findKey:Qe,global:Ze,isContextDefined:tn,isSpecCompliantForm:function(t){return!!(t&&De(t.append)&&"FormData"===t[Oe]&&t[_e])},toJSONObject:t=>{const e=new Array(10),n=(t,o)=>{if(qe(t)){if(e.indexOf(t)>=0)return;if(Pe(t))return t;if(!("toJSON"in t)){e[o]=t;const i=Fe(t)?[]:{};return Xe(t,(t,e)=>{const s=n(t,o+1);!Ue(s)&&(i[e]=s)}),e[o]=void 0,i}}return t};return n(t,0)},isAsyncFn:cn,isThenable:t=>t&&(qe(t)||De(t))&&De(t.then)&&De(t.catch),setImmediate:un,asap:fn,isIterable:t=>null!=t&&De(t[_e])};function gn(t,e,n,o,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=t,this.name="AxiosError",e&&(this.code=e),n&&(this.config=n),o&&(this.request=o),i&&(this.response=i,this.status=i.status?i.status:null)}mn.inherits(gn,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:mn.toJSONObject(this.config),code:this.code,status:this.status}}});const yn=gn.prototype,vn={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{vn[t]={value:t}}),Object.defineProperties(gn,vn),Object.defineProperty(yn,"isAxiosError",{value:!0}),gn.from=(t,e,n,o,i,s)=>{const r=Object.create(yn);mn.toFlatObject(t,r,function(t){return t!==Error.prototype},t=>"isAxiosError"!==t);const a=t&&t.message?t.message:"Error",c=null==e&&t?t.code:e;return gn.call(r,a,c,n,o,i),t&&null==r.cause&&Object.defineProperty(r,"cause",{value:t,configurable:!0}),r.name=t&&t.name||"Error",s&&Object.assign(r,s),r};function bn(t){return mn.isPlainObject(t)||mn.isArray(t)}function En(t){return mn.endsWith(t,"[]")?t.slice(0,-2):t}function wn(t,e,n){return t?t.concat(e).map(function(t,e){return t=En(t),!n&&e?"["+t+"]":t}).join(n?".":""):e}const Cn=mn.toFlatObject(mn,{},null,function(t){return/^is[A-Z]/.test(t)});function Sn(t,e,n){if(!mn.isObject(t))throw new TypeError("target must be an object");e=e||new FormData;const o=(n=mn.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(t,e){return!mn.isUndefined(e[t])})).metaTokens,i=n.visitor||u,s=n.dots,r=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&mn.isSpecCompliantForm(e);if(!mn.isFunction(i))throw new TypeError("visitor must be a function");function c(t){if(null===t)return"";if(mn.isDate(t))return t.toISOString();if(mn.isBoolean(t))return t.toString();if(!a&&mn.isBlob(t))throw new gn("Blob is not supported. Use a Buffer instead.");return mn.isArrayBuffer(t)||mn.isTypedArray(t)?a&&"function"==typeof Blob?new Blob([t]):Buffer.from(t):t}function u(t,n,i){let a=t;if(t&&!i&&"object"==typeof t)if(mn.endsWith(n,"{}"))n=o?n:n.slice(0,-2),t=JSON.stringify(t);else if(mn.isArray(t)&&function(t){return mn.isArray(t)&&!t.some(bn)}(t)||(mn.isFileList(t)||mn.endsWith(n,"[]"))&&(a=mn.toArray(t)))return n=En(n),a.forEach(function(t,o){!mn.isUndefined(t)&&null!==t&&e.append(!0===r?wn([n],o,s):null===r?n:n+"[]",c(t))}),!1;return!!bn(t)||(e.append(wn(i,n,s),c(t)),!1)}const l=[],d=Object.assign(Cn,{defaultVisitor:u,convertValue:c,isVisitable:bn});if(!mn.isObject(t))throw new TypeError("data must be an object");return function t(n,o){if(!mn.isUndefined(n)){if(-1!==l.indexOf(n))throw Error("Circular reference detected in "+o.join("."));l.push(n),mn.forEach(n,function(n,s){!0===(!(mn.isUndefined(n)||null===n)&&i.call(e,n,mn.isString(s)?s.trim():s,o,d))&&t(n,o?o.concat(s):[s])}),l.pop()}}(t),e}function xn(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(t){return e[t]})}function An(t,e){this._pairs=[],t&&Sn(t,this,e)}const Tn=An.prototype;function _n(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function On(t,e,n){if(!e)return t;const o=n&&n.encode||_n;mn.isFunction(n)&&(n={serialize:n});const i=n&&n.serialize;let s;if(s=i?i(e,n):mn.isURLSearchParams(e)?e.toString():new An(e,n).toString(o),s){const e=t.indexOf("#");-1!==e&&(t=t.slice(0,e)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t}Tn.append=function(t,e){this._pairs.push([t,e])},Tn.toString=function(t){const e=t?function(e){return t.call(this,e,xn)}:xn;return this._pairs.map(function(t){return e(t[0])+"="+e(t[1])},"").join("&")};class Rn{constructor(){this.handlers=[]}use(t,e,n){return this.handlers.push({fulfilled:t,rejected:e,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){mn.forEach(this.handlers,function(e){null!==e&&t(e)})}}var Ln={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},kn={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:An,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const Nn="undefined"!=typeof window&&"undefined"!=typeof document,Fn="object"==typeof navigator&&navigator||void 0,Un=Nn&&(!Fn||["ReactNative","NativeScript","NS"].indexOf(Fn.product)<0),Pn="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,jn=Nn&&window.location.href||"http://localhost";var In={...Object.freeze({__proto__:null,hasBrowserEnv:Nn,hasStandardBrowserEnv:Un,hasStandardBrowserWebWorkerEnv:Pn,navigator:Fn,origin:jn}),...kn};function Dn(t){function e(t,n,o,i){let s=t[i++];if("__proto__"===s)return!0;const r=Number.isFinite(+s),a=i>=t.length;if(s=!s&&mn.isArray(o)?o.length:s,a)return mn.hasOwnProp(o,s)?o[s]=[o[s],n]:o[s]=n,!r;o[s]&&mn.isObject(o[s])||(o[s]=[]);return e(t,n,o[s],i)&&mn.isArray(o[s])&&(o[s]=function(t){const e={},n=Object.keys(t);let o;const i=n.length;let s;for(o=0;o{e(function(t){return mn.matchAll(/\w+|\[(\w*)]/g,t).map(t=>"[]"===t[0]?"":t[1]||t[0])}(t),o,n,0)}),n}return null}const Bn={transitional:Ln,adapter:["xhr","http","fetch"],transformRequest:[function(t,e){const n=e.getContentType()||"",o=n.indexOf("application/json")>-1,i=mn.isObject(t);i&&mn.isHTMLForm(t)&&(t=new FormData(t));if(mn.isFormData(t))return o?JSON.stringify(Dn(t)):t;if(mn.isArrayBuffer(t)||mn.isBuffer(t)||mn.isStream(t)||mn.isFile(t)||mn.isBlob(t)||mn.isReadableStream(t))return t;if(mn.isArrayBufferView(t))return t.buffer;if(mn.isURLSearchParams(t))return e.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let s;if(i){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(t,e){return Sn(t,new In.classes.URLSearchParams,{visitor:function(t,e,n,o){return In.isNode&&mn.isBuffer(t)?(this.append(e,t.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...e})}(t,this.formSerializer).toString();if((s=mn.isFileList(t))||n.indexOf("multipart/form-data")>-1){const e=this.env&&this.env.FormData;return Sn(s?{"files[]":t}:t,e&&new e,this.formSerializer)}}return i||o?(e.setContentType("application/json",!1),function(t,e,n){if(mn.isString(t))try{return(e||JSON.parse)(t),mn.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(n||JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){const e=this.transitional||Bn.transitional,n=e&&e.forcedJSONParsing,o="json"===this.responseType;if(mn.isResponse(t)||mn.isReadableStream(t))return t;if(t&&mn.isString(t)&&(n&&!this.responseType||o)){const n=!(e&&e.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(t){if(n){if("SyntaxError"===t.name)throw gn.from(t,gn.ERR_BAD_RESPONSE,this,null,this.response);throw t}}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:In.classes.FormData,Blob:In.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};mn.forEach(["delete","get","head","post","put","patch"],t=>{Bn.headers[t]={}});const qn=mn.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const Mn=Symbol("internals");function Hn(t){return t&&String(t).trim().toLowerCase()}function $n(t){return!1===t||null==t?t:mn.isArray(t)?t.map($n):String(t)}function zn(t,e,n,o,i){return mn.isFunction(o)?o.call(this,e,n):(i&&(e=n),mn.isString(e)?mn.isString(o)?-1!==e.indexOf(o):mn.isRegExp(o)?o.test(e):void 0:void 0)}let Kn=class{constructor(t){t&&this.set(t)}set(t,e,n){const o=this;function i(t,e,n){const i=Hn(e);if(!i)throw new Error("header name must be a non-empty string");const s=mn.findKey(o,i);(!s||void 0===o[s]||!0===n||void 0===n&&!1!==o[s])&&(o[s||e]=$n(t))}const s=(t,e)=>mn.forEach(t,(t,n)=>i(t,n,e));if(mn.isPlainObject(t)||t instanceof this.constructor)s(t,e);else if(mn.isString(t)&&(t=t.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim()))s((t=>{const e={};let n,o,i;return t&&t.split("\n").forEach(function(t){i=t.indexOf(":"),n=t.substring(0,i).trim().toLowerCase(),o=t.substring(i+1).trim(),!n||e[n]&&qn[n]||("set-cookie"===n?e[n]?e[n].push(o):e[n]=[o]:e[n]=e[n]?e[n]+", "+o:o)}),e})(t),e);else if(mn.isObject(t)&&mn.isIterable(t)){let n,o,i={};for(const e of t){if(!mn.isArray(e))throw TypeError("Object iterator must return a key-value pair");i[o=e[0]]=(n=i[o])?mn.isArray(n)?[...n,e[1]]:[n,e[1]]:e[1]}s(i,e)}else null!=t&&i(e,t,n);return this}get(t,e){if(t=Hn(t)){const n=mn.findKey(this,t);if(n){const t=this[n];if(!e)return t;if(!0===e)return function(t){const e=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let o;for(;o=n.exec(t);)e[o[1]]=o[2];return e}(t);if(mn.isFunction(e))return e.call(this,t,n);if(mn.isRegExp(e))return e.exec(t);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,e){if(t=Hn(t)){const n=mn.findKey(this,t);return!(!n||void 0===this[n]||e&&!zn(0,this[n],n,e))}return!1}delete(t,e){const n=this;let o=!1;function i(t){if(t=Hn(t)){const i=mn.findKey(n,t);!i||e&&!zn(0,n[i],i,e)||(delete n[i],o=!0)}}return mn.isArray(t)?t.forEach(i):i(t),o}clear(t){const e=Object.keys(this);let n=e.length,o=!1;for(;n--;){const i=e[n];t&&!zn(0,this[i],i,t,!0)||(delete this[i],o=!0)}return o}normalize(t){const e=this,n={};return mn.forEach(this,(o,i)=>{const s=mn.findKey(n,i);if(s)return e[s]=$n(o),void delete e[i];const r=t?function(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,e,n)=>e.toUpperCase()+n)}(i):String(i).trim();r!==i&&delete e[i],e[r]=$n(o),n[r]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const e=Object.create(null);return mn.forEach(this,(n,o)=>{null!=n&&!1!==n&&(e[o]=t&&mn.isArray(n)?n.join(", "):n)}),e}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,e])=>t+": "+e).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...e){const n=new this(t);return e.forEach(t=>n.set(t)),n}static accessor(t){const e=(this[Mn]=this[Mn]={accessors:{}}).accessors,n=this.prototype;function o(t){const o=Hn(t);e[o]||(!function(t,e){const n=mn.toCamelCase(" "+e);["get","set","has"].forEach(o=>{Object.defineProperty(t,o+n,{value:function(t,n,i){return this[o].call(this,e,t,n,i)},configurable:!0})})}(n,t),e[o]=!0)}return mn.isArray(t)?t.forEach(o):o(t),this}};function Gn(t,e){const n=this||Bn,o=e||n,i=Kn.from(o.headers);let s=o.data;return mn.forEach(t,function(t){s=t.call(n,s,i.normalize(),e?e.status:void 0)}),i.normalize(),s}function Wn(t){return!(!t||!t.__CANCEL__)}function Vn(t,e,n){gn.call(this,null==t?"canceled":t,gn.ERR_CANCELED,e,n),this.name="CanceledError"}function Jn(t,e,n){const o=n.config.validateStatus;n.status&&o&&!o(n.status)?e(new gn("Request failed with status code "+n.status,[gn.ERR_BAD_REQUEST,gn.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):t(n)}Kn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),mn.reduceDescriptors(Kn.prototype,({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(t){this[n]=t}}}),mn.freezeMethods(Kn),mn.inherits(Vn,gn,{__CANCEL__:!0});const Yn=(t,e,n=3)=>{let o=0;const i=function(t,e){t=t||10;const n=new Array(t),o=new Array(t);let i,s=0,r=0;return e=void 0!==e?e:1e3,function(a){const c=Date.now(),u=o[r];i||(i=c),n[s]=a,o[s]=c;let l=r,d=0;for(;l!==s;)d+=n[l++],l%=t;if(s=(s+1)%t,s===r&&(r=(r+1)%t),c-i{i=s,n=null,o&&(clearTimeout(o),o=null),t(...e)};return[(...t)=>{const e=Date.now(),a=e-i;a>=s?r(t,e):(n=t,o||(o=setTimeout(()=>{o=null,r(n)},s-a)))},()=>n&&r(n)]}(n=>{const s=n.loaded,r=n.lengthComputable?n.total:void 0,a=s-o,c=i(a);o=s;t({loaded:s,total:r,progress:r?s/r:void 0,bytes:a,rate:c||void 0,estimated:c&&r&&s<=r?(r-s)/c:void 0,event:n,lengthComputable:null!=r,[e?"download":"upload"]:!0})},n)},Xn=(t,e)=>{const n=null!=t;return[o=>e[0]({lengthComputable:n,total:t,loaded:o}),e[1]]},Qn=t=>(...e)=>mn.asap(()=>t(...e));var Zn=In.hasStandardBrowserEnv?((t,e)=>n=>(n=new URL(n,In.origin),t.protocol===n.protocol&&t.host===n.host&&(e||t.port===n.port)))(new URL(In.origin),In.navigator&&/(msie|trident)/i.test(In.navigator.userAgent)):()=>!0,to=In.hasStandardBrowserEnv?{write(t,e,n,o,i,s){const r=[t+"="+encodeURIComponent(e)];mn.isNumber(n)&&r.push("expires="+new Date(n).toGMTString()),mn.isString(o)&&r.push("path="+o),mn.isString(i)&&r.push("domain="+i),!0===s&&r.push("secure"),document.cookie=r.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function eo(t,e,n){let o=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e);return t&&(o||0==n)?function(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}(t,e):e}const no=t=>t instanceof Kn?{...t}:t;function oo(t,e){e=e||{};const n={};function o(t,e,n,o){return mn.isPlainObject(t)&&mn.isPlainObject(e)?mn.merge.call({caseless:o},t,e):mn.isPlainObject(e)?mn.merge({},e):mn.isArray(e)?e.slice():e}function i(t,e,n,i){return mn.isUndefined(e)?mn.isUndefined(t)?void 0:o(void 0,t,0,i):o(t,e,0,i)}function s(t,e){if(!mn.isUndefined(e))return o(void 0,e)}function r(t,e){return mn.isUndefined(e)?mn.isUndefined(t)?void 0:o(void 0,t):o(void 0,e)}function a(n,i,s){return s in e?o(n,i):s in t?o(void 0,n):void 0}const c={url:s,method:s,data:s,baseURL:r,transformRequest:r,transformResponse:r,paramsSerializer:r,timeout:r,timeoutMessage:r,withCredentials:r,withXSRFToken:r,adapter:r,responseType:r,xsrfCookieName:r,xsrfHeaderName:r,onUploadProgress:r,onDownloadProgress:r,decompress:r,maxContentLength:r,maxBodyLength:r,beforeRedirect:r,transport:r,httpAgent:r,httpsAgent:r,cancelToken:r,socketPath:r,responseEncoding:r,validateStatus:a,headers:(t,e,n)=>i(no(t),no(e),0,!0)};return mn.forEach(Object.keys({...t,...e}),function(o){const s=c[o]||i,r=s(t[o],e[o],o);mn.isUndefined(r)&&s!==a||(n[o]=r)}),n}var io=t=>{const e=oo({},t);let{data:n,withXSRFToken:o,xsrfHeaderName:i,xsrfCookieName:s,headers:r,auth:a}=e;if(e.headers=r=Kn.from(r),e.url=On(eo(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),a&&r.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),mn.isFormData(n))if(In.hasStandardBrowserEnv||In.hasStandardBrowserWebWorkerEnv)r.setContentType(void 0);else if(mn.isFunction(n.getHeaders)){const t=n.getHeaders(),e=["content-type","content-length"];Object.entries(t).forEach(([t,n])=>{e.includes(t.toLowerCase())&&r.set(t,n)})}if(In.hasStandardBrowserEnv&&(o&&mn.isFunction(o)&&(o=o(e)),o||!1!==o&&Zn(e.url))){const t=i&&s&&to.read(s);t&&r.set(i,t)}return e};var so="undefined"!=typeof XMLHttpRequest&&function(t){return new Promise(function(e,n){const o=io(t);let i=o.data;const s=Kn.from(o.headers).normalize();let r,a,c,u,l,{responseType:d,onUploadProgress:h,onDownloadProgress:p}=o;function f(){u&&u(),l&&l(),o.cancelToken&&o.cancelToken.unsubscribe(r),o.signal&&o.signal.removeEventListener("abort",r)}let m=new XMLHttpRequest;function g(){if(!m)return;const o=Kn.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());Jn(function(t){e(t),f()},function(t){n(t),f()},{data:d&&"text"!==d&&"json"!==d?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:o,config:t,request:m}),m=null}m.open(o.method.toUpperCase(),o.url,!0),m.timeout=o.timeout,"onloadend"in m?m.onloadend=g:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(g)},m.onabort=function(){m&&(n(new gn("Request aborted",gn.ECONNABORTED,t,m)),m=null)},m.onerror=function(e){const o=new gn(e&&e.message?e.message:"Network Error",gn.ERR_NETWORK,t,m);o.event=e||null,n(o),m=null},m.ontimeout=function(){let e=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const i=o.transitional||Ln;o.timeoutErrorMessage&&(e=o.timeoutErrorMessage),n(new gn(e,i.clarifyTimeoutError?gn.ETIMEDOUT:gn.ECONNABORTED,t,m)),m=null},void 0===i&&s.setContentType(null),"setRequestHeader"in m&&mn.forEach(s.toJSON(),function(t,e){m.setRequestHeader(e,t)}),mn.isUndefined(o.withCredentials)||(m.withCredentials=!!o.withCredentials),d&&"json"!==d&&(m.responseType=o.responseType),p&&([c,l]=Yn(p,!0),m.addEventListener("progress",c)),h&&m.upload&&([a,u]=Yn(h),m.upload.addEventListener("progress",a),m.upload.addEventListener("loadend",u)),(o.cancelToken||o.signal)&&(r=e=>{m&&(n(!e||e.type?new Vn(null,t,m):e),m.abort(),m=null)},o.cancelToken&&o.cancelToken.subscribe(r),o.signal&&(o.signal.aborted?r():o.signal.addEventListener("abort",r)));const y=function(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}(o.url);y&&-1===In.protocols.indexOf(y)?n(new gn("Unsupported protocol "+y+":",gn.ERR_BAD_REQUEST,t)):m.send(i||null)})};const ro=(t,e)=>{const{length:n}=t=t?t.filter(Boolean):[];if(e||n){let n,o=new AbortController;const i=function(t){if(!n){n=!0,r();const e=t instanceof Error?t:this.reason;o.abort(e instanceof gn?e:new Vn(e instanceof Error?e.message:e))}};let s=e&&setTimeout(()=>{s=null,i(new gn(`timeout ${e} of ms exceeded`,gn.ETIMEDOUT))},e);const r=()=>{t&&(s&&clearTimeout(s),s=null,t.forEach(t=>{t.unsubscribe?t.unsubscribe(i):t.removeEventListener("abort",i)}),t=null)};t.forEach(t=>t.addEventListener("abort",i));const{signal:a}=o;return a.unsubscribe=()=>mn.asap(r),a}},ao=function*(t,e){let n=t.byteLength;if(n{const i=async function*(t,e){for await(const n of co(t))yield*ao(n,e)}(t,e);let s,r=0,a=t=>{s||(s=!0,o&&o(t))};return new ReadableStream({async pull(t){try{const{done:e,value:o}=await i.next();if(e)return a(),void t.close();let s=o.byteLength;if(n){let t=r+=s;n(t)}t.enqueue(new Uint8Array(o))}catch(t){throw a(t),t}},cancel:t=>(a(t),i.return())},{highWaterMark:2})},{isFunction:lo}=mn,ho=(({Request:t,Response:e})=>({Request:t,Response:e}))(mn.global),{ReadableStream:po,TextEncoder:fo}=mn.global,mo=(t,...e)=>{try{return!!t(...e)}catch(t){return!1}},go=t=>{t=mn.merge.call({skipUndefined:!0},ho,t);const{fetch:e,Request:n,Response:o}=t,i=e?lo(e):"function"==typeof fetch,s=lo(n),r=lo(o);if(!i)return!1;const a=i&&lo(po),c=i&&("function"==typeof fo?(u=new fo,t=>u.encode(t)):async t=>new Uint8Array(await new n(t).arrayBuffer()));var u;const l=s&&a&&mo(()=>{let t=!1;const e=new n(In.origin,{body:new po,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e}),d=r&&a&&mo(()=>mn.isReadableStream(new o("").body)),h={stream:d&&(t=>t.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!h[t]&&(h[t]=(e,n)=>{let o=e&&e[t];if(o)return o.call(e);throw new gn(`Response type '${t}' is not supported`,gn.ERR_NOT_SUPPORT,n)})});const p=async(t,e)=>{const o=mn.toFiniteNumber(t.getContentLength());return null==o?(async t=>{if(null==t)return 0;if(mn.isBlob(t))return t.size;if(mn.isSpecCompliantForm(t)){const e=new n(In.origin,{method:"POST",body:t});return(await e.arrayBuffer()).byteLength}return mn.isArrayBufferView(t)||mn.isArrayBuffer(t)?t.byteLength:(mn.isURLSearchParams(t)&&(t+=""),mn.isString(t)?(await c(t)).byteLength:void 0)})(e):o};return async t=>{let{url:i,method:r,data:a,signal:c,cancelToken:u,timeout:f,onDownloadProgress:m,onUploadProgress:g,responseType:y,headers:v,withCredentials:b="same-origin",fetchOptions:E}=io(t),w=e||fetch;y=y?(y+"").toLowerCase():"text";let C=ro([c,u&&u.toAbortSignal()],f),S=null;const x=C&&C.unsubscribe&&(()=>{C.unsubscribe()});let A;try{if(g&&l&&"get"!==r&&"head"!==r&&0!==(A=await p(v,a))){let t,e=new n(i,{method:"POST",body:a,duplex:"half"});if(mn.isFormData(a)&&(t=e.headers.get("content-type"))&&v.setContentType(t),e.body){const[t,n]=Xn(A,Yn(Qn(g)));a=uo(e.body,65536,t,n)}}mn.isString(b)||(b=b?"include":"omit");const e=s&&"credentials"in n.prototype,c={...E,signal:C,method:r.toUpperCase(),headers:v.normalize().toJSON(),body:a,duplex:"half",credentials:e?b:void 0};S=s&&new n(i,c);let u=await(s?w(S,E):w(i,c));const f=d&&("stream"===y||"response"===y);if(d&&(m||f&&x)){const t={};["status","statusText","headers"].forEach(e=>{t[e]=u[e]});const e=mn.toFiniteNumber(u.headers.get("content-length")),[n,i]=m&&Xn(e,Yn(Qn(m),!0))||[];u=new o(uo(u.body,65536,n,()=>{i&&i(),x&&x()}),t)}y=y||"text";let T=await h[mn.findKey(h,y)||"text"](u,t);return!f&&x&&x(),await new Promise((e,n)=>{Jn(e,n,{data:T,headers:Kn.from(u.headers),status:u.status,statusText:u.statusText,config:t,request:S})})}catch(e){if(x&&x(),e&&"TypeError"===e.name&&/Load failed|fetch/i.test(e.message))throw Object.assign(new gn("Network Error",gn.ERR_NETWORK,t,S),{cause:e.cause||e});throw gn.from(e,e&&e.code,t,S)}}},yo=new Map,vo=t=>{let e=t?t.env:{};const{fetch:n,Request:o,Response:i}=e,s=[o,i,n];let r,a,c=s.length,u=yo;for(;c--;)r=s[c],a=u.get(r),void 0===a&&u.set(r,a=c?new Map:go(e)),u=a;return a};vo();const bo={http:null,xhr:so,fetch:{get:vo}};mn.forEach(bo,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch(t){}Object.defineProperty(t,"adapterName",{value:e})}});const Eo=t=>`- ${t}`,wo=t=>mn.isFunction(t)||null===t||!1===t;var Co=(t,e)=>{t=mn.isArray(t)?t:[t];const{length:n}=t;let o,i;const s={};for(let r=0;r`adapter ${t} `+(!1===e?"is not supported by the environment":"is not available in the build"));throw new gn("There is no suitable adapter to dispatch the request "+(n?t.length>1?"since :\n"+t.map(Eo).join("\n"):" "+Eo(t[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return i};function So(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Vn(null,t)}function xo(t){So(t),t.headers=Kn.from(t.headers),t.data=Gn.call(t,t.transformRequest),-1!==["post","put","patch"].indexOf(t.method)&&t.headers.setContentType("application/x-www-form-urlencoded",!1);return Co(t.adapter||Bn.adapter,t)(t).then(function(e){return So(t),e.data=Gn.call(t,t.transformResponse,e),e.headers=Kn.from(e.headers),e},function(e){return Wn(e)||(So(t),e&&e.response&&(e.response.data=Gn.call(t,t.transformResponse,e.response),e.response.headers=Kn.from(e.response.headers))),Promise.reject(e)})}const Ao="1.12.2",To={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{To[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});const _o={};To.transitional=function(t,e,n){function o(t,e){return"[Axios v"+Ao+"] Transitional option '"+t+"'"+e+(n?". "+n:"")}return(n,i,s)=>{if(!1===t)throw new gn(o(i," has been removed"+(e?" in "+e:"")),gn.ERR_DEPRECATED);return e&&!_o[i]&&(_o[i]=!0,console.warn(o(i," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(n,i,s)}},To.spelling=function(t){return(e,n)=>(console.warn(`${n} is likely a misspelling of ${t}`),!0)};var Oo={assertOptions:function(t,e,n){if("object"!=typeof t)throw new gn("options must be an object",gn.ERR_BAD_OPTION_VALUE);const o=Object.keys(t);let i=o.length;for(;i-- >0;){const s=o[i],r=e[s];if(r){const e=t[s],n=void 0===e||r(e,s,t);if(!0!==n)throw new gn("option "+s+" must be "+n,gn.ERR_BAD_OPTION_VALUE);continue}if(!0!==n)throw new gn("Unknown option "+s,gn.ERR_BAD_OPTION)}},validators:To};const Ro=Oo.validators;let Lo=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Rn,response:new Rn}}async request(t,e){try{return await this._request(t,e)}catch(t){if(t instanceof Error){let e={};Error.captureStackTrace?Error.captureStackTrace(e):e=new Error;const n=e.stack?e.stack.replace(/^.+\n/,""):"";try{t.stack?n&&!String(t.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(t.stack+="\n"+n):t.stack=n}catch(t){}}throw t}}_request(t,e){"string"==typeof t?(e=e||{}).url=t:e=t||{},e=oo(this.defaults,e);const{transitional:n,paramsSerializer:o,headers:i}=e;void 0!==n&&Oo.assertOptions(n,{silentJSONParsing:Ro.transitional(Ro.boolean),forcedJSONParsing:Ro.transitional(Ro.boolean),clarifyTimeoutError:Ro.transitional(Ro.boolean)},!1),null!=o&&(mn.isFunction(o)?e.paramsSerializer={serialize:o}:Oo.assertOptions(o,{encode:Ro.function,serialize:Ro.function},!0)),void 0!==e.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?e.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:e.allowAbsoluteUrls=!0),Oo.assertOptions(e,{baseUrl:Ro.spelling("baseURL"),withXsrfToken:Ro.spelling("withXSRFToken")},!0),e.method=(e.method||this.defaults.method||"get").toLowerCase();let s=i&&mn.merge(i.common,i[e.method]);i&&mn.forEach(["delete","get","head","post","put","patch","common"],t=>{delete i[t]}),e.headers=Kn.concat(s,i);const r=[];let a=!0;this.interceptors.request.forEach(function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(a=a&&t.synchronous,r.unshift(t.fulfilled,t.rejected))});const c=[];let u;this.interceptors.response.forEach(function(t){c.push(t.fulfilled,t.rejected)});let l,d=0;if(!a){const t=[xo.bind(this),void 0];for(t.unshift(...r),t.push(...c),l=t.length,u=Promise.resolve(e);d{ko[e]=t});const No=function t(e){const n=new Lo(e),o=xe(Lo.prototype.request,n);return mn.extend(o,Lo.prototype,n,{allOwnKeys:!0}),mn.extend(o,n,null,{allOwnKeys:!0}),o.create=function(n){return t(oo(e,n))},o}(Bn);No.Axios=Lo,No.CanceledError=Vn,No.CancelToken=class t{constructor(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");let e;this.promise=new Promise(function(t){e=t});const n=this;this.promise.then(t=>{if(!n._listeners)return;let e=n._listeners.length;for(;e-- >0;)n._listeners[e](t);n._listeners=null}),this.promise.then=t=>{let e;const o=new Promise(t=>{n.subscribe(t),e=t}).then(t);return o.cancel=function(){n.unsubscribe(e)},o},t(function(t,o,i){n.reason||(n.reason=new Vn(t,o,i),e(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){this.reason?t(this.reason):this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);-1!==e&&this._listeners.splice(e,1)}toAbortSignal(){const t=new AbortController,e=e=>{t.abort(e)};return this.subscribe(e),t.signal.unsubscribe=()=>this.unsubscribe(e),t.signal}static source(){let e;const n=new t(function(t){e=t});return{token:n,cancel:e}}},No.isCancel=Wn,No.VERSION=Ao,No.toFormData=Sn,No.AxiosError=gn,No.Cancel=No.CanceledError,No.all=function(t){return Promise.all(t)},No.spread=function(t){return function(e){return t.apply(null,e)}},No.isAxiosError=function(t){return mn.isObject(t)&&!0===t.isAxiosError},No.mergeConfig=oo,No.AxiosHeaders=Kn,No.formToJSON=t=>Dn(mn.isHTMLForm(t)?new FormData(t):t),No.getAdapter=Co,No.HttpStatusCode=ko,No.default=No;const{Axios:Fo,AxiosError:Uo,CanceledError:Po,isCancel:jo,CancelToken:Io,VERSION:Do,all:Bo,Cancel:qo,isAxiosError:Mo,spread:Ho,toFormData:$o,AxiosHeaders:zo,HttpStatusCode:Ko,formToJSON:Go,getAdapter:Wo,mergeConfig:Vo}=No,{IdealPostcodesError:Jo}=ve,Yo=(t,e)=>{return{httpRequest:t,body:e.data,httpStatus:e.status||0,header:(n=e.headers,Object.keys(n).reduce((t,e)=>{const o=n[e];return"string"==typeof o?t[e]=o:Array.isArray(o)&&(t[e]=o.join(",")),t},{})),metadata:{response:e}};var n},Xo=t=>{const e=new Jo({message:`[${t.name}] ${t.message}`,httpStatus:0,metadata:{axios:t}});return Promise.reject(e)},Qo=()=>!0;class Zo{constructor(){this.Axios=No.create({validateStatus:Qo})}requestWithBody(t){const{body:e,method:n,timeout:o,url:i,header:s,query:r}=t;return this.Axios.request({url:i,method:n,headers:s,params:r,data:e,timeout:o}).then(e=>Yo(t,e)).catch(Xo)}request(t){const{method:e,timeout:n,url:o,header:i,query:s}=t;return this.Axios.request({url:o,method:e,headers:i,params:s,timeout:n}).then(e=>Yo(t,e)).catch(Xo)}http(t){return void 0!==t.body?this.requestWithBody(t):this.request(t)}}class ti extends Kt{constructor(t){super({agent:new Zo,...t})}}class ei{constructor(t){this.prefix="!",this.client=t,this.cache={}}key(t){return`${this.prefix}${t.toLowerCase()}`}retrieve(t){return this.cache[this.key(t)]}store(t,e){return this.cache[this.key(t)]=e,e}clear(){this.cache={}}query(t,e={}){const n=this.retrieve(t);if(n)return Promise.resolve(n);const o=(i=this.client,s={query:{query:t,api_key:this.client.config.api_key,...e}},we({resource:Se,client:i})(s)).then(e=>{const n=e.body.result.hits;return this.store(t,n),n});var i,s;return this.store(t,o),o}resolve(t,e,n={}){return"usa"===e?this.usaResolve(t,n):this.gbrResolve(t,n)}usaResolve(t,e={}){return(n=this.client,o=t.id,i={query:{api_key:this.client.config.api_key,...e}},Ee({resource:Se,client:n,action:"usa"})(o,i)).then(t=>t.body.result);var n,o,i}gbrResolve(t,e={}){return(n=this.client,o=t.id,i={query:{api_key:this.client.config.api_key,...e}},Ee({resource:Se,client:n,action:"gbr"})(o,i)).then(t=>t.body.result);var n,o,i}}function ni(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var o,i,s=n.call(t),r=[];try{for(;(void 0===e||e-- >0)&&!(o=s.next()).done;)r.push(o.value)}catch(t){i={error:t}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return r}var oi;!function(t){t[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped"}(oi||(oi={}));var ii={type:"xstate.init"};function si(t){return void 0===t?[]:[].concat(t)}function ri(t,e){return"string"==typeof(t="string"==typeof t&&e&&e[t]?e[t]:t)?{type:t}:"function"==typeof t?{type:t.name,exec:t}:t}function ai(t){return function(e){return t===e}}function ci(t){return"string"==typeof t?{type:t}:t}function ui(t,e){return{value:t,context:e,actions:[],changed:!1,matches:ai(t)}}function li(t,e,n){var o=e,i=!1;return[t.filter(function(t){if("xstate.assign"===t.type){i=!0;var e=Object.assign({},o);return"function"==typeof t.assignment?e=t.assignment(o,n):Object.keys(t.assignment).forEach(function(i){e[i]="function"==typeof t.assignment[i]?t.assignment[i](o,n):t.assignment[i]}),o=e,!1}return!0}),o,i]}function di(t,e){void 0===e&&(e={});var n=ni(li(si(t.states[t.initial].entry).map(function(t){return ri(t,e.actions)}),t.context,ii),2),o=n[0],i=n[1],s={config:t,_options:e,initialState:{value:t.initial,actions:o,context:i,matches:ai(t.initial)},transition:function(e,n){var o,i,r="string"==typeof e?{value:e,context:t.context}:e,a=r.value,c=r.context,u=ci(n),l=t.states[a];if(l.on){var d=si(l.on[u.type]);"*"in l.on&&d.push.apply(d,function(t,e,n){if(2===arguments.length)for(var o,i=0,s=e.length;i=t.length&&(t=void 0),{value:t&&t[o++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(d),p=h.next();!p.done;p=h.next()){var f=p.value;if(void 0===f)return ui(a,c);var m="string"==typeof f?{target:f}:f,g=m.target,y=m.actions,v=void 0===y?[]:y,b=m.cond,E=void 0===b?function(){return!0}:b,w=void 0===g,C=null!=g?g:a,S=t.states[C];if(E(c,u)){var x=ni(li((w?si(v):[].concat(l.exit,v,S.entry).filter(function(t){return t})).map(function(t){return ri(t,s._options.actions)}),c,u),3),A=x[0],T=x[1],_=x[2],O=null!=g?g:a;return{value:O,context:T,actions:A,changed:g!==a||A.length>0||_,matches:ai(O)}}}}catch(t){o={error:t}}finally{try{p&&!p.done&&(i=h.return)&&i.call(h)}finally{if(o)throw o.error}}}return ui(a,c)}};return s}var hi=function(t,e){return t.actions.forEach(function(n){var o=n.exec;return o&&o(t.context,e)})};const pi=({c:t})=>{const e=di({initial:"closed",states:{closed:{entry:["close"],exit:["open"],on:{COUNTRY_CHANGE_EVENT:{actions:["updateContextWithCountry"]},AWAKE:[{target:"suggesting",cond:()=>t.suggestions.length>0},{target:"notifying"}]}},notifying:{entry:["renderNotice"],exit:["clearAnnouncement"],on:{CLOSE:"closed",SUGGEST:{target:"suggesting",actions:["updateSuggestions"]},NOTIFY:{target:"notifying",actions:["updateMessage"]},INPUT:{actions:"input"},CHANGE_COUNTRY:{target:"suggesting_country"}}},suggesting_country:{entry:["clearInput","renderContexts","gotoCurrent","expand","addCountryHint"],exit:["resetCurrent","gotoCurrent","contract","clearHint","clearInput"],on:{CLOSE:"closed",NOTIFY:{target:"notifying",actions:["updateMessage"]},NEXT:{actions:["next","gotoCurrent"]},PREVIOUS:{actions:["previous","gotoCurrent"]},RESET:{actions:["resetCurrent","gotoCurrent"]},INPUT:{actions:["countryInput"]},SELECT_COUNTRY:{target:"notifying",actions:["selectCountry"]}}},suggesting:{entry:["renderSuggestions","gotoCurrent","expand","addHint"],exit:["resetCurrent","gotoCurrent","contract","clearHint"],on:{CLOSE:"closed",SUGGEST:{target:"suggesting",actions:["updateSuggestions"]},NOTIFY:{target:"notifying",actions:["updateMessage"]},INPUT:{actions:"input"},CHANGE_COUNTRY:{target:"suggesting_country"},NEXT:{actions:["next","gotoCurrent"]},PREVIOUS:{actions:["previous","gotoCurrent"]},RESET:{actions:["resetCurrent","gotoCurrent"]},SELECT_ADDRESS:{target:"closed",actions:["selectAddress"]}}}}},{actions:{updateContextWithCountry:(e,n)=>{"COUNTRY_CHANGE_EVENT"===n.type&&n.contextDetails&&(t.applyContext(n.contextDetails),t.suggestions=[],t.cache.clear())},addHint:()=>{t.setPlaceholder(t.options.msgPlaceholder)},addCountryHint:()=>{t.setPlaceholder(t.options.msgPlaceholderCountry)},clearHint:()=>{t.unsetPlaceholder()},clearInput:()=>{t.clearInput()},gotoCurrent:()=>{t.goToCurrent()},resetCurrent:()=>{t.current=-1},input:(e,n)=>{"INPUT"===n.type&&t.retrieveSuggestions(n.event)},countryInput:()=>{t.renderContexts()},clearAnnouncement:()=>{t.announce("")},renderContexts:(e,n)=>{"CHANGE_COUNTRY"===n.type&&t.renderContexts()},renderSuggestions:(e,n)=>{"SUGGEST"===n.type&&t.renderSuggestions()},updateSuggestions:(e,n)=>{"SUGGEST"===n.type&&t.updateSuggestions(n.suggestions)},close:(e,n)=>{if("CLOSE"===n.type)return t.close(n.reason);t.close()},open:()=>{t.open()},expand:()=>{t.ariaExpand()},contract:()=>{t.ariaContract()},updateMessage:(e,n)=>{"NOTIFY"===n.type&&(t.notification=n.notification)},renderNotice:()=>{t.renderNotice()},next:()=>{t.next()},previous:()=>{t.previous()},selectCountry:(e,n)=>{if("SELECT_COUNTRY"!==n.type)return;const o=n.contextDetails;o&&(t.applyContext(o),t.notification=`Country switched to ${o.description} ${o.emoji}`)},selectAddress:(e,n)=>{if("SELECT_ADDRESS"!==n.type)return;const o=n.suggestion;o&&t.applySuggestion(o)}}});return function(t){var e=t.initialState,n=oi.NotStarted,o=new Set,i={_machine:t,send:function(i){n===oi.Running&&(e=t.transition(e,i),hi(e,ci(i)),o.forEach(function(t){return t(e)}))},subscribe:function(t){return o.add(t),t(e),{unsubscribe:function(){return o.delete(t)}}},start:function(o){if(o){var s="object"==typeof o?o:{context:t.config.context,value:o};e={value:s.value,actions:[],context:s.context,matches:ai(s.value)}}else e=t.initialState;return n=oi.Running,hi(e,ii),i},stop:function(){return n=oi.Stopped,o.clear(),i},get state(){return e},get status(){return n}};return i}(e)},fi=()=>{},mi={outputScope:null,apiKey:"",checkKey:!0,aria:"1.0",titleizePostTown:!0,format:"gbr",outputFields:{},names:{},labels:{},removeOrganisation:!1,injectStyle:!0,inputField:"",autocomplete:"none",populateCounty:!0,populateOrganisation:!0,queryOptions:{},resolveOptions:{},alignToInput:!0,offset:2,hideToolbar:!1,detectCountry:!0,defaultCountry:"GBR",restrictCountries:[],contexts:{GBR:{iso_2:"GB",iso_3:"GBR",emoji:"πŸ‡¬πŸ‡§",rgeo:!0,description:"United Kingdom"},USA:{iso_2:"US",iso_3:"USA",emoji:"πŸ‡ΊπŸ‡Έ",rgeo:!1,description:"United States"}},msgFallback:"Please enter your address manually",msgInitial:"Start typing to find address",msgNoMatch:"No matches found",msgList:"Select your address",msgCountryToggle:"Change Country",msgPlaceholder:"Type the first line or postal code of your address",msgPlaceholderCountry:"Select your country",messageClass:"idpc_error",containerClass:"idpc_autocomplete",mainClass:"idpc_af",listClass:"idpc_ul",toolbarClass:"idpc_toolbar",countryToggleClass:"idpc_country",mainStyle:{},inputStyle:{},listStyle:{},liStyle:{},containerStyle:{},unhide:null,unhideClass:"idpc-unhide",msgUnhide:"Enter address manually",hide:[],fixed:!1,onOpen:fi,onSelect:fi,onBlur:fi,onClose:fi,onFocus:fi,onInput:fi,onLoaded:fi,onSearchError:fi,onSuggestionError:fi,onMounted:fi,onRemove:fi,onSuggestionsRetrieved:fi,onAddressSelected:fi,onAddressRetrieved:fi,onAddressPopulated:fi,onFailedCheck:fi,onMouseDown:fi,onKeyDown:fi,onUnhide:fi,onCountrySelected:fi,onContextChange:fi};let gi=class{constructor(e){let n;if(this.options={scope:window.document,document:window.document,...mi,...e},e.inputField||(this.options.inputField=this.options.outputFields.line_1||""),!0===this.options.autocomplete&&(this.options.autocomplete=mi.autocomplete),this.scope=l(this.options.scope),this.document=d(this.scope),this.outputScope=Si(this.scope,this.options.outputScope,()=>this.scope),this.context=this.options.defaultCountry,this.notification=this.options.msgInitial,this.current=-1,this.suggestions=[],this.contextSuggestions=[],this.updateContexts(this.options.contexts),this.client=new ti({...this.options,api_key:this.options.apiKey}),this.cache=new ei(this.client),this.retrieveSuggestions=Mt(t=>{this.options.onInput.call(this,t);const e=this.query();return 0===e.trim().length?(this.setMessage(this.options.msgInitial),Promise.resolve(this)):this.cache.query(e,{...this.options.queryOptions,context:this.context}).then(t=>(this.options.onSuggestionsRetrieved.call(this,t),this.setSuggestions(t,e))).catch(t=>(this.query()===e&&this.setMessage(this.options.msgFallback),this.options.onSuggestionError.call(this,t),this))},100,{leading:!0,trailing:!0,maxWait:100}),this.ids=((t="idpc_")=>()=>{const e=P();return e.idGen||(e.idGen={}),void 0===e.idGen[t]&&(e.idGen[t]=0),e.idGen[t]+=1,`${t}${e.idGen[t]}`})("idpcaf"),this.container=this.options.document.createElement("div"),this.container.className=this.options.containerClass,this.container.id=this.ids(),this.container.setAttribute("aria-haspopup","listbox"),this.message=this.options.document.createElement("li"),this.message.textContent=this.options.msgInitial,this.message.className=this.options.messageClass,this.countryToggle=this.options.document.createElement("span"),this.countryToggle.className=this.options.countryToggleClass,this.countryToggle.addEventListener("mousedown",Ei(this)),this.countryIcon=this.options.document.createElement("span"),this.countryIcon.className="idpc_icon",this.countryIcon.innerText=this.currentContext().emoji,this.countryMessage=this.options.document.createElement("span"),this.countryMessage.innerText="Select Country",this.countryMessage.className="idpc_country",this.countryToggle.appendChild(this.countryMessage),this.countryToggle.appendChild(this.countryIcon),this.toolbar=this.options.document.createElement("div"),this.toolbar.className=this.options.toolbarClass,this.toolbar.appendChild(this.countryToggle),this.options.hideToolbar&&f(this.toolbar),this.list=this.options.document.createElement("ul"),this.list.className=this.options.listClass,this.list.id=this.ids(),this.list.setAttribute("aria-label",this.options.msgList),this.list.setAttribute("role","listbox"),this.mainComponent=this.options.document.createElement("div"),this.mainComponent.appendChild(this.list),this.mainComponent.appendChild(this.toolbar),this.mainComponent.className=this.options.mainClass,f(this.mainComponent),this.unhideEvent=this.unhideFields.bind(this),this.unhide=this.createUnhide(),n=t(this.options.inputField)?this.scope.querySelector(this.options.inputField):this.options.inputField,!n)throw new Error("Address Finder: Unable to find valid input field");this.input=n,this.input.setAttribute("autocomplete",this.options.autocomplete),this.input.setAttribute("aria-autocomplete","list"),this.input.setAttribute("aria-controls",this.list.id),this.input.setAttribute("aria-autocomplete","list"),this.input.setAttribute("aria-activedescendant",""),this.input.setAttribute("autocorrect","off"),this.input.setAttribute("autocapitalize","off"),this.input.setAttribute("spellcheck","false"),this.input.id||(this.input.id=this.ids());const o=this.scope.querySelector(this.options.outputFields.country);this.countryInput=o,this.ariaAnchor().setAttribute("role","combobox"),this.ariaAnchor().setAttribute("aria-expanded","false"),this.ariaAnchor().setAttribute("aria-owns",this.list.id),this.placeholderCache=this.input.placeholder,this.inputListener=bi(this),this.blurListener=yi(this),this.focusListener=vi(this),this.keydownListener=wi(this),this.countryListener=Ci(this);const{container:i,announce:s}=(({document:t,idA:e,idB:n})=>{const o=t.createElement("div");(t=>{t.style.border="0px",t.style.padding="0px",t.style.clipPath="rect(0px,0px,0px,0px)",t.style.height="1px",t.style.marginBottom="-1px",t.style.marginRight="-1px",t.style.overflow="hidden",t.style.position="absolute",t.style.whiteSpace="nowrap",t.style.width="1px"})(o);const i=Ht(t.createElement("div"),e),s=Ht(t.createElement("div"),n);o.appendChild(i),o.appendChild(s);let r=!0;const a=Mt(t=>{const e=r?i:s,n=r?s:i;r=!r,e.textContent=t,n.textContent=""},1500,{});return{container:o,announce:a}})({idA:this.ids(),idB:this.ids(),document:this.options.document});this.announce=s,this.alerts=i,this.inputStyle=h(this.input,this.options.inputStyle),h(this.container,this.options.containerStyle),h(this.list,this.options.listStyle);const r=(t=>{let e;const n=t.input;if(!1===t.options.alignToInput)return{};try{const o=t.options.document.defaultView;if(!o)return{};e=o.getComputedStyle(n).marginBottom}catch(t){return{}}if(!e)return{};const o=parseInt(e.replace("px",""),10);return isNaN(o)||0===o?{}:{marginTop:-1*o+t.options.offset+"px"}})(this);h(this.mainComponent,{...r,...this.options.mainStyle}),this.fsm=pi({c:this}),this.init()}setPlaceholder(t){this.input.placeholder=t}unsetPlaceholder(){if(void 0===this.placeholderCache)return this.input.removeAttribute("placeholder");this.input.placeholder=this.placeholderCache}currentContext(){const t=this.options.contexts[this.context];if(t)return t;const e=Object.keys(this.options.contexts)[0];return this.options.contexts[e]}load(){this.attach(),(e=>{const n=e.options.injectStyle;if(!n)return;const o=P();if(o.afstyle||(o.afstyle={}),t(n)&&!o.afstyle[n]){o.afstyle[n]=!0;const t=((t,e)=>{const n=e.createElement("link");return n.type="text/css",n.rel="stylesheet",n.href=t,n})(n,e.document);return e.document.head.appendChild(t),t}!0!==n||o.afstyle[""]||(o.afstyle[""]=!0,((t,e)=>{const n=e.createElement("style");n.appendChild(e.createTextNode(t)),e.head.appendChild(n)})(".idpc_af.hidden{display:none}div.idpc_autocomplete{position:relative;margin:0!important;padding:0;border:0;color:#28282b;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}div.idpc_autocomplete>input{display:block}div.idpc_af{position:absolute;left:0;z-index:2000;min-width:100%;box-sizing:border-box;border-radius:3px;background:#fff;border:1px solid rgba(0,0,0,.3);box-shadow:.05em .2em .6em rgba(0,0,0,.2);text-shadow:none;padding:0;margin-top:2px}div.idpc_af>ul{list-style:none;padding:0;max-height:250px;overflow-y:scroll;margin:0!important}div.idpc_af>ul>li{position:relative;padding:.2em .5em;cursor:pointer;margin:0!important}div.idpc_toolbar{padding:.3em .5em;border-top:1px solid rgba(0,0,0,.3);text-align:right}div.idpc_af>ul>li:hover{background-color:#e5e4e2}div.idpc_af>ul>li.idpc_error{padding:.5em;text-align:center;cursor:default!important}div.idpc_af>ul>li.idpc_error:hover{background:#fff;cursor:default!important}div.idpc_af>ul>li[aria-selected=true]{background-color:#e5e4e2;z-index:3000}div.idpc_autocomplete>.idpc-unhide{font-size:.9em;text-decoration:underline;cursor:pointer}div.idpc_af>div>span{padding:.2em .5em;border-radius:3px;cursor:pointer;font-size:110%}span.idpc_icon{font-size:1.2em;line-height:1em;vertical-align:middle}div.idpc_toolbar>span span.idpc_country{margin-right:.3em;max-width:0;font-size:.9em;-webkit-transition:max-width .5s ease-out;transition:max-width .5s ease-out;display:inline-block;vertical-align:middle;white-space:nowrap;overflow:hidden}div.idpc_autocomplete>div>div>span:hover span.idpc_country{max-width:7em}div.idpc_autocomplete>div>div>span:hover{background-color:#e5e4e2;-webkit-transition:background-color .5s ease;-ms-transition:background-color .5s ease;transition:background-color .5s ease}",e.document))})(this),this.options.fixed&&xi(this.mainComponent,this.container,this.document),this.options.onLoaded.call(this),this.list.parentNode?.addEventListener("mousedown",t=>t.preventDefault())}init(){return new Promise(t=>{if(!this.options.checkKey)return this.load(),void t();Ce({client:this.client,api_key:this.options.apiKey}).then(e=>{if(!e.available)throw new Error("Key currently not usable");this.updateContexts($t(e.contexts));const n=this.options.contexts[e.context];this.options.detectCountry&&n?this.applyContext(n,!1):this.applyContext(this.currentContext(),!1),this.load(),t()}).catch(e=>{this.options.onFailedCheck.call(this,e),t()})})}updateContexts(t){this.contextSuggestions=((t,e)=>{const n=[],o=Object.keys(t);for(const i of o)e.length>0&&!e.some(t=>t===i)||n.push(t[i]);return n.sort((t,e)=>t.description.localeCompare(e.description)),n})(t,this.options.restrictCountries),this.options.contexts=t}filteredContexts(){const t=this.query();if(0===t.trim().length)return this.contextSuggestions;const e=t.toLowerCase().trim().replace(/\s+/g," "),n=new RegExp("^"+e);return this.contextSuggestions.filter(t=>!!n.test(t.description.toLowerCase())||(t.iso_2.toLowerCase()===e||t.iso_3.toLowerCase()===e))}renderContexts(){this.list.innerHTML="",this.filteredContexts().forEach((t,e)=>{const{description:n}=t,o=this.options.document.createElement("li");o.textContent=n,o.setAttribute("aria-selected","false"),o.setAttribute("tabindex","-1"),o.setAttribute("aria-posinset",`${e+1}`),o.setAttribute("aria-setsize",this.contextSuggestions.length.toString()),o.setAttribute("role","option"),h(o,this.options.liStyle),o.addEventListener("mousedown",e=>{e.preventDefault(),this.options.onMouseDown.call(this,e),this.fsm.send({type:"SELECT_COUNTRY",contextDetails:t})}),o.id=`${this.list.id}_${e}`,this.list.appendChild(o)}),this.announce(`${this.contextSuggestions.length} countries available`)}renderSuggestions(){this.list.innerHTML="";const t=this.suggestions;t.forEach((e,n)=>{const o=this.options.document.createElement("li");o.textContent=e.suggestion,o.setAttribute("aria-selected","false"),o.setAttribute("tabindex","-1"),o.setAttribute("title",e.suggestion),o.setAttribute("aria-posinset",`${n+1}`),o.setAttribute("aria-setsize",t.length.toString()),o.setAttribute("role","option"),h(o,this.options.liStyle),o.addEventListener("mousedown",t=>{t.preventDefault(),this.options.onMouseDown.call(this,t),this.fsm.send({type:"SELECT_ADDRESS",suggestion:e})}),o.id=`${this.list.id}_${n}`,this.list.appendChild(o)}),this.announce(`${t.length} addresses available`)}goToCurrent(){const t=this.list.children;this.input.setAttribute("aria-activedescendant","");for(let e=0;e{if(null===t)throw"Unable to retrieve address";return this.options.onAddressRetrieved.call(this,t),this.populateAddress(t),this}).catch(t=>(this.open(),this.setMessage(this.options.msgFallback),this.options.onSearchError.call(this,t),t))}populateAddress(t){this.unhideFields(),K({address:t,config:{...this.options,scope:this.outputScope},outputFields:this.options.outputFields,names:this.options.names,labels:this.options.labels}),this.options.onAddressPopulated.call(this,t)}setQueryOptions(t){this.cache.clear(),this.options.queryOptions=t}setResolveOptions(t){this.cache.clear(),this.options.resolveOptions=t}attach(){if(this.fsm.status===oi.Running)return this;this.input.addEventListener("input",this.inputListener),this.input.addEventListener("blur",this.blurListener),this.input.addEventListener("focus",this.focusListener),this.input.addEventListener("keydown",this.keydownListener),this.countryInput&&this.countryInput.addEventListener("change",this.countryListener);const t=this.input.parentNode;return t&&(t.insertBefore(this.container,this.input),this.container.appendChild(this.input),this.container.appendChild(this.mainComponent),this.container.appendChild(this.alerts),this.options.hide.length>0&&null==this.options.unhide&&this.container.appendChild(this.unhide)),this.fsm.start(),this.options.onMounted.call(this),this.hideFields(),this}detach(){if(this.fsm.status!==oi.Running)return this;this.input.removeEventListener("input",this.inputListener),this.input.removeEventListener("blur",this.blurListener),this.input.removeEventListener("focus",this.focusListener),this.input.removeEventListener("keydown",this.keydownListener),this.countryInput&&this.countryInput.removeEventListener("change",this.countryListener),this.container.removeChild(this.mainComponent),this.container.removeChild(this.alerts);const t=this.container.parentNode;return t&&(t.insertBefore(this.input,this.container),t.removeChild(this.container)),this.unmountUnhide(),this.unhideFields(),this.fsm.stop(),p(this.input,this.inputStyle),this.options.onRemove.call(this),this.unsetPlaceholder(),this}setMessage(t){return this.fsm.send({type:"NOTIFY",notification:t}),this}ariaAnchor(){return"1.0"===this.options.aria?this.input:this.container}query(){return this.input.value}clearInput(){T(this.input,"")}setSuggestions(t,e){return e!==this.query()?this:0===t.length?this.setMessage(this.options.msgNoMatch):(this.fsm.send({type:"SUGGEST",suggestions:t}),this)}close(t="blur"){f(this.mainComponent),"esc"===t&&T(this.input,""),this.options.onClose.call(this,t)}updateSuggestions(t){this.suggestions=t,this.current=-1}applyContext(t,e=!0){const n=t.iso_3;this.context=n,this.cache.clear(),this.countryIcon.innerText=t.emoji,e&&this.announce(`Country switched to ${t.description}`),this.options.onContextChange.call(this,n)}renderNotice(){this.list.innerHTML="",this.input.setAttribute("aria-activedescendant",""),this.message.textContent=this.notification,this.announce(this.notification),this.list.appendChild(this.message)}open(){m(this.mainComponent),this.options.onOpen.call(this)}next(){return this.current+1>this.list.children.length-1?this.current=0:this.current+=1,this}previous(){return this.current-1<0?this.current=this.list.children.length-1:this.current+=-1,this}scrollToView(t){const e=t.offsetTop,n=this.list.scrollTop;en+o&&(this.list.scrollTop=e-o+i),this}goto(t){const e=this.list.children,n=e[t];return t>-1&&e.length>0?this.scrollToView(n):this.scrollToView(e[0]),this}opened(){return!this.closed()}closed(){return this.fsm.state.matches("closed")}createUnhide(){const t=Si(this.scope,this.options.unhide,()=>{const t=this.options.document.createElement("p");return t.innerText=this.options.msgUnhide,t.setAttribute("role","button"),t.setAttribute("tabindex","0"),this.options.unhideClass&&(t.className=this.options.unhideClass),t});return t.addEventListener("click",this.unhideEvent),t}unmountUnhide(){this.unhide.removeEventListener("click",this.unhideEvent),null==this.options.unhide&&this.options.hide.length&&g(this.unhide)}hiddenFields(){return this.options.hide.map(e=>t(e)?r(this.options.scope,e):e).filter(t=>null!==t)}hideFields(){this.hiddenFields().forEach(f)}unhideFields(){this.hiddenFields().forEach(m),this.options.onUnhide.call(this)}};const yi=t=>function(){t.options.onBlur.call(t),t.fsm.send({type:"CLOSE",reason:"blur"})},vi=t=>function(e){t.options.onFocus.call(t),t.fsm.send("AWAKE")},bi=t=>function(e){if(":c"===t.query().toLowerCase())return T(t.input,""),t.fsm.send({type:"CHANGE_COUNTRY"});t.fsm.send({type:"INPUT",event:e})},Ei=t=>function(e){e.preventDefault(),t.fsm.send({type:"CHANGE_COUNTRY"})},wi=t=>function(e){const n=Z(e);if("Enter"===n&&e.preventDefault(),t.options.onKeyDown.call(t,e),t.closed())return t.fsm.send("AWAKE");if(t.fsm.state.matches("suggesting_country")){if("Enter"===n){const e=t.filteredContexts()[t.current];e&&t.fsm.send({type:"SELECT_COUNTRY",contextDetails:e})}"Backspace"===n&&t.fsm.send({type:"INPUT",event:e}),"ArrowUp"===n&&(e.preventDefault(),t.fsm.send("PREVIOUS")),"ArrowDown"===n&&(e.preventDefault(),t.fsm.send("NEXT"))}if(t.fsm.state.matches("suggesting")){if("Enter"===n){const e=t.suggestions[t.current];e&&t.fsm.send({type:"SELECT_ADDRESS",suggestion:e})}"Backspace"===n&&t.fsm.send({type:"INPUT",event:e}),"ArrowUp"===n&&(e.preventDefault(),t.fsm.send("PREVIOUS")),"ArrowDown"===n&&(e.preventDefault(),t.fsm.send("NEXT"))}"Escape"===n&&t.fsm.send({type:"CLOSE",reason:"esc"}),"Home"===n&&t.fsm.send({type:"RESET"}),"End"===n&&t.fsm.send({type:"RESET"})},Ci=t=>function(e){if(null===e.target)return;const n=e.target;if(!n)return;let o=Ai(n.value,t.options.contexts);t.fsm.send({type:"COUNTRY_CHANGE_EVENT",contextDetails:o})},Si=(e,n,o)=>t(n)?e.querySelector(n):o&&null===n?o():n,xi=(t,e,n)=>{const o=(t,e)=>{if(null===t)return;const n=t.getBoundingClientRect();e.style.minWidth=`${Math.round(n.width)}px`},i=e.parentElement;t.style.position="fixed",t.style.left="auto",o(i,t),null!==n.defaultView&&n.defaultView.addEventListener("resize",()=>{o(i,t)})},Ai=(t,e)=>{const n=t.toUpperCase();for(const t of Object.values(e)){if(t.iso_3===n)return t;if(t.iso_2===n)return t;if(t.description.toUpperCase()===n)return t}},Ti=t=>{const e=new gi(t);return _i.push(e),e},_i=[],Oi=()=>!0,Ri=1e3,Li=t=>s(t,"FORM"),ki=(t,i={})=>{const s=new ti({...mi,...t,api_key:t.apiKey}),{pageTest:r=Oi}=i;return r()?Ce({client:s}).then(s=>{if(!s.available)return null;const{getScope:a=Li,interval:c=Ri,anchor:u,onBind:d=fi,onAnchorFound:h=fi,onBindAttempt:p=fi,immediate:f=!0,marker:m="idpc"}=i,g=()=>{p({config:t,options:i}),((t,o)=>{const i=l(t.scope||null).querySelectorAll(t.anchor||t.inputField||(t.outputFields||{}).line_1);return e(i).filter(t=>!n(t,o))})({anchor:u,...t},m).forEach(e=>{const n=a(e);if(!n)return;const i=$t(s.contexts),r={scope:n,...t,checkKey:!1,contexts:i};h({anchor:e,scope:n,config:r});const c=Ti(r),u=c.options.contexts[s.context];c.options.detectCountry&&u?c.applyContext(u,!1):c.applyContext(c.currentContext(),!1),o(e,m),d(c)})},{start:y,stop:v}=(({pageTest:t,bind:e,interval:n=1e3})=>{let o=null;const i=()=>{null!==o&&(window.clearInterval(o),o=null)};return{start:s=>t()?(o=window.setInterval(()=>{try{e(s)}catch(t){i(),console.log(t)}},n),o):null,stop:i}})({bind:g,pageTest:r,interval:c});return f&&y(),{start:y,stop:v,bind:g}}).catch(t=>(i.onError&&i.onError(t),null)):Promise.resolve(null)},Ni=t=>(t.preventDefault&&t.preventDefault(),!1),Fi=()=>{},Ui=()=>!1,Pi=function(t){if("Enter"===Z(t))return t.preventDefault(),this.handleClick(),!1},ji=function(t){return t.cancelable&&t.preventDefault(),this.options.onButtonTrigger.call(this),this.handleClick(),!1},Ii=function(){const t=this.select.value.split("-");if("next"===t[0]){const e=parseInt(t[1],10);if(isNaN(e))return;return void this.executeSearch(this.lastLookup,e)}const e=parseInt(this.select.value,10);isNaN(e)||this.selectAddress(e)},Di={apiKey:"",checkKey:!0,context:"",outputScope:null,onButtonTrigger:Fi,onSearchCompleted:Fi,onAddressesRetrieved:Fi,onAddressSelected:Fi,onSelectCreated:Fi,onSelectRemoved:Fi,onLookupTriggered:Fi,shouldLookupTrigger:()=>!0,onSearchError:Fi,onLoaded:Fi,onFailedCheck:Fi,onRemove:Fi,onAddressPopulated:Fi,onUnhide:Fi,input:null,inputId:null,inputClass:"idpc-input",inputAriaLabel:"Search a postcode to retrieve your address",placeholder:"Search your postcode",button:null,buttonId:null,buttonLabel:"Find my Address",buttonClass:"idpc-button",selectContainer:null,selectId:null,selectClass:"idpc-select",selectContainerId:null,selectContainerClass:"idpc-select-container",selectAriaLabel:"Select your address",unhide:null,unhideClass:"idpc-unhide",message:null,messageId:null,messageClass:"idpc-error",msgSelect:"Please select your address",msgDisabled:"Finding addresses...",msgNotFound:"Your postcode could not be found. Please type in your address",msgAddressNotFound:"We could not find a match for your address. Please type in your address",msgError:"Sorry, we weren't able to get the address you were looking for. Please type in your address",msgUnhide:"Enter address manually",cooloff:500,removeOrganisation:!1,selectSinglePremise:!1,titleizePostTown:!0,postcodeSearchFormatter:t=>{const e=[t.line_1];return""!==t.line_2&&e.push(t.line_2),""!==t.line_3&&e.push(t.line_3),e.join(", ")},addressSearchFormatter:t=>{const e=[t.line_1];return""!==t.line_2&&e.push(t.line_2),e.push(t.post_town),e.push(t.postcode_outward),e.join(", ")},outputFields:{},strictlyPostcodes:!0,limit:10,inputStyle:{},buttonStyle:{},messageStyle:{},selectStyle:{},contextStyle:{},hide:[],autocomplete:"none",populateCounty:!0};class Bi{constructor(t){this.prevContext=null,this.options={scope:window.document,document:window.document,...Di,...t},this.client=new ti({...this.options,api_key:this.options.apiKey}),this.scope=l(this.options.scope),this.document=d(this.scope),this.outputScope=this.findOrCreate(this.options.outputScope,()=>this.scope),this.data=[],this.lastLookup="",this.context=this.findOrCreate(this.options.context),this.prevContext=h(this.context,this.options.contextStyle),this.keypress=Pi.bind(this),this.click=ji.bind(this),this.selectEvent=Ii.bind(this),this.unhideEvent=this.unhideFields.bind(this),this.input=this.createInput(),this.button=this.createButton(),this.message=this.createMessage(),this.select=this.createSelect(),this.selectContainer=this.createContainer(),this.unhide=this.createUnhide(),this.init()}findOrCreate(e,n){return t(e)?this.scope.querySelector(e):n&&null===e?n():e}createUnhide(){const t=this.findOrCreate(this.options.unhide,()=>{const t=this.document.createElement("p");return t.innerText=this.options.msgUnhide,t.setAttribute("role","button"),t.setAttribute("tabindex","0"),this.options.unhideClass&&(t.className=this.options.unhideClass),t});return t.addEventListener("click",this.unhideEvent),t.addEventListener("keyup",t=>"Enter"===t.key&&this.unhideEvent(t)),t}unmountUnhide(){this.unhide.removeEventListener("click",this.unhideEvent),!this.options.unhide&&this.options.hide.length&&g(this.unhide)}createContainer(){return this.findOrCreate(this.options.selectContainer,()=>{const t=this.options,e=this.document.createElement("div");return t.selectContainerId&&(e.id=t.selectContainerId),t.selectContainerClass&&(e.className=t.selectContainerClass),e.setAttribute("aria-live","polite"),f(e),e})}unmountContainer(){g(this.selectContainer)}createInput(){const t=this.findOrCreate(this.options.input,()=>{const t=this.document.createElement("input"),e=this.options;return t.type="text",e.inputId&&(t.id=e.inputId),e.inputClass&&(t.className=e.inputClass),e.placeholder&&(t.placeholder=e.placeholder),e.inputAriaLabel&&t.setAttribute("aria-label",e.inputAriaLabel),e.autocomplete&&t.setAttribute("autocomplete",e.autocomplete),h(t,this.options.inputStyle),t});return t.addEventListener("keypress",this.keypress),t.addEventListener("submit",Ui),t}unmountInput(){this.input.removeEventListener("keypress",this.keypress),this.input.removeEventListener("submit",Ui),null===this.options.input&&g(this.input)}createButton(){const t=this.findOrCreate(this.options.button,()=>{const t=this.document.createElement("button"),e=this.options;return t.type="button",e.buttonLabel&&(t.innerText=e.buttonLabel),e.buttonId&&(t.id=e.buttonId),e.buttonClass&&(t.className=e.buttonClass),h(t,this.options.buttonStyle),t.onclick=Ni,t});return t.addEventListener("submit",Ui),t.addEventListener("click",this.click),t}unmountButton(){this.button.removeEventListener("submit",Ui),this.button.removeEventListener("click",this.click),null===this.options.button&&g(this.button)}createMessage(){return this.findOrCreate(this.options.message,()=>{const t=this.document.createElement("p"),e=this.options;return e.messageClass&&(t.className=e.messageClass),e.messageId&&(t.id=e.messageId),t.setAttribute("role","alert"),h(t,this.options.messageStyle),f(t),t})}unmountMessage(){null===this.options.message&&g(this.message)}createSelect(){const t=this.document.createElement("select"),e=this.options;return e.selectId&&(t.id=e.selectId),e.selectClass&&(t.className=e.selectClass),h(t,this.options.selectStyle),e.selectAriaLabel&&t.setAttribute("aria-label",e.selectAriaLabel),t.addEventListener("change",this.selectEvent),t}mountSelect(t,e){t&&(this.data=t),(t=>{let e;for(e=t.options.length-1;e>=0;e--)t.remove(e)})(this.select),this.select.appendChild(this.createOption("ideal",this.options.msgSelect));for(let t=0;tthis.enableButton(),t)}reset(){this.unmountSelect(),this.hideMessage()}removeAll(){this.unmountInput(),this.unmountButton(),this.unmountContainer(),this.unmountMessage(),this.unmountUnhide(),p(this.context,this.prevContext),this.options.onRemove.call(this)}notFoundMessage(){return this.options.strictlyPostcodes?this.options.msgNotFound:this.options.msgAddressNotFound}executeSearch(t,e){this.enableLookup();return(this.options.strictlyPostcodes?this.searchPostcode(t,e):this.searchAddress(t,e)).catch(t=>{if(t instanceof he==!1)throw t;const e=t.response.body.suggestions||[];return e.length>1?(this.suggestionsMessage(e),null):1===e.length?(this.input.value=e[0],this.executeSearch(e[0]),null):"not_found"}).then(e=>{if(null===e)return;if("not_found"===e)return this.options.onSearchCompleted.call(this,null,[]),this.setMessage(this.notFoundMessage());const{addresses:n,total:o,page:i,limit:s}=e;if(this.options.onSearchCompleted.call(this,null,n),0===n.length)return this.setMessage(this.notFoundMessage());if(this.setMessage(),this.lastLookup=t,this.data=n,this.options.onAddressesRetrieved.call(this,n),this.options.selectSinglePremise&&1===n.length)return this.selectAddress(0);let r;o>(i+1)*s&&(r=i+1),this.mountSelect(n,r)}).catch(t=>{this.setMessage(this.options.msgError),this.options.onSearchCompleted.call(this,null,[]),this.options.onSearchError.call(this,t)})}suggestionsMessage(t){const e=this.document.createElement("span");e.innerHTML=`We couldn't find ${this.input.value}. Did you mean `,t.forEach((n,o)=>{const i=this.document.createElement("a");0===o?i.innerText=`${n}`:o===t.length-1?i.innerText=` or ${n}`:i.innerText=`, ${n}`,i.style.cursor="pointer",i.addEventListener("click",t=>{t.preventDefault(),this.input.value=n,this.executeSearch(n),this.hideMessage()}),e.appendChild(i)}),m(this.message),this.message.innerHTML="",this.message.appendChild(e)}searchPostcode(t,e=0){const n=(t=>{const e={},n={},{client:o}=t;Qt({client:o,header:e,options:t}),te({header:e,options:t}),ee({query:n,options:t}),ne({client:o,query:n,options:t});const i={header:e,query:n};return void 0!==t.timeout&&(i.timeout=t.timeout),i})({client:this.client});return e>0&&(n.query.page=String(e)),((t,e,n)=>Ee({resource:"postcodes",client:t})(e,n))(this.client,t,n).then(t=>({addresses:t.body.result,page:t.body.page,total:t.body.total,limit:t.body.limit}))}searchAddress(t,e){const n=(t=>{const e={},n={query:t.query},{client:o}=t;Qt({client:o,header:e,options:t}),te({header:e,options:t}),ee({query:n,options:t}),ne({client:o,query:n,options:t}),(({query:t,options:e})=>{const{page:n,limit:o}=e;void 0!==n&&(t.page=n.toString()),void 0!==o&&(t.limit=o.toString())})({query:n,options:t});const i={header:e,query:n};return void 0!==t.timeout&&(i.timeout=t.timeout),i})({client:this.client,query:t,limit:this.options.limit});return(o=this.client,i=n,we({resource:"addresses",client:o})(i)).then(t=>({addresses:t.body.result.hits,page:t.body.result.page,total:t.body.result.hits.length,limit:t.body.result.limit}));var o,i}formatAddress(t){return(this.options.strictlyPostcodes?this.options.postcodeSearchFormatter:this.options.addressSearchFormatter)(t)}createOption(t,e){const n=this.document.createElement("option");return n.text=e,n.value=t,n}setMessage(t){if(this.message){if(void 0===t)return this.hideMessage();m(this.message),this.message.innerText=t}}hideMessage(){this.message&&(this.message.innerText="",f(this.message))}init(){const t=()=>{this.render(),this.hideFields(),this.options.onLoaded.call(this)};if(!this.options.checkKey)return t();Ce({client:this.client}).then(({available:e})=>e?t():Promise.reject("Key not available")).catch(t=>{this.options.onFailedCheck&&this.options.onFailedCheck(t)})}populateAddress(t){this.unhideFields();const e=this.options.outputFields,n={...this.options,scope:this.outputScope};K({outputFields:e,address:t,config:n}),this.options.onAddressPopulated.call(this,t)}hiddenFields(){return this.options.hide.map(e=>t(e)?r(this.scope,e):e).filter(t=>null!==t)}hideFields(){this.hiddenFields().forEach(f)}unhideFields(){this.hiddenFields().forEach(m),this.options.onUnhide.call(this)}render(){this.context.innerHTML="",this.options.input||this.context.appendChild(this.input),this.options.button||this.context.appendChild(this.button),this.options.selectContainer||this.context.appendChild(this.selectContainer),this.options.message||this.context.appendChild(this.message),!this.options.unhide&&this.options.hide.length&&this.context.appendChild(this.unhide)}}const qi=()=>!0,Mi=()=>{},Hi=t=>s(t,"FORM"),$i=(t,i={})=>{const{pageTest:s=qi,onError:r=Mi,onBindAttempt:a=Mi,onBind:c=Mi,anchor:u,onAnchorFound:d=Mi,getScope:h=Hi,marker:p="idpc-pl"}=i;let f;const{start:m,stop:g}=nt({bind:()=>{try{a(t),((t,o)=>{const i=l(t.scope||null).querySelectorAll(t.anchor||t.context||t.scope);return e(i).filter(t=>!n(t,o))})({anchor:u,...t},p).forEach(e=>{if(!s())return;const n=h(e);d({anchor:e,scope:n,config:t}),f=(t=>new Bi(t))(t),o(e,p),c(f)})}catch(t){r(t)}}});return m(),{start:m,stop:g,controller:f}};var zi=["England","Scotland","Wales","Northern Ireland","Channel Islands","Isle of Man","United Kingdom","Jersey","Guernsey","GB","IM","JE","GG"],Ki=function(t,e){void 0===e&&(e="col-form-label");var n=document.createElement("label");return n.innerText="Search your Postcode",n.className=e,n.setAttribute("for","idpc_postcode_lookup"),a({target:t,elem:n}),n},Gi=function(){},Wi=function(t,e,n){var o=c(t.country,document);if(null===o)return Gi;var i=function(){if(function(t){var e=t.selectedIndex,n=t.options[e].text;return zi.reduce(function(t,e){return n===e||t},!1)}(o))return e();n()};return o.addEventListener("change",i),i},Vi=function(t,e,n,o,i){void 0===i&&(i=!1),!0===t.postcodeLookup&&$i({context:"div.idpc_lookup",apiKey:t.apiKey,inputClass:"form-control",buttonClass:"btn btn-primary idpc-button",selectClass:"form-select",checkKey:!0,outputFields:e,inputStyle:{marginBottom:"15px"},buttonStyle:{marginBottom:"15px"},removeOrganisation:!1,onLoaded:function(){var t=this;setTimeout(function(){var n=Ki(t.context,i?"col-sm-2 col-form-label":"col-form-label");Wi(e,function(){n.hidden=!1,m(t.context)},function(){n.hidden=!0,f(t.context)})()},0)},onAddressPopulated:function(t){var e=this;setTimeout(function(){Zi(t,e.options.outputFields.county_code)},300)}},{pageTest:n,getScope:o,anchor:e.line_1,onAnchorFound:function(t){var n=t.scope;(null==n?void 0:n.querySelector('.idpc_lookup[idpc="true"]'))||(t.config.context=function(t,e){var n;void 0===e&&(e=!1);var o=c(t.line_1,document);if(null===o)return null;var i=null===(n=o.parentElement)||void 0===n?void 0:n.parentElement;if(!i)return null;var s=document.createElement("div");s.className=e?"row mb-3":"row";var r=document.createElement("div");if(!1===e){var u=document.createElement("div");u.className="col mb-3",s.appendChild(u),r.className="idpc_lookup",u.appendChild(r)}else r.className="col-sm-10 idpc_lookup",s.appendChild(r);return a({target:i,elem:s}),r}(e,i))}})},Ji=function(t,e,n,o){!0===t.postcodeLookup&&$i({context:"div.idpc_lookup",apiKey:t.apiKey,inputClass:"form-control",buttonClass:"btn btn-primary idpc-button",selectClass:"form-select",checkKey:!0,outputFields:e,inputStyle:{marginBottom:"15px"},buttonStyle:{marginBottom:"15px"},removeOrganisation:!1,onLoaded:function(){var t=this;setTimeout(function(){var n=Ki(t.context,"form-label");Wi(e,function(){n.hidden=!1,m(t.context)},function(){n.hidden=!0,f(t.context)})()},0)},onAddressPopulated:function(t){var e=this;setTimeout(function(){Zi(t,e.options.outputFields.county_code)},300)}},{pageTest:n,getScope:o,anchor:e.line_1,onAnchorFound:function(t){var n=t.scope;(null==n?void 0:n.querySelector('.idpc_lookup[idpc="true"]'))||(t.config.context=function(t){var e=c(t.line_1,document);if(null===e)return null;var n=s(e,"div",function(t){return t.classList.contains("row")});if(null===n)return null;var o=document.createElement("div");o.className="row mb-3";var i=document.createElement("div");return i.className="idpc_lookup",o.appendChild(i),a({target:n,elem:o}),i}(e))}})},Yi=function(t,e,n,o){if(!0===t.autocomplete&&null!==e.line_1)return ki({apiKey:t.apiKey,checkKey:!0,populateOrganisation:!0,removeOrganisation:!1,outputFields:e,onAddressPopulated:function(t){var e=this;setTimeout(function(){Zi(t,e.options.outputFields.county_code)},300)},onContextChange:function(t){var n=document.querySelector(e.country);if(n&&C(n)){var o=n,i=o.value,s=!1,r="";if(Array.from(o.options).forEach(function(e){e.value.toUpperCase()===t&&(r=e.value,s=!0)}),!s){var a=this.currentContext();if(a){var c=Qi(o,a.description);c.length>0&&(r=c[0].value,s=!0)}}if(s&&r!==i){o.value=r;var u=new Event("change",{bubbles:!0});o.dispatchEvent(u)}else s||console.warn("No matching option found for context:",t)}},onMounted:function(){var t=this,n=document.querySelector(e.country);if(n)if(C(n)){var o=function(){var e=n,o=e.value,i=e.options[e.selectedIndex],s=i?i.text:"";if(o){var r=t.options.contexts;if(r){var a;for(var c in r)if(c===o.toUpperCase()){a=r[c];break}if(!a)for(var c in r){var u=r[c];if(u&&u.description&&u.description.toLowerCase()===s.toLowerCase()){a=u;break}}if(a){var l=t.currentContext();if(l&&l.iso_3===a.iso_3);else try{t.applyContext(a)}catch(t){console.error("Error applying context:",t)}}else console.warn("Could not find matching context for country:",o,s)}else console.warn("No contexts available in Address Finder")}else console.warn("No country value selected")};n.addEventListener("change",o),setTimeout(o,300)}else console.warn("Country element is not a select element:",e.country);else console.warn("Country select element not found:",e.country)}},{pageTest:n,getScope:o,marker:"idpc-af"})},Xi=function(t,e){return Array.from(t.options).some(function(t){return t.value===e})},Qi=function(t,e){return e?Array.from(t.options).filter(function(t){return-1!==t.text.toLowerCase().indexOf(e.toLowerCase())}):[]},Zi=function(t,e){if(null!==e){var n="string"==typeof e?document.querySelector(e):e;if(C(n)){var o=t.county_code||"",i=t.county||"";if("London"===i&&(i="Greater London"),C(n)){if(""!==o&&Xi(n,o))return void(n.value=o);if(""!==i&&Xi(n,i))return void(n.value=i);if(i){var s=Qi(n,i);if(s.length>0)return void(n.value=s[0].value)}if(o){var r=Qi(n,o);if(r.length>0)return void(n.value=r[0].value)}for(var a=0,c=["post_town","traditional_county","administrative_county"];a0)return void(n.value=l[0].value)}}}}}},ts={line_1:"#input-payment-address-1",line_2:"#input-payment-address-2",postcode:"#input-payment-postcode",post_town:"#input-payment-city",organisation_name:"#input-payment-company",county_code:"#input-payment-zone",country:"#input-payment-country"},es=function(t){return s(t,"fieldset")},ns=function(){return window.location.href.includes("/checkout")},os={bind:function(t){Yi(t,ts,ns,es),Ji(t,ts,ns,es)}},is={line_1:"#input-shipping-address-1",line_2:"#input-shipping-address-2",postcode:"#input-shipping-postcode",post_town:"#input-shipping-city",organisation_name:"#input-shipping-company",county_code:"#input-shipping-zone",country:"#input-shipping-country"},ss=function(t){return s(t,"fieldset",function(t){return"shipping-address"===t.id})},rs={bind:function(t){Yi(t,is,ns,ss),Vi(t,is,ns,ss)}},as={line_1:"#input-address-1",line_2:"#input-address-2",postcode:"#input-postcode",post_town:"#input-city",organisation_name:"#input-company",county_code:"#input-zone",country:"#input-country"},cs=void 0,us=function(){return window.location.href.includes("/address")},ls={bind:function(t){Yi(t,as,us,cs),Vi(t,as,us,cs,!0)}},ds=function(){return!0},hs={bind:function(t){(t.customFields||[]).forEach(function(e){Yi(t,e,ds),Ji(t,e,ds)})}};[os,rs,ls,hs].forEach(function(t){var e=(()=>{const t=window.idpcConfig;if(void 0!==t)return{...v,...t}})();e&&t.bind(e)})}(); +!function(){"use strict";const t=t=>"string"==typeof t,e=t=>Array.prototype.slice.call(t),n=(t,e="idpc")=>"true"===t.getAttribute(e),o=(t,e="idpc")=>t.setAttribute(e,"true"),i=()=>!0,s=(t,e,n=i)=>{let o=t;const s=e.toUpperCase();for(;"HTML"!==o.tagName;){if(o.tagName===s&&n(o))return o;if(null===o.parentNode)return null;o=o.parentNode}return null},r=(t,e)=>e?t.querySelector(e):null,a=({elem:t,target:e})=>{const n=e.parentNode;if(null!==n)return n.insertBefore(t,e),t},c=(e,n)=>t(e)?n.querySelector(e):e,u=()=>window.document,l=e=>t(e)?u().querySelector(e):null===e?u():e,d=t=>t instanceof Document||"HTMLDocument"===t.constructor.name?t:t.ownerDocument?t.ownerDocument:u(),h=(t,e)=>{const n=t.getAttribute("style");return Object.keys(e).forEach(n=>t.style[n]=e[n]),n},p=(t,e)=>{t.setAttribute("style",e||"")},f=t=>(t.style.display="none",t),m=t=>(t.style.display="",t),g=t=>{null!==t&&null!==t.parentNode&&t.parentNode.removeChild(t)},y=(t,e,n)=>{const o=t.querySelectorAll(e);for(let t=0;t{const e=(t=String(t)).length;let n,o=-1,i="";const s=t.charCodeAt(0);for(;++o=1&&n<=31||127==n||0==o&&n>=48&&n<=57||1==o&&n>=48&&n<=57&&45==s?"\\"+n.toString(16)+" ":(0!=o||1!=e||45!=n)&&(n>=128||45==n||95==n||n>=48&&n<=57||n>=65&&n<=90||n>=97&&n<=122)?t.charAt(o):"\\"+t.charAt(o):"οΏ½";return i},E=t=>void 0!==t.post_town,w=(t,e)=>t.dispatchEvent((({event:t,bubbles:e=!0,cancelable:n=!0})=>{if("function"==typeof window.Event)return new window.Event(t,{bubbles:e,cancelable:n});const o=document.createEvent("Event");return o.initEvent(t,e,n),o})({event:e})),C=t=>null!==t&&(t instanceof HTMLSelectElement||"HTMLSelectElement"===t.constructor.name),S=t=>null!==t&&(t instanceof HTMLInputElement||"HTMLInputElement"===t.constructor.name),x=t=>null!==t&&(t instanceof HTMLTextAreaElement||"HTMLTextAreaElement"===t.constructor.name),A=t=>S(t)||x(t)||C(t),T=(t,e,n=!1)=>{t&&(S(t)||x(t))&&L({e:t,value:e,skipTrigger:n})},_=(t,e)=>null!==e&&null!==t.querySelector(`[value="${e}"]`),O=(t,e)=>{if(null===e)return[];const n=t.querySelectorAll("option");return Array.from(n).filter(t=>(t.textContent?t.textContent.replace(/[\n\r]/g,"").replace(/\s+/g," ").trim():"")===e)},R=(t,e)=>{const n=Object.getOwnPropertyDescriptor(t.constructor.prototype,"value");if(void 0===n)return;if(void 0===n.set)return;n.set.call(t,e)},L=t=>{null!==t.value&&((({e:t,value:e,skipTrigger:n})=>{null!==e&&C(t)&&(R(t,e),n||w(t,"select"),w(t,"change"))})(t),(({e:t,value:e,skipTrigger:n})=>{null!==e&&(S(t)||x(t))&&(R(t,e),n||w(t,"input"),w(t,"change"))})(t))},k="United Kingdom",N="Isle of Man",F=t=>{const e=t.country;if("England"===e)return k;if("Scotland"===e)return k;if("Wales"===e)return k;if("Northern Ireland"===e)return k;if(e===N)return N;if(E(t)&&"Channel Islands"===e){if(/^GY/.test(t.postcode))return"Guernsey";if(/^JE/.test(t.postcode))return"Jersey"}return e};let U={};"undefined"!=typeof window&&(window.idpcGlobal?U=window.idpcGlobal:window.idpcGlobal=U);const P=()=>U,j=e=>e.filter(e=>t(e)?!!e.trim():!!e).join(", "),I=(t,e)=>{if(t.length<=e)return[t,""];const n=t.split(" ");let o="",i="";for(let t=0;te){i=n.slice(t).join(" ");break}o+=`${s} `}return[o.trim(),i.trim()]},D=(t,e)=>0===e.length?t:`${t}, ${e}`,B=(t,e,n)=>{const{line_1:o,line_2:i}=e,s="line_3"in e?e.line_3:"";return n.maxLineOne||n.maxLineTwo||n.maxLineThree?((t,e)=>{const{lineCount:n,maxLineOne:o,maxLineTwo:i,maxLineThree:s}=e,r=["","",""],a=[...t];if(o){const[t,e]=I(a[0],o);if(r[0]=t,e&&(a[1]=D(e,a[1])),1===n)return r}else if(r[0]=a[0],1===n)return[j(a),"",""];if(i){const[t,e]=I(a[1],i);if(r[1]=t,e&&(a[2]=D(e,a[2])),2===n)return r}else if(r[1]=a[1],2===n)return[r[0],j(a.slice(1)),""];if(s){const[t,e]=I(a[2],s);r[2]=t,e&&(a[3]=D(e,a[3]))}else r[2]=a[2];return r})([o,i,s],{lineCount:t,...n}):3===t?[o,i,s]:2===t?[o,j([i,s]),""]:[j([o,i,s]),"",""]},q=(t,e)=>{const n=t[e];return"number"==typeof n?n.toString():void 0===n?"":n},M=(t,e)=>{const n={};let o;for(o in t){const i=t[o];if(void 0===i)continue;const s=c(i,e);A(s)&&(n[o]=s)}return n},H=(t,e)=>{const n={};let o;for(o in t){if(!t.hasOwnProperty(o))continue;const i=t[o],s=c(`[name="${i}"]`,e);if(s){n[o]=s;continue}const r=c(`[aria-name="${i}"]`,e);r&&(n[o]=r)}return n},$=(t,e)=>{const n={};if(void 0===t)return t;let o;for(o in t){if(!t.hasOwnProperty(o))continue;const i=t[o];if(!i)continue;const s=y(e,"label",i),r=c(s,e);if(!r)continue;const a=r.getAttribute("for");if(a){const t=e.querySelector(`#${b(a)}`);if(t){n[o]=t;continue}}const u=r.querySelector("input");u&&(n[o]=u)}return n},z=["country","country_iso_2","country_iso"],K=t=>{const{config:e}=t,n={...M((o=t).outputFields||{},o.config.scope),...H(o.names||{},o.config.scope),...$(o.labels||{},o.config.scope)};var o;void 0===e.lines&&(e.lines=(t=>{const{line_2:e,line_3:n}=t;return e?n?3:2:1})(n));const i=((t,e)=>{E(t)&&e.removeOrganisation&&W(t);const[n,o,i]=B(e.lines||3,t,e);return t.line_1=n,t.line_2=o,E(t)&&(t.line_3=i),t})({...t.address},e),{scope:s,populateCounty:r}=e,a=[...z];E(i)&&(e.removeOrganisation&&W(i),!1===r&&a.push("county")),((t,e)=>{if(t){if(C(t)){const n=F(e);if(_(t,n))return void L({e:t,value:n});if(_(t,e.country_iso_2))return void L({e:t,value:e.country_iso_2});if(_(t,e.country_iso))return void L({e:t,value:e.country_iso});let o=O(t,n);if(o.length>0)return void L({e:t,value:o[0].value||""});if(o=O(t,e.country_iso_2),o.length>0)return void L({e:t,value:o[0].value||""});if(o=O(t,e.country_iso),o.length>0)return void L({e:t,value:o[0].value||""})}if(S(t)){const n=F(e);L({e:t,value:n})}}})(c(n.country||null,s),i);const u=c(n.country_iso_2||null,s);if(C(u))if(_(u,i.country_iso_2))L({e:u,value:i.country_iso_2});else{let t=O(u,i.country_iso_2);t.length>0?L({e:u,value:t[0].value||""}):(t=O(u,F(i)),t.length>0&&L({e:u,value:t[0].value||""}))}S(u)&&T(u,i.country_iso_2||"");const l=c(n.country_iso||null,s);if(C(l))if(_(l,i.country_iso))L({e:l,value:i.country_iso});else{let t=O(l,i.country_iso);t.length>0?L({e:l,value:t[0].value||""}):(t=O(l,F(i)),t.length>0&&L({e:l,value:t[0].value||""}))}S(l)&&T(l,i.country_iso||"");const d=c(V(n),s),h=J(i),p=Y(i);if(C(d))if(_(d,h))L({e:d,value:h});else if(_(d,p||""))L({e:d,value:p||""});else{let t=O(d,p);t.length>0?L({e:d,value:t[0].value||""}):(t=O(d,h),t&&L({e:d,value:t[0].value||""}))}let f;for(f in S(d)&&T(d,h),n)if(!a.includes(f))if(f.startsWith("native."))G(f,n,i,s);else if(void 0!==i[f]&&n.hasOwnProperty(f)){const t=n[f];if(!t)continue;T(c(t,s),q(i,f))}},G=(t,e,n,o)=>{const i=t.replace("native.",""),s=n.native;if(void 0===s)return;if(void 0!==s[i]&&e.hasOwnProperty(t)){const n=e[t];if(!n)return;T(c(n,o),q(s,i))}},W=t=>(0===t.organisation_name.length||0===t.line_2.length&&0===t.line_3.length||t.line_1===t.organisation_name&&(t.line_1=t.line_2,t.line_2=t.line_3,t.line_3=""),t),V=t=>(t=>t.hasOwnProperty("state_abbreviation"))(t)?t.state_abbreviation||null:t.county_code||null,J=t=>E(t)?t.county_code:t.state_abbreviation,Y=t=>E(t)?t.county:t.state,X={13:"Enter",38:"ArrowUp",40:"ArrowDown",36:"Home",35:"End",27:"Escape",8:"Backspace"},Q=["Enter","ArrowUp","ArrowDown","Home","End","Escape","Backspace"],Z=t=>{return t.keyCode?X[t.keyCode]||null:(e=t.key,-1!==Q.indexOf(e)?t.key:null);var e},tt=function(t,e,n){let o,i,s,r,a;if("function"!=typeof t)throw new TypeError("Expected a function");function c(t){const n=t-a;return void 0===a||n>=e||n<0||false}function u(){const n=Date.now();if(c(n))return function(){if(r=void 0,o)return function(){const e=o,n=i;return o=i=void 0,s=t.apply(n,e),s}();return o=i=void 0,s}();r=setTimeout(u,function(t){return e-(t-a)}(n))}function l(...t){const n=Date.now(),l=c(n);return o=t,i=this,a=n,l&&void 0===r?(r=setTimeout(u,e),s):(void 0===r&&(r=setTimeout(u,e)),s)}return e=+e||0,l.cancel=function(){void 0!==r&&clearTimeout(r),o=a=i=r=void 0},l.pending=function(){return void 0!==r},l},et=({bind:t,interval:e=1e3})=>{let n=null;const o=()=>{null!==n&&(window.clearInterval(n),n=null)};return{start:()=>(n=window.setInterval(()=>{try{t()}catch(t){o()}},e),n),stop:o}},nt=t=>window&&window.MutationObserver&&t.mutationObserver?(({bind:t,interval:e=1e3,target:n=window.document,observerConfig:o={subtree:!0,childList:!0}})=>{const i=new MutationObserver(tt(()=>{try{t()}catch(t){s()}},e)),s=()=>i.disconnect();return{start:()=>(i.observe(n,o),null),stop:s}})(t):et(t);function ot(t,e,n){if(n||2===arguments.length)for(var o,i=0,s=e.length;i=e||n<0||d&&t-u>=s}function m(){var t=It();if(f(t))return g(t);a=setTimeout(m,function(t){var n=e-(t-c);return d?qt(n,s-(t-u)):n}(t))}function g(t){return a=void 0,h&&o?p(t):(o=i=void 0,r)}function y(){var t=It(),n=f(t);if(o=arguments,i=this,c=t,n){if(void 0===a)return function(t){return u=t,a=setTimeout(m,e),l?p(t):r}(c);if(d)return clearTimeout(a),a=setTimeout(m,e),p(c)}return void 0===a&&(a=setTimeout(m,e)),r}return e=Dt(e)||0,jt(n)&&(l=!!n.leading,s=(d="maxWait"in n)?Bt(Dt(n.maxWait)||0,e):s,h="trailing"in n?!!n.trailing:h),y.cancel=function(){void 0!==a&&clearTimeout(a),u=0,o=c=i=a=void 0},y.flush=function(){return void 0===a?r:g(It())},y},Ht=st(Mt);const $t=(t,e)=>(t.id=e,t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t),zt=t=>{const e={};for(const n of t)e[n.iso_3]=n;return e},Kt={tls:!0,api_key:"",baseUrl:"api.ideal-postcodes.co.uk",version:"v1",strictAuthorisation:!1,timeout:1e4,header:{Accept:"application/json","Content-Type":"application/json"},tags:[],agent:{}};let Gt=class{constructor(t){this.config={...Kt,...t},this.config.header={...Kt.header,...t.header&&t.header}}url(){const{baseUrl:t,version:e}=this.config;return`${this.protocol()}://${t}/${e}`}protocol(){return this.config.tls?"https":"http"}};const Wt=t=>void 0===t?{}:Object.keys(t).reduce((e,n)=>{const o=t[n],i=Jt(o);return i.length>0&&(e[n]=i),e},{}),Vt=t=>"string"==typeof t,Jt=t=>{const e=[];return(t=>Array.isArray(t))(t)?(t.forEach(t=>{Yt(t)&&e.push(t.toString()),Vt(t)&&e.push(t)}),e.join(",")):Yt(t)?t.toString():Vt(t)?t:""},Yt=t=>"number"==typeof t,Xt=({timeout:t},e)=>Yt(t)?t:e.config.timeout,Qt=({header:t={}},e)=>({...e.config.header,...Wt(t)}),Zt=({header:t,options:e,client:n})=>(t.Authorization=((t,e)=>{const n=[],o=e.api_key||t.config.api_key;n.push(["api_key",o]);const i=e.licensee;void 0!==i&&n.push(["licensee",i]);const s=e.user_token;return void 0!==s&&n.push(["user_token",s]),`IDEALPOSTCODES ${te(n)}`})(n,e),t),te=t=>t.map(([t,e])=>`${t}="${e}"`).join(" "),ee=({header:t,options:e})=>{const{sourceIp:n}=e;return void 0!==n&&(t["IDPC-Source-IP"]=n),t},ne=({query:t,options:e})=>{const{filter:n}=e;return void 0!==n&&(t.filter=n.join(",")),t},oe=({client:t,query:e,options:n})=>{let o;return t.config.tags.length&&(o=t.config.tags),n.tags&&(o=n.tags),void 0!==o&&(e.tags=o.join(",")),e};let ie=class t extends Error{constructor(e){const n=new.target.prototype;super(),this.__proto__=n;const{message:o,httpStatus:i,metadata:s={}}=e;this.message=o,this.name="Ideal Postcodes Error",this.httpStatus=i,this.metadata=s,Error.captureStackTrace&&Error.captureStackTrace(this,t)}};class se extends ie{constructor(t){super({httpStatus:t.httpStatus,message:t.body.message}),this.response=t}}class re extends se{}class ae extends se{}class ce extends ae{}class ue extends se{}class le extends ue{}class de extends ue{}class he extends se{}class pe extends he{}class fe extends he{}class me extends he{}class ge extends he{}class ye extends se{}const ve=t=>{const{httpStatus:e,body:n}=t;if((o=e)<200||o>=300){var o;if((t=>{return null!==(e=t)&&"object"==typeof e&&"string"==typeof t.message&&"number"==typeof t.code;var e})(n)){const{code:o}=n;if(4010===o)return new ce(t);if(4040===o)return new pe(t);if(4042===o)return new fe(t);if(4044===o)return new me(t);if(4046===o)return new ge(t);if(4020===o)return new le(t);if(4021===o)return new de(t);if(404===e)return new he(t);if(400===e)return new re(t);if(402===e)return new ue(t);if(401===e)return new ae(t);if(500===e)return new ye(t)}return new ie({httpStatus:e,message:JSON.stringify(n)})}};var be=Object.freeze({__proto__:null,IdealPostcodesError:ie,IdpcApiError:se,IdpcBadRequestError:re,IdpcBalanceDepletedError:le,IdpcInvalidKeyError:ce,IdpcKeyNotFoundError:fe,IdpcLimitReachedError:de,IdpcPostcodeNotFoundError:pe,IdpcRequestFailedError:ue,IdpcResourceNotFoundError:he,IdpcServerError:ye,IdpcUdprnNotFoundError:me,IdpcUmprnNotFoundError:ge,IdpcUnauthorisedError:ae,parse:ve});const Ee=(t,e)=>[t.client.url(),t.resource,encodeURIComponent(e),t.action].filter(t=>void 0!==t).join("/"),we=t=>{const{client:e}=t;return(n,o)=>e.config.agent.http({method:"GET",url:Ee(t,n),query:Wt(o.query),header:Qt(o,e),timeout:Xt(o,e)}).then(t=>{const e=ve(t);if(e)throw e;return t})},Ce=t=>{const{client:e,resource:n}=t;return t=>e.config.agent.http({method:"GET",url:`${e.url()}/${n}`,query:Wt(t.query),header:Qt(t,e),timeout:Xt(t,e)}).then(t=>{const e=ve(t);if(e)throw e;return t})},Se=t=>{const{client:e,timeout:n}=t,o=t.api_key||t.client.config.api_key,{licensee:i}=t;let s;s=void 0===i?{}:{licensee:i};const r={query:s,header:{}};return void 0!==n&&(r.timeout=n),((t,e,n)=>we({resource:"keys",client:t})(e,n))(e,o,r).then(t=>t.body.result)},xe="autocomplete/addresses";function Ae(t,e){return function(){return t.apply(e,arguments)}}const{toString:Te}=Object.prototype,{getPrototypeOf:_e}=Object,{iterator:Oe,toStringTag:Re}=Symbol,Le=(ke=Object.create(null),t=>{const e=Te.call(t);return ke[e]||(ke[e]=e.slice(8,-1).toLowerCase())});var ke;const Ne=t=>(t=t.toLowerCase(),e=>Le(e)===t),Fe=t=>e=>typeof e===t,{isArray:Ue}=Array,Pe=Fe("undefined");function je(t){return null!==t&&!Pe(t)&&null!==t.constructor&&!Pe(t.constructor)&&Be(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const Ie=Ne("ArrayBuffer");const De=Fe("string"),Be=Fe("function"),qe=Fe("number"),Me=t=>null!==t&&"object"==typeof t,He=t=>{if("object"!==Le(t))return!1;const e=_e(t);return!(null!==e&&e!==Object.prototype&&null!==Object.getPrototypeOf(e)||Re in t||Oe in t)},$e=Ne("Date"),ze=Ne("File"),Ke=Ne("Blob"),Ge=Ne("FileList"),We=Ne("URLSearchParams"),[Ve,Je,Ye,Xe]=["ReadableStream","Request","Response","Headers"].map(Ne);function Qe(t,e,{allOwnKeys:n=!1}={}){if(null==t)return;let o,i;if("object"!=typeof t&&(t=[t]),Ue(t))for(o=0,i=t.length;o0;)if(o=n[i],e===o.toLowerCase())return o;return null}const tn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,en=t=>!Pe(t)&&t!==tn;const nn=(on="undefined"!=typeof Uint8Array&&_e(Uint8Array),t=>on&&t instanceof on);var on;const sn=Ne("HTMLFormElement"),rn=(({hasOwnProperty:t})=>(e,n)=>t.call(e,n))(Object.prototype),an=Ne("RegExp"),cn=(t,e)=>{const n=Object.getOwnPropertyDescriptors(t),o={};Qe(n,(n,i)=>{let s;!1!==(s=e(n,i,t))&&(o[i]=s||n)}),Object.defineProperties(t,o)};const un=Ne("AsyncFunction"),ln=(dn="function"==typeof setImmediate,hn=Be(tn.postMessage),dn?setImmediate:hn?(pn=`axios@${Math.random()}`,fn=[],tn.addEventListener("message",({source:t,data:e})=>{t===tn&&e===pn&&fn.length&&fn.shift()()},!1),t=>{fn.push(t),tn.postMessage(pn,"*")}):t=>setTimeout(t));var dn,hn,pn,fn;const mn="undefined"!=typeof queueMicrotask?queueMicrotask.bind(tn):"undefined"!=typeof process&&process.nextTick||ln;var gn={isArray:Ue,isArrayBuffer:Ie,isBuffer:je,isFormData:t=>{let e;return t&&("function"==typeof FormData&&t instanceof FormData||Be(t.append)&&("formdata"===(e=Le(t))||"object"===e&&Be(t.toString)&&"[object FormData]"===t.toString()))},isArrayBufferView:function(t){let e;return e="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&Ie(t.buffer),e},isString:De,isNumber:qe,isBoolean:t=>!0===t||!1===t,isObject:Me,isPlainObject:He,isEmptyObject:t=>{if(!Me(t)||je(t))return!1;try{return 0===Object.keys(t).length&&Object.getPrototypeOf(t)===Object.prototype}catch(t){return!1}},isReadableStream:Ve,isRequest:Je,isResponse:Ye,isHeaders:Xe,isUndefined:Pe,isDate:$e,isFile:ze,isBlob:Ke,isRegExp:an,isFunction:Be,isStream:t=>Me(t)&&Be(t.pipe),isURLSearchParams:We,isTypedArray:nn,isFileList:Ge,forEach:Qe,merge:function t(){const{caseless:e,skipUndefined:n}=en(this)&&this||{},o={},i=(i,s)=>{const r=e&&Ze(o,s)||s;He(o[r])&&He(i)?o[r]=t(o[r],i):He(i)?o[r]=t({},i):Ue(i)?o[r]=i.slice():n&&Pe(i)||(o[r]=i)};for(let t=0,e=arguments.length;t(Qe(e,(e,o)=>{n&&Be(e)?t[o]=Ae(e,n):t[o]=e},{allOwnKeys:o}),t),trim:t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:t=>(65279===t.charCodeAt(0)&&(t=t.slice(1)),t),inherits:(t,e,n,o)=>{t.prototype=Object.create(e.prototype,o),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),n&&Object.assign(t.prototype,n)},toFlatObject:(t,e,n,o)=>{let i,s,r;const a={};if(e=e||{},null==t)return e;do{for(i=Object.getOwnPropertyNames(t),s=i.length;s-- >0;)r=i[s],o&&!o(r,t,e)||a[r]||(e[r]=t[r],a[r]=!0);t=!1!==n&&_e(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e},kindOf:Le,kindOfTest:Ne,endsWith:(t,e,n)=>{t=String(t),(void 0===n||n>t.length)&&(n=t.length),n-=e.length;const o=t.indexOf(e,n);return-1!==o&&o===n},toArray:t=>{if(!t)return null;if(Ue(t))return t;let e=t.length;if(!qe(e))return null;const n=new Array(e);for(;e-- >0;)n[e]=t[e];return n},forEachEntry:(t,e)=>{const n=(t&&t[Oe]).call(t);let o;for(;(o=n.next())&&!o.done;){const n=o.value;e.call(t,n[0],n[1])}},matchAll:(t,e)=>{let n;const o=[];for(;null!==(n=t.exec(e));)o.push(n);return o},isHTMLForm:sn,hasOwnProperty:rn,hasOwnProp:rn,reduceDescriptors:cn,freezeMethods:t=>{cn(t,(e,n)=>{if(Be(t)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const o=t[n];Be(o)&&(e.enumerable=!1,"writable"in e?e.writable=!1:e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))})},toObjectSet:(t,e)=>{const n={},o=t=>{t.forEach(t=>{n[t]=!0})};return Ue(t)?o(t):o(String(t).split(e)),n},toCamelCase:t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,e,n){return e.toUpperCase()+n}),noop:()=>{},toFiniteNumber:(t,e)=>null!=t&&Number.isFinite(t=+t)?t:e,findKey:Ze,global:tn,isContextDefined:en,isSpecCompliantForm:function(t){return!!(t&&Be(t.append)&&"FormData"===t[Re]&&t[Oe])},toJSONObject:t=>{const e=new Array(10),n=(t,o)=>{if(Me(t)){if(e.indexOf(t)>=0)return;if(je(t))return t;if(!("toJSON"in t)){e[o]=t;const i=Ue(t)?[]:{};return Qe(t,(t,e)=>{const s=n(t,o+1);!Pe(s)&&(i[e]=s)}),e[o]=void 0,i}}return t};return n(t,0)},isAsyncFn:un,isThenable:t=>t&&(Me(t)||Be(t))&&Be(t.then)&&Be(t.catch),setImmediate:ln,asap:mn,isIterable:t=>null!=t&&Be(t[Oe])};function yn(t,e,n,o,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=t,this.name="AxiosError",e&&(this.code=e),n&&(this.config=n),o&&(this.request=o),i&&(this.response=i,this.status=i.status?i.status:null)}gn.inherits(yn,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:gn.toJSONObject(this.config),code:this.code,status:this.status}}});const vn=yn.prototype,bn={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{bn[t]={value:t}}),Object.defineProperties(yn,bn),Object.defineProperty(vn,"isAxiosError",{value:!0}),yn.from=(t,e,n,o,i,s)=>{const r=Object.create(vn);gn.toFlatObject(t,r,function(t){return t!==Error.prototype},t=>"isAxiosError"!==t);const a=t&&t.message?t.message:"Error",c=null==e&&t?t.code:e;return yn.call(r,a,c,n,o,i),t&&null==r.cause&&Object.defineProperty(r,"cause",{value:t,configurable:!0}),r.name=t&&t.name||"Error",s&&Object.assign(r,s),r};function En(t){return gn.isPlainObject(t)||gn.isArray(t)}function wn(t){return gn.endsWith(t,"[]")?t.slice(0,-2):t}function Cn(t,e,n){return t?t.concat(e).map(function(t,e){return t=wn(t),!n&&e?"["+t+"]":t}).join(n?".":""):e}const Sn=gn.toFlatObject(gn,{},null,function(t){return/^is[A-Z]/.test(t)});function xn(t,e,n){if(!gn.isObject(t))throw new TypeError("target must be an object");e=e||new FormData;const o=(n=gn.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(t,e){return!gn.isUndefined(e[t])})).metaTokens,i=n.visitor||u,s=n.dots,r=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&gn.isSpecCompliantForm(e);if(!gn.isFunction(i))throw new TypeError("visitor must be a function");function c(t){if(null===t)return"";if(gn.isDate(t))return t.toISOString();if(gn.isBoolean(t))return t.toString();if(!a&&gn.isBlob(t))throw new yn("Blob is not supported. Use a Buffer instead.");return gn.isArrayBuffer(t)||gn.isTypedArray(t)?a&&"function"==typeof Blob?new Blob([t]):Buffer.from(t):t}function u(t,n,i){let a=t;if(t&&!i&&"object"==typeof t)if(gn.endsWith(n,"{}"))n=o?n:n.slice(0,-2),t=JSON.stringify(t);else if(gn.isArray(t)&&function(t){return gn.isArray(t)&&!t.some(En)}(t)||(gn.isFileList(t)||gn.endsWith(n,"[]"))&&(a=gn.toArray(t)))return n=wn(n),a.forEach(function(t,o){!gn.isUndefined(t)&&null!==t&&e.append(!0===r?Cn([n],o,s):null===r?n:n+"[]",c(t))}),!1;return!!En(t)||(e.append(Cn(i,n,s),c(t)),!1)}const l=[],d=Object.assign(Sn,{defaultVisitor:u,convertValue:c,isVisitable:En});if(!gn.isObject(t))throw new TypeError("data must be an object");return function t(n,o){if(!gn.isUndefined(n)){if(-1!==l.indexOf(n))throw Error("Circular reference detected in "+o.join("."));l.push(n),gn.forEach(n,function(n,s){!0===(!(gn.isUndefined(n)||null===n)&&i.call(e,n,gn.isString(s)?s.trim():s,o,d))&&t(n,o?o.concat(s):[s])}),l.pop()}}(t),e}function An(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(t){return e[t]})}function Tn(t,e){this._pairs=[],t&&xn(t,this,e)}const _n=Tn.prototype;function On(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Rn(t,e,n){if(!e)return t;const o=n&&n.encode||On;gn.isFunction(n)&&(n={serialize:n});const i=n&&n.serialize;let s;if(s=i?i(e,n):gn.isURLSearchParams(e)?e.toString():new Tn(e,n).toString(o),s){const e=t.indexOf("#");-1!==e&&(t=t.slice(0,e)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t}_n.append=function(t,e){this._pairs.push([t,e])},_n.toString=function(t){const e=t?function(e){return t.call(this,e,An)}:An;return this._pairs.map(function(t){return e(t[0])+"="+e(t[1])},"").join("&")};class Ln{constructor(){this.handlers=[]}use(t,e,n){return this.handlers.push({fulfilled:t,rejected:e,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){gn.forEach(this.handlers,function(e){null!==e&&t(e)})}}var kn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Nn={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Tn,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const Fn="undefined"!=typeof window&&"undefined"!=typeof document,Un="object"==typeof navigator&&navigator||void 0,Pn=Fn&&(!Un||["ReactNative","NativeScript","NS"].indexOf(Un.product)<0),jn="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,In=Fn&&window.location.href||"http://localhost";var Dn={...Object.freeze({__proto__:null,hasBrowserEnv:Fn,hasStandardBrowserEnv:Pn,hasStandardBrowserWebWorkerEnv:jn,navigator:Un,origin:In}),...Nn};function Bn(t){function e(t,n,o,i){let s=t[i++];if("__proto__"===s)return!0;const r=Number.isFinite(+s),a=i>=t.length;if(s=!s&&gn.isArray(o)?o.length:s,a)return gn.hasOwnProp(o,s)?o[s]=[o[s],n]:o[s]=n,!r;o[s]&&gn.isObject(o[s])||(o[s]=[]);return e(t,n,o[s],i)&&gn.isArray(o[s])&&(o[s]=function(t){const e={},n=Object.keys(t);let o;const i=n.length;let s;for(o=0;o{e(function(t){return gn.matchAll(/\w+|\[(\w*)]/g,t).map(t=>"[]"===t[0]?"":t[1]||t[0])}(t),o,n,0)}),n}return null}const qn={transitional:kn,adapter:["xhr","http","fetch"],transformRequest:[function(t,e){const n=e.getContentType()||"",o=n.indexOf("application/json")>-1,i=gn.isObject(t);i&&gn.isHTMLForm(t)&&(t=new FormData(t));if(gn.isFormData(t))return o?JSON.stringify(Bn(t)):t;if(gn.isArrayBuffer(t)||gn.isBuffer(t)||gn.isStream(t)||gn.isFile(t)||gn.isBlob(t)||gn.isReadableStream(t))return t;if(gn.isArrayBufferView(t))return t.buffer;if(gn.isURLSearchParams(t))return e.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let s;if(i){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(t,e){return xn(t,new Dn.classes.URLSearchParams,{visitor:function(t,e,n,o){return Dn.isNode&&gn.isBuffer(t)?(this.append(e,t.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...e})}(t,this.formSerializer).toString();if((s=gn.isFileList(t))||n.indexOf("multipart/form-data")>-1){const e=this.env&&this.env.FormData;return xn(s?{"files[]":t}:t,e&&new e,this.formSerializer)}}return i||o?(e.setContentType("application/json",!1),function(t,e,n){if(gn.isString(t))try{return(e||JSON.parse)(t),gn.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(n||JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){const e=this.transitional||qn.transitional,n=e&&e.forcedJSONParsing,o="json"===this.responseType;if(gn.isResponse(t)||gn.isReadableStream(t))return t;if(t&&gn.isString(t)&&(n&&!this.responseType||o)){const n=!(e&&e.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(t){if(n){if("SyntaxError"===t.name)throw yn.from(t,yn.ERR_BAD_RESPONSE,this,null,this.response);throw t}}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Dn.classes.FormData,Blob:Dn.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};gn.forEach(["delete","get","head","post","put","patch"],t=>{qn.headers[t]={}});const Mn=gn.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const Hn=Symbol("internals");function $n(t){return t&&String(t).trim().toLowerCase()}function zn(t){return!1===t||null==t?t:gn.isArray(t)?t.map(zn):String(t)}function Kn(t,e,n,o,i){return gn.isFunction(o)?o.call(this,e,n):(i&&(e=n),gn.isString(e)?gn.isString(o)?-1!==e.indexOf(o):gn.isRegExp(o)?o.test(e):void 0:void 0)}let Gn=class{constructor(t){t&&this.set(t)}set(t,e,n){const o=this;function i(t,e,n){const i=$n(e);if(!i)throw new Error("header name must be a non-empty string");const s=gn.findKey(o,i);(!s||void 0===o[s]||!0===n||void 0===n&&!1!==o[s])&&(o[s||e]=zn(t))}const s=(t,e)=>gn.forEach(t,(t,n)=>i(t,n,e));if(gn.isPlainObject(t)||t instanceof this.constructor)s(t,e);else if(gn.isString(t)&&(t=t.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim()))s((t=>{const e={};let n,o,i;return t&&t.split("\n").forEach(function(t){i=t.indexOf(":"),n=t.substring(0,i).trim().toLowerCase(),o=t.substring(i+1).trim(),!n||e[n]&&Mn[n]||("set-cookie"===n?e[n]?e[n].push(o):e[n]=[o]:e[n]=e[n]?e[n]+", "+o:o)}),e})(t),e);else if(gn.isObject(t)&&gn.isIterable(t)){let n,o,i={};for(const e of t){if(!gn.isArray(e))throw TypeError("Object iterator must return a key-value pair");i[o=e[0]]=(n=i[o])?gn.isArray(n)?[...n,e[1]]:[n,e[1]]:e[1]}s(i,e)}else null!=t&&i(e,t,n);return this}get(t,e){if(t=$n(t)){const n=gn.findKey(this,t);if(n){const t=this[n];if(!e)return t;if(!0===e)return function(t){const e=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let o;for(;o=n.exec(t);)e[o[1]]=o[2];return e}(t);if(gn.isFunction(e))return e.call(this,t,n);if(gn.isRegExp(e))return e.exec(t);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,e){if(t=$n(t)){const n=gn.findKey(this,t);return!(!n||void 0===this[n]||e&&!Kn(0,this[n],n,e))}return!1}delete(t,e){const n=this;let o=!1;function i(t){if(t=$n(t)){const i=gn.findKey(n,t);!i||e&&!Kn(0,n[i],i,e)||(delete n[i],o=!0)}}return gn.isArray(t)?t.forEach(i):i(t),o}clear(t){const e=Object.keys(this);let n=e.length,o=!1;for(;n--;){const i=e[n];t&&!Kn(0,this[i],i,t,!0)||(delete this[i],o=!0)}return o}normalize(t){const e=this,n={};return gn.forEach(this,(o,i)=>{const s=gn.findKey(n,i);if(s)return e[s]=zn(o),void delete e[i];const r=t?function(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,e,n)=>e.toUpperCase()+n)}(i):String(i).trim();r!==i&&delete e[i],e[r]=zn(o),n[r]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const e=Object.create(null);return gn.forEach(this,(n,o)=>{null!=n&&!1!==n&&(e[o]=t&&gn.isArray(n)?n.join(", "):n)}),e}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,e])=>t+": "+e).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...e){const n=new this(t);return e.forEach(t=>n.set(t)),n}static accessor(t){const e=(this[Hn]=this[Hn]={accessors:{}}).accessors,n=this.prototype;function o(t){const o=$n(t);e[o]||(!function(t,e){const n=gn.toCamelCase(" "+e);["get","set","has"].forEach(o=>{Object.defineProperty(t,o+n,{value:function(t,n,i){return this[o].call(this,e,t,n,i)},configurable:!0})})}(n,t),e[o]=!0)}return gn.isArray(t)?t.forEach(o):o(t),this}};function Wn(t,e){const n=this||qn,o=e||n,i=Gn.from(o.headers);let s=o.data;return gn.forEach(t,function(t){s=t.call(n,s,i.normalize(),e?e.status:void 0)}),i.normalize(),s}function Vn(t){return!(!t||!t.__CANCEL__)}function Jn(t,e,n){yn.call(this,null==t?"canceled":t,yn.ERR_CANCELED,e,n),this.name="CanceledError"}function Yn(t,e,n){const o=n.config.validateStatus;n.status&&o&&!o(n.status)?e(new yn("Request failed with status code "+n.status,[yn.ERR_BAD_REQUEST,yn.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):t(n)}Gn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),gn.reduceDescriptors(Gn.prototype,({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(t){this[n]=t}}}),gn.freezeMethods(Gn),gn.inherits(Jn,yn,{__CANCEL__:!0});const Xn=(t,e,n=3)=>{let o=0;const i=function(t,e){t=t||10;const n=new Array(t),o=new Array(t);let i,s=0,r=0;return e=void 0!==e?e:1e3,function(a){const c=Date.now(),u=o[r];i||(i=c),n[s]=a,o[s]=c;let l=r,d=0;for(;l!==s;)d+=n[l++],l%=t;if(s=(s+1)%t,s===r&&(r=(r+1)%t),c-i{i=s,n=null,o&&(clearTimeout(o),o=null),t(...e)};return[(...t)=>{const e=Date.now(),a=e-i;a>=s?r(t,e):(n=t,o||(o=setTimeout(()=>{o=null,r(n)},s-a)))},()=>n&&r(n)]}(n=>{const s=n.loaded,r=n.lengthComputable?n.total:void 0,a=s-o,c=i(a);o=s;t({loaded:s,total:r,progress:r?s/r:void 0,bytes:a,rate:c||void 0,estimated:c&&r&&s<=r?(r-s)/c:void 0,event:n,lengthComputable:null!=r,[e?"download":"upload"]:!0})},n)},Qn=(t,e)=>{const n=null!=t;return[o=>e[0]({lengthComputable:n,total:t,loaded:o}),e[1]]},Zn=t=>(...e)=>gn.asap(()=>t(...e));var to=Dn.hasStandardBrowserEnv?((t,e)=>n=>(n=new URL(n,Dn.origin),t.protocol===n.protocol&&t.host===n.host&&(e||t.port===n.port)))(new URL(Dn.origin),Dn.navigator&&/(msie|trident)/i.test(Dn.navigator.userAgent)):()=>!0,eo=Dn.hasStandardBrowserEnv?{write(t,e,n,o,i,s){const r=[t+"="+encodeURIComponent(e)];gn.isNumber(n)&&r.push("expires="+new Date(n).toGMTString()),gn.isString(o)&&r.push("path="+o),gn.isString(i)&&r.push("domain="+i),!0===s&&r.push("secure"),document.cookie=r.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function no(t,e,n){let o=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e);return t&&(o||0==n)?function(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}(t,e):e}const oo=t=>t instanceof Gn?{...t}:t;function io(t,e){e=e||{};const n={};function o(t,e,n,o){return gn.isPlainObject(t)&&gn.isPlainObject(e)?gn.merge.call({caseless:o},t,e):gn.isPlainObject(e)?gn.merge({},e):gn.isArray(e)?e.slice():e}function i(t,e,n,i){return gn.isUndefined(e)?gn.isUndefined(t)?void 0:o(void 0,t,0,i):o(t,e,0,i)}function s(t,e){if(!gn.isUndefined(e))return o(void 0,e)}function r(t,e){return gn.isUndefined(e)?gn.isUndefined(t)?void 0:o(void 0,t):o(void 0,e)}function a(n,i,s){return s in e?o(n,i):s in t?o(void 0,n):void 0}const c={url:s,method:s,data:s,baseURL:r,transformRequest:r,transformResponse:r,paramsSerializer:r,timeout:r,timeoutMessage:r,withCredentials:r,withXSRFToken:r,adapter:r,responseType:r,xsrfCookieName:r,xsrfHeaderName:r,onUploadProgress:r,onDownloadProgress:r,decompress:r,maxContentLength:r,maxBodyLength:r,beforeRedirect:r,transport:r,httpAgent:r,httpsAgent:r,cancelToken:r,socketPath:r,responseEncoding:r,validateStatus:a,headers:(t,e,n)=>i(oo(t),oo(e),0,!0)};return gn.forEach(Object.keys({...t,...e}),function(o){const s=c[o]||i,r=s(t[o],e[o],o);gn.isUndefined(r)&&s!==a||(n[o]=r)}),n}var so=t=>{const e=io({},t);let{data:n,withXSRFToken:o,xsrfHeaderName:i,xsrfCookieName:s,headers:r,auth:a}=e;if(e.headers=r=Gn.from(r),e.url=Rn(no(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),a&&r.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),gn.isFormData(n))if(Dn.hasStandardBrowserEnv||Dn.hasStandardBrowserWebWorkerEnv)r.setContentType(void 0);else if(gn.isFunction(n.getHeaders)){const t=n.getHeaders(),e=["content-type","content-length"];Object.entries(t).forEach(([t,n])=>{e.includes(t.toLowerCase())&&r.set(t,n)})}if(Dn.hasStandardBrowserEnv&&(o&&gn.isFunction(o)&&(o=o(e)),o||!1!==o&&to(e.url))){const t=i&&s&&eo.read(s);t&&r.set(i,t)}return e};var ro="undefined"!=typeof XMLHttpRequest&&function(t){return new Promise(function(e,n){const o=so(t);let i=o.data;const s=Gn.from(o.headers).normalize();let r,a,c,u,l,{responseType:d,onUploadProgress:h,onDownloadProgress:p}=o;function f(){u&&u(),l&&l(),o.cancelToken&&o.cancelToken.unsubscribe(r),o.signal&&o.signal.removeEventListener("abort",r)}let m=new XMLHttpRequest;function g(){if(!m)return;const o=Gn.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());Yn(function(t){e(t),f()},function(t){n(t),f()},{data:d&&"text"!==d&&"json"!==d?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:o,config:t,request:m}),m=null}m.open(o.method.toUpperCase(),o.url,!0),m.timeout=o.timeout,"onloadend"in m?m.onloadend=g:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(g)},m.onabort=function(){m&&(n(new yn("Request aborted",yn.ECONNABORTED,t,m)),m=null)},m.onerror=function(e){const o=new yn(e&&e.message?e.message:"Network Error",yn.ERR_NETWORK,t,m);o.event=e||null,n(o),m=null},m.ontimeout=function(){let e=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const i=o.transitional||kn;o.timeoutErrorMessage&&(e=o.timeoutErrorMessage),n(new yn(e,i.clarifyTimeoutError?yn.ETIMEDOUT:yn.ECONNABORTED,t,m)),m=null},void 0===i&&s.setContentType(null),"setRequestHeader"in m&&gn.forEach(s.toJSON(),function(t,e){m.setRequestHeader(e,t)}),gn.isUndefined(o.withCredentials)||(m.withCredentials=!!o.withCredentials),d&&"json"!==d&&(m.responseType=o.responseType),p&&([c,l]=Xn(p,!0),m.addEventListener("progress",c)),h&&m.upload&&([a,u]=Xn(h),m.upload.addEventListener("progress",a),m.upload.addEventListener("loadend",u)),(o.cancelToken||o.signal)&&(r=e=>{m&&(n(!e||e.type?new Jn(null,t,m):e),m.abort(),m=null)},o.cancelToken&&o.cancelToken.subscribe(r),o.signal&&(o.signal.aborted?r():o.signal.addEventListener("abort",r)));const y=function(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}(o.url);y&&-1===Dn.protocols.indexOf(y)?n(new yn("Unsupported protocol "+y+":",yn.ERR_BAD_REQUEST,t)):m.send(i||null)})};const ao=(t,e)=>{const{length:n}=t=t?t.filter(Boolean):[];if(e||n){let n,o=new AbortController;const i=function(t){if(!n){n=!0,r();const e=t instanceof Error?t:this.reason;o.abort(e instanceof yn?e:new Jn(e instanceof Error?e.message:e))}};let s=e&&setTimeout(()=>{s=null,i(new yn(`timeout ${e} of ms exceeded`,yn.ETIMEDOUT))},e);const r=()=>{t&&(s&&clearTimeout(s),s=null,t.forEach(t=>{t.unsubscribe?t.unsubscribe(i):t.removeEventListener("abort",i)}),t=null)};t.forEach(t=>t.addEventListener("abort",i));const{signal:a}=o;return a.unsubscribe=()=>gn.asap(r),a}},co=function*(t,e){let n=t.byteLength;if(n{const i=async function*(t,e){for await(const n of uo(t))yield*co(n,e)}(t,e);let s,r=0,a=t=>{s||(s=!0,o&&o(t))};return new ReadableStream({async pull(t){try{const{done:e,value:o}=await i.next();if(e)return a(),void t.close();let s=o.byteLength;if(n){let t=r+=s;n(t)}t.enqueue(new Uint8Array(o))}catch(t){throw a(t),t}},cancel:t=>(a(t),i.return())},{highWaterMark:2})},{isFunction:ho}=gn,po=(({Request:t,Response:e})=>({Request:t,Response:e}))(gn.global),{ReadableStream:fo,TextEncoder:mo}=gn.global,go=(t,...e)=>{try{return!!t(...e)}catch(t){return!1}},yo=t=>{t=gn.merge.call({skipUndefined:!0},po,t);const{fetch:e,Request:n,Response:o}=t,i=e?ho(e):"function"==typeof fetch,s=ho(n),r=ho(o);if(!i)return!1;const a=i&&ho(fo),c=i&&("function"==typeof mo?(u=new mo,t=>u.encode(t)):async t=>new Uint8Array(await new n(t).arrayBuffer()));var u;const l=s&&a&&go(()=>{let t=!1;const e=new n(Dn.origin,{body:new fo,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e}),d=r&&a&&go(()=>gn.isReadableStream(new o("").body)),h={stream:d&&(t=>t.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!h[t]&&(h[t]=(e,n)=>{let o=e&&e[t];if(o)return o.call(e);throw new yn(`Response type '${t}' is not supported`,yn.ERR_NOT_SUPPORT,n)})});const p=async(t,e)=>{const o=gn.toFiniteNumber(t.getContentLength());return null==o?(async t=>{if(null==t)return 0;if(gn.isBlob(t))return t.size;if(gn.isSpecCompliantForm(t)){const e=new n(Dn.origin,{method:"POST",body:t});return(await e.arrayBuffer()).byteLength}return gn.isArrayBufferView(t)||gn.isArrayBuffer(t)?t.byteLength:(gn.isURLSearchParams(t)&&(t+=""),gn.isString(t)?(await c(t)).byteLength:void 0)})(e):o};return async t=>{let{url:i,method:r,data:a,signal:c,cancelToken:u,timeout:f,onDownloadProgress:m,onUploadProgress:g,responseType:y,headers:v,withCredentials:b="same-origin",fetchOptions:E}=so(t),w=e||fetch;y=y?(y+"").toLowerCase():"text";let C=ao([c,u&&u.toAbortSignal()],f),S=null;const x=C&&C.unsubscribe&&(()=>{C.unsubscribe()});let A;try{if(g&&l&&"get"!==r&&"head"!==r&&0!==(A=await p(v,a))){let t,e=new n(i,{method:"POST",body:a,duplex:"half"});if(gn.isFormData(a)&&(t=e.headers.get("content-type"))&&v.setContentType(t),e.body){const[t,n]=Qn(A,Xn(Zn(g)));a=lo(e.body,65536,t,n)}}gn.isString(b)||(b=b?"include":"omit");const e=s&&"credentials"in n.prototype,c={...E,signal:C,method:r.toUpperCase(),headers:v.normalize().toJSON(),body:a,duplex:"half",credentials:e?b:void 0};S=s&&new n(i,c);let u=await(s?w(S,E):w(i,c));const f=d&&("stream"===y||"response"===y);if(d&&(m||f&&x)){const t={};["status","statusText","headers"].forEach(e=>{t[e]=u[e]});const e=gn.toFiniteNumber(u.headers.get("content-length")),[n,i]=m&&Qn(e,Xn(Zn(m),!0))||[];u=new o(lo(u.body,65536,n,()=>{i&&i(),x&&x()}),t)}y=y||"text";let T=await h[gn.findKey(h,y)||"text"](u,t);return!f&&x&&x(),await new Promise((e,n)=>{Yn(e,n,{data:T,headers:Gn.from(u.headers),status:u.status,statusText:u.statusText,config:t,request:S})})}catch(e){if(x&&x(),e&&"TypeError"===e.name&&/Load failed|fetch/i.test(e.message))throw Object.assign(new yn("Network Error",yn.ERR_NETWORK,t,S),{cause:e.cause||e});throw yn.from(e,e&&e.code,t,S)}}},vo=new Map,bo=t=>{let e=t?t.env:{};const{fetch:n,Request:o,Response:i}=e,s=[o,i,n];let r,a,c=s.length,u=vo;for(;c--;)r=s[c],a=u.get(r),void 0===a&&u.set(r,a=c?new Map:yo(e)),u=a;return a};bo();const Eo={http:null,xhr:ro,fetch:{get:bo}};gn.forEach(Eo,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch(t){}Object.defineProperty(t,"adapterName",{value:e})}});const wo=t=>`- ${t}`,Co=t=>gn.isFunction(t)||null===t||!1===t;var So=(t,e)=>{t=gn.isArray(t)?t:[t];const{length:n}=t;let o,i;const s={};for(let r=0;r`adapter ${t} `+(!1===e?"is not supported by the environment":"is not available in the build"));throw new yn("There is no suitable adapter to dispatch the request "+(n?t.length>1?"since :\n"+t.map(wo).join("\n"):" "+wo(t[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return i};function xo(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Jn(null,t)}function Ao(t){xo(t),t.headers=Gn.from(t.headers),t.data=Wn.call(t,t.transformRequest),-1!==["post","put","patch"].indexOf(t.method)&&t.headers.setContentType("application/x-www-form-urlencoded",!1);return So(t.adapter||qn.adapter,t)(t).then(function(e){return xo(t),e.data=Wn.call(t,t.transformResponse,e),e.headers=Gn.from(e.headers),e},function(e){return Vn(e)||(xo(t),e&&e.response&&(e.response.data=Wn.call(t,t.transformResponse,e.response),e.response.headers=Gn.from(e.response.headers))),Promise.reject(e)})}const To="1.12.2",_o={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{_o[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});const Oo={};_o.transitional=function(t,e,n){function o(t,e){return"[Axios v"+To+"] Transitional option '"+t+"'"+e+(n?". "+n:"")}return(n,i,s)=>{if(!1===t)throw new yn(o(i," has been removed"+(e?" in "+e:"")),yn.ERR_DEPRECATED);return e&&!Oo[i]&&(Oo[i]=!0,console.warn(o(i," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(n,i,s)}},_o.spelling=function(t){return(e,n)=>(console.warn(`${n} is likely a misspelling of ${t}`),!0)};var Ro={assertOptions:function(t,e,n){if("object"!=typeof t)throw new yn("options must be an object",yn.ERR_BAD_OPTION_VALUE);const o=Object.keys(t);let i=o.length;for(;i-- >0;){const s=o[i],r=e[s];if(r){const e=t[s],n=void 0===e||r(e,s,t);if(!0!==n)throw new yn("option "+s+" must be "+n,yn.ERR_BAD_OPTION_VALUE);continue}if(!0!==n)throw new yn("Unknown option "+s,yn.ERR_BAD_OPTION)}},validators:_o};const Lo=Ro.validators;let ko=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Ln,response:new Ln}}async request(t,e){try{return await this._request(t,e)}catch(t){if(t instanceof Error){let e={};Error.captureStackTrace?Error.captureStackTrace(e):e=new Error;const n=e.stack?e.stack.replace(/^.+\n/,""):"";try{t.stack?n&&!String(t.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(t.stack+="\n"+n):t.stack=n}catch(t){}}throw t}}_request(t,e){"string"==typeof t?(e=e||{}).url=t:e=t||{},e=io(this.defaults,e);const{transitional:n,paramsSerializer:o,headers:i}=e;void 0!==n&&Ro.assertOptions(n,{silentJSONParsing:Lo.transitional(Lo.boolean),forcedJSONParsing:Lo.transitional(Lo.boolean),clarifyTimeoutError:Lo.transitional(Lo.boolean)},!1),null!=o&&(gn.isFunction(o)?e.paramsSerializer={serialize:o}:Ro.assertOptions(o,{encode:Lo.function,serialize:Lo.function},!0)),void 0!==e.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?e.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:e.allowAbsoluteUrls=!0),Ro.assertOptions(e,{baseUrl:Lo.spelling("baseURL"),withXsrfToken:Lo.spelling("withXSRFToken")},!0),e.method=(e.method||this.defaults.method||"get").toLowerCase();let s=i&&gn.merge(i.common,i[e.method]);i&&gn.forEach(["delete","get","head","post","put","patch","common"],t=>{delete i[t]}),e.headers=Gn.concat(s,i);const r=[];let a=!0;this.interceptors.request.forEach(function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(a=a&&t.synchronous,r.unshift(t.fulfilled,t.rejected))});const c=[];let u;this.interceptors.response.forEach(function(t){c.push(t.fulfilled,t.rejected)});let l,d=0;if(!a){const t=[Ao.bind(this),void 0];for(t.unshift(...r),t.push(...c),l=t.length,u=Promise.resolve(e);d{No[e]=t});const Fo=function t(e){const n=new ko(e),o=Ae(ko.prototype.request,n);return gn.extend(o,ko.prototype,n,{allOwnKeys:!0}),gn.extend(o,n,null,{allOwnKeys:!0}),o.create=function(n){return t(io(e,n))},o}(qn);Fo.Axios=ko,Fo.CanceledError=Jn,Fo.CancelToken=class t{constructor(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");let e;this.promise=new Promise(function(t){e=t});const n=this;this.promise.then(t=>{if(!n._listeners)return;let e=n._listeners.length;for(;e-- >0;)n._listeners[e](t);n._listeners=null}),this.promise.then=t=>{let e;const o=new Promise(t=>{n.subscribe(t),e=t}).then(t);return o.cancel=function(){n.unsubscribe(e)},o},t(function(t,o,i){n.reason||(n.reason=new Jn(t,o,i),e(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){this.reason?t(this.reason):this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);-1!==e&&this._listeners.splice(e,1)}toAbortSignal(){const t=new AbortController,e=e=>{t.abort(e)};return this.subscribe(e),t.signal.unsubscribe=()=>this.unsubscribe(e),t.signal}static source(){let e;const n=new t(function(t){e=t});return{token:n,cancel:e}}},Fo.isCancel=Vn,Fo.VERSION=To,Fo.toFormData=xn,Fo.AxiosError=yn,Fo.Cancel=Fo.CanceledError,Fo.all=function(t){return Promise.all(t)},Fo.spread=function(t){return function(e){return t.apply(null,e)}},Fo.isAxiosError=function(t){return gn.isObject(t)&&!0===t.isAxiosError},Fo.mergeConfig=io,Fo.AxiosHeaders=Gn,Fo.formToJSON=t=>Bn(gn.isHTMLForm(t)?new FormData(t):t),Fo.getAdapter=So,Fo.HttpStatusCode=No,Fo.default=Fo;const{Axios:Uo,AxiosError:Po,CanceledError:jo,isCancel:Io,CancelToken:Do,VERSION:Bo,all:qo,Cancel:Mo,isAxiosError:Ho,spread:$o,toFormData:zo,AxiosHeaders:Ko,HttpStatusCode:Go,formToJSON:Wo,getAdapter:Vo,mergeConfig:Jo}=Fo,{IdealPostcodesError:Yo}=be,Xo=(t,e)=>{return{httpRequest:t,body:e.data,httpStatus:e.status||0,header:(n=e.headers,Object.keys(n).reduce((t,e)=>{const o=n[e];return"string"==typeof o?t[e]=o:Array.isArray(o)&&(t[e]=o.join(",")),t},{})),metadata:{response:e}};var n},Qo=t=>{const e=new Yo({message:`[${t.name}] ${t.message}`,httpStatus:0,metadata:{axios:t}});return Promise.reject(e)},Zo=()=>!0;class ti{constructor(){this.Axios=Fo.create({validateStatus:Zo})}requestWithBody(t){const{body:e,method:n,timeout:o,url:i,header:s,query:r}=t;return this.Axios.request({url:i,method:n,headers:s,params:r,data:e,timeout:o}).then(e=>Xo(t,e)).catch(Qo)}request(t){const{method:e,timeout:n,url:o,header:i,query:s}=t;return this.Axios.request({url:o,method:e,headers:i,params:s,timeout:n}).then(e=>Xo(t,e)).catch(Qo)}http(t){return void 0!==t.body?this.requestWithBody(t):this.request(t)}}class ei extends Gt{constructor(t){super({agent:new ti,...t})}}class ni{constructor(t){this.prefix="!",this.client=t,this.cache={}}key(t){return`${this.prefix}${t.toLowerCase()}`}retrieve(t){return this.cache[this.key(t)]}store(t,e){return this.cache[this.key(t)]=e,e}clear(){this.cache={}}query(t,e={}){const n=this.retrieve(t);if(n)return Promise.resolve(n);const o=(i=this.client,s={query:{query:t,api_key:this.client.config.api_key,...e}},Ce({resource:xe,client:i})(s)).then(e=>{const n=e.body.result.hits;return this.store(t,n),n});var i,s;return this.store(t,o),o}resolve(t,e,n={}){return"usa"===e?this.usaResolve(t,n):this.gbrResolve(t,n)}usaResolve(t,e={}){return(n=this.client,o=t.id,i={query:{api_key:this.client.config.api_key,...e}},we({resource:xe,client:n,action:"usa"})(o,i)).then(t=>t.body.result);var n,o,i}gbrResolve(t,e={}){return(n=this.client,o=t.id,i={query:{api_key:this.client.config.api_key,...e}},we({resource:xe,client:n,action:"gbr"})(o,i)).then(t=>t.body.result);var n,o,i}}function oi(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var o,i,s=n.call(t),r=[];try{for(;(void 0===e||e-- >0)&&!(o=s.next()).done;)r.push(o.value)}catch(t){i={error:t}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return r}var ii;!function(t){t[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped"}(ii||(ii={}));var si={type:"xstate.init"};function ri(t){return void 0===t?[]:[].concat(t)}function ai(t,e){return"string"==typeof(t="string"==typeof t&&e&&e[t]?e[t]:t)?{type:t}:"function"==typeof t?{type:t.name,exec:t}:t}function ci(t){return function(e){return t===e}}function ui(t){return"string"==typeof t?{type:t}:t}function li(t,e){return{value:t,context:e,actions:[],changed:!1,matches:ci(t)}}function di(t,e,n){var o=e,i=!1;return[t.filter(function(t){if("xstate.assign"===t.type){i=!0;var e=Object.assign({},o);return"function"==typeof t.assignment?e=t.assignment(o,n):Object.keys(t.assignment).forEach(function(i){e[i]="function"==typeof t.assignment[i]?t.assignment[i](o,n):t.assignment[i]}),o=e,!1}return!0}),o,i]}function hi(t,e){void 0===e&&(e={});var n=oi(di(ri(t.states[t.initial].entry).map(function(t){return ai(t,e.actions)}),t.context,si),2),o=n[0],i=n[1],s={config:t,_options:e,initialState:{value:t.initial,actions:o,context:i,matches:ci(t.initial)},transition:function(e,n){var o,i,r="string"==typeof e?{value:e,context:t.context}:e,a=r.value,c=r.context,u=ui(n),l=t.states[a];if(l.on){var d=ri(l.on[u.type]);"*"in l.on&&d.push.apply(d,function(t,e,n){if(2===arguments.length)for(var o,i=0,s=e.length;i=t.length&&(t=void 0),{value:t&&t[o++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(d),p=h.next();!p.done;p=h.next()){var f=p.value;if(void 0===f)return li(a,c);var m="string"==typeof f?{target:f}:f,g=m.target,y=m.actions,v=void 0===y?[]:y,b=m.cond,E=void 0===b?function(){return!0}:b,w=void 0===g,C=null!=g?g:a,S=t.states[C];if(E(c,u)){var x=oi(di((w?ri(v):[].concat(l.exit,v,S.entry).filter(function(t){return t})).map(function(t){return ai(t,s._options.actions)}),c,u),3),A=x[0],T=x[1],_=x[2],O=null!=g?g:a;return{value:O,context:T,actions:A,changed:g!==a||A.length>0||_,matches:ci(O)}}}}catch(t){o={error:t}}finally{try{p&&!p.done&&(i=h.return)&&i.call(h)}finally{if(o)throw o.error}}}return li(a,c)}};return s}var pi=function(t,e){return t.actions.forEach(function(n){var o=n.exec;return o&&o(t.context,e)})};const fi=({c:t})=>{const e=hi({initial:"closed",states:{closed:{entry:["close"],exit:["open"],on:{COUNTRY_CHANGE_EVENT:{actions:["updateContextWithCountry"]},AWAKE:[{target:"suggesting",cond:()=>t.suggestions.length>0},{target:"notifying"}]}},notifying:{entry:["renderNotice"],exit:["clearAnnouncement"],on:{CLOSE:"closed",SUGGEST:{target:"suggesting",actions:["updateSuggestions"]},NOTIFY:{target:"notifying",actions:["updateMessage"]},INPUT:{actions:"input"},CHANGE_COUNTRY:{target:"suggesting_country"}}},suggesting_country:{entry:["clearInput","renderContexts","gotoCurrent","expand","addCountryHint"],exit:["resetCurrent","gotoCurrent","contract","clearHint","clearInput"],on:{CLOSE:"closed",NOTIFY:{target:"notifying",actions:["updateMessage"]},NEXT:{actions:["next","gotoCurrent"]},PREVIOUS:{actions:["previous","gotoCurrent"]},RESET:{actions:["resetCurrent","gotoCurrent"]},INPUT:{actions:["countryInput"]},SELECT_COUNTRY:{target:"notifying",actions:["selectCountry"]}}},suggesting:{entry:["renderSuggestions","gotoCurrent","expand","addHint"],exit:["resetCurrent","gotoCurrent","contract","clearHint"],on:{CLOSE:"closed",SUGGEST:{target:"suggesting",actions:["updateSuggestions"]},NOTIFY:{target:"notifying",actions:["updateMessage"]},INPUT:{actions:"input"},CHANGE_COUNTRY:{target:"suggesting_country"},NEXT:{actions:["next","gotoCurrent"]},PREVIOUS:{actions:["previous","gotoCurrent"]},RESET:{actions:["resetCurrent","gotoCurrent"]},SELECT_ADDRESS:{target:"closed",actions:["selectAddress"]}}}}},{actions:{updateContextWithCountry:(e,n)=>{"COUNTRY_CHANGE_EVENT"===n.type&&n.contextDetails&&(t.applyContext(n.contextDetails),t.suggestions=[],t.cache.clear())},addHint:()=>{t.setPlaceholder(t.options.msgPlaceholder)},addCountryHint:()=>{t.setPlaceholder(t.options.msgPlaceholderCountry)},clearHint:()=>{t.unsetPlaceholder()},clearInput:()=>{t.clearInput()},gotoCurrent:()=>{t.goToCurrent()},resetCurrent:()=>{t.current=-1},input:(e,n)=>{"INPUT"===n.type&&t.retrieveSuggestions(n.event)},countryInput:()=>{t.renderContexts()},clearAnnouncement:()=>{t.announce("")},renderContexts:(e,n)=>{"CHANGE_COUNTRY"===n.type&&t.renderContexts()},renderSuggestions:(e,n)=>{"SUGGEST"===n.type&&t.renderSuggestions()},updateSuggestions:(e,n)=>{"SUGGEST"===n.type&&t.updateSuggestions(n.suggestions)},close:(e,n)=>{if("CLOSE"===n.type)return t.close(n.reason);t.close()},open:()=>{t.open()},expand:()=>{t.ariaExpand()},contract:()=>{t.ariaContract()},updateMessage:(e,n)=>{"NOTIFY"===n.type&&(t.notification=n.notification)},renderNotice:()=>{t.renderNotice()},next:()=>{t.next()},previous:()=>{t.previous()},selectCountry:(e,n)=>{if("SELECT_COUNTRY"!==n.type)return;const o=n.contextDetails;o&&(t.applyContext(o),t.notification=`Country switched to ${o.description} ${o.emoji}`)},selectAddress:(e,n)=>{if("SELECT_ADDRESS"!==n.type)return;const o=n.suggestion;o&&t.applySuggestion(o)}}});return function(t){var e=t.initialState,n=ii.NotStarted,o=new Set,i={_machine:t,send:function(i){n===ii.Running&&(e=t.transition(e,i),pi(e,ui(i)),o.forEach(function(t){return t(e)}))},subscribe:function(t){return o.add(t),t(e),{unsubscribe:function(){return o.delete(t)}}},start:function(o){if(o){var s="object"==typeof o?o:{context:t.config.context,value:o};e={value:s.value,actions:[],context:s.context,matches:ci(s.value)}}else e=t.initialState;return n=ii.Running,pi(e,si),i},stop:function(){return n=ii.Stopped,o.clear(),i},get state(){return e},get status(){return n}};return i}(e)},mi=()=>{},gi={outputScope:null,apiKey:"",checkKey:!0,aria:"1.0",titleizePostTown:!0,format:"gbr",outputFields:{},names:{},labels:{},removeOrganisation:!1,injectStyle:!0,inputField:"",autocomplete:"none",populateCounty:!0,populateOrganisation:!0,queryOptions:{},resolveOptions:{},alignToInput:!0,offset:2,hideToolbar:!1,detectCountry:!0,defaultCountry:"GBR",restrictCountries:[],contexts:{GBR:{iso_2:"GB",iso_3:"GBR",emoji:"πŸ‡¬πŸ‡§",rgeo:!0,description:"United Kingdom"},USA:{iso_2:"US",iso_3:"USA",emoji:"πŸ‡ΊπŸ‡Έ",rgeo:!1,description:"United States"}},msgFallback:"Please enter your address manually",msgInitial:"Start typing to find address",msgNoMatch:"No matches found",msgList:"Select your address",msgCountryToggle:"Change Country",msgPlaceholder:"Type the first line or postal code of your address",msgPlaceholderCountry:"Select your country",messageClass:"idpc_error",containerClass:"idpc_autocomplete",mainClass:"idpc_af",listClass:"idpc_ul",toolbarClass:"idpc_toolbar",countryToggleClass:"idpc_country",mainStyle:{},inputStyle:{},listStyle:{},liStyle:{},containerStyle:{},unhide:null,unhideClass:"idpc-unhide",msgUnhide:"Enter address manually",hide:[],fixed:!1,onOpen:mi,onSelect:mi,onBlur:mi,onClose:mi,onFocus:mi,onInput:mi,onLoaded:mi,onSearchError:mi,onSuggestionError:mi,onMounted:mi,onRemove:mi,onSuggestionsRetrieved:mi,onAddressSelected:mi,onAddressRetrieved:mi,onAddressPopulated:mi,onFailedCheck:mi,onMouseDown:mi,onKeyDown:mi,onUnhide:mi,onCountrySelected:mi,onContextChange:mi};let yi=class{constructor(e){let n;if(this.options={scope:window.document,document:window.document,...gi,...e},e.inputField||(this.options.inputField=this.options.outputFields.line_1||""),!0===this.options.autocomplete&&(this.options.autocomplete=gi.autocomplete),this.scope=l(this.options.scope),this.document=d(this.scope),this.outputScope=xi(this.scope,this.options.outputScope,()=>this.scope),this.context=this.options.defaultCountry,this.notification=this.options.msgInitial,this.current=-1,this.suggestions=[],this.contextSuggestions=[],this.updateContexts(this.options.contexts),this.client=new ei({...this.options,api_key:this.options.apiKey}),this.cache=new ni(this.client),this.retrieveSuggestions=Ht(t=>{this.options.onInput.call(this,t);const e=this.query();return 0===e.trim().length?(this.setMessage(this.options.msgInitial),Promise.resolve(this)):this.cache.query(e,{...this.options.queryOptions,context:this.context}).then(t=>(this.options.onSuggestionsRetrieved.call(this,t),this.setSuggestions(t,e))).catch(t=>(this.query()===e&&this.setMessage(this.options.msgFallback),this.options.onSuggestionError.call(this,t),this))},100,{leading:!0,trailing:!0,maxWait:100}),this.ids=((t="idpc_")=>()=>{const e=P();return e.idGen||(e.idGen={}),void 0===e.idGen[t]&&(e.idGen[t]=0),e.idGen[t]+=1,`${t}${e.idGen[t]}`})("idpcaf"),this.container=this.options.document.createElement("div"),this.container.className=this.options.containerClass,this.container.id=this.ids(),this.container.setAttribute("aria-haspopup","listbox"),this.message=this.options.document.createElement("li"),this.message.textContent=this.options.msgInitial,this.message.className=this.options.messageClass,this.countryToggle=this.options.document.createElement("span"),this.countryToggle.className=this.options.countryToggleClass,this.countryToggle.addEventListener("mousedown",wi(this)),this.countryIcon=this.options.document.createElement("span"),this.countryIcon.className="idpc_icon",this.countryIcon.innerText=this.currentContext().emoji,this.countryMessage=this.options.document.createElement("span"),this.countryMessage.innerText="Select Country",this.countryMessage.className="idpc_country",this.countryToggle.appendChild(this.countryMessage),this.countryToggle.appendChild(this.countryIcon),this.toolbar=this.options.document.createElement("div"),this.toolbar.className=this.options.toolbarClass,this.toolbar.appendChild(this.countryToggle),this.options.hideToolbar&&f(this.toolbar),this.list=this.options.document.createElement("ul"),this.list.className=this.options.listClass,this.list.id=this.ids(),this.list.setAttribute("aria-label",this.options.msgList),this.list.setAttribute("role","listbox"),this.mainComponent=this.options.document.createElement("div"),this.mainComponent.appendChild(this.list),this.mainComponent.appendChild(this.toolbar),this.mainComponent.className=this.options.mainClass,f(this.mainComponent),this.unhideEvent=this.unhideFields.bind(this),this.unhide=this.createUnhide(),n=t(this.options.inputField)?this.scope.querySelector(this.options.inputField):this.options.inputField,!n)throw new Error("Address Finder: Unable to find valid input field");this.input=n,this.input.setAttribute("autocomplete",this.options.autocomplete),this.input.setAttribute("aria-autocomplete","list"),this.input.setAttribute("aria-controls",this.list.id),this.input.setAttribute("aria-autocomplete","list"),this.input.setAttribute("aria-activedescendant",""),this.input.setAttribute("autocorrect","off"),this.input.setAttribute("autocapitalize","off"),this.input.setAttribute("spellcheck","false"),this.input.id||(this.input.id=this.ids());const o=this.scope.querySelector(this.options.outputFields.country);this.countryInput=o,this.ariaAnchor().setAttribute("role","combobox"),this.ariaAnchor().setAttribute("aria-expanded","false"),this.ariaAnchor().setAttribute("aria-owns",this.list.id),this.placeholderCache=this.input.placeholder,this.inputListener=Ei(this),this.blurListener=vi(this),this.focusListener=bi(this),this.keydownListener=Ci(this),this.countryListener=Si(this);const{container:i,announce:s}=(({document:t,idA:e,idB:n})=>{const o=t.createElement("div");(t=>{t.style.border="0px",t.style.padding="0px",t.style.clipPath="rect(0px,0px,0px,0px)",t.style.height="1px",t.style.marginBottom="-1px",t.style.marginRight="-1px",t.style.overflow="hidden",t.style.position="absolute",t.style.whiteSpace="nowrap",t.style.width="1px"})(o);const i=$t(t.createElement("div"),e),s=$t(t.createElement("div"),n);o.appendChild(i),o.appendChild(s);let r=!0;const a=Ht(t=>{const e=r?i:s,n=r?s:i;r=!r,e.textContent=t,n.textContent=""},1500,{});return{container:o,announce:a}})({idA:this.ids(),idB:this.ids(),document:this.options.document});this.announce=s,this.alerts=i,this.inputStyle=h(this.input,this.options.inputStyle),h(this.container,this.options.containerStyle),h(this.list,this.options.listStyle);const r=(t=>{let e;const n=t.input;if(!1===t.options.alignToInput)return{};try{const o=t.options.document.defaultView;if(!o)return{};e=o.getComputedStyle(n).marginBottom}catch(t){return{}}if(!e)return{};const o=parseInt(e.replace("px",""),10);return isNaN(o)||0===o?{}:{marginTop:-1*o+t.options.offset+"px"}})(this);h(this.mainComponent,{...r,...this.options.mainStyle}),this.fsm=fi({c:this}),this.init()}setPlaceholder(t){this.input.placeholder=t}unsetPlaceholder(){if(void 0===this.placeholderCache)return this.input.removeAttribute("placeholder");this.input.placeholder=this.placeholderCache}currentContext(){const t=this.options.contexts[this.context];if(t)return t;const e=Object.keys(this.options.contexts)[0];return this.options.contexts[e]}load(){this.attach(),(e=>{const n=e.options.injectStyle;if(!n)return;const o=P();if(o.afstyle||(o.afstyle={}),t(n)&&!o.afstyle[n]){o.afstyle[n]=!0;const t=((t,e)=>{const n=e.createElement("link");return n.type="text/css",n.rel="stylesheet",n.href=t,n})(n,e.document);return e.document.head.appendChild(t),t}!0!==n||o.afstyle[""]||(o.afstyle[""]=!0,((t,e)=>{const n=e.createElement("style");n.appendChild(e.createTextNode(t)),e.head.appendChild(n)})(".idpc_af.hidden{display:none}div.idpc_autocomplete{position:relative;margin:0!important;padding:0;border:0;color:#28282b;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}div.idpc_autocomplete>input{display:block}div.idpc_af{position:absolute;left:0;z-index:2000;min-width:100%;box-sizing:border-box;border-radius:3px;background:#fff;border:1px solid rgba(0,0,0,.3);box-shadow:.05em .2em .6em rgba(0,0,0,.2);text-shadow:none;padding:0;margin-top:2px}div.idpc_af>ul{list-style:none;padding:0;max-height:250px;overflow-y:scroll;margin:0!important}div.idpc_af>ul>li{position:relative;padding:.2em .5em;cursor:pointer;margin:0!important}div.idpc_toolbar{padding:.3em .5em;border-top:1px solid rgba(0,0,0,.3);text-align:right}div.idpc_af>ul>li:hover{background-color:#e5e4e2}div.idpc_af>ul>li.idpc_error{padding:.5em;text-align:center;cursor:default!important}div.idpc_af>ul>li.idpc_error:hover{background:#fff;cursor:default!important}div.idpc_af>ul>li[aria-selected=true]{background-color:#e5e4e2;z-index:3000}div.idpc_autocomplete>.idpc-unhide{font-size:.9em;text-decoration:underline;cursor:pointer}div.idpc_af>div>span{padding:.2em .5em;border-radius:3px;cursor:pointer;font-size:110%}span.idpc_icon{font-size:1.2em;line-height:1em;vertical-align:middle}div.idpc_toolbar>span span.idpc_country{margin-right:.3em;max-width:0;font-size:.9em;-webkit-transition:max-width .5s ease-out;transition:max-width .5s ease-out;display:inline-block;vertical-align:middle;white-space:nowrap;overflow:hidden}div.idpc_autocomplete>div>div>span:hover span.idpc_country{max-width:7em}div.idpc_autocomplete>div>div>span:hover{background-color:#e5e4e2;-webkit-transition:background-color .5s ease;-ms-transition:background-color .5s ease;transition:background-color .5s ease}",e.document))})(this),this.options.fixed&&Ai(this.mainComponent,this.container,this.document),this.options.onLoaded.call(this),this.list.parentNode?.addEventListener("mousedown",t=>t.preventDefault())}init(){return new Promise(t=>{if(!this.options.checkKey)return this.load(),void t();Se({client:this.client,api_key:this.options.apiKey}).then(e=>{if(!e.available)throw new Error("Key currently not usable");this.updateContexts(zt(e.contexts));const n=this.options.contexts[e.context];this.options.detectCountry&&n?this.applyContext(n,!1):this.applyContext(this.currentContext(),!1),this.load(),t()}).catch(e=>{this.options.onFailedCheck.call(this,e),t()})})}updateContexts(t){this.contextSuggestions=((t,e)=>{const n=[],o=Object.keys(t);for(const i of o)e.length>0&&!e.some(t=>t===i)||n.push(t[i]);return n.sort((t,e)=>t.description.localeCompare(e.description)),n})(t,this.options.restrictCountries),this.options.contexts=t}filteredContexts(){const t=this.query();if(0===t.trim().length)return this.contextSuggestions;const e=t.toLowerCase().trim().replace(/\s+/g," "),n=new RegExp("^"+e);return this.contextSuggestions.filter(t=>!!n.test(t.description.toLowerCase())||(t.iso_2.toLowerCase()===e||t.iso_3.toLowerCase()===e))}renderContexts(){this.list.innerHTML="",this.filteredContexts().forEach((t,e)=>{const{description:n}=t,o=this.options.document.createElement("li");o.textContent=n,o.setAttribute("aria-selected","false"),o.setAttribute("tabindex","-1"),o.setAttribute("aria-posinset",`${e+1}`),o.setAttribute("aria-setsize",this.contextSuggestions.length.toString()),o.setAttribute("role","option"),h(o,this.options.liStyle),o.addEventListener("mousedown",e=>{e.preventDefault(),this.options.onMouseDown.call(this,e),this.fsm.send({type:"SELECT_COUNTRY",contextDetails:t})}),o.id=`${this.list.id}_${e}`,this.list.appendChild(o)}),this.announce(`${this.contextSuggestions.length} countries available`)}renderSuggestions(){this.list.innerHTML="";const t=this.suggestions;t.forEach((e,n)=>{const o=this.options.document.createElement("li");o.textContent=e.suggestion,o.setAttribute("aria-selected","false"),o.setAttribute("tabindex","-1"),o.setAttribute("title",e.suggestion),o.setAttribute("aria-posinset",`${n+1}`),o.setAttribute("aria-setsize",t.length.toString()),o.setAttribute("role","option"),h(o,this.options.liStyle),o.addEventListener("mousedown",t=>{t.preventDefault(),this.options.onMouseDown.call(this,t),this.fsm.send({type:"SELECT_ADDRESS",suggestion:e})}),o.id=`${this.list.id}_${n}`,this.list.appendChild(o)}),this.announce(`${t.length} addresses available`)}goToCurrent(){const t=this.list.children;this.input.setAttribute("aria-activedescendant","");for(let e=0;e{if(null===t)throw"Unable to retrieve address";return this.options.onAddressRetrieved.call(this,t),this.populateAddress(t),this}).catch(t=>(this.open(),this.setMessage(this.options.msgFallback),this.options.onSearchError.call(this,t),t))}populateAddress(t){this.unhideFields(),K({address:t,config:{...this.options,scope:this.outputScope},outputFields:this.options.outputFields,names:this.options.names,labels:this.options.labels}),this.options.onAddressPopulated.call(this,t)}setQueryOptions(t){this.cache.clear(),this.options.queryOptions=t}setResolveOptions(t){this.cache.clear(),this.options.resolveOptions=t}attach(){if(this.fsm.status===ii.Running)return this;this.input.addEventListener("input",this.inputListener),this.input.addEventListener("blur",this.blurListener),this.input.addEventListener("focus",this.focusListener),this.input.addEventListener("keydown",this.keydownListener),this.countryInput&&this.countryInput.addEventListener("change",this.countryListener);const t=this.input.parentNode;return t&&(t.insertBefore(this.container,this.input),this.container.appendChild(this.input),this.container.appendChild(this.mainComponent),this.container.appendChild(this.alerts),this.options.hide.length>0&&null==this.options.unhide&&this.container.appendChild(this.unhide)),this.fsm.start(),this.options.onMounted.call(this),this.hideFields(),this}detach(){if(this.fsm.status!==ii.Running)return this;this.input.removeEventListener("input",this.inputListener),this.input.removeEventListener("blur",this.blurListener),this.input.removeEventListener("focus",this.focusListener),this.input.removeEventListener("keydown",this.keydownListener),this.countryInput&&this.countryInput.removeEventListener("change",this.countryListener),this.container.removeChild(this.mainComponent),this.container.removeChild(this.alerts);const t=this.container.parentNode;return t&&(t.insertBefore(this.input,this.container),t.removeChild(this.container)),this.unmountUnhide(),this.unhideFields(),this.fsm.stop(),p(this.input,this.inputStyle),this.options.onRemove.call(this),this.unsetPlaceholder(),this}setMessage(t){return this.fsm.send({type:"NOTIFY",notification:t}),this}ariaAnchor(){return"1.0"===this.options.aria?this.input:this.container}query(){return this.input.value}clearInput(){T(this.input,"")}setSuggestions(t,e){return e!==this.query()?this:0===t.length?this.setMessage(this.options.msgNoMatch):(this.fsm.send({type:"SUGGEST",suggestions:t}),this)}close(t="blur"){f(this.mainComponent),"esc"===t&&T(this.input,""),this.options.onClose.call(this,t)}updateSuggestions(t){this.suggestions=t,this.current=-1}applyContext(t,e=!0){const n=t.iso_3;this.context=n,this.cache.clear(),this.countryIcon.innerText=t.emoji,e&&this.announce(`Country switched to ${t.description}`),this.options.onContextChange.call(this,n)}renderNotice(){this.list.innerHTML="",this.input.setAttribute("aria-activedescendant",""),this.message.textContent=this.notification,this.announce(this.notification),this.list.appendChild(this.message)}open(){m(this.mainComponent),this.options.onOpen.call(this)}next(){return this.current+1>this.list.children.length-1?this.current=0:this.current+=1,this}previous(){return this.current-1<0?this.current=this.list.children.length-1:this.current+=-1,this}scrollToView(t){const e=t.offsetTop,n=this.list.scrollTop;en+o&&(this.list.scrollTop=e-o+i),this}goto(t){const e=this.list.children,n=e[t];return t>-1&&e.length>0?this.scrollToView(n):this.scrollToView(e[0]),this}opened(){return!this.closed()}closed(){return this.fsm.state.matches("closed")}createUnhide(){const t=xi(this.scope,this.options.unhide,()=>{const t=this.options.document.createElement("p");return t.innerText=this.options.msgUnhide,t.setAttribute("role","button"),t.setAttribute("tabindex","0"),this.options.unhideClass&&(t.className=this.options.unhideClass),t});return t.addEventListener("click",this.unhideEvent),t}unmountUnhide(){this.unhide.removeEventListener("click",this.unhideEvent),null==this.options.unhide&&this.options.hide.length&&g(this.unhide)}hiddenFields(){return this.options.hide.map(e=>t(e)?r(this.options.scope,e):e).filter(t=>null!==t)}hideFields(){this.hiddenFields().forEach(f)}unhideFields(){this.hiddenFields().forEach(m),this.options.onUnhide.call(this)}};const vi=t=>function(){t.options.onBlur.call(t),t.fsm.send({type:"CLOSE",reason:"blur"})},bi=t=>function(e){t.options.onFocus.call(t),t.fsm.send("AWAKE")},Ei=t=>function(e){if(":c"===t.query().toLowerCase())return T(t.input,""),t.fsm.send({type:"CHANGE_COUNTRY"});t.fsm.send({type:"INPUT",event:e})},wi=t=>function(e){e.preventDefault(),t.fsm.send({type:"CHANGE_COUNTRY"})},Ci=t=>function(e){const n=Z(e);if("Enter"===n&&e.preventDefault(),t.options.onKeyDown.call(t,e),t.closed())return t.fsm.send("AWAKE");if(t.fsm.state.matches("suggesting_country")){if("Enter"===n){const e=t.filteredContexts()[t.current];e&&t.fsm.send({type:"SELECT_COUNTRY",contextDetails:e})}"Backspace"===n&&t.fsm.send({type:"INPUT",event:e}),"ArrowUp"===n&&(e.preventDefault(),t.fsm.send("PREVIOUS")),"ArrowDown"===n&&(e.preventDefault(),t.fsm.send("NEXT"))}if(t.fsm.state.matches("suggesting")){if("Enter"===n){const e=t.suggestions[t.current];e&&t.fsm.send({type:"SELECT_ADDRESS",suggestion:e})}"Backspace"===n&&t.fsm.send({type:"INPUT",event:e}),"ArrowUp"===n&&(e.preventDefault(),t.fsm.send("PREVIOUS")),"ArrowDown"===n&&(e.preventDefault(),t.fsm.send("NEXT"))}"Escape"===n&&t.fsm.send({type:"CLOSE",reason:"esc"}),"Home"===n&&t.fsm.send({type:"RESET"}),"End"===n&&t.fsm.send({type:"RESET"})},Si=t=>function(e){if(null===e.target)return;const n=e.target;if(!n)return;let o=Ti(n.value,t.options.contexts);t.fsm.send({type:"COUNTRY_CHANGE_EVENT",contextDetails:o})},xi=(e,n,o)=>t(n)?e.querySelector(n):o&&null===n?o():n,Ai=(t,e,n)=>{const o=(t,e)=>{if(null===t)return;const n=t.getBoundingClientRect();e.style.minWidth=`${Math.round(n.width)}px`},i=e.parentElement;t.style.position="fixed",t.style.left="auto",o(i,t),null!==n.defaultView&&n.defaultView.addEventListener("resize",()=>{o(i,t)})},Ti=(t,e)=>{const n=t.toUpperCase();for(const t of Object.values(e)){if(t.iso_3===n)return t;if(t.iso_2===n)return t;if(t.description.toUpperCase()===n)return t}},_i=t=>{const e=new yi(t);return Oi.push(e),e},Oi=[],Ri=()=>!0,Li=1e3,ki=t=>s(t,"FORM"),Ni=(t,i={})=>{const s=new ei({...gi,...t,api_key:t.apiKey}),{pageTest:r=Ri}=i;return r()?Se({client:s}).then(s=>{if(!s.available)return null;const{getScope:a=ki,interval:c=Li,anchor:u,onBind:d=mi,onAnchorFound:h=mi,onBindAttempt:p=mi,immediate:f=!0,marker:m="idpc"}=i,g=()=>{p({config:t,options:i}),((t,o)=>{const i=l(t.scope||null).querySelectorAll(t.anchor||t.inputField||(t.outputFields||{}).line_1);return e(i).filter(t=>!n(t,o))})({anchor:u,...t},m).forEach(e=>{const n=a(e);if(!n)return;const i=zt(s.contexts),r={scope:n,...t,checkKey:!1,contexts:i};h({anchor:e,scope:n,config:r});const c=_i(r),u=c.options.contexts[s.context];c.options.detectCountry&&u?c.applyContext(u,!1):c.applyContext(c.currentContext(),!1),o(e,m),d(c)})},{start:y,stop:v}=(({pageTest:t,bind:e,interval:n=1e3})=>{let o=null;const i=()=>{null!==o&&(window.clearInterval(o),o=null)};return{start:s=>t()?(o=window.setInterval(()=>{try{e(s)}catch(t){i(),console.log(t)}},n),o):null,stop:i}})({bind:g,pageTest:r,interval:c});return f&&y(),{start:y,stop:v,bind:g}}).catch(t=>(i.onError&&i.onError(t),null)):Promise.resolve(null)},Fi=t=>(t.preventDefault&&t.preventDefault(),!1),Ui=()=>{},Pi=()=>!1,ji=function(t){if("Enter"===Z(t))return t.preventDefault(),this.handleClick(),!1},Ii=function(t){return t.cancelable&&t.preventDefault(),this.options.onButtonTrigger.call(this),this.handleClick(),!1},Di=function(){const t=this.select.value.split("-");if("next"===t[0]){const e=parseInt(t[1],10);if(isNaN(e))return;return void this.executeSearch(this.lastLookup,e)}const e=parseInt(this.select.value,10);isNaN(e)||this.selectAddress(e)},Bi={apiKey:"",checkKey:!0,context:"",outputScope:null,onButtonTrigger:Ui,onSearchCompleted:Ui,onAddressesRetrieved:Ui,onAddressSelected:Ui,onSelectCreated:Ui,onSelectRemoved:Ui,onLookupTriggered:Ui,shouldLookupTrigger:()=>!0,onSearchError:Ui,onLoaded:Ui,onFailedCheck:Ui,onRemove:Ui,onAddressPopulated:Ui,onUnhide:Ui,input:null,inputId:null,inputClass:"idpc-input",inputAriaLabel:"Search a postcode to retrieve your address",placeholder:"Search your postcode",button:null,buttonId:null,buttonLabel:"Find my Address",buttonClass:"idpc-button",selectContainer:null,selectId:null,selectClass:"idpc-select",selectContainerId:null,selectContainerClass:"idpc-select-container",selectAriaLabel:"Select your address",unhide:null,unhideClass:"idpc-unhide",message:null,messageId:null,messageClass:"idpc-error",msgSelect:"Please select your address",msgDisabled:"Finding addresses...",msgNotFound:"Your postcode could not be found. Please type in your address",msgAddressNotFound:"We could not find a match for your address. Please type in your address",msgError:"Sorry, we weren't able to get the address you were looking for. Please type in your address",msgUnhide:"Enter address manually",cooloff:500,removeOrganisation:!1,selectSinglePremise:!1,titleizePostTown:!0,postcodeSearchFormatter:t=>{const e=[t.line_1];return""!==t.line_2&&e.push(t.line_2),""!==t.line_3&&e.push(t.line_3),e.join(", ")},addressSearchFormatter:t=>{const e=[t.line_1];return""!==t.line_2&&e.push(t.line_2),e.push(t.post_town),e.push(t.postcode_outward),e.join(", ")},outputFields:{},strictlyPostcodes:!0,limit:10,inputStyle:{},buttonStyle:{},messageStyle:{},selectStyle:{},contextStyle:{},hide:[],autocomplete:"none",populateCounty:!0};class qi{constructor(t){this.prevContext=null,this.options={scope:window.document,document:window.document,...Bi,...t},this.client=new ei({...this.options,api_key:this.options.apiKey}),this.scope=l(this.options.scope),this.document=d(this.scope),this.outputScope=this.findOrCreate(this.options.outputScope,()=>this.scope),this.data=[],this.lastLookup="",this.context=this.findOrCreate(this.options.context),this.prevContext=h(this.context,this.options.contextStyle),this.keypress=ji.bind(this),this.click=Ii.bind(this),this.selectEvent=Di.bind(this),this.unhideEvent=this.unhideFields.bind(this),this.input=this.createInput(),this.button=this.createButton(),this.message=this.createMessage(),this.select=this.createSelect(),this.selectContainer=this.createContainer(),this.unhide=this.createUnhide(),this.init()}findOrCreate(e,n){return t(e)?this.scope.querySelector(e):n&&null===e?n():e}createUnhide(){const t=this.findOrCreate(this.options.unhide,()=>{const t=this.document.createElement("p");return t.innerText=this.options.msgUnhide,t.setAttribute("role","button"),t.setAttribute("tabindex","0"),this.options.unhideClass&&(t.className=this.options.unhideClass),t});return t.addEventListener("click",this.unhideEvent),t.addEventListener("keyup",t=>"Enter"===t.key&&this.unhideEvent(t)),t}unmountUnhide(){this.unhide.removeEventListener("click",this.unhideEvent),!this.options.unhide&&this.options.hide.length&&g(this.unhide)}createContainer(){return this.findOrCreate(this.options.selectContainer,()=>{const t=this.options,e=this.document.createElement("div");return t.selectContainerId&&(e.id=t.selectContainerId),t.selectContainerClass&&(e.className=t.selectContainerClass),e.setAttribute("aria-live","polite"),f(e),e})}unmountContainer(){g(this.selectContainer)}createInput(){const t=this.findOrCreate(this.options.input,()=>{const t=this.document.createElement("input"),e=this.options;return t.type="text",e.inputId&&(t.id=e.inputId),e.inputClass&&(t.className=e.inputClass),e.placeholder&&(t.placeholder=e.placeholder),e.inputAriaLabel&&t.setAttribute("aria-label",e.inputAriaLabel),e.autocomplete&&t.setAttribute("autocomplete",e.autocomplete),h(t,this.options.inputStyle),t});return t.addEventListener("keypress",this.keypress),t.addEventListener("submit",Pi),t}unmountInput(){this.input.removeEventListener("keypress",this.keypress),this.input.removeEventListener("submit",Pi),null===this.options.input&&g(this.input)}createButton(){const t=this.findOrCreate(this.options.button,()=>{const t=this.document.createElement("button"),e=this.options;return t.type="button",e.buttonLabel&&(t.innerText=e.buttonLabel),e.buttonId&&(t.id=e.buttonId),e.buttonClass&&(t.className=e.buttonClass),h(t,this.options.buttonStyle),t.onclick=Fi,t});return t.addEventListener("submit",Pi),t.addEventListener("click",this.click),t}unmountButton(){this.button.removeEventListener("submit",Pi),this.button.removeEventListener("click",this.click),null===this.options.button&&g(this.button)}createMessage(){return this.findOrCreate(this.options.message,()=>{const t=this.document.createElement("p"),e=this.options;return e.messageClass&&(t.className=e.messageClass),e.messageId&&(t.id=e.messageId),t.setAttribute("role","alert"),h(t,this.options.messageStyle),f(t),t})}unmountMessage(){null===this.options.message&&g(this.message)}createSelect(){const t=this.document.createElement("select"),e=this.options;return e.selectId&&(t.id=e.selectId),e.selectClass&&(t.className=e.selectClass),h(t,this.options.selectStyle),e.selectAriaLabel&&t.setAttribute("aria-label",e.selectAriaLabel),t.addEventListener("change",this.selectEvent),t}mountSelect(t,e){t&&(this.data=t),(t=>{let e;for(e=t.options.length-1;e>=0;e--)t.remove(e)})(this.select),this.select.appendChild(this.createOption("ideal",this.options.msgSelect));for(let t=0;tthis.enableButton(),t)}reset(){this.unmountSelect(),this.hideMessage()}removeAll(){this.unmountInput(),this.unmountButton(),this.unmountContainer(),this.unmountMessage(),this.unmountUnhide(),p(this.context,this.prevContext),this.options.onRemove.call(this)}notFoundMessage(){return this.options.strictlyPostcodes?this.options.msgNotFound:this.options.msgAddressNotFound}executeSearch(t,e){this.enableLookup();return(this.options.strictlyPostcodes?this.searchPostcode(t,e):this.searchAddress(t,e)).catch(t=>{if(t instanceof pe==!1)throw t;const e=t.response.body.suggestions||[];return e.length>1?(this.suggestionsMessage(e),null):1===e.length?(this.input.value=e[0],this.executeSearch(e[0]),null):"not_found"}).then(e=>{if(null===e)return;if("not_found"===e)return this.options.onSearchCompleted.call(this,null,[]),this.setMessage(this.notFoundMessage());const{addresses:n,total:o,page:i,limit:s}=e;if(this.options.onSearchCompleted.call(this,null,n),0===n.length)return this.setMessage(this.notFoundMessage());if(this.setMessage(),this.lastLookup=t,this.data=n,this.options.onAddressesRetrieved.call(this,n),this.options.selectSinglePremise&&1===n.length)return this.selectAddress(0);let r;o>(i+1)*s&&(r=i+1),this.mountSelect(n,r)}).catch(t=>{this.setMessage(this.options.msgError),this.options.onSearchCompleted.call(this,null,[]),this.options.onSearchError.call(this,t)})}suggestionsMessage(t){const e=this.document.createElement("span");e.innerHTML=`We couldn't find ${this.input.value}. Did you mean `,t.forEach((n,o)=>{const i=this.document.createElement("a");0===o?i.innerText=`${n}`:o===t.length-1?i.innerText=` or ${n}`:i.innerText=`, ${n}`,i.style.cursor="pointer",i.addEventListener("click",t=>{t.preventDefault(),this.input.value=n,this.executeSearch(n),this.hideMessage()}),e.appendChild(i)}),m(this.message),this.message.innerHTML="",this.message.appendChild(e)}searchPostcode(t,e=0){const n=(t=>{const e={},n={},{client:o}=t;Zt({client:o,header:e,options:t}),ee({header:e,options:t}),ne({query:n,options:t}),oe({client:o,query:n,options:t});const i={header:e,query:n};return void 0!==t.timeout&&(i.timeout=t.timeout),i})({client:this.client});return e>0&&(n.query.page=String(e)),((t,e,n)=>we({resource:"postcodes",client:t})(e,n))(this.client,t,n).then(t=>({addresses:t.body.result,page:t.body.page,total:t.body.total,limit:t.body.limit}))}searchAddress(t,e){const n=(t=>{const e={},n={query:t.query},{client:o}=t;Zt({client:o,header:e,options:t}),ee({header:e,options:t}),ne({query:n,options:t}),oe({client:o,query:n,options:t}),(({query:t,options:e})=>{const{page:n,limit:o}=e;void 0!==n&&(t.page=n.toString()),void 0!==o&&(t.limit=o.toString())})({query:n,options:t});const i={header:e,query:n};return void 0!==t.timeout&&(i.timeout=t.timeout),i})({client:this.client,query:t,limit:this.options.limit});return(o=this.client,i=n,Ce({resource:"addresses",client:o})(i)).then(t=>({addresses:t.body.result.hits,page:t.body.result.page,total:t.body.result.hits.length,limit:t.body.result.limit}));var o,i}formatAddress(t){return(this.options.strictlyPostcodes?this.options.postcodeSearchFormatter:this.options.addressSearchFormatter)(t)}createOption(t,e){const n=this.document.createElement("option");return n.text=e,n.value=t,n}setMessage(t){if(this.message){if(void 0===t)return this.hideMessage();m(this.message),this.message.innerText=t}}hideMessage(){this.message&&(this.message.innerText="",f(this.message))}init(){const t=()=>{this.render(),this.hideFields(),this.options.onLoaded.call(this)};if(!this.options.checkKey)return t();Se({client:this.client}).then(({available:e})=>e?t():Promise.reject("Key not available")).catch(t=>{this.options.onFailedCheck&&this.options.onFailedCheck(t)})}populateAddress(t){this.unhideFields();const e=this.options.outputFields,n={...this.options,scope:this.outputScope};K({outputFields:e,address:t,config:n}),this.options.onAddressPopulated.call(this,t)}hiddenFields(){return this.options.hide.map(e=>t(e)?r(this.scope,e):e).filter(t=>null!==t)}hideFields(){this.hiddenFields().forEach(f)}unhideFields(){this.hiddenFields().forEach(m),this.options.onUnhide.call(this)}render(){this.context.innerHTML="",this.options.input||this.context.appendChild(this.input),this.options.button||this.context.appendChild(this.button),this.options.selectContainer||this.context.appendChild(this.selectContainer),this.options.message||this.context.appendChild(this.message),!this.options.unhide&&this.options.hide.length&&this.context.appendChild(this.unhide)}}const Mi=()=>!0,Hi=()=>{},$i=t=>s(t,"FORM"),zi=(t,i={})=>{const{pageTest:s=Mi,onError:r=Hi,onBindAttempt:a=Hi,onBind:c=Hi,anchor:u,onAnchorFound:d=Hi,getScope:h=$i,marker:p="idpc-pl"}=i;let f;const{start:m,stop:g}=nt({bind:()=>{try{a(t),((t,o)=>{const i=l(t.scope||null).querySelectorAll(t.anchor||t.context||t.scope);return e(i).filter(t=>!n(t,o))})({anchor:u,...t},p).forEach(e=>{if(!s())return;const n=h(e);d({anchor:e,scope:n,config:t}),f=(t=>new qi(t))(t),o(e,p),c(f)})}catch(t){r(t)}}});return m(),{start:m,stop:g,controller:f}};var Ki=["opencart"],Gi=ot(ot([],Ki,!0),["postcodelookup"],!1),Wi=ot(ot([],Ki,!0),["addressfinder"],!1).join(","),Vi=["England","Scotland","Wales","Northern Ireland","Channel Islands","Isle of Man","United Kingdom","Jersey","Guernsey","GB","IM","JE","GG"],Ji=function(t,e){void 0===e&&(e="col-form-label");var n=document.createElement("label");return n.innerText="Search your Postcode",n.className=e,n.setAttribute("for","idpc_postcode_lookup"),a({target:t,elem:n}),n},Yi=function(){},Xi=function(t,e,n){var o=c(t.country,document);if(null===o)return Yi;var i=function(){if(function(t){var e=t.selectedIndex,n=t.options[e].text;return Vi.reduce(function(t,e){return n===e||t},!1)}(o))return e();n()};return o.addEventListener("change",i),i},Qi=function(t,e,n,o,i){void 0===i&&(i=!1),!0===t.postcodeLookup&&zi({context:"div.idpc_lookup",apiKey:t.apiKey,tags:Gi,inputClass:"form-control",buttonClass:"btn btn-primary idpc-button",selectClass:"form-select",checkKey:!0,outputFields:e,inputStyle:{marginBottom:"15px"},buttonStyle:{marginBottom:"15px"},removeOrganisation:!1,onLoaded:function(){var t=this;setTimeout(function(){var n=Ji(t.context,i?"col-sm-2 col-form-label":"col-form-label");Xi(e,function(){n.hidden=!1,m(t.context)},function(){n.hidden=!0,f(t.context)})()},0)},onAddressPopulated:function(t){var e=this;setTimeout(function(){os(t,e.options.outputFields.county_code)},300)}},{pageTest:n,getScope:o,anchor:e.line_1,onAnchorFound:function(t){var n=t.scope;(null==n?void 0:n.querySelector('.idpc_lookup[idpc="true"]'))||(t.config.context=function(t,e){var n;void 0===e&&(e=!1);var o=c(t.line_1,document);if(null===o)return null;var i=null===(n=o.parentElement)||void 0===n?void 0:n.parentElement;if(!i)return null;var s=document.createElement("div");s.className=e?"row mb-3":"row";var r=document.createElement("div");if(!1===e){var u=document.createElement("div");u.className="col mb-3",s.appendChild(u),r.className="idpc_lookup",u.appendChild(r)}else r.className="col-sm-10 idpc_lookup",s.appendChild(r);return a({target:i,elem:s}),r}(e,i))}})},Zi=function(t,e,n,o){!0===t.postcodeLookup&&zi({context:"div.idpc_lookup",apiKey:t.apiKey,tags:Gi,inputClass:"form-control",buttonClass:"btn btn-primary idpc-button",selectClass:"form-select",checkKey:!0,outputFields:e,inputStyle:{marginBottom:"15px"},buttonStyle:{marginBottom:"15px"},removeOrganisation:!1,onLoaded:function(){var t=this;setTimeout(function(){var n=Ji(t.context,"form-label");Xi(e,function(){n.hidden=!1,m(t.context)},function(){n.hidden=!0,f(t.context)})()},0)},onAddressPopulated:function(t){var e=this;setTimeout(function(){os(t,e.options.outputFields.county_code)},300)}},{pageTest:n,getScope:o,anchor:e.line_1,onAnchorFound:function(t){var n=t.scope;(null==n?void 0:n.querySelector('.idpc_lookup[idpc="true"]'))||(t.config.context=function(t){var e=c(t.line_1,document);if(null===e)return null;var n=s(e,"div",function(t){return t.classList.contains("row")});if(null===n)return null;var o=document.createElement("div");o.className="row mb-3";var i=document.createElement("div");return i.className="idpc_lookup",o.appendChild(i),a({target:n,elem:o}),i}(e))}})},ts=function(t,e,n,o){if(!0===t.autocomplete&&null!==e.line_1)return Ni({apiKey:t.apiKey,checkKey:!0,queryOptions:{tags:Wi},resolveOptions:{tags:Wi},populateOrganisation:!0,removeOrganisation:!1,outputFields:e,onAddressPopulated:function(t){var e=this;setTimeout(function(){os(t,e.options.outputFields.county_code)},300)},onContextChange:function(t){var n=document.querySelector(e.country);if(n&&C(n)){var o=n,i=o.value,s=!1,r="";if(Array.from(o.options).forEach(function(e){e.value.toUpperCase()===t&&(r=e.value,s=!0)}),!s){var a=this.currentContext();if(a){var c=ns(o,a.description);c.length>0&&(r=c[0].value,s=!0)}}if(s&&r!==i){o.value=r;var u=new Event("change",{bubbles:!0});o.dispatchEvent(u)}else s||console.warn("No matching option found for context:",t)}},onMounted:function(){var t=this,n=document.querySelector(e.country);if(n)if(C(n)){var o=function(){var e=n,o=e.value,i=e.options[e.selectedIndex],s=i?i.text:"";if(o){var r=t.options.contexts;if(r){var a;for(var c in r)if(c===o.toUpperCase()){a=r[c];break}if(!a)for(var c in r){var u=r[c];if(u&&u.description&&u.description.toLowerCase()===s.toLowerCase()){a=u;break}}if(a){var l=t.currentContext();if(l&&l.iso_3===a.iso_3);else try{t.applyContext(a)}catch(t){console.error("Error applying context:",t)}}else console.warn("Could not find matching context for country:",o,s)}else console.warn("No contexts available in Address Finder")}else console.warn("No country value selected")};n.addEventListener("change",o),setTimeout(o,300)}else console.warn("Country element is not a select element:",e.country);else console.warn("Country select element not found:",e.country)}},{pageTest:n,getScope:o,marker:"idpc-af"})},es=function(t,e){return Array.from(t.options).some(function(t){return t.value===e})},ns=function(t,e){return e?Array.from(t.options).filter(function(t){return-1!==t.text.toLowerCase().indexOf(e.toLowerCase())}):[]},os=function(t,e){if(null!==e){var n="string"==typeof e?document.querySelector(e):e;if(C(n)){var o=t.county_code||"",i=t.county||"";if("London"===i&&(i="Greater London"),C(n)){if(""!==o&&es(n,o))return void(n.value=o);if(""!==i&&es(n,i))return void(n.value=i);if(i){var s=ns(n,i);if(s.length>0)return void(n.value=s[0].value)}if(o){var r=ns(n,o);if(r.length>0)return void(n.value=r[0].value)}for(var a=0,c=["post_town","traditional_county","administrative_county"];a0)return void(n.value=l[0].value)}}}}}},is={line_1:"#input-payment-address-1",line_2:"#input-payment-address-2",postcode:"#input-payment-postcode",post_town:"#input-payment-city",organisation_name:"#input-payment-company",county_code:"#input-payment-zone",country:"#input-payment-country"},ss=function(t){return s(t,"fieldset")},rs=function(){return window.location.href.includes("/checkout")},as={bind:function(t){ts(t,is,rs,ss),Zi(t,is,rs,ss)}},cs={line_1:"#input-shipping-address-1",line_2:"#input-shipping-address-2",postcode:"#input-shipping-postcode",post_town:"#input-shipping-city",organisation_name:"#input-shipping-company",county_code:"#input-shipping-zone",country:"#input-shipping-country"},us=function(t){return s(t,"fieldset",function(t){return"shipping-address"===t.id})},ls={bind:function(t){ts(t,cs,rs,us),Qi(t,cs,rs,us)}},ds={line_1:"#input-address-1",line_2:"#input-address-2",postcode:"#input-postcode",post_town:"#input-city",organisation_name:"#input-company",county_code:"#input-zone",country:"#input-country"},hs=void 0,ps=function(){return window.location.href.includes("/address")},fs={bind:function(t){ts(t,ds,ps,hs),Qi(t,ds,ps,hs,!0)}},ms=function(){return!0},gs={bind:function(t){(t.customFields||[]).forEach(function(e){ts(t,e,ms),Zi(t,e,ms)})}};[as,ls,fs,gs].forEach(function(t){var e=(()=>{const t=window.idpcConfig;if(void 0!==t)return{...v,...t}})();e&&t.bind(e)})}(); From 5aa152718d8809ccdeb2dca03397eff01e4b1d92 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 11 Jun 2026 08:45:58 +0000 Subject: [PATCH 2/3] ci: allow devin-ai-integration bot in claude-code-review workflow Co-Authored-By: Marcin Filip --- .github/workflows/claude-code-review.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index 5e90d4b..6ab94c9 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -36,6 +36,7 @@ jobs: uses: anthropics/claude-code-action@v1 with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} + allowed_bots: "devin-ai-integration[bot]" prompt: | Please review this pull request and provide feedback on: - Code quality and best practices From e67556d4e11f0cf26f640f417545d5a8400aed59 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 11 Jun 2026 08:49:56 +0000 Subject: [PATCH 3/3] ci: retrigger CI (flaky Cypress test) Co-Authored-By: Marcin Filip