@inploi/sdk 3.1.1 → 3.1.2
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/cdn/index.js +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as Tt}from"./chunk-KC7FKSIJ.mjs";var te="%c[inploi SDK]",ne="color: #65BC67; font-weight: bold;",fe={warn:(...t)=>console.warn(te,ne,...t),error:(...t)=>console.error(te,ne,...t),info:(...t)=>console.info(te,ne,...t),log:(...t)=>console.log(te,ne,...t)},ye={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var Et=t=>t;function Se(t,n){if(!t)throw new Error(n)}function M(t,n){return n in t}var Hn=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});var xt="Unauthenticated",It="This action is unauthorized.",O=class extends Error{constructor(r,i){super(r);this.status=i,this.name="ErrorWithStatus"}},G=class extends O{constructor(n){super(n??"Not found"),this.name="NotFoundError",this.status=404}},q=class extends O{constructor(n,r){super(n??"You are not authorised to perform this action."),this.name="UnauthorisedError",this.status=r??401}},w=class extends O{constructor(r,i){let l=i?` in ${i}`:"";super(`Schema validation failed${l}`);this.issues=r;this.source=i;this.name="SchemaValidationError",this.status=400}},V=class extends O{constructor(r,i,l){super(r);this.data=l;this.name="ApiError",this.status=i??500}},Rt=t=>t instanceof V&&t.data!==void 0,$=class extends O{constructor(r){super("Error parsing response into JSON.");this.response=r;this.name="ParsingError",this.status=r&&r.status>=300?r.status:500,this.contentType=new Headers(r?.headers).get("content-type")??void 0}};async function be(t){let r=new Headers(t.headers).get("content-type")?.replace(/;.*/,"").trim().toLowerCase();if(r&&r!=="application/json"&&!r.endsWith("+json"))throw new $(t);return t.json().catch(()=>{throw new $(t)})}var wt=["message","error","errors","exception","exceptions"];function Pt(t){let n=[];if(typeof t=="object"&&t!==null){for(let r of wt)if(M(t,r)){let i=t[r];typeof i=="string"&&n.push(i),Array.isArray(i)&&i.every(l=>typeof l=="string")&&n.push(...i)}M(t,"integration_response")&&typeof t.integration_response=="object"&&t.integration_response!==null&&M(t.integration_response,"error")&&typeof t.integration_response.error=="object"&&t.integration_response.error!==null&&M(t.integration_response.error,"message")&&typeof t.integration_response.error.message=="string"&&n.push(t.integration_response.error.message)}return n.length===0&&n.push("Unknown error"),[...new Set(n)].join(", ")}function _e(t,n){if(n>=300){let r=Pt(t);throw n===404?new G(r):r===xt?new q("You are not authenticated.",n):r===It?new q(r,n):new V(r,n,t)}}var je=t=>{let n={Accept:"application/json","Content-Type":"application/json","x-publishable-key":t.publishableKey};return{fetch:async(r,i={})=>{let l={...i,headers:{...i.headers,...n}},c=await fetch(`${t.baseUrl}${r}`,l);if(c.status===404)throw new G;let d=await be(c);return _e(d,c.status),d}}},Ne={NotFound:G,Unauthorised:q,SchemaValidation:w,Api:V,JsonParsing:$};function kt(t){return Object.values(Ne).some(n=>t instanceof n)}var Fe="3.1.1";var re={sandbox:"https://api.staging.inploi.com",production:"https://api.inploi.com",_internal_local:"http://api.test"},Ue={sandbox:"https://talent-bank.staging.inploi.com",production:"https://talent-bank.inploi.com",_internal_local:"http://localhost:8787"},Be=Fe;var P="isdk_session",Me=`${P}-candidate_id`,Ge=`${P}-consent`;var oe=new Map,Ae={get:t=>{if(oe.has(t))return oe.get(t)??null;try{return window.sessionStorage.getItem(t)}catch{return null}},set:(t,n)=>{try{window.sessionStorage.setItem(t,n),oe.delete(t)}catch{oe.set(t,n)}}};var J=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"10000000-1000-4000-8000-100000000000".replace(/[018]/g,t=>(+t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+t/4).toString(16));var Ve=7*24*60*60*1e3,$e=t=>{let n=new Date;return n.setTime(n.getTime()+Ve),`${P}=${t};expires=${n.toUTCString()};path=/`},Lt=(t,n)=>{let r=t.get("session_id");if(n||r)return r;let i=Ae.get(`${P}-session_id`);return typeof i=="string"?i:null},Dt=()=>{if(typeof window>"u")return null;try{let t=window.localStorage.getItem(Me);return typeof t=="string"&&t!==""?t:null}catch{return null}},Ot=new RegExp(`(?:^|;\\s*)${P}=([^;]+)`),Y=t=>{let n=t?t.headers.get("cookie"):document.cookie;return n?Ot.exec(n)?.[1]??null:null},He=()=>{try{let t=JSON.parse(window.localStorage.getItem(P)??"null");return typeof t!="object"||t===null||!("id"in t)||!("expires"in t)||typeof t.id!="string"||typeof t.expires!="number"?null:t.id!==""&&t.expires>Date.now()?t.id:null}catch{return null}},qe=()=>Y()??(new URL(location.href).searchParams.get("anonymous_id")?null:He()),jt=()=>location.protocol==="https:"&&window.self!==window.top?";SameSite=None;Secure;Partitioned":"",Ke=t=>{if(document.cookie=$e(t)+jt(),Y()!==t)try{window.localStorage.setItem(P,JSON.stringify({id:t,expires:Date.now()+Ve}))}catch{}},Te=t=>{let n=t?t.url:location.href,{searchParams:r}=new URL(n);return{anonymous_id:t?Y(t)??r.get("anonymous_id"):Y()??r.get("anonymous_id")??He(),session_id:Lt(r,typeof window>"u")}},We=()=>{if(typeof window>"u")throw new Error("getOrCreateAnonymousId() can only be called in browser environment");let t=Te().anonymous_id;if(t)return t;let n=J(),r=Te().anonymous_id;return r||(Ke(n),n)},Nt=t=>typeof t!="object"||t===null?null:{anonymous_id:"anonymous_id"in t&&typeof t.anonymous_id=="string"?t.anonymous_id:null,session_id:"session_id"in t&&typeof t.session_id=="string"?t.session_id:null},Ft=t=>t==="about:client"?"":t,Ut={pathname:"/log",method:"POST",schema:{response:C(),body:C()}},Je=({rpcClient:t,logger:n,onEvent:r,persistence:i="device",siteKind:l})=>{let c=null,d=null,u=0,S=0,E=p=>i==="none"?{anonymous_id:null,session_id:p?null:c}:Te(p),U=async(p,h,X)=>{try{let B={library:{name:"inploi-sdk",version:Be},page:h},W=E(p.request),ee=i==="none"?null:Dt(),f={anonymous_id:W.anonymous_id,session_id:W.session_id,candidate_id:ee,event:p.event,sent_at:new Date().toISOString(),context:B,properties:p.properties,custom_properties:{...p.customProperties,...X}},ve=i==="none"?null:p.request?Y(p.request):qe(),De=++u,_t=await t.request(Ut,{body:f,...p.keepalive&&{keepalive:!0}}),x=Nt(_t);if(i==="none")return!p.request&&x?.session_id&&De>S&&(S=De,x.session_id!==f.session_id&&(c=x.session_id)),f.session_id=p.request?x?.session_id||null:c,r?.(f),{success:!0,data:f};let ge=p.request?ve:qe(),At=ge!==null&&ge!==ve,he=ge??ve,Oe=!At&&(!he||!x?.anonymous_id||he===x.anonymous_id);return Oe?(x?.anonymous_id&&(f.anonymous_id=x.anonymous_id),x?.session_id&&(f.session_id=x.session_id)):f.anonymous_id=he,!p.request&&typeof window<"u"&&f.anonymous_id&&(Oe&&f.session_id&&Ae.set(`${P}-session_id`,f.session_id.toString()),Ke(f.anonymous_id)),r?.(f),{success:!0,data:f}}catch(B){return n.error("Failed to send log to API. Inspect error response of `log` for more information."),{success:!1,error:B}}},D=Promise.resolve();return{log:async p=>{Se(p.request||typeof window<"u","Cannot log on the server without a request. Please pass a request to `log`.");let h="request"in p&&p.request?{href:p.request.url,referrer:Ft(p.request.referrer),title:""}:{href:location.href,referrer:document.referrer,title:document.title};if(p.page_context==="no_query"){let ee=new URL(h.href),f=h.referrer?new URL(h.referrer):void 0;h={href:ee.origin+ee.pathname,referrer:f?f.origin+f.pathname:""}}i==="none"&&p.event==="FLOW_NODE"&&p.properties&&"trigger"in p.properties&&(p.properties.trigger==="pagehide"||p.properties.trigger==="hidden")&&(p={...p,keepalive:!0});let X={event_id:J(),consent_lane:i,site_kind:l};if(i==="device"||p.request||c||p.keepalive)return U(p,h,X);let B=()=>U(p,h,X),W=D.then(B,B);return D=W,W},supportsNoQueryPageContext:!0,getHeaders:p=>{let h=new Headers;return i==="none"||!p?.anonymous_id||h.append("Set-Cookie",$e(p.anonymous_id)),h},getSessionInfo:E,getOrCreateAnonymousId:()=>i==="none"?d??(d=J()):We()}};import{stringify as Bt}from"neoqs";function Ee(t,n,r){let i=t["~standard"].validate(n);if(i instanceof Promise)throw new TypeError("Async schema");if(i.issues)throw new w(i.issues,r);return i.value}function Mt(t,n,r){try{return{success:!0,output:Ee(t,n,r)}}catch(i){if(i instanceof w)return{success:!1,issues:i.issues,source:i.source};throw i}}var z=class{constructor(n){if(this.baseUrl=re[n.environment],this.headers=new Headers({"Content-Type":"application/json",Accept:"application/json"}),n.apiKey.type==="secret"){if(typeof window<"u")throw new Error("Secret key cannot be used in a browser environment");this.headers.set("x-secret-key",n.apiKey.key)}else this.headers.set("x-publishable-key",n.apiKey.key);this.logger=n.logger,this._environment=n.environment}get environment(){return this._environment}getFetchParams(n,r){let i=r.validateIn??!0,{searchParams:l,body:c}=i?Ye(n,r):r,d=new URL(this.baseUrl),u=n.pathname;if("params"in r&&r.params)for(let[S,E]of Object.entries(r.params))u=u.replace(`:${S}`,String(E));return d.pathname=u,n.schema.searchParams&&(d.search=Bt(l)),[d.toString(),{method:n.method,body:c?JSON.stringify(c):void 0,headers:this.headers,signal:r.signal,...r.keepalive&&{keepalive:!0}}]}async parseResponse(n,r){let i=await be(r.response);if(_e(i,r.response.status),!(r.validateOut??!0))return i;let c=Mt(n.schema.response,i,"response");if(!c.success)throw new w(c.issues,c.source);return c.output}async request(n,r){try{let i=this.getFetchParams(n,r),l=await fetch(...i);return await this.parseResponse(n,{response:l,validateOut:r.validateOut})}catch(i){throw i instanceof w?this.logger.error(i.message,i.issues):this.logger.error(i),i}}};function C(){return{"~standard":{vendor:"inploi",version:1,validate:t=>({value:t})}}}function ie(t){return t}function Ye(t,n){let r={searchParams:void 0,body:void 0,validateIn:!1};return t.schema.searchParams&&(r.searchParams=Ee(t.schema.searchParams,"searchParams"in n?n.searchParams:{})),t.schema.body&&(r.body=Ee(t.schema.body,"body"in n?n.body:{})),r}function Gt({publishableKey:t,env:n,logger:r=fe,onEvent:i,persistence:l,siteKind:c}){let d=je({baseUrl:re[n],publishableKey:t}),u=r===!1?ye:r,S=new z({environment:n,apiKey:{type:"publishable",key:t},logger:u}),E=Je({rpcClient:S,logger:u,onEvent:i,persistence:l,siteKind:c});return{register:D=>D({logger:u,apiClient:d,analytics:E,rpcClient:S,publishableKey:t,env:n}),analytics:E,apiClient:d}}var qt={VIEW_PAGE:"A careers-site page shown (not a job page).",VIEW_JOB:"A job's own page shown; one per job id the page names.",PAGE_ENGAGEMENT:"A page view's attention summary, sent when the view is hidden or left.",VIEW_SEARCH:"A job search seen for two seconds.",SEARCH_SETTLE:"A searched query or filter with results, unchanged for five seconds.",SEARCH_RESULTS:"A search whose results returned, zero included; once per distinct query, filters, place and order.",SEARCH_PAGINATE:"A move to another page of search results.",SEARCH_JOB_CLICK:"A job opened from search results.",SAVE_JOB:"A job saved or unsaved by the candidate.",LINK_CLICK:"A tracked link clicked.",INTERACTION:"A tagged interaction (`tag` names it).",FLOW_START:"An application flow started.",FLOW_INTERACT:"The candidate's first answer in a flow.",FLOW_END:"An application flow ended.",FLOW_NODE:"The candidate's path through an application, summarised when it pauses or ends.",FLOW_SUBMIT:"An application submitted, with the outcome.",FLOW_REDIRECT:"A flow sent the candidate to an external apply page.",FEEDBACK:"A rating or comment.",ADDRESS_SHADOW_COMPARED:"Engineering telemetry: the address lookup's shadow comparison.",SUBMIT_FORM:"Declared but sent by nothing."};function xe(t){let n=JSON.stringify({message:t.message,acceptLabel:t.acceptLabel??"",declineLabel:t.declineLabel??""}),r=5381;for(let i=0;i<n.length;i++)r=r*33^n.charCodeAt(i);return(r>>>0).toString(36)}function Ie(t,n){return`${Ge}:${t}:${n}`}function Vt(t,n){if(typeof window>"u")return!1;try{let r=Ie(t,xe(n));return window.localStorage.getItem(r)==="accepted"}catch{return!1}}function $t(t,n){if(!(typeof window>"u"))try{let r=Ie(t,xe(n));window.localStorage.setItem(r,"accepted")}catch{}}import*as s from"valibot";var Ht=["agent","sdk","form","integration","migration"],Kt=["APPLIED","SHORTLISTED","INTERVIEWED","OFFERED","HIRED","REJECTED","WITHDRAWN"];var Wt=["screening","cv_match","interview","overall"],Jt=["PENDING","IN_PROGRESS","COMPLETED","CANCELLED"],Yt=["agent"],zt=["job","company"],Qt=["created_at","updated_at","score","interview_score"],Zt=["asc","desc"],Xt=["careers_site","chatbot","plugin_job_search","ats_import","referral","agency","other","unknown"],en=["submit","stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate","score_written","ats_submission_attempted","ats_submission_succeeded","ats_submission_failed","ats_retry_payload_purged"],tn=["pending","submitted","failed","not_required"],nn=["user","system","automation","integration","candidate"],se=s.picklist(Ht),I=s.picklist(Kt),T=s.pipe(s.string(),s.trim(),s.minLength(1),s.maxLength(100)),ae=s.picklist(Wt),ze=s.picklist(Jt),Qe=s.picklist(Yt),xr=s.picklist(zt),Ze=s.picklist(Qt),Xe=s.picklist(Zt),Q=s.pipe(s.string(),s.trim(),s.minLength(1),s.maxLength(100)),ce=s.picklist(Xt),et=s.picklist(en),tt=s.picklist(nn),j=s.picklist(tn);var _=s.variant("type",[s.object({type:s.literal("user"),id:s.pipe(s.string(),s.minLength(1)),email:s.pipe(s.string(),s.minLength(1)),name:s.pipe(s.string(),s.minLength(1))}),s.object({type:s.literal("system"),id:s.pipe(s.string(),s.minLength(1)),name:s.optional(s.string())}),s.object({type:s.literal("automation"),id:s.pipe(s.string(),s.minLength(1)),name:s.optional(s.string())}),s.object({type:s.literal("integration"),id:s.pipe(s.string(),s.minLength(1)),name:s.optional(s.string())}),s.object({type:s.literal("candidate"),id:s.pipe(s.string(),s.minLength(1)),email:s.optional(s.string())})]);import*as R from"valibot";var rn=R.object({total:R.number(),page:R.number(),perPage:R.number(),lastPage:R.number()});function nt(t){return R.object({data:R.array(t),pagination:rn})}import*as y from"valibot";var Re=y.object({id:y.string(),email:y.nullable(y.string()),firstName:y.nullable(y.string()),lastName:y.nullable(y.string()),phone:y.nullable(y.string()),source:y.nullable(se),identifiedAt:y.nullable(y.string()),createdAt:y.string(),updatedAt:y.string()});import*as o from"valibot";import*as g from"valibot";var L=g.pipe(g.string(),g.minLength(1)),Z=g.pipe(g.number(),g.integer(),g.minValue(1)),k=g.record(g.string(),g.unknown()),on="(?!\\.{1,2}(?:/|$))[A-Za-z0-9._-]{1,128}",kr=g.pipe(g.string(),g.regex(new RegExp(`^${on}$`)));import*as b from"valibot";var rt=b.object({id:b.string(),applicationId:b.string(),status:ze,conductedBy:Qe,agentInterviewId:b.nullable(b.string()),generatedScore:b.nullable(b.number()),completedAt:b.nullable(b.string()),meta:b.nullable(k),createdAt:b.string(),updatedAt:b.string()});var sn=o.object({quote:o.string(),source:o.picklist(["cv","answer"])}),we=o.object({score:o.number(),reason:o.string(),confidence:o.number(),share:o.optional(o.number()),evidence:o.optional(o.array(sn))}),Pe=o.object({categoryId:o.string(),answerKey:o.string(),reason:o.picklist(["unanswered","unrecognised"])}),ot=o.object({id:o.string(),candidateId:o.string(),jobId:o.number(),stage:T,stageGroup:I,stageEnteredAt:o.string(),rating:o.nullable(o.number()),disqualifiedAt:o.nullable(o.string()),disqualificationReason:o.nullable(Q),disqualificationNote:o.nullable(o.string()),source:ce,sourceDetail:o.nullable(o.string()),sessionId:o.nullable(o.number()),externalApplicationId:o.nullable(o.string()),meta:o.nullable(k),context:o.nullable(k),scoredAt:o.nullable(o.string()),atsSubmissionStatus:o.optional(o.nullable(j)),atsSubmissionAttempts:o.optional(o.number()),atsNextAttemptAt:o.optional(o.nullable(o.string())),atsSubmittedAt:o.optional(o.nullable(o.string())),atsLastErrorCode:o.optional(o.nullable(o.string())),atsLastErrorMessage:o.optional(o.nullable(o.string())),createdAt:o.string(),updatedAt:o.string()}),an=o.object({id:o.string(),applicationId:o.string(),scoreType:ae,score:o.nullable(o.number()),reason:o.nullable(o.string()),categories:o.nullable(o.record(o.string(),we)),leftOut:o.optional(o.array(Pe)),scoredBy:o.nullable(o.string()),createdAt:o.string()}),N=o.object({...ot.entries,candidate:o.nullable(Re),score:o.nullable(an),interview:o.nullable(rt)}),Br=o.object({...Re.entries,applications:o.array(ot)}),it=o.object({id:o.string(),applicationId:o.string(),action:et,fromStage:o.nullable(T),fromStageGroup:o.nullable(I),toStage:o.nullable(T),toStageGroup:o.nullable(I),disqualificationReason:o.nullable(Q),disqualificationNote:o.nullable(o.string()),actorId:o.nullable(o.string()),actorType:tt,actorEmail:o.nullable(o.string()),actorName:o.nullable(o.string()),meta:o.nullable(k),schemaVersion:o.number(),createdAt:o.string()});import*as v from"valibot";var st=v.object({anonymousId:L,email:L,firstName:v.nullish(v.string()),lastName:v.nullish(v.string()),phone:v.nullish(v.string()),source:v.nullish(se),updateExisting:v.optional(v.boolean())}),ke=v.object({candidateId:v.string(),isNew:v.boolean()}),Vr=v.union([v.object({ok:v.literal(!0)}),ke]);import*as e from"valibot";var cn=["stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate"],pe=e.picklist(cn),Ce=e.pipe(e.string(),e.transform(t=>t.split(",").map(n=>n.trim()).filter(n=>n.length>0))),ln=e.pipe(Ce,e.array(T)),pn=e.pipe(Ce,e.array(I)),at=e.pipe(e.string(),e.transform(t=>t.split(",").map(n=>Number(n.trim())).filter(n=>Number.isInteger(n)&&n>0))),dn=e.pipe(Ce,e.array(j)),ct=e.object({stages:e.optional(ln),stage_groups:e.optional(pn),job_id:e.optional(e.string()),job_ids:e.optional(at),candidate_id:e.optional(e.string()),is_disqualified:e.optional(e.picklist(["true","false"])),created_from:e.optional(e.string()),created_to:e.optional(e.string()),updated_from:e.optional(e.string()),updated_to:e.optional(e.string()),entered_stage_from:e.optional(e.string()),entered_stage_to:e.optional(e.string()),from:e.optional(e.string()),to:e.optional(e.string()),q:e.optional(e.string()),scored:e.optional(e.picklist(["true","false"])),ats_submission_status:e.optional(dn),sort:e.optional(Ze),order:e.optional(Xe),page:e.optional(e.string()),per_page:e.optional(e.string())}),H=e.pipe(L,e.maxLength(255)),un=e.object({status:e.picklist(["pending","not_required"]),integrationId:e.nullish(H)}),Yr=e.pipe(e.object({candidateId:L,jobId:Z,meta:e.nullish(k),sessionId:e.nullish(e.number()),externalApplicationId:e.nullish(e.string()),externalJobId:e.nullish(e.pipe(L,e.maxLength(255))),context:e.nullish(k),source:e.nullish(ce),sourceDetail:e.nullish(e.string()),stage:e.nullish(T),stageGroup:e.nullish(I),actor:e.nullish(_),atsSubmission:e.nullish(un),duplicateScope:e.nullish(e.picklist(["job","attempt"]))}),e.check(t=>t.stage==null==(t.stageGroup==null),"stage and stageGroup must be supplied together"),e.check(t=>t.duplicateScope!=="attempt"||typeof t.meta?.attempt_id=="string"&&t.meta.attempt_id!=="","duplicateScope attempt needs meta.attempt_id")),lt=e.object({id:e.string(),stageGroup:e.string(),createdAt:e.string()}),zr=e.union([e.object({ok:e.literal(!0),duplicate:e.literal(!1),applicationId:e.string(),candidateId:e.string(),atsHeld:e.optional(e.boolean())}),e.object({ok:e.literal(!0),duplicate:e.literal(!0),existingApplication:lt,atsHeld:e.optional(e.boolean())})]),pt=e.object({isDuplicate:e.boolean(),existingApplication:e.optional(lt)}),mn=Date.UTC(1e4,0,1),vn=e.pipe(e.string(),e.regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,9})?(Z|[+-]\d{2}:\d{2})$/),e.check(t=>{let[n,r,i]=t.slice(0,10).split("-").map(Number),l=new Date(Date.UTC(n,r-1,i)),c=Date.parse(t);return l.getUTCMonth()===r-1&&l.getUTCDate()===i&&c>=0&&c<mn},"must be a real time")),Le=e.pipe(e.string(),e.regex(/^[A-Za-z0-9_.:-]{1,100}$/)),Qr=e.object({status:e.picklist(["pending","submitted","failed"]),nextAttemptAt:e.nullish(vn),errorCode:e.nullish(Le),errorMessage:e.nullish(e.pipe(e.string(),e.maxLength(1e4))),externalApplicationId:e.nullish(H),externalRunId:e.nullish(H),integrationId:e.nullish(H),answeredPending:e.optional(e.boolean())}),gn=e.picklist(["invalid_transition","next_attempt_required","retry_hold_expired"]),Zr=e.variant("kind",[e.object({kind:e.literal("recorded"),application:N}),e.object({kind:e.literal("rejected"),applicationId:e.string(),from:e.nullable(j),to:j,reason:gn})]),hn=e.object({integrationId:e.string(),state:e.picklist(["closed","open","half_open"]),coolingUntil:e.nullable(e.string()),transientCount:e.number(),held:e.boolean()}),Xr=e.object({groups:e.array(e.object({integrationId:e.nullable(e.string()),status:e.picklist(["pending","failed"]),errorCode:e.nullable(e.string()),count:e.number(),retryable:e.number(),sendable:e.optional(e.number()),nextRetryUntil:e.optional(e.nullable(e.string()))})),oldestPendingAgeSeconds:e.nullable(e.number()),breakers:e.array(hn),restoreHold:e.optional(e.boolean())}),eo=e.object({status:e.picklist(["pending","failed"]),integrationId:e.nullable(H),errorCode:e.nullable(Le)}),to=e.object({rows:e.array(e.object({id:e.string(),jobId:e.number(),status:e.picklist(["pending","failed"]),errorCode:e.nullable(e.string()),errorMessage:e.nullable(e.string()),attempts:e.number(),nextAttemptAt:e.nullable(e.string()),payloadHeld:e.boolean(),receivedAt:e.nullable(e.string()),retryUntil:e.nullable(e.string()),updatedAt:e.string()})),truncated:e.boolean()}),no=e.object({actor:_,expectedAtsLogCount:e.optional(e.pipe(e.number(),e.integer(),e.minValue(0)))}),fn=e.picklist(["invalid_transition","retry_payload_missing","retry_hold_expired","stale"]),ro=e.variant("kind",[e.object({kind:e.literal("retried"),application:N}),e.object({kind:e.literal("rejected"),applicationId:e.string(),from:e.nullable(j),reason:fn})]),oo=e.object({status:e.optional(e.picklist(["pending","failed"])),integrationId:e.nullable(H),errorCode:e.nullable(Le),actor:_}),io=e.object({retried:e.number()});var so=e.object({integrationId:e.string(),wasOpen:e.boolean()}),ao=e.object({integrationId:e.string(),wasHeld:e.boolean()}),co=e.object({applicationId:L,scoreType:ae,score:e.number(),reason:e.nullish(e.string()),categories:e.nullish(e.record(e.string(),we)),leftOut:e.nullish(e.array(Pe)),scoredBy:e.nullish(e.string()),actor:e.nullish(_),idempotencyKey:e.nullish(e.pipe(e.string(),e.maxLength(255)))}),lo=e.object({scoreId:e.string()}),po=nt(N);var uo=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified"]),mo=e.array(it),le=e.object({stage:e.nullish(T),note:e.nullish(e.string())}),yn=e.object({stage:e.nullish(T),startDate:e.nullish(e.string()),note:e.nullish(e.string())}),Sn=e.variant("action",[e.object({action:e.literal("shortlist"),actor:_,meta:e.nullish(le)}),e.object({action:e.literal("move_to_interview"),actor:_,meta:e.nullish(le)}),e.object({action:e.literal("make_offer"),actor:_,meta:e.nullish(le)}),e.object({action:e.literal("hire"),actor:_,meta:e.nullish(yn)}),e.object({action:e.literal("withdraw"),actor:_,meta:e.nullish(le)}),e.object({action:e.literal("move_to_stage"),actor:_,meta:e.object({stage:T,stageGroup:I,note:e.nullish(e.string())})}),e.object({action:e.literal("stage_transition"),actor:_,meta:e.object({toStage:T,toStageGroup:I,note:e.nullish(e.string())})}),e.object({action:e.literal("disqualify"),actor:_,meta:e.object({reason:Q,note:e.nullish(e.string())})}),e.object({action:e.literal("reinstate"),actor:_,meta:e.object({toStage:T,toStageGroup:I,note:e.nullish(e.string())})}),e.object({action:e.literal("rate"),actor:_,meta:e.object({rating:e.nullable(e.pipe(e.number(),e.integer(),e.minValue(1),e.maxValue(5)))})})]),vo=e.object({applicationIds:e.pipe(e.array(e.string()),e.minLength(1)),body:Sn}),dt=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified","already_disqualified"]),go=e.variant("kind",[e.object({kind:e.literal("updated"),action:pe,application:N}),e.object({kind:e.literal("skipped"),action:pe,applicationId:e.string(),reason:dt})]),ho=e.object({updated:e.array(e.object({kind:e.literal("updated"),action:pe,application:N})),skipped:e.array(e.object({kind:e.literal("skipped"),action:pe,applicationId:e.string(),reason:dt})),failed:e.array(e.object({applicationId:e.string(),error:e.string()}))}),m=e.pipe(e.number(),e.integer(),e.minValue(0)),ut=e.object({APPLIED:m,SHORTLISTED:m,INTERVIEWED:m,OFFERED:m,HIRED:m,REJECTED:m,WITHDRAWN:m}),fo=e.object({job_ids:at}),yo=e.object({counts:e.record(e.string(),ut)}),So=e.omit(ct,["sort","order","page","per_page"]),bo=e.object({counts:ut}),mt=92,bn=864e5,K=e.pipe(e.string(),e.regex(/^\d{4}-\d{2}-\d{2}$/),e.check(t=>{let n=new Date(`${t}T00:00:00Z`);return!Number.isNaN(n.getTime())&&n.toISOString().slice(0,10)===t},"must be a real calendar day"));function vt({from:t,to:n}){let r=(Date.parse(`${n}T00:00:00Z`)-Date.parse(`${t}T00:00:00Z`))/bn+1;return r>=1&&r<=mt}var gt=`to must be on or after from, and the range must span at most ${mt} days`,_o=e.pipe(e.object({from:K,to:K}),e.check(vt,gt)),_n=e.object({job_id:Z,date:K,received:m,scored:m,shortlisted:m}),Ao=e.object({rows:e.array(_n)}),An=5e3,Tn=e.pipe(e.object({from:K,to:K,jobIds:e.optional(e.pipe(e.array(Z),e.maxLength(An)))}),e.check(vt,gt)),To=e.pipe(e.object({from:e.string(),to:e.string(),job_ids:e.optional(e.string())}),e.transform(({from:t,to:n,job_ids:r})=>({from:t,to:n,jobIds:r===void 0?void 0:r===""?[]:r.split(",").map(i=>/^\d+$/.test(i.trim())?Number(i):Number.NaN)})),Tn),ht=e.pipe(e.array(m),e.length(5)),En=e.object({received:m,scored:m,shortlisted:m,histogram:e.pipe(e.array(m),e.length(101)),median_lag_minutes:e.nullable(e.number()),scored_same_day:m}),xn=e.object({job_id:Z,received:m,scored:m,shortlisted:m,score_sum:e.number(),bands:ht}),In=e.object({date:K,received:m,scored:m,score_sum:e.number(),bands:ht,scored_on_day:m}),Rn=e.object({id:e.string(),label:e.nullable(e.string()),sum:e.number(),count:m}),wn=e.object({template_id:e.string(),scored:m,criteria:e.array(Rn)}),Eo=e.object({totals:En,by_job:e.array(xn),by_day:e.array(In),criteria:e.array(wn)});var xo=e.object({...e.omit(ct,["page","per_page"]).entries,per_group:e.optional(e.string())}),F=e.object({data:e.array(N),total:m}),Io=e.object({board:e.object({APPLIED:F,SHORTLISTED:F,INTERVIEWED:F,OFFERED:F,HIRED:F,REJECTED:F,WITHDRAWN:F})});import*as de from"valibot";var Pn=({environment:t,publishableKey:n,logger:r})=>{let i=Ue[t];return{async checkDuplicate(l){try{let c=new URLSearchParams({email:l.email,scope:l.scope});l.scope==="job"&&l.jobId!=null&&c.set("job_id",String(l.jobId));let d=await fetch(`${i}/applications/check-duplicate?${c}`,{method:"GET",headers:{Accept:"application/json","x-publishable-key":n}});if(!d.ok)return r.error(`[TalentBankClient] checkDuplicate failed with status ${d.status}`),{isDuplicate:!1};let u=await d.json(),S=de.safeParse(pt,u);return S.success?S.output:(r.error("[TalentBankClient] checkDuplicate response failed strict validation; falling back to isDuplicate flag"),typeof u=="object"&&u!=null&&typeof u.isDuplicate=="boolean"?{isDuplicate:u.isDuplicate}:{isDuplicate:!1})}catch(c){return r.error("[TalentBankClient] checkDuplicate failed:",c),{isDuplicate:!1}}},async identify(l){try{if(!l.anonymousId)return r.error("[TalentBankClient] identify skipped because anonymousId is missing"),null;let c={email:l.email,firstName:l.firstName,lastName:l.lastName,phone:l.phone,anonymousId:l.anonymousId,source:l.source??"sdk"},d=de.safeParse(st,c);if(!d.success)return r.error("[TalentBankClient] identify received invalid input"),null;let u=await fetch(`${i}/identify`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-publishable-key":n},body:JSON.stringify(d.output)});if(!u.ok)return r.error(`[TalentBankClient] identify failed with status ${u.status}`),null;let S=de.safeParse(ke,await u.json());return S.success?S.output:(r.error("[TalentBankClient] identify returned an invalid response"),null)}catch(c){return r.error("[TalentBankClient] identify failed:",c),null}}}};function kn(t){if(!(typeof document>"u")){if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",t,{once:!0});return}Promise.resolve().then(t)}}import*as a from"valibot";var ft=["DAILY","WEEKLY","MONTHLY"],Cn=a.record(a.string(),a.union([a.string(),a.array(a.string()),a.object({type:a.literal("provided"),lat:a.number(),lng:a.number(),radius:a.number(),unit:a.optional(a.picklist(["miles","km"])),label:a.optional(a.string())})])),Ln={pathname:"/job/:id",method:"GET",schema:{response:a.object({id:a.number(),external_id:a.nullish(a.string()),city:a.nullish(a.string()),town:a.nullish(a.string()),category:a.nullish(a.string())})}};async function Dn(t,{contact:n,job:r}){let i={};if(r){let l=await t.request(Ln,{params:{id:r.id}});if((r.id_type==="internal"?String(l.id):l.external_id)!==r.id)throw new Error("Job lookup returned a different role");for(let d of["city","town","category"]){let u=l[d]?.trim();u&&(i[d]=[u])}}await t.request(yt,{body:{contact:n,alerts:"WEEKLY",filters:i}})}var yt={pathname:"/search/save",method:"POST",schema:{response:C(),body:a.object({contact:a.object({email:a.pipe(a.optional(a.string()),a.string(),a.email()),first_name:a.optional(a.string()),last_name:a.optional(a.string())}),alerts:a.pipe(a.optional(a.string()),a.string(),a.picklist(ft)),filters:Cn})}};import*as A from"valibot";var St=async t=>{let n={method:"GET",pathname:"/search/filters",schema:{response:A.pipe(A.object({country:A.optional(A.array(A.object({value:A.string()})),[])}),A.transform(({country:r})=>r.map(({value:i})=>i))),searchParams:C()}};return t.request(n,{searchParams:{filters:{country:null}}})},ue=new WeakMap,On=t=>(ue.has(t)||(ue.set(t,void 0),St(t).then(async n=>{let{jobCountryCodes:r}=await import("./sdk.country-codes-W6HRF5SA.mjs");ue.set(t,r(n).join(",")||void 0)}).catch(()=>{})),ue.get(t)),bt=(t,n)=>{let r=new Set,i=[];for(let l=0;l<Math.max(t.length,n.length);l++)for(let c of[t[l],n[l]]){if(!c)continue;let d=c.mapbox_id||c.full_address||[c.name,c.place_formatted].filter(Boolean).join(", ");if(!r.has(d)&&(r.add(d),i.push(c),i.length===5))return i}return i},jn=600,Nn=async(t,n,r)=>{if(r?.throwIfAborted(),!n){let i=await t();return r?.throwIfAborted(),i}return new Promise((i,l)=>{let c,d,u,S=!1,E=()=>{S=!0,clearTimeout(u),r?.removeEventListener("abort",U)},U=()=>{E(),l(r?.reason)},D=()=>{E(),c?.status==="fulfilled"&&d?.status==="fulfilled"?i(bt(c.value,d.value)):c?.status==="fulfilled"?i(c.value):d?.status==="fulfilled"?i(d.value):c?.status==="rejected"&&l(c.reason)},me=(p,h)=>{S||(p?c=h:d=h,c&&d?D():h.status==="fulfilled"&&h.value.length>0&&(u=setTimeout(D,jn)))};r?.addEventListener("abort",U,{once:!0});for(let p of[!0,!1])t(p?n:void 0).then(h=>me(p,{status:"fulfilled",value:h}),h=>me(p,{status:"rejected",reason:h}))})};export{qt as ANALYTICS_EVENTS,V as ApiError,z as InploiRpcClient,ft as JOB_ALERT_FREQUENCIES,G as NotFoundError,$ as ParsingError,w as SchemaValidationError,Ne as SdkError,q as UnauthorisedError,On as addressSearchCountry,bt as blendAddressSuggestions,Ie as consentStorageKey,Et as createPlugin,Pn as createTalentBankClient,ie as endpoint,J as generateUUID,Vt as getConsentAcceptance,St as getJobCountries,We as getOrCreateAnonymousId,xe as hashConsentConfig,Gt as initialiseSdk,fe as inploiBrandedLogger,Rt as isApiErrorWithData,kt as isSdkError,Tt as jobCountryCodes,ye as noLogging,kn as ready,Dn as saveClosedRoleJobAlerts,yt as saveSearchEndpoint,Nn as searchAddressSuggestions,$t as setConsentAcceptance,C as typed,Ye as validateEndpointInputs};
|
|
1
|
+
import{a as Nt}from"./chunk-KC7FKSIJ.mjs";var oe="%c[inploi SDK]",ie="color: #65BC67; font-weight: bold;",Se={warn:(...t)=>console.warn(oe,ie,...t),error:(...t)=>console.error(oe,ie,...t),info:(...t)=>console.info(oe,ie,...t),log:(...t)=>console.log(oe,ie,...t)},be={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var Bt=t=>t;function _e(t,r){if(!t)throw new Error(r)}function q(t,r){return r in t}var wr=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});var Ft="Unauthenticated",Ut="This action is unauthorized.",D=class extends Error{constructor(i,s){super(i);this.status=s,this.name="ErrorWithStatus"}},$=class extends D{constructor(r){super(r??"Not found"),this.name="NotFoundError",this.status=404}},J=class extends D{constructor(r,i){super(r??"You are not authorised to perform this action."),this.name="UnauthorisedError",this.status=i??401}},k=class extends D{constructor(i,s){let p=s?` in ${s}`:"";super(`Schema validation failed${p}`);this.issues=i;this.source=s;this.name="SchemaValidationError",this.status=400}},H=class extends D{constructor(i,s,p){super(i);this.data=p;this.name="ApiError",this.status=s??500}},Mt=t=>t instanceof H&&t.data!==void 0,K=class extends D{constructor(i){super("Error parsing response into JSON.");this.response=i;this.name="ParsingError",this.status=i&&i.status>=300?i.status:500,this.contentType=new Headers(i?.headers).get("content-type")??void 0}};async function Ae(t){let i=new Headers(t.headers).get("content-type")?.replace(/;.*/,"").trim().toLowerCase();if(i&&i!=="application/json"&&!i.endsWith("+json"))throw new K(t);return t.json().catch(()=>{throw new K(t)})}var Vt=["message","error","errors","exception","exceptions"];function Gt(t){let r=[];if(typeof t=="object"&&t!==null){for(let i of Vt)if(q(t,i)){let s=t[i];typeof s=="string"&&r.push(s),Array.isArray(s)&&s.every(p=>typeof p=="string")&&r.push(...s)}q(t,"integration_response")&&typeof t.integration_response=="object"&&t.integration_response!==null&&q(t.integration_response,"error")&&typeof t.integration_response.error=="object"&&t.integration_response.error!==null&&q(t.integration_response.error,"message")&&typeof t.integration_response.error.message=="string"&&r.push(t.integration_response.error.message)}return r.length===0&&r.push("Unknown error"),[...new Set(r)].join(", ")}function xe(t,r){if(r>=300){let i=Gt(t);throw r===404?new $(i):i===Ft?new J("You are not authenticated.",r):i===Ut?new J(i,r):new H(i,r,t)}}var Ge=t=>{let r={Accept:"application/json","Content-Type":"application/json","x-publishable-key":t.publishableKey};return{fetch:async(i,s={})=>{let p={...s,headers:{...s.headers,...r}},l=await fetch(`${t.baseUrl}${i}`,p);if(l.status===404)throw new $;let u=await Ae(l);return xe(u,l.status),u}}},qe={NotFound:$,Unauthorised:J,SchemaValidation:k,Api:H,JsonParsing:K};function qt(t){return Object.values(qe).some(r=>t instanceof r)}var $e="3.1.2";var se={sandbox:"https://api.staging.inploi.com",production:"https://api.inploi.com",_internal_local:"http://api.test"},Je={sandbox:"https://talent-bank.staging.inploi.com",production:"https://talent-bank.inploi.com",_internal_local:"http://localhost:8787"},He=$e;var C="isdk_session",Ke=`${C}-candidate_id`,We=`${C}-consent`;var ae=new Map,Te={get:t=>{if(ae.has(t))return ae.get(t)??null;try{return window.sessionStorage.getItem(t)}catch{return null}},set:(t,r)=>{try{window.sessionStorage.setItem(t,r),ae.delete(t)}catch{ae.set(t,r)}}};var Z=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"10000000-1000-4000-8000-100000000000".replace(/[018]/g,t=>(+t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+t/4).toString(16));var ze=7*24*60*60*1e3,Ze=t=>{let r=new Date;return r.setTime(r.getTime()+ze),`${C}=${t};expires=${r.toUTCString()};path=/`},Jt=(t,r)=>{let i=t.get("session_id");if(r||i)return i;let s=Te.get(`${C}-session_id`);return typeof s=="string"?s:null},Ht=()=>{if(typeof window>"u")return null;try{let t=window.localStorage.getItem(Ke);return typeof t=="string"&&t!==""?t:null}catch{return null}},Kt=new RegExp(`(?:^|;\\s*)${C}=([^;]+)`),Q=t=>{let r=t?t.headers.get("cookie"):document.cookie;return r?Kt.exec(r)?.[1]??null:null},Qe=()=>{try{let t=JSON.parse(window.localStorage.getItem(C)??"null");return typeof t!="object"||t===null||!("id"in t)||!("expires"in t)||typeof t.id!="string"||typeof t.expires!="number"?null:t.id!==""&&t.expires>Date.now()?t.id:null}catch{return null}},Ye=()=>Q()??(new URL(location.href).searchParams.get("anonymous_id")?null:Qe()),Wt=()=>location.protocol==="https:"&&window.self!==window.top?";SameSite=None;Secure;Partitioned":"",Xe=t=>{if(document.cookie=Ze(t)+Wt(),Q()!==t)try{window.localStorage.setItem(C,JSON.stringify({id:t,expires:Date.now()+ze}))}catch{}},Ee=t=>{let r=t?t.url:location.href,{searchParams:i}=new URL(r);return{anonymous_id:t?Q(t)??i.get("anonymous_id"):Q()??i.get("anonymous_id")??Qe(),session_id:Jt(i,typeof window>"u")}},et=()=>{if(typeof window>"u")throw new Error("getOrCreateAnonymousId() can only be called in browser environment");let t=Ee().anonymous_id;if(t)return t;let r=Z(),i=Ee().anonymous_id;return i||(Xe(r),r)},Yt=t=>typeof t!="object"||t===null?null:{anonymous_id:"anonymous_id"in t&&typeof t.anonymous_id=="string"?t.anonymous_id:null,session_id:"session_id"in t&&typeof t.session_id=="string"?t.session_id:null},zt=t=>t==="about:client"?"":t,Zt={pathname:"/log",method:"POST",schema:{response:O(),body:O()}},tt=({rpcClient:t,logger:r,onEvent:i,persistence:s="device",siteKind:p})=>{let l=null,u=null,m=0,b=0,E=d=>s==="none"?{anonymous_id:null,session_id:d?null:l}:Ee(d),V=async(d,y,ne)=>{try{let G={library:{name:"inploi-sdk",version:He},page:y},z=E(d.request),re=s==="none"?null:Ht(),S={anonymous_id:z.anonymous_id,session_id:z.session_id,candidate_id:re,event:d.event,sent_at:new Date().toISOString(),context:G,properties:d.properties,custom_properties:{...d.customProperties,...ne}},he=s==="none"?null:d.request?Q(d.request):Ye(),Me=++m,jt=await t.request(Zt,{body:S,...d.keepalive&&{keepalive:!0}}),I=Yt(jt);if(s==="none")return!d.request&&I?.session_id&&Me>b&&(b=Me,I.session_id!==S.session_id&&(l=I.session_id)),S.session_id=d.request?I?.session_id||null:l,i?.(S),{success:!0,data:S};let fe=d.request?he:Ye(),Dt=fe!==null&&fe!==he,ye=fe??he,Ve=!Dt&&(!ye||!I?.anonymous_id||ye===I.anonymous_id);return Ve?(I?.anonymous_id&&(S.anonymous_id=I.anonymous_id),I?.session_id&&(S.session_id=I.session_id)):S.anonymous_id=ye,!d.request&&typeof window<"u"&&S.anonymous_id&&(Ve&&S.session_id&&Te.set(`${C}-session_id`,S.session_id.toString()),Xe(S.anonymous_id)),i?.(S),{success:!0,data:S}}catch(G){return r.error("Failed to send log to API. Inspect error response of `log` for more information."),{success:!1,error:G}}},j=Promise.resolve();return{log:async d=>{_e(d.request||typeof window<"u","Cannot log on the server without a request. Please pass a request to `log`.");let y="request"in d&&d.request?{href:d.request.url,referrer:zt(d.request.referrer),title:""}:{href:location.href,referrer:document.referrer,title:document.title};if(d.page_context==="no_query"){let re=new URL(y.href),S=y.referrer?new URL(y.referrer):void 0;y={href:re.origin+re.pathname,referrer:S?S.origin+S.pathname:""}}s==="none"&&d.event==="FLOW_NODE"&&d.properties&&"trigger"in d.properties&&(d.properties.trigger==="pagehide"||d.properties.trigger==="hidden")&&(d={...d,keepalive:!0});let ne={event_id:Z(),consent_lane:s,site_kind:p};if(s==="device"||d.request||l||d.keepalive)return V(d,y,ne);let G=()=>V(d,y,ne),z=j.then(G,G);return j=z,z},supportsNoQueryPageContext:!0,getHeaders:d=>{let y=new Headers;return s==="none"||!d?.anonymous_id||y.append("Set-Cookie",Ze(d.anonymous_id)),y},getSessionInfo:E,getOrCreateAnonymousId:()=>s==="none"?u??(u=Z()):et()}};import{stringify as Qt}from"neoqs";function Ie(t,r,i){let s=t["~standard"].validate(r);if(s instanceof Promise)throw new TypeError("Async schema");if(s.issues)throw new k(s.issues,i);return s.value}function Xt(t,r,i){try{return{success:!0,output:Ie(t,r,i)}}catch(s){if(s instanceof k)return{success:!1,issues:s.issues,source:s.source};throw s}}var X=class{constructor(r){if(this.baseUrl=se[r.environment],this.headers=new Headers({"Content-Type":"application/json",Accept:"application/json"}),r.apiKey.type==="secret"){if(typeof window<"u")throw new Error("Secret key cannot be used in a browser environment");this.headers.set("x-secret-key",r.apiKey.key)}else this.headers.set("x-publishable-key",r.apiKey.key);this.logger=r.logger,this._environment=r.environment}get environment(){return this._environment}getFetchParams(r,i){let s=i.validateIn??!0,{searchParams:p,body:l}=s?nt(r,i):i,u=new URL(this.baseUrl),m=r.pathname;if("params"in i&&i.params)for(let[b,E]of Object.entries(i.params))m=m.replace(`:${b}`,String(E));return u.pathname=m,r.schema.searchParams&&(u.search=Qt(p)),[u.toString(),{method:r.method,body:l?JSON.stringify(l):void 0,headers:this.headers,signal:i.signal,...i.keepalive&&{keepalive:!0}}]}async parseResponse(r,i){let s=await Ae(i.response);if(xe(s,i.response.status),!(i.validateOut??!0))return s;let l=Xt(r.schema.response,s,"response");if(!l.success)throw new k(l.issues,l.source);return l.output}async request(r,i){try{let s=this.getFetchParams(r,i),p=await fetch(...s);return await this.parseResponse(r,{response:p,validateOut:i.validateOut})}catch(s){throw s instanceof k?this.logger.error(s.message,s.issues):this.logger.error(s),s}}};function O(){return{"~standard":{vendor:"inploi",version:1,validate:t=>({value:t})}}}function ce(t){return t}function nt(t,r){let i={searchParams:void 0,body:void 0,validateIn:!1};return t.schema.searchParams&&(i.searchParams=Ie(t.schema.searchParams,"searchParams"in r?r.searchParams:{})),t.schema.body&&(i.body=Ie(t.schema.body,"body"in r?r.body:{})),i}function en({publishableKey:t,env:r,logger:i=Se,onEvent:s,persistence:p,siteKind:l}){let u=Ge({baseUrl:se[r],publishableKey:t}),m=i===!1?be:i,b=new X({environment:r,apiKey:{type:"publishable",key:t},logger:m}),E=tt({rpcClient:b,logger:m,onEvent:s,persistence:p,siteKind:l});return{register:j=>j({logger:m,apiClient:u,analytics:E,rpcClient:b,publishableKey:t,env:r}),analytics:E,apiClient:u}}var tn={VIEW_PAGE:"A careers-site page shown (not a job page).",VIEW_JOB:"A job's own page shown; one per job id the page names.",PAGE_ENGAGEMENT:"A page view's attention summary, sent when the view is hidden or left.",VIEW_SEARCH:"A job search seen for two seconds.",SEARCH_SETTLE:"A searched query or filter with results, unchanged for five seconds.",SEARCH_RESULTS:"A search whose results returned, zero included; once per distinct query, filters, place and order.",SEARCH_PAGINATE:"A move to another page of search results.",SEARCH_JOB_CLICK:"A job opened from search results.",SAVE_JOB:"A job saved or unsaved by the candidate.",LINK_CLICK:"A tracked link clicked.",INTERACTION:"A tagged interaction (`tag` names it).",FLOW_START:"An application flow started.",FLOW_INTERACT:"The candidate's first answer in a flow.",FLOW_END:"An application flow ended.",FLOW_NODE:"The candidate's path through an application, summarised when it pauses or ends.",FLOW_SUBMIT:"An application submitted, with the outcome.",FLOW_REDIRECT:"A flow sent the candidate to an external apply page.",FEEDBACK:"A rating or comment.",ADDRESS_SHADOW_COMPARED:"Engineering telemetry: the address lookup's shadow comparison.",SUBMIT_FORM:"Declared but sent by nothing."};function we(t){let r=JSON.stringify({message:t.message,acceptLabel:t.acceptLabel??"",declineLabel:t.declineLabel??""}),i=5381;for(let s=0;s<r.length;s++)i=i*33^r.charCodeAt(s);return(i>>>0).toString(36)}function Re(t,r){return`${We}:${t}:${r}`}function nn(t,r){if(typeof window>"u")return!1;try{let i=Re(t,we(r));return window.localStorage.getItem(i)==="accepted"}catch{return!1}}function rn(t,r){if(!(typeof window>"u"))try{let i=Re(t,we(r));window.localStorage.setItem(i,"accepted")}catch{}}import*as a from"valibot";var on=["agent","sdk","form","integration","migration"],sn=["APPLIED","SHORTLISTED","INTERVIEWED","OFFERED","HIRED","REJECTED","WITHDRAWN"];var an=["screening","cv_match","interview","overall"],cn=["PENDING","IN_PROGRESS","COMPLETED","CANCELLED"],ln=["agent"],pn=["job","company"],dn=["created_at","updated_at","score","interview_score"],un=["asc","desc"],vn=["careers_site","chatbot","plugin_job_search","ats_import","referral","agency","other","unknown"],mn=["submit","stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate","score_written","ats_submission_attempted","ats_submission_succeeded","ats_submission_failed","ats_retry_payload_purged","note","share","verdict","offer_terms","offer_sent","offer_accepted","offer_declined","offer_withdrawn","exported","message_held","message_sent","message_delivered","message_failed","message_uncertain","message_cancelled","message_not_sent","score_override"],gn=["interview","not_for_me"],rt=a.picklist(gn),hn=["accept","reject"],ot=a.picklist(hn),fn=["transient_pass_through","failed_ats_submission_hold","retention","erasure","demo_reset"],ao=a.picklist(fn),yn=["pending","submitted","failed","not_required"],Sn=["user","system","automation","integration","candidate"],le=a.picklist(on),w=a.picklist(sn),x=a.pipe(a.string(),a.trim(),a.minLength(1),a.maxLength(100)),pe=a.picklist(an),it=a.picklist(cn),st=a.picklist(ln),at=a.picklist(pn),ct=a.picklist(dn),lt=a.picklist(un),ee=a.pipe(a.string(),a.trim(),a.minLength(1),a.maxLength(100)),de=a.picklist(vn),Pe=a.picklist(mn),pt=a.picklist(Sn),N=a.picklist(yn);var h=a.variant("type",[a.object({type:a.literal("user"),id:a.pipe(a.string(),a.minLength(1)),email:a.pipe(a.string(),a.minLength(1)),name:a.pipe(a.string(),a.minLength(1))}),a.object({type:a.literal("system"),id:a.pipe(a.string(),a.minLength(1)),name:a.optional(a.string())}),a.object({type:a.literal("automation"),id:a.pipe(a.string(),a.minLength(1)),name:a.optional(a.string())}),a.object({type:a.literal("integration"),id:a.pipe(a.string(),a.minLength(1)),name:a.optional(a.string())}),a.object({type:a.literal("candidate"),id:a.pipe(a.string(),a.minLength(1)),email:a.optional(a.string())})]);import*as R from"valibot";var bn=R.object({total:R.number(),page:R.number(),perPage:R.number(),lastPage:R.number()});function dt(t){return R.object({data:R.array(t),pagination:bn})}import*as o from"valibot";function ut(t){return/^\p{Zs}*\(?\p{Zs}*(\+|00)[\p{Zs}().-]*\d/u.test(t)}var ke=o.object({id:o.string(),email:o.nullable(o.string()),firstName:o.nullable(o.string()),lastName:o.nullable(o.string()),phone:o.nullable(o.string()),source:o.nullable(le),identifiedAt:o.nullable(o.string()),createdAt:o.string(),updatedAt:o.string()}),_n=o.pipe(o.string(),o.trim(),o.minLength(1)),vt=64*1024,te=o.pipe(o.string(),o.trim(),o.minLength(1),o.maxLength(500)),An=o.pipe(o.string(),o.regex(/^[A-Z]{2}$/)),xn=o.pipe(o.string(),o.maxLength(500),o.check(t=>ut(t.trim()),"phone must start with its country code (+ or 00)")),Tn=o.pipe(o.string(),o.regex(/^[\w:-]+$/)),En=new Set(["__proto__","constructor","prototype"]),In=o.custom(t=>kn(t),"custom answer must be a JSON value"),mo=o.strictObject({firstName:o.nullable(o.string()),lastName:o.nullable(o.string()),email:o.string(),phone:o.nullable(o.string()),country:o.nullable(o.string()),postcode:o.nullable(o.string()),currentTitle:o.nullable(o.string()),currentEmployer:o.nullable(o.string()),custom:o.record(o.string(),o.unknown())});var mt=o.strictObject({firstName:o.optional(te),lastName:o.optional(te),phone:o.optional(o.nullable(xn)),country:o.optional(o.nullable(An)),postcode:o.optional(o.nullable(te)),currentTitle:o.optional(o.nullable(te)),currentEmployer:o.optional(o.nullable(te)),custom:o.optional(o.pipe(o.custom(t=>Ce(t)&&Object.keys(t).every(r=>!En.has(r))&&Cn(t)<=vt,`custom must be a JSON object of at most ${vt} bytes`),o.record(Tn,o.nullable(In))))}),wn=o.pipe(o.custom(t=>Ce(t)&&Object.keys(t).every(r=>Object.hasOwn(mt.entries,r)),"set must be an object of profile fields"),mt),Rn=o.strictObject({email:_n}),go=o.strictObject({identity:Rn,set:wn,ifVersion:o.optional(o.pipe(o.number(),o.integer(),o.minValue(0))),disclosures:o.optional(o.unknown())}),Pn=o.strictObject({noticeId:o.pipe(o.string(),o.minLength(1),o.maxLength(200)),version:o.pipe(o.string(),o.minLength(1),o.maxLength(64)),wordingHash:o.pipe(o.string(),o.minLength(1),o.maxLength(128))}),ho=o.variant("withdrawTalentPool",[o.strictObject({withdrawTalentPool:o.literal(!1)}),o.strictObject({withdrawTalentPool:o.literal(!0),notice:Pn})]);function Ce(t){if(typeof t!="object"||t===null)return!1;let r=Object.getPrototypeOf(t);return r===Object.prototype||r===null}function kn(t){try{return gt(t,JSON.parse(JSON.stringify(t)))}catch{return!1}}function gt(t,r){if(t===r)return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null||Array.isArray(t)!==Array.isArray(r)||!Array.isArray(t)&&!Ce(t))return!1;let i=Object.keys(t);return i.length!==Object.keys(r).length?!1:i.every(s=>Object.hasOwn(r,s)&>(t[s],r[s]))}function Cn(t){try{return new TextEncoder().encode(JSON.stringify(t)).length}catch{return Number.POSITIVE_INFINITY}}import*as n from"valibot";import*as f from"valibot";var T=f.pipe(f.string(),f.minLength(1)),B=f.pipe(f.number(),f.integer(),f.minValue(1)),L=f.record(f.string(),f.unknown()),Ln="(?!\\.{1,2}(?:/|$))[A-Za-z0-9._-]{1,128}",yo=f.pipe(f.string(),f.regex(new RegExp(`^${Ln}$`)));import*as _ from"valibot";var ht=_.object({id:_.string(),applicationId:_.string(),status:it,conductedBy:st,agentInterviewId:_.nullable(_.string()),generatedScore:_.nullable(_.number()),completedAt:_.nullable(_.string()),meta:_.nullable(L),createdAt:_.string(),updatedAt:_.string()});var On=n.object({quote:n.string(),source:n.picklist(["cv","answer"])}),Le=n.object({score:n.number(),reason:n.string(),confidence:n.number(),share:n.optional(n.number()),evidence:n.optional(n.array(On))}),Oe=n.object({categoryId:n.string(),answerKey:n.string(),reason:n.picklist(["unanswered","unrecognised"])}),ft=n.object({id:n.string(),candidateId:n.string(),jobId:n.number(),stage:x,stageGroup:w,stageEnteredAt:n.string(),rating:n.nullable(n.number()),disqualifiedAt:n.nullable(n.string()),disqualificationReason:n.nullable(ee),disqualificationNote:n.nullable(n.string()),source:de,sourceDetail:n.nullable(n.string()),sessionId:n.nullable(n.number()),externalApplicationId:n.nullable(n.string()),meta:n.nullable(L),context:n.nullable(L),scoredAt:n.nullable(n.string()),atsSubmissionStatus:n.optional(n.nullable(N)),atsSubmissionAttempts:n.optional(n.number()),atsNextAttemptAt:n.optional(n.nullable(n.string())),atsSubmittedAt:n.optional(n.nullable(n.string())),atsLastErrorCode:n.optional(n.nullable(n.string())),atsLastErrorMessage:n.optional(n.nullable(n.string())),createdAt:n.string(),updatedAt:n.string()}),jn=n.object({id:n.string(),applicationId:n.string(),scoreType:pe,score:n.nullable(n.number()),reason:n.nullable(n.string()),categories:n.nullable(n.record(n.string(),Le)),leftOut:n.optional(n.array(Oe)),scoredBy:n.nullable(n.string()),createdAt:n.string()}),F=n.object({...ft.entries,candidate:n.nullable(ke),score:n.nullable(jn),interview:n.nullable(ht)}),wo=n.object({...ke.entries,applications:n.array(ft)}),yt=n.object({id:n.string(),applicationId:n.string(),action:Pe,fromStage:n.nullable(x),fromStageGroup:n.nullable(w),toStage:n.nullable(x),toStageGroup:n.nullable(w),disqualificationReason:n.nullable(ee),disqualificationNote:n.nullable(n.string()),actorId:n.nullable(n.string()),actorType:pt,actorEmail:n.nullable(n.string()),actorName:n.nullable(n.string()),meta:n.nullable(L),schemaVersion:n.number(),createdAt:n.string()}),Dn=500,St=n.object({scoreId:n.pipe(n.string(),n.minLength(1),n.maxLength(255)),scoredBy:n.pipe(n.string(),n.regex(/^scoring:[^:\s]{1,128}:[^:\s]{1,128}$/)),decision:ot,reason:n.pipe(n.string(),n.maxLength(Dn),n.check(t=>t.trim().length>0,"reason must not be blank")),score:n.pipe(n.number(),n.finite())}),Nn=500,Bn=200,Ro=n.strictObject({from:n.pipe(n.string(),n.isoTimestamp()),to:n.pipe(n.string(),n.isoTimestamp()),jobIds:n.pipe(n.array(n.pipe(n.number(),n.integer(),n.minValue(1))),n.minLength(1),n.maxLength(Nn)),actions:n.optional(n.pipe(n.array(Pe),n.minLength(1))),cursor:n.nullable(n.pipe(n.string(),n.regex(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\|.{1,255}$/))),limit:n.pipe(n.number(),n.integer(),n.minValue(1),n.maxValue(Bn))});import*as g from"valibot";var bt=g.object({anonymousId:T,email:T,firstName:g.nullish(g.string()),lastName:g.nullish(g.string()),phone:g.nullish(g.string()),source:g.nullish(le),updateExisting:g.optional(g.boolean())}),je=g.object({candidateId:g.string(),isNew:g.boolean()}),Lo=g.union([g.object({ok:g.literal(!0)}),je]);import*as e from"valibot";var Fn=["note","share","verdict","offer_terms","offer_sent","offer_accepted","offer_declined","offer_withdrawn","exported","score_override"],Un=["stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate",...Fn],ve=e.picklist(Un),De=e.pipe(e.string(),e.transform(t=>t.split(",").map(r=>r.trim()).filter(r=>r.length>0))),Mn=e.pipe(De,e.array(x)),Vn=e.pipe(De,e.array(w)),_t=e.pipe(e.string(),e.transform(t=>t.split(",").map(r=>Number(r.trim())).filter(r=>Number.isInteger(r)&&r>0))),Gn=e.pipe(De,e.array(N)),At=e.object({stages:e.optional(Mn),stage_groups:e.optional(Vn),job_id:e.optional(e.string()),job_ids:e.optional(_t),candidate_id:e.optional(e.string()),is_disqualified:e.optional(e.picklist(["true","false"])),created_from:e.optional(e.string()),created_to:e.optional(e.string()),updated_from:e.optional(e.string()),updated_to:e.optional(e.string()),entered_stage_from:e.optional(e.string()),entered_stage_to:e.optional(e.string()),from:e.optional(e.string()),to:e.optional(e.string()),q:e.optional(e.string()),scored:e.optional(e.picklist(["true","false"])),ats_submission_status:e.optional(Gn),sort:e.optional(ct),order:e.optional(lt),page:e.optional(e.string()),per_page:e.optional(e.string())}),W=e.pipe(T,e.maxLength(255)),qn=e.object({status:e.picklist(["pending","not_required"]),integrationId:e.nullish(W)}),Fo=e.pipe(e.object({candidateId:T,disclosures:e.optional(e.unknown()),jobLocation:e.optional(e.unknown()),jobId:B,meta:e.nullish(L),sessionId:e.nullish(e.number()),externalApplicationId:e.nullish(e.string()),externalJobId:e.nullish(e.pipe(T,e.maxLength(255))),context:e.nullish(L),source:e.nullish(de),sourceDetail:e.nullish(e.string()),stage:e.nullish(x),stageGroup:e.nullish(w),actor:e.nullish(h),atsSubmission:e.nullish(qn),duplicateScope:e.nullish(e.picklist(["job","attempt"]))}),e.check(t=>t.stage==null==(t.stageGroup==null),"stage and stageGroup must be supplied together"),e.check(t=>t.duplicateScope!=="attempt"||typeof t.meta?.attempt_id=="string"&&t.meta.attempt_id!=="","duplicateScope attempt needs meta.attempt_id")),xt=e.object({id:e.string(),stageGroup:e.string(),createdAt:e.string()}),Uo=e.union([e.object({ok:e.literal(!0),duplicate:e.literal(!1),applicationId:e.string(),candidateId:e.string(),atsHeld:e.optional(e.boolean())}),e.object({ok:e.literal(!0),duplicate:e.literal(!0),existingApplication:xt,atsHeld:e.optional(e.boolean())}),e.object({ok:e.literal(!1),refused:e.literal("pass_through_untracked")})]),Tt=e.object({email:e.pipe(e.string(),e.minLength(1),e.maxLength(320)),scope:e.optional(at,"job"),jobId:e.optional(e.union([e.string(),e.number()]))}),Et=e.object({isDuplicate:e.boolean(),existingApplication:e.optional(xt)}),$n=Date.UTC(1e4,0,1),It=e.pipe(e.string(),e.regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,9})?(Z|[+-]\d{2}:\d{2})$/),e.check(t=>{let[r,i,s]=t.slice(0,10).split("-").map(Number),p=new Date(Date.UTC(r,i-1,s)),l=Date.parse(t);return p.getUTCMonth()===i-1&&p.getUTCDate()===s&&l>=0&&l<$n},"must be a real time")),Ne=e.pipe(e.string(),e.regex(/^[A-Za-z0-9_.:-]{1,100}$/)),Mo=e.object({status:e.picklist(["pending","submitted","failed"]),nextAttemptAt:e.nullish(It),errorCode:e.nullish(Ne),errorMessage:e.nullish(e.pipe(e.string(),e.maxLength(1e4))),externalApplicationId:e.nullish(W),externalRunId:e.nullish(W),integrationId:e.nullish(W),answeredPending:e.optional(e.boolean())}),Jn=e.picklist(["invalid_transition","next_attempt_required","retry_hold_expired"]),Vo=e.variant("kind",[e.object({kind:e.literal("recorded"),application:F}),e.object({kind:e.literal("rejected"),applicationId:e.string(),from:e.nullable(N),to:N,reason:Jn})]),Hn=e.object({integrationId:e.string(),state:e.picklist(["closed","open","half_open"]),coolingUntil:e.nullable(e.string()),transientCount:e.number(),held:e.boolean()}),Go=e.object({groups:e.array(e.object({integrationId:e.nullable(e.string()),status:e.picklist(["pending","failed"]),errorCode:e.nullable(e.string()),count:e.number(),retryable:e.number(),sendable:e.optional(e.number()),nextRetryUntil:e.optional(e.nullable(e.string()))})),oldestPendingAgeSeconds:e.nullable(e.number()),breakers:e.array(Hn),restoreHold:e.optional(e.boolean())}),qo=e.object({status:e.picklist(["pending","failed"]),integrationId:e.nullable(W),errorCode:e.nullable(Ne)}),$o=e.object({rows:e.array(e.object({id:e.string(),jobId:e.number(),status:e.picklist(["pending","failed"]),errorCode:e.nullable(e.string()),errorMessage:e.nullable(e.string()),attempts:e.number(),nextAttemptAt:e.nullable(e.string()),payloadHeld:e.boolean(),receivedAt:e.nullable(e.string()),retryUntil:e.nullable(e.string()),updatedAt:e.string()})),truncated:e.boolean()}),Jo=e.object({actor:h,expectedAtsLogCount:e.optional(e.pipe(e.number(),e.integer(),e.minValue(0)))}),Kn=e.picklist(["invalid_transition","retry_payload_missing","retry_hold_expired","stale"]),Ho=e.variant("kind",[e.object({kind:e.literal("retried"),application:F}),e.object({kind:e.literal("rejected"),applicationId:e.string(),from:e.nullable(N),reason:Kn})]),Ko=e.object({status:e.optional(e.picklist(["pending","failed"])),integrationId:e.nullable(W),errorCode:e.nullable(Ne),actor:h}),Wo=e.object({retried:e.number()});var Yo=e.object({integrationId:e.string(),wasOpen:e.boolean()}),zo=e.object({integrationId:e.string(),wasHeld:e.boolean()}),Zo=e.object({applicationId:T,scoreType:pe,score:e.number(),reason:e.nullish(e.string()),categories:e.nullish(e.record(e.string(),Le)),leftOut:e.nullish(e.array(Oe)),scoredBy:e.nullish(e.string()),actor:e.nullish(h),idempotencyKey:e.nullish(e.pipe(e.string(),e.maxLength(255)))}),Qo=e.object({scoreId:e.string()}),Xo=dt(F);var ei=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified"]),ti=e.array(yt),ue=e.object({stage:e.nullish(x),note:e.nullish(e.string())}),Wn=e.object({stage:e.nullish(x),startDate:e.nullish(e.string()),note:e.nullish(e.string())}),Yn=e.pipe(e.string(),e.regex(/^[a-z0-9_.:-]{1,64}$/));var U=e.pipe(e.object({mode:e.picklist(["send","hold","none"]),templateKey:e.pipe(e.string(),e.regex(/^(received|rejection|interest_confirmation|campaign:invite|stage:[a-z0-9_-]{1,48})$/)),templateVersion:e.pipe(e.number(),e.integer(),e.minValue(1)),configVersionId:T,voice:e.optional(e.picklist(["casual","formal"])),holdUntil:e.optional(e.pipe(It,e.endsWith("Z","must be UTC with a Z suffix"),e.check(t=>Date.parse(t)>Date.now(),"must be in the future"))),subject:e.optional(e.pipe(e.string(),e.maxLength(200))),body:e.optional(e.pipe(e.string(),e.maxLength(2e4)))}),e.check(t=>t.mode==="hold"||t.holdUntil===void 0,"holdUntil is only for hold mode"),e.transform(({subject:t,body:r,...i})=>({...i,...t===void 0||t===""?{}:{subject:t},...r===void 0||r===""?{}:{body:r}}))),zn=e.variant("action",[e.object({action:e.literal("note"),actor:h,message:e.optional(e.never()),meta:e.object({note:T})}),e.object({action:e.literal("share"),actor:h,message:e.optional(e.never()),meta:e.object({subjectUserIds:e.pipe(e.array(T),e.minLength(1),e.maxLength(20)),comment:e.optional(e.string())})}),e.object({action:e.literal("verdict"),actor:h,message:e.optional(e.never()),meta:e.object({code:rt,comment:e.optional(e.string())})}),e.object({action:e.literal("offer_terms"),actor:h,message:e.optional(e.never()),meta:e.object({salary:e.optional(e.string()),startDate:e.optional(e.string()),hours:e.optional(e.string())})}),...["offer_sent","offer_accepted","offer_declined","offer_withdrawn"].map(t=>e.object({action:e.literal(t),actor:h,message:e.optional(e.never()),meta:e.object({reason:e.optional(e.string())})})),e.object({action:e.literal("exported"),actor:h,message:e.optional(e.never()),meta:e.object({presetId:Yn,exportId:T})}),e.object({action:e.literal("score_override"),actor:h,message:e.optional(e.never()),meta:e.pipe(St,e.transform(t=>({...t,reason:t.reason.trim()})))})]),Zn=e.variant("action",[zn,e.object({action:e.literal("shortlist"),actor:h,message:e.optional(U),meta:e.nullish(ue)}),e.object({action:e.literal("move_to_interview"),actor:h,message:e.optional(U),meta:e.nullish(ue)}),e.object({action:e.literal("make_offer"),actor:h,message:e.optional(U),meta:e.nullish(ue)}),e.object({action:e.literal("hire"),actor:h,message:e.optional(U),meta:e.nullish(Wn)}),e.object({action:e.literal("withdraw"),actor:h,message:e.optional(e.never()),meta:e.nullish(ue)}),e.object({action:e.literal("move_to_stage"),actor:h,message:e.optional(e.never()),meta:e.object({stage:x,stageGroup:w,note:e.nullish(e.string())})}),e.object({action:e.literal("stage_transition"),actor:h,message:e.optional(U),meta:e.object({toStage:x,toStageGroup:w,note:e.nullish(e.string())})}),e.object({action:e.literal("disqualify"),actor:h,message:e.optional(U),meta:e.object({reason:ee,note:e.nullish(e.string())})}),e.object({action:e.literal("reinstate"),actor:h,message:e.optional(U),meta:e.object({toStage:x,toStageGroup:w,note:e.nullish(e.string())})}),e.object({action:e.literal("rate"),actor:h,message:e.optional(e.never()),meta:e.object({rating:e.nullable(e.pipe(e.number(),e.integer(),e.minValue(1),e.maxValue(5)))})})]),ni=e.object({applicationIds:e.pipe(e.array(e.string()),e.minLength(1)),body:Zn}),wt=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified","already_disqualified"]),ri=e.variant("kind",[e.object({kind:e.literal("updated"),action:ve,application:F}),e.object({kind:e.literal("skipped"),action:ve,applicationId:e.string(),reason:wt})]),oi=e.object({updated:e.array(e.object({kind:e.literal("updated"),action:ve,application:F})),skipped:e.array(e.object({kind:e.literal("skipped"),action:ve,applicationId:e.string(),reason:wt})),failed:e.array(e.object({applicationId:e.string(),error:e.string()}))}),v=e.pipe(e.number(),e.integer(),e.minValue(0)),Rt=e.object({APPLIED:v,SHORTLISTED:v,INTERVIEWED:v,OFFERED:v,HIRED:v,REJECTED:v,WITHDRAWN:v}),Qn=e.pipe(e.string(),e.minLength(1),e.maxLength(255)),ii=e.object({pendingShares:e.optional(e.boolean())}),si=e.object({job_ids:_t,verdict_by:e.optional(Qn),pending_shares:e.optional(e.literal("1"))}),ai=e.object({counts:e.record(e.string(),Rt),existingAppliedCounts:e.optional(e.record(e.string(),v)),awaitingVerdictCounts:e.optional(e.record(e.string(),v)),pendingShareCounts:e.optional(e.record(e.string(),v))}),ci=e.omit(At,["sort","order","page","per_page"]),li=e.object({counts:Rt}),Pt=92,Xn=864e5,P=e.pipe(e.string(),e.regex(/^\d{4}-\d{2}-\d{2}$/),e.check(t=>{let r=new Date(`${t}T00:00:00Z`);return!Number.isNaN(r.getTime())&&r.toISOString().slice(0,10)===t},"must be a real calendar day"));function Be({from:t,to:r}){let i=(Date.parse(`${r}T00:00:00Z`)-Date.parse(`${t}T00:00:00Z`))/Xn+1;return i>=1&&i<=Pt}var Fe=`to must be on or after from, and the range must span at most ${Pt} days`,pi=e.pipe(e.object({from:P,to:P}),e.check(Be,Fe)),er=e.object({job_id:B,date:P,received:v,scored:v,shortlisted:v}),di=e.object({rows:e.array(er)}),tr=5e3,ui=e.pipe(e.object({from:P,to:P,jobIds:e.pipe(e.array(B),e.maxLength(tr))}),e.check(Be,Fe)),nr=e.object({job_id:B,date:P,received:v}),vi=e.object({rows:e.array(nr)}),rr=5e3,or=e.pipe(e.object({from:P,to:P,jobIds:e.optional(e.pipe(e.array(B),e.maxLength(rr)))}),e.check(Be,Fe)),mi=e.pipe(e.object({from:e.string(),to:e.string(),job_ids:e.optional(e.string())}),e.transform(({from:t,to:r,job_ids:i})=>({from:t,to:r,jobIds:i===void 0?void 0:i===""?[]:i.split(",").map(s=>/^\d+$/.test(s.trim())?Number(s):Number.NaN)})),or),Ue=e.pipe(e.array(v),e.length(5)),ir=e.object({received:v,scored:v,shortlisted:v,histogram:e.pipe(e.array(v),e.length(101)),median_lag_minutes:e.nullable(e.number()),scored_same_day:v}),sr=e.object({job_id:B,received:v,scored:v,shortlisted:v,score_sum:e.number(),bands:Ue}),ar=e.object({date:P,received:v,scored:v,score_sum:e.number(),bands:Ue,scored_on_day:v}),cr=e.object({id:e.string(),label:e.nullable(e.string()),sum:e.number(),count:v}),lr=e.object({template_id:e.string(),scored:v,criteria:e.array(cr)}),gi=e.object({totals:ir,by_job:e.array(sr),by_day:e.array(ar),criteria:e.array(lr)}),pr=e.object({date:P,scored:v,bands:Ue}),hi=e.object({rows:e.array(pr)});var fi=e.object({...e.omit(At,["page","per_page"]).entries,per_group:e.optional(e.string())}),M=e.object({data:e.array(F),total:v}),yi=e.object({board:e.object({APPLIED:M,SHORTLISTED:M,INTERVIEWED:M,OFFERED:M,HIRED:M,REJECTED:M,WITHDRAWN:M})});import*as Y from"valibot";var dr=({environment:t,publishableKey:r,logger:i})=>{let s=Je[t];return{async checkDuplicate(p){let l;try{l=Y.parse(Tt,{email:p.email,scope:p.scope,...p.scope==="job"&&p.jobId!=null?{jobId:p.jobId}:{}})}catch{return i.error("[TalentBankClient] checkDuplicate input failed validation"),{isDuplicate:!1}}try{let u=await fetch(`${s}/applications/check-duplicate`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-publishable-key":r},body:JSON.stringify(l)});if(!u.ok)return i.error(`[TalentBankClient] checkDuplicate failed with status ${u.status}`),{isDuplicate:!1};let m=await u.json(),b=Y.safeParse(Et,m);return b.success?b.output:(i.error("[TalentBankClient] checkDuplicate response failed strict validation; falling back to isDuplicate flag"),typeof m=="object"&&m!=null&&typeof m.isDuplicate=="boolean"?{isDuplicate:m.isDuplicate}:{isDuplicate:!1})}catch(u){return i.error("[TalentBankClient] checkDuplicate failed:",u),{isDuplicate:!1}}},async identify(p){try{if(!p.anonymousId)return i.error("[TalentBankClient] identify skipped because anonymousId is missing"),null;let l={email:p.email,firstName:p.firstName,lastName:p.lastName,phone:p.phone,anonymousId:p.anonymousId,source:p.source??"sdk"},u=Y.safeParse(bt,l);if(!u.success)return i.error("[TalentBankClient] identify received invalid input"),null;let m=await fetch(`${s}/identify`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-publishable-key":r},body:JSON.stringify(u.output)});if(!m.ok)return i.error(`[TalentBankClient] identify failed with status ${m.status}`),null;let b=Y.safeParse(je,await m.json());return b.success?b.output:(i.error("[TalentBankClient] identify returned an invalid response"),null)}catch(l){return i.error("[TalentBankClient] identify failed:",l),null}}}};function ur(t){if(!(typeof document>"u")){if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",t,{once:!0});return}Promise.resolve().then(t)}}import*as c from"valibot";var kt=["DAILY","WEEKLY","MONTHLY"],vr=c.record(c.string(),c.union([c.string(),c.array(c.string()),c.object({type:c.literal("provided"),lat:c.number(),lng:c.number(),radius:c.number(),unit:c.optional(c.picklist(["miles","km"])),label:c.optional(c.string())})])),mr={pathname:"/job/:id",method:"GET",schema:{response:c.object({id:c.number(),external_id:c.nullish(c.string()),city:c.nullish(c.string()),town:c.nullish(c.string()),category:c.nullish(c.string())})}};async function gr(t,{contact:r,job:i}){let s={};if(i){let p=await t.request(mr,{params:{id:i.id}});if((i.id_type==="internal"?String(p.id):p.external_id)!==i.id)throw new Error("Job lookup returned a different role");for(let u of["city","town","category"]){let m=p[u]?.trim();m&&(s[u]=[m])}}await t.request(Ct,{body:{contact:r,alerts:"WEEKLY",filters:s}})}var Ct={pathname:"/search/save",method:"POST",schema:{response:O(),body:c.object({contact:c.object({email:c.pipe(c.optional(c.string()),c.string(),c.email()),first_name:c.optional(c.string()),last_name:c.optional(c.string())}),alerts:c.pipe(c.optional(c.string()),c.string(),c.picklist(kt)),filters:vr})}};import*as A from"valibot";var Lt=async t=>{let r={method:"GET",pathname:"/search/filters",schema:{response:A.pipe(A.object({country:A.optional(A.array(A.object({value:A.string()})),[])}),A.transform(({country:i})=>i.map(({value:s})=>s))),searchParams:O()}};return t.request(r,{searchParams:{filters:{country:null}}})},me=new WeakMap,hr=t=>(me.has(t)||(me.set(t,void 0),Lt(t).then(async r=>{let{jobCountryCodes:i}=await import("./sdk.country-codes-W6HRF5SA.mjs");me.set(t,i(r).join(",")||void 0)}).catch(()=>{})),me.get(t)),Ot=(t,r)=>{let i=new Set,s=[];for(let p=0;p<Math.max(t.length,r.length);p++)for(let l of[t[p],r[p]]){if(!l)continue;let u=l.mapbox_id||l.full_address||[l.name,l.place_formatted].filter(Boolean).join(", ");if(!i.has(u)&&(i.add(u),s.push(l),s.length===5))return s}return s},fr=600,yr=async(t,r,i)=>{if(i?.throwIfAborted(),!r){let s=await t();return i?.throwIfAborted(),s}return new Promise((s,p)=>{let l,u,m,b=!1,E=()=>{b=!0,clearTimeout(m),i?.removeEventListener("abort",V)},V=()=>{E(),p(i?.reason)},j=()=>{E(),l?.status==="fulfilled"&&u?.status==="fulfilled"?s(Ot(l.value,u.value)):l?.status==="fulfilled"?s(l.value):u?.status==="fulfilled"?s(u.value):l?.status==="rejected"&&p(l.reason)},ge=(d,y)=>{b||(d?l=y:u=y,l&&u?j():y.status==="fulfilled"&&y.value.length>0&&(m=setTimeout(j,fr)))};i?.addEventListener("abort",V,{once:!0});for(let d of[!0,!1])t(d?r:void 0).then(y=>ge(d,{status:"fulfilled",value:y}),y=>ge(d,{status:"rejected",reason:y}))})};export{tn as ANALYTICS_EVENTS,H as ApiError,X as InploiRpcClient,kt as JOB_ALERT_FREQUENCIES,$ as NotFoundError,K as ParsingError,k as SchemaValidationError,qe as SdkError,J as UnauthorisedError,hr as addressSearchCountry,Ot as blendAddressSuggestions,Re as consentStorageKey,Bt as createPlugin,dr as createTalentBankClient,ce as endpoint,Z as generateUUID,nn as getConsentAcceptance,Lt as getJobCountries,et as getOrCreateAnonymousId,we as hashConsentConfig,en as initialiseSdk,Se as inploiBrandedLogger,Mt as isApiErrorWithData,qt as isSdkError,Nt as jobCountryCodes,be as noLogging,ur as ready,gr as saveClosedRoleJobAlerts,Ct as saveSearchEndpoint,yr as searchAddressSuggestions,rn as setConsentAcceptance,O as typed,nt as validateEndpointInputs};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|