@digital-realty/ui-service-management 12.6.3 → 12.6.4

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.
@@ -1,4 +1,4 @@
1
- import{__decorate as E}from"tslib";import{css as bt,html as g,LitElement as Rt,nothing as P,svg as Ot}from"lit";import{property as we,customElement as X,state as Ji}from"lit/decorators.js";import G from"moment";import{baseTheme as ua}from"@digital-realty/theme";import he from"moment-timezone";import"date-fns/format.js";import{makeAutoObservable as se}from"mobx";import{makePersistable as Je}from"mobx-persist-store";import{authedUser as ot}from"@digital-realty/ix-account-switcher";import{Router as rt}from"@vaadin/router";import{User as la,UserManager as ma}from"oidc-client-ts";import{MobxLitElement as _e}from"@adobe/lit-mobx";import{ifDefined as pa}from"lit/directives/if-defined.js";import"@digital-realty/ix-select/ix-select.js";import"@digital-realty/ix-select/ix-select-option.js";import"@digital-realty/ix-icon-button/ix-icon-button.js";import{until as fe}from"lit-html/directives/until.js";import{isPossiblePhoneNumber as ha}from"libphonenumber-js";var gi;(function(e){e.CustomerSupport="customer-support",e.FacilityAccess="facility-access",e.RemoteHands="remote-hands",e.DeliveriesAndRemovals="deliveries-removals",e.TroubleTicket="trouble-ticket"})(gi||(gi={}));var y;(function(e){e.CustomerSupport="customer-support",e.FacilityAccess="facility-access",e.VisitorAccess="visitor-access",e.PermanentBadge="permanent-badge",e.OSPAccess="osp-access",e.POPPOEAccess="pop-poe-access",e.RemoteHands="remote-hands",e.Deliveries="deliveries",e.Removals="removals",e.DeliveriesAndRemovals="deliveries-removals",e.TroubleTickets="trouble-tickets"})(y||(y={}));const va="ticketViewType";var wi;(function(e){e.PlannedWork="Planned Work",e.UrgentWork="Urgent Work"})(wi||(wi={}));var H;(function(e){e.TelxSFDC="TelxSFDC",e.Insite="InSite",e.ServiceNow="ServiceNow"})(H||(H={}));const ct="YYYY-MM-DD",ga="HH:mm:ss",$t="HH:mm",wa="YYYY-MM-DD HH:mm";var w;(function(e){e.Default="default",e.Submitting="submitting",e.Submitted="submitted",e.Error="error"})(w||(w={}));var Q;(function(e){e.Deliveries="deliveries-tickets",e.FacilityAccess="osp-access-tickets",e.TroubleTickets="trouble-tickets",e.RemoteHands="remote-hands-tickets"})(Q||(Q={}));const Wi=[{label:"CSV",extensions:["csv"]},{label:"DOC/X",extensions:["doc","docx"]},{label:"GIF",extensions:["gif"]},{label:"JPG (JPEG)",extensions:["jpg","jpeg"]},{label:"PDF",extensions:["pdf"]},{label:"PNG",extensions:["png"]},{label:"XLS/X",extensions:["xls","xlsx"]}],fa=[{label:"JPG (JPEG)",extensions:["image/jpg","image/jpeg"]},{label:"PDF",extensions:["application/pdf"]},{label:"PNG",extensions:["image/png"]},{label:"GIF",extensions:["image/gif"]}],ka=Wi.flatMap(e=>e.extensions),ya=fa.flatMap(e=>e.extensions),Ta=e=>{var t;return Number((t=e.split("cursor=").pop())===null||t===void 0?void 0:t.split("&")[0])},Gi=async(e,t)=>{const i=await t({...e,cursor:"1"});if(!i)return[];const s=[...i.items];if(i.last&&i.self!==i.last){const n=[];let o=1;o=Ta(i.last);for(let a=2;a<=o;a+=1)n.push(t({...e,cursor:a.toString()}));await Promise.all(n).then(a=>{a.forEach(r=>{r&&s.push(...r.items)})})}return s},ba=e=>{var t,i;return e?"name"in e?((t=e.name)===null||t===void 0?void 0:t.trim())||e.id||"":((i=e.comment)===null||i===void 0?void 0:i.trim())||e.id||"":""},Ra="https://api.digitalrealty.com/service-management/v1".replace(/\/+$/,"");class Zi{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Ra}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Ki}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const Aa=new Zi;class ai{constructor(t=Aa){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new Ca(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?ai.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new Sa(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;Ia(r.body)||r.body instanceof URLSearchParams||_a(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}ai.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function _a(e){return typeof Blob<"u"&&e instanceof Blob}function Ia(e){return typeof FormData<"u"&&e instanceof FormData}class Sa extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class Ca extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class ne extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function I(e,t){return e[t]!=null}function Ki(e,t=""){return Object.keys(e).map(i=>Yi(i,e[i],t)).filter(i=>i.length>0).join("&")}function Yi(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return Yi(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Ki(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class Ne{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class Na{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}const Pa="https://api.digitalrealty.com".replace(/\/+$/,"");class Et{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Pa}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Qi}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const qa=new Et;class kt{constructor(t=qa){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new Oa(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?kt.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new Xi(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;Ba(r.body)||r.body instanceof URLSearchParams||Da(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}kt.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function Da(e){return typeof Blob<"u"&&e instanceof Blob}function Ba(e){return typeof FormData<"u"&&e instanceof FormData}class Xi extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class Oa extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class $ extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function h(e,t){return e[t]!=null}function Qi(e,t=""){return Object.keys(e).map(i=>es(i,e[i],t)).filter(i=>i.length>0).join("&")}function es(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return es(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Qi(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class j{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class ts{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}class $a extends kt{async getCourierBySiteRaw(t,i){if(t.accountNumber===null||t.accountNumber===void 0)throw new $("accountNumber","Required parameter requestParameters.accountNumber was null or undefined when calling getCourierBySite.");if(t.site===null||t.site===void 0)throw new $("site","Required parameter requestParameters.site was null or undefined when calling getCourierBySite.");const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/deliveries-removals/courier-companies",method:"GET",headers:n,query:s},i);return new j(o)}async getCourierBySite(t,i){return await(await this.getCourierBySiteRaw(t,i)).value()}}function is(e){if(e!==void 0)return e===null?null:{cancellationReason:e.cancellationReason}}function ss(e){return Ea(e)}function Ea(e,t){return e==null?e:{message:h(e,"message")?e.message:void 0}}function fi(e){return xa(e)}function xa(e,t){return e==null?e:{createdBy:h(e,"created_by")?e.created_by:void 0,createdAt:h(e,"created_at")?new Date(e.created_at):void 0,comment:h(e,"comment")?e.comment:void 0}}function ns(e){return Fa(e)}function Fa(e,t){return e==null?e:{comments:h(e,"comments")?e.comments.map(fi):void 0}}function La(e){return Va(e)}function Va(e,t){return e==null?e:{deliveryBlocked:h(e,"delivery_blocked")?e.delivery_blocked:void 0}}function as(e){return Ua(e)}function Ua(e,t){return e==null?e:{accountNumber:h(e,"account_number")?e.account_number:void 0,accountName:h(e,"account_name")?e.account_name:void 0,id:h(e,"id")?e.id:void 0,status:h(e,"status")?e.status:void 0,site:h(e,"site")?e.site:void 0,subject:h(e,"subject")?e.subject:void 0,createdBy:h(e,"created_by")?e.created_by:void 0,updatedAt:h(e,"updated_at")?new Date(e.updated_at):void 0}}function Ha(e){return za(e)}function za(e,t){return e==null?e:{deliveryTickets:h(e,"delivery_tickets")?e.delivery_tickets.map(as):void 0,totalCount:h(e,"total_count")?e.total_count:void 0,pageNumber:h(e,"page_number")?e.page_number:void 0,pageSize:h(e,"page_size")?e.page_size:void 0}}function ja(e){if(e!==void 0)return e===null?null:{tracking_number:e.trackingNumber,size_when_oversized:e.sizeWhenOversized,weight_when_overweight:e.weightWhenOverweight,courier_company:e.courierCompany}}function Ma(e){if(e!==void 0)return e===null?null:{id:e.id,tracking_number:e.trackingNumber,number_of_packages:e.numberOfPackages,size_when_oversized:e.sizeWhenOversized,weight_when_overweight:e.weightWhenOverweight,courier_company:e.courierCompany}}function Ja(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,subject:e.subject,description:e.description,eta_from:e.etaFrom===null?null:e.etaFrom.toISOString().substring(0,10),eta_to:e.etaTo===null?null:e.etaTo.toISOString(),loading_bay_required:e.loadingBayRequired,remote_hands_required:e.remoteHandsRequired,customer_reference:e.customerReference,site:e.site,other_notification_recipients:e.otherNotificationRecipients,packages:e.packages===void 0?void 0:e.packages.map(Ma)}}function Wa(e){return Ga(e)}function Ga(e,t){return e==null?e:{id:h(e,"id")?e.id:void 0,trackingNumber:h(e,"tracking_number")?e.tracking_number:void 0,numberOfPackages:h(e,"number_of_packages")?e.number_of_packages:void 0,sizeWhenOversized:h(e,"size_when_oversized")?e.size_when_oversized:void 0,weightWhenOverweight:h(e,"weight_when_overweight")?e.weight_when_overweight:void 0,courierCompany:h(e,"courier_company")?e.courier_company:void 0}}function xt(e){return Za(e)}function Za(e,t){return e==null?e:{id:h(e,"id")?e.id:void 0,accountNumber:h(e,"account_number")?e.account_number:void 0,accountName:h(e,"account_name")?e.account_name:void 0,status:h(e,"status")?e.status:void 0,subject:h(e,"subject")?e.subject:void 0,description:h(e,"description")?e.description:void 0,cancellationReason:h(e,"cancellation_reason")?e.cancellation_reason:void 0,etaFrom:h(e,"eta_from")?e.eta_from===null?null:new Date(e.eta_from):void 0,etaTo:h(e,"eta_to")?e.eta_to===null?null:new Date(e.eta_to):void 0,customerReference:h(e,"customer_reference")?e.customer_reference:void 0,site:h(e,"site")?e.site:void 0,otherNotificationRecipients:h(e,"other_notification_recipients")?e.other_notification_recipients:void 0,createdBy:h(e,"created_by")?e.created_by:void 0,createdAt:h(e,"created_at")?new Date(e.created_at):void 0,updatedAt:h(e,"updated_at")?new Date(e.updated_at):void 0,loadingBayRequired:h(e,"loading_bay_required")?e.loading_bay_required:void 0,remoteHandsRequired:h(e,"remote_hands_required")?e.remote_hands_required:void 0,packages:h(e,"packages")?e.packages.map(Wa):void 0,comments:h(e,"comments")?e.comments.map(fi):void 0}}function Ka(e){if(e!==void 0)return e===null?null:{subject:e.subject,description:e.description,eta_from:e.etaFrom===void 0?void 0:e.etaFrom===null?null:e.etaFrom.toISOString(),eta_to:e.etaTo===void 0?void 0:e.etaTo===null?null:e.etaTo.toISOString(),loading_bay_required:e.loadingBayRequired,customer_reference:e.customerReference,other_notification_recipients:e.otherNotificationRecipients}}function Ya(e){return Xa(e)}function Xa(e,t){return e==null?e:{removalTickets:h(e,"removal_tickets")?e.removal_tickets.map(as):void 0,totalCount:h(e,"total_count")?e.total_count:void 0,pageNumber:h(e,"page_number")?e.page_number:void 0,pageSize:h(e,"page_size")?e.page_size:void 0}}function Qa(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,subject:e.subject,description:e.description,customer_reference:e.customerReference,removal_party:e.removalParty,courier_company:e.courierCompany,tracking_number:e.trackingNumber,pickup_date:e.pickupDate.toISOString(),site:e.site,other_notification_recipients:e.otherNotificationRecipients}}function ki(e){return eo(e)}function eo(e,t){return e==null?e:{id:h(e,"id")?e.id:void 0,accountNumber:h(e,"account_number")?e.account_number:void 0,accountName:h(e,"account_name")?e.account_name:void 0,status:h(e,"status")?e.status:void 0,cancellationReason:h(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:h(e,"subject")?e.subject:void 0,description:h(e,"description")?e.description:void 0,customerReference:h(e,"customer_reference")?e.customer_reference:void 0,removalParty:h(e,"removal_party")?e.removal_party:void 0,courierCompany:h(e,"courier_company")?e.courier_company:void 0,trackingNumber:h(e,"tracking_number")?e.tracking_number:void 0,pickupDate:h(e,"pickup_date")?e.pickup_date:void 0,site:h(e,"site")?e.site:void 0,otherNotificationRecipients:h(e,"other_notification_recipients")?e.other_notification_recipients:void 0,createdBy:h(e,"created_by")?e.created_by:void 0,createdAt:h(e,"created_at")?new Date(e.created_at):void 0,updatedAt:h(e,"updated_at")?new Date(e.updated_at):void 0,comments:h(e,"comments")?e.comments.map(fi):void 0}}function to(e){if(e!==void 0)return e===null?null:{subject:e.subject,description:e.description,customer_reference:e.customerReference,courier_company:e.courierCompany,tracking_number:e.trackingNumber,pickup_date:e.pickupDate===void 0?void 0:e.pickupDate===null?null:e.pickupDate.toISOString(),other_notification_recipients:e.otherNotificationRecipients}}function yi(e){return io(e)}function io(e,t){return e==null?e:{id:h(e,"id")?e.id:void 0,fileName:h(e,"file_name")?e.file_name:void 0,fileSize:h(e,"file_size")?e.file_size:void 0,contentType:h(e,"content_type")?e.content_type:void 0,createdBy:h(e,"created_by")?e.created_by:void 0,createdAt:h(e,"created_at")?new Date(e.created_at):void 0}}function os(e){return so(e)}function so(e,t){return e==null?e:{attachments:h(e,"attachments")?e.attachments.map(yi):void 0}}function rs(e){if(e!==void 0)return e===null?null:{comment:e.comment}}class no extends kt{async cancellationDeliveryRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationDeliveryRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new $("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationDeliveryRequest.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:is(t.cancellationTicketsRequest)},i);return new j(o,a=>ss(a))}async cancellationDeliveryRequest(t,i){return await(await this.cancellationDeliveryRequestRaw(t,i)).value()}async createAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createAttachment.");if(t.fileName===null||t.fileName===void 0)throw new $("fileName","Required parameter requestParameters.fileName was null or undefined when calling createAttachment.");if(t.body===null||t.body===void 0)throw new $("body","Required parameter requestParameters.body was null or undefined when calling createAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new j(o,a=>yi(a))}async createAttachment(t,i){return await(await this.createAttachmentRaw(t,i)).value()}async createDeliveriesCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createDeliveriesComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new $("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createDeliveriesComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:rs(t.ticketCommentsRequest)},i);return new j(o,a=>ns(a))}async createDeliveriesComment(t,i){return await(await this.createDeliveriesCommentRaw(t,i)).value()}async createDeliveryRaw(t,i){if(t.deliveryTicketsRequest===null||t.deliveryTicketsRequest===void 0)throw new $("deliveryTicketsRequest","Required parameter requestParameters.deliveryTicketsRequest was null or undefined when calling createDelivery.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets",method:"POST",headers:n,query:s,body:Ja(t.deliveryTicketsRequest)},i);return new j(o,a=>xt(a))}async createDelivery(t,i){return await(await this.createDeliveryRaw(t,i)).value()}async getDeliveriesRaw(t,i){if(t.accountNumber===null||t.accountNumber===void 0)throw new $("accountNumber","Required parameter requestParameters.accountNumber was null or undefined when calling getDeliveries.");const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets",method:"GET",headers:n,query:s},i);return new j(o,a=>Ha(a))}async getDeliveries(t,i){return await(await this.getDeliveriesRaw(t,i)).value()}async getDeliveryAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getDeliveryAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new $("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getDeliveryAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new ts(o)}async getDeliveryAttachmentsById(t,i){return await(await this.getDeliveryAttachmentsByIdRaw(t,i)).value()}async getDeliveryAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getDeliveryAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new j(o,a=>os(a))}async getDeliveryAttachmentsList(t,i){return await(await this.getDeliveryAttachmentsListRaw(t,i)).value()}async getDeliveryByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getDeliveryById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new j(o,a=>xt(a))}async getDeliveryById(t,i){return await(await this.getDeliveryByIdRaw(t,i)).value()}async getDeliveryDiscoveryRaw(t,i){if(t.accountNumber===null||t.accountNumber===void 0)throw new $("accountNumber","Required parameter requestParameters.accountNumber was null or undefined when calling getDeliveryDiscovery.");if(t.site===null||t.site===void 0)throw new $("site","Required parameter requestParameters.site was null or undefined when calling getDeliveryDiscovery.");const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-discovery",method:"GET",headers:n,query:s},i);return new j(o,a=>La(a))}async getDeliveryDiscovery(t,i){return await(await this.getDeliveryDiscoveryRaw(t,i)).value()}async updateDeliveriesTicketsRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateDeliveriesTickets.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:Ka(t.deliveryTicketsUpdateRequest)},i);return new j(o,a=>xt(a))}async updateDeliveriesTickets(t,i){return await(await this.updateDeliveriesTicketsRaw(t,i)).value()}async updateDeliveriesTicketsPackagesRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateDeliveriesTicketsPackages.");if(t.packageId===null||t.packageId===void 0)throw new $("packageId","Required parameter requestParameters.packageId was null or undefined when calling updateDeliveriesTicketsPackages.");if(t.deliveryTicketUpdatePackagesRequest===null||t.deliveryTicketUpdatePackagesRequest===void 0)throw new $("deliveryTicketUpdatePackagesRequest","Required parameter requestParameters.deliveryTicketUpdatePackagesRequest was null or undefined when calling updateDeliveriesTicketsPackages.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}/packages/{package_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{package_id}",encodeURIComponent(String(t.packageId))),method:"PATCH",headers:n,query:s,body:ja(t.deliveryTicketUpdatePackagesRequest)},i);return new j(o,a=>xt(a))}async updateDeliveriesTicketsPackages(t,i){return await(await this.updateDeliveriesTicketsPackagesRaw(t,i)).value()}}class ao extends kt{async cancellationRemovalRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationRemovalRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new $("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationRemovalRequest.");const s={},n={};n["Content-Type"]="application/json";const o=await this.request({path:"/removals-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:is(t.cancellationTicketsRequest)},i);return new j(o,a=>ss(a))}async cancellationRemovalRequest(t,i){return await(await this.cancellationRemovalRequestRaw(t,i)).value()}async createCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new $("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:rs(t.ticketCommentsRequest)},i);return new j(o,a=>ns(a))}async createComment(t,i){return await(await this.createCommentRaw(t,i)).value()}async createRemovalRaw(t,i){if(t.removalTicketsRequest===null||t.removalTicketsRequest===void 0)throw new $("removalTicketsRequest","Required parameter requestParameters.removalTicketsRequest was null or undefined when calling createRemoval.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets",method:"POST",headers:n,query:s,body:Qa(t.removalTicketsRequest)},i);return new j(o,a=>ki(a))}async createRemoval(t,i){return await(await this.createRemovalRaw(t,i)).value()}async createRemovalsAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createRemovalsAttachment.");if(t.fileName===null||t.fileName===void 0)throw new $("fileName","Required parameter requestParameters.fileName was null or undefined when calling createRemovalsAttachment.");if(t.body===null||t.body===void 0)throw new $("body","Required parameter requestParameters.body was null or undefined when calling createRemovalsAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new j(o,a=>yi(a))}async createRemovalsAttachment(t,i){return await(await this.createRemovalsAttachmentRaw(t,i)).value()}async getRemovalByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getRemovalById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new j(o,a=>ki(a))}async getRemovalById(t,i){return await(await this.getRemovalByIdRaw(t,i)).value()}async getRemovalPartiesRaw(t){const i={},s={};if(this.configuration&&this.configuration.accessToken){const o=this.configuration.accessToken,a=await o("BearerAuth",[]);a&&(s.Authorization=`Bearer ${a}`)}const n=await this.request({path:"/removal-parties",method:"GET",headers:s,query:i},t);return new j(n)}async getRemovalParties(t){return await(await this.getRemovalPartiesRaw(t)).value()}async getRemovalsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets",method:"GET",headers:n,query:s},i);return new j(o,a=>Ya(a))}async getRemovals(t={},i){return await(await this.getRemovalsRaw(t,i)).value()}async getRemovalsAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getRemovalsAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new $("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getRemovalsAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new ts(o)}async getRemovalsAttachmentsById(t,i){return await(await this.getRemovalsAttachmentsByIdRaw(t,i)).value()}async getRemovalsAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getRemovalsAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new j(o,a=>os(a))}async getRemovalsAttachmentsList(t,i){return await(await this.getRemovalsAttachmentsListRaw(t,i)).value()}async updateRemovalByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateRemovalById.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:to(t.removalsTicketsUpdateRequest)},i);return new j(o,a=>ki(a))}async updateRemovalById(t,i){return await(await this.updateRemovalByIdRaw(t,i)).value()}}const oo="https://api.digitalrealty.com/service-management/v1/facility-access".replace(/\/+$/,"");class pt{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:oo}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||cs}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const ro=new pt;class Xe{constructor(t=ro){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new mo(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?Xe.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new lo(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;uo(r.body)||r.body instanceof URLSearchParams||co(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}Xe.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function co(e){return typeof Blob<"u"&&e instanceof Blob}function uo(e){return typeof FormData<"u"&&e instanceof FormData}class lo extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class mo extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class v extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function c(e,t){return e[t]!=null}function cs(e,t=""){return Object.keys(e).map(i=>ds(i,e[i],t)).filter(i=>i.length>0).join("&")}function ds(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return ds(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?cs(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class q{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class Ft{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}function po(e){return ho(e)}function ho(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,accountNumber:c(e,"account_number")?e.account_number:void 0,firstName:c(e,"first_name")?e.first_name:void 0,lastName:c(e,"last_name")?e.last_name:void 0,email:c(e,"email")?e.email:void 0,phone:c(e,"phone")?e.phone:void 0,representingCompany:c(e,"representing_company")?e.representing_company:void 0,badgeStartDate:c(e,"badge_start_date")?new Date(e.badge_start_date):void 0,activeBadge:c(e,"active_badge")?e.active_badge:void 0,terminationRequested:c(e,"termination_requested")?e.termination_requested:void 0}}function vo(e){return go(e)}function go(e,t){return e==null?e:{items:c(e,"items")?e.items.map(po):void 0,totalCount:c(e,"total_count")?e.total_count:void 0}}function Lt(e){if(e!==void 0)return e===null?null:{cancellationReason:e.cancellationReason}}function Vt(e){return wo(e)}function wo(e,t){return e==null?e:{message:c(e,"message")?e.message:void 0}}function At(e){return fo(e)}function fo(e,t){return e==null?e:{createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,comment:c(e,"comment")?e.comment:void 0}}function Ut(e){return ko(e)}function ko(e,t){return e==null?e:{comments:c(e,"comments")?e.comments.map(At):void 0}}const us={Approved:"Approved",Denied:"Denied"};function Ht(e){if(e!==void 0)return e===null?null:{id:e.id,approval_status:e.approvalStatus}}function yo(e){return To(e)}function To(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,approvalStatus:c(e,"approval_status")?e.approval_status:void 0}}function zt(e){return bo(e)}function bo(e,t){return e==null?e:{items:c(e,"items")?e.items.map(yo):void 0}}function Ro(e){if(e!==void 0)return e===null?null:{id:e.id,start_date_time:e.startDateTime===void 0?void 0:e.startDateTime.toISOString(),end_date_time:e.endDateTime===void 0?void 0:e.endDateTime.toISOString()}}function Ao(e){if(e!==void 0)return e===null?null:{first_name:e.firstName,last_name:e.lastName,email:e.email,company:e.company,phone:e.phone,visitor_type:e.visitorType}}function _o(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,visitors:e.visitors.map(Ao),locations:e.locations.map(Ro),escort_first_name:e.escortFirstName,escort_last_name:e.escortLastName,visitor_host_first_name:e.visitorHostFirstName,visitor_host_last_name:e.visitorHostLastName,customer_external_reference:e.customerExternalReference,service_impacted_description:e.serviceImpactedDescription,work_description:e.workDescription,notification_recipients:e.notificationRecipients}}function Io(e){return So(e)}function So(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,startDateTime:c(e,"start_date_time")?e.start_date_time:void 0,endDateTime:c(e,"end_date_time")?e.end_date_time:void 0}}function ls(e){return Co(e)}function Co(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,cancellationReason:c(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:c(e,"subject")?e.subject:void 0,visitorFirstName:c(e,"visitor_first_name")?e.visitor_first_name:void 0,visitorLastName:c(e,"visitor_last_name")?e.visitor_last_name:void 0,visitorEmail:c(e,"visitor_email")?e.visitor_email:void 0,visitorCompany:c(e,"visitor_company")?e.visitor_company:void 0,visitorPhone:c(e,"visitor_phone")?e.visitor_phone:void 0,visitorType:c(e,"visitor_type")?e.visitor_type:void 0,site:c(e,"site")?e.site:void 0,locations:c(e,"locations")?e.locations.map(Io):void 0,escortFirstName:c(e,"escort_first_name")?e.escort_first_name:void 0,escortLastName:c(e,"escort_last_name")?e.escort_last_name:void 0,visitorHostFirstName:c(e,"visitor_host_first_name")?e.visitor_host_first_name:void 0,visitorHostLastName:c(e,"visitor_host_last_name")?e.visitor_host_last_name:void 0,customerExternalReference:c(e,"customer_external_reference")?e.customer_external_reference:void 0,serviceImpactedDescription:c(e,"service_impacted_description")?e.service_impacted_description:void 0,workDescription:c(e,"work_description")?e.work_description:void 0,notificationRecipients:c(e,"notification_recipients")?e.notification_recipients:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?e.created_at:void 0,updatedAt:c(e,"updated_at")?e.updated_at:void 0,closedAt:c(e,"closed_at")?e.closed_at:void 0,comments:c(e,"comments")?e.comments.map(At):void 0}}function No(e){if(e!==void 0)return e===null?null:{id:e.id,start_date_time:e.startDateTime===void 0?void 0:e.startDateTime.toISOString(),end_date_time:e.endDateTime===void 0?void 0:e.endDateTime.toISOString()}}function Po(e){if(e!==void 0)return e===null?null:{visitor_phone:e.visitorPhone,visitor_company:e.visitorCompany,escort_first_name:e.escortFirstName,escort_last_name:e.escortLastName,locations:e.locations===void 0?void 0:e.locations.map(No),visitor_host_first_name:e.visitorHostFirstName,visitor_host_last_name:e.visitorHostLastName,customer_external_reference:e.customerExternalReference,service_impacted_description:e.serviceImpactedDescription,work_description:e.workDescription,other_notification_recipients:e.otherNotificationRecipients}}function qo(e){return Do(e)}function Do(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,startDateTime:c(e,"start_date_time")?new Date(e.start_date_time):void 0,endDateTime:c(e,"end_date_time")?new Date(e.end_date_time):void 0}}function Bo(e){return Oo(e)}function Oo(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,subject:c(e,"subject")?e.subject:void 0,site:c(e,"site")?e.site:void 0,locations:c(e,"locations")?e.locations.map(qo):void 0,description:c(e,"description")?e.description:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,updatedAt:c(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:c(e,"closed_at")?new Date(e.closed_at):void 0}}function $o(e){return Eo(e)}function Eo(e,t){return e==null?e:{items:c(e,"items")?e.items.map(Bo):void 0,totalCount:c(e,"total_count")?e.total_count:void 0,pageNumber:c(e,"page_number")?e.page_number:void 0,pageSize:c(e,"page_size")?e.page_size:void 0}}function xo(e){if(e!==void 0)return e===null?null:{id:e.id,start_date_time:e.startDateTime.toISOString(),end_date_time:e.endDateTime.toISOString()}}function Fo(e){if(e!==void 0)return e===null?null:{ppop_space_from:e.ppopSpaceFrom,ppop_space_to:e.ppopSpaceTo,cable_type:e.cableType,on_ladder_rack:e.onLadderRack,in_inner_duct:e.inInnerDuct,in_fiber_guide:e.inFiberGuide}}function ms(e){return Lo(e)}function Lo(e,t){return e==null?e:{rack:c(e,"rack")?e.rack:void 0,cabinet:c(e,"cabinet")?e.cabinet:void 0}}function ps(e){if(e!==void 0)return e===null?null:{rack:e.rack,cabinet:e.cabinet}}function Vo(e){if(e!==void 0)return e===null?null:{side_a_name:e.sideAName,side_a_room_number:e.sideARoomNumber,side_a_rack_number:e.sideARackNumber,side_a_panel_number:e.sideAPanelNumber,side_a_port_1:e.sideAPort1,side_a_carrier_circuit_id:e.sideACarrierCircuitId,side_b_name:e.sideBName,side_b_room_number:e.sideBRoomNumber,side_b_rack_number:e.sideBRackNumber,side_b_panel_number:e.sideBPanelNumber,side_b_port_1:e.sideBPort1,side_b_carrier_circuit_id:e.sideBCarrierCircuitId}}function Uo(e){if(e!==void 0)return e===null?null:{service_type:e.serviceType,scope:e.scope,circuits:e.circuits===void 0?void 0:e.circuits.map(Vo),work_description:e.workDescription}}function Ho(e){if(e!==void 0)return e===null?null:{spop_space_from:e.spopSpaceFrom,spop_space_to:e.spopSpaceTo,cable_type:e.cableType,on_ladder_rack:e.onLadderRack,in_inner_duct:e.inInnerDuct,in_fiber_guide:e.inFiberGuide}}function zo(e){if(e!==void 0)return e===null?null:{first_name:e.firstName,last_name:e.lastName,email:e.email,company:e.company,phone:e.phone,visitor_type:e.visitorType}}function jo(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,visitors:e.visitors.map(zo),locations:e.locations.map(xo),escort_first_name:e.escortFirstName,escort_last_name:e.escortLastName,visitor_host_first_name:e.visitorHostFirstName,visitor_host_last_name:e.visitorHostLastName,customer_external_reference:e.customerExternalReference,service_impacted_description:e.serviceImpactedDescription,service_details:Uo(e.serviceDetails),ppop_space:e.ppopSpace===void 0?void 0:e.ppopSpace.map(ps),spop_space:e.spopSpace===void 0?void 0:e.spopSpace.map(ps),ppop_room_work:Fo(e.ppopRoomWork),spop_room_work:Ho(e.spopRoomWork),notification_recipients:e.notificationRecipients}}function Mo(e){return Jo(e)}function Jo(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,startDateTime:c(e,"start_date_time")?e.start_date_time:void 0,endDateTime:c(e,"end_date_time")?e.end_date_time:void 0,approvalStatus:c(e,"approval_status")?e.approval_status:void 0,modifiedBy:c(e,"modified_by")?e.modified_by:void 0}}function Wo(e){return Go(e)}function Go(e,t){return e==null?e:{ppopSpaceFrom:c(e,"ppop_space_from")?e.ppop_space_from:void 0,ppopSpaceTo:c(e,"ppop_space_to")?e.ppop_space_to:void 0,cableType:c(e,"cable_type")?e.cable_type:void 0,onLadderRack:c(e,"on_ladder_rack")?e.on_ladder_rack:void 0,inInnerDuct:c(e,"in_inner_duct")?e.in_inner_duct:void 0,inFiberGuide:c(e,"in_fiber_guide")?e.in_fiber_guide:void 0}}function Zo(e){return Ko(e)}function Ko(e,t){return e==null?e:{sideAName:c(e,"side_a_name")?e.side_a_name:void 0,sideARoomNumber:c(e,"side_a_room_number")?e.side_a_room_number:void 0,sideARackNumber:c(e,"side_a_rack_number")?e.side_a_rack_number:void 0,sideAPanelNumber:c(e,"side_a_panel_number")?e.side_a_panel_number:void 0,sideAPort1:c(e,"side_a_port_1")?e.side_a_port_1:void 0,sideACarrierCircuitId:c(e,"side_a_carrier_circuit_id")?e.side_a_carrier_circuit_id:void 0,sideBName:c(e,"side_b_name")?e.side_b_name:void 0,sideBRoomNumber:c(e,"side_b_room_number")?e.side_b_room_number:void 0,sideBRackNumber:c(e,"side_b_rack_number")?e.side_b_rack_number:void 0,sideBPanelNumber:c(e,"side_b_panel_number")?e.side_b_panel_number:void 0,sideBPort1:c(e,"side_b_port_1")?e.side_b_port_1:void 0,sideBCarrierCircuitId:c(e,"side_b_carrier_circuit_id")?e.side_b_carrier_circuit_id:void 0}}const We={SiteSurvey:"Site Survey",Testing:"Testing",InstallationDeInstallationWork:"Installation/De-installation Work"};function Yo(e){return Xo(e)}function Xo(e,t){return e==null?e:{serviceType:c(e,"service_type")?e.service_type:void 0,scope:c(e,"scope")?e.scope:void 0,circuits:c(e,"circuits")?e.circuits.map(Zo):void 0,workDescription:c(e,"work_description")?e.work_description:void 0}}function Qo(e){return er(e)}function er(e,t){return e==null?e:{spopSpaceFrom:c(e,"spop_space_from")?e.spop_space_from:void 0,spopSpaceTo:c(e,"spop_space_to")?e.spop_space_to:void 0,cableType:c(e,"cable_type")?e.cable_type:void 0,onLadderRack:c(e,"on_ladder_rack")?e.on_ladder_rack:void 0,inInnerDuct:c(e,"in_inner_duct")?e.in_inner_duct:void 0,inFiberGuide:c(e,"in_fiber_guide")?e.in_fiber_guide:void 0}}function hs(e){return tr(e)}function tr(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,cancellationReason:c(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:c(e,"subject")?e.subject:void 0,visitorFirstName:c(e,"visitor_first_name")?e.visitor_first_name:void 0,visitorLastName:c(e,"visitor_last_name")?e.visitor_last_name:void 0,visitorEmail:c(e,"visitor_email")?e.visitor_email:void 0,visitorCompany:c(e,"visitor_company")?e.visitor_company:void 0,visitorPhone:c(e,"visitor_phone")?e.visitor_phone:void 0,visitorType:c(e,"visitor_type")?e.visitor_type:void 0,site:c(e,"site")?e.site:void 0,locations:c(e,"locations")?e.locations.map(Mo):void 0,escortFirstName:c(e,"escort_first_name")?e.escort_first_name:void 0,escortLastName:c(e,"escort_last_name")?e.escort_last_name:void 0,visitorHostFirstName:c(e,"visitor_host_first_name")?e.visitor_host_first_name:void 0,visitorHostLastName:c(e,"visitor_host_last_name")?e.visitor_host_last_name:void 0,visitorHostCompany:c(e,"visitor_host_company")?e.visitor_host_company:void 0,customerExternalReference:c(e,"customer_external_reference")?e.customer_external_reference:void 0,serviceImpactedDescription:c(e,"service_impacted_description")?e.service_impacted_description:void 0,serviceDetails:c(e,"service_details")?Yo(e.service_details):void 0,ppopSpace:c(e,"ppop_space")?e.ppop_space.map(ms):void 0,spopSpace:c(e,"spop_space")?e.spop_space.map(ms):void 0,ppopRoomWork:c(e,"ppop_room_work")?Wo(e.ppop_room_work):void 0,spopRoomWork:c(e,"spop_room_work")?Qo(e.spop_room_work):void 0,notificationRecipients:c(e,"notification_recipients")?e.notification_recipients:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?e.created_at:void 0,updatedAt:c(e,"updated_at")?e.updated_at:void 0,closedAt:c(e,"closed_at")?e.closed_at:void 0,comments:c(e,"comments")?e.comments.map(At):void 0}}function ir(e){if(e!==void 0)return e===null?null:{id:e.id,start_date_time:e.startDateTime.toISOString(),end_date_time:e.endDateTime.toISOString()}}function sr(e){if(e!==void 0)return e===null?null:{ppop_space_from:e.ppopSpaceFrom,ppop_space_to:e.ppopSpaceTo,cable_type:e.cableType,on_ladder_rack:e.onLadderRack,in_inner_duct:e.inInnerDuct,in_fiber_guide:e.inFiberGuide}}function vs(e){if(e!==void 0)return e===null?null:{id:e.id,rack:e.rack,cabinet:e.cabinet}}function nr(e){if(e!==void 0)return e===null?null:{id:e.id,side_a_name:e.sideAName,side_a_room_number:e.sideARoomNumber,side_a_rack_number:e.sideARackNumber,side_a_panel_number:e.sideAPanelNumber,side_a_port_1:e.sideAPort1,side_a_carrier_circuit_id:e.sideACarrierCircuitId,side_b_name:e.sideBName,side_b_room_number:e.sideBRoomNumber,side_b_rack_number:e.sideBRackNumber,side_b_panel_number:e.sideBPanelNumber,side_b_port_1:e.sideBPort1,side_b_carrier_circuit_id:e.sideBCarrierCircuitId}}function ar(e){if(e!==void 0)return e===null?null:{service_type:e.serviceType,scope:e.scope,circuits:e.circuits===void 0?void 0:e.circuits.map(nr),work_description:e.workDescription}}function or(e){if(e!==void 0)return e===null?null:{spop_space_from:e.spopSpaceFrom,spop_space_to:e.spopSpaceTo,cable_type:e.cableType,on_ladder_rack:e.onLadderRack,in_inner_duct:e.inInnerDuct,in_fiber_guide:e.inFiberGuide}}function rr(e){if(e!==void 0)return e===null?null:{visitor_phone:e.visitorPhone,escort_first_name:e.escortFirstName,escort_last_name:e.escortLastName,visitor_host_first_name:e.visitorHostFirstName,visitor_host_last_name:e.visitorHostLastName,visitor_company:e.visitorCompany,service_impacted_description:e.serviceImpactedDescription,locations:e.locations===void 0?void 0:e.locations.map(ir),service_details:ar(e.serviceDetails),ppop_space:e.ppopSpace===void 0?void 0:e.ppopSpace.map(vs),spop_space:e.spopSpace===void 0?void 0:e.spopSpace.map(vs),ppop_room_work:sr(e.ppopRoomWork),spop_room_work:or(e.spopRoomWork),customer_external_reference:e.customerExternalReference,notification_recipients:e.notificationRecipients}}function cr(e){return dr(e)}function dr(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,startDateTime:c(e,"start_date_time")?new Date(e.start_date_time):void 0,endDateTime:c(e,"end_date_time")?new Date(e.end_date_time):void 0,approvalStatus:c(e,"approval_status")?e.approval_status:void 0,modifiedBy:c(e,"modified_by")?e.modified_by:void 0}}function ur(e){return lr(e)}function lr(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,subject:c(e,"subject")?e.subject:void 0,site:c(e,"site")?e.site:void 0,locations:c(e,"locations")?e.locations.map(cr):void 0,description:c(e,"description")?e.description:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,updatedAt:c(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:c(e,"closed_at")?new Date(e.closed_at):void 0}}function mr(e){return pr(e)}function pr(e,t){return e==null?e:{items:c(e,"items")?e.items.map(ur):void 0,totalCount:c(e,"total_count")?e.total_count:void 0,pageNumber:c(e,"page_number")?e.page_number:void 0,pageSize:c(e,"page_size")?e.page_size:void 0}}function hr(e){if(e!==void 0)return e===null?null:{id:e.id,start_date:e.startDate===void 0?void 0:e.startDate.toISOString().substring(0,10),end_date:e.endDate===void 0?void 0:e.endDate.toISOString().substring(0,10),operation:e.operation}}function vr(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,badgeholder_id:e.badgeholderId,badge_start_date:e.badgeStartDate.toISOString().substring(0,10),badge_end_date:e.badgeEndDate===void 0?void 0:e.badgeEndDate.toISOString().substring(0,10),locations:e.locations===void 0?void 0:e.locations.map(hr),notification_recipients:e.notificationRecipients}}function gr(e){if(e!==void 0)return e===null?null:{id:e.id,start_date:e.startDate===void 0?void 0:e.startDate.toISOString().substring(0,10),end_date:e.endDate===void 0?void 0:e.endDate.toISOString().substring(0,10)}}function wr(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,badgeholder_first_name:e.badgeholderFirstName,badgeholder_last_name:e.badgeholderLastName,badgeholder_email:e.badgeholderEmail,badgeholder_company:e.badgeholderCompany,badgeholder_phone:e.badgeholderPhone,badge_start_date:e.badgeStartDate.toISOString().substring(0,10),badge_end_date:e.badgeEndDate===void 0?void 0:e.badgeEndDate.toISOString().substring(0,10),locations:e.locations===void 0?void 0:e.locations.map(gr),notification_recipients:e.notificationRecipients}}function fr(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,badgeholder_id:e.badgeholderId,badge_end_date:e.badgeEndDate.toISOString().substring(0,10),notification_recipients:e.notificationRecipients}}function gs(e){return kr(e)}function kr(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,site:c(e,"site")?e.site:void 0,siteAddress:c(e,"site_address")?e.site_address:void 0,startDate:c(e,"start_date")?e.start_date:void 0,endDate:c(e,"end_date")?e.end_date:void 0,approvalStatus:c(e,"approval_status")?e.approval_status:void 0,modifiedBy:c(e,"modified_by")?e.modified_by:void 0}}function ws(e){return yr(e)}function yr(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,cancellationReason:c(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:c(e,"subject")?e.subject:void 0,badgeholderFirstName:c(e,"badgeholder_first_name")?e.badgeholder_first_name:void 0,badgeholderLastName:c(e,"badgeholder_last_name")?e.badgeholder_last_name:void 0,badgeholderEmail:c(e,"badgeholder_email")?e.badgeholder_email:void 0,badgeholderPhone:c(e,"badgeholder_phone")?e.badgeholder_phone:void 0,badgeholderCompany:c(e,"badgeholder_company")?e.badgeholder_company:void 0,requestType:c(e,"request_type")?e.request_type:void 0,badgeStartDate:c(e,"badge_start_date")?e.badge_start_date:void 0,badgeEndDate:c(e,"badge_end_date")?e.badge_end_date:void 0,locations:c(e,"locations")?e.locations.map(gs):void 0,notificationRecipients:c(e,"notification_recipients")?e.notification_recipients:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,updatedAt:c(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:c(e,"closed_at")?new Date(e.closed_at):void 0,comments:c(e,"comments")?e.comments.map(At):void 0}}function Tr(e){if(e!==void 0)return e===null?null:{other_notification_recipients:e.otherNotificationRecipients}}function br(e){return Rr(e)}function Rr(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,subject:c(e,"subject")?e.subject:void 0,badgeholderEmail:c(e,"badgeholder_email")?e.badgeholder_email:void 0,requestType:c(e,"request_type")?e.request_type:void 0,locations:c(e,"locations")?e.locations.map(gs):void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,updatedAt:c(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:c(e,"closed_at")?new Date(e.closed_at):void 0}}function Ar(e){return _r(e)}function _r(e,t){return e==null?e:{items:c(e,"items")?e.items.map(br):void 0,totalCount:c(e,"total_count")?e.total_count:void 0,pageNumber:c(e,"page_number")?e.page_number:void 0,pageSize:c(e,"page_size")?e.page_size:void 0}}function _t(e){return Ir(e)}function Ir(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,fileName:c(e,"file_name")?e.file_name:void 0,fileSize:c(e,"file_size")?e.file_size:void 0,contentType:c(e,"content_type")?e.content_type:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?e.created_at===null?null:new Date(e.created_at):void 0}}function jt(e){return Sr(e)}function Sr(e,t){return e==null?e:{attachments:c(e,"attachments")?e.attachments.map(_t):void 0}}function Mt(e){if(e!==void 0)return e===null?null:{comment:e.comment}}function ht(e){return Cr(e)}function Cr(e,t){return e==null?e:{ticketNumbers:c(e,"ticket_numbers")?e.ticket_numbers:void 0}}function Nr(e){if(e!==void 0)return e===null?null:{id:e.id,start_date:e.startDate===void 0?void 0:e.startDate.toISOString().substring(0,10),end_date:e.endDate===void 0?void 0:e.endDate.toISOString().substring(0,10)}}function Pr(e){if(e!==void 0)return e===null?null:{site_code:e.siteCode,visitor_host_id:e.visitorHostId,locations:e.locations===void 0?void 0:e.locations.map(Nr)}}function qr(e){if(e!==void 0)return e===null?null:{first_name:e.firstName,last_name:e.lastName,email:e.email,phone:e.phone}}const Jt={Escorted:"Escorted",Standard:"Standard",Extended:"Extended"};function Dr(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,visitors:e.visitors===void 0?void 0:e.visitors.map(qr),visit_start_date:e.visitStartDate.toISOString().substring(0,10),visit_end_date:e.visitEndDate.toISOString().substring(0,10),visit_type:e.visitType,sites:e.sites===void 0?void 0:e.sites.map(Pr),escort_first_name:e.escortFirstName,escort_last_name:e.escortLastName,visitor_host_first_name:e.visitorHostFirstName,visitor_host_last_name:e.visitorHostLastName,representing_company:e.representingCompany,description:e.description,notification_recipients:e.notificationRecipients}}function fs(e){return Br(e)}function Br(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,startDate:c(e,"start_date")?e.start_date:void 0,endDate:c(e,"end_date")?e.end_date:void 0,approvalStatus:c(e,"approval_status")?e.approval_status:void 0,modifiedBy:c(e,"modified_by")?e.modified_by:void 0}}function ks(e){return Or(e)}function Or(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,cancellationReason:c(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:c(e,"subject")?e.subject:void 0,visitorFirstName:c(e,"visitor_first_name")?e.visitor_first_name:void 0,visitorLastName:c(e,"visitor_last_name")?e.visitor_last_name:void 0,visitorEmail:c(e,"visitor_email")?e.visitor_email:void 0,visitorPhone:c(e,"visitor_phone")?e.visitor_phone:void 0,visitStartDate:c(e,"visit_start_date")?e.visit_start_date:void 0,visitEndDate:c(e,"visit_end_date")?e.visit_end_date:void 0,visitType:c(e,"visit_type")?e.visit_type:void 0,site:c(e,"site")?e.site:void 0,locations:c(e,"locations")?e.locations.map(fs):void 0,escortFirstName:c(e,"escort_first_name")?e.escort_first_name:void 0,escortLastName:c(e,"escort_last_name")?e.escort_last_name:void 0,visitorHostFirstName:c(e,"visitor_host_first_name")?e.visitor_host_first_name:void 0,visitorHostLastName:c(e,"visitor_host_last_name")?e.visitor_host_last_name:void 0,representingCompany:c(e,"representing_company")?e.representing_company:void 0,description:c(e,"description")?e.description:void 0,notificationRecipients:c(e,"notification_recipients")?e.notification_recipients:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,updatedAt:c(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:c(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0,comments:c(e,"comments")?e.comments.map(At):void 0}}function $r(e){if(e!==void 0)return e===null?null:{visitor_phone:e.visitorPhone,other_notification_recipients:e.otherNotificationRecipients}}function Er(e){return xr(e)}function xr(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,subject:c(e,"subject")?e.subject:void 0,site:c(e,"site")?e.site:void 0,locations:c(e,"locations")?e.locations.map(fs):void 0,visitType:c(e,"visit_type")?e.visit_type:void 0,description:c(e,"description")?e.description:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,updatedAt:c(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:c(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function Fr(e){return Lr(e)}function Lr(e,t){return e==null?e:{items:c(e,"items")?e.items.map(Er):void 0,totalCount:c(e,"total_count")?e.total_count:void 0,pageNumber:c(e,"page_number")?e.page_number:void 0,pageSize:c(e,"page_size")?e.page_size:void 0}}function Vr(e){return Ur(e)}function Ur(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,firstName:c(e,"first_name")?e.first_name:void 0,lastName:c(e,"last_name")?e.last_name:void 0}}function Hr(e){return zr(e)}function zr(e,t){return e==null?e:{items:c(e,"items")?e.items.map(Vr):void 0,totalCount:c(e,"total_count")?e.total_count:void 0}}class jr extends Xe{async cancellationOspAccessRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationOspAccessRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new v("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationOspAccessRequest.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:Lt(t.cancellationTicketsRequest)},i);return new q(o,a=>Vt(a))}async cancellationOspAccessRequest(t,i){return await(await this.cancellationOspAccessRequestRaw(t,i)).value()}async createOspAccessAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createOspAccessAttachment.");if(t.fileName===null||t.fileName===void 0)throw new v("fileName","Required parameter requestParameters.fileName was null or undefined when calling createOspAccessAttachment.");if(t.body===null||t.body===void 0)throw new v("body","Required parameter requestParameters.body was null or undefined when calling createOspAccessAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new q(o,a=>_t(a))}async createOspAccessAttachment(t,i){return await(await this.createOspAccessAttachmentRaw(t,i)).value()}async createOspAccessCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createOspAccessComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new v("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createOspAccessComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:Mt(t.ticketCommentsRequest)},i);return new q(o,a=>Ut(a))}async createOspAccessComment(t,i){return await(await this.createOspAccessCommentRaw(t,i)).value()}async createOspAccessTicketRaw(t,i){if(t.oSPAccessTicketRequest===null||t.oSPAccessTicketRequest===void 0)throw new v("oSPAccessTicketRequest","Required parameter requestParameters.oSPAccessTicketRequest was null or undefined when calling createOspAccessTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets",method:"POST",headers:n,query:s,body:_o(t.oSPAccessTicketRequest)},i);return new q(o,a=>ht(a))}async createOspAccessTicket(t,i){return await(await this.createOspAccessTicketRaw(t,i)).value()}async getOspAccessAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getOspAccessAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new v("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getOspAccessAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new Ft(o)}async getOspAccessAttachmentsById(t,i){return await(await this.getOspAccessAttachmentsByIdRaw(t,i)).value()}async getOspAccessAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getOspAccessAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new q(o,a=>jt(a))}async getOspAccessAttachmentsList(t,i){return await(await this.getOspAccessAttachmentsListRaw(t,i)).value()}async getOspAccessTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getOspAccessTicketById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new q(o,a=>ls(a))}async getOspAccessTicketById(t,i){return await(await this.getOspAccessTicketByIdRaw(t,i)).value()}async getOspAccessTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={},o=await this.request({path:"/osp-access-tickets",method:"GET",headers:n,query:s},i);return new q(o,a=>$o(a))}async getOspAccessTickets(t={},i){return await(await this.getOspAccessTicketsRaw(t,i)).value()}async updateOspAccessLocationsTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateOspAccessLocationsTicket.");if(t.locationsPatchRequestInner===null||t.locationsPatchRequestInner===void 0)throw new v("locationsPatchRequestInner","Required parameter requestParameters.locationsPatchRequestInner was null or undefined when calling updateOspAccessLocationsTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}/locations".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:t.locationsPatchRequestInner.map(Ht)},i);return new q(o,a=>zt(a))}async updateOspAccessLocationsTicket(t,i){return await(await this.updateOspAccessLocationsTicketRaw(t,i)).value()}async updateOspAccessTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateOspAccessTicket.");if(t.oSPAccessTicketUpdateRequest===null||t.oSPAccessTicketUpdateRequest===void 0)throw new v("oSPAccessTicketUpdateRequest","Required parameter requestParameters.oSPAccessTicketUpdateRequest was null or undefined when calling updateOspAccessTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:Po(t.oSPAccessTicketUpdateRequest)},i);return new q(o,a=>ls(a))}async updateOspAccessTicket(t,i){return await(await this.updateOspAccessTicketRaw(t,i)).value()}}class Mr extends Xe{async cancellationPopAccessRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationPopAccessRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new v("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationPopAccessRequest.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:Lt(t.cancellationTicketsRequest)},i);return new q(o,a=>Vt(a))}async cancellationPopAccessRequest(t,i){return await(await this.cancellationPopAccessRequestRaw(t,i)).value()}async createPopAccessAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createPopAccessAttachment.");if(t.fileName===null||t.fileName===void 0)throw new v("fileName","Required parameter requestParameters.fileName was null or undefined when calling createPopAccessAttachment.");if(t.body===null||t.body===void 0)throw new v("body","Required parameter requestParameters.body was null or undefined when calling createPopAccessAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new q(o,a=>_t(a))}async createPopAccessAttachment(t,i){return await(await this.createPopAccessAttachmentRaw(t,i)).value()}async createPopAccessCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createPopAccessComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new v("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createPopAccessComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:Mt(t.ticketCommentsRequest)},i);return new q(o,a=>Ut(a))}async createPopAccessComment(t,i){return await(await this.createPopAccessCommentRaw(t,i)).value()}async createPopAccessTicketRaw(t,i){if(t.pOPAccessTicketRequest===null||t.pOPAccessTicketRequest===void 0)throw new v("pOPAccessTicketRequest","Required parameter requestParameters.pOPAccessTicketRequest was null or undefined when calling createPopAccessTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets",method:"POST",headers:n,query:s,body:jo(t.pOPAccessTicketRequest)},i);return new q(o,a=>ht(a))}async createPopAccessTicket(t,i){return await(await this.createPopAccessTicketRaw(t,i)).value()}async getPopAccessAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPopAccessAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new v("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getPopAccessAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new Ft(o)}async getPopAccessAttachmentsById(t,i){return await(await this.getPopAccessAttachmentsByIdRaw(t,i)).value()}async getPopAccessAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPopAccessAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new q(o,a=>jt(a))}async getPopAccessAttachmentsList(t,i){return await(await this.getPopAccessAttachmentsListRaw(t,i)).value()}async getPopAccessTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPopAccessTicketById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new q(o,a=>hs(a))}async getPopAccessTicketById(t,i){return await(await this.getPopAccessTicketByIdRaw(t,i)).value()}async getPopAccessTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={},o=await this.request({path:"/pop-access-tickets",method:"GET",headers:n,query:s},i);return new q(o,a=>mr(a))}async getPopAccessTickets(t={},i){return await(await this.getPopAccessTicketsRaw(t,i)).value()}async updatePopAccessLocationsTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updatePopAccessLocationsTicket.");if(t.locationsPatchRequestInner===null||t.locationsPatchRequestInner===void 0)throw new v("locationsPatchRequestInner","Required parameter requestParameters.locationsPatchRequestInner was null or undefined when calling updatePopAccessLocationsTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}/locations".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:t.locationsPatchRequestInner.map(Ht)},i);return new q(o,a=>zt(a))}async updatePopAccessLocationsTicket(t,i){return await(await this.updatePopAccessLocationsTicketRaw(t,i)).value()}async updatePopAccessTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updatePopAccessTicket.");if(t.pOPAccessTicketUpdateRequest===null||t.pOPAccessTicketUpdateRequest===void 0)throw new v("pOPAccessTicketUpdateRequest","Required parameter requestParameters.pOPAccessTicketUpdateRequest was null or undefined when calling updatePopAccessTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:rr(t.pOPAccessTicketUpdateRequest)},i);return new q(o,a=>hs(a))}async updatePopAccessTicket(t,i){return await(await this.updatePopAccessTicketRaw(t,i)).value()}}class Jr extends Xe{async cancellationPermanentBadgeRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationPermanentBadgeRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new v("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationPermanentBadgeRequest.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:Lt(t.cancellationTicketsRequest)},i);return new q(o,a=>Vt(a))}async cancellationPermanentBadgeRequest(t,i){return await(await this.cancellationPermanentBadgeRequestRaw(t,i)).value()}async createPermanentBadegeAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createPermanentBadegeAttachment.");if(t.fileName===null||t.fileName===void 0)throw new v("fileName","Required parameter requestParameters.fileName was null or undefined when calling createPermanentBadegeAttachment.");if(t.body===null||t.body===void 0)throw new v("body","Required parameter requestParameters.body was null or undefined when calling createPermanentBadegeAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new q(o,a=>_t(a))}async createPermanentBadegeAttachment(t,i){return await(await this.createPermanentBadegeAttachmentRaw(t,i)).value()}async createPermanentBadgeCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createPermanentBadgeComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new v("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createPermanentBadgeComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:Mt(t.ticketCommentsRequest)},i);return new q(o,a=>Ut(a))}async createPermanentBadgeComment(t,i){return await(await this.createPermanentBadgeCommentRaw(t,i)).value()}async createPermanentBadgeModifyTicketRaw(t,i){if(t.permanentBadgeAccessModifyTicketRequest===null||t.permanentBadgeAccessModifyTicketRequest===void 0)throw new v("permanentBadgeAccessModifyTicketRequest","Required parameter requestParameters.permanentBadgeAccessModifyTicketRequest was null or undefined when calling createPermanentBadgeModifyTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-access-modify-tickets",method:"POST",headers:n,query:s,body:vr(t.permanentBadgeAccessModifyTicketRequest)},i);return new q(o,a=>ht(a))}async createPermanentBadgeModifyTicket(t,i){return await(await this.createPermanentBadgeModifyTicketRaw(t,i)).value()}async createPermanentBadgeNewTicketRaw(t,i){if(t.permanentBadgeAccessNewTicketRequest===null||t.permanentBadgeAccessNewTicketRequest===void 0)throw new v("permanentBadgeAccessNewTicketRequest","Required parameter requestParameters.permanentBadgeAccessNewTicketRequest was null or undefined when calling createPermanentBadgeNewTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-access-new-tickets",method:"POST",headers:n,query:s,body:wr(t.permanentBadgeAccessNewTicketRequest)},i);return new q(o,a=>ht(a))}async createPermanentBadgeNewTicket(t,i){return await(await this.createPermanentBadgeNewTicketRaw(t,i)).value()}async createPermanentBadgeTerminateTicketRaw(t,i){if(t.permanentBadgeAccessTerminateTicketRequest===null||t.permanentBadgeAccessTerminateTicketRequest===void 0)throw new v("permanentBadgeAccessTerminateTicketRequest","Required parameter requestParameters.permanentBadgeAccessTerminateTicketRequest was null or undefined when calling createPermanentBadgeTerminateTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-access-terminate-tickets",method:"POST",headers:n,query:s,body:fr(t.permanentBadgeAccessTerminateTicketRequest)},i);return new q(o,a=>ht(a))}async createPermanentBadgeTerminateTicket(t,i){return await(await this.createPermanentBadgeTerminateTicketRaw(t,i)).value()}async getPermanentBadgeAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPermanentBadgeAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new v("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getPermanentBadgeAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new Ft(o)}async getPermanentBadgeAttachmentsById(t,i){return await(await this.getPermanentBadgeAttachmentsByIdRaw(t,i)).value()}async getPermanentBadgeAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPermanentBadgeAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new q(o,a=>jt(a))}async getPermanentBadgeAttachmentsList(t,i){return await(await this.getPermanentBadgeAttachmentsListRaw(t,i)).value()}async getPermanentBadgeHoldersListRaw(t,i){if(t.accountNumber===null||t.accountNumber===void 0)throw new v("accountNumber","Required parameter requestParameters.accountNumber was null or undefined when calling getPermanentBadgeHoldersList.");const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.activeBadge!==void 0&&(s.active_badge=t.activeBadge),t.nameOrEmailContains!==void 0&&(s.name_or_email_contains=t.nameOrEmailContains),t.page!==void 0&&(s.page=t.page),t.size!==void 0&&(s.size=t.size);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/badge-holders",method:"GET",headers:n,query:s},i);return new q(o,a=>vo(a))}async getPermanentBadgeHoldersList(t,i){return await(await this.getPermanentBadgeHoldersListRaw(t,i)).value()}async getPermanentBadgeTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPermanentBadgeTicketById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new q(o,a=>ws(a))}async getPermanentBadgeTicketById(t,i){return await(await this.getPermanentBadgeTicketByIdRaw(t,i)).value()}async getPermanentBadgeTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={},o=await this.request({path:"/permanent-badge-access-tickets",method:"GET",headers:n,query:s},i);return new q(o,a=>Ar(a))}async getPermanentBadgeTickets(t={},i){return await(await this.getPermanentBadgeTicketsRaw(t,i)).value()}async updatePermanentBadgeLocationsTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updatePermanentBadgeLocationsTicket.");if(t.locationsPatchRequestInner===null||t.locationsPatchRequestInner===void 0)throw new v("locationsPatchRequestInner","Required parameter requestParameters.locationsPatchRequestInner was null or undefined when calling updatePermanentBadgeLocationsTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}/locations".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:t.locationsPatchRequestInner.map(Ht)},i);return new q(o,a=>zt(a))}async updatePermanentBadgeLocationsTicket(t,i){return await(await this.updatePermanentBadgeLocationsTicketRaw(t,i)).value()}async updatePermanentBadgeTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updatePermanentBadgeTicket.");if(t.permanentBadgeAccessTicketUpdateRequest===null||t.permanentBadgeAccessTicketUpdateRequest===void 0)throw new v("permanentBadgeAccessTicketUpdateRequest","Required parameter requestParameters.permanentBadgeAccessTicketUpdateRequest was null or undefined when calling updatePermanentBadgeTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:Tr(t.permanentBadgeAccessTicketUpdateRequest)},i);return new q(o,a=>ws(a))}async updatePermanentBadgeTicket(t,i){return await(await this.updatePermanentBadgeTicketRaw(t,i)).value()}}class Wr extends Xe{async cancellationVisitorAccessRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationVisitorAccessRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new v("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationVisitorAccessRequest.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:Lt(t.cancellationTicketsRequest)},i);return new q(o,a=>Vt(a))}async cancellationVisitorAccessRequest(t,i){return await(await this.cancellationVisitorAccessRequestRaw(t,i)).value()}async createVisitorAccessAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createVisitorAccessAttachment.");if(t.fileName===null||t.fileName===void 0)throw new v("fileName","Required parameter requestParameters.fileName was null or undefined when calling createVisitorAccessAttachment.");if(t.body===null||t.body===void 0)throw new v("body","Required parameter requestParameters.body was null or undefined when calling createVisitorAccessAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new q(o,a=>_t(a))}async createVisitorAccessAttachment(t,i){return await(await this.createVisitorAccessAttachmentRaw(t,i)).value()}async createVisitorAccessCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createVisitorAccessComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new v("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createVisitorAccessComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:Mt(t.ticketCommentsRequest)},i);return new q(o,a=>Ut(a))}async createVisitorAccessComment(t,i){return await(await this.createVisitorAccessCommentRaw(t,i)).value()}async createVisitorAccessTicketRaw(t,i){if(t.visitorAccessTicketRequest===null||t.visitorAccessTicketRequest===void 0)throw new v("visitorAccessTicketRequest","Required parameter requestParameters.visitorAccessTicketRequest was null or undefined when calling createVisitorAccessTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets",method:"POST",headers:n,query:s,body:Dr(t.visitorAccessTicketRequest)},i);return new q(o,a=>ht(a))}async createVisitorAccessTicket(t,i){return await(await this.createVisitorAccessTicketRaw(t,i)).value()}async getVisitorAccessAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getVisitorAccessAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new v("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getVisitorAccessAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new Ft(o)}async getVisitorAccessAttachmentsById(t,i){return await(await this.getVisitorAccessAttachmentsByIdRaw(t,i)).value()}async getVisitorAccessAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getVisitorAccessAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new q(o,a=>jt(a))}async getVisitorAccessAttachmentsList(t,i){return await(await this.getVisitorAccessAttachmentsListRaw(t,i)).value()}async getVisitorAccessTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getVisitorAccessTicketById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new q(o,a=>ks(a))}async getVisitorAccessTicketById(t,i){return await(await this.getVisitorAccessTicketByIdRaw(t,i)).value()}async getVisitorAccessTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={},o=await this.request({path:"/visitor-access-tickets",method:"GET",headers:n,query:s},i);return new q(o,a=>Fr(a))}async getVisitorAccessTickets(t={},i){return await(await this.getVisitorAccessTicketsRaw(t,i)).value()}async updateVisitorAccessLocationsTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateVisitorAccessLocationsTicket.");if(t.locationsPatchRequestInner===null||t.locationsPatchRequestInner===void 0)throw new v("locationsPatchRequestInner","Required parameter requestParameters.locationsPatchRequestInner was null or undefined when calling updateVisitorAccessLocationsTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}/locations".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:t.locationsPatchRequestInner.map(Ht)},i);return new q(o,a=>zt(a))}async updateVisitorAccessLocationsTicket(t,i){return await(await this.updateVisitorAccessLocationsTicketRaw(t,i)).value()}async updateVisitorAccessTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateVisitorAccessTicket.");if(t.visitorAccessTicketUpdateRequest===null||t.visitorAccessTicketUpdateRequest===void 0)throw new v("visitorAccessTicketUpdateRequest","Required parameter requestParameters.visitorAccessTicketUpdateRequest was null or undefined when calling updateVisitorAccessTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:$r(t.visitorAccessTicketUpdateRequest)},i);return new q(o,a=>ks(a))}async updateVisitorAccessTicket(t,i){return await(await this.updateVisitorAccessTicketRaw(t,i)).value()}}class Gr extends Xe{async getVisitorHostsListRaw(t,i){if(t.site===null||t.site===void 0)throw new v("site","Required parameter requestParameters.site was null or undefined when calling getVisitorHostsList.");const s={};t.site!==void 0&&(s.site=t.site),t.nameOrEmailContains!==void 0&&(s.name_or_email_contains=t.nameOrEmailContains),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-hosts",method:"GET",headers:n,query:s},i);return new q(o,a=>Hr(a))}async getVisitorHostsList(t,i){return await(await this.getVisitorHostsListRaw(t,i)).value()}}const Zr="http://localhost".replace(/\/+$/,"");class Wt{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Zr}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||ys}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const Kr=new Wt;class Bt{constructor(t=Kr){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new ec(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?Bt.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new Qr(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;Xr(r.body)||r.body instanceof URLSearchParams||Yr(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}Bt.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function Yr(e){return typeof Blob<"u"&&e instanceof Blob}function Xr(e){return typeof FormData<"u"&&e instanceof FormData}class Qr extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class ec extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class Ti extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function f(e,t){return e[t]!=null}function ys(e,t=""){return Object.keys(e).map(i=>Ts(i,e[i],t)).filter(i=>i.length>0).join("&")}function Ts(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return Ts(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?ys(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class It{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}const tc="https://service-management.digitalrealty.com".replace(/\/+$/,"");class Gt{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:tc}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||bs}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const ic=new Gt;class yt{constructor(t=ic){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new oc(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?yt.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new ac(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;nc(r.body)||r.body instanceof URLSearchParams||sc(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}yt.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function sc(e){return typeof Blob<"u"&&e instanceof Blob}function nc(e){return typeof FormData<"u"&&e instanceof FormData}class ac extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class oc extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class dt extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function Ge(e,t){return e[t]!=null}function bs(e,t=""){return Object.keys(e).map(i=>Rs(i,e[i],t)).filter(i=>i.length>0).join("&")}function Rs(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return Rs(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?bs(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class bi{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class rc{constructor(t){this.raw=t}async value(){return await this.raw.text()}}const cc="https://service-management.digitalrealty.com".replace(/\/+$/,"");class As{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:cc}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||_s}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const dc=new As;class oi{constructor(t=dc){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new pc(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?oi.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new mc(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;lc(r.body)||r.body instanceof URLSearchParams||uc(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}oi.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function uc(e){return typeof Blob<"u"&&e instanceof Blob}function lc(e){return typeof FormData<"u"&&e instanceof FormData}class mc extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class pc extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class ee extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function _(e,t){return e[t]!=null}function _s(e,t=""){return Object.keys(e).map(i=>Is(i,e[i],t)).filter(i=>i.length>0).join("&")}function Is(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return Is(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?_s(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class Pe{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class hc{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}function vc(e){if(e!==void 0)return e===null?null:{cancellationReason:e.cancellationReason}}function gc(e){return wc(e)}function wc(e,t){return e==null?e:{message:_(e,"message")?e.message:void 0}}function fc(e){return kc(e)}function kc(e,t){return e==null?e:{requestType:_(e,"request_type")?e.request_type:void 0,categories:_(e,"categories")?e.categories:void 0}}function yc(e){return Tc(e)}function Tc(e,t){return e==null?e:{items:_(e,"items")?e.items.map(fc):void 0}}function Ss(e){return bc(e)}function bc(e,t){return e==null?e:{createdBy:_(e,"created_by")?e.created_by:void 0,createdAt:_(e,"created_at")?new Date(e.created_at):void 0,comment:_(e,"comment")?e.comment:void 0}}function Rc(e){return Ac(e)}function Ac(e,t){return e==null?e:{comments:_(e,"comments")?e.comments.map(Ss):void 0}}function _c(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,request_type:e.requestType,category:e.category,subject:e.subject,description:e.description,expected_start:e.expectedStart===void 0?void 0:e.expectedStart===null?null:e.expectedStart.toISOString(),customer_reference:e.customerReference,locations:e.locations,reference_ticket:e.referenceTicket,other_notification_recipients:e.otherNotificationRecipients}}function Ri(e){return Ic(e)}function Ic(e,t){return e==null?e:{ticketId:_(e,"ticket_id")?e.ticket_id:void 0,accountNumber:_(e,"account_number")?e.account_number:void 0,accountName:_(e,"account_name")?e.account_name:void 0,status:_(e,"status")?e.status:void 0,cancellationReason:_(e,"cancellation_reason")?e.cancellation_reason:void 0,site:_(e,"site")?e.site:void 0,locations:_(e,"locations")?e.locations:void 0,requestType:_(e,"request_type")?e.request_type:void 0,category:_(e,"category")?e.category:void 0,subject:_(e,"subject")?e.subject:void 0,description:_(e,"description")?e.description:void 0,expectedStart:_(e,"expected_start")?e.expected_start===null?null:new Date(e.expected_start):void 0,referenceTicket:_(e,"reference_ticket")?e.reference_ticket:void 0,customerReference:_(e,"customer_reference")?e.customer_reference:void 0,otherNotificationRecipients:_(e,"other_notification_recipients")?e.other_notification_recipients:void 0,createdBy:_(e,"created_by")?e.created_by:void 0,createdAt:_(e,"created_at")?new Date(e.created_at):void 0,updatedAt:_(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:_(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0,comments:_(e,"comments")?e.comments.map(Ss):void 0}}function Sc(e){return Cc(e)}function Cc(e,t){return e==null?e:{accountNumber:_(e,"account_number")?e.account_number:void 0,accountName:_(e,"account_name")?e.account_name:void 0,id:_(e,"id")?e.id:void 0,status:_(e,"status")?e.status:void 0,site:_(e,"site")?e.site:void 0,locations:_(e,"locations")?e.locations:void 0,description:_(e,"description")?e.description:void 0,subject:_(e,"subject")?e.subject:void 0,createdBy:_(e,"created_by")?e.created_by:void 0,updatedAt:_(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:_(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function Nc(e){return Pc(e)}function Pc(e,t){return e==null?e:{remoteHandsTickets:_(e,"remote_hands_tickets")?e.remote_hands_tickets.map(Sc):void 0,totalCount:_(e,"total_count")?e.total_count:void 0,pageNumber:_(e,"page_number")?e.page_number:void 0,pageSize:_(e,"page_size")?e.page_size:void 0}}function qc(e){if(e!==void 0)return e===null?null:{customer_reference:e.customerReference,other_notification_recipients:e.otherNotificationRecipients}}function Cs(e){return Dc(e)}function Dc(e,t){return e==null?e:{id:_(e,"id")?e.id:void 0,fileName:_(e,"file_name")?e.file_name:void 0,fileSize:_(e,"file_size")?e.file_size:void 0,contentType:_(e,"content_type")?e.content_type:void 0,createdBy:_(e,"created_by")?e.created_by:void 0,createdAt:_(e,"created_at")?e.created_at===null?null:new Date(e.created_at):void 0}}function Bc(e){return Oc(e)}function Oc(e,t){return e==null?e:{attachments:_(e,"attachments")?e.attachments.map(Cs):void 0}}function $c(e){if(e!==void 0)return e===null?null:{comment:e.comment}}class Ec extends oi{async cancellationRemoteHandsRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationRemoteHandsRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new ee("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationRemoteHandsRequest.");const s={},n={};n["Content-Type"]="application/json";const o=await this.request({path:"/remote-hands-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:vc(t.cancellationTicketsRequest)},i);return new Pe(o,a=>gc(a))}async cancellationRemoteHandsRequest(t,i){return await(await this.cancellationRemoteHandsRequestRaw(t,i)).value()}async createRemoteHandsAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createRemoteHandsAttachment.");if(t.fileName===null||t.fileName===void 0)throw new ee("fileName","Required parameter requestParameters.fileName was null or undefined when calling createRemoteHandsAttachment.");if(t.body===null||t.body===void 0)throw new ee("body","Required parameter requestParameters.body was null or undefined when calling createRemoteHandsAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new Pe(o,a=>Cs(a))}async createRemoteHandsAttachment(t,i){return await(await this.createRemoteHandsAttachmentRaw(t,i)).value()}async createRemoteHandsCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createRemoteHandsComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new ee("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createRemoteHandsComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:$c(t.ticketCommentsRequest)},i);return new Pe(o,a=>Rc(a))}async createRemoteHandsComment(t,i){return await(await this.createRemoteHandsCommentRaw(t,i)).value()}async createRemoteHandsTicketRaw(t,i){if(t.remoteHandsRequest===null||t.remoteHandsRequest===void 0)throw new ee("remoteHandsRequest","Required parameter requestParameters.remoteHandsRequest was null or undefined when calling createRemoteHandsTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets",method:"POST",headers:n,query:s,body:_c(t.remoteHandsRequest)},i);return new Pe(o,a=>Ri(a))}async createRemoteHandsTicket(t,i){return await(await this.createRemoteHandsTicketRaw(t,i)).value()}async getRemoteHandsAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getRemoteHandsAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new ee("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getRemoteHandsAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new hc(o)}async getRemoteHandsAttachmentsById(t,i){return await(await this.getRemoteHandsAttachmentsByIdRaw(t,i)).value()}async getRemoteHandsAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getRemoteHandsAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new Pe(o,a=>Bc(a))}async getRemoteHandsAttachmentsList(t,i){return await(await this.getRemoteHandsAttachmentsListRaw(t,i)).value()}async getRemoteHandsCategoriesListRaw(t,i){if(t.site===null||t.site===void 0)throw new ee("site","Required parameter requestParameters.site was null or undefined when calling getRemoteHandsCategoriesList.");const s={};t.site!==void 0&&(s.site=t.site);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/categories",method:"GET",headers:n,query:s},i);return new Pe(o,a=>yc(a))}async getRemoteHandsCategoriesList(t,i){return await(await this.getRemoteHandsCategoriesListRaw(t,i)).value()}async getRemoteHandsTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getRemoteHandsTicketById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new Pe(o,a=>Ri(a))}async getRemoteHandsTicketById(t,i){return await(await this.getRemoteHandsTicketByIdRaw(t,i)).value()}async getRemoteHandsTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={},o=await this.request({path:"/remote-hands-tickets",method:"GET",headers:n,query:s},i);return new Pe(o,a=>Nc(a))}async getRemoteHandsTickets(t={},i){return await(await this.getRemoteHandsTicketsRaw(t,i)).value()}async updateRemoteHandsTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateRemoteHandsTicketById.");if(t.remoteHandsUpdateRequest===null||t.remoteHandsUpdateRequest===void 0)throw new ee("remoteHandsUpdateRequest","Required parameter requestParameters.remoteHandsUpdateRequest was null or undefined when calling updateRemoteHandsTicketById.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:qc(t.remoteHandsUpdateRequest)},i);return new Pe(o,a=>Ri(a))}async updateRemoteHandsTicketById(t,i){return await(await this.updateRemoteHandsTicketByIdRaw(t,i)).value()}}function xc(e){return Fc(e)}function Fc(e,t){return e==null?e:{serviceManagement:f(e,"service_management")?e.service_management:void 0,remoteHands:f(e,"remote_hands")?e.remote_hands:void 0,deliveries:f(e,"deliveries")?e.deliveries:void 0,removals:f(e,"removals")?e.removals:void 0,facilitiesAccess:f(e,"facilities_access")?e.facilities_access:void 0,temporaryAccess:f(e,"temporary_access")?e.temporary_access:void 0,inventory:f(e,"inventory")?e.inventory:void 0,orderHistory:f(e,"order_history")?e.order_history:void 0,precabling:f(e,"precabling")?e.precabling:void 0,crossConnect:f(e,"cross_connect")?e.cross_connect:void 0,customerEquipmentConnection:f(e,"customer_equipment_connection")?e.customer_equipment_connection:void 0,virtualConnectivity:f(e,"virtual_connectivity")?e.virtual_connectivity:void 0,customerCare:f(e,"customer_care")?e.customer_care:void 0,troubleTickets:f(e,"trouble_tickets")?e.trouble_tickets:void 0}}function Lc(e){return Vc(e)}function Vc(e,t){return e==null?e:{name:f(e,"name")?e.name:void 0,privilegeLevel:f(e,"privilege_level")?e.privilege_level:void 0}}function Uc(e){return Hc(e)}function Hc(e,t){return e==null?e:{id:e.id,accountNumber:e.account_number,siteId:e.site_id,floor:f(e,"floor")?e.floor:void 0,room:f(e,"room")?e.room:void 0,cage:f(e,"cage")?e.cage:void 0,rack:f(e,"rack")?e.rack:void 0,row:f(e,"row")?e.row:void 0,locationType:e.location_type,csrDemarcation:e.csr_demarcation,comment:f(e,"comment")?e.comment:void 0,dcimEnabled:f(e,"dcim_enabled")?e.dcim_enabled:void 0,permissions:f(e,"permissions")?e.permissions.map(Lc):void 0,assignableProcesses:f(e,"assignable_processes")?xc(e.assignable_processes):void 0}}function zc(e){return jc(e)}function jc(e,t){return e==null?e:{self:f(e,"self")?e.self:void 0,first:f(e,"first")?e.first:void 0,prev:f(e,"prev")?e.prev:void 0,next:f(e,"next")?e.next:void 0,last:f(e,"last")?e.last:void 0,items:e.items.map(Uc)}}function Mc(e){return Jc(e)}function Jc(e,t){return e==null?e:{count:e.count}}function Ns(e){return Wc(e)}function Wc(e,t){return e==null?e:{id:f(e,"id")?e.id:void 0,locationId:f(e,"location_id")?e.location_id:void 0,name:f(e,"name")?e.name:void 0,campus:f(e,"campus")?e.campus:void 0,metroArea:f(e,"metro_area")?e.metro_area:void 0,region:f(e,"region")?e.region:void 0,regionName:f(e,"region_name")?e.region_name:void 0,country:f(e,"country")?e.country:void 0,addressCountry:f(e,"address_country")?e.address_country:void 0,addressLocality:f(e,"address_locality")?e.address_locality:void 0,addressRegion:f(e,"address_region")?e.address_region:void 0,postalCode:f(e,"postal_code")?e.postal_code:void 0,streetAddress:f(e,"street_address")?e.street_address:void 0,peeringdbFacilityId:f(e,"peeringdb_facility_id")?e.peeringdb_facility_id:void 0,organisationName:f(e,"organisation_name")?e.organisation_name:void 0,timeZone:f(e,"time_zone")?e.time_zone:void 0,latitude:f(e,"latitude")?e.latitude:void 0,longitude:f(e,"longitude")?e.longitude:void 0,locations:f(e,"locations")?Mc(e.locations):void 0}}function Gc(e){return Zc(e)}function Zc(e,t){return e==null?e:{self:f(e,"self")?e.self:void 0,first:f(e,"first")?e.first:void 0,prev:f(e,"prev")?e.prev:void 0,next:f(e,"next")?e.next:void 0,last:f(e,"last")?e.last:void 0,items:e.items.map(Ns)}}function Kc(e){return Yc(e)}function Yc(e,t){return e==null?e:{id:f(e,"id")?e.id:void 0,name:f(e,"name")?e.name:void 0,description:f(e,"description")?e.description:void 0}}function Xc(e){return Qc(e)}function Qc(e,t){return e==null?e:{id:f(e,"id")?e.id:void 0,name:f(e,"name")?e.name:void 0,description:f(e,"description")?e.description:void 0}}class ed extends Bt{async getLocationsRaw(t,i){const s={};t.sort!==void 0&&(s.sort=t.sort),t.cursor!==void 0&&(s.cursor=t.cursor),t.pageSize!==void 0&&(s.page_size=t.pageSize),t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.id!==void 0&&(s.id=t.id),t.siteId!==void 0&&(s.site_id=t.siteId),t.floor!==void 0&&(s.floor=t.floor),t.room!==void 0&&(s.room=t.room),t.cage!==void 0&&(s.cage=t.cage),t.rack!==void 0&&(s.rack=t.rack),t.row!==void 0&&(s.row=t.row),t.demarcation!==void 0&&(s.demarcation=t.demarcation),t.locationType!==void 0&&(s.location_type=t.locationType),t.embed!==void 0&&(s.embed=t.embed),t.permissionType!==void 0&&(s.permission_type=t.permissionType),t.permissionPrivilege!==void 0&&(s.permission_privilege=t.permissionPrivilege),t.dcimEnabled!==void 0&&(s.dcim_enabled=t.dcimEnabled),t.assignableProcess!==void 0&&(s.assignable_process=t.assignableProcess);const n={};this.configuration&&this.configuration.apiKey&&(n.Authorization=this.configuration.apiKey("Authorization"));const o=await this.request({path:"/locations",method:"GET",headers:n,query:s},i);return new It(o,a=>zc(a))}async getLocations(t={},i){return await(await this.getLocationsRaw(t,i)).value()}}class Ps extends Bt{async getOspsBySiteIdRaw(t,i){if(t.siteId===null||t.siteId===void 0)throw new Ti("siteId","Required parameter requestParameters.siteId was null or undefined when calling getOspsBySiteId.");const s={},n={};this.configuration&&this.configuration.apiKey&&(n.Authorization=this.configuration.apiKey("Authorization"));const o=await this.request({path:"/sites/{siteId}/osps".replace("{siteId}",encodeURIComponent(String(t.siteId))),method:"GET",headers:n,query:s},i);return new It(o,a=>a.map(Kc))}async getOspsBySiteId(t,i){return await(await this.getOspsBySiteIdRaw(t,i)).value()}async getPopsBySiteIdRaw(t,i){if(t.siteId===null||t.siteId===void 0)throw new Ti("siteId","Required parameter requestParameters.siteId was null or undefined when calling getPopsBySiteId.");const s={},n={};this.configuration&&this.configuration.apiKey&&(n.Authorization=this.configuration.apiKey("Authorization"));const o=await this.request({path:"/sites/{siteId}/pops".replace("{siteId}",encodeURIComponent(String(t.siteId))),method:"GET",headers:n,query:s},i);return new It(o,a=>a.map(Xc))}async getPopsBySiteId(t,i){return await(await this.getPopsBySiteIdRaw(t,i)).value()}async getSiteByIdRaw(t,i){if(t.siteId===null||t.siteId===void 0)throw new Ti("siteId","Required parameter requestParameters.siteId was null or undefined when calling getSiteById.");const s={},n={};this.configuration&&this.configuration.apiKey&&(n.Authorization=this.configuration.apiKey("Authorization"));const o=await this.request({path:"/sites/{siteId}".replace("{siteId}",encodeURIComponent(String(t.siteId))),method:"GET",headers:n,query:s},i);return new It(o,a=>Ns(a))}async getSiteById(t,i){return await(await this.getSiteByIdRaw(t,i)).value()}async getSitesRaw(t,i){const s={};t.name!==void 0&&(s.name=t.name),t.sort!==void 0&&(s.sort=t.sort),t.cursor!==void 0&&(s.cursor=t.cursor),t.pageSize!==void 0&&(s.page_size=t.pageSize),t.showMySites!==void 0&&(s.show_my_sites=t.showMySites),t.embed!==void 0&&(s.embed=t.embed);const n={};this.configuration&&this.configuration.apiKey&&(n.Authorization=this.configuration.apiKey("Authorization"));const o=await this.request({path:"/sites",method:"GET",headers:n,query:s},i);return new It(o,a=>Gc(a))}async getSites(t={},i){return await(await this.getSitesRaw(t,i)).value()}}const td="https://api.digitalrealty.com".replace(/\/+$/,"");class qs{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:td}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Ds}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const id=new qs;class ri{constructor(t=id){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new od(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?ri.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new ad(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;nd(r.body)||r.body instanceof URLSearchParams||sd(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}ri.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function sd(e){return typeof Blob<"u"&&e instanceof Blob}function nd(e){return typeof FormData<"u"&&e instanceof FormData}class ad extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class od extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class Zt extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function T(e,t){return e[t]!=null}function Ds(e,t=""){return Object.keys(e).map(i=>Bs(i,e[i],t)).filter(i=>i.length>0).join("&")}function Bs(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return Bs(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Ds(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class Ai{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class Os{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}const rd="https://api.digitalrealty.com/service-management/v1".replace(/\/+$/,"");class $s{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:rd}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Es}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const cd=new $s;class ci{constructor(t=cd){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new md(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?ci.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new ld(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;ud(r.body)||r.body instanceof URLSearchParams||dd(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}ci.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function dd(e){return typeof Blob<"u"&&e instanceof Blob}function ud(e){return typeof FormData<"u"&&e instanceof FormData}class ld extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class md extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class vt extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function D(e,t){return e[t]!=null}function Es(e,t=""){return Object.keys(e).map(i=>xs(i,e[i],t)).filter(i=>i.length>0).join("&")}function xs(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return xs(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Es(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class Kt{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class Fs{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}function Ls(e){return pd(e)}function pd(e,t){return e==null?e:{createdBy:D(e,"created_by")?e.created_by:void 0,createdAt:D(e,"created_at")?new Date(e.created_at):void 0,comment:D(e,"comment")?e.comment:void 0}}function hd(e){return vd(e)}function vd(e,t){return e==null?e:{comments:D(e,"comments")?e.comments.map(Ls):void 0}}function Vs(e){return gd(e)}function gd(e,t){return e==null?e:{id:D(e,"id")?e.id:void 0,fileName:D(e,"file_name")?e.file_name:void 0}}function wd(e){return fd(e)}function fd(e,t){return e==null?e:{accountNumber:D(e,"account_number")?e.account_number:void 0,accountName:D(e,"account_name")?e.account_name:void 0,id:D(e,"id")?e.id:void 0,status:D(e,"status")?e.status:void 0,subject:D(e,"subject")?e.subject:void 0,site:D(e,"site")?e.site:void 0,priority:D(e,"priority")?e.priority:void 0,comments:D(e,"comments")?e.comments.map(Ls):void 0,attachments:D(e,"attachments")?e.attachments.map(Vs):void 0,createdAt:D(e,"created_at")?new Date(e.created_at):void 0,updatedAt:D(e,"updated_at")?new Date(e.updated_at):void 0}}function kd(e){return yd(e)}function yd(e,t){return e==null?e:{accountNumber:D(e,"account_number")?e.account_number:void 0,accountName:D(e,"account_name")?e.account_name:void 0,id:D(e,"id")?e.id:void 0,status:D(e,"status")?e.status:void 0,subject:D(e,"subject")?e.subject:void 0,site:D(e,"site")?e.site:void 0,priority:D(e,"priority")?e.priority:void 0,attachments:D(e,"attachments")?e.attachments.map(Vs):void 0,createdAt:D(e,"created_at")?new Date(e.created_at):void 0,updatedAt:D(e,"updated_at")?new Date(e.updated_at):void 0}}function Td(e){return bd(e)}function bd(e,t){return e==null?e:{items:D(e,"items")?e.items.map(kd):void 0,totalCount:D(e,"total_count")?e.total_count:void 0,pageNumber:D(e,"page_number")?e.page_number:void 0,pageSize:D(e,"page_size")?e.page_size:void 0}}function Rd(e){return Ad(e)}function Ad(e,t){return e==null?e:{id:D(e,"id")?e.id:void 0,fileName:D(e,"file_name")?e.file_name:void 0,fileSize:D(e,"file_size")?e.file_size:void 0,contentType:D(e,"content_type")?e.content_type:void 0,createdBy:D(e,"created_by")?e.created_by:void 0,createdAt:D(e,"created_at")?new Date(e.created_at):void 0}}function _d(e){return Id(e)}function Id(e,t){return e==null?e:{attachments:D(e,"attachments")?e.attachments.map(Rd):void 0}}function Sd(e){if(e!==void 0)return e===null?null:{comment:e.comment}}class Cd extends ci{async createIncidentCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new vt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createIncidentComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new vt("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createIncidentComment.");const s={},n={};n["Content-Type"]="application/json";const o=await this.request({path:"/incident-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:Sd(t.ticketCommentsRequest)},i);return new Kt(o,a=>hd(a))}async createIncidentComment(t,i){return await(await this.createIncidentCommentRaw(t,i)).value()}async downloadIncidentTicketsRaw(t,i){const s={};t.$filter!==void 0&&(s.$filter=t.$filter),t.$orderby!==void 0&&(s.$orderby=t.$orderby),t.$skip!==void 0&&(s.$skip=t.$skip),t.$top!==void 0&&(s.$top=t.$top);const n={},o=await this.request({path:"/incident-tickets/file",method:"GET",headers:n,query:s},i);return new Fs(o)}async downloadIncidentTickets(t={},i){return await(await this.downloadIncidentTicketsRaw(t,i)).value()}async getIncidentsAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new vt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getIncidentsAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new vt("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getIncidentsAttachmentsById.");const s={},n={},o=await this.request({path:"/incident-tickets/{ticket_id}/attachments/file/{attachment_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new Fs(o)}async getIncidentsAttachmentsById(t,i){return await(await this.getIncidentsAttachmentsByIdRaw(t,i)).value()}async getIncidentsAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new vt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getIncidentsAttachmentsList.");const s={},n={},o=await this.request({path:"/incident-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new Kt(o,a=>_d(a))}async getIncidentsAttachmentsList(t,i){return await(await this.getIncidentsAttachmentsListRaw(t,i)).value()}async getIncidentsTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new vt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getIncidentsTicketById.");const s={},n={},o=await this.request({path:"/incident-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new Kt(o,a=>wd(a))}async getIncidentsTicketById(t,i){return await(await this.getIncidentsTicketByIdRaw(t,i)).value()}async getIncidentsTicketsRaw(t,i){const s={};t.$filter!==void 0&&(s.$filter=t.$filter),t.$orderby!==void 0&&(s.$orderby=t.$orderby),t.$skip!==void 0&&(s.$skip=t.$skip),t.$top!==void 0&&(s.$top=t.$top);const n={},o=await this.request({path:"/incident-tickets",method:"GET",headers:n,query:s},i);return new Kt(o,a=>Td(a))}async getIncidentsTickets(t={},i){return await(await this.getIncidentsTicketsRaw(t,i)).value()}}const Nd="http://localhost".replace(/\/+$/,"");class Us{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Nd}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||zs}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const Pd=new Us;class di{constructor(t=Pd){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new Od(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?di.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new Bd(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;Dd(r.body)||r.body instanceof URLSearchParams||qd(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}di.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function qd(e){return typeof Blob<"u"&&e instanceof Blob}function Dd(e){return typeof FormData<"u"&&e instanceof FormData}class Bd extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class Od extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class Hs extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function qe(e,t){return e[t]!=null}function zs(e,t=""){return Object.keys(e).map(i=>js(i,e[i],t)).filter(i=>i.length>0).join("&")}function js(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return js(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?zs(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class $d{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}const Ed="http://localhost".replace(/\/+$/,"");class Ms{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Ed}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Ws}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const xd=new Ms;class ui{constructor(t=xd){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new Ud(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?ui.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new Vd(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;Ld(r.body)||r.body instanceof URLSearchParams||Fd(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}ui.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function Fd(e){return typeof Blob<"u"&&e instanceof Blob}function Ld(e){return typeof FormData<"u"&&e instanceof FormData}class Vd extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class Ud extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}function Js(e,t){return e[t]!=null}function Ws(e,t=""){return Object.keys(e).map(i=>Gs(i,e[i],t)).filter(i=>i.length>0).join("&")}function Gs(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return Gs(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Ws(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class Zs{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}function Hd(e){if(e!==void 0)return e===null?null:{cancellationReason:e.cancellationReason}}function zd(e){return jd(e)}function jd(e,t){return e==null?e:{message:I(e,"message")?e.message:void 0}}function Md(e){return Jd(e)}function Jd(e,t){return e==null?e:{requestType:I(e,"request_type")?e.request_type:void 0,categories:I(e,"categories")?e.categories:void 0}}function Wd(e){return Gd(e)}function Gd(e,t){return e==null?e:{items:I(e,"items")?e.items.map(Md):void 0}}function Ks(e){return Zd(e)}function Zd(e,t){return e==null?e:{createdBy:I(e,"created_by")?e.created_by:void 0,createdAt:I(e,"created_at")?new Date(e.created_at):void 0,comment:I(e,"comment")?e.comment:void 0}}function Kd(e){return Yd(e)}function Yd(e,t){return e==null?e:{comments:I(e,"comments")?e.comments.map(Ks):void 0}}function Xd(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,subject:e.subject,request_type:e.requestType,category:e.category,locations:e.locations,customer_reference:e.customerReference,description:e.description,notification_recipients:e.notificationRecipients}}function _i(e){return Qd(e)}function Qd(e,t){return e==null?e:{accountNumber:I(e,"account_number")?e.account_number:void 0,accountName:I(e,"account_name")?e.account_name:void 0,id:I(e,"id")?e.id:void 0,status:I(e,"status")?e.status:void 0,cancellationReason:I(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:I(e,"subject")?e.subject:void 0,requestType:I(e,"request_type")?e.request_type:void 0,category:I(e,"category")?e.category:void 0,site:I(e,"site")?e.site:void 0,locations:I(e,"locations")?e.locations:void 0,customerReference:I(e,"customer_reference")?e.customer_reference:void 0,description:I(e,"description")?e.description:void 0,notificationRecipients:I(e,"notification_recipients")?e.notification_recipients:void 0,createdBy:I(e,"created_by")?e.created_by:void 0,createdAt:I(e,"created_at")?new Date(e.created_at):void 0,updatedAt:I(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:I(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0,comments:I(e,"comments")?e.comments.map(Ks):void 0}}function eu(e){if(e!==void 0)return e===null?null:{subject:e.subject,description:e.description,customer_reference:e.customerReference,other_notification_recipients:e.otherNotificationRecipients}}function tu(e){return iu(e)}function iu(e,t){return e==null?e:{accountNumber:I(e,"account_number")?e.account_number:void 0,accountName:I(e,"account_name")?e.account_name:void 0,id:I(e,"id")?e.id:void 0,status:I(e,"status")?e.status:void 0,subject:I(e,"subject")?e.subject:void 0,site:I(e,"site")?e.site:void 0,locations:I(e,"locations")?e.locations:void 0,description:I(e,"description")?e.description:void 0,createdBy:I(e,"created_by")?e.created_by:void 0,createdAt:I(e,"created_at")?new Date(e.created_at):void 0,updatedAt:I(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:I(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function su(e){return nu(e)}function nu(e,t){return e==null?e:{items:I(e,"items")?e.items.map(tu):void 0,totalCount:I(e,"total_count")?e.total_count:void 0,pageNumber:I(e,"page_number")?e.page_number:void 0,pageSize:I(e,"page_size")?e.page_size:void 0}}function Ys(e){return au(e)}function au(e,t){return e==null?e:{id:I(e,"id")?e.id:void 0,fileName:I(e,"file_name")?e.file_name:void 0,fileSize:I(e,"file_size")?e.file_size:void 0,contentType:I(e,"content_type")?e.content_type:void 0,createdBy:I(e,"created_by")?e.created_by:void 0,createdAt:I(e,"created_at")?new Date(e.created_at):void 0}}function ou(e){return ru(e)}function ru(e,t){return e==null?e:{attachments:I(e,"attachments")?e.attachments.map(Ys):void 0}}function cu(e){if(e!==void 0)return e===null?null:{comment:e.comment}}class du extends ai{async cancellationCustomerCareRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ne("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationCustomerCareRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new ne("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationCustomerCareRequest.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:Hd(t.cancellationTicketsRequest)},i);return new Ne(o,a=>zd(a))}async cancellationCustomerCareRequest(t,i){return await(await this.cancellationCustomerCareRequestRaw(t,i)).value()}async createCustomerCareCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ne("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createCustomerCareComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new ne("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createCustomerCareComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:cu(t.ticketCommentsRequest)},i);return new Ne(o,a=>Kd(a))}async createCustomerCareComment(t,i){return await(await this.createCustomerCareCommentRaw(t,i)).value()}async createCustomerCareTicketRaw(t,i){if(t.customerCareTicketRequest===null||t.customerCareTicketRequest===void 0)throw new ne("customerCareTicketRequest","Required parameter requestParameters.customerCareTicketRequest was null or undefined when calling createCustomerCareTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets",method:"POST",headers:n,query:s,body:Xd(t.customerCareTicketRequest)},i);return new Ne(o,a=>_i(a))}async createCustomerCareTicket(t,i){return await(await this.createCustomerCareTicketRaw(t,i)).value()}async createCustomerCareTicketAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ne("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createCustomerCareTicketAttachment.");if(t.fileName===null||t.fileName===void 0)throw new ne("fileName","Required parameter requestParameters.fileName was null or undefined when calling createCustomerCareTicketAttachment.");if(t.body===null||t.body===void 0)throw new ne("body","Required parameter requestParameters.body was null or undefined when calling createCustomerCareTicketAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new Ne(o,a=>Ys(a))}async createCustomerCareTicketAttachment(t,i){return await(await this.createCustomerCareTicketAttachmentRaw(t,i)).value()}async getCustomerCareCategoriesListRaw(t,i){const s={};t.site!==void 0&&(s.site=t.site),t.accountNumber!==void 0&&(s.account_number=t.accountNumber);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/categories",method:"GET",headers:n,query:s},i);return new Ne(o,a=>Wd(a))}async getCustomerCareCategoriesList(t={},i){return await(await this.getCustomerCareCategoriesListRaw(t,i)).value()}async getCustomerCareTicketAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ne("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getCustomerCareTicketAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new ne("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getCustomerCareTicketAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}/attachments/file/{attachment_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new Na(o)}async getCustomerCareTicketAttachmentsById(t,i){return await(await this.getCustomerCareTicketAttachmentsByIdRaw(t,i)).value()}async getCustomerCareTicketAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ne("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getCustomerCareTicketAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new Ne(o,a=>ou(a))}async getCustomerCareTicketAttachmentsList(t,i){return await(await this.getCustomerCareTicketAttachmentsListRaw(t,i)).value()}async getCustomerCareTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ne("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getCustomerCareTicketById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new Ne(o,a=>_i(a))}async getCustomerCareTicketById(t,i){return await(await this.getCustomerCareTicketByIdRaw(t,i)).value()}async getCustomerCareTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={},o=await this.request({path:"/customer-care-tickets",method:"GET",headers:n,query:s},i);return new Ne(o,a=>su(a))}async getCustomerCareTickets(t={},i){return await(await this.getCustomerCareTicketsRaw(t,i)).value()}async updateCustomerCareTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ne("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateCustomerCareTicket.");if(t.customerCareTicketUpdateRequest===null||t.customerCareTicketUpdateRequest===void 0)throw new ne("customerCareTicketUpdateRequest","Required parameter requestParameters.customerCareTicketUpdateRequest was null or undefined when calling updateCustomerCareTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:eu(t.customerCareTicketUpdateRequest)},i);return new Ne(o,a=>_i(a))}async updateCustomerCareTicket(t,i){return await(await this.updateCustomerCareTicketRaw(t,i)).value()}}function uu(e){return lu(e)}function lu(e,t){return e==null?e:{requestType:Ge(e,"request_type")?e.request_type:void 0,categories:Ge(e,"categories")?e.categories:void 0}}function mu(e){return pu(e)}function pu(e,t){return e==null?e:{mappedRequestType:Ge(e,"mapped_request_type")?e.mapped_request_type:void 0,canonicalValue:Ge(e,"canonical_value")?e.canonical_value:void 0,mappedValue:Ge(e,"mapped_value")?e.mapped_value:void 0,isActive:Ge(e,"is_active")?e.is_active:void 0}}function hu(e){return vu(e)}function vu(e,t){return e==null?e:{requestType:Ge(e,"request_type")?e.request_type:void 0,categories:Ge(e,"categories")?e.categories.map(mu):void 0}}class gu extends yt{async getRequestTypesAndCategoriesRaw(t,i){if(t.serviceTicketType===null||t.serviceTicketType===void 0)throw new dt("serviceTicketType","Required parameter requestParameters.serviceTicketType was null or undefined when calling getRequestTypesAndCategories.");if(t.accountNumber===null||t.accountNumber===void 0)throw new dt("accountNumber","Required parameter requestParameters.accountNumber was null or undefined when calling getRequestTypesAndCategories.");if(t.site===null||t.site===void 0)throw new dt("site","Required parameter requestParameters.site was null or undefined when calling getRequestTypesAndCategories.");if(t.requestType===null||t.requestType===void 0)throw new dt("requestType","Required parameter requestParameters.requestType was null or undefined when calling getRequestTypesAndCategories.");const s={};t.serviceTicketType!==void 0&&(s.service_ticket_type=t.serviceTicketType),t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.requestType!==void 0&&(s.request_type=t.requestType);const n={},o=await this.request({path:"/categories",method:"GET",headers:n,query:s},i);return new bi(o,a=>a.map(uu))}async getRequestTypesAndCategories(t,i){return await(await this.getRequestTypesAndCategoriesRaw(t,i)).value()}}class wu extends yt{async getRequestTypeCategoryMappingsRaw(t,i){if(t.serviceTicketType===null||t.serviceTicketType===void 0)throw new dt("serviceTicketType","Required parameter requestParameters.serviceTicketType was null or undefined when calling getRequestTypeCategoryMappings.");if(t.serviceManagementSystem===null||t.serviceManagementSystem===void 0)throw new dt("serviceManagementSystem","Required parameter requestParameters.serviceManagementSystem was null or undefined when calling getRequestTypeCategoryMappings.");const s={};t.serviceTicketType!==void 0&&(s.service_ticket_type=t.serviceTicketType),t.serviceManagementSystem!==void 0&&(s.service_management_system=t.serviceManagementSystem),t.siteCode!==void 0&&(s.site_code=t.siteCode);const n={},o=await this.request({path:"/requestTypeCategoryMappings",method:"GET",headers:n,query:s},i);return new bi(o,a=>a.map(hu))}async getRequestTypeCategoryMappings(t,i){return await(await this.getRequestTypeCategoryMappingsRaw(t,i)).value()}}const fu={CustomerEnquiries:"customer_enquiries",RemoteHands:"remote_hands",CustomerCare:"customer_care",TroubleTickets:"trouble_tickets"};class ku extends yt{async getTermsRaw(t,i){if(t.service===null||t.service===void 0)throw new dt("service","Required parameter requestParameters.service was null or undefined when calling getTerms.");const s={},n={},o=await this.request({path:"/{service}/terms".replace("{service}",encodeURIComponent(String(t.service))),method:"GET",headers:n,query:s},i);return this.isJsonMime(o.headers.get("content-type"))?new bi(o):new rc(o)}async getTerms(t,i){return await(await this.getTermsRaw(t,i)).value()}}const yu="https://api.digitalrealty.com".replace(/\/+$/,"");class Xs{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:yu}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Qs}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const Tu=new Xs;class li{constructor(t=Tu){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new _u(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?li.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new Au(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;Ru(r.body)||r.body instanceof URLSearchParams||bu(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}li.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function bu(e){return typeof Blob<"u"&&e instanceof Blob}function Ru(e){return typeof FormData<"u"&&e instanceof FormData}class Au extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class _u extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}function V(e,t){return e[t]!=null}function Qs(e,t=""){return Object.keys(e).map(i=>en(i,e[i],t)).filter(i=>i.length>0).join("&")}function en(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return en(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Qs(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class Iu{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class Su{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}function Cu(e){return Nu(e)}function Nu(e,t){return e==null?e:{id:V(e,"id")?e.id:void 0,name:V(e,"name")?e.name:void 0}}function Pu(e){return qu(e)}function qu(e,t){return e==null?e:{accountNumber:V(e,"account_number")?e.account_number:void 0,accountName:V(e,"account_name")?e.account_name:void 0,ticketId:V(e,"ticket_id")?e.ticket_id:void 0,ticketType:V(e,"ticket_type")?e.ticket_type:void 0,requestType:V(e,"request_type")?e.request_type:void 0,category:V(e,"category")?e.category:void 0,subject:V(e,"subject")?e.subject:void 0,sites:V(e,"sites")?e.sites.map(Cu):void 0,locations:V(e,"locations")?e.locations:void 0,accessRequestedFor:V(e,"access_requested_for")?e.access_requested_for:void 0,status:V(e,"status")?e.status:void 0,cancellationReason:V(e,"cancellation_reason")?e.cancellation_reason:void 0,createdBy:V(e,"created_by")?e.created_by:void 0,createdAt:V(e,"created_at")?new Date(e.created_at):void 0,updatedAt:V(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:V(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function Du(e){return Bu(e)}function Bu(e,t){return e==null?e:{items:V(e,"items")?e.items.map(Pu):void 0,totalCount:V(e,"total_count")?e.total_count:void 0,pageNumber:V(e,"page_number")?e.page_number:void 0,pageSize:V(e,"page_size")?e.page_size:void 0}}class Ou extends li{async downloadServiceTicketsRaw(t,i){const s={};t.$filter!==void 0&&(s.$filter=t.$filter),t.permissionPrivilege!==void 0&&(s.permission_privilege=t.permissionPrivilege);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/service-tickets/file",method:"GET",headers:n,query:s},i);return new Su(o)}async downloadServiceTickets(t={},i){return await(await this.downloadServiceTicketsRaw(t,i)).value()}async getServiceTicketsRaw(t,i){const s={};t.$filter!==void 0&&(s.$filter=t.$filter),t.$orderby!==void 0&&(s.$orderby=t.$orderby),t.$skip!==void 0&&(s.$skip=t.$skip),t.$top!==void 0&&(s.$top=t.$top),t.permissionPrivilege!==void 0&&(s.permission_privilege=t.permissionPrivilege);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/service-tickets",method:"GET",headers:n,query:s},i);return new Iu(o,a=>Du(a))}async getServiceTickets(t={},i){return await(await this.getServiceTicketsRaw(t,i)).value()}}function $u(e){return Eu(e)}function Eu(e,t){return e==null?e:{id:T(e,"id")?e.id:void 0,fileName:T(e,"file_name")?e.file_name:void 0}}function xu(e){return Fu(e)}function Fu(e,t){return e==null?e:{accountNumber:T(e,"account_number")?e.account_number:void 0,accountName:T(e,"account_name")?e.account_name:void 0,id:T(e,"id")?e.id:void 0,status:T(e,"status")?e.status:void 0,cancellationReason:T(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:T(e,"subject")?e.subject:void 0,startDate:T(e,"start_date")?new Date(e.start_date):void 0,endDate:T(e,"end_date")?new Date(e.end_date):void 0,approvalStatus:T(e,"approval_status")?e.approval_status:void 0,category:T(e,"category")?e.category:void 0,activityType:T(e,"activity_type")?e.activity_type:void 0,activitySubtype:T(e,"activity_subtype")?e.activity_subtype:void 0,activityCategory:T(e,"activity_category")?e.activity_category:void 0,site:T(e,"site")?e.site:void 0,locations:T(e,"locations")?e.locations:void 0,highLevelSummary:T(e,"high_level_summary")?e.high_level_summary:void 0,serviceType:T(e,"service_type")?e.service_type:void 0,riskLevel:T(e,"risk_level")?e.risk_level:void 0,attachments:T(e,"attachments")?e.attachments.map($u):void 0,createdAt:T(e,"created_at")?new Date(e.created_at):void 0,updatedAt:T(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:T(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function Lu(e){return Vu(e)}function Vu(e,t){return e==null?e:{items:T(e,"items")?e.items.map(xu):void 0}}function Uu(e){return Hu(e)}function Hu(e,t){return e==null?e:{id:T(e,"id")?e.id:void 0,fileName:T(e,"file_name")?e.file_name:void 0}}function zu(e){return ju(e)}function ju(e,t){return e==null?e:{accountNumber:T(e,"account_number")?e.account_number:void 0,accountName:T(e,"account_name")?e.account_name:void 0,id:T(e,"id")?e.id:void 0,status:T(e,"status")?e.status:void 0,subject:T(e,"subject")?e.subject:void 0,startDate:T(e,"start_date")?new Date(e.start_date):void 0,endDate:T(e,"end_date")?new Date(e.end_date):void 0,activityType:T(e,"activity_type")?e.activity_type:void 0,site:T(e,"site")?e.site:void 0,locations:T(e,"locations")?e.locations:void 0,notificationType:T(e,"notification_type")?e.notification_type:void 0,riskLevel:T(e,"risk_level")?e.risk_level:void 0,attachments:T(e,"attachments")?e.attachments.map(Uu):void 0,createdAt:T(e,"created_at")?new Date(e.created_at):void 0,updatedAt:T(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:T(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function Mu(e){return Ju(e)}function Ju(e,t){return e==null?e:{items:T(e,"items")?e.items.map(zu):void 0,totalCount:T(e,"total_count")?e.total_count:void 0,pageNumber:T(e,"page_number")?e.page_number:void 0,pageSize:T(e,"page_size")?e.page_size:void 0}}function Wu(e){return Gu(e)}function Gu(e,t){return e==null?e:{id:T(e,"id")?e.id:void 0,fileName:T(e,"file_name")?e.file_name:void 0,fileSize:T(e,"file_size")?e.file_size:void 0,contentType:T(e,"content_type")?e.content_type:void 0,createdBy:T(e,"created_by")?e.created_by:void 0,createdAt:T(e,"created_at")?new Date(e.created_at):void 0}}function Zu(e){return Ku(e)}function Ku(e,t){return e==null?e:{attachments:T(e,"attachments")?e.attachments.map(Wu):void 0}}class Yu extends ri{async downloadPlannedMaintenanceTicketsRaw(t,i){const s={};t.$filter!==void 0&&(s.$filter=t.$filter),t.$orderby!==void 0&&(s.$orderby=t.$orderby),t.$skip!==void 0&&(s.$skip=t.$skip),t.$top!==void 0&&(s.$top=t.$top);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/planned-maintenances/file",method:"GET",headers:n,query:s},i);return new Os(o)}async downloadPlannedMaintenanceTickets(t={},i){return await(await this.downloadPlannedMaintenanceTicketsRaw(t,i)).value()}async getPlannedMaintenanceAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new Zt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPlannedMaintenanceAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new Zt("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getPlannedMaintenanceAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/planned-maintenances/{ticket_id}/attachments/file/{attachment_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new Os(o)}async getPlannedMaintenanceAttachmentsById(t,i){return await(await this.getPlannedMaintenanceAttachmentsByIdRaw(t,i)).value()}async getPlannedMaintenanceAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new Zt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPlannedMaintenanceAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/planned-maintenances/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new Ai(o,a=>Zu(a))}async getPlannedMaintenanceAttachmentsList(t,i){return await(await this.getPlannedMaintenanceAttachmentsListRaw(t,i)).value()}async getPlannedMaintenanceTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new Zt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPlannedMaintenanceTicketById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/planned-maintenances/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new Ai(o,a=>Lu(a))}async getPlannedMaintenanceTicketById(t,i){return await(await this.getPlannedMaintenanceTicketByIdRaw(t,i)).value()}async getPlannedMaintenanceTicketsRaw(t,i){const s={};t.$filter!==void 0&&(s.$filter=t.$filter),t.$orderby!==void 0&&(s.$orderby=t.$orderby),t.$skip!==void 0&&(s.$skip=t.$skip),t.$top!==void 0&&(s.$top=t.$top);const n={},o=await this.request({path:"/planned-maintenances",method:"GET",headers:n,query:s},i);return new Ai(o,a=>Mu(a))}async getPlannedMaintenanceTickets(t={},i){return await(await this.getPlannedMaintenanceTicketsRaw(t,i)).value()}}function Xu(e){return Qu(e)}function Qu(e,t){return e==null?e:{en:qe(e,"en")?e.en:void 0,fr:qe(e,"fr")?e.fr:void 0,de:qe(e,"de")?e.de:void 0,es:qe(e,"es")?e.es:void 0}}function el(e){return tl(e)}function tl(e,t){return e}function il(e){return sl(e)}function sl(e,t){return e}const Yt={ServiceNow:"ServiceNow",InSite:"InSite",TelxSfdc:"TelxSFDC"};function nl(e){return al(e)}function al(e,t){return e}function ol(e){return rl(e)}function rl(e,t){return e==null?e:{process:qe(e,"process")?il(e.process):void 0,site:qe(e,"site")?e.site:void 0,serviceManagementSystem:qe(e,"serviceManagementSystem")?nl(e.serviceManagementSystem):void 0,destinationUrls:qe(e,"destinationUrls")?Xu(e.destinationUrls):void 0,portal:qe(e,"portal")?el(e.portal):void 0}}class cl extends di{async getSiteNavigationRaw(t,i){if(t.accountNumber===null||t.accountNumber===void 0)throw new Hs("accountNumber","Required parameter requestParameters.accountNumber was null or undefined when calling getSiteNavigation.");if(t.site===null||t.site===void 0)throw new Hs("site","Required parameter requestParameters.site was null or undefined when calling getSiteNavigation.");const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.process!==void 0&&(s.process=t.process);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("bearerToken",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/site-configurations",method:"GET",headers:n,query:s},i);return new $d(o,a=>a.map(ol))}async getSiteNavigation(t,i){return await(await this.getSiteNavigationRaw(t,i)).value()}}const dl="http://localhost".replace(/\/+$/,"");class tn{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:dl}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||sn}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const ul=new tn;class mi{constructor(t=ul){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new hl(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?mi.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new pl(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;ml(r.body)||r.body instanceof URLSearchParams||ll(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}mi.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function ll(e){return typeof Blob<"u"&&e instanceof Blob}function ml(e){return typeof FormData<"u"&&e instanceof FormData}class pl extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class hl extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class te extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function R(e,t){return e[t]!=null}function sn(e,t=""){return Object.keys(e).map(i=>nn(i,e[i],t)).filter(i=>i.length>0).join("&")}function nn(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return nn(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?sn(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class De{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class vl{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}function gl(e){if(e!==void 0)return e===null?null:{cancellationReason:e.cancellationReason}}function wl(e){return fl(e)}function fl(e,t){return e==null?e:{message:R(e,"message")?e.message:void 0}}function kl(e){return yl(e)}function yl(e,t){return e==null?e:{requestType:R(e,"request_type")?e.request_type:void 0,categories:R(e,"categories")?e.categories:void 0}}function Tl(e){return bl(e)}function bl(e,t){return e==null?e:{items:R(e,"items")?e.items.map(kl):void 0}}function an(e){return Rl(e)}function Rl(e,t){return e==null?e:{createdBy:R(e,"created_by")?e.created_by:void 0,createdAt:R(e,"created_at")?new Date(e.created_at):void 0,comment:R(e,"comment")?e.comment:void 0}}function Al(e){return _l(e)}function _l(e,t){return e==null?e:{comments:R(e,"comments")?e.comments.map(an):void 0}}function on(e){return Il(e)}function Il(e,t){return e==null?e:{id:R(e,"id")?e.id:void 0,fileName:R(e,"file_name")?e.file_name:void 0,fileSize:R(e,"file_size")?e.file_size:void 0,contentType:R(e,"content_type")?e.content_type:void 0,createdBy:R(e,"created_by")?e.created_by:void 0,createdAt:R(e,"created_at")?new Date(e.created_at):void 0}}function Sl(e){return Cl(e)}function Cl(e,t){return e==null?e:{attachments:R(e,"attachments")?e.attachments.map(on):void 0}}function Nl(e){if(e!==void 0)return e===null?null:{comment:e.comment}}function Pl(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,subject:e.subject,request_type:e.requestType,category:e.category,locations:e.locations,circuit_id:e.circuitId,customer_reference:e.customerReference,description:e.description,notification_recipients:e.notificationRecipients}}function Ii(e){return ql(e)}function ql(e,t){return e==null?e:{ticketNumber:R(e,"ticket_number")?e.ticket_number:void 0,accountNumber:R(e,"account_number")?e.account_number:void 0,accountName:R(e,"account_name")?e.account_name:void 0,id:R(e,"id")?e.id:void 0,status:R(e,"status")?e.status:void 0,cancellationReason:R(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:R(e,"subject")?e.subject:void 0,requestType:R(e,"request_type")?e.request_type:void 0,category:R(e,"category")?e.category:void 0,site:R(e,"site")?e.site:void 0,locations:R(e,"locations")?e.locations:void 0,circuitId:R(e,"circuit_id")?e.circuit_id:void 0,customerReference:R(e,"customer_reference")?e.customer_reference:void 0,description:R(e,"description")?e.description:void 0,notificationRecipients:R(e,"notification_recipients")?e.notification_recipients:void 0,createdBy:R(e,"created_by")?e.created_by:void 0,createdAt:R(e,"created_at")?new Date(e.created_at):void 0,updatedAt:R(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:R(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0,comments:R(e,"comments")?e.comments.map(an):void 0}}function Dl(e){if(e!==void 0)return e===null?null:{subject:e.subject,description:e.description,circuit_id:e.circuitId,customer_reference:e.customerReference,other_notification_recipients:e.otherNotificationRecipients}}function Bl(e){return Ol(e)}function Ol(e,t){return e==null?e:{accountNumber:R(e,"account_number")?e.account_number:void 0,accountName:R(e,"account_name")?e.account_name:void 0,id:R(e,"id")?e.id:void 0,status:R(e,"status")?e.status:void 0,subject:R(e,"subject")?e.subject:void 0,site:R(e,"site")?e.site:void 0,locations:R(e,"locations")?e.locations:void 0,description:R(e,"description")?e.description:void 0,createdBy:R(e,"created_by")?e.created_by:void 0,createdAt:R(e,"created_at")?new Date(e.created_at):void 0,updatedAt:R(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:R(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function $l(e){return El(e)}function El(e,t){return e==null?e:{items:R(e,"items")?e.items.map(Bl):void 0,totalCount:R(e,"total_count")?e.total_count:void 0,pageNumber:R(e,"page_number")?e.page_number:void 0,pageSize:R(e,"page_size")?e.page_size:void 0}}class xl extends mi{async cancellationTroubleTicketRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationTroubleTicketRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new te("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationTroubleTicketRequest.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:gl(t.cancellationTicketsRequest)},i);return new De(o,a=>wl(a))}async cancellationTroubleTicketRequest(t,i){return await(await this.cancellationTroubleTicketRequestRaw(t,i)).value()}async createTroubleTicketAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createTroubleTicketAttachment.");if(t.fileName===null||t.fileName===void 0)throw new te("fileName","Required parameter requestParameters.fileName was null or undefined when calling createTroubleTicketAttachment.");if(t.body===null||t.body===void 0)throw new te("body","Required parameter requestParameters.body was null or undefined when calling createTroubleTicketAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new De(o,a=>on(a))}async createTroubleTicketAttachment(t,i){return await(await this.createTroubleTicketAttachmentRaw(t,i)).value()}async createTroubleTicketCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createTroubleTicketComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new te("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createTroubleTicketComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:Nl(t.ticketCommentsRequest)},i);return new De(o,a=>Al(a))}async createTroubleTicketComment(t,i){return await(await this.createTroubleTicketCommentRaw(t,i)).value()}async createTroubleTicketTicketRaw(t,i){if(t.troubleTicketRequest===null||t.troubleTicketRequest===void 0)throw new te("troubleTicketRequest","Required parameter requestParameters.troubleTicketRequest was null or undefined when calling createTroubleTicketTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets",method:"POST",headers:n,query:s,body:Pl(t.troubleTicketRequest)},i);return new De(o,a=>Ii(a))}async createTroubleTicketTicket(t,i){return await(await this.createTroubleTicketTicketRaw(t,i)).value()}async getTroubleTicketAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getTroubleTicketAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new te("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getTroubleTicketAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}/attachments/file/{attachment_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new vl(o)}async getTroubleTicketAttachmentsById(t,i){return await(await this.getTroubleTicketAttachmentsByIdRaw(t,i)).value()}async getTroubleTicketAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getTroubleTicketAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new De(o,a=>Sl(a))}async getTroubleTicketAttachmentsList(t,i){return await(await this.getTroubleTicketAttachmentsListRaw(t,i)).value()}async getTroubleTicketTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getTroubleTicketTicketById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new De(o,a=>Ii(a))}async getTroubleTicketTicketById(t,i){return await(await this.getTroubleTicketTicketByIdRaw(t,i)).value()}async getTroubleTicketTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={},o=await this.request({path:"/trouble-tickets",method:"GET",headers:n,query:s},i);return new De(o,a=>$l(a))}async getTroubleTicketTickets(t={},i){return await(await this.getTroubleTicketTicketsRaw(t,i)).value()}async getTroubleTicketsCategoriesListRaw(t,i){if(t.site===null||t.site===void 0)throw new te("site","Required parameter requestParameters.site was null or undefined when calling getTroubleTicketsCategoriesList.");const s={};t.site!==void 0&&(s.site=t.site);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/categories",method:"GET",headers:n,query:s},i);return new De(o,a=>Tl(a))}async getTroubleTicketsCategoriesList(t,i){return await(await this.getTroubleTicketsCategoriesListRaw(t,i)).value()}async updateTroubleTicketTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateTroubleTicketTicket.");if(t.troubleTicketUpdateRequest===null||t.troubleTicketUpdateRequest===void 0)throw new te("troubleTicketUpdateRequest","Required parameter requestParameters.troubleTicketUpdateRequest was null or undefined when calling updateTroubleTicketTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:Dl(t.troubleTicketUpdateRequest)},i);return new De(o,a=>Ii(a))}async updateTroubleTicketTicket(t,i){return await(await this.updateTroubleTicketTicketRaw(t,i)).value()}}function Fl(e){return Ll(e)}function Ll(e,t){return e==null?e:{id:e.id,name:e.name,isNonLocation:e.is_non_location,category:Js(e,"category")?e.category:void 0,privileges:e.privileges,isInternal:e.is_internal}}function Vl(e){return Ul(e)}function Ul(e,t){return e==null?e:{accountNumber:e.account_number,permissionName:e.permission_name,privilege:e.privilege,isNonLocation:Js(e,"is_non_location")?e.is_non_location:void 0,permissionIsInternal:e.permission_is_internal}}class Hl extends ui{async getPermissionsRaw(t){const i={},s={};this.configuration&&this.configuration.accessToken&&(s.Authorization=await this.configuration.accessToken("oAuth2",[]));const n=await this.request({path:"/permissions",method:"GET",headers:s,query:i},t);return new Zs(n,o=>o.map(Fl))}async getPermissions(t){return await(await this.getPermissionsRaw(t)).value()}async getUserPermissionsRaw(t,i){const s={};t.excludeSiblings!==void 0&&(s.exclude_siblings=t.excludeSiblings),t.excludeParents!==void 0&&(s.exclude_parents=t.excludeParents);const n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const o=await this.request({path:"/my-permissions",method:"GET",headers:n,query:s},i);return new Zs(o,a=>a.map(Vl))}async getUserPermissions(t={},i){return await(await this.getUserPermissionsRaw(t,i)).value()}}const z={CustomerCare:"sm-customer-care",DeliveriesRemovals:"sm-deliveries",References:"sm-references",RemoteHands:"sm-remote-hands",TroubleTickets:"sm-trouble-tickets",FacilityAccess:"sm-facility-access",ServiceTickets:"sm-service-tickets",SiteMaintenance:"sm-site-maintenance",Incidents:"sm-incidents",Inventory:"inventory",SiteNavigation:"site-navigations",UserManagement:"usermanagement"},F={Site:"Site",Floor:"Floor",Room:"Room",Cabinet:"Cabinet",Cage:"Cage"},U={Read:"Read",Update:"Update",Delete:"Delete",Create:"Create",Approve:"Approve"},zl={READ:1,UPDATE:2,DELETE:4,CREATE:8,APPROVE:16};var Si;(function(e){e.Security="Security",e.DCIM="DCIM",e.PlannedSiteMaintenance="Planned Site Maintenance"})(Si||(Si={}));const S={RemoteHands:"Remote Hands",TroubleTickets:"Trouble Ticket",DeliveriesRemovals:"Shipping & Receiving",VisitorAccess:"Visitor Access",CustomerCare:"Customer Support",PermanentBadge:"Permanent Badge",OSPAccess:"OSP Access",POPPOEAccess:"POP/POE Room Access",PlannedMaintenance:"Planned Site Maintenance"},jl={Duplicate:"Duplicate request",Error:"Request entered in error",NotNeeded:"Request no longer needed"},Ml={Delivery:"Delivery",Removal:"Removal",TroubleTicket:"Trouble Ticket",FacilityAccess:"Facility Access",RemoteHands:"Remote Hands",VisitorAccess:"Visitor Access",PermanentBadge:"Permanent Badge"},ut={GreaterThan:"gt:",GreaterOrEqual:"ge:",LessThan:"lt:",LessThanOrEqual:"le:"},Jl=10,Wl="permission_privilege";class Gl{constructor(t){this.configuration=t}get customerCareApi(){return new du(new Zi({basePath:`${this.configuration.SMApiUrl}/${z.CustomerCare}`,headers:{Authorization:this.getAuthorization()}}))}get courierCompaniesApi(){return new $a(new Et({basePath:`${this.configuration.SMApiUrl}/${z.DeliveriesRemovals}`,headers:{Authorization:this.getAuthorization()}}))}get deliveriesApi(){return new no(new Et({basePath:`${this.configuration.SMApiUrl}/${z.DeliveriesRemovals}`,headers:{Authorization:this.getAuthorization()}}))}get removalsApi(){return new ao(new Et({basePath:`${this.configuration.SMApiUrl}/${z.DeliveriesRemovals}`,headers:{Authorization:this.getAuthorization()}}))}get remoteHandsApi(){return new Ec(new As({basePath:`${this.configuration.SMApiUrl}/${z.RemoteHands}`,headers:{Authorization:this.getAuthorization()}}))}get troubleTicketsApi(){return new xl(new tn({basePath:`${this.configuration.SMApiUrl}/${z.TroubleTickets}`,headers:{Authorization:this.getAuthorization()}}))}get facilityAccessApi(){return{visitorAccess:new Wr(new pt({basePath:`${this.configuration.SMApiUrl}/${z.FacilityAccess}`,headers:{Authorization:this.getAuthorization()}})),visitorHost:new Gr(new pt({basePath:`${this.configuration.SMApiUrl}/${z.FacilityAccess}`,headers:{Authorization:this.getAuthorization()}})),permanentBadgeAccess:new Jr(new pt({basePath:`${this.configuration.SMApiUrl}/${z.FacilityAccess}`,headers:{Authorization:this.getAuthorization()}})),ospAccess:new jr(new pt({basePath:`${this.configuration.SMApiUrl}/${z.FacilityAccess}`,headers:{Authorization:this.getAuthorization()}})),popAccess:new Mr(new pt({basePath:`${this.configuration.SMApiUrl}/${z.FacilityAccess}`,headers:{Authorization:this.getAuthorization()}}))}}get serviceTicketApi(){return new Ou(new Xs({basePath:`${this.configuration.SMApiUrl}/${z.ServiceTickets}`,headers:{Authorization:this.getAuthorization()}}))}get inventoryApi(){return{locations:new ed(new Wt({basePath:`${this.configuration.SMApiUrl}/${z.Inventory}`,headers:{Authorization:this.getAuthorization()}})),sites:new Ps(new Wt({basePath:`${this.configuration.SMApiUrl}/${z.Inventory}`,headers:{Authorization:this.getAuthorization()}}))}}get sitesApi(){return new Ps(new Wt({basePath:`${this.configuration.SMApiUrl}/${z.Inventory}`,headers:{Authorization:this.getAuthorization()}}))}get siteNavigationApi(){return new cl(new Us({basePath:`${this.configuration.SMApiUrl}/${z.SiteNavigation}`,headers:{Authorization:this.getAuthorization()}}))}get plannedMaintenanceApi(){return new Yu(new qs({basePath:`${this.configuration.SMApiUrl}/${z.SiteMaintenance}`,headers:{Authorization:this.getAuthorization()}}))}get incidentsApi(){return new Cd(new $s({basePath:`${this.configuration.SMApiUrl}/${z.Incidents}`,headers:{Authorization:this.getAuthorization()}}))}get userPermissionsApi(){return new Hl(new Ms({basePath:`${this.configuration.SMApiUrl}/${z.UserManagement}`,headers:{Authorization:this.getAuthorization()}}))}getAuthorizationToken(){return this.getAuthorization()}get referencesApi(){return{categories:new gu(new Gt({basePath:`${this.configuration.SMApiUrl}/${z.References}`,headers:{Authorization:this.getAuthorization(),"cache-control":"no-cache"}})),requestTypeCategoryMappings:new wu(new Gt({basePath:`${this.configuration.SMApiUrl}/${z.References}`,headers:{Authorization:this.getAuthorization(),"cache-control":"no-cache"}})),terms:new ku(new Gt({basePath:`${this.configuration.SMApiUrl}/sm-references`,headers:{Authorization:this.getAuthorization(),"cache-control":"no-cache"}}))}}getAuthorization(){return this.configuration.getAuthorizationFn?this.configuration.getAuthorizationFn():""}}class Zl extends la{constructor(t,i){super({...t}),this.hashed_identifier=i}}class Kl{constructor(t,i){this.name=t,this.accountNumber=i}}class Qe{constructor({loginAuthority:t,clientId:i,scope:s,postLogoutRedirectUri:n,userStorageKey:o="user-authentication",redirectUrlKey:a="redirect-url",authPaths:r={authenticate:"authenticate",authCallback:"auth-callback",logout:"logout"}}){this.getHashedRootAccountNumberAndUserEmail=async()=>{const A=ot.getAccountHierarchy(),N=await Qe.hashValue(ot===null||ot===void 0?void 0:ot.email);let b=await Qe.hashValue(ot===null||ot===void 0?void 0:ot.account_number);return A&&(b=await Qe.hashValue(A==null?void 0:A.accountNumber)),`${b}-${N}`},this.configuration={loginAuthority:t,clientId:i,scope:s,postLogoutRedirectUri:n,userStorageKey:o,redirectUrlKey:a,authPaths:r};const{location:d}=window,u=`${d.protocol}//${d.hostname}${d.port?`:${d.port}`:""}`,p={authority:this.configuration.loginAuthority,client_id:this.configuration.clientId,redirect_uri:`${u}/${this.configuration.authPaths.authCallback}`,response_type:"code",scope:this.configuration.scope,post_logout_redirect_uri:this.configuration.postLogoutRedirectUri,loadUserInfo:!0};this.userManager=new ma(p)}isLoggedIn(){const t=this.getUser();if(t===null)return!1;if(!t.expires_at)return!0;const i=new Date,s=new Date(t.expires_at*1e3);return i<s}redirectToAuth(t=!1){const i=this.isAuthenticating();(t||!i)&&(i||localStorage.setItem(this.configuration.redirectUrlKey,window.location.href),rt.go(`/${this.configuration.authPaths.authenticate}`))}isAuthenticating(){const t=window.location.pathname.split("/");return t[t.length-1]===this.configuration.authPaths.authenticate?(this.userManager.signinRedirect(),!0):!1}isHandlingAuthCallback(){const t=window.location.pathname.split("/");return t[t.length-1]===this.configuration.authPaths.authCallback?(this.userManager.signinRedirectCallback().then(Qe.ensureValidUser).then(Qe.addHashedIdToUserProfile).then(i=>this.saveUser(i)).then(()=>this.authSuccessRedirect()).catch(()=>this.redirectToAuth()),!0):!1}authSuccessRedirect(){let t="/";const i=localStorage.getItem(this.configuration.redirectUrlKey);i&&(localStorage.removeItem(this.configuration.redirectUrlKey),t=i),rt.go(t)}redirectToLogout(){this.isHandlingLogout()||rt.go(`/${this.configuration.authPaths.logout}`)}isHandlingLogout(){const t=window.location.pathname.split("/");return t[t.length-1]===this.configuration.authPaths.logout?(this.clearUser(),window.localStorage.clear(),this.userManager.signoutRedirect({id_token_hint:this.getIdToken()}),!0):!1}isProcessing(){return this.isAuthenticating()||this.isHandlingAuthCallback()||this.isHandlingLogout()}saveUser(t){localStorage.setItem(this.configuration.userStorageKey,JSON.stringify(t))}clearUser(){localStorage.removeItem(this.configuration.userStorageKey)}getUser(){const t=localStorage.getItem(this.configuration.userStorageKey);return t?JSON.parse(t):null}getUserProfileSub(){var t;const i=this.getUser();return(t=i==null?void 0:i.profile)===null||t===void 0?void 0:t.sub}getUserLocale(){var t;const i=this.getUser();return(t=i==null?void 0:i.profile)===null||t===void 0?void 0:t.locale}getHashedIdentifer(){var t;return(t=this.getUser())===null||t===void 0?void 0:t.hashed_identifier}getIdToken(){var t;return(t=this.getUser())===null||t===void 0?void 0:t.id_token}getAccessToken(){var t;return(t=this.getUser())===null||t===void 0?void 0:t.access_token}getAuthorization(){var t,i;return`${(t=this.getUser())===null||t===void 0?void 0:t.token_type} ${(i=this.getUser())===null||i===void 0?void 0:i.access_token}`}getUserAccount(){var t,i,s,n;return new Kl((i=(t=this.getUser())===null||t===void 0?void 0:t.profile)===null||i===void 0?void 0:i.account_name,(n=(s=this.getUser())===null||s===void 0?void 0:s.profile)===null||n===void 0?void 0:n.account_number)}getUserEmail(){var t,i;return(i=(t=this.getUser())===null||t===void 0?void 0:t.profile)===null||i===void 0?void 0:i.email}getAccountNumber(){var t,i;return(i=(t=this.getUser())===null||t===void 0?void 0:t.profile)===null||i===void 0?void 0:i.account_number}static async hashValue(t){const i=new TextEncoder().encode(t),s=await crypto.subtle.digest("SHA-256",i);return Array.from(new Uint8Array(s)).map(n=>n.toString(16).padStart(2,"0")).join("")}static async addHashedIdToUserProfile(t){const i=`${t.profile.sub}-${t.profile.customer_id}`,s=await Qe.hashValue(i);return new Zl(t,s)}static ensureValidUser(t){if(!t.id_token)throw new Error("Missing property:id_token");return t}}function ke(){var e;const t=(e=window.gpConfig)===null||e===void 0?void 0:e["ui-service-management"];if(!t)throw new Error("ui-service-management config not loaded. Ensure config.json is fetched before app bootstrap.");return t}const Xt=ke(),ae=new Qe({loginAuthority:Xt.LoginAuthority,clientId:Xt.ServiceManagementUIClientId,scope:Xt.ServiceManagementUIScopes}),m=new Gl({SMApiUrl:Xt.SMApiUrl,getAuthorizationFn:()=>`Bearer ${ae.getAccessToken()}`}),rn="no instructions provided",Ci=" [Special Instructions] ",gt="Other",cn="Digital Realty",Yl="Interxion",dn=5;class Xl{constructor(){this.couriers={},this.sites=[],this.removalParties=[],this.requestTypeCategoriesDict={},this.termsLookup={[Q.Deliveries]:"",[Q.FacilityAccess]:"",[Q.TroubleTickets]:"",[Q.RemoteHands]:""},se(this),Je(this,{name:"lookups",properties:["couriers","sites","removalParties","requestTypeCategoriesDict","termsLookup"],storage:window.sessionStorage})}getCouriers(t,i){var s;const n=(s=this.couriers[t])!==null&&s!==void 0?s:[];return i?[...n,gt]:n}async fillCouriers(t,i,s){!t||!i||!s||this.couriers[s]||(this.couriers[s]=await m.courierCompaniesApi.getCourierBySite({accountNumber:i,site:t}))}async fillSites(){const t={pageSize:1e3};this.sites=await Gi(t,i=>m.inventoryApi.sites.getSites(i))}async getRequestCategories(t,i,s){const n=`${t}-${i}`;if(this.requestTypeCategoriesDict[n]&&!s)return this.requestTypeCategoriesDict[n];const o=(await m.referencesApi.requestTypeCategoryMappings.getRequestTypeCategoryMappings({serviceTicketType:i,serviceManagementSystem:t,siteCode:s})).filter(a=>{var r;return(r=a.categories)===null||r===void 0?void 0:r.some(d=>d.isActive)});return this.requestTypeCategoriesDict[n]=Object.fromEntries(o.map(a=>{var r;return[a.requestType,(r=a.categories)===null||r===void 0?void 0:r.filter(d=>d.isActive).map(d=>d.canonicalValue)]})),this.requestTypeCategoriesDict[n]}async fillRemovalParties(){this.removalParties=await m.removalsApi.getRemovalParties()}async fillLookups(){await Promise.all([this.fillRemovalParties(),this.fillTerms(),this.fillSites()])}async fillTerms(){const t=async i=>{await m.referencesApi.terms.getTerms({service:i}).then(s=>{this.termsLookup[i]=s})};await Promise.all([t(Q.Deliveries),t(Q.TroubleTickets),t(Q.RemoteHands),t(Q.FacilityAccess)])}clear(){this.couriers={},this.sites=[],this.removalParties=[],this.requestTypeCategoriesDict={},this.termsLookup={[Q.Deliveries]:"",[Q.FacilityAccess]:"",[Q.TroubleTickets]:"",[Q.RemoteHands]:""}}}const J=new Xl;function St(e){return new Date(e).toISOString().split("T")[0]}const un=()=>{var e;const t=localStorage.getItem("date-format");return t&&((e=JSON.parse(t))===null||e===void 0?void 0:e.preferredTimezone)||he.tz.guess()},Be=(e,t,i)=>{var s,n;if(!e||!t)return;const o=`${e} ${t}`,a=(n=(s=J.sites)===null||s===void 0?void 0:s.find(r=>r.id===i))===null||n===void 0?void 0:n.timeZone;return(a?he.tz(o,a):he.utc(o)).utc().toDate()};function Ql(e,t=un()){const i=he.tz(e,t).startOf("day").toDate(),s=he.tz(e,t).endOf("day").toDate();return{startOfDayLocal:i,endOfDayLocal:s}}const em=()=>he.utc().tz(un()).startOf("day").format("YYYY-MM-DD"),tm=(e,t)=>(t?he.tz(t):he.utc()).add(e,"days").format("YYYY-MM-DD"),Z=e=>{if(e)return new Date(e)},im=()=>{var e;const t=localStorage.getItem("date-format");return t&&((e=JSON.parse(t))===null||e===void 0?void 0:e.preferredDateFormat)||"yyyy-MM-dd"};St(new Date);const sm=bt`.header-container{display:flex;align-items:center;gap:20px}.header__title{margin:0;font-family:var(--root-secondary-font);font-style:normal;font-weight:700;font-size:34px;line-height:40px;letter-spacing:.35px;color:#092241;flex-grow:1}.header__profile{background-color:#092241;height:35px;border-radius:10px;color:#fff;padding-left:20px;padding-right:20px;display:flex;align-items:center;font-size:14px}.header__logout{height:35px;border-radius:10px;border:none;background-color:#1456e0;color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;padding-left:15px;padding-right:15px}.header__logout svg{width:1em;height:1em;font-size:20px;margin-right:5px}.header__accounts{width:200px;--md-outlined-field-top-space:5px;--md-outlined-field-bottom-space:5px}@media only screen and (min-width:5px) and (max-width:500px){.header-container{flex-direction:column}}@media only screen and (min-width:500px) and (max-width:1250px){.header-container{flex-direction:row}}`,L={ErrorRaised:"sm:error-raised",DrawerClose:"drawer-close",CreateTicket:"create-ticket",CancelTicket:"cancel-ticket",EditTicket:"edit-ticket",ApproveDenyTicket:"approve-deny-ticket"};class Oe{constructor(t,i,s){var n,o;this.id=t,this.siteId=i,this.accountNumber=s;const a=J.sites.find(r=>r.id===this.siteId);a?this.displayName=`${a==null?void 0:a.name} - ${a==null?void 0:a.streetAddress}`:this.displayName=(o=(n=this.id)!==null&&n!==void 0?n:this.siteId)!==null&&o!==void 0?o:""}}async function nm(e){if(!e)return"";const t=J.sites.find(i=>i.locationId===e);return t?`${t.name} - ${t.streetAddress}`:e}async function am(e){if(!e)return"";const t=J.sites.find(i=>i.id===e);return t?`${t.name} - ${t.streetAddress}`:e}async function om(e){const t=J.sites.find(i=>i.id===e);return t==null?void 0:t.locationId}const ln=(e,t,i)=>{e.dispatchEvent(new CustomEvent(t,{detail:i,bubbles:!0,composed:!0}))},rm=e=>ln(document,L.ErrorRaised,e),l=async(e,t=!0)=>{let i="An error occurred";if(e instanceof Xi&&e.response.status===400)try{const{detail:s}=await e.response.json();i=s}catch(s){console.error(e)}else console.error(e);t&&rm(i)},cm=e=>{window.dispatchEvent(new CustomEvent("add-toast",{detail:{id:"error-toast",content:g`<ix-message-toast forceClose="false" toastId="error-toast" type="error">${e} </ix-message-toast>`,vertical:"bottom",horizontal:"center",animated:!0,above:!1}}))};class dm{constructor(){se(this),Je(this,{name:"locations",properties:[],storage:window.localStorage})}async getLocations(t,i){var s;let n=[],o={...t,sort:t.sort||"+id"};const a=r=>m.inventoryApi.locations.getLocations(r).catch(d=>{l(d,!1)});if(i!=null&&i.onlyLoadFirstPage){const r=await a(o);n=(s=r==null?void 0:r.items)!==null&&s!==void 0?s:[]}else n=await Gi(o,a);return n.sort((r,d)=>r.id.localeCompare(d.id))}async getOspsBySiteId(t){try{const i=await m.inventoryApi.sites.getOspsBySiteId({siteId:t});return i!=null?i:[]}catch(i){return[]}}async getPopsBySiteId(t){try{const i=await m.inventoryApi.sites.getPopsBySiteId({siteId:t});return i!=null?i:[]}catch(i){return[]}}}const le=new dm;class um{constructor(){this.isHideLocationDatesEnabled=()=>{const t=ke()["SM:HideLocationDates"];return typeof t=="boolean"?t:!1},this.showNewDatePickerComponent=()=>{const t=ke()["SM:UseNewDatePicker"];return typeof t=="boolean"?t:!1},this.isOspEnabled=()=>{const t=ke()["SM:ShowOspAccess"];return typeof t=="boolean"?t:!1},this.isPopPoeEnabled=()=>{const t=ke()["SM:ShowPopPoeAccess"];return typeof t=="boolean"?t:!1},this.isIncidentsEnabled=()=>{const t=ke()["SM:IncidentsEnabled"];return typeof t=="boolean"?t:!1},this.isCustomerCarePopWhitelistEnabled=()=>{const t=ke()["SM:CustomerCarePopWhitelistEnabled"];return typeof t=="boolean"?t:!1},this.customerCarePopWhitelist=()=>{const t=ke()["SM:CustomerCarePopWhitelist"];return typeof t=="string"?t:""}}}const wt=new um,Ct=`${F.Floor},${F.Room},${F.Cabinet},${F.Cage}`;function mn(e){return e===S.VisitorAccess||e===S.PermanentBadge}function lm(e){return e===S.RemoteHands||e===S.TroubleTickets||e===S.VisitorAccess||e===S.PermanentBadge||e===S.CustomerCare||e===S.OSPAccess||e===S.POPPOEAccess}async function Ze(e){var t;const i=await le.getLocations({...e,pageSize:100});return(t=[...new Map(i.map(s=>[s.siteId,s])).values()].map(s=>new Oe(void 0,s.siteId,s.accountNumber)))!==null&&t!==void 0?t:[]}async function mm(e,t,i,s){let n=[];const o=lm(t);let a=ut.GreaterThan+F.Site;o?mn(t)&&(a=Ct):a=F.Site;let r=await le.getLocations({locationType:a,permissionType:t,permissionPrivilege:e,pageSize:100,accountNumber:s,assignableProcess:i});return o?(r=[...new Map(r.map(d=>[d.siteId,d])).values()],n=r.map(d=>new Oe(d.siteId,d.siteId,d.accountNumber))):n=r.map(d=>new Oe(d.id,d.siteId,d.accountNumber)),n!=null?n:[]}async function pm(e,t){const i=await le.getLocations({locationType:F.Site,permissionType:t,permissionPrivilege:e,pageSize:100}),s=[...new Set(i.map(n=>n.accountNumber))];return s!=null?s:[]}async function hm(e,t,i,s,n){let o=ut.GreaterThan+F.Site;return mn(t)&&(o=Ct),await le.getLocations({permissionType:t,locationType:o,permissionPrivilege:e,siteId:s,pageSize:100,accountNumber:n,assignableProcess:i})}async function Nt(e,t,i,s){const n=await le.getLocations({permissionType:t,permissionPrivilege:e,id:i,accountNumber:s,pageSize:1},{onlyLoadFirstPage:!0});return(n==null?void 0:n.length)>0}async function $e(e,t,i,s){return(await le.getLocations({permissionPrivilege:t,pageSize:1,permissionType:e,assignableProcess:i,locationType:s},{onlyLoadFirstPage:!0})).length>0}async function Ke(e,t,i){return(await le.getLocations({permissionPrivilege:i,pageSize:100,permissionType:t})).some(s=>e.includes(s.id))}async function pn(e){var t;if(!e)return;const i=await le.getLocations({id:e,pageSize:1},{onlyLoadFirstPage:!0});return(t=i==null?void 0:i[0])===null||t===void 0?void 0:t.siteId}async function vm(e){var t;if(!e)return;const i=await le.getLocations({siteId:e,locationType:F.Site,pageSize:1},{onlyLoadFirstPage:!0});return(t=i==null?void 0:i[0])===null||t===void 0?void 0:t.id}async function hn(){return $e(S.CustomerCare,U.Create,void 0,F.Site)}async function vn(){return $e(S.VisitorAccess,U.Create,void 0,F.Site)}async function gn(){return $e(S.PermanentBadge,U.Create,void 0,F.Site)}async function wn(){return wt.isOspEnabled()?$e(S.OSPAccess,U.Create,void 0,F.Site):!1}async function fn(){return wt.isPopPoeEnabled()?$e(S.POPPOEAccess,U.Create,void 0,F.Site):!1}async function gm(){return $e(S.DeliveriesRemovals,U.Create)}async function kn(){return(await Promise.all([vn(),gn(),wn(),fn()])).some(e=>e)}async function yn(){return $e(S.RemoteHands,U.Create,void 0,F.Site)}async function Ni(){return gm()}function Tn(){return $e(S.TroubleTickets,U.Create,void 0,F.Site)}async function wm(){return(await Promise.all([hn(),kn(),yn(),Ni(),Tn()])).some(e=>e)}function fm(e){switch(e){case"Visitor Access":return S.VisitorAccess;case"Permanent Badge":return S.PermanentBadge;case"OSP Access":return S.OSPAccess;case"PoP/POE Access":return S.POPPOEAccess;default:return}}async function bn(e){if(e===void 0)return!1;const t=await pn(e);return t?(await le.getLocations({siteId:t,permissionType:S.OSPAccess,locationType:ut.GreaterOrEqual+F.Site,permissionPrivilege:U.Update,pageSize:100,assignableProcess:"OSP_access"})).some(i=>i.siteId===t):!1}async function Rn(e){if(e===void 0)return!1;const t=await pn(e);return t?(await le.getLocations({siteId:t,permissionType:S.POPPOEAccess,locationType:ut.GreaterOrEqual+F.Site,permissionPrivilege:U.Update,pageSize:100,assignableProcess:"POP_access"})).some(i=>i.siteId===t):!1}async function An(e){return le.getOspsBySiteId(e)}async function _n(e){return le.getPopsBySiteId(e)}let Pi=class extends Rt{constructor(){super(...arguments),this.hasCreatePermission=!1}dispatchCreateTicketEvent(){const e=new CustomEvent(L.CreateTicket,{bubbles:!0,composed:!0});this.dispatchEvent(e)}async firstUpdated(){this.hasCreatePermission=await wm()}render(){return this.hasCreatePermission?g` <ix-button @click="${this.dispatchCreateTicketEvent}" has-icon> <md-icon slot="icon">add</md-icon> <span class="uppercase font-bold tracking-wider">Create Ticket</span> </ix-button>`:P}};E([we()],Pi.prototype,"hasCreatePermission",void 0),Pi=E([X("sm-create-service-ticket-button")],Pi);let Ie=null;function In(){const{pathname:e,search:t,hash:i}=window.location;rt.go({pathname:e,search:t,hash:i})}function km(e,t,i){const s=i.map(n=>({...n,path:`${t}${n.path}`,redirect:n.redirect?`${t}${n.redirect}`:null}));s.push({name:W.ServiceTickets,path:t||"/",component:"service-tickets-view",headerRight:g`<sm-create-service-ticket-button></sm-create-service-ticket-button>`,action:()=>{import("./ui-service-management2.js")}}),s.push({path:"(.*)",component:"service-tickets-view",action:()=>{import("./ui-service-management2.js")}}),Ie=new rt(e),Ie.setRoutes(s),window.addEventListener("shell-after-navigate",In)}function ym(){return Ie}function Tm(){Ie==null||Ie.unsubscribe(),Ie==null||Ie.removeRoutes(),Ie=null,window.removeEventListener("shell-after-navigate",In)}function Qt(e,t){return Ie&&Ie.urlForName(e,t)}function bm(e,t){const i=Qt(e);i&&rt.go({pathname:i,hash:t})}let qi=class extends Rt{constructor(){super(...arguments),this.routeName=null}return(){this.routeName&&bm(this.routeName),window.history.back()}render(){return g` <ix-button appearance="text" has-icon @click="${this.return}"> <md-icon slot="icon">arrow_back</md-icon> <span class="uppercase font-bold tracking-wider">Back</span> </ix-button>`}};E([we({type:String})],qi.prototype,"routeName",void 0),qi=E([X("sm-back-button")],qi);const Rm="Other parties to notify",Am="Result",Ye="CANCEL TICKET",_m="REQUEST CANCELLATION",Ee="EDIT TICKET",Im="Sites & Locations",Sm="Sites, Locations & Hosts",Cm="Trouble Ticket is not supported for this site.",Nm="We are unable to process your request. Please, try again or reach out to us for further assistance. We apologize for the inconvenience. Your Digital Realty Team.",Pm="Please be advised that your company has been restricted from submitting a new Delivery request for this location until all existing packages have been retrieved.",qm="We're unable to process your request at the moment. Please reach out to Customer Care for assistance.",Dm="Unable to process request. Contact Customer Care.",Bm='For POP/POE Room Access, please submit your request via the Customer Care form using the "Building" request type and "POP/POE Room Access" category.',Om="Important Note: Selecting a location is required to submit this ticket. If your specific POP/POE location is missing from the dropdown, please select any available location to complete your request for Room Access.";var O;(function(e){e.Announced="Announced",e.Cancelled="Cancelled",e.Completed="Completed",e.Draft="Draft",e.InProgress="In Progress",e.New="New",e.Expired="Expired"})(O||(O={}));var ei;(function(e){e.CancellationRequested="Cancellation requested"})(ei||(ei={}));var ft;(function(e){e.Approved="Approved",e.PendingPickup="Pending Pick-up",e.Rejected="Rejected"})(ft||(ft={}));var oe;(function(e){e.Approved="Approved",e.PendingApproval="Pending Approval",e.ApprovalDenied="Approval Denied"})(oe||(oe={}));const $m=[O.Cancelled,O.Completed,O.Expired,ft.Rejected,oe.ApprovalDenied],Em=[O.New,O.InProgress,O.Announced,ft.PendingPickup,ft.Approved,ei.CancellationRequested,oe.PendingApproval];var Di;(function(e){e.Resolved="Resolved",e.InProgress="In Progress",e.New="New",e.Closed="Closed",e.Cancelled="Cancelled"})(Di||(Di={}));class xm{constructor(){se(this)}async getServiceBackend(t,i,s){var n;i=i==null?void 0:i.split(".").pop();let o={accountNumber:t,site:i};const a=await m.siteNavigationApi.getSiteNavigation(o).catch(r=>{l(r,!1)});switch((n=a==null?void 0:a.find(r=>r.process===s))===null||n===void 0?void 0:n.serviceManagementSystem){case Yt.InSite:return H.Insite;case Yt.ServiceNow:return H.ServiceNow;case Yt.TelxSfdc:return s==="Facilities_access"?H.Insite:H.TelxSFDC;default:return}}}const K=new xm;var lt;(function(e){e.Kilograms="kilograms",e.Pounds="pounds"})(lt||(lt={}));function Sn(e){return typeof e=="string"&&e.trim().length>0}function Fm(e,t){return e.split(t).map(i=>i.trim().toLowerCase()).filter(i=>i.length>0)}const Cn=e=>/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(e);function Lm(e){return/^[a-zA-Z0-9]+$/.test(e)}function Vm(e){return/^[a-zA-Z0-9 ]+$/.test(e)}function Um(e){return/^[a-zA-Z0-9.' ]+$/.test(e)}function Hm(e){const t=he(e,"YYYY-MM-DD"),i=he().add(24,"hours").startOf("day");return t.isSameOrAfter(i)}function zm(e,t){const i=t?he.tz(t):he.utc(),[s,n]=e.split(":").map(o=>parseInt(o,10));return s>i.hours()||s===i.hours()&&n>i.minutes()}function Nn(e){return Sn(e)?/^(0|[1-9]\d*)$/.test(e):!1}const Pn=(e,t)=>{let i;return t===H.ServiceNow&&(i=e.weight,e.overweight&&(e.isHistorical||(i=`${e.weight} ${e.weightUnit}`))),{trackingNumber:e.trackingNumber,numberOfPackages:e.numberOfPackages,sizeWhenOversized:e.dimensions,weightWhenOverweight:i,courierCompany:e.courier===gt?e.otherCompany:e.courier}},qn=(e,t=!1)=>{var i,s,n,o,a;const r=e.serviceBackend!==H.ServiceNow?e.shortDescription+Ci+(e.instructions||rn):e.shortDescription,d={accountNumber:(i=e.site)===null||i===void 0?void 0:i.accountNumber,subject:(s=e.subject)!==null&&s!==void 0?s:"",description:r,etaFrom:Z(e.estimatedDate)||null,etaTo:Z(e.latestDate)||null,customerReference:e.referenceNumber,site:(o=(n=e.site)===null||n===void 0?void 0:n.id)!==null&&o!==void 0?o:"",otherNotificationRecipients:e.contacts,remoteHandsRequired:e.needRemoteHands};return(e==null?void 0:e.serviceBackend)!==H.TelxSFDC&&(d.loadingBayRequired=e.isLoadingBayRequired),t||(d.packages=(a=e.packages)===null||a===void 0?void 0:a.map(u=>Pn(u,e.serviceBackend))),d};function jm(e,t){const i=new Date;return t&&i.setDate(i.getDate()+e),St(i)}function Mm(e){const t=new Date;return t.setDate(t.getDate()+e),St(t)}const Dn=async(e,t,i)=>{if(!e||!t||!i)return[e];if(await K.getServiceBackend(t,i,"Deliveries")!==H.ServiceNow){const s=e.lastIndexOf(Ci);return s===-1?[e]:e.endsWith(rn)?[e.substring(0,s)]:[e.substring(0,s),e.substring(s+Ci.length)]}return[e]},Jm=e=>{if(!e)return[void 0,void 0];const t=e.split(" ");if(t.length!==2)return[e,void 0];const[i,s]=t;let n;if(s.toLowerCase()===lt.Kilograms)n=lt.Kilograms;else if(s.toLowerCase()===lt.Pounds)n=lt.Pounds;else return[e,void 0];return Nn(i)?[i,n]:[e,void 0]},Bn=async(e,t,i,s)=>{if(!e)return[];await J.fillCouriers(t,i,s);const n=J.getCouriers(s);return e.map(o=>{const a=n==null?void 0:n.find(N=>{var b;return N.toLowerCase()===((b=o.courierCompany)===null||b===void 0?void 0:b.toLowerCase())}),r=!!a,d=!!o.weightWhenOverweight;let u="",p;if(d){const[N,b]=Jm(o.weightWhenOverweight);u=N!=null?N:"",p=b}let A=!1;return d&&(A=!p||u.length>dn),{id:o.id||"",trackingNumber:o.trackingNumber,numberOfPackages:o.numberOfPackages||0,dimensions:o.sizeWhenOversized,overweight:d,oversized:!!o.sizeWhenOversized,weight:A?o.weightWhenOverweight:u,weightUnit:A?void 0:p,courier:r?a:gt,otherCompany:r?"":o.courierCompany,isHistorical:A}})},On=async e=>{var t,i,s,n,o,a;if(!e)return;const[r,d]=await Dn(e.description,e.accountNumber,e.site),u=await K.getServiceBackend(e.accountNumber,e.site,"Deliveries"),p=await Bn(e.packages,e.site,e.accountNumber,u);return{id:e.id,accountName:e.accountName,accountNumber:e.accountNumber,subject:e.subject,shortDescription:r,instructions:d,estimatedDate:(t=e.etaFrom)===null||t===void 0?void 0:t.toISOString().split("T")[0],latestDate:(i=e.etaTo)===null||i===void 0?void 0:i.toISOString().split("T")[0],referenceNumber:e.customerReference,site:e.site,cancellationReason:e.cancellationReason,contacts:e.otherNotificationRecipients,state:e.status,requester:e.createdBy,createdOn:(s=e.createdAt)===null||s===void 0?void 0:s.toISOString(),updatedOn:(n=e.updatedAt)===null||n===void 0?void 0:n.toISOString(),isLoadingBayRequired:e.loadingBayRequired,needRemoteHands:(o=e.remoteHandsRequired)!==null&&o!==void 0?o:!1,packages:p,comments:(a=e.comments)===null||a===void 0?void 0:a.map(A=>M(A)),serviceBackend:u}},Wm=async e=>{var t,i,s;if(!e)return;const[n,o]=await Dn(e.description,e.accountNumber,e.site),a=await K.getServiceBackend(e.accountNumber,e.site,"Deliveries"),r=await Bn(e.packages,e.site,e.accountNumber,a),d=J.sites.find(u=>u.id===e.site).locationId;return{id:e.id||"",accountNumber:e.accountNumber||"",subject:e.subject,shortDescription:n,instructions:o,estimatedDate:(t=e.etaFrom)===null||t===void 0?void 0:t.toISOString(),latestDate:(i=e.etaTo)===null||i===void 0?void 0:i.toISOString(),referenceNumber:e.customerReference,site:new Oe(d,e.site,e.accountNumber),contacts:e.otherNotificationRecipients,isLoadingBayRequired:e.loadingBayRequired,serviceBackend:a,isValid:!0,needRemoteHands:(s=e.remoteHandsRequired)!==null&&s!==void 0?s:!1,packages:r}},Gm=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),$n=e=>e.requestType===wi.PlannedWork&&e.serviceBackend===H.ServiceNow,Zm=e=>{var t,i;return $n(e)&&(i=Be(e.startDate,e.startTime,(t=e.site)===null||t===void 0?void 0:t.siteId))!==null&&i!==void 0?i:null},En=async e=>{var t,i;if(!e.expectedStart)return{startDate:"",startTime:"",startDateTime:""};const s=(i=(t=J.sites)===null||t===void 0?void 0:t.find(o=>o.locationId===e.site))===null||i===void 0?void 0:i.timeZone,n=s?G(e.expectedStart).tz(s):G(e.expectedStart);return{startDate:n.format("YYYY-MM-DD"),startTime:n.format("HH:mm"),startDateTime:n.format("YYYY-MM-DDTHH:mm")}},Km=e=>{var t,i,s,n,o;return{accountNumber:(t=e.accountNumber)!==null&&t!==void 0?t:"",requestType:(i=e.requestType)!==null&&i!==void 0?i:"",category:(s=e.category)!==null&&s!==void 0?s:"",subject:(n=e.subject)!==null&&n!==void 0?n:"",description:e.description,expectedStart:Zm(e),customerReference:e.referenceNumber,locations:!((o=e.location)===null||o===void 0)&&o.id?[e.location.id]:[],referenceTicket:e.referenceTicketNumber,otherNotificationRecipients:e.contacts}},Ym=e=>({customerReference:e.referenceNumber,otherNotificationRecipients:e.contacts}),xn=async e=>{var t,i,s,n,o;if(!e)return;const{startDate:a,startTime:r}=await En(e);return{id:e.ticketId,accountName:e.accountName,accountNumber:e.accountNumber,category:e.category,subject:e.subject,shortDescription:e.description,startDate:a,startTime:r,referenceNumber:e.customerReference,contacts:e.otherNotificationRecipients,state:e.status,site:e.site,locations:(i=(t=e.locations)===null||t===void 0?void 0:t.join(", "))!==null&&i!==void 0?i:"",requester:e.createdBy,requestType:e.requestType,referenceTicketNumber:e.referenceTicket,createdAt:(s=e.createdAt)===null||s===void 0?void 0:s.toISOString(),updatedAt:(n=e.updatedAt)===null||n===void 0?void 0:n.toISOString(),cancellationReason:e.cancellationReason,comments:(o=e.comments)===null||o===void 0?void 0:o.map(d=>M(d)),serviceBackend:await K.getServiceBackend(e.accountNumber,e.site,"Remote_hands"),ticketStatus:e.status||""}},Xm=async e=>{var t,i,s,n;if(!e)return;const{startDate:o,startTime:a,startDateTime:r}=await En(e);return{id:e.ticketId||"",accountName:e.accountName,accountNumber:e.accountNumber||"",category:e.category,subject:e.subject,description:e.description,shortDescription:(i=(t=e.description)===null||t===void 0?void 0:t.split("-")[0])===null||i===void 0?void 0:i.trim(),startDate:o,startTime:a,startDateTime:r,referenceNumber:e.customerReference,contacts:e.otherNotificationRecipients,state:e.status,site:{id:e.site},location:{id:e.locations[0],accountNumber:e.accountNumber},requester:e.createdBy,requestType:e.requestType,referenceTicketNumber:e.referenceTicket,createdOn:(s=e.createdAt)===null||s===void 0?void 0:s.toISOString(),updatedOn:(n=e.updatedAt)===null||n===void 0?void 0:n.toISOString(),ticketStatus:e.status||"",serviceBackend:await K.getServiceBackend(e.accountNumber,e.site,"Remote_hands")}},Qm=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),Bi=(e,t)=>{if(e===gt)return!0;const i=J.getCouriers(t).map(s=>s.toLowerCase());return!!e&&!(i!=null&&i.includes(e.toLowerCase()))},Fn=e=>e===cn,ep=e=>G().add({days:e}).format(ct),tp=(e,t)=>G(t).add({days:e}).format(ct),ip=e=>!!e&&G(e).isBefore(G().add({days:1}),"day"),sp=e=>!!e&&G(e).isBefore(G(),"day"),np=e=>{var t,i,s,n,o,a;const r=(t=Bi(e.courier,e.serviceBackend)?e.otherCompany:e.courier)!==null&&t!==void 0?t:"";return{accountNumber:(i=e.site)===null||i===void 0?void 0:i.accountNumber,subject:(s=e.subject)!==null&&s!==void 0?s:"",description:e.shortDescription,customerReference:e.referenceNumber,removalParty:(n=e.removalParty)!==null&&n!==void 0?n:"",courierCompany:r,trackingNumber:e.trackingNumber,pickupDate:Z(e.pickupDate),site:(a=(o=e.site)===null||o===void 0?void 0:o.id)!==null&&a!==void 0?a:"",otherNotificationRecipients:e.contacts}},ap=e=>{var t;const i=(t=Bi(e.courier,e.serviceBackend)?e.otherCompany:e.courier)!==null&&t!==void 0?t:"";return{subject:e.subject,description:e.shortDescription,customerReference:e.referenceNumber,courierCompany:i,trackingNumber:e.trackingNumber,pickupDate:Z(e.pickupDate),otherNotificationRecipients:e.contacts}},Ln=async(e,t,i,s)=>{await J.fillCouriers(t,i,s);const n=J.getCouriers(s).find(a=>a.toLowerCase()===(e==null?void 0:e.toLowerCase())),o=!!n;return{courier:o?n:gt,otherCompany:o?"":e}},Vn=e=>e===Yl?cn:e;async function op(e){if(!e)return;const t=await K.getServiceBackend(e.accountNumber,e.site,"Removals"),{courier:i,otherCompany:s}=await Ln(e.courierCompany,e.site,e.accountNumber,t),n=Vn(e.removalParty),o=J.sites.find(a=>a.id===e.site).locationId;return{id:e.id,accountNumber:e.accountNumber,site:new Oe(o,e.site,e.accountNumber),subject:e.subject,shortDescription:e.description,courier:i,otherCompany:s,removalParty:n,trackingNumber:e.trackingNumber,pickupDate:e.pickupDate,referenceNumber:e.customerReference,contacts:e.otherNotificationRecipients,status:e.status,isValid:!0,serviceBackend:await K.getServiceBackend(e.accountNumber,e.site,"Removals")}}const rp=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),Un=async e=>{var t,i,s;if(!e)return;const n=await K.getServiceBackend(e.accountNumber,e.site,"Removals"),{courier:o,otherCompany:a}=await Ln(e.courierCompany,e.site,e.accountNumber,n),r=Vn(e.removalParty);return{id:e.id,accountName:e.accountName,accountNumber:e.accountNumber,status:e.status,subject:e.subject,shortDescription:e.description,referenceNumber:e.customerReference,removalParty:r,needRemoteHands:Fn(r),courier:o,otherCompany:a,trackingNumber:e.trackingNumber,pickupDate:e.pickupDate,site:e.site,serviceBackend:n,contacts:e.otherNotificationRecipients,requester:e.createdBy,createdOn:(t=e.createdAt)===null||t===void 0?void 0:t.toISOString(),updatedOn:(i=e.updatedAt)===null||i===void 0?void 0:i.toISOString(),cancellationReason:e.cancellationReason,comments:(s=e.comments)===null||s===void 0?void 0:s.map(d=>M(d))}},cp=e=>{var t,i,s,n,o,a,r,d;return{accountNumber:(t=e.accountNumber)!==null&&t!==void 0?t:"",requestType:(i=e.requestType)!==null&&i!==void 0?i:"",category:(s=e.category)!==null&&s!==void 0?s:"",subject:(n=e.subject)!==null&&n!==void 0?n:"",description:(o=e.description)!==null&&o!==void 0?o:"",locations:e.locations,customerReference:(a=e.referenceNumber)!==null&&a!==void 0?a:"",circuitId:(r=e.circuitId)!==null&&r!==void 0?r:"",notificationRecipients:(d=e.contacts)!==null&&d!==void 0?d:""}},dp=e=>{const t={};return e.subject&&(t.subject=e.subject),e.description&&(t.description=e.description),e.circuitId&&(t.circuitId=e.circuitId),e.referenceNumber&&(t.customerReference=e.referenceNumber),e.contacts&&(t.otherNotificationRecipients=e.contacts),t},Oi=async e=>{var t,i,s,n;if(e)return{id:e.id,accountName:e.accountName,accountNumber:e.accountNumber,category:e.category,subject:e.subject,description:e.description,referenceNumber:e.customerReference,contacts:e.notificationRecipients,state:e.status,site:{id:e.site,accountNumber:e.accountNumber},locations:e.locations,requester:e.createdBy,requestType:e.requestType,circuitId:e.circuitId,createdOn:(t=e.createdAt)===null||t===void 0?void 0:t.toISOString(),updatedOn:(i=e.updatedAt)===null||i===void 0?void 0:i.toISOString(),closedOn:(s=e.closedAt)===null||s===void 0?void 0:s.toISOString(),comments:(n=e.comments)===null||n===void 0?void 0:n.map(o=>M(o)),cancellationReason:e.cancellationReason,serviceBackend:await K.getServiceBackend(e.accountNumber,e.site,"Trouble_tickets")}},up=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}});async function Pt(e,t,i,s,n,o){var a;let r;switch(e){case y.CustomerSupport:{r=await m.customerCareApi.createCustomerCareTicketAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d});break}case y.RemoteHands:{r=await m.remoteHandsApi.createRemoteHandsAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d});break}case y.Deliveries:{r=await m.deliveriesApi.createAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d});break}case y.Removals:{r=await m.removalsApi.createRemovalsAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d});break}case y.FacilityAccess:{switch(o){case"Visitor Access":r=await m.facilityAccessApi.visitorAccess.createVisitorAccessAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d});break;case"Permanent Badge":r=await((a=m.facilityAccessApi.permanentBadgeAccess)===null||a===void 0?void 0:a.createPermanentBadegeAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d}));break;case"OSP Access":r=await m.facilityAccessApi.ospAccess.createOspAccessAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d});break;case"PoP/POE Access":r=await m.facilityAccessApi.popAccess.createPopAccessAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d});break}break}case y.TroubleTickets:{r=await m.troubleTicketsApi.createTroubleTicketAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:m.getAuthorizationToken()}}).catch(d=>{throw l(d,!1),d});break}default:return}return r}const xe=e=>{const t=URL.createObjectURL(e);window.open(t),setTimeout(()=>URL.revokeObjectURL(t),1e3*60*5)};async function lp(e,t,i,s){var n;let o;try{switch(e){case y.CustomerSupport:{o=await m.customerCareApi.getCustomerCareTicketAttachmentsById({ticketId:i,attachmentId:t!=null?t:""}),xe(o);break}case y.RemoteHands:{o=await m.remoteHandsApi.getRemoteHandsAttachmentsById({ticketId:i,attachmentId:t!=null?t:""}),xe(o);break}case y.Deliveries:{o=await m.deliveriesApi.getDeliveryAttachmentsById({ticketId:i,attachmentId:t!=null?t:""}),xe(o);break}case y.Removals:{o=await m.removalsApi.getRemovalsAttachmentsById({ticketId:i,attachmentId:t!=null?t:""}),xe(o);break}case y.TroubleTickets:{o=await m.troubleTicketsApi.getTroubleTicketAttachmentsById({ticketId:i,attachmentId:t!=null?t:""}),xe(o);break}case y.FacilityAccess:{switch(s){case"Visitor Access":o=await m.facilityAccessApi.visitorAccess.getVisitorAccessAttachmentsById({ticketId:i,attachmentId:t}),xe(o);break;case"Permanent Badge":o=await((n=m.facilityAccessApi.permanentBadgeAccess)===null||n===void 0?void 0:n.getPermanentBadgeAttachmentsById({ticketId:i,attachmentId:t})),xe(o);break;case"OSP Access":o=await m.facilityAccessApi.ospAccess.getOspAccessAttachmentsById({ticketId:i,attachmentId:t}),xe(o);break;case"PoP/POE Access":o=await m.facilityAccessApi.popAccess.getPopAccessAttachmentsById({ticketId:i,attachmentId:t}),xe(o);break;default:break}break}default:return}}catch(a){console.error("error",a),l(a,!1)}return o}const Fe=(e,t)=>{const i=URL.createObjectURL(e),s=document.createElement("a");s.href=i,s.download=t,document.body.appendChild(s),s.click(),URL.revokeObjectURL(i)};async function mp(e,t,i,s,n){var o;let a;try{switch(e){case y.CustomerSupport:{a=await m.customerCareApi.getCustomerCareTicketAttachmentsById({ticketId:s,attachmentId:t!=null?t:""}),Fe(a,i);break}case y.RemoteHands:{a=await m.remoteHandsApi.getRemoteHandsAttachmentsById({ticketId:s,attachmentId:t!=null?t:""}),Fe(a,i);break}case y.Deliveries:{a=await m.deliveriesApi.getDeliveryAttachmentsById({ticketId:s,attachmentId:t!=null?t:""}),Fe(a,i);break}case y.Removals:{a=await m.removalsApi.getRemovalsAttachmentsById({ticketId:s,attachmentId:t!=null?t:""}),Fe(a,i);break}case y.TroubleTickets:{a=await m.troubleTicketsApi.getTroubleTicketAttachmentsById({ticketId:s,attachmentId:t!=null?t:""}),Fe(a,i);break}case y.FacilityAccess:{switch(n){case"Visitor Access":a=await m.facilityAccessApi.visitorAccess.getVisitorAccessAttachmentsById({ticketId:s,attachmentId:t}),Fe(a,i);break;case"Permanent Badge":a=await((o=m.facilityAccessApi.permanentBadgeAccess)===null||o===void 0?void 0:o.getPermanentBadgeAttachmentsById({ticketId:s,attachmentId:t})),Fe(a,i);break;case"OSP Access":a=await m.facilityAccessApi.ospAccess.getOspAccessAttachmentsById({ticketId:s,attachmentId:t}),Fe(a,i);break;case"PoP/POE Access":a=await m.facilityAccessApi.popAccess.getPopAccessAttachmentsById({ticketId:s,attachmentId:t}),Fe(a,i);break;default:break}break}default:return}}catch(r){console.error("error",r),l(r,!1)}return a}async function Hn(e,t,i){var s,n;try{let o;switch(e){case y.CustomerSupport:{o=await m.customerCareApi.getCustomerCareTicketAttachmentsList({ticketId:t});break}case y.RemoteHands:{o=await m.remoteHandsApi.getRemoteHandsAttachmentsList({ticketId:t});break}case y.Deliveries:{o=await m.deliveriesApi.getDeliveryAttachmentsList({ticketId:t});break}case y.Removals:{o=await m.removalsApi.getRemovalsAttachmentsList({ticketId:t});break}case y.TroubleTickets:{o=await m.troubleTicketsApi.getTroubleTicketAttachmentsList({ticketId:t});break}case y.FacilityAccess:{switch(i){case"Visitor Access":o=await m.facilityAccessApi.visitorAccess.getVisitorAccessAttachmentsList({ticketId:t});break;case"Permanent Badge":o=await((s=m.facilityAccessApi.permanentBadgeAccess)===null||s===void 0?void 0:s.getPermanentBadgeAttachmentsList({ticketId:t}));break;case"OSP Access":o=await m.facilityAccessApi.ospAccess.getOspAccessAttachmentsList({ticketId:t});break;case"PoP/POE Access":o=await m.facilityAccessApi.popAccess.getPopAccessAttachmentsList({ticketId:t});break;default:break}break}default:return}return k.attachments=(n=o==null?void 0:o.attachments)!==null&&n!==void 0?n:[],k.attachments}catch(o){console.error("error",o),await l(o,!1);return}}const qt=async(e,t,i="text/csv")=>{const s=new Blob([await e.arrayBuffer()],{type:i}),n=URL.createObjectURL(s),o=document.createElement("a");o.href=n,o.download=t,document.body.appendChild(o),o.click(),URL.revokeObjectURL(n)};async function pp(e,t){try{const i=await m.serviceTicketApi.downloadServiceTickets({$filter:e,permissionPrivilege:t});await qt(i,"service-tickets.csv")}catch(i){l(i,!1)}}async function hp(e,t,i,s){try{const n=await m.plannedMaintenanceApi.downloadPlannedMaintenanceTickets({$filter:e,$orderby:t,$skip:i,$top:s});await qt(n,"planned-maintenance-tickets.csv")}catch(n){l(n,!1)}}async function vp(e,t,i){try{const s=await m.plannedMaintenanceApi.getPlannedMaintenanceAttachmentsByIdRaw({ticketId:e,attachmentId:t}),n=s.raw.headers.get("content-type")||void 0,o=await s.value();await qt(o,i,n)}catch(s){l(s,!1)}}async function gp(e,t,i,s){try{const n=await m.incidentsApi.downloadIncidentTickets({$filter:e,$orderby:t,$skip:i,$top:s});await qt(n,"incident-tickets.csv")}catch(n){l(n,!1)}}async function wp(e,t,i){try{const s=await m.incidentsApi.getIncidentsAttachmentsByIdRaw({ticketId:e,attachmentId:t}),n=s.raw.headers.get("content-type")||void 0,o=await s.value();await qt(o,i,n)}catch(s){l(s,!1)}}const Le={ticketType:void 0,ticketStep:void 0,serviceTickets:void 0,permissions:{hasCustomerCareCreatePermission:!1,hasFacilityAccessCreatePermission:!1,hasRemoteHandsCreatePermission:!1,hasDeliveriesAndRemovalsCreatePermission:!1,hasTroubleTicketsCreatePermission:!1},loadings:{ticketCreatePermissionChecks:!0,serviceTicketList:!0,attachments:!0,downloadServiceTicketList:!1,serviceTicket:!1,isTicketCancelling:!1},attachments:[],failedAttachments:[],error:{uploadingAttachments:!1,serviceTicketsGrid:!1,fetchingTicket:!1,cancellingTicket:!1},hasPendingApprovalDialogBeenShown:!1};class fp{constructor(){this.ticketType=void 0,this.ticketStep=void 0,this.serviceTickets=void 0,this.permissions=Le.permissions,this.loadings=Le.loadings,this.attachments=Le.attachments,this.failedAttachments=Le.failedAttachments,this.error=Le.error,this.hasPendingApprovalDialogBeenShown=Le.hasPendingApprovalDialogBeenShown,se(this)}updateTicketType(t=void 0){this.ticketType=t}clear(){this.ticketType=void 0,this.ticketStep=void 0,this.error=Le.error,this.loadings=Le.loadings,this.failedAttachments=Le.failedAttachments}setPendingApprovalDialogShown(t){this.hasPendingApprovalDialogBeenShown=t}async checkPermissions(){this.loadings.ticketCreatePermissionChecks=!0,this.permissions.hasCustomerCareCreatePermission=await hn(),this.permissions.hasFacilityAccessCreatePermission=await kn(),this.permissions.hasRemoteHandsCreatePermission=await yn(),this.permissions.hasDeliveriesAndRemovalsCreatePermission=await Ni(),this.permissions.hasTroubleTicketsCreatePermission=await Tn(),this.loadings.ticketCreatePermissionChecks=!1}async postAttachments(t,i,s,n,o){i&&i.length>0&&(this.error.uploadingAttachments=!1,this.failedAttachments=i.map(a=>a.fileName),await Promise.all(i.map(async a=>{try{const r=await Pt(t,a.file,a.fileName,a.fileType,s,o);n&&r!=null&&r.id&&(this.attachments.push(r),this.failedAttachments=this.failedAttachments.filter(d=>d!==a.fileName))}catch(r){await l(r,!1),this.error.uploadingAttachments=!0}})))}async GetServiceTicketList(t,i,s,n,o,a){var r,d;this.loadings.serviceTicketList=!0,this.error.serviceTicketsGrid=!1;try{this.serviceTickets=await m.serviceTicketApi.getServiceTickets({$filter:t,$orderby:i,$skip:s,$top:n,permissionPrivilege:o},a)}catch(u){if(!((r=a==null?void 0:a.signal)===null||r===void 0)&&r.aborted)return;l(u,!1),this.serviceTickets=void 0,this.error.serviceTicketsGrid=!0}finally{!((d=a==null?void 0:a.signal)===null||d===void 0)&&d.aborted||(this.loadings.serviceTicketList=!1)}}async downloadServiceTickets(t,i){this.loadings.downloadServiceTicketList=!0,await pp(t,i),this.loadings.downloadServiceTicketList=!1}get ticketAttachments(){return this.attachments.filter(t=>!t.isError).map(t=>({name:t.fileName}))}}const k=new fp,ye={newTicket:{isValid:!1,accountNumber:"",attachments:[]},selectedTicket:void 0,submissionResult:{state:w.Default},loadings:{isSubmitting:!1,ticketDetailsPermissionCheck:!1}};class kp{constructor(){this.newTicket=ye.newTicket,this.submissionResult=ye.submissionResult,this.selectedTicket=ye.selectedTicket,this.loadings=ye.loadings,se(this),Je(this,{name:"removals",properties:[],storage:window.localStorage})}createTicket(){var t,i,s;this.newTicket={...ye.newTicket,site:(t=this.newTicket.site)!==null&&t!==void 0?t:void 0,serviceBackend:(i=this.newTicket.serviceBackend)!==null&&i!==void 0?i:void 0,accountNumber:(s=this.newTicket.accountNumber)!==null&&s!==void 0?s:"NOT FOUND"},this.submissionResult=ye.submissionResult}updateIsFormValid(t){this.newTicket.isValid=t}updateSite(t){this.newTicket.site=t}updateSubject(t){this.newTicket.subject=t}updateShortDesc(t){this.newTicket.shortDescription=t}updateCourier(t){this.newTicket.courier=t}updateOtherCompany(t){this.newTicket.otherCompany=t}updateTrackingNumber(t){this.newTicket.trackingNumber=t}updatePickupDate(t){this.newTicket.pickupDate=t}updateReferenceNumber(t){this.newTicket.referenceNumber=t}updateRemovalParty(t){this.newTicket.removalParty=t}updateContacts(t){this.newTicket.contacts=t}updateAttachments(t){var i;this.newTicket.attachments=[...(i=this.newTicket.attachments)!==null&&i!==void 0?i:[],...t]}async submitNewTicketRequest(){var t;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.result=void 0;try{this.submissionResult.result=await m.removalsApi.createRemoval({removalTicketsRequest:np(this.newTicket)})}catch(i){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await l(i,!1),i}try{!((t=this.submissionResult.result)===null||t===void 0)&&t.id&&(await k.postAttachments(y.Removals,this.newTicket.attachments,this.submissionResult.result.id),this.newTicket.attachments=void 0)}catch(i){throw await l(i,!1),i}finally{this.loadings.isSubmitting=!1}}async hasTicketPermissionAtLocation(t,i,s,n){try{return this.loadings.ticketDetailsPermissionCheck=!0,await Nt(t,i,s,n)}finally{this.loadings.ticketDetailsPermissionCheck=!1}}async setNewTicket(){try{this.newTicket=await op(this.submissionResult.result)||ye.newTicket}catch(t){throw await l(t,!1),t}}async getRemovalsServiceTicket(t){if(t)try{const i=await m.removalsApi.getRemovalById({ticketId:t});this.submissionResult.result=i,this.selectedTicket=await Un(i),await this.setNewTicket()}catch(i){throw await l(i,!1),i}}async editTicketRequest(){let t;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{t=await m.removalsApi.updateRemovalById({ticketId:this.newTicket.id||"",removalsTicketsUpdateRequest:ap(this.newTicket)}),this.submissionResult.result=t,this.submissionResult.state=w.Submitted}catch(i){this.submissionResult.state=w.Error,await l(i,!1)}try{await k.postAttachments(y.Removals,this.newTicket.attachments,this.newTicket.id,!0),this.newTicket.attachments=void 0}catch(i){await l(i,!1)}try{t&&(this.selectedTicket=await Un(t),await this.setNewTicket())}catch(i){throw await l(i,!1),i}}finally{this.loadings.isSubmitting=!1}}async cancelTicket(t){var i,s;try{if(k.loadings.isTicketCancelling=!0,!((i=this.selectedTicket)===null||i===void 0)&&i.id){const n=(s=this.selectedTicket)===null||s===void 0?void 0:s.id;await m.removalsApi.cancellationRemovalRequest({ticketId:n,cancellationTicketsRequest:{cancellationReason:t}}),await this.getRemovalsServiceTicket(n)}}catch(n){throw await l(n,!1),n}finally{k.loadings.isTicketCancelling=!1}}clear(){this.newTicket=ye.newTicket,this.selectedTicket=ye.selectedTicket,this.submissionResult=ye.submissionResult,this.loadings=ye.loadings}}const Ve=new kp,Te={newTicket:{isValid:!1,isLoadingBayRequired:!1,needRemoteHands:!1,accountNumber:"",contacts:"",attachments:[]},selectedTicket:void 0,submissionResult:{state:w.Default,result:void 0},loadings:{isSubmitting:!1,isDeliveryBlocked:!1,ticketDetailsPermissionCheck:!1}};class yp{constructor(){this.newTicket=Te.newTicket,this.submissionResult=Te.submissionResult,this.selectedTicket=Te.selectedTicket,this.loadings=Te.loadings,se(this),Je(this,{name:"deliveries",properties:[],storage:window.localStorage})}createTicket(){var t,i,s;this.newTicket={...Te.newTicket,site:(t=this.newTicket.site)!==null&&t!==void 0?t:void 0,serviceBackend:(i=this.newTicket.serviceBackend)!==null&&i!==void 0?i:void 0,accountNumber:(s=this.newTicket.accountNumber)!==null&&s!==void 0?s:"NOT FOUND"},this.submissionResult=Te.submissionResult}addPackage(t,i){var s;if(!t)return;const n=(s=this.newTicket.packages)!==null&&s!==void 0?s:[];i?this.newTicket.packages=n.map(o=>o.id===t.id?t:o):this.newTicket.packages=[...n,t]}removePackage(t){var i;if(t){const s=((i=this.newTicket.packages)!==null&&i!==void 0?i:[]).filter(n=>n.id!==t.id);this.newTicket.packages=[...s]}}updateSite(t){this.newTicket.site=t,this.newTicket.packages=[]}updateSubject(t){this.newTicket.subject=t}updateShortDesc(t){this.newTicket.shortDescription=t}updateEstimatedDate(t){this.newTicket.estimatedDate=t}updateLatestDate(t){this.newTicket.latestDate=t}updateReferenceNumber(t){this.newTicket.referenceNumber=t}updateLoadingBay(t){this.newTicket.isLoadingBayRequired=t}updateNeedRemoteHands(t){this.newTicket.needRemoteHands=t}updateInstructions(t){this.newTicket.instructions=t}updateContacts(t){this.newTicket.contacts=t}updateAttachments(t){var i;this.newTicket.attachments=[...(i=this.newTicket.attachments)!==null&&i!==void 0?i:[],...t]}updateTermsAgreed(t){this.newTicket.termsAgreed=t}updateIsValid(t){this.newTicket.isValid=t}async submitNewTicketRequest(){var t;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{this.submissionResult.result=await m.deliveriesApi.createDelivery({deliveryTicketsRequest:qn(this.newTicket)}),this.submissionResult.state=w.Submitted}catch(i){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await l(i,!1),i}try{!((t=this.submissionResult.result)===null||t===void 0)&&t.id&&await k.postAttachments(y.Deliveries,this.newTicket.attachments,this.submissionResult.result.id),this.newTicket.attachments=void 0}catch(i){throw await l(i,!1),i}finally{this.loadings.isSubmitting=!1}}async setNewTicket(){try{this.newTicket=await Wm(this.submissionResult.result)||Te.newTicket}catch(t){throw await l(t,!1),t}}async updateTicketRequest(){var t,i;let s;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{s=await m.deliveriesApi.updateDeliveriesTickets({ticketId:((t=this.selectedTicket)===null||t===void 0?void 0:t.id)||"",deliveryTicketsUpdateRequest:qn(this.newTicket,!0)});const n=((i=this.newTicket)===null||i===void 0?void 0:i.packages)||[],o=(await Promise.all(n.map(async a=>{var r;return m.deliveriesApi.updateDeliveriesTicketsPackages({ticketId:((r=this.selectedTicket)===null||r===void 0?void 0:r.id)||"",packageId:(a==null?void 0:a.id)||"",deliveryTicketUpdatePackagesRequest:Pn(a,this.newTicket.serviceBackend)}).then(d=>{var u,p;return(p=(u=d.packages)===null||u===void 0?void 0:u.find(A=>A.id===a.id))!==null&&p!==void 0?p:null}).catch(d=>(l(d,!1),null))}))).filter(a=>a!==null);s&&(s.packages=s.packages.map(a=>{const r=o.find(d=>a.id===d.id);return r!=null?r:a})),this.submissionResult.result=s,this.submissionResult.state=w.Submitted}catch(n){throw this.submissionResult.state=w.Error,await l(n,!1),n}try{await k.postAttachments(y.Deliveries,this.newTicket.attachments,this.newTicket.id,!0),this.newTicket.attachments=void 0}catch(n){await l(n,!1)}try{this.selectedTicket=await On(s),await this.setNewTicket()}catch(n){await l(n,!1)}}finally{this.loadings.isSubmitting=!1}}async hasTicketPermissionAtLocation(t,i,s,n){this.loadings.ticketDetailsPermissionCheck=!0;const o=await Nt(t,i,s,n);return this.loadings.ticketDetailsPermissionCheck=!1,o}async getDeliveriesServiceTicket(t){if(t)try{const i=await m.deliveriesApi.getDeliveryById({ticketId:t});this.submissionResult.result=i,this.selectedTicket=await On(i),await this.setNewTicket()}catch(i){throw await l(i,!1),i}}async cancelDelivery(t,i){try{k.loadings.isTicketCancelling=!0,t&&(await m.deliveriesApi.cancellationDeliveryRequest({ticketId:t,cancellationTicketsRequest:{cancellationReason:i}}),await this.getDeliveriesServiceTicket(t))}catch(s){throw await l(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}async isDeliveryBlocked(t,i){var s;let n;return this.loadings.isDeliveryBlocked=!0,t&&i&&(n=await m.deliveriesApi.getDeliveryDiscovery({site:t,accountNumber:i}).catch(o=>{l(o,!1)})),this.loadings.isDeliveryBlocked=!1,(s=n==null?void 0:n.deliveryBlocked)!==null&&s!==void 0?s:!0}clear(){this.newTicket=Te.newTicket,this.selectedTicket=Te.selectedTicket,this.submissionResult=Te.submissionResult,this.loadings=Te.loadings}}const be=new yp,Re={newTicket:{isValid:!1,accountNumber:"",disableReferenceTicketNumber:!1,attachments:[]},selectedTicket:void 0,submissionResult:{state:w.Default},loadings:{isSubmitting:!1,ticketDetailsPermissionCheck:!1,requestType:!1}};class Tp{constructor(){this.newTicket=Re.newTicket,this.submissionResult=Re.submissionResult,this.selectedTicket=Re.selectedTicket,this.loadings=Re.loadings,se(this),Je(this,{name:"remote-hands",properties:[],storage:window.localStorage})}createTicket(t){var i,s,n,o;const a=(i=this.newTicket.accountNumber)!==null&&i!==void 0?i:ae.getUserAccount().accountNumber;this.newTicket={...Re.newTicket,site:(s=this.newTicket.site)!==null&&s!==void 0?s:void 0,accountNumber:a!=null?a:"NOT FOUND",serviceBackend:t,referenceTicketNumber:(n=this.newTicket.referenceTicketNumber)!==null&&n!==void 0?n:void 0,disableReferenceTicketNumber:(o=this.newTicket.disableReferenceTicketNumber)!==null&&o!==void 0?o:void 0},this.submissionResult=Re.submissionResult}updateSite(t,i=!1){this.newTicket.site=t,this.newTicket.isValid=i}updateLocation(t){this.newTicket.location=t}updateSubject(t){this.newTicket.subject=t}updateDescription(t){this.newTicket.description=t}updateRequestType(t){this.newTicket.requestType=t,this.newTicket.category=void 0}updateCategory(t){this.newTicket.category=t}updateReferenceNumber(t){this.newTicket.referenceNumber=t}updateReferenceTicketNumber(t){this.newTicket.referenceTicketNumber=t}updateReferenceNumberDisable(t){this.newTicket.referenceTicketNumber=t,this.newTicket.disableReferenceTicketNumber=!0}updateStartDate(t){this.newTicket.startDate=t}updateStartTime(t){this.newTicket.startTime=t}updateContacts(t){this.newTicket.contacts=t}updateAccountNumber(t){this.newTicket.accountNumber=t}updateFormValidation(t){this.newTicket.isValid=t}updateAttachments(t){var i;this.newTicket.attachments=[...(i=this.newTicket.attachments)!==null&&i!==void 0?i:[],...t]}updateTermsAgreed(t){this.newTicket.termsAgreed=t}async setNewTicket(){try{this.newTicket=await Xm(this.submissionResult.result)||Re.newTicket}catch(t){throw await l(t,!1),t}}async updateTicketRequest(){var t;let i;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{i=await m.remoteHandsApi.updateRemoteHandsTicketById({ticketId:((t=this.selectedTicket)===null||t===void 0?void 0:t.id)||"",remoteHandsUpdateRequest:Ym(this.newTicket)}),this.submissionResult.result=i,this.submissionResult.state=w.Submitted}catch(s){this.submissionResult.state=w.Error,await l(s,!1)}try{await k.postAttachments(y.RemoteHands,this.newTicket.attachments,this.newTicket.id,!0),this.newTicket.attachments=void 0}catch(s){await l(s,!1)}try{i&&(this.selectedTicket=await xn(i))}catch(s){await l(s,!1)}}catch(s){throw await l(s,!1),s}finally{this.loadings.isSubmitting=!1}}async submitNewTicketRequest(){var t;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{this.submissionResult.result=await m.remoteHandsApi.createRemoteHandsTicket({remoteHandsRequest:Km(this.newTicket)}),this.submissionResult.state=w.Submitted}catch(i){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await l(i,!1),i}try{!((t=this.submissionResult.result)===null||t===void 0)&&t.ticketId&&(await k.postAttachments(y.RemoteHands,this.newTicket.attachments,this.submissionResult.result.ticketId),this.newTicket.attachments=void 0)}catch(i){throw await l(i,!1),i}finally{this.loadings.isSubmitting=!1}}async getRemoteHandsServiceTicket(t){if(t)try{const i=await m.remoteHandsApi.getRemoteHandsTicketById({ticketId:t});this.submissionResult.result=i,this.selectedTicket=await xn(i),await this.setNewTicket()}catch(i){throw await l(i,!1),i}}async cancelTicket(t){var i;try{k.loadings.isTicketCancelling=!0,!((i=this.selectedTicket)===null||i===void 0)&&i.id&&(await m.remoteHandsApi.cancellationRemoteHandsRequest({ticketId:this.selectedTicket.id,cancellationTicketsRequest:{cancellationReason:t}}),await this.getRemoteHandsServiceTicket(this.selectedTicket.id))}catch(s){throw await l(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}clear(){this.newTicket=Re.newTicket,this.selectedTicket=Re.selectedTicket,this.submissionResult=Re.submissionResult,this.loadings=Re.loadings}}const re=new Tp,bp=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),Ae={newTicket:{isValid:!1,accountNumber:"",attachments:[],locations:[]},selectedTicket:void 0,submissionResult:{state:w.Default},loadings:{isSubmitting:!1}};class Rp{constructor(){this.newTicket=Ae.newTicket,this.submissionResult=Ae.submissionResult,this.selectedTicket=Ae.selectedTicket,this.loadings=Ae.loadings,se(this),Je(this,{name:"trouble-tickets",properties:[],storage:window.localStorage})}getIsInProgress(){var t;return((t=this.selectedTicket)===null||t===void 0?void 0:t.state)===O.InProgress}createTicket(t){var i,s;const{accountNumber:n}=ae.getUserAccount();this.newTicket={...Ae.newTicket,site:(i=this.newTicket.site)!==null&&i!==void 0?i:void 0,accountNumber:n!=null?n:"NOT FOUND",referenceTicketNumber:t,serviceBackend:(s=this.newTicket.serviceBackend)!==null&&s!==void 0?s:void 0},this.submissionResult=Ae.submissionResult}updateSite(t,i=!1){this.newTicket.site=t,this.newTicket.isValid=i}updateLocations(t,i){var s,n,o;if(i)(o=this.newTicket.locations)===null||o===void 0||o.push(t);else{const a=(s=this.newTicket.locations)===null||s===void 0?void 0:s.indexOf(t);a!==void 0&&a!==-1&&((n=this.newTicket.locations)===null||n===void 0||n.splice(a,1))}}clearLocations(){this.newTicket.locations=[]}updateSubject(t){this.newTicket.subject=t}updateDescription(t){this.newTicket.description=t}updateRequestType(t){this.newTicket.requestType=t,this.newTicket.category=void 0}updateCategory(t){this.newTicket.category=t}updateReferenceNumber(t){this.newTicket.referenceNumber=t}updateReferenceTicketNumber(t){this.newTicket.referenceTicketNumber=t}updateReferenceNumberDisable(t){this.newTicket.referenceTicketNumber=t}updateCircuitId(t){this.newTicket.circuitId=t}updateContacts(t){this.newTicket.contacts=t}updateAccountNumber(t){this.newTicket.accountNumber=t}updateFormValidation(t){this.newTicket.isValid=t}updateTermsAgreed(t){this.newTicket.termsAgreed=t}updateAttachments(t){var i;this.newTicket.attachments=[...(i=this.newTicket.attachments)!==null&&i!==void 0?i:[],...t]}async submitNewTicketRequest(){var t,i;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.result=void 0;try{this.submissionResult.result=await m.troubleTicketsApi.createTroubleTicketTicket({troubleTicketRequest:cp(this.newTicket)}),this.submissionResult.state=w.Submitted}catch(s){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await l(s,!1),s}try{!((i=(t=this.submissionResult)===null||t===void 0?void 0:t.result)===null||i===void 0)&&i.id&&(await k.postAttachments(y.TroubleTickets,this.newTicket.attachments,this.submissionResult.result.id),this.newTicket.attachments=void 0)}catch(s){throw await l(s,!1),s}finally{this.loadings.isSubmitting=!1}}async setNewTicket(){try{this.newTicket=await Oi(this.submissionResult.result)||Ae.newTicket}catch(t){throw await l(t,!1),t}}async submitUpdateTicketRequest(){var t,i;if(this.newTicket&&this.selectedTicket&&this.selectedTicket.id){let s;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{s=await m.troubleTicketsApi.updateTroubleTicketTicket({ticketId:(t=this.selectedTicket.id)!==null&&t!==void 0?t:"",troubleTicketUpdateRequest:dp(this.newTicket)}),this.submissionResult.result=s}catch(n){this.submissionResult.state=w.Error,await l(n,!1)}try{await k.postAttachments(y.TroubleTickets,this.newTicket.attachments,(i=this.selectedTicket)===null||i===void 0?void 0:i.id,!0),this.newTicket.attachments=void 0}catch(n){await l(n,!1)}try{s&&(this.submissionResult.state=w.Submitted,this.submissionResult.result=s,this.selectedTicket=await Oi(this.submissionResult.result),await this.setNewTicket())}catch(n){await l(n,!1)}}finally{this.loadings.isSubmitting=!1}}}async getTroubleTicketById(t){if(t)try{const i=await m.troubleTicketsApi.getTroubleTicketTicketById({ticketId:t});this.submissionResult.result=i,this.selectedTicket=await Oi(i),await this.setNewTicket()}catch(i){throw await l(i,!1),i}}async cancelTicket(t){var i;try{k.loadings.isTicketCancelling=!0,!((i=this.selectedTicket)===null||i===void 0)&&i.id&&(await m.troubleTicketsApi.cancellationTroubleTicketRequest({ticketId:this.selectedTicket.id,cancellationTicketsRequest:{cancellationReason:t}}),await this.getTroubleTicketById(this.selectedTicket.id))}catch(s){throw await l(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}clear(){this.newTicket=Ae.newTicket,this.selectedTicket=Ae.selectedTicket,this.submissionResult=Ae.submissionResult,this.loadings=Ae.loadings}}const Ue=new Rp,Ap={"Visitor First Name":"visitorFirstName","Visitor Last Name":"visitorLastName","Visitor Email Address":"visitorEmailAddress","Visitor Phone Number":"visitorPhoneNumber"},zn=40,$i="bulk_";function mt(e){return e.startsWith("WO")}function _p(e){return e.startsWith("CS")||e.startsWith("DEL")}function Ip(e,t){return e?Jt.Escorted:t==="Standard"?Jt.Standard:Jt.Extended}function Sp(e){return e?e==="Escorted"?{isEscortedVisitor:!0,visitorBadge:void 0}:{isEscortedVisitor:!1,visitorBadge:e==="Standard"?"Standard":"Extended"}:{isEscortedVisitor:void 0,visitorBadge:void 0}}function Cp(e){return e.map(t=>{var i;return{siteCode:t.site.siteId,visitorHostId:(i=t.visitorHost)===null||i===void 0?void 0:i.id,locations:t.locations.map(s=>({id:s.id,startDate:Z(s.startDate),endDate:Z(s.endDate)}))}})}const Np=e=>({otherNotificationRecipients:e.contacts,visitorPhone:e.visitors[0].phone});async function jn(e,t,i,s,n,o){var a,r;const d=(a=J.sites.find(u=>u.locationId===e))===null||a===void 0?void 0:a.id;return[{site:new Oe(e,d,t),locations:(r=i==null?void 0:i.map(u=>({id:u.id||"-",site:d,startDate:u.startDate||"",endDate:u.endDate||"",status:u.approvalStatus||"-",modifiedBy:u.modifiedBy||"-"})))!==null&&r!==void 0?r:[],isVisitorHostDetailsValid:s,visitorHost:n,serviceBackend:o}]}const Pp=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),qp=e=>{var t,i,s,n;return{accountNumber:e.accountNumber,visitors:e.visitors.map(o=>({firstName:o.firstName,lastName:o.lastName,email:o.email,phone:o.phone})),visitStartDate:Z(e.startDate),visitEndDate:Z(e.endDate),visitType:Ip((t=e.isEscortedVisitor)!==null&&t!==void 0?t:!1,e.visitorBadge),sites:Cp(e.sitesDetails||[]),escortFirstName:e.escortFirstName,escortLastName:e.escortLastName,visitorHostFirstName:(i=e.hostFirstName)!==null&&i!==void 0?i:"",visitorHostLastName:(s=e.hostLastName)!==null&&s!==void 0?s:"",representingCompany:(n=e.representingCompany)!==null&&n!==void 0?n:"",description:e.notes,notificationRecipients:e.contacts}},Mn=async e=>{var t,i,s,n;if(!e)return;const o=mt(e.id)?H.Insite:H.ServiceNow;return{id:e.id,accountNumber:e.accountNumber||"-",accountName:e.accountName||"-",contacts:e.notificationRecipients||"",state:e.status||"-",requester:e.createdBy||"-",createdOn:e.createdAt.toISOString(),updatedOn:e.updatedAt.toISOString(),requestType:"Visitor Access",category:"New Visitor Access",visitors:[{firstName:e.visitorFirstName||"-",lastName:e.visitorLastName||"-",email:e.visitorEmail||"-",phone:e.visitorPhone||"-",id:""}],visitorType:e.visitType||"-",escortFirstName:e.escortFirstName||"-",escortLastName:e.escortLastName||"-",startDate:e.visitStartDate,endDate:e.visitEndDate,representingCompany:e.representingCompany||"-",notes:e.description||"-",site:e.site,cancellationReason:e.cancellationReason,sitesDetails:await jn((t=e.site)!==null&&t!==void 0?t:"-",(i=e.accountNumber)!==null&&i!==void 0?i:"-",(s=e.locations)!==null&&s!==void 0?s:[],!0,{firstName:e.visitorHostFirstName,lastName:e.visitorHostLastName},o),hostFirstName:e.visitorHostFirstName,hostLastName:e.visitorHostLastName,comments:(n=e.comments)===null||n===void 0?void 0:n.map(a=>M(a))}},Dp=async e=>{var t,i,s;if(!e)return;const{isEscortedVisitor:n,visitorBadge:o}=Sp(e.visitType),a=mt(e.id)?H.Insite:H.ServiceNow;return{id:e==null?void 0:e.id,accountNumber:e.accountNumber||"",contacts:e.notificationRecipients||"",requestType:"Visitor Access",category:"New Visitor Access",visitors:[{firstName:e.visitorFirstName||"",lastName:e.visitorLastName||"",email:e.visitorEmail||"",phone:e.visitorPhone||""}],escortFirstName:e.escortFirstName||"",escortLastName:e.escortLastName||"",startDate:e.visitStartDate,endDate:e.visitEndDate,representingCompany:e.representingCompany||"-",notes:e.description||"-",sitesDetails:await jn((t=e.site)!==null&&t!==void 0?t:"-",(i=e.accountNumber)!==null&&i!==void 0?i:"-",(s=e.locations)!==null&&s!==void 0?s:[],!0,{firstName:e.visitorHostFirstName,lastName:e.visitorHostLastName},a),hostFirstName:e.visitorHostFirstName,hostLastName:e.visitorHostLastName,cancellationReason:e.cancellationReason,visitorBadge:o,isEscortedVisitor:n,isFileAttachedForVisitors:!1,isNotificationsAttachmentsValid:!0,isRequestedAccessDetailsValid:!0,isVisitorContactsDetailsValid:!0,isVisitorEscortedDetailsValid:!0}},Jn=e=>{const{visitorFirstName:t,visitorLastName:i,visitorEmailAddress:s,visitorPhoneNumber:n}=e;if(!t||!i||!s)return"Error: First name, last name and email are required.";const o=!Cn(s),a=n&&n.length>0&&!ha(n);if(o&&a)return"Error: Invalid visitor email address and phone number";if(o)return"Error: Invalid visitor email address";if(a)return"Error: Invalid visitor phone number"};async function Bp(e){const[t,i]=await Promise.all([Ze({locationType:F.Site,permissionType:S.VisitorAccess,permissionPrivilege:e}),Ze({locationType:Ct,permissionType:S.VisitorAccess,permissionPrivilege:e,assignableProcess:"Facilities_access"})]),s=new Set(i.map(n=>n.siteId));return t.sort((n,o)=>n.siteId>o.siteId?1:-1).map(n=>({...n,hasSpaces:s.has(n.siteId)}))}const ce={newTicket:{isRequestedAccessDetailsValid:!1,isVisitorContactsDetailsValid:!1,isVisitorEscortedDetailsValid:!1,isNotificationsAttachmentsValid:!1,isRepresentingCompanyValid:!1,accountNumber:void 0,visitors:[],contacts:"",attachments:[],isEscortedVisitor:!1,startDate:void 0,endDate:void 0,sitesDetails:void 0,visitorBadge:"Standard"},selectedTicket:void 0,submissionResult:{state:w.Default,ticketNumbers:[],ticketResponse:void 0},loadings:{isSubmitting:!1,facilityAccessTicket:!1},isEditAttachmentAdded:!1};class Op{constructor(){this.DuplicateEmailErrorMessage="Each visitor must have a unique email address.",this.newTicket=ce.newTicket,this.submissionResult=ce.submissionResult,this.selectedTicket=ce.selectedTicket,this.loadings=ce.loadings,this.isEditAttachmentAdded=ce.isEditAttachmentAdded,se(this)}createTicket(){var t,i;const s=(t=this.newTicket.accountNumber)!==null&&t!==void 0?t:ae.getUserAccount().accountNumber;this.newTicket={...ce.newTicket,accountNumber:s,requestType:"Visitor Access",category:"New Visitor Access",serviceBackend:(i=this.newTicket.serviceBackend)!==null&&i!==void 0?i:void 0},this.submissionResult=ce.submissionResult}isVisitorContactsValid(t){this.newTicket.isVisitorContactsDetailsValid=t}isEscortedDetailsValid(t){this.newTicket.isVisitorEscortedDetailsValid=t}get isVisitorHostDetailsValid(){var t;return((t=this.newTicket.sitesDetails)===null||t===void 0?void 0:t.some(i=>i.isVisitorHostDetailsValid===!1))===!1}isVisitorHostDetailsValidBySite(t,i){var s;const n=(s=this.newTicket.sitesDetails)===null||s===void 0?void 0:s.find(o=>o.site.siteId===t);n&&(n.isVisitorHostDetailsValid=i)}isRequestedAccessDetailsValid(t){this.newTicket.isRequestedAccessDetailsValid=t}isNotificationsAttachmentsValid(t){this.newTicket.isNotificationsAttachmentsValid=t}isRepresentingCompanyValid(t){this.newTicket.isRepresentingCompanyValid=t}updateTermsAgreed(t){this.newTicket.termsAgreed=t}updateAttachments(t){var i;(i=this.newTicket.attachments)===null||i===void 0||i.push(...t)}removeBulkAttachment(){var t;this.newTicket.attachments=(t=this.newTicket.attachments)===null||t===void 0?void 0:t.filter(i=>{var s;return!(!((s=i.fileName)===null||s===void 0)&&s.startsWith($i))})}get isNewTicketValid(){return this.newTicket.isVisitorContactsDetailsValid&&this.newTicket.isVisitorEscortedDetailsValid&&this.isVisitorHostDetailsValid&&this.newTicket.isRequestedAccessDetailsValid&&this.newTicket.isRepresentingCompanyValid&&this.newTicket.isNotificationsAttachmentsValid}updateIsEscortedVisitor(t){this.newTicket.isEscortedVisitor=t,t?this.newTicket.visitorBadge=void 0:(this.newTicket.escortFirstName=void 0,this.newTicket.escortLastName=void 0,this.newTicket.visitorBadge===void 0&&(this.newTicket.visitorBadge="Standard"))}updateVisitorHost(t,i){var s;const n=(s=this.newTicket.sitesDetails)===null||s===void 0?void 0:s.find(o=>o.site.siteId===t);n&&(n.visitorHost=i,n.isVisitorHostDetailsValid=!0)}updateEscortFirstName(t){this.newTicket.escortFirstName=t}updateEscortLastName(t){this.newTicket.escortLastName=t}updateIsFileAttachedForVisitors(t){this.newTicket.isFileAttachedForVisitors=t}validateNoDuplicateEmails(t){const i=[...t];i.forEach((n,o)=>{n.validationError===this.DuplicateEmailErrorMessage&&(i[o]={...n,validationError:void 0,isValid:!0})});const s=i.filter(n=>!n.validationError);return i.forEach((n,o)=>{n.validationError||s.filter(a=>a.email.toLowerCase()===n.email.toLowerCase()).length>1&&(i[o]={...n,validationError:this.DuplicateEmailErrorMessage,isValid:!1})}),i}addOrUpdateVisitor(t){var i;if(!t)return;const s=(i=this.newTicket.visitors)!==null&&i!==void 0?i:[],n=s.findIndex(a=>a.id===t.id),o=n!==-1;if(!(!o&&s.length>=zn))if(this.newTicket.id)this.newTicket.visitors=[t];else{let a;t.isUploadedFromFile&&(a=Jn({visitorFirstName:t.firstName,visitorLastName:t.lastName,visitorEmailAddress:t.email,visitorPhoneNumber:t.phone}));const r={...t,validationError:a,isValid:!a},d=[...s];o?d[n]=r:d.push(r),this.newTicket.visitors=this.validateNoDuplicateEmails(d)}}addBulkVisitors(t){t.forEach(i=>{const s=Jn(i),n={id:crypto.randomUUID(),firstName:i.visitorFirstName,lastName:i.visitorLastName,email:i.visitorEmailAddress,phone:i.visitorPhoneNumber,isUploadedFromFile:!0,validationError:s,isValid:!s};this.addOrUpdateVisitor(n)})}removeBulkVisitors(){var t;const i=((t=this.newTicket.visitors)!==null&&t!==void 0?t:[]).filter(s=>s.isUploadedFromFile!==!0);this.newTicket.visitors=[...i]}removeVisitor(t){var i;if(t){const s=((i=this.newTicket.visitors)!==null&&i!==void 0?i:[]).filter(n=>n.id!==t.id);this.newTicket.visitors=this.validateNoDuplicateEmails(s)}}removeAllVisitors(){this.newTicket.visitors=[]}updateHostFirstName(t){this.newTicket.hostFirstName=t}updateHostLastName(t){this.newTicket.hostLastName=t}updateVisitorBadge(t){this.newTicket.visitorBadge=t}updateStartDate(t){var i;this.newTicket.startDate=t,(i=this.newTicket.sitesDetails)===null||i===void 0||i.forEach(s=>{s.locations.forEach(n=>{n.startDate=t})})}updateEndDate(t){var i;this.newTicket.endDate=t,(i=this.newTicket.sitesDetails)===null||i===void 0||i.forEach(s=>{s.locations.forEach(n=>{n.endDate=t})})}updateRepresentingCompany(t){this.newTicket.representingCompany=t}updateNotes(t){this.newTicket.notes=t}async addSiteLocations(t){var i;if(t){const s=await K.getServiceBackend(t.site.accountNumber,t.site.siteId,"Facilities_access"),n=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(a=>a.site.siteId!==t.site.siteId),o={...t,serviceBackend:s};this.newTicket.sitesDetails=[...n,o]}}removeSiteLocations(t){var i;if(t){const s=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(n=>n.site.siteId!==t.site.siteId);this.newTicket.sitesDetails=[...s]}}updateContacts(t){this.newTicket.contacts=t}async submitNewTicketRequest(){var t,i,s,n;let o;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{o=await m.facilityAccessApi.visitorAccess.createVisitorAccessTicket({visitorAccessTicketRequest:qp(this.newTicket)}),this.submissionResult.ticketNumbers=o==null?void 0:o.ticketNumbers}catch(a){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await l(a,!1),a}try{if(o){k.failedAttachments=((t=this.newTicket.attachments)!==null&&t!==void 0?t:[]).map(u=>u.fileName);const{ticketNumbers:a}=o,r=(i=a==null?void 0:a.filter(u=>_p(u)))!==null&&i!==void 0?i:[],d=(s=a==null?void 0:a.filter(u=>mt(u)))!==null&&s!==void 0?s:[];a!=null&&a.length&&!((n=this.newTicket.attachments)===null||n===void 0)&&n.length&&await Promise.all(this.newTicket.attachments.map(async u=>{const p=[];let A=[];u.fileName.startsWith($i)?(r.length>0&&A.push(r[0]),d.length>0&&A.push(...d)):A=a,p.push(...A.map(async N=>Pt(y.FacilityAccess,u.file,u.fileName,u.fileType,N,this.newTicket.requestType))),await Promise.all(p).then(()=>{var N;k.failedAttachments=((N=this.newTicket.attachments)!==null&&N!==void 0?N:[]).filter(b=>b.fileName!==u.fileName).map(b=>b.fileName)})})),this.newTicket.attachments=void 0}}catch(a){throw k.error.uploadingAttachments=!0,await l(a,!1),a}finally{this.submissionResult.state=w.Submitted,this.loadings.isSubmitting=!1}}async setNewTicket(){try{this.newTicket=await Dp(this.submissionResult.ticketResponse)||ce.newTicket}catch(t){throw await l(t,!1),t}}async submitUpdateTicketRequest(){let t;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{t=await m.facilityAccessApi.visitorAccess.updateVisitorAccessTicket({visitorAccessTicketUpdateRequest:Np(this.newTicket),ticketId:this.newTicket.id}),this.submissionResult.ticketResponse=t,this.submissionResult.state=w.Submitted,this.submissionResult.ticketNumbers=[t.id]}catch(i){this.submissionResult.state=w.Error,await l(i,!1)}try{await k.postAttachments(y.FacilityAccess,this.newTicket.attachments,this.newTicket.id,!0,"Visitor Access"),this.newTicket.attachments=void 0}catch(i){await l(i,!1)}try{t&&(this.selectedTicket=await Mn(t),await this.setNewTicket())}catch(i){await l(i,!1)}}catch(i){throw await l(i,!1),i}finally{this.loadings.isSubmitting=!1}}async getVisitorAccessServiceTicket(t){if(t)try{const i=await m.facilityAccessApi.visitorAccess.getVisitorAccessTicketById({ticketId:t});this.submissionResult.ticketResponse=i,this.selectedTicket=await Mn(i),await this.setNewTicket()}catch(i){throw await l(i,!1),i}}async cancelTicket(t,i){try{k.loadings.isTicketCancelling=!0,k.error.cancellingTicket=!1,t&&(await m.facilityAccessApi.visitorAccess.cancellationVisitorAccessRequest({ticketId:t,cancellationTicketsRequest:{cancellationReason:i}}).catch(s=>{throw l(s,!1),s}),await this.getVisitorAccessServiceTicket(t))}catch(s){throw k.error.cancellingTicket=!0,await l(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}async hasUpdatePermissions(){try{return!!await Ke(this.selectedTicket.sitesDetails[0].locations.map(t=>t.id),S.VisitorAccess,U.Update)}catch(t){return!1}}clearNewTicket(){this.newTicket=ce.newTicket}async patchLocationsApprovalStatus(t){var i,s;const n=t.map(o=>({id:o.id,approvalStatus:us[o.status]}));await m.facilityAccessApi.visitorAccess.updateVisitorAccessLocationsTicket({ticketId:((i=this.selectedTicket)===null||i===void 0?void 0:i.id)||"",locationsPatchRequestInner:n}),await this.getVisitorAccessServiceTicket((s=this.selectedTicket)===null||s===void 0?void 0:s.id)}async getVisitorHosts(t,i,s,n=1,o=10){return await m.facilityAccessApi.visitorHost.getVisitorHostsList({site:t,nameOrEmailContains:i,pageNumber:n,pageSize:o},s).catch(r=>{var d;!((d=s==null?void 0:s.signal)===null||d===void 0)&&d.aborted||l(r,!1)})||{items:[],totalCount:0}}clear(){this.newTicket=ce.newTicket,this.selectedTicket=ce.selectedTicket,this.submissionResult=ce.submissionResult,this.loadings=ce.loadings,this.isEditAttachmentAdded=ce.isEditAttachmentAdded}}const ie=new Op;function $p(e){return e.flatMap(t=>t.locations).map(t=>({id:t.id,startDate:Z(t.startDate),endDate:Z(t.endDate)}))}function Ep(e){return e.flatMap(t=>t.locations).map(t=>({id:t.id,startDate:Z(t.startDate),endDate:Z(t.endDate),operation:"add"}))}const xp=e=>{var t;return{accountNumber:(t=e.accountNumber)!==null&&t!==void 0?t:"",badgeholderFirstName:e.badgeHolder.firstName,badgeholderLastName:e.badgeHolder.lastName,badgeholderEmail:e.badgeHolder.email,badgeholderCompany:e.badgeHolder.company,badgeholderPhone:e.badgeHolder.phone,badgeStartDate:Z(e.startDate),badgeEndDate:Z(e.endDate),locations:$p(e.sitesDetails||[]),notificationRecipients:e.contacts}},Fp=e=>({otherNotificationRecipients:e.contacts}),Lp=e=>({otherNotificationRecipients:e.contacts}),Vp=()=>({}),Up=e=>{var t;return{accountNumber:(t=e.accountNumber)!==null&&t!==void 0?t:"",badgeholderId:e.badgeHolder.id,badgeStartDate:Z(e.startDate),badgeEndDate:Z(e.endDate),locations:Ep(e.sitesDetails||[]),notificationRecipients:e.contacts}},Hp=e=>({badgeholderId:e.badgeHolder.id,accountNumber:e.badgeHolder.accountNumber,badgeEndDate:Z(e.endDate)});async function Wn(e,t=""){if(!e)return[];const i=e.map(a=>({id:a.id||"-",site:a.site||"",siteAddress:a.siteAddress,startDate:a.startDate||"",endDate:a.endDate||"",status:a.approvalStatus||"-",modifiedBy:a.modifiedBy||"-"})),s=[...new Set(i.map(a=>a.site))],n={};await Promise.all(s.map(async a=>{var r;n[a]=(r=await vm(a))!==null&&r!==void 0?r:a}));const o=[];return i.forEach(a=>{const{site:r}=a,d=o.find(u=>u.site.siteId===r);d?d.locations.push(a):o.push({site:new Oe(n[r],r,t),locations:[a]})}),o}const Gn=async e=>{var t,i,s;if(e)return{id:e==null?void 0:e.id,accountNumber:e.accountNumber||"-",accountName:e.accountName||"-",contacts:e.notificationRecipients||"",state:e.status||"-",requester:e.createdBy||"-",createdOn:(t=e.createdAt)===null||t===void 0?void 0:t.toISOString(),updatedOn:(i=e.updatedAt)===null||i===void 0?void 0:i.toISOString(),requestType:"Permanent Badge",category:e.requestType,visitors:[{firstName:e.badgeholderFirstName||"-",lastName:e.badgeholderLastName||"-",email:e.badgeholderEmail||"-",phone:e.badgeholderPhone,company:e.badgeholderCompany||"-"}],startDate:e.badgeStartDate,endDate:e.badgeEndDate,sitesDetails:await Wn(e.locations,e.accountNumber),cancellationReason:e.cancellationReason,comments:(s=e.comments)===null||s===void 0?void 0:s.map(n=>M(n))}},zp=async e=>{if(e)return{id:e==null?void 0:e.id,contacts:e.notificationRecipients,requestType:"Permanent Badge",category:e.requestType,visitors:[{firstName:e.badgeholderFirstName||"",lastName:e.badgeholderLastName||"",email:e.badgeholderEmail||"",phone:e.badgeholderPhone||"",company:e.badgeholderCompany||""}],badgeHolder:{firstName:e.badgeholderFirstName||"",lastName:e.badgeholderLastName||"",email:e.badgeholderEmail||"",phone:e.badgeholderPhone||"",company:e.badgeholderCompany||""},startDate:e.badgeStartDate,endDate:e.badgeEndDate,sitesDetails:await Wn(e.locations,e.accountNumber),isNotificationsAttachmentsValid:!0,isRequestedAccessDetailsValid:!0,isVisitorContactsDetailsValid:!0,isEndDateValid:!0,isBadgeholderValid:!0}},jp=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),Zn=e=>e.map(t=>({id:t.id,accountNumber:t.accountNumber,firstName:t.firstName,lastName:t.lastName,email:t.email,phone:t.phone,company:t.representingCompany,startDate:t.badgeStartDate?St(t.badgeStartDate):void 0})),Mp=(e,t)=>[...e,...Zn(t)];async function Jp(e){const[t,i]=await Promise.all([Ze({locationType:F.Site,permissionType:S.PermanentBadge,permissionPrivilege:e}),Ze({locationType:Ct,permissionType:S.PermanentBadge,permissionPrivilege:e,assignableProcess:"Facilities_access"})]),s=new Set(i.map(n=>n.siteId));return t.sort((n,o)=>n.siteId>o.siteId?1:-1).map(n=>({...n,hasSpaces:s.has(n.siteId)}))}const de={newTicket:{isRequestedAccessDetailsValid:!1,isNotificationsAttachmentsValid:!1,isBadgeholderValid:!1,isStartDateSetViaBadgeHolder:!1,isEndDateValid:!1,accountNumber:void 0,contacts:"",badgeHolder:{},attachments:[],isVisitorContactsDetailsValid:!1,visitors:[]},selectedTicket:void 0,submissionResult:{state:w.Default,ticketNumbers:[],ticketResponse:void 0},loadings:{isSubmitting:!1,facilityAccessTicket:!1},isEditAttachmentAdded:!1};class Wp{constructor(){this.newTicket=de.newTicket,this.submissionResult=de.submissionResult,this.selectedTicket=de.selectedTicket,this.loadings=de.loadings,this.isEditAttachmentAdded=de.isEditAttachmentAdded,se(this)}createTicket(){var t,i,s,n;const o=(t=this.newTicket.accountNumber)!==null&&t!==void 0?t:ae.getUserAccount().accountNumber;this.newTicket={...de.newTicket,accountNumber:o,requestType:(i=this.newTicket.requestType)!==null&&i!==void 0?i:void 0,category:(s=this.newTicket.category)!==null&&s!==void 0?s:void 0,serviceBackend:(n=this.newTicket.serviceBackend)!==null&&n!==void 0?n:void 0},this.submissionResult=de.submissionResult}updateStartDateSetViaBadgeholder(t){this.newTicket.isStartDateSetViaBadgeHolder=t}isVisitorContactsValid(t){this.newTicket.isVisitorContactsDetailsValid=t}isRequestedAccessDetailsValid(t){this.newTicket.isRequestedAccessDetailsValid=t}isBadgeholderValid(t){this.newTicket.isBadgeholderValid=t}isNotificationsAttachmentsValid(t){this.newTicket.isNotificationsAttachmentsValid=t}isEndDateValid(t){this.newTicket.isEndDateValid=t}updateTermsAgreed(t){this.newTicket.termsAgreed=t}updateAttachments(t){var i;(i=this.newTicket.attachments)===null||i===void 0||i.push(...t)}removeBulkAttachment(){throw new Error("Method not implemented.")}get isNewTicketValid(){switch(this.newTicket.category){case"New":return this.newTicket.isVisitorContactsDetailsValid&&this.newTicket.isRequestedAccessDetailsValid&&this.newTicket.isNotificationsAttachmentsValid;case"Modify":return this.newTicket.isBadgeholderValid&&this.newTicket.isRequestedAccessDetailsValid&&this.newTicket.isNotificationsAttachmentsValid;case"Terminate":return this.newTicket.isBadgeholderValid&&this.newTicket.isEndDateValid;default:return!1}}setBadgeHolder(t){this.newTicket.badgeHolder=t,t===void 0?this.newTicket.visitors=[]:this.newTicket.visitors=[{id:t.id,firstName:t.firstName,lastName:t.lastName,email:t.email,phone:t.phone,company:t.company}]}addOrUpdateVisitor(t){t&&this.setBadgeHolder(t)}addBulkVisitors(t){throw new Error("Method not implemented.")}removeBulkVisitors(){throw new Error("Method not implemented.")}removeVisitor(t){this.setBadgeHolder(void 0)}removeAllVisitors(){this.newTicket.visitors=[]}clearStartDate(){this.newTicket.startDate=void 0}updateStartDate(t){var i;this.newTicket.startDate=t,(i=this.newTicket.sitesDetails)===null||i===void 0||i.forEach(s=>{s.locations.forEach(n=>{n.startDate=t})})}updateEndDate(t){var i;this.newTicket.endDate=t,(i=this.newTicket.sitesDetails)===null||i===void 0||i.forEach(s=>{s.locations.forEach(n=>{n.endDate=t})})}async addSiteLocations(t){var i;if(t){const s=await K.getServiceBackend(t.site.accountNumber,t.site.siteId,"Facilities_access"),n=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(a=>a.site.siteId!==t.site.siteId),o={...t,serviceBackend:s};this.newTicket.sitesDetails=[...n,o]}}removeSiteLocations(t){var i;if(t){const s=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(n=>n.site.siteId!==t.site.siteId);this.newTicket.sitesDetails=[...s]}}updateContacts(t){this.newTicket.contacts=t}async submitNewTicketRequest(){var t,i;let s;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{switch(this.newTicket.category){case"New":s=await m.facilityAccessApi.permanentBadgeAccess.createPermanentBadgeNewTicket({permanentBadgeAccessNewTicketRequest:xp(this.newTicket)});break;case"Modify":s=await m.facilityAccessApi.permanentBadgeAccess.createPermanentBadgeModifyTicket({permanentBadgeAccessModifyTicketRequest:Up(this.newTicket)});break;case"Terminate":s=await m.facilityAccessApi.permanentBadgeAccess.createPermanentBadgeTerminateTicket({permanentBadgeAccessTerminateTicketRequest:Hp(this.newTicket)});break;default:throw new Error("Invalid category")}this.submissionResult.ticketNumbers=s==null?void 0:s.ticketNumbers}catch(n){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await l(n,!1),n}try{if(s){k.failedAttachments=((t=this.newTicket.attachments)!==null&&t!==void 0?t:[]).map(o=>o.fileName);const{ticketNumbers:n}=s;n!=null&&n.length&&!((i=this.newTicket.attachments)===null||i===void 0)&&i.length&&await Promise.all(this.newTicket.attachments.map(async o=>Promise.all(n.map(async a=>Pt(y.FacilityAccess,o.file,o.fileName,o.fileType,a,this.newTicket.requestType))).then(()=>{var a;k.failedAttachments=((a=this.newTicket.attachments)!==null&&a!==void 0?a:[]).filter(r=>r.fileName!==o.fileName).map(r=>r.fileName)}))),this.newTicket.attachments=void 0}}catch(n){throw k.error.uploadingAttachments=!0,await l(n,!1),n}finally{this.submissionResult.state=w.Submitted,this.loadings.isSubmitting=!1}}mapPermanentBadgeTicketToUpdateRequest(){switch(this.newTicket.category){case"Modify":return Lp(this.newTicket);case"New":return Fp(this.newTicket);case"Terminate":return Vp();default:throw new Error("Invalid category")}}async setNewTicket(){try{this.newTicket=await zp(this.submissionResult.ticketResponse)||de.newTicket}catch(t){throw await l(t,!1),t}}async submitUpdateTicketRequest(){var t;let i;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{i=await((t=m.facilityAccessApi.permanentBadgeAccess)===null||t===void 0?void 0:t.updatePermanentBadgeTicket({permanentBadgeAccessTicketUpdateRequest:this.mapPermanentBadgeTicketToUpdateRequest(),ticketId:this.newTicket.id})),this.submissionResult.ticketResponse=i,this.submissionResult.state=w.Submitted,this.submissionResult.ticketNumbers=[i.id]}catch(s){await l(s,!1)}try{await k.postAttachments(y.FacilityAccess,this.newTicket.attachments,this.newTicket.id,!0,"Permanent Badge"),this.newTicket.attachments=void 0}catch(s){await l(s,!1)}try{i&&(this.selectedTicket=await Gn(i),await this.setNewTicket())}catch(s){await l(s,!1)}}catch(s){throw await l(s,!1),this.submissionResult.state=w.Error,s}finally{this.loadings.isSubmitting=!1}}async getPermanentBadgeAccessServiceTicket(t){if(t)try{const i=await m.facilityAccessApi.permanentBadgeAccess.getPermanentBadgeTicketById({ticketId:t});this.submissionResult.ticketResponse=i,this.selectedTicket=await Gn(i),await this.setNewTicket()}catch(i){throw await l(i,!1),i}}async cancelTicket(t,i){try{k.loadings.isTicketCancelling=!0,k.error.cancellingTicket=!1,t&&(await m.facilityAccessApi.permanentBadgeAccess.cancellationPermanentBadgeRequest({ticketId:t,cancellationTicketsRequest:{cancellationReason:i}}).catch(s=>{throw l(s,!1),s}),await this.getPermanentBadgeAccessServiceTicket(t))}catch(s){throw k.error.cancellingTicket=!0,await l(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}async hasUpdatePermissions(){try{return!!await Ke(this.selectedTicket.sitesDetails[0].locations.map(t=>t.id),S.PermanentBadge,U.Update)}catch(t){return!1}}async getAttachments(t,i){return Hn(y.FacilityAccess,t,i)}async getPermanentBadgeHolders(t,i,s=1,n=10){return await m.facilityAccessApi.permanentBadgeAccess.getPermanentBadgeHoldersList({accountNumber:this.newTicket.accountNumber,activeBadge:!0,nameOrEmailContains:t,page:s,size:n},i).catch(a=>{var r;!((r=i==null?void 0:i.signal)===null||r===void 0)&&r.aborted||l(a,!0)})||{items:[],totalCount:0}}clearNewTicket(){this.newTicket=de.newTicket}async patchLocationsApprovalStatus(t){var i,s,n;const o=t.map(a=>({id:a.id,approvalStatus:us[a.status]}));await((i=m.facilityAccessApi.permanentBadgeAccess)===null||i===void 0?void 0:i.updatePermanentBadgeLocationsTicket({ticketId:((s=this.selectedTicket)===null||s===void 0?void 0:s.id)||"",locationsPatchRequestInner:o}).catch(a=>{l(a,!1)})),await this.getPermanentBadgeAccessServiceTicket((n=this.selectedTicket)===null||n===void 0?void 0:n.id).catch(a=>{l(a,!1)})}clear(){this.newTicket=de.newTicket,this.selectedTicket=de.selectedTicket,this.submissionResult=de.submissionResult,this.loadings=de.loadings,this.isEditAttachmentAdded=de.isEditAttachmentAdded}}const Y=new Wp;function Gp(e){return e.flatMap(t=>t.locations.map(i=>({id:i.id,startDateTime:Be(i.startDate,i.startTime,t.site.siteId),endDateTime:Be(i.endDate,i.endTime,t.site.siteId)})))}async function Kn(e){var t,i,s;const{timeZone:n,id:o}=((t=J.sites)===null||t===void 0?void 0:t.find(d=>d.locationId===e.site))||{},a=o?await An(o):[],r=new Map(a.map(d=>{var u;return[d.id,(u=d.name)!==null&&u!==void 0?u:d.id]}));return[{site:new Oe(e.site,o,e.accountNumber),locations:(s=(i=e.locations)===null||i===void 0?void 0:i.map(d=>{var u,p,A,N;return{id:d.id,name:r.get(d.id)||d.id,site:o,startDate:d.startDateTime&&n?(u=G(d.startDateTime).tz(n))===null||u===void 0?void 0:u.format(ct):"-",startTime:d.startDateTime&&n?(p=G(d.startDateTime).tz(n))===null||p===void 0?void 0:p.format($t):"-",endDate:d.endDateTime&&n?(A=G(d.endDateTime).tz(n))===null||A===void 0?void 0:A.format(ct):"-",endTime:d.endDateTime&&n?(N=G(d.endDateTime).tz(n))===null||N===void 0?void 0:N.format($t):"-"}}))!==null&&s!==void 0?s:[]}]}async function Zp(e){const[t,i]=await Promise.all([Ze({locationType:F.Site,permissionType:S.OSPAccess,permissionPrivilege:e}),Ze({locationType:ut.GreaterThan+F.Site,permissionType:S.OSPAccess,permissionPrivilege:e,assignableProcess:"OSP_access"})]),s=new Set(i.map(n=>n.siteId));return t.sort((n,o)=>n.siteId>o.siteId?1:-1).map(n=>({...n,hasSpaces:s.has(n.siteId),accountNumber:n.accountNumber}))}const Kp=e=>({accountNumber:e.accountNumber,visitors:e.visitors.map(t=>({firstName:t.firstName,lastName:t.lastName,email:t.email,company:t.company,phone:t.phone,visitorType:t.visitorType})),locations:Gp(e.sitesDetails||[]),escortFirstName:e.escortFirstName,escortLastName:e.escortLastName,visitorHostFirstName:e.hostFirstName,visitorHostLastName:e.hostLastName,customerExternalReference:e.customerExternalReference,serviceImpactedDescription:e.serviceImpactDescription,workDescription:e.workDescription,notificationRecipients:e.contacts}),ue=(e,t)=>e===t||!e&&!t||!e&&t==="-",Yp=(e,t)=>{var i,s;const n={};ue(e.visitors[0].phone,t.visitors[0].phone)||(n.visitorPhone=e.visitors[0].phone),ue(e.visitors[0].company,t.visitors[0].company)||(n.visitorCompany=e.visitors[0].company),(!ue(e.escortFirstName,t.escortFirstName)||!ue(e.escortLastName,t.escortLastName))&&(n.escortFirstName=e.escortFirstName,n.escortLastName=e.escortLastName),(!ue(e.hostFirstName,t.visitorHostFirstName)||!ue(e.hostLastName,t.visitorHostLastName))&&(n.visitorHostFirstName=e.hostFirstName,n.visitorHostLastName=e.hostLastName),ue(e.customerExternalReference,t.customerExternalReference)||(n.customerExternalReference=e.customerExternalReference),ue(e.serviceImpactDescription,t.serviceImpactDescription)||(n.serviceImpactedDescription=e.serviceImpactDescription),ue(e.workDescription,t.workDescription)||(n.workDescription=e.workDescription),ue(e.contacts,t.notificationRecipients)||(n.otherNotificationRecipients=e.contacts);const o=((i=e.sitesDetails)===null||i===void 0?void 0:i.flatMap(d=>d.locations))||[],a=((s=t.sitesDetails)===null||s===void 0?void 0:s.flatMap(d=>d.locations))||[],r=o.map(d=>{var u,p;const A=a.find(b=>b.id===d.id),N={id:d.id};return(!A||!ue(d.startDate,A.startDate)||!ue(d.startTime,A.startTime))&&(N.startDateTime=Be(d.startDate,d.startTime,(u=e.sitesDetails)===null||u===void 0?void 0:u[0].site.siteId)),(!A||!ue(d.endDate,A.endDate)||!ue(d.endTime,A.endTime))&&(N.endDateTime=Be(d.endDate,d.endTime,(p=e.sitesDetails)===null||p===void 0?void 0:p[0].site.siteId)),N}).filter(d=>d.startDateTime||d.endDateTime);return r.length&&(n.locations=r),Object.keys(n).length===0&&(n.visitorCompany=e.visitors[0].company),n},Yn=async e=>{var t;return{id:e.id||"-",state:e.status||"-",requester:e.createdBy||"-",createdOn:e.createdAt||"-",updatedOn:e.updatedAt||"-",requestType:"OSP Access",visitors:[{firstName:e.visitorFirstName||"-",lastName:e.visitorLastName||"-",email:e.visitorEmail||"-",phone:e.visitorPhone||"-",company:e.visitorCompany||"-",visitorType:e.visitorType}],visitorType:e.visitorType||"-",escortFirstName:e.escortFirstName||"-",escortLastName:e.escortLastName||"-",visitorHostFirstName:e.visitorHostFirstName||"-",visitorHostLastName:e.visitorHostLastName||"-",site:e.site||"-",sitesDetails:await Kn(e),customerExternalReference:e.customerExternalReference||"-",serviceImpacted:e.serviceImpactedDescription?"Yes":"No",serviceImpactDescription:e.serviceImpactedDescription||"-",workDescription:e.workDescription||"-",notificationRecipients:e.notificationRecipients||"",cancellationReason:e.cancellationReason||"-",comments:(t=e.comments)===null||t===void 0?void 0:t.map(i=>M(i))}},Xp=async e=>{var t,i,s,n,o;if(e)return{isVisitorContactsDetailsValid:!0,isVisitorEscortedDetailsValid:!0,isVisitorHostValid:!0,isRequestedAccessDetailsValid:!0,isServiceImpactedSectionValid:!0,isNotificationsAttachmentsValid:!0,accountNumber:(t=e.accountNumber)!==null&&t!==void 0?t:"",status:e.status,requestType:"OSP Access",category:"",visitors:[{firstName:(i=e.visitorFirstName)!==null&&i!==void 0?i:"",lastName:(s=e.visitorLastName)!==null&&s!==void 0?s:"",email:(n=e.visitorEmail)!==null&&n!==void 0?n:"",company:e.visitorCompany,phone:(o=e.visitorPhone)!==null&&o!==void 0?o:"",visitorType:e.visitorType}],isEscortedVisitor:!0,escortFirstName:e.escortFirstName,escortLastName:e.escortLastName,hostFirstName:e.visitorHostFirstName,hostLastName:e.visitorHostLastName,visitorBadge:"Standard",sitesDetails:await Kn(e),contacts:e.notificationRecipients,customerExternalReference:e.customerExternalReference,isServiceImpacted:!!e.serviceImpactedDescription,serviceImpactDescription:e.serviceImpactedDescription,workDescription:e.workDescription,termsAgreed:!0,id:e.id,attachments:[]}},Qp=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),me={newTicket:{isVisitorContactsDetailsValid:!1,isVisitorEscortedDetailsValid:!1,isVisitorHostValid:!1,isRequestedAccessDetailsValid:!1,isServiceImpactedSectionValid:!1,isNotificationsAttachmentsValid:!1,accountNumber:"",visitors:[],contacts:"",attachments:[],startDate:void 0,endDate:void 0,sitesDetails:void 0,visitorBadge:"Standard",serviceType:void 0,isEscortedVisitor:!0,escortFirstName:void 0,escortLastName:void 0,hostCompany:void 0,hostFirstName:void 0,hostLastName:void 0},selectedTicket:void 0,submissionResult:{state:w.Default,ticketNumbers:[],ticketResponse:void 0},loadings:{isSubmitting:!1,facilityAccessTicket:!1},isEditAttachmentAdded:!1};class Xn{constructor(){this.newTicket=me.newTicket,this.submissionResult=me.submissionResult,this.selectedTicket=me.selectedTicket,this.loadings=me.loadings,this.isEditAttachmentAdded=me.isEditAttachmentAdded,se(this)}async setNewTicket(){var t;try{this.newTicket=(t=await Xp(this.submissionResult.ticketResponse))!==null&&t!==void 0?t:me.newTicket}catch(i){throw await l(i,!1),i}}async getOSPAccessServiceTicket(t){if(t)try{const i=await m.facilityAccessApi.ospAccess.getOspAccessTicketById({ticketId:t});this.submissionResult.ticketResponse=i,this.selectedTicket=await Yn(i),await this.setNewTicket()}catch(i){throw await l(i,!1),i}}createTicket(){var t;const i=(t=this.newTicket.accountNumber)!==null&&t!==void 0?t:ae.getUserAccount().accountNumber;this.newTicket={...me.newTicket,accountNumber:i,requestType:"OSP Access",category:""},this.submissionResult=me.submissionResult}isNotificationsAttachmentsValid(t){this.newTicket.isNotificationsAttachmentsValid=t}updateAttachments(t){var i;(i=this.newTicket.attachments)===null||i===void 0||i.push(...t)}updateIsEscortedVisitor(t){this.newTicket.isEscortedVisitor=t,t?this.newTicket.visitorBadge=void 0:(this.newTicket.escortFirstName=void 0,this.newTicket.escortLastName=void 0,this.newTicket.visitorBadge===void 0&&(this.newTicket.visitorBadge="Standard"))}updateVisitorHost(t,i){var s;const n=(s=this.newTicket.sitesDetails)===null||s===void 0?void 0:s.find(o=>o.site.siteId===t);n&&(n.visitorHost=i,n.isVisitorHostDetailsValid=!0)}updateEscortFirstName(t){this.newTicket.escortFirstName=t}updateEscortLastName(t){this.newTicket.escortLastName=t}addOrUpdateVisitor(t){var i;if(t)if(this.newTicket.id)this.newTicket.visitors=[t];else{const s=((i=this.newTicket.visitors)!==null&&i!==void 0?i:[]).filter(n=>n.id!==t.id);this.newTicket.visitors=[...s,t]}}removeVisitor(t){var i;if(t){const s=((i=this.newTicket.visitors)!==null&&i!==void 0?i:[]).filter(n=>n.id!==t.id);this.newTicket.visitors=[...s]}}updateHostFirstName(t){this.newTicket.hostFirstName=t}updateHostLastName(t){this.newTicket.hostLastName=t}updateVisitorBadge(t){this.newTicket.visitorBadge=t}updateTermsAgreed(t){this.newTicket.termsAgreed=t}async addSiteLocations(t){var i;if(t){const s=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(n=>n.site.siteId!==t.site.siteId);this.newTicket.sitesDetails=[...s,t]}}removeSiteLocations(t){var i;if(t){const s=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(n=>n.site.siteId!==t.site.siteId);this.newTicket.sitesDetails=[...s]}}updateContacts(t){this.newTicket.contacts=t}async submitNewTicketRequest(){var t,i;let s;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{s=await m.facilityAccessApi.ospAccess.createOspAccessTicket({oSPAccessTicketRequest:Kp(this.newTicket)}),this.submissionResult.ticketNumbers=s==null?void 0:s.ticketNumbers}catch(n){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await l(n,!1),n}try{if(s){k.failedAttachments=((t=this.newTicket.attachments)!==null&&t!==void 0?t:[]).map(o=>o.fileName);const{ticketNumbers:n}=s;n!=null&&n.length&&!((i=this.newTicket.attachments)===null||i===void 0)&&i.length&&await Promise.all(this.newTicket.attachments.map(async o=>Promise.all(n.map(async a=>Pt(y.FacilityAccess,o.file,o.fileName,o.fileType,a,this.newTicket.requestType))).then(()=>{var a;k.failedAttachments=((a=this.newTicket.attachments)!==null&&a!==void 0?a:[]).filter(r=>r.fileName!==o.fileName).map(r=>r.fileName)}))),this.newTicket.attachments=void 0}}catch(n){throw k.error.uploadingAttachments=!0,await l(n,!1),n}finally{this.submissionResult.state=w.Submitted,this.loadings.isSubmitting=!1}}async submitUpdateTicketRequest(){let t;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{t=await m.facilityAccessApi.ospAccess.updateOspAccessTicket({oSPAccessTicketUpdateRequest:Yp(this.newTicket,this.selectedTicket),ticketId:this.newTicket.id}),this.submissionResult.ticketResponse=t,this.submissionResult.state=w.Submitted,this.submissionResult.ticketNumbers=[t==null?void 0:t.id]}catch(i){this.submissionResult.state=w.Error,await l(i,!1)}try{await k.postAttachments(y.FacilityAccess,this.newTicket.attachments,this.newTicket.id,!0,"OSP Access"),this.newTicket.attachments=void 0}catch(i){await l(i,!1)}try{t&&(this.selectedTicket=await Yn(t))}catch(i){await l(i,!1)}}catch(i){throw await l(i,!1),i}finally{this.loadings.isSubmitting=!1}}updateFieldValue(t,i){this.newTicket[t]=i}isVisitorContactsValid(t){this.newTicket.isVisitorContactsDetailsValid=t}isEscortedDetailsValid(t){this.newTicket.isVisitorEscortedDetailsValid=t}isRequestedAccessDetailsValid(t){this.newTicket.isRequestedAccessDetailsValid=t}addBulkVisitors(t){throw new Error("Method not implemented.")}removeBulkVisitors(){throw new Error("Method not implemented.")}removeBulkAttachment(){throw new Error("Method not implemented.")}removeAllVisitors(){this.newTicket.visitors=[]}async hasUpdatePermissions(){var t;try{return await bn((t=this.selectedTicket)===null||t===void 0?void 0:t.site)}catch(i){return!1}}async cancelTicket(t){var i;try{k.loadings.isTicketCancelling=!0,!((i=this.selectedTicket)===null||i===void 0)&&i.id&&(await m.facilityAccessApi.ospAccess.cancellationOspAccessRequest({ticketId:this.selectedTicket.id,cancellationTicketsRequest:{cancellationReason:t}}),await this.getOSPAccessServiceTicket(this.selectedTicket.id))}catch(s){throw await l(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}get isNewTicketValid(){const t=this.newTicket.isVisitorContactsDetailsValid,i=this.newTicket.isVisitorEscortedDetailsValid,s=this.newTicket.isVisitorHostValid,n=this.newTicket.isRequestedAccessDetailsValid,o=this.newTicket.isServiceImpactedSectionValid,a=this.newTicket.isNotificationsAttachmentsValid;return t&&i&&s&&n&&o&&a}clear(){this.newTicket=me.newTicket,this.selectedTicket=me.selectedTicket,this.submissionResult=me.submissionResult,this.loadings=me.loadings,this.isEditAttachmentAdded=me.isEditAttachmentAdded}}const Se=new Xn;function eh(e){return e.flatMap(t=>t.locations.map(i=>({id:i.id,startDateTime:Be(i.startDate,i.startTime,t.site.siteId),endDateTime:Be(i.endDate,i.endTime,t.site.siteId)})))}async function Qn(e){var t,i,s,n;const{timeZone:o,id:a}=(i=(t=J.sites)===null||t===void 0?void 0:t.find(u=>u.locationId===e.site))!==null&&i!==void 0?i:{},r=a?await _n(a):[],d=new Map(r.map(u=>{var p;return[u.id,(p=u.name)!==null&&p!==void 0?p:u.id]}));return[{site:new Oe(e.site,a,e.accountNumber),locations:(n=(s=e.locations)===null||s===void 0?void 0:s.map(u=>{var p,A,N,b;return{id:u.id,name:d.get(u.id)||u.id,site:a,startDate:u.startDateTime&&o?(p=G(u.startDateTime).tz(o))===null||p===void 0?void 0:p.format(ct):"-",startTime:u.startDateTime&&o?(A=G(u.startDateTime).tz(o))===null||A===void 0?void 0:A.format($t):"-",endDate:u.endDateTime&&o?(N=G(u.endDateTime).tz(o))===null||N===void 0?void 0:N.format(ct):"-",endTime:u.endDateTime&&o?(b=G(u.endDateTime).tz(o))===null||b===void 0?void 0:b.format($t):"-"}}))!==null&&n!==void 0?n:[]}]}async function th(e){const[t,i]=await Promise.all([Ze({locationType:F.Site,permissionType:S.POPPOEAccess,permissionPrivilege:e}),Ze({locationType:ut.GreaterThan+F.Site,permissionType:S.POPPOEAccess,permissionPrivilege:e,assignableProcess:"POP_access"})]),s=new Set(i.map(n=>n.siteId));return t.sort((n,o)=>n.siteId>o.siteId?1:-1).map(n=>({...n,hasSpaces:s.has(n.siteId),accountNumber:n.accountNumber}))}const Ei=e=>{var t;return(t=e==null?void 0:e.map(i=>{var s,n,o,a,r,d,u,p,A,N,b,C;return{sideAName:(s=i.sideAName)!==null&&s!==void 0?s:"",sideARoomNumber:(n=i.sideARoomNumber)!==null&&n!==void 0?n:"",sideARackNumber:(o=i.sideARackNumber)!==null&&o!==void 0?o:"",sideAPanelNumber:(a=i.sideAPanelNumber)!==null&&a!==void 0?a:"",sideAPort1:(r=i.sideAPort)!==null&&r!==void 0?r:"",sideACarrierCircuitId:(d=i.sideACarrierCircuitID)!==null&&d!==void 0?d:"",sideBName:(u=i.sideZName)!==null&&u!==void 0?u:"",sideBRoomNumber:(p=i.sideZRoomNumber)!==null&&p!==void 0?p:"",sideBRackNumber:(A=i.sideZRackNumber)!==null&&A!==void 0?A:"",sideBPanelNumber:(N=i.sideZPanelNumber)!==null&&N!==void 0?N:"",sideBPort1:(b=i.sideZPort)!==null&&b!==void 0?b:"",sideBCarrierCircuitId:(C=i.sideZCarrierCircuitID)!==null&&C!==void 0?C:""}}))!==null&&t!==void 0?t:[]},ea=e=>!e||e.length===1&&!e[0].rack&&!e[0].cabinet?[]:e.map(t=>{var i,s;return{rack:(i=t.rack)!==null&&i!==void 0?i:"",cabinet:(s=t.cabinet)!==null&&s!==void 0?s:""}}),ih=e=>({accountNumber:e.accountNumber,visitors:e.visitors.map(t=>({firstName:t.firstName,lastName:t.lastName,email:t.email,company:t.company,phone:t.phone,visitorType:t.visitorType})),locations:eh(e.sitesDetails||[]),escortFirstName:e.escortFirstName,escortLastName:e.escortLastName,visitorHostFirstName:e.hostFirstName,visitorHostLastName:e.hostLastName,customerExternalReference:e.customerExternalReference,serviceImpactedDescription:e.serviceImpactDescription,serviceDetails:{serviceType:e.serviceType,scope:e.scope,circuits:Ei(e.circuits),workDescription:e.descriptionOfWork},ppopSpace:ea(e.ppopSpaces),spopSpace:ea(e.spopSpaces),ppopRoomWork:e.isPpopCableRunOutside?{ppopSpaceFrom:e.ppopFromRackPanel,ppopSpaceTo:e.ppopToRackPanel,cableType:e.ppopCableType,onLadderRack:e.ppopLadderRack,inInnerDuct:e.ppopInnerDuct,inFiberGuide:e.ppopFiberGuide}:void 0,spopRoomWork:e.isSpopCableRunOutside?{spopSpaceFrom:e.spopFromRackPanel,spopSpaceTo:e.spopToRackPanel,cableType:e.spopCableType,onLadderRack:e.spopLadderRack,inInnerDuct:e.spopInnerDuct,inFiberGuide:e.spopFiberGuide}:void 0,notificationRecipients:e.contacts}),ta=e=>(e==null?void 0:e.map(t=>({sideAName:t.sideAName||"-",sideARoomNumber:t.sideARoomNumber||"-",sideARackNumber:t.sideARackNumber||"-",sideAPanelNumber:t.sideAPanelNumber||"-",sideAPort:t.sideAPort1||"-",sideACarrierCircuitID:t.sideACarrierCircuitId||"-",sideZName:t.sideBName||"-",sideZRoomNumber:t.sideBRoomNumber||"-",sideZRackNumber:t.sideBRackNumber||"-",sideZPanelNumber:t.sideBPanelNumber||"-",sideZPort:t.sideBPort1||"-",sideZCarrierCircuitID:t.sideBCarrierCircuitId||"-"})))||[],ia=async e=>{var t,i,s,n,o,a,r,d,u,p,A,N,b,C,x,et,tt,it,st,nt,at;return{id:e.id||"-",state:e.status||"-",requester:e.createdBy||"-",createdOn:e.createdAt||"-",updatedOn:e.updatedAt||"-",requestType:"PoP/POE Access",visitors:[{firstName:e.visitorFirstName||"-",lastName:e.visitorLastName||"-",email:e.visitorEmail||"-",phone:e.visitorPhone||"-",company:e.visitorCompany||"-",visitorType:e.visitorType}],visitorType:e.visitorType||"-",escortFirstName:e.escortFirstName||"-",escortLastName:e.escortLastName||"-",visitorHostFirstName:e.visitorHostFirstName||"-",visitorHostLastName:e.visitorHostLastName||"-",visitorHostCompany:e.visitorHostCompany||"-",site:e.site||"-",sitesDetails:await Qn(e),customerExternalReference:e.customerExternalReference||"-",isServiceImpacted:!!e.serviceImpactedDescription,serviceImpactDescription:e.serviceImpactedDescription||"-",serviceType:((t=e.serviceDetails)===null||t===void 0?void 0:t.serviceType)||"-",scope:((i=e.serviceDetails)===null||i===void 0?void 0:i.scope)||"-",isCrossConnectPatchCableInstallationOrRemoval:!!(!((n=(s=e.serviceDetails)===null||s===void 0?void 0:s.circuits)===null||n===void 0)&&n.length),workDescription:((o=e.serviceDetails)===null||o===void 0?void 0:o.workDescription)||"-",circuits:ta((a=e.serviceDetails)===null||a===void 0?void 0:a.circuits),ppopSpaces:((r=e.ppopSpace)===null||r===void 0?void 0:r.map(ge=>({rack:ge.rack||"",cabinet:ge.cabinet||""})))||[],spopSpaces:((d=e.spopSpace)===null||d===void 0?void 0:d.map(ge=>({rack:ge.rack||"",cabinet:ge.cabinet||""})))||[],isPpopCableRunOutside:!!e.ppopRoomWork&&Object.keys(e.ppopRoomWork).length>0,ppopFromRackPanel:((u=e.ppopRoomWork)===null||u===void 0?void 0:u.ppopSpaceFrom)||"-",ppopToRackPanel:((p=e.ppopRoomWork)===null||p===void 0?void 0:p.ppopSpaceTo)||"-",ppopCableType:((A=e.ppopRoomWork)===null||A===void 0?void 0:A.cableType)||"-",ppopLadderRack:(N=e.ppopRoomWork)===null||N===void 0?void 0:N.onLadderRack,ppopInnerDuct:(b=e.ppopRoomWork)===null||b===void 0?void 0:b.inInnerDuct,ppopFiberGuide:(C=e.ppopRoomWork)===null||C===void 0?void 0:C.inFiberGuide,isSpopCableRunOutside:!!(e.spopRoomWork&&Object.keys(e.spopRoomWork).length>0),spopFromRackPanel:((x=e.spopRoomWork)===null||x===void 0?void 0:x.spopSpaceFrom)||"-",spopToRackPanel:((et=e.spopRoomWork)===null||et===void 0?void 0:et.spopSpaceTo)||"-",spopCableType:((tt=e.spopRoomWork)===null||tt===void 0?void 0:tt.cableType)||"-",spopLadderRack:(it=e.spopRoomWork)===null||it===void 0?void 0:it.onLadderRack,spopInnerDuct:(st=e.spopRoomWork)===null||st===void 0?void 0:st.inInnerDuct,spopFiberGuide:(nt=e.spopRoomWork)===null||nt===void 0?void 0:nt.inFiberGuide,notificationRecipients:e.notificationRecipients||"",cancellationReason:e.cancellationReason||"-",comments:(at=e.comments)===null||at===void 0?void 0:at.map(ge=>M(ge))}},sh=async e=>{var t,i,s,n,o,a,r,d,u,p,A,N,b,C,x,et,tt,it,st,nt,at,ge,pi,hi,vi;if(e)return{isVisitorContactsDetailsValid:!0,isVisitorEscortedDetailsValid:!0,isVisitorHostValid:!0,isRequestedAccessDetailsValid:!0,isNotificationsAttachmentsValid:!0,isPopRequestedAccessValid:!0,accountNumber:(t=e.accountNumber)!==null&&t!==void 0?t:"",status:e.status,requestType:"PoP/POE Access",category:"",id:e.id,visitors:[{firstName:(i=e.visitorFirstName)!==null&&i!==void 0?i:"",lastName:(s=e.visitorLastName)!==null&&s!==void 0?s:"",email:(n=e.visitorEmail)!==null&&n!==void 0?n:"",company:e.visitorCompany,phone:(o=e.visitorPhone)!==null&&o!==void 0?o:"",visitorType:e.visitorType}],isEscortedVisitor:!0,escortFirstName:e.escortFirstName,escortLastName:e.escortLastName,sitesDetails:await Qn(e),hostFirstName:e.visitorHostFirstName,hostLastName:e.visitorHostLastName,customerExternalReference:e.customerExternalReference,isServiceImpacted:!!e.serviceImpactedDescription,serviceImpactDescription:e.serviceImpactedDescription,termsAgreed:!0,serviceType:(a=e.serviceDetails)===null||a===void 0?void 0:a.serviceType,scope:(r=e.serviceDetails)===null||r===void 0?void 0:r.scope,isCrossConnectInstallation:!!(!((u=(d=e.serviceDetails)===null||d===void 0?void 0:d.circuits)===null||u===void 0)&&u.length),descriptionOfWork:(p=e.serviceDetails)===null||p===void 0?void 0:p.workDescription,circuits:ta((A=e.serviceDetails)===null||A===void 0?void 0:A.circuits),ppopSpaces:((N=e.ppopSpace)===null||N===void 0?void 0:N.map(Tt=>({rack:Tt.rack||"",cabinet:Tt.cabinet||""})))||[],spopSpaces:((b=e.spopSpace)===null||b===void 0?void 0:b.map(Tt=>({rack:Tt.rack||"",cabinet:Tt.cabinet||""})))||[],isPpopCableRunOutside:!!e.ppopRoomWork&&Object.keys(e.ppopRoomWork).length>0,ppopFromRackPanel:(C=e.ppopRoomWork)===null||C===void 0?void 0:C.ppopSpaceFrom,ppopToRackPanel:(x=e.ppopRoomWork)===null||x===void 0?void 0:x.ppopSpaceTo,ppopCableType:(et=e.ppopRoomWork)===null||et===void 0?void 0:et.cableType,ppopLadderRack:(tt=e.ppopRoomWork)===null||tt===void 0?void 0:tt.onLadderRack,ppopInnerDuct:(it=e.ppopRoomWork)===null||it===void 0?void 0:it.inInnerDuct,ppopFiberGuide:(st=e.ppopRoomWork)===null||st===void 0?void 0:st.inFiberGuide,isSpopCableRunOutside:!!(e.spopRoomWork&&Object.keys(e.spopRoomWork).length>0),spopFromRackPanel:(nt=e.spopRoomWork)===null||nt===void 0?void 0:nt.spopSpaceFrom,spopToRackPanel:(at=e.spopRoomWork)===null||at===void 0?void 0:at.spopSpaceTo,spopCableType:(ge=e.spopRoomWork)===null||ge===void 0?void 0:ge.cableType,spopLadderRack:(pi=e.spopRoomWork)===null||pi===void 0?void 0:pi.onLadderRack,spopInnerDuct:(hi=e.spopRoomWork)===null||hi===void 0?void 0:hi.inInnerDuct,spopFiberGuide:(vi=e.spopRoomWork)===null||vi===void 0?void 0:vi.inFiberGuide,contacts:e.notificationRecipients,attachments:[]}},nh=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),He=(e,t)=>(e!=null?e:!1)!==(t!=null?t:!1),B=(e,t)=>!(e===t||!e&&!t||!e&&t==="-"),ah=(e,t)=>B(e.sideAName,t.sideAName)||B(e.sideARoomNumber,t.sideARoomNumber)||B(e.sideARackNumber,t.sideARackNumber)||B(e.sideAPanelNumber,t.sideAPanelNumber)||B(e.sideAPort,t.sideAPort)||B(e.sideACarrierCircuitID,t.sideACarrierCircuitID)||B(e.sideZName,t.sideZName)||B(e.sideZRoomNumber,t.sideZRoomNumber)||B(e.sideZRackNumber,t.sideZRackNumber)||B(e.sideZPanelNumber,t.sideZPanelNumber)||B(e.sideZPort,t.sideZPort)||B(e.sideZCarrierCircuitID,t.sideZCarrierCircuitID),oh=(e,t)=>{if(e===void 0)return t.length!==0;if(e.length!==t.length)return!0;for(let i=0;i<e.length;i++)if(ah(e[i],t[i]))return!0;return!1},sa=(e,t)=>{if(e===void 0&&!(t!=null&&t.length))return!1;if(!e||!t||e.length!==t.length)return!0;for(let i=0;i<e.length;i++)if(B(e[i].rack,t[i].rack)||B(e[i].cabinet,t[i].cabinet))return!0;return!1},rh=(e,t)=>{var i,s;const n={};B(e.visitors[0].company,t.visitors[0].company)&&(n.visitorCompany=e.visitors[0].company),(B(e.escortFirstName,t.escortFirstName)||B(e.escortLastName,t.escortLastName))&&(n.escortFirstName=e.escortFirstName,n.escortLastName=e.escortLastName);const o=((i=e.sitesDetails)===null||i===void 0?void 0:i.flatMap(d=>d.locations.map(u=>({id:u.id,startDate:u.startDate,startTime:u.startTime,endDate:u.endDate,endTime:u.endTime,siteId:d.site.siteId}))))||[],a=((s=t.sitesDetails)===null||s===void 0?void 0:s.flatMap(d=>d.locations))||[],r=o.map(d=>{const u=a.find(A=>A.id===d.id),p={id:d.id};return(!u||B(d.startDate,u.startDate)||B(d.startTime,u.startTime)||B(d.endDate,u.endDate)||B(d.endTime,u.endTime))&&(p.startDateTime=Be(d.startDate,d.startTime,d.siteId),p.endDateTime=Be(d.endDate,d.endTime,d.siteId)),p}).filter(d=>d.startDateTime&&d.endDateTime);if(r.length&&(n.locations=r),(B(e.hostFirstName,t.visitorHostFirstName)||B(e.hostLastName,t.visitorHostLastName))&&(n.visitorHostFirstName=e.hostFirstName,n.visitorHostLastName=e.hostLastName),He(e.isServiceImpacted,t.isServiceImpacted)&&e.isServiceImpacted===!1&&(n.serviceImpactedDescription=""),B(e.serviceImpactDescription,t.serviceImpactDescription)&&(n.serviceImpactedDescription=e.serviceImpactDescription),n.serviceDetails={},B(e.serviceType,t.serviceType))switch(n.serviceDetails.serviceType=e.serviceType,e.serviceType){case We.SiteSurvey:case We.Testing:n.serviceDetails.scope=e.scope,n.serviceDetails.workDescription="",n.serviceDetails.circuits=[];break;case We.InstallationDeInstallationWork:n.serviceDetails.scope="",n.serviceDetails.workDescription=e.descriptionOfWork,n.serviceDetails.circuits=Ei(e.circuits);break;default:throw new Error("Unsupported service type for update")}else switch(e.serviceType){case We.SiteSurvey:case We.Testing:B(e.scope,t.scope)&&(n.serviceDetails.scope=e.scope);break;case We.InstallationDeInstallationWork:B(e.descriptionOfWork,t.workDescription)&&(n.serviceDetails.workDescription=e.descriptionOfWork),oh(e.circuits,t.circuits)&&(n.serviceDetails.circuits=Ei(e.circuits));break;default:throw new Error("Unsupported service type for update")}return Object.keys(n.serviceDetails).length===0&&delete n.serviceDetails,sa(e.ppopSpaces,t.ppopSpaces)&&(n.ppopSpace=e.ppopSpaces),sa(e.spopSpaces,t.spopSpaces)&&(n.spopSpace=e.spopSpaces),e.isPpopCableRunOutside?(n.ppopRoomWork={},B(e.ppopFromRackPanel,t.ppopFromRackPanel)&&(n.ppopRoomWork.ppopSpaceFrom=e.ppopFromRackPanel),B(e.ppopToRackPanel,t.ppopToRackPanel)&&(n.ppopRoomWork.ppopSpaceTo=e.ppopToRackPanel),B(e.ppopCableType,t.ppopCableType)&&(n.ppopRoomWork.cableType=e.ppopCableType),He(e.ppopLadderRack,t.ppopLadderRack)&&(n.ppopRoomWork.onLadderRack=e.ppopLadderRack),He(e.ppopInnerDuct,t.ppopInnerDuct)&&(n.ppopRoomWork.inInnerDuct=e.ppopInnerDuct),He(e.ppopFiberGuide,t.ppopFiberGuide)&&(n.ppopRoomWork.inFiberGuide=e.ppopFiberGuide),Object.keys(n.ppopRoomWork).length===0&&delete n.ppopRoomWork):He(e.isPpopCableRunOutside,t.isPpopCableRunOutside)&&(n.ppopRoomWork=null),e.isSpopCableRunOutside?(n.spopRoomWork={},B(e.spopFromRackPanel,t.spopFromRackPanel)&&(n.spopRoomWork.spopSpaceFrom=e.spopFromRackPanel),B(e.spopToRackPanel,t.spopToRackPanel)&&(n.spopRoomWork.spopSpaceTo=e.spopToRackPanel),B(e.spopCableType,t.spopCableType)&&(n.spopRoomWork.cableType=e.spopCableType),He(e.spopLadderRack,t.spopLadderRack)&&(n.spopRoomWork.onLadderRack=e.spopLadderRack),He(e.spopInnerDuct,t.spopInnerDuct)&&(n.spopRoomWork.inInnerDuct=e.spopInnerDuct),He(e.spopFiberGuide,t.spopFiberGuide)&&(n.spopRoomWork.inFiberGuide=e.spopFiberGuide),Object.keys(n.spopRoomWork).length===0&&delete n.spopRoomWork):He(e.isSpopCableRunOutside,t.isSpopCableRunOutside)&&(n.spopRoomWork=null),B(e.visitors[0].phone,t.visitors[0].phone)&&(n.visitorPhone=e.visitors[0].phone),B(e.customerExternalReference,t.customerExternalReference)&&(n.customerExternalReference=e.customerExternalReference),B(e.contacts,t.notificationRecipients)&&(n.notificationRecipients=e.contacts),Object.keys(n).length===0&&(n.visitorCompany=e.visitors[0].company),n},pe={newTicket:{isVisitorContactsDetailsValid:!1,isVisitorEscortedDetailsValid:!1,isVisitorHostValid:!1,isRequestedAccessDetailsValid:!1,isPopRequestedAccessValid:!1,isPPopRoomWorkValid:!1,isSPopRoomWorkValid:!1,isNotificationsAttachmentsValid:!1,accountNumber:"",visitors:[],contacts:"",attachments:[],startDate:void 0,endDate:void 0,sitesDetails:void 0,visitorBadge:"Standard",serviceType:void 0,isEscortedVisitor:!0,escortFirstName:void 0,escortLastName:void 0,hostCompany:void 0,hostFirstName:void 0,hostLastName:void 0,ppopSpaces:[{}],spopSpaces:[{}]},selectedTicket:void 0,submissionResult:{state:w.Default,ticketNumbers:[],popAccessResponse:void 0},loadings:{isSubmitting:!1,facilityAccessTicket:!1},isEditAttachmentAdded:!1};class na{constructor(){this.newTicket=pe.newTicket,this.submissionResult=pe.submissionResult,this.selectedTicket=pe.selectedTicket,this.loadings=pe.loadings,this.isEditAttachmentAdded=pe.isEditAttachmentAdded,se(this)}createTicket(){var t,i;const s=(t=this.newTicket.accountNumber)!==null&&t!==void 0?t:ae.getUserAccount().accountNumber;this.newTicket={...pe.newTicket,accountNumber:s,requestType:"PoP/POE Access",category:"",serviceBackend:(i=this.newTicket.serviceBackend)!==null&&i!==void 0?i:void 0},this.submissionResult=pe.submissionResult}async setNewTicket(){try{this.newTicket=await sh(this.submissionResult.ticketResponse),this.newTicket||(this.newTicket=pe.newTicket)}catch(t){throw await l(t,!1),t}}async getPOPAccessServiceTicket(t){if(t)try{const i=await m.facilityAccessApi.popAccess.getPopAccessTicketById({ticketId:t});this.submissionResult.ticketResponse=i,this.selectedTicket=await ia(i)}catch(i){throw await l(i,!1),i}}async hasUpdatePermissions(){var t;try{return await Rn((t=this.selectedTicket)===null||t===void 0?void 0:t.site)}catch(i){return!1}}isNotificationsAttachmentsValid(t){this.newTicket.isNotificationsAttachmentsValid=t}updateAttachments(t){var i;(i=this.newTicket.attachments)===null||i===void 0||i.push(...t)}updateIsEscortedVisitor(t){this.newTicket.isEscortedVisitor=t,t?this.newTicket.visitorBadge=void 0:(this.newTicket.escortFirstName=void 0,this.newTicket.escortLastName=void 0,this.newTicket.visitorBadge===void 0&&(this.newTicket.visitorBadge="Standard"))}updateVisitorHost(t,i){var s;const n=(s=this.newTicket.sitesDetails)===null||s===void 0?void 0:s.find(o=>o.site.siteId===t);n&&(n.visitorHost=i,n.isVisitorHostDetailsValid=!0)}updateEscortFirstName(t){this.newTicket.escortFirstName=t}updateEscortLastName(t){this.newTicket.escortLastName=t}addVisitor(t){var i;if(t)if(this.newTicket.id)this.newTicket.visitors=[t];else{const s=((i=this.newTicket.visitors)!==null&&i!==void 0?i:[]).filter(n=>n.id!==t.id);this.newTicket.visitors=[...s,t]}}removeVisitor(t){var i;if(t){const s=((i=this.newTicket.visitors)!==null&&i!==void 0?i:[]).filter(n=>n.id!==t.id);this.newTicket.visitors=[...s]}}addOrUpdateVisitor(t){var i;if(t)if(this.newTicket.id)this.newTicket.visitors=[t];else{const s=((i=this.newTicket.visitors)!==null&&i!==void 0?i:[]).filter(n=>n.id!==t.id);this.newTicket.visitors=[...s,t]}}updateHostFirstName(t){this.newTicket.hostFirstName=t}updateHostLastName(t){this.newTicket.hostLastName=t}updateVisitorBadge(t){this.newTicket.visitorBadge=t}updateTermsAgreed(t){this.newTicket.termsAgreed=t}updateStartDate(t){var i;this.newTicket.startDate=t,(i=this.newTicket.sitesDetails)===null||i===void 0||i.forEach(s=>{s.locations.forEach(n=>{n.startDate=t})})}updateEndDate(t){var i;this.newTicket.endDate=t,(i=this.newTicket.sitesDetails)===null||i===void 0||i.forEach(s=>{s.locations.forEach(n=>{n.endDate=t})})}async addSiteLocations(t){var i;if(t){const s=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(n=>n.site.siteId!==t.site.siteId);this.newTicket.sitesDetails=[...s,t]}}removeSiteLocations(t){var i;if(t){const s=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(n=>n.site.siteId!==t.site.siteId);this.newTicket.sitesDetails=[...s]}}updateContacts(t){this.newTicket.contacts=t}async submitNewTicketRequest(){var t;this.resetSubmission();try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;const i=await m.facilityAccessApi.popAccess.createPopAccessTicket({pOPAccessTicketRequest:ih(this.newTicket)}).catch(s=>{throw l(s,!1),this.submissionResult.state=w.Error,s});if(i){const{ticketNumbers:s}=i;s!=null&&s.length&&!((t=this.newTicket.attachments)===null||t===void 0)&&t.length&&await Promise.all(s.map(async n=>{await k.postAttachments(y.FacilityAccess,this.newTicket.attachments,n,!1,"PoP/POE Access")})),this.newTicket.attachments=void 0,this.submissionResult.state=w.Submitted,this.submissionResult.ticketNumbers=i==null?void 0:i.ticketNumbers}}catch(i){throw await l(i,!1),this.submissionResult.state=w.Error,i}finally{this.loadings.isSubmitting=!1}}async cancelTicket(t){var i;try{k.loadings.isTicketCancelling=!0,!((i=this.selectedTicket)===null||i===void 0)&&i.id&&(await m.facilityAccessApi.popAccess.cancellationPopAccessRequest({ticketId:this.selectedTicket.id,cancellationTicketsRequest:{cancellationReason:t}}),await this.getPOPAccessServiceTicket(this.selectedTicket.id))}catch(s){throw await l(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}async submitUpdateTicketRequest(){let t;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{t=await m.facilityAccessApi.popAccess.updatePopAccessTicket({pOPAccessTicketUpdateRequest:rh(this.newTicket,this.selectedTicket),ticketId:this.newTicket.id}),this.submissionResult.ticketResponse=t,this.submissionResult.state=w.Submitted,this.submissionResult.ticketNumbers=[t==null?void 0:t.id]}catch(i){throw this.submissionResult.state=w.Error,await l(i,!1),i}try{await k.postAttachments(y.FacilityAccess,this.newTicket.attachments,this.newTicket.id,!0,"PoP/POE Access"),this.newTicket.attachments=[]}catch(i){await l(i,!1)}try{t&&(this.selectedTicket=await ia(t))}catch(i){throw await l(i,!1),i}}finally{this.loadings.isSubmitting=!1}}resetSubmission(){this.submissionResult=pe.submissionResult}clearNewTicket(){this.newTicket=pe.newTicket}clear(){this.newTicket=pe.newTicket,this.selectedTicket=pe.selectedTicket,this.submissionResult=pe.submissionResult}updateFieldValue(t,i){this.newTicket[t]=i}updateIsServiceImpacted(t){this.newTicket.isServiceImpacted=t}updateCustomerExternalReference(t){this.newTicket.customerExternalReference=t}updateServiceImpactDescription(t){this.newTicket.serviceImpactDescription=t}updateServiceType(t){this.newTicket.serviceType=t,t===We.InstallationDeInstallationWork&&this.updateScope(""),this.updateIsCrossConnectInstallation(!1)}updateScope(t){this.newTicket.scope=t}updateDescriptionOfWork(t){this.newTicket.descriptionOfWork=t}updateIsCrossConnectInstallation(t){this.newTicket.isCrossConnectInstallation=t,t?this.newTicket.circuits=[{}]:(this.updateDescriptionOfWork(""),this.newTicket.circuits=void 0)}updateIsPPopCableRunOutside(t){this.newTicket.isPpopCableRunOutside=t,t||(this.newTicket.ppopFromRackPanel=void 0,this.newTicket.ppopToRackPanel=void 0,this.newTicket.ppopCableType=void 0,this.newTicket.ppopLadderRack=void 0,this.newTicket.ppopInnerDuct=void 0,this.newTicket.ppopFiberGuide=void 0)}updateIsSPopCableRunOutside(t){this.newTicket.isSpopCableRunOutside=t,t||(this.newTicket.spopFromRackPanel=void 0,this.newTicket.spopToRackPanel=void 0,this.newTicket.spopCableType=void 0,this.newTicket.spopLadderRack=void 0,this.newTicket.spopInnerDuct=void 0,this.newTicket.spopFiberGuide=void 0)}updateCircuitField(t,i,s){var n;(!this.newTicket.circuits||((n=this.newTicket.circuits)===null||n===void 0?void 0:n.length)===0)&&(this.newTicket.circuits=[{}]);const o=[...this.newTicket.circuits];o[s][i]=t,this.newTicket.circuits=o}isVisitorContactsValid(t){this.newTicket.isVisitorContactsDetailsValid=t}isEscortedDetailsValid(t){this.newTicket.isVisitorEscortedDetailsValid=t}isRequestedAccessDetailsValid(t){this.newTicket.isRequestedAccessDetailsValid=t}addBulkVisitors(t){throw new Error("Method not implemented.")}removeBulkVisitors(){throw new Error("Method not implemented.")}removeBulkAttachment(){throw new Error("Method not implemented.")}removeAllVisitors(){this.newTicket.visitors=[]}get isNewTicketValid(){const t=this.newTicket.isVisitorContactsDetailsValid,i=this.newTicket.isVisitorEscortedDetailsValid,s=this.newTicket.isVisitorHostValid,n=this.newTicket.isRequestedAccessDetailsValid,o=this.newTicket.isPopRequestedAccessValid;return t&&i&&s&&n&&o}get isAdditionalComponentValid(){return this.newTicket.isPPopRoomWorkValid&&this.newTicket.isSPopRoomWorkValid&&this.newTicket.isNotificationsAttachmentsValid}}const Ce=new na;var ti;(function(e){e.PLANNED_MAINTENANCE="Planned Maintenance",e.INCIDENTS="Incidents",e.DCIM_ALERTS="DCIM Alerts",e.SERVICE_TICKETS="Service Tickets"})(ti||(ti={}));const ch=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),M=e=>({comment:e.comment,commentedBy:e.createdBy,commentedOn:e.createdAt});async function dh(e,t,i){var s,n,o,a,r,d,u,p,A,N;let b;switch(e){case y.Deliveries:{const C=await m.deliveriesApi.createDeliveriesComment(Gm(t,i)).catch(x=>{l(x,!1)});b=(s=C==null?void 0:C.comments)===null||s===void 0?void 0:s.map(M),be.selectedTicket&&(be.selectedTicket.comments=b);break}case y.Removals:{const C=await m.removalsApi.createComment(rp(t,i)).catch(x=>{l(x,!1)});b=(n=C==null?void 0:C.comments)===null||n===void 0?void 0:n.map(M),Ve.selectedTicket&&(Ve.selectedTicket.comments=b);break}case y.RemoteHands:{const C=await m.remoteHandsApi.createRemoteHandsComment(Qm(t,i)).catch(x=>{l(x,!1)});b=(o=C==null?void 0:C.comments)===null||o===void 0?void 0:o.map(M),re.selectedTicket&&(re.selectedTicket.comments=b);break}case y.VisitorAccess:{const C=await m.facilityAccessApi.visitorAccess.createVisitorAccessComment(Pp(t,i)).catch(x=>{l(x,!1)});b=(a=C==null?void 0:C.comments)===null||a===void 0?void 0:a.map(M),ie.selectedTicket&&(ie.selectedTicket.comments=b);break}case y.PermanentBadge:{const C=await m.facilityAccessApi.permanentBadgeAccess.createPermanentBadgeComment(jp(t,i)).catch(x=>{l(x,!1)});b=(r=C==null?void 0:C.comments)===null||r===void 0?void 0:r.map(M),Y.selectedTicket&&(Y.selectedTicket.comments=b);break}case y.CustomerSupport:{const C=await m.customerCareApi.createCustomerCareComment(bp(t,i)).catch(x=>{l(x,!1)});b=(d=C==null?void 0:C.comments)===null||d===void 0?void 0:d.map(M),je.selectedTicket&&(je.selectedTicket.comments=b);break}case y.TroubleTickets:{const C=await m.troubleTicketsApi.createTroubleTicketComment(up(t,i)).catch(x=>{l(x,!1)});b=(u=C==null?void 0:C.comments)===null||u===void 0?void 0:u.map(M),Ue.selectedTicket&&(Ue.selectedTicket.comments=b);break}case y.OSPAccess:{const C=await m.facilityAccessApi.ospAccess.createOspAccessComment(Qp(t,i)).catch(x=>{l(x,!1)});b=(p=C==null?void 0:C.comments)===null||p===void 0?void 0:p.map(M),Se.selectedTicket&&(Se.selectedTicket.comments=b);break}case y.POPPOEAccess:{const C=await m.facilityAccessApi.popAccess.createPopAccessComment(nh(t,i)).catch(x=>{l(x,!1)});b=(A=C==null?void 0:C.comments)===null||A===void 0?void 0:A.map(M),Ce.selectedTicket&&(Ce.selectedTicket.comments=b);break}case ti.INCIDENTS:{const C=await m.incidentsApi.createIncidentComment(ch(t,i)).catch(x=>{l(x,!1)});b=(N=C==null?void 0:C.comments)===null||N===void 0?void 0:N.map(M);break}default:return}return b}const uh=e=>({subject:e.subject,customerReference:e.customerReferenceNumber,description:e.description,otherNotificationRecipients:e.contacts}),lh=e=>{var t;return{accountNumber:e.accountNumber,subject:e.subject,requestType:e.requestType,category:e.category,locations:!((t=e.location)===null||t===void 0)&&t.id?[e.location.id]:[],customerReference:e.customerReferenceNumber,description:e.description,notificationRecipients:e.contacts}},mh=async e=>{if(e)return{accountNumber:e.accountNumber,serviceBackend:await K.getServiceBackend(e.accountNumber,e.site,"Customer_care"),subject:e.subject,requestType:e.requestType,category:e.category,site:{id:e.site,accountNumber:e.accountNumber},location:{id:e.locations[0],accountNumber:e.accountNumber},customerReferenceNumber:e.customerReference,description:e.description,contacts:e.notificationRecipients}},aa=async e=>{var t,i,s,n,o;if(e)return{id:e.id,accountName:e.accountName,accountNumber:e.accountNumber,serviceBackend:await K.getServiceBackend(e.accountNumber,e.site,"Customer_care"),subject:e.subject,description:e.description,customerReference:e.customerReference,site:e.site,location:!((t=e.locations)===null||t===void 0)&&t.length?e.locations[0]:"",notificationRecipients:e.notificationRecipients,status:e.status,createdBy:e.createdBy,createdAt:(i=e.createdAt)===null||i===void 0?void 0:i.toISOString(),updatedAt:(s=e.updatedAt)===null||s===void 0?void 0:s.toISOString(),closedAt:(n=e.closedAt)===null||n===void 0?void 0:n.toISOString(),cancellationReason:e.cancellationReason,requestType:e.requestType,category:e.category,comments:(o=e.comments)===null||o===void 0?void 0:o.map(a=>M(a))}},ze={selectedTicket:void 0,ticket:{isValid:!1,subject:"",description:"",site:void 0,requestType:"",category:"",customerReferenceNumber:"",contacts:"",attachments:[],accountNumber:""},submissionResult:{state:w.Default,result:void 0},loadings:{isSubmitting:!1}};class ph{constructor(){this.selectedTicket=ze.selectedTicket,this.ticket=ze.ticket,this.submissionResult=ze.submissionResult,this.loadings=ze.loadings,se(this),Je(this,{name:"customerCare",properties:[],storage:window.localStorage})}async setTicket(){try{this.ticket=await mh(this.submissionResult.result)||ze.ticket}catch(t){throw await l(t,!1),t}}async getSelectedTicket(t){if(t)try{const i=await m.customerCareApi.getCustomerCareTicketById({ticketId:t});this.submissionResult.result=i,this.selectedTicket=await aa(i),await this.setTicket()}catch(i){throw await l(i,!1),i}}async getCategories(t,i){if(!(!t||!i))try{return await m.customerCareApi.getCustomerCareCategoriesList({site:t,accountNumber:i})}catch(s){throw await l(s,!1),s}}async cancelTicket(t){var i;try{k.loadings.isTicketCancelling=!0,!((i=this.selectedTicket)===null||i===void 0)&&i.id&&(await m.customerCareApi.cancellationCustomerCareRequest({ticketId:this.selectedTicket.id,cancellationTicketsRequest:{cancellationReason:t}}).catch(s=>{throw l(s,!1),s}),await this.getSelectedTicket(this.selectedTicket.id))}finally{k.loadings.isTicketCancelling=!1}}async updateSite(t){this.ticket.site=t,this.ticket.accountNumber=t.accountNumber}async createTicket(){var t;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{this.submissionResult.result=await m.customerCareApi.createCustomerCareTicket({customerCareTicketRequest:lh(this.ticket)}),this.submissionResult.state=w.Submitted}catch(i){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await l(i,!1),i}try{!((t=this.submissionResult.result)===null||t===void 0)&&t.id&&await k.postAttachments(y.CustomerSupport,this.ticket.attachments,this.submissionResult.result.id),this.ticket.attachments=void 0}catch(i){throw await l(i,!1),i}finally{this.loadings.isSubmitting=!1}}async updateTicket(){var t,i;let s;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{s=await m.customerCareApi.updateCustomerCareTicket({ticketId:((t=this.selectedTicket)===null||t===void 0?void 0:t.id)||"",customerCareTicketUpdateRequest:uh(this.ticket)}),this.submissionResult.result=s,this.submissionResult.state=w.Submitted}catch(n){throw this.submissionResult.state=w.Error,await l(n,!1),n}try{await k.postAttachments(y.CustomerSupport,this.ticket.attachments,(i=this.selectedTicket)===null||i===void 0?void 0:i.id,!0),this.ticket.attachments=void 0}catch(n){throw await l(n,!1),n}try{s&&(this.selectedTicket=await aa(s),await this.setTicket())}catch(n){throw await l(n,!1),n}}finally{this.loadings.isSubmitting=!1}}updateLocation(t){this.ticket.location=t}clear(){this.ticket=ze.ticket,this.selectedTicket=ze.selectedTicket,this.submissionResult=ze.submissionResult,this.loadings=ze.loadings}}const je=new ph,ve=bt` *, ::before, ::after {
1
+ import{__decorate as E}from"tslib";import{css as bt,html as g,LitElement as Rt,nothing as P,svg as Ot}from"lit";import{property as we,customElement as X,state as Ji}from"lit/decorators.js";import G from"moment";import{baseTheme as ua}from"@digital-realty/theme";import he from"moment-timezone";import"date-fns/format.js";import{makeAutoObservable as se}from"mobx";import{makePersistable as Je}from"mobx-persist-store";import{authedUser as ot}from"@digital-realty/ix-account-switcher";import{Router as rt}from"@vaadin/router";import{User as la,UserManager as ma}from"oidc-client-ts";import{MobxLitElement as _e}from"@adobe/lit-mobx";import{ifDefined as pa}from"lit/directives/if-defined.js";import"@digital-realty/ix-select/ix-select.js";import"@digital-realty/ix-select/ix-select-option.js";import"@digital-realty/ix-icon-button/ix-icon-button.js";import{until as fe}from"lit-html/directives/until.js";import{isPossiblePhoneNumber as ha}from"libphonenumber-js";var gi;(function(e){e.CustomerSupport="customer-support",e.FacilityAccess="facility-access",e.RemoteHands="remote-hands",e.DeliveriesAndRemovals="deliveries-removals",e.TroubleTicket="trouble-ticket"})(gi||(gi={}));var y;(function(e){e.CustomerSupport="customer-support",e.FacilityAccess="facility-access",e.VisitorAccess="visitor-access",e.PermanentBadge="permanent-badge",e.OSPAccess="osp-access",e.POPPOEAccess="pop-poe-access",e.RemoteHands="remote-hands",e.Deliveries="deliveries",e.Removals="removals",e.DeliveriesAndRemovals="deliveries-removals",e.TroubleTickets="trouble-tickets"})(y||(y={}));const va="ticketViewType";var wi;(function(e){e.PlannedWork="Planned Work",e.UrgentWork="Urgent Work"})(wi||(wi={}));var H;(function(e){e.TelxSFDC="TelxSFDC",e.Insite="InSite",e.ServiceNow="ServiceNow"})(H||(H={}));const ct="YYYY-MM-DD",ga="HH:mm:ss",$t="HH:mm",wa="YYYY-MM-DD HH:mm";var w;(function(e){e.Default="default",e.Submitting="submitting",e.Submitted="submitted",e.Error="error"})(w||(w={}));var Q;(function(e){e.Deliveries="deliveries-tickets",e.FacilityAccess="osp-access-tickets",e.TroubleTickets="trouble-tickets",e.RemoteHands="remote-hands-tickets"})(Q||(Q={}));const Wi=[{label:"CSV",extensions:["csv"]},{label:"DOC/X",extensions:["doc","docx"]},{label:"GIF",extensions:["gif"]},{label:"JPG (JPEG)",extensions:["jpg","jpeg"]},{label:"PDF",extensions:["pdf"]},{label:"PNG",extensions:["png"]},{label:"XLS/X",extensions:["xls","xlsx"]}],fa=[{label:"JPG (JPEG)",extensions:["image/jpg","image/jpeg"]},{label:"PDF",extensions:["application/pdf"]},{label:"PNG",extensions:["image/png"]},{label:"GIF",extensions:["image/gif"]}],ka=Wi.flatMap(e=>e.extensions),ya=fa.flatMap(e=>e.extensions),Ta=e=>{var t;return Number((t=e.split("cursor=").pop())===null||t===void 0?void 0:t.split("&")[0])},Gi=async(e,t)=>{const i=await t({...e,cursor:"1"});if(!i)return[];const s=[...i.items];if(i.last&&i.self!==i.last){const n=[];let o=1;o=Ta(i.last);for(let a=2;a<=o;a+=1)n.push(t({...e,cursor:a.toString()}));await Promise.all(n).then(a=>{a.forEach(r=>{r&&s.push(...r.items)})})}return s},ba=e=>{var t,i;return e?"name"in e?((t=e.name)===null||t===void 0?void 0:t.trim())||e.id||"":((i=e.comment)===null||i===void 0?void 0:i.trim())||e.id||"":""},Ra="https://api.digitalrealty.com/service-management/v1".replace(/\/+$/,"");class Zi{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Ra}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Ki}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const Aa=new Zi;class ai{constructor(t=Aa){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new Ca(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?ai.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new Sa(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;Ia(r.body)||r.body instanceof URLSearchParams||_a(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}ai.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function _a(e){return typeof Blob<"u"&&e instanceof Blob}function Ia(e){return typeof FormData<"u"&&e instanceof FormData}class Sa extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class Ca extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class ne extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function I(e,t){return e[t]!=null}function Ki(e,t=""){return Object.keys(e).map(i=>Yi(i,e[i],t)).filter(i=>i.length>0).join("&")}function Yi(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return Yi(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Ki(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class Ne{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class Na{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}const Pa="https://api.digitalrealty.com".replace(/\/+$/,"");class Et{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Pa}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Qi}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const qa=new Et;class kt{constructor(t=qa){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new Oa(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?kt.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new Xi(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;Ba(r.body)||r.body instanceof URLSearchParams||Da(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}kt.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function Da(e){return typeof Blob<"u"&&e instanceof Blob}function Ba(e){return typeof FormData<"u"&&e instanceof FormData}class Xi extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class Oa extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class $ extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function h(e,t){return e[t]!=null}function Qi(e,t=""){return Object.keys(e).map(i=>es(i,e[i],t)).filter(i=>i.length>0).join("&")}function es(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return es(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Qi(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class j{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class ts{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}class $a extends kt{async getCourierBySiteRaw(t,i){if(t.accountNumber===null||t.accountNumber===void 0)throw new $("accountNumber","Required parameter requestParameters.accountNumber was null or undefined when calling getCourierBySite.");if(t.site===null||t.site===void 0)throw new $("site","Required parameter requestParameters.site was null or undefined when calling getCourierBySite.");const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/deliveries-removals/courier-companies",method:"GET",headers:n,query:s},i);return new j(o)}async getCourierBySite(t,i){return await(await this.getCourierBySiteRaw(t,i)).value()}}function is(e){if(e!==void 0)return e===null?null:{cancellationReason:e.cancellationReason}}function ss(e){return Ea(e)}function Ea(e,t){return e==null?e:{message:h(e,"message")?e.message:void 0}}function fi(e){return xa(e)}function xa(e,t){return e==null?e:{createdBy:h(e,"created_by")?e.created_by:void 0,createdAt:h(e,"created_at")?new Date(e.created_at):void 0,comment:h(e,"comment")?e.comment:void 0}}function ns(e){return Fa(e)}function Fa(e,t){return e==null?e:{comments:h(e,"comments")?e.comments.map(fi):void 0}}function La(e){return Va(e)}function Va(e,t){return e==null?e:{deliveryBlocked:h(e,"delivery_blocked")?e.delivery_blocked:void 0}}function as(e){return Ua(e)}function Ua(e,t){return e==null?e:{accountNumber:h(e,"account_number")?e.account_number:void 0,accountName:h(e,"account_name")?e.account_name:void 0,id:h(e,"id")?e.id:void 0,status:h(e,"status")?e.status:void 0,site:h(e,"site")?e.site:void 0,subject:h(e,"subject")?e.subject:void 0,createdBy:h(e,"created_by")?e.created_by:void 0,updatedAt:h(e,"updated_at")?new Date(e.updated_at):void 0}}function Ha(e){return za(e)}function za(e,t){return e==null?e:{deliveryTickets:h(e,"delivery_tickets")?e.delivery_tickets.map(as):void 0,totalCount:h(e,"total_count")?e.total_count:void 0,pageNumber:h(e,"page_number")?e.page_number:void 0,pageSize:h(e,"page_size")?e.page_size:void 0}}function ja(e){if(e!==void 0)return e===null?null:{tracking_number:e.trackingNumber,size_when_oversized:e.sizeWhenOversized,weight_when_overweight:e.weightWhenOverweight,courier_company:e.courierCompany}}function Ma(e){if(e!==void 0)return e===null?null:{id:e.id,tracking_number:e.trackingNumber,number_of_packages:e.numberOfPackages,size_when_oversized:e.sizeWhenOversized,weight_when_overweight:e.weightWhenOverweight,courier_company:e.courierCompany}}function Ja(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,subject:e.subject,description:e.description,eta_from:e.etaFrom===null?null:e.etaFrom.toISOString().substring(0,10),eta_to:e.etaTo===null?null:e.etaTo.toISOString(),loading_bay_required:e.loadingBayRequired,remote_hands_required:e.remoteHandsRequired,customer_reference:e.customerReference,site:e.site,other_notification_recipients:e.otherNotificationRecipients,packages:e.packages===void 0?void 0:e.packages.map(Ma)}}function Wa(e){return Ga(e)}function Ga(e,t){return e==null?e:{id:h(e,"id")?e.id:void 0,trackingNumber:h(e,"tracking_number")?e.tracking_number:void 0,numberOfPackages:h(e,"number_of_packages")?e.number_of_packages:void 0,sizeWhenOversized:h(e,"size_when_oversized")?e.size_when_oversized:void 0,weightWhenOverweight:h(e,"weight_when_overweight")?e.weight_when_overweight:void 0,courierCompany:h(e,"courier_company")?e.courier_company:void 0}}function xt(e){return Za(e)}function Za(e,t){return e==null?e:{id:h(e,"id")?e.id:void 0,accountNumber:h(e,"account_number")?e.account_number:void 0,accountName:h(e,"account_name")?e.account_name:void 0,status:h(e,"status")?e.status:void 0,subject:h(e,"subject")?e.subject:void 0,description:h(e,"description")?e.description:void 0,cancellationReason:h(e,"cancellation_reason")?e.cancellation_reason:void 0,etaFrom:h(e,"eta_from")?e.eta_from===null?null:new Date(e.eta_from):void 0,etaTo:h(e,"eta_to")?e.eta_to===null?null:new Date(e.eta_to):void 0,customerReference:h(e,"customer_reference")?e.customer_reference:void 0,site:h(e,"site")?e.site:void 0,otherNotificationRecipients:h(e,"other_notification_recipients")?e.other_notification_recipients:void 0,createdBy:h(e,"created_by")?e.created_by:void 0,createdAt:h(e,"created_at")?new Date(e.created_at):void 0,updatedAt:h(e,"updated_at")?new Date(e.updated_at):void 0,loadingBayRequired:h(e,"loading_bay_required")?e.loading_bay_required:void 0,remoteHandsRequired:h(e,"remote_hands_required")?e.remote_hands_required:void 0,packages:h(e,"packages")?e.packages.map(Wa):void 0,comments:h(e,"comments")?e.comments.map(fi):void 0}}function Ka(e){if(e!==void 0)return e===null?null:{subject:e.subject,description:e.description,eta_from:e.etaFrom===void 0?void 0:e.etaFrom===null?null:e.etaFrom.toISOString(),eta_to:e.etaTo===void 0?void 0:e.etaTo===null?null:e.etaTo.toISOString(),loading_bay_required:e.loadingBayRequired,customer_reference:e.customerReference,other_notification_recipients:e.otherNotificationRecipients}}function Ya(e){return Xa(e)}function Xa(e,t){return e==null?e:{removalTickets:h(e,"removal_tickets")?e.removal_tickets.map(as):void 0,totalCount:h(e,"total_count")?e.total_count:void 0,pageNumber:h(e,"page_number")?e.page_number:void 0,pageSize:h(e,"page_size")?e.page_size:void 0}}function Qa(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,subject:e.subject,description:e.description,customer_reference:e.customerReference,removal_party:e.removalParty,courier_company:e.courierCompany,tracking_number:e.trackingNumber,pickup_date:e.pickupDate.toISOString(),site:e.site,other_notification_recipients:e.otherNotificationRecipients}}function ki(e){return eo(e)}function eo(e,t){return e==null?e:{id:h(e,"id")?e.id:void 0,accountNumber:h(e,"account_number")?e.account_number:void 0,accountName:h(e,"account_name")?e.account_name:void 0,status:h(e,"status")?e.status:void 0,cancellationReason:h(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:h(e,"subject")?e.subject:void 0,description:h(e,"description")?e.description:void 0,customerReference:h(e,"customer_reference")?e.customer_reference:void 0,removalParty:h(e,"removal_party")?e.removal_party:void 0,courierCompany:h(e,"courier_company")?e.courier_company:void 0,trackingNumber:h(e,"tracking_number")?e.tracking_number:void 0,pickupDate:h(e,"pickup_date")?e.pickup_date:void 0,site:h(e,"site")?e.site:void 0,otherNotificationRecipients:h(e,"other_notification_recipients")?e.other_notification_recipients:void 0,createdBy:h(e,"created_by")?e.created_by:void 0,createdAt:h(e,"created_at")?new Date(e.created_at):void 0,updatedAt:h(e,"updated_at")?new Date(e.updated_at):void 0,comments:h(e,"comments")?e.comments.map(fi):void 0}}function to(e){if(e!==void 0)return e===null?null:{subject:e.subject,description:e.description,customer_reference:e.customerReference,courier_company:e.courierCompany,tracking_number:e.trackingNumber,pickup_date:e.pickupDate===void 0?void 0:e.pickupDate===null?null:e.pickupDate.toISOString(),other_notification_recipients:e.otherNotificationRecipients}}function yi(e){return io(e)}function io(e,t){return e==null?e:{id:h(e,"id")?e.id:void 0,fileName:h(e,"file_name")?e.file_name:void 0,fileSize:h(e,"file_size")?e.file_size:void 0,contentType:h(e,"content_type")?e.content_type:void 0,createdBy:h(e,"created_by")?e.created_by:void 0,createdAt:h(e,"created_at")?new Date(e.created_at):void 0}}function os(e){return so(e)}function so(e,t){return e==null?e:{attachments:h(e,"attachments")?e.attachments.map(yi):void 0}}function rs(e){if(e!==void 0)return e===null?null:{comment:e.comment}}class no extends kt{async cancellationDeliveryRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationDeliveryRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new $("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationDeliveryRequest.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:is(t.cancellationTicketsRequest)},i);return new j(o,a=>ss(a))}async cancellationDeliveryRequest(t,i){return await(await this.cancellationDeliveryRequestRaw(t,i)).value()}async createAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createAttachment.");if(t.fileName===null||t.fileName===void 0)throw new $("fileName","Required parameter requestParameters.fileName was null or undefined when calling createAttachment.");if(t.body===null||t.body===void 0)throw new $("body","Required parameter requestParameters.body was null or undefined when calling createAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new j(o,a=>yi(a))}async createAttachment(t,i){return await(await this.createAttachmentRaw(t,i)).value()}async createDeliveriesCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createDeliveriesComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new $("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createDeliveriesComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:rs(t.ticketCommentsRequest)},i);return new j(o,a=>ns(a))}async createDeliveriesComment(t,i){return await(await this.createDeliveriesCommentRaw(t,i)).value()}async createDeliveryRaw(t,i){if(t.deliveryTicketsRequest===null||t.deliveryTicketsRequest===void 0)throw new $("deliveryTicketsRequest","Required parameter requestParameters.deliveryTicketsRequest was null or undefined when calling createDelivery.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets",method:"POST",headers:n,query:s,body:Ja(t.deliveryTicketsRequest)},i);return new j(o,a=>xt(a))}async createDelivery(t,i){return await(await this.createDeliveryRaw(t,i)).value()}async getDeliveriesRaw(t,i){if(t.accountNumber===null||t.accountNumber===void 0)throw new $("accountNumber","Required parameter requestParameters.accountNumber was null or undefined when calling getDeliveries.");const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets",method:"GET",headers:n,query:s},i);return new j(o,a=>Ha(a))}async getDeliveries(t,i){return await(await this.getDeliveriesRaw(t,i)).value()}async getDeliveryAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getDeliveryAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new $("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getDeliveryAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new ts(o)}async getDeliveryAttachmentsById(t,i){return await(await this.getDeliveryAttachmentsByIdRaw(t,i)).value()}async getDeliveryAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getDeliveryAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new j(o,a=>os(a))}async getDeliveryAttachmentsList(t,i){return await(await this.getDeliveryAttachmentsListRaw(t,i)).value()}async getDeliveryByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getDeliveryById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new j(o,a=>xt(a))}async getDeliveryById(t,i){return await(await this.getDeliveryByIdRaw(t,i)).value()}async getDeliveryDiscoveryRaw(t,i){if(t.accountNumber===null||t.accountNumber===void 0)throw new $("accountNumber","Required parameter requestParameters.accountNumber was null or undefined when calling getDeliveryDiscovery.");if(t.site===null||t.site===void 0)throw new $("site","Required parameter requestParameters.site was null or undefined when calling getDeliveryDiscovery.");const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-discovery",method:"GET",headers:n,query:s},i);return new j(o,a=>La(a))}async getDeliveryDiscovery(t,i){return await(await this.getDeliveryDiscoveryRaw(t,i)).value()}async updateDeliveriesTicketsRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateDeliveriesTickets.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:Ka(t.deliveryTicketsUpdateRequest)},i);return new j(o,a=>xt(a))}async updateDeliveriesTickets(t,i){return await(await this.updateDeliveriesTicketsRaw(t,i)).value()}async updateDeliveriesTicketsPackagesRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateDeliveriesTicketsPackages.");if(t.packageId===null||t.packageId===void 0)throw new $("packageId","Required parameter requestParameters.packageId was null or undefined when calling updateDeliveriesTicketsPackages.");if(t.deliveryTicketUpdatePackagesRequest===null||t.deliveryTicketUpdatePackagesRequest===void 0)throw new $("deliveryTicketUpdatePackagesRequest","Required parameter requestParameters.deliveryTicketUpdatePackagesRequest was null or undefined when calling updateDeliveriesTicketsPackages.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/delivery-tickets/{ticket_id}/packages/{package_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{package_id}",encodeURIComponent(String(t.packageId))),method:"PATCH",headers:n,query:s,body:ja(t.deliveryTicketUpdatePackagesRequest)},i);return new j(o,a=>xt(a))}async updateDeliveriesTicketsPackages(t,i){return await(await this.updateDeliveriesTicketsPackagesRaw(t,i)).value()}}class ao extends kt{async cancellationRemovalRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationRemovalRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new $("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationRemovalRequest.");const s={},n={};n["Content-Type"]="application/json";const o=await this.request({path:"/removals-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:is(t.cancellationTicketsRequest)},i);return new j(o,a=>ss(a))}async cancellationRemovalRequest(t,i){return await(await this.cancellationRemovalRequestRaw(t,i)).value()}async createCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new $("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:rs(t.ticketCommentsRequest)},i);return new j(o,a=>ns(a))}async createComment(t,i){return await(await this.createCommentRaw(t,i)).value()}async createRemovalRaw(t,i){if(t.removalTicketsRequest===null||t.removalTicketsRequest===void 0)throw new $("removalTicketsRequest","Required parameter requestParameters.removalTicketsRequest was null or undefined when calling createRemoval.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets",method:"POST",headers:n,query:s,body:Qa(t.removalTicketsRequest)},i);return new j(o,a=>ki(a))}async createRemoval(t,i){return await(await this.createRemovalRaw(t,i)).value()}async createRemovalsAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createRemovalsAttachment.");if(t.fileName===null||t.fileName===void 0)throw new $("fileName","Required parameter requestParameters.fileName was null or undefined when calling createRemovalsAttachment.");if(t.body===null||t.body===void 0)throw new $("body","Required parameter requestParameters.body was null or undefined when calling createRemovalsAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new j(o,a=>yi(a))}async createRemovalsAttachment(t,i){return await(await this.createRemovalsAttachmentRaw(t,i)).value()}async getRemovalByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getRemovalById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new j(o,a=>ki(a))}async getRemovalById(t,i){return await(await this.getRemovalByIdRaw(t,i)).value()}async getRemovalPartiesRaw(t){const i={},s={};if(this.configuration&&this.configuration.accessToken){const o=this.configuration.accessToken,a=await o("BearerAuth",[]);a&&(s.Authorization=`Bearer ${a}`)}const n=await this.request({path:"/removal-parties",method:"GET",headers:s,query:i},t);return new j(n)}async getRemovalParties(t){return await(await this.getRemovalPartiesRaw(t)).value()}async getRemovalsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets",method:"GET",headers:n,query:s},i);return new j(o,a=>Ya(a))}async getRemovals(t={},i){return await(await this.getRemovalsRaw(t,i)).value()}async getRemovalsAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getRemovalsAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new $("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getRemovalsAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new ts(o)}async getRemovalsAttachmentsById(t,i){return await(await this.getRemovalsAttachmentsByIdRaw(t,i)).value()}async getRemovalsAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getRemovalsAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new j(o,a=>os(a))}async getRemovalsAttachmentsList(t,i){return await(await this.getRemovalsAttachmentsListRaw(t,i)).value()}async updateRemovalByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new $("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateRemovalById.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/removal-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:to(t.removalsTicketsUpdateRequest)},i);return new j(o,a=>ki(a))}async updateRemovalById(t,i){return await(await this.updateRemovalByIdRaw(t,i)).value()}}const oo="https://api.digitalrealty.com/service-management/v1/facility-access".replace(/\/+$/,"");class pt{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:oo}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||cs}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const ro=new pt;class Xe{constructor(t=ro){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new mo(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?Xe.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new lo(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;uo(r.body)||r.body instanceof URLSearchParams||co(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}Xe.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function co(e){return typeof Blob<"u"&&e instanceof Blob}function uo(e){return typeof FormData<"u"&&e instanceof FormData}class lo extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class mo extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class v extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function c(e,t){return e[t]!=null}function cs(e,t=""){return Object.keys(e).map(i=>ds(i,e[i],t)).filter(i=>i.length>0).join("&")}function ds(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return ds(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?cs(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class q{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class Ft{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}function po(e){return ho(e)}function ho(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,accountNumber:c(e,"account_number")?e.account_number:void 0,firstName:c(e,"first_name")?e.first_name:void 0,lastName:c(e,"last_name")?e.last_name:void 0,email:c(e,"email")?e.email:void 0,phone:c(e,"phone")?e.phone:void 0,representingCompany:c(e,"representing_company")?e.representing_company:void 0,badgeStartDate:c(e,"badge_start_date")?new Date(e.badge_start_date):void 0,activeBadge:c(e,"active_badge")?e.active_badge:void 0,terminationRequested:c(e,"termination_requested")?e.termination_requested:void 0}}function vo(e){return go(e)}function go(e,t){return e==null?e:{items:c(e,"items")?e.items.map(po):void 0,totalCount:c(e,"total_count")?e.total_count:void 0}}function Lt(e){if(e!==void 0)return e===null?null:{cancellationReason:e.cancellationReason}}function Vt(e){return wo(e)}function wo(e,t){return e==null?e:{message:c(e,"message")?e.message:void 0}}function At(e){return fo(e)}function fo(e,t){return e==null?e:{createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,comment:c(e,"comment")?e.comment:void 0}}function Ut(e){return ko(e)}function ko(e,t){return e==null?e:{comments:c(e,"comments")?e.comments.map(At):void 0}}const us={Approved:"Approved",Denied:"Denied"};function Ht(e){if(e!==void 0)return e===null?null:{id:e.id,approval_status:e.approvalStatus}}function yo(e){return To(e)}function To(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,approvalStatus:c(e,"approval_status")?e.approval_status:void 0}}function zt(e){return bo(e)}function bo(e,t){return e==null?e:{items:c(e,"items")?e.items.map(yo):void 0}}function Ro(e){if(e!==void 0)return e===null?null:{id:e.id,start_date_time:e.startDateTime===void 0?void 0:e.startDateTime.toISOString(),end_date_time:e.endDateTime===void 0?void 0:e.endDateTime.toISOString()}}function Ao(e){if(e!==void 0)return e===null?null:{first_name:e.firstName,last_name:e.lastName,email:e.email,company:e.company,phone:e.phone,visitor_type:e.visitorType}}function _o(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,visitors:e.visitors.map(Ao),locations:e.locations.map(Ro),escort_first_name:e.escortFirstName,escort_last_name:e.escortLastName,visitor_host_first_name:e.visitorHostFirstName,visitor_host_last_name:e.visitorHostLastName,customer_external_reference:e.customerExternalReference,service_impacted_description:e.serviceImpactedDescription,work_description:e.workDescription,notification_recipients:e.notificationRecipients}}function Io(e){return So(e)}function So(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,startDateTime:c(e,"start_date_time")?e.start_date_time:void 0,endDateTime:c(e,"end_date_time")?e.end_date_time:void 0}}function ls(e){return Co(e)}function Co(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,cancellationReason:c(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:c(e,"subject")?e.subject:void 0,visitorFirstName:c(e,"visitor_first_name")?e.visitor_first_name:void 0,visitorLastName:c(e,"visitor_last_name")?e.visitor_last_name:void 0,visitorEmail:c(e,"visitor_email")?e.visitor_email:void 0,visitorCompany:c(e,"visitor_company")?e.visitor_company:void 0,visitorPhone:c(e,"visitor_phone")?e.visitor_phone:void 0,visitorType:c(e,"visitor_type")?e.visitor_type:void 0,site:c(e,"site")?e.site:void 0,locations:c(e,"locations")?e.locations.map(Io):void 0,escortFirstName:c(e,"escort_first_name")?e.escort_first_name:void 0,escortLastName:c(e,"escort_last_name")?e.escort_last_name:void 0,visitorHostFirstName:c(e,"visitor_host_first_name")?e.visitor_host_first_name:void 0,visitorHostLastName:c(e,"visitor_host_last_name")?e.visitor_host_last_name:void 0,customerExternalReference:c(e,"customer_external_reference")?e.customer_external_reference:void 0,serviceImpactedDescription:c(e,"service_impacted_description")?e.service_impacted_description:void 0,workDescription:c(e,"work_description")?e.work_description:void 0,notificationRecipients:c(e,"notification_recipients")?e.notification_recipients:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?e.created_at:void 0,updatedAt:c(e,"updated_at")?e.updated_at:void 0,closedAt:c(e,"closed_at")?e.closed_at:void 0,comments:c(e,"comments")?e.comments.map(At):void 0}}function No(e){if(e!==void 0)return e===null?null:{id:e.id,start_date_time:e.startDateTime===void 0?void 0:e.startDateTime.toISOString(),end_date_time:e.endDateTime===void 0?void 0:e.endDateTime.toISOString()}}function Po(e){if(e!==void 0)return e===null?null:{visitor_phone:e.visitorPhone,visitor_company:e.visitorCompany,escort_first_name:e.escortFirstName,escort_last_name:e.escortLastName,locations:e.locations===void 0?void 0:e.locations.map(No),visitor_host_first_name:e.visitorHostFirstName,visitor_host_last_name:e.visitorHostLastName,customer_external_reference:e.customerExternalReference,service_impacted_description:e.serviceImpactedDescription,work_description:e.workDescription,other_notification_recipients:e.otherNotificationRecipients}}function qo(e){return Do(e)}function Do(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,startDateTime:c(e,"start_date_time")?new Date(e.start_date_time):void 0,endDateTime:c(e,"end_date_time")?new Date(e.end_date_time):void 0}}function Bo(e){return Oo(e)}function Oo(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,subject:c(e,"subject")?e.subject:void 0,site:c(e,"site")?e.site:void 0,locations:c(e,"locations")?e.locations.map(qo):void 0,description:c(e,"description")?e.description:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,updatedAt:c(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:c(e,"closed_at")?new Date(e.closed_at):void 0}}function $o(e){return Eo(e)}function Eo(e,t){return e==null?e:{items:c(e,"items")?e.items.map(Bo):void 0,totalCount:c(e,"total_count")?e.total_count:void 0,pageNumber:c(e,"page_number")?e.page_number:void 0,pageSize:c(e,"page_size")?e.page_size:void 0}}function xo(e){if(e!==void 0)return e===null?null:{id:e.id,start_date_time:e.startDateTime.toISOString(),end_date_time:e.endDateTime.toISOString()}}function Fo(e){if(e!==void 0)return e===null?null:{ppop_space_from:e.ppopSpaceFrom,ppop_space_to:e.ppopSpaceTo,cable_type:e.cableType,on_ladder_rack:e.onLadderRack,in_inner_duct:e.inInnerDuct,in_fiber_guide:e.inFiberGuide}}function ms(e){return Lo(e)}function Lo(e,t){return e==null?e:{rack:c(e,"rack")?e.rack:void 0,cabinet:c(e,"cabinet")?e.cabinet:void 0}}function ps(e){if(e!==void 0)return e===null?null:{rack:e.rack,cabinet:e.cabinet}}function Vo(e){if(e!==void 0)return e===null?null:{side_a_name:e.sideAName,side_a_room_number:e.sideARoomNumber,side_a_rack_number:e.sideARackNumber,side_a_panel_number:e.sideAPanelNumber,side_a_port_1:e.sideAPort1,side_a_carrier_circuit_id:e.sideACarrierCircuitId,side_b_name:e.sideBName,side_b_room_number:e.sideBRoomNumber,side_b_rack_number:e.sideBRackNumber,side_b_panel_number:e.sideBPanelNumber,side_b_port_1:e.sideBPort1,side_b_carrier_circuit_id:e.sideBCarrierCircuitId}}function Uo(e){if(e!==void 0)return e===null?null:{service_type:e.serviceType,scope:e.scope,circuits:e.circuits===void 0?void 0:e.circuits.map(Vo),work_description:e.workDescription}}function Ho(e){if(e!==void 0)return e===null?null:{spop_space_from:e.spopSpaceFrom,spop_space_to:e.spopSpaceTo,cable_type:e.cableType,on_ladder_rack:e.onLadderRack,in_inner_duct:e.inInnerDuct,in_fiber_guide:e.inFiberGuide}}function zo(e){if(e!==void 0)return e===null?null:{first_name:e.firstName,last_name:e.lastName,email:e.email,company:e.company,phone:e.phone,visitor_type:e.visitorType}}function jo(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,visitors:e.visitors.map(zo),locations:e.locations.map(xo),escort_first_name:e.escortFirstName,escort_last_name:e.escortLastName,visitor_host_first_name:e.visitorHostFirstName,visitor_host_last_name:e.visitorHostLastName,customer_external_reference:e.customerExternalReference,service_impacted_description:e.serviceImpactedDescription,service_details:Uo(e.serviceDetails),ppop_space:e.ppopSpace===void 0?void 0:e.ppopSpace.map(ps),spop_space:e.spopSpace===void 0?void 0:e.spopSpace.map(ps),ppop_room_work:Fo(e.ppopRoomWork),spop_room_work:Ho(e.spopRoomWork),notification_recipients:e.notificationRecipients}}function Mo(e){return Jo(e)}function Jo(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,startDateTime:c(e,"start_date_time")?e.start_date_time:void 0,endDateTime:c(e,"end_date_time")?e.end_date_time:void 0,approvalStatus:c(e,"approval_status")?e.approval_status:void 0,modifiedBy:c(e,"modified_by")?e.modified_by:void 0}}function Wo(e){return Go(e)}function Go(e,t){return e==null?e:{ppopSpaceFrom:c(e,"ppop_space_from")?e.ppop_space_from:void 0,ppopSpaceTo:c(e,"ppop_space_to")?e.ppop_space_to:void 0,cableType:c(e,"cable_type")?e.cable_type:void 0,onLadderRack:c(e,"on_ladder_rack")?e.on_ladder_rack:void 0,inInnerDuct:c(e,"in_inner_duct")?e.in_inner_duct:void 0,inFiberGuide:c(e,"in_fiber_guide")?e.in_fiber_guide:void 0}}function Zo(e){return Ko(e)}function Ko(e,t){return e==null?e:{sideAName:c(e,"side_a_name")?e.side_a_name:void 0,sideARoomNumber:c(e,"side_a_room_number")?e.side_a_room_number:void 0,sideARackNumber:c(e,"side_a_rack_number")?e.side_a_rack_number:void 0,sideAPanelNumber:c(e,"side_a_panel_number")?e.side_a_panel_number:void 0,sideAPort1:c(e,"side_a_port_1")?e.side_a_port_1:void 0,sideACarrierCircuitId:c(e,"side_a_carrier_circuit_id")?e.side_a_carrier_circuit_id:void 0,sideBName:c(e,"side_b_name")?e.side_b_name:void 0,sideBRoomNumber:c(e,"side_b_room_number")?e.side_b_room_number:void 0,sideBRackNumber:c(e,"side_b_rack_number")?e.side_b_rack_number:void 0,sideBPanelNumber:c(e,"side_b_panel_number")?e.side_b_panel_number:void 0,sideBPort1:c(e,"side_b_port_1")?e.side_b_port_1:void 0,sideBCarrierCircuitId:c(e,"side_b_carrier_circuit_id")?e.side_b_carrier_circuit_id:void 0}}const We={SiteSurvey:"Site Survey",Testing:"Testing",InstallationDeInstallationWork:"Installation/De-installation Work"};function Yo(e){return Xo(e)}function Xo(e,t){return e==null?e:{serviceType:c(e,"service_type")?e.service_type:void 0,scope:c(e,"scope")?e.scope:void 0,circuits:c(e,"circuits")?e.circuits.map(Zo):void 0,workDescription:c(e,"work_description")?e.work_description:void 0}}function Qo(e){return er(e)}function er(e,t){return e==null?e:{spopSpaceFrom:c(e,"spop_space_from")?e.spop_space_from:void 0,spopSpaceTo:c(e,"spop_space_to")?e.spop_space_to:void 0,cableType:c(e,"cable_type")?e.cable_type:void 0,onLadderRack:c(e,"on_ladder_rack")?e.on_ladder_rack:void 0,inInnerDuct:c(e,"in_inner_duct")?e.in_inner_duct:void 0,inFiberGuide:c(e,"in_fiber_guide")?e.in_fiber_guide:void 0}}function hs(e){return tr(e)}function tr(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,cancellationReason:c(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:c(e,"subject")?e.subject:void 0,visitorFirstName:c(e,"visitor_first_name")?e.visitor_first_name:void 0,visitorLastName:c(e,"visitor_last_name")?e.visitor_last_name:void 0,visitorEmail:c(e,"visitor_email")?e.visitor_email:void 0,visitorCompany:c(e,"visitor_company")?e.visitor_company:void 0,visitorPhone:c(e,"visitor_phone")?e.visitor_phone:void 0,visitorType:c(e,"visitor_type")?e.visitor_type:void 0,site:c(e,"site")?e.site:void 0,locations:c(e,"locations")?e.locations.map(Mo):void 0,escortFirstName:c(e,"escort_first_name")?e.escort_first_name:void 0,escortLastName:c(e,"escort_last_name")?e.escort_last_name:void 0,visitorHostFirstName:c(e,"visitor_host_first_name")?e.visitor_host_first_name:void 0,visitorHostLastName:c(e,"visitor_host_last_name")?e.visitor_host_last_name:void 0,visitorHostCompany:c(e,"visitor_host_company")?e.visitor_host_company:void 0,customerExternalReference:c(e,"customer_external_reference")?e.customer_external_reference:void 0,serviceImpactedDescription:c(e,"service_impacted_description")?e.service_impacted_description:void 0,serviceDetails:c(e,"service_details")?Yo(e.service_details):void 0,ppopSpace:c(e,"ppop_space")?e.ppop_space.map(ms):void 0,spopSpace:c(e,"spop_space")?e.spop_space.map(ms):void 0,ppopRoomWork:c(e,"ppop_room_work")?Wo(e.ppop_room_work):void 0,spopRoomWork:c(e,"spop_room_work")?Qo(e.spop_room_work):void 0,notificationRecipients:c(e,"notification_recipients")?e.notification_recipients:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?e.created_at:void 0,updatedAt:c(e,"updated_at")?e.updated_at:void 0,closedAt:c(e,"closed_at")?e.closed_at:void 0,comments:c(e,"comments")?e.comments.map(At):void 0}}function ir(e){if(e!==void 0)return e===null?null:{id:e.id,start_date_time:e.startDateTime.toISOString(),end_date_time:e.endDateTime.toISOString()}}function sr(e){if(e!==void 0)return e===null?null:{ppop_space_from:e.ppopSpaceFrom,ppop_space_to:e.ppopSpaceTo,cable_type:e.cableType,on_ladder_rack:e.onLadderRack,in_inner_duct:e.inInnerDuct,in_fiber_guide:e.inFiberGuide}}function vs(e){if(e!==void 0)return e===null?null:{id:e.id,rack:e.rack,cabinet:e.cabinet}}function nr(e){if(e!==void 0)return e===null?null:{id:e.id,side_a_name:e.sideAName,side_a_room_number:e.sideARoomNumber,side_a_rack_number:e.sideARackNumber,side_a_panel_number:e.sideAPanelNumber,side_a_port_1:e.sideAPort1,side_a_carrier_circuit_id:e.sideACarrierCircuitId,side_b_name:e.sideBName,side_b_room_number:e.sideBRoomNumber,side_b_rack_number:e.sideBRackNumber,side_b_panel_number:e.sideBPanelNumber,side_b_port_1:e.sideBPort1,side_b_carrier_circuit_id:e.sideBCarrierCircuitId}}function ar(e){if(e!==void 0)return e===null?null:{service_type:e.serviceType,scope:e.scope,circuits:e.circuits===void 0?void 0:e.circuits.map(nr),work_description:e.workDescription}}function or(e){if(e!==void 0)return e===null?null:{spop_space_from:e.spopSpaceFrom,spop_space_to:e.spopSpaceTo,cable_type:e.cableType,on_ladder_rack:e.onLadderRack,in_inner_duct:e.inInnerDuct,in_fiber_guide:e.inFiberGuide}}function rr(e){if(e!==void 0)return e===null?null:{visitor_phone:e.visitorPhone,escort_first_name:e.escortFirstName,escort_last_name:e.escortLastName,visitor_host_first_name:e.visitorHostFirstName,visitor_host_last_name:e.visitorHostLastName,visitor_company:e.visitorCompany,service_impacted_description:e.serviceImpactedDescription,locations:e.locations===void 0?void 0:e.locations.map(ir),service_details:ar(e.serviceDetails),ppop_space:e.ppopSpace===void 0?void 0:e.ppopSpace.map(vs),spop_space:e.spopSpace===void 0?void 0:e.spopSpace.map(vs),ppop_room_work:sr(e.ppopRoomWork),spop_room_work:or(e.spopRoomWork),customer_external_reference:e.customerExternalReference,notification_recipients:e.notificationRecipients}}function cr(e){return dr(e)}function dr(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,startDateTime:c(e,"start_date_time")?new Date(e.start_date_time):void 0,endDateTime:c(e,"end_date_time")?new Date(e.end_date_time):void 0,approvalStatus:c(e,"approval_status")?e.approval_status:void 0,modifiedBy:c(e,"modified_by")?e.modified_by:void 0}}function ur(e){return lr(e)}function lr(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,subject:c(e,"subject")?e.subject:void 0,site:c(e,"site")?e.site:void 0,locations:c(e,"locations")?e.locations.map(cr):void 0,description:c(e,"description")?e.description:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,updatedAt:c(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:c(e,"closed_at")?new Date(e.closed_at):void 0}}function mr(e){return pr(e)}function pr(e,t){return e==null?e:{items:c(e,"items")?e.items.map(ur):void 0,totalCount:c(e,"total_count")?e.total_count:void 0,pageNumber:c(e,"page_number")?e.page_number:void 0,pageSize:c(e,"page_size")?e.page_size:void 0}}function hr(e){if(e!==void 0)return e===null?null:{id:e.id,start_date:e.startDate===void 0?void 0:e.startDate.toISOString().substring(0,10),end_date:e.endDate===void 0?void 0:e.endDate.toISOString().substring(0,10),operation:e.operation}}function vr(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,badgeholder_id:e.badgeholderId,badge_start_date:e.badgeStartDate.toISOString().substring(0,10),badge_end_date:e.badgeEndDate===void 0?void 0:e.badgeEndDate.toISOString().substring(0,10),locations:e.locations===void 0?void 0:e.locations.map(hr),notification_recipients:e.notificationRecipients}}function gr(e){if(e!==void 0)return e===null?null:{id:e.id,start_date:e.startDate===void 0?void 0:e.startDate.toISOString().substring(0,10),end_date:e.endDate===void 0?void 0:e.endDate.toISOString().substring(0,10)}}function wr(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,badgeholder_first_name:e.badgeholderFirstName,badgeholder_last_name:e.badgeholderLastName,badgeholder_email:e.badgeholderEmail,badgeholder_company:e.badgeholderCompany,badgeholder_phone:e.badgeholderPhone,badge_start_date:e.badgeStartDate.toISOString().substring(0,10),badge_end_date:e.badgeEndDate===void 0?void 0:e.badgeEndDate.toISOString().substring(0,10),locations:e.locations===void 0?void 0:e.locations.map(gr),notification_recipients:e.notificationRecipients}}function fr(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,badgeholder_id:e.badgeholderId,badge_end_date:e.badgeEndDate.toISOString().substring(0,10),notification_recipients:e.notificationRecipients}}function gs(e){return kr(e)}function kr(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,site:c(e,"site")?e.site:void 0,siteAddress:c(e,"site_address")?e.site_address:void 0,startDate:c(e,"start_date")?e.start_date:void 0,endDate:c(e,"end_date")?e.end_date:void 0,approvalStatus:c(e,"approval_status")?e.approval_status:void 0,modifiedBy:c(e,"modified_by")?e.modified_by:void 0}}function ws(e){return yr(e)}function yr(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,cancellationReason:c(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:c(e,"subject")?e.subject:void 0,badgeholderFirstName:c(e,"badgeholder_first_name")?e.badgeholder_first_name:void 0,badgeholderLastName:c(e,"badgeholder_last_name")?e.badgeholder_last_name:void 0,badgeholderEmail:c(e,"badgeholder_email")?e.badgeholder_email:void 0,badgeholderPhone:c(e,"badgeholder_phone")?e.badgeholder_phone:void 0,badgeholderCompany:c(e,"badgeholder_company")?e.badgeholder_company:void 0,requestType:c(e,"request_type")?e.request_type:void 0,badgeStartDate:c(e,"badge_start_date")?e.badge_start_date:void 0,badgeEndDate:c(e,"badge_end_date")?e.badge_end_date:void 0,locations:c(e,"locations")?e.locations.map(gs):void 0,notificationRecipients:c(e,"notification_recipients")?e.notification_recipients:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,updatedAt:c(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:c(e,"closed_at")?new Date(e.closed_at):void 0,comments:c(e,"comments")?e.comments.map(At):void 0}}function Tr(e){if(e!==void 0)return e===null?null:{other_notification_recipients:e.otherNotificationRecipients}}function br(e){return Rr(e)}function Rr(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,subject:c(e,"subject")?e.subject:void 0,badgeholderEmail:c(e,"badgeholder_email")?e.badgeholder_email:void 0,requestType:c(e,"request_type")?e.request_type:void 0,locations:c(e,"locations")?e.locations.map(gs):void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,updatedAt:c(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:c(e,"closed_at")?new Date(e.closed_at):void 0}}function Ar(e){return _r(e)}function _r(e,t){return e==null?e:{items:c(e,"items")?e.items.map(br):void 0,totalCount:c(e,"total_count")?e.total_count:void 0,pageNumber:c(e,"page_number")?e.page_number:void 0,pageSize:c(e,"page_size")?e.page_size:void 0}}function _t(e){return Ir(e)}function Ir(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,fileName:c(e,"file_name")?e.file_name:void 0,fileSize:c(e,"file_size")?e.file_size:void 0,contentType:c(e,"content_type")?e.content_type:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?e.created_at===null?null:new Date(e.created_at):void 0}}function jt(e){return Sr(e)}function Sr(e,t){return e==null?e:{attachments:c(e,"attachments")?e.attachments.map(_t):void 0}}function Mt(e){if(e!==void 0)return e===null?null:{comment:e.comment}}function ht(e){return Cr(e)}function Cr(e,t){return e==null?e:{ticketNumbers:c(e,"ticket_numbers")?e.ticket_numbers:void 0}}function Nr(e){if(e!==void 0)return e===null?null:{id:e.id,start_date:e.startDate===void 0?void 0:e.startDate.toISOString().substring(0,10),end_date:e.endDate===void 0?void 0:e.endDate.toISOString().substring(0,10)}}function Pr(e){if(e!==void 0)return e===null?null:{site_code:e.siteCode,visitor_host_id:e.visitorHostId,locations:e.locations===void 0?void 0:e.locations.map(Nr)}}function qr(e){if(e!==void 0)return e===null?null:{first_name:e.firstName,last_name:e.lastName,email:e.email,phone:e.phone}}const Jt={Escorted:"Escorted",Standard:"Standard",Extended:"Extended"};function Dr(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,visitors:e.visitors===void 0?void 0:e.visitors.map(qr),visit_start_date:e.visitStartDate.toISOString().substring(0,10),visit_end_date:e.visitEndDate.toISOString().substring(0,10),visit_type:e.visitType,sites:e.sites===void 0?void 0:e.sites.map(Pr),escort_first_name:e.escortFirstName,escort_last_name:e.escortLastName,visitor_host_first_name:e.visitorHostFirstName,visitor_host_last_name:e.visitorHostLastName,representing_company:e.representingCompany,description:e.description,notification_recipients:e.notificationRecipients}}function fs(e){return Br(e)}function Br(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,startDate:c(e,"start_date")?e.start_date:void 0,endDate:c(e,"end_date")?e.end_date:void 0,approvalStatus:c(e,"approval_status")?e.approval_status:void 0,modifiedBy:c(e,"modified_by")?e.modified_by:void 0}}function ks(e){return Or(e)}function Or(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,cancellationReason:c(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:c(e,"subject")?e.subject:void 0,visitorFirstName:c(e,"visitor_first_name")?e.visitor_first_name:void 0,visitorLastName:c(e,"visitor_last_name")?e.visitor_last_name:void 0,visitorEmail:c(e,"visitor_email")?e.visitor_email:void 0,visitorPhone:c(e,"visitor_phone")?e.visitor_phone:void 0,visitStartDate:c(e,"visit_start_date")?e.visit_start_date:void 0,visitEndDate:c(e,"visit_end_date")?e.visit_end_date:void 0,visitType:c(e,"visit_type")?e.visit_type:void 0,site:c(e,"site")?e.site:void 0,locations:c(e,"locations")?e.locations.map(fs):void 0,escortFirstName:c(e,"escort_first_name")?e.escort_first_name:void 0,escortLastName:c(e,"escort_last_name")?e.escort_last_name:void 0,visitorHostFirstName:c(e,"visitor_host_first_name")?e.visitor_host_first_name:void 0,visitorHostLastName:c(e,"visitor_host_last_name")?e.visitor_host_last_name:void 0,representingCompany:c(e,"representing_company")?e.representing_company:void 0,description:c(e,"description")?e.description:void 0,notificationRecipients:c(e,"notification_recipients")?e.notification_recipients:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,updatedAt:c(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:c(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0,comments:c(e,"comments")?e.comments.map(At):void 0}}function $r(e){if(e!==void 0)return e===null?null:{visitor_phone:e.visitorPhone,other_notification_recipients:e.otherNotificationRecipients}}function Er(e){return xr(e)}function xr(e,t){return e==null?e:{accountNumber:c(e,"account_number")?e.account_number:void 0,accountName:c(e,"account_name")?e.account_name:void 0,id:c(e,"id")?e.id:void 0,status:c(e,"status")?e.status:void 0,subject:c(e,"subject")?e.subject:void 0,site:c(e,"site")?e.site:void 0,locations:c(e,"locations")?e.locations.map(fs):void 0,visitType:c(e,"visit_type")?e.visit_type:void 0,description:c(e,"description")?e.description:void 0,createdBy:c(e,"created_by")?e.created_by:void 0,createdAt:c(e,"created_at")?new Date(e.created_at):void 0,updatedAt:c(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:c(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function Fr(e){return Lr(e)}function Lr(e,t){return e==null?e:{items:c(e,"items")?e.items.map(Er):void 0,totalCount:c(e,"total_count")?e.total_count:void 0,pageNumber:c(e,"page_number")?e.page_number:void 0,pageSize:c(e,"page_size")?e.page_size:void 0}}function Vr(e){return Ur(e)}function Ur(e,t){return e==null?e:{id:c(e,"id")?e.id:void 0,firstName:c(e,"first_name")?e.first_name:void 0,lastName:c(e,"last_name")?e.last_name:void 0}}function Hr(e){return zr(e)}function zr(e,t){return e==null?e:{items:c(e,"items")?e.items.map(Vr):void 0,totalCount:c(e,"total_count")?e.total_count:void 0}}class jr extends Xe{async cancellationOspAccessRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationOspAccessRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new v("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationOspAccessRequest.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:Lt(t.cancellationTicketsRequest)},i);return new q(o,a=>Vt(a))}async cancellationOspAccessRequest(t,i){return await(await this.cancellationOspAccessRequestRaw(t,i)).value()}async createOspAccessAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createOspAccessAttachment.");if(t.fileName===null||t.fileName===void 0)throw new v("fileName","Required parameter requestParameters.fileName was null or undefined when calling createOspAccessAttachment.");if(t.body===null||t.body===void 0)throw new v("body","Required parameter requestParameters.body was null or undefined when calling createOspAccessAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new q(o,a=>_t(a))}async createOspAccessAttachment(t,i){return await(await this.createOspAccessAttachmentRaw(t,i)).value()}async createOspAccessCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createOspAccessComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new v("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createOspAccessComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:Mt(t.ticketCommentsRequest)},i);return new q(o,a=>Ut(a))}async createOspAccessComment(t,i){return await(await this.createOspAccessCommentRaw(t,i)).value()}async createOspAccessTicketRaw(t,i){if(t.oSPAccessTicketRequest===null||t.oSPAccessTicketRequest===void 0)throw new v("oSPAccessTicketRequest","Required parameter requestParameters.oSPAccessTicketRequest was null or undefined when calling createOspAccessTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets",method:"POST",headers:n,query:s,body:_o(t.oSPAccessTicketRequest)},i);return new q(o,a=>ht(a))}async createOspAccessTicket(t,i){return await(await this.createOspAccessTicketRaw(t,i)).value()}async getOspAccessAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getOspAccessAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new v("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getOspAccessAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new Ft(o)}async getOspAccessAttachmentsById(t,i){return await(await this.getOspAccessAttachmentsByIdRaw(t,i)).value()}async getOspAccessAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getOspAccessAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new q(o,a=>jt(a))}async getOspAccessAttachmentsList(t,i){return await(await this.getOspAccessAttachmentsListRaw(t,i)).value()}async getOspAccessTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getOspAccessTicketById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new q(o,a=>ls(a))}async getOspAccessTicketById(t,i){return await(await this.getOspAccessTicketByIdRaw(t,i)).value()}async getOspAccessTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={},o=await this.request({path:"/osp-access-tickets",method:"GET",headers:n,query:s},i);return new q(o,a=>$o(a))}async getOspAccessTickets(t={},i){return await(await this.getOspAccessTicketsRaw(t,i)).value()}async updateOspAccessLocationsTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateOspAccessLocationsTicket.");if(t.locationsPatchRequestInner===null||t.locationsPatchRequestInner===void 0)throw new v("locationsPatchRequestInner","Required parameter requestParameters.locationsPatchRequestInner was null or undefined when calling updateOspAccessLocationsTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}/locations".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:t.locationsPatchRequestInner.map(Ht)},i);return new q(o,a=>zt(a))}async updateOspAccessLocationsTicket(t,i){return await(await this.updateOspAccessLocationsTicketRaw(t,i)).value()}async updateOspAccessTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateOspAccessTicket.");if(t.oSPAccessTicketUpdateRequest===null||t.oSPAccessTicketUpdateRequest===void 0)throw new v("oSPAccessTicketUpdateRequest","Required parameter requestParameters.oSPAccessTicketUpdateRequest was null or undefined when calling updateOspAccessTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/osp-access-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:Po(t.oSPAccessTicketUpdateRequest)},i);return new q(o,a=>ls(a))}async updateOspAccessTicket(t,i){return await(await this.updateOspAccessTicketRaw(t,i)).value()}}class Mr extends Xe{async cancellationPopAccessRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationPopAccessRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new v("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationPopAccessRequest.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:Lt(t.cancellationTicketsRequest)},i);return new q(o,a=>Vt(a))}async cancellationPopAccessRequest(t,i){return await(await this.cancellationPopAccessRequestRaw(t,i)).value()}async createPopAccessAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createPopAccessAttachment.");if(t.fileName===null||t.fileName===void 0)throw new v("fileName","Required parameter requestParameters.fileName was null or undefined when calling createPopAccessAttachment.");if(t.body===null||t.body===void 0)throw new v("body","Required parameter requestParameters.body was null or undefined when calling createPopAccessAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new q(o,a=>_t(a))}async createPopAccessAttachment(t,i){return await(await this.createPopAccessAttachmentRaw(t,i)).value()}async createPopAccessCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createPopAccessComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new v("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createPopAccessComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:Mt(t.ticketCommentsRequest)},i);return new q(o,a=>Ut(a))}async createPopAccessComment(t,i){return await(await this.createPopAccessCommentRaw(t,i)).value()}async createPopAccessTicketRaw(t,i){if(t.pOPAccessTicketRequest===null||t.pOPAccessTicketRequest===void 0)throw new v("pOPAccessTicketRequest","Required parameter requestParameters.pOPAccessTicketRequest was null or undefined when calling createPopAccessTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets",method:"POST",headers:n,query:s,body:jo(t.pOPAccessTicketRequest)},i);return new q(o,a=>ht(a))}async createPopAccessTicket(t,i){return await(await this.createPopAccessTicketRaw(t,i)).value()}async getPopAccessAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPopAccessAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new v("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getPopAccessAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new Ft(o)}async getPopAccessAttachmentsById(t,i){return await(await this.getPopAccessAttachmentsByIdRaw(t,i)).value()}async getPopAccessAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPopAccessAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new q(o,a=>jt(a))}async getPopAccessAttachmentsList(t,i){return await(await this.getPopAccessAttachmentsListRaw(t,i)).value()}async getPopAccessTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPopAccessTicketById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new q(o,a=>hs(a))}async getPopAccessTicketById(t,i){return await(await this.getPopAccessTicketByIdRaw(t,i)).value()}async getPopAccessTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={},o=await this.request({path:"/pop-access-tickets",method:"GET",headers:n,query:s},i);return new q(o,a=>mr(a))}async getPopAccessTickets(t={},i){return await(await this.getPopAccessTicketsRaw(t,i)).value()}async updatePopAccessLocationsTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updatePopAccessLocationsTicket.");if(t.locationsPatchRequestInner===null||t.locationsPatchRequestInner===void 0)throw new v("locationsPatchRequestInner","Required parameter requestParameters.locationsPatchRequestInner was null or undefined when calling updatePopAccessLocationsTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}/locations".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:t.locationsPatchRequestInner.map(Ht)},i);return new q(o,a=>zt(a))}async updatePopAccessLocationsTicket(t,i){return await(await this.updatePopAccessLocationsTicketRaw(t,i)).value()}async updatePopAccessTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updatePopAccessTicket.");if(t.pOPAccessTicketUpdateRequest===null||t.pOPAccessTicketUpdateRequest===void 0)throw new v("pOPAccessTicketUpdateRequest","Required parameter requestParameters.pOPAccessTicketUpdateRequest was null or undefined when calling updatePopAccessTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/pop-access-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:rr(t.pOPAccessTicketUpdateRequest)},i);return new q(o,a=>hs(a))}async updatePopAccessTicket(t,i){return await(await this.updatePopAccessTicketRaw(t,i)).value()}}class Jr extends Xe{async cancellationPermanentBadgeRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationPermanentBadgeRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new v("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationPermanentBadgeRequest.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:Lt(t.cancellationTicketsRequest)},i);return new q(o,a=>Vt(a))}async cancellationPermanentBadgeRequest(t,i){return await(await this.cancellationPermanentBadgeRequestRaw(t,i)).value()}async createPermanentBadegeAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createPermanentBadegeAttachment.");if(t.fileName===null||t.fileName===void 0)throw new v("fileName","Required parameter requestParameters.fileName was null or undefined when calling createPermanentBadegeAttachment.");if(t.body===null||t.body===void 0)throw new v("body","Required parameter requestParameters.body was null or undefined when calling createPermanentBadegeAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new q(o,a=>_t(a))}async createPermanentBadegeAttachment(t,i){return await(await this.createPermanentBadegeAttachmentRaw(t,i)).value()}async createPermanentBadgeCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createPermanentBadgeComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new v("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createPermanentBadgeComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:Mt(t.ticketCommentsRequest)},i);return new q(o,a=>Ut(a))}async createPermanentBadgeComment(t,i){return await(await this.createPermanentBadgeCommentRaw(t,i)).value()}async createPermanentBadgeModifyTicketRaw(t,i){if(t.permanentBadgeAccessModifyTicketRequest===null||t.permanentBadgeAccessModifyTicketRequest===void 0)throw new v("permanentBadgeAccessModifyTicketRequest","Required parameter requestParameters.permanentBadgeAccessModifyTicketRequest was null or undefined when calling createPermanentBadgeModifyTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-access-modify-tickets",method:"POST",headers:n,query:s,body:vr(t.permanentBadgeAccessModifyTicketRequest)},i);return new q(o,a=>ht(a))}async createPermanentBadgeModifyTicket(t,i){return await(await this.createPermanentBadgeModifyTicketRaw(t,i)).value()}async createPermanentBadgeNewTicketRaw(t,i){if(t.permanentBadgeAccessNewTicketRequest===null||t.permanentBadgeAccessNewTicketRequest===void 0)throw new v("permanentBadgeAccessNewTicketRequest","Required parameter requestParameters.permanentBadgeAccessNewTicketRequest was null or undefined when calling createPermanentBadgeNewTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-access-new-tickets",method:"POST",headers:n,query:s,body:wr(t.permanentBadgeAccessNewTicketRequest)},i);return new q(o,a=>ht(a))}async createPermanentBadgeNewTicket(t,i){return await(await this.createPermanentBadgeNewTicketRaw(t,i)).value()}async createPermanentBadgeTerminateTicketRaw(t,i){if(t.permanentBadgeAccessTerminateTicketRequest===null||t.permanentBadgeAccessTerminateTicketRequest===void 0)throw new v("permanentBadgeAccessTerminateTicketRequest","Required parameter requestParameters.permanentBadgeAccessTerminateTicketRequest was null or undefined when calling createPermanentBadgeTerminateTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-access-terminate-tickets",method:"POST",headers:n,query:s,body:fr(t.permanentBadgeAccessTerminateTicketRequest)},i);return new q(o,a=>ht(a))}async createPermanentBadgeTerminateTicket(t,i){return await(await this.createPermanentBadgeTerminateTicketRaw(t,i)).value()}async getPermanentBadgeAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPermanentBadgeAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new v("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getPermanentBadgeAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new Ft(o)}async getPermanentBadgeAttachmentsById(t,i){return await(await this.getPermanentBadgeAttachmentsByIdRaw(t,i)).value()}async getPermanentBadgeAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPermanentBadgeAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new q(o,a=>jt(a))}async getPermanentBadgeAttachmentsList(t,i){return await(await this.getPermanentBadgeAttachmentsListRaw(t,i)).value()}async getPermanentBadgeHoldersListRaw(t,i){if(t.accountNumber===null||t.accountNumber===void 0)throw new v("accountNumber","Required parameter requestParameters.accountNumber was null or undefined when calling getPermanentBadgeHoldersList.");const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.activeBadge!==void 0&&(s.active_badge=t.activeBadge),t.nameOrEmailContains!==void 0&&(s.name_or_email_contains=t.nameOrEmailContains),t.page!==void 0&&(s.page=t.page),t.size!==void 0&&(s.size=t.size);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/badge-holders",method:"GET",headers:n,query:s},i);return new q(o,a=>vo(a))}async getPermanentBadgeHoldersList(t,i){return await(await this.getPermanentBadgeHoldersListRaw(t,i)).value()}async getPermanentBadgeTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPermanentBadgeTicketById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new q(o,a=>ws(a))}async getPermanentBadgeTicketById(t,i){return await(await this.getPermanentBadgeTicketByIdRaw(t,i)).value()}async getPermanentBadgeTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={},o=await this.request({path:"/permanent-badge-access-tickets",method:"GET",headers:n,query:s},i);return new q(o,a=>Ar(a))}async getPermanentBadgeTickets(t={},i){return await(await this.getPermanentBadgeTicketsRaw(t,i)).value()}async updatePermanentBadgeLocationsTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updatePermanentBadgeLocationsTicket.");if(t.locationsPatchRequestInner===null||t.locationsPatchRequestInner===void 0)throw new v("locationsPatchRequestInner","Required parameter requestParameters.locationsPatchRequestInner was null or undefined when calling updatePermanentBadgeLocationsTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}/locations".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:t.locationsPatchRequestInner.map(Ht)},i);return new q(o,a=>zt(a))}async updatePermanentBadgeLocationsTicket(t,i){return await(await this.updatePermanentBadgeLocationsTicketRaw(t,i)).value()}async updatePermanentBadgeTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updatePermanentBadgeTicket.");if(t.permanentBadgeAccessTicketUpdateRequest===null||t.permanentBadgeAccessTicketUpdateRequest===void 0)throw new v("permanentBadgeAccessTicketUpdateRequest","Required parameter requestParameters.permanentBadgeAccessTicketUpdateRequest was null or undefined when calling updatePermanentBadgeTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/permanent-badge-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:Tr(t.permanentBadgeAccessTicketUpdateRequest)},i);return new q(o,a=>ws(a))}async updatePermanentBadgeTicket(t,i){return await(await this.updatePermanentBadgeTicketRaw(t,i)).value()}}class Wr extends Xe{async cancellationVisitorAccessRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationVisitorAccessRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new v("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationVisitorAccessRequest.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:Lt(t.cancellationTicketsRequest)},i);return new q(o,a=>Vt(a))}async cancellationVisitorAccessRequest(t,i){return await(await this.cancellationVisitorAccessRequestRaw(t,i)).value()}async createVisitorAccessAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createVisitorAccessAttachment.");if(t.fileName===null||t.fileName===void 0)throw new v("fileName","Required parameter requestParameters.fileName was null or undefined when calling createVisitorAccessAttachment.");if(t.body===null||t.body===void 0)throw new v("body","Required parameter requestParameters.body was null or undefined when calling createVisitorAccessAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new q(o,a=>_t(a))}async createVisitorAccessAttachment(t,i){return await(await this.createVisitorAccessAttachmentRaw(t,i)).value()}async createVisitorAccessCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createVisitorAccessComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new v("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createVisitorAccessComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:Mt(t.ticketCommentsRequest)},i);return new q(o,a=>Ut(a))}async createVisitorAccessComment(t,i){return await(await this.createVisitorAccessCommentRaw(t,i)).value()}async createVisitorAccessTicketRaw(t,i){if(t.visitorAccessTicketRequest===null||t.visitorAccessTicketRequest===void 0)throw new v("visitorAccessTicketRequest","Required parameter requestParameters.visitorAccessTicketRequest was null or undefined when calling createVisitorAccessTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets",method:"POST",headers:n,query:s,body:Dr(t.visitorAccessTicketRequest)},i);return new q(o,a=>ht(a))}async createVisitorAccessTicket(t,i){return await(await this.createVisitorAccessTicketRaw(t,i)).value()}async getVisitorAccessAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getVisitorAccessAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new v("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getVisitorAccessAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new Ft(o)}async getVisitorAccessAttachmentsById(t,i){return await(await this.getVisitorAccessAttachmentsByIdRaw(t,i)).value()}async getVisitorAccessAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getVisitorAccessAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new q(o,a=>jt(a))}async getVisitorAccessAttachmentsList(t,i){return await(await this.getVisitorAccessAttachmentsListRaw(t,i)).value()}async getVisitorAccessTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getVisitorAccessTicketById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new q(o,a=>ks(a))}async getVisitorAccessTicketById(t,i){return await(await this.getVisitorAccessTicketByIdRaw(t,i)).value()}async getVisitorAccessTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={},o=await this.request({path:"/visitor-access-tickets",method:"GET",headers:n,query:s},i);return new q(o,a=>Fr(a))}async getVisitorAccessTickets(t={},i){return await(await this.getVisitorAccessTicketsRaw(t,i)).value()}async updateVisitorAccessLocationsTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateVisitorAccessLocationsTicket.");if(t.locationsPatchRequestInner===null||t.locationsPatchRequestInner===void 0)throw new v("locationsPatchRequestInner","Required parameter requestParameters.locationsPatchRequestInner was null or undefined when calling updateVisitorAccessLocationsTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}/locations".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:t.locationsPatchRequestInner.map(Ht)},i);return new q(o,a=>zt(a))}async updateVisitorAccessLocationsTicket(t,i){return await(await this.updateVisitorAccessLocationsTicketRaw(t,i)).value()}async updateVisitorAccessTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new v("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateVisitorAccessTicket.");if(t.visitorAccessTicketUpdateRequest===null||t.visitorAccessTicketUpdateRequest===void 0)throw new v("visitorAccessTicketUpdateRequest","Required parameter requestParameters.visitorAccessTicketUpdateRequest was null or undefined when calling updateVisitorAccessTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-access-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:$r(t.visitorAccessTicketUpdateRequest)},i);return new q(o,a=>ks(a))}async updateVisitorAccessTicket(t,i){return await(await this.updateVisitorAccessTicketRaw(t,i)).value()}}class Gr extends Xe{async getVisitorHostsListRaw(t,i){if(t.site===null||t.site===void 0)throw new v("site","Required parameter requestParameters.site was null or undefined when calling getVisitorHostsList.");const s={};t.site!==void 0&&(s.site=t.site),t.nameOrEmailContains!==void 0&&(s.name_or_email_contains=t.nameOrEmailContains),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/visitor-hosts",method:"GET",headers:n,query:s},i);return new q(o,a=>Hr(a))}async getVisitorHostsList(t,i){return await(await this.getVisitorHostsListRaw(t,i)).value()}}const Zr="http://localhost".replace(/\/+$/,"");class Wt{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Zr}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||ys}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const Kr=new Wt;class Bt{constructor(t=Kr){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new ec(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?Bt.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new Qr(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;Xr(r.body)||r.body instanceof URLSearchParams||Yr(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}Bt.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function Yr(e){return typeof Blob<"u"&&e instanceof Blob}function Xr(e){return typeof FormData<"u"&&e instanceof FormData}class Qr extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class ec extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class Ti extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function f(e,t){return e[t]!=null}function ys(e,t=""){return Object.keys(e).map(i=>Ts(i,e[i],t)).filter(i=>i.length>0).join("&")}function Ts(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return Ts(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?ys(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class It{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}const tc="https://service-management.digitalrealty.com".replace(/\/+$/,"");class Gt{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:tc}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||bs}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const ic=new Gt;class yt{constructor(t=ic){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new oc(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?yt.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new ac(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;nc(r.body)||r.body instanceof URLSearchParams||sc(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}yt.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function sc(e){return typeof Blob<"u"&&e instanceof Blob}function nc(e){return typeof FormData<"u"&&e instanceof FormData}class ac extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class oc extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class dt extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function Ge(e,t){return e[t]!=null}function bs(e,t=""){return Object.keys(e).map(i=>Rs(i,e[i],t)).filter(i=>i.length>0).join("&")}function Rs(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return Rs(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?bs(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class bi{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class rc{constructor(t){this.raw=t}async value(){return await this.raw.text()}}const cc="https://service-management.digitalrealty.com".replace(/\/+$/,"");class As{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:cc}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||_s}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const dc=new As;class oi{constructor(t=dc){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new pc(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?oi.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new mc(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;lc(r.body)||r.body instanceof URLSearchParams||uc(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}oi.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function uc(e){return typeof Blob<"u"&&e instanceof Blob}function lc(e){return typeof FormData<"u"&&e instanceof FormData}class mc extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class pc extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class ee extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function _(e,t){return e[t]!=null}function _s(e,t=""){return Object.keys(e).map(i=>Is(i,e[i],t)).filter(i=>i.length>0).join("&")}function Is(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return Is(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?_s(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class Pe{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class hc{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}function vc(e){if(e!==void 0)return e===null?null:{cancellationReason:e.cancellationReason}}function gc(e){return wc(e)}function wc(e,t){return e==null?e:{message:_(e,"message")?e.message:void 0}}function fc(e){return kc(e)}function kc(e,t){return e==null?e:{requestType:_(e,"request_type")?e.request_type:void 0,categories:_(e,"categories")?e.categories:void 0}}function yc(e){return Tc(e)}function Tc(e,t){return e==null?e:{items:_(e,"items")?e.items.map(fc):void 0}}function Ss(e){return bc(e)}function bc(e,t){return e==null?e:{createdBy:_(e,"created_by")?e.created_by:void 0,createdAt:_(e,"created_at")?new Date(e.created_at):void 0,comment:_(e,"comment")?e.comment:void 0}}function Rc(e){return Ac(e)}function Ac(e,t){return e==null?e:{comments:_(e,"comments")?e.comments.map(Ss):void 0}}function _c(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,request_type:e.requestType,category:e.category,subject:e.subject,description:e.description,expected_start:e.expectedStart===void 0?void 0:e.expectedStart===null?null:e.expectedStart.toISOString(),customer_reference:e.customerReference,locations:e.locations,reference_ticket:e.referenceTicket,other_notification_recipients:e.otherNotificationRecipients}}function Ri(e){return Ic(e)}function Ic(e,t){return e==null?e:{ticketId:_(e,"ticket_id")?e.ticket_id:void 0,accountNumber:_(e,"account_number")?e.account_number:void 0,accountName:_(e,"account_name")?e.account_name:void 0,status:_(e,"status")?e.status:void 0,cancellationReason:_(e,"cancellation_reason")?e.cancellation_reason:void 0,site:_(e,"site")?e.site:void 0,locations:_(e,"locations")?e.locations:void 0,requestType:_(e,"request_type")?e.request_type:void 0,category:_(e,"category")?e.category:void 0,subject:_(e,"subject")?e.subject:void 0,description:_(e,"description")?e.description:void 0,expectedStart:_(e,"expected_start")?e.expected_start===null?null:new Date(e.expected_start):void 0,referenceTicket:_(e,"reference_ticket")?e.reference_ticket:void 0,customerReference:_(e,"customer_reference")?e.customer_reference:void 0,otherNotificationRecipients:_(e,"other_notification_recipients")?e.other_notification_recipients:void 0,createdBy:_(e,"created_by")?e.created_by:void 0,createdAt:_(e,"created_at")?new Date(e.created_at):void 0,updatedAt:_(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:_(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0,comments:_(e,"comments")?e.comments.map(Ss):void 0}}function Sc(e){return Cc(e)}function Cc(e,t){return e==null?e:{accountNumber:_(e,"account_number")?e.account_number:void 0,accountName:_(e,"account_name")?e.account_name:void 0,id:_(e,"id")?e.id:void 0,status:_(e,"status")?e.status:void 0,site:_(e,"site")?e.site:void 0,locations:_(e,"locations")?e.locations:void 0,description:_(e,"description")?e.description:void 0,subject:_(e,"subject")?e.subject:void 0,createdBy:_(e,"created_by")?e.created_by:void 0,updatedAt:_(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:_(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function Nc(e){return Pc(e)}function Pc(e,t){return e==null?e:{remoteHandsTickets:_(e,"remote_hands_tickets")?e.remote_hands_tickets.map(Sc):void 0,totalCount:_(e,"total_count")?e.total_count:void 0,pageNumber:_(e,"page_number")?e.page_number:void 0,pageSize:_(e,"page_size")?e.page_size:void 0}}function qc(e){if(e!==void 0)return e===null?null:{customer_reference:e.customerReference,other_notification_recipients:e.otherNotificationRecipients}}function Cs(e){return Dc(e)}function Dc(e,t){return e==null?e:{id:_(e,"id")?e.id:void 0,fileName:_(e,"file_name")?e.file_name:void 0,fileSize:_(e,"file_size")?e.file_size:void 0,contentType:_(e,"content_type")?e.content_type:void 0,createdBy:_(e,"created_by")?e.created_by:void 0,createdAt:_(e,"created_at")?e.created_at===null?null:new Date(e.created_at):void 0}}function Bc(e){return Oc(e)}function Oc(e,t){return e==null?e:{attachments:_(e,"attachments")?e.attachments.map(Cs):void 0}}function $c(e){if(e!==void 0)return e===null?null:{comment:e.comment}}class Ec extends oi{async cancellationRemoteHandsRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationRemoteHandsRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new ee("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationRemoteHandsRequest.");const s={},n={};n["Content-Type"]="application/json";const o=await this.request({path:"/remote-hands-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:vc(t.cancellationTicketsRequest)},i);return new Pe(o,a=>gc(a))}async cancellationRemoteHandsRequest(t,i){return await(await this.cancellationRemoteHandsRequestRaw(t,i)).value()}async createRemoteHandsAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createRemoteHandsAttachment.");if(t.fileName===null||t.fileName===void 0)throw new ee("fileName","Required parameter requestParameters.fileName was null or undefined when calling createRemoteHandsAttachment.");if(t.body===null||t.body===void 0)throw new ee("body","Required parameter requestParameters.body was null or undefined when calling createRemoteHandsAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new Pe(o,a=>Cs(a))}async createRemoteHandsAttachment(t,i){return await(await this.createRemoteHandsAttachmentRaw(t,i)).value()}async createRemoteHandsCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createRemoteHandsComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new ee("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createRemoteHandsComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:$c(t.ticketCommentsRequest)},i);return new Pe(o,a=>Rc(a))}async createRemoteHandsComment(t,i){return await(await this.createRemoteHandsCommentRaw(t,i)).value()}async createRemoteHandsTicketRaw(t,i){if(t.remoteHandsRequest===null||t.remoteHandsRequest===void 0)throw new ee("remoteHandsRequest","Required parameter requestParameters.remoteHandsRequest was null or undefined when calling createRemoteHandsTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets",method:"POST",headers:n,query:s,body:_c(t.remoteHandsRequest)},i);return new Pe(o,a=>Ri(a))}async createRemoteHandsTicket(t,i){return await(await this.createRemoteHandsTicketRaw(t,i)).value()}async getRemoteHandsAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getRemoteHandsAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new ee("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getRemoteHandsAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/{ticket_id}/attachments/{attachment_id}/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new hc(o)}async getRemoteHandsAttachmentsById(t,i){return await(await this.getRemoteHandsAttachmentsByIdRaw(t,i)).value()}async getRemoteHandsAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getRemoteHandsAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new Pe(o,a=>Bc(a))}async getRemoteHandsAttachmentsList(t,i){return await(await this.getRemoteHandsAttachmentsListRaw(t,i)).value()}async getRemoteHandsCategoriesListRaw(t,i){if(t.site===null||t.site===void 0)throw new ee("site","Required parameter requestParameters.site was null or undefined when calling getRemoteHandsCategoriesList.");const s={};t.site!==void 0&&(s.site=t.site),t.accountNumber!==void 0&&(s.account_number=t.accountNumber);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/categories",method:"GET",headers:n,query:s},i);return new Pe(o,a=>yc(a))}async getRemoteHandsCategoriesList(t,i){return await(await this.getRemoteHandsCategoriesListRaw(t,i)).value()}async getRemoteHandsTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getRemoteHandsTicketById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new Pe(o,a=>Ri(a))}async getRemoteHandsTicketById(t,i){return await(await this.getRemoteHandsTicketByIdRaw(t,i)).value()}async getRemoteHandsTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={},o=await this.request({path:"/remote-hands-tickets",method:"GET",headers:n,query:s},i);return new Pe(o,a=>Nc(a))}async getRemoteHandsTickets(t={},i){return await(await this.getRemoteHandsTicketsRaw(t,i)).value()}async updateRemoteHandsTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ee("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateRemoteHandsTicketById.");if(t.remoteHandsUpdateRequest===null||t.remoteHandsUpdateRequest===void 0)throw new ee("remoteHandsUpdateRequest","Required parameter requestParameters.remoteHandsUpdateRequest was null or undefined when calling updateRemoteHandsTicketById.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/remote-hands-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:qc(t.remoteHandsUpdateRequest)},i);return new Pe(o,a=>Ri(a))}async updateRemoteHandsTicketById(t,i){return await(await this.updateRemoteHandsTicketByIdRaw(t,i)).value()}}function xc(e){return Fc(e)}function Fc(e,t){return e==null?e:{serviceManagement:f(e,"service_management")?e.service_management:void 0,remoteHands:f(e,"remote_hands")?e.remote_hands:void 0,deliveries:f(e,"deliveries")?e.deliveries:void 0,removals:f(e,"removals")?e.removals:void 0,facilitiesAccess:f(e,"facilities_access")?e.facilities_access:void 0,temporaryAccess:f(e,"temporary_access")?e.temporary_access:void 0,inventory:f(e,"inventory")?e.inventory:void 0,orderHistory:f(e,"order_history")?e.order_history:void 0,precabling:f(e,"precabling")?e.precabling:void 0,crossConnect:f(e,"cross_connect")?e.cross_connect:void 0,customerEquipmentConnection:f(e,"customer_equipment_connection")?e.customer_equipment_connection:void 0,virtualConnectivity:f(e,"virtual_connectivity")?e.virtual_connectivity:void 0,customerCare:f(e,"customer_care")?e.customer_care:void 0,troubleTickets:f(e,"trouble_tickets")?e.trouble_tickets:void 0}}function Lc(e){return Vc(e)}function Vc(e,t){return e==null?e:{name:f(e,"name")?e.name:void 0,privilegeLevel:f(e,"privilege_level")?e.privilege_level:void 0}}function Uc(e){return Hc(e)}function Hc(e,t){return e==null?e:{id:e.id,accountNumber:e.account_number,siteId:e.site_id,floor:f(e,"floor")?e.floor:void 0,room:f(e,"room")?e.room:void 0,cage:f(e,"cage")?e.cage:void 0,rack:f(e,"rack")?e.rack:void 0,row:f(e,"row")?e.row:void 0,locationType:e.location_type,csrDemarcation:e.csr_demarcation,comment:f(e,"comment")?e.comment:void 0,dcimEnabled:f(e,"dcim_enabled")?e.dcim_enabled:void 0,permissions:f(e,"permissions")?e.permissions.map(Lc):void 0,assignableProcesses:f(e,"assignable_processes")?xc(e.assignable_processes):void 0}}function zc(e){return jc(e)}function jc(e,t){return e==null?e:{self:f(e,"self")?e.self:void 0,first:f(e,"first")?e.first:void 0,prev:f(e,"prev")?e.prev:void 0,next:f(e,"next")?e.next:void 0,last:f(e,"last")?e.last:void 0,items:e.items.map(Uc)}}function Mc(e){return Jc(e)}function Jc(e,t){return e==null?e:{count:e.count}}function Ns(e){return Wc(e)}function Wc(e,t){return e==null?e:{id:f(e,"id")?e.id:void 0,locationId:f(e,"location_id")?e.location_id:void 0,name:f(e,"name")?e.name:void 0,campus:f(e,"campus")?e.campus:void 0,metroArea:f(e,"metro_area")?e.metro_area:void 0,region:f(e,"region")?e.region:void 0,regionName:f(e,"region_name")?e.region_name:void 0,country:f(e,"country")?e.country:void 0,addressCountry:f(e,"address_country")?e.address_country:void 0,addressLocality:f(e,"address_locality")?e.address_locality:void 0,addressRegion:f(e,"address_region")?e.address_region:void 0,postalCode:f(e,"postal_code")?e.postal_code:void 0,streetAddress:f(e,"street_address")?e.street_address:void 0,peeringdbFacilityId:f(e,"peeringdb_facility_id")?e.peeringdb_facility_id:void 0,organisationName:f(e,"organisation_name")?e.organisation_name:void 0,timeZone:f(e,"time_zone")?e.time_zone:void 0,latitude:f(e,"latitude")?e.latitude:void 0,longitude:f(e,"longitude")?e.longitude:void 0,locations:f(e,"locations")?Mc(e.locations):void 0}}function Gc(e){return Zc(e)}function Zc(e,t){return e==null?e:{self:f(e,"self")?e.self:void 0,first:f(e,"first")?e.first:void 0,prev:f(e,"prev")?e.prev:void 0,next:f(e,"next")?e.next:void 0,last:f(e,"last")?e.last:void 0,items:e.items.map(Ns)}}function Kc(e){return Yc(e)}function Yc(e,t){return e==null?e:{id:f(e,"id")?e.id:void 0,name:f(e,"name")?e.name:void 0,description:f(e,"description")?e.description:void 0}}function Xc(e){return Qc(e)}function Qc(e,t){return e==null?e:{id:f(e,"id")?e.id:void 0,name:f(e,"name")?e.name:void 0,description:f(e,"description")?e.description:void 0}}class ed extends Bt{async getLocationsRaw(t,i){const s={};t.sort!==void 0&&(s.sort=t.sort),t.cursor!==void 0&&(s.cursor=t.cursor),t.pageSize!==void 0&&(s.page_size=t.pageSize),t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.id!==void 0&&(s.id=t.id),t.siteId!==void 0&&(s.site_id=t.siteId),t.floor!==void 0&&(s.floor=t.floor),t.room!==void 0&&(s.room=t.room),t.cage!==void 0&&(s.cage=t.cage),t.rack!==void 0&&(s.rack=t.rack),t.row!==void 0&&(s.row=t.row),t.demarcation!==void 0&&(s.demarcation=t.demarcation),t.locationType!==void 0&&(s.location_type=t.locationType),t.embed!==void 0&&(s.embed=t.embed),t.permissionType!==void 0&&(s.permission_type=t.permissionType),t.permissionPrivilege!==void 0&&(s.permission_privilege=t.permissionPrivilege),t.dcimEnabled!==void 0&&(s.dcim_enabled=t.dcimEnabled),t.assignableProcess!==void 0&&(s.assignable_process=t.assignableProcess);const n={};this.configuration&&this.configuration.apiKey&&(n.Authorization=this.configuration.apiKey("Authorization"));const o=await this.request({path:"/locations",method:"GET",headers:n,query:s},i);return new It(o,a=>zc(a))}async getLocations(t={},i){return await(await this.getLocationsRaw(t,i)).value()}}class Ps extends Bt{async getOspsBySiteIdRaw(t,i){if(t.siteId===null||t.siteId===void 0)throw new Ti("siteId","Required parameter requestParameters.siteId was null or undefined when calling getOspsBySiteId.");const s={},n={};this.configuration&&this.configuration.apiKey&&(n.Authorization=this.configuration.apiKey("Authorization"));const o=await this.request({path:"/sites/{siteId}/osps".replace("{siteId}",encodeURIComponent(String(t.siteId))),method:"GET",headers:n,query:s},i);return new It(o,a=>a.map(Kc))}async getOspsBySiteId(t,i){return await(await this.getOspsBySiteIdRaw(t,i)).value()}async getPopsBySiteIdRaw(t,i){if(t.siteId===null||t.siteId===void 0)throw new Ti("siteId","Required parameter requestParameters.siteId was null or undefined when calling getPopsBySiteId.");const s={},n={};this.configuration&&this.configuration.apiKey&&(n.Authorization=this.configuration.apiKey("Authorization"));const o=await this.request({path:"/sites/{siteId}/pops".replace("{siteId}",encodeURIComponent(String(t.siteId))),method:"GET",headers:n,query:s},i);return new It(o,a=>a.map(Xc))}async getPopsBySiteId(t,i){return await(await this.getPopsBySiteIdRaw(t,i)).value()}async getSiteByIdRaw(t,i){if(t.siteId===null||t.siteId===void 0)throw new Ti("siteId","Required parameter requestParameters.siteId was null or undefined when calling getSiteById.");const s={},n={};this.configuration&&this.configuration.apiKey&&(n.Authorization=this.configuration.apiKey("Authorization"));const o=await this.request({path:"/sites/{siteId}".replace("{siteId}",encodeURIComponent(String(t.siteId))),method:"GET",headers:n,query:s},i);return new It(o,a=>Ns(a))}async getSiteById(t,i){return await(await this.getSiteByIdRaw(t,i)).value()}async getSitesRaw(t,i){const s={};t.name!==void 0&&(s.name=t.name),t.sort!==void 0&&(s.sort=t.sort),t.cursor!==void 0&&(s.cursor=t.cursor),t.pageSize!==void 0&&(s.page_size=t.pageSize),t.showMySites!==void 0&&(s.show_my_sites=t.showMySites),t.embed!==void 0&&(s.embed=t.embed);const n={};this.configuration&&this.configuration.apiKey&&(n.Authorization=this.configuration.apiKey("Authorization"));const o=await this.request({path:"/sites",method:"GET",headers:n,query:s},i);return new It(o,a=>Gc(a))}async getSites(t={},i){return await(await this.getSitesRaw(t,i)).value()}}const td="https://api.digitalrealty.com".replace(/\/+$/,"");class qs{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:td}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Ds}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const id=new qs;class ri{constructor(t=id){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new od(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?ri.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new ad(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;nd(r.body)||r.body instanceof URLSearchParams||sd(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}ri.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function sd(e){return typeof Blob<"u"&&e instanceof Blob}function nd(e){return typeof FormData<"u"&&e instanceof FormData}class ad extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class od extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class Zt extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function T(e,t){return e[t]!=null}function Ds(e,t=""){return Object.keys(e).map(i=>Bs(i,e[i],t)).filter(i=>i.length>0).join("&")}function Bs(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return Bs(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Ds(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class Ai{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class Os{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}const rd="https://api.digitalrealty.com/service-management/v1".replace(/\/+$/,"");class $s{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:rd}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Es}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const cd=new $s;class ci{constructor(t=cd){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new md(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?ci.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new ld(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;ud(r.body)||r.body instanceof URLSearchParams||dd(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}ci.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function dd(e){return typeof Blob<"u"&&e instanceof Blob}function ud(e){return typeof FormData<"u"&&e instanceof FormData}class ld extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class md extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class vt extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function D(e,t){return e[t]!=null}function Es(e,t=""){return Object.keys(e).map(i=>xs(i,e[i],t)).filter(i=>i.length>0).join("&")}function xs(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return xs(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Es(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class Kt{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class Fs{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}function Ls(e){return pd(e)}function pd(e,t){return e==null?e:{createdBy:D(e,"created_by")?e.created_by:void 0,createdAt:D(e,"created_at")?new Date(e.created_at):void 0,comment:D(e,"comment")?e.comment:void 0}}function hd(e){return vd(e)}function vd(e,t){return e==null?e:{comments:D(e,"comments")?e.comments.map(Ls):void 0}}function Vs(e){return gd(e)}function gd(e,t){return e==null?e:{id:D(e,"id")?e.id:void 0,fileName:D(e,"file_name")?e.file_name:void 0}}function wd(e){return fd(e)}function fd(e,t){return e==null?e:{accountNumber:D(e,"account_number")?e.account_number:void 0,accountName:D(e,"account_name")?e.account_name:void 0,id:D(e,"id")?e.id:void 0,status:D(e,"status")?e.status:void 0,subject:D(e,"subject")?e.subject:void 0,site:D(e,"site")?e.site:void 0,priority:D(e,"priority")?e.priority:void 0,comments:D(e,"comments")?e.comments.map(Ls):void 0,attachments:D(e,"attachments")?e.attachments.map(Vs):void 0,createdAt:D(e,"created_at")?new Date(e.created_at):void 0,updatedAt:D(e,"updated_at")?new Date(e.updated_at):void 0}}function kd(e){return yd(e)}function yd(e,t){return e==null?e:{accountNumber:D(e,"account_number")?e.account_number:void 0,accountName:D(e,"account_name")?e.account_name:void 0,id:D(e,"id")?e.id:void 0,status:D(e,"status")?e.status:void 0,subject:D(e,"subject")?e.subject:void 0,site:D(e,"site")?e.site:void 0,priority:D(e,"priority")?e.priority:void 0,attachments:D(e,"attachments")?e.attachments.map(Vs):void 0,createdAt:D(e,"created_at")?new Date(e.created_at):void 0,updatedAt:D(e,"updated_at")?new Date(e.updated_at):void 0}}function Td(e){return bd(e)}function bd(e,t){return e==null?e:{items:D(e,"items")?e.items.map(kd):void 0,totalCount:D(e,"total_count")?e.total_count:void 0,pageNumber:D(e,"page_number")?e.page_number:void 0,pageSize:D(e,"page_size")?e.page_size:void 0}}function Rd(e){return Ad(e)}function Ad(e,t){return e==null?e:{id:D(e,"id")?e.id:void 0,fileName:D(e,"file_name")?e.file_name:void 0,fileSize:D(e,"file_size")?e.file_size:void 0,contentType:D(e,"content_type")?e.content_type:void 0,createdBy:D(e,"created_by")?e.created_by:void 0,createdAt:D(e,"created_at")?new Date(e.created_at):void 0}}function _d(e){return Id(e)}function Id(e,t){return e==null?e:{attachments:D(e,"attachments")?e.attachments.map(Rd):void 0}}function Sd(e){if(e!==void 0)return e===null?null:{comment:e.comment}}class Cd extends ci{async createIncidentCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new vt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createIncidentComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new vt("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createIncidentComment.");const s={},n={};n["Content-Type"]="application/json";const o=await this.request({path:"/incident-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:Sd(t.ticketCommentsRequest)},i);return new Kt(o,a=>hd(a))}async createIncidentComment(t,i){return await(await this.createIncidentCommentRaw(t,i)).value()}async downloadIncidentTicketsRaw(t,i){const s={};t.$filter!==void 0&&(s.$filter=t.$filter),t.$orderby!==void 0&&(s.$orderby=t.$orderby),t.$skip!==void 0&&(s.$skip=t.$skip),t.$top!==void 0&&(s.$top=t.$top);const n={},o=await this.request({path:"/incident-tickets/file",method:"GET",headers:n,query:s},i);return new Fs(o)}async downloadIncidentTickets(t={},i){return await(await this.downloadIncidentTicketsRaw(t,i)).value()}async getIncidentsAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new vt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getIncidentsAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new vt("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getIncidentsAttachmentsById.");const s={},n={},o=await this.request({path:"/incident-tickets/{ticket_id}/attachments/file/{attachment_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new Fs(o)}async getIncidentsAttachmentsById(t,i){return await(await this.getIncidentsAttachmentsByIdRaw(t,i)).value()}async getIncidentsAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new vt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getIncidentsAttachmentsList.");const s={},n={},o=await this.request({path:"/incident-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new Kt(o,a=>_d(a))}async getIncidentsAttachmentsList(t,i){return await(await this.getIncidentsAttachmentsListRaw(t,i)).value()}async getIncidentsTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new vt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getIncidentsTicketById.");const s={},n={},o=await this.request({path:"/incident-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new Kt(o,a=>wd(a))}async getIncidentsTicketById(t,i){return await(await this.getIncidentsTicketByIdRaw(t,i)).value()}async getIncidentsTicketsRaw(t,i){const s={};t.$filter!==void 0&&(s.$filter=t.$filter),t.$orderby!==void 0&&(s.$orderby=t.$orderby),t.$skip!==void 0&&(s.$skip=t.$skip),t.$top!==void 0&&(s.$top=t.$top);const n={},o=await this.request({path:"/incident-tickets",method:"GET",headers:n,query:s},i);return new Kt(o,a=>Td(a))}async getIncidentsTickets(t={},i){return await(await this.getIncidentsTicketsRaw(t,i)).value()}}const Nd="http://localhost".replace(/\/+$/,"");class Us{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Nd}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||zs}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const Pd=new Us;class di{constructor(t=Pd){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new Od(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?di.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new Bd(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;Dd(r.body)||r.body instanceof URLSearchParams||qd(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}di.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function qd(e){return typeof Blob<"u"&&e instanceof Blob}function Dd(e){return typeof FormData<"u"&&e instanceof FormData}class Bd extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class Od extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class Hs extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function qe(e,t){return e[t]!=null}function zs(e,t=""){return Object.keys(e).map(i=>js(i,e[i],t)).filter(i=>i.length>0).join("&")}function js(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return js(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?zs(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class $d{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}const Ed="http://localhost".replace(/\/+$/,"");class Ms{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Ed}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Ws}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const xd=new Ms;class ui{constructor(t=xd){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new Ud(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?ui.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new Vd(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;Ld(r.body)||r.body instanceof URLSearchParams||Fd(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}ui.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function Fd(e){return typeof Blob<"u"&&e instanceof Blob}function Ld(e){return typeof FormData<"u"&&e instanceof FormData}class Vd extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class Ud extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}function Js(e,t){return e[t]!=null}function Ws(e,t=""){return Object.keys(e).map(i=>Gs(i,e[i],t)).filter(i=>i.length>0).join("&")}function Gs(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return Gs(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Ws(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class Zs{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}function Hd(e){if(e!==void 0)return e===null?null:{cancellationReason:e.cancellationReason}}function zd(e){return jd(e)}function jd(e,t){return e==null?e:{message:I(e,"message")?e.message:void 0}}function Md(e){return Jd(e)}function Jd(e,t){return e==null?e:{requestType:I(e,"request_type")?e.request_type:void 0,categories:I(e,"categories")?e.categories:void 0}}function Wd(e){return Gd(e)}function Gd(e,t){return e==null?e:{items:I(e,"items")?e.items.map(Md):void 0}}function Ks(e){return Zd(e)}function Zd(e,t){return e==null?e:{createdBy:I(e,"created_by")?e.created_by:void 0,createdAt:I(e,"created_at")?new Date(e.created_at):void 0,comment:I(e,"comment")?e.comment:void 0}}function Kd(e){return Yd(e)}function Yd(e,t){return e==null?e:{comments:I(e,"comments")?e.comments.map(Ks):void 0}}function Xd(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,subject:e.subject,request_type:e.requestType,category:e.category,locations:e.locations,customer_reference:e.customerReference,description:e.description,notification_recipients:e.notificationRecipients}}function _i(e){return Qd(e)}function Qd(e,t){return e==null?e:{accountNumber:I(e,"account_number")?e.account_number:void 0,accountName:I(e,"account_name")?e.account_name:void 0,id:I(e,"id")?e.id:void 0,status:I(e,"status")?e.status:void 0,cancellationReason:I(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:I(e,"subject")?e.subject:void 0,requestType:I(e,"request_type")?e.request_type:void 0,category:I(e,"category")?e.category:void 0,site:I(e,"site")?e.site:void 0,locations:I(e,"locations")?e.locations:void 0,customerReference:I(e,"customer_reference")?e.customer_reference:void 0,description:I(e,"description")?e.description:void 0,notificationRecipients:I(e,"notification_recipients")?e.notification_recipients:void 0,createdBy:I(e,"created_by")?e.created_by:void 0,createdAt:I(e,"created_at")?new Date(e.created_at):void 0,updatedAt:I(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:I(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0,comments:I(e,"comments")?e.comments.map(Ks):void 0}}function eu(e){if(e!==void 0)return e===null?null:{subject:e.subject,description:e.description,customer_reference:e.customerReference,other_notification_recipients:e.otherNotificationRecipients}}function tu(e){return iu(e)}function iu(e,t){return e==null?e:{accountNumber:I(e,"account_number")?e.account_number:void 0,accountName:I(e,"account_name")?e.account_name:void 0,id:I(e,"id")?e.id:void 0,status:I(e,"status")?e.status:void 0,subject:I(e,"subject")?e.subject:void 0,site:I(e,"site")?e.site:void 0,locations:I(e,"locations")?e.locations:void 0,description:I(e,"description")?e.description:void 0,createdBy:I(e,"created_by")?e.created_by:void 0,createdAt:I(e,"created_at")?new Date(e.created_at):void 0,updatedAt:I(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:I(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function su(e){return nu(e)}function nu(e,t){return e==null?e:{items:I(e,"items")?e.items.map(tu):void 0,totalCount:I(e,"total_count")?e.total_count:void 0,pageNumber:I(e,"page_number")?e.page_number:void 0,pageSize:I(e,"page_size")?e.page_size:void 0}}function Ys(e){return au(e)}function au(e,t){return e==null?e:{id:I(e,"id")?e.id:void 0,fileName:I(e,"file_name")?e.file_name:void 0,fileSize:I(e,"file_size")?e.file_size:void 0,contentType:I(e,"content_type")?e.content_type:void 0,createdBy:I(e,"created_by")?e.created_by:void 0,createdAt:I(e,"created_at")?new Date(e.created_at):void 0}}function ou(e){return ru(e)}function ru(e,t){return e==null?e:{attachments:I(e,"attachments")?e.attachments.map(Ys):void 0}}function cu(e){if(e!==void 0)return e===null?null:{comment:e.comment}}class du extends ai{async cancellationCustomerCareRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ne("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationCustomerCareRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new ne("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationCustomerCareRequest.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:Hd(t.cancellationTicketsRequest)},i);return new Ne(o,a=>zd(a))}async cancellationCustomerCareRequest(t,i){return await(await this.cancellationCustomerCareRequestRaw(t,i)).value()}async createCustomerCareCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ne("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createCustomerCareComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new ne("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createCustomerCareComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:cu(t.ticketCommentsRequest)},i);return new Ne(o,a=>Kd(a))}async createCustomerCareComment(t,i){return await(await this.createCustomerCareCommentRaw(t,i)).value()}async createCustomerCareTicketRaw(t,i){if(t.customerCareTicketRequest===null||t.customerCareTicketRequest===void 0)throw new ne("customerCareTicketRequest","Required parameter requestParameters.customerCareTicketRequest was null or undefined when calling createCustomerCareTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets",method:"POST",headers:n,query:s,body:Xd(t.customerCareTicketRequest)},i);return new Ne(o,a=>_i(a))}async createCustomerCareTicket(t,i){return await(await this.createCustomerCareTicketRaw(t,i)).value()}async createCustomerCareTicketAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ne("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createCustomerCareTicketAttachment.");if(t.fileName===null||t.fileName===void 0)throw new ne("fileName","Required parameter requestParameters.fileName was null or undefined when calling createCustomerCareTicketAttachment.");if(t.body===null||t.body===void 0)throw new ne("body","Required parameter requestParameters.body was null or undefined when calling createCustomerCareTicketAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new Ne(o,a=>Ys(a))}async createCustomerCareTicketAttachment(t,i){return await(await this.createCustomerCareTicketAttachmentRaw(t,i)).value()}async getCustomerCareCategoriesListRaw(t,i){const s={};t.site!==void 0&&(s.site=t.site),t.accountNumber!==void 0&&(s.account_number=t.accountNumber);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/categories",method:"GET",headers:n,query:s},i);return new Ne(o,a=>Wd(a))}async getCustomerCareCategoriesList(t={},i){return await(await this.getCustomerCareCategoriesListRaw(t,i)).value()}async getCustomerCareTicketAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ne("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getCustomerCareTicketAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new ne("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getCustomerCareTicketAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}/attachments/file/{attachment_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new Na(o)}async getCustomerCareTicketAttachmentsById(t,i){return await(await this.getCustomerCareTicketAttachmentsByIdRaw(t,i)).value()}async getCustomerCareTicketAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ne("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getCustomerCareTicketAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new Ne(o,a=>ou(a))}async getCustomerCareTicketAttachmentsList(t,i){return await(await this.getCustomerCareTicketAttachmentsListRaw(t,i)).value()}async getCustomerCareTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ne("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getCustomerCareTicketById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new Ne(o,a=>_i(a))}async getCustomerCareTicketById(t,i){return await(await this.getCustomerCareTicketByIdRaw(t,i)).value()}async getCustomerCareTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={},o=await this.request({path:"/customer-care-tickets",method:"GET",headers:n,query:s},i);return new Ne(o,a=>su(a))}async getCustomerCareTickets(t={},i){return await(await this.getCustomerCareTicketsRaw(t,i)).value()}async updateCustomerCareTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new ne("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateCustomerCareTicket.");if(t.customerCareTicketUpdateRequest===null||t.customerCareTicketUpdateRequest===void 0)throw new ne("customerCareTicketUpdateRequest","Required parameter requestParameters.customerCareTicketUpdateRequest was null or undefined when calling updateCustomerCareTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/customer-care-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:eu(t.customerCareTicketUpdateRequest)},i);return new Ne(o,a=>_i(a))}async updateCustomerCareTicket(t,i){return await(await this.updateCustomerCareTicketRaw(t,i)).value()}}function uu(e){return lu(e)}function lu(e,t){return e==null?e:{requestType:Ge(e,"request_type")?e.request_type:void 0,categories:Ge(e,"categories")?e.categories:void 0}}function mu(e){return pu(e)}function pu(e,t){return e==null?e:{mappedRequestType:Ge(e,"mapped_request_type")?e.mapped_request_type:void 0,canonicalValue:Ge(e,"canonical_value")?e.canonical_value:void 0,mappedValue:Ge(e,"mapped_value")?e.mapped_value:void 0,isActive:Ge(e,"is_active")?e.is_active:void 0}}function hu(e){return vu(e)}function vu(e,t){return e==null?e:{requestType:Ge(e,"request_type")?e.request_type:void 0,categories:Ge(e,"categories")?e.categories.map(mu):void 0}}class gu extends yt{async getRequestTypesAndCategoriesRaw(t,i){if(t.serviceTicketType===null||t.serviceTicketType===void 0)throw new dt("serviceTicketType","Required parameter requestParameters.serviceTicketType was null or undefined when calling getRequestTypesAndCategories.");if(t.accountNumber===null||t.accountNumber===void 0)throw new dt("accountNumber","Required parameter requestParameters.accountNumber was null or undefined when calling getRequestTypesAndCategories.");if(t.site===null||t.site===void 0)throw new dt("site","Required parameter requestParameters.site was null or undefined when calling getRequestTypesAndCategories.");if(t.requestType===null||t.requestType===void 0)throw new dt("requestType","Required parameter requestParameters.requestType was null or undefined when calling getRequestTypesAndCategories.");const s={};t.serviceTicketType!==void 0&&(s.service_ticket_type=t.serviceTicketType),t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.requestType!==void 0&&(s.request_type=t.requestType);const n={},o=await this.request({path:"/categories",method:"GET",headers:n,query:s},i);return new bi(o,a=>a.map(uu))}async getRequestTypesAndCategories(t,i){return await(await this.getRequestTypesAndCategoriesRaw(t,i)).value()}}class wu extends yt{async getRequestTypeCategoryMappingsRaw(t,i){if(t.serviceTicketType===null||t.serviceTicketType===void 0)throw new dt("serviceTicketType","Required parameter requestParameters.serviceTicketType was null or undefined when calling getRequestTypeCategoryMappings.");if(t.serviceManagementSystem===null||t.serviceManagementSystem===void 0)throw new dt("serviceManagementSystem","Required parameter requestParameters.serviceManagementSystem was null or undefined when calling getRequestTypeCategoryMappings.");const s={};t.serviceTicketType!==void 0&&(s.service_ticket_type=t.serviceTicketType),t.serviceManagementSystem!==void 0&&(s.service_management_system=t.serviceManagementSystem),t.siteCode!==void 0&&(s.site_code=t.siteCode);const n={},o=await this.request({path:"/requestTypeCategoryMappings",method:"GET",headers:n,query:s},i);return new bi(o,a=>a.map(hu))}async getRequestTypeCategoryMappings(t,i){return await(await this.getRequestTypeCategoryMappingsRaw(t,i)).value()}}const fu={CustomerEnquiries:"customer_enquiries",RemoteHands:"remote_hands",CustomerCare:"customer_care",TroubleTickets:"trouble_tickets"};class ku extends yt{async getTermsRaw(t,i){if(t.service===null||t.service===void 0)throw new dt("service","Required parameter requestParameters.service was null or undefined when calling getTerms.");const s={},n={},o=await this.request({path:"/{service}/terms".replace("{service}",encodeURIComponent(String(t.service))),method:"GET",headers:n,query:s},i);return this.isJsonMime(o.headers.get("content-type"))?new bi(o):new rc(o)}async getTerms(t,i){return await(await this.getTermsRaw(t,i)).value()}}const yu="https://api.digitalrealty.com".replace(/\/+$/,"");class Xs{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:yu}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Qs}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const Tu=new Xs;class li{constructor(t=Tu){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new _u(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?li.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new Au(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;Ru(r.body)||r.body instanceof URLSearchParams||bu(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}li.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function bu(e){return typeof Blob<"u"&&e instanceof Blob}function Ru(e){return typeof FormData<"u"&&e instanceof FormData}class Au extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class _u extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}function V(e,t){return e[t]!=null}function Qs(e,t=""){return Object.keys(e).map(i=>en(i,e[i],t)).filter(i=>i.length>0).join("&")}function en(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return en(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Qs(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class Iu{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class Su{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}function Cu(e){return Nu(e)}function Nu(e,t){return e==null?e:{id:V(e,"id")?e.id:void 0,name:V(e,"name")?e.name:void 0}}function Pu(e){return qu(e)}function qu(e,t){return e==null?e:{accountNumber:V(e,"account_number")?e.account_number:void 0,accountName:V(e,"account_name")?e.account_name:void 0,ticketId:V(e,"ticket_id")?e.ticket_id:void 0,ticketType:V(e,"ticket_type")?e.ticket_type:void 0,requestType:V(e,"request_type")?e.request_type:void 0,category:V(e,"category")?e.category:void 0,subject:V(e,"subject")?e.subject:void 0,sites:V(e,"sites")?e.sites.map(Cu):void 0,locations:V(e,"locations")?e.locations:void 0,accessRequestedFor:V(e,"access_requested_for")?e.access_requested_for:void 0,status:V(e,"status")?e.status:void 0,cancellationReason:V(e,"cancellation_reason")?e.cancellation_reason:void 0,createdBy:V(e,"created_by")?e.created_by:void 0,createdAt:V(e,"created_at")?new Date(e.created_at):void 0,updatedAt:V(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:V(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function Du(e){return Bu(e)}function Bu(e,t){return e==null?e:{items:V(e,"items")?e.items.map(Pu):void 0,totalCount:V(e,"total_count")?e.total_count:void 0,pageNumber:V(e,"page_number")?e.page_number:void 0,pageSize:V(e,"page_size")?e.page_size:void 0}}class Ou extends li{async downloadServiceTicketsRaw(t,i){const s={};t.$filter!==void 0&&(s.$filter=t.$filter),t.permissionPrivilege!==void 0&&(s.permission_privilege=t.permissionPrivilege);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/service-tickets/file",method:"GET",headers:n,query:s},i);return new Su(o)}async downloadServiceTickets(t={},i){return await(await this.downloadServiceTicketsRaw(t,i)).value()}async getServiceTicketsRaw(t,i){const s={};t.$filter!==void 0&&(s.$filter=t.$filter),t.$orderby!==void 0&&(s.$orderby=t.$orderby),t.$skip!==void 0&&(s.$skip=t.$skip),t.$top!==void 0&&(s.$top=t.$top),t.permissionPrivilege!==void 0&&(s.permission_privilege=t.permissionPrivilege);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/service-tickets",method:"GET",headers:n,query:s},i);return new Iu(o,a=>Du(a))}async getServiceTickets(t={},i){return await(await this.getServiceTicketsRaw(t,i)).value()}}function $u(e){return Eu(e)}function Eu(e,t){return e==null?e:{id:T(e,"id")?e.id:void 0,fileName:T(e,"file_name")?e.file_name:void 0}}function xu(e){return Fu(e)}function Fu(e,t){return e==null?e:{accountNumber:T(e,"account_number")?e.account_number:void 0,accountName:T(e,"account_name")?e.account_name:void 0,id:T(e,"id")?e.id:void 0,status:T(e,"status")?e.status:void 0,cancellationReason:T(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:T(e,"subject")?e.subject:void 0,startDate:T(e,"start_date")?new Date(e.start_date):void 0,endDate:T(e,"end_date")?new Date(e.end_date):void 0,approvalStatus:T(e,"approval_status")?e.approval_status:void 0,category:T(e,"category")?e.category:void 0,activityType:T(e,"activity_type")?e.activity_type:void 0,activitySubtype:T(e,"activity_subtype")?e.activity_subtype:void 0,activityCategory:T(e,"activity_category")?e.activity_category:void 0,site:T(e,"site")?e.site:void 0,locations:T(e,"locations")?e.locations:void 0,highLevelSummary:T(e,"high_level_summary")?e.high_level_summary:void 0,serviceType:T(e,"service_type")?e.service_type:void 0,riskLevel:T(e,"risk_level")?e.risk_level:void 0,attachments:T(e,"attachments")?e.attachments.map($u):void 0,createdAt:T(e,"created_at")?new Date(e.created_at):void 0,updatedAt:T(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:T(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function Lu(e){return Vu(e)}function Vu(e,t){return e==null?e:{items:T(e,"items")?e.items.map(xu):void 0}}function Uu(e){return Hu(e)}function Hu(e,t){return e==null?e:{id:T(e,"id")?e.id:void 0,fileName:T(e,"file_name")?e.file_name:void 0}}function zu(e){return ju(e)}function ju(e,t){return e==null?e:{accountNumber:T(e,"account_number")?e.account_number:void 0,accountName:T(e,"account_name")?e.account_name:void 0,id:T(e,"id")?e.id:void 0,status:T(e,"status")?e.status:void 0,subject:T(e,"subject")?e.subject:void 0,startDate:T(e,"start_date")?new Date(e.start_date):void 0,endDate:T(e,"end_date")?new Date(e.end_date):void 0,activityType:T(e,"activity_type")?e.activity_type:void 0,site:T(e,"site")?e.site:void 0,locations:T(e,"locations")?e.locations:void 0,notificationType:T(e,"notification_type")?e.notification_type:void 0,riskLevel:T(e,"risk_level")?e.risk_level:void 0,attachments:T(e,"attachments")?e.attachments.map(Uu):void 0,createdAt:T(e,"created_at")?new Date(e.created_at):void 0,updatedAt:T(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:T(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function Mu(e){return Ju(e)}function Ju(e,t){return e==null?e:{items:T(e,"items")?e.items.map(zu):void 0,totalCount:T(e,"total_count")?e.total_count:void 0,pageNumber:T(e,"page_number")?e.page_number:void 0,pageSize:T(e,"page_size")?e.page_size:void 0}}function Wu(e){return Gu(e)}function Gu(e,t){return e==null?e:{id:T(e,"id")?e.id:void 0,fileName:T(e,"file_name")?e.file_name:void 0,fileSize:T(e,"file_size")?e.file_size:void 0,contentType:T(e,"content_type")?e.content_type:void 0,createdBy:T(e,"created_by")?e.created_by:void 0,createdAt:T(e,"created_at")?new Date(e.created_at):void 0}}function Zu(e){return Ku(e)}function Ku(e,t){return e==null?e:{attachments:T(e,"attachments")?e.attachments.map(Wu):void 0}}class Yu extends ri{async downloadPlannedMaintenanceTicketsRaw(t,i){const s={};t.$filter!==void 0&&(s.$filter=t.$filter),t.$orderby!==void 0&&(s.$orderby=t.$orderby),t.$skip!==void 0&&(s.$skip=t.$skip),t.$top!==void 0&&(s.$top=t.$top);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/planned-maintenances/file",method:"GET",headers:n,query:s},i);return new Os(o)}async downloadPlannedMaintenanceTickets(t={},i){return await(await this.downloadPlannedMaintenanceTicketsRaw(t,i)).value()}async getPlannedMaintenanceAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new Zt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPlannedMaintenanceAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new Zt("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getPlannedMaintenanceAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/planned-maintenances/{ticket_id}/attachments/file/{attachment_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new Os(o)}async getPlannedMaintenanceAttachmentsById(t,i){return await(await this.getPlannedMaintenanceAttachmentsByIdRaw(t,i)).value()}async getPlannedMaintenanceAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new Zt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPlannedMaintenanceAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/planned-maintenances/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new Ai(o,a=>Zu(a))}async getPlannedMaintenanceAttachmentsList(t,i){return await(await this.getPlannedMaintenanceAttachmentsListRaw(t,i)).value()}async getPlannedMaintenanceTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new Zt("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getPlannedMaintenanceTicketById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/planned-maintenances/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new Ai(o,a=>Lu(a))}async getPlannedMaintenanceTicketById(t,i){return await(await this.getPlannedMaintenanceTicketByIdRaw(t,i)).value()}async getPlannedMaintenanceTicketsRaw(t,i){const s={};t.$filter!==void 0&&(s.$filter=t.$filter),t.$orderby!==void 0&&(s.$orderby=t.$orderby),t.$skip!==void 0&&(s.$skip=t.$skip),t.$top!==void 0&&(s.$top=t.$top);const n={},o=await this.request({path:"/planned-maintenances",method:"GET",headers:n,query:s},i);return new Ai(o,a=>Mu(a))}async getPlannedMaintenanceTickets(t={},i){return await(await this.getPlannedMaintenanceTicketsRaw(t,i)).value()}}function Xu(e){return Qu(e)}function Qu(e,t){return e==null?e:{en:qe(e,"en")?e.en:void 0,fr:qe(e,"fr")?e.fr:void 0,de:qe(e,"de")?e.de:void 0,es:qe(e,"es")?e.es:void 0}}function el(e){return tl(e)}function tl(e,t){return e}function il(e){return sl(e)}function sl(e,t){return e}const Yt={ServiceNow:"ServiceNow",InSite:"InSite",TelxSfdc:"TelxSFDC"};function nl(e){return al(e)}function al(e,t){return e}function ol(e){return rl(e)}function rl(e,t){return e==null?e:{process:qe(e,"process")?il(e.process):void 0,site:qe(e,"site")?e.site:void 0,serviceManagementSystem:qe(e,"serviceManagementSystem")?nl(e.serviceManagementSystem):void 0,destinationUrls:qe(e,"destinationUrls")?Xu(e.destinationUrls):void 0,portal:qe(e,"portal")?el(e.portal):void 0}}class cl extends di{async getSiteNavigationRaw(t,i){if(t.accountNumber===null||t.accountNumber===void 0)throw new Hs("accountNumber","Required parameter requestParameters.accountNumber was null or undefined when calling getSiteNavigation.");if(t.site===null||t.site===void 0)throw new Hs("site","Required parameter requestParameters.site was null or undefined when calling getSiteNavigation.");const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.process!==void 0&&(s.process=t.process);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("bearerToken",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/site-configurations",method:"GET",headers:n,query:s},i);return new $d(o,a=>a.map(ol))}async getSiteNavigation(t,i){return await(await this.getSiteNavigationRaw(t,i)).value()}}const dl="http://localhost".replace(/\/+$/,"");class tn{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:dl}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||sn}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const ul=new tn;class mi{constructor(t=ul){this.configuration=t,this.fetchApi=async(i,s)=>{let n={url:i,init:s};for(const a of this.middleware)a.pre&&(n=await a.pre({fetch:this.fetchApi,...n})||n);let o;try{o=await(this.configuration.fetchApi||fetch)(n.url,n.init)}catch(a){for(const r of this.middleware)r.onError&&(o=await r.onError({fetch:this.fetchApi,url:n.url,init:n.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new hl(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:n.url,init:n.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(s=>({pre:s}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(s=>({post:s}));return this.withMiddleware(...i)}isJsonMime(t){return t?mi.jsonRegex.test(t):!1}async request(t,i){const{url:s,init:n}=await this.createFetchParams(t,i),o=await this.fetchApi(s,n);if(o&&o.status>=200&&o.status<300)return o;throw new pl(o,"Response returned an error code")}async createFetchParams(t,i){let s=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(s+="?"+this.configuration.queryParamsStringify(t.query));const n=Object.assign({},this.configuration.headers,t.headers);Object.keys(n).forEach(p=>n[p]===void 0?delete n[p]:{});const o=typeof i=="function"?i:async()=>i,a={method:t.method,headers:n,body:t.body,credentials:this.configuration.credentials},r={...a,...await o({init:a,context:t})};let d;ml(r.body)||r.body instanceof URLSearchParams||ll(r.body)?d=r.body:this.isJsonMime(n["Content-Type"])?d=JSON.stringify(r.body):d=r.body;const u={...r,body:d};return{url:s,init:u}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}}mi.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");function ll(e){return typeof Blob<"u"&&e instanceof Blob}function ml(e){return typeof FormData<"u"&&e instanceof FormData}class pl extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class hl extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class te extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function R(e,t){return e[t]!=null}function sn(e,t=""){return Object.keys(e).map(i=>nn(i,e[i],t)).filter(i=>i.length>0).join("&")}function nn(e,t,i=""){const s=i+(i.length?`[${e}]`:e);if(t instanceof Array){const n=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(s)}=`);return`${encodeURIComponent(s)}=${n}`}if(t instanceof Set){const n=Array.from(t);return nn(e,n,i)}return t instanceof Date?`${encodeURIComponent(s)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?sn(t,s):`${encodeURIComponent(s)}=${encodeURIComponent(String(t))}`}class De{constructor(t,i=s=>s){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}class vl{constructor(t){this.raw=t}async value(){return await this.raw.blob()}}function gl(e){if(e!==void 0)return e===null?null:{cancellationReason:e.cancellationReason}}function wl(e){return fl(e)}function fl(e,t){return e==null?e:{message:R(e,"message")?e.message:void 0}}function kl(e){return yl(e)}function yl(e,t){return e==null?e:{requestType:R(e,"request_type")?e.request_type:void 0,categories:R(e,"categories")?e.categories:void 0}}function Tl(e){return bl(e)}function bl(e,t){return e==null?e:{items:R(e,"items")?e.items.map(kl):void 0}}function an(e){return Rl(e)}function Rl(e,t){return e==null?e:{createdBy:R(e,"created_by")?e.created_by:void 0,createdAt:R(e,"created_at")?new Date(e.created_at):void 0,comment:R(e,"comment")?e.comment:void 0}}function Al(e){return _l(e)}function _l(e,t){return e==null?e:{comments:R(e,"comments")?e.comments.map(an):void 0}}function on(e){return Il(e)}function Il(e,t){return e==null?e:{id:R(e,"id")?e.id:void 0,fileName:R(e,"file_name")?e.file_name:void 0,fileSize:R(e,"file_size")?e.file_size:void 0,contentType:R(e,"content_type")?e.content_type:void 0,createdBy:R(e,"created_by")?e.created_by:void 0,createdAt:R(e,"created_at")?new Date(e.created_at):void 0}}function Sl(e){return Cl(e)}function Cl(e,t){return e==null?e:{attachments:R(e,"attachments")?e.attachments.map(on):void 0}}function Nl(e){if(e!==void 0)return e===null?null:{comment:e.comment}}function Pl(e){if(e!==void 0)return e===null?null:{account_number:e.accountNumber,subject:e.subject,request_type:e.requestType,category:e.category,locations:e.locations,circuit_id:e.circuitId,customer_reference:e.customerReference,description:e.description,notification_recipients:e.notificationRecipients}}function Ii(e){return ql(e)}function ql(e,t){return e==null?e:{ticketNumber:R(e,"ticket_number")?e.ticket_number:void 0,accountNumber:R(e,"account_number")?e.account_number:void 0,accountName:R(e,"account_name")?e.account_name:void 0,id:R(e,"id")?e.id:void 0,status:R(e,"status")?e.status:void 0,cancellationReason:R(e,"cancellation_reason")?e.cancellation_reason:void 0,subject:R(e,"subject")?e.subject:void 0,requestType:R(e,"request_type")?e.request_type:void 0,category:R(e,"category")?e.category:void 0,site:R(e,"site")?e.site:void 0,locations:R(e,"locations")?e.locations:void 0,circuitId:R(e,"circuit_id")?e.circuit_id:void 0,customerReference:R(e,"customer_reference")?e.customer_reference:void 0,description:R(e,"description")?e.description:void 0,notificationRecipients:R(e,"notification_recipients")?e.notification_recipients:void 0,createdBy:R(e,"created_by")?e.created_by:void 0,createdAt:R(e,"created_at")?new Date(e.created_at):void 0,updatedAt:R(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:R(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0,comments:R(e,"comments")?e.comments.map(an):void 0}}function Dl(e){if(e!==void 0)return e===null?null:{subject:e.subject,description:e.description,circuit_id:e.circuitId,customer_reference:e.customerReference,other_notification_recipients:e.otherNotificationRecipients}}function Bl(e){return Ol(e)}function Ol(e,t){return e==null?e:{accountNumber:R(e,"account_number")?e.account_number:void 0,accountName:R(e,"account_name")?e.account_name:void 0,id:R(e,"id")?e.id:void 0,status:R(e,"status")?e.status:void 0,subject:R(e,"subject")?e.subject:void 0,site:R(e,"site")?e.site:void 0,locations:R(e,"locations")?e.locations:void 0,description:R(e,"description")?e.description:void 0,createdBy:R(e,"created_by")?e.created_by:void 0,createdAt:R(e,"created_at")?new Date(e.created_at):void 0,updatedAt:R(e,"updated_at")?new Date(e.updated_at):void 0,closedAt:R(e,"closed_at")?e.closed_at===null?null:new Date(e.closed_at):void 0}}function $l(e){return El(e)}function El(e,t){return e==null?e:{items:R(e,"items")?e.items.map(Bl):void 0,totalCount:R(e,"total_count")?e.total_count:void 0,pageNumber:R(e,"page_number")?e.page_number:void 0,pageSize:R(e,"page_size")?e.page_size:void 0}}class xl extends mi{async cancellationTroubleTicketRequestRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling cancellationTroubleTicketRequest.");if(t.cancellationTicketsRequest===null||t.cancellationTicketsRequest===void 0)throw new te("cancellationTicketsRequest","Required parameter requestParameters.cancellationTicketsRequest was null or undefined when calling cancellationTroubleTicketRequest.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}/cancel".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PUT",headers:n,query:s,body:gl(t.cancellationTicketsRequest)},i);return new De(o,a=>wl(a))}async cancellationTroubleTicketRequest(t,i){return await(await this.cancellationTroubleTicketRequestRaw(t,i)).value()}async createTroubleTicketAttachmentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createTroubleTicketAttachment.");if(t.fileName===null||t.fileName===void 0)throw new te("fileName","Required parameter requestParameters.fileName was null or undefined when calling createTroubleTicketAttachment.");if(t.body===null||t.body===void 0)throw new te("body","Required parameter requestParameters.body was null or undefined when calling createTroubleTicketAttachment.");const s={};t.fileName!==void 0&&(s.file_name=t.fileName);const n={};if(n["Content-Type"]="image/jpeg",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}/attachments/file".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:t.body},i);return new De(o,a=>on(a))}async createTroubleTicketAttachment(t,i){return await(await this.createTroubleTicketAttachmentRaw(t,i)).value()}async createTroubleTicketCommentRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling createTroubleTicketComment.");if(t.ticketCommentsRequest===null||t.ticketCommentsRequest===void 0)throw new te("ticketCommentsRequest","Required parameter requestParameters.ticketCommentsRequest was null or undefined when calling createTroubleTicketComment.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}/comments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"POST",headers:n,query:s,body:Nl(t.ticketCommentsRequest)},i);return new De(o,a=>Al(a))}async createTroubleTicketComment(t,i){return await(await this.createTroubleTicketCommentRaw(t,i)).value()}async createTroubleTicketTicketRaw(t,i){if(t.troubleTicketRequest===null||t.troubleTicketRequest===void 0)throw new te("troubleTicketRequest","Required parameter requestParameters.troubleTicketRequest was null or undefined when calling createTroubleTicketTicket.");const s={},n={};if(n["Content-Type"]="application/json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets",method:"POST",headers:n,query:s,body:Pl(t.troubleTicketRequest)},i);return new De(o,a=>Ii(a))}async createTroubleTicketTicket(t,i){return await(await this.createTroubleTicketTicketRaw(t,i)).value()}async getTroubleTicketAttachmentsByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getTroubleTicketAttachmentsById.");if(t.attachmentId===null||t.attachmentId===void 0)throw new te("attachmentId","Required parameter requestParameters.attachmentId was null or undefined when calling getTroubleTicketAttachmentsById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}/attachments/file/{attachment_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))).replace("{attachment_id}",encodeURIComponent(String(t.attachmentId))),method:"GET",headers:n,query:s},i);return new vl(o)}async getTroubleTicketAttachmentsById(t,i){return await(await this.getTroubleTicketAttachmentsByIdRaw(t,i)).value()}async getTroubleTicketAttachmentsListRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getTroubleTicketAttachmentsList.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}/attachments".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new De(o,a=>Sl(a))}async getTroubleTicketAttachmentsList(t,i){return await(await this.getTroubleTicketAttachmentsListRaw(t,i)).value()}async getTroubleTicketTicketByIdRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling getTroubleTicketTicketById.");const s={},n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"GET",headers:n,query:s},i);return new De(o,a=>Ii(a))}async getTroubleTicketTicketById(t,i){return await(await this.getTroubleTicketTicketByIdRaw(t,i)).value()}async getTroubleTicketTicketsRaw(t,i){const s={};t.accountNumber!==void 0&&(s.account_number=t.accountNumber),t.site!==void 0&&(s.site=t.site),t.status!==void 0&&(s.status=t.status),t.createdBy!==void 0&&(s.created_by=t.createdBy),t.sort!==void 0&&(s.sort=t.sort),t.pageNumber!==void 0&&(s.page_number=t.pageNumber),t.pageSize!==void 0&&(s.page_size=t.pageSize);const n={},o=await this.request({path:"/trouble-tickets",method:"GET",headers:n,query:s},i);return new De(o,a=>$l(a))}async getTroubleTicketTickets(t={},i){return await(await this.getTroubleTicketTicketsRaw(t,i)).value()}async getTroubleTicketsCategoriesListRaw(t,i){if(t.site===null||t.site===void 0)throw new te("site","Required parameter requestParameters.site was null or undefined when calling getTroubleTicketsCategoriesList.");const s={};t.site!==void 0&&(s.site=t.site);const n={};if(this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/categories",method:"GET",headers:n,query:s},i);return new De(o,a=>Tl(a))}async getTroubleTicketsCategoriesList(t,i){return await(await this.getTroubleTicketsCategoriesListRaw(t,i)).value()}async updateTroubleTicketTicketRaw(t,i){if(t.ticketId===null||t.ticketId===void 0)throw new te("ticketId","Required parameter requestParameters.ticketId was null or undefined when calling updateTroubleTicketTicket.");if(t.troubleTicketUpdateRequest===null||t.troubleTicketUpdateRequest===void 0)throw new te("troubleTicketUpdateRequest","Required parameter requestParameters.troubleTicketUpdateRequest was null or undefined when calling updateTroubleTicketTicket.");const s={},n={};if(n["Content-Type"]="application/merge-patch+json",this.configuration&&this.configuration.accessToken){const a=this.configuration.accessToken,r=await a("BearerAuth",[]);r&&(n.Authorization=`Bearer ${r}`)}const o=await this.request({path:"/trouble-tickets/{ticket_id}".replace("{ticket_id}",encodeURIComponent(String(t.ticketId))),method:"PATCH",headers:n,query:s,body:Dl(t.troubleTicketUpdateRequest)},i);return new De(o,a=>Ii(a))}async updateTroubleTicketTicket(t,i){return await(await this.updateTroubleTicketTicketRaw(t,i)).value()}}function Fl(e){return Ll(e)}function Ll(e,t){return e==null?e:{id:e.id,name:e.name,isNonLocation:e.is_non_location,category:Js(e,"category")?e.category:void 0,privileges:e.privileges,isInternal:e.is_internal}}function Vl(e){return Ul(e)}function Ul(e,t){return e==null?e:{accountNumber:e.account_number,permissionName:e.permission_name,privilege:e.privilege,isNonLocation:Js(e,"is_non_location")?e.is_non_location:void 0,permissionIsInternal:e.permission_is_internal}}class Hl extends ui{async getPermissionsRaw(t){const i={},s={};this.configuration&&this.configuration.accessToken&&(s.Authorization=await this.configuration.accessToken("oAuth2",[]));const n=await this.request({path:"/permissions",method:"GET",headers:s,query:i},t);return new Zs(n,o=>o.map(Fl))}async getPermissions(t){return await(await this.getPermissionsRaw(t)).value()}async getUserPermissionsRaw(t,i){const s={};t.excludeSiblings!==void 0&&(s.exclude_siblings=t.excludeSiblings),t.excludeParents!==void 0&&(s.exclude_parents=t.excludeParents);const n={};this.configuration&&this.configuration.accessToken&&(n.Authorization=await this.configuration.accessToken("oAuth2",[]));const o=await this.request({path:"/my-permissions",method:"GET",headers:n,query:s},i);return new Zs(o,a=>a.map(Vl))}async getUserPermissions(t={},i){return await(await this.getUserPermissionsRaw(t,i)).value()}}const z={CustomerCare:"sm-customer-care",DeliveriesRemovals:"sm-deliveries",References:"sm-references",RemoteHands:"sm-remote-hands",TroubleTickets:"sm-trouble-tickets",FacilityAccess:"sm-facility-access",ServiceTickets:"sm-service-tickets",SiteMaintenance:"sm-site-maintenance",Incidents:"sm-incidents",Inventory:"inventory",SiteNavigation:"site-navigations",UserManagement:"usermanagement"},F={Site:"Site",Floor:"Floor",Room:"Room",Cabinet:"Cabinet",Cage:"Cage"},U={Read:"Read",Update:"Update",Delete:"Delete",Create:"Create",Approve:"Approve"},zl={READ:1,UPDATE:2,DELETE:4,CREATE:8,APPROVE:16};var Si;(function(e){e.Security="Security",e.DCIM="DCIM",e.PlannedSiteMaintenance="Planned Site Maintenance"})(Si||(Si={}));const S={RemoteHands:"Remote Hands",TroubleTickets:"Trouble Ticket",DeliveriesRemovals:"Shipping & Receiving",VisitorAccess:"Visitor Access",CustomerCare:"Customer Support",PermanentBadge:"Permanent Badge",OSPAccess:"OSP Access",POPPOEAccess:"POP/POE Room Access",PlannedMaintenance:"Planned Site Maintenance"},jl={Duplicate:"Duplicate request",Error:"Request entered in error",NotNeeded:"Request no longer needed"},Ml={Delivery:"Delivery",Removal:"Removal",TroubleTicket:"Trouble Ticket",FacilityAccess:"Facility Access",RemoteHands:"Remote Hands",VisitorAccess:"Visitor Access",PermanentBadge:"Permanent Badge"},ut={GreaterThan:"gt:",GreaterOrEqual:"ge:",LessThan:"lt:",LessThanOrEqual:"le:"},Jl=10,Wl="permission_privilege";class Gl{constructor(t){this.configuration=t}get customerCareApi(){return new du(new Zi({basePath:`${this.configuration.SMApiUrl}/${z.CustomerCare}`,headers:{Authorization:this.getAuthorization()}}))}get courierCompaniesApi(){return new $a(new Et({basePath:`${this.configuration.SMApiUrl}/${z.DeliveriesRemovals}`,headers:{Authorization:this.getAuthorization()}}))}get deliveriesApi(){return new no(new Et({basePath:`${this.configuration.SMApiUrl}/${z.DeliveriesRemovals}`,headers:{Authorization:this.getAuthorization()}}))}get removalsApi(){return new ao(new Et({basePath:`${this.configuration.SMApiUrl}/${z.DeliveriesRemovals}`,headers:{Authorization:this.getAuthorization()}}))}get remoteHandsApi(){return new Ec(new As({basePath:`${this.configuration.SMApiUrl}/${z.RemoteHands}`,headers:{Authorization:this.getAuthorization()}}))}get troubleTicketsApi(){return new xl(new tn({basePath:`${this.configuration.SMApiUrl}/${z.TroubleTickets}`,headers:{Authorization:this.getAuthorization()}}))}get facilityAccessApi(){return{visitorAccess:new Wr(new pt({basePath:`${this.configuration.SMApiUrl}/${z.FacilityAccess}`,headers:{Authorization:this.getAuthorization()}})),visitorHost:new Gr(new pt({basePath:`${this.configuration.SMApiUrl}/${z.FacilityAccess}`,headers:{Authorization:this.getAuthorization()}})),permanentBadgeAccess:new Jr(new pt({basePath:`${this.configuration.SMApiUrl}/${z.FacilityAccess}`,headers:{Authorization:this.getAuthorization()}})),ospAccess:new jr(new pt({basePath:`${this.configuration.SMApiUrl}/${z.FacilityAccess}`,headers:{Authorization:this.getAuthorization()}})),popAccess:new Mr(new pt({basePath:`${this.configuration.SMApiUrl}/${z.FacilityAccess}`,headers:{Authorization:this.getAuthorization()}}))}}get serviceTicketApi(){return new Ou(new Xs({basePath:`${this.configuration.SMApiUrl}/${z.ServiceTickets}`,headers:{Authorization:this.getAuthorization()}}))}get inventoryApi(){return{locations:new ed(new Wt({basePath:`${this.configuration.SMApiUrl}/${z.Inventory}`,headers:{Authorization:this.getAuthorization()}})),sites:new Ps(new Wt({basePath:`${this.configuration.SMApiUrl}/${z.Inventory}`,headers:{Authorization:this.getAuthorization()}}))}}get sitesApi(){return new Ps(new Wt({basePath:`${this.configuration.SMApiUrl}/${z.Inventory}`,headers:{Authorization:this.getAuthorization()}}))}get siteNavigationApi(){return new cl(new Us({basePath:`${this.configuration.SMApiUrl}/${z.SiteNavigation}`,headers:{Authorization:this.getAuthorization()}}))}get plannedMaintenanceApi(){return new Yu(new qs({basePath:`${this.configuration.SMApiUrl}/${z.SiteMaintenance}`,headers:{Authorization:this.getAuthorization()}}))}get incidentsApi(){return new Cd(new $s({basePath:`${this.configuration.SMApiUrl}/${z.Incidents}`,headers:{Authorization:this.getAuthorization()}}))}get userPermissionsApi(){return new Hl(new Ms({basePath:`${this.configuration.SMApiUrl}/${z.UserManagement}`,headers:{Authorization:this.getAuthorization()}}))}getAuthorizationToken(){return this.getAuthorization()}get referencesApi(){return{categories:new gu(new Gt({basePath:`${this.configuration.SMApiUrl}/${z.References}`,headers:{Authorization:this.getAuthorization(),"cache-control":"no-cache"}})),requestTypeCategoryMappings:new wu(new Gt({basePath:`${this.configuration.SMApiUrl}/${z.References}`,headers:{Authorization:this.getAuthorization(),"cache-control":"no-cache"}})),terms:new ku(new Gt({basePath:`${this.configuration.SMApiUrl}/sm-references`,headers:{Authorization:this.getAuthorization(),"cache-control":"no-cache"}}))}}getAuthorization(){return this.configuration.getAuthorizationFn?this.configuration.getAuthorizationFn():""}}class Zl extends la{constructor(t,i){super({...t}),this.hashed_identifier=i}}class Kl{constructor(t,i){this.name=t,this.accountNumber=i}}class Qe{constructor({loginAuthority:t,clientId:i,scope:s,postLogoutRedirectUri:n,userStorageKey:o="user-authentication",redirectUrlKey:a="redirect-url",authPaths:r={authenticate:"authenticate",authCallback:"auth-callback",logout:"logout"}}){this.getHashedRootAccountNumberAndUserEmail=async()=>{const A=ot.getAccountHierarchy(),N=await Qe.hashValue(ot===null||ot===void 0?void 0:ot.email);let b=await Qe.hashValue(ot===null||ot===void 0?void 0:ot.account_number);return A&&(b=await Qe.hashValue(A==null?void 0:A.accountNumber)),`${b}-${N}`},this.configuration={loginAuthority:t,clientId:i,scope:s,postLogoutRedirectUri:n,userStorageKey:o,redirectUrlKey:a,authPaths:r};const{location:d}=window,u=`${d.protocol}//${d.hostname}${d.port?`:${d.port}`:""}`,p={authority:this.configuration.loginAuthority,client_id:this.configuration.clientId,redirect_uri:`${u}/${this.configuration.authPaths.authCallback}`,response_type:"code",scope:this.configuration.scope,post_logout_redirect_uri:this.configuration.postLogoutRedirectUri,loadUserInfo:!0};this.userManager=new ma(p)}isLoggedIn(){const t=this.getUser();if(t===null)return!1;if(!t.expires_at)return!0;const i=new Date,s=new Date(t.expires_at*1e3);return i<s}redirectToAuth(t=!1){const i=this.isAuthenticating();(t||!i)&&(i||localStorage.setItem(this.configuration.redirectUrlKey,window.location.href),rt.go(`/${this.configuration.authPaths.authenticate}`))}isAuthenticating(){const t=window.location.pathname.split("/");return t[t.length-1]===this.configuration.authPaths.authenticate?(this.userManager.signinRedirect(),!0):!1}isHandlingAuthCallback(){const t=window.location.pathname.split("/");return t[t.length-1]===this.configuration.authPaths.authCallback?(this.userManager.signinRedirectCallback().then(Qe.ensureValidUser).then(Qe.addHashedIdToUserProfile).then(i=>this.saveUser(i)).then(()=>this.authSuccessRedirect()).catch(()=>this.redirectToAuth()),!0):!1}authSuccessRedirect(){let t="/";const i=localStorage.getItem(this.configuration.redirectUrlKey);i&&(localStorage.removeItem(this.configuration.redirectUrlKey),t=i),rt.go(t)}redirectToLogout(){this.isHandlingLogout()||rt.go(`/${this.configuration.authPaths.logout}`)}isHandlingLogout(){const t=window.location.pathname.split("/");return t[t.length-1]===this.configuration.authPaths.logout?(this.clearUser(),window.localStorage.clear(),this.userManager.signoutRedirect({id_token_hint:this.getIdToken()}),!0):!1}isProcessing(){return this.isAuthenticating()||this.isHandlingAuthCallback()||this.isHandlingLogout()}saveUser(t){localStorage.setItem(this.configuration.userStorageKey,JSON.stringify(t))}clearUser(){localStorage.removeItem(this.configuration.userStorageKey)}getUser(){const t=localStorage.getItem(this.configuration.userStorageKey);return t?JSON.parse(t):null}getUserProfileSub(){var t;const i=this.getUser();return(t=i==null?void 0:i.profile)===null||t===void 0?void 0:t.sub}getUserLocale(){var t;const i=this.getUser();return(t=i==null?void 0:i.profile)===null||t===void 0?void 0:t.locale}getHashedIdentifer(){var t;return(t=this.getUser())===null||t===void 0?void 0:t.hashed_identifier}getIdToken(){var t;return(t=this.getUser())===null||t===void 0?void 0:t.id_token}getAccessToken(){var t;return(t=this.getUser())===null||t===void 0?void 0:t.access_token}getAuthorization(){var t,i;return`${(t=this.getUser())===null||t===void 0?void 0:t.token_type} ${(i=this.getUser())===null||i===void 0?void 0:i.access_token}`}getUserAccount(){var t,i,s,n;return new Kl((i=(t=this.getUser())===null||t===void 0?void 0:t.profile)===null||i===void 0?void 0:i.account_name,(n=(s=this.getUser())===null||s===void 0?void 0:s.profile)===null||n===void 0?void 0:n.account_number)}getUserEmail(){var t,i;return(i=(t=this.getUser())===null||t===void 0?void 0:t.profile)===null||i===void 0?void 0:i.email}getAccountNumber(){var t,i;return(i=(t=this.getUser())===null||t===void 0?void 0:t.profile)===null||i===void 0?void 0:i.account_number}static async hashValue(t){const i=new TextEncoder().encode(t),s=await crypto.subtle.digest("SHA-256",i);return Array.from(new Uint8Array(s)).map(n=>n.toString(16).padStart(2,"0")).join("")}static async addHashedIdToUserProfile(t){const i=`${t.profile.sub}-${t.profile.customer_id}`,s=await Qe.hashValue(i);return new Zl(t,s)}static ensureValidUser(t){if(!t.id_token)throw new Error("Missing property:id_token");return t}}function ke(){var e;const t=(e=window.gpConfig)===null||e===void 0?void 0:e["ui-service-management"];if(!t)throw new Error("ui-service-management config not loaded. Ensure config.json is fetched before app bootstrap.");return t}const Xt=ke(),ae=new Qe({loginAuthority:Xt.LoginAuthority,clientId:Xt.ServiceManagementUIClientId,scope:Xt.ServiceManagementUIScopes}),l=new Gl({SMApiUrl:Xt.SMApiUrl,getAuthorizationFn:()=>`Bearer ${ae.getAccessToken()}`}),rn="no instructions provided",Ci=" [Special Instructions] ",gt="Other",cn="Digital Realty",Yl="Interxion",dn=5;class Xl{constructor(){this.couriers={},this.sites=[],this.removalParties=[],this.requestTypeCategoriesDict={},this.termsLookup={[Q.Deliveries]:"",[Q.FacilityAccess]:"",[Q.TroubleTickets]:"",[Q.RemoteHands]:""},se(this),Je(this,{name:"lookups",properties:["couriers","sites","removalParties","requestTypeCategoriesDict","termsLookup"],storage:window.sessionStorage})}getCouriers(t,i){var s;const n=(s=this.couriers[t])!==null&&s!==void 0?s:[];return i?[...n,gt]:n}async fillCouriers(t,i,s){!t||!i||!s||this.couriers[s]||(this.couriers[s]=await l.courierCompaniesApi.getCourierBySite({accountNumber:i,site:t}))}async fillSites(){const t={pageSize:1e3};this.sites=await Gi(t,i=>l.inventoryApi.sites.getSites(i))}async getRemoteHandsCategories(t,i){const s=`RemoteHands-${t}-${i}`;if(this.requestTypeCategoriesDict[s])return this.requestTypeCategoriesDict[s];const n=await l.remoteHandsApi.getRemoteHandsCategoriesList({site:t,accountNumber:i});return!n.items||n.items.length===0?{}:(this.requestTypeCategoriesDict[s]=Object.fromEntries(n.items.filter(o=>{var a;return o.requestType&&((a=o.categories)===null||a===void 0?void 0:a.length)}).map(o=>[o.requestType,o.categories])),this.requestTypeCategoriesDict[s])}async getRequestCategories(t,i,s){const n=`${t}-${i}`;if(this.requestTypeCategoriesDict[n]&&!s)return this.requestTypeCategoriesDict[n];const o=(await l.referencesApi.requestTypeCategoryMappings.getRequestTypeCategoryMappings({serviceTicketType:i,serviceManagementSystem:t,siteCode:s})).filter(a=>{var r;return(r=a.categories)===null||r===void 0?void 0:r.some(d=>d.isActive)});return this.requestTypeCategoriesDict[n]=Object.fromEntries(o.map(a=>{var r;return[a.requestType,(r=a.categories)===null||r===void 0?void 0:r.filter(d=>d.isActive).map(d=>d.canonicalValue)]})),this.requestTypeCategoriesDict[n]}async fillRemovalParties(){this.removalParties=await l.removalsApi.getRemovalParties()}async fillLookups(){await Promise.all([this.fillRemovalParties(),this.fillTerms(),this.fillSites()])}async fillTerms(){const t=async i=>{await l.referencesApi.terms.getTerms({service:i}).then(s=>{this.termsLookup[i]=s})};await Promise.all([t(Q.Deliveries),t(Q.TroubleTickets),t(Q.RemoteHands),t(Q.FacilityAccess)])}clear(){this.couriers={},this.sites=[],this.removalParties=[],this.requestTypeCategoriesDict={},this.termsLookup={[Q.Deliveries]:"",[Q.FacilityAccess]:"",[Q.TroubleTickets]:"",[Q.RemoteHands]:""}}}const J=new Xl;function St(e){return new Date(e).toISOString().split("T")[0]}const un=()=>{var e;const t=localStorage.getItem("date-format");return t&&((e=JSON.parse(t))===null||e===void 0?void 0:e.preferredTimezone)||he.tz.guess()},Be=(e,t,i)=>{var s,n;if(!e||!t)return;const o=`${e} ${t}`,a=(n=(s=J.sites)===null||s===void 0?void 0:s.find(r=>r.id===i))===null||n===void 0?void 0:n.timeZone;return(a?he.tz(o,a):he.utc(o)).utc().toDate()};function Ql(e,t=un()){const i=he.tz(e,t).startOf("day").toDate(),s=he.tz(e,t).endOf("day").toDate();return{startOfDayLocal:i,endOfDayLocal:s}}const em=()=>he.utc().tz(un()).startOf("day").format("YYYY-MM-DD"),tm=(e,t)=>(t?he.tz(t):he.utc()).add(e,"days").format("YYYY-MM-DD"),Z=e=>{if(e)return new Date(e)},im=()=>{var e;const t=localStorage.getItem("date-format");return t&&((e=JSON.parse(t))===null||e===void 0?void 0:e.preferredDateFormat)||"yyyy-MM-dd"};St(new Date);const sm=bt`.header-container{display:flex;align-items:center;gap:20px}.header__title{margin:0;font-family:var(--root-secondary-font);font-style:normal;font-weight:700;font-size:34px;line-height:40px;letter-spacing:.35px;color:#092241;flex-grow:1}.header__profile{background-color:#092241;height:35px;border-radius:10px;color:#fff;padding-left:20px;padding-right:20px;display:flex;align-items:center;font-size:14px}.header__logout{height:35px;border-radius:10px;border:none;background-color:#1456e0;color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;padding-left:15px;padding-right:15px}.header__logout svg{width:1em;height:1em;font-size:20px;margin-right:5px}.header__accounts{width:200px;--md-outlined-field-top-space:5px;--md-outlined-field-bottom-space:5px}@media only screen and (min-width:5px) and (max-width:500px){.header-container{flex-direction:column}}@media only screen and (min-width:500px) and (max-width:1250px){.header-container{flex-direction:row}}`,L={ErrorRaised:"sm:error-raised",DrawerClose:"drawer-close",CreateTicket:"create-ticket",CancelTicket:"cancel-ticket",EditTicket:"edit-ticket",ApproveDenyTicket:"approve-deny-ticket"};class Oe{constructor(t,i,s){var n,o;this.id=t,this.siteId=i,this.accountNumber=s;const a=J.sites.find(r=>r.id===this.siteId);a?this.displayName=`${a==null?void 0:a.name} - ${a==null?void 0:a.streetAddress}`:this.displayName=(o=(n=this.id)!==null&&n!==void 0?n:this.siteId)!==null&&o!==void 0?o:""}}async function nm(e){if(!e)return"";const t=J.sites.find(i=>i.locationId===e);return t?`${t.name} - ${t.streetAddress}`:e}async function am(e){if(!e)return"";const t=J.sites.find(i=>i.id===e);return t?`${t.name} - ${t.streetAddress}`:e}async function om(e){const t=J.sites.find(i=>i.id===e);return t==null?void 0:t.locationId}const ln=(e,t,i)=>{e.dispatchEvent(new CustomEvent(t,{detail:i,bubbles:!0,composed:!0}))},rm=e=>ln(document,L.ErrorRaised,e),m=async(e,t=!0)=>{let i="An error occurred";if(e instanceof Xi&&e.response.status===400)try{const{detail:s}=await e.response.json();i=s}catch(s){console.error(e)}else console.error(e);t&&rm(i)},cm=e=>{window.dispatchEvent(new CustomEvent("add-toast",{detail:{id:"error-toast",content:g`<ix-message-toast forceClose="false" toastId="error-toast" type="error">${e} </ix-message-toast>`,vertical:"bottom",horizontal:"center",animated:!0,above:!1}}))};class dm{constructor(){se(this),Je(this,{name:"locations",properties:[],storage:window.localStorage})}async getLocations(t,i){var s;let n=[],o={...t,sort:t.sort||"+id"};const a=r=>l.inventoryApi.locations.getLocations(r).catch(d=>{m(d,!1)});if(i!=null&&i.onlyLoadFirstPage){const r=await a(o);n=(s=r==null?void 0:r.items)!==null&&s!==void 0?s:[]}else n=await Gi(o,a);return n.sort((r,d)=>r.id.localeCompare(d.id))}async getOspsBySiteId(t){try{const i=await l.inventoryApi.sites.getOspsBySiteId({siteId:t});return i!=null?i:[]}catch(i){return[]}}async getPopsBySiteId(t){try{const i=await l.inventoryApi.sites.getPopsBySiteId({siteId:t});return i!=null?i:[]}catch(i){return[]}}}const le=new dm;class um{constructor(){this.isHideLocationDatesEnabled=()=>{const t=ke()["SM:HideLocationDates"];return typeof t=="boolean"?t:!1},this.showNewDatePickerComponent=()=>{const t=ke()["SM:UseNewDatePicker"];return typeof t=="boolean"?t:!1},this.isOspEnabled=()=>{const t=ke()["SM:ShowOspAccess"];return typeof t=="boolean"?t:!1},this.isPopPoeEnabled=()=>{const t=ke()["SM:ShowPopPoeAccess"];return typeof t=="boolean"?t:!1},this.isIncidentsEnabled=()=>{const t=ke()["SM:IncidentsEnabled"];return typeof t=="boolean"?t:!1},this.isCustomerCarePopWhitelistEnabled=()=>{const t=ke()["SM:CustomerCarePopWhitelistEnabled"];return typeof t=="boolean"?t:!1},this.customerCarePopWhitelist=()=>{const t=ke()["SM:CustomerCarePopWhitelist"];return typeof t=="string"?t:""}}}const wt=new um,Ct=`${F.Floor},${F.Room},${F.Cabinet},${F.Cage}`;function mn(e){return e===S.VisitorAccess||e===S.PermanentBadge}function lm(e){return e===S.RemoteHands||e===S.TroubleTickets||e===S.VisitorAccess||e===S.PermanentBadge||e===S.CustomerCare||e===S.OSPAccess||e===S.POPPOEAccess}async function Ze(e){var t;const i=await le.getLocations({...e,pageSize:100});return(t=[...new Map(i.map(s=>[s.siteId,s])).values()].map(s=>new Oe(void 0,s.siteId,s.accountNumber)))!==null&&t!==void 0?t:[]}async function mm(e,t,i,s){let n=[];const o=lm(t);let a=ut.GreaterThan+F.Site;o?mn(t)&&(a=Ct):a=F.Site;let r=await le.getLocations({locationType:a,permissionType:t,permissionPrivilege:e,pageSize:100,accountNumber:s,assignableProcess:i});return o?(r=[...new Map(r.map(d=>[d.siteId,d])).values()],n=r.map(d=>new Oe(d.siteId,d.siteId,d.accountNumber))):n=r.map(d=>new Oe(d.id,d.siteId,d.accountNumber)),n!=null?n:[]}async function pm(e,t){const i=await le.getLocations({locationType:F.Site,permissionType:t,permissionPrivilege:e,pageSize:100}),s=[...new Set(i.map(n=>n.accountNumber))];return s!=null?s:[]}async function hm(e,t,i,s,n){let o=ut.GreaterThan+F.Site;return mn(t)&&(o=Ct),await le.getLocations({permissionType:t,locationType:o,permissionPrivilege:e,siteId:s,pageSize:100,accountNumber:n,assignableProcess:i})}async function Nt(e,t,i,s){const n=await le.getLocations({permissionType:t,permissionPrivilege:e,id:i,accountNumber:s,pageSize:1},{onlyLoadFirstPage:!0});return(n==null?void 0:n.length)>0}async function $e(e,t,i,s){return(await le.getLocations({permissionPrivilege:t,pageSize:1,permissionType:e,assignableProcess:i,locationType:s},{onlyLoadFirstPage:!0})).length>0}async function Ke(e,t,i){return(await le.getLocations({permissionPrivilege:i,pageSize:100,permissionType:t})).some(s=>e.includes(s.id))}async function pn(e){var t;if(!e)return;const i=await le.getLocations({id:e,pageSize:1},{onlyLoadFirstPage:!0});return(t=i==null?void 0:i[0])===null||t===void 0?void 0:t.siteId}async function vm(e){var t;if(!e)return;const i=await le.getLocations({siteId:e,locationType:F.Site,pageSize:1},{onlyLoadFirstPage:!0});return(t=i==null?void 0:i[0])===null||t===void 0?void 0:t.id}async function hn(){return $e(S.CustomerCare,U.Create,void 0,F.Site)}async function vn(){return $e(S.VisitorAccess,U.Create,void 0,F.Site)}async function gn(){return $e(S.PermanentBadge,U.Create,void 0,F.Site)}async function wn(){return wt.isOspEnabled()?$e(S.OSPAccess,U.Create,void 0,F.Site):!1}async function fn(){return wt.isPopPoeEnabled()?$e(S.POPPOEAccess,U.Create,void 0,F.Site):!1}async function gm(){return $e(S.DeliveriesRemovals,U.Create)}async function kn(){return(await Promise.all([vn(),gn(),wn(),fn()])).some(e=>e)}async function yn(){return $e(S.RemoteHands,U.Create,void 0,F.Site)}async function Ni(){return gm()}function Tn(){return $e(S.TroubleTickets,U.Create,void 0,F.Site)}async function wm(){return(await Promise.all([hn(),kn(),yn(),Ni(),Tn()])).some(e=>e)}function fm(e){switch(e){case"Visitor Access":return S.VisitorAccess;case"Permanent Badge":return S.PermanentBadge;case"OSP Access":return S.OSPAccess;case"PoP/POE Access":return S.POPPOEAccess;default:return}}async function bn(e){if(e===void 0)return!1;const t=await pn(e);return t?(await le.getLocations({siteId:t,permissionType:S.OSPAccess,locationType:ut.GreaterOrEqual+F.Site,permissionPrivilege:U.Update,pageSize:100,assignableProcess:"OSP_access"})).some(i=>i.siteId===t):!1}async function Rn(e){if(e===void 0)return!1;const t=await pn(e);return t?(await le.getLocations({siteId:t,permissionType:S.POPPOEAccess,locationType:ut.GreaterOrEqual+F.Site,permissionPrivilege:U.Update,pageSize:100,assignableProcess:"POP_access"})).some(i=>i.siteId===t):!1}async function An(e){return le.getOspsBySiteId(e)}async function _n(e){return le.getPopsBySiteId(e)}let Pi=class extends Rt{constructor(){super(...arguments),this.hasCreatePermission=!1}dispatchCreateTicketEvent(){const e=new CustomEvent(L.CreateTicket,{bubbles:!0,composed:!0});this.dispatchEvent(e)}async firstUpdated(){this.hasCreatePermission=await wm()}render(){return this.hasCreatePermission?g` <ix-button @click="${this.dispatchCreateTicketEvent}" has-icon> <md-icon slot="icon">add</md-icon> <span class="uppercase font-bold tracking-wider">Create Ticket</span> </ix-button>`:P}};E([we()],Pi.prototype,"hasCreatePermission",void 0),Pi=E([X("sm-create-service-ticket-button")],Pi);let Ie=null;function In(){const{pathname:e,search:t,hash:i}=window.location;rt.go({pathname:e,search:t,hash:i})}function km(e,t,i){const s=i.map(n=>({...n,path:`${t}${n.path}`,redirect:n.redirect?`${t}${n.redirect}`:null}));s.push({name:W.ServiceTickets,path:t||"/",component:"service-tickets-view",headerRight:g`<sm-create-service-ticket-button></sm-create-service-ticket-button>`,action:()=>{import("./ui-service-management2.js")}}),s.push({path:"(.*)",component:"service-tickets-view",action:()=>{import("./ui-service-management2.js")}}),Ie=new rt(e),Ie.setRoutes(s),window.addEventListener("shell-after-navigate",In)}function ym(){return Ie}function Tm(){Ie==null||Ie.unsubscribe(),Ie==null||Ie.removeRoutes(),Ie=null,window.removeEventListener("shell-after-navigate",In)}function Qt(e,t){return Ie&&Ie.urlForName(e,t)}function bm(e,t){const i=Qt(e);i&&rt.go({pathname:i,hash:t})}let qi=class extends Rt{constructor(){super(...arguments),this.routeName=null}return(){this.routeName&&bm(this.routeName),window.history.back()}render(){return g` <ix-button appearance="text" has-icon @click="${this.return}"> <md-icon slot="icon">arrow_back</md-icon> <span class="uppercase font-bold tracking-wider">Back</span> </ix-button>`}};E([we({type:String})],qi.prototype,"routeName",void 0),qi=E([X("sm-back-button")],qi);const Rm="Other parties to notify",Am="Result",Ye="CANCEL TICKET",_m="REQUEST CANCELLATION",Ee="EDIT TICKET",Im="Sites & Locations",Sm="Sites, Locations & Hosts",Cm="Trouble Ticket is not supported for this site.",Nm="We are unable to process your request. Please, try again or reach out to us for further assistance. We apologize for the inconvenience. Your Digital Realty Team.",Pm="Please be advised that your company has been restricted from submitting a new Delivery request for this location until all existing packages have been retrieved.",qm="We're unable to process your request at the moment. Please reach out to Customer Care for assistance.",Dm="Unable to process request. Contact Customer Care.",Bm='For POP/POE Room Access, please submit your request via the Customer Care form using the "Building" request type and "POP/POE Room Access" category.',Om="Important Note: Selecting a location is required to submit this ticket. If your specific POP/POE location is missing from the dropdown, please select any available location to complete your request for Room Access.";var O;(function(e){e.Announced="Announced",e.Cancelled="Cancelled",e.Completed="Completed",e.Draft="Draft",e.InProgress="In Progress",e.New="New",e.Expired="Expired"})(O||(O={}));var ei;(function(e){e.CancellationRequested="Cancellation requested"})(ei||(ei={}));var ft;(function(e){e.Approved="Approved",e.PendingPickup="Pending Pick-up",e.Rejected="Rejected"})(ft||(ft={}));var oe;(function(e){e.Approved="Approved",e.PendingApproval="Pending Approval",e.ApprovalDenied="Approval Denied"})(oe||(oe={}));const $m=[O.Cancelled,O.Completed,O.Expired,ft.Rejected,oe.ApprovalDenied],Em=[O.New,O.InProgress,O.Announced,ft.PendingPickup,ft.Approved,ei.CancellationRequested,oe.PendingApproval];var Di;(function(e){e.Resolved="Resolved",e.InProgress="In Progress",e.New="New",e.Closed="Closed",e.Cancelled="Cancelled"})(Di||(Di={}));class xm{constructor(){se(this)}async getServiceBackend(t,i,s){var n;i=i==null?void 0:i.split(".").pop();let o={accountNumber:t,site:i};const a=await l.siteNavigationApi.getSiteNavigation(o).catch(r=>{m(r,!1)});switch((n=a==null?void 0:a.find(r=>r.process===s))===null||n===void 0?void 0:n.serviceManagementSystem){case Yt.InSite:return H.Insite;case Yt.ServiceNow:return H.ServiceNow;case Yt.TelxSfdc:return s==="Facilities_access"?H.Insite:H.TelxSFDC;default:return}}}const K=new xm;var lt;(function(e){e.Kilograms="kilograms",e.Pounds="pounds"})(lt||(lt={}));function Sn(e){return typeof e=="string"&&e.trim().length>0}function Fm(e,t){return e.split(t).map(i=>i.trim().toLowerCase()).filter(i=>i.length>0)}const Cn=e=>/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(e);function Lm(e){return/^[a-zA-Z0-9]+$/.test(e)}function Vm(e){return/^[a-zA-Z0-9 ]+$/.test(e)}function Um(e){return/^[a-zA-Z0-9.' ]+$/.test(e)}function Hm(e){const t=he(e,"YYYY-MM-DD"),i=he().add(24,"hours").startOf("day");return t.isSameOrAfter(i)}function zm(e,t){const i=t?he.tz(t):he.utc(),[s,n]=e.split(":").map(o=>parseInt(o,10));return s>i.hours()||s===i.hours()&&n>i.minutes()}function Nn(e){return Sn(e)?/^(0|[1-9]\d*)$/.test(e):!1}const Pn=(e,t)=>{let i;return t===H.ServiceNow&&(i=e.weight,e.overweight&&(e.isHistorical||(i=`${e.weight} ${e.weightUnit}`))),{trackingNumber:e.trackingNumber,numberOfPackages:e.numberOfPackages,sizeWhenOversized:e.dimensions,weightWhenOverweight:i,courierCompany:e.courier===gt?e.otherCompany:e.courier}},qn=(e,t=!1)=>{var i,s,n,o,a;const r=e.serviceBackend!==H.ServiceNow?e.shortDescription+Ci+(e.instructions||rn):e.shortDescription,d={accountNumber:(i=e.site)===null||i===void 0?void 0:i.accountNumber,subject:(s=e.subject)!==null&&s!==void 0?s:"",description:r,etaFrom:Z(e.estimatedDate)||null,etaTo:Z(e.latestDate)||null,customerReference:e.referenceNumber,site:(o=(n=e.site)===null||n===void 0?void 0:n.id)!==null&&o!==void 0?o:"",otherNotificationRecipients:e.contacts,remoteHandsRequired:e.needRemoteHands};return(e==null?void 0:e.serviceBackend)!==H.TelxSFDC&&(d.loadingBayRequired=e.isLoadingBayRequired),t||(d.packages=(a=e.packages)===null||a===void 0?void 0:a.map(u=>Pn(u,e.serviceBackend))),d};function jm(e,t){const i=new Date;return t&&i.setDate(i.getDate()+e),St(i)}function Mm(e){const t=new Date;return t.setDate(t.getDate()+e),St(t)}const Dn=async(e,t,i)=>{if(!e||!t||!i)return[e];if(await K.getServiceBackend(t,i,"Deliveries")!==H.ServiceNow){const s=e.lastIndexOf(Ci);return s===-1?[e]:e.endsWith(rn)?[e.substring(0,s)]:[e.substring(0,s),e.substring(s+Ci.length)]}return[e]},Jm=e=>{if(!e)return[void 0,void 0];const t=e.split(" ");if(t.length!==2)return[e,void 0];const[i,s]=t;let n;if(s.toLowerCase()===lt.Kilograms)n=lt.Kilograms;else if(s.toLowerCase()===lt.Pounds)n=lt.Pounds;else return[e,void 0];return Nn(i)?[i,n]:[e,void 0]},Bn=async(e,t,i,s)=>{if(!e)return[];await J.fillCouriers(t,i,s);const n=J.getCouriers(s);return e.map(o=>{const a=n==null?void 0:n.find(N=>{var b;return N.toLowerCase()===((b=o.courierCompany)===null||b===void 0?void 0:b.toLowerCase())}),r=!!a,d=!!o.weightWhenOverweight;let u="",p;if(d){const[N,b]=Jm(o.weightWhenOverweight);u=N!=null?N:"",p=b}let A=!1;return d&&(A=!p||u.length>dn),{id:o.id||"",trackingNumber:o.trackingNumber,numberOfPackages:o.numberOfPackages||0,dimensions:o.sizeWhenOversized,overweight:d,oversized:!!o.sizeWhenOversized,weight:A?o.weightWhenOverweight:u,weightUnit:A?void 0:p,courier:r?a:gt,otherCompany:r?"":o.courierCompany,isHistorical:A}})},On=async e=>{var t,i,s,n,o,a;if(!e)return;const[r,d]=await Dn(e.description,e.accountNumber,e.site),u=await K.getServiceBackend(e.accountNumber,e.site,"Deliveries"),p=await Bn(e.packages,e.site,e.accountNumber,u);return{id:e.id,accountName:e.accountName,accountNumber:e.accountNumber,subject:e.subject,shortDescription:r,instructions:d,estimatedDate:(t=e.etaFrom)===null||t===void 0?void 0:t.toISOString().split("T")[0],latestDate:(i=e.etaTo)===null||i===void 0?void 0:i.toISOString().split("T")[0],referenceNumber:e.customerReference,site:e.site,cancellationReason:e.cancellationReason,contacts:e.otherNotificationRecipients,state:e.status,requester:e.createdBy,createdOn:(s=e.createdAt)===null||s===void 0?void 0:s.toISOString(),updatedOn:(n=e.updatedAt)===null||n===void 0?void 0:n.toISOString(),isLoadingBayRequired:e.loadingBayRequired,needRemoteHands:(o=e.remoteHandsRequired)!==null&&o!==void 0?o:!1,packages:p,comments:(a=e.comments)===null||a===void 0?void 0:a.map(A=>M(A)),serviceBackend:u}},Wm=async e=>{var t,i,s;if(!e)return;const[n,o]=await Dn(e.description,e.accountNumber,e.site),a=await K.getServiceBackend(e.accountNumber,e.site,"Deliveries"),r=await Bn(e.packages,e.site,e.accountNumber,a),d=J.sites.find(u=>u.id===e.site).locationId;return{id:e.id||"",accountNumber:e.accountNumber||"",subject:e.subject,shortDescription:n,instructions:o,estimatedDate:(t=e.etaFrom)===null||t===void 0?void 0:t.toISOString(),latestDate:(i=e.etaTo)===null||i===void 0?void 0:i.toISOString(),referenceNumber:e.customerReference,site:new Oe(d,e.site,e.accountNumber),contacts:e.otherNotificationRecipients,isLoadingBayRequired:e.loadingBayRequired,serviceBackend:a,isValid:!0,needRemoteHands:(s=e.remoteHandsRequired)!==null&&s!==void 0?s:!1,packages:r}},Gm=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),$n=e=>e.requestType===wi.PlannedWork&&e.serviceBackend===H.ServiceNow,Zm=e=>{var t,i;return $n(e)&&(i=Be(e.startDate,e.startTime,(t=e.site)===null||t===void 0?void 0:t.siteId))!==null&&i!==void 0?i:null},En=async e=>{var t,i;if(!e.expectedStart)return{startDate:"",startTime:"",startDateTime:""};const s=(i=(t=J.sites)===null||t===void 0?void 0:t.find(o=>o.locationId===e.site))===null||i===void 0?void 0:i.timeZone,n=s?G(e.expectedStart).tz(s):G(e.expectedStart);return{startDate:n.format("YYYY-MM-DD"),startTime:n.format("HH:mm"),startDateTime:n.format("YYYY-MM-DDTHH:mm")}},Km=e=>{var t,i,s,n,o;return{accountNumber:(t=e.accountNumber)!==null&&t!==void 0?t:"",requestType:(i=e.requestType)!==null&&i!==void 0?i:"",category:(s=e.category)!==null&&s!==void 0?s:"",subject:(n=e.subject)!==null&&n!==void 0?n:"",description:e.description,expectedStart:Zm(e),customerReference:e.referenceNumber,locations:!((o=e.location)===null||o===void 0)&&o.id?[e.location.id]:[],referenceTicket:e.referenceTicketNumber,otherNotificationRecipients:e.contacts}},Ym=e=>({customerReference:e.referenceNumber,otherNotificationRecipients:e.contacts}),xn=async e=>{var t,i,s,n,o;if(!e)return;const{startDate:a,startTime:r}=await En(e);return{id:e.ticketId,accountName:e.accountName,accountNumber:e.accountNumber,category:e.category,subject:e.subject,shortDescription:e.description,startDate:a,startTime:r,referenceNumber:e.customerReference,contacts:e.otherNotificationRecipients,state:e.status,site:e.site,locations:(i=(t=e.locations)===null||t===void 0?void 0:t.join(", "))!==null&&i!==void 0?i:"",requester:e.createdBy,requestType:e.requestType,referenceTicketNumber:e.referenceTicket,createdAt:(s=e.createdAt)===null||s===void 0?void 0:s.toISOString(),updatedAt:(n=e.updatedAt)===null||n===void 0?void 0:n.toISOString(),cancellationReason:e.cancellationReason,comments:(o=e.comments)===null||o===void 0?void 0:o.map(d=>M(d)),serviceBackend:await K.getServiceBackend(e.accountNumber,e.site,"Remote_hands"),ticketStatus:e.status||""}},Xm=async e=>{var t,i,s,n;if(!e)return;const{startDate:o,startTime:a,startDateTime:r}=await En(e);return{id:e.ticketId||"",accountName:e.accountName,accountNumber:e.accountNumber||"",category:e.category,subject:e.subject,description:e.description,shortDescription:(i=(t=e.description)===null||t===void 0?void 0:t.split("-")[0])===null||i===void 0?void 0:i.trim(),startDate:o,startTime:a,startDateTime:r,referenceNumber:e.customerReference,contacts:e.otherNotificationRecipients,state:e.status,site:{id:e.site},location:{id:e.locations[0],accountNumber:e.accountNumber},requester:e.createdBy,requestType:e.requestType,referenceTicketNumber:e.referenceTicket,createdOn:(s=e.createdAt)===null||s===void 0?void 0:s.toISOString(),updatedOn:(n=e.updatedAt)===null||n===void 0?void 0:n.toISOString(),ticketStatus:e.status||"",serviceBackend:await K.getServiceBackend(e.accountNumber,e.site,"Remote_hands")}},Qm=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),Bi=(e,t)=>{if(e===gt)return!0;const i=J.getCouriers(t).map(s=>s.toLowerCase());return!!e&&!(i!=null&&i.includes(e.toLowerCase()))},Fn=e=>e===cn,ep=e=>G().add({days:e}).format(ct),tp=(e,t)=>G(t).add({days:e}).format(ct),ip=e=>!!e&&G(e).isBefore(G().add({days:1}),"day"),sp=e=>!!e&&G(e).isBefore(G(),"day"),np=e=>{var t,i,s,n,o,a;const r=(t=Bi(e.courier,e.serviceBackend)?e.otherCompany:e.courier)!==null&&t!==void 0?t:"";return{accountNumber:(i=e.site)===null||i===void 0?void 0:i.accountNumber,subject:(s=e.subject)!==null&&s!==void 0?s:"",description:e.shortDescription,customerReference:e.referenceNumber,removalParty:(n=e.removalParty)!==null&&n!==void 0?n:"",courierCompany:r,trackingNumber:e.trackingNumber,pickupDate:Z(e.pickupDate),site:(a=(o=e.site)===null||o===void 0?void 0:o.id)!==null&&a!==void 0?a:"",otherNotificationRecipients:e.contacts}},ap=e=>{var t;const i=(t=Bi(e.courier,e.serviceBackend)?e.otherCompany:e.courier)!==null&&t!==void 0?t:"";return{subject:e.subject,description:e.shortDescription,customerReference:e.referenceNumber,courierCompany:i,trackingNumber:e.trackingNumber,pickupDate:Z(e.pickupDate),otherNotificationRecipients:e.contacts}},Ln=async(e,t,i,s)=>{await J.fillCouriers(t,i,s);const n=J.getCouriers(s).find(a=>a.toLowerCase()===(e==null?void 0:e.toLowerCase())),o=!!n;return{courier:o?n:gt,otherCompany:o?"":e}},Vn=e=>e===Yl?cn:e;async function op(e){if(!e)return;const t=await K.getServiceBackend(e.accountNumber,e.site,"Removals"),{courier:i,otherCompany:s}=await Ln(e.courierCompany,e.site,e.accountNumber,t),n=Vn(e.removalParty),o=J.sites.find(a=>a.id===e.site).locationId;return{id:e.id,accountNumber:e.accountNumber,site:new Oe(o,e.site,e.accountNumber),subject:e.subject,shortDescription:e.description,courier:i,otherCompany:s,removalParty:n,trackingNumber:e.trackingNumber,pickupDate:e.pickupDate,referenceNumber:e.customerReference,contacts:e.otherNotificationRecipients,status:e.status,isValid:!0,serviceBackend:await K.getServiceBackend(e.accountNumber,e.site,"Removals")}}const rp=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),Un=async e=>{var t,i,s;if(!e)return;const n=await K.getServiceBackend(e.accountNumber,e.site,"Removals"),{courier:o,otherCompany:a}=await Ln(e.courierCompany,e.site,e.accountNumber,n),r=Vn(e.removalParty);return{id:e.id,accountName:e.accountName,accountNumber:e.accountNumber,status:e.status,subject:e.subject,shortDescription:e.description,referenceNumber:e.customerReference,removalParty:r,needRemoteHands:Fn(r),courier:o,otherCompany:a,trackingNumber:e.trackingNumber,pickupDate:e.pickupDate,site:e.site,serviceBackend:n,contacts:e.otherNotificationRecipients,requester:e.createdBy,createdOn:(t=e.createdAt)===null||t===void 0?void 0:t.toISOString(),updatedOn:(i=e.updatedAt)===null||i===void 0?void 0:i.toISOString(),cancellationReason:e.cancellationReason,comments:(s=e.comments)===null||s===void 0?void 0:s.map(d=>M(d))}},cp=e=>{var t,i,s,n,o,a,r,d;return{accountNumber:(t=e.accountNumber)!==null&&t!==void 0?t:"",requestType:(i=e.requestType)!==null&&i!==void 0?i:"",category:(s=e.category)!==null&&s!==void 0?s:"",subject:(n=e.subject)!==null&&n!==void 0?n:"",description:(o=e.description)!==null&&o!==void 0?o:"",locations:e.locations,customerReference:(a=e.referenceNumber)!==null&&a!==void 0?a:"",circuitId:(r=e.circuitId)!==null&&r!==void 0?r:"",notificationRecipients:(d=e.contacts)!==null&&d!==void 0?d:""}},dp=e=>{const t={};return e.subject&&(t.subject=e.subject),e.description&&(t.description=e.description),e.circuitId&&(t.circuitId=e.circuitId),e.referenceNumber&&(t.customerReference=e.referenceNumber),e.contacts&&(t.otherNotificationRecipients=e.contacts),t},Oi=async e=>{var t,i,s,n;if(e)return{id:e.id,accountName:e.accountName,accountNumber:e.accountNumber,category:e.category,subject:e.subject,description:e.description,referenceNumber:e.customerReference,contacts:e.notificationRecipients,state:e.status,site:{id:e.site,accountNumber:e.accountNumber},locations:e.locations,requester:e.createdBy,requestType:e.requestType,circuitId:e.circuitId,createdOn:(t=e.createdAt)===null||t===void 0?void 0:t.toISOString(),updatedOn:(i=e.updatedAt)===null||i===void 0?void 0:i.toISOString(),closedOn:(s=e.closedAt)===null||s===void 0?void 0:s.toISOString(),comments:(n=e.comments)===null||n===void 0?void 0:n.map(o=>M(o)),cancellationReason:e.cancellationReason,serviceBackend:await K.getServiceBackend(e.accountNumber,e.site,"Trouble_tickets")}},up=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}});async function Pt(e,t,i,s,n,o){var a;let r;switch(e){case y.CustomerSupport:{r=await l.customerCareApi.createCustomerCareTicketAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:l.getAuthorizationToken()}}).catch(d=>{throw m(d,!1),d});break}case y.RemoteHands:{r=await l.remoteHandsApi.createRemoteHandsAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:l.getAuthorizationToken()}}).catch(d=>{throw m(d,!1),d});break}case y.Deliveries:{r=await l.deliveriesApi.createAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:l.getAuthorizationToken()}}).catch(d=>{throw m(d,!1),d});break}case y.Removals:{r=await l.removalsApi.createRemovalsAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:l.getAuthorizationToken()}}).catch(d=>{throw m(d,!1),d});break}case y.FacilityAccess:{switch(o){case"Visitor Access":r=await l.facilityAccessApi.visitorAccess.createVisitorAccessAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:l.getAuthorizationToken()}}).catch(d=>{throw m(d,!1),d});break;case"Permanent Badge":r=await((a=l.facilityAccessApi.permanentBadgeAccess)===null||a===void 0?void 0:a.createPermanentBadegeAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:l.getAuthorizationToken()}}).catch(d=>{throw m(d,!1),d}));break;case"OSP Access":r=await l.facilityAccessApi.ospAccess.createOspAccessAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:l.getAuthorizationToken()}}).catch(d=>{throw m(d,!1),d});break;case"PoP/POE Access":r=await l.facilityAccessApi.popAccess.createPopAccessAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:l.getAuthorizationToken()}}).catch(d=>{throw m(d,!1),d});break}break}case y.TroubleTickets:{r=await l.troubleTicketsApi.createTroubleTicketAttachment({ticketId:n,fileName:i,body:t},{headers:{"Content-Type":s,Authorization:l.getAuthorizationToken()}}).catch(d=>{throw m(d,!1),d});break}default:return}return r}const xe=e=>{const t=URL.createObjectURL(e);window.open(t),setTimeout(()=>URL.revokeObjectURL(t),1e3*60*5)};async function lp(e,t,i,s){var n;let o;try{switch(e){case y.CustomerSupport:{o=await l.customerCareApi.getCustomerCareTicketAttachmentsById({ticketId:i,attachmentId:t!=null?t:""}),xe(o);break}case y.RemoteHands:{o=await l.remoteHandsApi.getRemoteHandsAttachmentsById({ticketId:i,attachmentId:t!=null?t:""}),xe(o);break}case y.Deliveries:{o=await l.deliveriesApi.getDeliveryAttachmentsById({ticketId:i,attachmentId:t!=null?t:""}),xe(o);break}case y.Removals:{o=await l.removalsApi.getRemovalsAttachmentsById({ticketId:i,attachmentId:t!=null?t:""}),xe(o);break}case y.TroubleTickets:{o=await l.troubleTicketsApi.getTroubleTicketAttachmentsById({ticketId:i,attachmentId:t!=null?t:""}),xe(o);break}case y.FacilityAccess:{switch(s){case"Visitor Access":o=await l.facilityAccessApi.visitorAccess.getVisitorAccessAttachmentsById({ticketId:i,attachmentId:t}),xe(o);break;case"Permanent Badge":o=await((n=l.facilityAccessApi.permanentBadgeAccess)===null||n===void 0?void 0:n.getPermanentBadgeAttachmentsById({ticketId:i,attachmentId:t})),xe(o);break;case"OSP Access":o=await l.facilityAccessApi.ospAccess.getOspAccessAttachmentsById({ticketId:i,attachmentId:t}),xe(o);break;case"PoP/POE Access":o=await l.facilityAccessApi.popAccess.getPopAccessAttachmentsById({ticketId:i,attachmentId:t}),xe(o);break;default:break}break}default:return}}catch(a){console.error("error",a),m(a,!1)}return o}const Fe=(e,t)=>{const i=URL.createObjectURL(e),s=document.createElement("a");s.href=i,s.download=t,document.body.appendChild(s),s.click(),URL.revokeObjectURL(i)};async function mp(e,t,i,s,n){var o;let a;try{switch(e){case y.CustomerSupport:{a=await l.customerCareApi.getCustomerCareTicketAttachmentsById({ticketId:s,attachmentId:t!=null?t:""}),Fe(a,i);break}case y.RemoteHands:{a=await l.remoteHandsApi.getRemoteHandsAttachmentsById({ticketId:s,attachmentId:t!=null?t:""}),Fe(a,i);break}case y.Deliveries:{a=await l.deliveriesApi.getDeliveryAttachmentsById({ticketId:s,attachmentId:t!=null?t:""}),Fe(a,i);break}case y.Removals:{a=await l.removalsApi.getRemovalsAttachmentsById({ticketId:s,attachmentId:t!=null?t:""}),Fe(a,i);break}case y.TroubleTickets:{a=await l.troubleTicketsApi.getTroubleTicketAttachmentsById({ticketId:s,attachmentId:t!=null?t:""}),Fe(a,i);break}case y.FacilityAccess:{switch(n){case"Visitor Access":a=await l.facilityAccessApi.visitorAccess.getVisitorAccessAttachmentsById({ticketId:s,attachmentId:t}),Fe(a,i);break;case"Permanent Badge":a=await((o=l.facilityAccessApi.permanentBadgeAccess)===null||o===void 0?void 0:o.getPermanentBadgeAttachmentsById({ticketId:s,attachmentId:t})),Fe(a,i);break;case"OSP Access":a=await l.facilityAccessApi.ospAccess.getOspAccessAttachmentsById({ticketId:s,attachmentId:t}),Fe(a,i);break;case"PoP/POE Access":a=await l.facilityAccessApi.popAccess.getPopAccessAttachmentsById({ticketId:s,attachmentId:t}),Fe(a,i);break;default:break}break}default:return}}catch(r){console.error("error",r),m(r,!1)}return a}async function Hn(e,t,i){var s,n;try{let o;switch(e){case y.CustomerSupport:{o=await l.customerCareApi.getCustomerCareTicketAttachmentsList({ticketId:t});break}case y.RemoteHands:{o=await l.remoteHandsApi.getRemoteHandsAttachmentsList({ticketId:t});break}case y.Deliveries:{o=await l.deliveriesApi.getDeliveryAttachmentsList({ticketId:t});break}case y.Removals:{o=await l.removalsApi.getRemovalsAttachmentsList({ticketId:t});break}case y.TroubleTickets:{o=await l.troubleTicketsApi.getTroubleTicketAttachmentsList({ticketId:t});break}case y.FacilityAccess:{switch(i){case"Visitor Access":o=await l.facilityAccessApi.visitorAccess.getVisitorAccessAttachmentsList({ticketId:t});break;case"Permanent Badge":o=await((s=l.facilityAccessApi.permanentBadgeAccess)===null||s===void 0?void 0:s.getPermanentBadgeAttachmentsList({ticketId:t}));break;case"OSP Access":o=await l.facilityAccessApi.ospAccess.getOspAccessAttachmentsList({ticketId:t});break;case"PoP/POE Access":o=await l.facilityAccessApi.popAccess.getPopAccessAttachmentsList({ticketId:t});break;default:break}break}default:return}return k.attachments=(n=o==null?void 0:o.attachments)!==null&&n!==void 0?n:[],k.attachments}catch(o){console.error("error",o),await m(o,!1);return}}const qt=async(e,t,i="text/csv")=>{const s=new Blob([await e.arrayBuffer()],{type:i}),n=URL.createObjectURL(s),o=document.createElement("a");o.href=n,o.download=t,document.body.appendChild(o),o.click(),URL.revokeObjectURL(n)};async function pp(e,t){try{const i=await l.serviceTicketApi.downloadServiceTickets({$filter:e,permissionPrivilege:t});await qt(i,"service-tickets.csv")}catch(i){m(i,!1)}}async function hp(e,t,i,s){try{const n=await l.plannedMaintenanceApi.downloadPlannedMaintenanceTickets({$filter:e,$orderby:t,$skip:i,$top:s});await qt(n,"planned-maintenance-tickets.csv")}catch(n){m(n,!1)}}async function vp(e,t,i){try{const s=await l.plannedMaintenanceApi.getPlannedMaintenanceAttachmentsByIdRaw({ticketId:e,attachmentId:t}),n=s.raw.headers.get("content-type")||void 0,o=await s.value();await qt(o,i,n)}catch(s){m(s,!1)}}async function gp(e,t,i,s){try{const n=await l.incidentsApi.downloadIncidentTickets({$filter:e,$orderby:t,$skip:i,$top:s});await qt(n,"incident-tickets.csv")}catch(n){m(n,!1)}}async function wp(e,t,i){try{const s=await l.incidentsApi.getIncidentsAttachmentsByIdRaw({ticketId:e,attachmentId:t}),n=s.raw.headers.get("content-type")||void 0,o=await s.value();await qt(o,i,n)}catch(s){m(s,!1)}}const Le={ticketType:void 0,ticketStep:void 0,serviceTickets:void 0,permissions:{hasCustomerCareCreatePermission:!1,hasFacilityAccessCreatePermission:!1,hasRemoteHandsCreatePermission:!1,hasDeliveriesAndRemovalsCreatePermission:!1,hasTroubleTicketsCreatePermission:!1},loadings:{ticketCreatePermissionChecks:!0,serviceTicketList:!0,attachments:!0,downloadServiceTicketList:!1,serviceTicket:!1,isTicketCancelling:!1},attachments:[],failedAttachments:[],error:{uploadingAttachments:!1,serviceTicketsGrid:!1,fetchingTicket:!1,cancellingTicket:!1},hasPendingApprovalDialogBeenShown:!1};class fp{constructor(){this.ticketType=void 0,this.ticketStep=void 0,this.serviceTickets=void 0,this.permissions=Le.permissions,this.loadings=Le.loadings,this.attachments=Le.attachments,this.failedAttachments=Le.failedAttachments,this.error=Le.error,this.hasPendingApprovalDialogBeenShown=Le.hasPendingApprovalDialogBeenShown,se(this)}updateTicketType(t=void 0){this.ticketType=t}clear(){this.ticketType=void 0,this.ticketStep=void 0,this.error=Le.error,this.loadings=Le.loadings,this.failedAttachments=Le.failedAttachments}setPendingApprovalDialogShown(t){this.hasPendingApprovalDialogBeenShown=t}async checkPermissions(){this.loadings.ticketCreatePermissionChecks=!0,this.permissions.hasCustomerCareCreatePermission=await hn(),this.permissions.hasFacilityAccessCreatePermission=await kn(),this.permissions.hasRemoteHandsCreatePermission=await yn(),this.permissions.hasDeliveriesAndRemovalsCreatePermission=await Ni(),this.permissions.hasTroubleTicketsCreatePermission=await Tn(),this.loadings.ticketCreatePermissionChecks=!1}async postAttachments(t,i,s,n,o){i&&i.length>0&&(this.error.uploadingAttachments=!1,this.failedAttachments=i.map(a=>a.fileName),await Promise.all(i.map(async a=>{try{const r=await Pt(t,a.file,a.fileName,a.fileType,s,o);n&&r!=null&&r.id&&(this.attachments.push(r),this.failedAttachments=this.failedAttachments.filter(d=>d!==a.fileName))}catch(r){await m(r,!1),this.error.uploadingAttachments=!0}})))}async GetServiceTicketList(t,i,s,n,o,a){var r,d;this.loadings.serviceTicketList=!0,this.error.serviceTicketsGrid=!1;try{this.serviceTickets=await l.serviceTicketApi.getServiceTickets({$filter:t,$orderby:i,$skip:s,$top:n,permissionPrivilege:o},a)}catch(u){if(!((r=a==null?void 0:a.signal)===null||r===void 0)&&r.aborted)return;m(u,!1),this.serviceTickets=void 0,this.error.serviceTicketsGrid=!0}finally{!((d=a==null?void 0:a.signal)===null||d===void 0)&&d.aborted||(this.loadings.serviceTicketList=!1)}}async downloadServiceTickets(t,i){this.loadings.downloadServiceTicketList=!0,await pp(t,i),this.loadings.downloadServiceTicketList=!1}get ticketAttachments(){return this.attachments.filter(t=>!t.isError).map(t=>({name:t.fileName}))}}const k=new fp,ye={newTicket:{isValid:!1,accountNumber:"",attachments:[]},selectedTicket:void 0,submissionResult:{state:w.Default},loadings:{isSubmitting:!1,ticketDetailsPermissionCheck:!1}};class kp{constructor(){this.newTicket=ye.newTicket,this.submissionResult=ye.submissionResult,this.selectedTicket=ye.selectedTicket,this.loadings=ye.loadings,se(this),Je(this,{name:"removals",properties:[],storage:window.localStorage})}createTicket(){var t,i,s;this.newTicket={...ye.newTicket,site:(t=this.newTicket.site)!==null&&t!==void 0?t:void 0,serviceBackend:(i=this.newTicket.serviceBackend)!==null&&i!==void 0?i:void 0,accountNumber:(s=this.newTicket.accountNumber)!==null&&s!==void 0?s:"NOT FOUND"},this.submissionResult=ye.submissionResult}updateIsFormValid(t){this.newTicket.isValid=t}updateSite(t){this.newTicket.site=t}updateSubject(t){this.newTicket.subject=t}updateShortDesc(t){this.newTicket.shortDescription=t}updateCourier(t){this.newTicket.courier=t}updateOtherCompany(t){this.newTicket.otherCompany=t}updateTrackingNumber(t){this.newTicket.trackingNumber=t}updatePickupDate(t){this.newTicket.pickupDate=t}updateReferenceNumber(t){this.newTicket.referenceNumber=t}updateRemovalParty(t){this.newTicket.removalParty=t}updateContacts(t){this.newTicket.contacts=t}updateAttachments(t){var i;this.newTicket.attachments=[...(i=this.newTicket.attachments)!==null&&i!==void 0?i:[],...t]}async submitNewTicketRequest(){var t;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.result=void 0;try{this.submissionResult.result=await l.removalsApi.createRemoval({removalTicketsRequest:np(this.newTicket)})}catch(i){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await m(i,!1),i}try{!((t=this.submissionResult.result)===null||t===void 0)&&t.id&&(await k.postAttachments(y.Removals,this.newTicket.attachments,this.submissionResult.result.id),this.newTicket.attachments=void 0)}catch(i){throw await m(i,!1),i}finally{this.loadings.isSubmitting=!1}}async hasTicketPermissionAtLocation(t,i,s,n){try{return this.loadings.ticketDetailsPermissionCheck=!0,await Nt(t,i,s,n)}finally{this.loadings.ticketDetailsPermissionCheck=!1}}async setNewTicket(){try{this.newTicket=await op(this.submissionResult.result)||ye.newTicket}catch(t){throw await m(t,!1),t}}async getRemovalsServiceTicket(t){if(t)try{const i=await l.removalsApi.getRemovalById({ticketId:t});this.submissionResult.result=i,this.selectedTicket=await Un(i),await this.setNewTicket()}catch(i){throw await m(i,!1),i}}async editTicketRequest(){let t;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{t=await l.removalsApi.updateRemovalById({ticketId:this.newTicket.id||"",removalsTicketsUpdateRequest:ap(this.newTicket)}),this.submissionResult.result=t,this.submissionResult.state=w.Submitted}catch(i){this.submissionResult.state=w.Error,await m(i,!1)}try{await k.postAttachments(y.Removals,this.newTicket.attachments,this.newTicket.id,!0),this.newTicket.attachments=void 0}catch(i){await m(i,!1)}try{t&&(this.selectedTicket=await Un(t),await this.setNewTicket())}catch(i){throw await m(i,!1),i}}finally{this.loadings.isSubmitting=!1}}async cancelTicket(t){var i,s;try{if(k.loadings.isTicketCancelling=!0,!((i=this.selectedTicket)===null||i===void 0)&&i.id){const n=(s=this.selectedTicket)===null||s===void 0?void 0:s.id;await l.removalsApi.cancellationRemovalRequest({ticketId:n,cancellationTicketsRequest:{cancellationReason:t}}),await this.getRemovalsServiceTicket(n)}}catch(n){throw await m(n,!1),n}finally{k.loadings.isTicketCancelling=!1}}clear(){this.newTicket=ye.newTicket,this.selectedTicket=ye.selectedTicket,this.submissionResult=ye.submissionResult,this.loadings=ye.loadings}}const Ve=new kp,Te={newTicket:{isValid:!1,isLoadingBayRequired:!1,needRemoteHands:!1,accountNumber:"",contacts:"",attachments:[]},selectedTicket:void 0,submissionResult:{state:w.Default,result:void 0},loadings:{isSubmitting:!1,isDeliveryBlocked:!1,ticketDetailsPermissionCheck:!1}};class yp{constructor(){this.newTicket=Te.newTicket,this.submissionResult=Te.submissionResult,this.selectedTicket=Te.selectedTicket,this.loadings=Te.loadings,se(this),Je(this,{name:"deliveries",properties:[],storage:window.localStorage})}createTicket(){var t,i,s;this.newTicket={...Te.newTicket,site:(t=this.newTicket.site)!==null&&t!==void 0?t:void 0,serviceBackend:(i=this.newTicket.serviceBackend)!==null&&i!==void 0?i:void 0,accountNumber:(s=this.newTicket.accountNumber)!==null&&s!==void 0?s:"NOT FOUND"},this.submissionResult=Te.submissionResult}addPackage(t,i){var s;if(!t)return;const n=(s=this.newTicket.packages)!==null&&s!==void 0?s:[];i?this.newTicket.packages=n.map(o=>o.id===t.id?t:o):this.newTicket.packages=[...n,t]}removePackage(t){var i;if(t){const s=((i=this.newTicket.packages)!==null&&i!==void 0?i:[]).filter(n=>n.id!==t.id);this.newTicket.packages=[...s]}}updateSite(t){this.newTicket.site=t,this.newTicket.packages=[]}updateSubject(t){this.newTicket.subject=t}updateShortDesc(t){this.newTicket.shortDescription=t}updateEstimatedDate(t){this.newTicket.estimatedDate=t}updateLatestDate(t){this.newTicket.latestDate=t}updateReferenceNumber(t){this.newTicket.referenceNumber=t}updateLoadingBay(t){this.newTicket.isLoadingBayRequired=t}updateNeedRemoteHands(t){this.newTicket.needRemoteHands=t}updateInstructions(t){this.newTicket.instructions=t}updateContacts(t){this.newTicket.contacts=t}updateAttachments(t){var i;this.newTicket.attachments=[...(i=this.newTicket.attachments)!==null&&i!==void 0?i:[],...t]}updateTermsAgreed(t){this.newTicket.termsAgreed=t}updateIsValid(t){this.newTicket.isValid=t}async submitNewTicketRequest(){var t;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{this.submissionResult.result=await l.deliveriesApi.createDelivery({deliveryTicketsRequest:qn(this.newTicket)}),this.submissionResult.state=w.Submitted}catch(i){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await m(i,!1),i}try{!((t=this.submissionResult.result)===null||t===void 0)&&t.id&&await k.postAttachments(y.Deliveries,this.newTicket.attachments,this.submissionResult.result.id),this.newTicket.attachments=void 0}catch(i){throw await m(i,!1),i}finally{this.loadings.isSubmitting=!1}}async setNewTicket(){try{this.newTicket=await Wm(this.submissionResult.result)||Te.newTicket}catch(t){throw await m(t,!1),t}}async updateTicketRequest(){var t,i;let s;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{s=await l.deliveriesApi.updateDeliveriesTickets({ticketId:((t=this.selectedTicket)===null||t===void 0?void 0:t.id)||"",deliveryTicketsUpdateRequest:qn(this.newTicket,!0)});const n=((i=this.newTicket)===null||i===void 0?void 0:i.packages)||[],o=(await Promise.all(n.map(async a=>{var r;return l.deliveriesApi.updateDeliveriesTicketsPackages({ticketId:((r=this.selectedTicket)===null||r===void 0?void 0:r.id)||"",packageId:(a==null?void 0:a.id)||"",deliveryTicketUpdatePackagesRequest:Pn(a,this.newTicket.serviceBackend)}).then(d=>{var u,p;return(p=(u=d.packages)===null||u===void 0?void 0:u.find(A=>A.id===a.id))!==null&&p!==void 0?p:null}).catch(d=>(m(d,!1),null))}))).filter(a=>a!==null);s&&(s.packages=s.packages.map(a=>{const r=o.find(d=>a.id===d.id);return r!=null?r:a})),this.submissionResult.result=s,this.submissionResult.state=w.Submitted}catch(n){throw this.submissionResult.state=w.Error,await m(n,!1),n}try{await k.postAttachments(y.Deliveries,this.newTicket.attachments,this.newTicket.id,!0),this.newTicket.attachments=void 0}catch(n){await m(n,!1)}try{this.selectedTicket=await On(s),await this.setNewTicket()}catch(n){await m(n,!1)}}finally{this.loadings.isSubmitting=!1}}async hasTicketPermissionAtLocation(t,i,s,n){this.loadings.ticketDetailsPermissionCheck=!0;const o=await Nt(t,i,s,n);return this.loadings.ticketDetailsPermissionCheck=!1,o}async getDeliveriesServiceTicket(t){if(t)try{const i=await l.deliveriesApi.getDeliveryById({ticketId:t});this.submissionResult.result=i,this.selectedTicket=await On(i),await this.setNewTicket()}catch(i){throw await m(i,!1),i}}async cancelDelivery(t,i){try{k.loadings.isTicketCancelling=!0,t&&(await l.deliveriesApi.cancellationDeliveryRequest({ticketId:t,cancellationTicketsRequest:{cancellationReason:i}}),await this.getDeliveriesServiceTicket(t))}catch(s){throw await m(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}async isDeliveryBlocked(t,i){var s;let n;return this.loadings.isDeliveryBlocked=!0,t&&i&&(n=await l.deliveriesApi.getDeliveryDiscovery({site:t,accountNumber:i}).catch(o=>{m(o,!1)})),this.loadings.isDeliveryBlocked=!1,(s=n==null?void 0:n.deliveryBlocked)!==null&&s!==void 0?s:!0}clear(){this.newTicket=Te.newTicket,this.selectedTicket=Te.selectedTicket,this.submissionResult=Te.submissionResult,this.loadings=Te.loadings}}const be=new yp,Re={newTicket:{isValid:!1,accountNumber:"",disableReferenceTicketNumber:!1,attachments:[]},selectedTicket:void 0,submissionResult:{state:w.Default},loadings:{isSubmitting:!1,ticketDetailsPermissionCheck:!1,requestType:!1}};class Tp{constructor(){this.newTicket=Re.newTicket,this.submissionResult=Re.submissionResult,this.selectedTicket=Re.selectedTicket,this.loadings=Re.loadings,se(this),Je(this,{name:"remote-hands",properties:[],storage:window.localStorage})}createTicket(t){var i,s,n,o;const a=(i=this.newTicket.accountNumber)!==null&&i!==void 0?i:ae.getUserAccount().accountNumber;this.newTicket={...Re.newTicket,site:(s=this.newTicket.site)!==null&&s!==void 0?s:void 0,accountNumber:a!=null?a:"NOT FOUND",serviceBackend:t,referenceTicketNumber:(n=this.newTicket.referenceTicketNumber)!==null&&n!==void 0?n:void 0,disableReferenceTicketNumber:(o=this.newTicket.disableReferenceTicketNumber)!==null&&o!==void 0?o:void 0},this.submissionResult=Re.submissionResult}updateSite(t,i=!1){this.newTicket.site=t,this.newTicket.isValid=i}updateLocation(t){this.newTicket.location=t}updateSubject(t){this.newTicket.subject=t}updateDescription(t){this.newTicket.description=t}updateRequestType(t){this.newTicket.requestType=t,this.newTicket.category=void 0}updateCategory(t){this.newTicket.category=t}updateReferenceNumber(t){this.newTicket.referenceNumber=t}updateReferenceTicketNumber(t){this.newTicket.referenceTicketNumber=t}updateReferenceNumberDisable(t){this.newTicket.referenceTicketNumber=t,this.newTicket.disableReferenceTicketNumber=!0}updateStartDate(t){this.newTicket.startDate=t}updateStartTime(t){this.newTicket.startTime=t}updateContacts(t){this.newTicket.contacts=t}updateAccountNumber(t){this.newTicket.accountNumber=t}updateFormValidation(t){this.newTicket.isValid=t}updateAttachments(t){var i;this.newTicket.attachments=[...(i=this.newTicket.attachments)!==null&&i!==void 0?i:[],...t]}updateTermsAgreed(t){this.newTicket.termsAgreed=t}async setNewTicket(){try{this.newTicket=await Xm(this.submissionResult.result)||Re.newTicket}catch(t){throw await m(t,!1),t}}async updateTicketRequest(){var t;let i;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{i=await l.remoteHandsApi.updateRemoteHandsTicketById({ticketId:((t=this.selectedTicket)===null||t===void 0?void 0:t.id)||"",remoteHandsUpdateRequest:Ym(this.newTicket)}),this.submissionResult.result=i,this.submissionResult.state=w.Submitted}catch(s){this.submissionResult.state=w.Error,await m(s,!1)}try{await k.postAttachments(y.RemoteHands,this.newTicket.attachments,this.newTicket.id,!0),this.newTicket.attachments=void 0}catch(s){await m(s,!1)}try{i&&(this.selectedTicket=await xn(i))}catch(s){await m(s,!1)}}catch(s){throw await m(s,!1),s}finally{this.loadings.isSubmitting=!1}}async submitNewTicketRequest(){var t;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{this.submissionResult.result=await l.remoteHandsApi.createRemoteHandsTicket({remoteHandsRequest:Km(this.newTicket)}),this.submissionResult.state=w.Submitted}catch(i){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await m(i,!1),i}try{!((t=this.submissionResult.result)===null||t===void 0)&&t.ticketId&&(await k.postAttachments(y.RemoteHands,this.newTicket.attachments,this.submissionResult.result.ticketId),this.newTicket.attachments=void 0)}catch(i){throw await m(i,!1),i}finally{this.loadings.isSubmitting=!1}}async getRemoteHandsServiceTicket(t){if(t)try{const i=await l.remoteHandsApi.getRemoteHandsTicketById({ticketId:t});this.submissionResult.result=i,this.selectedTicket=await xn(i),await this.setNewTicket()}catch(i){throw await m(i,!1),i}}async cancelTicket(t){var i;try{k.loadings.isTicketCancelling=!0,!((i=this.selectedTicket)===null||i===void 0)&&i.id&&(await l.remoteHandsApi.cancellationRemoteHandsRequest({ticketId:this.selectedTicket.id,cancellationTicketsRequest:{cancellationReason:t}}),await this.getRemoteHandsServiceTicket(this.selectedTicket.id))}catch(s){throw await m(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}clear(){this.newTicket=Re.newTicket,this.selectedTicket=Re.selectedTicket,this.submissionResult=Re.submissionResult,this.loadings=Re.loadings}}const re=new Tp,bp=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),Ae={newTicket:{isValid:!1,accountNumber:"",attachments:[],locations:[]},selectedTicket:void 0,submissionResult:{state:w.Default},loadings:{isSubmitting:!1}};class Rp{constructor(){this.newTicket=Ae.newTicket,this.submissionResult=Ae.submissionResult,this.selectedTicket=Ae.selectedTicket,this.loadings=Ae.loadings,se(this),Je(this,{name:"trouble-tickets",properties:[],storage:window.localStorage})}getIsInProgress(){var t;return((t=this.selectedTicket)===null||t===void 0?void 0:t.state)===O.InProgress}createTicket(t){var i,s;const{accountNumber:n}=ae.getUserAccount();this.newTicket={...Ae.newTicket,site:(i=this.newTicket.site)!==null&&i!==void 0?i:void 0,accountNumber:n!=null?n:"NOT FOUND",referenceTicketNumber:t,serviceBackend:(s=this.newTicket.serviceBackend)!==null&&s!==void 0?s:void 0},this.submissionResult=Ae.submissionResult}updateSite(t,i=!1){this.newTicket.site=t,this.newTicket.isValid=i}updateLocations(t,i){var s,n,o;if(i)(o=this.newTicket.locations)===null||o===void 0||o.push(t);else{const a=(s=this.newTicket.locations)===null||s===void 0?void 0:s.indexOf(t);a!==void 0&&a!==-1&&((n=this.newTicket.locations)===null||n===void 0||n.splice(a,1))}}clearLocations(){this.newTicket.locations=[]}updateSubject(t){this.newTicket.subject=t}updateDescription(t){this.newTicket.description=t}updateRequestType(t){this.newTicket.requestType=t,this.newTicket.category=void 0}updateCategory(t){this.newTicket.category=t}updateReferenceNumber(t){this.newTicket.referenceNumber=t}updateReferenceTicketNumber(t){this.newTicket.referenceTicketNumber=t}updateReferenceNumberDisable(t){this.newTicket.referenceTicketNumber=t}updateCircuitId(t){this.newTicket.circuitId=t}updateContacts(t){this.newTicket.contacts=t}updateAccountNumber(t){this.newTicket.accountNumber=t}updateFormValidation(t){this.newTicket.isValid=t}updateTermsAgreed(t){this.newTicket.termsAgreed=t}updateAttachments(t){var i;this.newTicket.attachments=[...(i=this.newTicket.attachments)!==null&&i!==void 0?i:[],...t]}async submitNewTicketRequest(){var t,i;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.result=void 0;try{this.submissionResult.result=await l.troubleTicketsApi.createTroubleTicketTicket({troubleTicketRequest:cp(this.newTicket)}),this.submissionResult.state=w.Submitted}catch(s){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await m(s,!1),s}try{!((i=(t=this.submissionResult)===null||t===void 0?void 0:t.result)===null||i===void 0)&&i.id&&(await k.postAttachments(y.TroubleTickets,this.newTicket.attachments,this.submissionResult.result.id),this.newTicket.attachments=void 0)}catch(s){throw await m(s,!1),s}finally{this.loadings.isSubmitting=!1}}async setNewTicket(){try{this.newTicket=await Oi(this.submissionResult.result)||Ae.newTicket}catch(t){throw await m(t,!1),t}}async submitUpdateTicketRequest(){var t,i;if(this.newTicket&&this.selectedTicket&&this.selectedTicket.id){let s;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{s=await l.troubleTicketsApi.updateTroubleTicketTicket({ticketId:(t=this.selectedTicket.id)!==null&&t!==void 0?t:"",troubleTicketUpdateRequest:dp(this.newTicket)}),this.submissionResult.result=s}catch(n){this.submissionResult.state=w.Error,await m(n,!1)}try{await k.postAttachments(y.TroubleTickets,this.newTicket.attachments,(i=this.selectedTicket)===null||i===void 0?void 0:i.id,!0),this.newTicket.attachments=void 0}catch(n){await m(n,!1)}try{s&&(this.submissionResult.state=w.Submitted,this.submissionResult.result=s,this.selectedTicket=await Oi(this.submissionResult.result),await this.setNewTicket())}catch(n){await m(n,!1)}}finally{this.loadings.isSubmitting=!1}}}async getTroubleTicketById(t){if(t)try{const i=await l.troubleTicketsApi.getTroubleTicketTicketById({ticketId:t});this.submissionResult.result=i,this.selectedTicket=await Oi(i),await this.setNewTicket()}catch(i){throw await m(i,!1),i}}async cancelTicket(t){var i;try{k.loadings.isTicketCancelling=!0,!((i=this.selectedTicket)===null||i===void 0)&&i.id&&(await l.troubleTicketsApi.cancellationTroubleTicketRequest({ticketId:this.selectedTicket.id,cancellationTicketsRequest:{cancellationReason:t}}),await this.getTroubleTicketById(this.selectedTicket.id))}catch(s){throw await m(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}clear(){this.newTicket=Ae.newTicket,this.selectedTicket=Ae.selectedTicket,this.submissionResult=Ae.submissionResult,this.loadings=Ae.loadings}}const Ue=new Rp,Ap={"Visitor First Name":"visitorFirstName","Visitor Last Name":"visitorLastName","Visitor Email Address":"visitorEmailAddress","Visitor Phone Number":"visitorPhoneNumber"},zn=40,$i="bulk_";function mt(e){return e.startsWith("WO")}function _p(e){return e.startsWith("CS")||e.startsWith("DEL")}function Ip(e,t){return e?Jt.Escorted:t==="Standard"?Jt.Standard:Jt.Extended}function Sp(e){return e?e==="Escorted"?{isEscortedVisitor:!0,visitorBadge:void 0}:{isEscortedVisitor:!1,visitorBadge:e==="Standard"?"Standard":"Extended"}:{isEscortedVisitor:void 0,visitorBadge:void 0}}function Cp(e){return e.map(t=>{var i;return{siteCode:t.site.siteId,visitorHostId:(i=t.visitorHost)===null||i===void 0?void 0:i.id,locations:t.locations.map(s=>({id:s.id,startDate:Z(s.startDate),endDate:Z(s.endDate)}))}})}const Np=e=>({otherNotificationRecipients:e.contacts,visitorPhone:e.visitors[0].phone});async function jn(e,t,i,s,n,o){var a,r;const d=(a=J.sites.find(u=>u.locationId===e))===null||a===void 0?void 0:a.id;return[{site:new Oe(e,d,t),locations:(r=i==null?void 0:i.map(u=>({id:u.id||"-",site:d,startDate:u.startDate||"",endDate:u.endDate||"",status:u.approvalStatus||"-",modifiedBy:u.modifiedBy||"-"})))!==null&&r!==void 0?r:[],isVisitorHostDetailsValid:s,visitorHost:n,serviceBackend:o}]}const Pp=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),qp=e=>{var t,i,s,n;return{accountNumber:e.accountNumber,visitors:e.visitors.map(o=>({firstName:o.firstName,lastName:o.lastName,email:o.email,phone:o.phone})),visitStartDate:Z(e.startDate),visitEndDate:Z(e.endDate),visitType:Ip((t=e.isEscortedVisitor)!==null&&t!==void 0?t:!1,e.visitorBadge),sites:Cp(e.sitesDetails||[]),escortFirstName:e.escortFirstName,escortLastName:e.escortLastName,visitorHostFirstName:(i=e.hostFirstName)!==null&&i!==void 0?i:"",visitorHostLastName:(s=e.hostLastName)!==null&&s!==void 0?s:"",representingCompany:(n=e.representingCompany)!==null&&n!==void 0?n:"",description:e.notes,notificationRecipients:e.contacts}},Mn=async e=>{var t,i,s,n;if(!e)return;const o=mt(e.id)?H.Insite:H.ServiceNow;return{id:e.id,accountNumber:e.accountNumber||"-",accountName:e.accountName||"-",contacts:e.notificationRecipients||"",state:e.status||"-",requester:e.createdBy||"-",createdOn:e.createdAt.toISOString(),updatedOn:e.updatedAt.toISOString(),requestType:"Visitor Access",category:"New Visitor Access",visitors:[{firstName:e.visitorFirstName||"-",lastName:e.visitorLastName||"-",email:e.visitorEmail||"-",phone:e.visitorPhone||"-",id:""}],visitorType:e.visitType||"-",escortFirstName:e.escortFirstName||"-",escortLastName:e.escortLastName||"-",startDate:e.visitStartDate,endDate:e.visitEndDate,representingCompany:e.representingCompany||"-",notes:e.description||"-",site:e.site,cancellationReason:e.cancellationReason,sitesDetails:await jn((t=e.site)!==null&&t!==void 0?t:"-",(i=e.accountNumber)!==null&&i!==void 0?i:"-",(s=e.locations)!==null&&s!==void 0?s:[],!0,{firstName:e.visitorHostFirstName,lastName:e.visitorHostLastName},o),hostFirstName:e.visitorHostFirstName,hostLastName:e.visitorHostLastName,comments:(n=e.comments)===null||n===void 0?void 0:n.map(a=>M(a))}},Dp=async e=>{var t,i,s;if(!e)return;const{isEscortedVisitor:n,visitorBadge:o}=Sp(e.visitType),a=mt(e.id)?H.Insite:H.ServiceNow;return{id:e==null?void 0:e.id,accountNumber:e.accountNumber||"",contacts:e.notificationRecipients||"",requestType:"Visitor Access",category:"New Visitor Access",visitors:[{firstName:e.visitorFirstName||"",lastName:e.visitorLastName||"",email:e.visitorEmail||"",phone:e.visitorPhone||""}],escortFirstName:e.escortFirstName||"",escortLastName:e.escortLastName||"",startDate:e.visitStartDate,endDate:e.visitEndDate,representingCompany:e.representingCompany||"-",notes:e.description||"-",sitesDetails:await jn((t=e.site)!==null&&t!==void 0?t:"-",(i=e.accountNumber)!==null&&i!==void 0?i:"-",(s=e.locations)!==null&&s!==void 0?s:[],!0,{firstName:e.visitorHostFirstName,lastName:e.visitorHostLastName},a),hostFirstName:e.visitorHostFirstName,hostLastName:e.visitorHostLastName,cancellationReason:e.cancellationReason,visitorBadge:o,isEscortedVisitor:n,isFileAttachedForVisitors:!1,isNotificationsAttachmentsValid:!0,isRequestedAccessDetailsValid:!0,isVisitorContactsDetailsValid:!0,isVisitorEscortedDetailsValid:!0}},Jn=e=>{const{visitorFirstName:t,visitorLastName:i,visitorEmailAddress:s,visitorPhoneNumber:n}=e;if(!t||!i||!s)return"Error: First name, last name and email are required.";const o=!Cn(s),a=n&&n.length>0&&!ha(n);if(o&&a)return"Error: Invalid visitor email address and phone number";if(o)return"Error: Invalid visitor email address";if(a)return"Error: Invalid visitor phone number"};async function Bp(e){const[t,i]=await Promise.all([Ze({locationType:F.Site,permissionType:S.VisitorAccess,permissionPrivilege:e}),Ze({locationType:Ct,permissionType:S.VisitorAccess,permissionPrivilege:e,assignableProcess:"Facilities_access"})]),s=new Set(i.map(n=>n.siteId));return t.sort((n,o)=>n.siteId>o.siteId?1:-1).map(n=>({...n,hasSpaces:s.has(n.siteId)}))}const ce={newTicket:{isRequestedAccessDetailsValid:!1,isVisitorContactsDetailsValid:!1,isVisitorEscortedDetailsValid:!1,isNotificationsAttachmentsValid:!1,isRepresentingCompanyValid:!1,accountNumber:void 0,visitors:[],contacts:"",attachments:[],isEscortedVisitor:!1,startDate:void 0,endDate:void 0,sitesDetails:void 0,visitorBadge:"Standard"},selectedTicket:void 0,submissionResult:{state:w.Default,ticketNumbers:[],ticketResponse:void 0},loadings:{isSubmitting:!1,facilityAccessTicket:!1},isEditAttachmentAdded:!1};class Op{constructor(){this.DuplicateEmailErrorMessage="Each visitor must have a unique email address.",this.newTicket=ce.newTicket,this.submissionResult=ce.submissionResult,this.selectedTicket=ce.selectedTicket,this.loadings=ce.loadings,this.isEditAttachmentAdded=ce.isEditAttachmentAdded,se(this)}createTicket(){var t,i;const s=(t=this.newTicket.accountNumber)!==null&&t!==void 0?t:ae.getUserAccount().accountNumber;this.newTicket={...ce.newTicket,accountNumber:s,requestType:"Visitor Access",category:"New Visitor Access",serviceBackend:(i=this.newTicket.serviceBackend)!==null&&i!==void 0?i:void 0},this.submissionResult=ce.submissionResult}isVisitorContactsValid(t){this.newTicket.isVisitorContactsDetailsValid=t}isEscortedDetailsValid(t){this.newTicket.isVisitorEscortedDetailsValid=t}get isVisitorHostDetailsValid(){var t;return((t=this.newTicket.sitesDetails)===null||t===void 0?void 0:t.some(i=>i.isVisitorHostDetailsValid===!1))===!1}isVisitorHostDetailsValidBySite(t,i){var s;const n=(s=this.newTicket.sitesDetails)===null||s===void 0?void 0:s.find(o=>o.site.siteId===t);n&&(n.isVisitorHostDetailsValid=i)}isRequestedAccessDetailsValid(t){this.newTicket.isRequestedAccessDetailsValid=t}isNotificationsAttachmentsValid(t){this.newTicket.isNotificationsAttachmentsValid=t}isRepresentingCompanyValid(t){this.newTicket.isRepresentingCompanyValid=t}updateTermsAgreed(t){this.newTicket.termsAgreed=t}updateAttachments(t){var i;(i=this.newTicket.attachments)===null||i===void 0||i.push(...t)}removeBulkAttachment(){var t;this.newTicket.attachments=(t=this.newTicket.attachments)===null||t===void 0?void 0:t.filter(i=>{var s;return!(!((s=i.fileName)===null||s===void 0)&&s.startsWith($i))})}get isNewTicketValid(){return this.newTicket.isVisitorContactsDetailsValid&&this.newTicket.isVisitorEscortedDetailsValid&&this.isVisitorHostDetailsValid&&this.newTicket.isRequestedAccessDetailsValid&&this.newTicket.isRepresentingCompanyValid&&this.newTicket.isNotificationsAttachmentsValid}updateIsEscortedVisitor(t){this.newTicket.isEscortedVisitor=t,t?this.newTicket.visitorBadge=void 0:(this.newTicket.escortFirstName=void 0,this.newTicket.escortLastName=void 0,this.newTicket.visitorBadge===void 0&&(this.newTicket.visitorBadge="Standard"))}updateVisitorHost(t,i){var s;const n=(s=this.newTicket.sitesDetails)===null||s===void 0?void 0:s.find(o=>o.site.siteId===t);n&&(n.visitorHost=i,n.isVisitorHostDetailsValid=!0)}updateEscortFirstName(t){this.newTicket.escortFirstName=t}updateEscortLastName(t){this.newTicket.escortLastName=t}updateIsFileAttachedForVisitors(t){this.newTicket.isFileAttachedForVisitors=t}validateNoDuplicateEmails(t){const i=[...t];i.forEach((n,o)=>{n.validationError===this.DuplicateEmailErrorMessage&&(i[o]={...n,validationError:void 0,isValid:!0})});const s=i.filter(n=>!n.validationError);return i.forEach((n,o)=>{n.validationError||s.filter(a=>a.email.toLowerCase()===n.email.toLowerCase()).length>1&&(i[o]={...n,validationError:this.DuplicateEmailErrorMessage,isValid:!1})}),i}addOrUpdateVisitor(t){var i;if(!t)return;const s=(i=this.newTicket.visitors)!==null&&i!==void 0?i:[],n=s.findIndex(a=>a.id===t.id),o=n!==-1;if(!(!o&&s.length>=zn))if(this.newTicket.id)this.newTicket.visitors=[t];else{let a;t.isUploadedFromFile&&(a=Jn({visitorFirstName:t.firstName,visitorLastName:t.lastName,visitorEmailAddress:t.email,visitorPhoneNumber:t.phone}));const r={...t,validationError:a,isValid:!a},d=[...s];o?d[n]=r:d.push(r),this.newTicket.visitors=this.validateNoDuplicateEmails(d)}}addBulkVisitors(t){t.forEach(i=>{const s=Jn(i),n={id:crypto.randomUUID(),firstName:i.visitorFirstName,lastName:i.visitorLastName,email:i.visitorEmailAddress,phone:i.visitorPhoneNumber,isUploadedFromFile:!0,validationError:s,isValid:!s};this.addOrUpdateVisitor(n)})}removeBulkVisitors(){var t;const i=((t=this.newTicket.visitors)!==null&&t!==void 0?t:[]).filter(s=>s.isUploadedFromFile!==!0);this.newTicket.visitors=[...i]}removeVisitor(t){var i;if(t){const s=((i=this.newTicket.visitors)!==null&&i!==void 0?i:[]).filter(n=>n.id!==t.id);this.newTicket.visitors=this.validateNoDuplicateEmails(s)}}removeAllVisitors(){this.newTicket.visitors=[]}updateHostFirstName(t){this.newTicket.hostFirstName=t}updateHostLastName(t){this.newTicket.hostLastName=t}updateVisitorBadge(t){this.newTicket.visitorBadge=t}updateStartDate(t){var i;this.newTicket.startDate=t,(i=this.newTicket.sitesDetails)===null||i===void 0||i.forEach(s=>{s.locations.forEach(n=>{n.startDate=t})})}updateEndDate(t){var i;this.newTicket.endDate=t,(i=this.newTicket.sitesDetails)===null||i===void 0||i.forEach(s=>{s.locations.forEach(n=>{n.endDate=t})})}updateRepresentingCompany(t){this.newTicket.representingCompany=t}updateNotes(t){this.newTicket.notes=t}async addSiteLocations(t){var i;if(t){const s=await K.getServiceBackend(t.site.accountNumber,t.site.siteId,"Facilities_access"),n=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(a=>a.site.siteId!==t.site.siteId),o={...t,serviceBackend:s};this.newTicket.sitesDetails=[...n,o]}}removeSiteLocations(t){var i;if(t){const s=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(n=>n.site.siteId!==t.site.siteId);this.newTicket.sitesDetails=[...s]}}updateContacts(t){this.newTicket.contacts=t}async submitNewTicketRequest(){var t,i,s,n;let o;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{o=await l.facilityAccessApi.visitorAccess.createVisitorAccessTicket({visitorAccessTicketRequest:qp(this.newTicket)}),this.submissionResult.ticketNumbers=o==null?void 0:o.ticketNumbers}catch(a){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await m(a,!1),a}try{if(o){k.failedAttachments=((t=this.newTicket.attachments)!==null&&t!==void 0?t:[]).map(u=>u.fileName);const{ticketNumbers:a}=o,r=(i=a==null?void 0:a.filter(u=>_p(u)))!==null&&i!==void 0?i:[],d=(s=a==null?void 0:a.filter(u=>mt(u)))!==null&&s!==void 0?s:[];a!=null&&a.length&&!((n=this.newTicket.attachments)===null||n===void 0)&&n.length&&await Promise.all(this.newTicket.attachments.map(async u=>{const p=[];let A=[];u.fileName.startsWith($i)?(r.length>0&&A.push(r[0]),d.length>0&&A.push(...d)):A=a,p.push(...A.map(async N=>Pt(y.FacilityAccess,u.file,u.fileName,u.fileType,N,this.newTicket.requestType))),await Promise.all(p).then(()=>{var N;k.failedAttachments=((N=this.newTicket.attachments)!==null&&N!==void 0?N:[]).filter(b=>b.fileName!==u.fileName).map(b=>b.fileName)})})),this.newTicket.attachments=void 0}}catch(a){throw k.error.uploadingAttachments=!0,await m(a,!1),a}finally{this.submissionResult.state=w.Submitted,this.loadings.isSubmitting=!1}}async setNewTicket(){try{this.newTicket=await Dp(this.submissionResult.ticketResponse)||ce.newTicket}catch(t){throw await m(t,!1),t}}async submitUpdateTicketRequest(){let t;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{t=await l.facilityAccessApi.visitorAccess.updateVisitorAccessTicket({visitorAccessTicketUpdateRequest:Np(this.newTicket),ticketId:this.newTicket.id}),this.submissionResult.ticketResponse=t,this.submissionResult.state=w.Submitted,this.submissionResult.ticketNumbers=[t.id]}catch(i){this.submissionResult.state=w.Error,await m(i,!1)}try{await k.postAttachments(y.FacilityAccess,this.newTicket.attachments,this.newTicket.id,!0,"Visitor Access"),this.newTicket.attachments=void 0}catch(i){await m(i,!1)}try{t&&(this.selectedTicket=await Mn(t),await this.setNewTicket())}catch(i){await m(i,!1)}}catch(i){throw await m(i,!1),i}finally{this.loadings.isSubmitting=!1}}async getVisitorAccessServiceTicket(t){if(t)try{const i=await l.facilityAccessApi.visitorAccess.getVisitorAccessTicketById({ticketId:t});this.submissionResult.ticketResponse=i,this.selectedTicket=await Mn(i),await this.setNewTicket()}catch(i){throw await m(i,!1),i}}async cancelTicket(t,i){try{k.loadings.isTicketCancelling=!0,k.error.cancellingTicket=!1,t&&(await l.facilityAccessApi.visitorAccess.cancellationVisitorAccessRequest({ticketId:t,cancellationTicketsRequest:{cancellationReason:i}}).catch(s=>{throw m(s,!1),s}),await this.getVisitorAccessServiceTicket(t))}catch(s){throw k.error.cancellingTicket=!0,await m(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}async hasUpdatePermissions(){try{return!!await Ke(this.selectedTicket.sitesDetails[0].locations.map(t=>t.id),S.VisitorAccess,U.Update)}catch(t){return!1}}clearNewTicket(){this.newTicket=ce.newTicket}async patchLocationsApprovalStatus(t){var i,s;const n=t.map(o=>({id:o.id,approvalStatus:us[o.status]}));await l.facilityAccessApi.visitorAccess.updateVisitorAccessLocationsTicket({ticketId:((i=this.selectedTicket)===null||i===void 0?void 0:i.id)||"",locationsPatchRequestInner:n}),await this.getVisitorAccessServiceTicket((s=this.selectedTicket)===null||s===void 0?void 0:s.id)}async getVisitorHosts(t,i,s,n=1,o=10){return await l.facilityAccessApi.visitorHost.getVisitorHostsList({site:t,nameOrEmailContains:i,pageNumber:n,pageSize:o},s).catch(r=>{var d;!((d=s==null?void 0:s.signal)===null||d===void 0)&&d.aborted||m(r,!1)})||{items:[],totalCount:0}}clear(){this.newTicket=ce.newTicket,this.selectedTicket=ce.selectedTicket,this.submissionResult=ce.submissionResult,this.loadings=ce.loadings,this.isEditAttachmentAdded=ce.isEditAttachmentAdded}}const ie=new Op;function $p(e){return e.flatMap(t=>t.locations).map(t=>({id:t.id,startDate:Z(t.startDate),endDate:Z(t.endDate)}))}function Ep(e){return e.flatMap(t=>t.locations).map(t=>({id:t.id,startDate:Z(t.startDate),endDate:Z(t.endDate),operation:"add"}))}const xp=e=>{var t;return{accountNumber:(t=e.accountNumber)!==null&&t!==void 0?t:"",badgeholderFirstName:e.badgeHolder.firstName,badgeholderLastName:e.badgeHolder.lastName,badgeholderEmail:e.badgeHolder.email,badgeholderCompany:e.badgeHolder.company,badgeholderPhone:e.badgeHolder.phone,badgeStartDate:Z(e.startDate),badgeEndDate:Z(e.endDate),locations:$p(e.sitesDetails||[]),notificationRecipients:e.contacts}},Fp=e=>({otherNotificationRecipients:e.contacts}),Lp=e=>({otherNotificationRecipients:e.contacts}),Vp=()=>({}),Up=e=>{var t;return{accountNumber:(t=e.accountNumber)!==null&&t!==void 0?t:"",badgeholderId:e.badgeHolder.id,badgeStartDate:Z(e.startDate),badgeEndDate:Z(e.endDate),locations:Ep(e.sitesDetails||[]),notificationRecipients:e.contacts}},Hp=e=>({badgeholderId:e.badgeHolder.id,accountNumber:e.badgeHolder.accountNumber,badgeEndDate:Z(e.endDate)});async function Wn(e,t=""){if(!e)return[];const i=e.map(a=>({id:a.id||"-",site:a.site||"",siteAddress:a.siteAddress,startDate:a.startDate||"",endDate:a.endDate||"",status:a.approvalStatus||"-",modifiedBy:a.modifiedBy||"-"})),s=[...new Set(i.map(a=>a.site))],n={};await Promise.all(s.map(async a=>{var r;n[a]=(r=await vm(a))!==null&&r!==void 0?r:a}));const o=[];return i.forEach(a=>{const{site:r}=a,d=o.find(u=>u.site.siteId===r);d?d.locations.push(a):o.push({site:new Oe(n[r],r,t),locations:[a]})}),o}const Gn=async e=>{var t,i,s;if(e)return{id:e==null?void 0:e.id,accountNumber:e.accountNumber||"-",accountName:e.accountName||"-",contacts:e.notificationRecipients||"",state:e.status||"-",requester:e.createdBy||"-",createdOn:(t=e.createdAt)===null||t===void 0?void 0:t.toISOString(),updatedOn:(i=e.updatedAt)===null||i===void 0?void 0:i.toISOString(),requestType:"Permanent Badge",category:e.requestType,visitors:[{firstName:e.badgeholderFirstName||"-",lastName:e.badgeholderLastName||"-",email:e.badgeholderEmail||"-",phone:e.badgeholderPhone,company:e.badgeholderCompany||"-"}],startDate:e.badgeStartDate,endDate:e.badgeEndDate,sitesDetails:await Wn(e.locations,e.accountNumber),cancellationReason:e.cancellationReason,comments:(s=e.comments)===null||s===void 0?void 0:s.map(n=>M(n))}},zp=async e=>{if(e)return{id:e==null?void 0:e.id,contacts:e.notificationRecipients,requestType:"Permanent Badge",category:e.requestType,visitors:[{firstName:e.badgeholderFirstName||"",lastName:e.badgeholderLastName||"",email:e.badgeholderEmail||"",phone:e.badgeholderPhone||"",company:e.badgeholderCompany||""}],badgeHolder:{firstName:e.badgeholderFirstName||"",lastName:e.badgeholderLastName||"",email:e.badgeholderEmail||"",phone:e.badgeholderPhone||"",company:e.badgeholderCompany||""},startDate:e.badgeStartDate,endDate:e.badgeEndDate,sitesDetails:await Wn(e.locations,e.accountNumber),isNotificationsAttachmentsValid:!0,isRequestedAccessDetailsValid:!0,isVisitorContactsDetailsValid:!0,isEndDateValid:!0,isBadgeholderValid:!0}},jp=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),Zn=e=>e.map(t=>({id:t.id,accountNumber:t.accountNumber,firstName:t.firstName,lastName:t.lastName,email:t.email,phone:t.phone,company:t.representingCompany,startDate:t.badgeStartDate?St(t.badgeStartDate):void 0})),Mp=(e,t)=>[...e,...Zn(t)];async function Jp(e){const[t,i]=await Promise.all([Ze({locationType:F.Site,permissionType:S.PermanentBadge,permissionPrivilege:e}),Ze({locationType:Ct,permissionType:S.PermanentBadge,permissionPrivilege:e,assignableProcess:"Facilities_access"})]),s=new Set(i.map(n=>n.siteId));return t.sort((n,o)=>n.siteId>o.siteId?1:-1).map(n=>({...n,hasSpaces:s.has(n.siteId)}))}const de={newTicket:{isRequestedAccessDetailsValid:!1,isNotificationsAttachmentsValid:!1,isBadgeholderValid:!1,isStartDateSetViaBadgeHolder:!1,isEndDateValid:!1,accountNumber:void 0,contacts:"",badgeHolder:{},attachments:[],isVisitorContactsDetailsValid:!1,visitors:[]},selectedTicket:void 0,submissionResult:{state:w.Default,ticketNumbers:[],ticketResponse:void 0},loadings:{isSubmitting:!1,facilityAccessTicket:!1},isEditAttachmentAdded:!1};class Wp{constructor(){this.newTicket=de.newTicket,this.submissionResult=de.submissionResult,this.selectedTicket=de.selectedTicket,this.loadings=de.loadings,this.isEditAttachmentAdded=de.isEditAttachmentAdded,se(this)}createTicket(){var t,i,s,n;const o=(t=this.newTicket.accountNumber)!==null&&t!==void 0?t:ae.getUserAccount().accountNumber;this.newTicket={...de.newTicket,accountNumber:o,requestType:(i=this.newTicket.requestType)!==null&&i!==void 0?i:void 0,category:(s=this.newTicket.category)!==null&&s!==void 0?s:void 0,serviceBackend:(n=this.newTicket.serviceBackend)!==null&&n!==void 0?n:void 0},this.submissionResult=de.submissionResult}updateStartDateSetViaBadgeholder(t){this.newTicket.isStartDateSetViaBadgeHolder=t}isVisitorContactsValid(t){this.newTicket.isVisitorContactsDetailsValid=t}isRequestedAccessDetailsValid(t){this.newTicket.isRequestedAccessDetailsValid=t}isBadgeholderValid(t){this.newTicket.isBadgeholderValid=t}isNotificationsAttachmentsValid(t){this.newTicket.isNotificationsAttachmentsValid=t}isEndDateValid(t){this.newTicket.isEndDateValid=t}updateTermsAgreed(t){this.newTicket.termsAgreed=t}updateAttachments(t){var i;(i=this.newTicket.attachments)===null||i===void 0||i.push(...t)}removeBulkAttachment(){throw new Error("Method not implemented.")}get isNewTicketValid(){switch(this.newTicket.category){case"New":return this.newTicket.isVisitorContactsDetailsValid&&this.newTicket.isRequestedAccessDetailsValid&&this.newTicket.isNotificationsAttachmentsValid;case"Modify":return this.newTicket.isBadgeholderValid&&this.newTicket.isRequestedAccessDetailsValid&&this.newTicket.isNotificationsAttachmentsValid;case"Terminate":return this.newTicket.isBadgeholderValid&&this.newTicket.isEndDateValid;default:return!1}}setBadgeHolder(t){this.newTicket.badgeHolder=t,t===void 0?this.newTicket.visitors=[]:this.newTicket.visitors=[{id:t.id,firstName:t.firstName,lastName:t.lastName,email:t.email,phone:t.phone,company:t.company}]}addOrUpdateVisitor(t){t&&this.setBadgeHolder(t)}addBulkVisitors(t){throw new Error("Method not implemented.")}removeBulkVisitors(){throw new Error("Method not implemented.")}removeVisitor(t){this.setBadgeHolder(void 0)}removeAllVisitors(){this.newTicket.visitors=[]}clearStartDate(){this.newTicket.startDate=void 0}updateStartDate(t){var i;this.newTicket.startDate=t,(i=this.newTicket.sitesDetails)===null||i===void 0||i.forEach(s=>{s.locations.forEach(n=>{n.startDate=t})})}updateEndDate(t){var i;this.newTicket.endDate=t,(i=this.newTicket.sitesDetails)===null||i===void 0||i.forEach(s=>{s.locations.forEach(n=>{n.endDate=t})})}async addSiteLocations(t){var i;if(t){const s=await K.getServiceBackend(t.site.accountNumber,t.site.siteId,"Facilities_access"),n=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(a=>a.site.siteId!==t.site.siteId),o={...t,serviceBackend:s};this.newTicket.sitesDetails=[...n,o]}}removeSiteLocations(t){var i;if(t){const s=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(n=>n.site.siteId!==t.site.siteId);this.newTicket.sitesDetails=[...s]}}updateContacts(t){this.newTicket.contacts=t}async submitNewTicketRequest(){var t,i;let s;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{switch(this.newTicket.category){case"New":s=await l.facilityAccessApi.permanentBadgeAccess.createPermanentBadgeNewTicket({permanentBadgeAccessNewTicketRequest:xp(this.newTicket)});break;case"Modify":s=await l.facilityAccessApi.permanentBadgeAccess.createPermanentBadgeModifyTicket({permanentBadgeAccessModifyTicketRequest:Up(this.newTicket)});break;case"Terminate":s=await l.facilityAccessApi.permanentBadgeAccess.createPermanentBadgeTerminateTicket({permanentBadgeAccessTerminateTicketRequest:Hp(this.newTicket)});break;default:throw new Error("Invalid category")}this.submissionResult.ticketNumbers=s==null?void 0:s.ticketNumbers}catch(n){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await m(n,!1),n}try{if(s){k.failedAttachments=((t=this.newTicket.attachments)!==null&&t!==void 0?t:[]).map(o=>o.fileName);const{ticketNumbers:n}=s;n!=null&&n.length&&!((i=this.newTicket.attachments)===null||i===void 0)&&i.length&&await Promise.all(this.newTicket.attachments.map(async o=>Promise.all(n.map(async a=>Pt(y.FacilityAccess,o.file,o.fileName,o.fileType,a,this.newTicket.requestType))).then(()=>{var a;k.failedAttachments=((a=this.newTicket.attachments)!==null&&a!==void 0?a:[]).filter(r=>r.fileName!==o.fileName).map(r=>r.fileName)}))),this.newTicket.attachments=void 0}}catch(n){throw k.error.uploadingAttachments=!0,await m(n,!1),n}finally{this.submissionResult.state=w.Submitted,this.loadings.isSubmitting=!1}}mapPermanentBadgeTicketToUpdateRequest(){switch(this.newTicket.category){case"Modify":return Lp(this.newTicket);case"New":return Fp(this.newTicket);case"Terminate":return Vp();default:throw new Error("Invalid category")}}async setNewTicket(){try{this.newTicket=await zp(this.submissionResult.ticketResponse)||de.newTicket}catch(t){throw await m(t,!1),t}}async submitUpdateTicketRequest(){var t;let i;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{i=await((t=l.facilityAccessApi.permanentBadgeAccess)===null||t===void 0?void 0:t.updatePermanentBadgeTicket({permanentBadgeAccessTicketUpdateRequest:this.mapPermanentBadgeTicketToUpdateRequest(),ticketId:this.newTicket.id})),this.submissionResult.ticketResponse=i,this.submissionResult.state=w.Submitted,this.submissionResult.ticketNumbers=[i.id]}catch(s){await m(s,!1)}try{await k.postAttachments(y.FacilityAccess,this.newTicket.attachments,this.newTicket.id,!0,"Permanent Badge"),this.newTicket.attachments=void 0}catch(s){await m(s,!1)}try{i&&(this.selectedTicket=await Gn(i),await this.setNewTicket())}catch(s){await m(s,!1)}}catch(s){throw await m(s,!1),this.submissionResult.state=w.Error,s}finally{this.loadings.isSubmitting=!1}}async getPermanentBadgeAccessServiceTicket(t){if(t)try{const i=await l.facilityAccessApi.permanentBadgeAccess.getPermanentBadgeTicketById({ticketId:t});this.submissionResult.ticketResponse=i,this.selectedTicket=await Gn(i),await this.setNewTicket()}catch(i){throw await m(i,!1),i}}async cancelTicket(t,i){try{k.loadings.isTicketCancelling=!0,k.error.cancellingTicket=!1,t&&(await l.facilityAccessApi.permanentBadgeAccess.cancellationPermanentBadgeRequest({ticketId:t,cancellationTicketsRequest:{cancellationReason:i}}).catch(s=>{throw m(s,!1),s}),await this.getPermanentBadgeAccessServiceTicket(t))}catch(s){throw k.error.cancellingTicket=!0,await m(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}async hasUpdatePermissions(){try{return!!await Ke(this.selectedTicket.sitesDetails[0].locations.map(t=>t.id),S.PermanentBadge,U.Update)}catch(t){return!1}}async getAttachments(t,i){return Hn(y.FacilityAccess,t,i)}async getPermanentBadgeHolders(t,i,s=1,n=10){return await l.facilityAccessApi.permanentBadgeAccess.getPermanentBadgeHoldersList({accountNumber:this.newTicket.accountNumber,activeBadge:!0,nameOrEmailContains:t,page:s,size:n},i).catch(a=>{var r;!((r=i==null?void 0:i.signal)===null||r===void 0)&&r.aborted||m(a,!0)})||{items:[],totalCount:0}}clearNewTicket(){this.newTicket=de.newTicket}async patchLocationsApprovalStatus(t){var i,s,n;const o=t.map(a=>({id:a.id,approvalStatus:us[a.status]}));await((i=l.facilityAccessApi.permanentBadgeAccess)===null||i===void 0?void 0:i.updatePermanentBadgeLocationsTicket({ticketId:((s=this.selectedTicket)===null||s===void 0?void 0:s.id)||"",locationsPatchRequestInner:o}).catch(a=>{m(a,!1)})),await this.getPermanentBadgeAccessServiceTicket((n=this.selectedTicket)===null||n===void 0?void 0:n.id).catch(a=>{m(a,!1)})}clear(){this.newTicket=de.newTicket,this.selectedTicket=de.selectedTicket,this.submissionResult=de.submissionResult,this.loadings=de.loadings,this.isEditAttachmentAdded=de.isEditAttachmentAdded}}const Y=new Wp;function Gp(e){return e.flatMap(t=>t.locations.map(i=>({id:i.id,startDateTime:Be(i.startDate,i.startTime,t.site.siteId),endDateTime:Be(i.endDate,i.endTime,t.site.siteId)})))}async function Kn(e){var t,i,s;const{timeZone:n,id:o}=((t=J.sites)===null||t===void 0?void 0:t.find(d=>d.locationId===e.site))||{},a=o?await An(o):[],r=new Map(a.map(d=>{var u;return[d.id,(u=d.name)!==null&&u!==void 0?u:d.id]}));return[{site:new Oe(e.site,o,e.accountNumber),locations:(s=(i=e.locations)===null||i===void 0?void 0:i.map(d=>{var u,p,A,N;return{id:d.id,name:r.get(d.id)||d.id,site:o,startDate:d.startDateTime&&n?(u=G(d.startDateTime).tz(n))===null||u===void 0?void 0:u.format(ct):"-",startTime:d.startDateTime&&n?(p=G(d.startDateTime).tz(n))===null||p===void 0?void 0:p.format($t):"-",endDate:d.endDateTime&&n?(A=G(d.endDateTime).tz(n))===null||A===void 0?void 0:A.format(ct):"-",endTime:d.endDateTime&&n?(N=G(d.endDateTime).tz(n))===null||N===void 0?void 0:N.format($t):"-"}}))!==null&&s!==void 0?s:[]}]}async function Zp(e){const[t,i]=await Promise.all([Ze({locationType:F.Site,permissionType:S.OSPAccess,permissionPrivilege:e}),Ze({locationType:ut.GreaterThan+F.Site,permissionType:S.OSPAccess,permissionPrivilege:e,assignableProcess:"OSP_access"})]),s=new Set(i.map(n=>n.siteId));return t.sort((n,o)=>n.siteId>o.siteId?1:-1).map(n=>({...n,hasSpaces:s.has(n.siteId),accountNumber:n.accountNumber}))}const Kp=e=>({accountNumber:e.accountNumber,visitors:e.visitors.map(t=>({firstName:t.firstName,lastName:t.lastName,email:t.email,company:t.company,phone:t.phone,visitorType:t.visitorType})),locations:Gp(e.sitesDetails||[]),escortFirstName:e.escortFirstName,escortLastName:e.escortLastName,visitorHostFirstName:e.hostFirstName,visitorHostLastName:e.hostLastName,customerExternalReference:e.customerExternalReference,serviceImpactedDescription:e.serviceImpactDescription,workDescription:e.workDescription,notificationRecipients:e.contacts}),ue=(e,t)=>e===t||!e&&!t||!e&&t==="-",Yp=(e,t)=>{var i,s;const n={};ue(e.visitors[0].phone,t.visitors[0].phone)||(n.visitorPhone=e.visitors[0].phone),ue(e.visitors[0].company,t.visitors[0].company)||(n.visitorCompany=e.visitors[0].company),(!ue(e.escortFirstName,t.escortFirstName)||!ue(e.escortLastName,t.escortLastName))&&(n.escortFirstName=e.escortFirstName,n.escortLastName=e.escortLastName),(!ue(e.hostFirstName,t.visitorHostFirstName)||!ue(e.hostLastName,t.visitorHostLastName))&&(n.visitorHostFirstName=e.hostFirstName,n.visitorHostLastName=e.hostLastName),ue(e.customerExternalReference,t.customerExternalReference)||(n.customerExternalReference=e.customerExternalReference),ue(e.serviceImpactDescription,t.serviceImpactDescription)||(n.serviceImpactedDescription=e.serviceImpactDescription),ue(e.workDescription,t.workDescription)||(n.workDescription=e.workDescription),ue(e.contacts,t.notificationRecipients)||(n.otherNotificationRecipients=e.contacts);const o=((i=e.sitesDetails)===null||i===void 0?void 0:i.flatMap(d=>d.locations))||[],a=((s=t.sitesDetails)===null||s===void 0?void 0:s.flatMap(d=>d.locations))||[],r=o.map(d=>{var u,p;const A=a.find(b=>b.id===d.id),N={id:d.id};return(!A||!ue(d.startDate,A.startDate)||!ue(d.startTime,A.startTime))&&(N.startDateTime=Be(d.startDate,d.startTime,(u=e.sitesDetails)===null||u===void 0?void 0:u[0].site.siteId)),(!A||!ue(d.endDate,A.endDate)||!ue(d.endTime,A.endTime))&&(N.endDateTime=Be(d.endDate,d.endTime,(p=e.sitesDetails)===null||p===void 0?void 0:p[0].site.siteId)),N}).filter(d=>d.startDateTime||d.endDateTime);return r.length&&(n.locations=r),Object.keys(n).length===0&&(n.visitorCompany=e.visitors[0].company),n},Yn=async e=>{var t;return{id:e.id||"-",state:e.status||"-",requester:e.createdBy||"-",createdOn:e.createdAt||"-",updatedOn:e.updatedAt||"-",requestType:"OSP Access",visitors:[{firstName:e.visitorFirstName||"-",lastName:e.visitorLastName||"-",email:e.visitorEmail||"-",phone:e.visitorPhone||"-",company:e.visitorCompany||"-",visitorType:e.visitorType}],visitorType:e.visitorType||"-",escortFirstName:e.escortFirstName||"-",escortLastName:e.escortLastName||"-",visitorHostFirstName:e.visitorHostFirstName||"-",visitorHostLastName:e.visitorHostLastName||"-",site:e.site||"-",sitesDetails:await Kn(e),customerExternalReference:e.customerExternalReference||"-",serviceImpacted:e.serviceImpactedDescription?"Yes":"No",serviceImpactDescription:e.serviceImpactedDescription||"-",workDescription:e.workDescription||"-",notificationRecipients:e.notificationRecipients||"",cancellationReason:e.cancellationReason||"-",comments:(t=e.comments)===null||t===void 0?void 0:t.map(i=>M(i))}},Xp=async e=>{var t,i,s,n,o;if(e)return{isVisitorContactsDetailsValid:!0,isVisitorEscortedDetailsValid:!0,isVisitorHostValid:!0,isRequestedAccessDetailsValid:!0,isServiceImpactedSectionValid:!0,isNotificationsAttachmentsValid:!0,accountNumber:(t=e.accountNumber)!==null&&t!==void 0?t:"",status:e.status,requestType:"OSP Access",category:"",visitors:[{firstName:(i=e.visitorFirstName)!==null&&i!==void 0?i:"",lastName:(s=e.visitorLastName)!==null&&s!==void 0?s:"",email:(n=e.visitorEmail)!==null&&n!==void 0?n:"",company:e.visitorCompany,phone:(o=e.visitorPhone)!==null&&o!==void 0?o:"",visitorType:e.visitorType}],isEscortedVisitor:!0,escortFirstName:e.escortFirstName,escortLastName:e.escortLastName,hostFirstName:e.visitorHostFirstName,hostLastName:e.visitorHostLastName,visitorBadge:"Standard",sitesDetails:await Kn(e),contacts:e.notificationRecipients,customerExternalReference:e.customerExternalReference,isServiceImpacted:!!e.serviceImpactedDescription,serviceImpactDescription:e.serviceImpactedDescription,workDescription:e.workDescription,termsAgreed:!0,id:e.id,attachments:[]}},Qp=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),me={newTicket:{isVisitorContactsDetailsValid:!1,isVisitorEscortedDetailsValid:!1,isVisitorHostValid:!1,isRequestedAccessDetailsValid:!1,isServiceImpactedSectionValid:!1,isNotificationsAttachmentsValid:!1,accountNumber:"",visitors:[],contacts:"",attachments:[],startDate:void 0,endDate:void 0,sitesDetails:void 0,visitorBadge:"Standard",serviceType:void 0,isEscortedVisitor:!0,escortFirstName:void 0,escortLastName:void 0,hostCompany:void 0,hostFirstName:void 0,hostLastName:void 0},selectedTicket:void 0,submissionResult:{state:w.Default,ticketNumbers:[],ticketResponse:void 0},loadings:{isSubmitting:!1,facilityAccessTicket:!1},isEditAttachmentAdded:!1};class Xn{constructor(){this.newTicket=me.newTicket,this.submissionResult=me.submissionResult,this.selectedTicket=me.selectedTicket,this.loadings=me.loadings,this.isEditAttachmentAdded=me.isEditAttachmentAdded,se(this)}async setNewTicket(){var t;try{this.newTicket=(t=await Xp(this.submissionResult.ticketResponse))!==null&&t!==void 0?t:me.newTicket}catch(i){throw await m(i,!1),i}}async getOSPAccessServiceTicket(t){if(t)try{const i=await l.facilityAccessApi.ospAccess.getOspAccessTicketById({ticketId:t});this.submissionResult.ticketResponse=i,this.selectedTicket=await Yn(i),await this.setNewTicket()}catch(i){throw await m(i,!1),i}}createTicket(){var t;const i=(t=this.newTicket.accountNumber)!==null&&t!==void 0?t:ae.getUserAccount().accountNumber;this.newTicket={...me.newTicket,accountNumber:i,requestType:"OSP Access",category:""},this.submissionResult=me.submissionResult}isNotificationsAttachmentsValid(t){this.newTicket.isNotificationsAttachmentsValid=t}updateAttachments(t){var i;(i=this.newTicket.attachments)===null||i===void 0||i.push(...t)}updateIsEscortedVisitor(t){this.newTicket.isEscortedVisitor=t,t?this.newTicket.visitorBadge=void 0:(this.newTicket.escortFirstName=void 0,this.newTicket.escortLastName=void 0,this.newTicket.visitorBadge===void 0&&(this.newTicket.visitorBadge="Standard"))}updateVisitorHost(t,i){var s;const n=(s=this.newTicket.sitesDetails)===null||s===void 0?void 0:s.find(o=>o.site.siteId===t);n&&(n.visitorHost=i,n.isVisitorHostDetailsValid=!0)}updateEscortFirstName(t){this.newTicket.escortFirstName=t}updateEscortLastName(t){this.newTicket.escortLastName=t}addOrUpdateVisitor(t){var i;if(t)if(this.newTicket.id)this.newTicket.visitors=[t];else{const s=((i=this.newTicket.visitors)!==null&&i!==void 0?i:[]).filter(n=>n.id!==t.id);this.newTicket.visitors=[...s,t]}}removeVisitor(t){var i;if(t){const s=((i=this.newTicket.visitors)!==null&&i!==void 0?i:[]).filter(n=>n.id!==t.id);this.newTicket.visitors=[...s]}}updateHostFirstName(t){this.newTicket.hostFirstName=t}updateHostLastName(t){this.newTicket.hostLastName=t}updateVisitorBadge(t){this.newTicket.visitorBadge=t}updateTermsAgreed(t){this.newTicket.termsAgreed=t}async addSiteLocations(t){var i;if(t){const s=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(n=>n.site.siteId!==t.site.siteId);this.newTicket.sitesDetails=[...s,t]}}removeSiteLocations(t){var i;if(t){const s=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(n=>n.site.siteId!==t.site.siteId);this.newTicket.sitesDetails=[...s]}}updateContacts(t){this.newTicket.contacts=t}async submitNewTicketRequest(){var t,i;let s;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{s=await l.facilityAccessApi.ospAccess.createOspAccessTicket({oSPAccessTicketRequest:Kp(this.newTicket)}),this.submissionResult.ticketNumbers=s==null?void 0:s.ticketNumbers}catch(n){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await m(n,!1),n}try{if(s){k.failedAttachments=((t=this.newTicket.attachments)!==null&&t!==void 0?t:[]).map(o=>o.fileName);const{ticketNumbers:n}=s;n!=null&&n.length&&!((i=this.newTicket.attachments)===null||i===void 0)&&i.length&&await Promise.all(this.newTicket.attachments.map(async o=>Promise.all(n.map(async a=>Pt(y.FacilityAccess,o.file,o.fileName,o.fileType,a,this.newTicket.requestType))).then(()=>{var a;k.failedAttachments=((a=this.newTicket.attachments)!==null&&a!==void 0?a:[]).filter(r=>r.fileName!==o.fileName).map(r=>r.fileName)}))),this.newTicket.attachments=void 0}}catch(n){throw k.error.uploadingAttachments=!0,await m(n,!1),n}finally{this.submissionResult.state=w.Submitted,this.loadings.isSubmitting=!1}}async submitUpdateTicketRequest(){let t;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{t=await l.facilityAccessApi.ospAccess.updateOspAccessTicket({oSPAccessTicketUpdateRequest:Yp(this.newTicket,this.selectedTicket),ticketId:this.newTicket.id}),this.submissionResult.ticketResponse=t,this.submissionResult.state=w.Submitted,this.submissionResult.ticketNumbers=[t==null?void 0:t.id]}catch(i){this.submissionResult.state=w.Error,await m(i,!1)}try{await k.postAttachments(y.FacilityAccess,this.newTicket.attachments,this.newTicket.id,!0,"OSP Access"),this.newTicket.attachments=void 0}catch(i){await m(i,!1)}try{t&&(this.selectedTicket=await Yn(t))}catch(i){await m(i,!1)}}catch(i){throw await m(i,!1),i}finally{this.loadings.isSubmitting=!1}}updateFieldValue(t,i){this.newTicket[t]=i}isVisitorContactsValid(t){this.newTicket.isVisitorContactsDetailsValid=t}isEscortedDetailsValid(t){this.newTicket.isVisitorEscortedDetailsValid=t}isRequestedAccessDetailsValid(t){this.newTicket.isRequestedAccessDetailsValid=t}addBulkVisitors(t){throw new Error("Method not implemented.")}removeBulkVisitors(){throw new Error("Method not implemented.")}removeBulkAttachment(){throw new Error("Method not implemented.")}removeAllVisitors(){this.newTicket.visitors=[]}async hasUpdatePermissions(){var t;try{return await bn((t=this.selectedTicket)===null||t===void 0?void 0:t.site)}catch(i){return!1}}async cancelTicket(t){var i;try{k.loadings.isTicketCancelling=!0,!((i=this.selectedTicket)===null||i===void 0)&&i.id&&(await l.facilityAccessApi.ospAccess.cancellationOspAccessRequest({ticketId:this.selectedTicket.id,cancellationTicketsRequest:{cancellationReason:t}}),await this.getOSPAccessServiceTicket(this.selectedTicket.id))}catch(s){throw await m(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}get isNewTicketValid(){const t=this.newTicket.isVisitorContactsDetailsValid,i=this.newTicket.isVisitorEscortedDetailsValid,s=this.newTicket.isVisitorHostValid,n=this.newTicket.isRequestedAccessDetailsValid,o=this.newTicket.isServiceImpactedSectionValid,a=this.newTicket.isNotificationsAttachmentsValid;return t&&i&&s&&n&&o&&a}clear(){this.newTicket=me.newTicket,this.selectedTicket=me.selectedTicket,this.submissionResult=me.submissionResult,this.loadings=me.loadings,this.isEditAttachmentAdded=me.isEditAttachmentAdded}}const Se=new Xn;function eh(e){return e.flatMap(t=>t.locations.map(i=>({id:i.id,startDateTime:Be(i.startDate,i.startTime,t.site.siteId),endDateTime:Be(i.endDate,i.endTime,t.site.siteId)})))}async function Qn(e){var t,i,s,n;const{timeZone:o,id:a}=(i=(t=J.sites)===null||t===void 0?void 0:t.find(u=>u.locationId===e.site))!==null&&i!==void 0?i:{},r=a?await _n(a):[],d=new Map(r.map(u=>{var p;return[u.id,(p=u.name)!==null&&p!==void 0?p:u.id]}));return[{site:new Oe(e.site,a,e.accountNumber),locations:(n=(s=e.locations)===null||s===void 0?void 0:s.map(u=>{var p,A,N,b;return{id:u.id,name:d.get(u.id)||u.id,site:a,startDate:u.startDateTime&&o?(p=G(u.startDateTime).tz(o))===null||p===void 0?void 0:p.format(ct):"-",startTime:u.startDateTime&&o?(A=G(u.startDateTime).tz(o))===null||A===void 0?void 0:A.format($t):"-",endDate:u.endDateTime&&o?(N=G(u.endDateTime).tz(o))===null||N===void 0?void 0:N.format(ct):"-",endTime:u.endDateTime&&o?(b=G(u.endDateTime).tz(o))===null||b===void 0?void 0:b.format($t):"-"}}))!==null&&n!==void 0?n:[]}]}async function th(e){const[t,i]=await Promise.all([Ze({locationType:F.Site,permissionType:S.POPPOEAccess,permissionPrivilege:e}),Ze({locationType:ut.GreaterThan+F.Site,permissionType:S.POPPOEAccess,permissionPrivilege:e,assignableProcess:"POP_access"})]),s=new Set(i.map(n=>n.siteId));return t.sort((n,o)=>n.siteId>o.siteId?1:-1).map(n=>({...n,hasSpaces:s.has(n.siteId),accountNumber:n.accountNumber}))}const Ei=e=>{var t;return(t=e==null?void 0:e.map(i=>{var s,n,o,a,r,d,u,p,A,N,b,C;return{sideAName:(s=i.sideAName)!==null&&s!==void 0?s:"",sideARoomNumber:(n=i.sideARoomNumber)!==null&&n!==void 0?n:"",sideARackNumber:(o=i.sideARackNumber)!==null&&o!==void 0?o:"",sideAPanelNumber:(a=i.sideAPanelNumber)!==null&&a!==void 0?a:"",sideAPort1:(r=i.sideAPort)!==null&&r!==void 0?r:"",sideACarrierCircuitId:(d=i.sideACarrierCircuitID)!==null&&d!==void 0?d:"",sideBName:(u=i.sideZName)!==null&&u!==void 0?u:"",sideBRoomNumber:(p=i.sideZRoomNumber)!==null&&p!==void 0?p:"",sideBRackNumber:(A=i.sideZRackNumber)!==null&&A!==void 0?A:"",sideBPanelNumber:(N=i.sideZPanelNumber)!==null&&N!==void 0?N:"",sideBPort1:(b=i.sideZPort)!==null&&b!==void 0?b:"",sideBCarrierCircuitId:(C=i.sideZCarrierCircuitID)!==null&&C!==void 0?C:""}}))!==null&&t!==void 0?t:[]},ea=e=>!e||e.length===1&&!e[0].rack&&!e[0].cabinet?[]:e.map(t=>{var i,s;return{rack:(i=t.rack)!==null&&i!==void 0?i:"",cabinet:(s=t.cabinet)!==null&&s!==void 0?s:""}}),ih=e=>({accountNumber:e.accountNumber,visitors:e.visitors.map(t=>({firstName:t.firstName,lastName:t.lastName,email:t.email,company:t.company,phone:t.phone,visitorType:t.visitorType})),locations:eh(e.sitesDetails||[]),escortFirstName:e.escortFirstName,escortLastName:e.escortLastName,visitorHostFirstName:e.hostFirstName,visitorHostLastName:e.hostLastName,customerExternalReference:e.customerExternalReference,serviceImpactedDescription:e.serviceImpactDescription,serviceDetails:{serviceType:e.serviceType,scope:e.scope,circuits:Ei(e.circuits),workDescription:e.descriptionOfWork},ppopSpace:ea(e.ppopSpaces),spopSpace:ea(e.spopSpaces),ppopRoomWork:e.isPpopCableRunOutside?{ppopSpaceFrom:e.ppopFromRackPanel,ppopSpaceTo:e.ppopToRackPanel,cableType:e.ppopCableType,onLadderRack:e.ppopLadderRack,inInnerDuct:e.ppopInnerDuct,inFiberGuide:e.ppopFiberGuide}:void 0,spopRoomWork:e.isSpopCableRunOutside?{spopSpaceFrom:e.spopFromRackPanel,spopSpaceTo:e.spopToRackPanel,cableType:e.spopCableType,onLadderRack:e.spopLadderRack,inInnerDuct:e.spopInnerDuct,inFiberGuide:e.spopFiberGuide}:void 0,notificationRecipients:e.contacts}),ta=e=>(e==null?void 0:e.map(t=>({sideAName:t.sideAName||"-",sideARoomNumber:t.sideARoomNumber||"-",sideARackNumber:t.sideARackNumber||"-",sideAPanelNumber:t.sideAPanelNumber||"-",sideAPort:t.sideAPort1||"-",sideACarrierCircuitID:t.sideACarrierCircuitId||"-",sideZName:t.sideBName||"-",sideZRoomNumber:t.sideBRoomNumber||"-",sideZRackNumber:t.sideBRackNumber||"-",sideZPanelNumber:t.sideBPanelNumber||"-",sideZPort:t.sideBPort1||"-",sideZCarrierCircuitID:t.sideBCarrierCircuitId||"-"})))||[],ia=async e=>{var t,i,s,n,o,a,r,d,u,p,A,N,b,C,x,et,tt,it,st,nt,at;return{id:e.id||"-",state:e.status||"-",requester:e.createdBy||"-",createdOn:e.createdAt||"-",updatedOn:e.updatedAt||"-",requestType:"PoP/POE Access",visitors:[{firstName:e.visitorFirstName||"-",lastName:e.visitorLastName||"-",email:e.visitorEmail||"-",phone:e.visitorPhone||"-",company:e.visitorCompany||"-",visitorType:e.visitorType}],visitorType:e.visitorType||"-",escortFirstName:e.escortFirstName||"-",escortLastName:e.escortLastName||"-",visitorHostFirstName:e.visitorHostFirstName||"-",visitorHostLastName:e.visitorHostLastName||"-",visitorHostCompany:e.visitorHostCompany||"-",site:e.site||"-",sitesDetails:await Qn(e),customerExternalReference:e.customerExternalReference||"-",isServiceImpacted:!!e.serviceImpactedDescription,serviceImpactDescription:e.serviceImpactedDescription||"-",serviceType:((t=e.serviceDetails)===null||t===void 0?void 0:t.serviceType)||"-",scope:((i=e.serviceDetails)===null||i===void 0?void 0:i.scope)||"-",isCrossConnectPatchCableInstallationOrRemoval:!!(!((n=(s=e.serviceDetails)===null||s===void 0?void 0:s.circuits)===null||n===void 0)&&n.length),workDescription:((o=e.serviceDetails)===null||o===void 0?void 0:o.workDescription)||"-",circuits:ta((a=e.serviceDetails)===null||a===void 0?void 0:a.circuits),ppopSpaces:((r=e.ppopSpace)===null||r===void 0?void 0:r.map(ge=>({rack:ge.rack||"",cabinet:ge.cabinet||""})))||[],spopSpaces:((d=e.spopSpace)===null||d===void 0?void 0:d.map(ge=>({rack:ge.rack||"",cabinet:ge.cabinet||""})))||[],isPpopCableRunOutside:!!e.ppopRoomWork&&Object.keys(e.ppopRoomWork).length>0,ppopFromRackPanel:((u=e.ppopRoomWork)===null||u===void 0?void 0:u.ppopSpaceFrom)||"-",ppopToRackPanel:((p=e.ppopRoomWork)===null||p===void 0?void 0:p.ppopSpaceTo)||"-",ppopCableType:((A=e.ppopRoomWork)===null||A===void 0?void 0:A.cableType)||"-",ppopLadderRack:(N=e.ppopRoomWork)===null||N===void 0?void 0:N.onLadderRack,ppopInnerDuct:(b=e.ppopRoomWork)===null||b===void 0?void 0:b.inInnerDuct,ppopFiberGuide:(C=e.ppopRoomWork)===null||C===void 0?void 0:C.inFiberGuide,isSpopCableRunOutside:!!(e.spopRoomWork&&Object.keys(e.spopRoomWork).length>0),spopFromRackPanel:((x=e.spopRoomWork)===null||x===void 0?void 0:x.spopSpaceFrom)||"-",spopToRackPanel:((et=e.spopRoomWork)===null||et===void 0?void 0:et.spopSpaceTo)||"-",spopCableType:((tt=e.spopRoomWork)===null||tt===void 0?void 0:tt.cableType)||"-",spopLadderRack:(it=e.spopRoomWork)===null||it===void 0?void 0:it.onLadderRack,spopInnerDuct:(st=e.spopRoomWork)===null||st===void 0?void 0:st.inInnerDuct,spopFiberGuide:(nt=e.spopRoomWork)===null||nt===void 0?void 0:nt.inFiberGuide,notificationRecipients:e.notificationRecipients||"",cancellationReason:e.cancellationReason||"-",comments:(at=e.comments)===null||at===void 0?void 0:at.map(ge=>M(ge))}},sh=async e=>{var t,i,s,n,o,a,r,d,u,p,A,N,b,C,x,et,tt,it,st,nt,at,ge,pi,hi,vi;if(e)return{isVisitorContactsDetailsValid:!0,isVisitorEscortedDetailsValid:!0,isVisitorHostValid:!0,isRequestedAccessDetailsValid:!0,isNotificationsAttachmentsValid:!0,isPopRequestedAccessValid:!0,accountNumber:(t=e.accountNumber)!==null&&t!==void 0?t:"",status:e.status,requestType:"PoP/POE Access",category:"",id:e.id,visitors:[{firstName:(i=e.visitorFirstName)!==null&&i!==void 0?i:"",lastName:(s=e.visitorLastName)!==null&&s!==void 0?s:"",email:(n=e.visitorEmail)!==null&&n!==void 0?n:"",company:e.visitorCompany,phone:(o=e.visitorPhone)!==null&&o!==void 0?o:"",visitorType:e.visitorType}],isEscortedVisitor:!0,escortFirstName:e.escortFirstName,escortLastName:e.escortLastName,sitesDetails:await Qn(e),hostFirstName:e.visitorHostFirstName,hostLastName:e.visitorHostLastName,customerExternalReference:e.customerExternalReference,isServiceImpacted:!!e.serviceImpactedDescription,serviceImpactDescription:e.serviceImpactedDescription,termsAgreed:!0,serviceType:(a=e.serviceDetails)===null||a===void 0?void 0:a.serviceType,scope:(r=e.serviceDetails)===null||r===void 0?void 0:r.scope,isCrossConnectInstallation:!!(!((u=(d=e.serviceDetails)===null||d===void 0?void 0:d.circuits)===null||u===void 0)&&u.length),descriptionOfWork:(p=e.serviceDetails)===null||p===void 0?void 0:p.workDescription,circuits:ta((A=e.serviceDetails)===null||A===void 0?void 0:A.circuits),ppopSpaces:((N=e.ppopSpace)===null||N===void 0?void 0:N.map(Tt=>({rack:Tt.rack||"",cabinet:Tt.cabinet||""})))||[],spopSpaces:((b=e.spopSpace)===null||b===void 0?void 0:b.map(Tt=>({rack:Tt.rack||"",cabinet:Tt.cabinet||""})))||[],isPpopCableRunOutside:!!e.ppopRoomWork&&Object.keys(e.ppopRoomWork).length>0,ppopFromRackPanel:(C=e.ppopRoomWork)===null||C===void 0?void 0:C.ppopSpaceFrom,ppopToRackPanel:(x=e.ppopRoomWork)===null||x===void 0?void 0:x.ppopSpaceTo,ppopCableType:(et=e.ppopRoomWork)===null||et===void 0?void 0:et.cableType,ppopLadderRack:(tt=e.ppopRoomWork)===null||tt===void 0?void 0:tt.onLadderRack,ppopInnerDuct:(it=e.ppopRoomWork)===null||it===void 0?void 0:it.inInnerDuct,ppopFiberGuide:(st=e.ppopRoomWork)===null||st===void 0?void 0:st.inFiberGuide,isSpopCableRunOutside:!!(e.spopRoomWork&&Object.keys(e.spopRoomWork).length>0),spopFromRackPanel:(nt=e.spopRoomWork)===null||nt===void 0?void 0:nt.spopSpaceFrom,spopToRackPanel:(at=e.spopRoomWork)===null||at===void 0?void 0:at.spopSpaceTo,spopCableType:(ge=e.spopRoomWork)===null||ge===void 0?void 0:ge.cableType,spopLadderRack:(pi=e.spopRoomWork)===null||pi===void 0?void 0:pi.onLadderRack,spopInnerDuct:(hi=e.spopRoomWork)===null||hi===void 0?void 0:hi.inInnerDuct,spopFiberGuide:(vi=e.spopRoomWork)===null||vi===void 0?void 0:vi.inFiberGuide,contacts:e.notificationRecipients,attachments:[]}},nh=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),He=(e,t)=>(e!=null?e:!1)!==(t!=null?t:!1),B=(e,t)=>!(e===t||!e&&!t||!e&&t==="-"),ah=(e,t)=>B(e.sideAName,t.sideAName)||B(e.sideARoomNumber,t.sideARoomNumber)||B(e.sideARackNumber,t.sideARackNumber)||B(e.sideAPanelNumber,t.sideAPanelNumber)||B(e.sideAPort,t.sideAPort)||B(e.sideACarrierCircuitID,t.sideACarrierCircuitID)||B(e.sideZName,t.sideZName)||B(e.sideZRoomNumber,t.sideZRoomNumber)||B(e.sideZRackNumber,t.sideZRackNumber)||B(e.sideZPanelNumber,t.sideZPanelNumber)||B(e.sideZPort,t.sideZPort)||B(e.sideZCarrierCircuitID,t.sideZCarrierCircuitID),oh=(e,t)=>{if(e===void 0)return t.length!==0;if(e.length!==t.length)return!0;for(let i=0;i<e.length;i++)if(ah(e[i],t[i]))return!0;return!1},sa=(e,t)=>{if(e===void 0&&!(t!=null&&t.length))return!1;if(!e||!t||e.length!==t.length)return!0;for(let i=0;i<e.length;i++)if(B(e[i].rack,t[i].rack)||B(e[i].cabinet,t[i].cabinet))return!0;return!1},rh=(e,t)=>{var i,s;const n={};B(e.visitors[0].company,t.visitors[0].company)&&(n.visitorCompany=e.visitors[0].company),(B(e.escortFirstName,t.escortFirstName)||B(e.escortLastName,t.escortLastName))&&(n.escortFirstName=e.escortFirstName,n.escortLastName=e.escortLastName);const o=((i=e.sitesDetails)===null||i===void 0?void 0:i.flatMap(d=>d.locations.map(u=>({id:u.id,startDate:u.startDate,startTime:u.startTime,endDate:u.endDate,endTime:u.endTime,siteId:d.site.siteId}))))||[],a=((s=t.sitesDetails)===null||s===void 0?void 0:s.flatMap(d=>d.locations))||[],r=o.map(d=>{const u=a.find(A=>A.id===d.id),p={id:d.id};return(!u||B(d.startDate,u.startDate)||B(d.startTime,u.startTime)||B(d.endDate,u.endDate)||B(d.endTime,u.endTime))&&(p.startDateTime=Be(d.startDate,d.startTime,d.siteId),p.endDateTime=Be(d.endDate,d.endTime,d.siteId)),p}).filter(d=>d.startDateTime&&d.endDateTime);if(r.length&&(n.locations=r),(B(e.hostFirstName,t.visitorHostFirstName)||B(e.hostLastName,t.visitorHostLastName))&&(n.visitorHostFirstName=e.hostFirstName,n.visitorHostLastName=e.hostLastName),He(e.isServiceImpacted,t.isServiceImpacted)&&e.isServiceImpacted===!1&&(n.serviceImpactedDescription=""),B(e.serviceImpactDescription,t.serviceImpactDescription)&&(n.serviceImpactedDescription=e.serviceImpactDescription),n.serviceDetails={},B(e.serviceType,t.serviceType))switch(n.serviceDetails.serviceType=e.serviceType,e.serviceType){case We.SiteSurvey:case We.Testing:n.serviceDetails.scope=e.scope,n.serviceDetails.workDescription="",n.serviceDetails.circuits=[];break;case We.InstallationDeInstallationWork:n.serviceDetails.scope="",n.serviceDetails.workDescription=e.descriptionOfWork,n.serviceDetails.circuits=Ei(e.circuits);break;default:throw new Error("Unsupported service type for update")}else switch(e.serviceType){case We.SiteSurvey:case We.Testing:B(e.scope,t.scope)&&(n.serviceDetails.scope=e.scope);break;case We.InstallationDeInstallationWork:B(e.descriptionOfWork,t.workDescription)&&(n.serviceDetails.workDescription=e.descriptionOfWork),oh(e.circuits,t.circuits)&&(n.serviceDetails.circuits=Ei(e.circuits));break;default:throw new Error("Unsupported service type for update")}return Object.keys(n.serviceDetails).length===0&&delete n.serviceDetails,sa(e.ppopSpaces,t.ppopSpaces)&&(n.ppopSpace=e.ppopSpaces),sa(e.spopSpaces,t.spopSpaces)&&(n.spopSpace=e.spopSpaces),e.isPpopCableRunOutside?(n.ppopRoomWork={},B(e.ppopFromRackPanel,t.ppopFromRackPanel)&&(n.ppopRoomWork.ppopSpaceFrom=e.ppopFromRackPanel),B(e.ppopToRackPanel,t.ppopToRackPanel)&&(n.ppopRoomWork.ppopSpaceTo=e.ppopToRackPanel),B(e.ppopCableType,t.ppopCableType)&&(n.ppopRoomWork.cableType=e.ppopCableType),He(e.ppopLadderRack,t.ppopLadderRack)&&(n.ppopRoomWork.onLadderRack=e.ppopLadderRack),He(e.ppopInnerDuct,t.ppopInnerDuct)&&(n.ppopRoomWork.inInnerDuct=e.ppopInnerDuct),He(e.ppopFiberGuide,t.ppopFiberGuide)&&(n.ppopRoomWork.inFiberGuide=e.ppopFiberGuide),Object.keys(n.ppopRoomWork).length===0&&delete n.ppopRoomWork):He(e.isPpopCableRunOutside,t.isPpopCableRunOutside)&&(n.ppopRoomWork=null),e.isSpopCableRunOutside?(n.spopRoomWork={},B(e.spopFromRackPanel,t.spopFromRackPanel)&&(n.spopRoomWork.spopSpaceFrom=e.spopFromRackPanel),B(e.spopToRackPanel,t.spopToRackPanel)&&(n.spopRoomWork.spopSpaceTo=e.spopToRackPanel),B(e.spopCableType,t.spopCableType)&&(n.spopRoomWork.cableType=e.spopCableType),He(e.spopLadderRack,t.spopLadderRack)&&(n.spopRoomWork.onLadderRack=e.spopLadderRack),He(e.spopInnerDuct,t.spopInnerDuct)&&(n.spopRoomWork.inInnerDuct=e.spopInnerDuct),He(e.spopFiberGuide,t.spopFiberGuide)&&(n.spopRoomWork.inFiberGuide=e.spopFiberGuide),Object.keys(n.spopRoomWork).length===0&&delete n.spopRoomWork):He(e.isSpopCableRunOutside,t.isSpopCableRunOutside)&&(n.spopRoomWork=null),B(e.visitors[0].phone,t.visitors[0].phone)&&(n.visitorPhone=e.visitors[0].phone),B(e.customerExternalReference,t.customerExternalReference)&&(n.customerExternalReference=e.customerExternalReference),B(e.contacts,t.notificationRecipients)&&(n.notificationRecipients=e.contacts),Object.keys(n).length===0&&(n.visitorCompany=e.visitors[0].company),n},pe={newTicket:{isVisitorContactsDetailsValid:!1,isVisitorEscortedDetailsValid:!1,isVisitorHostValid:!1,isRequestedAccessDetailsValid:!1,isPopRequestedAccessValid:!1,isPPopRoomWorkValid:!1,isSPopRoomWorkValid:!1,isNotificationsAttachmentsValid:!1,accountNumber:"",visitors:[],contacts:"",attachments:[],startDate:void 0,endDate:void 0,sitesDetails:void 0,visitorBadge:"Standard",serviceType:void 0,isEscortedVisitor:!0,escortFirstName:void 0,escortLastName:void 0,hostCompany:void 0,hostFirstName:void 0,hostLastName:void 0,ppopSpaces:[{}],spopSpaces:[{}]},selectedTicket:void 0,submissionResult:{state:w.Default,ticketNumbers:[],popAccessResponse:void 0},loadings:{isSubmitting:!1,facilityAccessTicket:!1},isEditAttachmentAdded:!1};class na{constructor(){this.newTicket=pe.newTicket,this.submissionResult=pe.submissionResult,this.selectedTicket=pe.selectedTicket,this.loadings=pe.loadings,this.isEditAttachmentAdded=pe.isEditAttachmentAdded,se(this)}createTicket(){var t,i;const s=(t=this.newTicket.accountNumber)!==null&&t!==void 0?t:ae.getUserAccount().accountNumber;this.newTicket={...pe.newTicket,accountNumber:s,requestType:"PoP/POE Access",category:"",serviceBackend:(i=this.newTicket.serviceBackend)!==null&&i!==void 0?i:void 0},this.submissionResult=pe.submissionResult}async setNewTicket(){try{this.newTicket=await sh(this.submissionResult.ticketResponse),this.newTicket||(this.newTicket=pe.newTicket)}catch(t){throw await m(t,!1),t}}async getPOPAccessServiceTicket(t){if(t)try{const i=await l.facilityAccessApi.popAccess.getPopAccessTicketById({ticketId:t});this.submissionResult.ticketResponse=i,this.selectedTicket=await ia(i)}catch(i){throw await m(i,!1),i}}async hasUpdatePermissions(){var t;try{return await Rn((t=this.selectedTicket)===null||t===void 0?void 0:t.site)}catch(i){return!1}}isNotificationsAttachmentsValid(t){this.newTicket.isNotificationsAttachmentsValid=t}updateAttachments(t){var i;(i=this.newTicket.attachments)===null||i===void 0||i.push(...t)}updateIsEscortedVisitor(t){this.newTicket.isEscortedVisitor=t,t?this.newTicket.visitorBadge=void 0:(this.newTicket.escortFirstName=void 0,this.newTicket.escortLastName=void 0,this.newTicket.visitorBadge===void 0&&(this.newTicket.visitorBadge="Standard"))}updateVisitorHost(t,i){var s;const n=(s=this.newTicket.sitesDetails)===null||s===void 0?void 0:s.find(o=>o.site.siteId===t);n&&(n.visitorHost=i,n.isVisitorHostDetailsValid=!0)}updateEscortFirstName(t){this.newTicket.escortFirstName=t}updateEscortLastName(t){this.newTicket.escortLastName=t}addVisitor(t){var i;if(t)if(this.newTicket.id)this.newTicket.visitors=[t];else{const s=((i=this.newTicket.visitors)!==null&&i!==void 0?i:[]).filter(n=>n.id!==t.id);this.newTicket.visitors=[...s,t]}}removeVisitor(t){var i;if(t){const s=((i=this.newTicket.visitors)!==null&&i!==void 0?i:[]).filter(n=>n.id!==t.id);this.newTicket.visitors=[...s]}}addOrUpdateVisitor(t){var i;if(t)if(this.newTicket.id)this.newTicket.visitors=[t];else{const s=((i=this.newTicket.visitors)!==null&&i!==void 0?i:[]).filter(n=>n.id!==t.id);this.newTicket.visitors=[...s,t]}}updateHostFirstName(t){this.newTicket.hostFirstName=t}updateHostLastName(t){this.newTicket.hostLastName=t}updateVisitorBadge(t){this.newTicket.visitorBadge=t}updateTermsAgreed(t){this.newTicket.termsAgreed=t}updateStartDate(t){var i;this.newTicket.startDate=t,(i=this.newTicket.sitesDetails)===null||i===void 0||i.forEach(s=>{s.locations.forEach(n=>{n.startDate=t})})}updateEndDate(t){var i;this.newTicket.endDate=t,(i=this.newTicket.sitesDetails)===null||i===void 0||i.forEach(s=>{s.locations.forEach(n=>{n.endDate=t})})}async addSiteLocations(t){var i;if(t){const s=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(n=>n.site.siteId!==t.site.siteId);this.newTicket.sitesDetails=[...s,t]}}removeSiteLocations(t){var i;if(t){const s=((i=this.newTicket.sitesDetails)!==null&&i!==void 0?i:[]).filter(n=>n.site.siteId!==t.site.siteId);this.newTicket.sitesDetails=[...s]}}updateContacts(t){this.newTicket.contacts=t}async submitNewTicketRequest(){var t;this.resetSubmission();try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;const i=await l.facilityAccessApi.popAccess.createPopAccessTicket({pOPAccessTicketRequest:ih(this.newTicket)}).catch(s=>{throw m(s,!1),this.submissionResult.state=w.Error,s});if(i){const{ticketNumbers:s}=i;s!=null&&s.length&&!((t=this.newTicket.attachments)===null||t===void 0)&&t.length&&await Promise.all(s.map(async n=>{await k.postAttachments(y.FacilityAccess,this.newTicket.attachments,n,!1,"PoP/POE Access")})),this.newTicket.attachments=void 0,this.submissionResult.state=w.Submitted,this.submissionResult.ticketNumbers=i==null?void 0:i.ticketNumbers}}catch(i){throw await m(i,!1),this.submissionResult.state=w.Error,i}finally{this.loadings.isSubmitting=!1}}async cancelTicket(t){var i;try{k.loadings.isTicketCancelling=!0,!((i=this.selectedTicket)===null||i===void 0)&&i.id&&(await l.facilityAccessApi.popAccess.cancellationPopAccessRequest({ticketId:this.selectedTicket.id,cancellationTicketsRequest:{cancellationReason:t}}),await this.getPOPAccessServiceTicket(this.selectedTicket.id))}catch(s){throw await m(s,!1),s}finally{k.loadings.isTicketCancelling=!1}}async submitUpdateTicketRequest(){let t;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting,this.submissionResult.ticketNumbers=void 0;try{t=await l.facilityAccessApi.popAccess.updatePopAccessTicket({pOPAccessTicketUpdateRequest:rh(this.newTicket,this.selectedTicket),ticketId:this.newTicket.id}),this.submissionResult.ticketResponse=t,this.submissionResult.state=w.Submitted,this.submissionResult.ticketNumbers=[t==null?void 0:t.id]}catch(i){throw this.submissionResult.state=w.Error,await m(i,!1),i}try{await k.postAttachments(y.FacilityAccess,this.newTicket.attachments,this.newTicket.id,!0,"PoP/POE Access"),this.newTicket.attachments=[]}catch(i){await m(i,!1)}try{t&&(this.selectedTicket=await ia(t))}catch(i){throw await m(i,!1),i}}finally{this.loadings.isSubmitting=!1}}resetSubmission(){this.submissionResult=pe.submissionResult}clearNewTicket(){this.newTicket=pe.newTicket}clear(){this.newTicket=pe.newTicket,this.selectedTicket=pe.selectedTicket,this.submissionResult=pe.submissionResult}updateFieldValue(t,i){this.newTicket[t]=i}updateIsServiceImpacted(t){this.newTicket.isServiceImpacted=t}updateCustomerExternalReference(t){this.newTicket.customerExternalReference=t}updateServiceImpactDescription(t){this.newTicket.serviceImpactDescription=t}updateServiceType(t){this.newTicket.serviceType=t,t===We.InstallationDeInstallationWork&&this.updateScope(""),this.updateIsCrossConnectInstallation(!1)}updateScope(t){this.newTicket.scope=t}updateDescriptionOfWork(t){this.newTicket.descriptionOfWork=t}updateIsCrossConnectInstallation(t){this.newTicket.isCrossConnectInstallation=t,t?this.newTicket.circuits=[{}]:(this.updateDescriptionOfWork(""),this.newTicket.circuits=void 0)}updateIsPPopCableRunOutside(t){this.newTicket.isPpopCableRunOutside=t,t||(this.newTicket.ppopFromRackPanel=void 0,this.newTicket.ppopToRackPanel=void 0,this.newTicket.ppopCableType=void 0,this.newTicket.ppopLadderRack=void 0,this.newTicket.ppopInnerDuct=void 0,this.newTicket.ppopFiberGuide=void 0)}updateIsSPopCableRunOutside(t){this.newTicket.isSpopCableRunOutside=t,t||(this.newTicket.spopFromRackPanel=void 0,this.newTicket.spopToRackPanel=void 0,this.newTicket.spopCableType=void 0,this.newTicket.spopLadderRack=void 0,this.newTicket.spopInnerDuct=void 0,this.newTicket.spopFiberGuide=void 0)}updateCircuitField(t,i,s){var n;(!this.newTicket.circuits||((n=this.newTicket.circuits)===null||n===void 0?void 0:n.length)===0)&&(this.newTicket.circuits=[{}]);const o=[...this.newTicket.circuits];o[s][i]=t,this.newTicket.circuits=o}isVisitorContactsValid(t){this.newTicket.isVisitorContactsDetailsValid=t}isEscortedDetailsValid(t){this.newTicket.isVisitorEscortedDetailsValid=t}isRequestedAccessDetailsValid(t){this.newTicket.isRequestedAccessDetailsValid=t}addBulkVisitors(t){throw new Error("Method not implemented.")}removeBulkVisitors(){throw new Error("Method not implemented.")}removeBulkAttachment(){throw new Error("Method not implemented.")}removeAllVisitors(){this.newTicket.visitors=[]}get isNewTicketValid(){const t=this.newTicket.isVisitorContactsDetailsValid,i=this.newTicket.isVisitorEscortedDetailsValid,s=this.newTicket.isVisitorHostValid,n=this.newTicket.isRequestedAccessDetailsValid,o=this.newTicket.isPopRequestedAccessValid;return t&&i&&s&&n&&o}get isAdditionalComponentValid(){return this.newTicket.isPPopRoomWorkValid&&this.newTicket.isSPopRoomWorkValid&&this.newTicket.isNotificationsAttachmentsValid}}const Ce=new na;var ti;(function(e){e.PLANNED_MAINTENANCE="Planned Maintenance",e.INCIDENTS="Incidents",e.DCIM_ALERTS="DCIM Alerts",e.SERVICE_TICKETS="Service Tickets"})(ti||(ti={}));const ch=(e,t)=>({ticketId:t,ticketCommentsRequest:{comment:e}}),M=e=>({comment:e.comment,commentedBy:e.createdBy,commentedOn:e.createdAt});async function dh(e,t,i){var s,n,o,a,r,d,u,p,A,N;let b;switch(e){case y.Deliveries:{const C=await l.deliveriesApi.createDeliveriesComment(Gm(t,i)).catch(x=>{m(x,!1)});b=(s=C==null?void 0:C.comments)===null||s===void 0?void 0:s.map(M),be.selectedTicket&&(be.selectedTicket.comments=b);break}case y.Removals:{const C=await l.removalsApi.createComment(rp(t,i)).catch(x=>{m(x,!1)});b=(n=C==null?void 0:C.comments)===null||n===void 0?void 0:n.map(M),Ve.selectedTicket&&(Ve.selectedTicket.comments=b);break}case y.RemoteHands:{const C=await l.remoteHandsApi.createRemoteHandsComment(Qm(t,i)).catch(x=>{m(x,!1)});b=(o=C==null?void 0:C.comments)===null||o===void 0?void 0:o.map(M),re.selectedTicket&&(re.selectedTicket.comments=b);break}case y.VisitorAccess:{const C=await l.facilityAccessApi.visitorAccess.createVisitorAccessComment(Pp(t,i)).catch(x=>{m(x,!1)});b=(a=C==null?void 0:C.comments)===null||a===void 0?void 0:a.map(M),ie.selectedTicket&&(ie.selectedTicket.comments=b);break}case y.PermanentBadge:{const C=await l.facilityAccessApi.permanentBadgeAccess.createPermanentBadgeComment(jp(t,i)).catch(x=>{m(x,!1)});b=(r=C==null?void 0:C.comments)===null||r===void 0?void 0:r.map(M),Y.selectedTicket&&(Y.selectedTicket.comments=b);break}case y.CustomerSupport:{const C=await l.customerCareApi.createCustomerCareComment(bp(t,i)).catch(x=>{m(x,!1)});b=(d=C==null?void 0:C.comments)===null||d===void 0?void 0:d.map(M),je.selectedTicket&&(je.selectedTicket.comments=b);break}case y.TroubleTickets:{const C=await l.troubleTicketsApi.createTroubleTicketComment(up(t,i)).catch(x=>{m(x,!1)});b=(u=C==null?void 0:C.comments)===null||u===void 0?void 0:u.map(M),Ue.selectedTicket&&(Ue.selectedTicket.comments=b);break}case y.OSPAccess:{const C=await l.facilityAccessApi.ospAccess.createOspAccessComment(Qp(t,i)).catch(x=>{m(x,!1)});b=(p=C==null?void 0:C.comments)===null||p===void 0?void 0:p.map(M),Se.selectedTicket&&(Se.selectedTicket.comments=b);break}case y.POPPOEAccess:{const C=await l.facilityAccessApi.popAccess.createPopAccessComment(nh(t,i)).catch(x=>{m(x,!1)});b=(A=C==null?void 0:C.comments)===null||A===void 0?void 0:A.map(M),Ce.selectedTicket&&(Ce.selectedTicket.comments=b);break}case ti.INCIDENTS:{const C=await l.incidentsApi.createIncidentComment(ch(t,i)).catch(x=>{m(x,!1)});b=(N=C==null?void 0:C.comments)===null||N===void 0?void 0:N.map(M);break}default:return}return b}const uh=e=>({subject:e.subject,customerReference:e.customerReferenceNumber,description:e.description,otherNotificationRecipients:e.contacts}),lh=e=>{var t;return{accountNumber:e.accountNumber,subject:e.subject,requestType:e.requestType,category:e.category,locations:!((t=e.location)===null||t===void 0)&&t.id?[e.location.id]:[],customerReference:e.customerReferenceNumber,description:e.description,notificationRecipients:e.contacts}},mh=async e=>{if(e)return{accountNumber:e.accountNumber,serviceBackend:await K.getServiceBackend(e.accountNumber,e.site,"Customer_care"),subject:e.subject,requestType:e.requestType,category:e.category,site:{id:e.site,accountNumber:e.accountNumber},location:{id:e.locations[0],accountNumber:e.accountNumber},customerReferenceNumber:e.customerReference,description:e.description,contacts:e.notificationRecipients}},aa=async e=>{var t,i,s,n,o;if(e)return{id:e.id,accountName:e.accountName,accountNumber:e.accountNumber,serviceBackend:await K.getServiceBackend(e.accountNumber,e.site,"Customer_care"),subject:e.subject,description:e.description,customerReference:e.customerReference,site:e.site,location:!((t=e.locations)===null||t===void 0)&&t.length?e.locations[0]:"",notificationRecipients:e.notificationRecipients,status:e.status,createdBy:e.createdBy,createdAt:(i=e.createdAt)===null||i===void 0?void 0:i.toISOString(),updatedAt:(s=e.updatedAt)===null||s===void 0?void 0:s.toISOString(),closedAt:(n=e.closedAt)===null||n===void 0?void 0:n.toISOString(),cancellationReason:e.cancellationReason,requestType:e.requestType,category:e.category,comments:(o=e.comments)===null||o===void 0?void 0:o.map(a=>M(a))}},ze={selectedTicket:void 0,ticket:{isValid:!1,subject:"",description:"",site:void 0,requestType:"",category:"",customerReferenceNumber:"",contacts:"",attachments:[],accountNumber:""},submissionResult:{state:w.Default,result:void 0},loadings:{isSubmitting:!1}};class ph{constructor(){this.selectedTicket=ze.selectedTicket,this.ticket=ze.ticket,this.submissionResult=ze.submissionResult,this.loadings=ze.loadings,se(this),Je(this,{name:"customerCare",properties:[],storage:window.localStorage})}async setTicket(){try{this.ticket=await mh(this.submissionResult.result)||ze.ticket}catch(t){throw await m(t,!1),t}}async getSelectedTicket(t){if(t)try{const i=await l.customerCareApi.getCustomerCareTicketById({ticketId:t});this.submissionResult.result=i,this.selectedTicket=await aa(i),await this.setTicket()}catch(i){throw await m(i,!1),i}}async getCategories(t,i){if(!(!t||!i))try{return await l.customerCareApi.getCustomerCareCategoriesList({site:t,accountNumber:i})}catch(s){throw await m(s,!1),s}}async cancelTicket(t){var i;try{k.loadings.isTicketCancelling=!0,!((i=this.selectedTicket)===null||i===void 0)&&i.id&&(await l.customerCareApi.cancellationCustomerCareRequest({ticketId:this.selectedTicket.id,cancellationTicketsRequest:{cancellationReason:t}}).catch(s=>{throw m(s,!1),s}),await this.getSelectedTicket(this.selectedTicket.id))}finally{k.loadings.isTicketCancelling=!1}}async updateSite(t){this.ticket.site=t,this.ticket.accountNumber=t.accountNumber}async createTicket(){var t;this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{this.submissionResult.result=await l.customerCareApi.createCustomerCareTicket({customerCareTicketRequest:lh(this.ticket)}),this.submissionResult.state=w.Submitted}catch(i){throw this.loadings.isSubmitting=!1,this.submissionResult.state=w.Error,await m(i,!1),i}try{!((t=this.submissionResult.result)===null||t===void 0)&&t.id&&await k.postAttachments(y.CustomerSupport,this.ticket.attachments,this.submissionResult.result.id),this.ticket.attachments=void 0}catch(i){throw await m(i,!1),i}finally{this.loadings.isSubmitting=!1}}async updateTicket(){var t,i;let s;try{this.loadings.isSubmitting=!0,this.submissionResult.state=w.Submitting;try{s=await l.customerCareApi.updateCustomerCareTicket({ticketId:((t=this.selectedTicket)===null||t===void 0?void 0:t.id)||"",customerCareTicketUpdateRequest:uh(this.ticket)}),this.submissionResult.result=s,this.submissionResult.state=w.Submitted}catch(n){throw this.submissionResult.state=w.Error,await m(n,!1),n}try{await k.postAttachments(y.CustomerSupport,this.ticket.attachments,(i=this.selectedTicket)===null||i===void 0?void 0:i.id,!0),this.ticket.attachments=void 0}catch(n){throw await m(n,!1),n}try{s&&(this.selectedTicket=await aa(s),await this.setTicket())}catch(n){throw await m(n,!1),n}}finally{this.loadings.isSubmitting=!1}}updateLocation(t){this.ticket.location=t}clear(){this.ticket=ze.ticket,this.selectedTicket=ze.selectedTicket,this.submissionResult=ze.submissionResult,this.loadings=ze.loadings}}const je=new ph,ve=bt` *, ::before, ::after {
2
2
  --tw-border-spacing-x: 0;
3
3
  --tw-border-spacing-y: 0;
4
4
  --tw-translate-x: 0;
@@ -1071,4 +1071,4 @@ video {
1071
1071
  <path d="M4 4C2.897 4 2 4.897 2 6V16C2 17.103 2.897 18 4 18H0V20H24V18H20C21.103 18 22 17.103 22 16V6C22 4.897 21.103 4 20 4H4ZM4 6H20L20.002 16H4V6ZM14.2852 8.00781L11 11.293L9.20703 9.5L7.79297 10.9141L11 14.1211L15.6992 9.42188L14.2852 8.00781Z"></path>
1072
1072
  `,reportsIcon:Ot`
1073
1073
  <path d="M6 2C4.90575 2 4 2.90575 4 4V20C4 21.0943 4.90575 22 6 22H11V20H6V4H13V9H18V13H20V8L14 2H6ZM12 11V14H15C15 12.343 13.641 11.031 12 11ZM11 12C9.343 12 8 13.343 8 15C8 16.657 9.343 18 11 18C12.657 18 13.969 16.641 14 15H11V12ZM16 15V21H13C13 22.654 14.346 24 16 24H21C22.645 24 24 22.645 24 21V15H16ZM18 17H22V21C22 21.565 21.565 22 21 22C20.449 22 20 21.552 20 21H18V17Z" fill="white"/>
1074
- `};let Mi=class extends Rt{constructor(){super(...arguments),this.navigationItems=[],this.compact=!1}static get styles(){return[ve,vh]}firstUpdated(){window.addEventListener("vaadin-router-location-changed",()=>{this.requestUpdate(),this.navigationItems.length||(this.navigationItems=[{href:Qt(W.ServiceTickets),title:W.ServiceTickets,icon:g`<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24"> ${ni.serviceTicketsIcon} </svg>`},{href:Qt(W.Reports),title:W.Reports,icon:g`<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24"> ${ni.reportsIcon} </svg>`}])})}toggleCompact(){this.compact=!this.compact}renderItems(){return g` <ul> ${this.navigationItems.map(e=>g` <li> <a href="${e.href}" class="${e.href===window.location.pathname?"active":""}"> <div class="navigation-icon">${e.icon}</div> ${this.compact?"":g`<h6 class="dlr-text-small">${e.title}</h6>`} </a> </li> `)} </ul>`}render(){return g` <div class="${`container ${this.compact?"compact":""}`}"> <svg @click="${this.toggleCompact}" class="navigation-logo" focusable="false" aria-hidden="true" viewBox="0 0 178 27"> ${this.compact?ni.digitalRealtyLogo:ni.digitalRealtyLogoWithText} </svg> <hr class="divider"> ${this.renderItems()} <dev-clear-storage-button-service></dev-clear-storage-button-service> </div> `}};E([we({type:Boolean,attribute:!1})],Mi.prototype,"compact",void 0),Mi=E([X("sm-navigation-bar")],Mi);const gh=bt`:host{display:block;font-size:calc(10px + 2vmin);color:#1a2b42;margin:0 auto;background-color:#f5f7ff;font-size:18px;--desktop-device-width:1920px;--tablet-device-width:1024px;--mobile-device-width:375px}.service-management__body{display:flex;flex-direction:column}.service-management__body.standalone{flex-direction:row}.center-container{flex-grow:1;padding:40px;padding-bottom:48px}main{flex-grow:1;max-width:100%}.create-service-ticket-btn{font-family:var(--root-secondary-font);font-weight:700;font-style:normal;font-size:14px;line-height:18.52px;letter-spacing:1.25px}@media only screen and (min-width:5px) and (max-width:500px){.service-management__body.standalone{flex-direction:column}}@media only screen and (min-width:500px) and (max-width:1250px){.service-management__body.standalone{flex-direction:column}}`;class wh{constructor(){this.isStandalone=!1,se(this),Je(this,{name:"app-state",properties:["isStandalone"],storage:window.sessionStorage})}}const da=new wh;let Me=class extends Rt{constructor(){super(...arguments),this.routes=[],this.baseUrl="",this.sessionToken="",this.disableAuthentication=!1,this.isStandalone=!1,this.appIsVisible=!1,this.handleErrorRaised=e=>{this.errorMessage=e.detail}}static get styles(){return[ua,ve,gh]}updated(e){e.has("routes")&&this.routes.length&&ym().setRoutes(this.routes)}async firstUpdated(){da.isStandalone=this.isStandalone,this.configureAuth(),this.init(),this.configureMomentCalendarDate(),await J.fillLookups()}configureAuth(){this.disableAuthentication||ke().DisableServiceManagementUIAuth?this.appIsVisible=!0:ae.isProcessing()||(ae.isLoggedIn()?this.appIsVisible=!0:ae.redirectToAuth())}configureMomentCalendarDate(){const e=im().toUpperCase();G.updateLocale("en",{calendar:{sameDay:`[Today], ${e}`,lastDay:`[Yesterday], ${e}`,lastWeek:`${e}`,sameElse:`${e}`}})}init(){window.addEventListener(L.ErrorRaised,this.handleErrorRaised),setTimeout(()=>{var e;const t=(e=this.shadowRoot)===null||e===void 0?void 0:e.querySelector("main");t&&km(t,this.baseUrl,Dt)})}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener(L.ErrorRaised,this.handleErrorRaised),Tm()}clearErrorMessage(){this.errorMessage=void 0}renderNavBar(){return this.isStandalone?g`<sm-navigation-bar></sm-navigation-bar>`:P}renderBody(){return this.isStandalone?g`<div class="center-container"> <sm-app-header></sm-app-header> <main></main> </div>`:g`<main></main>`}render(){return this.appIsVisible?g` <div class="md:mx-4 lg:mx-0 service-management__body ${this.isStandalone?"standalone":""}"> ${this.renderNavBar()} ${this.renderBody()} <ix-dialog ?open="${this.errorMessage}" @closed="${this.clearErrorMessage}"> <div slot="content" method="dialog">${this.errorMessage}</div> <div class="dialog-actions" slot="actions"> <ix-button id="dialogCloseBtn" ariaLabel="Close" appearance="text" text="Close" @click="${this.clearErrorMessage}"> <span>Close</span> </ix-button> </div> </ix-dialog> </div> `:P}};E([we({type:Array})],Me.prototype,"routes",void 0),E([we({type:String})],Me.prototype,"baseUrl",void 0),E([we({type:String})],Me.prototype,"sessionToken",void 0),E([we({type:Boolean,attribute:!0})],Me.prototype,"disableAuthentication",void 0),E([we({type:Boolean,attribute:!0})],Me.prototype,"isStandalone",void 0),E([we({type:Boolean,attribute:!1})],Me.prototype,"appIsVisible",void 0),E([we({type:String,attribute:!1})],Me.prototype,"errorMessage",void 0),Me=E([X("ui-service-management")],Me);export{St as $,L as A,om as B,nm as C,Pm as D,Fm as E,O as F,qm as G,ka as H,ba as I,Om as J,w as K,U as L,dn as M,gt as N,Rm as O,Wl as P,Vm as Q,W as R,H as S,ve as T,Um as U,Nn as V,Lm as W,lt as X,J as Y,am as Z,Mm as _,y as a,Pt as a$,jm as a0,ip as a1,ep as a2,tp as a3,Nt as a4,Q as a5,pm as a6,vn as a7,gn as a8,wn as a9,Ce as aA,_n as aB,th as aC,Bm as aD,Sn as aE,We as aF,Jp as aG,fm as aH,Zn as aI,Mp as aJ,tm as aK,fu as aL,$n as aM,Hm as aN,zm as aO,ga as aP,Bi as aQ,sp as aR,Fn as aS,Ue as aT,l as aU,cm as aV,Nm as aW,ft as aX,ei as aY,ya as aZ,Hn as a_,fn as aa,$e as ab,Yt as ac,hh as ad,ut as ae,F as af,Ct as ag,Xn as ah,na as ai,oe as aj,Cn as ak,ct as al,wa as am,ie as an,Sm as ao,Im as ap,Y as aq,$i as ar,Ap as as,zn as at,Wi as au,Bp as av,Dm as aw,Se as ax,An as ay,Zp as az,ln as b,lp as b0,mp as b1,jl as b2,ra as b3,dh as b4,ti as b5,Jt as b6,Ke as b7,m as b8,hp as b9,vp as ba,Jl as bb,zl as bc,Si as bd,gp as be,wp as bf,Di as bg,gi as c,be as d,k as e,da as f,wt as g,ae as h,va as i,Ql as j,Ni as k,Ml as l,Qt as m,$m as n,Em as o,ke as p,em as q,Ve as r,K as s,Cm as t,mm as u,S as v,re as w,Am as x,je as y,hm as z};
1074
+ `};let Mi=class extends Rt{constructor(){super(...arguments),this.navigationItems=[],this.compact=!1}static get styles(){return[ve,vh]}firstUpdated(){window.addEventListener("vaadin-router-location-changed",()=>{this.requestUpdate(),this.navigationItems.length||(this.navigationItems=[{href:Qt(W.ServiceTickets),title:W.ServiceTickets,icon:g`<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24"> ${ni.serviceTicketsIcon} </svg>`},{href:Qt(W.Reports),title:W.Reports,icon:g`<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24"> ${ni.reportsIcon} </svg>`}])})}toggleCompact(){this.compact=!this.compact}renderItems(){return g` <ul> ${this.navigationItems.map(e=>g` <li> <a href="${e.href}" class="${e.href===window.location.pathname?"active":""}"> <div class="navigation-icon">${e.icon}</div> ${this.compact?"":g`<h6 class="dlr-text-small">${e.title}</h6>`} </a> </li> `)} </ul>`}render(){return g` <div class="${`container ${this.compact?"compact":""}`}"> <svg @click="${this.toggleCompact}" class="navigation-logo" focusable="false" aria-hidden="true" viewBox="0 0 178 27"> ${this.compact?ni.digitalRealtyLogo:ni.digitalRealtyLogoWithText} </svg> <hr class="divider"> ${this.renderItems()} <dev-clear-storage-button-service></dev-clear-storage-button-service> </div> `}};E([we({type:Boolean,attribute:!1})],Mi.prototype,"compact",void 0),Mi=E([X("sm-navigation-bar")],Mi);const gh=bt`:host{display:block;font-size:calc(10px + 2vmin);color:#1a2b42;margin:0 auto;background-color:#f5f7ff;font-size:18px;--desktop-device-width:1920px;--tablet-device-width:1024px;--mobile-device-width:375px}.service-management__body{display:flex;flex-direction:column}.service-management__body.standalone{flex-direction:row}.center-container{flex-grow:1;padding:40px;padding-bottom:48px}main{flex-grow:1;max-width:100%}.create-service-ticket-btn{font-family:var(--root-secondary-font);font-weight:700;font-style:normal;font-size:14px;line-height:18.52px;letter-spacing:1.25px}@media only screen and (min-width:5px) and (max-width:500px){.service-management__body.standalone{flex-direction:column}}@media only screen and (min-width:500px) and (max-width:1250px){.service-management__body.standalone{flex-direction:column}}`;class wh{constructor(){this.isStandalone=!1,se(this),Je(this,{name:"app-state",properties:["isStandalone"],storage:window.sessionStorage})}}const da=new wh;let Me=class extends Rt{constructor(){super(...arguments),this.routes=[],this.baseUrl="",this.sessionToken="",this.disableAuthentication=!1,this.isStandalone=!1,this.appIsVisible=!1,this.handleErrorRaised=e=>{this.errorMessage=e.detail}}static get styles(){return[ua,ve,gh]}updated(e){e.has("routes")&&this.routes.length&&ym().setRoutes(this.routes)}async firstUpdated(){da.isStandalone=this.isStandalone,this.configureAuth(),this.init(),this.configureMomentCalendarDate(),await J.fillLookups()}configureAuth(){this.disableAuthentication||ke().DisableServiceManagementUIAuth?this.appIsVisible=!0:ae.isProcessing()||(ae.isLoggedIn()?this.appIsVisible=!0:ae.redirectToAuth())}configureMomentCalendarDate(){const e=im().toUpperCase();G.updateLocale("en",{calendar:{sameDay:`[Today], ${e}`,lastDay:`[Yesterday], ${e}`,lastWeek:`${e}`,sameElse:`${e}`}})}init(){window.addEventListener(L.ErrorRaised,this.handleErrorRaised),setTimeout(()=>{var e;const t=(e=this.shadowRoot)===null||e===void 0?void 0:e.querySelector("main");t&&km(t,this.baseUrl,Dt)})}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener(L.ErrorRaised,this.handleErrorRaised),Tm()}clearErrorMessage(){this.errorMessage=void 0}renderNavBar(){return this.isStandalone?g`<sm-navigation-bar></sm-navigation-bar>`:P}renderBody(){return this.isStandalone?g`<div class="center-container"> <sm-app-header></sm-app-header> <main></main> </div>`:g`<main></main>`}render(){return this.appIsVisible?g` <div class="md:mx-4 lg:mx-0 service-management__body ${this.isStandalone?"standalone":""}"> ${this.renderNavBar()} ${this.renderBody()} <ix-dialog ?open="${this.errorMessage}" @closed="${this.clearErrorMessage}"> <div slot="content" method="dialog">${this.errorMessage}</div> <div class="dialog-actions" slot="actions"> <ix-button id="dialogCloseBtn" ariaLabel="Close" appearance="text" text="Close" @click="${this.clearErrorMessage}"> <span>Close</span> </ix-button> </div> </ix-dialog> </div> `:P}};E([we({type:Array})],Me.prototype,"routes",void 0),E([we({type:String})],Me.prototype,"baseUrl",void 0),E([we({type:String})],Me.prototype,"sessionToken",void 0),E([we({type:Boolean,attribute:!0})],Me.prototype,"disableAuthentication",void 0),E([we({type:Boolean,attribute:!0})],Me.prototype,"isStandalone",void 0),E([we({type:Boolean,attribute:!1})],Me.prototype,"appIsVisible",void 0),E([we({type:String,attribute:!1})],Me.prototype,"errorMessage",void 0),Me=E([X("ui-service-management")],Me);export{St as $,L as A,om as B,nm as C,Pm as D,Fm as E,O as F,qm as G,ka as H,ba as I,Om as J,w as K,U as L,dn as M,gt as N,Rm as O,Wl as P,Vm as Q,W as R,H as S,ve as T,Um as U,Nn as V,Lm as W,lt as X,J as Y,am as Z,Mm as _,y as a,Pt as a$,jm as a0,ip as a1,ep as a2,tp as a3,Nt as a4,Q as a5,pm as a6,vn as a7,gn as a8,wn as a9,Ce as aA,_n as aB,th as aC,Bm as aD,Sn as aE,We as aF,Jp as aG,fm as aH,Zn as aI,Mp as aJ,tm as aK,$n as aL,Hm as aM,zm as aN,ga as aO,Bi as aP,sp as aQ,Fn as aR,Ue as aS,fu as aT,m as aU,cm as aV,Nm as aW,ft as aX,ei as aY,ya as aZ,Hn as a_,fn as aa,$e as ab,Yt as ac,hh as ad,ut as ae,F as af,Ct as ag,Xn as ah,na as ai,oe as aj,Cn as ak,ct as al,wa as am,ie as an,Sm as ao,Im as ap,Y as aq,$i as ar,Ap as as,zn as at,Wi as au,Bp as av,Dm as aw,Se as ax,An as ay,Zp as az,ln as b,lp as b0,mp as b1,jl as b2,ra as b3,dh as b4,ti as b5,Jt as b6,Ke as b7,l as b8,hp as b9,vp as ba,Jl as bb,zl as bc,Si as bd,gp as be,wp as bf,Di as bg,gi as c,be as d,k as e,da as f,wt as g,ae as h,va as i,Ql as j,Ni as k,Ml as l,Qt as m,$m as n,Em as o,ke as p,em as q,Ve as r,K as s,Cm as t,mm as u,S as v,re as w,Am as x,je as y,hm as z};