PageSourceSearch

https://saharalondon.com/cdn/shopifycloud/checkout-web/assets/c1/client.DRetCTka.js

js saharalondon.com collected 2026-09-26 07:00:14 UTC 12,916 bytes, 2 lines download raw bytes

1import{v as U}from"./dist-v4.EwEgHOG0.js";const j={production:"https://frontend-event-collector.shopifysvc.com/produce",development:"https://frontend-event-collector-staging.shopifysvc.com/produce",origin:"/.well-known/shopify/fec/produce"};function S(s){const e=s.client?.message;return e==null?"Client message undefined":[`CreatedAt: ${e.createdAt}`,`SentAt: ${e.sentAt}`,`LowId: ${e.id?.lowid}`,`HighId: ${e.id?.highid}`].join(" / ").replace(/ \/ $/,"").trim()}class x{producer;logOptions;static TAG="ProducerMiddleware";constructor(e,t){this.producer=e,this.logOptions=t}do(e,t){return this.logOptions.logger({tags:[x.TAG],message:`Producing ${e.length} events`,metadata:this.logOptions.verbose?{messages:e.map(S)}:void 0}),this.producer.produce(e)}flush(){this.logOptions.logger({tags:[x.TAG],message:"Flushing producer"}),this.producer.flush()}}class k extends Error{cause;constructor(e,t){super(e),this.cause=t,this.name="ProtoError",t instanceof Error?this.stack=t.stack:t?this.stack=new Error(t).stack:this.stack=new Error().stack}}class O extends k{cause;constructor(e,t){super(e,t),this.cause=t,this.name="ProtoRequestError"}}class z extends O{phase;details;constructor(e,t,r,n){super(t,n),this.name="ProtoTransportError",this.phase=e,this.details=r}}class G extends k{constructor(e,t,r){super(`[${e}] ${t??"Error message not provided"} (CODE: ${r??-1})`)}}class D extends G{constructor(e,t){super(`Event Result ${e}`,t.error_msg,t.error_code),this.name="ProtoEventResultError"}}class q extends G{status;requestId;constructor(e){super("Batch Result",e.batch_result.error_msg,e.batch_result.error_code),this.name="ProtoResponseError",this.status=e.status,this.requestId=e.requestId;const t=[`Status: ${e.status} ${e.statusText}`,`X-Request-ID: ${e.requestId}`];for(const[r,n]of Object.entries(e.event_results))if(n.state==="ERROR"){const a=new D(Number(r),n);t.push(a.message)}this.stack=t.join(`
2`)}}function N(s){return s.map(H)}function H(s){const e=s.client;if(!e)return s;const t=e.message;return t?{...s,client:{...e,message:{...t,sentAt:new Date().toISOString()}}}:s}function L(s){return s.forEach(e=>{const t=C(e.client,"ClientContext is not set"),r=C(t.message,"ClientContext.Message is not set");C(r.sentAt,"ClientContext.Message.sentAt is not set")}),JSON.stringify({events:s})}function C(s,e){if(!s)throw new Error(e);return s}class y{endpoint;logOptions;options;static TAG="HttpProducer";constructor(e,t,r){this.endpoint=e,this.logOptions=t,this.options=r}async produce(e){if(e.length===0)throw new O("No envelopes to produce");let t,r;try{r=N(e),t=L(r)}catch(d){throw this.transportError("serialize","HttpProducer serialize step failed",{endpoint:this.endpoint},d)}const n=typeof Blob=="function"?new Blob([t],{type:"application/json"}):void 0,a=n&&typeof n.size=="number"?n.size:X(t);this.logOptions.logger({tags:[y.TAG],message:`Producing ${r.length} envelope(s)`,metadata:this.logOptions.verbose?{envelopes:r}:{messages:r.map(S)}});let o=!1,u=!1,l={};try{if(l=this.options?.headers?.()||{},!(Object.keys(l).length>0)&&n&&J())try{const E=navigator.sendBeacon.bind(navigator);if(o=!0,u=E(this.endpoint,n),u)return this.logOptions.logger({tags:[y.TAG],message:"Successfully produced via sendBeacon"}),{batch_result:{state:"ENQUEUED"},event_results:{},status:200,statusText:"OK",requestId:""}}catch{u="threw"}l["Content-Type"]="application/json"}catch(d){throw this.transportError("serialize","HttpProducer header setup failed",{endpoint:this.endpoint,payloadBytes:a,usedSendBeacon:o,beaconResult:u},d)}const g=a<6e4;let c;try{c=await fetch(this.endpoint,{method:"POST",headers:l,body:t,keepalive:g,...this.options?.timeout?{signal:AbortSignal.timeout(this.options.timeout)}:{}})}catch(d){if(d instanceof O||d instanceof q)throw d;const E=d,b=Z(E,o,u);throw this.transportError(b,"HttpProducer produce call failed",{endpoint:this.endpoint,payloadBytes:a,usedSendBeacon:o,beaconResult:u,keepalive:g},E)}let f;try{f=await c.text()}catch(d){throw this.transportError("response_parse","Failed to read response body",{endpoint:this.endpoint,payloadBytes:a,usedSendBeacon:o,beaconResult:u,keepalive:g,responseStatus:c.status,responseStatusText:c.statusText},d)}let p;try{if(p={...JSON.parse(f),status:c.status,statusText:c.statusText,requestId:c.headers.get("x-request-id")||""},c.ok)return this.logOptions.logger({tags:[y.TAG],message:"Successfully produced via fetch"}),p}catch(d){throw this.transportError("response_parse",`Failed to parse response body: ${f}`,{endpoint:this.endpoint,payloadBytes:a,usedSendBeacon:o,beaconResult:u,keepalive:g,responseStatus:c.status,responseStatusText:c.statusText},d)}throw W(p)?new q(p):this.transportError("response_parse","Failed to parse response body: invali
2d ProtoResponse error body",{endpoint:this.endpoint,payloadBytes:a,usedSendBeacon:o,beaconResult:u,keepalive:g,responseStatus:c.status,responseStatusText:c.statusText},new Error("Invalid ProtoResponse error body"))}flush(){}transportError(e,t,r,n){const a={...r,causeName:n.name,causeMessage:n.message};return this.logOptions.logger({tags:[y.TAG],message:`Produce failed: ${e} (${n.name}: ${n.message})`,metadata:{phase:e,...a},error:n}),new z(e,t,a,n)}}function W(s){return M(s.batch_result)&&M(s.event_results)}function M(s){return typeof s=="object"&&s!==null}function J(){return typeof navigator<"u"&&typeof navigator.sendBeacon=="function"}function X(s){return typeof TextEncoder=="function"?new TextEncoder().encode(s).length:s.length}function K(s){return s.name==="AbortError"||s.name==="TimeoutError"}function Z(s,e,t){return K(s)?"fetch_abort":e?t==="threw"?"beacon_throw_fetch_failed":"beacon_false_fetch_failed":"fetch_throw"}function V(s=[]){return{batch_result:{state:"ENQUEUED",error_code:0,error_msg:void 0},event_results:Object.fromEntries(s.map((e,t)=>[t.toString(),{state:"ENQUEUED",error_code:0,error_msg:void 0}])),status:200,statusText:"OK",requestId:""}}class B{logOptions;static TAG="LogProducer";constructor(e){this.logOptions=e}async produce(e){return this.logOptions.logger({tags:[B.TAG],message:`Producing ${e.length} envelope(s)`,metadata:this.logOptions.verbose?{envelopes:e}:{messages:e.map(S)}}),V(e)}flush(){}}class m{middleware;logOptions;static identityFn;static TAG="ProtoProducer";static createLogProducer({middleware:e,logOptions:t}){return new m(new B(t),e||[],t)}static createHttpProducer({endpoint:e,middleware:t,httpOptions:r,logOptions:n}){return new m(new y(j[e],n,r),t||[],n)}static buildMiddlewareChain(e,t=0){return t===e.length?m.identityFn:r=>e[t].do(r,this.buildMiddlewareChain(e,t+1))}static buildMiddlewareFlushChainFn(e,t=0){return t===e.length?()=>{}:()=>{e[t].flush(),this.buildMiddlewareFlushChainFn(e,t+1)()}}executeChain;executeFlushChain;constructor(e,t,r){this.middleware=t,this.logOptions=r;const n=new x(e,r);this.executeChain=m.buildMiddlewareChain(this.middleware.concat(n)),this.executeFlushChain=m.buildMiddlewareFlushChainFn(this.middleware.concat(n))}produce(e){return this.logOptions.logger({tags:[m.TAG],message:"Producing events",metadata:{eventCount:e.length,messages:e.map(S)}}),this.executeChain(e)}flush(){this.logOptions.logger({tags:[m.TAG],message:"Flushing producer"}),this.executeFlushChain()}}class Y{protoProducer;constructor({endpoint:e="development",producer:t="http",logOptions:r={verbose:!1,logger:()=>{}},middleware:n=[],httpOptions:a={timeout:void 0,headers:void 0}}={}){const o={endpoint:e,producer:t,logOptions:{verbose:r?.verbose??!1,logger:({tags:u,message:l,metadata:g,error:c})=>{r?.logger({tags:["proto-ts",...u],message:l,metadata:g,error:c})}},middleware:n,httpOptions:a};if(o.producer==="http")this.protoProducer=m.createHttpProducer({endpoint:o.endpoint,middleware:o.middleware,httpOptions:o.httpOptions,logOptions:o.logOptions});else if(o.producer==="log")this.protoProducer=m.createLogProducer({middleware:o.middleware,logOptions:o.logOptions});else throw new Error(`Invalid producer: ${o.producer}`)}get producer(){return this.protoProducer}async produceEvents(e){return this.protoProducer.produce(e)}async produceEvent(e){return this.produceEvents([e])}flush(){this.protoProducer.flush()}}function ee(s,e,t){const r=t?.leading??!1,n=t?.trailing??!0,a=t?.maxWait,o=a!==void 0,u=o?Math.max(a,e):0;let l,g,c=0,f,p;function d(i){const h=f;return f=void 0,c=i,p=s.apply(h?.context,h?.args),p}function E(i,h){l=setTimeout(i,h)}function b(){l!==void 0&&(clearTimeout(l),l=void 0)}function Q(i){const h=i-(g??0),v=i-c,F=e-h;return o?Math.min(F,u-v):F}function _(i){const h=g===void 0?void 0:i-g,v=i-c;return h===void 0||h>=e||h<0||o&&v>=u}function P(i){return l=void 0,n&&f!==void 0?d(i):(f=void 0,p)}function T(){const i=Date.now();if(_(i)){P(i);return}E(T,Q(i))}function R(i){return c=i,E(T,e),r?d(i):p}function I(...i){const h=Date.now(),v=_(h);if(f={args:i,context:this},g=h,v){if(l===void 0)return R(h);if(o)return b(),E(T,e),d(h)}return l===void 0&&E(T,e),p}return I.cancel=function(){b(),c=0,f=void 0,g=void 0},I.flush=function(){return l===void 0?p:P(Date.now())},I.pending=function(){return l!==void 0},I}
2class te extends Error{constructor(e){super(e),this.name="BatchEventQueueError"}}class se{queue;_promise;_resolve;_reject;_nextMiddleware;flushed=!1;constructor(e){this.queue=[],this._nextMiddleware=e,this._promise=new Promise((t,r)=>{this._resolve=t,this._reject=r})}add(e){if(this.flushed)throw new te("Queue already flushed");this.queue.push(...e)}flush(){this.flushed||(this._nextMiddleware(this.queue).then(this._resolve).catch(this._reject),this.flushed=!0)}get promise(){return this._promise}get length(){return this.queue.length}}const re=500,ne=2e3,oe=20;class w{static TAG="BatchMiddleware";state={type:"initial"};scheduleFlush;maxQueueSize;logger;shouldSkipBatching;constructor(e){const t=e?.debounceCoolOffMs??re,r=e?.maxWaitTimeMs??ne;this.maxQueueSize=e?.maxQueueSize??oe,this.logger=e?.logger??(()=>{}),this.shouldSkipBatching=e?.shouldSkipBatching,this.scheduleFlush=ee(()=>{this.state.type==="open"&&this.flushCurrentQueue()},t,{maxWait:r})}do(e,t){if(this.shouldSkipBatchingForAny(e))return this.logger({tags:[w.TAG],message:"Skipping batch queue",metadata:{eventCount:e.length}}),t(e);const r=this.getOrCreateQueue(t);return this.logger({tags:[w.TAG],message:"Adding events to queue",metadata:{state:this.state.type,queueSize:r.length,eventCount:e.length}}),r.add(e),r.length>=this.maxQueueSize?(this.scheduleFlush.cancel(),this.flushCurrentQueue()):this.scheduleFlush(),r.promise}flush(){this.logger({tags:[w.TAG],message:"Flushing queue",metadata:{state:this.state.type,queueSize:this.state.type==="open"?this.state.queue.length:void 0}}),this.state.type==="open"&&(this.scheduleFlush.cancel(),this.flushCurrentQueue())}shouldSkipBatchingForAny(e){return e.some(t=>this.shouldSkipBatching?.(t)===!0)}getOrCreateQueue(e){if(this.state.type==="initial")return this.createQueue(e);const t=this.state.queue;return t.flushed?this.createQueue(e):t}createQueue(e){const t=new se(e);return this.state={type:"open",queue:t},t}flushCurrentQueue(){if(this.state.type==="open"){const e=this.state.queue;this.logger({tags:[w.TAG],message:"Flushing current queue",metadata:{queueSize:e.length}}),e.flush(),this.state={type:"initial"}}}}class ie{uuidProvider;constructor(e){this.uuidProvider=e}createGlobalId(e){if(typeof e=="number"&&this.isUint64(e.toString()))return{lowid:e.toString(),highid:void 0};if(typeof e=="string"){if(this.isUint64(e))return{lowid:e,highid:void 0};if(this.isUuid(e))return this.convertUuidToGlobalId(e)}}isUint64(e){if(!/^\d+$/.test(e))return!1;const t=BigInt(0),r=BigInt("18446744073709551615"),n=BigInt(e);return n>=t&&n<=r}isUuid(e){return/^(?:[a-f0-9]{32}|[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})$/i.test(e.trim())}convertUuidToGlobalId(e){const t=e?.trim();if(!t)return;const r=this.uuidProvider.parse(t),n=new Uint8Array(r);let a=BigInt(0);for(let u=0;u<8;u++)a=a<<BigInt(8)|BigInt(n[u]);let o=BigInt(0);for(let u=8;u<16;u++)o=o<<BigInt(8)|BigInt(n[u]);return{lowid:o.toString(),highid:a.toString()}}}var A;(function(s){s.EventTypeIdentifier="@type";function e(t,r){const n={...r};return delete n[s.EventTypeIdentifier],{...t,timestamp:void 0,payload:{...n,[s.EventTypeIdentifier]:`type.googleapis.com/${r[s.EventTypeIdentifier]}`}}}s.createEnvelope=e})(A||(A={}));const $={v4:()=>U(),parse:s=>{const e=s.replace(/-/g,"");return Array.from({length:16},(t,r)=>parseInt(e.slice(r*2,r*2+2),16))}},ue=new ie($);class ae extends Error{constructor(){super(...arguments),this.name="MessageIdMintError"}}function ce(){const s=ue.createGlobalId($.v4());if(!s)throw new ae("ProtoGlobalIdProvider failed to mint a message id");return s}class de{#e=[];async get(){return this.#e}async set(e){this.#e=e}async clear(){this.#e=[]}}function he(){const s=new Y({endpoint:"origin",middleware:[new w({storage:new de,logger:({tags:e,message:t})=>{}})]});return{proto:A,client:s,createMessageId:ce,flush(){s.flush()}}}export{he as createProtoHub};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.