Spaces:
Runtime error
Runtime error
Antigravity AI Agent commited on
Commit ·
9873f3c
1
Parent(s): e565aa7
Optimize document loading performance, make document info circular icon-only, align header button fonts, and move selection hint slightly down
Browse filesFiles changed (6)
42 unmodified lines434445464748493 unmodified lines5354555657585916 unmodified lines7677787980818255 unmodified lines13813914014114214314414514614742 unmodified lineselse:raise ValueError("Supported formats are JPG, PNG, WebP, PDF, and DOCX")self._cache[cache_key] = resultwhile len(self._cache) > 4:self._cache.popitem(last=False)return {**result, "cached": False}3 unmodified linesimage.load()except Exception as exc:raise ValueError("The uploaded image could not be opened") from excimage.thumbnail((1400, 1400), Image.Resampling.LANCZOS)prepared = ImageOps.autocontrast(image.convert("L")).filter(ImageFilter.SHARPEN).convert("RGB")detections = self.ocr.extract(prepared, language)terms = self.glossary.match_regions(detections)16 unmodified linescanvas_width = 0for index in range(page_count):page = document[index]zoom = min(1.5, 1100 / max(1, page.rect.width))pixmap = page.get_pixmap(matrix=fitz.Matrix(zoom, zoom), alpha=False)page_image = Image.frombytes("RGB", [pixmap.width, pixmap.height], pixmap.samples)rendered.append((page, page_image, zoom))55 unmodified linesreturn self._render_text(paragraphs)def _render_text(self, paragraphs: list[str]) -> dict:width, margin, line_height = 1400, 100, 42wrapped = []for paragraph in paragraphs:wrapped.extend(textwrap.wrap(paragraph, width=85, break_long_words=False) or [""])wrapped.append("")height = max(900, margin * 2 + len(wrapped) * line_height)image = Image.new("RGB", (width, height), "#ffffff")42 unmodified lines434445464748493 unmodified lines5354555657585916 unmodified lines7677787980818255 unmodified lines13813914014114214314414514614742 unmodified lineselse:raise ValueError("Supported formats are JPG, PNG, WebP, PDF, and DOCX")self._cache[cache_key] = resultwhile len(self._cache) > 16:self._cache.popitem(last=False)return {**result, "cached": False}3 unmodified linesimage.load()except Exception as exc:raise ValueError("The uploaded image could not be opened") from excimage.thumbnail((1000, 1000), Image.Resampling.BICUBIC)prepared = ImageOps.autocontrast(image.convert("L")).filter(ImageFilter.SHARPEN).convert("RGB")detections = self.ocr.extract(prepared, language)terms = self.glossary.match_regions(detections)16 unmodified linescanvas_width = 0for index in range(page_count):page = document[index]zoom = min(1.2, 800 / max(1, page.rect.width))pixmap = page.get_pixmap(matrix=fitz.Matrix(zoom, zoom), alpha=False)page_image = Image.frombytes("RGB", [pixmap.width, pixmap.height], pixmap.samples)rendered.append((page, page_image, zoom))55 unmodified linesreturn self._render_text(paragraphs)def _render_text(self, paragraphs: list[str]) -> dict:width, margin, line_height = 1000, 80, 36wrapped = []for paragraph in paragraphs:wrapped.extend(textwrap.wrap(paragraph, width=65, break_long_words=False) or [""])wrapped.append("")height = max(900, margin * 2 + len(wrapped) * line_height)image = Image.new("RGB", (width, height), "#ffffff")
1{}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997{"0e95b3fc1895805205a0926d": {"detected_terms": [],"unknown_terms": [],"ocr_items": [],"cached": false,"ocr_available": true,"quality": {"brightness": 138.98,"contrast": 45.3,"acceptable": true},"mean_ocr_confidence": 0.0,"suggest_vlm": true,"vlm_reasons": ["low_ocr_confidence"]},"6da67123e8a333c7a9651cc6": {"detected_terms": [{"term": "ameter","full_form": null,"definition": "This document phrase is not yet in the verified customs glossary. Select or highlight it for a contextual summary and business meaning.","definition_ar": null,"source": "ai_generated_unverified","source_label": "Contextual marker · needs verification","confidence": 0.586,"category": "Document Context","related_terms": [],"document_types": [],"match_type": "contextual_fallback","bbox": [337,680,393,709],"ocr_text": "ameter","ocr_confidence": 0.945,"language": "en"},{"term": "adingrenderngandcesingoped","full_form": null,"definition": "This document phrase is not yet in the verified customs glossary. Select or highlight it for a contextual summary and business meaning.","definition_ar": null,"source": "ai_generated_unverified","source_label": "Contextual marker · needs verification","confidence": 0.471,"category": "Document Context","related_terms": [],"document_types": [],"match_type": "contextual_fallback","bbox": [332,516,722,588],"ocr_text": "adingrenderngandcesingoped","ocr_confidence": 0.7595,"language": "en"},{"term": "ts.","full_form": null,"definition": "This document phrase is not yet in the verified customs glossary. Select or highlight it for a contextual summary and business meaning.","definition_ar": null,"source": "ai_generated_unverified","source_label": "Contextual marker · needs verification","confidence": 0.465,"category": "Document Context","related_terms": [],"document_types": [],"match_type": "contextual_fallback","bbox": [333,364,358,379],"ocr_text": "ts.","ocr_confidence": 0.75,"language": "en"}],"unknown_terms": [{"text": "ts.","bbox": [333,364,358,379],"confidence": 0.75,"language": "en"},{"text": "adingrenderngandcesingoped","bbox": [332,516,722,588],"confidence": 0.7595,"language": "en"},{"text": "ameter","bbox": [337,680,393,709],"confidence": 0.945,"language": "en"}],"ocr_items": [{"text": "ts.","bbox": [333,364,358,379],"confidence": 0.75,"language": "en"},{"text": "adingrenderngandcesingoped","bbox": [332,516,722,588],"confidence": 0.7595,"language": "en"},{"text": "ameter","bbox": [337,680,393,709],"confidence": 0.945,"language": "en"}],"cached": false,"ocr_available": true,"quality": {"brightness": 151.18,"contrast": 64.77,"acceptable": true},"mean_ocr_confidence": 0.818,"suggest_vlm": true,"vlm_reasons": ["unknown_terms"]},"e042c809964abcf690daf8af": {"detected_terms": [],"unknown_terms": [],"ocr_items": [],"cached": false,"ocr_available": true,"quality": {"brightness": 133.9,"contrast": 42.13,"acceptable": true},"mean_ocr_confidence": 0.0,"suggest_vlm": true,"vlm_reasons": ["low_ocr_confidence"]},"15f7a6e038b50173e2c6a697": {"detected_terms": [],"unknown_terms": [],"ocr_items": [],"cached": false,"ocr_available": true,"quality": {"brightness": 132.16,"contrast": 44.73,"acceptable": true},"mean_ocr_confidence": 0.0,"suggest_vlm": true,"vlm_reasons": ["low_ocr_confidence"]},"8283cb9892b926731b625631": {"detected_terms": [{"term": "111","full_form": null,"definition": "This document phrase is not yet in the verified customs glossary. Select or highlight it for a contextual summary and business meaning.","definition_ar": null,"source": "ai_generated_unverified","source_label": "Contextual marker · needs verification","confidence": 0.366,"category": "Document Context","related_terms": [],"document_types": [],"match_type": "contextual_fallback","bbox": [891,297,1045,516],"ocr_text": "111","ocr_confidence": 0.5911,"language": "en"}],"unknown_terms": [{"text": "111","bbox": [891,297,1045,516],"confidence": 0.5911,"language": "en"}],"ocr_items": [{"text": "111","bbox": [891,297,1045,516],"confidence": 0.5911,"language": "en"}],"cached": false,"ocr_available": true,"quality": {"brightness": 138.59,"contrast": 43.97,"acceptable": true},"mean_ocr_confidence": 0.591,"suggest_vlm": true,"vlm_reasons": ["low_ocr_confidence","unknown_terms"]},"853cd90c283c3e3226b26753": {"detected_terms": [],"unknown_terms": [{"text": "111","bbox": [902,304,1034,507],"confidence": 0.5188,"language": "en"}],"ocr_items": [{"text": "111","bbox": [902,304,1034,507],"confidence": 0.5188,"language": "en"}],"cached": false,"ocr_available": true,"quality": {"brightness": 138.3,"contrast": 43.64,"acceptable": true},"mean_ocr_confidence": 0.519,"suggest_vlm": true,"vlm_reasons": ["low_ocr_confidence","unknown_terms"]},"d2150ffb3575b91e32987c17": {"detected_terms": [{"term": "1三1","full_form": null,"definition": "This document phrase is not yet in the verified customs glossary. Select or highlight it for a contextual summary and business meaning.","definition_ar": null,"source": "ai_generated_unverified","source_label": "Contextual marker · needs verification","confidence": 0.38,"category": "Document Context","related_terms": [],"document_types": [],"match_type": "contextual_fallback","bbox": [881,293,1048,522],"ocr_text": "1三1","ocr_confidence": 0.6129,"language": "en"}],"unknown_terms": [{"text": "1三1","bbox": [881,293,1048,522],"confidence": 0.6129,"language": "en"}],"ocr_items": [{"text": "1三1","bbox": [881,293,1048,522],"confidence": 0.6129,"language": "en"}],"cached": false,"ocr_available": true,"quality": {"brightness": 138.89,"contrast": 44.23,"acceptable": true},"mean_ocr_confidence": 0.613,"suggest_vlm": true,"vlm_reasons": ["low_ocr_confidence","unknown_terms"]},"e513088e891adc71dbc94d45": {"detected_terms": [],"unknown_terms": [],"ocr_items": [],"cached": false,"ocr_available": true,"quality": {"brightness": 133.1,"contrast": 43.21,"acceptable": true},"mean_ocr_confidence": 0.0,"suggest_vlm": true,"vlm_reasons": ["low_ocr_confidence"]},"3dd120d6c5f618fd90579428": {"detected_terms": [{"term": "1三","full_form": null,"definition": "This document phrase is not yet in the verified customs glossary. Select or highlight it for a contextual summary and business meaning.","definition_ar": null,"source": "ai_generated_unverified","source_label": "Contextual marker · needs verification","confidence": 0.362,"category": "Document Context","related_terms": [],"document_types": [],"match_type": "contextual_fallback","bbox": [897,301,1040,510],"ocr_text": "1三","ocr_confidence": 0.584,"language": "en"}],"unknown_terms": [],"ocr_items": [{"text": "1三","bbox": [897,301,1040,510],"confidence": 0.584,"language": "en"}],"cached": false,"ocr_available": true,"quality": {"brightness": 138.5,"contrast": 44.11,"acceptable": true},"mean_ocr_confidence": 0.584,"suggest_vlm": true,"vlm_reasons": ["low_ocr_confidence"]},"0141543747f818612aeb7df8": {"detected_terms": [{"term": "1三1","full_form": null,"definition": "This document phrase is not yet in the verified customs glossary. Select or highlight it for a contextual summary and business meaning.","definition_ar": null,"source": "ai_generated_unverified","source_label": "Contextual marker · needs verification","confidence": 0.351,"category": "Document Context","related_terms": [],"document_types": [],"match_type": "contextual_fallback","bbox": [891,296,1047,517],"ocr_text": "1三1","ocr_confidence": 0.5656,"language": "en"}],"unknown_terms": [{"text": "1三1","bbox": [891,296,1047,517],"confidence": 0.5656,"language": "en"}],"ocr_items": [{"text": "1三1","bbox": [891,296,1047,517],"confidence": 0.5656,"language": "en"}],"cached": false,"ocr_available": true,"quality": {"brightness": 139.05,"contrast": 44.47,"acceptable": true},"mean_ocr_confidence": 0.566,"suggest_vlm": true,"vlm_reasons": ["low_ocr_confidence","unknown_terms"]},"ff1f2f282cc195ac99df68f5": {"detected_terms": [],"unknown_terms": [],"ocr_items": [],"cached": false,"ocr_available": true,"quality": {"brightness": 138.57,"contrast": 44.32,"acceptable": true},"mean_ocr_confidence": 0.0,"suggest_vlm": true,"vlm_reasons": ["low_ocr_confidence"]},"f0f39e6f92aefee8e0fbb041": {"detected_terms": [],"unknown_terms": [],"ocr_items": [],"cached": false,"ocr_available": true,"quality": {"brightness": 139.12,"contrast": 44.26,"acceptable": true},"mean_ocr_confidence": 0.0,"suggest_vlm": true,"vlm_reasons": ["low_ocr_confidence"]},"96cceefa6e6e2e37cfdfd309": {"detected_terms": [{"term": "1三","full_form": null,"definition": "This document phrase is not yet in the verified customs glossary. Select or highlight it for a contextual summary and business meaning.","definition_ar": null,"source": "ai_generated_unverified","source_label": "Contextual marker · needs verification","confidence": 0.373,"category": "Document Context","related_terms": [],"document_types": [],"match_type": "contextual_fallback","bbox": [887,295,1046,519],"ocr_text": "1三","ocr_confidence": 0.6024,"language": "en"}],"unknown_terms": [],"ocr_items": [{"text": "1三","bbox": [887,295,1046,519],"confidence": 0.6024,"language": "en"}],"cached": false,"ocr_available": true,"quality": {"brightness": 139.1,"contrast": 44.15,"acceptable": true},"mean_ocr_confidence": 0.602,"suggest_vlm": true,"vlm_reasons": ["low_ocr_confidence"]},"defda18eaae337eddf9822a9": {"detected_terms": [{"term": "1三1","full_form": null,"definition": "This document phrase is not yet in the verified customs glossary. Select or highlight it for a contextual summary and business meaning.","definition_ar": null,"source": "ai_generated_unverified","source_label": "Contextual marker · needs verification","confidence": 0.357,"category": "Document Context","related_terms": [],"document_types": [],"match_type": "contextual_fallback","bbox": [881,292,1051,521],"ocr_text": "1三1","ocr_confidence": 0.5759,"language": "en"}],"unknown_terms": [{"text": "1三1","bbox": [881,292,1051,521],"confidence": 0.5759,"language": "en"}],"ocr_items": [{"text": "1三1","bbox": [881,292,1051,521],"confidence": 0.5759,"language": "en"}],"cached": false,"ocr_available": true,"quality": {"brightness": 139.07,"contrast": 44.05,"acceptable": true},"mean_ocr_confidence": 0.576,"suggest_vlm": true,"vlm_reasons": ["low_ocr_confidence","unknown_terms"]},"300e046d915802ef6f512f94": {"detected_terms": [],"unknown_terms": [],"ocr_items": [],"cached": false,"ocr_available": true,"quality": {"brightness": 139.1,"contrast": 43.74,"acceptable": true},"mean_ocr_confidence": 0.0,"suggest_vlm": true,"vlm_reasons": ["low_ocr_confidence"]},"95a633507d3b8a3964209f26": {"detected_terms": [{"term": "1三1","full_form": null,"definition": "This document phrase is not yet in the verified customs glossary. Select or highlight it for a contextual summary and business meaning.","definition_ar": null,"source": "ai_generated_unverified","source_label": "Contextual marker · needs verification","confidence": 0.356,"category": "Document Context","related_terms": [],"document_types": [],"match_type": "contextual_fallback","bbox": [887,295,1047,519],"ocr_text": "1三1","ocr_confidence": 0.5744,"language": "en"}],"unknown_terms": [{"text": "1三1","bbox": [887,295,1047,519],"confidence": 0.5744,"language": "en"}],"ocr_items": [{"text": "1三1","bbox": [887,295,1047,519],"confidence": 0.5744,"language": "en"}],"cached": false,"ocr_available": true,"quality": {"brightness": 139.01,"contrast": 44.06,"acceptable": true},"mean_ocr_confidence": 0.574,"suggest_vlm": true,"vlm_reasons": ["low_ocr_confidence","unknown_terms"]},"1ddcb807d91281649cd6da3b": {"detected_terms": [],"unknown_terms": [],"ocr_items": [],"cached": false,"ocr_available": true,"quality": {"brightness": 136.82,"contrast": 44.26,"acceptable": true},"mean_ocr_confidence": 0.0,"suggest_vlm": true,"vlm_reasons": ["low_ocr_confidence"]},"f33009b49867b3f1798582c2": {"detected_terms": [{"term": "1三1","full_form": null,"definition": "This document phrase is not yet in the verified customs glossary. Select or highlight it for a contextual summary and business meaning.","definition_ar": null,"source": "ai_generated_unverified","source_label": "Contextual marker · needs verification","confidence": 0.345,"category": "Document Context","related_terms": [],"document_types": [],"match_type": "contextual_fallback","bbox": [888,295,1047,517],"ocr_text": "1三1","ocr_confidence": 0.5568,"language": "en"}],"unknown_terms": [{"text": "1三1","bbox": [888,295,1047,517],"confidence": 0.5568,"language": "en"}],"ocr_items": [{"text": "1三1","bbox": [888,295,1047,517],"confidence": 0.5568,"language": "en"}],"cached": false,"ocr_available": true,"quality": {"brightness": 136.17,"contrast": 44.99,"acceptable": true},"mean_ocr_confidence": 0.557,"suggest_vlm": true,"vlm_reasons": ["low_ocr_confidence","unknown_terms"]},"1de62820e32b893526936624": {"detected_terms": [],"unknown_terms": [],"ocr_items": [],"cached": false,"ocr_available": true,"quality": {"brightness": 143.55,"contrast": 49.45,"acceptable": true},"mean_ocr_confidence": 0.0,"suggest_vlm": true,"vlm_reasons": ["low_ocr_confidence"]},"3d4ec0f248af18826864842f": {"detected_terms": [{"term": "1三","full_form": null,"definition": "This document phrase is not yet in the verified customs glossary. Select or highlight it for a contextual summary and business meaning.","definition_ar": null,"source": "ai_generated_unverified","source_label": "Contextual marker · needs verification","confidence": 0.429,"category": "Document Context","related_terms": [],"document_types": [],"match_type": "contextual_fallback","bbox": [875,291,1050,526],"ocr_text": "1三","ocr_confidence": 0.6914,"language": "en"}],"unknown_terms": [],"ocr_items": [{"text": "1三","bbox": [875,291,1050,526],"confidence": 0.6914,"language": "en"}],"cached": false,"ocr_available": true,"quality": {"brightness": 145.56,"contrast": 49.52,"acceptable": true},"mean_ocr_confidence": 0.691,"suggest_vlm": true,"vlm_reasons": ["low_ocr_confidence"]},"cd6f9bef655c7a890b9b0d1b": {"detected_terms": [],"unknown_terms": [],"ocr_items": [],"cached": false,"ocr_available": true,"quality": {"brightness": 146.3,"contrast": 49.78,"acceptable": true},"mean_ocr_confidence": 0.0,"suggest_vlm": true,"vlm_reasons": ["low_ocr_confidence"]},"c9c9b2a7ce7ae6d3cf5c1505": {"detected_terms": [],"unknown_terms": [],"ocr_items": [],"cached": false,"ocr_available": true,"quality": {"brightness": 141.7,"contrast": 51.65,"acceptable": true},"mean_ocr_confidence": 0.0,"suggest_vlm": true,"vlm_reasons": ["low_ocr_confidence"]},"ef0e1fc649d5ec778700abbe": {"detected_terms": [],"unknown_terms": [],"ocr_items": [],"cached": false,"ocr_available": true,"quality": {"brightness": 148.26,"contrast": 44.34,"acceptable": true},"mean_ocr_confidence": 0.0,"suggest_vlm": true,"vlm_reasons": ["low_ocr_confidence"]},"8194dc3e783babc297c2c131": {"detected_terms": [],"unknown_terms": [],"ocr_items": [],"cached": false,"ocr_available": true,"quality": {"brightness": 144.38,"contrast": 46.51,"acceptable": true},"mean_ocr_confidence": 0.0,"suggest_vlm": true,"vlm_reasons": ["low_ocr_confidence"]},"68beff108bd3ff6547814e36": {"detected_terms": [],"unknown_terms": [],"ocr_items": [],"cached": false,"ocr_available": true,"quality": {"brightness": 148.65,"contrast": 44.4,"acceptable": true},"mean_ocr_confidence": 0.0,"suggest_vlm": true,"vlm_reasons": ["low_ocr_confidence"]},"77cc8f05db422267852bb514": {"detected_terms": [],"unknown_terms": [],"ocr_items": [],"cached": false,"ocr_available": true,"quality": {"brightness": 149.55,"contrast": 43.41,"acceptable": true},"mean_ocr_confidence": 0.0,"suggest_vlm": true,"vlm_reasons": ["low_ocr_confidence"]}}
217 unmodified lines218219220221222223224217 unmodified linesconst objectUrl = URL.createObjectURL(file);try {const image = await loadImage(objectUrl);const maxEdge = 1400;const scale = Math.min(1, maxEdge / Math.max(image.naturalWidth, image.naturalHeight));if (scale === 1 && file.size < 2 * 1024 * 1024) {return { base64: await readBase64(file), filename: file.name };217 unmodified lines218219220221222223224217 unmodified linesconst objectUrl = URL.createObjectURL(file);try {const image = await loadImage(objectUrl);const maxEdge = 1000;const scale = Math.min(1, maxEdge / Math.max(image.naturalWidth, image.naturalHeight));if (scale === 1 && file.size < 2 * 1024 * 1024) {return { base64: await readBase64(file), filename: file.name };
4 unmodified lines5678910111213141516171825 unmodified lines444546474849505117 unmodified lines6970717273744 unmodified lines<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover"><meta name="theme-color" content="#071a18"><title>FalconScan — Customs terms, made clear</title><link rel="stylesheet" href="/static/styles.css"></head><body><header><a class="brand" href="#" aria-label="FalconScan home"><span class="mark" aria-hidden="true"><span class="mark-f">F</span><span class="mark-s">S</span></span><span>FalconScan<small>Customs intelligence</small></span></a><div class="header-actions"><select id="language" aria-label="Definition language"><option value="en">English</option><option value="ar">العربية</option></select><button class="ghost" id="adminButton" aria-label="Open SME review queue">SME review <span id="reviewCount" class="count" hidden>0</span></button></div></header>25 unmodified lines<div id="statusPill" class="status-pill"><i></i><span>Camera off</span></div><div id="qualityPill" class="quality-pill">Waiting for camera</div><div id="selectionHint" class="selection-hint" hidden>Select or highlight document text for a live business insight</div><button id="documentInfo" class="document-info" type="button" aria-label="Summarize this document" hidden><span aria-hidden="true">i</span><b>Document info</b></button><button id="detailsToggle" class="details-toggle" aria-expanded="false" aria-controls="scanDetails"><span>Scan details</span><i aria-hidden="true">⌃</i></button></div><aside id="scanDetails" class="control-panel" aria-hidden="true"><button id="detailsClose" class="details-close" aria-label="Close scan details">×</button>17 unmodified lines<div id="adminModal" class="modal" aria-hidden="true"><div class="admin-card" role="dialog" aria-modal="true"><button class="close" data-close="adminModal">×</button><p class="eyebrow">KNOWLEDGE GOVERNANCE</p><h2>SME correction review</h2><p class="muted">Approve suggestions to make them the official definition.</p><div id="adminList" class="admin-list"></div></div></div><div id="insightModal" class="modal" aria-hidden="true"><div class="insight-card" role="dialog" aria-modal="true" aria-labelledby="insightTitle"><button id="insightClose" class="close" aria-label="Close insight">×</button><p class="eyebrow">LIVE DOCUMENT INSIGHT</p><h2 id="insightTitle">Selection insight</h2><blockquote id="insightSelection"></blockquote><section><small>SUMMARY</small><p id="insightSummary"></p></section><section><small>BUSINESS MEANING</small><p id="insightBusiness"></p></section><div id="insightTerms" class="insight-terms"></div><div class="definition-meta"><span id="insightSource"></span><span id="insightConfidence"></span></div></div></div><div id="toast" class="toast"></div><script src="/static/insights.js" defer></script><script src="/static/overlay.js" defer></script><script src="/static/feedback.js" defer></script><script src="/static/camera.js" defer></script></body></html>4 unmodified lines5678910111213141516171825 unmodified lines444546474849505117 unmodified lines6970717273744 unmodified lines<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover"><meta name="theme-color" content="#071a18"><title>FalconScan — Customs terms, made clear</title><link rel="stylesheet" href="/static/styles.css?v=1.1"></head><body><header><a class="brand" href="#" aria-label="FalconScan home"><span class="mark" aria-hidden="true"><span class="mark-f">F</span><span class="mark-s">S</span></span><span>FalconScan<small>Customs intelligence</small></span></a><div class="header-actions"><select id="language" aria-label="Definition language"><option value="en">English</option><option value="ar">العربية</option></select><button class="ghost" id="adminButton" aria-label="Open SME review queue">SME Review <span id="reviewCount" class="count" hidden>0</span></button></div></header>25 unmodified lines<div id="statusPill" class="status-pill"><i></i><span>Camera off</span></div><div id="qualityPill" class="quality-pill">Waiting for camera</div><div id="selectionHint" class="selection-hint" hidden>Select or highlight document text for a live business insight</div><button id="documentInfo" class="document-info" type="button" aria-label="Summarize this document" hidden><span aria-hidden="true">i</span></button><button id="detailsToggle" class="details-toggle" aria-expanded="false" aria-controls="scanDetails"><span>Scan</span><i aria-hidden="true">⌃</i></button></div><aside id="scanDetails" class="control-panel" aria-hidden="true"><button id="detailsClose" class="details-close" aria-label="Close scan details">×</button>17 unmodified lines<div id="adminModal" class="modal" aria-hidden="true"><div class="admin-card" role="dialog" aria-modal="true"><button class="close" data-close="adminModal">×</button><p class="eyebrow">KNOWLEDGE GOVERNANCE</p><h2>SME correction review</h2><p class="muted">Approve suggestions to make them the official definition.</p><div id="adminList" class="admin-list"></div></div></div><div id="insightModal" class="modal" aria-hidden="true"><div class="insight-card" role="dialog" aria-modal="true" aria-labelledby="insightTitle"><button id="insightClose" class="close" aria-label="Close insight">×</button><p class="eyebrow">LIVE DOCUMENT INSIGHT</p><h2 id="insightTitle">Selection insight</h2><blockquote id="insightSelection"></blockquote><section><small>SUMMARY</small><p id="insightSummary"></p></section><section><small>BUSINESS MEANING</small><p id="insightBusiness"></p></section><div id="insightTerms" class="insight-terms"></div><div class="definition-meta"><span id="insightSource"></span><span id="insightConfidence"></span></div></div></div><div id="toast" class="toast"></div><script src="/static/insights.js?v=1.1" defer></script><script src="/static/overlay.js?v=1.1" defer></script><script src="/static/feedback.js?v=1.1" defer></script><script src="/static/camera.js?v=1.1" defer></script></body></html>
123 unmodified lines124125126127128129130131132133123 unmodified linesfunction triggerDotAtText(event, region, layout) {const selection = window.getSelection();if (selection && !selection.isCollapsed && selection.toString().trim()) return;const existingMarkers = [...overlay.querySelectorAll(".term-marker")];if (existingMarkers.length >= 3) {(overlay.querySelector(".term-marker.user-triggered") || existingMarkers[existingMarkers.length - 1]).remove();}const match = terms.find((item) =>item.bbox?.every((value, index) => Math.abs(value - region.bbox[index]) < 2)|| String(region.text).toLowerCase().includes(String(item.term).toLowerCase())123 unmodified lines124125126127128129130123 unmodified linesfunction triggerDotAtText(event, region, layout) {const selection = window.getSelection();if (selection && !selection.isCollapsed && selection.toString().trim()) return;overlay.querySelectorAll(".term-marker").forEach(m => m.remove());const match = terms.find((item) =>item.bbox?.every((value, index) => Math.abs(value - region.bbox[index]) < 2)|| String(region.text).toLowerCase().includes(String(item.term).toLowerCase())
64 unmodified lines656667686970108 unmodified lines1791801811821831841852 unmodified lines188189190191192193194195196256 unmodified lines45345445545645745845964 unmodified linesmin-height: 38px; border: 1px solid var(--line);background: rgba(255, 255, 255, 0.05); border-radius: 11px;padding: 7px 9px; color: var(--ink);transition: border-color 0.2s, background 0.2s;}.header-actions select:hover, .ghost:hover {108 unmodified lines}.selection-hint {position: absolute; z-index: 3; left: 50%; bottom: 58px; transform: translateX(-50%);max-width: calc(100% - 32px); padding: 7px 12px; background: rgba(14, 23, 21, 0.86);color: var(--ink); border: 1px solid var(--line); border-radius: 99px;backdrop-filter: blur(12px); font-size: 9px; font-weight: 650; text-align: center;2 unmodified lines.selection-hint[hidden] { display: none; }.document-info {position: absolute; z-index: 5; right: 12px; top: 14px; display: flex; align-items: center; gap: 7px;min-height: 40px; border: 1px solid rgba(255, 255, 255, 0.15); padding: 7px 11px 7px 7px;background: rgba(14, 23, 21, 0.85); color: white; border-radius: 99px;backdrop-filter: blur(16px); pointer-events: auto; transition: background 0.2s, border-color 0.2s;}.document-info:hover {256 unmodified lines.admin-card { width: min(800px, 100%); border-radius: 18px; padding: 30px; }.insight-card { width: min(600px, 100%); border-radius: 18px; padding: 30px; }.definition-meta { display: flex; justify-content: space-between; }.document-info b { display: block; }.toast { left: 50%; right: auto; width: max-content; max-width: 90vw; transform: translate(-50%, 20px); }.toast.show { transform: translate(-50%, 0); }}64 unmodified lines65666768697071108 unmodified lines1801811821831841851862 unmodified lines189190191192193194195196197256 unmodified lines45445545645745845964 unmodified linesmin-height: 38px; border: 1px solid var(--line);background: rgba(255, 255, 255, 0.05); border-radius: 11px;padding: 7px 9px; color: var(--ink);font-family: inherit; font-size: 12px; font-weight: 500;transition: border-color 0.2s, background 0.2s;}.header-actions select:hover, .ghost:hover {108 unmodified lines}.selection-hint {position: absolute; z-index: 3; left: 50%; bottom: 46px; transform: translateX(-50%);max-width: calc(100% - 32px); padding: 7px 12px; background: rgba(14, 23, 21, 0.86);color: var(--ink); border: 1px solid var(--line); border-radius: 99px;backdrop-filter: blur(12px); font-size: 9px; font-weight: 650; text-align: center;2 unmodified lines.selection-hint[hidden] { display: none; }.document-info {position: absolute; z-index: 5; right: 28px; top: 20px; display: grid; place-items: center;width: 40px; height: 40px; border: 1px solid rgba(255, 255, 255, 0.15); padding: 0;background: rgba(14, 23, 21, 0.85); color: white; border-radius: 50%;backdrop-filter: blur(16px); pointer-events: auto; transition: background 0.2s, border-color 0.2s;}.document-info:hover {256 unmodified lines.admin-card { width: min(800px, 100%); border-radius: 18px; padding: 30px; }.insight-card { width: min(600px, 100%); border-radius: 18px; padding: 30px; }.definition-meta { display: flex; justify-content: space-between; }.toast { left: 50%; right: auto; width: max-content; max-width: 90vw; transform: translate(-50%, 20px); }.toast.show { transform: translate(-50%, 0); }}
backend/document_service.py+5-5
data/ocr_cache.json+997-1
frontend/camera.js+1-1
frontend/index.html+5-5
frontend/overlay.js+1-4
frontend/styles.css+5-5