PageSourceSearch

https://www.ikook.co.uk/_next/static/chunks/3803-671fb8884c70c884.js

js ikook.co.uk collected 2026-10-07 02:14:50 UTC 12,334 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3803],{91389:(e,t,n)=>{n.d(t,{c:()=>r});var o=n(8224);function r(){return(0,o.c0)()}},87276:(e,t,n)=>{n.d(t,{G:()=>r});var o=n(15757);let r={async getToken(){var e;let t=await o.A.get("/calling/token/");return(null===(e=t.data)||void 0===e?void 0:e.data)||t.data},async initiateCall(e){var t;let n=await o.A.post("/calling/initiate/",{booking_id:e});return(null===(t=n.data)||void 0===t?void 0:t.data)||n.data},async updateCallSid(e,t){var n;let r=await o.A.post("/calling/update-sid/",{call_id:e,provider_call_id:t});return(null===(n=r.data)||void 0===n?void 0:n.data)||r.data},async getCallStatus(e){var t;let n=await o.A.get("/calling/status/".concat(e,"/"));return(null===(t=n.data)||void 0===t?void 0:t.data)||n.data}}},15757:(e,t,n)=>{n.d(t,{A:()=>u});var o=n(82651),r=n(86249);let l=o.A.create({baseURL:"https://ikook-prod-9c50f663a33f.herokuapp.com",headers:{"Content-Type":"application/json"},withCredentials:!0,timeout:6e4});(0,r.Ay)(l,{retries:3,retryDelay:e=>1e3*e,retryCondition:e=>{var t,n;let o=null===(n=e.config)||void 0===n?void 0:null===(t=n.method)||void 0===t?void 0:t.toUpperCase();return(!o||"GET"===o)&&!!(r.Ay.isNetworkError(e)||e.response&&e.response.status>=500)},shouldResetTimeout:!0});let a=!1,i=[],c=e=>{i.forEach(t=>{e?t.reject(e):t.resolve()}),i=[]};l.interceptors.response.use(e=>e,async e=>{var t,n,o,r;let u=e.config;if((null===(t=e.response)||void 0===t?void 0:t.status)===401&&u&&!u._retry&&!(null===(n=u.url)||void 0===n?void 0:n.includes("/auth/login"))&&!(null===(o=u.url)||void 0===o?void 0:o.includes("/auth/signup"))&&!(null===(r=u.url)||void 0===r?void 0:r.includes("/auth/refresh"))){if(a)return new Promise((e,t)=>{i.push({resolve:e,reject:t})}).then(()=>l(u));u._retry=!0,a=!0;try{return await l.post("/users/auth/refresh/"),c(null),l(u)}catch(e){return c(e),window.location.pathname.includes("/login")||(window.location.href="/login"),Promise.reject(e)}finally{a=!1}
1}return Promise.reject(e)});let u=l},8224:(e,t,n)=>{n.d(t,{QP:()=>c,c0:()=>u});var o=n(95155),r=n(12115),l=n(87276),a=n(67610);let i=(0,r.createContext)(null);function c(e){let{children:t}=e,[c,u]=(0,r.useState)("idle"),[s,d]=(0,r.useState)(0),[g,m]=(0,r.useState)(null),[p,f]=(0,r.useState)(null),[y,h]=(0,r.useState)(!1),[k,v]=(0,r.useState)(null),[S,_]=(0,r.useState)(!1),[b,w]=(0,r.useState)(null),[C,A]=(0,r.useState)(""),T=(0,r.useRef)(null),I=(0,r.useRef)(null),E=(0,r.useRef)(null),N=(0,r.useRef)(null),x=(0,r.useRef)("idle");(0,r.useEffect)(()=>{x.current=c},[c]);let j=(0,r.useCallback)(()=>{d(0),E.current=setInterval(()=>{d(e=>e+1)},1e3)},[]),P=(0,r.useCallback)(()=>{E.current&&(clearInterval(E.current),E.current=null)},[]),{isAuthenticated:F}=(0,a.n)();(0,r.useEffect)(()=>{let e=!0,t=0,o=null,r=async()=>{if(F)try{v(null);let{token:t,provider:r}=await l.G.getToken();if(!e)return;if(w(r),T.current){try{T.current.destroy?T.current.destroy():T.current.hangup&&T.current.hangup()}catch(e){}T.current=null}if("twilio"===r){let{Device:o}=await n.e(6632).then(n.bind(n,86632)),r=new o(t,{logLevel:1,codecPreferences:["pcmu","opus"],edge:"roaming"});r.on("registered",()=>{e&&(h(!0),v(null))}),r.on("error",t=>{e&&(f((null==t?void 0:t.message)||"Twilio device error"),v((null==t?void 0:t.message)||"Twilio device error"))}),r.on("incoming",t=>{var n;e&&m({from:(null===(n=t.parameters)||void 0===n?void 0:n.From)||"Unknown",accept:()=>{t.accept(),I.current=t,t.on("accept",()=>{u("connected"),j()}),t.on("disconnect",()=>{u("disconnected"),P(),I.current=null,setTimeout(()=>u("idle"),2e3)})},reject:()=>{t.reject(),m(null)}})}),await r.register(),T.current=r}else if("africastalking"===r){let n=await new Promise((e,t)=>{let n=document.getElementById("at-webrtc-script");n&&n.remove();let o=document.createElement("script");o.id="at-webrtc-script",o.src="https://unpkg.com/[email protected]/build/africastalking.js?t=".concat(Date.now()),o.async=!0,o.onload=()=>{let n=window.Africastalking||window.AfricasTalking;n?e(n):t(Error("Africastalking global not found after script load"))},o.onerror=()=>t(Error("Failed to load AT WebRTC script from CDN")),document.head.appendChild(o)}),r=n.Client||n,l=document.getElementById("remote-stream-audio");l||((l=document.createElement("audio")).id="remote-stream-audio",l.setAttribute("autoplay","autoplay"),l.setAttribute("playsinline","true"),l.style.position="absolute",l.style.width="1px",l.style.height="1px",l.style.opacity="0",l.style.overflow="hidden",l.style.top="-9999px",l.style.left="-9999px",document.body.appendChild(l));let a=new r(t,{iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"}]}),i=!1;a.on("ready",()=>{e&&(i=!0,o&&clearTimeout(o),h(!0),v(null))}),o=setTimeout(()=>{e&&!i&&(h(!0),v(null))},5e3),a.on("incomingcall",t=>{e&&m({from:t.from||"Unknown",accept:()=>{let e=document.getElementById("remote-stream-audio");if(e)try{e.play().catch(()=>{})}catch(e){}a.answer(),u("connected"),j()},reject:()=>{a.hangup(),m(null)}})}),a.on("callaccepted",()=>{if(e){u("connected"),j();let e=document.getElementById("remote-stream-audio");e&&e.play().catch(()=>{})}}),a.on("hangup",t=>{e&&(("connecting"===x.current||"ringing"===x.current)&&f("Call disconnected instantly. Please manually refresh the page (F5) and try again."),u("disconnected"),P()),I.current=null,setTimeout(()=>{e&&u("idle")},2e3)}),a.on("error",t=>{e&&f("string"==typeof t?t:"Africa's Talking device error")}),T.current=a}}catch(n){e&&t<2?setTimeout(r,3e3*++t):e&&v("Unable to initialize calling. Please refresh.")}};return r(),()=>{if(e=!1,P(),o&&clearTimeout(o),T.current){try{T.current.destroy?T.current.destroy():T.current.logout&&T.current.logout()}catch(e){}T.current=null}}},[F,j,P]);let G=(0,r.useCallback)(async(e,t)=>{var n,o,r;if(!T.current){f("Calling is not available. Please refresh.");return}try{_(!0),f(null),u("connecting"),A(t||"User");let o=await l.G.initiateCall(e);if(N.current=o.call_id,o.receiver_name&&A(o.receiver_name),"twilio"===o.provider){let e=await T.current.connect({params:{To:o.receiver_identity,call_id:String(o.call_id)}});I.current=e,u("ringing"),(null===(n=e.parameters)||void 0===n?void 0:n.CallSid)&&l.G.updateCallSid(o.call_id,e.parameters.CallSid).catch(()=>{}),e.on("accept",()=>{u("connected"),j()}),e.on("disconnect",()=>{u("disconnected"),P(),I.current=null,setTimeout(()=>u("idle"),2e3)})}else if("africastalking"===o.provider){let e=document.getElementById("remote-stream-audio");e||((e=document.createElement("audio")).id="remote-stream-audio",e.setAttribute("autoplay","autoplay"),e.setAttribute("playsinline","true"),e.style.position="absolute",e.style.width="1px",e.style.height="1px",e.style.opacity="0",e.
1style.overflow="hidden",e.style.top="-9999px",e.style.left="-9999px",document.body.appendChild(e));try{e.play().catch(()=>{})}catch(e){}let{token:t}=await l.G.getToken();T.current.call(o.receiver_identity,{token:t,call_id:String(o.call_id)}),I.current={provider:"africastalking"},u("ringing")}}catch(e){f((null==e?void 0:null===(r=e.response)||void 0===r?void 0:null===(o=r.data)||void 0===o?void 0:o.error)||(null==e?void 0:e.message)||"Failed to start call"),u("idle")}finally{_(!1)}},[j,P]),D=(0,r.useCallback)(()=>{I.current&&("twilio"===b&&I.current.disconnect?I.current.disconnect():"africastalking"===b&&T.current.hangup(),I.current=null),P(),u("idle")},[P,b]),B=(0,r.useCallback)(()=>{g&&g.accept()},[g]),J=(0,r.useCallback)(()=>{g&&g.reject()},[g]);return(0,o.jsx)(i.Provider,{value:{makeCall:G,hangup:D,callStatus:c,isCalling:"idle"!==c&&"disconnected"!==c,callDuration:s,incomingCall:g,acceptIncoming:B,rejectIncoming:J,error:p,isDeviceReady:y,deviceError:k,activeRecipientName:C,isConnecting:S,provider:b},children:t})}function u(){let e=(0,r.useContext)(i);if(!e)throw Error("useVoice must be used within a VoiceProvider");return e}},68383:(e,t,n)=>{n.d(t,{A:()=>c,w:()=>i});var o=n(95155),r=n(12115);let l="ikook_market_src",a=r.createContext(void 0);function i(e){let{children:t}=e,[n,i]=r.useState("NG"),[c,u]=r.useState(void 0),[s,d]=r.useState(void 0),[g,m]=r.useState(void 0);r.useEffect(()=>{i(function(){if("undefined"==typeof document)return"NG";let e=document.cookie.split("; ").find(e=>e.startsWith("".concat("ikook_market","="))),t=null==e?void 0:e.split("=")[1];return"NG"===t||"ZA"===t||"GB"===t?t:"NG"}());try{let e=localStorage.getItem("userLocation");if(e){let{latitude:t,longitude:n}=JSON.parse(e);"number"==typeof t&&"number"==typeof n&&(d(t),m(n))}}catch(e){}},[]),r.useEffect(()=>{var e;let t=!1;async function o(){try{let e=new AbortController,o=setTimeout(()=>e.abort(),3e3),r=await fetch("https://ipapi.co/json/",{signal:e.signal});if(clearTimeout(o),!r.ok){if(!(r=await fetch("https://ip-api.com/json/",{signal:e.signal})).ok)return;let n=await r.json();if(n.city&&!t&&u(n.city),"number"==typeof n.lat&&"number"==typeof n.lon&&!t){d(n.lat),m(n.lon);try{localStorage.setItem("userLocation",JSON.stringify({latitude:n.lat,longitude:n.lon}))}catch(e){}}return}let a=await r.json(),c=(a.country_code||"").toUpperCase(),s=a.city;if(s&&!t&&u(s),"number"==typeof a.latitude&&"number"==typeof a.longitude&&!t){d(a.latitude),m(a.longitude);try{localStorage.setItem("userLocation",JSON.stringify({latitude:a.latitude,longitude:a.longitude}))}catch(e){}}if(!c)return;let g="NG"===c||"ZA"===c||"GB"===c?c:"NG";t||g===n||(i(g),document.cookie="ikook_market=".concat(g,"; Path=/; Max-Age=").concat(2592e3,"; SameSite=Lax"),document.cookie="".concat(l,"=auto; Path=/; Max-Age=").concat(2592e3,"; SameSite=Lax"))}catch(e){}}return"user"!==("undefined"!=typeof document?null===(e=document.cookie.split("; ").find(e=>e.startsWith("".concat(l,"="))))||void 0===e?void 0:e.split("=")[1]:void 0)&&o(),()=>{t=!0}},[n]);let p=r.useMemo(()=>({market:n,city:c,latitude:s,longitude:g,setMarket:i}),[n,c,s,g]);return(0,o.jsx)(a.Provider,{value:p,children:t})}function c(){let e=r.useContext(a);if(!e)throw Error("useMarket must be used within MarketProvider");return e}},67610:(e,t,n)=>{n.d(t,{n:()=>d});var o=n(99827);let r="ikook_authenticated",l=()=>{localStorage.setItem(r,"true")},a=()=>"true"===localStorage.getItem(r),i=()=>{localStorage.removeItem(r)},c=e=>{{let{access_token:t,refresh_token:n,...o}=e;localStorage.setItem("ikook_user_data",JSON.stringify(o))}},u=()=>{{let e=localStorage.getItem("ikook_user_data");if(e)try{return JSON.parse(e)}catch(e){}}return null},s=()=>{localStorage.removeItem("ikook_user_data")},d=(0,o.v)((e,t)=>({userType:null,user:null,isAuthenticated:!1,isInitialized:!1,hostFormData:null,chefFormData:null,bookingMenu:(()=>{try{let e=localStorage.getItem("ikook_booking_menu");return e?JSON.parse(e):null}catch(e){}return null})(),bookingMenuSelection:(()=>{try{let e=localStorage.getItem("ikook_booking_menu_selection");return e?JSON.parse(e):null}catch(e){}return null})(),bookingSelectedAddons:(()=>{try{let e=localStorage.getItem("ikook_booking_selected_addons");return e?JSON.parse(e):null}catch(e){}return null})(),booking:null,bookingService:null,setBooking:t=>{e({booking:t})},setUserType:t=>{e({userType:t})},setUser:t=>{l(),c(t),e({user:t,isAuthenticated:!0,userType:"Host"===t.user_type?"host":"chef"})},logout:()=>{i(),s(),localStorage.removeItem("ikook_booking_selected_addons"),localStorage.removeItem("ikook_booking_menu"),localStorage.removeItem("ikook_booking_menu_selection"),e({user:null,isAuthenticated:!1,userType:null})},initializeAuth:()=>
1{if(a()){let t=u();t?e({user:t,isAuthenticated:!0,userType:"Host"===t.user_type?"host":"chef",isInitialized:!0}):e({isAuthenticated:!0,isInitialized:!0})}else s(),e({user:null,isAuthenticated:!1,userType:null,isInitialized:!0})},setHostFormData:t=>{e({hostFormData:t})},setChefFormData:t=>{e({chefFormData:t})},clearUserType:()=>{e({userType:null})},clearHostFormData:()=>{e({hostFormData:null})},clearChefFormData:()=>{e({chefFormData:null})},setBookingMenu:t=>{e({bookingMenu:t});try{localStorage.setItem("ikook_booking_menu",JSON.stringify(t))}catch(e){}},setBookingMenuSelection:t=>{e({bookingMenuSelection:t});try{localStorage.setItem("ikook_booking_menu_selection",JSON.stringify(t))}catch(e){}},setBookingSelectedAddons:t=>{e({bookingSelectedAddons:t});try{localStorage.setItem("ikook_booking_selected_addons",JSON.stringify(t))}catch(e){}},setBookingService:t=>{e({bookingService:t})}}))}}]);

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