@lockerverse/sdk 0.2.78 → 0.2.80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/transport.js CHANGED
@@ -1,2 +1,2 @@
1
- import{n as e}from"./types.js";const t={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function n(e){return e?{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}:t}function r(e){let t=typeof e;return t===`string`?`"${e}"`:t===`number`||t===`bigint`||t===`boolean`?`${e}`:t===`object`||t===`function`?(e&&Object.getPrototypeOf(e)?.constructor?.name)??`null`:t}function i(e,t,n,i,a){let o=a&&`input`in a?a.input:n.value,s=a?.expected??e.expects??null,c=a?.received??r(o),l={kind:e.kind,type:e.type,input:o,expected:s,received:c,message:`Invalid ${t}: ${s?`Expected ${s} but r`:`R`}eceived ${c}`,requirement:e.requirement,path:a?.path,issues:a?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},u=e.kind===`schema`,d=a?.message??e.message??(e.reference,l.lang,void 0)??(u?(l.lang,void 0):null)??i.message??(l.lang,void 0);d!==void 0&&(l.message=typeof d==`function`?d(l):d),u&&(n.typed=!1),n.issues?n.issues.push(l):n.issues=[l]}const a=new WeakMap;function o(e){let t=a.get(e);return t||(t={version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},n())}},a.set(e,t)),t}function s(e,t){return Object.prototype.hasOwnProperty.call(e,t)&&t!==`__proto__`&&t!==`prototype`&&t!==`constructor`}function c(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??`never`}var l=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};const u=/^\d{4}-(?:0[1-9]|1[0-2])-(?:[12]\d|0[1-9]|3[01])[T ](?:0\d|1\d|2[0-3])(?::[0-5]\d){2}(?:\.\d{1,9})?(?:Z| ?[+-](?:0\d|1\d|2[0-3])(?::?[0-5]\d)?)$/u;function d(e,t){return{kind:`validation`,type:`check`,reference:d,async:!1,expects:null,requirement:e,message:t,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&i(this,`input`,e,t),e}}}function f(e){return{kind:`validation`,type:`finite`,reference:f,async:!1,expects:null,requirement:Number.isFinite,message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&i(this,`finite`,e,t),e}}}function p(e){return{kind:`validation`,type:`iso_timestamp`,reference:p,async:!1,expects:null,requirement:u,message:e,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&i(this,`timestamp`,e,t),e}}}function m(e,t){return{kind:`validation`,type:`max_value`,reference:m,async:!1,expects:`<=${e instanceof Date?e.toJSON():r(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value<=this.requirement)&&i(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():r(e.value)}),e}}}function h(e,t){return{kind:`validation`,type:`min_length`,reference:h,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length<this.requirement&&i(this,`length`,e,t,{received:`${e.value.length}`}),e}}}function g(e,t){return{kind:`validation`,type:`min_value`,reference:g,async:!1,expects:`>=${e instanceof Date?e.toJSON():r(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value>=this.requirement)&&i(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():r(e.value)}),e}}}function _(e){return{kind:`validation`,type:`non_empty`,reference:_,async:!1,expects:`!0`,message:e,"~run"(e,t){return e.typed&&e.value.length===0&&i(this,`length`,e,t,{received:`0`}),e}}}function v(e,t){return{kind:`validation`,type:`regex`,reference:v,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&i(this,`format`,e,t),e}}}function y(e){return{kind:`validation`,type:`safe_integer`,reference:y,async:!1,expects:null,requirement:Number.isSafeInteger,message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&i(this,`safe integer`,e,t),e}}}function b(e){return{kind:`transformation`,type:`transform`,reference:b,async:!1,operation:e,"~run"(e){return e.value=this.operation(e.value),e}}}const x={abortEarly:!0};function S(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function C(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function w(e,t){return{kind:`schema`,type:`array`,reference:w,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return o(this)},"~run"(e,t){let n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<n.length;r++){let i=n[r],a=this.item[`~run`]({value:i},t);if(a.issues){let o={type:`array`,origin:`value`,input:n,key:r,value:i};for(let t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value.push(a.value)}}else i(this,`type`,e,t);return e}}}function T(e){return{kind:`schema`,type:`boolean`,reference:T,expects:`boolean`,async:!1,message:e,get"~standard"(){return o(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:i(this,`type`,e,t),e}}}function E(e,t){return{kind:`schema`,type:`custom`,reference:E,expects:`unknown`,async:!1,check:e,message:t,get"~standard"(){return o(this)},"~run"(e,t){return this.check(e.value)?e.typed=!0:i(this,`type`,e,t),e}}}function D(e,t){return{kind:`schema`,type:`literal`,reference:D,expects:r(e),async:!1,literal:e,message:t,get"~standard"(){return o(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:i(this,`type`,e,t),e}}}function O(e,t){return{kind:`schema`,type:`loose_object`,reference:O,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return o(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in this.entries){let a=this.entries[r];if(r in n||(a.type===`exact_optional`||a.type===`optional`||a.type===`nullish`)&&a.default!==void 0){let i=r in n?n[r]:C(a),o=a[`~run`]({value:i},t);if(o.issues){let a={type:`object`,origin:`value`,input:n,key:r,value:i};for(let t of o.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(a.fallback!==void 0)e.value[r]=S(a);else if(a.type!==`exact_optional`&&a.type!==`optional`&&a.type!==`nullish`&&(i(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}if(!e.issues||!t.abortEarly)for(let t in n)s(n,t)&&!(t in this.entries)&&(e.value[t]=n[t])}else i(this,`type`,e,t);return e}}}function k(e,t){return{kind:`schema`,type:`nullable`,reference:k,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,get"~standard"(){return o(this)},"~run"(e,t){return e.value===null&&(this.default!==void 0&&(e.value=C(this,e,t)),e.value===null)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function A(e){return{kind:`schema`,type:`number`,reference:A,expects:`number`,async:!1,message:e,get"~standard"(){return o(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:i(this,`type`,e,t),e}}}function j(e,t){return{kind:`schema`,type:`object`,reference:j,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return o(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in this.entries){let a=this.entries[r];if(r in n||(a.type===`exact_optional`||a.type===`optional`||a.type===`nullish`)&&a.default!==void 0){let i=r in n?n[r]:C(a),o=a[`~run`]({value:i},t);if(o.issues){let a={type:`object`,origin:`value`,input:n,key:r,value:i};for(let t of o.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(a.fallback!==void 0)e.value[r]=S(a);else if(a.type!==`exact_optional`&&a.type!==`optional`&&a.type!==`nullish`&&(i(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}}else i(this,`type`,e,t);return e}}}function M(e,t){return{kind:`schema`,type:`optional`,reference:M,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return o(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=C(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function N(e,t){return{kind:`schema`,type:`picklist`,reference:N,expects:c(e.map(r),`|`),async:!1,options:e,message:t,get"~standard"(){return o(this)},"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:i(this,`type`,e,t),e}}}function P(e,t,n){return{kind:`schema`,type:`record`,reference:P,expects:`Object`,async:!1,key:e,value:t,message:n,get"~standard"(){return o(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in n)if(s(n,r)){let i=n[r],a=this.key[`~run`]({value:r},t);if(a.issues){let o={type:`object`,origin:`key`,input:n,key:r,value:i};for(let t of a.issues)t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}let o=this.value[`~run`]({value:i},t);if(o.issues){let a={type:`object`,origin:`value`,input:n,key:r,value:i};for(let t of o.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}(!a.typed||!o.typed)&&(e.typed=!1),a.typed&&(e.value[a.value]=o.value)}}else i(this,`type`,e,t);return e}}}function F(e,t){return{kind:`schema`,type:`strict_object`,reference:F,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return o(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in this.entries){let a=this.entries[r];if(r in n||(a.type===`exact_optional`||a.type===`optional`||a.type===`nullish`)&&a.default!==void 0){let i=r in n?n[r]:C(a),o=a[`~run`]({value:i},t);if(o.issues){let a={type:`object`,origin:`value`,input:n,key:r,value:i};for(let t of o.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(a.fallback!==void 0)e.value[r]=S(a);else if(a.type!==`exact_optional`&&a.type!==`optional`&&a.type!==`nullish`&&(i(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}if(!e.issues||!t.abortEarly){for(let r in n)if(!(r in this.entries)){i(this,`key`,e,t,{input:r,expected:`never`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]});break}}}else i(this,`type`,e,t);return e}}}function I(e){return{kind:`schema`,type:`string`,reference:I,expects:`string`,async:!1,message:e,get"~standard"(){return o(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:i(this,`type`,e,t),e}}}function L(e){let t;if(e)for(let n of e)if(t)for(let e of n.issues)t.push(e);else t=n.issues;return t}function R(e,t){return{kind:`schema`,type:`union`,reference:R,expects:c(e.map(e=>e.expects),`|`),async:!1,options:e,message:t,get"~standard"(){return o(this)},"~run"(e,t){let n,r,a;for(let i of this.options){let o=i[`~run`]({value:e.value},t);if(o.typed)if(o.issues)r?r.push(o):r=[o];else{n=o;break}else a?a.push(o):a=[o]}if(n)return n;if(r){if(r.length===1)return r[0];i(this,`type`,e,t,{issues:L(r)}),e.typed=!0}else if(a?.length===1)return a[0];else i(this,`type`,e,t,{issues:L(a)});return e}}}function z(){return{kind:`schema`,type:`unknown`,reference:z,expects:`unknown`,async:!1,get"~standard"(){return o(this)},"~run"(e){return e.typed=!0,e}}}function B(e,t,n){return{kind:`schema`,type:`variant`,reference:B,expects:`Object`,async:!1,key:e,options:t,message:n,get"~standard"(){return o(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){let r,a=0,o=this.key,s=[],l=(e,i)=>{for(let c of e.options){if(c.type===`variant`)l(c,new Set(i).add(c.key));else{let e=!0,l=0;for(let t of i){let r=c.entries[t];if(t in n?r[`~run`]({typed:!1,value:n[t]},x).issues:r.type!==`exact_optional`&&r.type!==`optional`&&r.type!==`nullish`){e=!1,o!==t&&(a<l||a===l&&t in n&&!(o in n))&&(a=l,o=t,s=[]),o===t&&s.push(c.entries[t].expects);break}l++}if(e){let e=c[`~run`]({value:n},t);(!r||!r.typed&&e.typed)&&(r=e)}}if(r&&!r.issues)break}};if(l(this,new Set([this.key])),r)return r;i(this,`type`,e,t,{input:n[o],expected:c(s,`|`),path:[{type:`object`,origin:`value`,input:n,key:o,value:n[o]}]})}else i(this,`type`,e,t);return e}}}function V(e,t,r){let i=e[`~run`]({value:t},n(r));if(i.issues)throw new l(i.issues);return i.value}function H(e,t){let n=n=>V(e,n,t);return n.schema=e,n.config=t,n}function U(...e){return{...e[0],pipe:e,get"~standard"(){return o(this)},"~run"(t,n){for(let r of e)if(r.kind!==`metadata`){if(t.issues&&(r.kind===`schema`||r.kind===`transformation`)){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r[`~run`](t,n))}return t}}}const W=/\/+$/,G=new Set([`localhost`,`127.0.0.1`,`[::1]`]),K={development:{sentryDsn:`https://1977371f7bc44480935a7bc9726ca296@o1338376.ingest.sentry.io/6631829`},production:{sentryDsn:`https://43d2d853c129415cf77531c914511174@o1338376.ingest.us.sentry.io/4511911476133888`}};function q(e,t){let n;try{n=new URL(e)}catch{throw TypeError(`apiBaseUrl must be a valid HTTP or HTTPS URL.`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw TypeError(`apiBaseUrl must be a valid HTTP or HTTPS URL.`);if(n.username||n.password)throw TypeError(`apiBaseUrl must not include credentials.`);if(n.search||n.hash)throw TypeError(`apiBaseUrl must not include a query or fragment.`);if(n.protocol!==`https:`&&!(t===`development`&&G.has(n.hostname)))throw TypeError(`apiBaseUrl must use HTTPS except for development loopback endpoints.`);return n.pathname=n.pathname.replace(W,``),n.toString().replace(W,``)}function ee(e,t){let n=`requestTimeoutMs must be a positive integer no greater than 2147483647.`,r=e=>U(I(`${e} must be a non-empty string.`),d(e=>e.trim().length>0,`${e} must be a non-empty string.`));try{let i=V(O({apiBaseUrl:M(I(`apiBaseUrl must be a valid HTTP or HTTPS URL.`)),communitySlug:r(`communitySlug`),environment:M(N([`development`,`production`],`environment must be either development or production.`)),fetch:M(E(e=>typeof e==`function`,`fetch must be a function when provided.`)),onError:M(E(e=>typeof e==`function`,`onError must be a function when provided.`)),requestTimeoutMs:M(U(A(n),y(n),g(1,n),m(2147483647,n))),sentryDsn:M(k(I(`sentryDsn must be a string or null when provided.`)))},`Expected an object.`),e);return{apiBaseUrl:i.apiBaseUrl,communitySlug:i.communitySlug,environment:i.environment,fetch:i.fetch,onError:i.onError,requestTimeoutMs:i.requestTimeoutMs,resourceSlugValue:V(r(t),i[t]),sentryDsn:i.sentryDsn}}catch(e){let t=e instanceof l?e.issues[0]?.message??`Invalid SDK options.`:`Invalid SDK options.`;throw TypeError(t)}}function J(e,t){let n=ee(e,t),r=n.environment;if(n.apiBaseUrl!==void 0&&r===void 0)throw TypeError(`environment is required when apiBaseUrl is provided.`);if(n.apiBaseUrl===void 0&&r===`development`)throw TypeError(`apiBaseUrl is required when environment is development.`);let i=r===void 0?`production`:r,{communitySlug:a,resourceSlugValue:o}=n,s=n.fetch??globalThis.fetch,c=n.apiBaseUrl===void 0?`https://portal.lockerverse.com/api`:q(n.apiBaseUrl,i),l=K[i],u=n.sentryDsn,d=u===null?null:u??l.sentryDsn;return{apiBaseUrl:c,communitySlug:encodeURIComponent(a),communitySlugValue:a,environment:i,fetchImplementation:s,onError:n.onError,requestTimeoutMs:n.requestTimeoutMs??2e4,resourceSlug:encodeURIComponent(o),resourceSlugValue:o,sentryDsn:d}}function te(e){let t=J(e,`signupSlug`);return{...t,signupSlug:t.resourceSlug,signupSlugValue:t.resourceSlugValue}}const Y=U(I(),_(),d(e=>e.trim().length>0)),ne=M(k(I()),null);function re(e){return U(A(),y(),g(e))}const X=U(w(z()),b(e=>e.filter(e=>{let{archivedAt:t}=V(O({archivedAt:M(k(Y))}),e);return!t}))),Z=U(X,w(j({id:Y,label:Y})),h(2),d(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Expected unique custom field option IDs.`)),Q={id:Y,label:Y,required:T()},ie=B(`type`,[j({...Q,type:N([`text`,`textarea`])}),j({...Q,options:Z,type:N([`radio`,`select`])}),j({...Q,options:Z,type:N([`checkboxes`,`multi_select`])})]),ae=U(M(X,[]),w(ie),d(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Expected unique custom field IDs.`)),oe=j({fieldId:Y,value:R([I(),w(I())])}),se=j({checkoutId:I(),checkoutStatus:N([`action_required`,`failed`,`pending`,`success`]),clientSecret:k(I()),paymentReference:I(),paymentRequired:T(),requiresAction:T(),status:k(I())}),ce=j({id:I(),submittedAt:U(I(),p())});function $(e){if(typeof e!=`object`||!e||Object.isFrozen(e))return e;for(let t of Object.values(e))$(t);return Object.freeze(e)}function le({communitySlug:e,environment:t,getContext:n,onError:r,resourceContextName:i,sentryDsn:a}){let o=null;return function(s){try{r?.(s)}catch{}if(s.reportable&&a&&typeof window<`u`){let r=o??import(`./telemetry.js`);o=r;let c={communitySlug:e,...n()};s.status!==void 0&&(c.status=s.status),r.then(({captureSdkError:e})=>e({context:c,contextName:i,dsn:a,environment:t,error:s})).catch(()=>{o===r&&(o=null)})}return s}}function ue(t,n,r){function i(t){let r=new e({code:t.code,message:t.message,operation:t.operation,reportable:!0});return t.report===!1?r:n(r)}async function a(e,n,a,o,s){let c=new AbortController,l=n?.signal??void 0,u=()=>c.abort(l?.reason);l?.aborted?u():l?.addEventListener(`abort`,u,{once:!0});let d,f=new Promise((e,t)=>{d=()=>t(c.signal.reason??new DOMException(`The request was aborted.`,`AbortError`)),c.signal.aborted?d():c.signal.addEventListener(`abort`,d,{once:!0})}),p=setTimeout(()=>{c.abort(new DOMException(`The request timed out.`,`TimeoutError`))},r);try{let r;try{r=await Promise.race([t(e,{...n,signal:c.signal}),f])}catch{throw i(o)}if(!r.ok)return{ok:!1,response:r};try{let e=await Promise.race([r.json(),f]);return{ok:!0,response:r,value:a(e)}}catch{throw i(s)}}finally{clearTimeout(p),l?.removeEventListener(`abort`,u),d&&c.signal.removeEventListener(`abort`,d)}}return{requestJson:a}}export{F as A,j as C,U as D,N as E,b as M,R as N,P as O,B as P,A as S,H as T,D as _,ce as a,g as b,Y as c,J as d,te as f,f as g,d as h,se as i,I as j,v as k,ne as l,T as m,le as n,oe as o,w as p,$ as r,ae as s,ue as t,re as u,m as v,M as w,k as x,h as y};
1
+ import{n as e}from"./types.js";import*as t from"valibot";import{ValiError as n,array as r,boolean as i,check as a,custom as o,looseObject as s,maxValue as c,minLength as l,minValue as u,nonEmpty as d,nullable as f,number as p,object as m,optional as h,parse as g,picklist as _,pipe as v,safeInteger as y,string as b,transform as x,union as ee,unknown as S,variant as C}from"valibot";const w=/\/+$/,T=new Set([`localhost`,`127.0.0.1`,`[::1]`]),E={development:{sentryDsn:`https://1977371f7bc44480935a7bc9726ca296@o1338376.ingest.sentry.io/6631829`},production:{sentryDsn:`https://43d2d853c129415cf77531c914511174@o1338376.ingest.us.sentry.io/4511911476133888`}};function D(e,t){let n;try{n=new URL(e)}catch{throw TypeError(`apiBaseUrl must be a valid HTTP or HTTPS URL.`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw TypeError(`apiBaseUrl must be a valid HTTP or HTTPS URL.`);if(n.username||n.password)throw TypeError(`apiBaseUrl must not include credentials.`);if(n.search||n.hash)throw TypeError(`apiBaseUrl must not include a query or fragment.`);if(n.protocol!==`https:`&&!(t===`development`&&T.has(n.hostname)))throw TypeError(`apiBaseUrl must use HTTPS except for development loopback endpoints.`);return n.pathname=n.pathname.replace(w,``),n.toString().replace(w,``)}function te(e,t){let r=`requestTimeoutMs must be a positive integer no greater than 2147483647.`,i=e=>v(b(`${e} must be a non-empty string.`),a(e=>e.trim().length>0,`${e} must be a non-empty string.`));try{let n=g(s({apiBaseUrl:h(b(`apiBaseUrl must be a valid HTTP or HTTPS URL.`)),communitySlug:i(`communitySlug`),environment:h(_([`development`,`production`],`environment must be either development or production.`)),fetch:h(o(e=>typeof e==`function`,`fetch must be a function when provided.`)),onError:h(o(e=>typeof e==`function`,`onError must be a function when provided.`)),requestTimeoutMs:h(v(p(r),y(r),u(1,r),c(2147483647,r))),sentryDsn:h(f(b(`sentryDsn must be a string or null when provided.`)))},`Expected an object.`),e);return{apiBaseUrl:n.apiBaseUrl,communitySlug:n.communitySlug,environment:n.environment,fetch:n.fetch,onError:n.onError,requestTimeoutMs:n.requestTimeoutMs,resourceSlugValue:g(i(t),n[t]),sentryDsn:n.sentryDsn}}catch(e){let t=e instanceof n?e.issues[0]?.message??`Invalid SDK options.`:`Invalid SDK options.`;throw TypeError(t)}}function O(e,t){let n=te(e,t),r=n.environment;if(n.apiBaseUrl!==void 0&&r===void 0)throw TypeError(`environment is required when apiBaseUrl is provided.`);if(n.apiBaseUrl===void 0&&r===`development`)throw TypeError(`apiBaseUrl is required when environment is development.`);let i=r===void 0?`production`:r,{communitySlug:a,resourceSlugValue:o}=n,s=n.fetch??globalThis.fetch,c=n.apiBaseUrl===void 0?`https://portal.lockerverse.com/api`:D(n.apiBaseUrl,i),l=E[i],u=n.sentryDsn,d=u===null?null:u??l.sentryDsn;return{apiBaseUrl:c,communitySlug:encodeURIComponent(a),communitySlugValue:a,environment:i,fetchImplementation:s,onError:n.onError,requestTimeoutMs:n.requestTimeoutMs??2e4,resourceSlug:encodeURIComponent(o),resourceSlugValue:o,sentryDsn:d}}function ne(e){let t=O(e,`signupSlug`);return{...t,signupSlug:t.resourceSlug,signupSlugValue:t.resourceSlugValue}}const k=v(b(),d(),a(e=>e.trim().length>0)),A=h(f(b()),null);function j(e){return v(p(),y(),u(e))}const M=v(r(S()),x(e=>e.filter(e=>{let{archivedAt:t}=g(s({archivedAt:h(f(k))}),e);return!t}))),N=m({id:k,label:k}),P=v(M,r(N),l(2),a(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Expected unique custom field option IDs.`)),F={id:k,label:k,required:i()},I=C(`type`,[m({...F,type:_([`text`,`textarea`])}),m({...F,type:_([`checkbox`])}),m({...F,options:P,type:_([`radio`,`select`])}),m({...F,options:P,type:_([`checkboxes`,`multi_select`])})]),L=v(h(M,[]),r(I),a(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Expected unique custom field IDs.`)),R=m({fieldId:k,value:ee([i(),b(),r(b())])}),z=t.object({percentageOff:t.number(),source:t.picklist([`email_list`,`promo_code`])}),B=t.object({acceptsDiscounts:t.optional(t.boolean()),listingId:t.string(),listingSlug:t.string(),paymentOption:t.picklist([`one-time`,`monthly`,`annually`]),pricingMode:t.picklist([`fixed`,`custom`]),productId:t.string(),productName:t.string(),quantity:t.number(),subtotalCents:t.number(),unitAmountCents:t.number()}),V=t.object({checkoutId:t.string(),checkoutStatus:t.picklist([`action_required`,`failed`,`pending`,`success`]),clientSecret:t.nullable(t.string()),paymentReference:t.string(),paymentRequired:t.boolean(),requiresAction:t.boolean(),status:t.nullable(t.string())}),H=t.object({amountCents:t.number(),appliedDiscount:t.nullable(z),connectedAccountId:t.nullable(t.string()),discountableSubtotalCents:t.number(),discountCents:t.number(),lineItems:t.array(B),paymentOption:t.picklist([`one-time`,`monthly`,`annually`]),serviceFeeCents:t.number(),subtotalCents:t.number(),tipCents:t.number(),totalCents:t.number()}),U=t.object({connectedAccountId:t.nullable(t.string()),currency:t.picklist([`usd`]),publishableKey:t.string()}),W=t.object({amountCents:t.optional(t.pipe(t.number(),t.minValue(100))),optionId:t.optional(t.pipe(t.string(),t.uuid())),productId:t.optional(t.pipe(t.string(),t.uuid())),quantity:t.optional(t.pipe(t.number(),t.minValue(1)))}),G=t.object({color:t.string(),name:t.string(),thumbnail:t.nullable(t.string())}),K=t.object({fieldId:t.string(),value:t.nullish(t.union([t.boolean(),t.string(),t.array(t.string())]))}),q=t.object({archivedAt:t.nullish(t.string()),id:t.string(),label:t.string()}),J=t.object({archivedAt:t.nullish(t.string()),id:t.string(),label:t.string(),options:t.optional(t.array(q)),required:t.boolean(),type:t.picklist([`text`,`textarea`,`select`,`multi_select`,`radio`,`checkbox`,`checkboxes`])}),re=t.object({percentageOff:t.pipe(t.number(),t.minValue(0),t.maxValue(100)),source:t.picklist([`email_list`,`promo_code`])}),Y=t.object({memberId:t.boolean(),merchSize:t.boolean(),phone:t.boolean(),promoCode:t.boolean(),serviceFee:t.boolean(),shipping:t.boolean(),tipping:t.boolean()}),X=t.object({customFields:t.array(J),fields:Y}),ie=t.object({currency:t.picklist([`usd`]),serviceFeeRateBasisPoints:t.number()}),ae=t.object({amountCents:t.nullable(t.number()),description:t.nullable(t.string()),id:t.string(),inventoryQuantity:t.nullable(t.number()),maxQuantity:t.nullable(t.number()),minimumAmountCents:t.nullable(t.number()),minQuantity:t.nullable(t.number()),name:t.string(),paymentOption:t.picklist([`one-time`,`monthly`,`annually`]),pricingMode:t.picklist([`fixed`,`custom`])}),oe=t.object({acceptsDiscounts:t.boolean(),id:t.string(),product:ae,productId:t.string(),slug:t.string()});t.object({email:t.optional(t.pipe(t.string(),t.email())),includeServiceFee:t.optional(t.boolean()),items:t.array(W),promoCode:t.optional(t.pipe(t.string(),t.maxLength(255))),tipCents:t.optional(t.pipe(t.number(),t.minValue(0)))});const se=t.object({community:G,config:X,description:t.nullable(t.string()),id:t.string(),name:t.string(),payment:U,pricingPolicy:ie,products:t.array(oe),quote:t.optional(H),showCommunityBranding:t.boolean(),title:t.nullable(t.string())}),ce=t.object({city:t.string(),country:t.string(),line1:t.string(),line2:t.optional(t.string()),postal_code:t.string(),state:t.string()}),le=t.object({address:ce,name:t.string()});t.object({confirmationToken:t.optional(t.string()),customFieldAnswers:t.optional(t.array(K)),email:t.pipe(t.string(),t.email()),expectedAmountCents:t.optional(t.pipe(t.number(),t.minValue(0))),expectedAppliedDiscount:t.nullish(re),expectedConnectedAccountId:t.nullish(t.string()),expectedDiscountableSubtotalCents:t.optional(t.pipe(t.number(),t.minValue(0))),expectedDiscountCents:t.optional(t.pipe(t.number(),t.minValue(0))),expectedServiceFeeCents:t.optional(t.pipe(t.number(),t.minValue(0))),expectedSubtotalCents:t.optional(t.pipe(t.number(),t.minValue(100))),expectedTipCents:t.optional(t.pipe(t.number(),t.minValue(0))),expectedTotalCents:t.optional(t.pipe(t.number(),t.minValue(0))),includeServiceFee:t.optional(t.boolean()),items:t.array(W),memberId:t.optional(t.string()),merchSize:t.optional(t.picklist([`XS`,`S`,`M`,`L`,`XL`,`XXL`,`XXXL`])),metadata:t.optional(t.record(t.string(),t.string())),paymentReference:t.optional(t.pipe(t.string(),t.uuid())),phone:t.optional(t.string()),promoCode:t.optional(t.string()),quoteContractVersion:t.optional(t.pipe(t.number(),t.minValue(1),t.maxValue(1))),shipping:t.optional(le),tipCents:t.optional(t.pipe(t.number(),t.minValue(0)))});const ue=t.object({city:t.string(),country:t.string(),line1:t.string(),line2:t.nullish(t.string()),postalCode:t.string(),state:t.string()}),de=t.object({fieldId:t.string(),value:t.nullish(t.union([t.boolean(),t.string(),t.array(t.string())]))}),fe=t.object({archivedAt:t.nullish(t.string()),id:t.string(),label:t.string()}),pe=t.object({archivedAt:t.nullish(t.string()),id:t.string(),label:t.string(),options:t.optional(t.array(fe)),required:t.boolean(),type:t.picklist([`text`,`textarea`,`select`,`multi_select`,`radio`,`checkbox`,`checkboxes`])}),Z=t.object({enabled:t.boolean(),required:t.boolean()}),me=t.object({address:Z,email:Z,name:Z,participantCount:Z,phone:Z}),Q=t.object({builtInFields:me,customFields:t.array(pe)}),he=t.object({config:Q,coverImageUrl:t.nullable(t.string()),description:t.nullable(t.string()),id:t.string(),isActive:t.boolean(),name:t.string(),slug:t.string(),title:t.nullable(t.string())});t.object({address:t.nullish(ue),answers:t.optional(t.array(de)),email:t.nullish(t.pipe(t.string(),t.email())),honeypot:t.optional(t.string()),name:t.string(),participantCount:t.nullish(t.pipe(t.number(),t.minValue(1))),phone:t.nullish(t.string()),submissionReference:t.optional(t.pipe(t.string(),t.uuid()))});const ge=t.object({id:t.string(),submittedAt:t.pipe(t.string(),t.isoTimestamp())});function $(e){if(typeof e!=`object`||!e||Object.isFrozen(e))return e;for(let t of Object.values(e))$(t);return Object.freeze(e)}function _e({communitySlug:e,environment:t,getContext:n,onError:r,resourceContextName:i,sentryDsn:a}){let o=null;return function(s){try{Promise.resolve(r?.(s)).catch(()=>void 0)}catch{}if(s.reportable&&a&&typeof window<`u`){let r=o??import(`./telemetry.js`);o=r;let c={communitySlug:e,...n()};s.status!==void 0&&(c.status=s.status),r.then(({captureSdkError:e})=>e({context:c,contextName:i,dsn:a,environment:t,error:s})).catch(()=>{o===r&&(o=null)})}return s}}function ve(t,n,r){function i(t){let r=new e({code:t.code,message:t.message,operation:t.operation,reportable:!0});return t.report===!1?r:n(r)}async function a(e,n,a,o,s){let c=new AbortController,l=n?.signal??void 0,u=()=>c.abort(l?.reason);l?.aborted?u():l?.addEventListener(`abort`,u,{once:!0});let d,f=new Promise((e,t)=>{d=()=>t(c.signal.reason??new DOMException(`The request was aborted.`,`AbortError`)),c.signal.aborted?d():c.signal.addEventListener(`abort`,d,{once:!0})}),p=setTimeout(()=>{c.abort(new DOMException(`The request timed out.`,`TimeoutError`))},r);try{let r;try{r=await Promise.race([t(e,{...n,signal:c.signal}),f])}catch{throw i(o)}if(!r.ok)return{ok:!1,response:r};try{let e=await Promise.race([r.json(),f]);return{ok:!0,response:r,value:a(e)}}catch{throw i(s)}}finally{clearTimeout(p),l?.removeEventListener(`abort`,u),d&&c.signal.removeEventListener(`abort`,d)}}return{requestJson:a}}export{H as a,ge as c,k as d,A as f,ne as h,V as i,R as l,O as m,_e as n,se as o,j as p,$ as r,he as s,ve as t,L as u};
2
2
  //# sourceMappingURL=transport.js.map