PageSourceSearch

https://app.gilly.org/_next/static/chunks/9266-ad2341bba6c84cda.js?dpl=dpl_8MCsGeQDPKLMySDpcfYugyf6u2Pk

js gilly.org collected 2026-10-06 15:19:08 UTC 53,857 bytes, 1 lines download raw bytes

1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ce42a45c-9aa5-48cd-983e-fb6ebe4719df",e._sentryDebugIdIdentifier="sentry-dbid-ce42a45c-9aa5-48cd-983e-fb6ebe4719df")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9266],{5698:(e,t,n)=>{n.d(t,{r:()=>a});var i=n(44914),o=n(64407),r=n(24544);let a=(0,o.XT)({links:[(0,o.fu)({url:"/api/trpc",async headers(){try{var e;let t=await (0,i.Kr)(),n=null==t||null==(e=t.idToken)?void 0:e.toString();return n?{authorization:"Bearer ".concat(n)}:{}}catch(e){return(0,r.vV)({error:{module:"tRPC Proxy Client",component:"trpc-client.ts",func:"headers",message:e instanceof Error?e.message:"Failed to get fresh token"},tagName:"VANILLA_TRPC_CLIENT_AUTH_ERROR"}),{}}}}),(0,o.$H)({enabled:e=>"down"===e.direction&&e.result instanceof Error})]})},24359:(e,t,n)=>{n.d(t,{gE:()=>c,yn:()=>s,gq:()=>a,Xn:()=>l,Le:()=>r});var i=function(e){return e.INSPECTOR_1="INSPECTOR_1",e.INSPECTOR_2="INSPECTOR_2",e.FISH_WILDLIFE_PARKS_REP="FISH_WILDLIFE_PARKS_REP",e}({}),o=n(37823);let r=Object.freeze({inspectionFormStep:"inspectionFormStep",signaturesStep:"signaturesStep"}),a=Object.freeze({firstInspector:"firstInspector",secondInspector:"secondInspector",thirdInspector:"thirdInspector"}),s=Object.freeze({[a.firstInspector]:i.INSPECTOR_1,[a.secondInspector]:i.INSPECTOR_2,[a.thirdInspector]:i.FISH_WILDLIFE_PARKS_REP}),c=Object.keys(i),l=(0,o.nY)({[r.inspectionFormStep]:{permitInformation:{needsInspection:"".concat(r.inspectionFormStep,".permitInformation.needsInspection"),applicationNumber:"".concat(r.inspectionFormStep,".permitInformation.applicationNumber"),dateOfSubmissionToCd:"".concat(r.inspectionFormStep,".permitInformation.dateOfSubmissionToCd"),state:"".concat(r.inspectionFormStep,".permitInformation.state"),dateOfInspection:"".concat(r.inspectionFormStep,".permitInformation.dateOfInspection")},teamMemberReport:{applicantAgent:"".concat(r.inspectionFormStep,".teamMemberReport.applicantAgent"),for:"".concat(r.inspectionFormStep,".teamMemberReport.for")},perennialStream:"".concat(r.inspectionFormStep,".perennialStream"),projectLocation:{address:"".concat(r.inspectionFormStep,".projectLocation.address"),nearestTown:"".concat(r.inspectionFormStep,".projectLocation.nearestTown"),county:"".concat(r.inspectionFormStep,".projectLocation.county"),geocode:"".concat(r.inspectionFormStep,".projectLocation.geocode"),latitude:"".concat(r.inspectionFormStep,".projectLocation.latitude"),longitude:"".concat(r.inspectionFormStep,".projectLocation.longitude"),sectionTownship:{drivingDirection:"".concat(r.inspectionFormStep,".projectLocation.sectionTownship.drivingDirection"),firstQuarter:"".concat(r.inspectionFormStep,".projectLocation.sectionTownship.firstQuarter"),secondQuarter:"".concat(r.inspectionFormStep,".projectLocation.sectionTownship.secondQuarter"),range:"".concat(r.inspectionFormStep,".projectLocation.sectionTownship.range"),section:"".concat(r.inspectionFormStep,".projectLocation.sectionTownship.section"),township:"".concat(r.inspectionFormStep,".projectLocation.sectionTownship.township")}},onsiteInspection:{on:"".concat(r.inspectionFormStep,".onsiteInspection.on"),riverbank:"".concat(r.inspectionFormStep,".onsiteInspection.riverbank")},considerations:"".concat(r.inspectionFormStep,".considerations"),recommendation:"".concat(r.inspectionFormStep,".recommendation"),modifications:{existAlternativeOptionsRecommended:"".concat(r.inspectionFormStep,".modifications.existAlternativeOptionsRecommended"),comments:"".concat(r.inspectionFormStep,".modifications.comments")},attachments:"".concat(r.inspectionFormStep,".attachments")},[r.signaturesStep]:{[a.firstInspector]:{name:"".concat(r.signaturesStep,".firstInspector.name"),hasComment:"".concat(r.signaturesStep,".firstInspector.hasComment"),comment:"".concat(r.signaturesStep,".firstInspector.comment")},[a.secondInspector]:{name:"".concat(r.signaturesStep,".secondInspector.name"),hasComment:"".concat(r.signaturesStep,".secondInspector.hasComment"),comment:"".concat(r.signaturesStep,".secondInspector.comment")},[a.thirdInspector]:{name:"".concat(r.signaturesStep,".thirdInspector.name"),hasComment:"".concat(r.signaturesStep,".thirdInspector.hasComment"),comment:"".concat(r.signaturesStep,".thirdInspector.comment")},allSignatures:"".concat(r.signaturesStep,".allSignatures"),"signed-document":"".concat(r.signaturesStep,".signed-document"),signedInspectionFormPDF:"".concat(r.signaturesStep,".signedInspectionFormPDF"),waiveDecisionFifteenDays:"".concat(r.signaturesStep,".waiveDecisionFifteenDays")},isManualSignature:"isManualSignature"})},28066:(e,t,n)=>{n.d(t,{Uu:()=>a,_F:()=>c,ip:()=>o,qM:()=>s});let i="offline-sync-channel";
1class o extends Error{constructor(e="Sync lock is currently held by another process"){super(e),this.name="SyncLockBusyError"}}let r=Symbol("SYNC_LOCK_BUSY");async function a(e){if("undefined"==typeof navigator||!navigator.locks)return await e();let t=await navigator.locks.request("offline-sync-lock",{ifAvailable:!0},async t=>t?await e():(console.info("[SyncCoordinator] Sync lock already held. Signaling busy state."),r));if(t===r)throw new o;return t}function s(e){if(0!==e.length)try{let t=new BroadcastChannel(i);t.postMessage({type:"SYNC_COMPLETE",ids:e}),t.close()}catch(e){console.warn("[SyncCoordinator] Failed to broadcast sync complete:",e)}}function c(e){try{let t=new BroadcastChannel(i),n=t=>{var n;(null==(n=t.data)?void 0:n.type)==="SYNC_COMPLETE"&&e(t.data.ids)};return t.addEventListener("message",n),()=>{t.removeEventListener("message",n),t.close()}}catch(e){return console.warn("[SyncCoordinator] BroadcastChannel error or unsupported environment.",e),()=>{}}}},29469:(e,t,n)=>{let i;n.d(t,{D:()=>b,syncRecord:()=>k});var o=n(86315),r=n(84070),a=n(76419),s=n(24359);let c=(0,a.Ik)({id:(0,a.Yj)().required(),permitPatch:(0,a.Ik)({inspection:(0,a.Ik)({inspectionForm:(0,a.Ik)({permitInformation:(0,a.Ik)({needsInspection:(0,a.zM)().required(),dateOfInspection:(0,a.Yj)().notRequired()}),teamMemberReport:(0,a.Ik)({applicantAgent:(0,a.Yj)().notRequired(),for:(0,a.Yj)().notRequired()}),onsiteInspection:(0,a.Ik)({on:(0,a.Yj)().notRequired(),riverbank:(0,a.Yj)().notRequired()}),reviewConsiderations:(0,a.YO)((0,a.Yj)().notRequired()).notRequired(),recommendation:(0,a.Yj)().notRequired(),comments:(0,a.Ik)({alternativesOption:(0,a.Yj)().notRequired(),alternativesComments:(0,a.Yj)().notRequired()}).notRequired(),attachments:(0,a.YO)(o.Zr).notRequired()}),signatures:(0,a.Ik)({waiveDecisionFifteenDays:(0,a.zM)().notRequired(),firstInspector:(0,a.Ik)({name:(0,a.Yj)().notRequired(),hasComment:(0,a.zM)().notRequired(),comment:(0,a.Yj)().notRequired()}).notRequired(),secondInspector:(0,a.Ik)({name:(0,a.Yj)().notRequired(),hasComment:(0,a.zM)().notRequired(),comment:(0,a.Yj)().notRequired()}).notRequired(),thirdInspector:(0,a.Ik)({name:(0,a.Yj)().notRequired(),hasComment:(0,a.zM)().notRequired(),comment:(0,a.Yj)().notRequired()}).notRequired(),allSignatures:(0,a.YO)((0,a.Ik)({...r.gw.fields,type:(0,a.Yj)().oneOf(s.gE).notRequired(),clarification:(0,a.Yj)().notRequired()})).notRequired(),signedInspectionForm:(0,a.YO)(r.gw).notRequired()}).notRequired(),isManualSignature:(0,a.zM)().notRequired(),activeStep:(0,a.ai)().required()}).notRequired()}).notRequired()});var l=n(5698),d=n(69541),u=n(19137),p=n(79812),m=n(57858),g=n(59417),y=n(28066),h=n(35200),f=n(44914),v=n(50582),S=n(94083),I=n(75212);let w=f.KH.PERMIT_ATTACHMENT,P=f.KH.UPLOADED_SIGNATURE;async function A(e){let{data:t,permitId:n,s3Path:i=w,authToken:o}=e;if(!t||"object"!=typeof t)return;if(Array.isArray(t))return void await Promise.all(t.map(e=>A({data:e,permitId:n,s3Path:i,authToken:o})));let r=t.acceptedFile instanceof Blob?t.acceptedFile:null,a=!1,s="string"==typeof t.key?t.key:null,c=!!s&&s.includes("/");if(!r&&s&&s.length>0){let e=new m.KC(m.hH.INSPECTOR_DB),n=await e.getById(m.ek.MEDIA_CACHE_ST,s);(r=(null==n?void 0:n.blob)||null)||null==n||!n.newKey||(console.info("[ClientSideSync] Key already processed previously, translating: ".concat(s," -> ").concat(n.newKey)),t.key=n.newKey,a=!0)}if(c&&!r)return void console.info("[ClientSideSync] Key ".concat(s," is already an S3 path, skipping upload."));if(r instanceof Blob){let e=r instanceof File,a=e?r.name:"attachment.png",c=e?a.split(".").pop()||"png":(null==s?void 0:s.split(".").pop())||"png",l=(0,I.cZ)(r.type)||(0,I.AE)(a);console.info("[ClientSideSync] Found binary content (".concat(l?"video":"image","), orchestrating S3 upload..."));let d=new m.KC(m.hH.INSPECTOR_DB),u=await d.getById(m.ek.INSPECTION_ST,n),p=null==u?void 0:u.cdId;p||console.warn("[ClientSideSync] Could not find cdId for permit, S3 upload might fail:",n);let g=p?{cdId:p,id:n,path:i,fileTypes:[c],fileSize:r.size}:{feId:t.feId||crypto.randomUUID(),id:n,path:i,fileTypes:[c],fileSize:r.size},y=await C(o),h=await fetch("".concat((0,v.$)(),"/api/s3/").concat(n,"/upload"),{method:"POST",headers:{"Content-Type":"application/json",...y},body:JSON.stringify(g),credentials:"include"});if(!h.ok)throw Error("Failed to get signed URL for offline file upload: ".concat(h.statusText));let f=await h.json(),w=null==f?void 0:f.body;if(!w||0===w.length)throw Error("Failed to get signed URL for offline file upload");let{key:P,url:A}=w[0];await new Promise((e,t)=>
1{(0,S.f)({signedUrl:A,file:r,responseText:()=>e(),responseError:e=>t(Error(e))})});let k=new m.KC(m.hH.INSPECTOR_DB);await k.put(m.ek.MEDIA_CACHE_ST,{id:P,blob:r,contentType:r.type,cachedAt:Date.now()}),s&&s!==P&&(await k.delete(m.ek.MEDIA_CACHE_ST,s),await k.put(m.ek.MEDIA_CACHE_ST,{id:s,newKey:P,cachedAt:Date.now()})),t.key=P,delete t.acceptedFile,delete t.localUrl,console.info("[ClientSideSync] Binary upload complete:",t.key)}else"acceptedFile"in t?(delete t.acceptedFile,delete t.localUrl):"string"==typeof t.key&&t.key.length>0&&!a&&(t.key.includes("/")?console.info("[ClientSideSync] Preserving valid S3 key:",t.key):(console.warn("[ClientSideSync] Could not recover blob for placeholder key, omitting from payload to avoid NoSuchKey:",t.key),delete t.key));for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e)){let r=t[e];if(r&&"object"==typeof r){let t="signatures"===e||"uploadedSignature"===e||"signedInspectionForm"===e||"manualSignature"===e?P:i;await A({data:r,permitId:n,s3Path:t,authToken:o})}}}async function C(e){if(e)return{Authorization:"Bearer ".concat(e)};try{var t;let e=await (0,f.Kr)(),n=null==e||null==(t=e.idToken)?void 0:t.toString();if(n)return{Authorization:"Bearer ".concat(n)}}catch(e){console.warn("[ClientSideSync] Failed to retrieve Bearer token:",e)}return{}}let k=async e=>{var t,n,o,r;console.info("[ClientSideSync] Processing: ".concat(e.entity," - ").concat(e.operation));let a=e.data.id||e.id;await A({data:e.data,permitId:a});let s=new m.KC(m.hH.BACKGROUND_SYNC_DB);if(await s.put(m.ek.REQUESTS_ST,e),(0,h.AR)(e)){let r=e.data,a=function(e){var t,n,i,o,r,a,s,l;if(!e||"object"!=typeof e)return e;let d=null!=(l=null==e||null==(o=e.permitPatch)||null==(i=o.inspection)||null==(n=i.signatures)||null==(t=n.signedInspectionForm)?void 0:t.map(e=>({type:e.type,clarification:e.clarification})))?l:[],u=c.validateSync(e,{stripUnknown:!0,abortEarly:!1}),p=null==u||null==(s=u.permitPatch)||null==(a=s.inspection)||null==(r=a.signatures)?void 0:r.signedInspectionForm;return Array.isArray(p)&&p.forEach((e,t)=>{var n,i;(null==(n=d[t])?void 0:n.type)&&(e.type=d[t].type),(null==(i=d[t])?void 0:i.clarification)&&(e.clarification=d[t].clarification)}),u}(r);i=null==(n=r.permitPatch)||null==(t=n.inspection)?void 0:t.inspectionForm.permitInformation.needsInspection,console.info("[ClientSideSync] Sending inspection payload:",JSON.stringify(a));let s=await l.r.updatePermitJointApplicationInspection.mutate(a);console.info("[ClientSideSync] Inspection sync response:",JSON.stringify(s));let d=null==s||null==(o=s.updatePermitById)?void 0:o.permit;if(!(null==d?void 0:d.id))throw Error("Inspection sync failed: server returned permit: null for ".concat(e.id,". Data was NOT persisted."));return}if((0,g.z)(e)){let{url:t,body:n}=e.data;if(t.includes("/signature/submit")&&n)if(!i)return void console.info("[ClientSideSync] Skipping signature submission because needsInspection is false:",e.id);else{let t=JSON.parse(n);await A({data:t,permitId:t.id||e.id});let i=await (0,p.y)(t);if(!(i&&"body"in i&&"string"==typeof i.body&&d.jS.test(i.body)))throw Error("Signature PDF generation failed during sync: ".concat(JSON.stringify(null!=(r=null==i?void 0:i.body)?r:i)));console.info("[ClientSideSync] Signature sync success:",e.id);return}let{method:o,headers:a}=e.data,s=await fetch(t,{method:o,headers:a,body:n,credentials:"include"});if(!s.ok)throw Error("Mutation sync failed: ".concat(s.status," ").concat(s.statusText));return void console.info("[ClientSideSync] Mutation sync success:",e.id)}throw console.warn("[ClientSideSync] No handler found for entity:",e.entity),Error("No client-side handler for entity: ".concat(e.entity))},b=async()=>{try{await (0,y.Uu)(async()=>{if(!await (0,u.j8)())return void console.info("[ClientSideSync] Skipping queue processing — not actually online");let e=new m.KC(m.hH.BACKGROUND_SYNC_DB),t=m.ek.REQUESTS_ST;try{let n=await e.getAll(t);if(0===n.length)return;(0,h.sortByTimestamp)(n),console.info("[ClientSideSync] Found ".concat(n.length," pending requests. Replaying..."));let i=new Set,o=new Set;
1for(let r of n)try{if((0,h.c2)(r,o)){console.warn("[ClientSideSync] Skipping ".concat(r.id," — prior step for same permit failed"));continue}await k(r),(0,h.AR)(r)&&i.add(r.data.id),await e.delete(t,r.id)}catch(e){console.error("[ClientSideSync] Failed to replay request:",r.id,e),(0,h.kg)(r,o)}i.size>0&&(0,y.qM)(Array.from(i))}catch(e){console.error("[ClientSideSync] Queue processing failed:",e)}})}catch(e){e instanceof y.ip?console.info("[ClientSideSync] Sync lock busy (Service Worker or another context is currently syncing). Skipping this trigger."):console.error("[ClientSideSync] Critical failure during client-side offline sync:",e)}}},35200:(e,t,n)=>{n.d(t,{AR:()=>o,c2:()=>c,extractPermitIdFromPayload:()=>r,kg:()=>l,sortByTimestamp:()=>s});var i=n(59417);let o=e=>"inspection"===e.entity,r=e=>o(e)?e.data.id:(0,i.z)(e)?a(e.data.body):null,a=e=>{if(!e)return null;try{var t;let n=JSON.parse(e);if("string"==typeof n.id)return n.id;if(null==(t=n["0"])?void 0:t.permitId)return n["0"].permitId}catch(e){}return null},s=e=>e.sort((e,t)=>{if(e.timestamp!==t.timestamp)return e.timestamp-t.timestamp;if("inspection"===e.entity&&"inspection"!==t.entity)return -1;if("inspection"!==e.entity&&"inspection"===t.entity)return 1;if("mutation"===e.entity&&"mutation"===t.entity){let n=e.data,i=t.data,o=(null==n?void 0:n.url)||"",r=(null==i?void 0:i.url)||"",a=o.includes("/signature/submit")||"manualSignature"in n,s=r.includes("/signature/submit")||"manualSignature"in i;if(a&&!s)return -1;if(!a&&s)return 1}return 0}),c=(e,t)=>{let n=r(e);return null!==n&&t.has(n)},l=(e,t)=>{let n=r(e);n&&t.add(n)}}
1,37823:(e,t,n)=>{n.d(t,{VD:()=>s,YJ:()=>c,nY:()=>a});var i=n(10878),o=n(8706),r=n(26143);function a(e){return e}async function s(e,t){let n=await (0,o.V)(e,t);n.length>0&&await (0,i.R)(null==n?void 0:n[0],"".concat(t,".pdf"))}async function c(e){let t=await (0,r.GO)({url:"/permit/generateInspectionFormPDF/".concat(e),withAuthentication:!0});if(t.body)return t.body}},38610:(e,t,n)=>{n.d(t,{p2:()=>l,dI:()=>d,hU:()=>c});var i=n(5643),o=n(50741),r=n(90392);let a=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:6,t=arguments.length>1?arguments[1]:void 0;return Array(e).fill(t)};var s=n(75212);let c=(e,t)=>{let n=null==e?void 0:e.inspection,o=null==e?void 0:e.content,c=null==e?void 0:e.cdInfo,l=null==e?void 0:e.state;if(n||o||c||l){var d,u,p,m,g,y,h,f,v,S,I,w,P,A,C,k,b,T,E,R,F,N,O,D,_,M,W,q,B,U,j,L,H,Y,Q,K,x,z,G,J,V,X,$,Z,ee,et,en,ei,eo,er,ea,es,ec,el,ed,eu,ep,em,eg,ey,eh,ef,ev,eS,eI;let ew=null==n||null==(d=n.inspectionForm)?void 0:d.permitInformation,eP=null==n||null==(u=n.inspectionForm)?void 0:u.teamMemberReport,eA=null==n||null==(p=n.inspectionForm)?void 0:p.recommendation,eC=null==n||null==(m=n.inspectionForm)?void 0:m.reviewConsiderations,ek=null==n||null==(g=n.inspectionForm)?void 0:g.onsiteInspection,eb=null==n||null==(y=n.inspectionForm)?void 0:y.comments,eT=null==n?void 0:n.signatures,eE=(null==eb?void 0:eb.alternativesOption)==="true",eR=null==o||null==(f=o.projectInfo)||null==(h=f.projectSiteInformation)?void 0:h.location,eF=null==o||null==(S=o.projectInfo)||null==(v=S.projectSiteInformation)?void 0:v.sectionTownship,eN=null!=(U=null==e||null==(I=e.inspection)?void 0:I.isManualSignature)&&U,eO=null==l?void 0:l["signed-document"],eD=null!=(j=null==l?void 0:l.signedInspectionForm)?j:[];return{inspectionFormStep:{permitInformation:{needsInspection:null==(L=null==ew?void 0:ew.needsInspection)||L,state:null!=(H=null==e||null==(w=e.conservationDistrictByCdId)?void 0:w.state)?H:"",applicationNumber:null!=(Y=null==c||null==(P=c.beforeProjectStarts)?void 0:P.applicationNumber)?Y:"",dateOfInspection:(e=>{let{permitInformation:t,signedInspectionFormFileDate:n,permitStatus:o}=e,a=o===i.yGe.ReadyForCd,c=null==t?void 0:t.dateOfInspection;if(a)return(0,s.vd)(c)?(0,r.Yq)({dateTimeStamp:c}):n&&(0,s.vd)(n)?(0,r.Yq)({dateTimeStamp:n}):void 0;let l=(0,r.Yq)({dateTimeStamp:new Date().toISOString()});return(0,s.vd)(c)?(0,r.Yq)({dateTimeStamp:c}):l})({permitInformation:ew,signedInspectionFormFileDate:null==eD||null==(A=eD[0])?void 0:A.uploadedAt,permitStatus:t}),dateOfSubmissionToCd:(0,s.vd)(null==eO||null==(C=eO[0])?void 0:C.uploadedAt)?(0,r.Yq)({dateTimeStamp:null==eO||null==(k=eO[0])?void 0:k.uploadedAt}):null},teamMemberReport:{applicantAgent:null!=(Q=null==eP?void 0:eP.applicantAgent)?Q:"",for:null!=(K=null==eP?void 0:eP.for)?K:""},perennialStream:null!=(x=null==o||null==(E=o.projectInfo)||null==(T=E.projectSiteInformation)||null==(b=T.waterBody)?void 0:b.streamName)?x:"",projectLocation:{address:null!=(z=null==eR?void 0:eR.address)?z:"",nearestTown:null!=(G=null==eR?void 0:eR.nearestTown)?G:"",county:null!=(J=null==eR?void 0:eR.county)?J:"",geocode:null!=(V=null==eR?void 0:eR.geocode)?V:"",latitude:null!=(X=null==eR?void 0:eR.latitude)?X:"",longitude:null!=($=null==eR?void 0:eR.longitude)?$:"",sectionTownship:{drivingDirection:null!=(Z=null==eF?void 0:eF.drivingDirection)?Z:"",firstQuarter:null!=(ee=null==eF?void 0:eF.firstQuarter)?ee:"",secondQuarter:null!=(et=null==eF?void 0:eF.secondQuarter)?et:"",range:null!=(en=null==eF?void 0:eF.range)?en:"",section:null!=(ei=null==eF?void 0:eF.section)?ei:"",township:null!=(eo=null==eF?void 0:eF.township)?eo:""}},onsiteInspection:{on:null!=(er=null==ek?void 0:ek.on)?er:"",riverbank:null!=(ea=null==ek?void 0:ek.riverbank)?ea:""},considerations:null!=(es=null==eC?void 0:eC.map(e=>null!=e?e:""))?es:a(6,""),recommendation:null!=eA?eA:"",modifications:{existAlternativeOptionsRecommended:eE,comments:null!=(ec=null==eb?void 0:eb.alternativesComments)?ec:""},attachments:null!=(el=null==n||null==(R=n.inspectionForm)?void 0:R.attachments)?el:[]},signaturesStep:{firstInspector:{name:null!=(ed=null==eT||null==(F=eT.firstInspector)?void 0:F.name)?ed:"",hasComment:null!=(eu=null==eT||null==(N=eT.firstInspector)?void 0:N.hasComment)&&eu,comment:null!=(ep=null==eT||null==(O=eT.firstInspector)?void 0:O.comment)?ep:""},secondInspector:{name:null!=(em=null==eT||null==(D=eT.secondInspector)?void 0:D.name)?em:"",hasComment:null!=(eg=null==eT||null==(_=eT.secondInspector)?void 0:_.hasComment)&&eg,comment:null!=(ey=null==eT||null==(M=eT.secondInspector)?void 0:M.comment)?ey:""},thirdInspector:{name:null!=(eh=null==eT||null==(W=eT.thirdInspector)?void 0:W.name)?eh:"",hasComment:null!=(ef=null==eT||null==(q=eT.thirdInspector)?void 0:q.hasComment)&&ef,comment:null!=(ev=null==eT||null==(B=eT.thirdInspector)?void 0:B.comment)?ev:""},waiveDecisionFifteenDays:null!=(eS=null==eT?void 0:eT.waiveDecisionFifteenDays)&&eS,allSignatures:null!=(eI=null==eT?void 0:eT.allSignatures)?eI:[],"signed-document":[],signedInspectionFormPDF:null!=eD?eD:[]},isManualSignature:eN}}return{inspectionFormStep:{permitInformation:{needsInspection:!0,applicationNumber:"",dateOfSubmissionToCd:void 0,state:"",dateOfInspection:void 0},teamMemberReport:{applicantAgent:"",for:""}
1,perennialStream:"",projectLocation:{address:"",nearestTown:"",county:"",geocode:"",latitude:"",longitude:"",sectionTownship:{drivingDirection:"",firstQuarter:"",secondQuarter:"",range:"",section:"",township:""}},onsiteInspection:{on:"",riverbank:""},considerations:a(6,""),recommendation:"",modifications:{existAlternativeOptionsRecommended:!1,comments:""},attachments:[]},signaturesStep:{firstInspector:{name:"",hasComment:!1,comment:""},secondInspector:{name:"",hasComment:!1,comment:""},thirdInspector:{name:"",hasComment:!1,comment:""},waiveDecisionFifteenDays:!1,allSignatures:[],"signed-document":[],signedInspectionFormPDF:[]},isManualSignature:!1}},l=e=>{var t,n,i,r,a,s,c,l,d,u,p,m,g,y,h,f,v,S,I,w,P,A,C,k,b,T;let{permitId:E,formValues:R,activeStep:F,shouldFinalize:N=!1}=e,{inspectionFormStep:O,signaturesStep:D}=R,_=R.isManualSignature,M=_?null==(t=D["signed-document"])?void 0:t.map(e=>{var t,n;return{method:e.method||o.X.UPLOAD_SIGNATURE,image64:null!=(t=e.image64)?t:void 0,typedSignaturePayload:null!=(n=e.typedSignaturePayload)?n:void 0,uploadedSignature:e}}):void 0;return{id:E,permitPatch:{inspection:{inspectionForm:{permitInformation:{dateOfInspection:O.permitInformation.dateOfInspection,needsInspection:O.permitInformation.needsInspection},teamMemberReport:{applicantAgent:null==(n=O.teamMemberReport)?void 0:n.applicantAgent,for:null==(i=O.teamMemberReport)?void 0:i.for},onsiteInspection:{on:null==(r=O.onsiteInspection)?void 0:r.on,riverbank:null==(a=O.onsiteInspection)?void 0:a.riverbank},reviewConsiderations:O.considerations,recommendation:O.recommendation,comments:{alternativesOption:"".concat(null==(s=O.modifications)?void 0:s.existAlternativeOptionsRecommended),alternativesComments:null!=(v=null==(c=O.modifications)?void 0:c.comments)?v:void 0},attachments:O.attachments},signatures:{waiveDecisionFifteenDays:null==D?void 0:D.waiveDecisionFifteenDays,firstInspector:{name:null!=(S=null==D||null==(l=D.firstInspector)?void 0:l.name)?S:"",hasComment:null!=(I=null==D||null==(d=D.firstInspector)?void 0:d.hasComment)&&I,comment:null!=(w=null==D||null==(u=D.firstInspector)?void 0:u.comment)?w:void 0},secondInspector:{name:null!=(P=null==D||null==(p=D.secondInspector)?void 0:p.name)?P:"",hasComment:null!=(A=null==D||null==(m=D.secondInspector)?void 0:m.hasComment)&&A,comment:null!=(C=null==D||null==(g=D.secondInspector)?void 0:g.comment)?C:void 0},thirdInspector:{name:null!=(k=null==D||null==(y=D.thirdInspector)?void 0:y.name)?k:"",hasComment:null!=(b=null==D||null==(h=D.thirdInspector)?void 0:h.hasComment)&&b,comment:null!=(T=null==D||null==(f=D.thirdInspector)?void 0:f.comment)?T:void 0},allSignatures:null==D?void 0:D.allSignatures,signedInspectionForm:N?M:void 0},isManualSignature:N?_:void 0,activeStep:F}}}},d=e=>{let{isInspector:t,isAdmin:n,isReadOnly:o,isFetchingPermitInspectorData:r,permitStatus:a}=e;return!o&&(t||n)&&!r&&a===i.yGe.OnInspection}},59417:(e,t,n)=>{n.d(t,{z:()=>i});let i=e=>"mutation"===e.entity},85175:(e,t,n)=>{n.d(t,{V:()=>a,d:()=>o});var i=n(5643);function o(e,t){return t?e.filter(e=>(function e(t,n){return!(n.and&&!n.and.every(n=>e(t,n))||n.or&&!n.or.some(n=>e(t,n))||n.not&&e(t,n.not))&&(!n.id||!!r(t.id,n.id))&&(!n.applicantName||!!r(t.applicantName,n.applicantName))&&(!n.streamName||!!r(t.streamName,n.streamName))&&(!n.submittedAt||!!r(t.submittedAt,n.submittedAt))&&(!n.createdAt||!!r(t.createdAt,n.createdAt))&&(!n.permitStatus||!!r(t.permitStatus,n.permitStatus))&&!0})(e,t)):e}function r(e,t){return!0===t.isNull?null===e:!1===t.isNull?null!==e:null!=e&&!(void 0!==t.equalTo&&e!==t.equalTo||void 0!==t.equalToInsensitive&&null!==t.equalToInsensitive&&e.toLowerCase()!==t.equalToInsensitive.toLowerCase()||void 0!==t.includes&&null!==t.includes&&!e.includes(t.includes)||void 0!==t.includesInsensitive&&null!==t.includesInsensitive&&!e.toLowerCase().includes(t.includesInsensitive.toLowerCase())||void 0!==t.in&&Array.isArray(t.in)&&!t.in.includes(e))&&(void 0===t.greaterThanOrEqualTo||null===t.greaterThanOrEqualTo||!(e<t.greaterThanOrEqualTo))&&(void 0===t.lessThanOrEqualTo||null===t.lessThanOrEqualTo||!(e>t.lessThanOrEqualTo))}function a(e,t){if(!t)return[...e];let n=[...e];return n.sort((e,n)=>{switch(t){case i.OXx.SubmittedAtAsc:return s(e.submittedAt,n.submittedAt);case i.OXx.SubmittedAtDesc:return s(n.submittedAt,e.submittedAt);case i.OXx.ApplicantNameAsc:return s(e.applicantName,n.applicantName);case i.OXx.ApplicantNameDesc:return s(n.applicantName,e.applicantName);case i.OXx.CreatedAtAsc:return s(e.createdAt,n.createdAt);case i.OXx.CreatedAtDesc:return s(n.createdAt,e.createdAt);case i.OXx.StreamNameAsc:return s(e.streamName,n.streamName);case i.OXx.StreamNameDesc:return s(n.streamName,e.streamName);default:return 0}}),n}
1function s(e,t){return e===t?0:null==e?1:null==t?-1:"string"==typeof e&&"string"==typeof t?e.localeCompare(t):"number"==typeof e&&"number"==typeof t?e-t:e instanceof Date&&t instanceof Date?e.getTime()-t.getTime():("string"==typeof e||"number"==typeof e||"boolean"==typeof e)&&("string"==typeof t||"number"==typeof t||"boolean"==typeof t)?e<t?-1:1:0}},92111:(e,t,n)=>{n.d(t,{P:()=>a,getOfflineMediaManager:()=>c});var i=n(36880),o=n(57858),r=n(50582);class a{extractMediaKeys(e,t){let n=new Set,i=(e,t)=>{if(null==e)return;if(0===t.length)return void("string"==typeof e&&e.trim().length>0?e.startsWith("http")||n.add(e):Array.isArray(e)&&e.forEach(e=>{"string"==typeof e&&e.trim().length>0&&!e.startsWith("http")&&n.add(e)}));if(Array.isArray(e))return void e.forEach(e=>i(e,t));let[o,...r]=t;"object"==typeof e&&null!==e&&i(e[o],r)};return t.forEach(t=>i(e,t.split("."))),Array.from(n)}async cacheMedia(e){let t=e.filter(e=>!!e);await Promise.allSettled(t.map(async e=>{try{var t;if(await this.mediaStoreManager.getById(o.ek.MEDIA_CACHE_ST,e))return;let n=await (0,i.G)({url:"".concat((0,r.$)(),"/api/s3/download"),init:{method:"POST",body:JSON.stringify({fileKeys:[{key:e}],zip:!1})}}),a=null==n||null==(t=n.body)?void 0:t[0];if(!(null==a?void 0:a.url)||a.url.includes("undefined")||!a.url.startsWith("http"))return;let s=await (0,i.G)({url:a.url,responseType:"blob",withAuthentication:!1});if(!s)return;await this.mediaStoreManager.put(o.ek.MEDIA_CACHE_ST,{id:e,blob:s,contentType:s.type||a.type,name:a.name,size:a.size,cachedAt:Date.now()})}catch(t){console.warn("[OfflineMediaManager] Failed to cache media ".concat(e,":"),t)}}))}async getMediaBlob(e){let t=await this.mediaStoreManager.getById(o.ek.MEDIA_CACHE_ST,e);return null==t?void 0:t.blob}async savePendingUpload(e,t){await this.mediaStoreManager.put(o.ek.MEDIA_CACHE_ST,{id:e,blob:t,contentType:t.type,cachedAt:Date.now()})}async deleteCachedMedia(e){let t=await this.mediaStoreManager.getById(o.ek.MEDIA_CACHE_ST,e);(null==t?void 0:t.newKey)&&await this.mediaStoreManager.delete(o.ek.MEDIA_CACHE_ST,t.newKey),await this.mediaStoreManager.delete(o.ek.MEDIA_CACHE_ST,e)}async getMediaItem(e){return this.mediaStoreManager.getById(o.ek.MEDIA_CACHE_ST,e)}constructor(e=o.hH.INSPECTOR_DB){this.mediaStoreManager=new o.KC(e)}}let s=null,c=()=>(s||(s=new a),s)},99266:(e,t,n)=>{n.d(t,{s:()=>L,Q:()=>H});var i=n(6207),o=n(29847),r=n(83280),a=n(19137),s=n(28066),c=n(35200),l=n(29469),d=n(57858);
1class u{start(){if(!(0,r.isIosDevice)())return void console.info("[IosSyncManager] Non-iOS device detected. Sync watcher dormant.");console.info("[IosSyncManager] iOS detected. Initializing main-thread sync watcher."),window.addEventListener("online",()=>{console.info("[IosSyncManager] Device reported online. Triggering sync..."),this.sync()}),this.sync(),setInterval(()=>{this.sync()},3e5)}async sync(){if(!this.isProcessing){if(!await (0,a.j8)())return void console.info("[IosSyncManager] Device is offline. Skipping sync.");try{this.isProcessing=!0,await (0,s.Uu)(async()=>{let e=await this.getPendingRequests();if(0===e.length)return;let{sortByTimestamp:t}=await Promise.resolve().then(n.bind(n,35200)),i=t([...e]);console.info("[IosSyncManager] Starting replay of ".concat(i.length," item(s)..."));let o=[];for(let e of i)await this.processQueueItem(e)&&(0,c.AR)(e)&&o.push(e.data.id);o.length>0&&(0,s.qM)(o)})}catch(e){e instanceof s.ip?console.info("[IosSyncManager] Sync lock busy (another tab/worker is syncing). Skipping this attempt."):console.error("[IosSyncManager] Critical failure during sync loop:",e)}finally{this.isProcessing=!1}}}async pushRequest(e,t){var n;await this.idbAdapter.put(this.storeName,{...e,id:e.id,timestamp:e.timestamp||Date.now(),retryCount:null!=(n=e.retryCount)?n:0}),this.sync().catch(e=>console.error("[IosSyncManager] Immediate sync attempt failed:",e))}async getQueueStatus(){try{let e=await this.idbAdapter.getAll(this.storeName);return{pendingCount:e.length,failedCount:e.filter(e=>e.retryCount>3).length,lastSyncTime:e.length>0?new Date(Math.min(...e.map(e=>e.timestamp))).toISOString():null,totalProcessed:this.totalProcessed,isProcessing:this.isProcessing}}catch(e){return console.error("Failed to get queue status:",e),{pendingCount:0,failedCount:0,lastSyncTime:null,totalProcessed:this.totalProcessed,isProcessing:this.isProcessing}}}async clearQueue(){await this.idbAdapter.clear(this.storeName),console.info("Sync queue cleared")}async getPendingRequests(){try{return await this.idbAdapter.getAll(this.storeName)}catch(e){return console.error("Failed to get pending requests:",e),[]}}async removeRequest(e){await this.idbAdapter.delete(this.storeName,e)}async updateRetryCount(e,t){let n=await this.idbAdapter.getById(this.storeName,e);n&&(n.retryCount=t,await this.idbAdapter.put(this.storeName,n))}async hasPendingRequestsByPermitId(e){try{let t=await this.getPendingRequests();if(0===t.length)return!1;let{extractPermitIdFromPayload:i}=await Promise.resolve().then(n.bind(n,35200));return t.some(t=>i(t)===e)}catch(e){return console.error("[IosSyncManager] Failed to check for pending requests by permit ID:",e),!1}}async getQueueSize(){return(await this.getQueueStatus()).pendingCount}async processQueueItem(e){try{return await (0,l.syncRecord)(e),await this.removeRequest(e.id),this.totalProcessed+=1,console.info("[IosSyncManager] Synced ".concat(e.entity,": ").concat(e.id)),!0}catch(t){return console.error("[IosSyncManager] Failed ".concat(e.entity,": ").concat(e.id),t),await this.handleFailedItem(e),!1}}async handleFailedItem(e){var t;let n=(null!=(t=e.retryCount)?t:0)+1;await this.updateRetryCount(e.id,n),n>3&&console.warn("[IosSyncManager] Item ".concat(e.id," exceeded retry threshold ")+"(".concat(n,"/").concat(3,"). ")+"Check via getQueueStatus().failedCount.")}constructor(){this.storeName=d.ek.REQUESTS_ST,this.totalProcessed=0,this.isProcessing=!1,this.idbAdapter=new d.KC(d.hH.BACKGROUND_SYNC_DB)}}var p=n(44914);let m=e=>{console.error("[SW Error] ".concat(e.tagName," - ").concat(e.error.module,".").concat(e.error.component,".").concat(e.error.func,": ").concat(e.error.message))};class g{async pushRequest(e,t){var i;this.isProcessing=!0;let o=null!=(i=null==t?void 0:t.skipNetworkAttempt)&&i;try{if("undefined"==typeof navigator)throw Error("Not running in browser context");if(o)throw Error("Offline: skipping network attempt, queueing directly to IDB");await (0,s.Uu)(async()=>{let t=await this.getQueueSize();if(t>0)throw Error("Queue not empty (".concat(t," items pending). Preserving First In, First Out order."));let{syncRecord:i}=await Promise.resolve().then(n.bind(n,29469));await i(e),this.totalProcessed+=1;
1let o=[e.id];(0,c.AR)(e)&&e.data.id&&o.push(e.data.id),(0,s.qM)(o),console.info("Request synced successfully (Live Sync):",e.entity)})}catch(i){let t=i instanceof s.ip?"Sync lock busy (possible background sync in progress)":i.message;console.info("[PWA Adapter] Request queued for background sync (".concat(t,"):"),e.id);try{let t;await this.saveToQueue(e);let{isIosDevice:i}=await Promise.resolve().then(n.bind(n,83280));if(!i()&&"serviceWorker"in navigator&&"sync"in ServiceWorkerRegistration.prototype&&(t=await navigator.serviceWorker.ready),(null==t?void 0:t.sync)&&(await t.sync.register("background-sync"),console.debug("[PWA Adapter] Sync tag registered for NEXT loop.")),this.isProcessing)return}catch(e){throw m({error:{module:"SerwistBackgroundSyncQueue",component:"pushRequest",func:"pushRequest",message:"Failed to queue mutation: ".concat(e)},tagName:"SERWIST_BACKGROUND_SYNC_QUEUE"}),e}}finally{this.isProcessing=!1}}async getQueueStatus(){try{let e=await this.idbAdapter.getAll(this.storeName);return{pendingCount:e.length,failedCount:e.filter(e=>e.retryCount>3).length,lastSyncTime:e.length>0?new Date(Math.min(...e.map(e=>e.timestamp))).toISOString():null,totalProcessed:this.totalProcessed,isProcessing:this.isProcessing}}catch(e){return console.error("Failed to get queue status:",e),{pendingCount:0,failedCount:0,lastSyncTime:null,totalProcessed:this.totalProcessed,isProcessing:this.isProcessing}}}async clearQueue(){await this.idbAdapter.clear(this.storeName),console.info("Sync queue cleared")}async getPendingRequests(){try{return await this.idbAdapter.getAll(this.storeName)}catch(e){return console.error("Failed to get pending requests:",e),[]}}async removeRequest(e){await this.idbAdapter.delete(this.storeName,e)}async updateRetryCount(e,t){let n=await this.idbAdapter.getById(this.storeName,e);n&&(n.retryCount=t,await this.idbAdapter.put(this.storeName,n))}async hasPendingRequestsByPermitId(e){try{let t=await this.getPendingRequests();if(0===t.length)return!1;let{extractPermitIdFromPayload:i}=await Promise.resolve().then(n.bind(n,35200));return t.some(t=>i(t)===e)}catch(e){return console.error("[PWA Adapter] Failed to check for pending requests by permit ID:",e),!1}}async getQueueSize(){return(await this.getQueueStatus()).pendingCount}async saveToQueue(e){var t,n;let i=await (0,p.Kr)(),o=null==i||null==(t=i.idToken)?void 0:t.toString();await this.idbAdapter.put(this.storeName,{...e,id:e.id,timestamp:e.timestamp||Date.now(),authToken:e.authToken||o,retryCount:null!=(n=e.retryCount)?n:0})}constructor(){this.storeName=d.ek.REQUESTS_ST,this.totalProcessed=0,this.isProcessing=!1,this.idbAdapter=new d.KC(d.hH.BACKGROUND_SYNC_DB)}}var y=n(36324);class h{onUpdateAvailable(e){if(!this.swClient)return()=>{};let t=()=>{console.info("[PWA] Update detected - new service worker waiting"),e()};this.swClient.addEventListener("waiting",t);let n=()=>{console.info("[PWA] New service worker installed")};return this.swClient.addEventListener("installed",n),()=>{this.swClient&&(this.swClient.removeEventListener("waiting",t),this.swClient.removeEventListener("installed",n))}}async messageSW(e){if(!this.swClient)throw m({error:{module:"SerwistPWAAdapter",component:"messageSW",func:"messageSW",message:"Serwist client not initialized (server-side render)"},tagName:"SERWIST_PWA_ADAPTER"}),Error("Serwist client not initialized (server-side render)");return this.swClient.messageSW(e)}messageSkipWaiting(){if(!this.swClient)return void console.info("[PWA] Cannot skip waiting - client not initialized");this.swClient.messageSkipWaiting()}async registerWorker(){return this.swClient?(this.registrationPromise?console.info("[PWA] Service Worker registration already in progress, waiting..."):this.registrationPromise=(async()=>{try{var e;console.info("[PWA] Registering Service Worker instance...");let t=await (null==(e=this.swClient)?void 0:e.register());return this.startPeriodicUpdateChecks(),t&&"waiting"in t&&t.waiting&&(console.info("[PWA] Update already waiting on registration"),window.dispatchEvent(new CustomEvent("swUpdate",{detail:"Update available"}))),!!t}catch(e){return m({error:{module:"SerwistPWAAdapter",component:"registerWorker",func:"registerWorker",message:"Service Worker registration failed"},tagName:"SERWIST_PWA_ADAPTER"}),!1}finally{this.registrationPromise=null}})(),await this.registrationPromise):(console.info("[PWA] Cannot register worker - client not initialized (server-side render)"),!1)}async checkForUpdate(){if(!this.swClient)return console.info("[PWA] Cannot check for update - client not initialized"),!1;try{return console.info("[PWA] Checking for service worker updates..."),await this.swClient.update(
1),!0}catch(e){try{let e=await this.getRegistration();if(e)return await e.update(),!0}catch(e){m({error:{module:"SerwistPWAAdapter",component:"checkForUpdate",func:"checkForUpdate",message:"Failed to check for worker update via both Serwist and Navigator"},tagName:"SERWIST_PWA_ADAPTER"})}return!1}}startPeriodicUpdateChecks(){this.updateCheckInterval&&clearInterval(this.updateCheckInterval),this.updateCheckInterval=setInterval(()=>{this.checkForUpdate()},6e4),"undefined"==typeof document||this.visibilityHandler||(this.visibilityHandler=()=>{document.hidden||(console.info("[PWA] App became visible, checking for updates..."),this.checkForUpdate())},document.addEventListener("visibilitychange",this.visibilityHandler))}stopPeriodicUpdateChecks(){this.updateCheckInterval&&(clearInterval(this.updateCheckInterval),this.updateCheckInterval=null),"undefined"!=typeof document&&this.visibilityHandler&&(document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null)}async getRegistration(){if("serviceWorker"in navigator)return await navigator.serviceWorker.getRegistration()}notifyUpdateAvailable(e){window.dispatchEvent(new CustomEvent("swUpdate",{detail:null!=e?e:"A new version is available!"}))}constructor(){this.swClient=null,this.updateCheckInterval=null,this.registrationPromise=null,this.visibilityHandler=null,"undefined"!=typeof navigator&&(this.swClient=new y.ge("/sw.js",{updateViaCache:"none"}))}}function f(){let[e,t]=(0,o.useState)({inProgress:!1,total:0,progress:0,currentFile:"",completed:!1}),n=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!("serviceWorker"in navigator))return;let e=e=>{"CACHING_STARTED"===e.data.type?t({inProgress:!0,total:e.data.payload.total,progress:0,currentFile:"",completed:!1}):"CACHING_PROGRESS"===e.data.type?t(t=>({...t,progress:e.data.payload.progress,total:e.data.payload.total,currentFile:e.data.payload.page})):"CACHING_COMPLETE"===e.data.type&&(t(e=>({...e,inProgress:!1,completed:!0})),setTimeout(()=>{t(e=>({...e,completed:!1}))},3e3))};n.current=e;try{let t=navigator.serviceWorker;t&&t.addEventListener("message",e)}catch(e){console.warn("[CachingProgress] Failed to add service worker listener:",e)}return()=>{try{"serviceWorker"in navigator&&navigator.serviceWorker&&n.current&&navigator.serviceWorker.removeEventListener("message",n.current)}catch(e){console.warn("[CachingProgress] Failed to remove service worker listener:",e)}}},[]);let{progress:i,total:r}=e;return null}class v{constructor(e,t){this.online=e,this.offline=t}}var S=n(75212);function I(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new WeakMap;if(w(e)&&w(t)){if(n.has(t))return n.get(t);let i={...e};return n.set(t,i),Object.keys(t).forEach(o=>{let r=t[o],a=e[o];w(r)&&w(a)?i[o]=I(a,r,n):void 0!==r&&(i[o]=r)}),i}return{...e}}function w(e){return(0,S.Gv)(e)&&!Array.isArray(e)}var P=n(92111),A=n(85175),C=n(34510),k=n(48363),b=n(38610);let T=d.hH.INSPECTOR_DB,E=d.ek.INSPECTION_ST,R=d.ek.INSPECTION_SUMMARY_ST;class F{getMonotonicTimestamp(){let e=Math.max(Date.now(),(F.lastIdbTimestamp||0)+1);return F.lastIdbTimestamp=e,e}async getAllInspections(e){let t=await this.localStoreManager.getAll(R);if(!t||0===t.length)return[];let n=(0,A.d)(t,e.filter);return(0,A.V)(n,e.orderBy)}async getInspectionById(e){let t=await this.localStoreManager.getById(E,e.id);if(t)return(e=>{var t,n,i;let o=JSON.parse(JSON.stringify(e)),r=o.content;if(null==r||null==(t=r.applicantInfo)?void 0:t.permitInformation){let e=r.applicantInfo.permitInformation;"boolean"==typeof e.isAnnualMaintenancePermit&&(e.annualMaintenance=e.isAnnualMaintenancePermit?"yes":"no"),"boolean"==typeof e.consentedLandowner&&(e.consentedLandowner=e.consentedLandowner?"yes":"no")}if(null==r||null==(i=r.construction)||null==(n=i.constructionDetails)?void 0:n.projectTimeline){let e=r.construction.constructionDetails.projectTimeline;"boolean"==typeof e.alreadyCompleted&&(e.alreadyCompleted=e.alreadyCompleted?"yes":"no")}let a=o.inspection;if(null==a?void 0:a.inspectionForm){let e=a.inspectionForm;e.comments&&"boolean"==typeof e.comments.alternativesOption&&(e.comments.alternativesOption=String(e.comments.alternativesOption))}return o}
1)(t)}async updateInspectionById(e,t){return await this.updateLocalStore(e),{data:{updatePermitById:{permit:{id:e.id}}}}}async updateLocalStore(e,t){let n,i=await this.getInspectionById({id:e.id});if(i){var o,r,a,s,c;n=I(i,{id:e.id,inspection:I(i.inspection||{},(null==(o=e.permitPatch)?void 0:o.inspection)||{}),state:I(i.state||{},{activeStep:null!=(c=null==(a=e.permitPatch)||null==(r=a.inspection)?void 0:r.activeStep)?c:null==(s=i.state)?void 0:s.activeStep})}),t&&(n.permitPermitStatusesByPermitId||(n.permitPermitStatusesByPermitId={nodes:[]}),n.permitPermitStatusesByPermitId.nodes||(n.permitPermitStatusesByPermitId.nodes=[]),0===n.permitPermitStatusesByPermitId.nodes.length?n.permitPermitStatusesByPermitId.nodes.push({permitStatus:t}):n.permitPermitStatusesByPermitId.nodes[0]={...n.permitPermitStatusesByPermitId.nodes[0],permitStatus:t},n.permitStatus=t)}else n=function(e){var t,n,i;let o=(null==(n=e.permitPatch)||null==(t=n.inspection)?void 0:t.activeStep)||1,r=(0,C.ao)(),a=(0,k.Wc)({values:r,permitId:e.id,state:{activeStep:1,version:{version_number:1,version_year:2025}}}),s=(0,b.hU)(),c=(0,b.p2)({permitId:e.id,formValues:s,activeStep:o}),l=a.permitPatch,d=null==(i=c.permitPatch)?void 0:i.inspection;return{id:e.id,cdId:(null==l?void 0:l.cdId)||"",conservationDistrictByCdId:{name:"",state:""},content:null==l?void 0:l.content,permitPermitStatusesByPermitId:{nodes:[]},permitType:"JOINT_APPLICATION",cdInfo:null,inspection:d,state:{activeStep:o,version:{version_number:1,version_year:2025}}}}(e),t&&(n.permitPermitStatusesByPermitId||(n.permitPermitStatusesByPermitId={nodes:[]}),n.permitPermitStatusesByPermitId.nodes||(n.permitPermitStatusesByPermitId.nodes=[]),0===n.permitPermitStatusesByPermitId.nodes.length?n.permitPermitStatusesByPermitId.nodes.push({permitStatus:t}):n.permitPermitStatusesByPermitId.nodes[0]={...n.permitPermitStatusesByPermitId.nodes[0],permitStatus:t},n.permitStatus=t);await this.localStoreManager.put(E,{...n})}async cacheAllInspections(e){for(let t of e)t.id&&await this.localStoreManager.put(R,{id:t.id,...t})}async cacheInspection(e,t){await this.localStoreManager.put(E,{id:e,...t});let n=this.mediaManager.extractMediaKeys(t,this.MEDIA_KEY_PATHS);n.length>0&&this.mediaManager.cacheMedia(n)}async hasPendingRequestsByPermitId(e){return this.syncQueue.hasPendingRequestsByPermitId(e)}async pushToSyncQueue(e){let t={id:e.id,operation:"UPDATE",entity:"inspection",data:e,timestamp:this.getMonotonicTimestamp(),retryCount:0};await this.syncQueue.pushRequest(t,{skipNetworkAttempt:!0})}async pushMutationToSyncQueue(e){let t={id:crypto.randomUUID(),operation:"UPDATE",entity:"mutation",data:{url:e.url||"",method:e.method||"PATCH",headers:e.headers||{"Content-Type":"application/json"},body:e.body||("manualSignature"in e?JSON.stringify(e):void 0)},timestamp:this.getMonotonicTimestamp(),retryCount:0};await this.syncQueue.pushRequest(t,{skipNetworkAttempt:!0})}constructor(e){this.syncQueue=e,this.MEDIA_KEY_PATHS=["inspection.inspectionForm.attachments.key","inspection.signatures.allSignatures.uploadedSignature.key","inspection.signatures.allSignatures.key","inspection.signatures.signedInspectionForm.uploadedSignature.key","inspection.signatures.signedInspectionForm.key","state.signed-document.uploadedSignature.key","state.signed-document.key","state.signedInspectionForm.uploadedSignature.key","state.signedInspectionForm.key"],this.localStoreManager=new d.KC(T),this.mediaManager=new P.P(T)}}F.lastIdbTimestamp=0;var N=n(5698),O=n(24544);class D{async getAllInspections(e){try{return await N.r.getPermitInspectorSummary.query(e)}catch(e){throw(0,O.vV)({error:{module:"PWA Inspector Domain",component:"online-repo.ts",func:"getAllInspections",message:e instanceof Error?e.message:"Unknown error"},tagName:"PWA_INSPECTOR_DOMAIN"}),e}}async getInspectionById(e){try{let t=await N.r.getInspectionByPermitId.query(e),n=await N.r.getInspectorsAssignedToPermit.query({permitId:e.id}).then(e=>{var t,n;return null!=(n=null==e||null==(t=e.getInspectorsAssignedToPermit)?void 0:t.nodes)?n:[]}).catch(()=>[]);return{...t,assignedInspectors:n}}catch(t){throw(0,O.vV)({error:{module:"PWA Inspector Domain",component:"online-repo.ts",func:"getInspectionById",message:t instanceof Error?t.message:"Unknown error"},tagName:"PWA_INSPECTOR_DOMAIN",context:{args:e}}),t}}async updateInspectionById(e,t){try{if(null==t?void 0:t.headers){var n;let i=await (0,p.Kr)(),o=null==i||null==(n=i.idToken)?void 0:n.toString(),r=await fetch("/api/trpc/updatePermitJointApplicationInspection",{method:"POST",headers:{"Content-Type":"application/json",...o?{Authorization:"Bearer ".concat(o)}:{},...t.headers},body:JSON.stringify(e)});if(!r.ok)throw Error("Failed to update inspection via fetch: ".concat(r.statusText));return await r.json()}let i=await N.r.updatePermitJointApplicationInspection.mutate(e);if(!i)throw Error("Server returned empty response for updateInspection");return i}catch(e){throw(0,O.vV)({error:{module:"PWA Inspector Domain",component:"online-repo.ts",func:"updateInspection",message:e instanceof Error?e.message:"Unknown error"},tagName:"PWA_INSPECTOR_DOMAIN"}),e}}async hasPendingRequestsByPermitId(e){return!1}}var _=n(79812);async function M(e,t){let{onlineFetch:n,offlineFetch:i,cacheData:o,operationName:r,domainName:a,errorTag:s}=t,c=await e.isOnline();console.log("[".concat(a,"Service] ").concat(r," - isOnline:"),c);try{if(!c)return console.log("[".concat(a,"Service] Offline - reading ").concat(r," from IndexedDB")),await i();{let e=await n();return e&&(console.log("[".concat(a,"Service] Caching ").concat(r," for offline")),await o(e)),e}}catch(e){(0,O.vV)({error:{module:"PWA ".concat(a," Service"),component:"fetch-with-cache.ts",func:r,message:e instanceof Error?e.message:"Unknown error"},tagName:s,context:{isOnline:c}});try{let e=await i();if(e&&(!Array.isArray(e)||e.length>0))return console.warn("[".concat(a,"Service] ").concat(r," - Online fetch failed, served from IndexedDB cache.")),e}catch(e){console.error("[".concat(a,"Service] ").concat(r," - Cache fallback failed:"),e)}throw e}}let W="Inspector";class q{async getAllInspections(e){return M({isOnline:a.j8},{onlineFetch:()=>this.inspectorRepo.online.getAllInspections(e),offlineFetch:()=>this.inspectorRepo.offline.getAllInspections(e),cacheData:e=>e?this.inspectorRepo.offline.cacheAllInspections(e):Promise.resolve(),operationName:"getAllInspections",domainName:W,errorTag:"PWA_INSPECTOR_DOMAIN"})}async getInspectionById(e){return M({isOnline:a.j8},{onlineFetch:()=>this.inspectorRepo.online.getInspectionById(e),offlineFetch:()=>this.inspectorRepo.offline.getInspectionById(e),cacheData:t=>t?this.inspectorRepo.offline.cacheInspection(e.id,t):Promise.resolve(),operationName:"getInspectionById",domainName:W,errorTag:"PWA_INSPECTOR_DOMAIN"})}async updateInspectionById(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.id,i=async()=>{var i;await this.inspectorRepo.offline.updateLocalStore(e),console.info("[InspectorService] Local store updated:",n);let o=await this.inspectorRepo.offline.getInspectionById({id:n}),r=null!=(i=e.permitPatch)?i:{},s=(e=>{var t,n;let i=structuredClone(e),o=null==(t=i.permitPatch)?void 0:t.inspection;if(o){o.signatures&&"boolean"==typeof o.signatures.waiveDecisionFifteenDays&&(o.signatures.waiveDecisionFifteenDays=String(o.signatures.waiveDecisionFifteenDays));let e=null==(n=o.inspectionForm)?void 0:n.comments;e&&"boolean"==typeof e.alternativesOption&&(e.alternativesOption=String(e.alternativesOption))}return i})({id:n,permitPatch:{...r,inspection:I((null==o?void 0:o.inspection)||{},(null==r?void 0:r.inspection)||{})}});if(!await this.inspectorRepo.offline.hasPendingRequestsByPermitId(e.id)&&await (0,a.j8)()){let e=t.skipInterceptor?{headers:{"x-pwa-skip-interceptor":"true"}}:void 0;return await this.inspectorRepo.online.updateInspectionById(s,e)}return await this.stageBinaryFiles(s),await this.inspectorRepo.offline.pushToSyncQueue(s),{data:{updatePermitById:{permit:{id:n}}}}};return t.skipLock?await i():await (0,s.Uu)(i)}async submitInspection(e){let t=e.statusUpdate.permitId;console.info("[InspectorService] Unified submission initiated for permit:",t),await (0,s.Uu)(async()=>{let n=!await this.inspectorRepo.offline.hasPendingRequestsByPermitId(t)&&await (0,a.j8)();if(await this.updateInspectionById(e.inspectionUpdate,{skipLock:!0,skipInterceptor:n}),n){if(!await (0,_.y)(e.signatureSubmit))throw Error("Signature submission failed online.")}else await this.inspectorRepo.offline.pushMutationToSyncQueue({url:"/api/signature/submit",method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e.signatureSubmit)});await this.inspectorRepo.offline.updateLocalStore(I(e.inspectionUpdate,{permitPatch:{inspection:{isManualSignature:!!e.signatureSubmit.manualSignature}}}),e.statusUpdate.newPermitStatus)}),console.info("[InspectorService] Unified submission orchestrated (held in sync queue if busy or offline).")}
1async checkPWAStatus(){try{return await this.pwaProvider.checkForUpdate()}catch(e){throw(0,O.vV)({error:{module:"PWA Inspector Service",component:"service.ts",func:"checkPWAStatus",message:e instanceof Error?e.message:"Unknown error"},tagName:"PWA_INSPECTOR_DOMAIN"}),e}}async stageBinaryFiles(e){if(e&&"object"==typeof e){if(Array.isArray(e))return void await Promise.all(e.map(e=>this.stageBinaryFiles(e)));if(e.key&&"string"==typeof e.key&&e.acceptedFile instanceof Blob){var t;await (null==(t=(0,P.getOfflineMediaManager)())?void 0:t.savePendingUpload(e.key,e.acceptedFile))}for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let n=e[t];n&&"object"==typeof n&&await this.stageBinaryFiles(n)}}}constructor(e,t){this.inspectorRepo=e,this.pwaProvider=t}}let B=null,U=null;{B=new h;let e=(0,r.isIosDevice)()?new u:new g;U=new v(new D,new F(e)),(0,r.isIosDevice)()&&e.start()}let j=(0,o.createContext)(void 0),L=e=>{let{children:t}=e,n=(0,o.useRef)(!1),r=(0,o.useRef)(null),a=(0,o.useRef)(!1),s=e=>{try{try{sessionStorage.setItem("pwa_reload_path",e)}catch(e){}setTimeout(()=>{window.location.reload()},100)}catch(e){console.error("[PWA] Error during reload:",e),window.location.reload()}},c=(0,o.useCallback)(()=>{if(!B)return;console.log("[PWA] Auto-applying update - signaling skip waiting..."),B.notifyUpdateAvailable(),n.current=!0;let e=window.location.pathname;try{B.messageSkipWaiting(),setTimeout(()=>{n.current&&(console.log("[PWA] Controller change timeout, forcing reload..."),s(e))},1e3)}catch(t){console.error("[PWA] Failed to signal service worker to skip waiting:",t),s(e)}},[]),l=(0,o.useCallback)(()=>{console.log("[PWA] Update detected - auto-applying..."),c()},[c]);(0,o.useEffect)(function(){if(!B)return void console.warn("[PWA] PWA adapter not available (server-side render)");let e=!0;(async()=>{try{if(a.current)return void console.log("[PWA] Registration already attempted, skipping");r.current=B.onUpdateAvailable(l),(async()=>{if(B&&e&&!a.current){a.current=!0;try{if(console.log("registerSW ~ success:","registerWorker"),await B.registerWorker()&&e){console.log("[PWA] Service Worker registered successfully");let t=await B.getRegistration();(null==t?void 0:t.waiting)&&e&&(console.log("[PWA] Found waiting service worker immediately after registration"),l()),e&&setTimeout(()=>{B&&e&&(console.log("[PWA] Performing initial update check..."),B.checkForUpdate())},1e3)}else e?console.warn("[PWA] Service Worker registration failed"):console.log("[PWA] Component unmounted, skipping registration callbacks")}catch(t){e&&console.error("[PWA] Service Worker registration error:",t)}}})()}catch(e){console.error("[PWA] Error checking consent:",e)}})();let t=()=>{e&&l()};window.addEventListener("swUpdate",t);let i=async e=>{"SW_INSTALLING"===e.data.type&&console.log("[PWA] Service worker installing, version:",e.data.version)};"serviceWorker"in navigator&&navigator.serviceWorker&&navigator.serviceWorker.addEventListener("message",i);let o=null;return"serviceWorker"in navigator&&navigator.serviceWorker&&(o=()=>{if(!n.current)return;console.log("[PWA] Controller changed, reloading...");let e="/";try{let t=sessionStorage.getItem("pwa_reload_path");t&&(e=t,sessionStorage.removeItem("pwa_reload_path"))}catch(e){}setTimeout(()=>{try{e!==window.location.pathname?window.location.href=e:window.location.reload()}catch(e){console.warn("[PWA] Error during controller change reload:",e),window.location.reload()}},50)},navigator.serviceWorker.addEventListener("controllerchange",o)),()=>{e=!1,window.removeEventListener("swUpdate",t),"serviceWorker"in navigator&&navigator.serviceWorker&&(navigator.serviceWorker.removeEventListener("message",i),o&&navigator.serviceWorker.removeEventListener("controllerchange",o)),r.current&&r.current()}},[l]);let d=(0,o.useMemo)(()=>({inspectorService:new q(U,B)}),[]);return(0,i.jsxs)(j.Provider,{value:d,"data-sentry-element":"PwaContext.Provider","data-sentry-component":"PwaProvider","data-sentry-source-file":"pwa-provider.tsx",children:[t,(0,i.jsx)(f,{"data-sentry-element":"CachingProgress","data-sentry-source-file":"pwa-provider.tsx"})]})},H=()=>{let e=(0,o.useContext)(j);if(!e)throw Error("usePwa must be used within PwaProvider");return e}}}]);

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