'use strict'; const assert=require('assert/strict'); const {functionSource,read}=require('./helpers/app-source'); const bindBoard=functionSource('bindBoard'),takeBatch=functionSource('takeCloudPendingBatch'),pushPending=functionSource('pushCloudPending'),claim=functionSource('requestBoardClaim'),handleRealtime=functionSource('handleRealtimeMessage'),scheduleRemote=functionSource('scheduleRemoteWorldPull'); assert(read('index.html').includes('app.js?v=48.0.3'),'The gameplay hotfix is not cache-busted for already-open v48.0 browsers'); assert(bindBoard.includes("boardTarget=e.target.closest?.('.board-input-surface')")&&bindBoard.includes('!endpointTarget&&!gateTarget&&!boardTarget'),'Existing path cells do not reach the line pickup logic'); assert(claim.includes('allowLocalSolved=false')&&claim.includes('!allowLocalSolved&&metaState(boardId)?.solved'),'A locally solved board cannot be reclaimed after a rejected clear push'); assert(pushPending.includes("error.status===423")&&pushPending.includes("requestBoardClaim(boardId,{allowLocalSolved:true})"),'A claim-rejected cloud save does not reclaim and retry its board'); assert(handleRealtime.includes("message.type==='world-revision'")&&handleRealtime.includes('scheduleRemoteWorldPull'),'Realtime world changes are ignored by the browser'); assert(scheduleRemote.includes('pullCloudWorld()')&&scheduleRemote.includes('scheduleRemoteWorldPull(remoteWorldRevision,500)'),'A realtime pull lost during an interaction is not retried'); assert(functionSource('pullCloudWorld').includes('reopenMissingGateExpansions()')&&functionSource('pullCloudWorld').includes('scheduleExpansionRepair(150)'),'A reconciled generated-board conflict remains falsely marked expanded until reload'); assert(functionSource('scheduleRealtimeHttpPoll').includes('PHP_REALTIME_POLL_INTERVAL')&&functionSource('queueRealtimeCursor').includes('PHP_REALTIME_CURSOR_INTERVAL'),'PHP fallback cursor latency remains on the multi-second cadence'); assert(functionSource('recoverLostBoardPointerCapture').includes('realtimeHeldPointers.has(pointerId)')&&bindBoard.includes('recoverLostBoardPointerCapture(b,e)'),'A transient pointer-capture loss still terminates an actively held drag'); assert(functionSource('preserveActiveDrawingClaim').includes("requestBoardClaim(boardId,{force:true})")&&!functionSource('removeClaim').includes('cancelPointerGestures'),'A transient claim update still forcibly stops an active drag'); assert(functionSource('applyRealtimeWorldDelta').includes('mergeSnapshotIntoData')&&handleRealtime.includes('applyRealtimeWorldDelta(message)'),'Realtime map changes still require an additional cloud pull before rendering'); assert(functionSource('scheduleCloudPush').includes('delay=120'),'Completed progress waits too long before publication'); for(let level=1;level<=3;level++)assert.deepEqual(require('../app-logic').sectionCountRange(level),{min:1,max:1},`Level ${level} can still generate merged sections`); assert(functionSource('placeChildAtFrontierAttempt').includes("level<=3&&shape.length!==1"),'A low intrinsic difficulty can bypass the single-square generation rule'); const emptyCloudPending=()=>({metaIds:new Set(),stateIds:new Set(),deleted:new Set(),globalChanged:false}); const take=Function('emptyCloudPending',`return (${takeBatch})`)(emptyCloudPending),source={metaIds:new Set(['B1','B2']),stateIds:new Set(['B1','B2']),deleted:new Set(['B9']),globalChanged:true}; const {batch,remainder}=take(source,16,'B2'); assert.deepEqual([...batch.metaIds],['B2']);assert.deepEqual([...batch.stateIds],['B2']);assert.deepEqual([...remainder.metaIds],['B1']);assert.deepEqual([...remainder.stateIds],['B1']);assert.equal(batch.globalChanged,true); assert(functionSource('checkSolvedAndExpand').includes('pushCloudPending(b.id)'),'Clear confirmation can publish an unrelated older board instead of the solved board'); console.log('LinkField v48.03 drag recovery and low-latency map synchronization smoke test passed');