{
  "version": 3,
  "sources": ["../alpine-components/photo-modals.js", "../alpine-components/highlight-polygon.js", "../alpine-components/highlight-brush.js", "../alpine-components/highlight-box.js", "../alpine-components/highlight-straighten.js", "../alpine-components/highlight-editor.js", "../alpine-components/batch.js", "../alpine-components/social-post.js", "../alpine-components/upload-validation.js", "../alpine-components/photo-upload.js", "../alpine-components/branding-logo-upload.js", "../alpine-components/estimated-progress.js", "../alpine-components/onboarding.js", "../alpine-components/guides.js", "../alpine-components/next-property-ask.js", "../alpine-components/property-create.js", "../alpine-components/property-search.js", "../alpine-components/address.js", "../alpine-components/listing-form.js", "../alpine-components/expose-text-fit.js", "../public-upload.js"],
  "sourcesContent": ["document.addEventListener('alpine:init', () => {\n    const I18N = window.I18N || {};\n\n    // Corners of a rectangle or polygon shape, normalized 0..1.\n    function shapePoints(shape) {\n        if (!shape) return [];\n        if (shape.type === 'rect') {\n            const {x, y, width, height} = shape.rect;\n            return [{x, y}, {x: x + width, y}, {x: x + width, y: y + height}, {x, y: y + height}];\n        }\n        return shape.points || [];\n    }\n\n    // Points for an SVG polygon in a 0..100 viewBox.\n    function svgPoints(shape) {\n        return shapePoints(shape).map((point) => (point.x * 100) + ',' + (point.y * 100)).join(' ');\n    }\n\n    Alpine.data('photoModals', () => ({\n        comparisonOpen: false,\n        retryOpen: false,\n        revisionOpen: false,\n        deleteOpen: false,\n        qaExplainOpen: false,\n        metadataOpen: false,\n        upscaleConfirmOpen: false,\n        rebaseOpen: false,\n        rebaseReturnToRetry: false,\n        rebaseRequestPending: false,\n        rebaseDismissedWhilePending: false,\n        rebaseSummaryRequest: null,\n        historyOpen: false,\n        deleting: false,\n        retryText: '',\n        refundText: '',\n        retryAction: '',\n        retryBodyCache: '',\n        revisionSrc: '',\n        revisionId: '',\n        revisionUrls: {},\n        editorOpen: false,\n        // \"M\u00F6belst\u00FCck platzieren\" in the retry dialog. The state lives\n        // here, outside the dialog body the server swaps, and belongs to one\n        // rejected job (placementJob). placementBase is the version the job\n        // was made from, which the space is drawn on.\n        placementJob: '',\n        placementShape: null,\n        placementLabel: '',\n        placementBase: null,\n        placementLocked: false,\n        // True while the dialog is hidden for the image editor.\n        placementDrawing: false,\n\n        init() {\n            const json = this.$el.dataset.revisionUrls;\n            if (json) {\n                try { this.revisionUrls = JSON.parse(json); } catch (e) { this.revisionUrls = {}; }\n            }\n\n            // The retry dialog closes itself once the server has swapped the\n            // page fragments it changed. The hint is cleared here and not in\n            // closeRetry(), so Escape keeps a draft but a sent hint is not\n            // re-sent when the next result is rejected too.\n            // The body now holds a dialog for the *new* active revision, so the\n            // cached choice step is stale: drop it and let the next open cache\n            // what the server just swapped in.\n            this._onRetryDone = () => {\n                this.retryText = ''; this.refundText = ''; this.retryAction = ''; this.retryBodyCache = '';\n                this.placementJob = ''; this.placementShape = null; this.placementLabel = '';\n                this.closeRetry();\n            };\n            window.addEventListener('retry-done', this._onRetryDone);\n        },\n\n        destroy() {\n            window.removeEventListener('retry-done', this._onRetryDone);\n        },\n\n        openComparison()  { this.comparisonOpen = true;  this.lockScroll(); },\n        closeComparison() { this.comparisonOpen = false; this.unlockScroll(); },\n        openRetry()       { this.cacheRetryBody(); this.retryOpen = true; this.lockScroll(); },\n        closeRetry() {\n            // Hidden for the image editor: the shell's Escape handler still\n            // listens, and the editor's own Escape must not close the dialog.\n            if (this.placementDrawing) return;\n            // A retry request can still be resolving its fast modal shell.\n            // Treat closing the retry sheet as declining that pending offer.\n            if (this.rebaseRequestPending && !this.rebaseOpen) {\n                this.rebaseDismissedWhilePending = true;\n            }\n            this.retryOpen = false;\n            this.unlockScroll();\n            // Without this the next open shows whatever the server last\n            // swapped in \u2014 the proposal of a result the user walked away\n            // from \u2014 and the other path is unreachable.\n            this.restoreRetryBody();\n        },\n        retryBody() { return document.getElementById('retry-dialog-body'); },\n        // The server swaps this body (proposal step, validation errors, the\n        // dialog for the next revision after an action). Cache the choice step\n        // the first time the dialog opens so closing it, or \"Zur\u00FCck\" inside the\n        // proposal step, can put that step back.\n        cacheRetryBody() {\n            const body = this.retryBody();\n            if (body && !this.retryBodyCache) this.retryBodyCache = body.innerHTML;\n        },\n        // Drop the proposal poll and its timer so neither can fire a retry the\n        // customer has stepped away from. An element htmx is posting right now\n        // is left in place; removing it would strand its own response.\n        stopSuggestionWait() {\n            const body = this.retryBody();\n            if (!body) return;\n            body.querySelectorAll('[data-suggestion-wait]:not(.htmx-request)')\n                .forEach((node) => node.remove());\n        },\n        restoreRetryBody() {\n            const body = this.retryBody();\n            if (!body || !this.retryBodyCache) return;\n            this.stopSuggestionWait();\n            body.innerHTML = this.retryBodyCache;\n            // Restored markup is new DOM to htmx: without this its forms fall\n            // back to native posts, the same trap teleported modals hit after\n            // an hx-boost navigation.\n            if (window.htmx) window.htmx.process(body);\n        },\n        backToRetryChoice() { this.restoreRetryBody(); },\n        // Only caller is the sidebar \"Versionen\" list, so the event measures\n        // that surface against the history modal opened from the \"Mehr\" menu.\n        showRevision(id)  { this.revisionSrc = this.revisionUrls[id] || ''; this.revisionId = String(id); this.revisionOpen = true; this.lockScroll(); window.trackEvent && window.trackEvent('revision_preview_open'); },\n        closeRevision()   { this.revisionOpen = false;   this.unlockScroll(); },\n        openHistory()     { this.historyOpen = true;  this.lockScroll(); window.trackEvent && window.trackEvent('revision_history_open'); },\n        closeHistory()    { this.historyOpen = false; this.unlockScroll(); },\n        openDelete()      { this.deleteOpen = true;      this.lockScroll(); },\n        closeDelete()     { this.deleteOpen = false;     this.unlockScroll(); },\n        openQaExplain()   { this.qaExplainOpen = true;   this.lockScroll(); },\n        closeQaExplain()  { this.qaExplainOpen = false;  this.unlockScroll(); },\n        openMetadata()        { this.metadataOpen = true;        this.lockScroll(); },\n        closeMetadata()       { this.metadataOpen = false;       this.unlockScroll(); },\n        openUpscaleConfirm()  { this.upscaleConfirmOpen = true;  this.lockScroll(); },\n        closeUpscaleConfirm() { this.upscaleConfirmOpen = false; this.unlockScroll(); },\n        prepareRebase() {\n            this.rebaseRequestPending = true;\n            this.rebaseDismissedWhilePending = false;\n            this.abortRebaseSummaryRequest();\n        },\n        openRebase() {\n            // The request can complete after the user closed the originating\n            // surface. Keep its prepared shell available, but do not reopen it.\n            if (this.rebaseDismissedWhilePending) {\n                this.rebaseRequestPending = false;\n                this.rebaseDismissedWhilePending = false;\n                return;\n            }\n            this.rebaseRequestPending = false;\n            this.showRebase();\n        },\n        showRebase() {\n            if (this.retryOpen) {\n                // Preserve the retry draft in photoModals. The rebase dialog\n                // replaces the sheet, so it is the only overlay on screen.\n                this.rebaseReturnToRetry = true;\n                this.retryOpen = false;\n            }\n            // The consolidation offer answers a retry posted from the proposal\n            // step and takes over the screen. Nothing behind it may still fire\n            // a retry, so the poll and the timer go now. The panel itself is\n            // rebuilt when the retry dialog comes back: this runs while htmx is\n            // still resolving the response that opened this modal, and pulling\n            // the requesting form out from under it breaks its retarget.\n            this.stopSuggestionWait();\n            if (!this.rebaseOpen) {\n                this.rebaseOpen = true;\n                this.lockScroll();\n            }\n        },\n        closeRebase() {\n            this.abortRebaseSummaryRequest();\n            if (this.rebaseRequestPending) this.rebaseDismissedWhilePending = true;\n            this.rebaseOpen = false;\n            if (this.rebaseReturnToRetry) {\n                this.rebaseReturnToRetry = false;\n                // The dialog underneath still shows the wait it was in when the\n                // offer interrupted it. That moment is over.\n                this.restoreRetryBody();\n                this.retryOpen = true;\n            }\n            this.unlockScroll();\n        },\n        finishRebase() {\n            this.rebaseRequestPending = false;\n            this.rebaseDismissedWhilePending = false;\n            this.rebaseReturnToRetry = false;\n            this.closeRebase();\n        },\n        setRebaseSummaryRequest(xhr) {\n            this.abortRebaseSummaryRequest();\n            this.rebaseSummaryRequest = xhr;\n        },\n        clearRebaseSummaryRequest(xhr) {\n            if (!xhr || this.rebaseSummaryRequest === xhr) {\n                this.rebaseSummaryRequest = null;\n            }\n        },\n        abortRebaseSummaryRequest() {\n            if (this.rebaseSummaryRequest) {\n                this.rebaseSummaryRequest.abort();\n                this.rebaseSummaryRequest = null;\n            }\n        },\n\n        // The box's data, once per rejected job: the dialog body is rendered\n        // again for errors and restored from the cache, and the space drawn\n        // so far must survive both.\n        initRetryPlacement(json) {\n            let config = {};\n            try { config = JSON.parse(json || '{}'); } catch (e) { config = {}; }\n            this.placementBase = config.base || null;\n            if (this.placementJob === config.job) return;\n            this.placementJob = config.job || '';\n            this.placementShape = config.placement?.shape || null;\n            this.placementLabel = config.placement?.label || '';\n        },\n        get placementImageUrl() { return this.placementBase?.url || ''; },\n        get placementAspect() {\n            const base = this.placementBase || {};\n            return base.width && base.height ? base.width + '/' + base.height : '4/3';\n        },\n        get placementSvgPoints() { return svgPoints(this.placementShape); },\n        get placementInputsDisabled() { return this.retryAction !== 'retry' || !this.placementShape; },\n        // The dialog steps out of the way while the space is drawn. It hides\n        // only once the editor opened: the editor refuses while an AI edit runs.\n        openPlacementEditor() {\n            this.$dispatch('open-place-editor', {\n                shape: this.placementShape, target: 'retry', base: this.placementBase,\n            });\n            if (!this.editorOpen) return;\n            this.placementDrawing = true;\n            this.retryOpen = false;\n            this.unlockScroll();\n        },\n        removePlacement() { this.placementShape = null; },\n        receivePlacement(detail) {\n            if (detail?.target !== 'retry') return;\n            this.placementShape = detail.shape || null;\n            this.$nextTick(() => {\n                const box = document.querySelector('[data-retry-placement]');\n                box?.scrollIntoView({block: 'nearest'});\n                if (this.placementShape && !this.placementLabel.trim()) box?.querySelector('input[name=\"placement_label\"]')?.focus({preventScroll: true});\n            });\n        },\n        // The image editor opened or closed. Closing it, with the space\n        // taken or not, brings the hidden retry dialog back.\n        editorModeChanged(open) {\n            this.editorOpen = open;\n            if (open || !this.placementDrawing) return;\n            this.retryOpen = true;\n            this.lockScroll();\n            // An Escape that closed the editor reaches the dialog's own Escape\n            // handler next. The guard in closeRetry() stays up until it passed.\n            setTimeout(() => { this.placementDrawing = false; }, 0);\n        },\n\n        get anyOpen() { return this.comparisonOpen || this.retryOpen || this.revisionOpen || this.deleteOpen || this.qaExplainOpen || this.metadataOpen || this.upscaleConfirmOpen || this.rebaseOpen || this.historyOpen; },\n        lockScroll()   { window._scrollLock.lock(); },\n        unlockScroll() { if (!this.anyOpen) window._scrollLock.unlock(); },\n    }));\n\n    Alpine.data('rebaseModal', () => ({\n        submitting: false,\n        summaryReady: false,\n        summaryLoading: false,\n        summaryRequestFailed: false,\n        rebaseBehavior: 'ask',\n\n        init() {\n            this.summaryLoading = this.$el.dataset.summaryLoading === 'true';\n            this.summaryReady = !this.summaryLoading;\n            const behavior = this.$el.dataset.rebaseBehavior;\n            this.rebaseBehavior = ['ask', 'always', 'never'].includes(behavior)\n                ? behavior\n                : 'ask';\n        },\n        startSummaryRequest(event) {\n            this.summaryLoading = true;\n            this.summaryRequestFailed = false;\n            this.$dispatch('rebase-summary-request-start', { xhr: event.detail.xhr });\n        },\n        finishSummaryRequest(event) {\n            const xhr = event.detail.xhr;\n            const successful = xhr.status >= 200 && xhr.status < 300;\n            this.summaryLoading = false;\n            this.summaryReady = successful;\n            this.summaryRequestFailed = !successful;\n            this.$dispatch('rebase-summary-request-finished', { xhr });\n        },\n    }));\n\n    Alpine.data('editForm', () => ({\n        activeTab: 'outdoor',\n        // Au\u00DFen or Innen inside the Vorlagen tab, kept while another tab is\n        // open so coming back shows the same preset family.\n        presetTab: 'outdoor',\n        submitting: false,\n        duplicateWarningBypassed: false,\n        floorplanWarningBypassed: false,\n        floorplanWarningPending: false,\n        rebaseOfferPossible: false,\n        previousPresets: [],\n        // staging_outdoor stays unchecked by default and is deliberately\n        // excluded from saved-prefs application below\n        outdoor: { optimize: true, sunshine: true, declutter: true, staging_outdoor: false },\n        indoor: { optimize: true, declutter: true, details: true, staging: true },\n        replaceFurniture: false,\n        // \"Baumaterial und Ger\u00FCste behalten\" under declutter, building sites\n        // only. Always on by default; not saved with the preset preferences.\n        keepSiteMaterials: true,\n        sceneSubtype: '',\n        lockCameraAngle: true,\n        resolution4k: false,\n        nextEditCredits2k: 0,\n        nextEditCredits4k: 0,\n        roomType: '',\n        outdoorType: '',\n        furnitureStyle: '',\n        furnitureInstructions: '',\n        intensity: 'normal',\n        additionalGuidance: '',\n        roomOpen: false,\n        styleOpen: false,\n        // \"Stelle \u00E4ndern\": one area marked in the image editor (mask mode)\n        // and one instruction. The shape is normalized to the clean base the\n        // editor draws on, the frame the server builds the mask in.\n        maskShape: null,\n        maskInstruction: '',\n        maskBaseUrl: '',\n        maskAspect: '4/3',\n        // Pixel size of that image, for the brush preview's viewBox.\n        maskWidth: 4000,\n        maskHeight: 3000,\n        // \"M\u00F6belst\u00FCck platzieren\" under the staging options: one space\n        // drawn in the image editor's place mode, on the same base as the\n        // mask, and what stands there.\n        placementShape: null,\n        placementLabel: '',\n        // \"Passend zu diesem Foto\": a staged photo to match, pre-selected from\n        // the same room or picked in the modal from all staged photos.\n        matchReference: false,\n        referenceRemoved: false,\n        referenceId: '',\n        referenceUrl: '',\n        referenceStyle: '',\n        referenceRemoveUrl: '',\n        // Only a reference from this photo's own room can be taken out of it.\n        referenceSameRoom: false,\n        roomOptions: [\n            {v:'',l:'Auto'}, {v:'living_room',l:I18N.roomLivingRoom || 'Wohnzimmer'},\n            {v:'bedroom',l:I18N.roomBedroom || 'Schlafzimmer'}, {v:'kitchen',l:I18N.roomKitchen || 'K\u00FCche'},\n            {v:'bathroom',l:I18N.roomBathroom || 'Badezimmer'}, {v:'kids_room',l:I18N.roomKidsRoom || 'Kinderzimmer'},\n            {v:'dining_room',l:I18N.roomDiningRoom || 'Esszimmer'}, {v:'hallway',l:I18N.roomHallway || 'Flur'},\n            {v:'home_office',l:I18N.roomHomeOffice || 'Arbeitszimmer'},\n            {v:'office',l:I18N.roomOffice || 'B\u00FCro'}, {v:'garage',l:'Garage'},\n            {v:'basement',l:I18N.roomBasement || 'Keller'},\n            {v:'dressing_room',l:I18N.roomDressingRoom || 'Ankleide'},\n            {v:'attic',l:I18N.roomAttic || 'Dachboden'},\n        ],\n        styleOptions: [\n            {v:'',l:I18N.styleUnspecified || 'Keine Vorgabe'}, {v:'modern',l:'Modern'},\n            {v:'skandinavisch',l:I18N.styleScandinavian || 'Skandinavisch'}, {v:'klassisch',l:I18N.styleClassic || 'Klassisch'},\n            {v:'landhausstil',l:I18N.styleCountry || 'Landhausstil'}, {v:'industriell',l:I18N.styleIndustrial || 'Industriell'},\n        ],\n\n        init() {\n            this.nextEditCredits2k = Number(this.$el.dataset.nextEditCreditsStandard || 0);\n            this.nextEditCredits4k = Number(this.$el.dataset.nextEditCreditsHigh || 0);\n            this.floorplanWarningPending = this.$el.dataset.floorplanWarningPending === 'true';\n            this.rebaseOfferPossible = this.$el.dataset.rebaseOfferPossible === 'true';\n            // Apply saved preset preferences\n            const prefsJson = this.$el.dataset.presetPrefs;\n            if (prefsJson) {\n                try {\n                    const prefs = JSON.parse(prefsJson);\n                    if (prefs.outdoor) {\n                        this.outdoor.optimize = prefs.outdoor.includes('optimize');\n                        this.outdoor.sunshine = prefs.outdoor.includes('sunshine');\n                        this.outdoor.declutter = prefs.outdoor.includes('declutter');\n                    }\n                    if (prefs.indoor) {\n                        this.indoor.optimize = prefs.indoor.includes('optimize_indoor');\n                        this.indoor.declutter = prefs.indoor.includes('declutter_indoor');\n                        this.indoor.details = prefs.indoor.includes('details');\n                        this.indoor.staging = prefs.indoor.includes('staging');\n                    }\n                    if (typeof prefs.replace_furniture === 'boolean')\n                        this.replaceFurniture = prefs.replace_furniture;\n                    if (typeof prefs.lock_camera_angle === 'boolean')\n                        this.lockCameraAngle = prefs.lock_camera_angle;\n                    if (prefs.intensity === 'subtle')\n                        this.intensity = 'subtle';\n                    if (prefs.resolution === '4K')\n                        this.resolution4k = true;\n                    if (prefs.furniture_style)\n                        this.furnitureStyle = prefs.furniture_style;\n                    if (prefs.aspect_ratio) {\n                        const sel = this.$el.querySelector('#aspect-ratio');\n                        if (sel) sel.value = prefs.aspect_ratio;\n                    }\n                } catch (e) {}\n            }\n\n            // Parse previous presets for duplicate detection\n            try {\n                this.previousPresets = JSON.parse(this.$el.dataset.previousPresets || '[]');\n            } catch (e) { this.previousPresets = []; }\n\n            this.activeTab = this.$el.dataset.initialTab || 'outdoor';\n            this.isFloorplan = this.activeTab === 'floorplan';\n            if (this.isPresetTab) this.presetTab = this.activeTab;\n\n            // The image the mask editor draws on, for the small preview here.\n            try {\n                const host = this.$el.closest('[data-highlight-editor-config]');\n                const config = JSON.parse(host?.dataset.highlightEditorConfig || '{}');\n                this.maskBaseUrl = config.baseUrl || '';\n                if (config.width && config.height) {\n                    this.maskAspect = config.width + '/' + config.height;\n                    this.maskWidth = Number(config.width);\n                    this.maskHeight = Number(config.height);\n                }\n            } catch (e) {}\n            // A refused submit or a result without change comes back to this\n            // mode with the same area and words, ready to adjust.\n            if (this.$el.dataset.maskPrefill && !this.isFloorplan) {\n                try {\n                    const prefill = JSON.parse(this.$el.dataset.maskPrefill);\n                    this.activeTab = 'mask';\n                    this.maskShape = prefill.shape || null;\n                    this.maskInstruction = prefill.instruction || '';\n                } catch (e) {}\n            }\n            this.roomType = this.$el.dataset.roomType || '';\n            this.outdoorType = this.$el.dataset.outdoorType || '';\n\n            // The metadata modal saves room and outdoor type without\n            // re-rendering this form. Pick the saved values up here, because\n            // the edit view persists whatever the form posts and would\n            // otherwise write the old values back on the next edit.\n            this._onMetadataUpdated = (event) => {\n                const detail = event.detail || {};\n                if ('room_type' in detail) this.roomType = detail.room_type || '';\n                if ('outdoor_type' in detail) this.outdoorType = detail.outdoor_type || '';\n            };\n            window.addEventListener('metadata-updated', this._onMetadataUpdated);\n\n            // A staged photo of the same room: matching it is pre-selected and\n            // takes its furniture style. Another style cannot match, so picking\n            // one unticks the box; ticking it again restores the style. The\n            // same rule holds for a reference picked in the modal.\n            if (this.$el.dataset.hasReference === 'true') {\n                this.matchReference = true;\n                this.referenceId = this.$el.dataset.referenceId || '';\n                this.referenceUrl = this.$el.dataset.referenceUrl || '';\n                this.referenceStyle = this.$el.dataset.referenceStyle || '';\n                this.referenceRemoveUrl = this.$el.dataset.referenceRemoveUrl || '';\n                this.referenceSameRoom = true;\n                this.furnitureStyle = this.referenceStyle;\n            }\n            if (this.$el.dataset.hasCandidates === 'true') {\n                this.$watch('furnitureStyle', (value) => {\n                    if (value !== this.referenceStyle) this.matchReference = false;\n                });\n                this.$watch('matchReference', (value) => {\n                    if (value) this.furnitureStyle = this.referenceStyle;\n                });\n            }\n\n            // Construction subtype override (photo-specific > account preference)\n            const subtype = this.$el.dataset.sceneSubtype || '';\n            this.sceneSubtype = subtype;\n            if (this.activeTab === 'indoor' && subtype === 'construction') {\n                this.indoor.declutter = false;\n                this.indoor.staging = false;\n                this.indoor.details = false;\n            }\n        },\n\n        destroy() {\n            window.removeEventListener('metadata-updated', this._onMetadataUpdated);\n        },\n\n        get isPresetTab() {\n            return this.activeTab === 'outdoor' || this.activeTab === 'indoor';\n        },\n\n        switchTab(tab) {\n            this.activeTab = tab;\n            if (this.isPresetTab) this.presetTab = tab;\n            if (tab !== 'indoor') {\n                this.indoor.staging = false;\n                this.replaceFurniture = false;\n                this.roomType = '';\n                this.furnitureStyle = '';\n            }\n        },\n\n        // \"Passend zu diesem Foto\" is ticked: the edit becomes a set photo,\n        // always 2K in the source format.\n        get followActive() {\n            return this.matchReference && !!this.referenceId && !this.referenceRemoved\n                && this.activeTab === 'indoor' && this.indoor.staging;\n        },\n\n        get nextEditCredits() {\n            // A mask edit is always 2K.\n            return this.resolution4k && !this.followActive && this.activeTab !== 'mask'\n                ? this.nextEditCredits4k : this.nextEditCredits2k;\n        },\n\n        get maskReady() {\n            return Boolean(this.maskShape) && this.maskInstruction.trim().length > 0;\n        },\n\n        get maskPreviewStyle() {\n            return 'aspect-ratio:' + this.maskAspect;\n        },\n\n        get maskIsBrush() {\n            return Boolean(this.maskShape) && this.maskShape.type === 'brush';\n        },\n\n        get maskViewBox() {\n            return '0 0 ' + this.maskWidth + ' ' + this.maskHeight;\n        },\n\n        // Brush strokes look as in the editor: translucent paint, no dimming.\n        get maskBrushMarkup() {\n            if (!this.maskIsBrush) return '';\n            return window.brushStrokesMarkup(this.maskShape.strokes, this.maskWidth, this.maskHeight);\n        },\n\n        get maskPoints() {\n            const shape = this.maskShape;\n            if (!shape || shape.type === 'brush') return [];\n            return shapePoints(shape);\n        },\n\n        get maskSvgPoints() {\n            return this.maskPoints.map((point) => (point.x * 100) + ',' + (point.y * 100)).join(' ');\n        },\n\n        // \"Passend zu diesem Foto\" stages to match another photo; it does not\n        // take a placement in this version, and the server refuses both.\n        get placementLocked() { return this.followActive; },\n        get placementInputsDisabled() {\n            return this.activeTab !== 'indoor' || !this.indoor.staging || this.followActive || !this.placementShape;\n        },\n        get placementImageUrl() { return this.maskBaseUrl; },\n        get placementAspect() { return this.maskAspect; },\n        get placementSvgPoints() { return svgPoints(this.placementShape); },\n\n        openPlacementEditor() {\n            if (this.placementLocked) return;\n            this.$dispatch('open-place-editor', {shape: this.placementShape, target: 'form'});\n        },\n\n        removePlacement() { this.placementShape = null; },\n\n        // Back from the editor: show the block again, ready for its label.\n        receivePlacement(detail) {\n            if (detail?.target !== 'form') return;\n            this.placementShape = detail.shape || null;\n            this.$nextTick(() => {\n                this.$el.querySelector('[data-placement-block]')?.scrollIntoView({block: 'center'});\n                if (this.placementShape && !this.placementLabel.trim()) this.$el.querySelector('#photo-placement-label')?.focus({preventScroll: true});\n            });\n        },\n\n        // The line in \"Stelle \u00E4ndern\": Vorlagen \u203A Innen with staging on, at the\n        // block. Called from that line's button, so $el is the button: $root\n        // is the form.\n        openPlacementFromMask() {\n            this.switchTab('indoor');\n            this.indoor.staging = true;\n            this.$nextTick(() => {\n                this.$root.querySelector('[data-placement-block]')?.scrollIntoView({block: 'center'});\n            });\n        },\n\n        // The marked area at full brightness over the dimmed photo.\n        get maskClipStyle() {\n            if (!this.maskShape || this.maskIsBrush) return 'display:none';\n            return 'clip-path:polygon(' + this.maskPoints.map((point) => (\n                (point.x * 100) + '% ' + (point.y * 100) + '%'\n            )).join(',') + ')';\n        },\n\n        // The image editor (photo column) opens in mask mode and answers\n        // with mask-area-selected.\n        openMaskEditor() {\n            this.$dispatch('open-mask-editor', {shape: this.maskShape});\n        },\n\n        // A manual save changed the straightening: the mask and the placement\n        // are drawn on the new frame, so an area marked on the old one goes.\n        receiveDrawingBase(detail) {\n            if (!detail?.url || detail.url === this.maskBaseUrl) return;\n            this.maskBaseUrl = detail.url;\n            this.maskShape = null;\n            this.placementShape = null;\n        },\n\n        receiveMaskArea(detail) {\n            this.maskShape = detail?.shape || null;\n            this.$nextTick(() => {\n                this.$el.querySelector('[data-mask-section]')?.scrollIntoView({block: 'center'});\n                if (this.maskShape && !this.maskInstruction.trim()) this.$el.querySelector('#mask-instruction')?.focus({preventScroll: true});\n            });\n        },\n\n        // The retry dialog's \"Nur eine Stelle stimmt nicht?\" link.\n        startMaskEdit() {\n            if (this.isFloorplan) return;\n            this.switchTab('mask');\n            this.openMaskEditor();\n        },\n\n        // \"Geh\u00F6rt nicht dazu\": the reference photo shows another room. A\n        // reference from this photo's own room leaves the room on the server\n        // and this photo is staged on its own. A reference picked from another\n        // room is only dropped: its own room is right.\n        removeReference() {\n            if (this.referenceRemoved) return;\n            this.referenceRemoved = true;\n            this.matchReference = false;\n            if (!this.referenceSameRoom) return;\n            const meta = document.querySelector('meta[name=\"csrf-token\"]');\n            fetch(this.referenceRemoveUrl, {\n                method: 'POST',\n                headers: { 'X-CSRFToken': meta ? meta.content : '', 'X-Requested-With': 'XMLHttpRequest' },\n            }).catch(err => console.error(err));\n        },\n\n        // \"Anderes Foto w\u00E4hlen\" opens the picker modal. It is teleported out of\n        // this form, so it gets the current reference and a callback through\n        // the modal store instead of reading this component's state.\n        openReferencePicker() {\n            Alpine.store('modal').show('reference-picker', {\n                current: this.referenceRemoved ? '' : this.referenceId,\n                choose: (button) => {\n                    this.chooseReference(button);\n                    Alpine.store('modal').close();\n                },\n            });\n        },\n\n        // A candidate from the picker becomes the reference, ticked, with its\n        // own furniture style.\n        chooseReference(button) {\n            const data = button.dataset;\n            this.referenceId = data.referenceCandidate;\n            this.referenceUrl = data.url;\n            this.referenceStyle = data.style || '';\n            this.referenceRemoveUrl = data.removeUrl;\n            this.referenceSameRoom = data.sameRoom === 'true';\n            this.referenceRemoved = false;\n            this.furnitureStyle = this.referenceStyle;\n            this.matchReference = true;\n        },\n\n        // GA4 funnel step: the customer asked for this edit. The onboarding\n        // demo edit reports itself with auto: true from its own partial.\n        trackEditStarted(propertyId) {\n            window.trackEvent('edit_started', {\n                property_id: propertyId,\n                preset: this.activeTab === 'mask' ? 'mask' : this.getSelectedPresets().join(','),\n                auto: false,\n            });\n        },\n\n        getSelectedPresets() {\n            if (this.activeTab === 'outdoor') {\n                // The same keys the server stores on the job (resolve_site_declutter).\n                const keepSite = this.keepSiteMaterials && this.sceneSubtype === 'construction';\n                return Object.entries(this.outdoor).filter(([, v]) => v)\n                    .map(([k]) => (k === 'declutter' && keepSite ? 'declutter_construction' : k));\n            }\n            if (this.activeTab === 'indoor') {\n                var presets = [];\n                if (this.indoor.optimize) presets.push('optimize_indoor');\n                if (this.indoor.declutter) presets.push('declutter_indoor');\n                if (this.indoor.details) presets.push('details');\n                if (this.indoor.staging) presets.push(this.replaceFurniture ? 'staging_replace' : 'staging');\n                return presets;\n            }\n            if (this.activeTab === 'floorplan') {\n                // One floorplan preset: the checked 2D/3D radio for this plan type.\n                var inputs = this.$el.querySelectorAll('input[name=\"presets\"][value^=\"floorplan\"]');\n                for (var i = 0; i < inputs.length; i++) {\n                    var inp = inputs[i];\n                    if (inp.disabled) continue;\n                    if (inp.type === 'radio' && !inp.checked) continue;\n                    return [inp.value];\n                }\n                return [];\n            }\n            return [];\n        },\n\n        isDuplicatePresets() {\n            if (!this.previousPresets.length) return false;\n            if (this.additionalGuidance.trim()) return false;\n            if (!this.placementInputsDisabled) return false;\n            var selected = this.getSelectedPresets();\n            if (!selected.length) return false;\n            return selected.every(function(p) { return this.previousPresets.indexOf(p) !== -1; }.bind(this));\n        },\n\n        // Pre-submit gates. handleConfirm walks this list and opens the\n        // first gate whose `needs()` returns true. Confirming a gate sets\n        // its `bypassed` flag and calls _resumeSubmit(), which re-walks the\n        // gates synchronously and either opens the next pending gate or\n        // fires the captured HTMX issueRequest.\n        gates() {\n            const self = this;\n            return [\n                {\n                    needs() {\n                        // Warning is for 3D outputs only. Any floorplan_2d_modern*\n                        // key (Grundriss/Ansicht/Schnitt) is a faithful redraw and\n                        // never warns.\n                        var has3d = self.getSelectedPresets().some(function(k) {\n                            return k.indexOf('floorplan') === 0 && k.indexOf('floorplan_2d_modern') !== 0;\n                        });\n                        return self.activeTab === 'floorplan'\n                            && self.floorplanWarningPending\n                            && !self.floorplanWarningBypassed\n                            && has3d;\n                    },\n                    open() {\n                        Alpine.store('modal').show('floorplan-warning', {\n                            onConfirm: () => self.confirmFloorplanWarning(),\n                        });\n                    },\n                },\n                {\n                    needs() {\n                        return self.activeTab !== 'custom'\n                            && !self.duplicateWarningBypassed\n                            && self.isDuplicatePresets();\n                    },\n                    open() {\n                        Alpine.store('modal').show('duplicate-warning', {\n                            onConfirm: () => self.confirmSubmit(),\n                        });\n                    },\n                },\n            ];\n        },\n\n        handleConfirm(event) {\n            for (const gate of this.gates()) {\n                if (gate.needs()) {\n                    event.preventDefault();\n                    this._issueRequest = event.detail.issueRequest;\n                    gate.open();\n                    return;\n                }\n            }\n        },\n\n        _resumeSubmit() {\n            // A bypassed gate may have unblocked the next one \u2014 walk the\n            // chain again before submitting. event.detail.issueRequest is\n            // the htmx:confirm completion callback and does NOT re-emit\n            // htmx:confirm, so the chain has to advance itself here.\n            for (const gate of this.gates()) {\n                if (gate.needs()) {\n                    gate.open();\n                    return;\n                }\n            }\n            this.submitting = true;\n            if (this._issueRequest) this._issueRequest();\n        },\n\n        confirmFloorplanWarning() {\n            Alpine.store('modal').close();\n            this.floorplanWarningBypassed = true;\n            this._resumeSubmit();\n        },\n\n        confirmSubmit() {\n            Alpine.store('modal').close();\n            this.duplicateWarningBypassed = true;\n            this._resumeSubmit();\n        },\n    }));\n\n});\n", "const MAX_POLYGON_POINTS = 64;\nconst MIN_POLYGON_AREA = 0.000001;\n// A second tap this soon and this close (screen px) closes an open polygon.\nconst DOUBLE_TAP_MS = 400;\nconst DOUBLE_TAP_SLOP = {mouse: 6, touch: 24, pen: 12};\n\nfunction clamp(value, min, max) {\n    return Math.min(max, Math.max(min, value));\n}\n\nfunction orientation(a, b, c) {\n    return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);\n}\n\nfunction pointOnSegment(a, b, point) {\n    const epsilon = 1e-12;\n    return Math.abs(orientation(a, b, point)) <= epsilon\n        && point.x >= Math.min(a.x, b.x) - epsilon\n        && point.x <= Math.max(a.x, b.x) + epsilon\n        && point.y >= Math.min(a.y, b.y) - epsilon\n        && point.y <= Math.max(a.y, b.y) + epsilon;\n}\n\nfunction segmentsIntersect(a, b, c, d) {\n    const abC = orientation(a, b, c);\n    const abD = orientation(a, b, d);\n    const cdA = orientation(c, d, a);\n    const cdB = orientation(c, d, b);\n    const epsilon = 1e-12;\n    const crosses = (\n        ((abC > epsilon && abD < -epsilon) || (abC < -epsilon && abD > epsilon))\n        && ((cdA > epsilon && cdB < -epsilon) || (cdA < -epsilon && cdB > epsilon))\n    );\n    return crosses\n        || pointOnSegment(a, b, c)\n        || pointOnSegment(a, b, d)\n        || pointOnSegment(c, d, a)\n        || pointOnSegment(c, d, b);\n}\n\nfunction polygonArea(points) {\n    return Math.abs(points.reduce((sum, point, index) => {\n        const next = points[(index + 1) % points.length];\n        return sum + point.x * next.y - next.x * point.y;\n    }, 0)) / 2;\n}\n\nfunction polygonIsSimple(points) {\n    if (points.length < 3 || polygonArea(points) < MIN_POLYGON_AREA) return false;\n    for (let first = 0; first < points.length; first++) {\n        const firstNext = (first + 1) % points.length;\n        for (let second = first + 1; second < points.length; second++) {\n            const secondNext = (second + 1) % points.length;\n            if (firstNext === second || secondNext === first) continue;\n            if (segmentsIntersect(\n                points[first], points[firstNext], points[second], points[secondNext]\n            )) return false;\n        }\n    }\n    return true;\n}\n\nfunction openPathIsSimple(points) {\n    if (points.length < 4) return true;\n    const lastStart = points.length - 2;\n    const lastEnd = points.length - 1;\n    for (let index = 0; index < lastStart - 1; index++) {\n        if (segmentsIntersect(\n            points[index], points[index + 1], points[lastStart], points[lastEnd]\n        )) return false;\n    }\n    return true;\n}\n\n/** Polygon-specific Alpine methods mixed into the shared image editor state. */\nwindow.highlightPolygonEditorMethods = function() {\n    return {\n        selectHighlightShape(shape) {\n            // The brush exists only for a mask: the manual highlight renderer\n            // has no brush operation. The box exists only for a placement.\n            const shapes = {\n                mask: ['rect', 'polygon', 'brush'],\n                place: ['box', 'rect', 'polygon'],\n            }[this.mode] || ['rect', 'polygon'];\n            if (!shapes.includes(shape) || this.applying) return;\n            if (shape === this.highlightShape) return;\n            this.polygonError = '';\n            this.brushError = '';\n            if (shape === 'polygon' && this.highlightShape === 'box' && this.canConfirmMask) {\n                // A complete box becomes its outline as a closed free form,\n                // so single points can be corrected. Lossless, so no dialog.\n                this.polygonPoints = this.boxOutline().map((point) => ({...point}));\n                this.polygonClosed = true;\n                this.polygonPointer = null;\n                this.resetBox();\n                this.highlightShape = 'polygon';\n                this.guideVisible = true;\n                return;\n            }\n            if (['brush', 'box'].includes(shape) || ['brush', 'box'].includes(this.highlightShape)) {\n                // Strokes, a box and outlines cannot be converted into each other.\n                if (this.hasShapeContent) {\n                    this.pendingShape = shape;\n                    this.shapeChangeOpen = true;\n                    return;\n                }\n                this.highlightShape = shape;\n                this.guideVisible = false;\n                return;\n            }\n            if (shape === 'polygon') {\n                if (this.highlightRect) {\n                    const rect = this.highlightRect;\n                    this.polygonPoints = [\n                        {x: rect.x, y: rect.y},\n                        {x: rect.x + rect.width, y: rect.y},\n                        {x: rect.x + rect.width, y: rect.y + rect.height},\n                        {x: rect.x, y: rect.y + rect.height},\n                    ];\n                    this.polygonClosed = true;\n                    this.highlightRect = null;\n                    this.guideVisible = true;\n                } else {\n                    this.polygonPoints = [];\n                    this.polygonClosed = false;\n                    this.guideVisible = false;\n                }\n                this.highlightShape = 'polygon';\n                return;\n            }\n            if (this.polygonPoints.length) {\n                this.pendingShape = 'rect';\n                this.shapeChangeOpen = true;\n                return;\n            }\n            this.highlightShape = 'rect';\n            this.guideVisible = Boolean(this.highlightRect);\n        },\n\n        cancelShapeChange() {\n            this.shapeChangeOpen = false;\n            this.pendingShape = null;\n        },\n\n        confirmShapeChange() {\n            if (this.discardShapeChange) {\n                this.highlightRect = null;\n                this.resetPolygon();\n                this.resetBrush();\n                this.resetBox();\n                this.highlightShape = this.pendingShape;\n                this.pendingShape = null;\n                this.shapeChangeOpen = false;\n                return;\n            }\n            if (this.polygonClosed && this.polygonPoints.length >= 3) {\n                const xs = this.polygonPoints.map((point) => point.x);\n                const ys = this.polygonPoints.map((point) => point.y);\n                const left = Math.min(...xs);\n                const top = Math.min(...ys);\n                this.highlightRect = {\n                    x: left,\n                    y: top,\n                    width: Math.max(...xs) - left,\n                    height: Math.max(...ys) - top,\n                };\n            } else {\n                this.highlightRect = null;\n            }\n            this.polygonPoints = [];\n            this.polygonClosed = false;\n            this.polygonPointer = null;\n            this.polygonError = '';\n            this.highlightShape = 'rect';\n            this.pendingShape = null;\n            this.shapeChangeOpen = false;\n            this.guideVisible = Boolean(this.highlightRect);\n        },\n\n        startPolygonPoint(event) {\n            if (this.pointerCount > 0) {\n                this.trackPointer(event);\n                this.beginPinchIfNeeded();\n                return;\n            }\n            this.trackPointer(event);\n            const point = this.imagePoint(event);\n            this._gesture = this.polygonClosed ? 'polygon-dismiss' : 'polygon-point';\n            this._gestureStart = {\n                point,\n                client: {x: event.clientX, y: event.clientY},\n                moved: false,\n            };\n            if (!this.polygonClosed) this.polygonPointer = point;\n            this.capturePointer(event);\n        },\n\n        startPolygonVertex(event, index) {\n            this.trackPointer(event);\n            if (this.pointerCount > 1) {\n                this.beginPinchIfNeeded();\n                return;\n            }\n            this.polygonError = '';\n            this.guideVisible = true;\n            this._gesture = !this.polygonClosed && index === 0 && this.polygonPoints.length >= 3\n                ? 'polygon-close'\n                : 'polygon-vertex';\n            this._gestureStart = {\n                index,\n                client: {x: event.clientX, y: event.clientY},\n                originalPoints: this.polygonPoints.map((point) => ({...point})),\n                moved: false,\n            };\n            this.capturePointer(event);\n        },\n\n        startPolygonMove(event) {\n            this.trackPointer(event);\n            if (this.pointerCount > 1) {\n                this.beginPinchIfNeeded();\n                return;\n            }\n            this.guideVisible = true;\n            this._gesture = 'polygon-move';\n            this._gestureStart = {\n                point: this.imagePoint(event),\n                originalPoints: this.polygonPoints.map((point) => ({...point})),\n            };\n            this.capturePointer(event);\n        },\n\n        markPolygonGestureMoved(event, threshold) {\n            if (!this._gestureStart || this._gestureStart.moved) return;\n            this._gestureStart.moved = Math.hypot(\n                event.clientX - this._gestureStart.client.x,\n                event.clientY - this._gestureStart.client.y\n            ) >= threshold;\n        },\n\n        finishPolygonGesture(event, gesture) {\n            const start = this._gestureStart;\n            const cancelled = event.type === 'pointercancel';\n            // The first tap of a double tap already set the last point. The\n            // second one closes instead of adding a point of its own; it\n            // usually lands on that new point's handle.\n            const closingTap = (\n                !cancelled\n                && !start?.moved\n                && !this.polygonClosed\n                && this.polygonPoints.length >= 3\n                && (\n                    gesture === 'polygon-point'\n                    || (gesture === 'polygon-vertex' && start?.index === this.polygonPoints.length - 1)\n                )\n                && this.isDoubleTap(event)\n            );\n            if (closingTap) {\n                this._lastTap = null;\n                this.closePolygon();\n            } else if (cancelled) {\n                if (start?.originalPoints) this.polygonPoints = start.originalPoints;\n            } else if (gesture === 'polygon-point' && !start?.moved) {\n                this.addPolygonPoint(this.imagePoint(event));\n                this._lastTap = {time: event.timeStamp, x: event.clientX, y: event.clientY};\n            } else if (gesture === 'polygon-close' && !start?.moved) {\n                this.closePolygon();\n            } else if (gesture === 'polygon-vertex' && start?.moved) {\n                const valid = this.polygonClosed\n                    ? polygonIsSimple(this.polygonPoints)\n                    : openPathIsSimple(this.polygonPoints);\n                if (!valid) {\n                    const areaTooSmall = (\n                        this.polygonClosed\n                        && polygonArea(this.polygonPoints) < MIN_POLYGON_AREA\n                    );\n                    this.polygonPoints = start.originalPoints;\n                    this.polygonError = this.message(\n                        areaTooSmall ? 'polygonTooSmall' : 'polygonCrossed',\n                        areaTooSmall\n                            ? 'Die markierte Fl\u00E4che ist zu klein.'\n                            : 'Die Linien d\u00FCrfen sich nicht kreuzen.'\n                    );\n                }\n            } else if (gesture === 'polygon-dismiss' && !start?.moved) {\n                this.guideVisible = false;\n            }\n            this._gesture = null;\n            this._gestureStart = null;\n        },\n\n        isDoubleTap(event) {\n            const last = this._lastTap;\n            if (!last || event.timeStamp - last.time > DOUBLE_TAP_MS) return false;\n            const slop = DOUBLE_TAP_SLOP[event.pointerType] || DOUBLE_TAP_SLOP.touch;\n            return Math.hypot(event.clientX - last.x, event.clientY - last.y) <= slop;\n        },\n\n        addPolygonPoint(point) {\n            this.polygonError = '';\n            if (\n                this.polygonPoints.length >= 3\n                && this.pointScreenDistance(point, this.polygonPoints[0]) <= 28\n            ) {\n                this.closePolygon();\n                return;\n            }\n            if (this.polygonPoints.length >= MAX_POLYGON_POINTS) {\n                this.polygonError = this.message(\n                    'polygonMaxPoints', 'Die maximale Anzahl an Punkten ist erreicht.'\n                );\n                return;\n            }\n            const previous = this.polygonPoints[this.polygonPoints.length - 1];\n            if (previous && this.pointScreenDistance(point, previous) < 8) return;\n            const candidate = [...this.polygonPoints, point];\n            if (!openPathIsSimple(candidate)) {\n                this.polygonError = this.message(\n                    'polygonCrossed', 'Die Linien d\u00FCrfen sich nicht kreuzen.'\n                );\n                return;\n            }\n            this.polygonPoints = candidate;\n            this.polygonPointer = point;\n            this.guideVisible = true;\n        },\n\n        closePolygon() {\n            if (this.polygonPoints.length < 3) return;\n            if (polygonArea(this.polygonPoints) < MIN_POLYGON_AREA) {\n                this.polygonError = this.message(\n                    'polygonTooSmall', 'Die markierte Fl\u00E4che ist zu klein.'\n                );\n                return;\n            }\n            if (!polygonIsSimple(this.polygonPoints)) {\n                this.polygonError = this.message(\n                    'polygonCrossed', 'Die Linien d\u00FCrfen sich nicht kreuzen.'\n                );\n                return;\n            }\n            this.polygonClosed = true;\n            this.polygonPointer = null;\n            this.polygonError = '';\n            this.guideVisible = true;\n        },\n\n        undoPolygonPoint() {\n            if (!this.polygonPoints.length) return;\n            this.polygonClosed = false;\n            this.polygonPoints = this.polygonPoints.slice(0, -1);\n            this.polygonPointer = this.polygonPoints[this.polygonPoints.length - 1] || null;\n            this.polygonError = '';\n            this.guideVisible = Boolean(this.polygonPoints.length);\n            this._lastTap = null;\n        },\n\n        resetPolygon() {\n            this.polygonPoints = [];\n            this.polygonClosed = false;\n            this.polygonPointer = null;\n            this.polygonError = '';\n            this.guideVisible = false;\n            this._lastTap = null;\n        },\n\n        updatePolygonMove(point) {\n            const start = this._gestureStart;\n            const xs = start.originalPoints.map((item) => item.x);\n            const ys = start.originalPoints.map((item) => item.y);\n            const dx = clamp(point.x - start.point.x, -Math.min(...xs), 1 - Math.max(...xs));\n            const dy = clamp(point.y - start.point.y, -Math.min(...ys), 1 - Math.max(...ys));\n            this.polygonPoints = start.originalPoints.map((item) => ({\n                x: item.x + dx,\n                y: item.y + dy,\n            }));\n        },\n\n        pointScreenDistance(first, second) {\n            if (!this._viewportElement) return Infinity;\n            const viewport = this._viewportElement.getBoundingClientRect();\n            return Math.hypot(\n                (first.x - second.x) * viewport.width * this.zoom,\n                (first.y - second.y) * viewport.height * this.zoom\n            );\n        },\n    };\n};\n", "// Brush tool of the image editor's mask mode (\"Stelle \u00E4ndern\"). A stroke is\n// normalized to the image: x and y in 0..1, width as a share of the image\n// width. The limits match dashboard/mask_edit.py.\nconst BRUSH_MAX_STROKES = 40;\nconst BRUSH_MAX_POINTS = 400;\n// In screen pixels. Closer pointer samples add nothing visible.\nconst BRUSH_MIN_POINT_DISTANCE = 2.5;\n// A stroke at the point limit is simplified to this deviation (screen px).\nconst BRUSH_SIMPLIFY_TOLERANCE = 1;\n// The primary's hue, lighter, so the paint reads on dark and on light photos.\nconst BRUSH_COLOR = '#2b7fee';\nconst BRUSH_OPACITY = 0.5;\n\nfunction svgNumber(value) {\n    return Math.round(value * 100) / 100;\n}\n\n// Ramer-Douglas-Peucker in screen pixels. Keeps the first and last point.\nfunction simplifyStroke(points, scaleX, scaleY, tolerance) {\n    if (points.length < 3) return points;\n    const keep = new Array(points.length).fill(false);\n    keep[0] = true;\n    keep[points.length - 1] = true;\n    const stack = [[0, points.length - 1]];\n    while (stack.length) {\n        const [first, last] = stack.pop();\n        const ax = points[first].x * scaleX;\n        const ay = points[first].y * scaleY;\n        const dx = points[last].x * scaleX - ax;\n        const dy = points[last].y * scaleY - ay;\n        const length = Math.hypot(dx, dy);\n        let farthest = -1;\n        let farthestDistance = 0;\n        for (let index = first + 1; index < last; index++) {\n            const px = points[index].x * scaleX - ax;\n            const py = points[index].y * scaleY - ay;\n            const distance = length\n                ? Math.abs(dx * py - dy * px) / length\n                : Math.hypot(px, py);\n            if (distance > farthestDistance) {\n                farthest = index;\n                farthestDistance = distance;\n            }\n        }\n        if (farthest > 0 && farthestDistance > tolerance) {\n            keep[farthest] = true;\n            stack.push([first, farthest], [farthest, last]);\n        }\n    }\n    return points.filter((_, index) => keep[index]);\n}\n\n/**\n * SVG markup of brush strokes for a viewBox of `0 0 width height` (the image\n * in pixels), so stroke widths are exact. Points may be {x, y} objects (the\n * editor) or [x, y] pairs (the posted shape). The strokes are opaque inside\n * one translucent group, so overlaps do not add up. Only numbers go into the\n * markup.\n */\nwindow.brushStrokesMarkup = function(strokes, width, height) {\n    const items = (strokes || []).map((stroke) => {\n        const strokeWidth = Number(stroke.width) * width;\n        const points = (stroke.points || []).map((point) => (\n            Array.isArray(point)\n                ? [Number(point[0]) * width, Number(point[1]) * height]\n                : [Number(point.x) * width, Number(point.y) * height]\n        )).filter(([x, y]) => Number.isFinite(x) && Number.isFinite(y));\n        if (!points.length || !Number.isFinite(strokeWidth)) return '';\n        if (points.length === 1) {\n            return '<circle cx=\"' + svgNumber(points[0][0]) + '\" cy=\"' + svgNumber(points[0][1])\n                + '\" r=\"' + svgNumber(strokeWidth / 2) + '\" stroke=\"none\"></circle>';\n        }\n        return '<polyline fill=\"none\" stroke-width=\"' + svgNumber(strokeWidth) + '\" points=\"'\n            + points.map(([x, y]) => svgNumber(x) + ',' + svgNumber(y)).join(' ') + '\"></polyline>';\n    }).join('');\n    return '<g fill=\"' + BRUSH_COLOR + '\" stroke=\"' + BRUSH_COLOR + '\" stroke-linecap=\"round\"'\n        + ' stroke-linejoin=\"round\" opacity=\"' + BRUSH_OPACITY + '\">' + items + '</g>';\n};\n\n/**\n * Brush-specific Alpine methods mixed into the shared image editor state.\n * Methods only: a spread copies a getter's value, not the getter.\n */\nwindow.highlightBrushEditorMethods = function() {\n    return {\n        startBrushStroke(event) {\n            if (this.pointerCount > 0) {\n                // A second finger turns the stroke into a pinch.\n                this.trackPointer(event);\n                this.beginPinchIfNeeded();\n                return;\n            }\n            this.trackPointer(event);\n            this.brushError = '';\n            if (this.brushStrokes.length >= BRUSH_MAX_STROKES) {\n                this.brushError = this.message(\n                    'brushMaxStrokes', 'Die maximale Anzahl an Pinselstrichen ist erreicht.'\n                );\n                this._gesture = null;\n                this._gestureStart = null;\n                return;\n            }\n            this.brushStrokes.push({width: this.brushSize / 100, points: [this.imagePoint(event)]});\n            this._gesture = 'brush';\n            this._gestureStart = {strokeIndex: this.brushStrokes.length - 1};\n            this.capturePointer(event);\n        },\n\n        extendBrushStroke(event) {\n            const stroke = this.brushStrokes[this._gestureStart?.strokeIndex];\n            if (!stroke) return;\n            const point = this.imagePoint(event);\n            const last = stroke.points[stroke.points.length - 1];\n            if (this.pointScreenDistance(point, last) < BRUSH_MIN_POINT_DISTANCE) return;\n            if (stroke.points.length >= BRUSH_MAX_POINTS) {\n                const viewport = this._viewportElement.getBoundingClientRect();\n                stroke.points = simplifyStroke(\n                    stroke.points,\n                    viewport.width * this.zoom,\n                    viewport.height * this.zoom,\n                    BRUSH_SIMPLIFY_TOLERANCE\n                );\n                if (stroke.points.length >= BRUSH_MAX_POINTS) {\n                    this.brushError = this.message(\n                        'brushStrokeTooLong', 'Dieser Pinselstrich ist zu lang. Bitte setzen Sie neu an.'\n                    );\n                    return;\n                }\n            }\n            stroke.points.push(point);\n        },\n\n        // A pinch or a cancelled pointer drops the stroke in progress.\n        cancelBrushStroke() {\n            const index = this._gestureStart?.strokeIndex;\n            if (index !== undefined && index === this.brushStrokes.length - 1) {\n                this.brushStrokes.pop();\n            }\n        },\n\n        finishBrushStroke(event) {\n            if (event.type === 'pointercancel') this.cancelBrushStroke();\n            this._gesture = null;\n            this._gestureStart = null;\n        },\n\n        trackBrushCursor(event) {\n            this.brushCursor = event.pointerType === 'touch' ? null : this.imagePoint(event);\n        },\n\n        hideBrushCursor() {\n            this.brushCursor = null;\n        },\n\n        undoBrushStroke() {\n            this.brushStrokes = this.brushStrokes.slice(0, -1);\n            this.brushError = '';\n        },\n\n        resetBrush() {\n            this.brushStrokes = [];\n            this.brushError = '';\n        },\n    };\n};\n", "// \"Quader\", place mode only: the customer taps the four corners the piece\n// stands on, then drags its height up from the nearest corner. The editor\n// turns the box into its outline, one polygon, so the server, the stored\n// shape and the prompt stay as they are (docs/system/furniture-placement.md).\n//\n// The geometry runs in the photo's pixel space. The editor stores points\n// normalized 0..1 on both axes, which skews angles and heights on a photo\n// that is not square.\n\nconst BOX_CORNERS = 4;\n// The bounds the server sets for a placement (dashboard/placement.py).\nconst BOX_MIN_AREA_SHARE = 0.001;\nconst BOX_MAX_AREA_SHARE = 0.6;\n// The smallest height, as a share of the photo height. The top of the\n// nearest corner may go up to one photo height above the frame: a\n// ceiling-high wardrobe near the camera ends outside the photo.\nconst BOX_MIN_HEIGHT = 0.01;\nconst BOX_MAX_ABOVE_FRAME = 1;\n// Screen px from the nearest corner to the height handle before the height\n// is set: more than one 44 px finger target, so the two do not overlap.\nconst BOX_HANDLE_GAP = 52;\n// Half a 44 px finger target: the height handle stays this far inside the\n// top of the photo, so all of it can be grabbed.\nconst BOX_HANDLE_HALF = 22;\n// A footprint is a box only when it is a real quadrilateral: corners at\n// least this share of the long photo edge apart, every corner turning by at\n// least this sine (no corner on or near the line through its neighbours, no\n// corner inside the other three) and at least this share of the photo.\nconst BOX_MIN_CORNER_GAP = 0.005;\nconst BOX_MIN_TURN = 0.1;\nconst BOX_MIN_FOOTPRINT_SHARE = 0.0005;\n// A tap that moved this far (screen px) was a drag. A handle moves from 3 px.\nconst BOX_TAP_SLOP = 8;\nconst BOX_DRAG_SLOP = 3;\n// A vanishing point is used for the horizon only above the footprint and not\n// farther away than this, both as shares of the photo height. Farther away,\n// the two edges are about parallel and say nothing about the horizon.\nconst BOX_HORIZON_GAP = 0.02;\nconst BOX_HORIZON_LIMIT = 6;\n// A far corner keeps at least this share of the height at the nearest corner.\nconst BOX_MIN_SCALE = 0.05;\n\nfunction boxClamp(value, min, max) {\n    return Math.min(max, Math.max(min, value));\n}\n\n// Tapped in any order: sorted around their centre, the footprint never\n// crosses itself.\nfunction boxSortedAround(points) {\n    const centre = {\n        x: points.reduce((sum, point) => sum + point.x, 0) / points.length,\n        y: points.reduce((sum, point) => sum + point.y, 0) / points.length,\n    };\n    return [...points].sort((a, b) => (\n        Math.atan2(a.y - centre.y, a.x - centre.x) - Math.atan2(b.y - centre.y, b.x - centre.x)\n    ));\n}\n\n// Where the line through a and b meets the line through c and d, or null\n// for (almost) parallel lines.\nfunction boxLineIntersection(a, b, c, d) {\n    const denominator = (a.x - b.x) * (c.y - d.y) - (a.y - b.y) * (c.x - d.x);\n    const lengths = Math.hypot(a.x - b.x, a.y - b.y) * Math.hypot(c.x - d.x, c.y - d.y);\n    if (!lengths || Math.abs(denominator) < 1e-6 * lengths) return null;\n    const t = ((a.x - c.x) * (c.y - d.y) - (a.y - c.y) * (c.x - d.x)) / denominator;\n    return {x: a.x + t * (b.x - a.x), y: a.y + t * (b.y - a.y)};\n}\n\n// The horizon of a level camera: the mean height of the vanishing points of\n// the footprint's two pairs of opposite edges. Null when neither is usable.\nfunction boxHorizonY(footprint, imageHeight) {\n    const top = Math.min(...footprint.map((point) => point.y));\n    const heights = [[0, 1, 3, 2], [1, 2, 0, 3]]\n        .map(([a, b, c, d]) => boxLineIntersection(footprint[a], footprint[b], footprint[c], footprint[d]))\n        .filter((point) => (\n            point\n            && point.y < top - BOX_HORIZON_GAP * imageHeight\n            && point.y > -BOX_HORIZON_LIMIT * imageHeight\n        ))\n        .map((point) => point.y);\n    return heights.length ? heights.reduce((sum, y) => sum + y, 0) / heights.length : null;\n}\n\n// The box in pixels: the footprint, its top corners in the same order and\n// the nearest corner (largest y). `height` is the height at the nearest\n// corner. A level camera shows a vertical edge shorter the closer its foot\n// is to the horizon, so each corner's height scales with its distance below\n// the horizon. Without a horizon every corner gets the same height.\nfunction boxGeometry(corners, height, imageHeight) {\n    const footprint = boxSortedAround(corners);\n    const nearIndex = footprint.reduce((best, point, index) => (\n        point.y > footprint[best].y ? index : best\n    ), 0);\n    const near = footprint[nearIndex];\n    const horizon = boxHorizonY(footprint, imageHeight);\n    const top = footprint.map((point) => {\n        const scale = horizon === null\n            ? 1\n            : Math.max(BOX_MIN_SCALE, (point.y - horizon) / (near.y - horizon));\n        return {x: point.x, y: point.y - height * scale};\n    });\n    return {footprint, top, near, nearTop: top[nearIndex]};\n}\n\nfunction boxCross(origin, a, b) {\n    return (a.x - origin.x) * (b.y - origin.y) - (a.y - origin.y) * (b.x - origin.x);\n}\n\n// True when the footprint (in pixels, sorted around its centre) is a convex\n// quadrilateral with four distinct corners and some area. Taps along one\n// line (the wall-floor seam) or one inside the other three give a flat or\n// wrong box, which the server would still take.\nfunction boxFootprintIsQuadrilateral(footprint, width, height) {\n    const gap = BOX_MIN_CORNER_GAP * Math.max(width, height);\n    for (let first = 0; first < footprint.length; first++) {\n        for (let second = first + 1; second < footprint.length; second++) {\n            const a = footprint[first];\n            const b = footprint[second];\n            if (Math.hypot(a.x - b.x, a.y - b.y) < gap) return false;\n        }\n    }\n    const turns = footprint.map((point, index) => {\n        const previous = footprint[(index + footprint.length - 1) % footprint.length];\n        const next = footprint[(index + 1) % footprint.length];\n        const lengths = Math.hypot(point.x - previous.x, point.y - previous.y) * Math.hypot(next.x - point.x, next.y - point.y);\n        return boxCross(previous, point, next) / lengths;\n    });\n    const convex = turns.every((turn) => turn >= BOX_MIN_TURN) || turns.every((turn) => turn <= -BOX_MIN_TURN);\n    return convex && boxArea(footprint) >= BOX_MIN_FOOTPRINT_SHARE * width * height;\n}\n\n// Convex hull (monotone chain), counter-clockwise, no collinear points.\nfunction boxConvexHull(points) {\n    const sorted = [...points].sort((a, b) => a.x - b.x || a.y - b.y);\n    const lower = [];\n    const upper = [];\n    sorted.forEach((point) => {\n        while (lower.length > 1 && boxCross(lower[lower.length - 2], lower[lower.length - 1], point) <= 0) lower.pop();\n        lower.push(point);\n    });\n    sorted.reverse().forEach((point) => {\n        while (upper.length > 1 && boxCross(upper[upper.length - 2], upper[upper.length - 1], point) <= 0) upper.pop();\n        upper.push(point);\n    });\n    return lower.slice(0, -1).concat(upper.slice(0, -1));\n}\n\n// Keeps the part of a convex polygon on one side of x = bound or y = bound.\nfunction boxClipEdge(points, axis, bound, keepBelow) {\n    const inside = (point) => (keepBelow ? point[axis] <= bound : point[axis] >= bound);\n    const clipped = [];\n    points.forEach((current, index) => {\n        const previous = points[(index + points.length - 1) % points.length];\n        if (inside(current) !== inside(previous)) {\n            const t = (bound - previous[axis]) / (current[axis] - previous[axis]);\n            const crossing = {\n                x: previous.x + t * (current.x - previous.x),\n                y: previous.y + t * (current.y - previous.y),\n            };\n            crossing[axis] = bound;\n            clipped.push(crossing);\n        }\n        if (inside(current)) clipped.push(current);\n    });\n    return clipped;\n}\n\n// The polygon cut to the photo frame (Sutherland-Hodgman), so a box that\n// reaches past an edge keeps its outline along that edge.\nfunction boxClipToFrame(points, width, height) {\n    let clipped = points;\n    [['x', 0, false], ['x', width, true], ['y', 0, false], ['y', height, true]].forEach(([axis, bound, keepBelow]) => {\n        if (clipped.length) clipped = boxClipEdge(clipped, axis, bound, keepBelow);\n    });\n    return clipped;\n}\n\n// The server refuses duplicate points. Rounding can make neighbours equal\n// or put three of them on one line, so the middle one goes.\nfunction boxCleanRing(points) {\n    let ring = points;\n    let changed = true;\n    while (changed && ring.length >= 3) {\n        changed = false;\n        for (let index = 0; index < ring.length; index++) {\n            const previous = ring[(index + ring.length - 1) % ring.length];\n            const next = ring[(index + 1) % ring.length];\n            if (Math.abs(boxCross(previous, ring[index], next)) < 1e-12) {\n                ring = ring.filter((_, other) => other !== index);\n                changed = true;\n                break;\n            }\n        }\n    }\n    return ring;\n}\n\nfunction boxArea(points) {\n    return Math.abs(points.reduce((sum, point, index) => {\n        const next = points[(index + 1) % points.length];\n        return sum + point.x * next.y - next.x * point.y;\n    }, 0)) / 2;\n}\n\nfunction boxSvgPoint(point) {\n    return (point.x * 100) + ' ' + (point.y * 100);\n}\n\nfunction boxSvgRing(points) {\n    return 'M' + points.map(boxSvgPoint).join('L') + 'Z';\n}\n\n/** Box (\"Quader\") Alpine methods mixed into the shared image editor state. */\nwindow.highlightBoxEditorMethods = function() {\n    return {\n        // 1: tap the floor corners, 2: drag the height, 3: adjust. 0: the\n        // four corners form no quadrilateral; one must move first.\n        boxStep() {\n            if (this.boxCorners.length < BOX_CORNERS) return 1;\n            if (!this.boxFootprintValid()) return 0;\n            return this.boxHeight > 0 ? 3 : 2;\n        },\n\n        boxFootprintValid() {\n            if (this.boxCorners.length !== BOX_CORNERS) return false;\n            const {width, height} = this.imageSize;\n            return boxFootprintIsQuadrilateral(this.boxPixelGeometry().footprint, width, height);\n        },\n\n        boxComplete() {\n            return this.boxCorners.length === BOX_CORNERS && this.boxHeight > 0 && this.boxFootprintValid();\n        },\n\n        // The box in pixels, from the normalized corners and height.\n        boxPixelGeometry() {\n            const {width, height} = this.imageSize;\n            return boxGeometry(\n                this.boxCorners.map((point) => ({x: point.x * width, y: point.y * height})),\n                this.boxHeight * height,\n                height\n            );\n        },\n\n        // The box for the stage, normalized, or null before the fourth corner.\n        boxPreview() {\n            if (this.boxCorners.length !== BOX_CORNERS) return null;\n            const {width, height} = this.imageSize;\n            const geometry = this.boxPixelGeometry();\n            const normalized = (point) => ({x: point.x / width, y: point.y / height});\n            return {\n                footprint: geometry.footprint.map(normalized),\n                top: geometry.top.map(normalized),\n                near: normalized(geometry.near),\n                nearTop: normalized(geometry.nearTop),\n            };\n        },\n\n        // The outline the server gets: the convex hull of the eight box\n        // corners, cut to the photo, rounded as every shape is. Null until\n        // the box is complete or when nothing of it is left.\n        boxOutline() {\n            if (!this.boxComplete()) return null;\n            const {width, height} = this.imageSize;\n            const geometry = this.boxPixelGeometry();\n            const hull = boxConvexHull(geometry.footprint.concat(geometry.top));\n            const points = boxCleanRing(boxClipToFrame(hull, width, height).map((point) => (\n                this.serializedPoint({x: point.x / width, y: point.y / height})\n            )));\n            return points.length >= 3 ? points : null;\n        },\n\n        // A footprint that is no quadrilateral, or the server's bounds, as an\n        // inline error, so a box it would refuse or draw flat cannot be taken.\n        boxError() {\n            if (this.highlightShape !== 'box' || this.boxCorners.length !== BOX_CORNERS) return '';\n            if (!this.boxFootprintValid()) {\n                return this.message(\n                    'boxFootprint',\n                    'Die vier Ecken m\u00FCssen ein Viereck auf dem Boden bilden. Verschieben Sie die Ecken.'\n                );\n            }\n            if (!this.boxComplete()) return '';\n            const outline = this.boxOutline();\n            const area = outline ? boxArea(outline) : 0;\n            if (area < BOX_MIN_AREA_SHARE) {\n                return this.message('polygonTooSmall', 'Die markierte Fl\u00E4che ist zu klein.');\n            }\n            if (area > BOX_MAX_AREA_SHARE) {\n                return this.message('boxTooLarge', 'Die markierte Fl\u00E4che ist zu gro\u00DF.');\n            }\n            return '';\n        },\n\n        boxOpenSvgPoints() {\n            return this.boxCorners.map((point) => (point.x * 100) + ',' + (point.y * 100)).join(' ');\n        },\n\n        // The filled space: the footprint until the box is complete, then the\n        // outline the server gets.\n        boxFillSvgPoints() {\n            const points = this.boxComplete() ? this.boxOutline() : this.boxPreview()?.footprint;\n            return (points || []).map((point) => (point.x * 100) + ',' + (point.y * 100)).join(' ');\n        },\n\n        // The box edges: the footprint, then also the top and four verticals.\n        boxEdgesPath() {\n            const preview = this.boxPreview();\n            if (!preview) return '';\n            if (!this.boxComplete()) return boxSvgRing(preview.footprint);\n            return boxSvgRing(preview.footprint) + boxSvgRing(preview.top)\n                + preview.footprint.map((point, index) => (\n                    'M' + boxSvgPoint(point) + 'L' + boxSvgPoint(preview.top[index])\n                )).join('');\n        },\n\n        // The height handle: on the nearest corner's top, or above that\n        // corner before the height is set. None until the footprint is a\n        // quadrilateral. A top above the photo keeps its handle at the top\n        // edge, whole inside the photo.\n        boxHeightHandle() {\n            const preview = this.boxPreview();\n            if (!preview || !this.boxFootprintValid()) return null;\n            this.viewportTick;\n            const viewport = this._viewportElement?.getBoundingClientRect();\n            const screenShare = (pixels, fallback) => (\n                viewport?.height ? pixels / (viewport.height * this.zoom) : fallback\n            );\n            const y = this.boxHeight > 0\n                ? preview.nearTop.y\n                : preview.near.y - screenShare(BOX_HANDLE_GAP, 0.06);\n            return {x: preview.near.x, y: Math.max(screenShare(BOX_HANDLE_HALF, 0.03), y)};\n        },\n\n        // The line from the nearest corner up to the unset height handle.\n        boxHeightGuidePath() {\n            const preview = this.boxPreview();\n            const handle = this.boxHeightHandle();\n            if (!preview || !handle || this.boxHeight > 0) return '';\n            return 'M' + boxSvgPoint(preview.near) + 'L' + boxSvgPoint(handle);\n        },\n\n        boxHeightDotStyle() {\n            return 'width:' + (24 / this.zoom) + 'px;height:' + (24 / this.zoom) + 'px;border-width:' + (2 / this.zoom) + 'px';\n        },\n\n        boxSnapshot() {\n            return {corners: this.boxCorners.map((point) => ({...point})), height: this.boxHeight};\n        },\n\n        restoreBoxSnapshot(snapshot) {\n            this.boxCorners = snapshot.corners.map((point) => ({...point}));\n            this.boxHeight = snapshot.height;\n        },\n\n        // A tap on the photo sets the next corner on release, so a second\n        // finger can still turn it into a pinch.\n        startBoxPoint(event) {\n            this.trackPointer(event);\n            if (this.pointerCount > 1) {\n                this.beginPinchIfNeeded();\n                return;\n            }\n            this._gesture = 'box-tap';\n            this._gestureStart = {client: {x: event.clientX, y: event.clientY}, moved: false};\n            this.capturePointer(event);\n        },\n\n        startBoxCorner(event, index) {\n            this.startBoxHandle(event, 'box-corner', index);\n        },\n\n        startBoxHeight(event) {\n            this.startBoxHandle(event, 'box-height', null);\n        },\n\n        startBoxHandle(event, gesture, index) {\n            this.trackPointer(event);\n            if (this.pointerCount > 1) {\n                this.beginPinchIfNeeded();\n                return;\n            }\n            this._gesture = gesture;\n            this._gestureStart = {\n                index,\n                client: {x: event.clientX, y: event.clientY},\n                moved: false,\n                originalBox: this.boxSnapshot(),\n                // The height follows the finger from where it took the\n                // handle, so a handle held at the top edge for a top above\n                // the photo does not jump.\n                grabOffset: gesture === 'box-height' ? this.boxHeightGrabOffset(event) : 0,\n            };\n            this.capturePointer(event);\n        },\n\n        // From the finger to the top of the nearest corner: the top itself\n        // once the height is set, the handle before.\n        boxHeightGrabOffset(event) {\n            const preview = this.boxPreview();\n            const handle = this.boxHeightHandle();\n            if (!preview || !handle) return 0;\n            const top = this.boxHeight > 0 ? preview.nearTop.y : handle.y;\n            return top - this.imagePoint(event, false).y;\n        },\n\n        updateBoxGesture(event, point) {\n            if (this._gesture === 'box-tap') {\n                this.markPolygonGestureMoved(event, BOX_TAP_SLOP);\n                return;\n            }\n            this.markPolygonGestureMoved(event, BOX_DRAG_SLOP);\n            if (!this._gestureStart.moved) return;\n            if (this._gesture === 'box-corner') {\n                this.boxCorners[this._gestureStart.index] = point;\n            } else if (this._gesture === 'box-height') {\n                // The top of the nearest corner follows the finger, also past\n                // the top of the photo (the pointer is captured), down to the\n                // floor and up to one photo height above the frame. The\n                // outline is cut to the photo.\n                const near = this.boxPreview()?.near;\n                const top = this.imagePoint(event, false).y + this._gestureStart.grabOffset;\n                if (near) this.boxHeight = boxClamp(near.y - top, BOX_MIN_HEIGHT, near.y + BOX_MAX_ABOVE_FRAME);\n            }\n        },\n\n        finishBoxGesture(event, gesture) {\n            const start = this._gestureStart;\n            if (event.type === 'pointercancel') {\n                if (start?.originalBox) this.restoreBoxSnapshot(start.originalBox);\n            } else if (gesture === 'box-tap' && start && !start.moved) {\n                this.addBoxCorner(this.imagePoint(event));\n            }\n            this._gesture = null;\n            this._gestureStart = null;\n        },\n\n        addBoxCorner(point) {\n            if (this.boxCorners.length >= BOX_CORNERS) return;\n            this.boxCorners = [...this.boxCorners, point];\n        },\n\n        // \"R\u00FCckg\u00E4ngig\": the height first, then the last corner.\n        undoBoxStep() {\n            if (this.boxHeight > 0) this.boxHeight = 0;\n            else this.boxCorners = this.boxCorners.slice(0, -1);\n        },\n\n        resetBox() {\n            this.boxCorners = [];\n            this.boxHeight = 0;\n        },\n\n        // \"Platz \u00E4ndern\" on a box taken in this editor: the box comes back if\n        // it still gives exactly the shape the form holds. The server never\n        // sees the box; any other shape reopens as it is.\n        restorePlacedBox(shape) {\n            const saved = shape ? this._placedBoxes[this.placeTarget] : null;\n            if (!saved || saved.shape !== JSON.stringify(shape)) return false;\n            const previousShape = this.highlightShape;\n            this.highlightShape = 'box';\n            this.restoreBoxSnapshot(saved);\n            if (JSON.stringify(this.maskShape()) === saved.shape) return true;\n            this.highlightShape = previousShape;\n            this.resetBox();\n            return false;\n        },\n\n        rememberPlacedBox(shapeJson) {\n            this._placedBoxes[this.placeTarget] = this.highlightShape === 'box'\n                ? {shape: shapeJson, ...this.boxSnapshot()}\n                : null;\n        },\n    };\n};\n", "// \"Begradigen\" tool of the manual image editor (docs/code/image-editor.md,\n// keystone operation). The server computes the strength table when the tool\n// opens (views/image_editor.photo_straighten_steps; for a version without a\n// detection it detects first, about 1 s) and renders on save. The\n// browser previews a step with the server's 3x3 matrix as a CSS matrix3d and\n// moves the step's frame; it never makes its own warp.\n//\n// One coordinate system, the normalized warped plane of dashboard/verticals.py:\n// the photo spans the unit square, `matrix` maps it into the plane, `quad` is\n// its outline there, and `frame` is the kept square (the photo's aspect in\n// pixels) inside the quad. The crop is measured in the photo: one minus the\n// area of the frame mapped back.\n\n// Distance a moved frame keeps from the quad edge, in plane units (about one\n// pixel at 2K). The server's bicubic filter then never samples outside the\n// photo. The detector's own frame keeps about twice this.\nconst STRAIGHTEN_EDGE_MARGIN = 0.0005;\n// Room around the quad in the tool view, so the corner handles stay reachable.\nconst STRAIGHTEN_VIEW_PADDING = 1.06;\n// Bisection steps when a drag pushes the frame against the quad edge.\nconst STRAIGHTEN_SEARCH_STEPS = 24;\n\nfunction straightenProject(m, x, y) {\n    const w = m[6] * x + m[7] * y + m[8];\n    return {x: (m[0] * x + m[1] * y + m[2]) / w, y: (m[3] * x + m[4] * y + m[5]) / w};\n}\n\nfunction straightenMultiply(a, b) {\n    const result = [];\n    for (let row = 0; row < 3; row++) {\n        for (let col = 0; col < 3; col++) {\n            result.push(a[row * 3] * b[col] + a[row * 3 + 1] * b[3 + col] + a[row * 3 + 2] * b[6 + col]);\n        }\n    }\n    return result;\n}\n\nfunction straightenInvert(m) {\n    const [a, b, c, d, e, f, g, h, i] = m;\n    const det = a * (e * i - f * h) - b * (d * i - f * g) + c * (d * h - e * g);\n    return [\n        (e * i - f * h) / det, (c * h - b * i) / det, (b * f - c * e) / det,\n        (f * g - d * i) / det, (a * i - c * g) / det, (c * d - a * f) / det,\n        (d * h - e * g) / det, (b * g - a * h) / det, (a * e - b * d) / det,\n    ];\n}\n\nfunction straightenQuad(matrix) {\n    return [[0, 0], [1, 0], [1, 1], [0, 1]].map(([x, y]) => straightenProject(matrix, x, y));\n}\n\nfunction straightenCorners(frame) {\n    return [\n        {x: frame.x, y: frame.y},\n        {x: frame.x + frame.width, y: frame.y},\n        {x: frame.x + frame.width, y: frame.y + frame.height},\n        {x: frame.x, y: frame.y + frame.height},\n    ];\n}\n\n// verticals._half_planes: a point p is inside an edge when n.p <= c.\nfunction straightenHalfPlanes(quad) {\n    let signed = 0;\n    for (let k = 0; k < 4; k++) {\n        const a = quad[k];\n        const b = quad[(k + 1) % 4];\n        signed += a.x * b.y - b.x * a.y;\n    }\n    const sign = signed > 0 ? 1 : -1;\n    return quad.map((a, k) => {\n        const b = quad[(k + 1) % 4];\n        const nx = sign * (b.y - a.y);\n        const ny = -sign * (b.x - a.x);\n        return {nx, ny, c: nx * a.x + ny * a.y, length: Math.hypot(nx, ny)};\n    });\n}\n\nfunction straightenFrameInside(frame, planes) {\n    return straightenCorners(frame).every((point) => planes.every((plane) => (\n        plane.nx * point.x + plane.ny * point.y <= plane.c - STRAIGHTEN_EDGE_MARGIN * plane.length\n    )));\n}\n\n// verticals.crop_pct\nwindow.straightenCropPercent = function(matrix, frame) {\n    const inverse = straightenInvert(matrix);\n    const kept = straightenCorners(frame).map((point) => straightenProject(inverse, point.x, point.y));\n    let area = 0;\n    for (let k = 0; k < 4; k++) {\n        const a = kept[k];\n        const b = kept[(k + 1) % 4];\n        area += a.x * b.y - b.x * a.y;\n    }\n    return Math.max(0, (1 - Math.abs(area) / 2) * 100);\n};\n\n// Cells per side of the triangle mesh. Within one cell the warp is close to\n// affine: on the eval photos the error stays under a tenth of a pixel.\nconst STRAIGHTEN_MESH_CELLS = 16;\n// Each clip triangle's corners move this many canvas pixels away from its\n// centre, which moves its edges out by about one pixel. The anti-aliased clip\n// edges of neighbouring triangles then overlap and leave no seam (0.6 left\n// faint diagonal lines on light walls).\nconst STRAIGHTEN_SEAM_PIXELS = 1.5;\n\n// The affine map (canvas setTransform order a, b, c, d, e, f) that takes the\n// source triangle s onto the target triangle t.\nfunction straightenAffine(s, t) {\n    const denominator = s[0].x * (s[1].y - s[2].y) + s[1].x * (s[2].y - s[0].y) + s[2].x * (s[0].y - s[1].y);\n    const solve = (key) => [\n        (t[0][key] * (s[1].y - s[2].y) + t[1][key] * (s[2].y - s[0].y) + t[2][key] * (s[0].y - s[1].y)) / denominator,\n        (t[0][key] * (s[2].x - s[1].x) + t[1][key] * (s[0].x - s[2].x) + t[2][key] * (s[1].x - s[0].x)) / denominator,\n        (t[0][key] * (s[1].x * s[2].y - s[2].x * s[1].y) + t[1][key] * (s[2].x * s[0].y - s[0].x * s[2].y)\n            + t[2][key] * (s[0].x * s[1].y - s[1].x * s[0].y)) / denominator,\n    ];\n    const [a, c, e] = solve('x');\n    const [b, d, f] = solve('y');\n    return [a, b, c, d, e, f];\n}\n\n// Draws the raw photo warped by `matrix` so that the plane square `view` fills\n// the canvas: the server render (verticals.render_coefficients) run forwards,\n// photo pixel -> plane -> view -> canvas pixel.\n//\n// Not a CSS matrix3d: WebKit without a compositing layer flattens a 3D\n// transform to its affine part and drops the perspective, so the preview leans\n// and shears where the saved JPEG is straight. A mesh of small triangles, each\n// an exact 2D affine map, draws the same in every engine. The canvas is never\n// read, so the photo needs no CORS.\nwindow.straightenDraw = function(canvas, image, matrix, view, cssWidth, cssHeight) {\n    const scale = Math.min(window.devicePixelRatio || 1, 2);\n    const width = Math.max(1, Math.round(cssWidth * scale));\n    const height = Math.max(1, Math.round(cssHeight * scale));\n    if (canvas.width !== width) canvas.width = width;\n    if (canvas.height !== height) canvas.height = height;\n    const context = canvas.getContext('2d');\n    context.setTransform(1, 0, 0, 1, 0, 0);\n    context.clearRect(0, 0, width, height);\n    context.imageSmoothingEnabled = true;\n    context.imageSmoothingQuality = 'high';\n    const sourceWidth = image.naturalWidth;\n    const sourceHeight = image.naturalHeight;\n    const fit = [1 / view.width, 0, -view.x / view.width, 0, 1 / view.height, -view.y / view.height, 0, 0, 1];\n    const toCanvas = straightenMultiply(\n        straightenMultiply(straightenMultiply([width, 0, 0, 0, height, 0, 0, 0, 1], fit), matrix),\n        [1 / sourceWidth, 0, 0, 0, 1 / sourceHeight, 0, 0, 0, 1],\n    );\n    const cells = STRAIGHTEN_MESH_CELLS;\n    const source = [];\n    const target = [];\n    for (let row = 0; row <= cells; row++) {\n        for (let col = 0; col <= cells; col++) {\n            const point = {x: col / cells * sourceWidth, y: row / cells * sourceHeight};\n            source.push(point);\n            target.push(straightenProject(toCanvas, point.x, point.y));\n        }\n    }\n    const at = (col, row) => row * (cells + 1) + col;\n    const cellWidth = sourceWidth / cells;\n    const cellHeight = sourceHeight / cells;\n    for (let row = 0; row < cells; row++) {\n        for (let col = 0; col < cells; col++) {\n            const corners = [at(col, row), at(col + 1, row), at(col + 1, row + 1), at(col, row + 1)];\n            for (const triangle of [[corners[0], corners[1], corners[2]], [corners[0], corners[2], corners[3]]]) {\n                const t = triangle.map((index) => target[index]);\n                const xs = t.map((point) => point.x);\n                const ys = t.map((point) => point.y);\n                if (Math.max(...xs) < 0 || Math.min(...xs) > width || Math.max(...ys) < 0 || Math.min(...ys) > height) continue;\n                const cx = (xs[0] + xs[1] + xs[2]) / 3;\n                const cy = (ys[0] + ys[1] + ys[2]) / 3;\n                context.save();\n                context.beginPath();\n                t.forEach((point, index) => {\n                    const length = Math.hypot(point.x - cx, point.y - cy) || 1;\n                    const grow = 1 + STRAIGHTEN_SEAM_PIXELS / length;\n                    const x = cx + (point.x - cx) * grow;\n                    const y = cy + (point.y - cy) * grow;\n                    if (index === 0) context.moveTo(x, y);\n                    else context.lineTo(x, y);\n                });\n                context.closePath();\n                context.clip();\n                context.setTransform(...straightenAffine(triangle.map((index) => source[index]), t));\n                // Only this cell of the photo, with a margin for the filter.\n                const left = Math.max(0, (col - 1) * cellWidth);\n                const top = Math.max(0, (row - 1) * cellHeight);\n                const right = Math.min(sourceWidth, (col + 2) * cellWidth);\n                const bottom = Math.min(sourceHeight, (row + 2) * cellHeight);\n                context.drawImage(image, left, top, right - left, bottom - top, left, top, right - left, bottom - top);\n                context.restore();\n            }\n        }\n    }\n};\n\nwindow.highlightStraightenEditorMethods = function() {\n    return {\n        // Opened by \"Anpassen\" under the photo and by the retry dialog.\n        openStraightenTool() {\n            if (!this.config.straightenUrl) return;\n            if (!this.editing) this.openEditor();\n            if (this.mode !== 'manual' || !this.editing) return;\n            this.selectTool('straighten');\n        },\n\n        async loadStraightenSteps() {\n            if (this.straightenSteps || this.straightenLoading || !this.config.straightenUrl) return;\n            this.straightenLoading = true;\n            this.straightenError = '';\n            try {\n                const response = await fetch(this.config.straightenUrl, {\n                    credentials: 'same-origin',\n                    headers: {'Accept': 'application/json'},\n                });\n                // Busy (too many detections at once on the server): its\n                // sentence shows, and tapping the tab again tries again.\n                if (response.status === 503) {\n                    const busy = await response.json().catch(() => null);\n                    throw new Error(busy?.message || this.message('straightenFailed', 'Die Begradigung konnte nicht geladen werden.'));\n                }\n                // Any other failure (detection_failed, not_available) is no\n                // stale page: a reload would not help.\n                if (!response.ok && response.status !== 409) {\n                    throw new Error(this.message('straightenFailed', 'Die Begradigung konnte nicht geladen werden.'));\n                }\n                const body = response.ok ? await response.json() : null;\n                if (!body || body.revision !== this.config.revisionId) {\n                    throw new Error(this.message('stale', 'Das Foto wurde zwischenzeitlich ge\u00E4ndert. Bitte laden Sie die Seite neu.'));\n                }\n                this.straightenSteps = body.steps;\n                // No steps: the detection found nothing to correct, and the\n                // server says why in one sentence.\n                this.straightenNote = body.steps.length ? '' : (body.message || '');\n                this.straightenStart = Number(body.start) || 0;\n                this.straightenMinShare = Number(body.minFrameShare) || 0.5;\n                // No saved straightening: show the step the server suggests,\n                // the strongest one within the automatic 15 % cap.\n                if (!this.keystone && !this.straightenTouched && this.activeTool === 'straighten') {\n                    this.selectStraightenStrength(this.straightenStart);\n                }\n            } catch (error) {\n                this.straightenError = error.message || this.message('straightenFailed', 'Die Begradigung konnte nicht geladen werden.');\n            } finally {\n                this.straightenLoading = false;\n            }\n        },\n\n        straightenStrength() {\n            return this.keystone ? Number(this.keystone.params.strength) : 0;\n        },\n\n        straightenStepFor(strength) {\n            return (this.straightenSteps || []).find((step) => Math.abs(step.strength - strength) < 1e-6) || null;\n        },\n\n        // The strength buttons.\n        chooseStraightenStrength(strength) {\n            if (this.applying) return;\n            this.straightenTouched = true;\n            this.selectStraightenStrength(strength);\n        },\n\n        // A new strength starts from that step's largest frame. The same\n        // strength keeps the moved frame.\n        selectStraightenStrength(strength) {\n            if (this.applying) return;\n            if (!strength) {\n                this.keystone = null;\n                return;\n            }\n            if (this.keystone && Math.abs(this.straightenStrength() - strength) < 1e-6) return;\n            const step = this.straightenStepFor(strength);\n            if (!step) return;\n            this.keystone = {\n                type: 'keystone',\n                version: 1,\n                params: {\n                    strength: step.strength,\n                    matrix: step.matrix.slice(),\n                    frame: {...step.frame},\n                    auto: false,\n                },\n            };\n        },\n\n        straightenStepLabel(step) {\n            return this.message('straightenStep', '{pct} %').replace('{pct}', String(Math.round(step.strength * 100)));\n        },\n\n        // A step's largest frame touches the warped photo on every side, so it\n        // cannot move until it is smaller. The panel then says to shrink first.\n        straightenFrameFull() {\n            if (!this.keystone) return false;\n            const step = this.straightenStepFor(this.straightenStrength());\n            return Boolean(step) && this.keystone.params.frame.width >= step.frame.width * 0.995;\n        },\n\n        straightenCropText() {\n            if (!this.keystone) return this.message('straightenOff', 'Das Foto bleibt unver\u00E4ndert.');\n            const pct = Math.round(window.straightenCropPercent(this.keystone.params.matrix, this.keystone.params.frame));\n            return this.message('straightenCrop', 'Dabei fallen {pct} % des Bildes am Rand weg.').replace('{pct}', String(pct));\n        },\n\n        // The plane square the tool view shows: the whole warped photo with\n        // some room, so the customer sees what the frame cuts.\n        straightenView() {\n            const quad = straightenQuad(this.keystone.params.matrix);\n            const xs = quad.map((point) => point.x);\n            const ys = quad.map((point) => point.y);\n            const side = Math.max(Math.max(...xs) - Math.min(...xs), Math.max(...ys) - Math.min(...ys)) * STRAIGHTEN_VIEW_PADDING;\n            const cx = (Math.max(...xs) + Math.min(...xs)) / 2;\n            const cy = (Math.max(...ys) + Math.min(...ys)) / 2;\n            return {x: cx - side / 2, y: cy - side / 2, width: side, height: side};\n        },\n\n        // The raw photo, warped by the saved or chosen step, on the stage\n        // canvases (x-effect). Outside the tool the kept frame fills the stage,\n        // as in the saved JPEG; in the tool the whole warped photo shows. Each\n        // canvas sits inside its output-coordinate layer (filter, clip path),\n        // so the highlight clip, the crop and the handles stay in the\n        // coordinates of the saved JPEG. A moved frame redraws nothing in the\n        // tool view: the view depends on the step only.\n        drawStagePreview() {\n            if (!this.stageWarped) return;\n            this.viewportTick;\n            this.stageImageTick;\n            const matrix = this.keystone.params.matrix.slice();\n            const view = this.straightenToolView ? this.straightenView() : {...this.keystone.params.frame};\n            // data-* selectors, not x-ref: hx-boost tears this page down and\n            // rebuilds it (test_template_hygiene).\n            const stage = this._viewportElement;\n            if (!stage) return;\n            const image = stage.querySelector('[data-stage-image]');\n            const canvas = stage.querySelector('[data-stage-canvas]');\n            const sharp = stage.querySelector('[data-stage-canvas-sharp]');\n            if (!image || !canvas || !image.complete || !image.naturalWidth) return;\n            const box = this._viewportElement.getBoundingClientRect();\n            if (!box.width || !box.height) return;\n            window.straightenDraw(canvas, image, matrix, view, box.width, box.height);\n            if (sharp) {\n                sharp.width = canvas.width;\n                sharp.height = canvas.height;\n                sharp.getContext('2d').drawImage(canvas, 0, 0);\n            }\n        },\n\n        straightenFrameStyle() {\n            if (!this.straightenToolView) return 'display:none';\n            const view = this.straightenView();\n            const frame = this.keystone.params.frame;\n            return 'left:' + ((frame.x - view.x) / view.width * 100) + '%;top:' + ((frame.y - view.y) / view.height * 100)\n                + '%;width:' + (frame.width / view.width * 100) + '%;height:' + (frame.height / view.height * 100)\n                + '%;border:' + (1.5 / this.zoom) + 'px solid white;box-shadow:0 0 0 9999px rgba(0,0,0,0.55)'\n                + ';-webkit-touch-callout:none';\n        },\n\n        straightenQuadPoints() {\n            if (!this.straightenToolView) return '';\n            const view = this.straightenView();\n            return straightenQuad(this.keystone.params.matrix).map((point) => (\n                ((point.x - view.x) / view.width * 100) + ',' + ((point.y - view.y) / view.height * 100)\n            )).join(' ');\n        },\n\n        straightenPlanePoint(event) {\n            const point = this.imagePoint(event);\n            const view = this.straightenView();\n            return {x: view.x + point.x * view.width, y: view.y + point.y * view.height};\n        },\n\n        startFrameMove(event) {\n            this.trackPointer(event);\n            if (this.pointerCount > 1) {\n                this.beginPinchIfNeeded();\n                return;\n            }\n            this._gesture = 'frame-move';\n            this._gestureStart = {point: this.straightenPlanePoint(event), frame: {...this.keystone.params.frame}};\n            this.capturePointer(event);\n        },\n\n        startFrameResize(event, handle) {\n            this.trackPointer(event);\n            if (this.pointerCount > 1) {\n                this.beginPinchIfNeeded();\n                return;\n            }\n            this._gesture = 'frame-resize';\n            this._gestureStart = {point: this.straightenPlanePoint(event), frame: {...this.keystone.params.frame}, handle};\n            this.capturePointer(event);\n        },\n\n        updateFrameGesture(event) {\n            if (!this.keystone) return;\n            const step = this.straightenStepFor(this.straightenStrength());\n            if (!step) return;\n            const planes = straightenHalfPlanes(step.quad.map(([x, y]) => ({x, y})));\n            const point = this.straightenPlanePoint(event);\n            const start = this._gestureStart;\n            const current = this.keystone.params.frame;\n            let frame;\n            if (this._gesture === 'frame-move') {\n                // Each axis on its own, so the frame slides along an edge.\n                frame = this.slideFrame(current, {...current, x: start.frame.x + point.x - start.point.x}, planes);\n                frame = this.slideFrame(frame, {...frame, y: start.frame.y + point.y - start.point.y}, planes);\n            } else {\n                frame = this.resizeFrame(current, start, point, step, planes);\n            }\n            this.keystone.params.frame = frame;\n            this.keystone.params.auto = false;\n        },\n\n        // The target when it fits, else the farthest point towards it that fits.\n        slideFrame(from, to, planes) {\n            if (straightenFrameInside(to, planes)) return to;\n            if (!straightenFrameInside(from, planes)) return from;\n            let low = 0;\n            let high = 1;\n            const at = (t) => ({\n                x: from.x + (to.x - from.x) * t,\n                y: from.y + (to.y - from.y) * t,\n                width: from.width + (to.width - from.width) * t,\n                height: from.height + (to.height - from.height) * t,\n            });\n            for (let index = 0; index < STRAIGHTEN_SEARCH_STEPS; index++) {\n                const middle = (low + high) / 2;\n                if (straightenFrameInside(at(middle), planes)) low = middle;\n                else high = middle;\n            }\n            return at(low);\n        },\n\n        // Aspect-locked: the corner opposite the handle stays where it is.\n        resizeFrame(current, start, point, step, planes) {\n            const handle = start.handle;\n            const anchorX = handle.includes('l') ? start.frame.x + start.frame.width : start.frame.x;\n            const anchorY = handle.includes('t') ? start.frame.y + start.frame.height : start.frame.y;\n            const reachX = handle.includes('l') ? anchorX - point.x : point.x - anchorX;\n            const reachY = handle.includes('t') ? anchorY - point.y : point.y - anchorY;\n            const minimum = this.straightenMinShare * step.frame.width;\n            const size = Math.max(minimum, reachX, reachY);\n            const frameOf = (side) => ({\n                x: handle.includes('l') ? anchorX - side : anchorX,\n                y: handle.includes('t') ? anchorY - side : anchorY,\n                width: side,\n                height: side,\n            });\n            return this.slideFrame(frameOf(current.width), frameOf(size), planes);\n        },\n    };\n};\n", "document.addEventListener('alpine:init', () => {\n    const EMPTY_RECT = null;\n    // Single source for the combined-strength mapping; the server stores the\n    // resolved blur/darken values, so preview and serialization must agree.\n    const STRENGTH_MAX_BLUR = 0.014;\n    const STRENGTH_MAX_DARKEN = 0.4;\n\n    function clamp(value, min, max) {\n        return Math.min(max, Math.max(min, value));\n    }\n\n    function rounded(value) {\n        return Math.round(value * 1000000) / 1000000;\n    }\n\n    function brushRounded(value) {\n        return Math.round(value * 10000) / 10000;\n    }\n\n    // Brush size slider, in percent of the image width. The server accepts\n    // 0.5% to 20% (dashboard/mask_edit.py).\n    const BRUSH_SIZE_MIN = 1;\n    const BRUSH_SIZE_MAX = 12;\n    // Viewport height kept free for the sticky header and the controls panel\n    // below the stage (checked by screenshot at 1440x900, mask mode), and the\n    // smallest stage height on short screens.\n    const STAGE_RESERVED_HEIGHT = '21rem';\n    const STAGE_MIN_HEIGHT = '16rem';\n\n    function distance(a, b) {\n        return Math.hypot(a.x - b.x, a.y - b.y);\n    }\n\n    function midpoint(a, b) {\n        return {x: (a.x + b.x) / 2, y: (a.y + b.y) / 2};\n    }\n\n    function highlightOperation(operations) {\n        const list = operations && Array.isArray(operations.operations)\n            ? operations.operations\n            : [];\n        return list.find((operation) => (\n            operation.type === 'highlight_rect' || operation.type === 'highlight_polygon'\n        )) || null;\n    }\n\n    function cropOperation(operations) {\n        const list = operations && Array.isArray(operations.operations)\n            ? operations.operations\n            : [];\n        return list.find((operation) => operation.type === 'crop_rect') || null;\n    }\n\n    function keystoneOperation(operations) {\n        const list = operations && Array.isArray(operations.operations)\n            ? operations.operations\n            : [];\n        return list.find((operation) => operation.type === 'keystone') || null;\n    }\n\n    Alpine.data('highlightEditor', () => ({\n        editing: false,\n        // 'manual' edits the photo's own recipe. 'mask' borrows the same\n        // drawing tools to mark the one area of a \"Stelle \u00E4ndern\" AI edit and\n        // hands the shape to the edit form instead of saving anything. 'place'\n        // draws the space of \"M\u00F6belst\u00FCck platzieren\" the same way, for\n        // the edit form or the retry dialog (placeTarget).\n        mode: 'manual',\n        placeTarget: 'form',\n        // The retry dialog draws on the version the rejected result was made\n        // from: {url, width, height}. Null draws on config.baseUrl.\n        baseOverride: null,\n        applying: false,\n        discardOpen: false,\n        error: '',\n        config: {},\n        activeTool: 'highlight',\n        highlightShape: 'rect',\n        highlightRect: EMPTY_RECT,\n        polygonPoints: [],\n        polygonClosed: false,\n        polygonPointer: null,\n        polygonError: '',\n        // Brush strokes, mask mode only: {width, points: [{x, y}]}, width\n        // as a share of the image width (highlight-brush.js).\n        brushStrokes: [],\n        // Percent of the image width, for the next stroke.\n        brushSize: 4,\n        brushSizeMin: BRUSH_SIZE_MIN,\n        brushSizeMax: BRUSH_SIZE_MAX,\n        brushCursor: null,\n        brushError: '',\n        // \"Quader\", place mode only (highlight-box.js): the floor corners in\n        // tap order, and the height at the nearest corner as a share of the\n        // image height, 0 until set.\n        boxCorners: [],\n        boxHeight: 0,\n        // The box behind each target's last taken space, kept here and\n        // never sent: {shape (JSON), corners, height} or null.\n        _placedBoxes: {},\n        cropRect: EMPTY_RECT,\n        // The \"Begradigen\" operation being edited (highlight-straighten.js),\n        // null for no straightening. Every save sends it, so a crop or\n        // highlight save keeps the straightening.\n        keystone: null,\n        // The server's strength table, loaded when the tool first opens.\n        straightenSteps: null,\n        straightenStart: 0,\n        straightenMinShare: 0.5,\n        straightenLoading: false,\n        straightenError: '',\n        // Why the tool has no steps (\"Dieses Foto ist bereits gerade.\").\n        straightenNote: '',\n        // Set once the customer picks a strength, so the tool never replaces\n        // a chosen \"Aus\" with its suggestion.\n        straightenTouched: false,\n        // Bumped when the stage photo has loaded, so the canvases redraw.\n        stageImageTick: 0,\n        guideVisible: false,\n        shapeChangeOpen: false,\n        pendingShape: null,\n        cornerRadius: 8,\n        strength: 55,\n        borderWidth: 2,\n        borderColor: '#ffffff',\n        zoom: 1,\n        panX: 0,\n        panY: 0,\n        // Bumped when the viewport box changes (editor opened, window resized).\n        // Style getters measure the viewport via getBoundingClientRect, which\n        // is not reactive \u2014 reading this counter makes them re-evaluate.\n        viewportTick: 0,\n        _initialOperations: '{}',\n        _pointers: {},\n        _gesture: null,\n        _gestureStart: null,\n        _beforeUnloadHandler: null,\n        _htmxHandler: null,\n        _resizeHandler: null,\n        _pendingNavHref: null,\n        _viewportElement: null,\n        _lastTap: null,\n\n        ...window.highlightPolygonEditorMethods(),\n        ...window.highlightBrushEditorMethods(),\n        ...window.highlightBoxEditorMethods(),\n        ...window.highlightStraightenEditorMethods(),\n\n        init() {\n            this._viewportElement = this.$el.querySelector('[data-highlight-stage]');\n            const configElement = this.$el.closest('[data-highlight-editor-config]');\n            try {\n                this.config = JSON.parse(configElement?.dataset.highlightEditorConfig || '{}');\n            } catch (_) {\n                this.config = {};\n            }\n            this.loadOperations(this.config.operations || {});\n            this._initialOperations = JSON.stringify(this.serializeOperations());\n\n            this._beforeUnloadHandler = (event) => {\n                if (!this.editing || !this.dirty) return;\n                event.preventDefault();\n                event.returnValue = '';\n            };\n            this._htmxHandler = (event) => {\n                if (!this.editing || !this.dirty || !event.detail.boosted) return;\n                event.preventDefault();\n                this._pendingNavHref = event.detail.elt?.getAttribute?.('href')\n                    || event.detail.requestConfig?.path\n                    || null;\n                this.discardOpen = true;\n            };\n            this._resizeHandler = () => {\n                if (this.editing) this.viewportTick++;\n            };\n            window.addEventListener('beforeunload', this._beforeUnloadHandler);\n            document.addEventListener('htmx:beforeRequest', this._htmxHandler);\n            window.addEventListener('resize', this._resizeHandler);\n        },\n\n        destroy() {\n            window.removeEventListener('beforeunload', this._beforeUnloadHandler);\n            document.removeEventListener('htmx:beforeRequest', this._htmxHandler);\n            window.removeEventListener('resize', this._resizeHandler);\n            this._viewportElement = null;\n        },\n\n        loadOperations(operations) {\n            const highlight = highlightOperation(operations);\n            const crop = cropOperation(operations);\n            const keystone = keystoneOperation(operations);\n            this.keystone = keystone ? JSON.parse(JSON.stringify(keystone)) : null;\n            this.straightenTouched = false;\n            const params = highlight?.params || {};\n            const rect = params.rect;\n            this.highlightShape = highlight?.type === 'highlight_polygon' ? 'polygon' : 'rect';\n            this.highlightRect = rect ? {\n                x: Number(rect.x),\n                y: Number(rect.y),\n                width: Number(rect.width),\n                height: Number(rect.height),\n            } : EMPTY_RECT;\n            this.polygonPoints = highlight?.type === 'highlight_polygon'\n                ? (params.points || []).map((point) => ({\n                    x: Number(point.x),\n                    y: Number(point.y),\n                }))\n                : [];\n            this.polygonClosed = this.polygonPoints.length >= 3;\n            this.polygonPointer = null;\n            this.polygonError = '';\n            this.brushStrokes = [];\n            this.brushError = '';\n            const cropRect = crop?.params?.rect;\n            this.cropRect = cropRect ? {\n                x: Number(cropRect.x),\n                y: Number(cropRect.y),\n                width: Number(cropRect.width),\n                height: Number(cropRect.height),\n            } : EMPTY_RECT;\n            this.activeTool = highlight ? 'highlight' : (this.cropRect ? 'crop' : 'highlight');\n            this.cornerRadius = clamp(Math.round(Number(params.corner_radius_ratio ?? 0.08) * 100), 0, 40);\n            this.strength = clamp(Math.round((Number(params.outside?.darken ?? 0.22) / STRENGTH_MAX_DARKEN) * 100), 0, 100);\n            // Round to the slider's 0.5 steps so stored recipes survive a reload.\n            this.borderWidth = clamp(Math.round(Number(params.stroke?.width_ratio ?? 0.002) * 2000) / 2, 0, 12);\n            this.borderColor = /^#[0-9a-f]{6}$/i.test(params.stroke?.color || '')\n                ? params.stroke.color\n                : '#ffffff';\n            this.guideVisible = Boolean(this.rect || this.polygonClosed);\n        },\n\n        selectTool(tool) {\n            if (!['highlight', 'crop', 'straighten'].includes(tool) || this.applying) return;\n            if (tool === 'straighten' && !this.config.straightenUrl) return;\n            this.activeTool = tool;\n            this.guideVisible = Boolean(\n                this.rect || (tool === 'highlight' && this.polygonClosed)\n            );\n            this._gesture = null;\n            this._gestureStart = null;\n            if (tool === 'straighten') {\n                if (this.straightenSteps) {\n                    if (!this.keystone && !this.straightenTouched) this.selectStraightenStrength(this.straightenStart);\n                } else {\n                    this.loadStraightenSteps();\n                }\n            }\n        },\n\n        openEditor() {\n            if (this.config.aiBusy || !this.config.baseUrl || !this.config.applyUrl) return;\n            this.mode = 'manual';\n            this.baseOverride = null;\n            this.loadOperations(this.config.operations || {});\n            this._initialOperations = JSON.stringify(this.serializeOperations());\n            this.zoom = 1;\n            this.panX = 0;\n            this.panY = 0;\n            this.error = '';\n            this.editing = true;\n            this.$dispatch('highlight-editor-mode', {open: true});\n            // The viewport only gets real dimensions once x-show reveals it.\n            this.$nextTick(() => this.viewportTick++);\n        },\n\n        // Opened by the edit form's \"Stelle \u00E4ndern\" mode with the area marked\n        // so far, if any. Rectangle is the default shape.\n        openMaskEditor(detail) {\n            this.openAreaEditor('mask', detail);\n        },\n\n        // Opened by \"M\u00F6belst\u00FCck platzieren\" in the edit form or the\n        // retry dialog, with the space drawn so far. Box, rectangle and free\n        // form, no brush: the block painted into the AI input needs one\n        // outline. The box is the default.\n        openPlaceEditor(detail) {\n            this.openAreaEditor('place', detail);\n        },\n\n        // Mask and place mode: draw one area and hand it back as a shape.\n        openAreaEditor(mode, detail) {\n            const base = mode === 'place' && detail?.base?.url ? detail.base : null;\n            if (this.config.aiBusy || !(base?.url || this.config.baseUrl)) return;\n            const shape = detail?.shape || null;\n            this.mode = mode;\n            this.placeTarget = detail?.target || 'form';\n            this.baseOverride = base;\n            this.activeTool = 'highlight';\n            this.cropRect = EMPTY_RECT;\n            if (['polygon', 'brush'].includes(shape?.type)) this.highlightShape = shape.type;\n            else this.highlightShape = mode === 'place' && !shape ? 'box' : 'rect';\n            this.highlightRect = shape?.type === 'rect' ? {...shape.rect} : EMPTY_RECT;\n            this.polygonPoints = shape?.type === 'polygon'\n                ? shape.points.map((point) => ({x: Number(point.x), y: Number(point.y)}))\n                : [];\n            this.polygonClosed = this.polygonPoints.length >= 3;\n            this.polygonPointer = null;\n            this.polygonError = '';\n            this.brushStrokes = shape?.type === 'brush'\n                ? shape.strokes.map((stroke) => ({\n                    width: Number(stroke.width),\n                    points: stroke.points.map(([x, y]) => ({x: Number(x), y: Number(y)})),\n                }))\n                : [];\n            this.brushError = '';\n            if (this.brushStrokes.length) {\n                const lastWidth = this.brushStrokes[this.brushStrokes.length - 1].width * 100;\n                this.brushSize = clamp(Math.round(lastWidth * 2) / 2, BRUSH_SIZE_MIN, BRUSH_SIZE_MAX);\n            }\n            this.resetBox();\n            if (mode === 'place' && this.restorePlacedBox(shape)) {\n                this.highlightRect = EMPTY_RECT;\n                this.polygonPoints = [];\n                this.polygonClosed = false;\n            }\n            this.cornerRadius = 0;\n            this.borderWidth = 0;\n            this.guideVisible = Boolean(shape) && shape.type !== 'brush';\n            this._initialOperations = JSON.stringify(this.maskShape());\n            this.zoom = 1;\n            this.panX = 0;\n            this.panY = 0;\n            this.error = '';\n            this.editing = true;\n            this.$dispatch('highlight-editor-mode', {open: true});\n            this.$nextTick(() => {\n                this.viewportTick++;\n                this.$el.scrollIntoView({block: 'start'});\n            });\n        },\n\n        // The marked area in the normalized base coordinates the server\n        // validates (dashboard/mask_edit.py), or null.\n        maskShape() {\n            if (this.highlightShape === 'rect' && this.highlightRect) {\n                return {type: 'rect', rect: this.serializedRect(this.highlightRect)};\n            }\n            if (this.highlightShape === 'polygon' && this.polygonClosed && this.polygonPoints.length >= 3) {\n                return {type: 'polygon', points: this.polygonPoints.map((point) => this.serializedPoint(point))};\n            }\n            // A box goes out as its outline, a plain polygon.\n            if (this.highlightShape === 'box') {\n                const outline = this.boxOutline();\n                return outline ? {type: 'polygon', points: outline} : null;\n            }\n            if (this.highlightShape === 'brush' && this.brushStrokes.length) {\n                // Pairs at 4 decimals (under a pixel on any photo) keep the\n                // posted JSON small; a stroke can hold hundreds of points.\n                return {\n                    type: 'brush',\n                    strokes: this.brushStrokes.map((stroke) => ({\n                        width: brushRounded(stroke.width),\n                        points: stroke.points.map((point) => [brushRounded(point.x), brushRounded(point.y)]),\n                    })),\n                };\n            }\n            return null;\n        },\n\n        confirmMask() {\n            if (!this.canConfirmMask) return;\n            const shape = this.maskShape();\n            this._initialOperations = JSON.stringify(shape);\n            this.closeEditor();\n            this.$dispatch('mask-area-selected', {shape});\n        },\n\n        confirmPlace() {\n            if (!this.canConfirmMask) return;\n            const shape = this.maskShape();\n            this._initialOperations = JSON.stringify(shape);\n            this.rememberPlacedBox(this._initialOperations);\n            this.closeEditor();\n            this.$dispatch('place-area-selected', {shape, target: this.placeTarget});\n        },\n\n        cancel() {\n            if (!this.editing || this.applying) return;\n            if (this.shapeChangeOpen) {\n                this.cancelShapeChange();\n                return;\n            }\n            if (this.discardOpen) return;\n            if (this.dirty) {\n                // Deferred: the modal shell's own window-escape handler runs\n                // later in the same keydown and would instantly re-close it.\n                this.$nextTick(() => { this.discardOpen = true; });\n                return;\n            }\n            this.closeEditor();\n        },\n\n        closeEditor() {\n            this.editing = false;\n            this.error = '';\n            this.shapeChangeOpen = false;\n            this.pendingShape = null;\n            this.brushCursor = null;\n            this.$dispatch('highlight-editor-mode', {open: false});\n        },\n\n        keepEditing() {\n            this.discardOpen = false;\n            this._pendingNavHref = null;\n        },\n\n        confirmDiscard() {\n            const target = this._pendingNavHref;\n            this._pendingNavHref = null;\n            this.discardOpen = false;\n            this.closeEditor();\n            if (target) window.location.href = target;\n        },\n\n        removeEdits() {\n            this.highlightRect = EMPTY_RECT;\n            this.polygonPoints = [];\n            this.polygonClosed = false;\n            this.polygonPointer = null;\n            this.polygonError = '';\n            this.cropRect = EMPTY_RECT;\n            this.guideVisible = false;\n            this.zoom = 1;\n            this.panX = 0;\n            this.panY = 0;\n        },\n\n        serializeOperations() {\n            const operations = [];\n            // The keystone renders first; the server checks it against the\n            // photo's own detection (image_editor.check_keystone).\n            if (this.keystone) {\n                operations.push(JSON.parse(JSON.stringify(this.keystone)));\n            }\n            if (this.cropRect) {\n                operations.push({\n                    type: 'crop_rect',\n                    version: 1,\n                    params: {rect: this.serializedRect(this.cropRect)},\n                });\n            }\n            if (this.highlightRect) {\n                operations.push({\n                    type: 'highlight_rect',\n                    version: 1,\n                    params: {\n                        rect: this.serializedRect(this.highlightRect),\n                        corner_radius_ratio: rounded(this.cornerRadius / 100),\n                        outside: {\n                            blur_sigma_ratio: rounded((this.strength / 100) * STRENGTH_MAX_BLUR),\n                            darken: rounded((this.strength / 100) * STRENGTH_MAX_DARKEN),\n                        },\n                        stroke: {\n                            width_ratio: rounded(this.borderWidth / 1000),\n                            color: this.borderColor.toUpperCase(),\n                            opacity: 1,\n                        },\n                    },\n                });\n            } else if (this.polygonClosed && this.polygonPoints.length >= 3) {\n                operations.push({\n                    type: 'highlight_polygon',\n                    version: 1,\n                    params: {\n                        points: this.polygonPoints.map((point) => this.serializedPoint(point)),\n                        outside: {\n                            blur_sigma_ratio: rounded((this.strength / 100) * STRENGTH_MAX_BLUR),\n                            darken: rounded((this.strength / 100) * STRENGTH_MAX_DARKEN),\n                        },\n                        stroke: {\n                            width_ratio: rounded(this.borderWidth / 1000),\n                            color: this.borderColor.toUpperCase(),\n                            opacity: 1,\n                        },\n                    },\n                });\n            }\n            if (!operations.length) return {};\n            return {\n                schema_version: 1,\n                operations,\n            };\n        },\n\n        serializedRect(rect) {\n            return {\n                x: rounded(rect.x),\n                y: rounded(rect.y),\n                width: rounded(rect.width),\n                height: rounded(rect.height),\n            };\n        },\n\n        serializedPoint(point) {\n            return {x: rounded(point.x), y: rounded(point.y)};\n        },\n\n        removeCurrentTool() {\n            if (this.activeTool === 'highlight' && this.highlightShape === 'polygon') {\n                this.polygonPoints = [];\n                this.polygonClosed = false;\n                this.polygonPointer = null;\n                this.polygonError = '';\n            } else {\n                this.rect = EMPTY_RECT;\n            }\n            this.guideVisible = false;\n        },\n\n        async apply() {\n            if (!this.canApply) return;\n            this.applying = true;\n            this.error = '';\n            try {\n                const response = await fetch(this.config.applyUrl, {\n                    method: 'POST',\n                    credentials: 'same-origin',\n                    headers: {\n                        'Content-Type': 'application/json',\n                        'X-CSRFToken': this.csrfToken(),\n                        'Accept': 'application/json',\n                    },\n                    body: JSON.stringify({\n                        revision: this.config.revisionId || '',\n                        version: Number(this.config.version || 0),\n                        operations: this.serializeOperations(),\n                    }),\n                });\n                if (!response.ok) {\n                    let message = this.message('applyFailed', 'Die \u00C4nderungen konnten nicht angewendet werden.');\n                    try {\n                        const body = await response.json();\n                        if (body.error === 'ai_edit_active') {\n                            message = this.message('aiBusy', 'F\u00FCr dieses Foto l\u00E4uft gerade eine KI-Bearbeitung.');\n                        } else if (body.error === 'stale_version') {\n                            message = this.message('stale', 'Das Foto wurde zwischenzeitlich ge\u00E4ndert. Bitte laden Sie die Seite neu.');\n                        } else if (body.message) {\n                            message = body.message;\n                        }\n                    } catch (_) {}\n                    throw new Error(message);\n                }\n                const body = await response.json();\n                this.config.version = body.version;\n                this.config.operations = body.operations;\n                this.config.hasEdits = body.hasEdits;\n                this.loadOperations(body.operations);\n                this._initialOperations = JSON.stringify(this.serializeOperations());\n                this.updatePublishedImage(body);\n                this.updateStraightening(body);\n                this.$dispatch('revision-image-updated', {id: this.config.revisionId, url: body.imageUrl});\n                this.applying = false;\n                this.closeEditor();\n            } catch (error) {\n                this.error = error.message || this.message('applyFailed', 'Die \u00C4nderungen konnten nicht angewendet werden.');\n                this.applying = false;\n            }\n        },\n\n        updatePublishedImage(body) {\n            const image = document.getElementById('photo-image');\n            if (image) {\n                image.src = body.imageUrl;\n                const lightboxLink = image.closest('a');\n                if (lightboxLink) {\n                    lightboxLink.href = body.imageUrl;\n                    if (body.imageWidth && body.imageHeight) {\n                        lightboxLink.style.aspectRatio = body.imageWidth + '/' + body.imageHeight;\n                    }\n                }\n            }\n            document.querySelectorAll('[data-photo-current-image]').forEach((el) => {\n                el.src = body.imageUrl;\n            });\n            const id = this.config.revisionId;\n            if (!id) return;\n            document.querySelectorAll(`[data-manually-edited=\"${id}\"]`).forEach((el) => {\n                el.style.display = body.hasEdits ? '' : 'none';\n            });\n            document.querySelectorAll(`[data-revision-image=\"${id}\"]`).forEach((el) => {\n                el.src = body.imageUrl;\n            });\n            document.querySelectorAll(`[data-revision-link=\"${id}\"]`).forEach((el) => {\n                el.href = body.imageUrl;\n            });\n        },\n\n        // A save can change the keystone: the frame that mask and placement\n        // draw on, the callout under the photo and the \"Begradigen\" button in\n        // the action row. The server renders both slots; this only swaps them.\n        updateStraightening(body) {\n            if (body.drawingBaseUrl && body.drawingBaseUrl !== this.config.baseUrl) {\n                this.config.baseUrl = body.drawingBaseUrl;\n                window.dispatchEvent(new CustomEvent('drawing-base-updated', {detail: {url: body.drawingBaseUrl}}));\n            }\n            [['hint', body.straightenHint], ['action', body.straightenAction]].forEach(([name, html]) => {\n                const slot = document.querySelector(`[data-straighten-slot=\"${name}\"]`);\n                if (!slot || typeof html !== 'string') return;\n                const holder = document.createElement('div');\n                holder.innerHTML = html.trim();\n                const fresh = holder.firstElementChild;\n                if (fresh) {\n                    slot.replaceWith(fresh);\n                    if (window.htmx) window.htmx.process(fresh);\n                }\n            });\n        },\n\n        message(key, fallback) {\n            return this.config.messages?.[key] || fallback;\n        },\n\n        csrfToken() {\n            return document.querySelector('meta[name=\"csrf-token\"]')?.content || '';\n        },\n\n        startDraw(event) {\n            // The straighten tool draws nothing: its frame has its own\n            // handlers. A pointer here can still become a pinch.\n            if (this.activeTool === 'straighten') {\n                this.trackPointer(event);\n                this.beginPinchIfNeeded();\n                return;\n            }\n            if (this.activeTool === 'highlight' && this.highlightShape === 'polygon') {\n                this.startPolygonPoint(event);\n                return;\n            }\n            if (this.activeTool === 'highlight' && this.highlightShape === 'box') {\n                this.startBoxPoint(event);\n                return;\n            }\n            if (this.brushActive) {\n                this.startBrushStroke(event);\n                return;\n            }\n            if (this.pointerCount > 0) {\n                this.trackPointer(event);\n                this.beginPinchIfNeeded();\n                return;\n            }\n            this.trackPointer(event);\n            const point = this.imagePoint(event);\n            this._gesture = 'draw';\n            this._gestureStart = {\n                point,\n                client: {x: event.clientX, y: event.clientY},\n                originalRect: this.rect ? {...this.rect} : null,\n                moved: false,\n            };\n            this.capturePointer(event);\n        },\n\n        startMove(event) {\n            this.trackPointer(event);\n            if (this.pointerCount > 1) {\n                this.beginPinchIfNeeded();\n                return;\n            }\n            this.guideVisible = true;\n            this._gesture = 'move';\n            this._gestureStart = {point: this.imagePoint(event), rect: {...this.rect}};\n            this.capturePointer(event);\n        },\n\n        startResize(event, handle) {\n            this.trackPointer(event);\n            if (this.pointerCount > 1) {\n                this.beginPinchIfNeeded();\n                return;\n            }\n            this.guideVisible = true;\n            this._gesture = 'resize';\n            this._gestureStart = {\n                point: this.imagePoint(event),\n                rect: {...this.rect},\n                handle: handle || 'br',\n            };\n            this.capturePointer(event);\n        },\n\n        pointerMove(event) {\n            if (this.brushActive) this.trackBrushCursor(event);\n            if (!this._pointers[event.pointerId]) {\n                if (\n                    this.activeTool === 'highlight'\n                    && this.highlightShape === 'polygon'\n                    && !this.polygonClosed\n                    && this.polygonPoints.length\n                    && event.pointerType !== 'touch'\n                ) this.polygonPointer = this.imagePoint(event);\n                return;\n            }\n            this.trackPointer(event);\n            if (this.pointerCount > 1 || this._gesture === 'pinch') {\n                this.updatePinch();\n                return;\n            }\n            if (!this._gestureStart) return;\n            if (this._gesture === 'brush') {\n                this.extendBrushStroke(event);\n                return;\n            }\n            if (this._gesture === 'frame-move' || this._gesture === 'frame-resize') {\n                this.updateFrameGesture(event);\n                return;\n            }\n            const point = this.imagePoint(event);\n            if (this._gesture === 'draw') this.updateDraw(event, point);\n            else if (this._gesture === 'move') this.updateMove(point);\n            else if (this._gesture === 'resize') this.updateResize(point);\n            else if (this._gesture === 'polygon-point') {\n                this.polygonPointer = point;\n                this.markPolygonGestureMoved(event, 8);\n            } else if (this._gesture === 'polygon-close') {\n                this.markPolygonGestureMoved(event, 8);\n            } else if (this._gesture === 'polygon-vertex') {\n                this.markPolygonGestureMoved(event, 3);\n                if (this._gestureStart.moved) {\n                    this.polygonPoints[this._gestureStart.index] = point;\n                }\n            } else if (this._gesture === 'polygon-move') {\n                this.updatePolygonMove(point);\n            } else if (this._gesture?.startsWith('box-')) {\n                this.updateBoxGesture(event, point);\n            }\n        },\n\n        pointerEnd(event) {\n            const gesture = this._gesture;\n            const wasDraw = this._gesture === 'draw';\n            const moved = this._gestureStart?.moved;\n            const originalRect = this._gestureStart?.originalRect;\n            delete this._pointers[event.pointerId];\n\n            if (this._gesture === 'pinch') {\n                if (this.pointerCount < 2) this._gestureStart = null;\n                if (this.pointerCount === 0) this._gesture = null;\n                return;\n            }\n            if (gesture?.startsWith('polygon-')) {\n                this.finishPolygonGesture(event, gesture);\n                return;\n            }\n            if (gesture?.startsWith('box-')) {\n                this.finishBoxGesture(event, gesture);\n                return;\n            }\n            if (gesture === 'brush') {\n                this.finishBrushStroke(event);\n                return;\n            }\n            if (gesture === 'frame-move' || gesture === 'frame-resize') {\n                this._gesture = null;\n                this._gestureStart = null;\n                return;\n            }\n            if (wasDraw && !moved) {\n                this.rect = originalRect;\n                this.guideVisible = false;\n            } else if (wasDraw && this.rect) {\n                // A straight-line drag yields a zero-size rect: invisible, yet\n                // it would enable Apply and be rejected by the server.\n                const minimum = this.minimumSelectionSize;\n                if (this.rect.width < minimum.x || this.rect.height < minimum.y) {\n                    this.rect = originalRect;\n                    this.guideVisible = Boolean(originalRect);\n                } else {\n                    this.guideVisible = true;\n                }\n            } else if (this.rect) {\n                this.guideVisible = true;\n            }\n            this._gesture = null;\n            this._gestureStart = null;\n        },\n\n        updateDraw(event, point) {\n            const distanceMoved = Math.hypot(\n                event.clientX - this._gestureStart.client.x,\n                event.clientY - this._gestureStart.client.y\n            );\n            if (!this._gestureStart.moved && distanceMoved < 5) return;\n            this._gestureStart.moved = true;\n            const start = this._gestureStart.point;\n            this.rect = {\n                x: clamp(Math.min(start.x, point.x), 0, 1),\n                y: clamp(Math.min(start.y, point.y), 0, 1),\n                width: Math.abs(point.x - start.x),\n                height: Math.abs(point.y - start.y),\n            };\n            this.guideVisible = true;\n        },\n\n        updateMove(point) {\n            const start = this._gestureStart;\n            const dx = point.x - start.point.x;\n            const dy = point.y - start.point.y;\n            this.rect = {\n                ...start.rect,\n                x: clamp(start.rect.x + dx, 0, 1 - start.rect.width),\n                y: clamp(start.rect.y + dy, 0, 1 - start.rect.height),\n            };\n        },\n\n        updateResize(point) {\n            const original = this._gestureStart.rect;\n            const handle = this._gestureStart.handle;\n            const minimum = this.minimumSelectionSize;\n            let left = original.x;\n            let top = original.y;\n            let right = original.x + original.width;\n            let bottom = original.y + original.height;\n            if (handle.includes('l')) left = clamp(point.x, 0, Math.max(0, right - minimum.x));\n            else if (handle.includes('r')) right = clamp(point.x, left + minimum.x, 1);\n            if (handle.includes('t')) top = clamp(point.y, 0, Math.max(0, bottom - minimum.y));\n            else if (handle.includes('b')) bottom = clamp(point.y, top + minimum.y, 1);\n            this.rect = {x: left, y: top, width: right - left, height: bottom - top};\n        },\n\n        trackPointer(event) {\n            this._pointers[event.pointerId] = {x: event.clientX, y: event.clientY};\n        },\n\n        capturePointer(event) {\n            try { this._viewportElement?.setPointerCapture(event.pointerId); } catch (_) {}\n        },\n\n        beginPinchIfNeeded() {\n            if (this.pointerCount < 2) return;\n            if (!this._viewportElement) return;\n            if (this._gestureStart?.originalPoints) {\n                this.polygonPoints = this._gestureStart.originalPoints;\n            }\n            if (this._gestureStart?.originalBox) this.restoreBoxSnapshot(this._gestureStart.originalBox);\n            if (this._gesture === 'brush') this.cancelBrushStroke();\n            this.polygonPointer = null;\n            const points = Object.values(this._pointers).slice(0, 2);\n            const viewport = this._viewportElement.getBoundingClientRect();\n            const mid = midpoint(points[0], points[1]);\n            this._gesture = 'pinch';\n            this._gestureStart = {\n                distance: Math.max(1, distance(points[0], points[1])),\n                midpoint: {x: mid.x - viewport.left, y: mid.y - viewport.top},\n                zoom: this.zoom,\n                panX: this.panX,\n                panY: this.panY,\n            };\n        },\n\n        updatePinch() {\n            if (this.pointerCount < 2) return;\n            if (this._gesture !== 'pinch') this.beginPinchIfNeeded();\n            if (!this._gestureStart || !this._viewportElement) return;\n            const points = Object.values(this._pointers).slice(0, 2);\n            const viewport = this._viewportElement.getBoundingClientRect();\n            const mid = midpoint(points[0], points[1]);\n            const currentMid = {x: mid.x - viewport.left, y: mid.y - viewport.top};\n            const nextZoom = clamp(\n                this._gestureStart.zoom * distance(points[0], points[1]) / this._gestureStart.distance,\n                1,\n                4\n            );\n            const anchorX = (this._gestureStart.midpoint.x - this._gestureStart.panX) / this._gestureStart.zoom;\n            const anchorY = (this._gestureStart.midpoint.y - this._gestureStart.panY) / this._gestureStart.zoom;\n            this.zoom = nextZoom;\n            this.panX = currentMid.x - anchorX * nextZoom;\n            this.panY = currentMid.y - anchorY * nextZoom;\n            this.clampPan();\n        },\n\n        clampPan() {\n            if (!this._viewportElement) return;\n            const viewport = this._viewportElement.getBoundingClientRect();\n            this.panX = clamp(this.panX, viewport.width * (1 - this.zoom), 0);\n            this.panY = clamp(this.panY, viewport.height * (1 - this.zoom), 0);\n        },\n\n        resetZoom() {\n            this.zoom = 1;\n            this.panX = 0;\n            this.panY = 0;\n        },\n\n        // The pointer in normalized image coordinates, clamped to the image.\n        // The box height drag passes false: its top may lie above the photo.\n        imagePoint(event, clampToImage = true) {\n            if (!this._viewportElement) return {x: 0, y: 0};\n            const viewport = this._viewportElement.getBoundingClientRect();\n            const x = (event.clientX - viewport.left - this.panX) / (viewport.width * this.zoom);\n            const y = (event.clientY - viewport.top - this.panY) / (viewport.height * this.zoom);\n            return clampToImage ? {x: clamp(x, 0, 1), y: clamp(y, 0, 1)} : {x, y};\n        },\n\n        get pointerCount() {\n            return Object.keys(this._pointers).length;\n        },\n\n        get rect() {\n            if (this.activeTool === 'crop') return this.cropRect;\n            if (this.activeTool === 'straighten') return EMPTY_RECT;\n            return this.highlightShape === 'rect' ? this.highlightRect : EMPTY_RECT;\n        },\n\n        set rect(value) {\n            if (this.activeTool === 'crop') this.cropRect = value;\n            else if (this.activeTool !== 'straighten') this.highlightRect = value;\n        },\n\n        // The stage shows the photo through the straightening canvases.\n        get stageWarped() {\n            return this.mode === 'manual' && Boolean(this.keystone);\n        },\n\n        // The tool view shows the whole warped photo and the movable frame.\n        get straightenToolView() {\n            return this.mode === 'manual' && this.activeTool === 'straighten' && Boolean(this.keystone);\n        },\n\n        // The saved recipe straightens (\"Originalperspektive\" in the panel).\n        get hasSavedKeystone() {\n            return Boolean(keystoneOperation(this.config.operations));\n        },\n\n        get dirty() {\n            const polygonDraft = (\n                this.highlightShape === 'polygon'\n                && this.polygonPoints.length > 0\n                && !this.polygonClosed\n            );\n            const boxDraft = this.highlightShape === 'box' && this.boxCorners.length > 0 && !this.boxComplete();\n            const current = this.mode === 'manual' ? this.serializeOperations() : this.maskShape();\n            return polygonDraft || boxDraft || JSON.stringify(current) !== this._initialOperations;\n        },\n\n        get canApply() {\n            // Mask mode never applies; skipping it here also keeps the button\n            // binding from serializing every brush point on each move.\n            if (this.mode !== 'manual') return false;\n            const polygonInProgress = (\n                this.highlightShape === 'polygon'\n                && this.polygonPoints.length > 0\n                && !this.polygonClosed\n            );\n            return this.dirty && !this.applying && !polygonInProgress;\n        },\n\n        get canConfirmMask() {\n            if (this.highlightShape === 'brush') return this.brushStrokes.length > 0;\n            // Four corners and a height, inside the server's bounds.\n            if (this.highlightShape === 'box') return Boolean(this.maskShape()) && !this.boxError();\n            const polygonInProgress = (\n                this.highlightShape === 'polygon'\n                && this.polygonPoints.length > 0\n                && !this.polygonClosed\n            );\n            return Boolean(this.maskShape()) && !polygonInProgress;\n        },\n\n        get brushActive() {\n            return this.activeTool === 'highlight' && this.highlightShape === 'brush';\n        },\n\n        // True when the current shape holds something a shape switch would lose.\n        get hasShapeContent() {\n            if (this.highlightShape === 'brush') return this.brushStrokes.length > 0;\n            if (this.highlightShape === 'polygon') return this.polygonPoints.length > 0;\n            if (this.highlightShape === 'box') return this.boxCorners.length > 0;\n            return Boolean(this.highlightRect);\n        },\n\n        // The hint line stays in the text colour until the shape is drawn.\n        // The box has a new instruction at each step, so it stays until the\n        // box is complete.\n        get shapeHintMuted() {\n            return this.highlightShape === 'box' ? this.boxComplete() : this.hasShapeContent;\n        },\n\n        // The shape-change dialog discards instead of converting: strokes,\n        // a box and outlines cannot be converted into each other.\n        get discardShapeChange() {\n            return ['brush', 'box'].includes(this.highlightShape) || ['brush', 'box'].includes(this.pendingShape);\n        },\n\n        // The action row below the photo: one undo and one reset for the\n        // free form, the brush and the box.\n        get canUndoShapeStep() {\n            if (this.highlightShape === 'brush') return this.brushStrokes.length > 0;\n            if (this.highlightShape === 'polygon') return this.polygonPoints.length > 0;\n            if (this.highlightShape === 'box') return this.boxCorners.length > 0;\n            return false;\n        },\n\n        get shapeError() {\n            if (this.highlightShape === 'brush') return this.brushError;\n            if (this.highlightShape === 'box') return this.boxError();\n            return this.polygonError;\n        },\n\n        undoShapeStep() {\n            if (this.highlightShape === 'brush') this.undoBrushStroke();\n            else if (this.highlightShape === 'polygon') this.undoPolygonPoint();\n            else if (this.highlightShape === 'box') this.undoBoxStep();\n        },\n\n        resetShape() {\n            if (this.highlightShape === 'brush') this.resetBrush();\n            else if (this.highlightShape === 'polygon') this.resetPolygon();\n            else if (this.highlightShape === 'box') this.resetBox();\n        },\n\n        // Shortcuts while the editor is open, so closing and undoing do not\n        // depend on a control: Enter closes an open free form, Backspace and\n        // Delete undo the last point or stroke. Escape has its own handler.\n        handleEditorKey(event) {\n            if (!this.editing || this.applying || this.discardOpen || this.shapeChangeOpen) return;\n            if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return;\n            if (this.activeTool !== 'highlight') return;\n            const target = event.target;\n            const nonTextInputs = ['range', 'color', 'checkbox', 'radio', 'button', 'submit', 'reset'];\n            if (\n                target?.isContentEditable\n                || ['TEXTAREA', 'SELECT'].includes(target?.tagName)\n                || (target?.tagName === 'INPUT' && !nonTextInputs.includes(target.type))\n            ) return;\n            if (event.key === 'Enter') {\n                // Enter on a focused button or link is that control's click.\n                if (['BUTTON', 'A'].includes(target?.tagName)) return;\n                if (this.highlightShape !== 'polygon' || this.polygonClosed || this.polygonPoints.length < 3) return;\n                event.preventDefault();\n                this.closePolygon();\n            } else if (event.key === 'Backspace' || event.key === 'Delete') {\n                if (!this.canUndoShapeStep) return;\n                event.preventDefault();\n                this.undoShapeStep();\n            }\n        },\n\n        get hasHighlightSelection() {\n            return Boolean(\n                this.highlightRect\n                || (this.polygonClosed && this.polygonPoints.length >= 3)\n            );\n        },\n\n        get hasSavedEdits() {\n            return Boolean(this.config.hasEdits);\n        },\n\n        // The manual editor draws on the raw file and previews the keystone\n        // itself (drawStagePreview). Mask and place mode draw on the drawing\n        // base, the server's keystone render, which their coordinates refer to.\n        get stageBaseUrl() {\n            if (this.mode === 'manual') return this.config.rawUrl || this.config.baseUrl;\n            return this.baseOverride?.url || this.config.baseUrl;\n        },\n\n        // Pixel size of the image the editor draws on; 4:3 when unknown.\n        get imageSize() {\n            const source = this.baseOverride || this.config;\n            const width = Number(source.width);\n            const height = Number(source.height);\n            return width > 0 && height > 0 ? {width, height} : {width: 4000, height: 3000};\n        },\n\n        get imageViewBox() {\n            return '0 0 ' + this.imageSize.width + ' ' + this.imageSize.height;\n        },\n\n        // The stage keeps the photo's aspect, and its height is capped so the\n        // controls below a portrait photo stay on screen. The cap narrows the\n        // stage, which stays centred in the dark frame.\n        get viewportStyle() {\n            const {width, height} = this.imageSize;\n            const ratio = width / height;\n            return 'aspect-ratio:' + width + '/' + height\n                + ';max-width:calc(max(100vh - ' + STAGE_RESERVED_HEIGHT + ', ' + STAGE_MIN_HEIGHT + ') * ' + ratio + ')'\n                + ';max-width:calc(max(100dvh - ' + STAGE_RESERVED_HEIGHT + ', ' + STAGE_MIN_HEIGHT + ') * ' + ratio + ')';\n        },\n\n        get brushMarkup() {\n            const {width, height} = this.imageSize;\n            return window.brushStrokesMarkup(this.brushStrokes, width, height);\n        },\n\n        get brushCursorRadius() {\n            return (this.brushSize / 100) * this.imageSize.width / 2;\n        },\n\n        get stageStyle() {\n            return 'transform:translate(' + this.panX + 'px,' + this.panY + 'px) scale(' + this.zoom + ');transform-origin:top left';\n        },\n\n        get outsideImageStyle() {\n            if (this.activeTool !== 'highlight' || !this.hasHighlightSelection) return '';\n            // A placement fills the space itself instead (selectionStyle and\n            // the polygon fill): the rest of the photo stays as it is.\n            if (this.mode === 'place') return '';\n            // A mask only dims the rest of the photo: blurring it would look\n            // like part of the requested change.\n            if (this.mode === 'mask') return 'filter:brightness(0.55)';\n            this.viewportTick;\n            const viewport = this._viewportElement?.getBoundingClientRect();\n            const shortEdge = viewport ? Math.min(viewport.width, viewport.height) : 600;\n            const blur = (this.strength / 100) * STRENGTH_MAX_BLUR * shortEdge;\n            const brightness = 1 - (this.strength / 100) * STRENGTH_MAX_DARKEN;\n            return 'filter:blur(' + blur + 'px) brightness(' + brightness + ')';\n        },\n\n        get sharpClipStyle() {\n            if (this.activeTool !== 'highlight' || !this.hasHighlightSelection || this.mode === 'place') return 'display:none';\n            if (this.highlightShape === 'polygon') {\n                return 'clip-path:polygon(' + this.polygonPoints.map((point) => (\n                    (point.x * 100) + '% ' + (point.y * 100) + '%'\n                )).join(',') + ')';\n            }\n            const top = this.highlightRect.y * 100;\n            const right = (1 - this.highlightRect.x - this.highlightRect.width) * 100;\n            const bottom = (1 - this.highlightRect.y - this.highlightRect.height) * 100;\n            const left = this.highlightRect.x * 100;\n            return 'clip-path:inset(' + top + '% ' + right + '% ' + bottom + '% ' + left + '% round ' + this.selectionRadiusPx + 'px)';\n        },\n\n        get selectionStyle() {\n            if (!this.rect) return 'display:none';\n            // The primary colour at 35%: the space the piece will take.\n            const fill = this.mode === 'place' && this.activeTool === 'highlight' ? ';background-color:rgba(31,59,97,0.35)' : '';\n            return 'left:' + (this.rect.x * 100) + '%;top:' + (this.rect.y * 100) + '%;width:' + (this.rect.width * 100) + '%;height:' + (this.rect.height * 100) + '%;border-radius:' + this.selectionRadiusPx + 'px' + fill;\n        },\n\n        get outputBorderStyle() {\n            return this.selectionStyle + ';border:' + this.outputBorderPx + 'px solid ' + this.borderColor;\n        },\n\n        get polygonSvgPoints() {\n            return this.polygonPoints.map((point) => (\n                (point.x * 100) + ',' + (point.y * 100)\n            )).join(' ');\n        },\n\n        get openPolygonSvgPoints() {\n            const points = [...this.polygonPoints];\n            if (!this.polygonClosed && this.polygonPointer && points.length) {\n                points.push(this.polygonPointer);\n            }\n            return points.map((point) => (\n                (point.x * 100) + ',' + (point.y * 100)\n            )).join(' ');\n        },\n\n        polygonHandleStyle(point) {\n            return 'left:' + (point.x * 100) + '%;top:' + (point.y * 100)\n                + '%;width:' + (44 / this.zoom) + 'px;height:' + (44 / this.zoom)\n                + 'px;transform:translate(-50%,-50%)';\n        },\n\n        get cropShadeStyle() {\n            return this.activeTool === 'crop' && this.cropRect\n                ? 'border:' + (1 / this.zoom) + 'px solid white;box-shadow:0 0 0 9999px rgba(0,0,0,0.62)'\n                : 'display:none';\n        },\n\n        get selectionRadiusPx() {\n            if (this.activeTool === 'crop' || !this.rect || !this._viewportElement) return 0;\n            this.viewportTick;\n            const viewport = this._viewportElement.getBoundingClientRect();\n            return (this.cornerRadius / 100) * Math.min(\n                this.rect.width * viewport.width,\n                this.rect.height * viewport.height\n            );\n        },\n\n        get outputBorderPx() {\n            if (!this._viewportElement) return 0;\n            this.viewportTick;\n            const viewport = this._viewportElement.getBoundingClientRect();\n            return (this.borderWidth / 1000) * Math.min(viewport.width, viewport.height);\n        },\n\n        get guideBorderPx() {\n            return 2 / this.zoom;\n        },\n\n        get handleStyle() {\n            return 'width:' + (36 / this.zoom) + 'px;height:' + (36 / this.zoom) + 'px';\n        },\n\n        // The \"Begradigen\" frame corners: a 44 px finger target (Apple's\n        // minimum) around the same 12 px square.\n        get frameHandleStyle() {\n            return 'width:' + (44 / this.zoom) + 'px;height:' + (44 / this.zoom) + 'px;-webkit-touch-callout:none';\n        },\n\n        get handleDotStyle() {\n            return 'width:' + (12 / this.zoom) + 'px;height:' + (12 / this.zoom) + 'px;border-width:' + (2 / this.zoom) + 'px';\n        },\n\n        get minimumSelectionSize() {\n            if (!this._viewportElement) return {x: 0.03, y: 0.03};\n            const viewport = this._viewportElement.getBoundingClientRect();\n            return {\n                x: Math.min(0.2, 32 / (viewport.width * this.zoom)),\n                y: Math.min(0.2, 32 / (viewport.height * this.zoom)),\n            };\n        },\n    }));\n});\n", "document.addEventListener('alpine:init', () => {\n    const I18N = window.I18N || {};\n\n    Alpine.data('batchOutdoorPresets', () => ({\n        outdoor: { optimize: true, sunshine: true, declutter: true },\n        init() {\n            const prefs = JSON.parse(this.$el.dataset.presetPrefs || '{}');\n            if (prefs.outdoor) {\n                this.outdoor.optimize = prefs.outdoor.includes('optimize');\n                this.outdoor.sunshine = prefs.outdoor.includes('sunshine');\n                this.outdoor.declutter = prefs.outdoor.includes('declutter');\n            }\n        },\n    }));\n\n    Alpine.data('batchIndoorPresets', () => ({\n        indoor: { optimize_indoor: true, declutter_indoor: true, details: true, staging: true },\n        replaceFurniture: false,\n        furnitureStyle: '',\n        furnitureInstructions: '',\n        styleOpen: false,\n        styleOptions: [\n            {v:'',l:I18N.styleUnspecified || 'Keine Vorgabe'}, {v:'modern',l:'Modern'},\n            {v:'skandinavisch',l:I18N.styleScandinavian || 'Skandinavisch'}, {v:'klassisch',l:I18N.styleClassic || 'Klassisch'},\n            {v:'landhausstil',l:I18N.styleCountry || 'Landhausstil'}, {v:'industriell',l:I18N.styleIndustrial || 'Industriell'},\n        ],\n        init() {\n            const prefs = JSON.parse(this.$el.dataset.presetPrefs || '{}');\n            if (prefs.indoor) {\n                this.indoor.optimize_indoor = prefs.indoor.includes('optimize_indoor');\n                this.indoor.declutter_indoor = prefs.indoor.includes('declutter_indoor');\n                this.indoor.details = prefs.indoor.includes('details');\n                this.indoor.staging = prefs.indoor.includes('staging');\n            }\n            if (typeof prefs.replace_furniture === 'boolean')\n                this.replaceFurniture = prefs.replace_furniture;\n            if (prefs.furniture_style)\n                this.furnitureStyle = prefs.furniture_style;\n        },\n    }));\n\n    // One \"Einheitlich m\u00F6blieren\" line in the batch modal: the photos of one\n    // room, staged as one set while ticked. A tap on a thumbnail takes that\n    // photo out of the room on the server too, so it is staged alone and the\n    // correction is recorded.\n    Alpine.data('roomSetLine', () => ({\n        checked: true,\n        photoIds: [],\n        removed: [],\n        countTemplate: '{n}',\n        removeUrlTemplate: '',\n\n        init() {\n            const data = this.$root.dataset;\n            this.photoIds = (data.photoIds || '').split(',').filter(Boolean);\n            this.countTemplate = data.countTemplate || '{n}';\n            this.removeUrlTemplate = data.removeUrlTemplate || '';\n        },\n\n        get activeIds() {\n            return this.photoIds.filter(id => !this.removed.includes(id));\n        },\n\n        get countText() {\n            return this.countTemplate.replace('{n}', this.activeIds.length);\n        },\n\n        remove(photoId) {\n            if (this.removed.includes(photoId)) return;\n            this.removed.push(photoId);\n            if (this.activeIds.length < 2) this.checked = false;\n            const url = this.removeUrlTemplate.replace('PHOTO_ID', photoId);\n            const meta = document.querySelector('meta[name=\"csrf-token\"]');\n            fetch(url, {\n                method: 'POST',\n                headers: { 'X-CSRFToken': meta ? meta.content : '', 'X-Requested-With': 'XMLHttpRequest' },\n            }).catch(err => console.error(err));\n        },\n    }));\n\n    Alpine.data('batchSelect', () => ({\n        selectedPhotos: {},\n        modalOpen: false,\n        loading: false,\n        modalUrl: '',\n        upscaleUrl: '',\n        downloadUrl: '',\n        deleteUrl: '',\n        csrf: '',\n\n        get count() { return Object.keys(this.selectedPhotos).length; },\n        get hasSelection() { return this.count > 0; },\n        get countLabel() {\n            return this.count === 1 ? (I18N.photoSelectedSingular || '1 Foto ausgew\u00E4hlt') : this.count + ' ' + (I18N.photosSelectedPlural || 'Fotos ausgew\u00E4hlt');\n        },\n\n        togglePhoto(id, checked) {\n            if (checked) this.selectedPhotos[id] = true;\n            else delete this.selectedPhotos[id];\n        },\n\n        isSelectableCheckbox(checkbox) {\n            return !checkbox.disabled && checkbox.offsetParent !== null;\n        },\n\n        // A group is a type section under \"Nach Bereich\" and a status group\n        // under \"Nach Status\". Only one arrangement renders at a time.\n        getGroupCheckboxes(groupKey) {\n            const selector = '.batch-select-checkbox[data-photo-group=\"' + groupKey + '\"]';\n            return Array.from(this.$root.querySelectorAll(selector))\n                .filter(cb => this.isSelectableCheckbox(cb));\n        },\n\n        isGroupFullySelected(groupKey) {\n            const checkboxes = this.getGroupCheckboxes(groupKey);\n            return checkboxes.length > 0 && checkboxes.every(cb => this.isSelected(cb.dataset.photoId));\n        },\n\n        isGroupPartiallySelected(groupKey) {\n            const checkboxes = this.getGroupCheckboxes(groupKey);\n            if (!checkboxes.length) return false;\n            const selectedCount = checkboxes.filter(cb => this.isSelected(cb.dataset.photoId)).length;\n            return selectedCount > 0 && selectedCount < checkboxes.length;\n        },\n\n        toggleGroup(groupKey, checked) {\n            this.getGroupCheckboxes(groupKey).forEach(cb => {\n                cb.checked = checked;\n                this.togglePhoto(cb.dataset.photoId, checked);\n            });\n        },\n\n        isSelected(id) { return !!this.selectedPhotos[id]; },\n\n        clearSelection() {\n            this.selectedPhotos = {};\n            this.$root.querySelectorAll('.batch-select-checkbox').forEach(cb => { cb.checked = false; });\n        },\n\n        // The container keeps the last modal after it closes. Empty it before the\n        // next one loads: else the old form shows at once and can be submitted,\n        // and the new form that replaces it can be submitted a second time.\n        clearModalContent() {\n            document.getElementById('batch-modal-content').replaceChildren();\n        },\n\n        openModal() {\n            if (!this.hasSelection || this.loading) return;\n            this.loading = true;\n            this.clearModalContent();\n            this.modalOpen = true;\n            const params = Object.keys(this.selectedPhotos).map(id => 'photos=' + encodeURIComponent(id)).join('&');\n            htmx.ajax('GET', this.modalUrl + '?' + params, { target: '#batch-modal-content', swap: 'innerHTML' })\n                .finally(() => { this.loading = false; });\n        },\n\n        openUpscaleModal() {\n            if (!this.hasSelection || this.loading) return;\n            this.loading = true;\n            this.clearModalContent();\n            this.modalOpen = true;\n            const params = Object.keys(this.selectedPhotos).map(id => 'photos=' + encodeURIComponent(id)).join('&');\n            htmx.ajax('GET', this.upscaleUrl + '?' + params, { target: '#batch-modal-content', swap: 'innerHTML' })\n                .finally(() => { this.loading = false; });\n        },\n\n        openDownloadModal() {\n            if (this.loading) return;\n            this.loading = true;\n            const params = Object.keys(this.selectedPhotos).map(id => 'photos=' + encodeURIComponent(id)).join('&');\n            const url = this.downloadUrl + (params ? '?' + params : '');\n            htmx.ajax('GET', url, { target: '#download-modal-container', swap: 'innerHTML' })\n                .finally(() => { this.loading = false; });\n        },\n\n        closeModal() { this.modalOpen = false; },\n        closeAndRefresh() { this.modalOpen = false; this.clearSelection(); htmx.trigger('#photo-grid', 'refresh'); },\n\n        openDeleteModal() {\n            const photoIds = Object.keys(this.selectedPhotos);\n            if (!photoIds.length) return;\n            Alpine.store('modal')?.show('batch-photo-delete', {\n                count: photoIds.length,\n                deleting: false,\n                onCancel: () => this.closeDeleteModal(),\n                onConfirm: () => this.submitDelete(photoIds),\n            });\n        },\n\n        closeDeleteModal() {\n            const modal = Alpine.store('modal');\n            if (modal?.context?.deleting) return;\n            modal?.close();\n        },\n\n        submitDelete(photoIds) {\n            const modal = Alpine.store('modal');\n            const context = modal?.context;\n            if (!photoIds?.length || context?.deleting) return;\n            context.deleting = true;\n            const url = this.deleteUrl;\n            const csrf = this.csrf;\n            const formData = new FormData();\n            photoIds.forEach(id => formData.append('photo_ids', id));\n            fetch(url, {\n                method: 'POST',\n                body: formData,\n                headers: { 'X-CSRFToken': csrf, 'X-Requested-With': 'XMLHttpRequest' },\n            })\n                .then(r => { if (!r.ok) throw new Error('Delete failed (' + r.status + ')'); })\n                .then(() => {\n                    Alpine.store('modal')?.close();\n                    this.clearSelection();\n                    htmx.trigger('#photo-grid', 'refresh');\n                })\n                .catch(err => {\n                    console.error(err);\n                    window.alert(I18N.deleteFailed || 'L\u00F6schen fehlgeschlagen. Bitte erneut versuchen.');\n                })\n                .finally(() => {\n                    if (modal?.context === context) context.deleting = false;\n                });\n        },\n\n        init() {\n            this.modalUrl = this.$root.dataset.modalUrl;\n            this.upscaleUrl = this.$root.dataset.upscaleUrl;\n            this.downloadUrl = this.$root.dataset.downloadUrl;\n            this.deleteUrl = this.$root.dataset.deleteUrl;\n            this.csrf = this.$root.dataset.csrf;\n\n            // Listen for batch clear events from HTMX-swapped partials\n            this._onBatchClear = () => this.clearSelection();\n            document.addEventListener('batch:clear', this._onBatchClear);\n\n            // Re-check boxes after HTMX swaps photo cards or re-renders the\n            // whole grid (arrangement switch, completion refresh). Selection\n            // lives on this component, which sits outside #photo-grid.\n            this.$root.addEventListener('htmx:afterSwap', () => {\n                this.$root.querySelectorAll('.batch-select-checkbox').forEach(cb => {\n                    cb.checked = this.isSelected(cb.dataset.photoId);\n                });\n                // Force Alpine to recompute section header tri-state bindings.\n                this.selectedPhotos = { ...this.selectedPhotos };\n            });\n        },\n\n        destroy() {\n            document.removeEventListener('batch:clear', this._onBatchClear);\n        },\n    }));\n\n});\n", "// The social media post panel in the property export modal\n// (dashboard/partials/social_post_panel.html, docs/code/social-posts.md).\n//\n// Every slide is fetched once, as a File, when the panel opens. A tap on\n// \"Teilen\" must call navigator.share inside the user gesture: iOS WebKit\n// rejects a share that follows an await. The tap also copies the post text\n// first, because Instagram ignores text from the share menu.\n\n// Three slides at a time, so one panel does not hold every server thread.\nconst PARALLEL_FETCHES = 3;\n// The cover is fetched again once the agent stops typing the label.\nconst LABEL_DELAY_MS = 600;\nconst MAX_LABEL_LENGTH = 30;\n\nfunction canShareFiles() {\n    if (!window.navigator.canShare || !window.File) return false;\n    try {\n        return window.navigator.canShare({ files: [new window.File([''], 'test.jpg', { type: 'image/jpeg' })] });\n    } catch (_) {\n        return false;\n    }\n}\n\nasync function fetchSlide(url, name) {\n    const response = await fetch(url, { credentials: 'same-origin' });\n    if (!response.ok) {\n        const error = new Error('Slide ' + name + ' failed (' + response.status + ')');\n        // 404: the photo file is gone. Anything else may work the next time.\n        error.status = response.status;\n        throw error;\n    }\n    const blob = await response.blob();\n    return new window.File([blob], name, { type: 'image/jpeg' });\n}\n\n// The generated price line out of an edited text, with its line break. A\n// price line alone in its block would leave two blank lines behind.\nfunction withoutLine(text, line) {\n    const lines = text.split('\\n');\n    const position = lines.indexOf(line);\n    if (!line || position === -1) return text;\n    lines.splice(position, 1);\n    if (lines[position - 1] === '' && lines[position] === '') lines.splice(position, 1);\n    return lines.join('\\n');\n}\n\n// The label as the server cleans it (social_posts.clean_label): one line, no\n// control or format characters, at most 30 code points. Cover and text then\n// agree, also for emoji and zero-width characters.\nfunction cleanLabel(value) {\n    const text = value.replace(/\\s+/g, ' ').replace(/\\p{C}/gu, '').trim();\n    return Array.from(text).slice(0, MAX_LABEL_LENGTH).join('').trim();\n}\n\n// Everything after the first line of a generated text.\nfunction afterFirstLine(text) {\n    const position = text.indexOf('\\n');\n    return position === -1 ? '' : text.slice(position);\n}\n\nfunction slideName(position) {\n    return String(position + 1).padStart(2, '0') + '.jpg';\n}\n\n// The price line back into an edited text, right after the generated facts\n// line. Without that line, the text stays as the agent left it.\nfunction withLineAfter(text, anchor, line) {\n    const lines = text.split('\\n');\n    const position = lines.indexOf(anchor);\n    if (!anchor || !line || position === -1 || lines.includes(line)) return text;\n    lines.splice(position + 1, 0, line);\n    return lines.join('\\n');\n}\n\ndocument.addEventListener('alpine:init', () => {\n    Alpine.data('socialPost', () => {\n        // Outside Alpine's reactive state: navigator.share needs the File\n        // objects themselves, not reactive proxies of them.\n        let files = [];\n        const objectUrls = new Set();\n        let destroyed = false;\n        let labelTimer = null;\n        // Only the newest cover request may change the cover.\n        let coverRequest = 0;\n        // The price and label choices the current cover file shows.\n        let rendered = {};\n\n        return {\n            slides: [],\n            index: 0,\n            text: '',\n            showPrice: false,\n            price: {},\n            downloadBase: '',\n            ready: false,\n            loaded: false,\n            hasCover: true,\n            label: '',\n            labelOn: true,\n            headline: '',\n            title: '',\n            cover: {},\n            loadFailed: false,\n            shareSupported: false,\n            copied: false,\n            // '' | 'copied' | 'failed': what the last share did with the text.\n            shareCopy: '',\n            shareFailed: false,\n            sharedUrl: '',\n\n            get firstLine() {\n                return this.text.split('\\n')[0];\n            },\n\n            get downloadUrl() {\n                const url = new URL(this.downloadBase, window.location.origin);\n                this.setChoices(url.searchParams);\n                return url.pathname + url.search;\n            },\n\n            // The price and label choices, as the slide and zip views read them.\n            setChoices(params) {\n                params.set('price', this.showPrice ? '1' : '0');\n                params.set('label_on', this.labelOn ? '1' : '0');\n                params.set('label', this.label);\n            },\n\n            coverUrl() {\n                const url = new URL(this.cover.path, window.location.origin);\n                url.searchParams.set('cover', '1');\n                this.setChoices(url.searchParams);\n                url.searchParams.set('v', this.cover.version);\n                return url.pathname + url.search;\n            },\n\n            // The first line the generator would write for the current label.\n            headlineFor() {\n                const label = this.labelOn ? cleanLabel(this.label) : '';\n                return label ? label + ': ' + this.title : this.title;\n            },\n\n            // The text the generator would write for the current label.\n            generated(withPrice) {\n                const caption = withPrice ? this.price.captionWith : this.price.captionWithout;\n                return this.headlineFor() + afterFirstLine(caption);\n            },\n\n            init() {\n                const data = this.$root.dataset;\n                this.slides = JSON.parse(data.slides || '[]').map(slide => ({ ...slide, src: '' }));\n                this.text = data.caption || '';\n                this.showPrice = data.showPrice === '1';\n                this.downloadBase = data.downloadUrl || '';\n                this.price = {\n                    captionWith: data.captionWithPrice || '',\n                    captionWithout: data.captionWithoutPrice || '',\n                    line: data.priceLine || '',\n                    factsLine: data.factsLine || '',\n                };\n                this.cover = { path: data.coverPath || '', version: data.coverVersion || '' };\n                this.label = data.label || '';\n                this.title = data.captionTitle || '';\n                this.headline = this.firstLine;\n                rendered = this.choices();\n                this.sharedUrl = data.sharedUrl || '';\n                this.shareSupported = canShareFiles();\n                // An edited text no longer matches the clipboard.\n                this.$watch('text', () => { this.shareCopy = ''; });\n                this.loadSlides();\n            },\n\n            destroy() {\n                destroyed = true;\n                objectUrls.forEach(url => URL.revokeObjectURL(url));\n            },\n\n            showSlide(position, file) {\n                if (destroyed) return;\n                const previous = this.slides[position].src;\n                const url = URL.createObjectURL(file);\n                objectUrls.add(url);\n                this.slides[position].src = url;\n                if (previous) {\n                    URL.revokeObjectURL(previous);\n                    objectUrls.delete(previous);\n                }\n            },\n\n            async loadSlides() {\n                const loaded = new Array(this.slides.length).fill(null);\n                let next = 0;\n                const worker = async () => {\n                    while (next < this.slides.length && !destroyed) {\n                        const position = next++;\n                        const slide = this.slides[position];\n                        try {\n                            loaded[position] = await fetchSlide(slide.url, slide.name);\n                            this.showSlide(position, loaded[position]);\n                        } catch (err) {\n                            // A missing photo file (404) or a failed render: the\n                            // post goes out without this slide.\n                            console.error(err);\n                        }\n                    }\n                };\n                const workers = [];\n                for (let count = 0; count < PARALLEL_FETCHES; count++) workers.push(worker());\n                await Promise.all(workers);\n                this.keepSlides(loaded);\n            },\n\n            // Keep the slides that have a file (null drops one) and number them\n            // again without gaps. Without the first slide the post has no cover,\n            // so the price switch has nothing to change any more.\n            keepSlides(loaded) {\n                if (destroyed) return;\n                const kept = [];\n                const keptFiles = [];\n                this.slides.forEach((slide, position) => {\n                    if (loaded[position]) {\n                        kept.push(slide);\n                        keptFiles.push(loaded[position]);\n                    } else if (slide.src) {\n                        URL.revokeObjectURL(slide.src);\n                        objectUrls.delete(slide.src);\n                    }\n                });\n                if (!loaded[0]) this.hasCover = false;\n                files = keptFiles.map((file, position) => new window.File(\n                    [file], slideName(position), { type: 'image/jpeg' },\n                ));\n                this.slides = kept.map((slide, position) => ({ ...slide, name: slideName(position) }));\n                this.index = 0;\n                this.ready = kept.length > 0;\n                this.loaded = true;\n                this.loadFailed = kept.length === 0;\n            },\n\n            choices() {\n                return { showPrice: this.showPrice, labelOn: this.labelOn, label: this.label };\n            },\n\n            // Fetch the cover for the current price and label. A newer request\n            // wins. A 404 means the photo file is gone: the post goes on without\n            // a cover. Any other failure keeps the old cover and takes the\n            // switches and their text change back, so text and cover agree.\n            async refreshCover() {\n                const request = ++coverRequest;\n                const choices = this.choices();\n                this.ready = false;\n                try {\n                    const file = await fetchSlide(this.coverUrl(), this.slides[0].name);\n                    if (request !== coverRequest || destroyed) return;\n                    files[0] = file;\n                    this.showSlide(0, file);\n                    rendered = choices;\n                    this.ready = true;\n                } catch (err) {\n                    if (request !== coverRequest || destroyed) return;\n                    console.error(err);\n                    if (err.status === 404) {\n                        this.keepSlides(files.map((file, position) => (position === 0 ? null : file)));\n                        return;\n                    }\n                    clearTimeout(labelTimer);\n                    this.labelOn = rendered.labelOn;\n                    this.label = rendered.label;\n                    this.applyLabelText();\n                    if (this.showPrice !== rendered.showPrice) this.applyPriceText(rendered.showPrice);\n                    this.ready = true;\n                }\n            },\n\n            // The first line of the text follows the label only while the agent\n            // has not changed that line.\n            applyLabelText() {\n                const headline = this.headlineFor();\n                const lines = this.text.split('\\n');\n                if (lines[0] === this.headline) {\n                    lines[0] = headline;\n                    this.text = lines.join('\\n');\n                }\n                this.headline = headline;\n            },\n\n            // An unedited text switches to the other generated text; an edited\n            // one only loses or gets back the generated price line.\n            applyPriceText(on) {\n                const price = this.price;\n                if (this.text === this.generated(!on)) {\n                    this.text = this.generated(on);\n                } else if (on) {\n                    this.text = withLineAfter(this.text, price.factsLine, price.line);\n                } else {\n                    this.text = withoutLine(this.text, price.line);\n                }\n                this.showPrice = on;\n            },\n\n            // The label is per post.\n            labelChanged() {\n                if (!this.hasCover) return;\n                clearTimeout(labelTimer);\n                this.applyLabelText();\n                this.refreshCover();\n            },\n\n            labelInput(value) {\n                this.label = value;\n                // The shared files would still show the old label until the\n                // new cover is in.\n                this.ready = false;\n                clearTimeout(labelTimer);\n                labelTimer = setTimeout(() => this.labelChanged(), LABEL_DELAY_MS);\n            },\n\n            // \"Preis zeigen\" without a reload, so the agent's text edits stay.\n            // Only the cover is fetched again.\n            togglePrice(on) {\n                if (on === this.showPrice || !this.ready || !this.hasCover) return;\n                this.applyPriceText(on);\n                this.refreshCover();\n            },\n\n            previous() {\n                this.index = (this.index + this.slides.length - 1) % this.slides.length;\n            },\n\n            next() {\n                this.index = (this.index + 1) % this.slides.length;\n            },\n\n            copyText() {\n                if (!window.navigator.clipboard) return Promise.reject(new Error('Clipboard unavailable'));\n                return window.navigator.clipboard.writeText(this.text).then(() => {\n                    this.copied = true;\n                    setTimeout(() => { this.copied = false; }, 1500);\n                });\n            },\n\n            copy() {\n                this.copyText().catch(err => {\n                    // No clipboard access: select the text, so a manual copy is one step.\n                    console.error(err);\n                    this.$root.querySelector('[data-social-text]')?.select();\n                });\n            },\n\n            share() {\n                if (!this.ready) return;\n                this.shareFailed = false;\n                this.shareCopy = '';\n                this.copyText()\n                    .then(() => { this.shareCopy = 'copied'; })\n                    .catch(err => {\n                        console.error(err);\n                        this.shareCopy = 'failed';\n                    });\n                window.navigator.share({ files })\n                    .then(() => this.recordShare())\n                    .catch(err => {\n                        // The user closed the share menu: nothing failed.\n                        if (err && err.name === 'AbortError') return;\n                        console.error(err);\n                        this.shareFailed = true;\n                    });\n            },\n\n            recordShare() {\n                const body = new FormData();\n                this.slides.forEach(slide => body.append('photo_ids', slide.photo_id));\n                const meta = document.querySelector('meta[name=\"csrf-token\"]');\n                fetch(this.sharedUrl, {\n                    method: 'POST',\n                    body: body,\n                    headers: { 'X-CSRFToken': meta ? meta.content : '' },\n                }).catch(err => console.error(err));\n            },\n        };\n    });\n});\n", "// The one browser-side check for photo uploads: JPG, PNG, WebP or HEIC, at\n// most 20 MB. The server converts HEIC (iPhone photos) to JPEG. Used by the upload modal, the onboarding and gallery uploads, and the\n// public upload forms. The server validates every file again.\n\nconst VALID_TYPES = ['image/jpeg', 'image/png', 'image/webp', 'image/heic', 'image/heif'];\nconst MAX_BYTES = 20 * 1024 * 1024;\n\n// 'type', 'size', or '' when the file can be uploaded.\nexport function uploadRejection(file) {\n    // Some drag sources and Windows apps report an empty MIME type; fall back\n    // to the file extension instead of dropping the file.\n    const typeOk = file.type\n        ? VALID_TYPES.includes(file.type)\n        : /\\.(jpe?g|png|webp|heic|heif)$/i.test(file.name || '');\n    if (!typeOk) return 'type';\n    if (file.size > MAX_BYTES) return 'size';\n    return '';\n}\n\n// HEIC/HEIF is the iPhone format. Desktop Chrome, Firefox and Edge cannot show\n// it in an <img>, so the previews show an image icon for these files instead of\n// a broken image. The server thumbnail (a JPEG) replaces the icon after upload.\nexport function isHeic(file) {\n    return /^image\\/hei[cf]/.test(file.type || '') || /\\.hei[cf]$/i.test(file.name || '');\n}\n\n// The app pages' message for a rejection (window.I18N comes from app_base.html).\nexport function rejectionMessage(reason) {\n    const I18N = window.I18N || {};\n    if (reason === 'size') return I18N.fileTooLarge || 'Datei zu gro\u00DF (max. 20 MB)';\n    return I18N.invalidImageType || 'Bitte w\u00E4hlen Sie ein JPG, PNG, WebP oder HEIC Bild.';\n}\n", "import { isHeic, rejectionMessage, uploadRejection } from './upload-validation.js';\n\n// The preview tile's image icon. It sits under the local preview and shows when\n// the browser cannot decode the file (HEIC on desktop Chrome, Firefox, Edge).\nconst PHOTO_ICON = '<svg class=\"w-5 h-5 text-muted-foreground\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1.5\" d=\"M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909M3.75 21h16.5\"/></svg>';\n\ndocument.addEventListener('alpine:init', () => {\n    const I18N = window.I18N || {};\n\n    Alpine.data('photoUpload', () => ({\n        isOpen: false,\n        dragging: false,\n        hasUploads: false,\n        pendingUploads: 0,\n        // Photos stored since the last batch event, so one batch = one event.\n        uploadedInBatch: 0,\n        // URL import state\n        activeTab: 'device',\n        importUrl: '',\n        scraping: false,\n        importing: false,\n        scrapedImages: [],\n        scrapedMetadata: {},\n\n        open(files) {\n            this.isOpen = true;\n            this.lockScroll();\n            // The empty-state card is a drop target: it dispatches the open\n            // event with the dropped files so the modal starts uploading\n            // instead of asking for them again.\n            if (files && files.length) this.handleFiles(files);\n        },\n\n        close() {\n            if (this.pendingUploads > 0 || this.importing) return;\n            this.isOpen = false;\n            this.unlockScroll();\n            this.resetUrlImport();\n            if (this.hasUploads) htmx.trigger('#photo-grid', 'refresh');\n        },\n\n        // GA4 funnel step. Fires when the last upload of a batch lands, so a\n        // 12-photo drop reports once with count 12, not twelve times.\n        trackBatchComplete() {\n            if (this.pendingUploads > 0 || this.uploadedInBatch === 0) return;\n            window.trackEvent('photo_upload_complete', {\n                property_id: this.$root.dataset.propertyId || '',\n                count: this.uploadedInBatch,\n            });\n            this.uploadedInBatch = 0;\n        },\n\n        lockScroll()   { window._scrollLock.lock(); },\n        unlockScroll() { window._scrollLock.unlock(); },\n\n        openFilePicker() { this.$refs.fileInput?.click(); },\n\n        onFileSelect(e) {\n            this.handleFiles(e.target.files);\n            e.target.value = '';\n        },\n\n        onDrop(e) {\n            this.dragging = false;\n            this.handleFiles(e.dataTransfer.files);\n        },\n\n        handleFiles(files) {\n            Array.from(files).forEach(file => {\n                const rejection = uploadRejection(file);\n                if (rejection) {\n                    this.showRejected(file, rejectionMessage(rejection));\n                    return;\n                }\n                this.uploadFile(file);\n            });\n        },\n\n        // Rejected before any request: the file never reaches the server, so\n        // the row is final and carries no retry button.\n        showRejected(file, msg) {\n            this.hasUploads = true;\n            const rowId = 'rejected-' + Date.now() + '-' + Math.random().toString(36).substr(2, 9);\n            const uploadRows = this.$refs.uploadRows;\n            if (uploadRows) uploadRows.insertAdjacentHTML('beforeend', this.errorRowHtml(rowId, file.name, msg));\n        },\n\n        errorRowHtml(rowId, name, msg, retryId) {\n            return '<div id=\"' + rowId + '\" class=\"flex items-center gap-4 p-3 bg-red-50 rounded-lg border border-red-200\">' +\n                '<div class=\"w-16 h-12 bg-red-100 rounded flex items-center justify-center flex-shrink-0\">' +\n                '<svg class=\"w-5 h-5 text-red-500\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">' +\n                '<path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M6 18L18 6M6 6l12 12\"/>' +\n                '</svg></div>' +\n                '<div class=\"flex-1 min-w-0\">' +\n                '<p class=\"font-medium text-red-800 truncate text-sm\">' + this.escapeHtml(name) + '</p>' +\n                '<p class=\"text-sm text-red-600\">' + this.escapeHtml(msg) + '</p>' +\n                '</div>' +\n                (retryId ? '<button id=\"' + retryId + '\" class=\"px-3 py-1 text-xs font-medium text-red-700 bg-red-100 hover:bg-red-200 rounded transition-colors cursor-pointer flex-shrink-0\">' + (I18N.retry || 'Nochmal') + '</button>' : '') +\n                '</div>';\n        },\n\n        uploadFile(file) {\n            this.hasUploads = true;\n            this.pendingUploads++;\n\n            const tempId = 'temp-' + Date.now() + '-' + Math.random().toString(36).substr(2, 9);\n            // No local preview for HEIC: the icon shows until the server row\n            // with its JPEG thumbnail replaces this one.\n            const previewUrl = isHeic(file) ? '' : URL.createObjectURL(file);\n            const uploadUrl = this.$root.dataset.uploadUrl;\n            const csrfToken = document.querySelector('meta[name=\"csrf-token\"]').content;\n            // Capture the ref now: `this.$refs` throws (_x_refs) once an hx-boost\n            // navigation tears the component down mid-upload.\n            const uploadRows = this.$refs.uploadRows;\n\n            const placeholderHtml = '<div id=\"' + tempId + '\" class=\"flex items-center gap-4 p-3 bg-soft rounded-lg border border-border\">' +\n                '<div data-testid=\"upload-preview\" class=\"relative w-16 h-12 bg-muted rounded overflow-hidden flex-shrink-0 flex items-center justify-center\">' +\n                PHOTO_ICON +\n                (previewUrl ? '<img src=\"' + previewUrl + '\" alt=\"\" class=\"absolute inset-0 w-full h-full object-cover\" onerror=\"this.remove()\">' : '') +\n                '</div>' +\n                '<div class=\"flex-1 min-w-0\">' +\n                '<p class=\"font-medium text-foreground truncate text-sm\">' + this.escapeHtml(file.name) + '</p>' +\n                '<div class=\"flex items-center gap-1.5 text-sm text-muted-foreground mt-0.5\">' +\n                '<svg class=\"w-4 h-4 animate-spin\" fill=\"none\" viewBox=\"0 0 24 24\">' +\n                '<circle class=\"opacity-25\" cx=\"12\" cy=\"12\" r=\"10\" stroke=\"currentColor\" stroke-width=\"4\"></circle>' +\n                '<path class=\"opacity-75\" fill=\"currentColor\" d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z\"></path>' +\n                '</svg>' +\n                '<span>' + (I18N.uploading || 'Wird hochgeladen...') + '</span>' +\n                '</div></div></div>';\n            if (uploadRows) uploadRows.insertAdjacentHTML('beforeend', placeholderHtml);\n\n            const doUpload = () => {\n                const formData = new FormData();\n                formData.append('photo', file);\n                return fetch(uploadUrl, {\n                    method: 'POST',\n                    headers: { 'X-CSRFToken': csrfToken },\n                    body: formData\n                }).then(response => {\n                    if (!response.ok) return response.json().then(data => { throw new Error(data.error || I18N.uploadFailed || 'Upload fehlgeschlagen'); });\n                    return response.json();\n                });\n            };\n\n            const showError = (msg) => {\n                const placeholder = document.getElementById(tempId);\n                if (placeholder) {\n                    const retryId = tempId + '-retry';\n                    placeholder.outerHTML = this.errorRowHtml(tempId, file.name, msg, retryId);\n                    const retryBtn = document.getElementById(retryId);\n                    if (retryBtn) retryBtn.addEventListener('click', () => {\n                        const row = document.getElementById(tempId);\n                        if (row) row.outerHTML = placeholderHtml;\n                        this.pendingUploads++;\n                        doUpload().then(onSuccess).catch(e => showError(friendlyMsg(e))).finally(onDone);\n                    });\n                }\n            };\n\n            const friendlyMsg = (error) => {\n                if (error instanceof TypeError) return I18N.uploadFailedRetry || 'Upload fehlgeschlagen \u2014 bitte erneut versuchen';\n                return error.message || I18N.uploadFailed || 'Upload fehlgeschlagen';\n            };\n\n            const onSuccess = (data) => {\n                this.uploadedInBatch++;\n                const placeholder = document.getElementById(tempId);\n                if (placeholder && data.row_html) {\n                    placeholder.outerHTML = data.row_html;\n                    if (uploadRows) htmx.process(uploadRows);\n                }\n            };\n\n            const onDone = () => {\n                if (previewUrl) URL.revokeObjectURL(previewUrl);\n                this.pendingUploads--;\n                this.trackBatchComplete();\n            };\n\n            doUpload()\n            .then(onSuccess)\n            .catch(error => {\n                // Auto-retry once for transient errors (e.g. iOS Safari after photo picker)\n                if (error instanceof TypeError) {\n                    return new Promise(r => setTimeout(r, 500))\n                        .then(doUpload)\n                        .then(onSuccess)\n                        .catch(e => showError(friendlyMsg(e)));\n                }\n                showError(friendlyMsg(error));\n            })\n            .finally(onDone);\n        },\n\n        // --- URL Import ---\n\n        async startScrape() {\n            const url = this.importUrl.trim();\n            if (!url) return;\n\n            this.scraping = true;\n            this.scrapedImages = [];\n            // Capture the ref now, before any await \u2014 `this.$refs` throws (_x_refs)\n            // if an hx-boost navigation tears the component down mid-scrape.\n            const scrapeResults = this.$refs.scrapeResults;\n            if (scrapeResults) scrapeResults.innerHTML = '';\n\n            const scrapeUrl = this.$root.dataset.scrapeUrl;\n            const csrfToken = document.querySelector('meta[name=\"csrf-token\"]').content;\n\n            try {\n                const formData = new FormData();\n                formData.append('url', url);\n\n                const res = await fetch(scrapeUrl, {\n                    method: 'POST',\n                    headers: { 'X-CSRFToken': csrfToken },\n                    body: formData,\n                });\n\n                const html = await res.text();\n                if (scrapeResults) {\n                    scrapeResults.innerHTML = html;\n\n                    // Read image URLs and metadata from embedded JSON\n                    const dataEl = scrapeResults.querySelector('#scraped-image-data');\n                    if (dataEl) {\n                        try { this.scrapedImages = JSON.parse(dataEl.textContent); } catch(e) {}\n                    }\n                    const metaEl = scrapeResults.querySelector('#scraped-metadata');\n                    if (metaEl) {\n                        try { this.scrapedMetadata = JSON.parse(metaEl.textContent); } catch(e) {}\n                    }\n                }\n            } catch (e) {\n                if (scrapeResults) scrapeResults.innerHTML = '<p class=\"text-sm text-alert-error-foreground text-center py-4\">' + (I18N.connectionErrorRetry || 'Verbindungsfehler. Bitte erneut versuchen.') + '</p>';\n            } finally {\n                this.scraping = false;\n            }\n        },\n\n        resetUrlImport() {\n            this.scrapedImages = [];\n            this.scrapedMetadata = {};\n            this.importUrl = '';\n            this.scraping = false;\n            this.importing = false;\n            if (this.$refs.scrapeResults) this.$refs.scrapeResults.innerHTML = '';\n        },\n\n        async importSelectedUrls(selectedIndexes) {\n            if (this.importing) return;\n            const urls = selectedIndexes.map(i => this.scrapedImages[i]).filter(Boolean);\n            if (!urls.length) return;\n\n            this.importing = true;\n            this.hasUploads = true;\n            this.activeTab = 'device'; // Switch to show upload rows\n            // Capture refs now, before any await \u2014 `this.$refs` throws (_x_refs)\n            // if an hx-boost navigation tears the component down mid-import.\n            const scrapeResults = this.$refs.scrapeResults;\n            const uploadRows = this.$refs.uploadRows;\n            if (scrapeResults) scrapeResults.innerHTML = '';\n            this.scrapedImages = [];\n\n            const importUrl = this.$root.dataset.importUrl;\n            const csrfToken = document.querySelector('meta[name=\"csrf-token\"]').content;\n            let importedCount = 0;\n\n            // Show pending placeholders\n            const tempIds = urls.map((_, i) => {\n                const tempId = 'import-' + Date.now() + '-' + i;\n                const html = '<div id=\"' + tempId + '\" class=\"flex items-center gap-4 p-3 bg-soft rounded-lg border border-border\">' +\n                    '<div class=\"w-16 h-12 bg-muted rounded flex items-center justify-center flex-shrink-0\">' +\n                    '<svg class=\"w-5 h-5 text-muted-foreground\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1.5\" d=\"M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909M3.75 21h16.5\"/></svg>' +\n                    '</div>' +\n                    '<div class=\"flex-1 min-w-0\">' +\n                    '<p class=\"font-medium text-foreground text-sm\">' + (I18N.photoOfCount || 'Foto {n} von {total}').replace('{n}', i + 1).replace('{total}', urls.length) + '</p>' +\n                    '<div class=\"flex items-center gap-1.5 text-sm text-muted-foreground mt-0.5\">' +\n                    '<svg class=\"w-4 h-4 animate-spin\" fill=\"none\" viewBox=\"0 0 24 24\">' +\n                    '<circle class=\"opacity-25\" cx=\"12\" cy=\"12\" r=\"10\" stroke=\"currentColor\" stroke-width=\"4\"></circle>' +\n                    '<path class=\"opacity-75\" fill=\"currentColor\" d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z\"></path>' +\n                    '</svg><span>' + (I18N.importing || 'Wird importiert...') + '</span></div></div></div>';\n                if (uploadRows) uploadRows.insertAdjacentHTML('beforeend', html);\n                return tempId;\n            });\n\n            this.pendingUploads += urls.length;\n\n            try {\n                const res = await fetch(importUrl, {\n                    method: 'POST',\n                    headers: {\n                        'X-CSRFToken': csrfToken,\n                        'Content-Type': 'application/json',\n                    },\n                    body: JSON.stringify({ urls, metadata: this.scrapedMetadata }),\n                });\n\n                const data = await res.json();\n\n                // Replace placeholders with actual upload rows\n                (data.results || []).forEach((result, i) => {\n                    const placeholder = document.getElementById(tempIds[i]);\n                    if (placeholder && result.row_html) {\n                        placeholder.outerHTML = result.row_html;\n                    }\n                });\n\n                // Mark remaining placeholders as failed\n                const successCount = (data.results || []).length;\n                importedCount = successCount;\n                for (let i = successCount; i < tempIds.length; i++) {\n                    const placeholder = document.getElementById(tempIds[i]);\n                    if (placeholder) {\n                        placeholder.outerHTML = '<div class=\"flex items-center gap-4 p-3 bg-alert-error rounded-lg border border-alert-error-border\">' +\n                            '<div class=\"w-16 h-12 bg-alert-error rounded flex items-center justify-center flex-shrink-0\">' +\n                            '<svg class=\"w-5 h-5 text-alert-error-foreground\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">' +\n                            '<path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M6 18L18 6M6 6l12 12\"/></svg></div>' +\n                            '<div class=\"flex-1 min-w-0\"><p class=\"font-medium text-alert-error-foreground text-sm\">' + (I18N.importFailed || 'Import fehlgeschlagen') + '</p></div></div>';\n                    }\n                }\n\n                if (uploadRows) htmx.process(uploadRows);\n            } catch (e) {\n                // Network error \u2014 mark all as failed\n                tempIds.forEach(id => {\n                    const el = document.getElementById(id);\n                    if (el) el.querySelector('span').textContent = I18N.importFailed || 'Import fehlgeschlagen';\n                });\n            } finally {\n                this.pendingUploads -= urls.length;\n                this.importing = false;\n                this.uploadedInBatch += importedCount;\n                this.trackBatchComplete();\n            }\n        },\n\n        escapeHtml(text) {\n            const div = document.createElement('div');\n            div.textContent = text;\n            return div.innerHTML;\n        },\n    }));\n\n});\n", "document.addEventListener('alpine:init', () => {\n    Alpine.data('brandingLogoUpload', () => ({\n        dragging: false,\n        previewUrl: '',\n        fileName: '',\n        fileSize: '',\n        error: '',\n        helpOpen: false,\n\n        get hasSelection() {\n            return Boolean(this.previewUrl);\n        },\n\n        init() {\n            this.$watch('$store.modal.open', (openModal) => {\n                if (openModal === 'logo-upload') {\n                    this.$nextTick(() => this.$refs.dropzone?.focus());\n                } else {\n                    this.reset();\n                }\n            });\n        },\n\n        openFilePicker() {\n            this.$refs.fileInput?.click();\n        },\n\n        handleFileSelect(event) {\n            const file = event.target.files?.[0];\n            if (file) this.selectFile(file);\n        },\n\n        handleDrop(event) {\n            this.dragging = false;\n            const file = event.dataTransfer?.files?.[0];\n            if (!file) return;\n\n            this.$refs.fileInput.files = event.dataTransfer.files;\n            this.selectFile(file);\n        },\n\n        selectFile(file) {\n            const validExtension = /\\.(jpe?g|png|webp)$/i.test(file.name);\n            const validType = !file.type || [\n                'image/jpeg',\n                'image/png',\n                'image/webp',\n            ].includes(file.type);\n\n            if (!validExtension || !validType) {\n                this.clearSelection();\n                this.error = this.$root.dataset.invalidFormat;\n                return;\n            }\n            if (file.size > 5 * 1024 * 1024) {\n                this.clearSelection();\n                this.error = this.$root.dataset.fileTooLarge;\n                return;\n            }\n\n            if (this.previewUrl) URL.revokeObjectURL(this.previewUrl);\n            this.previewUrl = URL.createObjectURL(file);\n            this.fileName = file.name;\n            this.fileSize = file.size < 1024 * 1024\n                ? `${Math.max(1, Math.round(file.size / 1024))} KB`\n                : `${(file.size / (1024 * 1024)).toFixed(1)} MB`;\n            this.error = '';\n        },\n\n        clearSelection() {\n            if (this.previewUrl) URL.revokeObjectURL(this.previewUrl);\n            this.previewUrl = '';\n            this.fileName = '';\n            this.fileSize = '';\n            if (this.$refs.fileInput) this.$refs.fileInput.value = '';\n        },\n\n        reset() {\n            this.clearSelection();\n            this.dragging = false;\n            this.error = '';\n            this.helpOpen = false;\n        },\n\n        close() {\n            this.reset();\n            Alpine.store('modal')?.close();\n        },\n    }));\n});\n", "// Estimated progress for waits we cannot measure (scraping a listing page).\n// The bar runs fast at first and slows down near the end, reaching about 85%\n// at `expectedMs` and never passing 95% until the caller calls done().\n// Better than a spinner: the customer sees that the wait is finite.\n\nexport function estimateProgress(set, expectedMs) {\n    const started = Date.now();\n    const tau = expectedMs / 1.9; // 1 - e^-1.9 \u2248 0.85\n    set(3);\n    const timer = setInterval(() => {\n        const t = Date.now() - started;\n        set(Math.min(95, Math.round(95 * (1 - Math.exp(-t / tau)))));\n    }, 200);\n    return function done() {\n        clearInterval(timer);\n        set(100);\n    };\n}\n", "// Onboarding: listing link or photo upload, then the gallery page.\n// See docs/product/listing-gallery.md.\nimport { estimateProgress } from './estimated-progress.js';\nimport { rejectionMessage, uploadRejection } from './upload-validation.js';\n\n// Loading a listing: Firecrawl waits 5 s for the page to render, then we\n// download the title photo. Measured 2 to 11 s on staging (2026-09-24).\nconst LISTING_LOAD_MS = 12000;\n\nconst PARALLEL_UPLOADS = 3;\n\nfunction csrfToken() {\n    return document.querySelector('meta[name=\"csrf-token\"]').content;\n}\n\nasync function postForm(url, formData) {\n    const response = await fetch(url, {\n        method: 'POST',\n        headers: { 'X-CSRFToken': csrfToken() },\n        body: formData,\n    });\n    let data = {};\n    try { data = await response.json(); } catch (e) { data = {}; }\n    return { ok: response.ok && data.success, data, status: response.status };\n}\n\n// Server failure code for analytics: the view's `reason`, else the HTTP status\n// (a proxy timeout or a crash answers without JSON).\nfunction failureReason(data, status) {\n    return data.reason || `http_${status}`;\n}\n\nfunction hostOf(url) {\n    try { return new URL(url).hostname; } catch (e) { return ''; }\n}\n\n// Uploads files into the onboarding gallery. The first file creates the\n// gallery property unless `propertyId` is given; the rest follow in parallel.\nasync function uploadToGallery(uploadUrl, files, propertyId, onProgress) {\n    const I18N = window.I18N || {};\n    let done = 0;\n    let galleryUrl = '';\n    let lastError = '';\n    const send = async (file) => {\n        const formData = new FormData();\n        formData.append('photo', file);\n        if (propertyId) formData.append('property', propertyId);\n        let response;\n        try {\n            response = await postForm(uploadUrl, formData);\n        } catch (e) {\n            // A network error must not leave the upload hanging.\n            window.trackEvent?.('onboarding_error', { step: 'upload', reason: 'network' });\n            response = { ok: false, data: { error: I18N.connectionErrorTryAgain || 'Verbindungsfehler. Bitte versuchen Sie es erneut.' } };\n        }\n        const { ok, data } = response;\n        done += 1;\n        onProgress(done);\n        if (!ok) {\n            lastError = data.error || I18N.uploadFailed || 'Upload fehlgeschlagen';\n            return data;\n        }\n        propertyId = data.property_id;\n        galleryUrl = data.gallery_url;\n        return data;\n    };\n\n    const queue = [...files];\n    if (!propertyId && queue.length) {\n        const first = await send(queue.shift());\n        if (first.limit_reached || !propertyId) {\n            return { galleryUrl: '', error: lastError, limitReached: !!first.limit_reached };\n        }\n    }\n    const worker = async () => {\n        while (queue.length) await send(queue.shift());\n    };\n    await Promise.all(Array.from({ length: PARALLEL_UPLOADS }, worker));\n    return { galleryUrl, error: galleryUrl ? '' : lastError, limitReached: false };\n}\n\n// The files to upload, and the message for the first file left out ('' when\n// every file passed).\nfunction checkFiles(fileList) {\n    const files = [];\n    let error = '';\n    for (const file of fileList) {\n        const reason = uploadRejection(file);\n        if (!reason) files.push(file);\n        else if (!error) error = rejectionMessage(reason);\n    }\n    return { files, error };\n}\n\ndocument.addEventListener('alpine:init', () => {\n    const I18N = window.I18N || {};\n\n    // The onboarding page (/app/start/). \"Sp\u00E4ter\" is a plain form post.\n    Alpine.data('onboarding', () => ({\n        step: 'welcome', // welcome | start | uploading | scraping | select | error\n        progress: 0,\n        dragging: false,\n        error: '',\n        limitReached: false,\n        importUrl: '',\n        total: 0,\n        done: 0,\n        candidates: [],\n        selected: [],\n        small: [],       // candidates under the import's 400 x 300 minimum\n        touched: false,  // the customer changed the preselection\n        maxPicks: 9,     // plus the title photo = the 10 gallery slots\n        firstUrl: '',\n        confirmUrl: '',\n        galleryUrl: '',\n\n        begin() {\n            this.track('begin');\n            this.step = 'start';\n            window.scrollTo({ top: 0 });\n        },\n\n        track(path) {\n            if (window.trackEvent) window.trackEvent('onboarding_path', { path });\n        },\n\n        openFilePicker() { this.$refs.fileInput?.click(); },\n\n        onFileSelect(e) { this.handleFiles(e.target.files); },\n\n        onDrop(e) {\n            this.dragging = false;\n            this.handleFiles(e.dataTransfer.files);\n        },\n\n        async handleFiles(fileList) {\n            const { files, error } = checkFiles(fileList);\n            if (!files.length) {\n                this.error = error || rejectionMessage('type');\n                return;\n            }\n            this.error = '';\n            this.track('upload');\n            this.total = files.length;\n            this.done = 0;\n            this.step = 'uploading';\n            const result = await uploadToGallery(\n                this.$root.dataset.uploadUrl, files, '', (n) => { this.done = n; });\n            if (result.galleryUrl) {\n                window.trackEvent?.('photo_upload_complete', { count: this.done });\n                window.location.href = result.galleryUrl;\n                return;\n            }\n            this.showError(result.error, result.limitReached);\n        },\n\n        async startUrlImport() {\n            const url = this.importUrl.trim();\n            if (!url) return;\n            this.error = '';\n            this.step = 'scraping';\n            this.track('url');\n            const formData = new FormData();\n            formData.append('url', url);\n            const done = estimateProgress((v) => { this.progress = v; }, LISTING_LOAD_MS);\n            const host = hostOf(url);\n            let response;\n            try {\n                response = await postForm(this.$root.dataset.urlImportUrl, formData);\n            } catch (e) {\n                done();\n                window.trackEvent?.('listing_import_result', { result: 'error', reason: 'network', host });\n                this.step = 'start';\n                this.error = I18N.connectionErrorTryAgain || 'Verbindungsfehler. Bitte versuchen Sie es erneut.';\n                return;\n            }\n            done();\n            const { ok, data, status } = response;\n            if (!ok) {\n                window.trackEvent?.('listing_import_result', {\n                    result: 'error', reason: failureReason(data, status), host,\n                });\n                if (data.limit_reached) {\n                    this.showError(data.error, true);\n                } else {\n                    this.step = 'start';\n                    this.error = data.error || I18N.importFailed || 'Import fehlgeschlagen';\n                }\n                return;\n            }\n            window.trackEvent?.('listing_import_result', { result: 'ok', host });\n            window.trackEvent?.('photo_upload_complete', { property_id: data.property_id, count: 1 });\n            this.galleryUrl = data.gallery_url;\n            this.confirmUrl = data.confirm_url;\n            this.firstUrl = data.first_url;\n            this.candidates = data.candidates;\n            this.maxPicks = data.max_picks;\n            this.small = [];\n            this.touched = false;\n            if (!this.candidates.length) {\n                this.confirmSelection();\n                return;\n            }\n            this.step = 'select';\n        },\n\n        // Opt-in: the first usable photos are preselected until the customer\n        // changes the selection. Images the import would drop as too small\n        // never show, so no pick can silently vanish.\n        get visible() { return this.candidates.filter((u) => !this.small.includes(u)); },\n        get chosen() { return this.touched ? this.selected : this.visible.slice(0, this.maxPicks); },\n\n        isSelected(url) { return this.chosen.includes(url); },\n\n        toggle(url) {\n            if (!this.touched) {\n                this.selected = [...this.chosen];\n                this.touched = true;\n            }\n            if (this.selected.includes(url)) {\n                this.selected = this.selected.filter((u) => u !== url);\n            } else if (this.selected.length < this.maxPicks) {\n                this.selected = [...this.selected, url];\n            }\n        },\n\n        onCandidateLoad(event, url) {\n            const img = event.target;\n            if (img.naturalWidth < 400 || img.naturalHeight < 300) this.dropCandidate(url);\n        },\n\n        dropCandidate(url) {\n            if (!this.small.includes(url)) this.small = [...this.small, url];\n            this.selected = this.selected.filter((u) => u !== url);\n        },\n\n        async confirmSelection() {\n            const formData = new FormData();\n            this.chosen.forEach((u) => formData.append('selected', u));\n            this.step = 'scraping';\n            estimateProgress((v) => { this.progress = v; }, 2000);\n            // The gallery opens either way (it shows the title photo); a failed\n            // confirm only loses the picks, so report it instead of swallowing it.\n            try {\n                const { ok, data, status } = await postForm(this.confirmUrl, formData);\n                if (!ok) {\n                    window.trackEvent?.('onboarding_error', { step: 'confirm', reason: failureReason(data, status) });\n                }\n            } catch (e) {\n                window.trackEvent?.('onboarding_error', { step: 'confirm', reason: 'network' });\n            } finally {\n                window.location.href = this.galleryUrl;\n            }\n        },\n\n        showError(message, limitReached) {\n            this.step = 'error';\n            this.limitReached = !!limitReached;\n            this.error = message || I18N.uploadFailed || 'Upload fehlgeschlagen';\n        },\n\n        reset() { window.location.reload(); },\n    }));\n\n    // The gallery page. A photo click swaps the before/after comparison in\n    // place; the choice survives the 3 s refresh of #gallery-body, which\n    // re-renders the comparison on the first finished photo.\n    Alpine.data('galleryPage', () => ({\n        busy: false,\n        error: '',\n        progressText: '',\n        selectedId: '',\n        lightboxOpen: false,\n        lightboxBefore: '',\n        lightboxAfter: '',\n\n        init() {\n            this._onSettle = () => this.show(this.selectedId);\n            window.addEventListener('htmx:afterSettle', this._onSettle);\n        },\n\n        destroy() {\n            window.removeEventListener('htmx:afterSettle', this._onSettle);\n        },\n\n        // The comparison large, like \"Vergleichen\" on the photo page. Only\n        // once the after image exists.\n        openLightbox() {\n            const after = document.getElementById('compare-after');\n            if (!after || after.classList.contains('hidden')) return;\n            this.lightboxBefore = document.getElementById('compare-before').src;\n            this.lightboxAfter = after.src;\n            this.lightboxOpen = true;\n            window._scrollLock.lock();\n        },\n\n        closeLightbox() {\n            this.lightboxOpen = false;\n            window._scrollLock.unlock();\n        },\n\n        // The normal export dialog, with the account's watermark choices.\n        downloadShown() {\n            const url = document.getElementById('compare-download')?.dataset.url;\n            if (url) htmx.ajax('GET', url, { target: '#download-modal-container', swap: 'innerHTML' });\n        },\n\n        // Start the unlock from the comparison: submit the guide's unlock form\n        // (pack checkout or own credits), else take the customer to it.\n        unlockNow() {\n            const form = document.getElementById('gallery-unlock-form');\n            if (form) {\n                form.requestSubmit();\n                return;\n            }\n            document.querySelector('[data-testid=\"gallery-unlock\"]')?.scrollIntoView({ behavior: 'smooth', block: 'center' });\n        },\n\n        choose(id) {\n            this.selectedId = id;\n            this.show(id);\n            document.getElementById('gallery-compare-anchor')?.scrollIntoView({ behavior: 'smooth', block: 'start' });\n        },\n\n        show(id) {\n            if (!id) return;\n            const card = document.querySelector(`[data-gallery-card][data-photo-id=\"${id}\"]`);\n            const before = document.getElementById('compare-before');\n            if (!card || !before) return;\n            const d = card.dataset;\n            before.src = d.before;\n            const after = document.getElementById('compare-after');\n            if (d.after) after.src = d.after;\n            after.classList.toggle('hidden', !d.after);\n            document.getElementById('compare-pending').classList.toggle('hidden', !!d.after);\n            document.getElementById('compare-preview').classList.toggle('hidden', d.state !== 'locked');\n            document.getElementById('compare-label').textContent = d.label;\n            const download = document.getElementById('compare-download');\n            download.dataset.url = d.downloadUrl || '';\n            document.getElementById('compare-cta-done').classList.toggle('hidden', d.state !== 'done');\n            document.getElementById('compare-cta-locked').classList.toggle('hidden', d.state !== 'locked');\n            document.getElementById('compare-approximate').classList.toggle('hidden', !d.approximate);\n            // A floor plan is shown whole; photos fill the frame.\n            [before, after].forEach((img) => {\n                img.classList.toggle('object-contain', !!d.floorplan);\n                img.classList.toggle('object-cover', !d.floorplan);\n            });\n            document.querySelectorAll('[data-gallery-card] [data-card-frame]').forEach((frame) => {\n                const selected = frame.closest('[data-gallery-card]') === card;\n                frame.classList.toggle('border-primary', selected);\n                frame.classList.toggle('border-transparent', !selected);\n            });\n        },\n\n        async upload(fileList) {\n            const { files, error: rejected } = checkFiles(fileList);\n            if (!files.length) {\n                this.error = rejected;\n                return;\n            }\n            this.busy = true;\n            this.error = '';\n            const total = files.length;\n            const label = I18N.uploadingOf || 'Wird hochgeladen';\n            this.progressText = `${label} 0 / ${total}`;\n            const result = await uploadToGallery(\n                this.$root.dataset.uploadUrl, files, this.$root.dataset.propertyId,\n                (n) => { this.progressText = `${label} ${n} / ${total}`; });\n            this.busy = false;\n            this.error = result.error || rejected;\n            htmx.ajax('GET', this.$root.dataset.gridUrl, { target: '#gallery-body', swap: 'outerHTML' });\n        },\n    }));\n});\n", "// In-app guides: carry out the server's auto-open decision and record state.\n//\n// The server decides which guide opens (dashboard/guides.py) and renders its\n// key into data-guide-key. This component only executes that decision, which\n// is what makes hx-boost navigation work for free: the swapped body carries a\n// fresh x-data root, Alpine initialises it, and init() opens the guide for the\n// page that was just navigated to \u2014 exactly as on a full load.\n//\n// State POSTs are fire-and-forget. Guide bookkeeping must never be the reason\n// a modal fails to open or close.\ndocument.addEventListener('alpine:init', () => {\n    const modalStore = () => window.Alpine && window.Alpine.store('modal');\n\n    function csrfToken() {\n        const meta = document.querySelector('meta[name=\"csrf-token\"]');\n        return meta ? meta.content : '';\n    }\n\n    function post(url, params) {\n        if (!url) return;\n        const body = new FormData();\n        Object.keys(params || {}).forEach(key => body.append(key, params[key]));\n        fetch(url, {\n            method: 'POST',\n            headers: { 'X-CSRFToken': csrfToken() },\n            body: body,\n            // A url-kind CTA navigates away in the same tick; keepalive stops\n            // the browser cancelling the dismissal on the way out.\n            keepalive: true,\n        }).catch(() => {});\n    }\n\n    function track(name, params) {\n        if (window.trackEvent) window.trackEvent(name, params);\n    }\n\n    // Called from the header help menu and the mobile menu, which are plain\n    // inline x-data dropdowns with no component of their own.\n    window.immopixGuides = {\n        open(key, seenUrl) {\n            const store = modalStore();\n            if (store) store.show('guide-' + key);\n            track('guide_shown', { guide: key, auto: false });\n            post(seenUrl, { reopen: '1' });\n        },\n    };\n\n    Alpine.data('guideAutoOpen', () => ({\n        init() {\n            const key = this.$el.dataset.guideKey;\n            if (!key) return;\n\n            const forced = this.$el.dataset.forced === '1';\n            const seenUrl = this.$el.dataset.seenUrl;\n\n            // $nextTick: the modal body is teleported into <body> by Alpine,\n            // and on a full load that clone may not be mounted yet when this\n            // root initialises. Showing after the tick keeps the first paint\n            // of the modal correct instead of relying on the store's\n            // reactivity to catch up.\n            this.$nextTick(() => {\n                const store = modalStore();\n                // A forced open (?guide=<key>) is a review aid, so it must not\n                // change what this user sees on their next visit. The flag\n                // rides along in the store context, which guideModal reads\n                // when it sees itself open.\n                if (store) store.show('guide-' + key, forced ? { forced: true } : {});\n                track('guide_shown', { guide: key, auto: true });\n                if (!forced) post(seenUrl, {});\n            });\n        },\n    }));\n\n    Alpine.data('guideModal', () => ({\n        // Guards one dismissal record per open. Reset every time this guide\n        // opens, set by whichever close path gets there first.\n        recorded: false,\n        forcedOpen: false,\n\n        init() {\n            // $el is the component root here; capture it instead of reading\n            // $root from the watcher, which fires during hx-boost teardown\n            // when magic properties can no longer resolve across the teleport\n            // boundary.\n            const el = this.$el;\n            const id = 'guide-' + el.dataset.guideKey;\n            const self = this;\n\n            // Every way out of the modal counts as \"understood\": Verstanden,\n            // Escape, the backdrop, the X, and navigating away (the\n            // htmx:beforeHistorySave hook closes the store). Escape and the\n            // backdrop are wired by the modal shell straight to\n            // $store.modal.close(), so watching the store is the only place\n            // that sees all of them.\n            this.$watch('$store.modal?.open', (value, previous) => {\n                if (value === id) {\n                    const store = modalStore();\n                    const context = (store && store.context) || {};\n                    self.recorded = false;\n                    self.forcedOpen = !!context.forced;\n                    return;\n                }\n                if (previous === id) self.record(el);\n            });\n        },\n\n        record(el) {\n            if (this.recorded || this.forcedOpen) return;\n            this.recorded = true;\n            track('guide_dismissed', { guide: el.dataset.guideKey });\n            post(el.dataset.dismissUrl, {});\n        },\n\n        dismiss() {\n            // Record before closing so the store watcher finds the guard set\n            // and does not post a second time.\n            this.record(this.$root);\n            const store = modalStore();\n            if (store) store.close();\n        },\n\n        mute() {\n            const el = this.$root;\n            // Muting is the recorded action for this click. Claiming the\n            // guard keeps the close from also firing a dismissal.\n            this.recorded = true;\n            const store = modalStore();\n            if (store) store.close();\n            track('guide_muted', { guide: el.dataset.guideKey });\n            post(el.dataset.muteUrl, {});\n        },\n    }));\n});\n", "// The one-time \"other properties?\" question for payers on /app/.\n//\n// The server decides who is asked and claims every showing\n// (dashboard/next_property_ask.py). This file decides when in a tab session to\n// ask for the claim: from the second app page view on, once per tab. The modal\n// opens only when the server answers {\"show\": true}. Closing it without an\n// answer records nothing, because the showing was already claimed.\n// See docs/product/next-property-ask.md.\n\nconst VIEWS_KEY = 'immopix.appPageViews';\nconst SHOWN_KEY = 'immopix.nextPropertyAsk.shown';\nconst MODAL_ID = 'next-property-ask';\n\n// sessionStorage can throw (blocked site data, some private modes). A blocked\n// counter reads as 0, so the question never shows. That is the safe side.\nfunction appPageViews() {\n    try { return parseInt(window.sessionStorage.getItem(VIEWS_KEY), 10) || 0; }\n    catch (_) { return 0; }\n}\n\nfunction countAppPageView() {\n    try { window.sessionStorage.setItem(VIEWS_KEY, String(appPageViews() + 1)); }\n    catch (_) { /* storage blocked: the question stays off */ }\n}\n\nfunction shownInThisTab() {\n    try { return window.sessionStorage.getItem(SHOWN_KEY) === '1'; }\n    catch (_) { return true; }\n}\n\nfunction markShownInThisTab() {\n    try { window.sessionStorage.setItem(SHOWN_KEY, '1'); }\n    catch (_) { /* nothing to remember */ }\n}\n\n// An app page view is a page in the boosted app shell (app_base.html). A full\n// load counts when this bundle runs and its body carries hx-boost. A boosted\n// navigation counts in htmx:beforeSwap, before the new body and this\n// component initialise. A history restore fires no beforeSwap, so going back\n// is not a new view.\nif (document.body && document.body.getAttribute('hx-boost') === 'true') countAppPageView();\ndocument.addEventListener('htmx:beforeSwap', (event) => {\n    if (!event.detail.boosted || !event.detail.shouldSwap) return;\n    countAppPageView();\n});\n\ndocument.addEventListener('alpine:init', () => {\n    const modalStore = () => window.Alpine && window.Alpine.store('modal');\n\n    function csrfToken() {\n        const meta = document.querySelector('meta[name=\"csrf-token\"]');\n        return meta ? meta.content : '';\n    }\n\n    function post(url, params, options) {\n        const body = new FormData();\n        Object.keys(params || {}).forEach(key => body.append(key, params[key]));\n        return fetch(url, Object.assign({\n            method: 'POST',\n            headers: { 'X-CSRFToken': csrfToken() },\n            body: body,\n        }, options || {}));\n    }\n\n    Alpine.data('nextPropertyAsk', () => ({\n        step: 'question',  // question | decline | thanks | help | sent\n        reason: '',\n        note: '',\n        message: '',\n        sending: false,\n        failed: false,\n\n        init() {\n            // $el is the root inside the teleported modal body. Capture it\n            // before the request: an hx-boost swap can remove it meanwhile.\n            const el = this.$el;\n            if (appPageViews() < 2 || shownInThisTab()) return;\n            // Set before the request, so a quick boosted round trip cannot ask\n            // for a second showing while the first claim is in flight.\n            markShownInThisTab();\n            post(el.dataset.shownUrl)\n                .then(response => (response.ok ? response.json() : { show: false }))\n                .then(data => {\n                    const store = modalStore();\n                    if (!data.show || !el.isConnected || !store || store.open) return;\n                    store.show(MODAL_ID);\n                })\n                .catch(() => {});\n        },\n\n        go(step) {\n            this.failed = false;\n            this.step = step;\n        },\n\n        create() {\n            // keepalive: the answer must arrive even though the property\n            // dialog takes over at once.\n            post(this.$root.dataset.answerUrl, { answer: 'create' }, { keepalive: true })\n                .catch(() => {});\n            const store = modalStore();\n            if (!store) return;\n            // Close first: show() over an open modal measures the scrollbar\n            // while it is already hidden, and the page shifts sideways.\n            store.close();\n            store.show('property-create');\n        },\n\n        decline() {\n            if (!this.reason) return;\n            this.submit({ answer: 'decline', reason: this.reason, text: this.note.trim() }, 'thanks');\n        },\n\n        askForHelp() {\n            const text = this.message.trim();\n            if (!text) return;\n            this.submit({ answer: 'help', text: text }, 'sent');\n        },\n\n        async submit(params, nextStep) {\n            if (this.sending) return;\n            const url = this.$root.dataset.answerUrl;\n            this.sending = true;\n            this.failed = false;\n            try {\n                const response = await post(url, params);\n                if (response.ok) this.step = nextStep;\n                else this.failed = true;\n            } catch (_) {\n                this.failed = true;\n            }\n            this.sending = false;\n        },\n    }));\n});\n", "import { estimateProgress } from './estimated-progress.js';\n\n// Scraping renders the page first (Firecrawl waits 5 s); the photo download\n// runs in parallel waves, roughly half a second per photo.\nconst SCRAPE_MS = 12000;\nconst IMPORT_BASE_MS = 2000;\nconst IMPORT_PER_PHOTO_MS = 500;\n\ndocument.addEventListener('alpine:init', () => {\n    const I18N = window.I18N || {};\n\n    Alpine.data('propertyCreate', () => ({\n        step: 'choice',  // choice | manual | url | scraping | results | importing\n        progress: 0,\n        importUrl: '',\n        scraping: false,\n        importing: false,\n        scrapedImages: [],\n        scrapedMetadata: {},\n        propertyName: '',\n        importError: '',\n\n        // Integration requests \u2014 the chip footer under the two choice cards.\n        integrationSources: ['onOffice', 'Propstack', 'FlowFact', 'Dropbox / Drive'],\n        integrationSelected: [],\n        integrationSent: [],\n        integrationOtherOpen: false,\n        integrationOther: '',\n        integrationThanks: false,\n        integrationSending: false,\n\n        get isOpen() { return !!Alpine.store('modal')?.is('property-create'); },\n\n        init() {\n            // The component lives inside the teleported modal body. Reset it\n            // no matter how the shared shell closes (button, Escape, backdrop,\n            // or hx-boost navigation).\n            this.$watch('isOpen', isOpen => {\n                if (!isOpen) this.reset();\n            });\n\n            // /app/?create=1 (trial guide + onboarding CTAs) opens the modal directly.\n            // The flag is server-rendered so it works for full loads and hx-boost swaps alike.\n            if (this.$root.dataset.autoOpen === '1') {\n                // Strip the param so refresh/back doesn't reopen the modal.\n                const url = new URL(window.location);\n                if (url.searchParams.has('create')) {\n                    url.searchParams.delete('create');\n                    window.history.replaceState(\n                        window.history.state,\n                        '',\n                        url.pathname + url.search + url.hash,\n                    );\n                }\n                this.$nextTick(() => this.openModal());\n            }\n        },\n\n        openModal() {\n            Alpine.store('modal')?.show('property-create');\n        },\n\n        closeModal() {\n            if (this.importing) return;\n            Alpine.store('modal')?.close();\n            this.reset();\n        },\n\n        reset() {\n            this.step = 'choice';\n            this.importUrl = '';\n            this.scraping = false;\n            this.importing = false;\n            this.scrapedImages = [];\n            this.scrapedMetadata = {};\n            this.propertyName = '';\n            this.importError = '';\n            this.integrationSelected = [];\n            this.integrationSent = [];\n            this.integrationOtherOpen = false;\n            this.integrationOther = '';\n            this.integrationThanks = false;\n            this.integrationSending = false;\n            if (this.$refs.scrapeResults) this.$refs.scrapeResults.innerHTML = '';\n        },\n\n        // Sent sources typed into \"Andere \u2026\" \u2014 rendered as extra success chips so\n        // the \"Andere \u2026\" chip itself stays available for a second suggestion.\n        get integrationSentCustom() {\n            return this.integrationSent.filter(s => !this.integrationSources.includes(s));\n        },\n\n        get showIntegrationSend() {\n            return this.integrationSelected.length > 0 || this.integrationOtherOpen;\n        },\n\n        toggleIntegrationChip(source) {\n            if (this.integrationSent.includes(source)) return;\n            const i = this.integrationSelected.indexOf(source);\n            if (i === -1) this.integrationSelected.push(source);\n            else this.integrationSelected.splice(i, 1);\n            this.integrationThanks = false;\n        },\n\n        toggleIntegrationOther() {\n            this.integrationOtherOpen = !this.integrationOtherOpen;\n            this.integrationThanks = false;\n            if (this.integrationOtherOpen) {\n                this.$nextTick(() => this.$refs.integrationOtherInput?.focus());\n            }\n        },\n\n        async sendIntegrationRequest() {\n            if (this.integrationSending) return;\n            const other = this.integrationOther.trim();\n            // Only \"Andere \u2026\" is open and nothing was typed \u2014 ask for the name\n            // instead of reporting an empty request.\n            if (!other && !this.integrationSelected.length) {\n                this.$refs.integrationOtherInput?.focus();\n                return;\n            }\n\n            // Dedupe against already-sent sources \u2014 a repeated custom name would\n            // otherwise render twice and break the x-for keys.\n            const sources = [...new Set([...this.integrationSelected, ...(other ? [other] : [])])]\n                .filter(s => !this.integrationSent.includes(s));\n            if (!sources.length) {\n                this.integrationOtherOpen = false;\n                this.integrationOther = '';\n                return;\n            }\n\n            const requestUrl = this.$root.dataset.integrationRequestUrl;\n            const csrfToken = document.querySelector('meta[name=\"csrf-token\"]').content;\n\n            this.integrationSending = true;\n            try {\n                const res = await fetch(requestUrl, {\n                    method: 'POST',\n                    headers: {\n                        'X-CSRFToken': csrfToken,\n                        'Content-Type': 'application/json',\n                    },\n                    body: JSON.stringify({ sources }),\n                });\n                // Leave the selection intact on failure so the user can retry.\n                if (!res.ok) return;\n            } catch (e) {\n                return;\n            } finally {\n                this.integrationSending = false;\n            }\n\n            // The modal may have closed (and reset) while the request ran \u2014\n            // don't resurrect success state onto a fresh component.\n            if (!this.isOpen) return;\n\n            this.integrationSent.push(...sources);\n            this.integrationSelected = [];\n            this.integrationOtherOpen = false;\n            this.integrationOther = '';\n            this.integrationThanks = true;\n        },\n\n        goManual() { this.step = 'manual'; },\n\n        goUrl() { this.step = 'url'; },\n\n        goBack() {\n            if (this.step === 'results') {\n                this.step = 'url';\n                this.scrapedImages = [];\n                this.scrapedMetadata = {};\n                this.propertyName = '';\n                this.importError = '';\n                if (this.$refs.scrapeResults) this.$refs.scrapeResults.innerHTML = '';\n            } else {\n                this.step = 'choice';\n            }\n        },\n\n        async startScrape() {\n            const url = this.importUrl.trim();\n            if (!url) return;\n\n            this.step = 'scraping';\n            const done = estimateProgress((v) => { this.progress = v; }, SCRAPE_MS);\n            this.scrapedImages = [];\n            this.importError = '';\n            // Capture the ref now, before any await. After an hx-boost navigation\n            // the component is torn down and `this.$refs` itself throws (_x_refs).\n            const scrapeResults = this.$refs.scrapeResults;\n            if (scrapeResults) scrapeResults.innerHTML = '';\n\n            const scrapeUrl = this.$root.dataset.scrapeUrl;\n            const csrfToken = document.querySelector('meta[name=\"csrf-token\"]').content;\n\n            try {\n                const formData = new FormData();\n                formData.append('url', url);\n\n                const res = await fetch(scrapeUrl, {\n                    method: 'POST',\n                    headers: { 'X-CSRFToken': csrfToken },\n                    body: formData,\n                });\n\n                const html = await res.text();\n                if (scrapeResults) {\n                    scrapeResults.innerHTML = html;\n\n                    // Read image URLs from embedded JSON\n                    const dataEl = scrapeResults.querySelector('#scraped-image-data');\n                    if (dataEl) {\n                        try { this.scrapedImages = JSON.parse(dataEl.textContent); } catch(e) {}\n                    }\n\n                    // Read metadata\n                    const metaEl = scrapeResults.querySelector('#scraped-metadata');\n                    if (metaEl) {\n                        try { this.scrapedMetadata = JSON.parse(metaEl.textContent); } catch(e) {}\n                    }\n                }\n\n                // Prefill property name from metadata\n                if (this.scrapedMetadata.name) {\n                    this.propertyName = this.scrapedMetadata.name;\n                }\n\n                done();\n                this.step = 'results';\n            } catch (e) {\n                done();\n                if (scrapeResults) {\n                    scrapeResults.innerHTML = '<p class=\"text-sm text-alert-error-foreground text-center py-4\">' + (I18N.connectionErrorRetry || 'Verbindungsfehler. Bitte erneut versuchen.') + '</p>';\n                }\n                this.step = 'results';\n            }\n        },\n\n        resetScrape() {\n            this.scrapedImages = [];\n            this.scrapedMetadata = {};\n            this.propertyName = '';\n            this.importUrl = '';\n            this.importError = '';\n            if (this.$refs.scrapeResults) this.$refs.scrapeResults.innerHTML = '';\n            this.step = 'url';\n        },\n\n        async createWithImport(selectedIndexes) {\n            if (this.importing) return;\n\n            const name = this.propertyName.trim();\n            if (!name) {\n                this.importError = I18N.nameRequired || 'Name ist erforderlich';\n                return;\n            }\n\n            const urls = selectedIndexes.map(i => this.scrapedImages[i]).filter(Boolean);\n            if (!urls.length) return;\n\n            this.importError = '';\n            this.step = 'importing';\n            this.importing = true;\n            estimateProgress((v) => { this.progress = v; }, IMPORT_BASE_MS + IMPORT_PER_PHOTO_MS * urls.length);\n\n            const createUrl = this.$root.dataset.createUrl;\n            const csrfToken = document.querySelector('meta[name=\"csrf-token\"]').content;\n\n            try {\n                const res = await fetch(createUrl, {\n                    method: 'POST',\n                    headers: {\n                        'X-CSRFToken': csrfToken,\n                        'Content-Type': 'application/json',\n                    },\n                    body: JSON.stringify({ name, urls, metadata: this.scrapedMetadata }),\n                });\n\n                const data = await res.json();\n\n                if (!res.ok) {\n                    this.importError = data.error || I18N.importFailed || 'Import fehlgeschlagen';\n                    this.step = 'results';\n                    this.importing = false;\n                    return;\n                }\n\n                // Redirect to new property\n                if (data.redirect_url) {\n                    window.location.href = data.redirect_url;\n                    return;\n                }\n            } catch (e) {\n                this.importError = I18N.connectionErrorRetry || 'Verbindungsfehler. Bitte erneut versuchen.';\n                this.step = 'results';\n            } finally {\n                this.importing = false;\n            }\n        },\n    }));\n\n});\n", "// Search box on the property list (/app/), shown from\n// PROPERTY_SEARCH_MIN_PROPERTIES properties on (dashboard/views/account.py).\n//\n// The list renders every property on one page, so the filter runs here,\n// without a request. Matching ignores case, accents and the German umlaut\n// spellings: \"strasse\" finds \"Stra\u00DFe\", \"muller\" and \"mueller\" find \"M\u00FCller\".\n// Every word must match, in any order. See docs/code/property-search.md.\n\n// Letters that NFD does not split into a base letter and an accent.\nconst SPECIAL_LETTERS = { '\u00DF': 'ss', '\u00E6': 'ae', '\u0153': 'oe', '\u00F8': 'o', '\u0142': 'l', '\u0111': 'd' };\nconst COMBINING_MARKS = /[\u0300-\u036F]/g;\n// \"mueller\" and \"m\u00FCller\" both become \"muller\" in the loose form.\nconst UMLAUT_SPELLINGS = { a: 'e', o: 'e', u: 'e' };\nconst URL_DELAY_MS = 300;\n\n// Lower-cases and strips accents. Each output character remembers the range\n// of the input it came from, so a match can be highlighted in the original.\nfunction fold(text) {\n    let out = '';\n    const ranges = [];\n    let i = 0;\n    for (const ch of text) {\n        const lower = ch.toLowerCase().normalize('NFD').replace(COMBINING_MARKS, '');\n        for (const c of lower) {\n            const plain = SPECIAL_LETTERS[c] || c;\n            for (const p of plain) {\n                out += p;\n                ranges.push([i, i + ch.length]);\n            }\n        }\n        i += ch.length;\n    }\n    return { text: out, ranges };\n}\n\n// Folded text with \"ae\", \"oe\" and \"ue\" written as one letter.\nfunction loosen(folded) {\n    let out = '';\n    const ranges = [];\n    const src = folded.text;\n    for (let i = 0; i < src.length; i++) {\n        if (UMLAUT_SPELLINGS[src[i]] && src[i + 1] === UMLAUT_SPELLINGS[src[i]]) {\n            out += src[i];\n            ranges.push([folded.ranges[i][0], folded.ranges[i + 1][1]]);\n            i++;\n        } else {\n            out += src[i];\n            ranges.push(folded.ranges[i]);\n        }\n    }\n    return { text: out, ranges };\n}\n\nfunction searchable(text) {\n    const strict = fold(text);\n    return { strict, loose: loosen(strict) };\n}\n\n// Ranges of the original text where the word occurs. The strict form finds\n// \"er\" in \"Hauer\"; the loose form finds \"mueller\" in \"M\u00FCller\".\nfunction wordRanges(name, word) {\n    // A lone accent folds to nothing. It matches everything, marks nothing.\n    if (!word.strict.text) return [];\n    for (const form of ['strict', 'loose']) {\n        const haystack = name[form];\n        const needle = word[form].text;\n        const found = [];\n        let at = haystack.text.indexOf(needle);\n        while (at !== -1) {\n            found.push([haystack.ranges[at][0], haystack.ranges[at + needle.length - 1][1]]);\n            at = haystack.text.indexOf(needle, at + needle.length);\n        }\n        if (found.length) return found;\n    }\n    return null;\n}\n\nfunction mergeRanges(ranges) {\n    const sorted = ranges.slice().sort((a, b) => a[0] - b[0]);\n    const merged = [];\n    for (const r of sorted) {\n        const last = merged[merged.length - 1];\n        if (last && r[0] <= last[1]) last[1] = Math.max(last[1], r[1]);\n        else merged.push([r[0], r[1]]);\n    }\n    return merged;\n}\n\n// Writes the name as text nodes plus <mark> elements. No innerHTML, so a\n// property name can never inject markup.\nfunction renderName(el, name, ranges) {\n    if (!ranges.length) {\n        el.textContent = name;\n        return;\n    }\n    const parts = document.createDocumentFragment();\n    let pos = 0;\n    for (const [start, end] of ranges) {\n        if (start > pos) parts.append(name.slice(pos, start));\n        const mark = document.createElement('mark');\n        mark.textContent = name.slice(start, end);\n        parts.append(mark);\n        pos = end;\n    }\n    if (pos < name.length) parts.append(name.slice(pos));\n    el.replaceChildren(parts);\n}\n\nfunction isTypingTarget(el) {\n    return !!el && (el.isContentEditable || ['INPUT', 'TEXTAREA', 'SELECT'].includes(el.tagName));\n}\n\ndocument.addEventListener('alpine:init', () => {\n    Alpine.data('propertySearch', () => {\n        // Plain closure state, not Alpine data: DOM nodes do not belong in\n        // a reactive proxy.\n        let root = null;\n        let cards = [];\n        let countTemplate = '';\n        let emptyTemplate = '';\n        let urlTimer = null;\n\n        return {\n            query: '',\n            shown: 0,\n            total: 0,\n            announcement: '',\n\n            init() {\n                root = this.$el;\n                countTemplate = root.dataset.countTemplate || '';\n                emptyTemplate = root.dataset.emptyTemplate || '';\n                cards = Array.from(root.querySelectorAll('[data-property-card]')).map((card) => {\n                    const nameEl = card.querySelector('[data-property-name]');\n                    // NFC keeps an accent inside the <mark> with its letter.\n                    const name = nameEl.textContent.normalize('NFC');\n                    return { card, nameEl, name, search: searchable(name) };\n                });\n                this.total = cards.length;\n                // The URL is the source of truth, also when htmx restores a\n                // snapshot of this page on back navigation.\n                this.query = new URL(window.location.href).searchParams.get('q') || '';\n                this.filter();\n                this.announce();\n                this.$watch('query', () => {\n                    this.filter();\n                    clearTimeout(urlTimer);\n                    urlTimer = setTimeout(() => this.settle(), URL_DELAY_MS);\n                });\n            },\n\n            destroy() {\n                clearTimeout(urlTimer);\n            },\n\n            get hasQuery() {\n                return this.query.trim() !== '';\n            },\n\n            get noMatch() {\n                return this.hasQuery && this.shown === 0;\n            },\n\n            get countText() {\n                return countTemplate.replace('{shown}', this.shown).replace('{total}', this.total);\n            },\n\n            get emptyText() {\n                // A function, so \"$&\" in a query stays literal text.\n                const q = this.query.trim();\n                return emptyTemplate.replace('{query}', () => q);\n            },\n\n            filter() {\n                const words = Array.from(new Set(this.query.trim().split(/\\s+/).filter(Boolean)))\n                    .map((w) => searchable(w.normalize('NFC')));\n                let shown = 0;\n                for (const item of cards) {\n                    let ranges = [];\n                    let match = true;\n                    for (const word of words) {\n                        const found = wordRanges(item.search, word);\n                        if (!found) {\n                            match = false;\n                            break;\n                        }\n                        ranges = ranges.concat(found);\n                    }\n                    item.card.hidden = !match;\n                    renderName(item.nameEl, item.name, match ? mergeRanges(ranges) : []);\n                    if (match) shown++;\n                }\n                this.shown = shown;\n            },\n\n            // Once typing pauses: put the query in the URL and tell screen\n            // readers the count. Every keystroke would flood both, and\n            // WebKit throws after 100 history calls in 10 seconds.\n            settle() {\n                clearTimeout(urlTimer);\n                urlTimer = null;\n                // After an hx-boost navigation the URL belongs to another page.\n                if (!root.isConnected) return;\n                this.announce();\n                const url = new URL(window.location.href);\n                const q = this.query.trim();\n                if (q) url.searchParams.set('q', q);\n                else url.searchParams.delete('q');\n                const path = url.pathname + url.search + url.hash;\n                if (path === window.location.pathname + window.location.search + window.location.hash) return;\n                window.history.replaceState(window.history.state, '', path);\n                // htmx 2 files its snapshot of this page under the path it\n                // last pushed, kept in this sessionStorage key. Without the\n                // update, going back misses the cache and reloads the page.\n                // The reload also restores the query, only slower.\n                try { window.sessionStorage.setItem('htmx-current-path-for-history', url.pathname + url.search); }\n                catch (_) { /* storage blocked: back navigation reloads instead */ }\n            },\n\n            // A click on a card can come before the delay ran out.\n            flushUrl() {\n                if (urlTimer) this.settle();\n            },\n\n            announce() {\n                this.announcement = this.hasQuery ? this.countText : '';\n            },\n\n            clear() {\n                this.query = '';\n                this.$nextTick(() => this.input().focus());\n            },\n\n            onEscape(event) {\n                if (this.query) {\n                    event.preventDefault();\n                    this.clear();\n                } else {\n                    event.target.blur();\n                }\n            },\n\n            // \"/\" jumps to the search box, as on many websites. Not while the\n            // user types in a field or a dialog is open.\n            onWindowKey(event) {\n                if (event.key !== '/' || event.ctrlKey || event.metaKey || event.altKey) return;\n                if (event.defaultPrevented || event.isComposing) return;\n                // currentModalId comes from shared_base.html; a page without it has no dialogs.\n                if (isTypingTarget(event.target) || window.currentModalId?.()) return;\n                event.preventDefault();\n                const input = this.input();\n                input.focus();\n                input.select();\n            },\n\n            input() {\n                return root.querySelector('[data-property-search-input]');\n            },\n        };\n    });\n});\n", "document.addEventListener('alpine:init', () => {\n\n    // Reusable address autocomplete via Google Places Autocomplete Data API\n    // Uses our own input + dropdown \u2014 no Google widget, no full-screen overlay on mobile\n    Alpine.data('addressAutocomplete', (initialStreet = '', initialPostalCode = '', initialCity = '', apiKey = '') => ({\n        street: initialStreet,\n        postalCode: initialPostalCode,\n        city: initialCity,\n        query: '',\n        suggestions: [],\n        showDropdown: false,\n        _debounceTimer: null,\n        _sessionToken: null,\n        _places: null,\n        _ready: false,\n        _els: null,\n\n        init() {\n            this.query = [this.street, this.postalCode, this.city].filter(Boolean).join(', ');\n            // Cache DOM refs now \u2014 they won't work after await in async methods\n            this._els = {\n                street: this.$refs.hiddenStreet,\n                postalCode: this.$refs.hiddenPostalCode,\n                city: this.$refs.hiddenCity,\n                root: this.$el,\n            };\n            if (apiKey) this._loadApi(apiKey);\n        },\n\n        async _loadApi(key) {\n            try {\n                // Dynamically load Google Maps API if not yet present.\n                // Done here instead of a <script> tag so it works with hx-boost navigation.\n                if (!window.google?.maps?.importLibrary) {\n                    await this._injectScript(key);\n                }\n                // Use the module reference from importLibrary directly to avoid\n                // instanceof mismatches when the API is loaded dynamically.\n                this._places = await google.maps.importLibrary('places');\n                this._sessionToken = new this._places.AutocompleteSessionToken();\n                this._ready = true;\n            } catch (e) {\n                console.error('Google Places API failed to load:', e);\n            }\n        },\n\n        _injectScript(key) {\n            // Deduplicate: reuse existing loading promise if another instance started it\n            if (window._gmapsLoading) return window._gmapsLoading;\n            window._gmapsLoading = new Promise((resolve, reject) => {\n                const cb = '__gmapsReady';\n                window[cb] = () => { delete window[cb]; resolve(); };\n                const s = document.createElement('script');\n                s.src = 'https://maps.googleapis.com/maps/api/js?key=' + key + '&loading=async&callback=' + cb;\n                s.async = true;\n                s.onerror = () => { window._gmapsLoading = null; reject(new Error('Google Maps script failed')); };\n                document.head.appendChild(s);\n            });\n            return window._gmapsLoading;\n        },\n\n        onInput() {\n            const q = this.query.trim();\n            if (q.length < 3 || !this._ready) {\n                this.suggestions = [];\n                this.showDropdown = false;\n                return;\n            }\n            clearTimeout(this._debounceTimer);\n            this._debounceTimer = setTimeout(() => this._fetchSuggestions(q), 250);\n        },\n\n        async _fetchSuggestions(input) {\n            try {\n                const { suggestions } = await this._places.AutocompleteSuggestion.fetchAutocompleteSuggestions({\n                    input,\n                    sessionToken: this._sessionToken,\n                    region: 'de',\n                    includedPrimaryTypes: ['street_address', 'route', 'premise', 'subpremise'],\n                    language: 'de',\n                });\n                this.suggestions = suggestions.map(s => ({\n                    text: s.placePrediction.text.text,\n                    mainText: s.placePrediction.mainText?.text || s.placePrediction.text.text,\n                    secondaryText: s.placePrediction.secondaryText?.text || '',\n                    place: s.placePrediction.toPlace(),\n                }));\n                this.showDropdown = this.suggestions.length > 0;\n            } catch (e) {\n                console.error('Address autocomplete error:', e);\n                this.suggestions = [];\n                this.showDropdown = false;\n            }\n        },\n\n        async selectSuggestion(suggestion) {\n            this.query = suggestion.text;\n            this.showDropdown = false;\n            this.suggestions = [];\n\n            try {\n                // Unwrap Alpine's reactive proxy: the Place getter returns a frozen\n                // array, and reading it through the proxy throws a TypeError, which\n                // saved the street without postal code and city (June to Nov 2026).\n                const place = Alpine.raw(suggestion).place;\n                await place.fetchFields({ fields: ['addressComponents'] });\n                if (place.addressComponents) {\n                    this._parsePlaceComponents(place.addressComponents);\n                } else {\n                    this.street = suggestion.mainText;\n                    this._syncAndNotify();\n                }\n            } catch (e) {\n                console.error('Address details failed:', e);\n                this.street = suggestion.mainText;\n                this._syncAndNotify();\n            }\n\n            this._sessionToken = new this._places.AutocompleteSessionToken();\n        },\n\n        onBlur() {\n            setTimeout(() => { this.showDropdown = false; }, 200);\n        },\n\n        _parsePlaceComponents(components) {\n            let route = '';\n            let streetNumber = '';\n            this.postalCode = '';\n            this.city = '';\n\n            for (const component of components) {\n                const type = component.types[0];\n                if (type === 'route') route = component.longText;\n                else if (type === 'street_number') streetNumber = component.longText;\n                else if (type === 'postal_code') this.postalCode = component.longText;\n                else if (type === 'locality') this.city = component.longText;\n                else if (type === 'sublocality_level_1' && !this.city) this.city = component.longText;\n            }\n\n            this.street = streetNumber ? `${route} ${streetNumber}` : route;\n            this.query = [this.street, this.postalCode, this.city].filter(Boolean).join(', ');\n            this._syncAndNotify();\n        },\n\n        _syncAndNotify() {\n            if (this._els.street) this._els.street.value = this.street;\n            if (this._els.postalCode) this._els.postalCode.value = this.postalCode;\n            if (this._els.city) this._els.city.value = this.city;\n\n            // Root may be detached if an hx-boost navigation tore the component\n            // down while a Places callback was in flight \u2014 guard the dispatch.\n            if (this._els.root && this._els.root.isConnected) {\n                this._els.root.dispatchEvent(new CustomEvent('address-changed', { bubbles: true }));\n            }\n        },\n    }));\n\n});\n", "document.addEventListener('alpine:init', () => {\n\n    Alpine.data('listingForm', function() {\n        return {\n            listingType: '',\n            propertyType: '',\n            hasParking: false,\n            hasProvision: false,\n            energyValue: '',\n            energySources: [],\n            energySourceLabels: {},\n            counts: {},\n            sections: {\n                basisdaten: ['property_type', 'condition', 'construction_year'],\n                adresse: ['street'],\n                flaechen: ['living_area', 'rooms'],\n                finanzen_sale: ['price', 'buyer_commission'],\n                finanzen_rental: ['cold_rent', 'utilities', 'deposit'],\n                energie: ['energy_cert_type', 'energy_value', 'energy_source', 'heating_type']\n            },\n            _saveTimer: null,\n            saveStatus: '',\n            _saveUrl: '',\n\n            init() {\n                const d = this.$el.dataset;\n                this.listingType = d.listingType || 'sale';\n                this.propertyType = d.propertyType || '';\n                this.hasParking = d.hasParking === 'true';\n                this.hasProvision = d.hasProvision === 'true';\n                this.energyValue = d.energyValue || '';\n                this._saveUrl = d.saveUrl || '';\n\n                try { this.energySources = JSON.parse(d.energySources || '[]'); } catch(e) { this.energySources = []; }\n                try { this.energySourceLabels = JSON.parse(d.energySourceLabels || '{}'); } catch(e) { this.energySourceLabels = {}; }\n\n                this.$nextTick(() => this.updateAll());\n            },\n\n            updateAll() {\n                for (const [key, fields] of Object.entries(this.sections)) {\n                    if (key === 'finanzen_sale' || key === 'finanzen_rental') continue;\n                    this.counts[key] = this._count(fields);\n                }\n                const finKey = this.listingType === 'sale' ? 'finanzen_sale' : 'finanzen_rental';\n                this.counts.finanzen = this._count(this.sections[finKey]);\n            },\n\n            _count(fields) {\n                let filled = 0;\n                for (const f of fields) {\n                    if (f === 'energy_source') { if (this.energySources.length > 0) filled++; continue; }\n                    const el = this.$el.querySelector('[name=\"' + f + '\"]');\n                    if (el && el.value && el.value.trim() !== '') filled++;\n                }\n                return { filled, total: fields.length };\n            },\n\n            filled(s) { return this.counts[s]?.filled || 0; },\n            total(s) { return this.counts[s]?.total || 0; },\n            pct(s) { const t = this.total(s); return t > 0 ? Math.round(this.filled(s) / t * 100) : 0; },\n            colorClass(s) { const p = this.pct(s); return p === 100 ? 'text-emerald-600' : p > 0 ? 'text-amber-600' : 'text-muted-foreground'; },\n            strokeClass(s) { const p = this.pct(s); return p === 100 ? 'stroke-emerald-500' : p > 0 ? 'stroke-amber-500' : 'stroke-muted-foreground/30'; },\n\n            // Same rules as _parse_decimal in dashboard/views/expose.py: with dot\n            // and comma the later one is the decimal separator, a lone\n            // separator before groups of three digits groups thousands\n            // (\"219.000\", \"450,000\"), any other comma is a decimal separator.\n            parseNumber(raw) {\n                let value = (raw || '').trim();\n                if (value.includes(',') && value.includes('.')) {\n                    value = value.lastIndexOf('.') > value.lastIndexOf(',')\n                        ? value.replace(/,/g, '')\n                        : value.replace(/\\./g, '').replace(',', '.');\n                } else if (/^[1-9]\\d{0,2}([.,])\\d{3}(?:\\1\\d{3})*$/.test(value)) {\n                    value = value.replace(/[.,]/g, '');\n                } else {\n                    value = value.replace(',', '.');\n                }\n                return parseFloat(value);\n            },\n\n            computedWarmRent() {\n                const cold = this.parseNumber(this.$el.querySelector('[name=\"cold_rent\"]')?.value);\n                const util = this.parseNumber(this.$el.querySelector('[name=\"utilities\"]')?.value);\n                if (!isNaN(cold) && !isNaN(util)) return (cold + util).toLocaleString('de-DE', {minimumFractionDigits: 0, maximumFractionDigits: 2});\n                if (!isNaN(cold)) return cold.toLocaleString('de-DE', {minimumFractionDigits: 0, maximumFractionDigits: 2});\n                return '';\n            },\n\n            computedEnergyClass() {\n                const val = this.parseNumber(this.energyValue);\n                if (isNaN(val)) return '';\n                if (val <= 30) return 'A+';\n                if (val <= 50) return 'A';\n                if (val <= 75) return 'B';\n                if (val <= 100) return 'C';\n                if (val <= 130) return 'D';\n                if (val <= 160) return 'E';\n                if (val <= 200) return 'F';\n                if (val <= 250) return 'G';\n                return 'H';\n            },\n\n            autoSave() {\n                clearTimeout(this._saveTimer);\n                this._saveTimer = setTimeout(() => this._doSave(), 1500);\n            },\n\n            async _doSave() {\n                this.saveStatus = 'saving';\n                try {\n                    const formData = new FormData(this.$el);\n                    const res = await fetch(this._saveUrl, {\n                        method: 'POST',\n                        headers: {\n                            'X-Auto-Save': '1',\n                            'X-CSRFToken': formData.get('csrfmiddlewaretoken'),\n                        },\n                        body: formData,\n                    });\n                    const data = await res.json();\n                    this.saveStatus = data.ok ? 'saved' : '';\n                    if (data.ok) {\n                        window.dispatchEvent(new CustomEvent('expose-preview-stale'));\n                    }\n                } catch {\n                    this.saveStatus = '';\n                }\n                if (this.saveStatus === 'saved') {\n                    setTimeout(() => { if (this.saveStatus === 'saved') this.saveStatus = ''; }, 2000);\n                }\n            }\n        };\n    });\n\n});\n", "document.addEventListener('alpine:init', () => {\n\n    // Expos\u00E9 preview: a text box hides what does not fit its page (overflow:\n    // hidden, in the PDF too). Flag a clipped box so the customer shortens it.\n    Alpine.data('exposeTextFit', () => ({\n        clipped: false,\n\n        init() {\n            const el = this.$el;\n            const check = () => {\n                const boxes = [el, ...el.querySelectorAll('[data-fit-body]')];\n                this.clipped = boxes.some(box => box.scrollHeight > box.clientHeight + 1);\n            };\n            check();\n            // The web fonts change line breaks, so measure again once they load.\n            if (document.fonts) document.fonts.ready.then(check);\n        },\n    }));\n\n});\n", "/**\n * Shared Alpine.js component for public upload forms.\n * Used by: free tool, foto check, landing pages.\n *\n * Config via data attributes on the x-data element:\n *   data-upload-url    \u2014 POST endpoint for the upload\n *   data-prefill-email \u2014 optional pre-filled email\n *   data-require-consent \u2014 if present, consent checkbox is required\n *   data-error-*       \u2014 messages in the page language, from\n *                        templates/components/public_upload_messages.html\n *                        (marketing pages have no window.I18N)\n */\nimport { isHeic, uploadRejection } from './alpine-components/upload-validation.js';\n\ndocument.addEventListener('alpine:init', () => {\n    Alpine.data('publicUpload', function() {\n        return {\n            step: 1,\n            dragOver: false,\n            file: null,\n            fileName: '',\n            fileSize: '',\n            previewUrl: '',\n            email: '',\n            consent: false,\n            error: '',\n            submitting: false,\n\n            init() {\n                this.email = this.$root.dataset.prefillEmail || '';\n            },\n\n            handleFileSelect(event) {\n                const file = event.target.files[0];\n                if (file) this.selectFile(file);\n            },\n\n            handleDrop(event) {\n                this.dragOver = false;\n                const file = event.dataTransfer.files[0];\n                if (file) this.selectFile(file);\n            },\n\n            selectFile(file) {\n                const rejection = uploadRejection(file);\n                if (rejection) {\n                    this.error = rejection === 'size'\n                        ? this.$root.dataset.errorFileSize\n                        : this.$root.dataset.errorFileType;\n                    return;\n                }\n\n                this.file = file;\n                this.fileName = file.name;\n                this.fileSize = (file.size / (1024 * 1024)).toFixed(1) + ' MB';\n                // HEIC gets no local preview; the template shows an image icon.\n                this.previewUrl = isHeic(file) ? '' : URL.createObjectURL(file);\n                this.error = '';\n                this.step = 2;\n            },\n\n            reset() {\n                if (this.previewUrl) URL.revokeObjectURL(this.previewUrl);\n                this.step = 1;\n                this.file = null;\n                this.fileName = '';\n                this.fileSize = '';\n                this.previewUrl = '';\n                this.error = '';\n                this.consent = false;\n                const fileInput = this.$root.querySelector('input[type=file]');\n                if (fileInput) fileInput.value = '';\n            },\n\n            async submit() {\n                if (this.$root.dataset.requireConsent !== undefined && !this.consent) {\n                    this.error = this.$root.dataset.errorConsent;\n                    return;\n                }\n\n                this.error = '';\n                this.submitting = true;\n\n                const formData = new FormData();\n                formData.append('image', this.file);\n                formData.append('email', this.email);\n\n                if (this.consent) {\n                    formData.append('consent_public', 'on');\n                }\n\n                // Turnstile token\n                const turnstileInput = this.$root.querySelector('[name=\"cf-turnstile-response\"]');\n                if (turnstileInput) {\n                    formData.append('cf-turnstile-response', turnstileInput.value);\n                }\n\n                const csrfToken = document.querySelector('meta[name=\"csrf-token\"]').content;\n                const uploadUrl = this.$root.dataset.uploadUrl;\n\n                try {\n                    const response = await fetch(uploadUrl, {\n                        method: 'POST',\n                        headers: { 'X-CSRFToken': csrfToken },\n                        body: formData,\n                    });\n\n                    const data = await response.json();\n\n                    if (!response.ok) {\n                        this.error = data.error || this.$root.dataset.errorGeneric;\n                        const widget = this.$root.querySelector('.cf-turnstile');\n                        if (widget && typeof turnstile !== 'undefined') {\n                            turnstile.reset(widget);\n                        }\n                        this.submitting = false;\n                        return;\n                    }\n\n                    window.location.href = data.redirect_url;\n                } catch (e) {\n                    this.error = this.$root.dataset.errorConnection;\n                    this.submitting = false;\n                }\n            }\n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AAM,MAAMD,EAAW,CACpC,OAAQ,OACR,QAAS,CAAE,cAAeD,CAAU,EACpC,KAAMF,CACV,CAAC,EAEKK,EAAO,MAAMD,EAAS,KAAK,EAEjC,GAAI,CAACA,EAAS,GAAI,CACd,KAAK,MAAQC,EAAK,OAAS,KAAK,MAAM,QAAQ,aAC9C,IAAMC,EAAS,KAAK,MAAM,cAAc,eAAe,EACnDA,GAAU,OAAO,WAAc,aAC/B,UAAU,MAAMA,CAAM,EAE1B,KAAK,WAAa,GAClB,MACJ,CAEA,OAAO,SAAS,KAAOD,EAAK,YAChC,MAAY,CACR,KAAK,MAAQ,KAAK,MAAM,QAAQ,gBAChC,KAAK,WAAa,EACtB,CACJ,CACJ,CACJ,CAAC,CACL,CAAC",
  "names": ["I18N", "shapePoints", "shape", "x", "y", "width", "height", "svgPoints", "point", "json", "body", "node", "id", "xhr", "_a", "_b", "config", "base", "detail", "box", "open", "behavior", "event", "successful", "prefsJson", "prefs", "sel", "host", "prefill", "value", "subtype", "tab", "meta", "err", "button", "data", "propertyId", "keepSite", "v", "k", "presets", "inputs", "i", "inp", "selected", "p", "self", "has3d", "gate", "DOUBLE_TAP_SLOP", "clamp", "value", "min", "max", "orientation", "a", "b", "c", "pointOnSegment", "point", "segmentsIntersect", "d", "abC", "abD", "cdA", "cdB", "epsilon", "polygonArea", "points", "sum", "index", "next", "polygonIsSimple", "first", "firstNext", "second", "secondNext", "openPathIsSimple", "lastStart", "lastEnd", "shape", "rect", "xs", "ys", "left", "top", "event", "threshold", "gesture", "start", "cancelled", "areaTooSmall", "last", "slop", "previous", "candidate", "item", "dx", "dy", "viewport", "BRUSH_COLOR", "svgNumber", "value", "simplifyStroke", "points", "scaleX", "scaleY", "tolerance", "keep", "stack", "first", "last", "ax", "ay", "dx", "dy", "length", "farthest", "farthestDistance", "index", "px", "py", "distance", "_", "strokes", "width", "height", "items", "stroke", "strokeWidth", "point", "x", "y", "BRUSH_COLOR", "event", "_a", "viewport", "boxClamp", "value", "min", "max", "boxSortedAround", "points", "centre", "sum", "point", "a", "b", "boxLineIntersection", "c", "d", "denominator", "lengths", "t", "boxHorizonY", "footprint", "imageHeight", "top", "heights", "y", "boxGeometry", "corners", "height", "nearIndex", "best", "index", "near", "horizon", "scale", "boxCross", "origin", "boxFootprintIsQuadrilateral", "width", "gap", "first", "second", "turns", "previous", "next", "turn", "boxArea", "boxConvexHull", "sorted", "lower", "upper", "boxClipEdge", "axis", "bound", "keepBelow", "inside", "clipped", "current", "crossing", "boxClipToFrame", "boxCleanRing", "ring", "changed", "_", "other", "boxSvgPoint", "boxSvgRing", "geometry", "normalized", "hull", "outline", "area", "_a", "preview", "viewport", "screenShare", "pixels", "fallback", "handle", "snapshot", "event", "gesture", "start", "shape", "saved", "previousShape", "shapeJson", "straightenProject", "m", "x", "y", "w", "straightenMultiply", "a", "b", "result", "row", "col", "straightenInvert", "c", "d", "e", "f", "g", "h", "i", "det", "straightenQuad", "matrix", "straightenCorners", "frame", "straightenHalfPlanes", "quad", "signed", "k", "sign", "nx", "ny", "straightenFrameInside", "planes", "point", "plane", "inverse", "kept", "area", "STRAIGHTEN_MESH_CELLS", "STRAIGHTEN_SEAM_PIXELS", "straightenAffine", "s", "t", "denominator", "solve", "key", "canvas", "image", "view", "cssWidth", "cssHeight", "scale", "width", "height", "context", "sourceWidth", "sourceHeight", "fit", "toCanvas", "cells", "source", "target", "at", "cellWidth", "cellHeight", "corners", "triangle", "index", "xs", "ys", "cx", "cy", "length", "grow", "left", "top", "right", "bottom", "response", "busy", "body", "error", "strength", "step", "pct", "side", "stage", "sharp", "box", "event", "handle", "start", "current", "from", "to", "low", "high", "middle", "anchorX", "anchorY", "reachX", "reachY", "minimum", "size", "frameOf", "clamp", "value", "min", "max", "rounded", "brushRounded", "BRUSH_SIZE_MIN", "BRUSH_SIZE_MAX", "STAGE_RESERVED_HEIGHT", "STAGE_MIN_HEIGHT", "distance", "b", "midpoint", "highlightOperation", "operations", "operation", "cropOperation", "keystoneOperation", "configElement", "event", "_a", "_b", "_c", "_d", "_e", "_f", "_g", "highlight", "crop", "keystone", "params", "rect", "point", "cropRect", "tool", "detail", "mode", "base", "shape", "stroke", "x", "y", "lastWidth", "outline", "target", "response", "message", "body", "error", "image", "lightboxLink", "el", "id", "name", "html", "slot", "holder", "fresh", "key", "fallback", "handle", "gesture", "wasDraw", "moved", "originalRect", "minimum", "distanceMoved", "start", "dx", "dy", "original", "left", "top", "right", "bottom", "points", "viewport", "mid", "currentMid", "nextZoom", "anchorX", "anchorY", "clampToImage", "polygonDraft", "boxDraft", "current", "polygonInProgress", "nonTextInputs", "source", "width", "height", "ratio", "shortEdge", "blur", "brightness", "fill", "I18N", "prefs", "data", "id", "photoId", "url", "meta", "err", "checked", "checkbox", "groupKey", "selector", "cb", "checkboxes", "selectedCount", "params", "_a", "photoIds", "modal", "context", "csrf", "formData", "r", "canShareFiles", "fetchSlide", "url", "name", "response", "error", "blob", "withoutLine", "text", "line", "lines", "position", "cleanLabel", "value", "afterFirstLine", "slideName", "withLineAfter", "anchor", "files", "objectUrls", "destroyed", "labelTimer", "coverRequest", "rendered", "params", "label", "withPrice", "caption", "data", "slide", "file", "previous", "loaded", "next", "worker", "err", "workers", "count", "kept", "keptFiles", "request", "choices", "headline", "on", "price", "_a", "body", "meta", "VALID_TYPES", "uploadRejection", "file", "VALID_TYPES", "isHeic", "rejectionMessage", "reason", "I18N", "PHOTO_ICON", "I18N", "files", "_a", "file", "rejection", "uploadRejection", "rejectionMessage", "msg", "rowId", "uploadRows", "name", "retryId", "tempId", "previewUrl", "isHeic", "uploadUrl", "csrfToken", "placeholderHtml", "doUpload", "formData", "response", "data", "showError", "placeholder", "retryBtn", "row", "onSuccess", "e", "friendlyMsg", "onDone", "error", "r", "url", "scrapeResults", "scrapeUrl", "html", "dataEl", "metaEl", "selectedIndexes", "urls", "i", "importUrl", "importedCount", "tempIds", "_", "result", "successCount", "id", "el", "text", "div", "openModal", "_a", "event", "file", "_b", "validExtension", "validType", "estimateProgress", "set", "expectedMs", "started", "tau", "timer", "t", "LISTING_LOAD_MS", "PARALLEL_UPLOADS", "csrfToken", "postForm", "url", "formData", "response", "data", "failureReason", "status", "hostOf", "uploadToGallery", "uploadUrl", "files", "propertyId", "onProgress", "I18N", "done", "galleryUrl", "lastError", "send", "file", "_a", "ok", "queue", "first", "worker", "checkFiles", "fileList", "error", "reason", "uploadRejection", "rejectionMessage", "path", "result", "n", "_b", "_c", "_d", "estimateProgress", "v", "host", "u", "event", "img", "message", "limitReached", "after", "form", "id", "card", "before", "d", "download", "frame", "selected", "rejected", "total", "label", "modalStore", "csrfToken", "meta", "post", "url", "params", "body", "key", "track", "name", "seenUrl", "store", "forced", "el", "id", "self", "value", "previous", "context", "VIEWS_KEY", "SHOWN_KEY", "MODAL_ID", "appPageViews", "countAppPageView", "shownInThisTab", "markShownInThisTab", "event", "modalStore", "csrfToken", "meta", "post", "url", "params", "options", "body", "key", "el", "response", "data", "store", "step", "text", "nextStep", "SCRAPE_MS", "IMPORT_BASE_MS", "IMPORT_PER_PHOTO_MS", "I18N", "_a", "isOpen", "url", "s", "source", "i", "other", "sources", "requestUrl", "csrfToken", "done", "estimateProgress", "v", "scrapeResults", "scrapeUrl", "formData", "html", "dataEl", "metaEl", "selectedIndexes", "name", "urls", "createUrl", "res", "data", "SPECIAL_LETTERS", "COMBINING_MARKS", "UMLAUT_SPELLINGS", "URL_DELAY_MS", "fold", "text", "out", "ranges", "ch", "lower", "c", "plain", "p", "loosen", "folded", "src", "i", "searchable", "strict", "wordRanges", "name", "word", "form", "haystack", "needle", "found", "at", "mergeRanges", "sorted", "a", "b", "merged", "r", "last", "renderName", "el", "parts", "pos", "start", "end", "mark", "isTypingTarget", "root", "cards", "countTemplate", "emptyTemplate", "urlTimer", "card", "nameEl", "q", "words", "w", "shown", "item", "match", "url", "path", "event", "_a", "input", "initialStreet", "initialPostalCode", "initialCity", "apiKey", "key", "_a", "_b", "e", "resolve", "reject", "cb", "s", "q", "input", "suggestions", "suggestion", "place", "components", "route", "streetNumber", "component", "type", "d", "key", "fields", "finKey", "filled", "f", "el", "s", "_a", "t", "p", "raw", "value", "_b", "cold", "util", "val", "formData", "data", "el", "check", "boxes", "box", "event", "file", "rejection", "uploadRejection", "isHeic", "fileInput", "formData", "turnstileInput", "csrfToken", "uploadUrl", "response", "data", "widget"]
}
