@inploi/sdk 3.1.0 → 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 +8 -3
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as dt}from"./chunk-KC7FKSIJ.mjs";var Q="%c[inploi SDK]",Z="color: #65BC67; font-weight: bold;",ve={warn:(...t)=>console.warn(Q,Z,...t),error:(...t)=>console.error(Q,Z,...t),info:(...t)=>console.info(Q,Z,...t),log:(...t)=>console.log(Q,Z,...t)},fe={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var ut=t=>t;function he(t,n){if(!t)throw new Error(n)}function F(t,n){return n in t}var vn=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});var mt="Unauthenticated",gt="This action is unauthorized.",O=class extends Error{constructor(r,o){super(r);this.status=o,this.name="ErrorWithStatus"}},U=class extends O{constructor(n){super(n??"Not found"),this.name="NotFoundError",this.status=404}},B=class extends O{constructor(n,r){super(n??"You are not authorised to perform this action."),this.name="UnauthorisedError",this.status=r??401}},P=class extends O{constructor(r,o){let l=o?` in ${o}`:"";super(`Schema validation failed${l}`);this.issues=r;this.source=o;this.name="SchemaValidationError",this.status=400}},q=class extends O{constructor(r,o,l){super(r);this.data=l;this.name="ApiError",this.status=o??500}},vt=t=>t instanceof q&&t.data!==void 0,G=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 ye(t){let r=new Headers(t.headers).get("content-type")?.replace(/;.*/,"").trim().toLowerCase();if(r&&r!=="application/json"&&!r.endsWith("+json"))throw new G(t);return t.json().catch(()=>{throw new G(t)})}var ft=["message","error","errors","exception","exceptions"];function ht(t){let n=[];if(typeof t=="object"&&t!==null){for(let r of ft)if(F(t,r)){let o=t[r];typeof o=="string"&&n.push(o),Array.isArray(o)&&o.every(l=>typeof l=="string")&&n.push(...o)}F(t,"integration_response")&&typeof t.integration_response=="object"&&t.integration_response!==null&&F(t.integration_response,"error")&&typeof t.integration_response.error=="object"&&t.integration_response.error!==null&&F(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 Se(t,n){if(n>=300){let r=ht(t);throw n===404?new U(r):r===mt?new B("You are not authenticated.",n):r===gt?new B(r,n):new q(r,n,t)}}var Pe=t=>{let n={Accept:"application/json","Content-Type":"application/json","x-publishable-key":t.publishableKey};return{fetch:async(r,o={})=>{let l={...o,headers:{...o.headers,...n}},c=await fetch(`${t.baseUrl}${r}`,l);if(c.status===404)throw new U;let d=await ye(c);return Se(d,c.status),d}}},Re={NotFound:U,Unauthorised:B,SchemaValidation:P,Api:q,JsonParsing:G};function yt(t){return Object.values(Re).some(n=>t instanceof n)}var ke="3.1.0";var X={sandbox:"https://api.staging.inploi.com",production:"https://api.inploi.com",_internal_local:"http://api.test"},Ce={sandbox:"https://talent-bank.staging.inploi.com",production:"https://talent-bank.inploi.com",_internal_local:"http://localhost:8787"},Le=ke;var R="isdk_session",Oe=`${R}-candidate_id`,De=`${R}-consent`;var ee=new Map,be={get:t=>{if(ee.has(t))return ee.get(t)??null;try{return window.sessionStorage.getItem(t)}catch{return null}},set:(t,n)=>{try{window.sessionStorage.setItem(t,n),ee.delete(t)}catch{ee.set(t,n)}}};var K=()=>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 je=7*24*60*60*1e3,Fe=t=>{let n=new Date;return n.setTime(n.getTime()+je),`${R}=${t};expires=${n.toUTCString()};path=/`},bt=(t,n)=>{let r=t.get("session_id");if(n||r)return r;let o=be.get(`${R}-session_id`);return typeof o=="string"?o:null},_t=()=>{if(typeof window>"u")return null;try{let t=window.localStorage.getItem(Oe);return typeof t=="string"&&t!==""?t:null}catch{return null}},Tt=new RegExp(`(?:^|;\\s*)${R}=([^;]+)`),W=t=>{let n=t?t.headers.get("cookie"):document.cookie;return n?Tt.exec(n)?.[1]??null:null},Ue=()=>{try{let t=JSON.parse(window.localStorage.getItem(R)??"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}},Ne=()=>W()??(new URL(location.href).searchParams.get("anonymous_id")?null:Ue()),At=()=>location.protocol==="https:"&&window.self!==window.top?";SameSite=None;Secure;Partitioned":"",Be=t=>{if(document.cookie=Fe(t)+At(),W()!==t)try{window.localStorage.setItem(R,JSON.stringify({id:t,expires:Date.now()+je}))}catch{}},_e=t=>{let n=t?t.url:location.href,{searchParams:r}=new URL(n);return{anonymous_id:t?W(t)??r.get("anonymous_id"):W()??r.get("anonymous_id")??Ue(),session_id:bt(r,typeof window>"u")}},qe=()=>{if(typeof window>"u")throw new Error("getOrCreateAnonymousId() can only be called in browser environment");let t=_e().anonymous_id;if(t)return t;let n=K(),r=_e().anonymous_id;return r||(Be(n),n)},Et=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},xt=t=>t==="about:client"?"":t,It={pathname:"/log",method:"POST",schema:{response:C(),body:C()}},Ge=({rpcClient:t,logger:n,onEvent:r,persistence:o="device",siteKind:l})=>{let c=null,d=null,u=0,h=0,E=p=>o==="none"?{anonymous_id:null,session_id:p?null:c}:_e(p),N=async(p,m,Y)=>{try{let j={library:{name:"inploi-sdk",version:Le},page:m},V=E(p.request),z=o==="none"?null:_t(),g={anonymous_id:V.anonymous_id,session_id:V.session_id,candidate_id:z,event:p.event,sent_at:new Date().toISOString(),context:j,properties:p.properties,custom_properties:{...p.customProperties,...Y}},ue=o==="none"?null:p.request?W(p.request):Ne(),Ie=++u,lt=await t.request(It,{body:g,...p.keepalive&&{keepalive:!0}}),x=Et(lt);if(o==="none")return!p.request&&x?.session_id&&Ie>h&&(h=Ie,x.session_id!==g.session_id&&(c=x.session_id)),g.session_id=p.request?x?.session_id||null:c,r?.(g),{success:!0,data:g};let me=p.request?ue:Ne(),pt=me!==null&&me!==ue,ge=me??ue,we=!pt&&(!ge||!x?.anonymous_id||ge===x.anonymous_id);return we?(x?.anonymous_id&&(g.anonymous_id=x.anonymous_id),x?.session_id&&(g.session_id=x.session_id)):g.anonymous_id=ge,!p.request&&typeof window<"u"&&g.anonymous_id&&(we&&g.session_id&&be.set(`${R}-session_id`,g.session_id.toString()),Be(g.anonymous_id)),r?.(g),{success:!0,data:g}}catch(j){return n.error("Failed to send log to API. Inspect error response of `log` for more information."),{success:!1,error:j}}},L=Promise.resolve();return{log:async p=>{he(p.request||typeof window<"u","Cannot log on the server without a request. Please pass a request to `log`.");let m="request"in p&&p.request?{href:p.request.url,referrer:xt(p.request.referrer),title:""}:{href:location.href,referrer:document.referrer,title:document.title};if(p.page_context==="no_query"){let z=new URL(m.href),g=m.referrer?new URL(m.referrer):void 0;m={href:z.origin+z.pathname,referrer:g?g.origin+g.pathname:""}}o==="none"&&p.event==="FLOW_NODE"&&p.properties&&"trigger"in p.properties&&(p.properties.trigger==="pagehide"||p.properties.trigger==="hidden")&&(p={...p,keepalive:!0});let Y={event_id:K(),consent_lane:o,site_kind:l};if(o==="device"||p.request||c||p.keepalive)return N(p,m,Y);let j=()=>N(p,m,Y),V=L.then(j,j);return L=V,V},supportsNoQueryPageContext:!0,getHeaders:p=>{let m=new Headers;return o==="none"||!p?.anonymous_id||m.append("Set-Cookie",Fe(p.anonymous_id)),m},getSessionInfo:E,getOrCreateAnonymousId:()=>o==="none"?d??(d=K()):qe()}};import{stringify as wt}from"neoqs";function Te(t,n,r){let o=t["~standard"].validate(n);if(o instanceof Promise)throw new TypeError("Async schema");if(o.issues)throw new P(o.issues,r);return o.value}function Pt(t,n,r){try{return{success:!0,output:Te(t,n,r)}}catch(o){if(o instanceof P)return{success:!1,issues:o.issues,source:o.source};throw o}}var J=class{constructor(n){if(this.baseUrl=X[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 o=r.validateIn??!0,{searchParams:l,body:c}=o?Me(n,r):r,d=new URL(this.baseUrl),u=n.pathname;if("params"in r&&r.params)for(let[h,E]of Object.entries(r.params))u=u.replace(`:${h}`,String(E));return d.pathname=u,n.schema.searchParams&&(d.search=wt(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 o=await ye(r.response);if(Se(o,r.response.status),!(r.validateOut??!0))return o;let c=Pt(n.schema.response,o,"response");if(!c.success)throw new P(c.issues,c.source);return c.output}async request(n,r){try{let o=this.getFetchParams(n,r),l=await fetch(...o);return await this.parseResponse(n,{response:l,validateOut:r.validateOut})}catch(o){throw o instanceof P?this.logger.error(o.message,o.issues):this.logger.error(o),o}}};function C(){return{"~standard":{vendor:"inploi",version:1,validate:t=>({value:t})}}}function te(t){return t}function Me(t,n){let r={searchParams:void 0,body:void 0,validateIn:!1};return t.schema.searchParams&&(r.searchParams=Te(t.schema.searchParams,"searchParams"in n?n.searchParams:{})),t.schema.body&&(r.body=Te(t.schema.body,"body"in n?n.body:{})),r}function Rt({publishableKey:t,env:n,logger:r=ve,onEvent:o,persistence:l,siteKind:c}){let d=Pe({baseUrl:X[n],publishableKey:t}),u=r===!1?fe:r,h=new J({environment:n,apiKey:{type:"publishable",key:t},logger:u}),E=Ge({rpcClient:h,logger:u,onEvent:o,persistence:l,siteKind:c});return{register:L=>L({logger:u,apiClient:d,analytics:E,rpcClient:h,publishableKey:t,env:n}),analytics:E,apiClient:d}}var kt={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 Ae(t){let n=JSON.stringify({message:t.message,acceptLabel:t.acceptLabel??"",declineLabel:t.declineLabel??""}),r=5381;for(let o=0;o<n.length;o++)r=r*33^n.charCodeAt(o);return(r>>>0).toString(36)}function Ee(t,n){return`${De}:${t}:${n}`}function Ct(t,n){if(typeof window>"u")return!1;try{let r=Ee(t,Ae(n));return window.localStorage.getItem(r)==="accepted"}catch{return!1}}function Lt(t,n){if(!(typeof window>"u"))try{let r=Ee(t,Ae(n));window.localStorage.setItem(r,"accepted")}catch{}}import*as s from"valibot";var Ot=["agent","sdk","form","integration","migration"],Dt=["APPLIED","SHORTLISTED","INTERVIEWED","OFFERED","HIRED","REJECTED","WITHDRAWN"];var Nt=["screening","cv_match","interview","overall"],jt=["PENDING","SCHEDULED","IN_PROGRESS","COMPLETED","CANCELLED"],Ft=["job","company"],Ut=["created_at","updated_at"],Bt=["asc","desc"],qt=["careers_site","chatbot","plugin_job_search","ats_import","referral","agency","other","unknown"],Gt=["submit","stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate","score_written"],Mt=["user","system","automation","integration","candidate"],ne=s.picklist(Ot),I=s.picklist(Dt),A=s.pipe(s.string(),s.trim(),s.minLength(1),s.maxLength(100)),re=s.picklist(Nt),Ve=s.picklist(jt),Yn=s.picklist(Ft),Ke=s.picklist(Ut),We=s.picklist(Bt),$=s.pipe(s.string(),s.trim(),s.minLength(1),s.maxLength(100)),oe=s.picklist(qt),Je=s.picklist(Gt),$e=s.picklist(Mt);var b=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 w from"valibot";var Vt=w.object({total:w.number(),page:w.number(),perPage:w.number(),lastPage:w.number()});function ie(t){return w.object({data:w.array(t),pagination:Vt})}import*as v from"valibot";var H=v.object({id:v.string(),email:v.nullable(v.string()),firstName:v.nullable(v.string()),lastName:v.nullable(v.string()),phone:v.nullable(v.string()),source:v.nullable(ne),identifiedAt:v.nullable(v.string()),createdAt:v.string(),updatedAt:v.string()});import*as i from"valibot";import*as f from"valibot";var M=f.pipe(f.string(),f.minLength(1)),He=f.pipe(f.number(),f.integer(),f.minValue(1)),k=f.record(f.string(),f.unknown());import*as _ from"valibot";var Ye=_.object({id:_.string(),applicationId:_.string(),status:Ve,scheduledAt:_.nullable(_.string()),completedAt:_.nullable(_.string()),meta:_.nullable(k),createdAt:_.string(),updatedAt:_.string()});var xe=i.object({score:i.number(),reason:i.string(),confidence:i.number()}),ze=i.object({id:i.string(),candidateId:i.string(),jobId:i.number(),stage:A,stageGroup:I,stageEnteredAt:i.string(),rating:i.nullable(i.number()),disqualifiedAt:i.nullable(i.string()),disqualificationReason:i.nullable($),disqualificationNote:i.nullable(i.string()),source:oe,sourceDetail:i.nullable(i.string()),sessionId:i.nullable(i.number()),externalApplicationId:i.nullable(i.string()),meta:i.nullable(k),context:i.nullable(k),scoredAt:i.nullable(i.string()),createdAt:i.string(),updatedAt:i.string()}),Kt=i.object({id:i.string(),applicationId:i.string(),scoreType:re,score:i.nullable(i.number()),reason:i.nullable(i.string()),categories:i.nullable(i.record(i.string(),xe)),scoredBy:i.nullable(i.string()),createdAt:i.string()}),se=i.object({...ze.entries,candidate:i.nullable(H),score:i.nullable(Kt),interview:i.nullable(Ye)}),Wt=i.object({...H.entries,applications:i.array(ze)}),Qe=i.object({id:i.string(),applicationId:i.string(),action:Je,fromStage:i.nullable(A),fromStageGroup:i.nullable(I),toStage:i.nullable(A),toStageGroup:i.nullable(I),disqualificationReason:i.nullable($),disqualificationNote:i.nullable(i.string()),actorId:i.nullable(i.string()),actorType:$e,actorEmail:i.nullable(i.string()),actorName:i.nullable(i.string()),meta:i.nullable(k),schemaVersion:i.number(),createdAt:i.string()});import*as y from"valibot";var Ze=y.object({anonymousId:M,email:M,firstName:y.nullish(y.string()),lastName:y.nullish(y.string()),phone:y.nullish(y.string()),source:y.nullish(ne)}),Xe=y.object({candidateId:y.string(),isNew:y.boolean()});import*as e from"valibot";var Jt=["stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate"],ce=e.picklist(Jt),et=e.pipe(e.string(),e.transform(t=>t.split(",").map(n=>n.trim()).filter(n=>n.length>0))),$t=e.pipe(et,e.array(A)),Ht=e.pipe(et,e.array(I)),tt=e.pipe(e.string(),e.transform(t=>t.split(",").map(n=>Number(n.trim())).filter(n=>Number.isInteger(n)&&n>0))),fr=e.object({stages:e.optional($t),stage_groups:e.optional(Ht),job_id:e.optional(e.string()),job_ids:e.optional(tt),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"])),sort:e.optional(Ke),order:e.optional(We),page:e.optional(e.string()),per_page:e.optional(e.string())}),hr=e.pipe(e.object({candidateId:M,jobId:He,meta:e.nullish(k),sessionId:e.nullish(e.number()),externalApplicationId:e.nullish(e.string()),context:e.nullish(k),source:e.nullish(oe),sourceDetail:e.nullish(e.string()),stage:e.nullish(A),stageGroup:e.nullish(I),actor:e.nullish(b)}),e.check(t=>t.stage==null==(t.stageGroup==null),"stage and stageGroup must be supplied together")),nt=e.object({id:e.string(),stageGroup:e.string(),createdAt:e.string()}),yr=e.union([e.object({ok:e.literal(!0),duplicate:e.literal(!1),applicationId:e.string(),candidateId:e.string()}),e.object({ok:e.literal(!0),duplicate:e.literal(!0),existingApplication:nt})]),rt=e.object({isDuplicate:e.boolean(),existingApplication:e.optional(nt)}),Sr=e.object({applicationId:M,scoreType:re,score:e.number(),reason:e.nullish(e.string()),categories:e.nullish(e.record(e.string(),xe)),scoredBy:e.nullish(e.string()),actor:e.nullish(b)}),br=e.object({scoreId:e.string()}),_r=ie(se);var Tr=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified"]),Ar=e.array(Qe),ae=e.object({stage:e.nullish(A),note:e.nullish(e.string())}),Yt=e.object({stage:e.nullish(A),startDate:e.nullish(e.string()),note:e.nullish(e.string())}),zt=e.variant("action",[e.object({action:e.literal("shortlist"),actor:b,meta:e.nullish(ae)}),e.object({action:e.literal("move_to_interview"),actor:b,meta:e.nullish(ae)}),e.object({action:e.literal("make_offer"),actor:b,meta:e.nullish(ae)}),e.object({action:e.literal("hire"),actor:b,meta:e.nullish(Yt)}),e.object({action:e.literal("withdraw"),actor:b,meta:e.nullish(ae)}),e.object({action:e.literal("move_to_stage"),actor:b,meta:e.object({stage:A,stageGroup:I,note:e.nullish(e.string())})}),e.object({action:e.literal("stage_transition"),actor:b,meta:e.object({toStage:A,toStageGroup:I,note:e.nullish(e.string())})}),e.object({action:e.literal("disqualify"),actor:b,meta:e.object({reason:$,note:e.nullish(e.string())})}),e.object({action:e.literal("reinstate"),actor:b,meta:e.object({toStage:A,toStageGroup:I,note:e.nullish(e.string())})}),e.object({action:e.literal("rate"),actor:b,meta:e.object({rating:e.nullable(e.pipe(e.number(),e.integer(),e.minValue(1),e.maxValue(5)))})})]),Er=e.object({applicationIds:e.pipe(e.array(e.string()),e.minLength(1)),body:zt}),ot=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified","already_disqualified"]),xr=e.variant("kind",[e.object({kind:e.literal("updated"),action:ce,application:se}),e.object({kind:e.literal("skipped"),action:ce,applicationId:e.string(),reason:ot})]),Ir=e.object({updated:e.array(e.object({kind:e.literal("updated"),action:ce,application:se})),skipped:e.array(e.object({kind:e.literal("skipped"),action:ce,applicationId:e.string(),reason:ot})),failed:e.array(e.object({applicationId:e.string(),error:e.string()}))}),D=e.pipe(e.number(),e.integer(),e.minValue(0)),Qt=e.object({APPLIED:D,SHORTLISTED:D,INTERVIEWED:D,OFFERED:D,HIRED:D,REJECTED:D,WITHDRAWN:D}),wr=e.object({job_ids:tt}),Pr=e.object({counts:e.record(e.string(),Qt)});var Or=ie(H);import*as S from"valibot";var Nr=S.object({avg_score:S.nullable(S.number()),p90_score:S.nullable(S.number()),p85_score:S.nullable(S.number()),p80_score:S.nullable(S.number()),total_scores:S.number(),total_shortlists:S.number()});import*as le from"valibot";var Zt=({environment:t,publishableKey:n,logger:r})=>{let o=Ce[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(`${o}/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(),h=le.safeParse(rt,u);return h.success?h.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=le.safeParse(Ze,c);if(!d.success)return r.error("[TalentBankClient] identify received invalid input"),null;let u=await fetch(`${o}/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 h=le.safeParse(Xe,await u.json());return h.success?h.output:(r.error("[TalentBankClient] identify returned an invalid response"),null)}catch(c){return r.error("[TalentBankClient] identify failed:",c),null}}}};function Xt(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 it=["DAILY","WEEKLY","MONTHLY"],en=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())})])),tn={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 nn(t,{contact:n,job:r}){let o={};if(r){let l=await t.request(tn,{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&&(o[d]=[u])}}await t.request(st,{body:{contact:n,alerts:"WEEKLY",filters:o}})}var st={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(it)),filters:en})}};import*as T from"valibot";var at=async t=>{let n={method:"GET",pathname:"/search/filters",schema:{response:T.pipe(T.object({country:T.optional(T.array(T.object({value:T.string()})),[])}),T.transform(({country:r})=>r.map(({value:o})=>o))),searchParams:C()}};return t.request(n,{searchParams:{filters:{country:null}}})},pe=new WeakMap,rn=t=>(pe.has(t)||(pe.set(t,void 0),at(t).then(async n=>{let{jobCountryCodes:r}=await import("./sdk.country-codes-W6HRF5SA.mjs");pe.set(t,r(n).join(",")||void 0)}).catch(()=>{})),pe.get(t)),ct=(t,n)=>{let r=new Set,o=[];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),o.push(c),o.length===5))return o}return o},on=600,sn=async(t,n,r)=>{if(r?.throwIfAborted(),!n){let o=await t();return r?.throwIfAborted(),o}return new Promise((o,l)=>{let c,d,u,h=!1,E=()=>{h=!0,clearTimeout(u),r?.removeEventListener("abort",N)},N=()=>{E(),l(r?.reason)},L=()=>{E(),c?.status==="fulfilled"&&d?.status==="fulfilled"?o(ct(c.value,d.value)):c?.status==="fulfilled"?o(c.value):d?.status==="fulfilled"?o(d.value):c?.status==="rejected"&&l(c.reason)},de=(p,m)=>{h||(p?c=m:d=m,c&&d?L():m.status==="fulfilled"&&m.value.length>0&&(u=setTimeout(L,on)))};r?.addEventListener("abort",N,{once:!0});for(let p of[!0,!1])t(p?n:void 0).then(m=>de(p,{status:"fulfilled",value:m}),m=>de(p,{status:"rejected",reason:m}))})};export{kt as ANALYTICS_EVENTS,q as ApiError,J as InploiRpcClient,it as JOB_ALERT_FREQUENCIES,U as NotFoundError,G as ParsingError,P as SchemaValidationError,Re as SdkError,B as UnauthorisedError,rn as addressSearchCountry,ct as blendAddressSuggestions,Ee as consentStorageKey,ut as createPlugin,Zt as createTalentBankClient,te as endpoint,K as generateUUID,Ct as getConsentAcceptance,at as getJobCountries,qe as getOrCreateAnonymousId,Ae as hashConsentConfig,Rt as initialiseSdk,ve as inploiBrandedLogger,vt as isApiErrorWithData,yt as isSdkError,dt as jobCountryCodes,fe as noLogging,Xt as ready,nn as saveClosedRoleJobAlerts,st as saveSearchEndpoint,sn as searchAddressSuggestions,Lt as setConsentAcceptance,C as typed,Me 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
|