From dd8f9a49c4d78a4cb4c44323429153f4a78fe1d4 Mon Sep 17 00:00:00 2001 From: HeuJung Date: Tue, 8 Sep 2026 16:45:09 +0900 Subject: [PATCH] =?UTF-8?q?fix(core,template):=20=ED=8E=B8=EC=A7=91?= =?UTF-8?q?=EA=B8=B0=20image=20=EC=9C=84=EC=A0=AF=20=EA=B0=92=20=ED=98=95?= =?UTF-8?q?=ED=83=9C=C2=B7=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=97=B0=EA=B2=B0?= =?UTF-8?q?=20=EA=B0=92=20=EB=B3=B4=ED=98=B8=C2=B7=EC=83=81=EC=86=8D=20?= =?UTF-8?q?=EB=85=B8=EB=93=9C=20=ED=8E=B8=EC=A7=91=20=ED=91=9C=EB=A9=B4=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 공개 는 헤더 「로고 이미지」에 이미지를 지정하면 화면이 엑박이 되는 제보였다. image 위젯은 배경용으로 설계되어 {url,size,repeat,position} 객체를 내보내는데, 값 슬롯이 하나뿐인 apply 경로(propValue/cssVar/단일 styleProp)가 그 객체를 그대로 props 에 기록해 소비 컴포넌트가 [object Object] 를 URL 로 받았다. 예외도 콘솔 오류도 서버 로그도 남지 않는다 — 깨진 이미지 요청은 SPA catch-all 때문에 404 조차 아니라 200(HTML)이고, 편집기 미리보기는 정상이라 조작 중에는 이상이 보이지 않는다. 방어선을 넷으로 세웠다. 쓰기 축약(공용 헬퍼 scalarizeImageValue 단일 지점, 게이트는 위젯 이름이며 값 형태 sniffing 이 아니다) · 읽기 역조립(표현식 문자열도 되감아 업로드 1클릭에 소실되지 않게 한다) · 런타임 방어(업그레이드 전 화면을 위해 템플릿 Img 가 url 을 해석하고 손상값이면 src 를 아예 붙이지 않는다) · 저장 데이터 백필(업그레이드 스텝). 런타임과 백필은 완전히 같은 엄격 판정식(키 집합 ⊆ 4키 AND url 보유)을 쓴다 — 엔진의 느슨한 판정식을 백필에 이식하면 레이아웃 전수에서 정상 props 2,219건을 파괴한다(실측). 전수조사에서 파생한 인접 결함 넷을 함께 고쳤다. - number 위젯이 코어 레지스트리에 미등록이라 「탭 표시 게시판 수」 같은 컨트롤이 「지원하지 않는 컨트롤」로 폴백해 편집 자체가 불가했다. nodeKey apply 는 coreProps 가 선언만 하고 엔진 switch 에 case 가 없어 무음 no-op 이었다. - 상속(base)·주입(extension) 노드 중 바인딩을 가진 것이 data_bound 로 분류돼 편집이 열려 있었는데, 저장 마스킹이 그 노드를 통째로 폐기하므로 편집분이 오류도 경고도 없이 사라졌다(저장은 200 이고 history 는 clear 돼 undo 도 불가). 출처 잠금이 항상 우선하도록 판정 순서를 통일하고, 단일 판정 헬퍼로 인라인 편집·복제·Delete·잘라내기·드래그 commit 까지 전 표면을 같은 기준으로 막았다. - prop 자리의 표현식 값을 위젯이 해석하지 못해 빈 컨트롤로 보이고, 조작하는 순간 환경설정 과의 연결이 소리 없이 끊겼다. 판정·배지·잠금·해제·복구를 ControlRenderer 공용 게이트 한 곳으로 올려 신규 위젯에도 자동 적용되게 했다. 「직접 지정으로 바꾸기」에는 「되돌리기」를 동반해 편도가 되지 않게 한다. - 편집기 모드에서 updateTemplateData 가 빈 레이아웃으로 같은 reactRoot 에 두 번째 커밋을 걸어 편집기 트리를 통째로 제거했다. renderTemplate 의 편집기 분기가 비동기라 부팅 중 setGlobalState 가 그 커밋 뒤에 도착할 때만 발현하는 경합이었다. --- AGENTS.md | 51 ++ CHANGELOG.md | 5 + docs/extension/editor-spec.md | 20 +- lang-packs/_bundled/g7-core-ja/CHANGELOG.md | 2 + .../frontend/partial/layout_editor.json | 8 + lang/partial/en/layout_editor.json | 8 + lang/partial/ko/layout_editor.json | 8 + public/build/core/layout-editor.min.js | 12 +- public/build/core/template-engine.min.js | 59 +- ...plate-engine.layoutEditorRerender.test.tsx | 190 +++++ resources/js/core/template-engine.ts | 17 + .../js/core/template-engine/CHANGELOG.md | 37 + .../ControlRenderer.boundValueGuard.test.tsx | 145 ++++ .../components/DndCanvasLayer.test.tsx | 143 ++++ ...itorCanvasOverlay.entryPointGuard.test.tsx | 203 +++++ ...itorCanvasOverlay.sourceLockGuard.test.tsx | 290 ++++++++ .../PropertyEditorModal.propsTab.test.tsx | 41 +- .../components/property-controls.test.tsx | 275 +++++++ .../__tests__/hooks/useCanvasDnd.test.ts | 114 ++- .../useElementSelection.normalize.test.tsx | 60 ++ .../hooks/useElementSelection.test.ts | 160 +++- .../__tests__/spec/coreProps.dataKey.test.ts | 17 + .../__tests__/spec/recipeEngine.test.ts | 336 +++++++++ .../__tests__/spec/widgetRegistry.test.ts | 8 + .../components/DndCanvasLayer.tsx | 40 +- .../components/EditorCanvasOverlay.tsx | 28 +- .../property-controls/ControlRenderer.tsx | 57 +- .../property-controls/ImagePickerControl.tsx | 178 ++++- .../property-controls/StyleControlWidgets.tsx | 86 +++ .../property-controls/boundValueGuard.tsx | 193 +++++ .../layout-editor/hooks/useCanvasDnd.ts | 84 ++- .../hooks/useElementSelection.ts | 68 +- .../layout-editor/spec/coreProps.ts | 20 +- .../layout-editor/spec/recipeEngine.ts | 182 ++++- .../layout-editor/spec/registerCoreWidgets.ts | 5 + .../layout-editor/spec/specTypes.ts | 14 + .../layout-editor/utils/layoutTreeUtils.ts | 33 + templates/_bundled/sirsoft-basic/AGENTS.md | 2 +- templates/_bundled/sirsoft-basic/CHANGELOG.md | 1 + .../sirsoft-basic/dist/js/components.iife.js | 22 +- .../src/components/basic/Img.tsx | 32 + .../components/basic/__tests__/Img.test.tsx | 116 +++ ...Upgrade7011ImageObjectPropBackfillTest.php | 698 ++++++++++++++++++ .../sirsoft-basic.e2e_sandbox.json | 8 + .../image-widget-value-shape.spec.ts | 377 ++++++++++ ...ayout-editor-image-widget-value-shape.yaml | 127 ++++ upgrades/Upgrade_7_0_11.php | 37 + .../01_NarrowImageObjectPropsInLayouts.php | 360 +++++++++ 48 files changed, 4784 insertions(+), 193 deletions(-) create mode 100644 resources/js/core/__tests__/template-engine.layoutEditorRerender.test.tsx create mode 100644 resources/js/core/template-engine/layout-editor/__tests__/components/ControlRenderer.boundValueGuard.test.tsx create mode 100644 resources/js/core/template-engine/layout-editor/__tests__/components/EditorCanvasOverlay.entryPointGuard.test.tsx create mode 100644 resources/js/core/template-engine/layout-editor/__tests__/components/EditorCanvasOverlay.sourceLockGuard.test.tsx create mode 100644 resources/js/core/template-engine/layout-editor/components/property-controls/boundValueGuard.tsx create mode 100644 templates/_bundled/sirsoft-basic/src/components/basic/__tests__/Img.test.tsx create mode 100644 tests/Feature/Upgrades/Upgrade7011ImageObjectPropBackfillTest.php create mode 100644 tests/Playwright/specs/layout-editor/image-widget-value-shape.spec.ts create mode 100644 tests/scenarios/layout-editor-image-widget-value-shape.yaml create mode 100644 upgrades/Upgrade_7_0_11.php create mode 100644 upgrades/data/7.0.11/migrations/01_NarrowImageObjectPropsInLayouts.php diff --git a/AGENTS.md b/AGENTS.md index 49a6d729..ae6c844c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -278,6 +278,57 @@ | `"item"`, `"index"` | `"item_var"`, `"index_var"` | | iteration 내 if 순서 무시 | if가 iteration보다 먼저 평가됨 | +### 위젯 값 형태 ↔ apply 경로 + +편집기 위젯 중 **값이 스칼라가 아닌 것**(`image` → `{url,size,repeat,position}` 객체)을 값 슬롯이 하나뿐인 apply 경로에 연결하면, 객체가 그대로 `props[key]` 에 저장되어 소비 컴포넌트가 `[object Object]` 를 URL 로 받는다. 이 결함은 예외도 콘솔 오류도 서버 로그도 남기지 않는다 — 깨진 이미지 요청은 SPA catch-all 때문에 404 조차 아니라 **200(HTML)** 이고, 편집기 위젯의 미리보기는 정상이라 조작 중에는 이상이 보이지 않는다. 화면의 엑박이 유일한 증상이다. + +| ❌ 금지 | ✅ 올바른 사용 | +|--------|---------------| +| `image` 위젯을 `classToken`·`cssVar` 에 연결하거나 `apply` 를 생략 | 값이 스칼라로 축약되는 경로만 — `propValue`(맨 url 문자열) 또는 `backgroundImage` 를 포함한 `styleProp` 묶음(4속성 분해) | +| 축약 판정을 **값 형태 sniffing** 으로 게이트 | `widget === 'image'` 게이트 — `isImageValueObject` 는 4키 중 **하나만** 있어도 참이라 `props.tooltip = {position:'left'}` 같은 정당한 객체 prop 을 이미지로 오인해 삭제한다 | +| 축약 분기를 writer 마다 복붙 | 공용 헬퍼 `scalarizeImageValue` 단일 지점 — 이번 결함의 원인이 정확히 "방어가 `applyStyleProp` 안에만 있었다" 이다 | +| 쓰기만 축약하고 읽기는 그대로 | `propValue` 역해석이 저장 문자열을 `{url}` 로 되감는다. **표현식 문자열도 감싼다** — 감싸지 않으면 빈 피커로 보이고 업로드 1클릭에 그 표현식이 소리 없이 소실된다 | +| 저장되지 않는 컨트롤을 `disabled` 로 남김 | 단일 값 슬롯이면 표시모드 버튼을 **컨테이너째 미렌더** — `disabled` 는 *일시적* 비활성의 시각 언어라 "URL 을 넣으면 살아나겠지" 라는 거짓 정보를 준다 | +| 저장되지 않는 `size` 를 미리보기에 반영 | 단일 슬롯 미리보기는 `contain` 고정 — 실제 표시 방식은 소비 컴포넌트의 클래스가 정하므로 편집기가 흉내내면 거짓 미리보기다 | +| 코어 엔진의 느슨한 판정식을 **백필**에 이식 | 백필·런타임 방어는 **엄격 판정식**(키 집합 ⊆ 4키 **AND** `url` 키 존재). 느슨한 판정식은 레이아웃 전수에서 2,219건을 매치하고 그 대부분이 정상 props 다(`{className,name,size}` 674건 · `{name,size}` 552건) — 엄격 판정식의 매치는 0건이었다 | +| 백필 순회 범위를 **노드 키 allowlist** 로 정의 | `props` 키 진입 시 모드 ON / `style` 키 진입 시 OFF 인 **모드 플래그 전역 재귀** — 실측상 `props` 안에 컴포넌트 노드가 1,150건 살아 allowlist 는 원리상 완결 불가다 | +| 두 방어선(런타임 `Img` / 백필)의 판정 강도를 따로 정함 | 완전히 같은 엄격도 — 어긋나면 한쪽만 통과하는 값이 생긴다 | + +> 상세: [editor-spec.md](docs/extension/editor-spec.md) "controls — 재사용 스타일 컨트롤" +> 정적 검사가 두 축을 함께 본다 — editor-spec 선언과 코어 엔진의 축약 분기 실존. 선언 축만 보면 코어 분기가 삭제돼도 통과하는데 결함은 부활한다. 기설치본 보정은 DB 데이터 상태라 정적 검사 대상이 아니며, 업그레이드 스텝의 회귀 테스트가 그 축을 잠근다 + +### 편집기 컨트롤의 데이터 연결 값 보호 + +레이아웃의 prop 자리에는 `{{_global.settings?.general?.site_logo_url}}` 같은 **표현식 문자열**이 저장돼 있을 수 있다. 위젯은 그 값을 해석하지 못해 **빈 컨트롤**로 보이고, 조작하는 순간 그 연결이 사라진다 — 값 하나가 아니라 **환경설정과의 연결**이 끊기고, 원문이 화면 어디에도 남지 않아 되돌릴 수단조차 없다. 예외도 콘솔 오류도 남지 않는다. + +| ❌ 금지 | ✅ 올바른 사용 | +|--------|---------------| +| 바인딩 판정·배지·잠금을 위젯마다 구현 | `ControlRenderer` 의 **공용 게이트 한 곳** — 새 위젯을 등록해도 자동 적용된다 | +| 해제 경로 없이 잠그기만 | 「직접 지정으로 바꾸기」로 **명시적으로만** 연다 | +| 「직접 지정으로 바꾸기」를 편도로 두기 | 「되돌리기」 동반 — 해제 직후엔 취소로, 값을 이미 넣은 뒤엔 원문 복구로 동작한다 | +| 파괴적 조작 표면 중 일부만 잠그기 | 그 위젯의 **전 표면** — 업로드·제거·목록 선택뿐 아니라 **관리 모달 진입**까지. 같은 동작이 두 곳에 렌더되면 하나만 잠근 것은 판단이 아니라 누락이다 | +| 위젯이 자체 처리를 가지면서 공용 게이트도 통과 | 둘 중 하나 — 자체 처리 위젯은 제외 목록에 등재하고, 그 위젯이 **원문 표시·해제·복구 셋을 모두** 제공하는지 확인한다 | +| 자체 분기가 공용 해제 경로를 막음 | 해제된 뒤에는 위젯이 평소대로 편집 가능해야 한다 | +| 해석 못 하는 값을 위젯이 흉내내 표시 | 원문 배지로 대체 — 흉내내면 거짓 컨트롤이다 | + +> 상세: [editor-spec.md](docs/extension/editor-spec.md) "데이터 연결 값 보호" + +### 상속·주입 노드의 편집 표면 + +저장 마스킹(`stripInheritedFromLayoutContent`)은 상속(base)·주입(extension) 출처 노드를 **정상 저장에서도 항상 폐기**한다. 그래서 그 노드를 편집할 수 있게 열어 두면 편집분이 오류도 경고도 없이 사라진다 — 저장은 200 으로 성공하고 `history.clear()` 로 undo 도 불가능하다. + +| ❌ 금지 | ✅ 올바른 사용 | +|--------|---------------| +| 잠금 판정에 편집 모드 예외를 둠 (`editMode !== 'route' && isNodeLocked(...)`) | 출처 잠금이 `data_bound` 보다 **항상 우선** — "route 는 종전 동작을 한 줄도 바꾸지 않는다" 는 계약이 아니라 보수성 선언이었고, 그 보수성이 곧 결함이었다 | +| `data_bound` 의 **의미**를 좁혀 해결 | 의미는 그대로 두고(= 편집 가능, 텍스트만 잠금) **어느 노드가 그렇게 분류되는가**만 좁힌다 — 형제 경로(DnD·오버레이)가 그 계약에 실제로 의존한다 | +| 게이트 조건을 표면마다 복사 | 단일 판정 헬퍼 `isEditableLockKind` / `resolveDndDenial` 만 호출 — 한 곳만 빠져도 같은 소실 결함이 재발한다 | +| ⓘ 메뉴와 드래그 핸들만 막고 끝냄 | 인라인 편집(더블클릭)·복제·키보드 `Delete`·잘라내기까지 전 표면 — 키보드 경로는 ⓘ 메뉴를 거치지 않아 무방비였다 | +| 드래그 거부를 `zone === null` 에 기댄 간접 방어로 | commit 직전 최종 가드 — stale 슬롯이나 유효 zone 이 들어오면 그대로 이동 commit 된다 | +| 거부된 드래그가 `activeDragPath` 를 남김 | 거부 시 즉시 비운다 — 남으면 DragOverlay 가 잡힌 노드를 따라다녀 "옮길 수 있다" 는 거짓 어포던스를 준다 | +| 조상 산출 구현을 파일마다 복제 | `collectAncestors` 단일 출처 — 잠금 판정의 입력이 갈리면 "핸들은 있는데 드래그는 거부" 같은 어긋남이 조용히 생긴다 | + +차단된 노드에는 「🔒 공통 레이아웃 편집」·「🔒 확장 편집」 진입 어포던스가 대신 뜬다. 상속 노드의 「데이터 영역」 라벨은 사라지지만 후자가 행동 가능한 정보이므로 순증이다. + ### 컴포넌트 Props | 금지 | 올바른 사용 | diff --git a/CHANGELOG.md b/CHANGELOG.md index 56625848..cf86678b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,11 @@ - 업데이트 진행 중 판정이 명령줄에서 실행될 때만 커맨드 이름을 참고하도록 좁혔습니다. 일부 PHP 설정(`register_argc_argv` 활성)에서는 웹 주소의 쿼리만으로 업데이트가 진행 중인 것처럼 보이게 할 수 있었습니다. - 레이아웃 편집기에서 올린 배경 이미지의 주소가 「공개 자산 스토리지」 설정과 무관하게 항상 사이트 서버를 거쳐 전달되던 문제를 수정했습니다. 파일은 설정한 저장소에 정상 저장되지만 방문자 요청은 매번 사이트 서버가 저장소에서 받아 다시 내보내고 있어, CDN 을 쓰도록 설정해도 그 효과를 볼 수 없었습니다. 이제 「공개 자산 스토리지」를 지정하면 그 저장소에 올라간 배경 이미지가 저장소 주소로 직접 전달됩니다. 설정하지 않은 경우와 설정 이전에 올린 이미지는 종전과 똑같이 동작합니다. (#134 @lyg-kaban 님께서 제보해주셨습니다.) - 확장이 카테고리별로 다른 저장소를 쓰도록 설정했을 때, 확장 개발용 파일 주소·경로 조회가 그 설정을 반영하지 않고 언제나 기본 저장소를 보던 문제를 수정했습니다. +- 화면 편집기에서 로고처럼 이미지 주소를 직접 받는 항목에 이미지를 지정하면 그림이 깨져 보이던 문제를 수정했습니다. 지정한 주소 대신 알 수 없는 값이 저장된 것이 원인이며, 편집기 화면에서는 미리보기가 정상으로 보여 저장 전에는 알아챌 수 없었습니다. 이제 주소가 그대로 저장되고, 이미 잘못 저장된 사이트도 업데이트하면 자동으로 정정됩니다. 업데이트 전에도 화면은 정상 표시됩니다. (#135 @lyg-kaban 님께서 제보해주셨습니다.) +- 화면 편집기의 「탭 표시 게시판 수」처럼 숫자를 받는 항목이 「지원하지 않는 컨트롤」로 표시되어 편집할 수 없던 문제를 수정했습니다. 이제 숫자 입력칸이 나타납니다. +- 화면 편집기에서 공통 레이아웃이나 확장이 넣은 요소를 고쳐도 저장되지 않던 문제를 수정했습니다. 편집은 되는데 저장 후 되돌아가 있었고 실행 취소로도 되살릴 수 없었습니다. 이제 그런 요소는 편집 대신 「공통 레이아웃 편집」·「확장 편집」 진입 안내가 표시되며, 옮기기·복제·삭제도 같은 기준으로 막힙니다. +- 화면 편집기가 열리자마자 빈 화면이 되는 경우가 있던 문제를 수정했습니다. 편집기가 잠깐 보였다가 사라졌고, 새로고침에 따라 나타났다 사라졌다 했습니다. +- 화면 편집기에서 환경설정과 연결된 항목(예: 헤더 로고)을 무심코 조작하면 그 연결이 소리 없이 끊기던 문제를 수정했습니다. 이제 그런 항목은 연결된 값이라는 안내와 원래 값이 표시되고, 「직접 지정으로 바꾸기」를 눌러야 편집할 수 있으며 「되돌리기」로 언제든 원래 연결로 복구할 수 있습니다. ## [7.0.10] - 2026-09-06 diff --git a/docs/extension/editor-spec.md b/docs/extension/editor-spec.md index 4e4a5b3a..23f22514 100644 --- a/docs/extension/editor-spec.md +++ b/docs/extension/editor-spec.md @@ -134,15 +134,31 @@ php artisan {module|plugin|template}:update {id} --force ### controls — 재사용 스타일 컨트롤 -위젯 종류(`widget`)·친화 라벨(`label`)·적용 방식(`apply`)·대상(`target`)·선택지(`options`)를 한 곳에 선언하고 `componentCapabilities.styleControls`(스타일 탭) 또는 `propControls`(속성 탭)가 키로 참조한다. `apply` 타입은 `classToken`(클래스 토큰 교체) / `styleProp`(인라인 스타일 속성) / `cssVar` / `propValue`(임의 `node.props[propKey]` 기입 — 속성 탭의 기본 적용 방식). 색·크기 등 라이브러리 대응 컨트롤은 프리셋 토큰 + 자유값(tokenTemplate)을 함께 선언한다. 상/우/하/좌 여백처럼 측마다 다른 값이 공존하는 속성은 다값을 1급으로 다룬다(일괄/개별 2모드, 단일 토큰 교체 금지). +위젯 종류(`widget`)·친화 라벨(`label`)·적용 방식(`apply`)·대상(`target`)·선택지(`options`)를 한 곳에 선언하고 `componentCapabilities.styleControls`(스타일 탭) 또는 `propControls`(속성 탭)가 키로 참조한다. `apply` 타입은 `classToken`(클래스 토큰 교체) / `styleProp`(인라인 스타일 속성) / `cssVar` / `propValue`(임의 `node.props[propKey]` 기입 — 속성 탭의 기본 적용 방식) / `nodeKey`(노드 **최상위** 구조키 `node[nodeKey]` 기입 — `dataKey` 처럼 런타임 엔진이 props 가 아니라 노드 자신에서 읽는 키. `props`·`children`·`type` 등 예약 구조키는 지정해도 무시되고, 디바이스(breakpoint) 축은 무시하며 항상 최상위에 쓴다 — 런타임 responsive 병합은 `props`/`children`/`text`/`if`/`iteration` 5키만 보므로 분기에 쓰면 영원히 읽히지 않는다). 색·크기 등 라이브러리 대응 컨트롤은 프리셋 토큰 + 자유값(tokenTemplate)을 함께 선언한다. 상/우/하/좌 여백처럼 측마다 다른 값이 공존하는 속성은 다값을 1급으로 다룬다(일괄/개별 2모드, 단일 토큰 교체 금지). **`propControls` 전용 위젯 종류**: - `icon-picker` — 아이콘 prop(예 `iconName`/`triggerIcon`)을 카탈로그 그리드에서 검색·선택한다. **카탈로그는 템플릿 소유**(라이브러리 종속) — Font Awesome 등 아이콘셋을 쓰는 템플릿이 `G7Core.layoutEditor.registerWidget('icon-picker', ...)` 로 자기 위젯을 등록한다(코어는 위젯명만 디스패치, 아이콘 라이브러리 토큰 0). 프리뷰 폴백은 `preview.html`(코어 비해석) → `preview.className` → raw value 순. 카탈로그 미공급 시 자유 텍스트 입력으로 디그레이드. - `options-list` — `Select`/`RadioGroup` 등의 정적 `options` 배열(value/label 행)을 추가/삭제/이동 편집한다. 값이 `{{바인딩}}` 이면 "바인딩됨(코드 편집)" 디그레이드(덮어쓰기 차단). 데이터소스 바인딩(dataProps `options`)과 직교 공존(위 "선택지 직교 완화"). - `array-items` / `array-group` / `array-cell-tree` / `number-list` — 정적 배열 prop 편집(탭/차트 데이터/카드 컬럼 등). `nodeEditor` 슬롯 또는 propControl 로 결선한다(아래 "데이터 정의 빌트인" 참조). +- `number` — 숫자를 기대하는 prop(예 `maxVisibleBoards`)을 편집한다. 위젯이 `number` 타입을 직접 내보내므로 `"5"` 같은 문자열이 저장되지 않는다. 빈 입력은 prop 삭제, `0` 은 유효값이라 삭제되지 않으며, 숫자로 해석할 수 없는 입력은 방출하지 않아 저장본을 보존한다(조용한 변조 금지). `min`/`max`/`step` 은 선언만 하고 **클램프하지 않는다** — 사용자가 넣은 값은 그대로 보존한다. 값이 `{{바인딩}}` 문자열일 때의 보호는 위젯이 아니라 아래 「데이터 연결 값 보호」 공용 게이트가 맡는다 — 숫자 입력칸이 그 값을 빈칸으로 표시해 다음 blur 에 소실시키는 것을 그 게이트가 차단한다. - `i18n-text` vs `text` — **표시 텍스트**(사용자가 화면에서 읽는 라벨/메시지/플레이스홀더)는 `i18n-text` 를 쓴다. `i18n-text` 는 평문 입력 시 `createCustomKey` 로 다국어 키를 자동 생성해 `$t:custom.*` 로 치환하고(미리보기에 raw 키 미노출), 🌐 펼침으로 ko/en/ja 동시 편집을 제공하며, `{{바인딩}}` 값이면 읽기전용 디그레이드한다(공통 위젯 `I18nTextField`). **비-표시값**(URL/id/수치/색/통화코드/separator 등)만 `text` 를 쓴다. 표시 텍스트에 `text` 를 쓰면 raw `$t:` 노출·다국어 누락 회귀가 발생한다(정적 검사가 배열 라벨 필드의 `text` 사용을 차단). +**데이터 연결 값 보호 — 모든 위젯 공통**: +prop 자리에 `{{...}}` 표현식이나 설정 참조가 저장돼 있으면, 그 값을 편집하는 컨트롤은 **원문 배지**로 디그레이드된다. 위젯은 그 문자열을 해석하지 못해 빈 컨트롤로 보이고, 그 상태에서 조작하면 표현식이 그대로 덮여 **환경설정과의 연결이 끊기기** 때문이다. 이 판정은 개별 위젯이 아니라 컨트롤 렌더러 한 곳에서 이뤄지므로 **새 위젯을 등록해도 자동 적용**된다 — 위젯 안에 같은 판정을 다시 넣지 않는다(넣으면 해제 경로까지 막혀 「직접 지정으로 바꾸기」가 무반응이 된다). + +보호 상태에서는 그 컨트롤의 파괴적 조작이 함께 잠긴다. 값을 바꾸려면 「직접 지정으로 바꾸기」를 눌러 명시적으로 열고, 「되돌리기」로 원래 연결값을 복구할 수 있다(해제 직후에는 취소, 값을 넣은 뒤에는 복구로 동작). + +예외는 표현식 자체를 다루도록 설계된 위젯뿐이다 — `text`·`i18n-text` 는 표현식을 데이터 칩으로 **분해해 보여 주는 것**이 그 위젯의 기능이고, `image`·`core-id` 는 같은 보호를 위젯 안에서 더 세밀하게(갤러리·업로드·관리 모달 진입까지) 제공한다. 새 위젯을 이 예외에 넣으려면 **원문 표시·해제·복구 셋을 모두** 갖춰야 한다. + +**`image` 위젯의 값 형태 — apply 경로에 따라 축약된다**: + +`image` 위젯은 배경 이미지용으로 설계되어 `{url, size, repeat, position}` **객체**를 내보낸다. 그런데 값 슬롯이 하나뿐인 apply 경로(`propValue` / `cssVar` / 단일 `styleProp`)는 그 객체를 담을 수 없다 — 엔진이 `url` 만 남겨 스칼라로 축약한다(컴포넌트 prop 은 맨 문자열, CSS 값 문맥은 `url(...)` 래핑). `url` 이 없거나 비어 있으면 그 자리를 삭제해 컴포넌트의 폴백이 살아난다. + +축약을 전제로 위젯 표면도 달라진다 — 단일 값 슬롯 컨트롤에서는 표시모드(채움/맞춤/타일) 버튼이 **렌더되지 않는다**(`size`/`repeat`/`position` 을 저장할 자리가 없어 눌러도 저장되지 않는 죽은 컨트롤이다). 4속성을 모두 저장하려면 `styleProp` 의 `props` 배열에 `backgroundImage`·`backgroundSize`·`backgroundRepeat`·`backgroundPosition` 을 함께 선언한다. + +`image` 를 `classToken` 이나 `cssVar` 에 연결하거나 `apply` 를 생략하면 값이 문자열로 축약될 경로가 없어 `[object Object]` 가 저장된다 — 정적 검사가 그 선언을 차단한다. + ### componentCapabilities — 컴포넌트별 편집 역량 컴포넌트별로 `propControls`(속성 탭 컨트롤 화이트리스트 — `controls.json` 의 `apply.type==="propValue"` 컨트롤 참조, 비-스타일 prop 편집) / `dataProps`(데이터 연결 선언 — 아래) / `styleControls`(스타일 탭 컨트롤 화이트리스트) / `advanced`(고급 속성) / `events`(액션 편집 이벤트 — 미선언 시 동작 탭 숨김) / `flexEditor`(`container`/`item`/`auto` — 정렬 박스 편집 역할) / `visibilityCondition`(표시조건 탭 허용 여부) / `nodeEditor`·`canvasOverlay`(구조 에디터 일반 슬롯 `{kind,params}` — 종류별 고정 키 금지, kind 핸들러 레지스트리 디스패치)을 선언한다. @@ -172,6 +188,8 @@ php artisan {module|plugin|template}:update {id} --force **코어 제공 속성(요소 ID) + opt-out**: 코어는 모든 draggable 컴포넌트의 [속성] 탭 최상단에 "요소 ID" 컨트롤을 일괄 제공한다(값 = 표준 `node.props.id`, 강제 DOM 주입 없음 — 컴포넌트 passthrough 책임). 기존 `elemId`(→id) 같은 템플릿 propControl 은 코어로 이전(중복 선언 금지 — 코어 우선). 인라인 루트가 없는 컴포넌트(서드파티 모달/Portal)는 capability 에 `"coreProps": false` 로 opt-out 한다. `"coreProps": ["id"]` 처럼 부분집합 선언도 가능(미선언 = 코어 기본 전체). 코어 id 컨트롤은 `{{바인딩}}` 값이면 "바인딩됨(코드 편집)" 디그레이드, HTML 안전 문자만 허용(한글·공백 자동 제거). 컴포넌트 측 id passthrough 규약은 `docs/frontend/components-types.md` "요소 id 패스스루" 참조. +**전용 UI 를 가진 코어 속성은 `coreProps` 로 다시 선언하지 않는다**: `isolatedState`·`isolatedScopeId` 는 편집기가 별도 전용 컨트롤로 제공하며 그것이 값의 단일 출처다. 이 두 키를 `coreProps` 배열에 적어도 [속성] 탭의 일반 컨트롤 목록에는 나타나지 않는다 — 같은 값을 두 경로가 쓰면 값 형태가 갈리기 때문이다(전용 UI 는 켜짐 상태를 객체로 쓰는데 일반 토글 위젯은 `true` 를 낸다). 선언 자체는 오류가 아니고 조용히 무시되므로, 격리 설정을 노출하려면 그 전용 컨트롤을 쓴다. + ### nesting — 중첩 규칙 `draggable`(드래그/팔레트 배치 가능한 컴포넌트 이름) + `containers`(컨테이너별 `accepts` 자식 허용 목록). 병합 시 `draggable` 은 union, `containers` 는 key 병합. `accepts: []` 는 명시적 자식 거부, 엔트리 없는 컴포넌트는 어떤 자식도 받지 않는다(폴백 없음). diff --git a/lang-packs/_bundled/g7-core-ja/CHANGELOG.md b/lang-packs/_bundled/g7-core-ja/CHANGELOG.md index bfb41ed9..31d3cbee 100644 --- a/lang-packs/_bundled/g7-core-ja/CHANGELOG.md +++ b/lang-packs/_bundled/g7-core-ja/CHANGELOG.md @@ -10,6 +10,8 @@ - 로그인 시도가 많아 잠시 차단될 때의 안내와, 본인인증 화면에서 로그인용 인증 요청을 처리할 수 없다는 안내의 일본어 번역을 추가했습니다. - 레이아웃 편집기 [화면 동작] 탭의 「인증번호 확인」·「인증번호 다시 받기」 항목 이름의 일본어 번역을 추가했습니다. +- 레이아웃 편집기에서 환경설정과 연결된 항목에 표시되는 안내와 「직접 지정으로 바꾸기」·「데이터 연결로 되돌리기」 버튼의 일본어 번역을 추가했습니다. +- 레이아웃 편집기 숫자 입력 항목의 입력 자리 표시 문구의 일본어 번역을 추가했습니다. ## [1.0.9] - 2026-09-06 diff --git a/lang-packs/_bundled/g7-core-ja/frontend/partial/layout_editor.json b/lang-packs/_bundled/g7-core-ja/frontend/partial/layout_editor.json index 98906894..e6181b48 100644 --- a/lang-packs/_bundled/g7-core-ja/frontend/partial/layout_editor.json +++ b/lang-packs/_bundled/g7-core-ja/frontend/partial/layout_editor.json @@ -322,6 +322,9 @@ "mode_tile": "タイル", "upload_failed": "画像アップロードに失敗しました" }, + "number": { + "placeholder": "数値を入力" + }, "dimension": { "placeholder": "例: 320px, 50%, 24rem, auto" }, @@ -335,6 +338,11 @@ "right": "右", "bottom": "下", "left": "左" + }, + "bound_value": { + "notice": "データ連携の値です(自動で入ります)", + "replace": "直接指定に変更", + "restore": "データ連携に戻す" } }, "recipe": { diff --git a/lang/partial/en/layout_editor.json b/lang/partial/en/layout_editor.json index 6d1590ca..c008a9d6 100644 --- a/lang/partial/en/layout_editor.json +++ b/lang/partial/en/layout_editor.json @@ -343,6 +343,9 @@ "mode_tile": "Tile", "upload_failed": "Image upload failed" }, + "number": { + "placeholder": "Enter a number" + }, "dimension": { "placeholder": "e.g. 320px, 50%, 24rem, auto" }, @@ -356,6 +359,11 @@ "right": "Right", "bottom": "Bottom", "left": "Left" + }, + "bound_value": { + "notice": "Bound to data (filled automatically)", + "replace": "Replace with a fixed value", + "restore": "Restore the data binding" } }, "recipe": { diff --git a/lang/partial/ko/layout_editor.json b/lang/partial/ko/layout_editor.json index af4b72ef..2b425b79 100644 --- a/lang/partial/ko/layout_editor.json +++ b/lang/partial/ko/layout_editor.json @@ -343,6 +343,9 @@ "mode_tile": "타일", "upload_failed": "이미지 업로드에 실패했습니다" }, + "number": { + "placeholder": "숫자 입력" + }, "dimension": { "placeholder": "예: 320px, 50%, 24rem, auto" }, @@ -356,6 +359,11 @@ "right": "오른쪽", "bottom": "아래", "left": "왼쪽" + }, + "bound_value": { + "notice": "데이터 연결 값입니다(자동으로 채워집니다)", + "replace": "직접 지정으로 바꾸기", + "restore": "데이터 연결로 되돌리기" } }, "recipe": { diff --git a/public/build/core/layout-editor.min.js b/public/build/core/layout-editor.min.js index 8adad1d7..36534a72 100644 --- a/public/build/core/layout-editor.min.js +++ b/public/build/core/layout-editor.min.js @@ -1,13 +1,13 @@ -var OM=Object.defineProperty;var BM=(dn,i,u)=>i in dn?OM(dn,i,{enumerable:!0,configurable:!0,writable:!0,value:u}):dn[i]=u;var Ni=(dn,i,u)=>BM(dn,typeof i!="symbol"?i+"":i,u);(function(dn,i,u,Cn){"use strict";function Lt(){const e=typeof window<"u"?window.G7Core?.__runtime:void 0;if(!e)throw new Error("[layout-editor] window.G7Core.__runtime 이 없습니다. 코어 번들(template-engine.min.js)이 편집기 번들보다 먼저 로드되어야 합니다.");return e}const Mi=Lt();Mi.TranslationProvider;const tt=Mi.useTranslation;Mi.TranslationReactContext;function rt(){return typeof window>"u"?null:window.__g7Devtools??null}function Il(e,t){const n=rt();if(!n?.trackEditorState)return;const o={templateIdentifier:e.templateIdentifier,editMode:e.editMode,selectedRoutePath:e.selectedRoute?.path??null,selectedLayoutName:e.selectedRoute?.layoutName??null,routeTreeSize:e.routeTree.length,isRouteTreeCollapsed:e.isRouteTreeCollapsed,locale:e.locale,previewDevice:e.previewDevice,previewZoom:e.previewZoom,lastAction:t,timestamp:Date.now()};try{n.trackEditorState(o)}catch{}}function Zh(){const e=rt();if(e?.clearEditorStateData)try{e.clearEditorStateData()}catch{}}function Qh(e){const t=rt();if(t?.trackEditorSampleMatch)try{t.trackEditorSampleMatch(e)}catch{}}function Rh(){const e=rt();if(e?.clearEditorSampleData)try{e.clearEditorSampleData()}catch{}}function ey(e){const t=rt();if(t?.trackEditorHistoryEntry)try{t.trackEditorHistoryEntry(e)}catch{}}function ty(){const e=rt();if(e?.clearEditorHistoryData)try{e.clearEditorHistoryData()}catch{}}function Al(e){const t=rt();if(t?.trackEditorSelection)try{t.trackEditorSelection(e)}catch{}}function ny(){const e=rt();if(e?.clearEditorSelectionData)try{e.clearEditorSelectionData()}catch{}}function dr(e){const t=rt();if(t?.trackEditorPropertyPatch)try{t.trackEditorPropertyPatch(e)}catch{}}function $n(e){const t=rt();if(t?.trackEditorDnd)try{t.trackEditorDnd(e)}catch{}}function oy(){const e=rt();if(e?.clearEditorDndData)try{e.clearEditorDndData()}catch{}}function st(e){const t=rt();if(t?.trackEditorDocument)try{t.trackEditorDocument(e)}catch{}}function ry(){const e=rt();if(e?.clearEditorDocumentData)try{e.clearEditorDocumentData()}catch{}}function iy(e){const t=rt();if(t?.trackEditorSpecMerge)try{t.trackEditorSpecMerge(e)}catch{}}function sy(){const e=rt();if(e?.clearEditorSpecMergeData)try{e.clearEditorSpecMergeData()}catch{}}function Li(e){let t=5381;for(let n=0;n>>0;return t}function Et(e){const t=rt();if(t?.trackEditorI18n)try{t.trackEditorI18n(e)}catch{}}function ay(){const e=rt();if(e?.clearEditorI18nData)try{e.clearEditorI18nData()}catch{}}function Tl(e){const t=rt();if(t?.trackPageState)try{t.trackPageState(e)}catch{}}function ly(){const e=rt();if(e?.clearPageStateData)try{e.clearPageStateData()}catch{}}const Dl="g7le.routeTree.collapsed";function dy(){if(typeof window>"u")return!1;try{return window.localStorage?.getItem(Dl)==="1"}catch{return!1}}function cy(e){if(!(typeof window>"u"))try{window.localStorage?.setItem(Dl,e?"1":"0")}catch{}}function uy(e,t){return{templateIdentifier:e,routeTree:[],routesError:null,selectedRoute:null,isRouteTreeCollapsed:dy(),editMode:"route",returnRoute:null,returnEditMode:null,locale:t,previewDevice:"desktop",previewZoom:1,previewCustomWidth:1024,previewColorScheme:"light",history:{canUndo:!1,canRedo:!1},isPaletteOpen:!1,availableStates:[],activeStateId:null,layoutVersions:{},extensionVersions:{}}}function py(e,t){switch(t.type){case"SET_ROUTE_TREE":return{...e,routeTree:t.tree,routesError:null};case"SET_ROUTES_ERROR":return{...e,routesError:t.error};case"SELECT_ROUTE":return{...e,editMode:"route",selectedRoute:t.route,returnRoute:null,returnEditMode:null};case"TOGGLE_ROUTE_TREE":return{...e,isRouteTreeCollapsed:!e.isRouteTreeCollapsed};case"SET_LOCALE":return{...e,locale:t.locale};case"ENTER_BASE_EDIT":return{...e,editMode:"base",returnRoute:t.returnRoute!==void 0?t.returnRoute:e.selectedRoute,selectedRoute:{path:`__base__/${t.layoutName}`,layoutName:t.layoutName}};case"EXIT_BASE_EDIT":return{...e,editMode:"route",selectedRoute:e.returnRoute,returnRoute:null};case"ENTER_MODAL_EDIT":return{...e,editMode:"modal",returnRoute:t.returnRoute!==void 0?t.returnRoute:e.selectedRoute,selectedRoute:{path:`__modal__/${t.modalId}`,layoutName:t.hostLayout}};case"EXIT_MODAL_EDIT":return{...e,editMode:"route",selectedRoute:e.returnRoute,returnRoute:null};case"ENTER_EXTENSION_EDIT":return{...e,editMode:"extension",returnRoute:t.returnRoute!==void 0?t.returnRoute:e.selectedRoute,selectedRoute:{path:`__extension__/${t.extensionId}`,layoutName:t.extensionHost??null}};case"SET_RETURN_ROUTE":return e.editMode==="route"||e.returnRoute!==null?e:{...e,returnRoute:t.route};case"EXIT_EXTENSION_EDIT":return{...e,editMode:"route",selectedRoute:e.returnRoute,returnRoute:null};case"ENTER_ITERATION_ITEM_EDIT":return{...e,editMode:"iteration_item",returnRoute:t.returnRoute!==void 0?t.returnRoute:e.selectedRoute,returnEditMode:e.editMode,selectedRoute:{path:`__iteration__/${t.sourcePath}`,layoutName:t.hostLayout??e.selectedRoute?.layoutName??null}};case"EXIT_ITERATION_ITEM_EDIT":return{...e,editMode:e.returnEditMode??"route",selectedRoute:e.returnRoute,returnRoute:null,returnEditMode:null};case"SET_PREVIEW_DEVICE":return{...e,previewDevice:t.device};case"SET_PREVIEW_ZOOM":return{...e,previewZoom:t.zoom};case"SET_PREVIEW_CUSTOM_WIDTH":return{...e,previewCustomWidth:t.width};case"SET_PREVIEW_COLOR_SCHEME":return{...e,previewColorScheme:t.scheme};case"TOGGLE_PALETTE":return{...e,isPaletteOpen:!e.isPaletteOpen};case"SET_PALETTE_OPEN":return{...e,isPaletteOpen:t.open};case"SET_AVAILABLE_STATES":return{...e,availableStates:t.states,activeStateId:t.activeStateId};case"SET_ACTIVE_STATE":return{...e,activeStateId:t.activeStateId};case"SET_LAYOUT_VERSIONS":return{...e,layoutVersions:t.versions};case"SET_LAYOUT_VERSION":return{...e,layoutVersions:{...e.layoutVersions,[t.layoutName]:t.version}};case"SET_EXTENSION_VERSIONS":return{...e,extensionVersions:t.versions};case"SET_EXTENSION_VERSION":return{...e,extensionVersions:{...e.extensionVersions,[t.extensionId]:t.version}};default:return e}}function fy(e,t){const n=py(e,t);return((n.selectedRoute?.path??null)!==(e.selectedRoute?.path??null)||n.editMode!==e.editMode)&&(n.availableStates.length>0||n.activeStateId!==null)?{...n,availableStates:[],activeStateId:null}:n}const zl=u.createContext(null);function gy(e,t){const n=fy(e,t);return Il(n,t.type),n}function hy({templateIdentifier:e,initialLocale:t,children:n}){const[o,r]=u.useReducer(gy,void 0,()=>{const a=uy(e,t);return Il(a,void 0),a});u.useEffect(()=>{cy(o.isRouteTreeCollapsed)},[o.isRouteTreeCollapsed]);const s=u.useMemo(()=>({state:o,dispatch:r}),[o]);return u.createElement(zl.Provider,{value:s},n)}function Qe(){const e=u.useContext(zl);if(!e)throw new Error("useLayoutEditor must be used within LayoutEditorProvider");return e}const Nl=u.createContext(null);function yy({value:e,children:t}){return u.createElement(Nl.Provider,{value:e},t)}function Ft(){return u.useContext(Nl)}const Pi=u.createContext(null);let by=1;function my({children:e,t}){const[n,o]=u.useState([]),r=u.useRef([]),[s,a]=u.useState({}),l=u.useCallback(y=>{const _=y.id??`editor-modal-${by++}`,w={id:_,content:y.content,ariaLabel:y.ariaLabel??"",closeOnBackdrop:y.closeOnBackdrop??!0,closeOnEscape:y.closeOnEscape??!0,width:y.width??"auto",height:y.height??"auto",maxHeightRatio:y.maxHeightRatio??.85,draggable:y.draggable??!1,avoidRect:y.avoidRect,onClose:y.onClose};return o(k=>{const $=[...k.filter(S=>S.id!==_),w];return r.current=$,$}),_},[]),d=u.useCallback(y=>{o(_=>{const w=_.find(x=>x.id===y),k=_.filter(x=>x.id!==y);return r.current=k,w?.onClose&&queueMicrotask(()=>w.onClose?.()),k})},[]),c=u.useCallback(()=>{const y=r.current[r.current.length-1];y&&d(y.id)},[d]),p=u.useCallback(()=>{o(y=>{for(let _=y.length-1;_>=0;_--){const w=y[_];w?.onClose&&queueMicrotask(()=>w.onClose?.())}return r.current=[],[]})},[]),f=u.useCallback((y,_)=>{a(w=>{const k=r.current.find($=>$.id===y),x=_??k?.ariaLabel??"";return{...w,[y]:x}})},[]),b=u.useCallback(y=>{a(_=>{if(!(y in _))return _;const w={..._};return delete w[y],w})},[]),g=u.useCallback(y=>{b(y),d(y)},[b,d]),m=u.useCallback(()=>{a({}),p()},[p]),h=u.useMemo(()=>Object.keys(s),[s]),v=u.useMemo(()=>({open:l,close:g,closeTop:c,closeAll:m,stack:n,minimize:f,restore:b,minimizedStack:h}),[l,g,c,m,n,f,b,h]);return u.createElement(Pi.Provider,{value:v},e,u.createElement(_y,{minimized:s,onRestore:b,t,key:"__min_bar"}))}function bo(){const e=u.useContext(Pi);if(!e)throw new Error("useEditorModal must be used within EditorModalProvider");return e}function vy(){const e=u.useContext(Pi);if(!e)return null;const{stack:t,close:n,minimizedStack:o}=e,r=u.useMemo(()=>new Set(o),[o]);return u.useEffect(()=>{if(t.length===0)return;const s=a=>{if(a.key!=="Escape"&&a.key!=="Esc")return;const l=t.filter(c=>!r.has(c.id)),d=l[l.length-1];d?.closeOnEscape&&(a.preventDefault(),a.stopPropagation(),n(d.id))};return window.addEventListener("keydown",s,!0),()=>window.removeEventListener("keydown",s,!0)},[t,n,r]),t.length===0?null:i.jsx(i.Fragment,{children:t.map((s,a)=>i.jsx(wy,{entry:s,depth:a,hidden:r.has(s.id),onClose:()=>n(s.id)},s.id))})}function _y({minimized:e,onRestore:t,t:n}){const o=n??(s=>s),r=Object.keys(e);return r.length===0?null:i.jsx("div",{className:"g7le-minimized-bar","data-testid":"g7le-minimized-bar",style:{position:"fixed",left:16,bottom:16,display:"flex",gap:8,zIndex:9300},children:r.map(s=>i.jsxs("button",{type:"button","data-testid":`g7le-minimized-${s}`,onClick:()=>t(s),style:{display:"flex",alignItems:"center",gap:6,padding:"8px 12px",background:"#1e293b",color:"#fff",border:"none",borderRadius:8,boxShadow:"0 8px 24px rgba(15, 23, 42, 0.3)",cursor:"pointer",fontSize:13},children:[i.jsx("span",{"aria-hidden":"true",children:"🗗"}),i.jsx("span",{children:e[s]||o("layout_editor.modal.minimized_default")}),i.jsx("span",{style:{opacity:.7},children:o("layout_editor.modal.restore")})]},s))})}function xy(e,t,n){if(!e||typeof window>"u")return null;const o=window.innerWidth,r=window.innerHeight,s=16,a=e.left,l=o-(e.left+e.width),d=t+s;let c;if(l>=a&&l>=d)c=e.left+e.width+s;else if(a>=d)c=Math.max(s,e.left-s-t);else return null;c=Math.min(Math.max(s,c),Math.max(s,o-t-s));let p=e.top;return p=Math.min(Math.max(s,p),Math.max(s,r-n-s)),{left:c,top:p}}const Ml="clamp(16px, 6vh, 56px)";function wy({entry:e,depth:t,hidden:n,onClose:o}){const r=9100+t*10,s=e.maxHeightRatio>0?`${e.maxHeightRatio*100}vh`:void 0,a=e.draggable?s:`calc(100vh - (${Ml}) * 2)`,[l,d]=u.useState(null),c=u.useRef(null),p=u.useRef(null);u.useEffect(()=>{if(!e.draggable)return;const v=c.current;if(!v)return;const y=v.getBoundingClientRect(),_=xy(e.avoidRect,y.width,y.height);_&&d(_)},[e.id,e.draggable]);const f=u.useCallback(v=>{if(!e.draggable)return;const y=v.target;if(!y.closest("[data-modal-drag-handle]")||y.closest("button, a, input, textarea, select"))return;const w=c.current,k=w?.getBoundingClientRect(),x=l?.left??k?.left??0,$=l?.top??k?.top??0;p.current={startX:v.clientX,startY:v.clientY,baseLeft:x,baseTop:$};const S=T=>{const E=p.current;if(!E)return;const A=window.innerWidth,N=window.innerHeight,D=w?.offsetWidth??0,B=w?.offsetHeight??0;let M=E.baseLeft+(T.clientX-E.startX),O=E.baseTop+(T.clientY-E.startY);M=Math.min(Math.max(0,M),Math.max(0,A-D)),O=Math.min(Math.max(0,O),Math.max(0,N-B)),d({left:M,top:O})},C=()=>{p.current=null,window.removeEventListener("pointermove",S),window.removeEventListener("pointerup",C)};window.addEventListener("pointermove",S),window.addEventListener("pointerup",C)},[e.draggable,l]),b=v=>{e.closeOnBackdrop&&v.target===v.currentTarget&&o()},g=e.draggable&&l!==null,m=e.draggable?{position:"fixed",inset:0,background:"transparent",pointerEvents:"none",zIndex:r,...n?{display:"none"}:{}}:{position:"fixed",inset:0,background:"rgba(15, 23, 42, 0.45)",display:n?"none":"flex",alignItems:"flex-start",justifyContent:"center",paddingTop:Ml,boxSizing:"border-box",zIndex:r},h={background:"#fff",borderRadius:10,boxShadow:"0 20px 60px rgba(15, 23, 42, 0.25)",width:e.width,height:e.height,maxHeight:a,maxWidth:"92vw",overflow:"hidden",display:"flex",flexDirection:"column",...e.draggable?{position:"absolute",pointerEvents:"auto",left:g?l.left:"50%",top:g?l.top:"50%",transform:g?void 0:"translate(-50%, -50%)"}:{}};return i.jsx("div",{className:"g7le-modal-backdrop",role:"presentation","data-testid":`g7le-modal-backdrop-${e.id}`,"data-draggable":e.draggable?"true":"false",onClick:b,style:m,children:i.jsx("div",{ref:c,className:"g7le-modal",role:"dialog","aria-modal":"true","aria-label":e.ariaLabel||void 0,"data-testid":`g7le-modal-${e.id}`,"data-positioned":g?"true":"false",onClick:v=>v.stopPropagation(),onPointerDown:e.draggable?f:void 0,style:h,children:e.content})})}function ht({baseStyle:e,hoverStyle:t,disabled:n,style:o,children:r,...s}){const[a,l]=u.useState(!1),d={outline:"none",...e,...o,...a&&!n?t:{}};return i.jsx("button",{type:"button",disabled:n,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:d,...s,children:r})}function ky({templateIdentifier:e,templateName:t,templateVersion:n,templateList:o,onSwitch:r}){const{t:s}=tt(),[a,l]=u.useState(!1),[d,c]=u.useState(!1),p=u.useRef(null);u.useEffect(()=>{if(!a)return;const v=_=>{p.current&&!p.current.contains(_.target)&&l(!1)},y=_=>{_.key==="Escape"&&l(!1)};return document.addEventListener("mousedown",v),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("keydown",y)}},[a]);const f=o??[],b=f.some(v=>v.identifier!==e),g=!!r&&b,m=t||e,h=v=>{if(v===e){l(!1);return}l(!1),r?.(v)};return i.jsxs("div",{ref:p,className:"g7le-toolbar__template-switcher",style:{position:"relative",display:"inline-flex"},children:[i.jsxs("button",{type:"button",className:"g7le-toolbar__template","data-testid":"g7le-toolbar-template-label","data-can-switch":g?"true":"false","aria-haspopup":g?"listbox":void 0,"aria-expanded":g?a:void 0,disabled:!g,onClick:()=>g&&l(v=>!v),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),title:g?s("layout_editor.chrome.toolbar.switch_template"):m,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"4px 8px",fontSize:13,fontWeight:600,color:"#0f172a",letterSpacing:.1,borderRadius:6,borderWidth:1,borderStyle:"solid",borderColor:g&&(d||a)?"#cbd5e1":"transparent",backgroundColor:g&&(d||a)?"#f1f5f9":"transparent",cursor:g?"pointer":"default",outline:"none",transition:"background-color 120ms, border-color 120ms"},children:[i.jsx("span",{className:"g7le-toolbar__template-name","data-testid":"g7le-toolbar-template-name",children:m}),n&&i.jsxs("span",{className:"g7le-toolbar__template-version","data-testid":"g7le-toolbar-template-version",style:{fontSize:11,fontWeight:500,color:"#64748b",padding:"1px 6px",borderRadius:999,background:"#f1f5f9",border:"1px solid #e2e8f0"},children:["v",n]}),g&&i.jsx("span",{className:"g7le-toolbar__template-caret","aria-hidden":"true",style:{fontSize:9,color:"#94a3b8",marginLeft:1},children:"▼"})]}),g&&a&&i.jsx("div",{className:"g7le-toolbar__template-menu","data-testid":"g7le-toolbar-template-menu",role:"listbox",style:{position:"absolute",top:"calc(100% + 4px)",left:0,minWidth:240,maxWidth:360,maxHeight:360,overflowY:"auto",background:"#ffffff",border:"1px solid #e2e8f0",borderRadius:8,boxShadow:"0 8px 24px rgba(15, 23, 42, 0.14)",zIndex:30,padding:4},children:f.map(v=>{const y=v.identifier===e;return i.jsxs("button",{type:"button",role:"option","aria-selected":y,"aria-current":y?"true":void 0,className:"g7le-toolbar__template-menu-item","data-testid":"g7le-toolbar-template-menu-item","data-identifier":v.identifier,"data-current":y?"true":"false",onClick:()=>h(v.identifier),style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,width:"100%",padding:"8px 10px",fontSize:13,color:"#1e293b",background:y?"#eff6ff":"transparent",border:"none",borderRadius:6,cursor:y?"default":"pointer",textAlign:"left",outline:"none"},onMouseEnter:_=>{y||(_.currentTarget.style.background="#f1f5f9")},onMouseLeave:_=>{_.currentTarget.style.background=y?"#eff6ff":"transparent"},children:[i.jsxs("span",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[i.jsx("span",{"aria-hidden":"true",style:{width:12,flex:"0 0 auto",color:"#2563eb",fontSize:12,textAlign:"center"},children:y?"✓":""}),i.jsxs("span",{style:{display:"flex",flexDirection:"column",gap:2,minWidth:0},children:[i.jsx("span",{style:{fontWeight:600,color:y?"#1d4ed8":"#1e293b",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:v.name||v.identifier}),i.jsx("span",{style:{fontSize:11,color:"#94a3b8",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:v.identifier})]})]}),i.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,flex:"0 0 auto"},children:[i.jsx("span",{style:{fontSize:10,fontWeight:600,color:v.type==="admin"?"#7c3aed":"#0891b2",textTransform:"uppercase",letterSpacing:.4},children:v.type}),v.version&&i.jsxs("span",{style:{fontSize:11,color:"#64748b"},children:["v",v.version]})]})]},v.identifier)})})]})}function Sy(e={}){const{onSave:t,isDirty:n=!1,onExit:o,onEditCode:r,onManageImages:s,onManageTranslations:a,onPageSettings:l,onReset:d,onShowShortcuts:c,onPreview:p,onShowVersions:f,templateName:b,templateVersion:g,templateList:m,onSwitchTemplate:h,onToggleCustomAssets:v,customAssetsDisabled:y=!1,onManageCustomAssets:_}=e,[w,k]=u.useState(!1),[x,$]=u.useState(!1),{t:S}=tt(),{state:C,dispatch:T}=Qe(),[E,A]=u.useState(null);u.useEffect(()=>{const K=()=>{const Z=window.__g7LayoutEditorHistory;A(Z?{undo:Z.undo,redo:Z.redo,canUndo:!!Z.canUndo,canRedo:!!Z.canRedo}:null)};K();const X=window.setInterval(K,250);return()=>window.clearInterval(X)},[]);const N=()=>{T({type:"TOGGLE_ROUTE_TREE"})},D=()=>C.editMode==="base"?S("layout_editor.chrome.toolbar.mode_badge.base"):C.editMode==="modal"?S("layout_editor.chrome.toolbar.mode_badge.modal"):C.editMode==="extension"?S("layout_editor.chrome.toolbar.mode_badge.extension"):C.editMode==="iteration_item"?S("layout_editor.chrome.toolbar.mode_badge.iteration_item"):null,B=()=>{C.editMode==="base"?T({type:"EXIT_BASE_EDIT"}):C.editMode==="modal"?T({type:"EXIT_MODAL_EDIT"}):C.editMode==="extension"?T({type:"EXIT_EXTENSION_EDIT"}):C.editMode==="iteration_item"&&T({type:"EXIT_ITERATION_ITEM_EDIT"})},M=D(),O=C.editMode!=="route",z={display:"inline-flex",alignItems:"center",gap:6,padding:"6px 12px",fontSize:13,fontWeight:500,borderRadius:6,borderWidth:1,borderStyle:"solid",borderColor:"transparent",backgroundColor:"transparent",color:"#475569",cursor:"pointer",transition:"background-color 120ms, color 120ms, border-color 120ms"},H={...z,backgroundColor:"#2563eb",color:"#ffffff",borderColor:"#2563eb",fontWeight:600},P={backgroundColor:"#fef3c7",borderColor:"#f59e0b",color:"#92400e",fontWeight:600},I={...z,borderColor:"#e2e8f0",backgroundColor:"#ffffff",color:"#0f172a"},L={backgroundColor:"#f1f5f9",color:"#0f172a",borderColor:"#cbd5e1"},F={backgroundColor:"#1d4ed8",borderColor:"#1d4ed8"},Y={backgroundColor:"#f8fafc",borderColor:"#cbd5e1"};return i.jsxs("div",{className:"g7le-toolbar","data-testid":"g7le-toolbar",role:"toolbar",style:{display:"flex",alignItems:"center",gap:6,padding:"8px 12px",borderBottom:"1px solid #e2e8f0",background:"#ffffff",boxShadow:"0 1px 2px rgba(15, 23, 42, 0.04)"},children:[i.jsx("style",{children:"@keyframes g7le-spin { to { transform: rotate(360deg); } }.g7le-toolbar > * { flex-shrink: 0; white-space: nowrap; }"}),i.jsx("button",{type:"button",className:"g7le-toolbar__route-tree-toggle","data-testid":"g7le-toolbar-toggle-route-tree","aria-label":S("layout_editor.chrome.toolbar.toggle_route_tree"),title:S("layout_editor.chrome.toolbar.toggle_route_tree"),onClick:N,style:{...z,outline:"none",padding:"6px 10px",fontSize:16,lineHeight:1,color:"#64748b"},children:"☰"}),i.jsx(ky,{templateIdentifier:C.templateIdentifier,templateName:b,templateVersion:g,templateList:m,onSwitch:h}),M&&i.jsx("span",{className:"g7le-toolbar__mode-badge","data-testid":"g7le-toolbar-mode-badge","data-mode":C.editMode,style:{padding:"2px 8px",borderRadius:999,background:"#fef3c7",color:"#92400e",fontSize:11,fontWeight:600,border:"1px solid #fde68a"},children:M}),i.jsx("div",{style:{flex:1}}),i.jsxs(i.Fragment,{children:[i.jsx(ht,{"data-testid":"g7le-toolbar-undo","aria-label":S("layout_editor.chrome.toolbar.undo"),title:S("layout_editor.chrome.toolbar.undo"),disabled:!E?.canUndo,onClick:()=>E?.undo?.(),baseStyle:z,hoverStyle:L,style:{opacity:E?.canUndo?1:.4},children:"↶"}),i.jsx(ht,{"data-testid":"g7le-toolbar-redo","aria-label":S("layout_editor.chrome.toolbar.redo"),title:S("layout_editor.chrome.toolbar.redo"),disabled:!E?.canRedo,onClick:()=>E?.redo?.(),baseStyle:z,hoverStyle:L,style:{opacity:E?.canRedo?1:.4},children:"↷"}),i.jsxs(ht,{"data-testid":"g7le-toolbar-add-element","data-open":C.isPaletteOpen?"true":"false",disabled:!C.selectedRoute,onClick:()=>T({type:"TOGGLE_PALETTE"}),"aria-pressed":C.isPaletteOpen,baseStyle:z,hoverStyle:L,style:C.isPaletteOpen?{backgroundColor:"#eff6ff",color:"#1d4ed8",borderColor:"#93c5fd"}:void 0,children:["+ ",S("layout_editor.chrome.toolbar.add_element")]}),i.jsx(ht,{"data-testid":"g7le-toolbar-preview","data-previewing":x?"true":"false",disabled:!p||!C.selectedRoute?.layoutName||x,onClick:()=>{const K=p?.();K&&typeof K.then=="function"&&($(!0),K.finally(()=>$(!1)))},baseStyle:z,hoverStyle:L,style:{opacity:x?.7:1},children:x?i.jsxs(i.Fragment,{children:[i.jsx("span",{"data-testid":"g7le-toolbar-preview-spinner","aria-hidden":"true",style:{display:"inline-block",width:12,height:12,border:"2px solid rgba(71,85,105,0.35)",borderTopColor:"#475569",borderRadius:"50%",animation:"g7le-spin 600ms linear infinite"}}),S("layout_editor.chrome.toolbar.previewing")]}):i.jsxs(i.Fragment,{children:["👁 ",S("layout_editor.chrome.toolbar.preview")]})}),i.jsxs(ht,{"data-testid":"g7le-toolbar-versions",disabled:!f||!(C.selectedRoute?.layoutName||C.selectedRoute?.path?.startsWith("__extension__/")),onClick:()=>f?.(),"aria-label":S("layout_editor.chrome.toolbar.version_history"),title:S("layout_editor.chrome.toolbar.version_history"),baseStyle:z,hoverStyle:L,children:["🕘 ",S("layout_editor.chrome.toolbar.version_history")]}),i.jsxs(ht,{"data-testid":"g7le-toolbar-edit-code",disabled:!r,onClick:()=>r?.(),baseStyle:z,hoverStyle:L,children:["⟨/⟩ ",S("layout_editor.chrome.toolbar.edit_code")]}),i.jsxs(ht,{"data-testid":"g7le-toolbar-images",disabled:!s||!C.selectedRoute,onClick:()=>s?.(),baseStyle:z,hoverStyle:L,children:["🖼 ",S("layout_editor.chrome.toolbar.images")]}),i.jsxs(ht,{"data-testid":"g7le-toolbar-translations",disabled:!a||!C.selectedRoute,onClick:()=>a?.(),baseStyle:z,hoverStyle:L,children:["🌐 ",S("layout_editor.chrome.toolbar.translations")]}),i.jsxs(ht,{"data-testid":"g7le-toolbar-custom-assets",disabled:!_,onClick:()=>_?.(),title:S("layout_editor.chrome.toolbar.custom_assets_hint"),baseStyle:z,hoverStyle:L,children:["🎨 ",S("layout_editor.chrome.toolbar.custom_assets")]}),i.jsxs(ht,{"data-testid":"g7le-toolbar-toggle-custom-assets","data-custom-disabled":y?"true":"false",disabled:!v,onClick:()=>v?.(),"aria-pressed":y,title:S(y?"layout_editor.chrome.toolbar.custom_assets_on_hint":"layout_editor.chrome.toolbar.custom_assets_off_hint"),baseStyle:z,hoverStyle:L,style:y?{...z,...P}:void 0,children:[y?"👁":"🚫"," ",S(y?"layout_editor.chrome.toolbar.custom_assets_on":"layout_editor.chrome.toolbar.custom_assets_off")]}),i.jsxs(ht,{"data-testid":"g7le-toolbar-page-settings",disabled:!l||!C.selectedRoute||C.editMode==="extension"||C.editMode==="iteration_item",onClick:()=>l?.(),baseStyle:z,hoverStyle:L,children:["⚙ ",S("layout_editor.chrome.toolbar.page_settings")]}),i.jsxs(ht,{"data-testid":"g7le-toolbar-reset",disabled:!d||!n,onClick:()=>d?.(),"aria-label":S("layout_editor.chrome.toolbar.reset"),title:S("layout_editor.chrome.toolbar.reset"),baseStyle:z,hoverStyle:L,style:{opacity:n?1:.4},children:["↺ ",S("layout_editor.chrome.toolbar.reset")]}),i.jsx(ht,{"data-testid":"g7le-toolbar-save","data-dirty":n?"true":"false","data-saving":w?"true":"false",disabled:!t||w,onClick:()=>{const K=t?.();K&&typeof K.then=="function"&&(k(!0),K.finally(()=>k(!1)))},baseStyle:H,hoverStyle:F,style:{opacity:w?.7:n?1:.7},children:w?i.jsxs(i.Fragment,{children:[i.jsx("span",{"data-testid":"g7le-toolbar-save-spinner","aria-hidden":"true",className:"g7le-toolbar__spinner",style:{display:"inline-block",width:12,height:12,border:"2px solid rgba(255,255,255,0.4)",borderTopColor:"#ffffff",borderRadius:"50%",animation:"g7le-spin 600ms linear infinite"}}),S("layout_editor.chrome.toolbar.saving")]}):i.jsxs(i.Fragment,{children:["💾 ",S("layout_editor.chrome.toolbar.save")]})}),i.jsx(ht,{"data-testid":"g7le-toolbar-shortcuts",disabled:!c,onClick:()=>c?.(),"aria-label":S("layout_editor.shortcuts.title"),title:S("layout_editor.shortcuts.title"),baseStyle:z,hoverStyle:L,children:"⌨"}),i.jsxs(ht,{"data-testid":"g7le-toolbar-exit",disabled:!o,onClick:()=>o?.(),baseStyle:I,hoverStyle:Y,children:["✕ ",S("layout_editor.chrome.toolbar.exit")]})]}),O&&i.jsxs(ht,{"data-testid":"g7le-toolbar-exit-alt-mode",onClick:B,baseStyle:I,hoverStyle:Y,children:["← ",C.editMode==="base"&&S("layout_editor.chrome.toolbar.exit_base_edit"),C.editMode==="modal"&&S("layout_editor.chrome.toolbar.exit_modal_edit"),C.editMode==="extension"&&S("layout_editor.chrome.toolbar.exit_extension_edit"),C.editMode==="iteration_item"&&S("layout_editor.chrome.toolbar.exit_iteration_item_edit")]})]})}function cr(){if(typeof window>"u")return null;try{return window.localStorage?.getItem("auth_token")??null}catch{return null}}function Ne(e){const t={Accept:"application/json",...e??{}},n=cr();return n&&(t.Authorization=`Bearer ${n}`),t}function Oi(e){return encodeURIComponent(e)}async function Ll(e,t){const n=`/api/admin/templates/${Oi(e)}/layout-attachments?layout_name=${encodeURIComponent(t)}`;try{const o=await fetch(n,{method:"GET",headers:Ne(),credentials:"same-origin"}),r=await o.json().catch(()=>null);return!o.ok||!r?.success?{ok:!1,status:o.status,message:Bi(r,o.status)}:{ok:!0,data:Array.isArray(r?.data)?r.data:[]}}catch(o){return{ok:!1,status:0,message:o instanceof Error?o.message:"network error"}}}async function Pl(e,t,n){const o=`/api/admin/templates/${Oi(e)}/layout-attachments`,r=new FormData;r.append("file",n),r.append("layout_name",t);try{const s=await fetch(o,{method:"POST",headers:Ne(),body:r,credentials:"same-origin"}),a=await s.json().catch(()=>null);return!s.ok||!a?.success||!a?.data?.url?{ok:!1,status:s.status,message:Bi(a,s.status)}:{ok:!0,data:a.data}}catch(s){return{ok:!1,status:0,message:s instanceof Error?s.message:"network error"}}}async function Ol(e){const t=`/api/admin/templates/layout-attachments/${Oi(String(e))}`;try{const n=await fetch(t,{method:"DELETE",headers:Ne(),credentials:"same-origin"}),o=await n.json().catch(()=>null);return!n.ok||o&&o.success===!1?{ok:!1,status:n.status,message:Bi(o,n.status)}:{ok:!0,data:!0}}catch(n){return{ok:!1,status:0,message:n instanceof Error?n.message:"network error"}}}function Bi(e,t){if(e&&typeof e=="object"&&"message"in e){const n=e.message;if(typeof n=="string"&&n.length>0)return n}return`HTTP ${t}`}function Cy(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function $y(e){if(!e)return"";const t=e.match(/^(\d{4})-(\d{2})-(\d{2})/);return t?`${t[2]}-${t[3]}`:""}function Bl({templateIdentifier:e,layoutName:t,t:n,onSelect:o,onChanged:r,onClose:s}){const[a,l]=u.useState([]),[d,c]=u.useState("idle"),[p,f]=u.useState(!1),[b,g]=u.useState(null),m=u.useRef(null),h=u.useCallback(async()=>{c("loading"),g(null);const _=await Ll(e,t);_.ok?(l(_.data),c("idle")):(g(_.message),c("error"))},[e,t]);u.useEffect(()=>{h()},[h]);const v=async _=>{const w=_.target.files?.[0];if(!w)return;f(!0),g(null);const k=await Pl(e,t,w);k.ok?(l(x=>[k.data,...x.filter($=>$.id!==k.data.id)]),r?.()):g(k.message),f(!1),m.current&&(m.current.value="")},y=async _=>{if(!(typeof window<"u"&&typeof window.confirm=="function"?window.confirm(n("layout_editor.attachment_manager.delete_confirm")):!0))return;const k=await Ol(_.id);k.ok?(l(x=>x.filter($=>$.id!==_.id)),r?.()):g(k.message)};return i.jsxs("div",{className:"g7le-attachment-manager","data-testid":"g7le-attachment-manager",style:Ey,children:[i.jsxs("div",{"data-modal-drag-handle":!0,style:Iy,children:[i.jsx("span",{style:{fontSize:14,fontWeight:700},"data-testid":"g7le-attachment-manager-title",children:n("layout_editor.attachment_manager.title")}),i.jsx("button",{type:"button","aria-label":"close",onClick:s,style:Ay,"data-testid":"g7le-attachment-manager-close",children:"✕"})]}),i.jsx("div",{style:Ty,children:i.jsxs("label",{style:Dy,"data-testid":"g7le-attachment-upload",children:[p?"…":`⬆ ${n("layout_editor.attachment_manager.upload")}`,i.jsx("input",{ref:m,type:"file",accept:"image/*",onChange:v,disabled:p,style:{display:"none"},"data-testid":"g7le-attachment-upload-input"})]})}),b&&i.jsx("div",{style:zy,"data-testid":"g7le-attachment-manager-error",children:b}),i.jsx("div",{style:Ny,children:d==="loading"?i.jsx("div",{style:Wl,"data-testid":"g7le-attachment-manager-loading",children:n("layout_editor.attachment_manager.loading")}):a.length===0&&d!=="error"?i.jsx("div",{style:Wl,"data-testid":"g7le-attachment-manager-empty",children:n("layout_editor.attachment_manager.empty")}):i.jsx("div",{style:My,"data-testid":"g7le-attachment-grid",children:a.map(_=>i.jsxs("div",{style:Ly,"data-testid":`g7le-attachment-card-${_.id}`,children:[i.jsx("div",{style:{...Py,backgroundImage:`url(${_.url})`}}),i.jsx("div",{style:Oy,title:_.original_name,children:_.original_name}),i.jsxs("div",{style:By,children:[Cy(_.size),_.created_at?` · ${$y(_.created_at)}`:""]}),i.jsxs("div",{style:Wy,children:[o&&i.jsx("button",{type:"button",onClick:()=>o(_.url),style:jy,"data-testid":`g7le-attachment-use-${_.id}`,children:n("layout_editor.attachment_manager.use_as_bg")}),i.jsx("button",{type:"button",onClick:()=>y(_),style:Hy,"data-testid":`g7le-attachment-delete-${_.id}`,children:"🗑"})]})]},_.id))})}),i.jsx("div",{style:Fy,children:i.jsx("button",{type:"button",onClick:s,style:Ky,"data-testid":"g7le-attachment-manager-footer-close",children:n("layout_editor.attachment_manager.close")})})]})}const Ey={display:"flex",flexDirection:"column",minHeight:0,flex:1},Iy={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:"1px solid #e2e8f0"},Ay={border:"none",background:"transparent",fontSize:16,color:"#94a3b8",cursor:"pointer"},Ty={padding:"10px 16px",borderBottom:"1px solid #f1f5f9",display:"flex",gap:8},Dy={padding:"6px 12px",fontSize:13,border:"1px solid #2563eb",borderRadius:6,background:"#fff",color:"#2563eb",cursor:"pointer",display:"inline-flex",alignItems:"center"},zy={padding:"8px 16px",fontSize:12,color:"#b91c1c",background:"#fef2f2"},Ny={padding:16,overflow:"auto",flex:1,minHeight:120},Wl={fontSize:13,color:"#94a3b8",textAlign:"center",padding:"32px 0"},My={display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(140px, 1fr))",gap:12},Ly={display:"flex",flexDirection:"column",gap:4,border:"1px solid #e2e8f0",borderRadius:8,padding:8},Py={width:"100%",height:88,borderRadius:6,border:"1px solid #cbd5e1",backgroundSize:"cover",backgroundPosition:"center",backgroundColor:"#f8fafc"},Oy={fontSize:12,fontWeight:600,color:"#0f172a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},By={fontSize:11,color:"#64748b"},Wy={display:"flex",gap:6,marginTop:2},jy={flex:1,padding:"4px 6px",fontSize:11,border:"1px solid #2563eb",borderRadius:6,background:"#2563eb",color:"#fff",cursor:"pointer"},Hy={padding:"4px 8px",fontSize:12,border:"1px solid #fecaca",borderRadius:6,background:"#fff",color:"#dc2626",cursor:"pointer"},Fy={padding:"10px 16px",borderTop:"1px solid #e2e8f0",display:"flex",justifyContent:"flex-end"},Ky={padding:"6px 14px",fontSize:13,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"};function ur(e){return encodeURIComponent(e)}async function Vy(e,t,n){const o=new URLSearchParams;t&&o.set("layout_name",t);const r=o.toString(),s=`/api/admin/templates/${ur(e)}/custom-translations`+(r?`?${r}`:"");try{const a=await fetch(s,{method:"GET",headers:Ne(),credentials:"same-origin"}),l=await a.json().catch(()=>null);return!a.ok||!l?.success?{ok:!1,status:a.status,message:pr(l,a.status)}:{ok:!0,data:Array.isArray(l?.data)?l.data:[]}}catch(a){return{ok:!1,status:0,message:a instanceof Error?a.message:"network error"}}}async function Uy(e,t,n,o){const r=`/api/admin/templates/${ur(e)}/custom-translations/${t}`;try{const s=await fetch(r,{method:"PUT",headers:Ne({"Content-Type":"application/json"}),body:JSON.stringify({values:n,expected_lock_version:o}),credentials:"same-origin"}),a=await s.json().catch(()=>null);return!s.ok||!a?.success||!a?.data?{ok:!1,status:s.status,message:pr(a,s.status)}:{ok:!0,data:a.data}}catch(s){return{ok:!1,status:0,message:s instanceof Error?s.message:"network error"}}}async function qy(e,t){const n=`/api/admin/templates/${ur(e)}/custom-translations/${t}`;try{const o=await fetch(n,{method:"DELETE",headers:Ne(),credentials:"same-origin"}),r=await o.json().catch(()=>null);return!o.ok||r&&r.success===!1?{ok:!1,status:o.status,message:pr(r,o.status)}:{ok:!0,data:!0}}catch(o){return{ok:!1,status:0,message:o instanceof Error?o.message:"network error"}}}async function Gy(e,t){const n=`/api/admin/templates/${ur(e)}/custom-translations`;try{const o=await fetch(n,{method:"DELETE",headers:Ne({"Content-Type":"application/json"}),body:JSON.stringify({ids:t}),credentials:"same-origin"}),r=await o.json().catch(()=>null);return!o.ok||!r?.success?{ok:!1,status:o.status,message:pr(r,o.status)}:{ok:!0,data:{deleted:typeof r?.data?.deleted=="number"?r.data.deleted:t.length}}}catch(o){return{ok:!1,status:0,message:o instanceof Error?o.message:"network error"}}}const jl=/\$t:(custom\.[A-Za-z0-9_\-]+\.\d+)/g;function Yy(e){const t=new Set,n=o=>{if(typeof o=="string"){if(o.includes("$t:custom.")){let r;for(jl.lastIndex=0;(r=jl.exec(o))!==null;)t.add(r[1])}return}if(Array.isArray(o)){for(const r of o)n(r);return}if(o&&typeof o=="object")for(const r of Object.values(o))n(r)};return n(e),t}function pr(e,t){if(e&&typeof e=="object"&&"message"in e){const n=e.message;if(typeof n=="string"&&n.length>0)return n}return`HTTP ${t}`}const Pt=Lt().TranslationEngine,mo=Lt().createLogger,Wi=mo("EditorSpecLoader"),Xy=["controls","componentCapabilities","actionRecipes","conditionRecipes","pageSettings","initActionRecipes","errorRecipes","computedRecipes","loadingComponents"],Jy=["actionRecipes","initActionRecipes","errorRecipes","computedRecipes","loadingComponents"];function Hl(e){if(typeof window>"u")return[];const n=window.G7Config?.[e];if(!Array.isArray(n))return[];const o=[];for(const r of n){const s=r?.identifier;typeof s=="string"&&s.length>0&&o.push(s)}return o}async function Zy(e,t,n,o){const s=`${n}/${e==="template"?"templates":e==="module"?"modules":"plugins"}/${encodeURIComponent(t)}/editor-spec`;try{const a=await o(s);if(!a.ok)return a.status!==404&&Wi.warn(`fetchOneSpec: HTTP ${a.status}`,s),null;const l=await a.json();return!l?.success||!l.data?null:l.data.spec??null}catch(a){return Wi.warn("fetchOneSpec: fetch failed",s,a),null}}function Qy(e){return Jy.includes(e)}function Ry(e,t){return e==null||typeof e!="object"?e:{...e,__source:t}}function eb(e,t,n,o){const r=t[n];if(!r||typeof r!="object")return;const s=e[n]??{};if(o&&Qy(n)){const a={};for(const[l,d]of Object.entries(r))a[l]=Ry(d,o);e[n]={...s,...a};return}e[n]={...s,...r}}function tb(e,t){if(!t.nesting)return;const n=e.nesting??{},o=new Set(n.draggable??[]);for(const r of t.nesting.draggable??[])o.add(r);n.draggable=Array.from(o),n.containers={...n.containers??{},...t.nesting.containers??{}},e.nesting=n}function nb(e,t){if(!t.componentPalette)return;const n=e.componentPalette??{},o=[...n.groups??[],...t.componentPalette.groups??[]];n.groups=o,n.entries={...n.entries??{},...t.componentPalette.entries??{}},e.componentPalette=n}function ob(e,t){if(!t.states)return;const n=e.states??{},o=[...n.groups??[],...t.states.groups??[]];n.groups=o,e.states=n}function rb(e,t){if(!Array.isArray(t.stateLabels)||t.stateLabels.length===0)return;const n=[...e.stateLabels??[],...t.stateLabels],o=new Map;for(const r of n)!r||typeof r.key!="string"||typeof r.scope!="string"||o.set(`${r.scope}:${r.key}`,r);e.stateLabels=Array.from(o.values())}function ib(e,t){if(!t.actionChipCandidates)return;const n=e.actionChipCandidates??{};for(const o of["response","error","payload"]){const r=t.actionChipCandidates[o];!Array.isArray(r)||r.length===0||(n[o]=[...n[o]??[],...r])}e.actionChipCandidates=n}function sb(e,t){if(!t.sampleData)return;const n=e.sampleData??{};n.byDataSourceId={...n.byDataSourceId??{},...t.sampleData.byDataSourceId??{}},n.byEndpointPattern={...n.byEndpointPattern??{},...t.sampleData.byEndpointPattern??{}},e.sampleData=n}function Fl(e,t,n){for(const o of Xy)eb(e,t,o,n);tb(e,t),nb(e,t),ob(e,t),rb(e,t),ib(e,t),sb(e,t),t.version&&(e.version=t.version)}async function ab(e){const t=e.apiBaseUrl??"/api",n=e.fetcher??(typeof fetch<"u"?fetch:void 0);if(!n)return Wi.warn("loadEditorSpecBundle: fetch unavailable, returning null spec"),{spec:null,sampleGlobalSources:[]};const o=e.activeModuleIdentifiers??Hl("activeModules"),r=e.activePluginIdentifiers??Hl("activePlugins"),s=[...o.map(p=>({kind:"module",id:p})),...r.map(p=>({kind:"plugin",id:p})),{kind:"template",id:e.templateIdentifier}],a=await Promise.all(s.map(p=>Zy(p.kind,p.id,t,n)));let l=null;const d=[],c={};if(e.coreSeed&&(l={},Fl(l,e.coreSeed,{kind:"core"})),s.forEach((p,f)=>{const b=a[f];if(!b)return;b.sampleGlobal&&typeof b.sampleGlobal=="object"&&d.push({id:p.id,kind:p.kind,sampleGlobal:b.sampleGlobal});const g=b.sampleData?.byDataSourceId;if(g&&typeof g=="object"){const m=p.kind==="template"?"template":`${p.kind}:${p.id}`;c[m]={...c[m]??{},...g}}l===null&&(l={}),Fl(l,b,{kind:p.kind,id:p.id})}),l!==null&&Object.keys(c).length>0){const p=l;p.sampleData={...p.sampleData??{},bySource:c}}return{spec:l,sampleGlobalSources:d}}function ji(e,t){return e?.componentCapabilities?.[t]??null}function Ct(e,t){return e?.controls?.[t]??null}function lb(e){return e?.initActionRecipes??{}}function db(e){return e?.computedRecipes??{}}function cb(e){return e?.errorRecipes??{}}function ub(e){const t=e?.loadingComponents;return!t||typeof t!="object"?[]:Object.values(t).filter(n=>n!=null&&typeof n=="object"&&typeof n.name=="string")}function pb(e,t,n){const o=e?.stateLabels;if(!Array.isArray(o))return null;for(const r of o)if(r?.scope===t&&r?.key===n)return typeof r.label_key=="string"?r.label_key:null;return null}function Hi(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function fb(e){return e===null?"null":typeof e=="string"?e.length>40?`${e.slice(0,40)}…`:e:typeof e=="number"||typeof e=="boolean"?String(e):""}function gb(e){const t=e.find(n=>Hi(n));if(Hi(t))return Object.keys(t).slice(0,8)}function hb(e){return Object.keys(e).slice(0,8)}function yb(e){const t=Object.entries(e);return t.length===0?!1:t.some(([,n])=>n===null||typeof n!="object")}function Fi(e,t,n,o,r){if(Array.isArray(e)){r(t,"array",`[${e.length}]`,gb(e));return}if(Hi(e)){if(t&&yb(e)){const s=hb(e);r(t,"object",`{${s.length}}`,s)}if(n>=o)return;for(const[s,a]of Object.entries(e)){const l=t?`${t}.${s}`:s;Fi(a,l,n+1,o,r)}return}r(t,"scalar",fb(e))}function bb(e,t,n){const o=[];let r=e;for(const s of t){if(!r||(r=(Array.isArray(r.children)?r.children:[])[s],!r))break;const l=r.iteration;if(!(!l||l.source===void 0)&&(typeof l.index_var=="string"&&l.index_var.length>0&&o.push({name:l.index_var,kind:"index"}),typeof l.item_var=="string"&&l.item_var.length>0)){const d=typeof l.source=="string"?l.source:"",c=d&&n?.get(Kl(d))||[];o.push({name:l.item_var,kind:"item",itemFields:c})}}return o}function Kl(e){return e.replace(/^\{\{|\}\}$/g,"").trim()}function mb(e){const t=new Map;for(const n of e)n.shape==="array"&&n.itemFields&&n.itemFields.length>0&&t.set(Kl(n.expression),n.itemFields);return t}function Ki(e){const t=e.maxDepth??4,n=[];for(const o of e.dataSources??[])!o||typeof o.id!="string"||o.id.length===0||Fi(o.sample,"",0,t,(r,s,a,l)=>{const d=r?`{{${o.id}.${r}}}`:`{{${o.id}}}`;n.push({expression:d,source:"data_source",sourceId:o.id,path:r,shape:s,groupLabelKey:o.labelKey?.startsWith("$t:")?o.labelKey.slice(3):o.labelKey,preview:a,itemFields:l})});for(const o of e.states??[])!o||typeof o.scope!="string"||Fi(o.tree,"",0,t,(r,s,a,l)=>{if(!r)return;const d=pb(e.spec,o.scope,r)??void 0;n.push({expression:`{{${o.scope}.${r}}}`,source:o.scope,sourceId:o.scope,path:r,shape:s,labelKey:d?.startsWith("$t:")?d.slice(3):d,preview:a,itemFields:l})});for(const o of e.iterationVars??[])if(!(!o||typeof o.name!="string"||o.name.length===0)){if(o.kind==="index"){n.push({expression:`{{${o.name}}}`,source:"iteration",sourceId:o.name,path:"",shape:"scalar",preview:"0"});continue}for(const r of o.itemFields??[])n.push({expression:`{{${o.name}.${r}}}`,source:"iteration",sourceId:o.name,path:r,shape:"scalar",preview:""})}return n}const vb=["$localized"];function _b(e){const t=e.trim(),n=t.indexOf("(");if(n===-1||!t.endsWith(")"))return{fn:null,inner:t};const o=t.slice(0,n).trim();if(!vb.includes(o))return{fn:null,inner:t};const r=t.slice(n+1,-1);let s=0,a=null;for(let l=0;ln.shape===t)}function qi(e,t){const n=t.trim().toLowerCase();return n===""?e:e.filter(o=>[o.resolvedLabel??"",o.sourceId,o.path,o.preview].join(" ").toLowerCase().includes(n))}function Vl(e,t,n){const o={response:[{path:"data",labelKey:"layout_editor.action_chip.response_data",shape:"object"},{path:"message",labelKey:"layout_editor.action_chip.response_message",shape:"scalar"}],error:[{path:"status",labelKey:"layout_editor.action_chip.error_status",shape:"scalar"},{path:"message",labelKey:"layout_editor.action_chip.error_message",shape:"scalar"},{path:"errors",labelKey:"layout_editor.action_chip.error_errors",shape:"object"},{path:"data",labelKey:"layout_editor.action_chip.error_data",shape:"object"},{path:"statusText",labelKey:"layout_editor.action_chip.error_status_text",shape:"scalar"}],payload:[{path:"data",labelKey:"layout_editor.action_chip.payload_data",shape:"object"}]},r=e==="response"?"response":e==="error"?"error":"message",s=new Set,a=[];for(const d of o[e])s.has(d.path)||(s.add(d.path),a.push(d));const l=n?.[e];if(Array.isArray(l))for(const d of l)!d||typeof d.path!="string"||typeof d.labelKey!="string"||s.has(d.path)||(s.add(d.path),a.push({path:d.path,labelKey:d.labelKey,shape:d.shape??"scalar"}));return a.map(d=>({expression:`{{${r}.${d.path}}}`,source:"_local",sourceId:r,path:d.path,shape:d.shape,labelKey:d.labelKey,preview:t(d.labelKey)}))}const Gi=/\{\{(?:[^}]|\}(?!\}))*\}\}/g;function In(e){const t=[];if(typeof e!="string"||e.length===0)return t;let n=0,o=0;const r=new RegExp(Gi.source,"g");let s;for(;(s=r.exec(e))!==null;){const a=s.index,l=a+s[0].length;a>n&&t.push({kind:"literal",raw:e.slice(n,a),start:n,end:a}),t.push({kind:"binding",raw:s[0],start:a,end:l,parsed:Kt(s[0]),bindingIndex:o++}),n=l}return nt.kind==="binding")}function Yi(e){return typeof e!="string"?!1:new RegExp(Gi.source).test(e)}function wb(e){const t=new Set(e.map(o=>o.trim()));let n=0;for(;t.has(`p${n}`);)n+=1;return`p${n}`}function Ul(e,t,n){const o=typeof e=="string"?e:"",r=Math.max(0,Math.min(t,o.length)),s=o.slice(0,r),a=o.slice(r),l=s.length>0&&!/\s$/.test(s)?" ":"",d=a.length>0&&!/^\s/.test(a)?" ":"";return`${s}${l}{${n}}${d}${a}`}function Xi(e,t){const n=typeof e=="string"?e:"";return An(n).includes(t)?n:n.length===0?`{${t}}`:/\s$/.test(n)?`${n}{${t}}`:`${n} {${t}}`}function ql(e){return fr(e).map(t=>({bindingIndex:t.bindingIndex??0,expression:t.raw,parsed:t.parsed??null,isComplex:(t.parsed??null)===null}))}function gr(e){return typeof e!="string"?"":e.replace(new RegExp(Gi.source,"g")," ").replace(/\s+/g," ").trim()}const kb=/\$t:([a-zA-Z0-9._-]+)/g,Gl="custom.";function Ji(e,t){return typeof e!="string"||e.length===0?typeof e=="string"?e:"":t?In(e).map(n=>n.kind!=="literal"?n.raw:n.raw.replace(kb,(o,r)=>{if(r.startsWith(Gl))return o;const s=t(r);return s&&s!==r?s:o})).join(""):e}const Kn="(?:(?!\\|[a-zA-Z0-9_]+=).)*",Sb=new RegExp(`^\\s*\\$t:([a-zA-Z0-9._-]+)((?:\\|[a-zA-Z0-9_]+=${Kn})*)`),Cb=new RegExp(`\\|([a-zA-Z0-9_]+)=(${Kn})`,"g");function Vt(e){if(typeof e!="string")return"";const t=Kt(e);if(t)return t.path||t.sourceId;const n=e.trim().replace(/^\{\{\s*/,"").replace(/\s*\}\}$/,"");let o=-1;for(let l=0;l0){const l=n.slice(0,o).trim(),d=Kt(`{{${l}}}`);if(d)return d.path||d.sourceId;const c=l.replace(/\?\./g,".").replace(/\s*\?\?.*$/,"").trim();if(/^[A-Za-z_$][\w$.]*$/.test(c)){const p=c.split(".").filter(Boolean);return p.length>1&&p.slice(1).join(".")||c}}const r=n.replace(/\s+/g," ").trim(),s=r.replace(/\s*(\?\?|\|\|)\s*(\[\s*\]|\{\s*\}|'[^']*'|"[^"]*"|\d+|null|undefined)\s*$/,"").trim(),a=/\.([A-Za-z_$][\w$]*)\s*$/.exec(s);return a?a[1]:r}const Yl=/\$(?:core|module|plugin)_settings:[a-zA-Z0-9._:-]+/g;function Xl(e){return typeof e=="string"&&new RegExp(Yl.source).test(e)}function $b(e){return typeof e!="string"?"":e.replace(/^\$(?:core|module|plugin)_settings:/,"").split(/[.:]/).filter(Boolean).pop()||e}function Jl(e){const t=[];for(const n of In(e)){if(n.kind==="binding"){t.push({kind:"chip",label:Vt(n.raw)});continue}let o=0;const r=n.raw,s=new RegExp(Yl.source,"g");let a;for(;(a=s.exec(r))!==null;)a.index>o&&t.push({kind:"text",label:r.slice(o,a.index)}),t.push({kind:"chip",label:$b(a[0])}),o=a.index+a[0].length;o{const m=`p${o.length}`;return o.push(g),r[m]=Vt(g),`{${m}}`};let a=e,l="";const d=Sb.exec(e);if(d&&!d[1].startsWith(Gl)){const g=d[1],m=d[2]??"",h=e.slice(d[0].length),v=new Map,y=new RegExp(Cb.source,"g");let _;for(;(_=y.exec(m))!==null;)_[2]&&_[2].includes("{{")&&v.set(_[1],_[2]);const w=t?t(g):"";if(w&&w!==g&&!w.startsWith("$t:"))l=w.replace(/\{\{?([a-zA-Z0-9_]+)\}?\}/g,(k,x)=>{const $=v.get(x);return $?s($):k});else return n;a=h}const c=Ji(a,t),p=In(c).map(g=>g.kind==="binding"?s(g.raw):g.raw).join(""),f=`${l}${p}`;return/\$t:[a-zA-Z0-9._-]+/.test(f)||o.length===0?n:{chipValue:f,bindings:o,paramLabels:r,keyifiable:!0}}function Zl(e,t){return t.bindings.length?e+t.bindings.map((n,o)=>`|p${o}=${n}`).join(""):e}function Ql(e,t){const n=fr(t).map(r=>r.raw);if(n.length===0)return e;const o=n.map((r,s)=>`|p${s}=${r}`).join("");return`${e}${o}`}function Rl(e){if(typeof e!="string")return"";const t=In(e);let n=0;return t.map(o=>o.kind==="binding"?`{p${n++}}`:o.raw).join("")}const ed=new RegExp(`^\\s*\\$t:([a-zA-Z0-9._-]+)((?:\\|[a-zA-Z0-9_]+=${Kn})+)\\s*$`),Ib=new RegExp(`\\|([a-zA-Z0-9_]+)=(${Kn})`,"g");function vt(e){if(typeof e!="string")return null;const t=ed.exec(e);if(!t)return null;const n=t[1],o=t[2],r=[],s=new RegExp(Ib.source,"g");let a;for(;(a=s.exec(o))!==null;){const l=a[1],d=a[2];r.push({name:l,expression:d,parsed:Kt(d)})}return{key:n,params:r}}function td(e){return typeof e=="string"&&ed.test(e)}function An(e){if(typeof e!="string")return[];const t=[],n=/\{\{?(p\d+)\}?\}/g;let o;for(;(o=n.exec(e))!==null;)t.push(o[1]);return t.sort()}function Ab(e,t,n){if(typeof e!="string")return e;const o=new RegExp(`(\\|${t}=)${Kn}`);return o.test(e)?e.replace(o,`$1${n}`):e}function vo(e,t){if(typeof e!="string")return e;const n=new RegExp(`\\|${t}=${Kn}`);return e.replace(n,"")}function nd(e,t){return typeof e!="string"?e:e.replace(new RegExp(`\\s*\\{\\{?${t}\\}?\\}\\s*`,"g")," ").replace(/\s+/g," ").trim()}function Tb(e,t){const n=s=>fr(typeof s=="string"?s:"").map(a=>a.raw.replace(/\s+/g,"")).sort(),o=n(e),r=n(t);return o.length!==r.length?!1:o.every((s,a)=>s===r[a])}function od(e){return e.__source?.kind==="base"}function rd(e){return e.__source?.kind==="partial"}function Db(e){return e.__source?.kind==="route"}function hr(e,t){return e.__source?.kind!=="extension"?!1:t==null?!0:e.__source.extensionId!==t}function id(e){return e.type==="extension_point"}function Qi(e=[]){for(const t of e)if(t.iteration&&t.iteration.source!==void 0)return!0;return!1}function zb(e,t=[]){for(const n of t)if(n.iteration&&n.iteration.source!==void 0)return!0;return e.iteration&&e.iteration.source!==void 0?!0:sd(e)}function sd(e){if(typeof e.text=="string"&&ad(e.text)&&!Nb(e.text))return!0;if(e.props&&typeof e.props=="object"){for(const t of Object.values(e.props))if(typeof t=="string"&&ad(t))return!0}return!1}function ad(e){return/\{\{[\s\S]*?\}\}/.test(e)}function Nb(e){const t=vt(e);return t!==null&&t.key.startsWith("custom.")}function Mb(e,t){return e??t??null}function Ri(e,t,n){if(id(e))return!0;switch(t){case"route":return od(e)||rd(e)||hr(e);case"base":return hr(e);case"modal":return hr(e);case"extension":return hr(e,n)?!0:od(e)||Db(e)||rd(e);default:return!1}}function et(e){return typeof e=="object"&&e!==null&&typeof e.responsive=="string"}function yr(e,t){return et(e)?et(t)&&e.responsive===t.responsive:!et(t)&&e===t}function at(e){const t=[];let n=!1;for(const o of e){if(et(o)){t.push("responsive",o.responsive),n=!0;continue}n?t.push("children",String(o)):(t.push(String(o)),n=!0)}return t.join(".")}function Qt(e){return Array.isArray(e.children)?e.children:[]}function br(e,t){const n=e.responsive?.[t];return n&&Array.isArray(n.children)?n.children:[]}function Be(e,t){if(!e)return null;if(t.length===0)return e;let n=e,o=Qt(e);for(const r of t){if(et(r)){o=br(n,r.responsive);continue}if(r<0||r>=o.length||(n=o[r],!n))return null;o=Qt(n)}return n}function Lb(e,t,n){if(!e||t.length===0)return t;let o=e,r=Qt(e),s;for(let a=0;a=2?t[t.length-2]:void 0;if(r!==void 0&&et(r)){const a=Be(e,t.slice(0,-2));return a?{owner:a,children:br(a,r.responsive),branchKey:r.responsive,index:o}:null}const s=Be(e,t.slice(0,-1));return s?{owner:s,children:Qt(s),index:o}:null}function es(e,t){if(e.branchKey!==void 0){const n={...e.owner.responsive??{}};n[e.branchKey]={...n[e.branchKey]??{},children:t},e.owner.responsive=n}else e.owner.children=t}function Rt(e){const t={...e};t.props&&typeof t.props=="object"&&(t.props={...t.props});const n=Qt(e);if(n.length>0&&(t.children=n.map(Rt)),e.responsive&&typeof e.responsive=="object"){const o={};for(const r of Object.keys(e.responsive)){const s=e.responsive[r];if(!s||typeof s!="object"){o[r]=s;continue}const a={...s};Array.isArray(s.children)&&(a.children=s.children.map(Rt)),a.props&&typeof a.props=="object"&&(a.props={...a.props}),o[r]=a}t.responsive=o}return t}function ts(e,t,n,o){const r=Rt(e),s=t.length>0?t[t.length-1]:void 0;if(s!==void 0&&et(s)){const p=Be(r,t.slice(0,-1));if(!p)return r;const f=br(p,s.responsive),b=Math.max(0,Math.min(n,f.length)),g=[...f];return g.splice(b,0,o),es({owner:p,branchKey:s.responsive},g),r}const a=Be(r,t);if(!a)return r;const l=Qt(a),d=Math.max(0,Math.min(n,l.length)),c=[...l];return c.splice(d,0,o),a.children=c,r}function ns(e,t){if(t.length===0)return e;const n=Rt(e),o=ld(n,t);if(!o||o.index<0||o.index>=o.children.length)return n;const r=[...o.children];return r.splice(o.index,1),es(o,r),n}function Pb(e,t,n,o){if(t.length===0||!n||et(t[t.length-1]))return e;const r=Rt(e),s=Be(r,t);if(!s)return r;const a=s.responsive&&typeof s.responsive=="object"?s.responsive[n]:void 0;if(a&&Array.isArray(a.children))return r;const l=o&&s.responsive&&typeof s.responsive=="object"?s.responsive[o]:void 0,c=(l&&Array.isArray(l.children)?l.children:Qt(s)).map(Rt),p={...s.responsive??{}};return p[n]={...p[n]??{},children:c},s.responsive=p,r}function Ob(e,t,n){if(t.length===0||!n||et(t[t.length-1]))return e;const o=Rt(e),r=Be(o,t);if(!r||!r.responsive||typeof r.responsive!="object")return o;const s=r.responsive[n];if(!s||!Array.isArray(s.children))return o;const a={...r.responsive},l={...a[n]};return delete l.children,Object.keys(l).length===0?delete a[n]:a[n]=l,r.responsive=Object.keys(a).length>0?a:void 0,o}function Bb(e,t,n,o){if(t.length===0)return e;const r=Be(e,t);if(!r||Wb(t,n))return e;const s=Rt(r),a=ns(e,t),l=dd(n,t);let d=o;const c=t.slice(0,-1);if(cd(c,n)){const p=t[t.length-1];(typeof p=="number"?p:0)o){const s=[...e];return s[n]=r-1,s}return e}function cd(e,t){if(e.length!==t.length)return!1;for(let n=0;ne.length||cd(e,t)}function os(e){const t={...e};if(t.props&&typeof t.props=="object"&&(t.props={...t.props}),typeof t.id=="string"&&t.id.length>0){const o=typeof t.name=="string"?t.name:"node";t.id=`${o}_${jb()}`}const n=Qt(e);return n.length>0&&(t.children=n.map(os)),t}function Ot(e,t,n){if(t.length===0)return n(e);const o=Rt(e),r=Be(o,t);if(!r)return o;const s=n(r),a=ld(o,t);if(!a||a.index<0||a.index>=a.children.length)return o;const l=[...a.children];return l[a.index]=s,es(a,l),o}function jb(){return Math.floor(Math.random()*2821109907456).toString(36).padStart(8,"0")}function Vn(e){if(!Array.isArray(e)||e.length===0)return[];const t=[];for(const n of e){const o=Hb(n);o.length>0&&t.push(...o)}return t}function Hb(e){if(!e||typeof e!="object")return[];const t=e.__source,n=e._fromBase===!0,o=t?.kind;if(o==="extension"||o==="partial")return[];if(o==="base"||n){const s=Array.isArray(e.children)?e.children:[];return Vn(s)}const r={...e};return delete r.__source,delete r._fromBase,delete r.__injectedProps,Array.isArray(r.children)&&(r.children=Vn(r.children)),[r]}function _o(e){if(!e||typeof e!="object")return e;const t=e.__editor,n=t&&typeof t=="object"&&!Array.isArray(t)?t.original:void 0,o=n&&typeof n=="object"&&!Array.isArray(n)?n:void 0,r=Array.isArray(e.components)?e.components:[],s=r.length>0,a=Vn(r),l=o?{...o}:{...e};if(typeof l.extends=="string"&&l.extends.length>0){delete l.components;const c=l.slots&&typeof l.slots=="object"&&!Array.isArray(l.slots)?l.slots:{},p=Object.keys(c);if(!s&&p.length>0){const f={};for(const[b,g]of Object.entries(c))f[b]=Array.isArray(g)?Vn(g):g;l.slots=f}else if(p.length===1)l.slots={[p[0]]:a};else if(p.length===0)l.slots={content:a};else{const f={};for(const[b,g]of Object.entries(c))f[b]=Array.isArray(g)?Vn(g):g;l.slots=f}}else l.components=a,delete l.slots;return delete l.lock_version,delete l.__editor,l}const ud="extension",Un="extensionless";function Fb(){const e=globalThis?.G7Config;if(globalThis?.__g7AssetUrlMode===Un)return Un;const n=e?.assetUrlMode;return n===Un||n===ud?n:e?.settings?.general?.asset_url_mode===Un?Un:ud}function Kb(){return Fb()===Un}function en(e,t,n,o){const r=e.replace(/\/+$/,""),s=t.replace(/^\.+/,""),a=Kb()?r:`${r}.${s}`,l=[];return o&&l.push(o.replace(/^[?&]+/,"")),n!=null&&n!==""&&l.push(`v=${n}`),l.length>0?`${a}?${l.join("&")}`:a}const pd=/^\s*\$t:([a-zA-Z0-9._-]+)\s*$/,mr="custom.",Vb=/\{\{.*?\}\}/;function Ub(e){return!!(!e||e.iteration&&typeof e.iteration=="object")}function fd(e,t){const n=e?.text,o=typeof n=="string"?n:"";if(Ub(e)||typeof n!="string")return{sourceState:"plain_text",editable:!1,customKey:null,displayValue:o};const r=vt(o);if(r&&r.key.startsWith(mr)){const a=t?t(r.key):r.key;return{sourceState:"custom_key",editable:!0,customKey:r.key,displayValue:a,isParamKey:!0}}const s=pd.exec(o);if(s){const a=s[1];if(a.startsWith(mr)){const d=t?t(a):a;return{sourceState:"custom_key",editable:!0,customKey:a,displayValue:d}}const l=t?t(a):"";return{sourceState:"plain_text",editable:!0,customKey:null,displayValue:l&&l!==a?l:""}}if(Vb.test(o)){const a=gr(o),l=pd.exec(a);if(l&&l[1].startsWith(mr)){const f=l[1],b=t?t(f):f;return{sourceState:"custom_key",editable:!0,customKey:f,displayValue:b}}const d=Ji(o,t),c=gr(d),p=/\$t:[a-zA-Z0-9._-]+/.test(c);if(c.length>0){const f=Zi(o,t);return{sourceState:"plain_with_binding",editable:!0,customKey:null,displayValue:p?"":c,chipValue:f.keyifiable?f.chipValue:void 0,chipParamLabels:f.keyifiable?f.paramLabels:void 0}}return{sourceState:"binding_expression",editable:!1,customKey:null,displayValue:o}}return{sourceState:"plain_text",editable:!0,customKey:null,displayValue:o}}function qb(){const{state:e}=Qe(),t=Ft(),n=e.templateIdentifier,o=e.locale,r=e.selectedRoute?.layoutName??null,s=u.useCallback(p=>{try{const b=Pt.getInstance().translate(p,{templateId:n,locale:o});return b&&b!==p?b:""}catch{return""}},[n,o]),a=u.useCallback(p=>fd(p,s),[s]),l=u.useCallback(p=>{Et({op:"inline_edit_cancel",componentPath:p?at(p):null,timestamp:Date.now()})},[]),d=u.useCallback(async(p,f)=>{if(!t)return{kind:"error",message:"no document context"};const g={children:t.document?.raw?.components??[]},m=Be(g,p),h=fd(m,s);if(!h.editable)return Et({op:"inline_edit_blocked_binding",sourceState:h.sourceState,componentPath:at(p),timestamp:Date.now()}),{kind:"blocked"};if(h.customKey){if(f===h.displayValue)return{kind:"noop",translationKey:h.customKey};xo(n,o,h.customKey,f);const S=await vr(n,h.customKey,o,f);return S.kind==="error"?{kind:"error",message:S.message}:(await tn(n,o),Et({op:"inline_edit_update_value",sourceState:"custom_key",componentPath:at(p),translationKey:h.customKey,toLocale:o,valueLength:f.length,valueHash:Li(f),timestamp:Date.now()}),{kind:"updated",translationKey:h.customKey})}const v=typeof m?.text=="string"?m.text:"",y=h.sourceState==="plain_with_binding",_=Ji(v,s),w=y?Rl(_):f,k=S=>y?Ql(S,v):S;t.patchLayout(S=>Ot({children:S},p,E=>({...E,text:f})).children??[]);const x=await qn(n,r,o,w);if(x.kind==="error"||!x.resource)return{kind:"error",message:x.message};const $=x.resource.translation_key;return xo(n,o,$,w),t.patchLayout(S=>Ot({children:S},p,E=>({...E,text:k(`$t:${$}`)})).children??[]),await tn(n,o),Et({op:"inline_edit_create_key",sourceState:h.sourceState,componentPath:at(p),translationKey:$,toLocale:o,valueLength:f.length,valueHash:Li(f),timestamp:Date.now()}),{kind:"created",translationKey:$,id:x.resource.id}},[t,n,o,r,s]),c=u.useCallback(async(p,f)=>{if(!t)return{kind:"error",message:"no document context"};const g={children:t.document?.raw?.components??[]},m=Be(g,p),h=typeof m?.text=="string"?m.text:"",v=vt(h);if(v&&v.key.startsWith(mr))return _r(n,v.key,o,f),xo(n,o,v.key,f),t.markDirty?.(),{kind:"updated",translationKey:v.key};const y=Zi(h,s),_=gr(f.replace(/\{\{?p\d+\}?\}/g," ")).replace(/\s+/g," ").trim(),w=await qn(n,r,o,_);if(w.kind==="error"||!w.resource)return{kind:"error",message:w.message};const k=w.resource.translation_key,x=An(f),$=w.resource.values??{},S={[o]:f};for(const C of Object.keys($)){if(C===o)continue;let T=$[C]??"";for(const E of x)T=Xi(T,E);S[C]=T}return wo(n,k,S),xo(n,o,k,f),t.patchLayout(C=>Ot({children:C},p,A=>({...A,text:Zl(`$t:${k}`,y)})).children??[]),t.markDirty?.(),await tn(n,o),xo(n,o,k,f),Et({op:"inline_edit_create_key",sourceState:"plain_with_binding",componentPath:at(p),translationKey:k,toLocale:o,valueLength:f.length,valueHash:Li(f),timestamp:Date.now()}),{kind:"created",translationKey:k}},[t,n,o,r]);return{classify:a,commit:d,trackCancel:l,keyifyChipValue:c}}async function qn(e,t,n,o){const r=`/api/admin/templates/${encodeURIComponent(e)}/custom-translations`;try{const s=await fetch(r,{method:"POST",credentials:"same-origin",headers:Ne({"Content-Type":"application/json"}),body:JSON.stringify({layout_name:t,locale:n,value:o})}),a=await s.json().catch(()=>null);if(!s.ok)return{kind:"error",message:a?.message??`HTTP ${s.status}`};const l=a?.data;return!l||typeof l.translation_key!="string"?{kind:"error",message:"invalid response"}:{kind:"ok",resource:l}}catch(s){return{kind:"error",message:s instanceof Error?s.message:"network error"}}}async function vr(e,t,n,o){const r=await cn(e,t);if(!r)return{kind:"error",message:"custom key not found"};const s=`/api/admin/templates/${encodeURIComponent(e)}/custom-translations/${r.id}`,a={...r.values??{},[n]:o};try{const l=await fetch(s,{method:"PUT",credentials:"same-origin",headers:Ne({"Content-Type":"application/json"}),body:JSON.stringify({values:a,expected_lock_version:r.lock_version})}),d=await l.json().catch(()=>null);return l.status===409?{kind:"error",message:"concurrent_modification"}:l.ok?{kind:"ok"}:{kind:"error",message:d?.message??`HTTP ${l.status}`}}catch(l){return{kind:"error",message:l instanceof Error?l.message:"network error"}}}async function cn(e,t){const n=`/api/admin/templates/${encodeURIComponent(e)}/custom-translations`;try{const o=await fetch(n,{method:"GET",credentials:"same-origin",headers:Ne()});if(!o.ok)return null;const s=(await o.json().catch(()=>null))?.data;return Array.isArray(s)?s.find(a=>a.translation_key===t)??null:null}catch{return null}}function xo(e,t,n,o){try{Pt.getInstance().setTranslationValue(e,t,n,o)}catch{}if(typeof window<"u")try{window.dispatchEvent(new CustomEvent(kt,{detail:{templateIdentifier:e,locale:t}}))}catch{}}const kt="g7le:translations-refreshed";async function tn(e,t){if(typeof window>"u")return;const n=t??window.__g7EditorContentLocale;if(n){try{const o=Pt.getInstance();try{const r=await fetch(en(`/api/templates/${encodeURIComponent(e)}/config`,"json"),{headers:{Accept:"application/json"},credentials:"same-origin"}).then(a=>a.ok?a.json():null),s=r?.data?.cache_version??r?.cache_version;if(typeof s=="number"&&s>0){o.setCacheVersion(s);const a=window;a.G7Config&&(a.G7Config.cache_version=s)}}catch{}await o.loadTranslations(e,n,"/api",!0)}catch{}try{window.dispatchEvent(new CustomEvent(kt,{detail:{templateIdentifier:e,locale:n}}))}catch{}}}const nn=new Map;function _r(e,t,n,o){const r=nn.get(t)??{};r[n]=o,nn.set(t,r);try{Pt.getInstance().setTranslationValue(e,n,t,o)}catch{}if(typeof window<"u")try{window.dispatchEvent(new CustomEvent(kt,{detail:{templateIdentifier:e,locale:n}}))}catch{}}function wo(e,t,n){for(const[o,r]of Object.entries(n))_r(e,t,o,r)}function It(e,t){return nn.get(e)?.[t]}function Gb(e){const t=nn.get(e);return t?{...t}:void 0}function Yb(){return nn.size>0}function gd(e,t){for(const[n,o]of nn.entries())for(const[r,s]of Object.entries(o))try{e.setTranslationValue(t,r,n,s)}catch{}}async function Xb(e){if(nn.size===0)return{ok:0,failed:[]};const t=Array.from(nn.entries());let n=0;const o=[];for(const[r,s]of t)try{const a=await cn(e,r);if(!a){o.push(r);continue}const l={...a.values??{},...s},d=`/api/admin/templates/${encodeURIComponent(e)}/custom-translations/${a.id}`;if(!(await fetch(d,{method:"PUT",credentials:"same-origin",headers:Ne({"Content-Type":"application/json"}),body:JSON.stringify({values:l,expected_lock_version:a.lock_version})})).ok){o.push(r);continue}n+=1}catch{o.push(r)}for(const[r]of t)o.includes(r)||nn.delete(r);try{await tn(e)}catch{}return{ok:n,failed:o}}function Gn(e,t){const n=`layout_editor.locale.${e}`,o=t(n);return o&&o!==n?o:e.toUpperCase()}function hd(){if(typeof window>"u")return[];const t=window.G7Config?.appConfig?.supportedLocales;return Array.isArray(t)?t.filter(n=>typeof n=="string"&&n.length>0):[]}function Jb({locales:e}={}){const{t}=tt(),{state:n,dispatch:o}=Qe();u.useEffect(()=>{window.__g7EditorContentLocale=n.locale},[n.locale]);const r=e??hd(),s=r.includes(n.locale)?r:[n.locale,...r];if(s.length<=1)return i.jsxs("span",{className:"g7le-locale-switcher g7le-locale-switcher--single","data-testid":"g7le-locale-switcher-single",style:{fontSize:11,color:"#475569",padding:"0 4px"},children:[t("layout_editor.chrome.toolbar.locale_switcher_label"),": ",Gn(n.locale,t)]});const a=l=>{if(l===n.locale)return;const d=n.locale;o({type:"SET_LOCALE",locale:l}),Et({op:"locale_switch",fromLocale:d,toLocale:l,timestamp:Date.now()})};return i.jsxs("div",{className:"g7le-locale-switcher","data-testid":"g7le-locale-switcher",role:"group","aria-label":t("layout_editor.chrome.toolbar.locale_switcher_label"),style:{display:"inline-flex",alignItems:"center",gap:4},children:[i.jsx("span",{style:{fontSize:11,color:"#475569"},children:t("layout_editor.chrome.toolbar.locale_switcher_label")}),i.jsx("div",{style:{display:"inline-flex",gap:2},children:s.map(l=>{const d=l===n.locale;return i.jsx("button",{type:"button","data-testid":`g7le-locale-${l}`,"aria-pressed":d,onClick:()=>a(l),style:{padding:"2px 8px",fontSize:12,cursor:"pointer",background:d?"#0f172a":"#f8fafc",color:d?"#fff":"#0f172a",border:"1px solid #cbd5e1",borderRadius:4},children:Gn(l,t)},l)})})]})}const Zb=/\{\{?(p\d+)\}?\}/g;function Qb(e){const t=[];if(typeof e!="string"||e.length===0)return t;const n=new RegExp(Zb.source,"g");let o=0,r;for(;(r=n.exec(e))!==null;){const s=r.index,a=s+r[0].length;s>o&&t.push({kind:"text",raw:e.slice(o,s),start:o,end:s}),t.push({kind:"chip",raw:r[0],paramName:r[1],start:s,end:a}),o=a}return o{n.push({kind:"text",text:a}),r=!0};for(const a of t)a.kind==="text"?(o=a.raw,s(o),o=""):(r||s(""),n.push({kind:"chip",paramName:a.paramName}),r=!1);return r||s(""),n}function em(e,t,n,o){const r=[];return e.forEach((s,a)=>{if(s.kind==="chip"){if(s.paramName===t)return;r.push(`{${s.paramName}}`)}else{const l=s.text??"";if(a===n){const d=Math.max(0,Math.min(o,l.length));r.push(l.slice(0,d),`{${t}}`,l.slice(d))}else r.push(l)}}),r.join("")}function xr({value:e,onChange:t,t:n,paramLabels:o,onRequestInsert:r,onRemoveChip:s,testIdSuffix:a="pc",disabled:l=!1,hideInsertButton:d=!1,caretRef:c}){const p=u.useMemo(()=>Rb(e),[e]),f=u.useRef(null),[b,g]=u.useState(null),[m,h]=u.useState(null),[v,y]=u.useState(null),_=u.useMemo(()=>p.map(O=>O.kind==="chip"?`c:${O.paramName}`:"t").join("|"),[p]),w=u.useRef(null),k=u.useRef([]),x=u.useRef(!1);u.useLayoutEffect(()=>{const O=x.current;x.current=!1,!(!O&&w.current===_)&&(w.current=_,p.forEach((z,H)=>{if(z.kind!=="text")return;const P=k.current[H];P&&P.textContent!==(z.text??"")&&(P.textContent=z.text??"")}))},[_,p,e]);const $=()=>{const O=f.current;if(!O)return e;const z=[];for(const H of Array.from(O.querySelectorAll("[data-seg]")))H.dataset.seg==="chip"?z.push(`{${H.dataset.param??""}}`):z.push(H.textContent??"");return z.join("")},S=()=>{l||t($())},C=u.useRef(null),T=u.useRef(!1),E=(O,z)=>{if(!l){O.preventDefault(),O.stopPropagation(),C.current={param:z,pointerId:O.pointerId},T.current=!1,g(z);try{O.currentTarget.setPointerCapture(O.pointerId)}catch{}}},A=O=>{const z=C.current;if(!z||O.pointerId!==z.pointerId)return;T.current=!0;const H=B(O.clientX,O.clientY);H&&(h({slotIdx:H.slotIdx,offset:H.offset}),y(nm(f.current,H.slotIdx,H.offset)))},N=(O,z)=>{if(O.stopPropagation(),T.current){T.current=!1;return}s?.(z)},D=O=>{const z=C.current;if(!z||O.pointerId!==z.pointerId)return;try{O.currentTarget.releasePointerCapture(O.pointerId)}catch{}C.current=null,T.current&&typeof setTimeout=="function"&&setTimeout(()=>{T.current=!1},0);const H=B(O.clientX,O.clientY);if(g(null),h(null),y(null),!H)return;const P=f.current;if(!P)return;const L=Array.from(P.querySelectorAll("[data-seg]")).map(Y=>Y.dataset.seg==="chip"?{kind:"chip",paramName:Y.dataset.param??""}:{kind:"text",text:Y.textContent??""}),F=em(L,z.param,H.slotIdx,H.offset);F!==e&&(x.current=!0,t(F))},B=(O,z)=>{const H=f.current;if(!H)return null;const P=Array.from(H.querySelectorAll("[data-seg]")),I=H.ownerDocument,L=I.elementFromPoint(O,z);let F=L?.closest('[data-seg="text"]');if(F)return{slotIdx:P.indexOf(F),offset:tm(I,F,O,z)};const Y=L?.closest('[data-seg="chip"]');if(Y){const X=P.indexOf(Y),Z=Y.getBoundingClientRect();if(O=0){const ae=P[X-1];return{slotIdx:X-1,offset:(ae.textContent??"").length}}if(X+1({s:X,i:Z})).filter(X=>X.s.dataset.seg==="text").pop();return K?{slotIdx:K.i,offset:(K.s.textContent??"").length}:null},M=()=>{l||!r||r(yd(f.current,e.length))};return u.useEffect(()=>{if(c)return c.current=()=>yd(f.current,e.length),()=>{c.current=null}},[c,e.length]),i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[i.jsxs("div",{ref:f,"data-testid":`g7le-chip-input-${a}`,className:"g7le-chip-input",style:om,children:[p.map((O,z)=>O.kind==="chip"?i.jsxs("span",{"data-seg":"chip","data-param":O.paramName,"data-testid":`g7le-chip-${a}-${O.paramName}`,contentEditable:!1,onPointerDown:H=>E(H,O.paramName??""),onPointerMove:A,onPointerUp:D,title:n("layout_editor.translation.placeholder_locked"),style:{...am,...b===O.paramName?lm:null,touchAction:"none"},children:[i.jsx("span",{"aria-hidden":"true",style:dm,children:"⠿"}),i.jsx("span",{"aria-hidden":"true",style:{marginRight:3},children:"🔗"}),i.jsx("span",{style:cm,children:o?.[O.paramName??""]??O.paramName}),s&&!l&&i.jsx("button",{type:"button","data-testid":`g7le-chip-remove-${a}-${O.paramName}`,"aria-label":n("layout_editor.inline_binding.clear"),title:n("layout_editor.inline_binding.clear"),onPointerDown:H=>{H.stopPropagation(),H.preventDefault()},onClick:H=>N(H,O.paramName??""),style:um,children:"✕"})]},`chip-${O.paramName}`):i.jsx("span",{ref:H=>{k.current[z]=H},"data-seg":"text",contentEditable:!l,suppressContentEditableWarning:!0,onInput:S,"data-testid":`g7le-chip-text-${a}-${z}`,style:{...rm,...b?im:null,...m?.slotIdx===z?sm:null}},`text-slot-${z}`)),v&&i.jsx("span",{"aria-hidden":"true","data-testid":`g7le-chip-caret-${a}`,style:{position:"absolute",left:v.left,top:v.top,width:2,height:v.height,background:"#2563eb",borderRadius:1,pointerEvents:"none",boxShadow:"0 0 0 1px rgba(37,99,235,0.3)"}})]}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[r&&!d&&i.jsxs("button",{type:"button","data-testid":`g7le-chip-insert-${a}`,onClick:M,disabled:l,style:pm,children:["+ ",n("layout_editor.inline_binding.insert_data")]}),i.jsx("span",{style:fm,children:n("layout_editor.translation.placeholder_locked")})]})]})}function tm(e,t,n,o){const r=(t.textContent??"").length;try{const a=e;let l=null,d=0;if(typeof a.caretRangeFromPoint=="function"){const c=a.caretRangeFromPoint(n,o);c&&(l=c.startContainer,d=c.startOffset)}else if(typeof a.caretPositionFromPoint=="function"){const c=a.caretPositionFromPoint(n,o);c&&(l=c.offsetNode,d=c.offset)}if(l&&t.contains(l))return Math.max(0,Math.min(d,r))}catch{}const s=t.getBoundingClientRect();return n>s.left+s.width/2?r:0}function nm(e,t,n){if(!e)return null;const r=Array.from(e.querySelectorAll("[data-seg]"))[t];if(!r)return null;const s=e.getBoundingClientRect();try{const d=r.firstChild,c=e.ownerDocument;if(d&&d.nodeType===Node.TEXT_NODE&&(d.textContent??"").length>0){const p=c.createRange(),f=Math.max(0,Math.min(n,(d.textContent??"").length));p.setStart(d,f),p.setEnd(d,f);const b=p.getClientRects(),g=b.length>0?b[0]:p.getBoundingClientRect();if(g&&(g.height>0||g.width>=0))return{left:g.left-s.left,top:g.top-s.top,height:g.height||r.getBoundingClientRect().height}}}catch{}const a=r.getBoundingClientRect();return{left:(n>0?a.right:a.left)-s.left,top:a.top-s.top,height:a.height||16}}function yd(e,t){if(!e)return t;try{const n=e.ownerDocument.defaultView?.getSelection();if(!n||n.rangeCount===0)return t;const o=n.getRangeAt(0);let r=o.startContainer,s=null;for(;r&&r!==e;){if(r instanceof HTMLElement&&r.dataset.seg==="text"){s=r;break}r=r.parentNode}if(!s||!e.contains(s))return t;const a=Array.from(e.querySelectorAll("[data-seg]"));let l=0;for(const d of a){if(d===s)break;l+=d.dataset.seg==="chip"?`{${d.dataset.param??""}}`.length:(d.textContent??"").length}return l+o.startOffset}catch{return t}}const om={position:"relative",display:"flex",flexWrap:"wrap",alignItems:"center",gap:2,minHeight:30,padding:"4px 8px",border:"1px solid #cbd5e1",borderRadius:4,background:"#fff",fontSize:13,lineHeight:1.6},rm={outline:"none",minWidth:8,minHeight:"1.2em",whiteSpace:"pre-wrap",color:"#0f172a",display:"inline-block"},im={boxShadow:"inset 0 -2px 0 #93c5fd",background:"#eff6ff",borderRadius:2},sm={background:"#dbeafe",boxShadow:"inset 0 -2px 0 #2563eb"},am={display:"inline-flex",alignItems:"center",gap:1,background:"linear-gradient(180deg,#eff6ff,#dbeafe)",color:"#1d4ed8",border:"1px dashed #60a5fa",borderRadius:9999,padding:"1px 8px 1px 4px",margin:"0 1px",fontSize:12,fontWeight:600,cursor:"grab",userSelect:"none",whiteSpace:"nowrap",boxShadow:"0 1px 2px rgba(37,99,235,0.18)",verticalAlign:"middle"},lm={opacity:.5,borderStyle:"solid",cursor:"grabbing"},dm={color:"#2563eb",opacity:.7,fontSize:11,marginRight:1,cursor:"grab"},cm={textDecoration:"none"},um={marginLeft:4,width:14,height:14,lineHeight:"12px",padding:0,border:"none",borderRadius:9999,background:"rgba(29,78,216,0.12)",color:"#1d4ed8",fontSize:9,fontWeight:700,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",flex:"0 0 auto"},pm={fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#334155",padding:"3px 10px",cursor:"pointer"},fm={fontSize:10,color:"#94a3b8"};function bd(e){e&&(e.style.height="auto",e.style.height=`${Math.max(e.scrollHeight,28)}px`)}function gm(e){bd(e)}function hm(e){const t=new Set;for(const n of e)for(const o of Object.keys(n.values??{}))t.add(o);return Array.from(t).sort()}function ym({templateIdentifier:e,layoutName:t,t:n,referencedKeys:o,onClose:r}){const[s,a]=u.useState([]),[l,d]=u.useState("idle"),[c,p]=u.useState(null),[f,b]=u.useState("all"),[g,m]=u.useState(new Set),[h,v]=u.useState({}),[y,_]=u.useState(null),[w,k]=u.useState({}),x=u.useCallback(async()=>{d("loading"),p(null);const z=await Vy(e,t);z.ok?(a(z.data),v({}),m(new Set),k({}),d("idle")):(p(z.message),d("error"))},[e,t]);u.useEffect(()=>{x()},[x]);const $=u.useMemo(()=>hm(s),[s]),S=u.useMemo(()=>s.filter(z=>f==="all"?!0:z.status===f).slice().sort((z,H)=>{const P=z.updated_at?Date.parse(z.updated_at):0,I=H.updated_at?Date.parse(H.updated_at):0;return I!==P?I-P:H.id-z.id}),[s,f]),C=u.useMemo(()=>s.filter(z=>z.status==="orphaned"),[s]),T=u.useCallback(z=>{const H={...z.values??{}};for(const P of Object.keys(H)){const I=It(z.translation_key,P);I!==void 0&&(H[P]=I)}return H},[]),E=u.useCallback(z=>h[z.id]??T(z),[h,T]),A=u.useCallback((z,H,P)=>{v(I=>{const L=I[z]??s.find(F=>F.id===z)?.values??{};return{...I,[z]:{...L,[H]:P}}})},[s]),N=u.useCallback(async z=>{_(z.id),k(I=>({...I,[z.id]:""}));const H=E(z),P=await Uy(e,z.id,H,z.lock_version);if(P.ok)a(I=>I.map(L=>L.id===z.id?P.data:L)),v(I=>{const L={...I};return delete L[z.id],L});else{const I=P.status===409?n("layout_editor.translation_manager.conflict"):P.message;k(L=>({...L,[z.id]:I}))}_(null)},[e,E,n]),D=u.useCallback(z=>typeof window<"u"&&typeof window.confirm=="function"?window.confirm(n("layout_editor.translation_manager.delete_confirm",{count:z})):!0,[n]),B=u.useCallback(async z=>{if(!D(1))return;const H=await qy(e,z.id);H.ok?(a(P=>P.filter(I=>I.id!==z.id)),m(P=>{const I=new Set(P);return I.delete(z.id),I})):p(H.message)},[e,D]),M=u.useCallback(async z=>{if(z.length===0||!D(z.length))return;const H=await Gy(e,z);if(H.ok){const P=new Set(z);a(I=>I.filter(L=>!P.has(L.id))),m(new Set)}else p(H.message)},[e,D]),O=u.useCallback(z=>{m(H=>{const P=new Set(H);return P.has(z)?P.delete(z):P.add(z),P})},[]);return i.jsxs("div",{className:"g7le-translation-manager","data-testid":"g7le-translation-manager",style:bm,children:[i.jsxs("div",{"data-modal-drag-handle":!0,style:mm,children:[i.jsx("span",{style:{fontSize:14,fontWeight:700},"data-testid":"g7le-translation-manager-title",children:n("layout_editor.translation_manager.title")}),i.jsx("button",{type:"button","aria-label":"close",onClick:r,style:vm,"data-testid":"g7le-translation-manager-close",children:"✕"})]}),i.jsxs("div",{style:_m,children:[i.jsx("div",{style:{display:"inline-flex",gap:4},role:"tablist","aria-label":n("layout_editor.translation_manager.filter_label"),children:["all","active","orphaned"].map(z=>i.jsx("button",{type:"button",role:"tab","aria-selected":f===z,"data-active":f===z?"true":"false",onClick:()=>b(z),style:f===z?xm:md,"data-testid":`g7le-translation-filter-${z}`,children:n(`layout_editor.translation_manager.filter_${z}`)},z))}),i.jsx("div",{style:{flex:1}}),g.size>0&&i.jsxs("button",{type:"button",onClick:()=>void M(Array.from(g)),style:vd,"data-testid":"g7le-translation-bulk-delete",children:["🗑 ",n("layout_editor.translation_manager.delete_selected",{count:g.size})]}),C.length>0&&i.jsxs("button",{type:"button",onClick:()=>void M(C.map(z=>z.id)),style:vd,"data-testid":"g7le-translation-purge-orphaned",children:["🧹 ",n("layout_editor.translation_manager.purge_orphaned",{count:C.length})]})]}),c&&i.jsx("div",{style:wm,"data-testid":"g7le-translation-manager-error",children:c}),i.jsx("div",{style:km,children:l==="loading"?i.jsx("div",{style:_d,"data-testid":"g7le-translation-manager-loading",children:n("layout_editor.translation_manager.loading")}):S.length===0&&l!=="error"?i.jsx("div",{style:_d,"data-testid":"g7le-translation-manager-empty",children:n("layout_editor.translation_manager.empty")}):i.jsx("div",{"data-testid":"g7le-translation-list",style:Sm,children:S.map(z=>{const H=E(z),P=z.status==="orphaned",I=o?o.has(z.translation_key):null;return i.jsxs("div",{style:Cm,"data-testid":`g7le-translation-row-${z.id}`,children:[i.jsxs("div",{style:$m,children:[i.jsx("input",{type:"checkbox",checked:g.has(z.id),onChange:()=>O(z.id),"aria-label":n("layout_editor.translation_manager.select_aria",{key:z.translation_key}),"data-testid":`g7le-translation-select-${z.id}`}),i.jsx("code",{style:Em,children:z.translation_key}),P&&i.jsx("span",{style:Im,"data-testid":`g7le-translation-badge-orphaned-${z.id}`,children:n("layout_editor.translation_manager.badge_orphaned")}),I===!0&&i.jsx("span",{style:Am,"data-testid":`g7le-translation-badge-live-inuse-${z.id}`,children:n("layout_editor.translation_manager.badge_live_in_use")}),I===!1&&i.jsx("span",{style:Tm,"data-testid":`g7le-translation-badge-live-unused-${z.id}`,children:n("layout_editor.translation_manager.badge_live_unused")}),i.jsx("div",{style:{flex:1}}),i.jsx("button",{type:"button",onClick:()=>void B(z),style:Om,"data-testid":`g7le-translation-delete-${z.id}`,children:"🗑"})]}),i.jsxs("div",{style:Dm,children:[$.map(L=>{const F=H[L]??"",Y=An(F).length>0;return i.jsxs("div",{style:zm,"data-testid":`g7le-translation-field-${z.id}-${L}`,children:[i.jsxs("label",{style:Nm,title:L,children:[Gn(L,n),i.jsxs("span",{style:Mm,children:["(",L,")"]})]}),Y?i.jsx("div",{style:{flex:1},"data-testid":`g7le-translation-chip-${z.id}-${L}`,children:i.jsx(xr,{value:F,onChange:K=>A(z.id,L,K),t:n,testIdSuffix:`${z.id}-${L}`})}):i.jsx("textarea",{value:F,rows:1,ref:gm,onChange:K=>{A(z.id,L,K.currentTarget.value),bd(K.currentTarget)},style:Lm,"data-testid":`g7le-translation-input-${z.id}-${L}`})]},L)}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i.jsx("button",{type:"button",disabled:y===z.id,onClick:()=>void N(z),style:Pm,"data-testid":`g7le-translation-save-${z.id}`,children:y===z.id?n("layout_editor.translation_manager.saving"):n("layout_editor.translation_manager.save")}),w[z.id]?i.jsx("span",{style:{fontSize:11,color:"#dc2626"},"data-testid":`g7le-translation-row-error-${z.id}`,children:w[z.id]}):null]})]})]},z.id)})})}),i.jsx("div",{style:Bm,children:i.jsx("button",{type:"button",onClick:r,style:Wm,"data-testid":"g7le-translation-manager-footer-close",children:n("layout_editor.translation_manager.close")})})]})}const bm={display:"flex",flexDirection:"column",minHeight:0,flex:1},mm={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:"1px solid #e2e8f0"},vm={border:"none",background:"transparent",fontSize:16,color:"#94a3b8",cursor:"pointer"},_m={padding:"10px 16px",borderBottom:"1px solid #f1f5f9",display:"flex",gap:8,alignItems:"center"},md={padding:"4px 10px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},xm={...md,borderColor:"#2563eb",background:"#eff6ff",color:"#1d4ed8",fontWeight:600},vd={padding:"4px 10px",fontSize:12,border:"1px solid #fecaca",borderRadius:6,background:"#fff",color:"#dc2626",cursor:"pointer"},wm={padding:"8px 16px",fontSize:12,color:"#b91c1c",background:"#fef2f2"},km={padding:16,overflow:"auto",flex:1,minHeight:120,display:"flex",flexDirection:"column",gap:12},_d={fontSize:13,color:"#94a3b8",textAlign:"center",padding:"32px 0"},Sm={display:"flex",flexDirection:"column",gap:20},Cm={border:"1px solid #e2e8f0",borderRadius:8,padding:10,display:"flex",flexDirection:"column",gap:6},$m={display:"flex",alignItems:"center",gap:8},Em={fontSize:11,background:"#f1f5f9",padding:"2px 6px",borderRadius:4,color:"#0f172a"},Im={fontSize:10,color:"#b45309",background:"#fef3c7",padding:"1px 6px",borderRadius:4,fontWeight:600},Am={fontSize:10,color:"#15803d",background:"#dcfce7",padding:"1px 6px",borderRadius:4,fontWeight:600},Tm={fontSize:10,color:"#9f1239",background:"#ffe4e6",padding:"1px 6px",borderRadius:4,fontWeight:600},Dm={display:"flex",flexDirection:"column",gap:6},zm={display:"flex",alignItems:"flex-start",gap:8},Nm={fontSize:12,color:"#475569",minWidth:88,fontWeight:600,paddingTop:4,display:"flex",flexDirection:"column",lineHeight:1.2},Mm={fontSize:10,color:"#94a3b8",fontWeight:400},Lm={flex:1,padding:"4px 8px",fontSize:13,border:"1px solid #cbd5e1",borderRadius:4,color:"#0f172a",resize:"vertical",overflow:"hidden",minHeight:28,lineHeight:1.4,fontFamily:"inherit",boxSizing:"border-box"},Pm={padding:"5px 12px",fontSize:12,border:"none",borderRadius:6,background:"#2563eb",color:"#fff",cursor:"pointer"},Om={padding:"4px 8px",fontSize:12,border:"1px solid #fecaca",borderRadius:6,background:"#fff",color:"#dc2626",cursor:"pointer"},Bm={padding:"10px 16px",borderTop:"1px solid #e2e8f0",display:"flex",justifyContent:"flex-end"},Wm={padding:"6px 14px",fontSize:13,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"};function jm(){const e=Ft(),{state:t}=Qe(),n=e?.document?.raw??null,o=t.templateIdentifier??"",r=t.selectedRoute?.layoutName??"",s=u.useCallback((c,p)=>{const f=n?.[c];return f===void 0?p:f},[n]),a=u.useCallback((c,p,...f)=>{e&&(f.length>=1?e.patchDocumentRaw(c,p,f[0]):e.patchDocumentRaw(c,p))},[e]),l=u.useCallback(async(c,p)=>!o||!r?null:qn(o,r,c,p),[o,r]),d=u.useCallback(async(c,p,f)=>o?vr(o,c,p,f):null,[o]);return{raw:n,getValue:s,patch:a,createI18nKey:l,updateI18nKeyValue:d}}function Hm(e){const t=e.__source;return t&&(t.kind==="module"||t.kind==="plugin")&&t.identifier?`${t.kind}:${t.identifier}`:"template"}function xd(e,t){if(!t)return null;const n=Hm(e);if(n&&t.bySource){const a=t.bySource[n]?.[e.id];if(a!==void 0)return{value:a,match:{dataSourceId:e.id,resolvedBy:"spec_byId",sourceKey:n}}}const o=t.byDataSourceId?.[e.id];if(o!==void 0)return{value:o,match:{dataSourceId:e.id,resolvedBy:"spec_byId"}};const r=e.endpoint??"";if(t.byEndpointPattern&&typeof r=="string"&&r.length>0){for(const[s,a]of Object.entries(t.byEndpointPattern))if(Fm(r,s))return{value:a,match:{dataSourceId:e.id,resolvedBy:"spec_byEndpoint"}}}return null}function rs(e,t){const n=xd(e,t);if(n)return n;const o=e.fallback?.data;return o!==void 0?{value:{data:Array.isArray(o)?o:[o]},match:{dataSourceId:e.id,resolvedBy:"fallback"}}:{value:{},match:{dataSourceId:e.id,resolvedBy:"inferred"}}}function Fm(e,t){const n=t.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${n}$`).test(e)}function Km(e={}){const{spec:t,overrideSpec:n,onMatch:o}=e;return{has(r){return!0},resolve(r){const s=n?xd(r,n):null,{value:a,match:l}=s??rs(r,t);if(o)try{o(l)}catch{}return a}}}const wd=Lt(),kd=wd.DataBindingEngine,Sd=wd.dataBindingEngine;mo("PipeRegistry");function Vm(e){let t=null,n=0;for(let o=0;o0?e[o-1]:"",a=o{const a=t[r],l=a==null?[]:String(a).split(",").map(d=>d.trim()).filter(Boolean);return l.length===0?"":l.join(" ?? ")+(s?" ?? ":"")});return n=n.replace(/\{(\w+)\}/g,(o,r)=>{const s=t[r];return s===void 0?o:s}),n}function wr(e){const t=e.trim(),n=/^\{\{([\s\S]*)\}\}$/.exec(t);return n?n[1].trim():t}function $d(e){const t=e.trim();return/^\{\{[\s\S]*\}\}$/.test(t)?t:`{{ ${t} }}`}function Ed(e,t){const n={};for(const[r,s]of Object.entries(t))n[r]=typeof s=="string"?wr(s):s;const o=qm(e.expr,n);return $d(o)}function Gm(e,t){if(typeof e!="string")return null;const n=Id(wr(e));for(const o of t){const r=Ym(n,o.expr,o.params);if(r)return{recipeId:o.id,params:r}}return null}function Id(e){return e.replace(/\s+/g," ").trim()}function Ad(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ym(e,t,n){const o=[],r=new Set;let s="";const a=/\{(\w+)(\*?)\}(\s*\?\?\s*)?/g;let l=0,d;const c=Id(t);for(;(d=a.exec(c))!==null;){const g=c.slice(l,d.index);s+=Ad(g).replace(/\\ /g,"\\s*");const m=d[2]==="*",h=!!d[3];m?(r.add(d[1]),s+="(.*?)",h&&(s+="(?:\\s*\\?\\?\\s*)?")):(s+="(.+?)",h&&(s+="\\s*\\?\\?\\s*")),o.push(d[1]),l=a.lastIndex}s+=Ad(c.slice(l)).replace(/\\ /g,"\\s*");let p;try{p=new RegExp(`^${s}$`)}catch{return null}const f=p.exec(e);if(!f)return null;const b={};if(o.forEach((g,m)=>{let h=(f[m+1]??"").trim();r.has(g)&&(h=h.split(/\s*\?\?\s*/).map(v=>v.trim()).filter(Boolean).join(", ")),b[g]=h}),n.length>0){const g=new Set(n.map(m=>m.key));for(const m of Object.keys(b))g.has(m)||delete b[m]}return b}function Xm(e){const t=`x.${e.field}`,n=Jm(e.value);switch(e.cmp){case"=":return`${t} === ${n}`;case"!=":return`${t} !== ${n}`;case">":return`${t} > ${n}`;case"<":return`${t} < ${n}`;case">=":return`${t} >= ${n}`;case"<=":return`${t} <= ${n}`;case"includes":return`(${t} ?? []).includes(${n})`;default:return`${t} === ${n}`}}function Jm(e){const t=e.trim();return t==="true"||t==="false"||t!==""&&!Number.isNaN(Number(t))||/^['"].*['"]$/.test(t)||/[.([{]/.test(t)?t:`'${t.replace(/'/g,"\\'")}'`}function is(e){return!e||e.length===0?"true":e.map(Xm).join(" && ")}function Zm(e){const n=`(${(e.source??"").trim()||"[]"} ?? [])`;let o;switch(e.op){case"count":o=`${n}.filter(x => ${is(e.conditions)}).length`;break;case"sum":{const r=(e.sumField??"").trim()||"value";o=`${n}.filter(x => ${is(e.conditions)}).reduce((s, x) => s + (x.${r} ?? 0), 0)`;break}case"filter":o=`${n}.filter(x => ${is(e.conditions)})`;break;case"toOptions":{const r=(e.valueField??"").trim()||"value",s=(e.labelField??"").trim()||"label";o=`${n}.map(x => ({ value: x.${r}, label: x.${s} }))`;break}case"nth":{const r=(e.index??"").trim()||"0",s=(e.prop??"").trim();o=`${n}[${r}]${s?`?.${s}`:""}`;break}case"firstOf":{const r=(e.candidates??[]).map(l=>l.trim()).filter(Boolean),s=r.length>0?r.join(" ?? "):"''",a=(e.fallback??"").trim();o=a?`${s} ?? '${a.replace(/'/g,"\\'")}'`:s;break}case"literal":{const r=e.literalKind??"string",s=(e.literalValue??"").trim();r==="number"?o=s===""?"0":s:r==="boolean"?o=s==="true"?"true":"false":o=`'${s.replace(/'/g,"\\'")}'`;break}default:o="[]"}return $d(o)}function Qm(e){if(typeof e!="string")return null;const t=wr(e).trim();let n=/^\((.+?)\s*\?\?\s*\[\]\)\.filter\(x => (.+)\)\.length$/.exec(t);return n?{key:"",op:"count",source:n[1].trim(),conditions:ss(n[2])}:(n=/^\((.+?)\s*\?\?\s*\[\]\)\.filter\(x => (.+)\)\.reduce\(\(s, x\) => s \+ \(x\.(\w+(?:\.\w+)*) \?\? 0\), 0\)$/.exec(t),n?{key:"",op:"sum",source:n[1].trim(),conditions:ss(n[2]),sumField:n[3]}:(n=/^\((.+?)\s*\?\?\s*\[\]\)\.filter\(x => (.+)\)$/.exec(t),n?{key:"",op:"filter",source:n[1].trim(),conditions:ss(n[2])}:(n=/^\((.+?)\s*\?\?\s*\[\]\)\.map\(x => \(\{ value: x\.(\w+(?:\.\w+)*), label: x\.(\w+(?:\.\w+)*) \}\)\)$/.exec(t),n?{key:"",op:"toOptions",source:n[1].trim(),valueField:n[2],labelField:n[3]}:(n=/^\((.+?)\s*\?\?\s*\[\]\)\[(.+?)\](?:\?\.(\w+(?:\.\w+)*))?$/.exec(t),n?{key:"",op:"nth",source:n[1].trim(),index:n[2].trim(),prop:n[3]}:null))))}function ss(e){const t=e.trim();if(t==="true")return[];const n=[];for(const o of Rm(t)){const r=ev(o.trim());r&&n.push(r)}return n}function Rm(e){const t=[];let n=0,o=0;for(let r=0;r=|<=|>|<)\s*(.+)$/.exec(e),t){const n={"===":"=","!==":"!=",">":">","<":"<",">=":">=","<=":"<="};return{field:t[1],cmp:n[t[2]]??"=",value:Td(t[3])}}return null}function Td(e){const t=e.trim(),n=/^'(.*)'$/.exec(t)||/^"(.*)"$/.exec(t);return n?n[1]:t}function Dd(e,t){const n=Gm(e,t);if(n)return{kind:"preset",recipeId:n.recipeId,params:n.params};const o=Qm(e);return o?{kind:"custom",model:o}:{kind:"advanced"}}function tv(e){if(e==null)return"null";if(Array.isArray(e))return"list";switch(typeof e){case"number":return"number";case"boolean":return"boolean";case"string":return"string";default:return"object"}}function zd(e,t){if(typeof e!="string"||e.trim()==="")return{ok:!1,reason:"empty"};const n=wr(e);try{const o=Vm(n)?Sd.evaluatePipeExpression(n,t??{},{skipCache:!0}):Sd.evaluateExpression(n,t??{},{skipCache:!0});return{ok:!0,value:o,type:tv(o)}}catch(o){return{ok:!1,reason:o instanceof Error?o.message:String(o)}}}function Nd(e,t){const n=Array.isArray(e?.data_sources)?e.data_sources:[],o=[];for(const r of n){const s=r?.id;if(typeof s!="string"||s.length===0)continue;const{value:a}=rs(r,t?.sampleData),l=typeof r.label_key=="string"?r.label_key:void 0;o.push({id:s,sample:a,labelKey:l})}return o}function Md(e,t){const n=[];t?.sampleGlobal&&typeof t.sampleGlobal=="object"&&n.push({scope:"_global",tree:t.sampleGlobal});const o={},r={},s={},a=(l,d)=>{if(!(!d||typeof d!="object"||Array.isArray(d)))for(const[c,p]of Object.entries(d))if(p&&typeof p=="object"&&!Array.isArray(p)){const f=l[c]&&typeof l[c]=="object"&&!Array.isArray(l[c])?l[c]:l[c]={};a(f,p)}else c in l||(l[c]=p)};for(const l of t?.states?.groups??[])for(const d of l.items??[]){const c=d.initialState;c?.local&&a(o,c.local),c?.query&&a(r,c.query),c?.route&&a(s,c.route)}return Object.keys(o).length&&n.push({scope:"_local",tree:o}),Object.keys(r).length&&n.push({scope:"query",tree:r}),Object.keys(s).length&&n.push({scope:"route",tree:s}),e?.computed&&typeof e.computed=="object"&&!Array.isArray(e.computed)&&n.push({scope:"_computed",tree:e.computed}),n}function Ld(e,t){const n={};for(const r of t)r.scope!=="_computed"&&(n[r.scope]=r.tree);const o={};for(const[r,s]of Object.entries(e)){if(typeof s!="string"){o[r]=s;continue}const a=zd(s,n);o[r]=a.ok?a.value:s}return o}function nv(e,t){const n=Nd(e,t),o=Md(e,t),r={};for(const s of n)s.sample!==void 0&&(r[s.id]=s.sample);for(const s of o)s.scope==="_computed"?r[s.scope]=Ld(s.tree,o):r[s.scope]=s.tree;return r}function Pd(e){const{raw:t,spec:n,evaluateComputed:o}=e;return u.useMemo(()=>{const r=Nd(t,n),s=Md(t,n);if(o){const a=s.findIndex(l=>l.scope==="_computed");if(a>=0){const l=Ld(s[a].tree,s);s[a]={scope:"_computed",tree:l}}}return Ki({dataSources:r,states:s,spec:n??void 0})},[t,n,o])}function ov(e){const{raw:t,spec:n,pageType:o}=e;return u.useMemo(()=>{const r=Array.isArray(t?.data_sources)?t.data_sources:[],s=[];for(const d of r){const c=d?.id;if(typeof c!="string"||c.length===0)continue;const{value:p}=rs(d,n?.sampleData),f=typeof d.label_key=="string"?d.label_key:void 0;s.push({id:c,sample:p,labelKey:f})}const a=[];n?.sampleGlobal&&typeof n.sampleGlobal=="object"&&a.push({scope:"_global",tree:n.sampleGlobal}),t?.computed&&typeof t.computed=="object"&&!Array.isArray(t.computed)&&a.push({scope:"_computed",tree:t.computed});const l=Ki({dataSources:s,states:a,spec:n??void 0});if(typeof o=="string"&&o!=="")for(const d of["title","description"])l.push({expression:`{{_seo.${o}.${d}}}`,source:"_seo",sourceId:"_seo",path:`${o}.${d}`,shape:"scalar",preview:""});return l},[t,n,o])}function Od(e,t){const n=[],o=new Set,r=s=>{for(const a of s??[]){if(a.kind==="route"&&!a.isRedirect&&typeof a.path=="string"&&a.path.startsWith("/")&&!o.has(a.path)){o.add(a.path);const l=a.label.startsWith("$t:")?a.label.slice(3):a.label,d=a.label.startsWith("$t:")?t(l):l,c=d&&d!==l&&!d.startsWith("$t:")?d:"";n.push({value:a.path,label:c?`${c} (${a.path})`:a.path})}r(a.children)}};return r(e),n}function Bd(e){const t=Array.isArray(e?.data_sources)?e.data_sources:[],n=[];for(const o of t){const r=o?.id;typeof r=="string"&&r.length>0&&n.push({value:r,label:r})}return n}function as(e,t){const n=typeof e.id=="string"?e.id:"",o=typeof e.label_key=="string"?e.label_key:"";if(!o)return null;const r=o.startsWith("$t:")?o.slice(3):o,s=t(r);return s&&s!==r&&!s.startsWith("$t:")&&s!==n?s:null}function ls(e,t){const n=e.__source;if(!n||typeof n!="object"||Array.isArray(n))return null;const o=n;if(o.kind!=="extension")return null;const r=o.extensionSourceType==="plugin"?t("layout_editor.data_sources.source.plugin"):t("layout_editor.data_sources.source.module"),s=typeof o.extensionIdentifier=="string"?o.extensionIdentifier:"",a=typeof o.extensionName=="string"?o.extensionName:"",l=a&&a!==s?`${a} (${s})`:s;return l?`${r}: ${l}`:r}function rv(e,t,n){const o=Array.isArray(e?.data_sources)?e.data_sources:[],r=[],s=new Set;for(const a of o){const l=a?.id;typeof l!="string"||l.length===0||s.has(l)||(s.add(l),r.push({id:l,friendly:as(a,t),source:ls(a,n)}))}return r}function Wd(e){const t=e?.states?.groups??[],n=new Set;for(const o of t)for(const r of o.items??[]){for(const s of Object.keys(r.initialState?.local??{}))n.add(s);for(const s of Object.keys(r.initialState?.global??{}))n.add(s)}return Array.from(n).map(o=>({value:o,label:o}))}function iv(e,t){const n=Array.isArray(e?.modals)?e.modals:[],o=[],r=new Set;for(const s of n){const a=s?.id;typeof a!="string"||a.length===0||r.has(a)||(r.add(a),o.push({value:a,label:sv(s,a,t)}))}return o}function sv(e,t,n){const r=e?.meta?.editor_label;if(typeof r=="string"&&r.length>0)return jd(r,n);const s=e?.title;return typeof s=="string"&&s.length>0?jd(s,n):t}function jd(e,t){if(e.startsWith("$t:")){const n=e.slice(3),o=t?t(n):n;return o&&o!==n?o:n}return e}const Hd=mo("ActionRecipeEngine"),av={api:"apiCall",nav:"navigate",showToast:"toast",setLocalState:"setState"},lv=new Set(["comment"]);function ko(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,o]of Object.entries(e)){if(lv.has(n)||!o||typeof o!="object")continue;const r=o,s=r.build&&typeof r.build=="object"?r.build:typeof r.handler=="string"?{handler:r.handler}:void 0;!s||typeof s.handler!="string"||s.handler.length===0||t.push({id:n,label:typeof r.label=="string"?r.label:void 0,params:Array.isArray(r.params)?r.params:[],build:s})}return t}function on(e){const t=/^\{\{\s*([\w.]+)\s*\}\}$/.exec(e);return t?t[1]:null}const kr="...";function dv(e,t){return e.replace(/\{\{\s*([\w.]+)\s*\}\}/g,(n,o)=>{const r=t[o];return r==null?"":String(r)})}function ds(e,t){if(typeof e=="string"){const n=on(e);return n!==null?n in t?t[n]:void 0:e.includes("{{")?dv(e,t):e}if(Array.isArray(e))return e.map(n=>ds(n,t)).filter(n=>n!==void 0);if(e&&typeof e=="object"){const n={};for(const[o,r]of Object.entries(e)){if(o===kr&&typeof r=="string"){const d=on(r),c=d!==null?t[d]:void 0;if(c&&typeof c=="object"&&!Array.isArray(c))for(const[p,f]of Object.entries(c))f===void 0||p===""||(n[p]=f);continue}const s=ds(r,t);if(s===void 0||Array.isArray(s)&&s.length===0&&(o==="onSuccess"||o==="onError"))continue;const a=on(o),l=a!==null?a in t?String(t[a]):null:o;l===null||l===""||s&&typeof s=="object"&&!Array.isArray(s)&&Object.keys(s).length===0||(n[l]=s)}return n}return e}function cv(e){const t=e.handler;if(typeof t!="string")return e;const n=av[t];if(n)return Hd.warn(`action recipe used forbidden handler "${t}" — corrected to "${n}" (core handler rules)`),{...e,handler:n};if(t==="apiCall"||t==="navigate"){const o=e.params;if(o&&typeof o=="object")for(const r of["target","onSuccess","onError"])r in o&&Hd.warn(`action recipe build placed "${r}" inside params for handler "${t}" — should be top-level (core handler rules)`)}return e}function Sr(e,t){const n=ds(e.build,t);if(typeof n.handler!="string"&&e.build.handler.includes("{{")&&(n.handler=e.build.handler),e.build.handler.includes("{{")){const o=new Set(e.params.filter(r=>r.required).map(r=>r.key));o.size>0&&Fd(e.build,n,o)}return cv(n)}function Fd(e,t,n){if(!e||typeof e!="object"||Array.isArray(e)||!t||typeof t!="object"||Array.isArray(t))return;const o=e,r=t;for(const[s,a]of Object.entries(o))if(s!=="handler"){if(typeof a=="string"){const l=on(a);l!==null&&n.has(l)&&!(s in r)&&(r[s]=a)}else if(a&&typeof a=="object"){if(!(s in r)||typeof r[s]!="object"||r[s]===null)if(JSON.stringify(a).includes("{{"))r[s]={};else continue;Fd(a,r[s],n)}}}function uv(e,t){if(!e||typeof e!="object")return null;const n=e.handler;if(typeof n!="string")return null;let o=null,r=-1;for(const s of t){const a=s.build.handler.includes("{{");if(!a&&s.build.handler!==n||a&&!pv(s.build,e))continue;const l=fv(s.build,e);if(l===null)continue;const d=Object.keys(l).length;d>r&&(r=d,o={recipeId:s.id,values:l})}return o}function pv(e,t){if(typeof t.handler=="string"&&t.handler===e.handler)return!0;const n=e.params;if(!n||typeof n!="object")return!1;const o=t.params;if(!o||typeof o!="object")return!1;const r=o,s=Object.entries(n).filter(([,a])=>typeof a=="string"&&on(a)!==null);return s.length===0?!1:s.every(([a])=>a in r)}function fv(e,t){const n={},o=(r,s)=>{if(typeof r=="string"){const a=on(r);return a!==null?(n[a]=s,!0):r.includes("{{")?typeof s=="string":r===s}if(Array.isArray(r))return Array.isArray(s);if(r&&typeof r=="object"){if(!s||typeof s!="object"||Array.isArray(s))return!1;const a=s,l=r[kr],d=typeof l=="string"?on(l):null,c=new Set(Object.keys(r).filter(p=>p!==kr));for(const[p,f]of Object.entries(r))if(p!==kr){if(typeof f=="string"&&on(f)!==null){const b=on(f);p in a&&(n[b]=a[p]);continue}if(!(p in a)){if(p==="onSuccess"||p==="onError"||p==="params"||p==="identity_target")continue;return!1}if(!o(f,a[p]))return!1}if(d!==null){const p={};for(const[f,b]of Object.entries(a))c.has(f)||(p[f]=b);Object.keys(p).length>0&&(n[d]=p)}return!0}return r===s};return o(e,t)?n:null}function Yn(e,t){const n=typeof e?.handler=="string"?e.handler:"",o=uv(e,t);return o?{kind:"preset",recipeId:o.recipeId,values:o.values,handler:n}:{kind:"advanced",handler:n}}function Kd(e,t,n){const o=e?.label,r=o?n?n(o):o:"",s=[],a=e?.params??[];for(const l of a){if(l.advanced||l.widget==="action-list")continue;const d=t[l.key];if(d==null||d==="")continue;const c=gv(d);if(c!==""&&(s.push(c),s.length>=2))break}return s.length===0?r:`${r} (${s.join(", ")})`}function gv(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):Array.isArray(e)?`[${e.length}]`:e&&typeof e=="object"?"{…}":""}function Vd(e,t){const n={...e};return typeof t=="string"&&t.trim().length>0?n.if=t.trim():delete n.if,n}function cs(e){const t=e?.if;return typeof t=="string"&&t.trim().length>0?t:null}const hv=/^\s*\$t:(custom\.[a-zA-Z0-9._-]+)\s*$/,yv=/^\s*\$t:([a-zA-Z0-9._-]+)\s*$/,bv=/\{\{.*?\}\}/;function Ud(e,t){const n=typeof e=="string"?e:"",o=hv.exec(n);if(o){const a=o[1],l=t?t(a):"";return{customKey:a,binding:!1,paramKey:!1,displayValue:l}}const r=vt(n);if(r&&r.key.startsWith("custom.")){const a=t?t(r.key):"";return{customKey:r.key,binding:!1,paramKey:!0,displayValue:a}}if(bv.test(n))return{customKey:null,binding:!0,paramKey:!1,displayValue:n};const s=yv.exec(n);if(s){const a=s[1],l=t?t(a):"";return{customKey:null,binding:!1,paramKey:!1,displayValue:l&&l!==a?l:""}}return{customKey:null,binding:!1,paramKey:!1,displayValue:n}}function mv(){const{state:e}=Qe(),t=e.templateIdentifier,n=e.locale,o=e.selectedRoute?.layoutName??null,r=u.useCallback(l=>{try{const c=Pt.getInstance().translate(l,{templateId:t,locale:n});return c&&c!==l?c:""}catch{return""}},[t,n]),s=u.useCallback(l=>Ud(l,r),[r]),a=u.useCallback(async(l,d)=>{const c=Ud(l,r);if(c.binding)return{kind:"blocked"};if(c.customKey){if(d===c.displayValue)return{kind:"noop",customKey:c.customKey};const b=await vr(t,c.customKey,n,d);return b.kind==="error"?{kind:"error",message:b.message}:(await tn(t,n),{kind:"updated",customKey:c.customKey})}const p=await qn(t,o,n,d);if(p.kind==="error"||!p.resource)return{kind:"error",message:p.message};const f=p.resource.translation_key;return await tn(t,n),{kind:"created",customKey:f,token:`$t:${f}`}},[t,n,o,r]);return{locale:n,templateIdentifier:t,translate:r,classify:s,commitText:a}}async function us(e,t,n,o,r,s,a,l,d,c){const p=c?Zi(o,c):null,f=!!(p&&p.keyifiable),b=d?d(o):o,g=f?p.chipValue:Rl(b),h=`p${f?p.bindings.length:fr(b).length}`,v=Math.max(0,Math.min(r,g.length)),y=Ul(g,v,h),_=gr(y).replace(/\{\{?p\d+\}?\}/g," ").replace(/\s+/g," ").trim(),w=_.length>0?_:y,k=await qn(e,t,n,w);if(k.kind==="error"||!k.resource)return{kind:"error",message:k.message};const x=k.resource.translation_key,$=An(y),S=k.resource.values??{},C={[n]:y};for(const N of Object.keys(S)){if(N===n)continue;let D=S[N]??"";for(const B of $)D=Xi(D,B);C[N]=D}wo(e,x,C);const T=En(s,a,l);return{kind:"ok",text:`${f?Zl(`$t:${x}`,p):Ql(`$t:${x}`,b)}|${h}=${T}`,key:x}}async function Cr(e,t,n,o,r,s,a){let l=vt(n);if(!l&&typeof n=="string"){const h=/^\s*\$t:(custom\.[A-Za-z0-9._-]+)\s*$/.exec(n);h&&(l={key:h[1],params:[]})}if(!l)return{kind:"error",message:"not a param key"};if(!l.key.startsWith("custom."))return{kind:"error",message:"not a custom param key"};const d=wb(l.params.map(h=>h.name)),c=En(r,s,a),p=`${n.trim()}|${d}=${c}`,f=await cn(e,l.key),b=Gb(l.key)??{},g=new Set([...Object.keys(f?.values??{}),...Object.keys(b),t]);if(g.size===0)return{kind:"error",message:"custom key not found"};const m={};for(const h of g){const v=It(l.key,h)??f?.values?.[h]??"";m[h]=h===t?Ul(v,o,d):Xi(v,d)}return wo(e,l.key,m),{kind:"ok",text:p,paramName:d}}async function So(e,t,n,o){return _r(e,t,n,o),{kind:"ok"}}async function vv(e,t,n){const o=await cn(e,t);if(!o)return{kind:"error",message:"custom key not found"};const r={};for(const[s,a]of Object.entries(o.values??{})){const l=It(t,s)??a;r[s]=n(l)}wo(e,t,r);try{const s=Pt.getInstance();for(const[a,l]of Object.entries(r))s.setTranslationValue(e,a,t,l)}catch{}return{kind:"ok"}}function qd(e,t,n){return vv(e,t,o=>nd(o,n))}function Gd(e,t){if(!(typeof window>"u"))try{window.dispatchEvent(new CustomEvent(kt,{detail:{templateIdentifier:e,locale:t}}))}catch{}}async function $r(e,t,n,o){const r=await qd(e,t,n);return Gd(e,o),r}const _v=/^\s*\$t:(custom\.[a-zA-Z0-9._-]+)\s*$/;function xv(e,t){const n=s=>{const a=[],l=/\{\{?(p\d+)\}?\}/g;let d;for(;(d=l.exec(s))!==null;)a.push(d[1]);return a},o=n(e),r=n(t);return o.length!==r.length?!0:o.some((s,a)=>s!==r[a])}function Yd(e){const t=e.text;if(typeof t!="string")return null;const n=_v.exec(t);if(n)return n[1];const o=vt(t);return o&&o.key.startsWith("custom.")?o.key:null}function ps(e){const t={},n=vt(typeof e=="string"?e:"");for(const o of n?.params??[])t[o.name]=Vt(o.expression);return t}function wv(e){return ps(typeof e.text=="string"?e.text:"")}function Xd({customKey:e,templateIdentifier:t,t:n,paramLabels:o,locales:r,onRemoveParam:s}){const a=r??hd(),l=Ft(),d=o??{},[c,p]=u.useState({status:"idle",values:{}}),[f,b]=u.useState(!1),[g,m]=u.useState(!1),[h,v]=u.useState(null),y=u.useRef({});u.useEffect(()=>{let E=!1;if(!e){p({status:"not_a_key",values:{}});return}return p({status:"loading",values:{}}),(async()=>{const A=await cn(t,e);if(E)return;if(!A){p({status:"error",values:{}});return}const N={...A.values??{}};for(const D of Object.keys(N)){const B=It(e,D);B!==void 0&&(N[D]=B)}for(const D of a){const B=It(e,D);B!==void 0&&(N[D]=B)}y.current={...N},p({status:"loaded",id:A.id,lockVersion:A.lock_version,values:N})})(),()=>{E=!0}},[e,t]),u.useEffect(()=>{if(typeof window>"u"||!e)return;const E=A=>{const N=A.detail;N?.templateIdentifier&&N.templateIdentifier!==t||p(D=>{if(D.status!=="loaded")return D;let B=!1;const M={...D.values};for(const O of Object.keys(M)){const z=It(e,O);z!==void 0&&z!==M[O]&&(M[O]=z,B=!0)}return B?(y.current={...y.current,...M},{...D,values:M}):D})};return window.addEventListener(kt,E),()=>window.removeEventListener(kt,E)},[e,t]);const _=u.useCallback((E,A)=>{p(N=>{const D=N.values[E]??"",B={...N,values:{...N.values,[E]:A}};return e&&xv(D,A)&&(_r(t,e,E,A),y.current={...y.current,[E]:A},l?.markDirty?.(),Gd(t,E)),B})},[e,t,l]),w=u.useCallback(E=>{p(A=>{const N={};for(const[D,B]of Object.entries(A.values))N[D]=nd(B,E);return y.current={...N},{...A,values:N}}),s?.(E)},[s]),k=u.useMemo(()=>[...Object.values(c.values),...Object.values(y.current)].some(A=>An(A).length>0),[c.values]),x=u.useRef(null),$=u.useCallback(()=>{m(!0),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>m(!1),1500)},[]);u.useEffect(()=>()=>{x.current&&clearTimeout(x.current)},[]);const S=u.useCallback(async()=>{if(m(!1),c.status!=="loaded"||c.id===void 0)return;const E=y.current;for(const[N,D]of Object.entries(c.values)){const B=E[N]??"";if(k){const M=An(B);if(M.length===0)continue;const O=An(D);if(!(M.length===O.length&&M.every((H,P)=>H===O[P]))){v(n("layout_editor.translation.placeholder_mismatch"));return}continue}if(Yi(B)&&!Tb(B,D)){v(n("layout_editor.translation.token_mismatch"));return}}if(b(!0),v(null),k){wo(t,e??"",c.values),y.current={...c.values},l?.markDirty?.(),Et({op:"translation_field_update",translationKey:e,changedLocales:Object.keys(c.values),timestamp:Date.now()}),await new Promise(N=>setTimeout(N,0)),b(!1),$();return}const A=`/api/admin/templates/${encodeURIComponent(t)}/custom-translations/${c.id}`;try{const N=await fetch(A,{method:"PUT",credentials:"same-origin",headers:Ne({"Content-Type":"application/json"}),body:JSON.stringify({values:c.values,expected_lock_version:c.lockVersion??0})}),D=await N.json().catch(()=>null);if(N.status===409){v(n("layout_editor.translation.conflict"));return}if(!N.ok){v(D?.message??n("layout_editor.translation.save_failed"));return}const B=typeof D?.data?.lock_version=="number"?D.data.lock_version:(c.lockVersion??0)+1;p(M=>({...M,lockVersion:B})),y.current={...c.values},await tn(t),Et({op:"translation_field_update",translationKey:e,changedLocales:Object.keys(c.values),timestamp:Date.now()}),$()}catch(N){v(N instanceof Error?N.message:n("layout_editor.translation.save_failed"))}finally{b(!1)}},[c,t,e,n]);if(c.status==="not_a_key"||!e)return i.jsx("div",{"data-testid":"g7le-translation-not-a-key",style:fs,children:n("layout_editor.translation.not_a_key")});if(c.status==="loading"||c.status==="idle")return i.jsx("div",{"data-testid":"g7le-translation-loading",style:fs,children:n("layout_editor.translation.loading")});if(c.status==="error")return i.jsx("div",{"data-testid":"g7le-translation-error",style:fs,children:n("layout_editor.translation.load_failed")});const C=new Set([...a,...Object.keys(c.values)]),T=Array.from(C);return i.jsxs("div",{"data-testid":"g7le-translation-field",style:{display:"flex",flexDirection:"column",gap:8},children:[i.jsxs("div",{"data-testid":"g7le-translation-key",style:kv,children:[n("layout_editor.translation.key_label"),": ",i.jsx("code",{style:Sv,children:e})]}),T.map(E=>{const A=c.values[E]??"",N=A.trim().length===0;return i.jsxs("div",{className:"g7le-translation-row","data-testid":`g7le-translation-row-${E}`,style:Cv,children:[i.jsxs("label",{htmlFor:`g7le-translation-input-${E}`,style:{fontSize:12,color:"#475569",minWidth:72,display:"inline-flex",alignItems:"center",gap:4},children:[Gn(E,n),N&&i.jsx("span",{"data-testid":`g7le-translation-missing-${E}`,style:$v,children:n("layout_editor.translation.needs_translation")})]}),k?i.jsx("div",{style:{flex:1},"data-testid":`g7le-translation-chip-${E}`,children:i.jsx(xr,{value:A,onChange:D=>_(E,D),t:n,paramLabels:d,testIdSuffix:E,onRemoveChip:s?w:void 0})}):i.jsx("input",{id:`g7le-translation-input-${E}`,type:"text","data-testid":`g7le-translation-input-${E}`,value:A,placeholder:N?n("layout_editor.translation.needs_translation"):"",onChange:D=>_(E,D.currentTarget.value),onBlur:S,style:{flex:1,padding:"4px 8px",fontSize:13,border:"1px solid #cbd5e1",borderRadius:4,color:N?"#94a3b8":"#0f172a"}})]},E)}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i.jsx("button",{type:"button","data-testid":"g7le-translation-save",disabled:f,onClick:S,style:Ev,children:n(f?"layout_editor.translation.saving":"layout_editor.translation.save")}),g&&!f&&i.jsxs("span",{"data-testid":"g7le-translation-saved",style:{fontSize:11,color:"#16a34a",display:"inline-flex",alignItems:"center",gap:4},children:["✓ ",n("layout_editor.translation.saved")]}),h&&i.jsx("span",{"data-testid":"g7le-translation-save-error",style:{fontSize:11,color:"#dc2626"},children:h})]})]})}const fs={fontSize:12,color:"#94a3b8",padding:"16px 0",textAlign:"center"},kv={fontSize:12,color:"#475569"},Sv={fontSize:11,background:"#f1f5f9",padding:"1px 4px",borderRadius:3,color:"#0f172a"},Cv={display:"flex",alignItems:"center",gap:8},$v={fontSize:10,color:"#b45309",background:"#fef3c7",padding:"0 4px",borderRadius:3},Ev={padding:"6px 12px",fontSize:12,border:"none",borderRadius:6,background:"#2563eb",color:"#fff",cursor:"pointer"};function Xn({anchorRef:e,open:t,onClose:n,children:o,placement:r="bottom",minWidth:s=240,maxWidth:a=360,margin:l=8,testid:d}){const c=u.useRef(null),[p,f]=u.useState(null),b=u.useCallback(()=>{const m=e.current,h=c.current;if(!m||!h)return;const v=m.getBoundingClientRect(),y=window.innerWidth,_=window.innerHeight,w=h.getBoundingClientRect(),k=Math.min(Math.max(w.width,s),a),x=w.height;let $=v.left;$+k+l>y&&($=v.right-k),$=Math.min(Math.max($,l),y-k-l);const S=_-v.bottom-l,C=v.top-l;let T,E;const A=r==="bottom",N=S>=Math.min(x,160),D=C>=Math.min(x,160);A&&N||A&&!D?(T=v.bottom+4,E=S):!A&&D||D?(T=v.top-4-Math.min(x,C),E=C):S>=C?(T=v.bottom+4,E=S):(T=l,E=C),f({left:$,top:T,maxHeight:Math.max(E,120)})},[e,r,s,a,l]);if(u.useLayoutEffect(()=>{if(!t){f(null);return}b()},[t,b]),u.useEffect(()=>{if(!t)return;const m=()=>b();window.addEventListener("resize",m),window.addEventListener("scroll",m,!0);const h=y=>{const _=c.current,w=e.current,k=y.target;_?.contains(k)||w?.contains(k)||n()},v=y=>{y.key==="Escape"&&n()};return document.addEventListener("pointerdown",h,!0),document.addEventListener("keydown",v),()=>{window.removeEventListener("resize",m),window.removeEventListener("scroll",m,!0),document.removeEventListener("pointerdown",h,!0),document.removeEventListener("keydown",v)}},[t,b,n,e]),!t)return null;const g={...Iv,minWidth:s,maxWidth:`min(${a}px, calc(100vw - ${l*2}px))`,...p?{left:p.left,top:p.top,maxHeight:p.maxHeight,visibility:"visible"}:{left:-9999,top:-9999,visibility:"hidden"}};return i.jsx("div",{ref:c,"data-testid":d,style:g,role:"dialog",children:o})}const Iv={position:"fixed",zIndex:1e3,background:"#fff",border:"1px solid #cbd5e1",borderRadius:8,boxShadow:"0 4px 16px rgba(0,0,0,0.14)",padding:6,overflowY:"auto",boxSizing:"border-box"};function Jd(e,t,n){if(!t)return n;const o=e(t);return!o||o===t||o.startsWith("$t:")?n:o}function $t({candidates:e,t,onSelect:n,testIdSuffix:o,defaultOpen:r=!1,floating:s=!0}){const[a,l]=u.useState(r),[d,c]=u.useState(""),p=u.useRef(null),f=u.useMemo(()=>Ui(e,"scalar").map(h=>({...h,resolvedLabel:Jd(t,h.labelKey,h.path||h.sourceId)})),[e,t]),b=u.useMemo(()=>qi(f,d),[f,d]),g=i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"text",autoFocus:!0,"data-testid":`g7le-inline-binding-search-input-${o}`,value:d,placeholder:t("layout_editor.inline_binding.search_placeholder"),onChange:m=>c(m.target.value),style:zv}),i.jsx("div",{style:Nv,children:b.length===0?i.jsx("div",{style:Mv,children:t("layout_editor.inline_binding.no_results")}):b.map(m=>i.jsxs("button",{type:"button","data-testid":`g7le-inline-binding-candidate-${m.expression}`,onClick:()=>{n(m),l(!1),c("")},style:Lv,children:[i.jsxs("span",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start"},children:[i.jsx("span",{style:{fontSize:12},children:m.resolvedLabel}),i.jsxs("span",{style:Pv,children:[Jd(t,m.groupLabelKey,m.sourceId)," · ",m.path||m.sourceId]})]}),i.jsx("span",{style:Ov,children:m.preview})]},m.expression))})]});return i.jsxs("div",{style:s?Dv:{marginTop:4},children:[i.jsx("button",{ref:p,type:"button","data-testid":`g7le-inline-binding-search-toggle-${o}`,onClick:()=>l(m=>!m),title:t("layout_editor.inline_binding.search"),"aria-label":t("layout_editor.inline_binding.search"),"aria-expanded":a,style:Av,children:"🔍"}),s?i.jsx(Xn,{anchorRef:p,open:a,onClose:()=>l(!1),testid:`g7le-inline-binding-picker-${o}`,children:g}):a&&i.jsx("div",{"data-testid":`g7le-inline-binding-picker-${o}`,style:Tv,children:g})]})}const Av={fontSize:13,lineHeight:1,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#334155",padding:"4px 8px",cursor:"pointer",textAlign:"center",whiteSpace:"nowrap"},Tv={marginTop:4,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",padding:6},Dv={display:"inline-block"},zv={width:"100%",padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,boxSizing:"border-box"},Nv={marginTop:4,maxHeight:200,overflowY:"auto",display:"flex",flexDirection:"column",gap:2},Mv={fontSize:11,color:"#94a3b8",padding:"8px 0",textAlign:"center"},Lv={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,border:"none",background:"transparent",cursor:"pointer",padding:"6px 8px",borderRadius:4,textAlign:"left"},Pv={fontSize:10,color:"#94a3b8"},Ov={fontSize:10,color:"#64748b",fontFamily:"monospace",whiteSpace:"nowrap"},Bv=["$localized"];function Jn(e){const t=e.trim();if(!t.startsWith("{{")||!t.endsWith("}}")||t.length<4)return null;let n=0;for(let o=0;oun(n).decomposed)}function Co(e,t,n,o){switch(e.kind){case"leaf":Qd(e.text,t,n,o);return;case"conditional":Co(e.then,t,n,o),o.push({kind:"ellipsis",text:"⋯"});return;case"fallback":Co(e.primary,t,n,o);return;case"concat":e.parts.forEach(r=>Co(r,t,n,o));return;case"raw":default:o.push({kind:"text",text:e.source});return}}function Qd(e,t,n,o){const r=e.trim();if(/^\{\{([\s\S]*)\}\}$/.exec(r)&&!r.slice(2,-2).includes("}}")){o.push({kind:"chip",text:n(r)});return}if(r.startsWith("$t:")){const a=r.slice(3).split("|")[0];o.push({kind:"text",text:t(a)||a});return}for(const a of e.split(/(\{\{(?:[^}]|\}(?!\}))*\}\})/g))a!==""&&(/^\{\{[\s\S]*\}\}$/.test(a)?o.push({kind:"chip",text:n(a)}):o.push({kind:"text",text:a}))}function gs(e,t,n){const o=[];if(typeof e!="string"||e==="")return o;if(Jn(e)===null&&/\{\{/.test(e)){for(const a of e.split(/(\{\{(?:[^}]|\}(?!\}))*\}\})/g))if(!(a===void 0||a===""))if(/^\{\{[\s\S]*\}\}$/.test(a)){const l=un(a);Co(l.node,t,n,o)}else Qd(a,t,n,o);return o}const s=un(e);return Co(s.node,t,n,o),o}function Wv(e){if(typeof e!="string"||e.trim()==="")return"empty";const t=e.trim();if(Jn(t)===null)return"simple";const n=un(e);return n.node.kind==="leaf"?"simple":n.decomposed?"expression":"raw"}function un(e){const t=typeof e=="string"?e:"",n=t.trim();if(n==="")return{node:{kind:"leaf",text:t},decomposed:!1,original:t};const o=Jn(n);if(o===null)return{node:{kind:"leaf",text:t},decomposed:!1,original:t};let r;try{r=Yv(o)}catch{r=null}if(r===null)return{node:{kind:"raw",source:o},decomposed:!1,original:t};if(r.kind==="leaf"||r.kind==="raw")return{node:r,decomposed:!1,original:t};if(r.kind==="fallback"&&r.op==="??"&&jv(r.primary)&&Hv(r.fallback))return{node:{kind:"leaf",text:t},decomposed:!1,original:t};const s=Zn(r,!0);return Rv(o,s)?{node:r,decomposed:!0,original:t}:{node:{kind:"raw",source:o},decomposed:!1,original:t}}function Zn(e,t=!1){const n=ec(e);return t?n:e.kind==="leaf"?e.text:`{{${n}}}`}function $o(e){return Zn({kind:"conditional",condition:{kind:"simple",left:"",op:"truthy",right:""},then:{kind:"leaf",text:typeof e=="string"?e:""},else:{kind:"leaf",text:""}},!1)}function hs(e){return Zn({kind:"fallback",op:"??",primary:{kind:"leaf",text:typeof e=="string"?e:""},fallback:{kind:"leaf",text:""}},!1)}function Eo(e){switch(e.kind){case"leaf":return e.text;case"conditional":return Eo(e.then);case"fallback":return Eo(e.primary);case"concat":return e.parts.map(Eo).join("");case"raw":default:return e.kind==="raw"?`{{${e.source}}}`:""}}function WM(e){return e}function Er(e){if(typeof e!="string"||e.trim()==="")return"";if(Jn(e)===null&&/\{\{/.test(e)){for(const n of e.split(/(\{\{(?:[^}]|\}(?!\}))*\}\})/g))if(!(n===void 0||n===""))return/^\{\{[\s\S]*\}\}$/.test(n)?Eo(un(n).node):n;return""}return Eo(un(e).node)}function jv(e){if(e.kind!=="leaf")return!1;const t=/^\{\{([\s\S]*)\}\}$/.exec(e.text.trim());return t?Qn(t[1].trim()):!1}function Hv(e){if(e.kind!=="leaf")return!1;const t=e.text.trim();return!(/\{\{/.test(t)||t.startsWith("$t:"))}function Ir(e){return`'${e.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}'`}function Fv(e){const t=[];let n=0,o=0;const r=e.length;for(;on&&t.push(Ir(e.slice(n,o)));let s=o+2;for(;s=r)break;const a=e.slice(o+2,s).trim();t.push(a),o=s+2,n=o;continue}o++}return nIo(t,"concat")).join(" + ");case"fallback":return`${Io(e.primary,"fallback")} ${e.op} ${Io(e.fallback,"fallback")}`;case"conditional":return`${Vv(e.condition)} ? ${Io(e.then,"conditional")} : ${Io(e.else,"conditional")}`;default:return""}}function Io(e,t){const n=ec(e);return e.kind==="leaf"||e.kind==="raw"?n:e.kind==="conditional"?t==="conditional"?n:`(${n})`:e.kind==="fallback"?t==="concat"?`(${n})`:n:(e.kind==="concat",n)}const qv=["===","!==","??","||","&&","==","!=",">=","<="];function tc(e){const t=[];let n=0;const o=e.length;for(;n=o)throw new Error("unterminated-binding-in-string");d+=e.slice(l,c+2),l=c+2;continue}if(e[l]===a){d+=a,l++;break}if(a==="`"&&e[l]==="$"&&e[l+1]==="{")throw new Error("template-literal-interpolation-unsupported");d+=e[l],l++}if(l>o||d[d.length-1]!==a)throw new Error("unterminated-string");t.push({kind:"string",value:d,start:n,end:l}),n=l;continue}if(r==="{"&&e[n+1]==="{"){let a=n+2;for(;a"||r==="<"){t.push({kind:"op",value:r,start:n,end:n+1}),n++;continue}if(r==="!"){t.push({kind:"op",value:"!",start:n,end:n+1}),n++;continue}if(r==="("){t.push({kind:"lparen",value:"(",start:n,end:n+1}),n++;continue}if(r===")"){t.push({kind:"rparen",value:")",start:n,end:n+1}),n++;continue}if(r==="["){t.push({kind:"lbracket",value:"[",start:n,end:n+1}),n++;continue}if(r==="]"){t.push({kind:"rbracket",value:"]",start:n,end:n+1}),n++;continue}if(r==="."){t.push({kind:"dot",value:".",start:n,end:n+1}),n++;continue}if(/[0-9]/.test(r)){let a=n;for(;a=n)return"";const o=this.toks[t].start,r=this.toks[n-1].end;return this.src.slice(o,r)}parseFallback(){let t=this.parseConcat(),n=this.peek();for(;n&&n.kind==="op"&&(n.value==="??"||n.value==="||");){const o=n.value;this.next();const r=this.parseConcat();t={kind:"fallback",op:o,primary:t,fallback:r},n=this.peek()}return t}parseConcat(){const t=this.parseUnaryOrPrimary(),n=[t];let o=this.peek();for(;o&&o.kind==="op"&&o.value==="+";)this.next(),n.push(this.parseUnaryOrPrimary()),o=this.peek();return n.length===1?t:{kind:"concat",parts:n}}parseUnaryOrPrimary(){return this.parsePrimary()}parsePrimary(){const t=this.peek();if(!t)throw new Error("unexpected-end");if(t.kind==="lparen"){this.next();const n=this.parseTernary(),o=this.next();if(!o||o.kind!=="rparen")throw new Error("expected-rparen");return n}if(t.kind==="string")return this.next(),{kind:"leaf",text:oc(t.value)};if(t.kind==="tkey")return this.next(),{kind:"leaf",text:t.value};if(t.kind==="binding")return this.next(),{kind:"leaf",text:t.value};if(t.kind==="ident"&&Bv.includes(t.value)&&this.toks[this.pos+1]?.kind==="lparen"){const n=this.tryParsePathWrapperCall(t.value);if(n!==null)return n;throw new Error("path-wrapper-non-simple-arg")}if(t.kind==="ident")return{kind:"leaf",text:`{{${this.parsePath()}}}`};if(t.kind==="number")return this.next(),{kind:"leaf",text:t.value};throw new Error(`unparseable-primary:${t.kind}`)}parsePath(){let t="";const n=this.next();if(!n||n.kind!=="ident")throw new Error("expected-ident");for(t+=n.value;;){const o=this.peek();if(!o)break;if(o.kind==="op"&&o.value==="?"&&this.toks[this.pos+1]?.kind==="dot"){this.next(),this.next();const r=this.next();if(!r||r.kind!=="ident")throw new Error("expected-ident-after-optional");t+="?."+r.value;continue}if(o.kind==="dot"){this.next();const r=this.next();if(!r||r.kind!=="ident")throw new Error("expected-ident-after-dot");t+="."+r.value;continue}if(o.kind==="lbracket"){this.next();const r=this.next(),s=this.next();if(!s||s.kind!=="rbracket")throw new Error("expected-rbracket");if(r&&(r.kind==="number"||r.kind==="string")){t+=`[${r.value}]`;continue}throw new Error("non-literal-index")}if(o.kind==="lparen")throw new Error("call-expression");break}return t}tryParsePathWrapperCall(t){const n=this.pos;this.next();const o=this.next();if(!o||o.kind!=="lparen")return this.pos=n,null;let r;try{if(this.peek()?.kind!=="ident")return this.pos=n,null;r=this.parsePath()}catch{return this.pos=n,null}const s=this.next();return!s||s.kind!=="rparen"?(this.pos=n,null):{kind:"leaf",text:`{{${t}(${r})}}`}}}function Yv(e){return new Gv(e).parse()}const Xv=["===","!==","==","!=",">=","<=",">","<"];function Jv(e,t){const n=e.trim();if(n==="")return{kind:"raw",source:n};if(n===Rd)return{kind:"simple",left:"",op:"truthy",right:""};if(n.startsWith("!")){const s=n.slice(1).trim(),a=nc(s);return Qn(a)?{kind:"simple",left:a,op:"falsy",right:""}:{kind:"raw",source:n}}const o=Zv(n);if(o){const{left:s,op:a,right:l}=o,d=s.trim(),c=l.trim();return Qn(d)&&(c==="''"||c==='""')?{kind:"simple",left:d,op:a,right:""}:Qn(d)&&Qv(c)?{kind:"simple",left:d,op:a,right:c}:{kind:"raw",source:n}}const r=nc(n);return Qn(r)?{kind:"simple",left:r,op:"truthy",right:""}:{kind:"raw",source:n}}function Zv(e){let t=0,n=null;for(let o=0;o=o||!/[A-Za-z_$]/.test(t[n]))return!1;for(n++;n=o||!/[A-Za-z_$]/.test(t[n]))return!1;for(n++;n=2&&(t[0]==="'"||t[0]==='"'||t[0]==="`")?t.slice(1,-1).replace(/\\(['"`\\])/g,"$1"):t}function Rv(e,t){try{return Ar(e)===Ar(t)}catch{return!1}}function Ar(e){const t=Jn(e);return t!==null?Ar(t):tc(e).map(o=>{if(o.kind==="string")return`S:${oc(o.value)}`;if(o.kind==="binding"){const r=/^\{\{([\s\S]*)\}\}$/.exec(o.value);return`B:${r?Ar(r[1].trim()):o.value.replace(/\s+/g,"")}`}return o.kind==="tkey"?`S:${o.value}`:o.kind==="op"?`O:${o.value}`:o.kind==="ident"||o.kind==="number"?`I:${o.value}`:o.kind==="dot"?".":o.kind==="lbracket"?"[":o.kind==="rbracket"?"]":o.kind==="lparen"||o.kind==="rparen"?"":`X:${o.value}`}).join("")}function Rn({active:e,testid:t}){return i.jsx("div",{"data-testid":t,"data-active":e?"true":"false","aria-hidden":"true",style:e?t_:e_})}const e_={height:0,margin:0,transition:"height 80ms"},t_={height:3,margin:"1px 0",borderRadius:2,background:"#2563eb",boxShadow:"0 0 0 1px #93c5fd"};function ys(e){const{length:t,onMove:n,canDrag:o,canDropAt:r}=e,[s,a]=u.useState(null),[l,d]=u.useState(null),c=u.useCallback(m=>{o&&!o(m)||(a(m),d(m))},[o]),p=u.useCallback(()=>{a(null),d(null)},[]),f=u.useCallback((m,h)=>{if(s===null)return;const v=h==="before"?m:m+1;if(r&&!r(s,v)){d(null);return}d(v)},[s,r]),b=u.useCallback(()=>{if(s!==null&&l!==null){const m=l>s?l-1:l;m!==s&&(!r||r(s,l))&&n(s,m)}a(null),d(null)},[s,l,n,r]),g=u.useCallback(m=>s!==null&&l===m&&m<=t,[s,l,t]);return{dragIndex:s,dropIndex:l,dragging:s!==null,onDragStart:c,onDragEnd:p,onDragOverItem:f,onDrop:b,isDropTarget:g}}const n_={text:"",expression:"{{false ? '' : ''}}",fallback:"{{'' ?? ''}}",data:""};function rc(e,t){const n=In(e);let o=t;const r=n.map(s=>({id:o++,kind:s.kind==="literal"?"text":"expression",value:s.raw}));return r.length===0&&r.push({id:o++,kind:"text",value:""}),{segs:r,nextSeq:o}}function bs({value:e,onChange:t,t:n,candidates:o,testidPrefix:r="g7le-seg-value",renderLeafInput:s}){const a=u.useRef(0),l=u.useRef(e),d=u.useMemo(()=>{const w=rc(e,a.current);return a.current=w.nextSeq,w.segs},[]),[c,p]=u.useState(d),[f,b]=u.useState(!1);if(e!==l.current){l.current=e;const w=c.map(k=>k.value).join("");if(e!==w){const k=rc(e,a.current);a.current=k.nextSeq,p(k.segs)}}const g=u.useCallback(w=>{p(w);const k=w.map(x=>x.value).join("");l.current=k,t(k)},[t]),m=u.useCallback((w,k)=>{g(c.map(x=>x.id===w?{...x,value:k??""}:x))},[c,g]),h=u.useCallback(w=>{const k=c.filter(x=>x.id!==w);g(k.length>0?k:[{id:a.current++,kind:"text",value:""}])},[c,g]),v=u.useCallback(w=>{g([...c,{id:a.current++,kind:w,value:n_[w]}])},[c,g]),y=u.useCallback((w,k)=>{if(w===k||w<0||k<0||w>=c.length||k>=c.length)return;const x=c.slice(),[$]=x.splice(w,1);x.splice(k,0,$),g(x)},[c,g]),_=ys({length:c.length,onMove:y});return i.jsxs("div",{"data-testid":r,style:i_,children:[i.jsx("div",{style:s_,children:n("layout_editor.value_tree.segmented_hint")}),c.map((w,k)=>i.jsxs(u.Fragment,{children:[i.jsx(Rn,{active:_.isDropTarget(k),testid:`${r}-dropline-${k}`}),i.jsx(r_,{seg:w,index:k,t:n,candidates:o,testidPrefix:r,renderLeafInput:s,onValueChange:x=>m(w.id,x),onRemove:()=>h(w.id),dragging:_.dragIndex===k,onDragStartCard:()=>_.onDragStart(k),onDragEndCard:_.onDragEnd,onDragOverCard:x=>_.onDragOverItem(k,x),onDropCard:_.onDrop})]},w.id)),i.jsx(Rn,{active:_.isDropTarget(c.length),testid:`${r}-dropline-end`}),i.jsxs("div",{style:p_,"data-testid":`${r}-add-row`,children:[i.jsxs("button",{type:"button","data-testid":`${r}-add-text`,onClick:()=>v("text"),style:Tr,children:["+ ",n("layout_editor.value_tree.segment.text")]}),i.jsxs("button",{type:"button","data-testid":`${r}-add-expression`,onClick:()=>v("expression"),style:Tr,children:["+ ",n("layout_editor.value_tree.segment.expression")]}),i.jsxs("button",{type:"button","data-testid":`${r}-add-fallback`,onClick:()=>v("fallback"),style:Tr,children:["+ ",n("layout_editor.value_tree.segment.fallback")]}),i.jsxs("button",{type:"button","data-testid":`${r}-add-data`,onClick:()=>v("data"),style:Tr,children:["+ ",n("layout_editor.value_tree.segment.data")]})]}),i.jsxs("div",{style:h_,children:[i.jsxs("button",{type:"button","data-testid":`${r}-source-toggle`,"aria-expanded":f,onClick:()=>b(w=>!w),style:y_,children:[""," ",n("layout_editor.value_tree.show_source")," ",f?"▴":"▾"]}),f&&i.jsx("code",{"data-testid":`${r}-source-code`,style:b_,children:c.map(w=>w.value).join("")})]})]})}function o_({t:e,candidates:t,onPick:n,testidPrefix:o}){return!t||t.length===0?i.jsx("div",{"data-testid":`${o}-data-empty`,style:g_,children:e("layout_editor.value_tree.segment.data_no_candidates")}):i.jsxs("div",{"data-testid":`${o}-data-picker`,style:{minWidth:0},children:[i.jsx("div",{style:f_,children:e("layout_editor.value_tree.segment.data_pick_hint")}),i.jsx($t,{candidates:t,t:e,onSelect:r=>{n(En(r.sourceId,r.path,"scalar"))},testIdSuffix:`${o}-data`,defaultOpen:!0,floating:!0})]})}function r_({seg:e,index:t,t:n,candidates:o,testidPrefix:r,renderLeafInput:s,onValueChange:a,onRemove:l,dragging:d,onDragStartCard:c,onDragEndCard:p,onDragOverCard:f,onDropCard:b}){const g=e.kind==="text"?"layout_editor.value_tree.segment.text":e.kind==="data"?"layout_editor.value_tree.segment.data":e.kind==="fallback"?"layout_editor.value_tree.segment.fallback":"layout_editor.value_tree.segment.expression";return i.jsxs("div",{"data-testid":`${r}-card-${t}`,"data-seg-kind":e.kind,style:d?{...ic,opacity:.5}:ic,onDragOver:m=>{m.preventDefault();const h=m.currentTarget.getBoundingClientRect();f(m.clientY{m.preventDefault(),b()},children:[i.jsxs("div",{style:a_,children:[i.jsx("span",{"data-testid":`${r}-drag-${t}`,style:c_,draggable:!0,onDragStart:c,onDragEnd:p,title:n("layout_editor.value_tree.drag_reorder"),"aria-label":n("layout_editor.value_tree.drag_reorder"),role:"button",children:"⠿"}),i.jsx("span",{style:l_,children:n(g)}),i.jsx("button",{type:"button","data-testid":`${r}-remove-${t}`,onClick:l,title:n("layout_editor.value_tree.segment.remove"),"aria-label":n("layout_editor.value_tree.segment.remove"),style:u_,children:"✕"})]}),i.jsx("div",{style:d_,children:e.kind==="data"&&e.value.trim()===""?i.jsx(o_,{t:n,candidates:o,onPick:a,testidPrefix:`${r}-field-${t}`}):s?s({value:e.value,onChange:a,t:n,candidates:o,testidPrefix:`${r}-field-${t}`}):i.jsx(_t,{value:e.value,onChange:a,t:n,candidates:o,testidPrefix:`${r}-field-${t}`,enableExpressionTree:!0,expressionSourceToggle:!1})})]})}const i_={display:"flex",flexDirection:"column",gap:6,width:"100%",minWidth:0},s_={fontSize:11,color:"#64748b"},ic={display:"flex",flexDirection:"column",gap:4,padding:"6px 8px",border:"1px solid #e2e8f0",borderLeft:"3px solid #6366f1",borderRadius:6,background:"#f8fafc",minWidth:0},a_={display:"flex",alignItems:"center",gap:6,minWidth:0},l_={fontSize:10,fontWeight:600,color:"#6366f1",flex:1,minWidth:0},d_={minWidth:0},c_={color:"#94a3b8",cursor:"grab",fontSize:14,userSelect:"none"},u_={border:"none",background:"transparent",color:"#94a3b8",cursor:"pointer",fontSize:12,padding:2,flexShrink:0},p_={display:"flex",flexWrap:"wrap",gap:6,marginTop:2},f_={fontSize:11,color:"#64748b",marginBottom:2},g_={fontSize:11,color:"#94a3b8",padding:"4px 0"},Tr={padding:"4px 10px",fontSize:11,border:"1px dashed #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",whiteSpace:"nowrap"},h_={display:"flex",flexDirection:"column",gap:4,marginTop:2},y_={alignSelf:"flex-start",padding:"3px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer",fontFamily:"monospace"},b_={fontSize:11,background:"#0f172a",color:"#e2e8f0",padding:"6px 8px",borderRadius:4,wordBreak:"break-all",fontFamily:"monospace"},m_=[{value:"truthy",labelKey:"layout_editor.value_tree.cond.op_truthy"},{value:"falsy",labelKey:"layout_editor.value_tree.cond.op_falsy"},{value:"===",labelKey:"layout_editor.value_tree.cond.op_eq"},{value:"!==",labelKey:"layout_editor.value_tree.cond.op_neq"},{value:">",labelKey:"layout_editor.value_tree.cond.op_gt"},{value:"<",labelKey:"layout_editor.value_tree.cond.op_lt"},{value:">=",labelKey:"layout_editor.value_tree.cond.op_gte"},{value:"<=",labelKey:"layout_editor.value_tree.cond.op_lte"}];function sc({node:e,onChange:t,t:n,candidates:o,testidPrefix:r="g7le-value-tree",depth:s=0,showSourceToggle:a=!0,renderLeafInput:l}){const[d,c]=u.useState(!1),p=s===0,f=i.jsx(eo,{node:e,onChange:t,t:n,candidates:o,testidPrefix:r,depth:s,renderLeafInput:l});return p?a?i.jsxs("div",{"data-testid":r,style:lc,children:[f,i.jsxs("div",{style:B_,children:[i.jsxs("button",{type:"button","data-testid":`${r}-source-toggle`,"aria-expanded":d,onClick:()=>c(b=>!b),style:W_,children:[""," ",n("layout_editor.value_tree.show_source")," ",d?"▴":"▾"]}),d&&i.jsx("code",{"data-testid":`${r}-source-code`,style:j_,children:Zn(e,!1)})]})]}):i.jsx("div",{"data-testid":r,style:lc,children:f}):f}function eo({node:e,onChange:t,t:n,candidates:o,testidPrefix:r,depth:s,renderLeafInput:a}){switch(e.kind){case"leaf":return i.jsx(bs,{value:e.text,onChange:l=>t({kind:"leaf",text:l}),t:n,candidates:o,testidPrefix:`${r}-leaf`,renderLeafInput:a});case"conditional":return i.jsx(v_,{node:e,onChange:t,t:n,candidates:o,testidPrefix:r,depth:s,renderLeafInput:a});case"fallback":return i.jsx(__,{node:e,onChange:t,t:n,candidates:o,testidPrefix:r,depth:s,renderLeafInput:a});case"concat":return i.jsx(w_,{node:e,onChange:t,t:n,candidates:o,testidPrefix:r,depth:s,renderLeafInput:a});case"raw":default:return i.jsxs("div",{"data-testid":`${r}-raw`,style:H_,children:[i.jsx("code",{style:uc,children:e.source??""}),i.jsxs("span",{style:pc,children:["🔒 ",n("layout_editor.value_tree.raw_code_only")]})]})}}function v_({node:e,onChange:t,t:n,candidates:o,testidPrefix:r,depth:s,renderLeafInput:a}){const l=u.useCallback(p=>t({...e,condition:p}),[e,t]),d=u.useCallback(p=>t({...e,then:p}),[e,t]),c=u.useCallback(p=>t({...e,else:p}),[e,t]);return i.jsxs("div",{"data-testid":`${r}-conditional`,style:ms(s),children:[i.jsx(k_,{condition:e.condition,onChange:l,t:n,candidates:o,testidPrefix:r}),i.jsx(Dr,{label:n("layout_editor.value_tree.cond.when_true"),testid:`${r}-then`,children:i.jsx(eo,{node:e.then,onChange:d,t:n,candidates:o,testidPrefix:`${r}-then`,depth:s+1,renderLeafInput:a})}),i.jsx(Dr,{label:n("layout_editor.value_tree.cond.when_false"),testid:`${r}-else`,children:i.jsx(eo,{node:e.else,onChange:c,t:n,candidates:o,testidPrefix:`${r}-else`,depth:s+1,renderLeafInput:a})})]})}function __({node:e,onChange:t,t:n,candidates:o,testidPrefix:r,depth:s,renderLeafInput:a}){const l=u.useCallback(c=>t({...e,primary:c}),[e,t]),d=u.useCallback(c=>t({...e,fallback:c}),[e,t]);return i.jsxs("div",{"data-testid":`${r}-fallback`,style:ms(s),children:[i.jsx(Dr,{label:n("layout_editor.value_tree.fallback.primary"),testid:`${r}-primary`,children:i.jsx(eo,{node:e.primary,onChange:l,t:n,candidates:o,testidPrefix:`${r}-primary`,depth:s+1,renderLeafInput:a})}),i.jsx(Dr,{label:n(e.op==="??"?"layout_editor.value_tree.fallback.when_empty":"layout_editor.value_tree.fallback.when_falsy"),testid:`${r}-fallback-branch`,children:i.jsx(eo,{node:e.fallback,onChange:d,t:n,candidates:o,testidPrefix:`${r}-fallbackb`,depth:s+1,renderLeafInput:a})})]})}const x_={text:()=>({kind:"leaf",text:""}),data:()=>({kind:"leaf",text:""}),expression:()=>({kind:"conditional",condition:{kind:"simple",left:"",op:"truthy",right:""},then:{kind:"leaf",text:""},else:{kind:"leaf",text:""}}),fallback:()=>({kind:"fallback",op:"??",primary:{kind:"leaf",text:""},fallback:{kind:"leaf",text:""}})};function w_({node:e,onChange:t,t:n,candidates:o,testidPrefix:r,depth:s,renderLeafInput:a}){const l=u.useCallback((g,m)=>{const h=e.parts.slice();h[g]=m,t({...e,parts:h})},[e,t]),d=u.useCallback(g=>{g.length===0?t({kind:"leaf",text:""}):g.length===1?t(g[0]):t({...e,parts:g})},[e,t]),c=u.useCallback(g=>d(e.parts.filter((m,h)=>h!==g)),[e.parts,d]),p=u.useCallback(g=>d([...e.parts,x_[g]()]),[e.parts,d]),f=u.useCallback((g,m)=>{if(g===m||g<0||m<0||g>=e.parts.length||m>=e.parts.length)return;const h=e.parts.slice(),[v]=h.splice(g,1);h.splice(m,0,v),d(h)},[e.parts,d]),b=ys({length:e.parts.length,onMove:f});return i.jsxs("div",{"data-testid":`${r}-concat`,style:ms(s),children:[i.jsx("div",{style:z_,children:n("layout_editor.value_tree.concat.hint")}),e.parts.map((g,m)=>i.jsxs(u.Fragment,{children:[i.jsx(Rn,{active:b.isDropTarget(m),testid:`${r}-part-dropline-${m}`}),i.jsxs("div",{"data-testid":`${r}-part-card-${m}`,style:b.dragIndex===m?{...cc,opacity:.5}:cc,onDragOver:h=>{h.preventDefault();const v=h.currentTarget.getBoundingClientRect();b.onDragOverItem(m,h.clientY{h.preventDefault(),b.onDrop()},children:[i.jsxs("div",{style:N_,children:[i.jsx("span",{"data-testid":`${r}-part-handle-${m}`,style:P_,draggable:!0,onDragStart:()=>b.onDragStart(m),onDragEnd:b.onDragEnd,title:n("layout_editor.value_tree.drag_reorder"),"aria-label":n("layout_editor.value_tree.drag_reorder"),role:"button",children:"⠿"}),i.jsx("span",{style:M_,children:n("layout_editor.value_tree.concat.part",{n:m+1})}),i.jsx("button",{type:"button","data-testid":`${r}-part-remove-${m}`,onClick:()=>c(m),title:n("layout_editor.value_tree.segment.remove"),"aria-label":n("layout_editor.value_tree.segment.remove"),style:O_,children:"✕"})]}),i.jsx("div",{style:{minWidth:0},children:i.jsx(eo,{node:g,onChange:h=>l(m,h),t:n,candidates:o,testidPrefix:`${r}-part-${m}`,depth:s+1,renderLeafInput:a})})]})]},m)),i.jsx(Rn,{active:b.isDropTarget(e.parts.length),testid:`${r}-part-dropline-end`}),i.jsxs("div",{style:L_,"data-testid":`${r}-part-add-row`,children:[i.jsxs("button",{type:"button","data-testid":`${r}-part-add-text`,onClick:()=>p("text"),style:zr,children:["+ ",n("layout_editor.value_tree.segment.text")]}),i.jsxs("button",{type:"button","data-testid":`${r}-part-add-expression`,onClick:()=>p("expression"),style:zr,children:["+ ",n("layout_editor.value_tree.segment.expression")]}),i.jsxs("button",{type:"button","data-testid":`${r}-part-add-fallback`,onClick:()=>p("fallback"),style:zr,children:["+ ",n("layout_editor.value_tree.segment.fallback")]}),i.jsxs("button",{type:"button","data-testid":`${r}-part-add-data`,onClick:()=>p("data"),style:zr,children:["+ ",n("layout_editor.value_tree.segment.data")]})]})]})}function k_({condition:e,onChange:t,t:n,candidates:o,testidPrefix:r}){if(e.kind==="raw")return i.jsxs("div",{"data-testid":`${r}-cond-raw`,style:I_,children:[i.jsx("span",{style:dc,children:n("layout_editor.value_tree.cond.label")}),i.jsx("code",{style:uc,children:e.source}),i.jsxs("span",{style:pc,children:["🔒 ",n("layout_editor.value_tree.cond.code_only")]})]});const s=e,a=s.op!=="truthy"&&s.op!=="falsy";return i.jsxs("div",{"data-testid":`${r}-cond`,style:E_,children:[i.jsx("span",{style:dc,children:n("layout_editor.value_tree.cond.label")}),i.jsx(ac,{testid:`${r}-cond-left`,value:s.left,onCommit:l=>t({...s,left:l}),placeholder:n("layout_editor.value_tree.cond.field_placeholder"),candidates:o,t:n}),i.jsx("select",{"data-testid":`${r}-cond-op`,value:s.op,onChange:l=>t({...s,op:l.target.value}),style:D_,children:m_.map(l=>i.jsx("option",{value:l.value,children:n(l.labelKey)},l.value))}),a&&i.jsx(ac,{testid:`${r}-cond-right`,value:s.right,onCommit:l=>t({...s,right:l}),placeholder:n("layout_editor.value_tree.cond.value_placeholder"),candidates:o,t:n,quoteDataPick:!0})]})}function ac({testid:e,value:t,onCommit:n,placeholder:o,candidates:r,t:s,quoteDataPick:a=!1}){const[l,d]=u.useState(null),c=l!==null?l:t,p=()=>{l!==null&&(l!==t&&n(l),d(null))},f=(b,g)=>{const m=En(b,g,"scalar"),h=/^\{\{\s*([\s\S]*?)\s*\}\}$/.exec(m.trim());let v=h?h[1]:m;v=v.replace(/\s*\?\?\s*''$/,"").trim(),n(a?`'${v}'`:v),d(null)};return i.jsxs("span",{style:A_,children:[i.jsx("input",{type:"text","data-testid":e,value:c,onChange:b=>d(b.target.value),onBlur:p,onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),p())},placeholder:o,style:T_}),r&&r.length>0&&s&&i.jsx($t,{candidates:r,t:s,onSelect:b=>f(b.sourceId,b.path),testIdSuffix:`${e}-data`,floating:!0})]})}function Dr({label:e,testid:t,children:n}){return i.jsxs("div",{"data-testid":t,style:S_,children:[i.jsx("span",{style:C_,children:e}),i.jsx("div",{style:$_,children:n})]})}const lc={display:"flex",flexDirection:"column",gap:6,width:"100%",minWidth:0},ms=e=>({display:"flex",flexDirection:"column",gap:6,padding:"8px",border:"1px solid #e2e8f0",borderLeft:`3px solid ${e%2===0?"#6366f1":"#0ea5e9"}`,borderRadius:6,background:e%2===0?"#f8fafc":"#fefefe",minWidth:0}),S_={display:"flex",flexDirection:"column",gap:3,minWidth:0},C_={fontSize:11,fontWeight:600,color:"#475569"},$_={paddingLeft:8,minWidth:0},E_={display:"flex",flexWrap:"wrap",gap:4,alignItems:"center",minWidth:0},I_={display:"flex",flexWrap:"wrap",gap:4,alignItems:"center",minWidth:0},dc={fontSize:11,fontWeight:600,color:"#0f172a",whiteSpace:"nowrap"},A_={display:"inline-flex",alignItems:"flex-start",gap:2,flex:"1 1 80px",minWidth:60},T_={flex:"1 1 80px",minWidth:60,padding:"4px 6px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6},D_={padding:"4px 6px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff"},z_={fontSize:11,color:"#94a3b8"},cc={display:"flex",flexDirection:"column",gap:4,padding:"6px 8px",border:"1px solid #e2e8f0",borderLeft:"3px solid #6366f1",borderRadius:6,background:"#fff",minWidth:0},N_={display:"flex",alignItems:"center",gap:6,minWidth:0},M_={fontSize:10,fontWeight:600,color:"#6366f1",flex:1,minWidth:0},L_={display:"flex",flexWrap:"wrap",gap:6,marginTop:2},P_={color:"#94a3b8",cursor:"grab",fontSize:14,userSelect:"none"},O_={border:"none",background:"transparent",color:"#94a3b8",cursor:"pointer",fontSize:12,padding:2,flexShrink:0},zr={padding:"4px 10px",fontSize:11,border:"1px dashed #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",whiteSpace:"nowrap"},B_={display:"flex",flexDirection:"column",gap:4,marginTop:2},W_={alignSelf:"flex-start",padding:"3px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer",fontFamily:"monospace"},j_={fontSize:11,background:"#0f172a",color:"#e2e8f0",padding:"6px 8px",borderRadius:4,wordBreak:"break-all",fontFamily:"monospace"},H_={display:"flex",flexDirection:"column",gap:2,minWidth:0},uc={fontSize:11,background:"#f1f5f9",padding:"3px 6px",borderRadius:4,color:"#0f172a",wordBreak:"break-all",fontFamily:"monospace"},pc={fontSize:10,color:"#64748b"};function _t({value:e,onChange:t,t:n,placeholder:o,testidPrefix:r="g7le-i18n-text-field",locales:s,candidates:a,enableExpressionTree:l=!1,expressionTreeCollapsible:d=!1,expressionSourceToggle:c=!0}){const{locale:p,templateIdentifier:f,commitText:b,classify:g,translate:m}=mv(),[h,v]=u.useState(null),[y,_]=u.useState(!1),[w,k]=u.useState(!1),[x,$]=u.useState(!1),[S,C]=u.useState(!1),[T,E]=u.useState(!1),[,A]=u.useState(0);u.useEffect(()=>{if(typeof window>"u")return;const z=H=>{const P=H.detail;P?.templateIdentifier&&P.templateIdentifier!==f||A(I=>I+1)};return window.addEventListener(kt,z),()=>window.removeEventListener(kt,z)},[f]);const N=g(e);u.useEffect(()=>{v(null),E(!1)},[p,e]);const D=h!==null?h:N.displayValue,B=u.useCallback(async()=>{if(h!==null){if(h===N.displayValue){v(null);return}_(!0);try{const z=await b(e,h);z.kind==="created"&&z.token?(t(z.token),Et({op:"prop_i18n_create_key",sourceState:"plain_text",translationKey:z.customKey,toLocale:p,valueLength:h.length,timestamp:Date.now()})):z.kind==="updated"&&Et({op:"prop_i18n_update_value",sourceState:"custom_key",translationKey:z.customKey,toLocale:p,valueLength:h.length,timestamp:Date.now()})}finally{_(!1),v(null)}}},[h,N.displayValue,b,e,t,p]),M=u.useCallback(z=>{typeof e=="string"&&(t(vo(e,z)),N.customKey&&$r(f,N.customKey,z,p))},[e,t,N.customKey,f,p]);if(N.binding){if(l&&typeof e=="string"){const z=Zd(e),H=un(e),P=!z&&Kt(e)!==null,I=(z||H.decomposed)&&!P;if(I&&d&&!x)return i.jsx(V_,{value:e,t:n,translate:m,onEdit:()=>$(!0),testidPrefix:`${r}-preview`});const F=I&&(d||z)?i.jsx(bs,{value:e,onChange:Y=>t(Y),t:n,candidates:a,testidPrefix:`${r}-seg`}):H.decomposed?i.jsx(sc,{node:H.node,onChange:Y=>t(Zn(Y,!1)),t:n,candidates:a,testidPrefix:`${r}-tree`,showSourceToggle:c}):null;if(F){if(!d)return F;const Y=Er(e),K=Y?gs(Y,X=>{const Z=m(X);return Z&&Z!==X&&!Z.startsWith("$t:")?Z:""},X=>Vt(X)):[];return i.jsxs("div",{"data-testid":`${r}-builder`,style:{display:"flex",flexDirection:"column",gap:6,width:"100%",minWidth:0},children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:6},children:[i.jsxs("button",{type:"button","data-testid":`${r}-to-plain`,onClick:()=>C(!0),style:Z_,title:n("layout_editor.value_tree.to_plain"),"aria-label":n("layout_editor.value_tree.to_plain"),children:["↩ ",n("layout_editor.value_tree.to_plain")]}),i.jsxs("button",{type:"button","data-testid":`${r}-builder-collapse`,onClick:()=>$(!1),style:hc,title:n("layout_editor.value_tree.collapse"),"aria-label":n("layout_editor.value_tree.collapse"),children:["▴ ",n("layout_editor.value_tree.collapse")]})]}),S&&i.jsxs("div",{"data-testid":`${r}-to-plain-confirm`,style:Q_,children:[i.jsx("p",{style:R_,children:n("layout_editor.value_tree.to_plain_lead")}),i.jsx("div",{style:ex,children:K.length===0?i.jsx("span",{style:{color:"#94a3b8"},children:n("layout_editor.prop_i18n.placeholder")}):K.map((X,Z)=>X.kind==="chip"?i.jsxs("span",{style:fc,children:["🔗 ",X.text]},Z):i.jsx("span",{style:X.kind==="ellipsis"?gc:void 0,children:X.text},Z))}),i.jsxs("p",{style:tx,children:["⚠ ",n("layout_editor.value_tree.to_plain_warn")]}),i.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:6},children:[i.jsx("button",{type:"button","data-testid":`${r}-to-plain-confirm-cancel`,onClick:()=>C(!1),style:hc,children:n("layout_editor.value_tree.to_plain_cancel")}),i.jsx("button",{type:"button","data-testid":`${r}-to-plain-confirm-ok`,onClick:()=>{C(!1),$(!1),t(Er(e)||void 0)},style:nx,children:n("layout_editor.value_tree.to_plain_ok")})]})]}),F]})}}return l&&typeof e=="string"&&a&&a.length>0&&Kt(e)!==null?i.jsx(U_,{value:e,onChange:t,t:n,candidates:a,testidPrefix:`${r}-data`}):i.jsxs("div",{"data-testid":`${r}-binding`,style:lx,children:[i.jsx("code",{style:dx,children:typeof e=="string"?e:""}),i.jsxs("span",{style:cx,children:["🔗 ",n("layout_editor.prop_i18n.bound_code_only")]})]})}if(!T&&typeof e=="string"&&Xl(e)){const z=Jl(e);return i.jsxs("div",{"data-testid":`${r}-settings-ref`,style:ix,children:[i.jsx("div",{"data-testid":`${r}-settings-ref-chips`,style:sx,children:z.map((H,P)=>H.kind==="chip"?i.jsxs("span",{style:ax,children:["🔗 ",H.label]},P):i.jsx("span",{children:H.label},P))}),i.jsxs("button",{type:"button","data-testid":`${r}-settings-ref-edit`,onClick:()=>E(!0),style:yc,title:n("layout_editor.value_tree.edit"),"aria-label":n("layout_editor.value_tree.edit"),children:["✎ ",n("layout_editor.value_tree.edit")]})]})}const O=i.jsxs("button",{type:"button","data-testid":`${r}-toggle`,title:`${n("layout_editor.prop_i18n.edit_languages")} (${Gn(p,n)})`,"aria-label":`${n("layout_editor.prop_i18n.edit_languages")} (${Gn(p,n)})`,"aria-expanded":w,onClick:()=>k(z=>!z),style:yc,children:["🌐 ",N.customKey?w?"⌃":"⌄":"+"]});return i.jsxs("div",{"data-testid":r,style:{display:"flex",flexDirection:"column",gap:4,width:"100%"},children:[i.jsx("div",{style:ox,children:N.paramKey&&N.customKey?i.jsx(F_,{customKey:N.customKey,value:typeof e=="string"?e:"",onChange:t,t:n,candidates:a,testidPrefix:r,showExprButton:l&&d,onToExpression:()=>{$(!0),t($o(typeof e=="string"?e:""))},langToggle:O}):i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"text","data-testid":`${r}-preview`,value:D,placeholder:o??n("layout_editor.prop_i18n.placeholder"),onChange:z=>v(z.target.value),onBlur:()=>{B(),T&&E(!1)},disabled:y,style:rx}),a&&a.length>0&&i.jsx(K_,{value:typeof e=="string"?e:"",customKey:N.customKey,onChange:t,t:n,candidates:a,testidPrefix:r}),l&&d&&i.jsx("button",{type:"button","data-testid":`${r}-to-expr`,onClick:()=>{$(!0),t($o(typeof e=="string"?e:""))},title:n("layout_editor.value_tree.to_expression"),"aria-label":n("layout_editor.value_tree.to_expression"),style:Ao,children:"ƒx"}),O]})}),w&&(N.customKey?i.jsx(Xd,{customKey:N.customKey,templateIdentifier:f,t:n,paramLabels:ps(e),locales:s,onRemoveParam:M},N.customKey):i.jsx("div",{"data-testid":`${r}-expand-hint`,style:ux,children:n("layout_editor.prop_i18n.create_first")}))]})}function F_({customKey:e,value:t,onChange:n,t:o,candidates:r,testidPrefix:s,showExprButton:a=!1,onToExpression:l,langToggle:d}){const{state:c}=Qe(),p=c.templateIdentifier,f=c.locale,b=Ft(),[g,m]=u.useState(null),h=u.useRef(""),v=u.useRef(null),y=u.useRef(null),_=u.useRef(null),[w,k]=u.useState(null),[x,$]=u.useState(!1),S=ps(t),C=u.useCallback(async()=>{const D=It(e,f);if(D!==void 0){h.current=D,m(D);return}const M=(await cn(p,e))?.values?.[f]??"";h.current=M,m(M)},[e,p,f]);u.useEffect(()=>{let D=!1;return(async()=>{const B=It(e,f);if(B!==void 0){D||(h.current=B,m(B));return}const M=await cn(p,e);if(D)return;const O=M?.values?.[f]??"";h.current=O,m(O)})(),()=>{D=!0}},[e,p,f]),u.useEffect(()=>{if(typeof window>"u")return;const D=B=>{const M=B.detail;if(M?.templateIdentifier&&M.templateIdentifier!==p)return;const O=It(e,f);O!==void 0&&O!==g&&(h.current=O,m(O))};return window.addEventListener(kt,D),()=>window.removeEventListener(kt,D)},[e,p,f,g]);const T=u.useCallback(D=>{m(D),So(p,e,f,D).then(()=>{b?.markDirty?.()})},[p,e,f,b]),E=u.useCallback(D=>{n(vo(t,D)),$r(p,e,D,f).then(()=>{C(),b?.markDirty?.()})},[t,n,p,e,f,C,b]),A=u.useCallback(async D=>{if(!(w===null||x)){$(!0);try{g!==null&&g!==h.current&&(await So(p,e,f,g),h.current=g);const B=await Cr(p,f,t,w,D.sourceId,D.path,"scalar");B.kind==="ok"&&(n(B.text),await C(),b?.markDirty?.())}finally{$(!1),k(null)}}},[w,x,g,t,p,e,f,n,C,b]),N=!!r&&r.length>0;return i.jsxs("div",{"data-testid":`${s}-chipfield-wrap`,style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:4},children:[i.jsx("div",{ref:v,"data-testid":`${s}-chipfield`,style:{flex:1,minWidth:0},children:g===null?i.jsx("div",{"data-testid":`${s}-chipfield-loading`,style:{fontSize:11,color:"#94a3b8",padding:"4px 0"},children:o("layout_editor.translation.loading")}):i.jsx(xr,{value:g,onChange:T,t:o,paramLabels:S,testIdSuffix:`${s}-field`,onRequestInsert:N?D=>k(D):void 0,onRemoveChip:E,hideInsertButton:!0,caretRef:_})}),N&&i.jsx("button",{ref:y,type:"button","data-testid":`${s}-plus-data-btn`,onClick:()=>k(_.current?_.current():g?.length??0),title:o("layout_editor.inline_binding.insert_data"),"aria-label":o("layout_editor.inline_binding.insert_data"),style:Ao,children:"+"}),a&&l&&i.jsx("button",{type:"button","data-testid":`${s}-to-expr`,onClick:l,title:o("layout_editor.value_tree.to_expression"),"aria-label":o("layout_editor.value_tree.to_expression"),style:Ao,children:"ƒx"}),d,N&&i.jsx(Xn,{anchorRef:y,open:w!==null,onClose:()=>k(null),children:i.jsx("div",{"data-testid":`${s}-chipfield-picker`,children:i.jsx($t,{candidates:r,t:o,onSelect:D=>void A(D),testIdSuffix:`${s}-field-insert`,defaultOpen:!0,floating:!1})})})]})}function K_({value:e,customKey:t,onChange:n,t:o,candidates:r,testidPrefix:s}){const{state:a}=Qe(),l=a.templateIdentifier,d=a.selectedRoute?.layoutName??null,c=a.locale,p=Ft(),[f,b]=u.useState(!1),[g,m]=u.useState(!1),h=u.useRef(null),v=u.useCallback(w=>{const k=o(w);return k&&k!==w&&!k.startsWith("$t:")?k:""},[o]),y=u.useCallback(w=>w.replace(/\$t:[a-zA-Z0-9._-]+/g,k=>v(k.slice(3))).replace(/\s+/g," ").trim(),[v]),_=u.useCallback(async w=>{if(!g){m(!0);try{if(t){const k=await Cr(l,c,e,Number.MAX_SAFE_INTEGER,w.sourceId,w.path,"scalar");k.kind==="ok"&&(n(k.text),p?.markDirty?.())}else{const k=await us(l,d,c,e,e.length,w.sourceId,w.path,"scalar",y,x=>o(x));k.kind==="ok"&&(n(k.text),p?.markDirty?.())}}finally{m(!1),b(!1)}}},[g,t,l,d,c,e,n,p,o,y]);return i.jsxs("div",{"data-testid":`${s}-plus-data`,style:{display:"inline-block"},children:[i.jsx("button",{ref:h,type:"button","data-testid":`${s}-plus-data-btn`,disabled:g,onClick:()=>b(w=>!w),title:o("layout_editor.inline_binding.insert_data"),"aria-label":o("layout_editor.inline_binding.insert_data"),style:Ao,children:"+"}),i.jsx(Xn,{anchorRef:h,open:f,onClose:()=>b(!1),children:i.jsx($t,{candidates:r,t:o,onSelect:w=>void _(w),testIdSuffix:`${s}-plus-insert`,defaultOpen:!0,floating:!1})})]})}function V_({value:e,t,translate:n,onEdit:o,testidPrefix:r}){const s=gs(e,a=>{const l=n(a);return l&&l!==a&&!l.startsWith("$t:")?l:""},a=>Vt(a));return i.jsxs("div",{"data-testid":r,style:Y_,children:[i.jsx("div",{"data-testid":`${r}-text`,style:X_,children:s.length===0?i.jsx("span",{style:{color:"#94a3b8"},children:t("layout_editor.prop_i18n.placeholder")}):s.map((a,l)=>a.kind==="chip"?i.jsxs("span",{style:fc,children:["🔗 ",a.text]},l):i.jsx("span",{style:a.kind==="ellipsis"?gc:void 0,children:a.text},l))}),i.jsxs("button",{type:"button","data-testid":`${r}-edit`,onClick:o,style:J_,title:t("layout_editor.value_tree.edit"),"aria-label":t("layout_editor.value_tree.edit"),children:["✎ ",t("layout_editor.value_tree.edit")]})]})}function U_({value:e,onChange:t,t:n,candidates:o,testidPrefix:r}){const[s,a]=u.useState(!1),l=u.useRef(null),d=Vt(e);return i.jsxs("div",{"data-testid":r,style:{display:"flex",flexDirection:"column",gap:4,width:"100%",minWidth:0},children:[i.jsxs("div",{style:q_,children:[i.jsxs("span",{"data-testid":`${r}-chip`,style:G_,children:["🔗 ",d]}),i.jsx("button",{ref:l,type:"button","data-testid":`${r}-change`,onClick:()=>a(c=>!c),style:Ao,title:n("layout_editor.value_tree.change_data"),"aria-label":n("layout_editor.value_tree.change_data"),children:n("layout_editor.value_tree.change_data")})]}),i.jsx(Xn,{anchorRef:l,open:s,onClose:()=>a(!1),children:i.jsx($t,{candidates:o,t:n,onSelect:c=>{const p=c.path?c.path.split(".").filter(Boolean):[],f=[c.sourceId,...p].join("?.");t(`{{${f}}}`),a(!1)},testIdSuffix:`${r}-pick`,defaultOpen:!0,floating:!1})})]})}const q_={display:"flex",alignItems:"center",gap:6,width:"100%",minWidth:0,flexWrap:"wrap"},G_={fontSize:11,background:"#eef2ff",color:"#4338ca",padding:"3px 8px",borderRadius:12,wordBreak:"break-all"},Y_={display:"flex",alignItems:"center",gap:8,width:"100%",minWidth:0},X_={flex:1,minWidth:0,display:"flex",flexWrap:"wrap",alignItems:"center",gap:4,padding:"5px 8px",fontSize:12,color:"#334155",border:"1px solid #e2e8f0",borderRadius:6,background:"#f8fafc",overflow:"hidden"},fc={fontSize:11,background:"#eef2ff",color:"#4338ca",padding:"1px 6px",borderRadius:10,whiteSpace:"nowrap"},gc={color:"#94a3b8"},J_={padding:"4px 10px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#2563eb",cursor:"pointer",whiteSpace:"nowrap",flexShrink:0},hc={padding:"3px 10px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer",whiteSpace:"nowrap"},Z_={padding:"3px 10px",fontSize:11,border:"1px solid #fca5a5",borderRadius:6,background:"#fef2f2",color:"#b91c1c",cursor:"pointer",whiteSpace:"nowrap"},Q_={display:"flex",flexDirection:"column",gap:6,padding:10,border:"1px solid #fca5a5",borderRadius:8,background:"#fffbeb"},R_={margin:0,fontSize:12,color:"#334155"},ex={padding:"5px 8px",fontSize:12,color:"#0f172a",background:"#fff",border:"1px solid #e2e8f0",borderRadius:6,wordBreak:"break-all"},tx={margin:0,fontSize:11,color:"#b45309"},nx={padding:"3px 12px",fontSize:11,border:"1px solid #dc2626",borderRadius:6,background:"#dc2626",color:"#fff",cursor:"pointer",whiteSpace:"nowrap"},ox={display:"flex",gap:4,alignItems:"center",width:"100%",minWidth:0},rx={flex:1,padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,minWidth:0,width:"100%"},yc={padding:"4px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer",whiteSpace:"nowrap"},Ao={padding:"4px 8px",fontSize:13,lineHeight:1,border:"1px solid #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer",whiteSpace:"nowrap"},ix={display:"flex",alignItems:"center",gap:6,width:"100%",minWidth:0,flexWrap:"wrap"},sx={flex:1,minWidth:0,display:"flex",flexWrap:"wrap",alignItems:"center",gap:4,fontSize:12,color:"#334155"},ax={fontSize:11,background:"#eef2ff",color:"#4338ca",padding:"2px 8px",borderRadius:12,whiteSpace:"nowrap"},lx={display:"flex",flexDirection:"column",gap:2,width:"100%"},dx={fontSize:11,background:"#f1f5f9",padding:"3px 6px",borderRadius:4,color:"#0f172a",wordBreak:"break-all"},cx={fontSize:10,color:"#64748b"},ux={fontSize:11,color:"#94a3b8",padding:"6px 8px",border:"1px dashed #cbd5e1",borderRadius:6,background:"#f8fafc"};function vs({value:e,onChange:t,candidates:n,t:o}){const r=Array.isArray(e)?e:[],s=n??[],[a,l]=u.useState(!1),d=g=>s.find(m=>m.value===g)?.label??g,c=g=>d(g)!==g,p=g=>{const m=r.filter(h=>h!==g);t(m.length===0?void 0:m)},f=g=>{r.includes(g)||(t([...r,g]),l(!1))},b=s.filter(g=>!r.includes(g.value));return i.jsxs("div",{className:"g7le-widget g7le-widget--tag-input","data-testid":"g7le-widget-tag-input",style:px,children:[i.jsxs("div",{style:fx,children:[r.map(g=>i.jsxs("span",{"data-testid":`g7le-tag-chip-${g}`,style:gx,children:[i.jsx("span",{style:hx,children:d(g)}),c(g)&&i.jsx("code",{"data-testid":`g7le-tag-chip-id-${g}`,style:yx,children:g}),i.jsx("button",{type:"button","aria-label":`remove ${g}`,"data-testid":`g7le-tag-remove-${g}`,onClick:()=>p(g),style:bx,children:"✕"})]},g)),i.jsx("button",{type:"button","data-testid":"g7le-tag-add",onClick:()=>l(g=>!g),disabled:b.length===0,style:mx,children:o("layout_editor.control.tag_add")})]}),a&&b.length>0&&i.jsx("div",{"data-testid":"g7le-tag-candidates",style:vx,children:b.map(g=>{const m=g.value!==g.label;return i.jsxs("button",{type:"button","data-testid":`g7le-tag-candidate-${g.value}`,onClick:()=>f(g.value),style:_x,children:[i.jsx("span",{style:xx,children:g.label}),m&&i.jsx("code",{"data-testid":`g7le-tag-candidate-id-${g.value}`,style:wx,children:g.value})]},g.value)})})]})}const px={display:"flex",flexDirection:"column",gap:6},fx={display:"flex",flexWrap:"wrap",gap:4,alignItems:"center"},gx={display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px",fontSize:12,background:"#e0e7ff",color:"#1d4ed8",borderRadius:12},hx={fontSize:12},yx={fontSize:10,color:"#4f46e5",background:"#c7d2fe",borderRadius:4,padding:"0 4px",fontFamily:"monospace"},bx={border:"none",background:"transparent",color:"#1d4ed8",cursor:"pointer",fontSize:10,padding:0,lineHeight:1},mx={padding:"2px 8px",fontSize:12,border:"1px dashed #94a3b8",borderRadius:12,background:"#fff",cursor:"pointer",color:"#475569"},vx={display:"flex",flexDirection:"column",maxHeight:180,overflowY:"auto",border:"1px solid #cbd5e1",borderRadius:6,background:"#fff"},_x={display:"flex",flexDirection:"column",gap:1,textAlign:"left",padding:"6px 10px",fontSize:12,border:"none",borderBottom:"1px solid #f1f5f9",background:"transparent",cursor:"pointer",color:"#0f172a"},xx={fontSize:12,color:"#0f172a"},wx={fontSize:10,color:"#64748b",fontFamily:"monospace"},bc=new Map;function Ze(e,t){bc.set(e,t)}function Tn(e){return e?bc.get(e)??null:null}function Nr(e,t){const o=e("meta",{})?.[t];return typeof o=="string"?o:""}function kx({getValue:e,patch:t,t:n,fieldT:o,spec:r,permissionCandidates:s,bindingCandidates:a}){const l=o??n,d=Nr(e,"title"),c=Nr(e,"description"),p=Nr(e,"icon"),f=Nr(e,"editor_label"),b=e("permissions",[]),g=u.useCallback((y,_)=>{const w={...e("meta",{})??{}};_===void 0||_===""?delete w[y]:w[y]=_,t("meta",w)},[e,t]),m=u.useCallback(y=>{const _=Array.isArray(y)?y:[];_.length===0?t("permissions",void 0):t("permissions",_)},[t]),h=Tn("icon-picker"),v=Ct(r,"icon-picker")??Ct(r,"icon")??(r?.controls?Object.values(r.controls).find(y=>y&&typeof y=="object"&&y.widget==="icon-picker")??null:null);return i.jsxs("div",{className:"g7le-meta-form","data-testid":"g7le-meta-form",style:Cx,children:[i.jsx(To,{label:n("layout_editor.page_settings.meta.title"),children:i.jsx(_t,{value:d,onChange:y=>g("title",y),t:l,testidPrefix:"g7le-meta-title",candidates:a,enableExpressionTree:!0,expressionTreeCollapsible:!0})}),i.jsx(To,{label:n("layout_editor.page_settings.meta.description"),children:i.jsx(_t,{value:c,onChange:y=>g("description",y),t:l,testidPrefix:"g7le-meta-description",candidates:a,enableExpressionTree:!0,expressionTreeCollapsible:!0})}),i.jsx(To,{label:n("layout_editor.page_settings.meta.icon"),children:h?i.jsx(Sx,{icon:p,t:n,onChange:y=>g("icon",typeof y=="string"?y:void 0),IconWidget:h,iconControl:v??{widget:"icon-picker"}}):i.jsx("input",{type:"text","data-testid":"g7le-meta-icon",value:p,placeholder:n("layout_editor.page_settings.meta.icon_placeholder"),onChange:y=>g("icon",y.target.value),style:Ax})}),i.jsx(To,{label:n("layout_editor.page_settings.meta.editor_label"),hint:n("layout_editor.page_settings.meta.editor_label_hint"),children:i.jsx(_t,{value:f,onChange:y=>g("editor_label",y),t:l,testidPrefix:"g7le-meta-editor-label",candidates:a,enableExpressionTree:!0,expressionTreeCollapsible:!0})}),i.jsx(To,{label:n("layout_editor.page_settings.meta.permissions"),hint:n("layout_editor.page_settings.meta.permissions_hint"),children:i.jsx("div",{"data-testid":"g7le-meta-permissions",children:i.jsx(vs,{control:{widget:"tag-input"},value:b,onChange:m,t:n,candidates:s})})})]})}function To({label:e,hint:t,children:n}){return i.jsxs("div",{className:"g7le-meta-field",style:$x,children:[i.jsx("label",{style:Ex,children:e}),n,t?i.jsxs("p",{style:Ix,children:["ⓘ ",t]}):null]})}function Sx({icon:e,onChange:t,t:n,IconWidget:o,iconControl:r}){const[s,a]=u.useState(!1),l=e?/\bfa-/.test(e)?i.jsx("i",{className:e,"aria-hidden":"true"}):e:"📄";return i.jsxs("div",{"data-testid":"g7le-meta-icon",style:{display:"flex",flexDirection:"column",gap:6,minWidth:0},children:[i.jsxs("button",{type:"button","data-testid":"g7le-meta-icon-toggle","aria-expanded":s,onClick:()=>a(d=>!d),style:{display:"flex",alignItems:"center",gap:8,padding:"5px 8px",border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",cursor:"pointer",fontSize:12,color:"#475569",width:"fit-content"},children:[i.jsx("span",{style:{fontSize:16},"aria-hidden":"true",children:l}),i.jsx("span",{children:e||n("layout_editor.page_settings.meta.icon_placeholder")}),i.jsx("span",{"aria-hidden":"true",children:s?"▴":"▾"})]}),s?i.jsx(o,{control:r,value:e,onChange:d=>{t(d),a(!1)},t:n}):null]})}const Cx={display:"flex",flexDirection:"column",gap:16,minWidth:0},$x={display:"flex",flexDirection:"column",gap:6,minWidth:0},Ex={fontSize:13,fontWeight:600,color:"#0f172a"},Ix={margin:0,fontSize:11,color:"#94a3b8"},Ax={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,minWidth:0,width:"100%"};function Mr({checked:e,onChange:t,label:n,testid:o,ariaLabel:r,disabled:s=!1}){return i.jsxs("label",{style:{...Mx,...s?{cursor:"not-allowed"}:{}},children:[i.jsx("button",{type:"button","data-testid":o,role:"switch","aria-checked":e,"aria-label":r,disabled:s,onClick:()=>t(!e),style:Lx(e,s),children:i.jsx("span",{style:Px(e)})}),n!=null?i.jsx("span",{style:Ox(s),children:n}):null]})}function Lr({disabled:e,children:t,testid:n,style:o}){return i.jsx("div",{"data-testid":n,"data-disabled":e?"true":"false","aria-disabled":e,style:{...o,...e?{opacity:.5,pointerEvents:"none",userSelect:"none"}:{}},children:t})}function Tx({filled:e,sourceLabel:t,onRevert:n,revertLabel:o,hint:r,children:s,testid:a}){const l=e&&typeof n=="function",d=!e&&t!=null&&t!=="";return i.jsxs("div",{"data-testid":a,style:Dx,children:[s,l?i.jsxs("button",{type:"button","data-testid":a?`${a}-revert`:void 0,onClick:n,title:r??o,"aria-label":o,style:Nx,children:["↩ ",o]}):d?i.jsx("span",{"data-testid":a?`${a}-source`:void 0,title:r,style:zx,children:t}):null]})}const Dx={position:"relative",minWidth:0,width:"100%"},zx={position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",fontSize:10,color:"#94a3b8",background:"#f1f5f9",borderRadius:4,padding:"1px 6px",pointerEvents:"none",maxWidth:"45%",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},Nx={position:"absolute",right:6,top:"50%",transform:"translateY(-50%)",fontSize:10,color:"#0369a1",background:"#e0f2fe",border:"1px solid #bae6fd",borderRadius:4,padding:"1px 6px",cursor:"pointer",whiteSpace:"nowrap"},Mx={display:"inline-flex",alignItems:"center",gap:8,cursor:"pointer"},Lx=(e,t)=>({position:"relative",width:38,height:22,flexShrink:0,borderRadius:999,border:"none",padding:0,background:t?"#e2e8f0":e?"#2563eb":"#cbd5e1",cursor:t?"not-allowed":"pointer",transition:"background 0.15s ease"}),Px=e=>({position:"absolute",top:2,left:e?18:2,width:18,height:18,borderRadius:"50%",background:"#fff",boxShadow:"0 1px 2px rgba(0,0,0,0.2)",transition:"left 0.15s ease"}),Ox=e=>({fontSize:13,fontWeight:600,color:e?"#94a3b8":"#0f172a"}),Bx=/\$(?:core|module|plugin)_settings:[a-zA-Z0-9._:-]+/;function Wx(e){const t=[];let n=!1;const o=s=>{t.push({kind:"text",text:s}),n=!0},r=(s,a,l)=>{n||o(""),t.push({kind:"chip",raw:s,text:a,removable:l}),n=!1};for(const s of jx(e))s.kind==="text"?o(s.raw):r(s.raw,s.label,s.removable);return n||o(""),t}function jx(e){const t=[];if(typeof e!="string"||e.length===0)return t;const n=e.length;let o=0,r=0;const s=a=>{a>r&&t.push({kind:"text",raw:e.slice(r,a),label:"",removable:!1})};for(;o=n){o++;continue}s(o);const l=e.slice(o,a+2);t.push({kind:"chip",raw:l,label:Vt(l),removable:!0}),o=a+2,r=o;continue}if(e[o]==="$"){const a=Bx.exec(e.slice(o));if(a&&a.index===0){s(o);const l=a[0],d=l.split(":").pop()||l;t.push({kind:"chip",raw:l,label:d,removable:!1}),o+=l.length,r=o;continue}}o++}return s(n),t}function Hx(e,t,n,o){const r=[];let s=!1;return e.forEach((a,l)=>{if(a.kind==="chip"){if(!s&&a.raw===t){s=!0;return}r.push(a.raw??"")}else{const d=a.text??"";if(l===n){const c=Math.max(0,Math.min(o,d.length));r.push(d.slice(0,c),t,d.slice(c))}else r.push(d)}}),r.join("")}function Fx(e,t,n){const o=Math.max(0,Math.min(t,e.length));return e.slice(0,o)+n+e.slice(o)}function Kx(e,t){const n=e.indexOf(t);return n<0?e:e.slice(0,n)+e.slice(n+t.length)}function _s({value:e,onChange:t,t:n,candidates:o,onDone:r,testidPrefix:s="g7le-binding-chip-text",disabled:a=!1}){const l=u.useMemo(()=>Wx(e),[e]),d=u.useRef(null),c=!!o&&o.length>0,[p,f]=u.useState(null),[b,g]=u.useState(null),[m,h]=u.useState(null),[v,y]=u.useState(!1),_=u.useRef(0),w=u.useRef(null),k=u.useMemo(()=>l.map(P=>P.kind==="chip"?`c:${P.raw}`:"t").join("|"),[l]),x=u.useRef(null),$=u.useRef([]),S=u.useRef(!1);u.useLayoutEffect(()=>{const P=S.current;S.current=!1,!(!P&&x.current===k)&&(x.current=k,l.forEach((I,L)=>{if(I.kind!=="text")return;const F=$.current[L];F&&F.textContent!==(I.text??"")&&(F.textContent=I.text??"")}))},[k,l,e]);const C=u.useCallback(()=>{const P=d.current;if(!P)return e;const I=[];for(const L of Array.from(P.querySelectorAll("[data-seg]")))L.dataset.seg==="chip"?I.push(L.dataset.raw??""):I.push(L.textContent??"");return I.join("")},[e]),T=u.useCallback(()=>{a||t(C())},[a,t,C]),E=u.useRef(null),A=u.useRef(!1),N=(P,I)=>{if(!a){P.preventDefault(),P.stopPropagation(),E.current={raw:I,pointerId:P.pointerId},A.current=!1,f(I);try{P.currentTarget.setPointerCapture(P.pointerId)}catch{}}},D=P=>{const I=E.current;if(!I||P.pointerId!==I.pointerId)return;A.current=!0;const L=O(P.clientX,P.clientY);L&&(g({slotIdx:L.slotIdx,offset:L.offset}),h(Ux(d.current,L.slotIdx,L.offset)))},B=(P,I)=>{if(P.stopPropagation(),A.current){A.current=!1;return}S.current=!0,t(Kx(e,I))},M=P=>{const I=E.current;if(!I||P.pointerId!==I.pointerId)return;try{P.currentTarget.releasePointerCapture(P.pointerId)}catch{}E.current=null,A.current&&typeof setTimeout=="function"&&setTimeout(()=>{A.current=!1},0);const L=O(P.clientX,P.clientY);if(f(null),g(null),h(null),!L)return;const F=d.current;if(!F)return;const K=Array.from(F.querySelectorAll("[data-seg]")).map(Z=>Z.dataset.seg==="chip"?{kind:"chip",raw:Z.dataset.raw??""}:{kind:"text",text:Z.textContent??""}),X=Hx(K,I.raw,L.slotIdx,L.offset);X!==e&&(S.current=!0,t(X))},O=(P,I)=>{const L=d.current;if(!L)return null;const F=Array.from(L.querySelectorAll("[data-seg]")),Y=L.ownerDocument,K=Y.elementFromPoint(P,I),X=K?.closest('[data-seg="text"]');if(X)return{slotIdx:F.indexOf(X),offset:Vx(Y,X,P,I)};const Z=K?.closest('[data-seg="chip"]');if(Z){const oe=F.indexOf(Z),G=Z.getBoundingClientRect();if(P=0){const ee=F[oe-1];return{slotIdx:oe-1,offset:(ee.textContent??"").length}}if(oe+1({s:oe,i:G})).filter(oe=>oe.s.dataset.seg==="text").pop();return ae?{slotIdx:ae.i,offset:(ae.s.textContent??"").length}:null},z=()=>{a||!c||(_.current=qx(d.current,e.length),y(P=>!P))},H=P=>{const I=P.path?P.path.split(".").filter(Boolean):[],L=[P.sourceId,...I].join("?.");S.current=!0,t(Fx(e,_.current,`{{${L}}}`)),y(!1)};return i.jsxs("div",{"data-testid":s,style:{display:"flex",flexDirection:"column",gap:4},children:[i.jsxs("div",{ref:d,"data-testid":`${s}-box`,className:"g7le-binding-chip-input",style:Gx,children:[l.map((P,I)=>P.kind==="chip"?i.jsxs("span",{"data-seg":"chip","data-raw":P.raw,"data-testid":`${s}-chip-${I}`,contentEditable:!1,onPointerDown:L=>N(L,P.raw??""),onPointerMove:D,onPointerUp:M,title:P.removable?n("layout_editor.value_tree.change_data"):n("layout_editor.prop_i18n.bound_code_only"),style:{...Zx,...p===P.raw?Qx:null,touchAction:"none"},children:[i.jsx("span",{"aria-hidden":"true",style:Rx,children:"⠿"}),i.jsx("span",{"aria-hidden":"true",style:{marginRight:3},children:"🔗"}),i.jsx("span",{children:P.text}),P.removable&&!a&&i.jsx("button",{type:"button","data-testid":`${s}-chip-remove-${I}`,"aria-label":n("layout_editor.inline_binding.clear"),title:n("layout_editor.inline_binding.clear"),onPointerDown:L=>{L.stopPropagation(),L.preventDefault()},onClick:L=>B(L,P.raw??""),style:ew,children:"✕"})]},`chip-${P.raw}-${I}`):i.jsx("span",{ref:L=>{$.current[I]=L},"data-seg":"text",contentEditable:!a,suppressContentEditableWarning:!0,onInput:T,"data-testid":`${s}-text-${I}`,style:{...Yx,...p?Xx:null,...b?.slotIdx===I?Jx:null}},`text-slot-${I}`)),m&&i.jsx("span",{"aria-hidden":"true","data-testid":`${s}-caret`,style:{position:"absolute",left:m.left,top:m.top,width:2,height:m.height,background:"#2563eb",borderRadius:1,pointerEvents:"none",boxShadow:"0 0 0 1px rgba(37,99,235,0.3)"}})]}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[r&&i.jsxs("button",{type:"button","data-testid":`${s}-done`,onClick:r,style:mc,title:n("layout_editor.value_tree.done"),"aria-label":n("layout_editor.value_tree.done"),children:["✓ ",n("layout_editor.value_tree.done")]}),c&&i.jsxs("div",{style:{position:"relative"},children:[i.jsxs("button",{ref:w,type:"button","data-testid":`${s}-insert`,onClick:z,disabled:a,style:mc,title:n("layout_editor.inline_binding.insert_data"),"aria-label":n("layout_editor.inline_binding.insert_data"),children:["+ ",n("layout_editor.inline_binding.insert_data")]}),i.jsx(Xn,{anchorRef:w,open:v,onClose:()=>y(!1),children:i.jsx($t,{candidates:o,t:n,onSelect:H,testIdSuffix:`${s}-insert`,defaultOpen:!0,floating:!1})})]}),i.jsx("span",{style:tw,children:n("layout_editor.translation.placeholder_locked")})]})]})}function Vx(e,t,n,o){const r=(t.textContent??"").length;try{const a=e;let l=null,d=0;if(typeof a.caretRangeFromPoint=="function"){const c=a.caretRangeFromPoint(n,o);c&&(l=c.startContainer,d=c.startOffset)}else if(typeof a.caretPositionFromPoint=="function"){const c=a.caretPositionFromPoint(n,o);c&&(l=c.offsetNode,d=c.offset)}if(l&&t.contains(l))return Math.max(0,Math.min(d,r))}catch{}const s=t.getBoundingClientRect();return n>s.left+s.width/2?r:0}function Ux(e,t,n){if(!e)return null;const r=Array.from(e.querySelectorAll("[data-seg]"))[t];if(!r)return null;const s=e.getBoundingClientRect();try{const d=r.firstChild,c=e.ownerDocument;if(d&&d.nodeType===Node.TEXT_NODE&&(d.textContent??"").length>0){const p=c.createRange(),f=Math.max(0,Math.min(n,(d.textContent??"").length));p.setStart(d,f),p.setEnd(d,f);const b=p.getClientRects(),g=b.length>0?b[0]:p.getBoundingClientRect();if(g&&(g.height>0||g.width>=0))return{left:g.left-s.left,top:g.top-s.top,height:g.height||r.getBoundingClientRect().height}}}catch{}const a=r.getBoundingClientRect();return{left:(n>0?a.right:a.left)-s.left,top:a.top-s.top,height:a.height||16}}function qx(e,t){if(!e)return t;try{const n=e.ownerDocument.defaultView?.getSelection();if(!n||n.rangeCount===0)return t;const o=n.getRangeAt(0);let r=o.startContainer,s=null;for(;r&&r!==e;){if(r instanceof HTMLElement&&r.dataset.seg==="text"){s=r;break}r=r.parentNode}if(!s||!e.contains(s))return t;const a=Array.from(e.querySelectorAll("[data-seg]"));let l=0;for(const d of a){if(d===s)break;l+=d.dataset.seg==="chip"?(d.dataset.raw??"").length:(d.textContent??"").length}return l+o.startOffset}catch{return t}}const Gx={position:"relative",display:"flex",flexWrap:"wrap",alignItems:"center",gap:2,minHeight:30,padding:"4px 8px",border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",fontSize:12,lineHeight:1.6,minWidth:0,width:"100%",boxSizing:"border-box"},Yx={outline:"none",minWidth:8,minHeight:"1.2em",whiteSpace:"pre-wrap",color:"#0f172a",display:"inline-block",wordBreak:"break-all"},Xx={boxShadow:"inset 0 -2px 0 #93c5fd",background:"#eff6ff",borderRadius:2},Jx={background:"#dbeafe",boxShadow:"inset 0 -2px 0 #2563eb"},Zx={display:"inline-flex",alignItems:"center",gap:1,background:"linear-gradient(180deg,#eff6ff,#dbeafe)",color:"#1d4ed8",border:"1px dashed #60a5fa",borderRadius:9999,padding:"1px 8px 1px 4px",margin:"0 1px",fontSize:11,fontWeight:600,cursor:"grab",userSelect:"none",whiteSpace:"nowrap",boxShadow:"0 1px 2px rgba(37,99,235,0.18)",verticalAlign:"middle"},Qx={opacity:.5,borderStyle:"solid",cursor:"grabbing"},Rx={color:"#2563eb",opacity:.7,fontSize:11,marginRight:1,cursor:"grab"},ew={marginLeft:4,width:14,height:14,lineHeight:"12px",padding:0,border:"none",borderRadius:9999,background:"rgba(29,78,216,0.12)",color:"#1d4ed8",fontSize:9,fontWeight:700,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",flex:"0 0 auto"},mc={padding:"4px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer",whiteSpace:"nowrap"},tw={fontSize:10,color:"#94a3b8"},nw=Jl;function xs(e){return Eb(e)}function Ke({value:e,onChange:t,t:n,candidates:o,placeholder:r,testidPrefix:s="g7le-data-chip-value",readOnly:a=!1,enableExpressionTree:l=!0}){const d=typeof e=="string"?e:"",c=!!o&&o.length>0,[p,f]=u.useState(!1),[b,g]=u.useState(!1),[m,h]=u.useState(!1),v=u.useCallback(S=>i.jsx(Ke,{value:S.value,onChange:C=>S.onChange(C),t:S.t,candidates:S.candidates,testidPrefix:S.testidPrefix,enableExpressionTree:!0}),[]),y=()=>i.jsx("div",{style:{display:"flex",gap:4,alignItems:"center",width:"100%",minWidth:0},children:i.jsx("input",{type:"text","data-testid":`${s}-input`,value:d,placeholder:r??n("layout_editor.page_settings.seo.value_placeholder"),readOnly:a,onChange:S=>t(S.target.value),onFocus:()=>f(!0),onBlur:()=>f(!1),style:{flex:1,padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,minWidth:0,width:"100%",background:a?"#f1f5f9":"#fff",color:a?"#64748b":"#0f172a"}})}),_=u.useCallback(S=>{const C=d?`${d} ${S.expression}`:S.expression;t(C)},[d,t]);if(!l||a)return i.jsxs("div",{"data-testid":s,style:pn,children:[y(),!a&&c&&i.jsx($t,{candidates:o,t:n,onSelect:_,testIdSuffix:`${s}-pick`})]});const w=Wv(d),k=Zd(d),x=Kt(d),$=S=>{const C=Er(d),T=C?gs(C,()=>"",E=>Vt(E)):[];return i.jsxs(i.Fragment,{children:[i.jsx("div",{style:{display:"flex",justifyContent:"flex-start"},children:i.jsxs("button",{type:"button","data-testid":`${S}-to-plain`,onClick:()=>h(!0),style:sw,title:n("layout_editor.value_tree.to_plain"),"aria-label":n("layout_editor.value_tree.to_plain"),children:["↩ ",n("layout_editor.value_tree.to_plain")]})}),m&&i.jsxs("div",{"data-testid":`${S}-to-plain-confirm`,style:aw,children:[i.jsx("p",{style:lw,children:n("layout_editor.value_tree.to_plain_lead")}),i.jsx("div",{style:dw,children:T.length===0?i.jsx("span",{style:{color:"#94a3b8"},children:n("layout_editor.page_settings.seo.value_placeholder")}):T.map((E,A)=>E.kind==="chip"?i.jsxs("span",{style:ws,children:["🔗 ",E.text]},A):i.jsx("span",{style:E.kind==="ellipsis"?{color:"#94a3b8"}:void 0,children:E.text},A))}),i.jsxs("p",{style:cw,children:["⚠ ",n("layout_editor.value_tree.to_plain_warn")]}),i.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:6},children:[i.jsx("button",{type:"button","data-testid":`${S}-to-plain-confirm-cancel`,onClick:()=>h(!1),style:Ut,children:n("layout_editor.value_tree.to_plain_cancel")}),i.jsx("button",{type:"button","data-testid":`${S}-to-plain-confirm-ok`,onClick:()=>{h(!1),t(Er(d)||"")},style:uw,children:n("layout_editor.value_tree.to_plain_ok")})]})]})]})};if(!p&&(w==="expression"||k)){if(k)return i.jsxs("div",{"data-testid":s,style:pn,children:[!a&&$(`${s}-seg`),i.jsx(bs,{value:d,onChange:C=>t(C),t:n,candidates:o,testidPrefix:`${s}-seg`,renderLeafInput:v})]});const S=un(d);return i.jsxs("div",{"data-testid":s,style:pn,children:[!a&&$(`${s}-tree`),i.jsx(sc,{node:S.node,onChange:C=>t(Zn(C,!1)),t:n,candidates:o,testidPrefix:`${s}-tree`,renderLeafInput:v})]})}if(x&&!p&&!b)return i.jsx(ow,{value:d,onChange:t,t:n,candidates:o,testidPrefix:s,onEditRaw:()=>g(!0)});if(!p&&!b&&xs(d)){const S=nw(d);return i.jsx("div",{"data-testid":s,style:pn,children:i.jsxs("div",{style:vc,children:[i.jsx("div",{"data-testid":`${s}-chips`,style:rw,children:S.map((C,T)=>C.kind==="chip"?i.jsxs("span",{style:ws,children:["🔗 ",C.label]},T):i.jsx("span",{children:C.label},T))}),i.jsxs("button",{type:"button","data-testid":`${s}-edit-raw`,onClick:()=>g(!0),style:Ut,title:n("layout_editor.value_tree.edit"),"aria-label":n("layout_editor.value_tree.edit"),children:["✎ ",n("layout_editor.value_tree.edit")]})]})})}return b&&xs(d)?i.jsxs("div",{"data-testid":s,style:pn,children:[i.jsx(_s,{value:d,onChange:t,t:n,candidates:o,disabled:a,onDone:()=>g(!1),testidPrefix:`${s}-chipedit`}),!a&&w!=="raw"&&i.jsxs("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:[i.jsxs("button",{type:"button","data-testid":`${s}-to-expr`,onClick:()=>t($o(d)),style:Ut,title:n("layout_editor.value_tree.to_expression"),"aria-label":n("layout_editor.value_tree.to_expression"),children:["ƒx ",n("layout_editor.value_tree.to_expression")]}),i.jsxs("button",{type:"button","data-testid":`${s}-to-fallback`,onClick:()=>t(hs(d)),style:Ut,title:n("layout_editor.value_tree.segment.fallback"),"aria-label":n("layout_editor.value_tree.segment.fallback"),children:["?? ",n("layout_editor.value_tree.segment.fallback")]})]}),w==="raw"&&i.jsxs("p",{"data-testid":`${s}-raw-hint`,style:ks,children:["ⓘ ",n("layout_editor.value_tree.raw_expression_hint")]})]}):!p&&xs(d)?i.jsxs("div",{"data-testid":s,style:pn,children:[i.jsx(_s,{value:d,onChange:t,t:n,candidates:o,disabled:a,onDone:()=>{g(!1),f(!1)},testidPrefix:`${s}-chipedit`}),!a&&w!=="raw"&&i.jsxs("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:[i.jsxs("button",{type:"button","data-testid":`${s}-to-expr`,onClick:()=>t($o(d)),style:Ut,title:n("layout_editor.value_tree.to_expression"),"aria-label":n("layout_editor.value_tree.to_expression"),children:["ƒx ",n("layout_editor.value_tree.to_expression")]}),i.jsxs("button",{type:"button","data-testid":`${s}-to-fallback`,onClick:()=>t(hs(d)),style:Ut,title:n("layout_editor.value_tree.segment.fallback"),"aria-label":n("layout_editor.value_tree.segment.fallback"),children:["?? ",n("layout_editor.value_tree.segment.fallback")]})]}),w==="raw"&&i.jsxs("p",{"data-testid":`${s}-raw-hint`,style:ks,children:["ⓘ ",n("layout_editor.value_tree.raw_expression_hint")]})]}):i.jsxs("div",{"data-testid":s,style:pn,children:[y(),i.jsxs("div",{style:iw,children:[c&&i.jsx($t,{candidates:o,t:n,onSelect:_,testIdSuffix:`${s}-pick`}),w!=="raw"&&i.jsxs("div",{style:{display:"flex",gap:4},children:[i.jsxs("button",{type:"button","data-testid":`${s}-to-expr`,onClick:()=>t($o(d)),style:Ut,title:n("layout_editor.value_tree.to_expression"),"aria-label":n("layout_editor.value_tree.to_expression"),children:["ƒx ",n("layout_editor.value_tree.to_expression")]}),i.jsxs("button",{type:"button","data-testid":`${s}-to-fallback`,onClick:()=>t(hs(d)),style:Ut,title:n("layout_editor.value_tree.segment.fallback"),"aria-label":n("layout_editor.value_tree.segment.fallback"),children:["?? ",n("layout_editor.value_tree.segment.fallback")]})]})]}),w==="raw"&&!p&&i.jsxs("p",{"data-testid":`${s}-raw-hint`,style:ks,children:["ⓘ ",n("layout_editor.value_tree.raw_expression_hint")]})]})}function ow({value:e,onChange:t,t:n,candidates:o,testidPrefix:r,onEditRaw:s}){const[a,l]=u.useState(!1),d=u.useRef(null),c=Vt(e),p=!!o&&o.length>0,f=Kt(e)?.localeFn;return i.jsxs("div",{"data-testid":r,style:pn,children:[i.jsxs("div",{style:vc,children:[i.jsxs("span",{"data-testid":`${r}-chip`,style:ws,children:["🔗 ",c]}),p&&i.jsx("button",{ref:d,type:"button","data-testid":`${r}-change`,onClick:()=>l(b=>!b),style:Ut,title:n("layout_editor.value_tree.change_data"),"aria-label":n("layout_editor.value_tree.change_data"),children:n("layout_editor.value_tree.change_data")}),i.jsx("button",{type:"button","data-testid":`${r}-edit-raw`,onClick:s,style:Ut,title:n("layout_editor.value_tree.edit"),"aria-label":n("layout_editor.value_tree.edit"),children:"✎"})]}),p&&i.jsx(Xn,{anchorRef:d,open:a,onClose:()=>l(!1),children:i.jsx($t,{candidates:o,t:n,onSelect:b=>{if(f){const h=[b.sourceId,...b.path?b.path.split(".").filter(Boolean):[]].join(".");t(`{{${f}(${h})}}`),l(!1);return}const g=b.path?b.path.split(".").filter(Boolean):[],m=[b.sourceId,...g].join("?.");t(`{{${m}}}`),l(!1)},testIdSuffix:`${r}-pick`,defaultOpen:!0,floating:!1})})]})}const pn={display:"flex",flexDirection:"column",gap:4,width:"100%",minWidth:0},vc={display:"flex",alignItems:"center",gap:6,width:"100%",minWidth:0,flexWrap:"wrap"},rw={flex:1,minWidth:0,display:"flex",flexWrap:"wrap",alignItems:"center",gap:4,padding:"5px 8px",fontSize:12,color:"#334155",border:"1px solid #e2e8f0",borderRadius:6,background:"#f8fafc"},ws={fontSize:11,background:"#eef2ff",color:"#4338ca",padding:"2px 8px",borderRadius:12,whiteSpace:"nowrap"},Ut={padding:"4px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer",whiteSpace:"nowrap"},iw={display:"flex",flexWrap:"wrap",alignItems:"center",gap:6},ks={margin:"2px 0 0",fontSize:11,color:"#94a3b8",lineHeight:1.4},sw={padding:"3px 10px",fontSize:11,border:"1px solid #fca5a5",borderRadius:6,background:"#fef2f2",color:"#b91c1c",cursor:"pointer",whiteSpace:"nowrap"},aw={display:"flex",flexDirection:"column",gap:6,padding:10,border:"1px solid #fca5a5",borderRadius:8,background:"#fffbeb"},lw={margin:0,fontSize:12,color:"#334155"},dw={padding:"5px 8px",fontSize:12,color:"#0f172a",background:"#fff",border:"1px solid #e2e8f0",borderRadius:6,wordBreak:"break-all",display:"flex",flexWrap:"wrap",gap:4,alignItems:"center"},cw={margin:0,fontSize:11,color:"#b45309"},uw={padding:"3px 12px",fontSize:11,border:"1px solid #dc2626",borderRadius:6,background:"#dc2626",color:"#fff",cursor:"pointer",whiteSpace:"nowrap"};let _c=0;function Pr({value:e,onChange:t,keyField:n,valueField:o="content",t:r,candidates:s,testidPrefix:a="g7le-kv-chip-editor",keyPlaceholder:l,valuePlaceholder:d,addLabel:c,renderKeyInput:p}){const f=u.useMemo(()=>(Array.isArray(e)?e:[]).map(w=>({id:_c++,k:typeof w[n]=="string"?w[n]:"",v:typeof w[o]=="string"?w[o]:""})),[]),[b,g]=u.useState(f),m=u.useCallback(w=>{g(w);const k=w.filter(x=>x.k.trim()!=="").map(x=>({[n]:x.k,[o]:x.v}));t(k)},[n,o,t]),h=u.useCallback(()=>{m([...b,{id:_c++,k:"",v:""}])},[b,m]),v=u.useCallback(w=>{m(b.filter(k=>k.id!==w))},[b,m]),y=u.useCallback((w,k)=>{m(b.map(x=>x.id===w?{...x,k}:x))},[b,m]),_=u.useCallback((w,k)=>{m(b.map(x=>x.id===w?{...x,v:k}:x))},[b,m]);return i.jsxs("div",{"data-testid":a,style:{display:"flex",flexDirection:"column",gap:6},children:[b.map(w=>i.jsxs("div",{"data-testid":`${a}-row-${w.id}`,style:{display:"flex",gap:6,alignItems:"flex-start",border:"1px solid #e2e8f0",borderRadius:8,padding:8},children:[i.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:6},children:[i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:2,minWidth:0},children:p?i.jsx("div",{style:{minWidth:0},children:p({value:w.k,onChange:k=>y(w.id,k),testid:`${a}-key-${w.id}`,placeholder:l??r(`layout_editor.page_settings.seo.extra_${n}`)})}):i.jsx("input",{type:"text","data-testid":`${a}-key-${w.id}`,value:w.k,placeholder:l??r(`layout_editor.page_settings.seo.extra_${n}`),onChange:k=>y(w.id,k.target.value),style:{width:"100%",padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,minWidth:0,boxSizing:"border-box"}})}),i.jsx("div",{style:{minWidth:0},children:i.jsx(Ke,{value:w.v,onChange:k=>_(w.id,k),t:r,candidates:s,placeholder:d??r("layout_editor.page_settings.seo.extra_content"),testidPrefix:`${a}-value-${w.id}`})})]}),i.jsx("button",{type:"button","data-testid":`${a}-remove-${w.id}`,onClick:()=>v(w.id),title:r("layout_editor.page_settings.seo.remove"),"aria-label":r("layout_editor.page_settings.seo.remove"),style:{flex:"0 0 auto",padding:"4px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#64748b",cursor:"pointer"},children:"✕"})]},w.id)),i.jsxs("button",{type:"button","data-testid":`${a}-add`,onClick:h,style:{alignSelf:"flex-start",padding:"5px 10px",fontSize:12,border:"1px dashed #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer"},children:["+ ",c??r("layout_editor.page_settings.seo.add_extra")]})]})}const pw=["website","article","product","profile"],fw=["summary","summary_large_image","app","player"];function gw(e){switch(e){case"core":return"layout_editor.page_settings.seo.og_source_core";case"inherited":return"layout_editor.page_settings.seo.og_source_inherited";case"filter":return"layout_editor.page_settings.seo.og_source_filter";case"layout":return null;default:return e?"layout_editor.page_settings.seo.og_source_module":null}}function xc(e){const t={};for(const n of e??[])t[n.key]=n;return t}function wc(e,t){return!!e&&t&&typeof e.sourceExpr=="string"&&e.sourceExpr!==""&&!e.overriddenByLayout&&!e.lockedByFilter}function kc({label:e,sourceExpr:t,onReplace:n,t:o,testid:r}){return i.jsxs("div",{"data-testid":r,style:Sw,children:[i.jsxs("span",{"data-testid":`${r}-chip`,style:Cw,title:t,children:["🔗 ",e||t]}),i.jsx("span",{"data-testid":`${r}-badge`,style:$w,children:o("layout_editor.page_settings.seo.auto_chip_source")}),i.jsx("button",{type:"button","data-testid":`${r}-replace`,onClick:n,style:Ew,children:o("layout_editor.page_settings.seo.auto_chip_replace")})]})}function hw({og:e,twitter:t,onChangeOg:n,onChangeTwitter:o,ogPreview:r,twitterPreview:s,defaultsAvailable:a=!1,candidates:l,t:d,testidPrefix:c="g7le-seo-og"}){const p=e&&typeof e=="object"?e:{},f=t&&typeof t=="object"?t:{},[b,g]=u.useState(p.image_height!=null||p.image_type!=null||p.image_secure_url!=null),m=xc(r),h=xc(s),v=u.useCallback((T,E)=>{const A={...p};E===void 0||E===""||E===null?delete A[T]:A[T]=E,n(A)},[p,n]),y=u.useCallback((T,E)=>{const A={...f};E===void 0||E===""||E===null?delete A[T]:A[T]=E,o(A)},[f,o]),_=(T,E,A)=>!A||!a||!A.lockedByFilter?null:i.jsx("div",{style:{display:"flex",gap:6,alignItems:"center",marginTop:2},children:i.jsxs("span",{"data-testid":`${T}-locked-${E}`,style:xw,children:["🔒 ",d("layout_editor.page_settings.seo.og_locked")]})}),w=T=>{if(!T||!a||T.lockedByFilter||T.overriddenByLayout)return;const E=gw(T.source);return E?d(E):void 0},k=(T,E)=>T&&a?T.overriddenByLayout===!0:E!=="",x=(T,E,A,N,D,B)=>{const M=B[E],O=!!M?.lockedByFilter,z=typeof N[E]=="string"?N[E]:"";return i.jsxs("div",{"data-testid":`${T}-${E}`,style:Dn,children:[i.jsx("label",{style:to,children:d(A)}),O?i.jsx("div",{"data-testid":`${T}-locked-value-${E}`,style:_w,children:String(M?.effectiveValue??"")}):wc(M,a)?i.jsx(kc,{label:M.label??"",sourceExpr:M.sourceExpr,onReplace:()=>D(E,M.sourceExpr),t:d,testid:`${T}-${E}-auto`}):i.jsx(_t,{value:z,onChange:H=>D(E,H??""),t:d,candidates:l,placeholder:a&&M?.effectiveValue!=null?String(M.effectiveValue):void 0,testidPrefix:`${T}-${E}-field`,enableExpressionTree:!0,expressionTreeCollapsible:!0}),_(T,E,M)]})},$=(T,E,A,N,D,B)=>{const M=B[E],O=!!M?.lockedByFilter,z=typeof N[E]=="string"?N[E]:"";return i.jsxs("div",{"data-testid":`${T}-${E}`,style:Dn,children:[i.jsx("label",{style:to,children:d(A)}),wc(M,a)?i.jsx(kc,{label:M.label??"",sourceExpr:M.sourceExpr,onReplace:()=>D(E,M.sourceExpr),t:d,testid:`${T}-${E}-auto`}):i.jsx(Ke,{value:z,onChange:H=>D(E,H),t:d,candidates:l,readOnly:O,placeholder:a&&M?.effectiveValue!=null?String(M.effectiveValue):void 0,testidPrefix:`${T}-${E}-field`}),_(T,E,M)]})},S=(T,E,A,N,D,B)=>{const M=B[E],O=!!M?.lockedByFilter,z=typeof N[E]=="string"?N[E]:"",H=k(M,z),P=H?z:"";return i.jsxs("div",{"data-testid":`${T}-${E}`,style:Dn,children:[i.jsx("label",{style:to,children:d(A)}),i.jsx(Tx,{filled:H,sourceLabel:w(M),onRevert:O?void 0:()=>D(E,void 0),revertLabel:d("layout_editor.page_settings.seo.revert_default"),testid:`${T}-${E}-overlay`,children:i.jsx("div",{"data-testid":`${T}-${E}-input`,style:{minWidth:0},children:i.jsx(Ke,{value:P,onChange:I=>D(E,I),t:d,candidates:l,readOnly:O,placeholder:a&&M?.effectiveValue!=null?String(M.effectiveValue):void 0,testidPrefix:`${T}-${E}-chip`})})}),_(T,E,M)]})},C=(T,E,A,N,D,B,M)=>{const O=M[E],z=typeof D[E]=="string"?D[E]:"",H=k(O,z),P=w(O),I=H?z:"";return i.jsxs("div",{"data-testid":`${T}-${E}`,style:Dn,children:[i.jsxs("div",{style:bw,children:[i.jsx("label",{style:to,children:d(A)}),P?i.jsxs("span",{"data-testid":`${T}-${E}-source-inline`,style:mw,children:["· ",P]}):null]}),i.jsxs("select",{"data-testid":`${T}-${E}-select`,value:I,onChange:L=>B(E,L.target.value),style:vw,children:[i.jsx("option",{value:"",children:a&&O?.effectiveValue!=null&&O.effectiveValue!==""?`${d("layout_editor.page_settings.seo.use_default")} (${String(O.effectiveValue)})`:d("layout_editor.page_settings.seo.use_default")}),N.map(L=>i.jsx("option",{value:L,children:L},L))]}),_(T,E,O)]})};return i.jsxs("div",{"data-testid":c,style:{display:"flex",flexDirection:"column",gap:12},children:[i.jsxs("div",{"data-testid":`${c}-og-section`,style:Sc,children:[i.jsx("div",{style:Cc,children:d("layout_editor.page_settings.seo.og_section")}),i.jsxs("p",{"data-testid":`${c}-intro`,style:yw,children:["ⓘ ",d("layout_editor.page_settings.seo.og_intro")]}),C(c,"type","layout_editor.page_settings.seo.og_type",pw,p,v,m),x(c,"title","layout_editor.page_settings.seo.og_title",p,v,m),x(c,"description","layout_editor.page_settings.seo.og_description",p,v,m),$(c,"image","layout_editor.page_settings.seo.og_image",p,v,m),x(c,"image_alt","layout_editor.page_settings.seo.og_image_alt",p,v,m),i.jsxs("div",{style:Dn,children:[i.jsxs("button",{type:"button","data-testid":`${c}-image-adv-toggle`,"aria-expanded":b,onClick:()=>g(T=>!T),style:ww,children:[b?"▾":"▸"," ",d("layout_editor.page_settings.seo.og_image_adv")]}),b?i.jsxs("div",{"data-testid":`${c}-image-adv`,style:kw,children:[S(c,"image_height","layout_editor.page_settings.seo.og_image_height",p,v,m),S(c,"image_type","layout_editor.page_settings.seo.og_image_type",p,v,m),S(c,"image_secure_url","layout_editor.page_settings.seo.og_image_secure_url",p,v,m)]}):null]}),S(c,"site_name","layout_editor.page_settings.seo.og_site_name",p,v,m),S(c,"locale","layout_editor.page_settings.seo.og_locale",p,v,m),i.jsxs("div",{"data-testid":`${c}-extra`,style:Dn,children:[i.jsx("label",{style:to,children:d("layout_editor.page_settings.seo.og_extra")}),i.jsx(Pr,{value:Array.isArray(p.extra)?p.extra:[],onChange:T=>v("extra",T.length>0?T:void 0),keyField:"property",t:d,candidates:l,testidPrefix:`${c}-extra-editor`})]})]}),i.jsxs("div",{"data-testid":`${c}-tw-section`,style:Sc,children:[i.jsx("div",{style:Cc,children:d("layout_editor.page_settings.seo.tw_section")}),i.jsx("p",{style:{margin:"0 0 6px",fontSize:11,color:"#94a3b8"},children:d("layout_editor.page_settings.seo.tw_fallback_note")}),C("g7le-seo-tw","card","layout_editor.page_settings.seo.tw_card",fw,f,y,h),S("g7le-seo-tw","site","layout_editor.page_settings.seo.tw_site",f,y,h),S("g7le-seo-tw","creator","layout_editor.page_settings.seo.tw_creator",f,y,h),x("g7le-seo-tw","title","layout_editor.page_settings.seo.tw_title",f,y,h),x("g7le-seo-tw","description","layout_editor.page_settings.seo.tw_description",f,y,h),$("g7le-seo-tw","image","layout_editor.page_settings.seo.tw_image",f,y,h),x("g7le-seo-tw","image_alt","layout_editor.page_settings.seo.tw_image_alt",f,y,h),i.jsxs("div",{"data-testid":"g7le-seo-tw-extra",style:Dn,children:[i.jsx("label",{style:to,children:d("layout_editor.page_settings.seo.tw_extra")}),i.jsx(Pr,{value:Array.isArray(f.extra)?f.extra:[],onChange:T=>y("extra",T.length>0?T:void 0),keyField:"name",t:d,candidates:l,testidPrefix:"g7le-seo-tw-extra-editor"})]})]})]})}const Sc={border:"1px solid #e2e8f0",borderRadius:8,padding:12,display:"flex",flexDirection:"column",gap:10},Cc={fontSize:13,fontWeight:600,color:"#0f172a"},yw={margin:0,fontSize:11,color:"#64748b",background:"#f8fafc",borderRadius:6,padding:"6px 8px"},Dn={display:"flex",flexDirection:"column",gap:4},to={fontSize:12,color:"#475569"},bw={display:"flex",alignItems:"center",gap:6},mw={fontSize:11,color:"#94a3b8"},vw={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,width:"100%",minWidth:0,boxSizing:"border-box"},_w={padding:"5px 8px",fontSize:12,border:"1px solid #e2e8f0",borderRadius:6,background:"#f1f5f9",color:"#64748b"},xw={fontSize:11,color:"#7c3aed"},ww={alignSelf:"flex-start",padding:"2px 0",fontSize:12,fontWeight:600,color:"#475569",background:"transparent",border:"none",cursor:"pointer"},kw={display:"flex",flexDirection:"column",gap:8,paddingLeft:14,marginTop:4,minWidth:0},Sw={display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",minWidth:0},Cw={display:"inline-flex",alignItems:"center",maxWidth:"100%",padding:"3px 8px",fontSize:12,color:"#1d4ed8",background:"#eff6ff",border:"1px solid #bfdbfe",borderRadius:6,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},$w={fontSize:11,color:"#94a3b8"},Ew={padding:"2px 8px",fontSize:11,color:"#475569",background:"#fff",border:"1px solid #cbd5e1",borderRadius:6,cursor:"pointer"},Iw=["WebPage","WebSite","ItemList","BreadcrumbList","Organization","Person","CollectionPage","AboutPage","ContactPage","SearchAction"];function Or(e){const t=[],n=(o,r)=>{for(const[s,a]of Object.entries(o)){if(s==="@type"||s==="@context")continue;const l=r?`${r}.${s}`:s;a!==null&&typeof a=="object"&&!Array.isArray(a)?n(a,l):t.push({key:l,value:a==null?"":String(a)})}};return n(e,""),t}function $c(e,t){const n={"@type":e};for(const{key:o,value:r}of t){if(o.trim()==="")continue;const s=o.split(".");let a=n;for(let l=0;lp?Or(e).map(D=>({id:Ss++,...D})):[]),_=u.useCallback((D,B)=>{h(D),y(B),t($c(D,B.map(M=>({key:M.key,value:M.value}))))},[t]),w=u.useCallback(()=>{const D=n,B=typeof D["@type"]=="string"?D["@type"]:m,M=Or(D).map(O=>({id:Ss++,key:O.key,value:o?.[O.key]?.expr??O.value}));return{type:B,rows:M}},[n,o,m]),k=u.useCallback(D=>{if(b(D),D){if(v.length===0&&n&&typeof n=="object"){const B=w();_(B.type,B.rows);return}t($c(m,v.map(B=>({key:B.key,value:B.value}))))}else t(null)},[m,v,n,w,_,t]),x=u.useCallback(()=>{if(!n)return;const D=w();_(D.type,D.rows)},[n,w,_]),$=u.useCallback(()=>{_(m,[...v,{id:Ss++,key:"",value:""}])},[m,v,_]),S=u.useCallback(D=>{_(m,v.filter(B=>B.id!==D))},[m,v,_]),C=u.useCallback((D,B)=>{_(m,v.map(M=>M.id===D?{...M,key:B}:M))},[m,v,_]),T=u.useCallback((D,B)=>{_(m,v.map(M=>M.id===D?{...M,value:B}:M))},[m,v,_]),E=u.useMemo(()=>n?Or(n):[],[n]),A=u.useMemo(()=>s?Or(s):[],[s]),N=v.some(D=>D.key.trim()!==""&&D.value.trim()==="");if(r){const D=s&&typeof s["@type"]=="string"?s["@type"]:"";return i.jsxs("div",{"data-testid":c,style:Ec,children:[i.jsxs("div",{style:Ic,children:[i.jsx("span",{style:Tw,children:"🔒"}),i.jsx("span",{style:{fontSize:13,fontWeight:600},children:d("layout_editor.page_settings.seo.sd_mode")}),i.jsx("span",{"data-testid":`${c}-locked-badge`,style:Dw,children:d("layout_editor.page_settings.seo.sd_filter_locked")})]}),i.jsxs("div",{"data-testid":`${c}-locked`,style:zw,children:[i.jsxs("p",{style:{margin:"0 0 6px",fontSize:12,color:"#475569"},children:["ⓘ ",d("layout_editor.page_settings.seo.sd_filter_locked_note")]}),i.jsxs("div",{"data-testid":`${c}-filtered-block`,children:[D?i.jsxs("div",{style:{fontSize:12,fontWeight:600,marginBottom:4},children:["@type: ",D]}):null,A.map(B=>i.jsxs("div",{"data-testid":`${c}-filtered-row-${B.key}`,style:Ac,children:[i.jsx("code",{style:Tc,children:B.key}),i.jsx("span",{style:Dc,children:B.value})]},B.key))]})]})]})}return i.jsxs("div",{"data-testid":c,style:Ec,children:[i.jsx("div",{style:Ic,children:i.jsx(Mr,{checked:f,onChange:k,testid:`${c}-mode`,label:d("layout_editor.page_settings.seo.sd_manual_toggle")})}),!f&&i.jsxs("div",{"data-testid":`${c}-auto`,style:{marginTop:8},children:[i.jsxs("div",{"data-testid":`${c}-auto-preview`,style:Nw,children:[i.jsxs("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:[d("layout_editor.page_settings.seo.sd_auto_title"),n&&typeof n["@type"]=="string"?`: ${n["@type"]}`:"",a?i.jsxs("span",{style:{marginLeft:6,color:"#94a3b8",fontWeight:400},children:["(",a,")"]}):null]}),E.length===0?i.jsx("p",{style:{margin:0,fontSize:12,color:"#94a3b8"},children:d("layout_editor.page_settings.seo.sd_auto_empty")}):E.map(D=>{const B=o?.[D.key];return i.jsxs("div",{"data-testid":`${c}-auto-row-${D.key}`,style:Ac,children:[i.jsx("code",{style:Tc,children:D.key}),B?i.jsxs("span",{"data-testid":`${c}-auto-chip-${D.key}`,style:Mw,title:B.expr,children:["🔗 ",B.label||B.expr]}):i.jsx("span",{style:Dc,children:D.value})]},D.key)})]}),i.jsxs("p",{"data-testid":`${c}-replace-warn`,style:Lw,children:["ⓘ ",d("layout_editor.page_settings.seo.sd_replace_pre_warn")]})]}),f&&i.jsxs("div",{"data-testid":`${c}-manual`,style:{marginTop:8},children:[i.jsxs("p",{"data-testid":`${c}-replace-warn`,style:Pw,children:["⚠ ",d("layout_editor.page_settings.seo.sd_replace_warn")]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[i.jsx("label",{style:{fontSize:12,color:"#475569"},children:d("layout_editor.page_settings.seo.sd_type")}),i.jsx("input",{type:"text","data-testid":`${c}-type`,list:`${c}-type-options`,value:m,onChange:D=>_(D.target.value,v),style:Ow}),i.jsx("datalist",{id:`${c}-type-options`,children:Iw.map(D=>i.jsx("option",{value:D},D))})]}),i.jsx("div",{style:{marginTop:8,display:"flex",flexDirection:"column",gap:6},children:v.map(D=>i.jsxs("div",{"data-testid":`${c}-prop-${D.id}`,style:Bw,children:[i.jsx("input",{type:"text","data-testid":`${c}-prop-key-${D.id}`,value:D.key,placeholder:d("layout_editor.page_settings.seo.sd_prop_key"),onChange:B=>C(D.id,B.target.value),style:{width:160,padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,minWidth:0}}),i.jsx("div",{style:{flex:1,minWidth:0},children:i.jsx(Ke,{value:D.value,onChange:B=>T(D.id,B),t:d,candidates:l,placeholder:d("layout_editor.page_settings.seo.sd_prop_value"),testidPrefix:`${c}-prop-value-${D.id}`})}),i.jsx("button",{type:"button","data-testid":`${c}-prop-remove-${D.id}`,onClick:()=>S(D.id),title:d("layout_editor.page_settings.seo.remove"),"aria-label":d("layout_editor.page_settings.seo.remove"),style:Ww,children:"✕"})]},D.id))}),i.jsxs("div",{style:{marginTop:8,display:"flex",gap:8},children:[i.jsxs("button",{type:"button","data-testid":`${c}-add`,onClick:$,style:zc,children:["+ ",d("layout_editor.page_settings.seo.sd_add_prop")]}),n?i.jsxs("button",{type:"button","data-testid":`${c}-seed-from-module`,onClick:x,style:zc,children:["↩ ",d("layout_editor.page_settings.seo.sd_seed_from_module")]}):null]}),i.jsxs("p",{"data-testid":`${c}-empty-note`,style:jw,children:["ⓘ ",d("layout_editor.page_settings.seo.sd_empty_note"),N?i.jsxs("span",{style:{color:"#b45309"},children:[" ",d("layout_editor.page_settings.seo.sd_has_empty")]}):null]})]})]})}const Ec={display:"flex",flexDirection:"column"},Ic={display:"flex",alignItems:"center",gap:8},Tw={fontSize:14},Dw={fontSize:11,padding:"2px 6px",borderRadius:4,background:"#f1f5f9",color:"#64748b"},zw={marginTop:8,border:"1px solid #fcd34d",borderRadius:8,padding:10,background:"#fffbeb"},Nw={border:"1px solid #e2e8f0",borderRadius:8,padding:10,background:"#f8fafc"},Ac={display:"flex",gap:8,alignItems:"center",padding:"2px 0"},Tc={fontSize:11,color:"#475569",background:"#fff",padding:"2px 6px",borderRadius:4,minWidth:120},Dc={fontSize:11,color:"#0f172a",fontFamily:"monospace",wordBreak:"break-all"},Mw={display:"inline-flex",alignItems:"center",padding:"2px 8px",fontSize:11,color:"#1d4ed8",background:"#eff6ff",border:"1px solid #bfdbfe",borderRadius:6},Lw={margin:"6px 0 0",fontSize:12,color:"#64748b"},Pw={margin:"0 0 8px",fontSize:12,color:"#b45309",background:"#fffbeb",border:"1px solid #fcd34d",borderRadius:6,padding:"6px 8px"},Ow={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,width:"100%",minWidth:0},Bw={display:"flex",gap:6,alignItems:"flex-start",border:"1px solid #e2e8f0",borderRadius:8,padding:8},Ww={padding:"4px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#64748b",cursor:"pointer"},zc={padding:"5px 10px",fontSize:12,border:"1px dashed #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer"},jw={margin:"8px 0 0",fontSize:11,color:"#94a3b8"},Nc=new Set(["core_setting","setting","query","route"]);function Hw({vars:e,onChange:t,varCandidates:n,gatingMet:o=!1,candidates:r,t:s,testidPrefix:a="g7le-seo-vars"}){const l=u.useMemo(()=>e&&typeof e=="object"?{...e}:{},[e]),d=u.useMemo(()=>Array.isArray(n)?n:[],[n]),c=u.useMemo(()=>o?d.filter(x=>Nc.has(x.source)):[],[d,o]),p=u.useMemo(()=>o?d.filter(x=>x.source==="data"):[],[d,o]);u.useMemo(()=>new Set(c.map(x=>x.name)),[c]);const f=u.useMemo(()=>new Set(p.map(x=>x.name)),[p]),b=u.useMemo(()=>{const x=new Set;for(const $ of d)Nc.has($.source)&&x.add($.name);return x},[d]),g=u.useMemo(()=>Object.keys(l).filter(x=>!f.has(x)),[l,f]),m=u.useCallback((x,$)=>{const S={...l};$===void 0?delete S[x]:S[x]=$,t(S)},[l,t]),[h,v]=u.useState(""),y=h.trim()!==""&&b.has(h.trim()),_=h.trim()!==""&&Object.prototype.hasOwnProperty.call(l,h.trim()),w=h.trim()!==""&&!y&&!_&&!f.has(h.trim()),k=u.useCallback(()=>{const x=h.trim();x===""||b.has(x)||Object.prototype.hasOwnProperty.call(l,x)||(t({...l,[x]:""}),v(""))},[h,b,l,t]);return i.jsxs("div",{"data-testid":a,style:{display:"flex",flexDirection:"column",gap:10},children:[i.jsx("span",{"data-testid":"g7le-seo-var-list",hidden:!0,"data-gating":o?"1":"0"}),!o&&i.jsxs("div",{"data-testid":`${a}-precondition`,style:Fw,children:["⚠ ",s("layout_editor.page_settings.seo.vars_precondition")]}),c.length>0&&i.jsxs("div",{"data-testid":`${a}-auto-group`,style:Cs,children:[i.jsx("div",{style:$s,children:s("layout_editor.page_settings.seo.vars_auto_group")}),c.map(x=>i.jsxs("div",{"data-testid":`g7le-seo-var-auto-${x.name}`,style:Kw,children:[i.jsx("span",{style:Vw,children:"🔒"}),i.jsx("code",{style:Es,children:x.name}),i.jsxs("span",{style:Uw,children:["〔",s("layout_editor.page_settings.seo.vars_auto"),"·",x.source,"〕"]}),x.owner?.name?i.jsx("span",{style:qw,children:x.owner.name}):null]},x.name))]}),p.length>0&&i.jsxs("div",{"data-testid":`${a}-data-group`,style:Cs,children:[i.jsx("div",{style:$s,children:s("layout_editor.page_settings.seo.vars_data_group")}),p.map(x=>{const $=l[x.name]??"",S=$.trim()==="";return i.jsxs("div",{"data-testid":`g7le-seo-var-data-${x.name}`,style:Mc,children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[i.jsx("code",{style:Es,children:x.name}),x.required?i.jsx("span",{"data-testid":`g7le-seo-var-required-${x.name}`,style:Gw,children:"*"}):null]}),i.jsx(Ke,{value:$,onChange:C=>m(x.name,C??""),t:s,candidates:r,testidPrefix:`g7le-seo-var-data-field-${x.name}`}),x.required&&S?i.jsxs("p",{"data-testid":`g7le-seo-var-empty-warn-${x.name}`,style:Is,children:["⚠ ",s("layout_editor.page_settings.seo.vars_required_empty")]}):null]},x.name)})]}),i.jsxs("div",{"data-testid":`${a}-custom-group`,style:Cs,children:[i.jsx("div",{style:$s,children:s("layout_editor.page_settings.seo.vars_custom_group")}),g.map(x=>i.jsxs("div",{"data-testid":`g7le-seo-var-custom-${x}`,style:Mc,children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[i.jsx("code",{style:Es,children:x}),i.jsx("button",{type:"button","data-testid":`g7le-seo-var-custom-remove-${x}`,onClick:()=>m(x,void 0),title:s("layout_editor.page_settings.seo.remove"),"aria-label":s("layout_editor.page_settings.seo.remove"),style:{marginLeft:"auto",padding:"2px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#64748b",cursor:"pointer"},children:"✕"})]}),i.jsx(Ke,{value:l[x]??"",onChange:$=>m(x,$??""),t:s,candidates:r,testidPrefix:`g7le-seo-var-custom-field-${x}`})]},x)),i.jsxs("div",{"data-testid":"g7le-seo-var-add",style:{display:"flex",flexDirection:"column",gap:4,marginTop:6},children:[i.jsxs("div",{style:{display:"flex",gap:6},children:[i.jsx("input",{type:"text","data-testid":"g7le-seo-var-add-name",value:h,placeholder:s("layout_editor.page_settings.seo.vars_add_name"),onChange:x=>v(x.target.value),style:{flex:1,padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,minWidth:0}}),i.jsxs("button",{type:"button","data-testid":"g7le-seo-var-add-confirm",onClick:k,disabled:h.trim()===""||y||_,style:Yw,children:["+ ",s("layout_editor.page_settings.seo.vars_add")]})]}),y?i.jsxs("p",{"data-testid":"g7le-seo-var-add-reserved-warn",style:Is,children:["⚠ ",s("layout_editor.page_settings.seo.vars_name_reserved",{name:h.trim()})]}):null,_&&!y?i.jsxs("p",{"data-testid":"g7le-seo-var-add-duplicate-warn",style:Is,children:["⚠ ",s("layout_editor.page_settings.seo.vars_name_duplicate",{name:h.trim()})]}):null,w?i.jsxs("p",{"data-testid":"g7le-seo-var-add-not-provided-hint",style:{margin:0,fontSize:11,color:"#94a3b8"},children:["ⓘ ",s("layout_editor.page_settings.seo.vars_name_not_provided",{name:h.trim()})]}):null]})]}),i.jsxs("p",{style:{margin:0,fontSize:11,color:"#94a3b8"},children:["ⓘ ",s("layout_editor.page_settings.seo.vars_value_hint")]})]})}const Fw={fontSize:12,color:"#b45309",background:"#fffbeb",border:"1px solid #fcd34d",borderRadius:6,padding:"6px 8px"},Cs={border:"1px solid #e2e8f0",borderRadius:8,padding:10,display:"flex",flexDirection:"column",gap:6},$s={fontSize:12,fontWeight:600,color:"#475569"},Kw={display:"flex",alignItems:"center",gap:6,padding:"2px 0"},Mc={display:"flex",flexDirection:"column",border:"1px solid #f1f5f9",borderRadius:6,padding:8},Vw={fontSize:13},Es={fontSize:12,color:"#0f172a",background:"#f1f5f9",padding:"2px 6px",borderRadius:4},Uw={fontSize:11,color:"#64748b"},qw={fontSize:11,color:"#94a3b8"},Gw={color:"#dc2626",fontWeight:700},Is={margin:"4px 0 0",fontSize:11,color:"#b45309"},Yw={padding:"5px 10px",fontSize:12,border:"1px dashed #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer",whiteSpace:"nowrap"};function Xw({templateIdentifier:e,layout:t,url:n,locale:o,seedContext:r,routeParams:s,settingsSignature:a,t:l,debounceMs:d=400,fetchImpl:c,testidPrefix:p="g7le-seo-bot-preview"}){const[f,b]=u.useState(!0),[g,m]=u.useState(null),[h,v]=u.useState(!1),[y,_]=u.useState(null),w=u.useRef(null),k=u.useRef({templateIdentifier:e,layout:t,url:n,locale:o,seedContext:r,routeParams:s});k.current={templateIdentifier:e,layout:t,url:n,locale:o,seedContext:r,routeParams:s};const x=u.useCallback(async()=>{const T=c??(typeof fetch<"u"?fetch:void 0);if(!T)return;const{templateIdentifier:E,layout:A,url:N,locale:D,seedContext:B,routeParams:M}=k.current;v(!0),_(null);try{const O=`/api/admin/templates/${encodeURIComponent(E)}/editor/seo-bot-preview`,z=await T(O,{method:"POST",credentials:"same-origin",headers:Ne({"Content-Type":"application/json"}),body:JSON.stringify({layout:A,url:N,locale:D,seed_context:B??{},route_params:M??{}})}),H=await z.json().catch(()=>null);if(!z.ok){_(H?.message??`HTTP ${z.status}`);return}const P=H?.data??null;m(P)}catch(O){_(O instanceof Error?O.message:String(O))}finally{v(!1)}},[c]);u.useEffect(()=>{if(f)return w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{x()},d),()=>{w.current&&clearTimeout(w.current)}},[a,f,d,x]);const $=u.useCallback(()=>{w.current&&clearTimeout(w.current),x()},[x]),S=g?.html??null,C=g?.enabled??!0;return i.jsxs("div",{"data-testid":p,style:Jw,children:[i.jsxs("div",{style:Zw,children:[i.jsxs("button",{type:"button","data-testid":`${p}-toggle`,onClick:()=>b(T=>!T),"aria-expanded":f,style:Qw,children:[f?"▾":"▸"," ",l("layout_editor.page_settings.seo.bot_preview_title")]}),f?i.jsxs("button",{type:"button","data-testid":`${p}-refresh`,onClick:$,disabled:h,style:Rw,children:["⟳ ",l("layout_editor.page_settings.seo.bot_preview_refresh")]}):null]}),f&&i.jsxs("div",{style:{marginTop:8},children:[g&&!C?i.jsxs("p",{"data-testid":`${p}-disabled`,style:e0,children:["ⓘ ",l("layout_editor.page_settings.seo.bot_preview_disabled")]}):i.jsx("div",{"data-testid":`${p}-body`,style:t0,children:h&&!S?i.jsx("p",{style:As,children:l("layout_editor.translation.loading")}):y?i.jsx("p",{"data-testid":`${p}-error`,style:{...As,color:"#dc2626"},children:y}):S==null?i.jsx("p",{style:As,children:l("layout_editor.page_settings.seo.bot_preview_empty")}):i.jsx("pre",{"data-testid":`${p}-code`,style:n0,children:S})}),i.jsxs("p",{"data-testid":`${p}-sample-note`,style:o0,children:["ⓘ ",l("layout_editor.page_settings.seo.bot_preview_sample_note")]})]})]})}const Jw={borderTop:"1px solid #e2e8f0",paddingTop:10,marginTop:12},Zw={display:"flex",alignItems:"center",gap:8},Qw={background:"none",border:"none",cursor:"pointer",fontSize:13,fontWeight:600,color:"#0f172a",padding:0},Rw={marginLeft:"auto",padding:"4px 10px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},e0={margin:0,fontSize:12,color:"#64748b",background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:6,padding:"8px 10px"},t0={border:"1px solid #e2e8f0",borderRadius:8,background:"#0b1020",padding:0,minHeight:80,overflow:"hidden"},n0={margin:0,padding:12,fontSize:11,lineHeight:1.5,color:"#d1fae5",fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:360,overflow:"auto"},As={margin:0,padding:12,fontSize:12,color:"#94a3b8"},o0={margin:"8px 0 0",fontSize:11,color:"#94a3b8"};function Lc({option:e,testIdPrefix:t}){const{id:n,friendly:o,source:r}=e;return i.jsxs("span",{style:r0,children:[i.jsx("span",{"data-testid":t?`${t}-title`:void 0,style:i0,children:o??n}),o?i.jsx("span",{"data-testid":t?`${t}-id`:void 0,style:s0,children:n}):null,r?i.jsx("span",{"data-testid":t?`${t}-source`:void 0,style:a0,children:r}):null]})}const r0={display:"inline-flex",alignItems:"baseline",gap:4,flexWrap:"wrap",minWidth:0},i0={fontSize:12,color:"#0f172a"},s0={fontSize:10,color:"#94a3b8",fontFamily:"ui-monospace, monospace"},a0={fontSize:9,fontWeight:600,color:"#7c3aed",background:"#f5f3ff",border:"1px solid #ddd6fe",borderRadius:4,padding:"0 5px",whiteSpace:"nowrap"},l0=["always","hourly","daily","weekly","monthly","yearly","never"];function d0({getValue:e,patch:t,t:n,templateIdentifier:o,candidates:r,availableExtensions:s=[],dataSourceOptions:a=[],previewUrl:l="/",previewLocale:d="ko",seedContext:c,candidatesFetcher:p,ogPreviewFetcher:f,botFetchImpl:b,testidPrefix:g="g7le-seo"}){const m=e("meta",{}).seo,h=m&&typeof m=="object"?m:{},v=u.useCallback((V,te)=>{const be={...e("meta",{})},Ee={...be.seo??{}};te==null||te===""?delete Ee[V]:Ee[V]=te,be.seo=Ee,t("meta",be)},[e,t]),y=h.enabled===!0,_=typeof h.page_type=="string"?h.page_type:"",w=Array.isArray(h.extensions)?h.extensions:[],k=Array.isArray(h.data_sources)?h.data_sources:[],x=w.length>0&&_!=="",[$,S]=u.useState(null),[C,T]=u.useState(null),E=u.useCallback(async(V,te)=>{if(p)return p(V,te);if(typeof fetch>"u")return null;const be=new URLSearchParams;V&&be.set("page_type",V),Array.isArray(te)&&te.length>0&&be.set("extensions",JSON.stringify(te.map(Ue=>({type:Ue.type,id:Ue.id}))));const Ee=be.toString()?`?${be.toString()}`:"",De=await fetch(en(`/api/admin/templates/${encodeURIComponent(o)}/editor/seo-candidates`,"json",null,Ee.replace(/^[?&]+/,"")),{credentials:"same-origin",headers:Ne()}),Se=await De.json().catch(()=>null);return De.ok?Se?.data??null:null},[p,o]),A=u.useMemo(()=>{const be=(e("__editor",{})??{}).original?.meta?.seo;return be&&typeof be=="object"?be:void 0},[e]),N=u.useRef(A);N.current=A;const D=u.useCallback(async V=>{if(f)return f(V);if(typeof fetch>"u")return null;const te=await fetch(`/api/admin/templates/${encodeURIComponent(o)}/editor/seo-og-preview`,{method:"POST",credentials:"same-origin",headers:Ne({"Content-Type":"application/json"}),body:JSON.stringify({seo:V,own_seo:N.current??null,seed_context:c??{},route_params:{}})}),be=await te.json().catch(()=>null);return te.ok?be?.data??null:null},[f,o,c]),B=u.useMemo(()=>JSON.stringify(w),[w]),M=u.useRef(h);M.current=h,u.useEffect(()=>{let V=!1;return(async()=>{const te=await E(_,w);V||S(te)})(),()=>{V=!0}},[_,B]);const O=u.useMemo(()=>JSON.stringify({og:h.og??null,twitter:h.twitter??null,structured_data:h.structured_data??null}),[h.og,h.twitter,h.structured_data]),z=u.useRef(!1);u.useEffect(()=>{let V=!1;const te=()=>{(async()=>{const Ee=await D(M.current);V||T(Ee)})()};if(!z.current)return z.current=!0,te(),()=>{V=!0};const be=setTimeout(te,180);return()=>{V=!0,clearTimeout(be)}},[_,B,O]);const H=$?.page_types??[],P=$?.toggle_settings??[],I=$?.vars??[],L=u.useMemo(()=>JSON.stringify(h),[h]),F=u.useMemo(()=>e("meta")?{meta:e("meta"),components:e("components",[])}:{meta:{},components:[]},[e]),Y=u.useCallback(V=>{w.some(te=>te.type===V.type&&te.id===V.id)||v("extensions",[...w,{type:V.type,id:V.id}])},[w,v]),K=u.useCallback(V=>{const te=w.filter(be=>!(be.type===V.type&&be.id===V.id));v("extensions",te.length>0?te:void 0)},[w,v]),[X,Z]=u.useState(!1),[ae,oe]=u.useState(""),G=u.useMemo(()=>{const V=ae.trim().toLowerCase();return V?P.filter(te=>`${te.ref} ${te.label??""}`.toLowerCase().includes(V)):P},[P,ae]),ee=typeof h.toggle_setting=="string"?h.toggle_setting:"",ge=u.useCallback(V=>{const be=k.includes(V)?k.filter(Ee=>Ee!==V):[...k,V];v("data_sources",be.length>0?be:void 0)},[k,v]);return i.jsxs("div",{"data-testid":g,style:{display:"flex",flexDirection:"column",gap:14},children:[i.jsxs("div",{style:Bt,children:[i.jsx(Mr,{checked:y,onChange:V=>v("enabled",V),testid:`${g}-enabled`,label:n("layout_editor.page_settings.seo.enabled")}),y?null:i.jsxs("p",{"data-testid":`${g}-disabled-note`,style:no,children:["ⓘ ",n("layout_editor.page_settings.seo.disabled_note")]})]}),i.jsx(Lr,{disabled:!y,testid:`${g}-body`,style:{display:"flex",flexDirection:"column",gap:14},children:i.jsxs(i.Fragment,{children:[i.jsxs("div",{style:Bt,children:[i.jsx("label",{style:qt,children:n("layout_editor.page_settings.seo.page_type")}),H.length>0?i.jsxs("select",{"data-testid":`${g}-page-type`,value:_,onChange:V=>v("page_type",V.target.value),style:Br,children:[i.jsx("option",{value:"",children:n("layout_editor.page_settings.seo.page_type_none")}),H.map(V=>i.jsxs("option",{value:V.value,children:[V.label??V.value,V.owner?.name?` (${V.owner.name})`:""]},V.value))]}):i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"text","data-testid":`${g}-page-type-free`,value:_,placeholder:n("layout_editor.page_settings.seo.page_type_free_placeholder"),onChange:V=>v("page_type",V.target.value),style:Br}),i.jsxs("p",{"data-testid":`${g}-page-type-free-note`,style:no,children:["ⓘ ",n("layout_editor.page_settings.seo.page_type_free_note")]})]})]}),i.jsxs("div",{style:Bt,children:[i.jsxs("label",{style:qt,children:["★ ",n("layout_editor.page_settings.seo.extensions")]}),i.jsxs("div",{"data-testid":`${g}-extensions`,style:{display:"flex",flexWrap:"wrap",gap:6},children:[w.map(V=>i.jsxs("span",{"data-testid":`${g}-extension-${V.type}-${V.id}`,style:Pc,children:[V.name??`${V.type}:${V.id}`,i.jsx("button",{type:"button","data-testid":`${g}-extension-remove-${V.type}-${V.id}`,onClick:()=>K(V),style:Oc,children:"✕"})]},`${V.type}:${V.id}`)),i.jsxs("button",{type:"button","data-testid":`${g}-extension-add`,onClick:()=>Z(V=>!V),style:p0,children:["+ ",n("layout_editor.page_settings.seo.add_extension")]})]}),X&&i.jsx("div",{"data-testid":`${g}-extension-picker`,style:Bc,children:s.length===0?i.jsx("p",{style:no,children:n("layout_editor.page_settings.seo.no_extension_candidate")}):s.map(V=>i.jsx("button",{type:"button","data-testid":`${g}-extension-option-${V.type}-${V.id}`,onClick:()=>{Y(V),Z(!1)},style:Wc,children:V.name??`${V.type}:${V.id}`},`${V.type}:${V.id}`))})]}),!x&&i.jsxs("div",{"data-testid":`${g}-defaults-precondition`,style:u0,children:["⚠ ",n("layout_editor.page_settings.seo.defaults_precondition"),i.jsxs("div",{"data-testid":`${g}-defaults-missing`,style:{fontSize:11,marginTop:4},children:[w.length===0?n("layout_editor.page_settings.seo.missing_extensions"):"",_===""?` ${n("layout_editor.page_settings.seo.missing_page_type")}`:""]})]}),i.jsxs("div",{style:Bt,children:[i.jsx("label",{style:qt,children:n("layout_editor.page_settings.seo.toggle_setting")}),i.jsxs("div",{"data-testid":`${g}-toggle-setting`,children:[ee?i.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center",marginBottom:4},children:[i.jsx("code",{style:Pc,children:ee}),i.jsx("button",{type:"button","data-testid":`${g}-toggle-setting-clear`,onClick:()=>v("toggle_setting",void 0),style:Oc,children:"✕"})]}):null,i.jsx("input",{type:"text","data-testid":`${g}-toggle-setting-search`,value:ae,placeholder:n("layout_editor.page_settings.seo.toggle_setting_search"),onChange:V=>oe(V.target.value),style:Br}),ae.trim()!==""&&i.jsx("div",{"data-testid":`${g}-toggle-setting-results`,style:Bc,children:G.length===0?i.jsx("p",{style:no,children:n("layout_editor.inline_binding.no_results")}):G.map(V=>i.jsx("button",{type:"button","data-testid":`${g}-toggle-setting-option-${V.ref}`,onClick:()=>{v("toggle_setting",V.ref),oe("")},style:Wc,children:V.label??V.ref},V.ref))})]})]}),i.jsxs("div",{style:Bt,children:[i.jsx("label",{style:qt,children:n("layout_editor.page_settings.seo.data_sources")}),i.jsx("p",{style:no,children:n("layout_editor.page_settings.seo.data_sources_hint")}),i.jsx("div",{"data-testid":`${g}-data-sources`,style:{display:"flex",flexDirection:"column",gap:6},children:a.length===0?i.jsx("span",{style:no,children:n("layout_editor.page_settings.seo.data_sources_empty")}):a.map(V=>{const te=k.includes(V.id);return i.jsxs("label",{"data-testid":`${g}-data-source-${V.id}`,style:c0(te),children:[i.jsx("input",{type:"checkbox","data-testid":`${g}-data-source-check-${V.id}`,checked:te,onChange:()=>ge(V.id)}),i.jsx(Lc,{option:V,testIdPrefix:`${g}-data-source-${V.id}`})]},V.id)})})]}),i.jsxs("div",{style:Bt,children:[i.jsx("label",{style:qt,children:n("layout_editor.page_settings.seo.priority")}),i.jsx("input",{type:"range","data-testid":`${g}-priority`,min:0,max:1,step:.1,value:typeof h.priority=="number"?h.priority:.5,onChange:V=>v("priority",Number(V.target.value))}),i.jsx("span",{"data-testid":`${g}-priority-value`,style:{fontSize:12,color:"#475569"},children:typeof h.priority=="number"?h.priority:.5})]}),i.jsxs("div",{style:Bt,children:[i.jsx("label",{style:qt,children:n("layout_editor.page_settings.seo.changefreq")}),i.jsxs("select",{"data-testid":`${g}-changefreq`,value:typeof h.changefreq=="string"?h.changefreq:"",onChange:V=>v("changefreq",V.target.value),style:Br,children:[i.jsx("option",{value:"",children:n("layout_editor.page_settings.seo.use_default")}),l0.map(V=>i.jsx("option",{value:V,children:V},V))]})]}),i.jsxs("div",{style:Bt,children:[i.jsx("label",{style:qt,children:n("layout_editor.page_settings.seo.title")}),i.jsx(_t,{value:typeof h.title=="string"?h.title:"",onChange:V=>v("title",V??""),t:n,candidates:r,testidPrefix:`${g}-title`,enableExpressionTree:!0,expressionTreeCollapsible:!0})]}),i.jsxs("div",{style:Bt,children:[i.jsx("label",{style:qt,children:n("layout_editor.page_settings.seo.description")}),i.jsx(_t,{value:typeof h.description=="string"?h.description:"",onChange:V=>v("description",V??""),t:n,candidates:r,testidPrefix:`${g}-description`,enableExpressionTree:!0,expressionTreeCollapsible:!0})]}),i.jsx(hw,{og:h.og,twitter:h.twitter,onChangeOg:V=>v("og",Object.keys(V).length>0?V:void 0),onChangeTwitter:V=>v("twitter",Object.keys(V).length>0?V:void 0),ogPreview:C?.og,twitterPreview:C?.twitter,defaultsAvailable:C?.defaultsAvailable??!1,candidates:r,t:n}),i.jsxs("div",{style:Bt,children:[i.jsx("label",{style:qt,children:n("layout_editor.page_settings.seo.structured_data")}),i.jsx(Aw,{value:h.structured_data,onChange:V=>v("structured_data",V??void 0),autoBlock:C?.structured?.autoBlock,autoMeta:C?.structured?.autoMeta,lockedByFilter:C?.structured?.lockedByFilter,filteredBlock:C?.structured?.filteredBlock,pageType:_,candidates:r,t:n})]}),i.jsxs("div",{style:Bt,children:[i.jsx("label",{style:qt,children:n("layout_editor.page_settings.seo.vars")}),i.jsx(Hw,{vars:h.vars,onChange:V=>v("vars",Object.keys(V).length>0?V:void 0),varCandidates:I,gatingMet:x,candidates:r,t:n})]}),i.jsx(Xw,{templateIdentifier:o,layout:F,url:l,locale:d,seedContext:c,settingsSignature:L,t:n,fetchImpl:b})]})})]})}const Bt={display:"flex",flexDirection:"column",gap:4},qt={fontSize:12,fontWeight:600,color:"#334155"},Br={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,width:"100%",minWidth:0,boxSizing:"border-box"},no={margin:"4px 0 0",fontSize:11,color:"#94a3b8"},c0=e=>({display:"flex",alignItems:"center",gap:8,padding:"6px 10px",fontSize:12,border:`1px solid ${e?"#3b82f6":"#e2e8f0"}`,borderRadius:8,background:e?"#eff6ff":"#fff",cursor:"pointer",minWidth:0}),u0={fontSize:12,color:"#b45309",background:"#fffbeb",border:"1px solid #fcd34d",borderRadius:6,padding:"8px 10px"},Pc={display:"inline-flex",alignItems:"center",gap:4,fontSize:11,padding:"3px 8px",borderRadius:999,background:"#eef2ff",color:"#3730a3"},Oc={border:"none",background:"transparent",cursor:"pointer",color:"#6366f1",fontSize:11,padding:0},p0={fontSize:11,padding:"3px 10px",borderRadius:999,border:"1px dashed #cbd5e1",background:"#f8fafc",color:"#475569",cursor:"pointer"},Bc={marginTop:4,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",padding:6,display:"flex",flexDirection:"column",gap:2},Wc={textAlign:"left",border:"none",background:"transparent",cursor:"pointer",padding:"5px 8px",borderRadius:4,fontSize:12,color:"#0f172a"},f0={setState:"state",loadFromLocalStorage:"state",saveToLocalStorage:"state",navigate:"nav",openWindow:"nav",navigateBack:"nav",navigateForward:"nav",replaceUrl:"nav",toast:"notify",openModal:"notify",closeModal:"notify",showAlert:"notify",setError:"notify",refetchDataSource:"data",appendDataSource:"data",updateDataSource:"data",apiCall:"data",scrollIntoView:"etc",login:"etc",loginTwoFactor:"etc",loginTwoFactorResend:"etc",logout:"etc",setLocale:"locale",emitEvent:"etc",conditions:"flow",sequence:"flow",parallel:"flow",switch:"flow",suppress:"flow",showErrorPage:"error"},g0={state:"layout_editor.action.group.state",nav:"layout_editor.action.group.nav",notify:"layout_editor.action.group.notify",data:"layout_editor.action.group.data",locale:"layout_editor.action.group.locale",etc:"layout_editor.action.group.etc",flow:"layout_editor.action.group.flow",error:"layout_editor.action.group.error",extension:"layout_editor.action.group.extension"},h0={init:["state","data","notify","nav","locale","etc","flow","error","extension"],component:["nav","notify","data","state","locale","etc","flow","error","extension"]};function y0(e,t){const n=e?.[t];if(n&&typeof n=="object"){const o=n.__source;if(o&&typeof o=="object")return o}return null}function b0(e,t){return!e||e.kind==="core"?t("layout_editor.action.source_core"):e.id??t(`layout_editor.action.source_${e.kind}`)}function jc(e,t,n){return typeof e!="string"?n:e.startsWith("$t:")?t(e.slice(3)):e}function m0({recipes:e,t,onAdd:n,context:o="init",testIdPrefix:r="g7le-action-add"}){const[s,a]=u.useState(!1),[l,d]=u.useState(""),c=u.useMemo(()=>ko(e),[e]),p=u.useMemo(()=>{const f=h0[o],b=new Map;for(const m of c){const h=y0(e,m.id),y=h!=null&&h.kind!=="core"?"extension":f0[m.id]??"etc",_=b.get(y)??[];_.push({recipe:m,source:h}),b.set(y,_)}const g=l.trim().toLowerCase();return f.map(m=>{let h=b.get(m)??[];return g&&(h=h.filter(({recipe:v})=>jc(v.label,t,v.id).toLowerCase().includes(g)||v.id.toLowerCase().includes(g)||v.build.handler.toLowerCase().includes(g))),{groupKey:m,items:h}}).filter(m=>m.items.length>0)},[c,e,o,l,t]);return c.length===0?i.jsx("div",{"data-testid":`${r}-empty`,style:I0,children:t("layout_editor.action.no_recipes")}):i.jsxs("div",{className:r,"data-testid":r,style:{minWidth:0},children:[i.jsxs("button",{type:"button","data-testid":`${r}-toggle`,onClick:()=>a(f=>!f),style:v0,children:[t("layout_editor.action.add_action")," ▾"]}),s?i.jsxs("div",{"data-testid":`${r}-list`,style:_0,children:[i.jsx("input",{type:"text","data-testid":`${r}-search`,value:l,placeholder:t("layout_editor.action.add_search"),onChange:f=>d(f.target.value),style:x0}),p.map(({groupKey:f,items:b})=>i.jsxs("div",{"data-testid":`${r}-group-${f}`,children:[i.jsxs("div",{style:w0,children:["━━ ",t(g0[f]??f)," ━━"]}),b.map(({recipe:g,source:m})=>i.jsxs("button",{type:"button","data-testid":`g7le-init-action-spec-${g.id}`,onClick:()=>{n(Sr(g,{})),a(!1),d("")},style:k0,children:[i.jsx("span",{style:S0,children:jc(g.label,t,g.id)}),i.jsxs("span",{"data-testid":`g7le-init-action-spec-source-${g.id}`,style:C0,children:["〔",b0(m,t),"〕"]}),i.jsx("code",{style:$0,children:g.build.handler})]},g.id))]},f)),p.length===0?i.jsx("div",{"data-testid":`${r}-no-match`,style:E0,children:t("layout_editor.action.add_no_match")}):null]}):null]})}const v0={padding:"6px 12px",fontSize:12,border:"1px dashed #94a3b8",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},_0={marginTop:6,border:"1px solid #cbd5e1",borderRadius:8,background:"#fff",maxHeight:320,overflowY:"auto",padding:8},x0={width:"100%",padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,marginBottom:6,boxSizing:"border-box"},w0={fontSize:11,fontWeight:700,color:"#94a3b8",padding:"6px 4px 2px"},k0={display:"flex",alignItems:"center",gap:6,width:"100%",textAlign:"left",padding:"6px 8px",fontSize:12,border:"none",background:"transparent",cursor:"pointer",borderRadius:6},S0={flex:1,minWidth:0,color:"#0f172a"},C0={fontSize:10,color:"#64748b",whiteSpace:"nowrap"},$0={fontSize:10,color:"#cbd5e1",fontFamily:"monospace",whiteSpace:"nowrap"},E0={fontSize:12,color:"#94a3b8",padding:"8px 4px"},I0={fontSize:12,color:"#94a3b8",padding:"8px 0"};function A0(e,t){return t.startsWith("$t:")?e(t.slice(3)):t}function T0({action:e,recipe:t,values:n={},t:o,missingRequired:r=!1,showCodeButton:s=!0,testIdPrefix:a="g7le-action-preview"}){const[l,d]=u.useState(!1),c=t?Kd(t,n,p=>A0(o,p)):typeof e.handler=="string"?e.handler:o("layout_editor.action.advanced_action");return i.jsxs("div",{className:a,"data-testid":a,style:D0,children:[r?i.jsxs("span",{"data-testid":`${a}-missing`,style:N0,children:["⚠ ",o("layout_editor.action.summary_missing_required")]}):i.jsx("span",{"data-testid":`${a}-summary`,style:z0,children:c}),s?i.jsx("button",{type:"button","data-testid":`${a}-code-toggle`,onClick:()=>d(p=>!p),style:M0,"aria-expanded":l,"aria-label":o("layout_editor.action.view_code"),children:""}):null,s&&l?i.jsx("pre",{"data-testid":`${a}-code`,style:L0,children:JSON.stringify(e,null,2)}):null]})}const D0={display:"flex",flexWrap:"wrap",alignItems:"center",gap:6,minWidth:0},z0={flex:1,minWidth:0,fontSize:12,color:"#475569"},N0={flex:1,minWidth:0,fontSize:12,color:"#b45309"},M0={border:"1px solid #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer",fontSize:11,padding:"2px 6px",whiteSpace:"nowrap"},L0={flexBasis:"100%",margin:"6px 0 0",padding:8,background:"#0f172a",color:"#e2e8f0",borderRadius:6,fontSize:11,overflow:"auto"},Hc="__g7le_custom__";function Wr({value:e,onChange:t,candidates:n,placeholder:o,testid:r,t:s,bindingCandidates:a}){const l=e==null?"":String(e),d=Array.isArray(n)&&n.length>0,c=d&&n.some(b=>b.value===l),[p,f]=u.useState(!d||l!==""&&!c);return u.useEffect(()=>{l!==""&&d&&!c&&f(!0)},[l,d,c]),d&&!p?i.jsxs("div",{style:Uc,children:[i.jsxs("select",{className:"g7le-widget g7le-widget--picker","data-testid":r,value:c?l:"",onChange:b=>{const g=b.target.value;if(g===Hc){f(!0);return}t(g===""?void 0:g)},style:{...Kc,flex:1,minWidth:0},children:[i.jsx("option",{value:"",children:s("layout_editor.control.default")}),n.map(b=>i.jsx("option",{value:b.value,children:b.label},b.value)),i.jsx("option",{value:Hc,children:s("layout_editor.recipe.custom_input")})]}),i.jsx("button",{type:"button","data-testid":`${r}-to-custom`,title:s("layout_editor.recipe.custom_input"),"aria-label":s("layout_editor.recipe.custom_input"),onClick:()=>f(!0),style:qc,children:"✎"})]}):i.jsxs("div",{style:Uc,children:[i.jsx("div",{style:{flex:1,minWidth:0},children:i.jsx(Ke,{value:l,onChange:b=>t(b===""?void 0:b),t:s,candidates:a,placeholder:o,testidPrefix:`${r}-input`})}),d&&i.jsx("button",{type:"button","data-testid":`${r}-pick`,title:s("layout_editor.recipe.pick_from_list"),onClick:()=>{f(!1),t(void 0)},style:qc,children:"≡"})]})}function P0({value:e,onChange:t,candidates:n,t:o,bindingCandidates:r}){return i.jsx(Wr,{value:e,onChange:t,candidates:n,placeholder:o("layout_editor.recipe.page_placeholder"),testid:"g7le-widget-page-picker",t:o,bindingCandidates:r})}function Fc({value:e,onChange:t,candidates:n,t:o,bindingCandidates:r}){return i.jsx(Wr,{value:e,onChange:t,candidates:n,placeholder:o("layout_editor.recipe.datasource_placeholder"),testid:"g7le-widget-datasource-picker",t:o,bindingCandidates:r})}function Ts({value:e,onChange:t,candidates:n,t:o,bindingCandidates:r}){return i.jsx(Wr,{value:e,onChange:t,candidates:n,placeholder:o("layout_editor.recipe.state_key_placeholder"),testid:"g7le-widget-state-key-picker",t:o,bindingCandidates:r})}function O0({value:e,onChange:t,candidates:n,t:o,bindingCandidates:r}){return i.jsx(Wr,{value:e,onChange:t,candidates:n,placeholder:o("layout_editor.recipe.modal_placeholder"),testid:"g7le-widget-modal-picker",t:o,bindingCandidates:r})}function B0({value:e,onChange:t,t:n,bindingCandidates:o}){const r=typeof e=="string"?e:e==null?"":String(e);return i.jsx("div",{className:"g7le-widget g7le-widget--i18n-text","data-testid":"g7le-widget-i18n-text",style:{flex:1,minWidth:100,width:"100%"},children:i.jsx(_t,{value:r,onChange:s=>t(s===""?void 0:s),t:n,placeholder:n("layout_editor.recipe.i18n_text_placeholder"),testidPrefix:"g7le-widget-i18n-text-field",candidates:o,enableExpressionTree:!0,expressionTreeCollapsible:!0})})}function W0({value:e,onChange:t,candidates:n,t:o}){const r=e==null?"":String(e),s=r.split(",").map(d=>d.trim()).filter(Boolean),a=Array.isArray(n)&&n.length>0,l=d=>{if(!d)return;const c=[...s,d];t(c.join(", "))};return i.jsxs("div",{className:"g7le-widget g7le-widget--binding-list","data-testid":"g7le-widget-binding-list",style:{display:"flex",flexDirection:"column",gap:4,width:"100%"},children:[i.jsx("input",{type:"text","data-testid":"g7le-widget-binding-list-input",value:r,placeholder:o("layout_editor.recipe.datasource_placeholder"),onChange:d=>t(d.target.value===""?void 0:d.target.value),style:Vc}),a?i.jsxs("select",{className:"g7le-widget g7le-widget--picker","data-testid":"g7le-widget-binding-list-add",value:"",onChange:d=>{l(d.target.value),d.target.value=""},style:{...Kc,minWidth:0},children:[i.jsx("option",{value:"",children:o("layout_editor.recipe.pick_from_list")}),n.map(d=>i.jsx("option",{value:d.value,children:d.label},d.value))]}):null]})}function j0({value:e,onChange:t}){const n=e==null?"":String(e);return i.jsx("input",{type:"text",className:"g7le-widget g7le-widget--text","data-testid":"g7le-widget-text",value:n,onChange:o=>t(o.target.value===""?void 0:o.target.value),style:Vc})}const Kc={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",minWidth:140,width:"100%"},Vc={flex:1,padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,minWidth:100,width:"100%"},Uc={display:"flex",gap:4,alignItems:"flex-start",width:"100%"},qc={padding:"4px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#64748b",cursor:"pointer"};function H0(e){if(e==null)return"null";if(Array.isArray(e))return"list";switch(typeof e){case"number":return"number";case"boolean":return"boolean";case"string":return"string";default:return"object"}}function Gc(e){switch(e){case"string":return"";case"number":return 0;case"boolean":return!1;case"null":return null;case"list":return[];case"object":return{};default:return null}}function Ds(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)}function F0(e,t,n){return t.includes(n)?"self":e.includes(n)?"inherited":"self"}function K0(e){const t=e.state&&typeof e.state=="object"&&Object.keys(e.state).length>0,n=e.initLocal&&typeof e.initLocal=="object"?e.initLocal:void 0;if(!t)return{initLocal:n??{},migrated:!1};const o={...e.state};if(n)for(const[r,s]of Object.entries(n))o[r]=s;return{initLocal:o,migrated:!0}}const Yc=[{kind:"string",labelKey:"layout_editor.initstate.kind_string"},{kind:"number",labelKey:"layout_editor.initstate.kind_number"},{kind:"boolean",labelKey:"layout_editor.initstate.kind_boolean"},{kind:"null",labelKey:"layout_editor.initstate.kind_null"},{kind:"list",labelKey:"layout_editor.initstate.kind_list"},{kind:"object",labelKey:"layout_editor.initstate.kind_object"}];function zn({value:e,onChange:t,t:n,path:o,scope:r,depth:s=0,renderStringLeaf:a}){const l=H0(e),d=c=>{t(Gc(c))};return i.jsxs("div",{className:"g7le-initstate-value",style:{paddingLeft:s>0?12:0,minWidth:0},children:[i.jsxs("div",{style:U0,children:[i.jsx("select",{"data-testid":`g7le-initstate-type-${o}`,value:l,onChange:c=>d(c.target.value),style:Xc,children:Yc.map(({kind:c,labelKey:p})=>i.jsx("option",{value:c,children:n(p)},c))}),l==="string"?a?i.jsx("div",{style:{flex:1,minWidth:0},children:a({value:String(e??""),onChange:c=>t(c),testidPrefix:`g7le-initstate-value-${o}`})}):i.jsx("input",{type:"text","data-testid":`g7le-initstate-value-${o}`,value:String(e??""),onChange:c=>t(c.target.value),style:Jc}):l==="number"?i.jsx("input",{type:"number","data-testid":`g7le-initstate-value-${o}`,value:typeof e=="number"?e:"",onChange:c=>{const p=parseFloat(c.target.value);t(Number.isNaN(p)?0:p)},style:Jc}):l==="boolean"?i.jsx(Mr,{checked:!!e,onChange:t,testid:`g7le-initstate-value-${o}`,label:n(e?"layout_editor.overlay.on":"layout_editor.overlay.off")}):l==="null"?i.jsx("span",{"data-testid":`g7le-initstate-value-${o}`,style:q0,children:"null"}):null]}),l==="list"?i.jsxs("div",{style:Zc,children:[e.map((c,p)=>i.jsxs("div",{style:G0,children:[i.jsxs("span",{style:Y0,children:["[",p,"]"]}),i.jsx("div",{style:{flex:1,minWidth:0},children:i.jsx(zn,{value:c,onChange:f=>{const b=e.slice();b[p]=f,t(b)},t:n,path:`${o}.${p}`,scope:r,depth:s+1,renderStringLeaf:a})}),i.jsx("button",{type:"button","data-testid":`g7le-initstate-item-remove-${o}.${p}`,onClick:()=>t(e.filter((f,b)=>b!==p)),style:Qc,children:"✕"})]},p)),i.jsxs("button",{type:"button","data-testid":`g7le-initstate-item-add-${o}`,onClick:()=>t([...e,""]),style:Rc,children:["+ ",n("layout_editor.initstate.add_item")]})]}):null,l==="object"?i.jsx(V0,{value:e,onChange:t,t:n,path:o,scope:r,depth:s+1,renderStringLeaf:a}):null]})}function V0({value:e,onChange:t,t:n,path:o,scope:r,depth:s,renderStringLeaf:a}){const[l,d]=u.useState(""),[c,p]=u.useState("string"),[f,b]=u.useState(null),g=Object.entries(e),m=()=>{const h=l.trim();if(!h){b(n("layout_editor.initstate.name_required"));return}if(!Ds(h)){b(n("layout_editor.initstate.name_invalid"));return}if(h in e){b(n("layout_editor.initstate.name_duplicate"));return}t({...e,[h]:Gc(c)}),d(""),b(null)};return i.jsxs("div",{style:Zc,children:[g.map(([h,v])=>i.jsxs("div",{style:X0,children:[i.jsx("code",{style:J0,children:h}),i.jsx("div",{style:{flex:1,minWidth:0},children:i.jsx(zn,{value:v,onChange:y=>t({...e,[h]:y}),t:n,path:`${o}.${h}`,scope:r,depth:s,renderStringLeaf:a})}),i.jsx("button",{type:"button","data-testid":`g7le-initstate-subremove-${o}.${h}`,onClick:()=>{const y={...e};delete y[h],t(y)},style:Qc,children:"✕"})]},h)),i.jsxs("div",{style:Z0,children:[i.jsx("input",{type:"text","data-testid":`g7le-initstate-subkey-input-${o}`,value:l,placeholder:n("layout_editor.initstate.subkey_name"),onChange:h=>{d(h.target.value),f&&b(null)},onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),m())},"aria-invalid":f?!0:void 0,style:{...Q0,...f?R0:null}}),i.jsx("select",{"data-testid":`g7le-initstate-subkey-kind-${o}`,value:c,onChange:h=>p(h.target.value),"aria-label":n("layout_editor.initstate.value_kind"),style:Xc,children:Yc.map(({kind:h,labelKey:v})=>i.jsx("option",{value:h,children:n(v)},h))}),i.jsxs("button",{type:"button","data-testid":`g7le-initstate-subkey-add-${o}`,onClick:m,style:Rc,children:["+ ",n("layout_editor.initstate.add_subkey")]})]}),f?i.jsx("p",{"data-testid":`g7le-initstate-subkey-error-${o}`,style:ek,children:f}):null]})}const U0={display:"flex",gap:6,alignItems:"center",minWidth:0},Xc={padding:"4px 6px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,color:"#64748b"},Jc={flex:1,minWidth:0,padding:"4px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,boxSizing:"border-box"},q0={fontSize:12,color:"#94a3b8",fontFamily:"monospace"},Zc={display:"flex",flexDirection:"column",gap:6,marginTop:6,paddingLeft:8,borderLeft:"2px solid #e2e8f0"},G0={display:"flex",gap:6,alignItems:"flex-start",minWidth:0},Y0={fontSize:11,color:"#94a3b8",minWidth:28,paddingTop:4},X0={display:"flex",gap:6,alignItems:"flex-start",minWidth:0},J0={fontSize:11,color:"#475569",fontFamily:"monospace",minWidth:72,paddingTop:4},Qc={border:"none",background:"transparent",color:"#94a3b8",cursor:"pointer",fontSize:12},Rc={alignSelf:"flex-start",padding:"2px 8px",fontSize:11,border:"1px dashed #94a3b8",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},Z0={display:"flex",gap:6,alignItems:"center"},Q0={padding:"4px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6},R0={border:"1px solid #dc2626"},ek={margin:"2px 0 0",fontSize:11,color:"#dc2626"},tk=new Set(["text","data-chip","number"]),nk=new Set(["select","toggle","page-picker","datasource-picker","state-key-picker","modal-picker","component-target-picker","tag-input","locale-picker","i18n-text","segmented","slider","color","image"]);function ok(e,t,n){return typeof e!="string"?n:e.startsWith("$t:")?t(e.slice(3)):e}function rk(e,t){if(e==="page-picker")return t.pageCandidates;if(e==="datasource-picker")return t.dataSourceCandidates;if(e==="state-key-picker")return t.stateKeyCandidates;if(e==="modal-picker")return t.modalCandidates}function ik({param:e,value:t,t:n,pools:o,onChange:r,testIdPrefix:s,renderActionList:a,siblingValues:l}){const d=ok(e.label,n,e.key);if(e.advanced)return i.jsxs("div",{"data-testid":`${s}-locked-${e.key}`,style:hk,children:[i.jsx("span",{style:yk,children:d}),i.jsxs("span",{style:bk,children:["[",n("layout_editor.action.advanced"),"] ",n("layout_editor.init_actions.advanced_param_hint")]})]});if(e.widget==="action-list"&&a){const f=Array.isArray(t)?t.filter(b=>!!b&&typeof b=="object"):[];return i.jsxs("div",{"data-testid":`${s}-param-${e.key}`,style:{display:"flex",flexDirection:"column",gap:4},children:[i.jsx("span",{style:oo,children:d}),a(f,b=>r(b.length===0?void 0:b),`${s}-${e.key}`,e.key)]})}if(e.widget==="branch-list"&&a){const f=Array.isArray(t)?t.filter(b=>!!b&&typeof b=="object"):[];return i.jsxs("div",{"data-testid":`${s}-param-${e.key}`,style:{display:"flex",flexDirection:"column",gap:4},children:[i.jsx("span",{style:oo,children:d}),i.jsx(sk,{branches:f,onChange:b=>r(b.length===0?void 0:b),t:n,pools:o,renderActionList:a,testIdPrefix:`${s}-${e.key}`})]})}if(e.widget==="key-value")return i.jsxs("div",{"data-testid":`${s}-param-${e.key}`,style:{display:"flex",flexDirection:"column",gap:4},children:[i.jsx("span",{style:oo,children:d}),i.jsx(uk,{value:t,onChange:r,t:n,candidates:o.bindingCandidates,testIdPrefix:`${s}-kv-${e.key}`})]});if(e.widget==="state-key-value")return i.jsxs("div",{"data-testid":`${s}-param-${e.key}`,style:{display:"flex",flexDirection:"column",gap:4},children:[i.jsx("span",{style:oo,children:d}),i.jsx(pk,{value:t,onChange:r,t:n,candidates:o.bindingCandidates,stateKeyCandidates:o.stateKeyCandidates,param:e,siblingTarget:l?.target,testIdPrefix:`${s}-skv-${e.key}`})]});if(tk.has(e.widget??"")||!nk.has(e.widget??""))return i.jsxs("div",{"data-testid":`${s}-param-${e.key}`,style:tu,children:[i.jsx("span",{style:oo,children:d}),i.jsx("div",{style:{flex:1,minWidth:0},children:i.jsx(Ke,{value:typeof t=="string"?t:t==null?"":String(t),onChange:f=>r(f===""?void 0:f),t:n,candidates:o.bindingCandidates,placeholder:e.widget==="number"?n("layout_editor.action_param.number_placeholder"):void 0,testidPrefix:`${s}-chip-${e.key}`})})]});const p=Tn(e.widget);return i.jsxs("div",{"data-testid":`${s}-param-${e.key}`,style:tu,children:[i.jsx("span",{style:oo,children:d}),i.jsx("div",{style:{flex:1,minWidth:0},children:p?i.jsx(p,{control:{...e},value:t,onChange:r,t:n,candidates:rk(e.widget,o),bindingCandidates:o.bindingCandidates}):i.jsx(Ke,{value:typeof t=="string"?t:t==null?"":String(t),onChange:f=>r(f===""?void 0:f),t:n,candidates:o.bindingCandidates,testidPrefix:`${s}-chip-${e.key}`})})]})}function sk({branches:e,onChange:t,t:n,pools:o,renderActionList:r,testIdPrefix:s}){const a=b=>Array.isArray(b)?b.filter(g=>!!g&&typeof g=="object"):b&&typeof b=="object"?[b]:[],l=b=>{if(b.length!==0)return b.length===1?b[0]:b},d=(b,g)=>{const m=e.slice();m[b]=g,t(m)},c=b=>{t(e.filter((g,m)=>m!==b))},p=(b,g)=>{if(g<0||g>=e.length)return;const m=e.slice(),[h]=m.splice(b,1);m.splice(g,0,h),t(m)},f=()=>{t([...e,{if:"",then:void 0}])};return i.jsxs("div",{"data-testid":`${s}-branches`,style:{display:"flex",flexDirection:"column",gap:8},children:[e.map((b,g)=>{const m=typeof b.if=="string"?b.if:"",h=a(b.then);return i.jsxs("div",{"data-testid":`${s}-branch-${g}`,style:ak,children:[i.jsxs("div",{style:lk,children:[i.jsxs("span",{style:dk,children:[n(m?"layout_editor.action_recipe.conditions.branch_when":"layout_editor.action_recipe.conditions.branch_else")," ",g+1]}),i.jsxs("span",{style:{display:"flex",gap:4},children:[i.jsx("button",{type:"button","data-testid":`${s}-branch-${g}-up`,onClick:()=>p(g,g-1),disabled:g===0,style:zs,title:n("layout_editor.action_recipe.conditions.move_up"),children:"↑"}),i.jsx("button",{type:"button","data-testid":`${s}-branch-${g}-down`,onClick:()=>p(g,g+1),disabled:g===e.length-1,style:zs,title:n("layout_editor.action_recipe.conditions.move_down"),children:"↓"}),i.jsx("button",{type:"button","data-testid":`${s}-branch-${g}-remove`,onClick:()=>c(g),style:zs,title:n("layout_editor.action_recipe.conditions.remove_branch"),children:"✕"})]})]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:3},children:[i.jsx("span",{style:eu,children:n("layout_editor.action_recipe.conditions.param_if")}),i.jsx(Ke,{value:m,onChange:v=>d(g,{...b,if:v}),t:n,candidates:o.bindingCandidates,testidPrefix:`${s}-branch-${g}-if`})]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:3},children:[i.jsx("span",{style:eu,children:n("layout_editor.action_recipe.conditions.param_then")}),r(h,v=>d(g,{...b,then:l(v)}),`${s}-branch-${g}-then`)]})]},g)}),i.jsxs("button",{type:"button","data-testid":`${s}-add-branch`,onClick:f,style:ck,children:["+ ",n("layout_editor.action_recipe.conditions.add_branch")]})]})}const ak={border:"1px solid #e2e8f0",borderRadius:6,padding:8,display:"flex",flexDirection:"column",gap:6,background:"#f8fafc"},lk={display:"flex",justifyContent:"space-between",alignItems:"center"},dk={fontSize:12,fontWeight:700,color:"#475569"},eu={fontSize:11,color:"#64748b"},zs={border:"1px solid #cbd5e1",background:"#fff",borderRadius:4,width:22,height:22,cursor:"pointer",fontSize:12,lineHeight:"1",color:"#475569"},ck={border:"1px dashed #94a3b8",background:"#fff",borderRadius:6,padding:"6px 10px",cursor:"pointer",fontSize:12,color:"#475569",alignSelf:"flex-start"};function uk({value:e,onChange:t,t:n,candidates:o,testIdPrefix:r,renderKeyInput:s}){const a=e&&typeof e=="object"&&!Array.isArray(e)?Object.entries(e).map(([l,d])=>({key:l,value:typeof d=="string"?d:d==null?"":String(d)})):[];return i.jsx(Pr,{value:a,onChange:l=>{const d={};for(const c of l)c.key.trim()!==""&&(d[c.key]=c.value??"");t(Object.keys(d).length===0?void 0:d)},keyField:"key",valueField:"value",t:n,candidates:o,testidPrefix:r,keyPlaceholder:n("layout_editor.action_param.key_placeholder"),valuePlaceholder:n("layout_editor.action_param.value_placeholder"),addLabel:n("layout_editor.action_param.add_pair"),renderKeyInput:s})}function pk({value:e,onChange:t,t:n,candidates:o,stateKeyCandidates:r,param:s,siblingTarget:a,testIdPrefix:l}){const d=e&&typeof e=="object"&&!Array.isArray(e)?Object.entries(e):[],c=typeof a=="string"?a:"";if((c.startsWith("_local.")||c.startsWith("global.")||c.startsWith("$parent._local.")||c.startsWith("$root._local."))&&d.length===1&&d[0][0]==="value"){const y=d[0][1];return i.jsx("div",{"data-testid":`${l}-path-value`,style:{display:"flex",flexDirection:"column",gap:4},children:i.jsx(zn,{value:y,onChange:_=>t(_===void 0?void 0:{value:_}),t:n,path:"value",scope:`${l}-path-value-val`,renderStringLeaf:_=>i.jsx(Ke,{value:_.value,onChange:_.onChange,t:n,candidates:o,testidPrefix:_.testidPrefix})})})}const b=(y,_)=>{const w={};for(const[k,x]of d)w[k]=k===y?_:x;t(Object.keys(w).length===0?void 0:w)},g=y=>{const _={};for(const[w,k]of d)w!==y&&(_[w]=k);t(Object.keys(_).length===0?void 0:_)},[m,h]=u.useState(""),v=()=>{const y=m.trim();if(y===""||d.some(([w])=>w===y))return;const _={};for(const[w,k]of d)_[w]=k;_[y]="",t(_),h("")};return i.jsxs("div",{"data-testid":l,style:{display:"flex",flexDirection:"column",gap:6},children:[d.map(([y,_])=>i.jsxs("div",{"data-testid":`${l}-row-${y}`,style:{display:"flex",gap:6,alignItems:"flex-start",border:"1px solid #e2e8f0",borderRadius:8,padding:8},children:[i.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:6},children:[i.jsx("div",{style:{minWidth:0},children:i.jsx(Ts,{control:{...s},value:y,onChange:w=>{const k=w==null?"":String(w);if(k===""||k===y||d.some(([$])=>$===k))return;const x={};for(const[$,S]of d)x[$===y?k:$]=S;t(x)},t:n,candidates:r})}),i.jsx("div",{style:{minWidth:0},children:i.jsx(zn,{value:_,onChange:w=>b(y,w),t:n,path:y,scope:`${l}-val`,renderStringLeaf:w=>i.jsx(Ke,{value:w.value,onChange:w.onChange,t:n,candidates:o,testidPrefix:w.testidPrefix})})})]}),i.jsx("button",{type:"button","data-testid":`${l}-remove-${y}`,onClick:()=>g(y),title:n("layout_editor.page_settings.seo.remove"),"aria-label":n("layout_editor.page_settings.seo.remove"),style:{flex:"0 0 auto",padding:"4px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#64748b",cursor:"pointer"},children:"✕"})]},y)),i.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[i.jsx("div",{style:{flex:1,minWidth:0},children:i.jsx(Ts,{control:{...s},value:m,onChange:y=>h(y==null?"":String(y)),t:n,candidates:r})}),i.jsxs("button",{type:"button","data-testid":`${l}-add`,onClick:v,style:{flex:"0 0 auto",padding:"5px 10px",fontSize:12,border:"1px dashed #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer"},children:["+ ",n("layout_editor.action_param.add_pair")]})]})]})}function Ns({raw:e,recipe:t,values:n,t:o,pools:r,onChange:s,testIdPrefix:a,renderActionList:l}){const d=(c,p)=>{const f={...n,[c]:p},b=Sr(t,f),g=cs(e);s(g?Vd(b,g):b)};return i.jsx(i.Fragment,{children:t.params.filter(c=>fk(c,n)).map(c=>i.jsx(ik,{param:c,value:n[c.key],t:o,pools:r,onChange:p=>d(c.key,p),testIdPrefix:a,renderActionList:l,siblingValues:n},c.key))})}function fk(e,t){const n=e.dependsOn;return!n||typeof n!="object"||typeof n.param!="string"?!0:t[n.param]===n.equals}function gk({raw:e,t,onChange:n,testIdPrefix:o,candidates:r}){const[s,a]=u.useState(!1);return i.jsxs("div",{"data-testid":`${o}-if`,style:mk,children:[i.jsxs("button",{type:"button",onClick:()=>a(l=>!l),style:vk,children:["▸ ",t("layout_editor.init_actions.if_label")]}),s?i.jsx("div",{"data-testid":`${o}-if-input`,style:{minWidth:0},children:i.jsx(Ke,{value:cs(e)??"",onChange:l=>n(Vd(e,l)),t,candidates:r,placeholder:t("layout_editor.init_actions.if_placeholder"),testidPrefix:`${o}-if-chip`})}):null]})}const tu={display:"flex",alignItems:"center",gap:8,minWidth:0},oo={fontSize:11,color:"#64748b",minWidth:80},hk={display:"flex",alignItems:"center",gap:8,padding:"4px 0"},yk={fontSize:11,color:"#64748b",minWidth:80},bk={fontSize:11,color:"#92400e"},mk={display:"flex",flexDirection:"column",gap:4},vk={textAlign:"left",border:"none",background:"transparent",color:"#475569",cursor:"pointer",fontSize:11,padding:0};function _k(e,t,n){if(!t)return n("layout_editor.action.source_core");const o=e?.[t],r=o&&typeof o=="object"&&o.__source?o.__source:null;return!r||r.kind==="core"?n("layout_editor.action.source_core"):r.id??n(`layout_editor.action.source_${r.kind}`)}function xk(e,t,n){const o=Yn(e,t);if(o.kind==="preset"){const r=t.find(s=>s.id===o.recipeId);return Kd(r??null,o.values,s=>n(s.startsWith("$t:")?s.slice(3):s))}return typeof e.handler=="string"?e.handler:n("layout_editor.action_list.unknown")}function Gt({actions:e,onChange:t,t:n,recipes:o,chipContext:r,actionChipCandidates:s,addContext:a="init",renderAddPicker:l,renderEditor:d,candidatePools:c,showSourceBadge:p=!1,canDrag:f,canDropAt:b,isLocked:g,hideAddPicker:m=!1,testIdPrefix:h="g7le-action-list"}){const v=u.useMemo(()=>ko(o),[o]),y=u.useMemo(()=>{if(r==null||r==="init")return c;const B=Vl(r,n,s??null);if(B.length===0)return c;const M=c??{},O=new Set((M.bindingCandidates??[]).map(H=>H.expression)),z=B.filter(H=>!O.has(H.expression));return z.length===0?c:{...M,bindingCandidates:[...z,...M.bindingCandidates??[]]}},[r,s,c,n]),[_,w]=u.useState(null),[k,x]=u.useState(null),$=u.useCallback((B,M)=>{if(B===M||B<0||M<0||B>=e.length||M>=e.length)return;const O=e.slice(),[z]=O.splice(B,1);O.splice(M,0,z),t(O)},[e,t]),S=ys({length:e.length,onMove:$,canDrag:f,canDropAt:b}),C=u.useCallback(B=>{t(e.filter((M,O)=>O!==B))},[e,t]),T=u.useCallback((B,M)=>{const O=e.slice();O[B]=M,t(O)},[e,t]),E=u.useCallback(B=>{t([...e,B])},[e,t]),A=u.useCallback((B,M)=>{const O=Yn(B,v),z=O.kind==="preset"?v.find(P=>P.id===O.recipeId)??null:null;if(!z)return null;const H=O.kind==="preset"?O.values:{};return i.jsxs("div",{style:Ck,children:[i.jsx(Ns,{raw:B,recipe:z,values:H,t:n,pools:y??{},onChange:M,testIdPrefix:`${h}-edit`,renderActionList:(P,I,L,F)=>{const Y=F==="onSuccess"?"response":F==="onError"?"error":void 0;return i.jsx(Gt,{actions:P,onChange:I,t:n,recipes:o,chipContext:Y,actionChipCandidates:Y?s:void 0,candidatePools:Y?c:y,addContext:a,showSourceBadge:p,testIdPrefix:L})}}),i.jsx(gk,{raw:B,t:n,onChange:M,testIdPrefix:`${h}-edit`,candidates:y?.bindingCandidates})]})},[v,n,y,c,s,h,o,a,p]),N=d??(o?A:void 0),D=m?null:l?l(E):o?i.jsx(m0,{recipes:o,t:n,onAdd:E,context:a,testIdPrefix:`${h}-add-picker`}):null;return i.jsxs("div",{className:h,"data-testid":h,children:[i.jsxs("ul",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:6},children:[e.map((B,M)=>{const O=Yn(B,v),z=O.kind==="preset"?O.recipeId:null,H=z?v.find(Y=>Y.id===z)??null:null,P=H===null,I=g?.(M)??!1,L=cs(B)!==null,F=N?N(B,Y=>T(M,Y)):null;return i.jsxs(u.Fragment,{children:[I?null:i.jsx("li",{"aria-hidden":"true",style:{listStyle:"none",margin:0,padding:0},children:i.jsx(Rn,{active:S.isDropTarget(M),testid:`${h}-dropline-${M}`})}),i.jsxs("li",{"data-testid":`${h}-item-${M}`,"data-drag-source":S.dragIndex===M?"true":void 0,style:{border:"1px solid #e2e8f0",borderRadius:8,padding:"8px 10px",...S.dragIndex===M?{opacity:.5}:{}},onDragOver:S.dragging&&!I?Y=>{Y.preventDefault();const K=Y.currentTarget.getBoundingClientRect();S.onDragOverItem(M,Y.clientY{Y.preventDefault(),S.onDrop()}:void 0,children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[I?i.jsx("span",{style:{fontSize:12},children:"🔒"}):i.jsx("span",{"data-testid":`${h}-drag-${M}`,style:{color:"#94a3b8",cursor:"grab",fontSize:14,userSelect:"none"},draggable:!0,onDragStart:()=>S.onDragStart(M),onDragEnd:S.onDragEnd,"aria-label":n("layout_editor.action_list.drag_reorder"),role:"button",children:"⠿"}),i.jsx("span",{style:{flex:1,minWidth:0,fontSize:13},"data-testid":`${h}-summary-${M}`,children:xk(B,v,n)}),p?i.jsxs("span",{"data-testid":`${h}-source-${M}`,style:wk,children:["〔",_k(o,z,n),"〕"]}):null,L?i.jsxs("span",{"data-testid":`${h}-cond-badge-${M}`,style:kk,children:["〔",n("layout_editor.init_actions.cond_badge"),"〕"]}):null,P?i.jsxs("span",{"data-testid":`${h}-advanced-${M}`,style:Sk,children:["[",n("layout_editor.action.advanced"),"]"]}):null,!I&&F?i.jsxs("button",{type:"button","data-testid":`${h}-edit-${M}`,onClick:()=>x(k===M?null:M),"aria-label":n("layout_editor.init_actions.edit"),title:n("layout_editor.init_actions.edit"),style:k===M?$k:nu,children:["✎ ",n("layout_editor.init_actions.edit")]}):null,i.jsx("button",{type:"button","data-testid":`${h}-code-${M}`,onClick:()=>w(_===M?null:M),"aria-label":n("layout_editor.action_list.view_code"),title:n("layout_editor.action_list.view_code"),style:_===M?Ek:Ms,children:""}),I?null:i.jsx("button",{type:"button","data-testid":`${h}-remove-${M}`,onClick:()=>C(M),"aria-label":n("layout_editor.action_list.remove"),title:n("layout_editor.action_list.remove"),style:Ik,children:"✕"})]}),H?i.jsx(T0,{action:B,recipe:H,values:O.kind==="preset"?O.values:{},t:n,showCodeButton:!1,testIdPrefix:`${h}-preview-${M}`}):null,k===M&&!I&&F?i.jsx("div",{"data-testid":`${h}-edit-body-${M}`,children:F}):null,d&&k!==M?d(B,Y=>T(M,Y)):null,_===M?i.jsx("pre",{"data-testid":`${h}-code-view-${M}`,style:{margin:"8px 0 0",padding:8,background:"#0f172a",color:"#e2e8f0",borderRadius:6,fontSize:12,overflow:"auto"},children:JSON.stringify(B,null,2)}):null]})]},M)}),i.jsx("li",{"aria-hidden":"true",style:{listStyle:"none",margin:0,padding:0},children:i.jsx(Rn,{active:S.isDropTarget(e.length),testid:`${h}-dropline-end`})})]}),D?i.jsx("div",{style:{marginTop:8},children:D}):null]})}const wk={fontSize:10,color:"#64748b",whiteSpace:"nowrap"},kk={fontSize:10,color:"#7c3aed",whiteSpace:"nowrap"},Sk={fontSize:10,color:"#92400e",whiteSpace:"nowrap"},Ck={display:"flex",flexDirection:"column",gap:6,paddingTop:6,borderTop:"1px dashed #e2e8f0",marginTop:6},nu={flex:"0 0 auto",padding:"3px 8px",fontSize:11,fontWeight:500,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",whiteSpace:"nowrap",lineHeight:1.4},$k={...nu,background:"#eff6ff",borderColor:"#bfdbfe",color:"#2563eb"},Ms={flex:"0 0 auto",width:26,height:24,display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:11,border:"1px solid #e2e8f0",borderRadius:6,background:"#fff",color:"#64748b",cursor:"pointer",fontFamily:"ui-monospace, monospace"},Ek={...Ms,background:"#0f172a",borderColor:"#0f172a",color:"#e2e8f0"},Ik={...Ms,color:"#dc2626",borderColor:"#fecaca",fontFamily:"inherit"};function ou(e){const t=e.__source;return t&&typeof t=="object"?t:null}function Ak({actions:e,onChange:t,recipes:n,t:o,bindingCandidates:r,pageCandidates:s,dataSourceCandidates:a,stateKeyCandidates:l,modalCandidates:d}){const c=u.useMemo(()=>({pageCandidates:s,dataSourceCandidates:a,stateKeyCandidates:l,modalCandidates:d,bindingCandidates:r}),[s,a,l,d,r]),p=u.useMemo(()=>e.filter(h=>ou(h)?.kind==="base"),[e]),f=u.useMemo(()=>e.filter(h=>ou(h)?.kind!=="base"),[e]),b=p.length>0,g=u.useCallback(h=>{t(b?[...p,...h]:h)},[t,b,p]),m=u.useCallback(()=>{},[]);return i.jsxs("div",{className:"g7le-init-actions-form","data-testid":"g7le-init-actions-form",style:Tk,children:[i.jsx("p",{style:Dk,children:o("layout_editor.page_settings.init_actions.heading")}),b?i.jsxs(i.Fragment,{children:[i.jsxs("div",{"data-testid":"g7le-init-action-group-base",style:ru,children:[i.jsx("div",{style:iu,children:o("layout_editor.init_actions.group_base")}),i.jsx(Gt,{actions:p,onChange:m,t:o,recipes:n,candidatePools:c,addContext:"init",showSourceBadge:!0,isLocked:()=>!0,hideAddPicker:!0,testIdPrefix:"g7le-init-action-base"}),i.jsxs("p",{"data-testid":"g7le-init-action-base-hint",style:zk,children:["ⓘ ",o("layout_editor.init_actions.base_readonly_hint")]})]}),i.jsxs("div",{"data-testid":"g7le-init-action-group-self",style:ru,children:[i.jsx("div",{style:iu,children:o("layout_editor.init_actions.group_self")}),f.length===0?i.jsx("p",{style:su,children:o("layout_editor.init_actions.empty_self")}):null,i.jsx(Gt,{actions:f,onChange:g,t:o,recipes:n,candidatePools:c,addContext:"init",showSourceBadge:!0,testIdPrefix:"g7le-init-action-self"})]}),i.jsxs("p",{"data-testid":"g7le-init-action-merge-order",style:Nk,children:["ⓘ ",o("layout_editor.init_actions.merge_order")]})]}):i.jsxs(i.Fragment,{children:[e.length===0?i.jsx("p",{"data-testid":"g7le-init-action-empty",style:su,children:o("layout_editor.init_actions.empty")}):null,i.jsx(Gt,{actions:e,onChange:t,t:o,recipes:n,candidatePools:c,addContext:"init",showSourceBadge:!0,testIdPrefix:"g7le-init-action"})]})]})}const Tk={display:"flex",flexDirection:"column",gap:12,minWidth:0},Dk={margin:0,fontSize:13,fontWeight:700,color:"#0f172a"},ru={border:"1px solid #e2e8f0",borderRadius:10,padding:10,display:"flex",flexDirection:"column",gap:8},iu={fontSize:12,fontWeight:700,color:"#475569"},zk={margin:0,fontSize:11,color:"#64748b"},su={margin:0,fontSize:12,color:"#94a3b8"},Nk={margin:0,fontSize:11,color:"#64748b"};function Mk(e){return e==="spinner"?new Set(["spinner","page"]):new Set(["skeleton"])}function au(e,t,n){return typeof e!="string"?n:e.startsWith("$t:")?t(e.slice(3)):e}function lu({candidates:e,value:t,onSelect:n,styleKind:o,t:r,testIdPrefix:s="g7le-loading-component-picker"}){const a=bo(),l=()=>{const d=a.open({ariaLabel:r("layout_editor.overlay.loading_picker.select"),width:520,maxHeightRatio:.7,content:i.jsx(Lk,{candidates:e,value:t,styleKind:o,t:r,testIdPrefix:s,onPick:c=>{n(c),a.close(d)},onClose:()=>a.close(d)})})};return i.jsx("div",{className:s,"data-testid":s,style:{minWidth:0},children:i.jsxs("div",{style:Pk,children:[i.jsx("span",{"data-testid":`${s}-current`,style:Ok,children:t&&t.length>0?t:r("layout_editor.overlay.loading_picker.none")}),i.jsxs("button",{type:"button","data-testid":`${s}-open`,onClick:l,style:Bk,children:["🔍 ",r("layout_editor.overlay.loading_picker.select")]})]})})}function Lk({candidates:e,value:t,styleKind:n,t:o,testIdPrefix:r,onPick:s,onClose:a}){const[l,d]=u.useState(""),c=Mk(n),p=u.useMemo(()=>{const f=l.trim().toLowerCase();return e.filter(b=>c.has(b.role)).filter(b=>f?au(b.label,o,b.name).toLowerCase().includes(f)||b.name.toLowerCase().includes(f):!0)},[e,n,l,o]);return i.jsxs("div",{"data-testid":`${r}-modal`,style:Wk,children:[i.jsxs("div",{style:jk,children:[i.jsxs("span",{style:Hk,children:["🔍 ",o("layout_editor.overlay.loading_picker.select")]}),i.jsx("button",{type:"button","data-testid":`${r}-close`,onClick:a,"aria-label":o("layout_editor.overlay.loading_picker.select"),style:Fk,children:"✕"})]}),i.jsx("input",{type:"text","data-testid":`${r}-search`,value:l,placeholder:o("layout_editor.overlay.loading_picker.search"),onChange:f=>d(f.target.value),style:Kk,autoFocus:!0}),p.length===0?i.jsx("p",{"data-testid":`${r}-empty`,style:Jk,children:o("layout_editor.overlay.loading_picker.empty")}):i.jsx("ul",{style:Vk,children:p.map(f=>i.jsx("li",{children:i.jsxs("button",{type:"button","data-testid":`${r}-item-${f.name}`,onClick:()=>s(f.name),style:{...Uk,...t===f.name?qk:{}},children:[i.jsx("span",{style:Gk,children:au(f.label,o,f.name)}),i.jsx("code",{style:Yk,children:f.name}),i.jsx("span",{style:Xk,children:f.role})]})},f.name))})]})}const Pk={display:"flex",alignItems:"center",gap:6,minWidth:0},Ok={flex:1,minWidth:0,fontSize:12,color:"#0f172a",fontFamily:"monospace"},Bk={padding:"4px 10px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer",whiteSpace:"nowrap"},Wk={display:"flex",flexDirection:"column",minHeight:0,padding:16,boxSizing:"border-box",fontFamily:"system-ui, -apple-system, sans-serif"},jk={display:"flex",alignItems:"center",gap:8,paddingBottom:8,borderBottom:"1px solid #e2e8f0",marginBottom:10},Hk={flex:1,fontSize:14,fontWeight:700,color:"#0f172a",minWidth:0},Fk={border:"none",background:"transparent",color:"#64748b",cursor:"pointer",fontSize:15,lineHeight:1,padding:4},Kk={width:"100%",padding:"6px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,marginBottom:8,boxSizing:"border-box"},Vk={listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:2,overflowY:"auto",minHeight:0},Uk={display:"flex",alignItems:"center",gap:6,width:"100%",textAlign:"left",padding:"8px 10px",fontSize:12,border:"1px solid transparent",background:"transparent",cursor:"pointer",borderRadius:6},qk={border:"1px solid #3b82f6",background:"#eff6ff"},Gk={flex:1,minWidth:0,color:"#0f172a"},Yk={fontSize:10,color:"#94a3b8",fontFamily:"monospace"},Xk={fontSize:10,color:"#64748b",background:"#f1f5f9",borderRadius:4,padding:"0 4px"},Jk={margin:0,fontSize:12,color:"#94a3b8",padding:"8px 4px"};function du(e){return e===!0?{enabled:!0}:e===!1||e===void 0?{}:e}const Zk=["opaque","blur","fade","skeleton","spinner"];function Qk({value:e,patch:t,t:n,baseValue:o,ownValue:r,loadingComponents:s=[],progressiveDataSources:a=[],bindingCandidates:l}){const d=du(e),c=d.enabled??!1,p=!!o&&Object.keys(o).length>0,f=Tn("component-target-picker"),[b,g]=u.useState((d.wait_for??[]).length>0),m=u.useCallback(k=>{const x={...du(e)};k(x),t(x)},[e,t]),h=r&&typeof r=="object"?r:e&&typeof e=="object"?e:{},v=u.useCallback(k=>p&&o!==void 0&&k in o&&!(k in h),[p,o,h]),y=u.useCallback(k=>{o&&m(x=>{x[k]=o[k]})},[o,m]),_=u.useCallback(k=>m(x=>{x.enabled=k}),[m]),w=d.target!==void 0?"region":"full";return i.jsxs("div",{className:"g7le-overlay-form","data-testid":"g7le-overlay-form",style:Rk,children:[p?i.jsxs("p",{"data-testid":"g7le-overlay-inherit-banner",style:e1,children:["ⓘ ",n("layout_editor.overlay.inherit_banner")]}):null,i.jsxs("div",{style:Hr,children:[i.jsx(Ls,{label:n("layout_editor.overlay.enabled_label"),inherited:v("enabled"),hasInheritance:p,onOverride:()=>y("enabled"),testidKey:"enabled",t:n}),i.jsx(Lr,{disabled:v("enabled"),children:i.jsx(Mr,{checked:c,onChange:_,testid:"g7le-overlay-enabled",ariaLabel:n("layout_editor.overlay.enabled_label"),label:n(c?"layout_editor.overlay.on":"layout_editor.overlay.off")})}),i.jsxs("p",{style:Fr,children:["ⓘ ",n("layout_editor.overlay.enabled_hint")]})]}),i.jsx(Lr,{disabled:!c,testid:"g7le-overlay-body",style:{display:"flex",flexDirection:"column",gap:16,minWidth:0},children:i.jsxs(i.Fragment,{children:[i.jsxs("div",{style:Hr,children:[i.jsx(Ls,{label:n("layout_editor.overlay.scope_label"),inherited:v("target"),hasInheritance:p,onOverride:()=>y("target"),testidKey:"target",t:n}),i.jsxs("div",{"data-testid":"g7le-overlay-scope",style:Ps,children:[i.jsx(jr,{active:w==="full",onClick:()=>m(k=>{delete k.target,delete k.fallback_target}),testid:"g7le-overlay-scope-full",children:n("layout_editor.overlay.scope_full")}),i.jsx(jr,{active:w==="region",onClick:()=>m(k=>{k.target=k.target??""}),testid:"g7le-overlay-scope-region",children:n("layout_editor.overlay.scope_region")})]}),i.jsx(Lr,{disabled:w!=="region",testid:"g7le-overlay-region-box",style:r1,children:i.jsxs(i.Fragment,{children:[i.jsx(Nn,{label:n("layout_editor.overlay.target_label"),children:i.jsx("div",{"data-testid":"g7le-overlay-target-picker",children:f?i.jsx(f,{control:{label:n("layout_editor.overlay.target_label")},value:d.target??"",onChange:k=>m(x=>{x.target=typeof k=="string"?k:""}),t:n}):i.jsx("input",{type:"text","data-testid":"g7le-overlay-target-input",value:d.target??"",onChange:k=>m(x=>{x.target=k.target.value}),style:a1})})}),i.jsx(Nn,{label:n("layout_editor.overlay.fallback_label"),children:i.jsx("div",{"data-testid":"g7le-overlay-fallback-picker",children:f?i.jsx(f,{control:{label:n("layout_editor.overlay.fallback_label")},value:d.fallback_target??"",onChange:k=>m(x=>{const $=typeof k=="string"?k:"";$===""?delete x.fallback_target:x.fallback_target=$}),t:n}):null})}),i.jsxs("p",{style:Fr,children:["ⓘ ",n("layout_editor.overlay.fallback_hint")]})]})})]}),i.jsxs("div",{style:Hr,children:[i.jsx(Ls,{label:n("layout_editor.overlay.style_label"),inherited:v("style"),hasInheritance:p,onOverride:()=>y("style"),testidKey:"style",t:n}),i.jsx("div",{"data-testid":"g7le-overlay-style",style:Ps,children:Zk.map(k=>i.jsx(jr,{active:(d.style??"opaque")===k,onClick:()=>m(x=>{x.style=k}),testid:`g7le-overlay-style-${k}`,children:n(`layout_editor.overlay.style_${k}`)},k))}),d.style==="skeleton"?i.jsxs("div",{style:cu,children:[i.jsx(Nn,{label:n("layout_editor.overlay.skeleton_component"),children:i.jsx(lu,{candidates:s,value:d.skeleton?.component,styleKind:"skeleton",onSelect:k=>m(x=>{x.skeleton={...x.skeleton,component:k}}),t:n,testIdPrefix:"g7le-overlay-skeleton-component"})}),i.jsx(Nn,{label:n("layout_editor.overlay.skeleton_animation"),children:i.jsx("div",{"data-testid":"g7le-overlay-skeleton-anim",style:Ps,children:["wave","pulse","none"].map(k=>i.jsx(jr,{active:(d.skeleton?.animation??"wave")===k,onClick:()=>m(x=>{x.skeleton={...x.skeleton,animation:k}}),testid:`g7le-overlay-skeleton-anim-${k}`,children:n(`layout_editor.overlay.anim_${k}`)},k))})}),i.jsx(Nn,{label:n("layout_editor.overlay.skeleton_count"),children:i.jsx("input",{type:"number","data-testid":"g7le-overlay-skeleton-count",value:d.skeleton?.iteration_count??"",onChange:k=>m(x=>{const $=parseInt(k.target.value,10);x.skeleton={...x.skeleton,iteration_count:Number.isNaN($)?void 0:$}}),style:l1})})]}):null,d.style==="spinner"?i.jsxs("div",{style:cu,children:[i.jsx(Nn,{label:n("layout_editor.overlay.spinner_component"),children:i.jsx(lu,{candidates:s,value:d.spinner?.component,styleKind:"spinner",onSelect:k=>m(x=>{x.spinner={...x.spinner,component:k}}),t:n,testIdPrefix:"g7le-overlay-spinner-component"})}),i.jsx(Nn,{label:n("layout_editor.overlay.spinner_text"),children:i.jsx("div",{"data-testid":"g7le-overlay-spinner-text",style:{minWidth:0},children:i.jsx(_t,{value:d.spinner?.text??"",onChange:k=>m(x=>{x.spinner={...x.spinner,text:k===void 0||k===""?void 0:k}}),t:n,candidates:l,enableExpressionTree:!0,expressionTreeCollapsible:!0,testidPrefix:"g7le-overlay-spinner-text-field"})})})]}):null]}),i.jsxs("div",{style:Hr,children:[i.jsxs("button",{type:"button","data-testid":"g7le-overlay-waitfor-toggle","aria-expanded":b,onClick:()=>g(k=>!k),style:u1,children:[b?"▾":"▸"," ",n("layout_editor.overlay.waitfor_label")]}),b?i.jsxs("div",{"data-testid":"g7le-overlay-waitfor-body",style:p1,children:[i.jsxs("p",{"data-testid":"g7le-overlay-waitfor-hint",style:Fr,children:["ⓘ ",n("layout_editor.overlay.waitfor_hint")]}),a.length===0?i.jsx("p",{"data-testid":"g7le-overlay-waitfor-empty",style:Fr,children:n("layout_editor.overlay.waitfor_empty")}):i.jsx("div",{"data-testid":"g7le-overlay-waitfor",style:{display:"flex",flexWrap:"wrap",gap:6},children:a.map(k=>{const x=(d.wait_for??[]).includes(k.id);return i.jsxs("label",{"data-testid":`g7le-overlay-waitfor-${k.id}`,style:d1(x),children:[i.jsx("input",{type:"checkbox",checked:x,onChange:()=>m($=>{const S=new Set($.wait_for??[]);S.has(k.id)?S.delete(k.id):S.add(k.id);const C=Array.from(S);C.length===0?delete $.wait_for:$.wait_for=C})}),i.jsx(Lc,{option:k,testIdPrefix:`g7le-overlay-waitfor-${k.id}`})]},k.id)})})]}):null]}),p?i.jsxs("button",{type:"button","data-testid":"g7le-overlay-reset-inherit",onClick:()=>t(void 0),style:c1,children:["⟲ ",n("layout_editor.overlay.reset_inherit")]}):null]})})]})}function jr({active:e,onClick:t,children:n,testid:o}){return i.jsx("button",{type:"button","data-testid":o,"aria-pressed":e,onClick:t,style:{...n1,...e?o1:{}},children:n})}function Ls({label:e,inherited:t,hasInheritance:n,onOverride:o,testidKey:r,t:s}){return i.jsxs("div",{style:f1,children:[i.jsx("label",{style:t1,children:e}),n?t?i.jsxs(i.Fragment,{children:[i.jsxs("span",{"data-testid":`g7le-overlay-inherited-${r}`,style:g1,children:["〔",s("layout_editor.overlay.inherited_badge"),"〕"]}),i.jsx("button",{type:"button","data-testid":`g7le-overlay-override-${r}`,onClick:o,style:y1,children:s("layout_editor.overlay.override_field")})]}):i.jsxs("span",{"data-testid":`g7le-overlay-overridden-${r}`,style:h1,children:["〔",s("layout_editor.overlay.overridden_badge"),"〕"]}):null]})}function Nn({label:e,children:t}){return i.jsxs("div",{style:i1,children:[i.jsx("span",{style:s1,children:e}),i.jsx("div",{style:{flex:1,minWidth:0},children:t})]})}const Rk={display:"flex",flexDirection:"column",gap:16,minWidth:0},e1={margin:0,fontSize:12,color:"#1d4ed8",background:"#eff6ff",padding:"8px 10px",borderRadius:6},Hr={display:"flex",flexDirection:"column",gap:6,minWidth:0},t1={fontSize:13,fontWeight:600,color:"#0f172a"},Fr={margin:0,fontSize:11,color:"#94a3b8"},Ps={display:"flex",gap:4,flexWrap:"wrap"},n1={padding:"4px 10px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},o1={border:"1px solid #3b82f6",background:"#eff6ff",color:"#1d4ed8"},r1={display:"flex",flexDirection:"column",gap:8,padding:8,border:"1px dashed #e2e8f0",borderRadius:8},cu={display:"flex",flexDirection:"column",gap:8,padding:8,border:"1px dashed #e2e8f0",borderRadius:8},i1={display:"flex",alignItems:"center",gap:8,minWidth:0},s1={fontSize:11,color:"#64748b",minWidth:90},a1={width:"100%",padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,boxSizing:"border-box"},l1={width:80,padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6},d1=e=>({display:"inline-flex",alignItems:"center",gap:4,padding:"4px 8px",fontSize:12,border:`1px solid ${e?"#3b82f6":"#cbd5e1"}`,borderRadius:12,background:e?"#eff6ff":"#fff",cursor:"pointer"}),c1={alignSelf:"flex-start",padding:"6px 12px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},u1={alignSelf:"flex-start",padding:"4px 0",fontSize:13,fontWeight:600,color:"#0f172a",background:"transparent",border:"none",cursor:"pointer"},p1={display:"flex",flexDirection:"column",gap:6,paddingLeft:14,minWidth:0},f1={display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",minWidth:0},g1={fontSize:11,color:"#64748b",background:"#f1f5f9",borderRadius:4,padding:"1px 6px"},h1={fontSize:11,color:"#0369a1",background:"#e0f2fe",borderRadius:4,padding:"1px 6px"},y1={padding:"2px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},b1="g7le:computed-effect-preview",m1={number:"layout_editor.computed.type_number",string:"layout_editor.computed.type_string",boolean:"layout_editor.computed.type_boolean",list:"layout_editor.computed.type_list",object:"layout_editor.computed.type_object",null:"layout_editor.computed.type_null"};function v1(e,t,n){if(t==="list"){const o=e,r=o.slice(0,2).map(s=>JSON.stringify(s)).join(", ");return o.length<=2?`[${r}]`:`[${r}, ${n("layout_editor.computed.list_more",{count:o.length})}]`}return t==="object"?JSON.stringify(e):t==="boolean"?e?"true":"false":t==="null"?n("layout_editor.computed.value_none"):String(e)}function uu({expr:e,computedKey:t,sampleContext:n,t:o,isEffect:r=!1,testIdPrefix:s="g7le-computed-preview"}){const a=zd(e,n),l=()=>{typeof window>"u"||!t||window.dispatchEvent(new CustomEvent(b1,{detail:{key:t}}))};return a.ok?i.jsxs("div",{className:s,"data-testid":s,style:_1,children:[i.jsx("span",{style:x1,children:o("layout_editor.computed.preview_label")}),i.jsx("span",{"data-testid":`${s}-value`,style:w1,children:v1(a.value,a.type,o)}),i.jsxs("span",{"data-testid":`${s}-type`,style:k1,children:["(",o(m1[a.type]),")"]}),r&&a.type==="boolean"?i.jsxs("button",{type:"button","data-testid":`${s}-effect`,onClick:l,style:S1,children:["▷ ",o("layout_editor.computed.effect_preview")]}):null]}):i.jsxs("div",{"data-testid":`${s}-error`,style:C1,children:["⚠ ",o("layout_editor.computed.preview_error")]})}const _1={display:"flex",alignItems:"center",flexWrap:"wrap",gap:6,minWidth:0},x1={fontSize:11,color:"#94a3b8"},w1={fontSize:12,color:"#0f172a",fontFamily:"monospace",wordBreak:"break-all"},k1={fontSize:10,color:"#64748b"},S1={padding:"2px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer"},C1={fontSize:12,color:"#b45309"},$1=[{op:"count",labelKey:"layout_editor.computed.op_count"},{op:"sum",labelKey:"layout_editor.computed.op_sum"},{op:"filter",labelKey:"layout_editor.computed.op_filter"},{op:"toOptions",labelKey:"layout_editor.computed.op_to_options"},{op:"nth",labelKey:"layout_editor.computed.op_nth"},{op:"firstOf",labelKey:"layout_editor.computed.op_first_of"},{op:"literal",labelKey:"layout_editor.computed.op_literal"}],E1=["=","!=",">","<",">=","<=","includes"],I1=new Set(["count","sum","filter"]);function pu({model:e,onChange:t,t:n,dataSourceCandidates:o,bindingCandidates:r,existingKeys:s=[]}){const a=u.useCallback(g=>{const m={...e};g(m),t(m)},[e,t]),l=e.conditions??[],d=Tn("datasource-picker"),c=e.key!==""&&s.includes(e.key),p=()=>a(g=>{g.conditions=[...g.conditions??[],{field:"",cmp:"=",value:""}]}),f=(g,m)=>a(h=>{const v=(h.conditions??[]).slice(),y={...v[g]};m(y),v[g]=y,h.conditions=v}),b=g=>a(m=>{m.conditions=(m.conditions??[]).filter((h,v)=>v!==g)});return i.jsxs("div",{className:"g7le-computed-custom","data-testid":"g7le-computed-custom",style:A1,children:[i.jsx(Os,{label:`① ${n("layout_editor.computed.custom_step1")}`,children:i.jsx("div",{"data-testid":"g7le-computed-custom-source",children:d?i.jsx(d,{control:{},value:e.source,onChange:g=>a(m=>{m.source=typeof g=="string"?g:void 0}),t:n,candidates:o}):i.jsx("input",{type:"text",value:e.source??"",onChange:g=>a(m=>{m.source=g.target.value}),style:ro})})}),i.jsxs(Os,{label:`② ${n("layout_editor.computed.custom_step2")}`,children:[i.jsx("select",{"data-testid":"g7le-computed-custom-op",value:e.op,onChange:g=>a(m=>{m.op=g.target.value}),style:ro,children:$1.map(({op:g,labelKey:m})=>i.jsx("option",{value:g,children:n(m)},g))}),e.op==="sum"?i.jsx("div",{"data-testid":"g7le-computed-custom-sumfield",style:{minWidth:0},children:i.jsx(Ke,{value:e.sumField??"",onChange:g=>a(m=>{m.sumField=g}),t:n,candidates:r,placeholder:n("layout_editor.computed.custom_sum_field"),testidPrefix:"g7le-computed-custom-sumfield-chip"})}):null,e.op==="toOptions"?i.jsxs("div",{style:{display:"flex",gap:6},children:[i.jsx("div",{"data-testid":"g7le-computed-custom-valuefield",style:{flex:1,minWidth:0},children:i.jsx(Ke,{value:e.valueField??"",onChange:g=>a(m=>{m.valueField=g}),t:n,candidates:r,placeholder:n("layout_editor.computed.custom_value_field"),testidPrefix:"g7le-computed-custom-valuefield-chip"})}),i.jsx("div",{"data-testid":"g7le-computed-custom-labelfield",style:{flex:1,minWidth:0},children:i.jsx(Ke,{value:e.labelField??"",onChange:g=>a(m=>{m.labelField=g}),t:n,candidates:r,placeholder:n("layout_editor.computed.custom_label_field"),testidPrefix:"g7le-computed-custom-labelfield-chip"})})]}):null,e.op==="nth"?i.jsxs("div",{style:{display:"flex",gap:6},children:[i.jsx("input",{type:"text","data-testid":"g7le-computed-custom-index",value:e.index??"",placeholder:"0",onChange:g=>a(m=>{m.index=g.target.value}),style:ro}),i.jsx("div",{"data-testid":"g7le-computed-custom-prop",style:{flex:1,minWidth:0},children:i.jsx(Ke,{value:e.prop??"",onChange:g=>a(m=>{m.prop=g}),t:n,candidates:r,placeholder:n("layout_editor.computed.custom_prop"),testidPrefix:"g7le-computed-custom-prop-chip"})})]}):null,e.op==="literal"?i.jsxs("div",{style:{display:"flex",gap:6},children:[i.jsxs("select",{"data-testid":"g7le-computed-custom-literalkind",value:e.literalKind??"string",onChange:g=>a(m=>{m.literalKind=g.target.value}),style:ro,children:[i.jsx("option",{value:"string",children:n("layout_editor.computed.kind_string")}),i.jsx("option",{value:"number",children:n("layout_editor.computed.kind_number")}),i.jsx("option",{value:"boolean",children:n("layout_editor.computed.kind_boolean")})]}),i.jsx("div",{"data-testid":"g7le-computed-custom-literalvalue",style:{flex:1,minWidth:0},children:i.jsx(Ke,{value:e.literalValue??"",onChange:g=>a(m=>{m.literalValue=g}),t:n,candidates:r,testidPrefix:"g7le-computed-custom-literalvalue-chip"})})]}):null,e.op==="firstOf"?i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[i.jsx("input",{type:"text","data-testid":"g7le-computed-custom-candidates",value:(e.candidates??[]).join(", "),placeholder:n("layout_editor.computed.custom_candidates"),onChange:g=>a(m=>{m.candidates=g.target.value.split(",").map(h=>h.trim()).filter(Boolean)}),style:ro}),i.jsx("div",{"data-testid":"g7le-computed-custom-fallback",style:{minWidth:0},children:i.jsx(Ke,{value:e.fallback??"",onChange:g=>a(m=>{m.fallback=g}),t:n,candidates:r,placeholder:n("layout_editor.computed.custom_fallback"),testidPrefix:"g7le-computed-custom-fallback-chip"})})]}):null,I1.has(e.op)?i.jsxs("div",{style:N1,children:[l.map((g,m)=>i.jsxs("div",{"data-testid":`g7le-computed-custom-cond-${m}`,style:M1,children:[i.jsx("div",{"data-testid":`g7le-computed-custom-cond-field-${m}`,style:{flex:1,minWidth:0},children:i.jsx(Ke,{value:g.field,onChange:h=>f(m,v=>{v.field=h}),t:n,candidates:r,placeholder:n("layout_editor.computed.cond_field"),testidPrefix:`g7le-computed-custom-cond-field-${m}-chip`})}),i.jsx("select",{value:g.cmp,onChange:h=>f(m,v=>{v.cmp=h.target.value}),style:L1,children:E1.map(h=>i.jsx("option",{value:h,children:h},h))}),i.jsx("div",{"data-testid":`g7le-computed-custom-cond-value-${m}`,style:{flex:1,minWidth:0},children:i.jsx(Ke,{value:g.value,onChange:h=>f(m,v=>{v.value=h}),t:n,candidates:r,placeholder:n("layout_editor.computed.cond_value"),testidPrefix:`g7le-computed-custom-cond-value-${m}-chip`})}),i.jsx("button",{type:"button","data-testid":`g7le-computed-custom-cond-remove-${m}`,onClick:()=>b(m),style:P1,children:"✕"})]},m)),i.jsxs("button",{type:"button","data-testid":"g7le-computed-custom-cond-add",onClick:p,style:O1,children:["+ ",n("layout_editor.computed.cond_add")]})]}):null]}),i.jsxs(Os,{label:`③ ${n("layout_editor.computed.custom_step3")}`,children:[i.jsx("input",{type:"text","data-testid":"g7le-computed-custom-key",value:e.key,onChange:g=>a(m=>{m.key=g.target.value}),style:{...ro,...c?z1:{}}}),c?i.jsxs("p",{"data-testid":"g7le-computed-custom-key-dup",style:B1,children:["⚠ ",n("layout_editor.computed.key_duplicate")]}):null]})]})}function Os({label:e,children:t}){return i.jsxs("div",{style:T1,children:[i.jsx("div",{style:D1,children:e}),i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,minWidth:0},children:t})]})}function Bs(e){return Zm(e)}const A1={display:"flex",flexDirection:"column",gap:12,padding:10,border:"1px solid #cbd5e1",borderRadius:8,background:"#fff"},T1={display:"flex",flexDirection:"column",gap:4,minWidth:0},D1={fontSize:12,fontWeight:600,color:"#475569"},ro={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,minWidth:0,width:"100%",boxSizing:"border-box"},z1={border:"1px solid #ef4444"},N1={display:"flex",flexDirection:"column",gap:6,marginTop:4},M1={display:"flex",gap:4,alignItems:"center",minWidth:0},L1={padding:"4px 6px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6},P1={border:"none",background:"transparent",color:"#94a3b8",cursor:"pointer",fontSize:12},O1={alignSelf:"flex-start",padding:"2px 8px",fontSize:11,border:"1px dashed #94a3b8",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},B1={margin:0,fontSize:11,color:"#b45309"};function Ws(e,t,n){return typeof e!="string"?n:e.startsWith("$t:")?t(e.slice(3)):e}function W1(e){if(e&&typeof e=="object"){const t=e.__source;if(t&&typeof t=="object")return t}return null}function j1({computed:e,onChange:t,recipes:n,t:o,sampleContext:r,dataSourceCandidates:s,bindingCandidates:a,computedSource:l={},effectKeys:d=[],onRevert:c}){const p=u.useMemo(()=>Cd(n),[n]),[f,b]=u.useState(!1),[g,m]=u.useState(null),h=Object.keys(e),v=u.useCallback((x,$)=>{t({...e,[x]:$})},[e,t]),y=u.useCallback(x=>{const $={...e};delete $[x],t($)},[e,t]),_=u.useCallback((x,$,S)=>{const C={...e};x&&x!==$&&delete C[x],C[$]=S,t(C)},[e,t]),w=u.useCallback(x=>{const $=Ed(x,{});let S=x.id,C=1;for(;S in e;)S=`${x.id}${++C}`;t({...e,[S]:$}),b(!1)},[e,t]),k=u.useCallback(()=>{!g||!g.key||(t({...e,[g.key]:Bs(g)}),m(null),b(!1))},[g,e,t]);return i.jsxs("div",{className:"g7le-computed-form","data-testid":"g7le-computed-form",style:V1,children:[i.jsx("p",{style:U1,children:o("layout_editor.page_settings.computed.heading")}),h.length>0?h.map(x=>i.jsx(H1,{computedKey:x,expr:e[x],recipes:p,rawRecipes:n,t:o,sampleContext:r,dataSourceCandidates:s,bindingCandidates:a,source:l[x],isEffect:d.includes(x),existingKeys:h,onPatchExpr:$=>v(x,$),onRename:($,S)=>_(x,$,S),onRemove:()=>y(x),onRevert:c?()=>c(x):void 0},x)):i.jsx("p",{"data-testid":"g7le-computed-empty",style:gS,children:o("layout_editor.computed.empty")}),i.jsxs("div",{style:{minWidth:0},children:[i.jsxs("button",{type:"button","data-testid":"g7le-computed-add",onClick:()=>b(x=>!x),style:sS,children:["+ ",o("layout_editor.computed.add")," ▾"]}),f?i.jsxs("div",{"data-testid":"g7le-computed-add-list",style:aS,children:[["common","more"].map(x=>{const $=p.filter(S=>(S.group??"more")===x);return $.length===0?null:i.jsxs("div",{children:[i.jsxs("div",{style:lS,children:["━━ ",o(`layout_editor.computed.group_${x}`)," ━━"]}),$.map(S=>{const C=W1(n?.[S.id]);return i.jsxs("button",{type:"button","data-testid":`g7le-computed-preset-${S.id}`,onClick:()=>w(S),style:dS,children:[i.jsx("span",{style:cS,children:Ws(S.label,o,S.id)}),C&&C.kind!=="core"?i.jsxs("span",{"data-testid":`g7le-computed-preset-source-${S.id}`,style:uS,children:["〔",C.id??C.kind,"〕"]}):null]},S.id)})]},x)}),i.jsxs("div",{style:{borderTop:"1px solid #e2e8f0",marginTop:6,paddingTop:6},children:[i.jsxs("button",{type:"button","data-testid":"g7le-computed-custom-open",onClick:()=>m(g?null:{key:"",op:"count",source:"",conditions:[]}),style:pS,children:["⚙ ",o("layout_editor.computed.custom_open")," ▾"]}),g?i.jsxs("div",{style:{marginTop:6},children:[i.jsx(pu,{model:g,onChange:m,t:o,dataSourceCandidates:s,bindingCandidates:a,existingKeys:h}),i.jsx("div",{"data-testid":"g7le-computed-custom-preview",style:{marginTop:6},children:i.jsx(uu,{expr:Bs(g),sampleContext:r,t:o,testIdPrefix:"g7le-computed-custom-preview-eval"})}),i.jsx("button",{type:"button","data-testid":"g7le-computed-custom-commit",disabled:!g.key||h.includes(g.key),onClick:k,style:fS,children:o("layout_editor.computed.custom_add")})]}):null]})]}):null]})]})}function H1({computedKey:e,expr:t,recipes:n,rawRecipes:o,t:r,sampleContext:s,dataSourceCandidates:a,bindingCandidates:l,source:d,isEffect:c,existingKeys:p,onPatchExpr:f,onRename:b,onRemove:g,onRevert:m}){const[h,v]=u.useState(!1),[y,_]=u.useState(!1),w=u.useMemo(()=>Dd(t,n),[t,n]),k=d==="base",x=d==="route-override",$=w.kind==="advanced",S=w.kind==="preset"?n.find(E=>E.id===w.recipeId)??null:null,C=S?Ws(S.label,r,e):e,T=(E,A)=>{if(w.kind!=="preset"||!S)return;const N={...w.params,[E]:A};f(Ed(S,N))};return i.jsxs("div",{"data-testid":`g7le-computed-item-${e}`,style:q1,children:[i.jsxs("div",{style:G1,children:[i.jsx("span",{style:Y1,children:C}),i.jsx("code",{style:X1,children:e}),k?i.jsxs("span",{"data-testid":`g7le-computed-source-${e}`,style:J1,children:["〔",r("layout_editor.computed.source_base"),"〕"]}):null,x?i.jsxs("span",{"data-testid":`g7le-computed-overridden-${e}`,style:Z1,children:["〔",r("layout_editor.computed.source_overridden"),"〕"]}):null,$?i.jsxs("span",{"data-testid":"g7le-computed-advanced",style:Q1,children:["[",r("layout_editor.action.advanced"),"]"]}):null,i.jsx("span",{style:{flex:1}}),i.jsx("button",{type:"button","data-testid":`g7le-computed-code-${e}`,onClick:()=>_(E=>!E),style:js,"aria-label":r("layout_editor.value_tree.show_source"),title:r("layout_editor.value_tree.show_source"),children:""}),$?null:i.jsx("button",{type:"button","data-testid":`g7le-computed-edit-${e}`,onClick:()=>v(E=>!E),style:js,children:r("layout_editor.init_actions.edit")}),i.jsx("button",{type:"button","data-testid":`g7le-computed-remove-${e}`,onClick:g,style:js,"aria-label":r("layout_editor.init_actions.remove"),children:"✕"})]}),y?i.jsx("pre",{"data-testid":`g7le-computed-code-block-${e}`,style:hS,children:t}):null,i.jsx("div",{"data-testid":`g7le-computed-preview-${e}`,children:i.jsx(uu,{expr:t,computedKey:e,sampleContext:s,t:r,isEffect:c,testIdPrefix:`g7le-computed-preview-${e}-eval`})}),x&&m?i.jsxs("div",{style:R1,children:[i.jsxs("span",{style:eS,children:["ⓘ ",r("layout_editor.computed.overridden_hint")]}),i.jsx("button",{type:"button","data-testid":`g7le-computed-revert-${e}`,onClick:m,style:tS,children:r("layout_editor.computed.revert")})]}):null,h&&!$?i.jsxs("div",{style:nS,children:[k?i.jsxs("p",{"data-testid":`g7le-computed-override-notice-${e}`,style:oS,children:["⚠ ",r("layout_editor.computed.override_notice")]}):null,w.kind==="preset"&&S?i.jsx(i.Fragment,{children:S.params.map(E=>i.jsx(K1,{param:E,value:w.params[E.key]??"",t:r,dataSourceCandidates:a,bindingCandidates:l,onChange:A=>T(E.key,A)},E.key))}):w.kind==="custom"?i.jsx(pu,{model:{...w.model,key:e},onChange:E=>b(E.key,Bs(E)),t:r,dataSourceCandidates:a,bindingCandidates:l,existingKeys:p.filter(E=>E!==e)}):null]}):null]})}const F1=new Set(["datasource-picker","binding-picker","select","toggle","state-key-picker","page-picker"]);function K1({param:e,value:t,t:n,dataSourceCandidates:o,bindingCandidates:r,onChange:s}){const a=Ws(e.label,n,e.key),l=e.widget??"",c=F1.has(l)?Tn(e.widget):null,p=l==="datasource-picker"||l==="binding-picker"?o:void 0;return i.jsxs("div",{"data-testid":`g7le-computed-param-${e.key}`,style:rS,children:[i.jsx("span",{style:iS,children:a}),i.jsx("div",{style:{flex:1,minWidth:0},children:c?i.jsx(c,{control:{...e},value:t,onChange:f=>s(typeof f=="string"?f:""),t:n,candidates:p}):i.jsx(Ke,{value:t,onChange:f=>s(f),t:n,candidates:r,testidPrefix:`g7le-computed-param-${e.key}-chip`})})]})}const V1={display:"flex",flexDirection:"column",gap:12,minWidth:0},U1={margin:0,fontSize:13,fontWeight:700,color:"#0f172a"},q1={border:"1px solid #e2e8f0",borderRadius:8,padding:"8px 10px",display:"flex",flexDirection:"column",gap:6,background:"#f8fafc"},G1={display:"flex",alignItems:"center",gap:6},Y1={fontSize:13,fontWeight:600,color:"#0f172a"},X1={fontSize:10,color:"#64748b",fontFamily:"monospace"},J1={fontSize:10,color:"#0891b2",whiteSpace:"nowrap"},Z1={fontSize:10,color:"#7c3aed",whiteSpace:"nowrap"},Q1={fontSize:10,color:"#92400e",whiteSpace:"nowrap"},R1={display:"flex",alignItems:"center",gap:8,marginTop:4,minWidth:0},eS={fontSize:11,color:"#7c3aed",flex:1,minWidth:0},tS={border:"1px solid #c4b5fd",borderRadius:6,background:"#f5f3ff",color:"#6d28d9",cursor:"pointer",fontSize:11,padding:"2px 8px",whiteSpace:"nowrap"},js={border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",fontSize:11,padding:"2px 6px"},nS={display:"flex",flexDirection:"column",gap:6,paddingTop:6,borderTop:"1px dashed #e2e8f0"},oS={margin:0,fontSize:11,color:"#b45309",background:"#fef3c7",padding:"6px 8px",borderRadius:6},rS={display:"flex",alignItems:"center",gap:8,minWidth:0},iS={fontSize:11,color:"#64748b",minWidth:90},sS={padding:"6px 12px",fontSize:12,border:"1px dashed #94a3b8",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},aS={marginTop:6,border:"1px solid #cbd5e1",borderRadius:8,background:"#fff",padding:8,maxHeight:380,overflowY:"auto"},lS={fontSize:11,fontWeight:700,color:"#94a3b8",padding:"6px 4px 2px"},dS={display:"flex",alignItems:"center",gap:6,width:"100%",textAlign:"left",padding:"6px 8px",fontSize:12,border:"none",background:"transparent",cursor:"pointer",borderRadius:6},cS={flex:1,minWidth:0,color:"#0f172a"},uS={fontSize:10,color:"#64748b",whiteSpace:"nowrap"},pS={padding:"6px 10px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer"},fS={marginTop:6,padding:"6px 12px",fontSize:12,border:"1px solid #3b82f6",borderRadius:6,background:"#3b82f6",color:"#fff",cursor:"pointer"},gS={margin:0,fontSize:12,color:"#94a3b8"},hS={margin:"2px 0 0",padding:"6px 8px",fontSize:11,fontFamily:"monospace",color:"#0f172a",background:"#f1f5f9",border:"1px solid #e2e8f0",borderRadius:6,whiteSpace:"pre-wrap",wordBreak:"break-all",overflowX:"auto"};function yS(e,t){return t==="any"?!0:e===null||typeof e!="object"?!1:t==="object"?!Array.isArray(e):!0}function Hs({value:e,onChange:t,onValidityChange:n,t:o,shape:r="any",emptyValue:s=void 0,placeholder:a,minHeight:l=80,testidPrefix:d="g7le-json-block",shapeErrorKey:c,invalidErrorKey:p,ariaLabel:f,id:b,validate:g}){const[m,h]=u.useState(()=>Kr(e)),[v,y]=u.useState(null),_=u.useRef(!1),w=u.useRef(e);u.useEffect(()=>{if(!_.current&&!Object.is(e,w.current)){if(Kr(e)===Kr(w.current)){w.current=e;return}h(Kr(e)),y(null),w.current=e,n?.(!0)}},[e]);const k=x=>{if(_.current=!0,h(x),x.trim()===""){y(null),w.current=s,n?.(!0),t(s);return}let $;try{$=JSON.parse(x)}catch{y(o(p??"layout_editor.json_block.invalid")),n?.(!1);return}if(!yS($,r)){y(o(c??"layout_editor.json_block.invalid")),n?.(!1);return}const S=g?.($)??null;if(S){y(S),n?.(!1);return}y(null),w.current=$,n?.(!0),t($)};return i.jsxs("div",{className:"g7le-json-block",style:bS,children:[i.jsx("textarea",{id:b,"data-testid":d,style:{...mS,minHeight:l},value:m,spellCheck:!1,"aria-label":f,"aria-invalid":v?!0:void 0,placeholder:a,onChange:x=>k(x.target.value),onBlur:()=>{_.current=!1}}),v?i.jsx("div",{"data-testid":`${d}-error`,style:vS,children:v}):null]})}function Kr(e){if(e===void 0)return"";try{return JSON.stringify(e,null,2)??""}catch{return""}}const bS={display:"flex",flexDirection:"column",gap:4,minWidth:0},mS={width:"100%",boxSizing:"border-box",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:12,lineHeight:1.5,color:"#0f172a",background:"#fff",border:"1px solid #cbd5e1",borderRadius:6,padding:"6px 8px",resize:"vertical"},vS={fontSize:11,color:"#dc2626"},_S=[{kind:"string",labelKey:"layout_editor.initstate.kind_string"},{kind:"number",labelKey:"layout_editor.initstate.kind_number"},{kind:"boolean",labelKey:"layout_editor.initstate.kind_boolean"},{kind:"null",labelKey:"layout_editor.initstate.kind_null"},{kind:"list",labelKey:"layout_editor.initstate.kind_list"},{kind:"object",labelKey:"layout_editor.initstate.kind_object"}],Fs={local:"initLocal",global:"initGlobal",isolated:"initIsolated"};function xS({raw:e,own:t,patch:n,t:o,isolatedOrphan:r={}}){const s=u.useMemo(()=>{const f=t?.state&&typeof t.state=="object"?t.state:void 0,b=e?.state&&typeof e.state=="object"?e.state:void 0;if(!(!f&&!b))return{...b??{},...f??{}}},[t,e]),{initLocal:a,migrated:l}=u.useMemo(()=>K0({initLocal:e?.initLocal,state:s}),[e,s]),d=f=>{if(f==="local")return a;const b=e?.[Fs[f]];return b&&typeof b=="object"?b:{}},c=f=>{if(f==="local"){const b=t?.initLocal??{},g=s?Object.keys(s):[];return Array.from(new Set([...Object.keys(b),...g]))}return Object.keys(t?.[Fs[f]]??{})},p=u.useCallback((f,b)=>{const g=Fs[f];f==="local"&&l&&n("state",void 0),n(g,Object.keys(b).length===0?void 0:b)},[n,l]);return i.jsxs("div",{className:"g7le-initstate-form","data-testid":"g7le-initstate-form",style:kS,children:[i.jsx("p",{style:SS,children:o("layout_editor.page_settings.initstate.heading")}),l?i.jsxs("p",{"data-testid":"g7le-initstate-legacy-state",style:CS,children:["ⓘ ",o("layout_editor.initstate.legacy_state")]}):null,i.jsx(Ks,{scope:"local",label:o("layout_editor.initstate.section_local"),value:d("local"),ownKeys:c("local"),patchSection:p,t:o}),i.jsx(Ks,{scope:"global",label:o("layout_editor.initstate.section_global"),value:d("global"),ownKeys:c("global"),patchSection:p,t:o}),i.jsx(Ks,{scope:"isolated",label:o("layout_editor.initstate.section_isolated"),description:o("layout_editor.initstate.section_isolated_desc"),value:d("isolated"),ownKeys:c("isolated"),patchSection:p,t:o,orphan:r}),i.jsxs("p",{style:KS,children:["ⓘ ",o("layout_editor.initstate.isolated_dynamic_hint")]})]})}function Ks({scope:e,label:t,description:n,value:o,ownKeys:r,patchSection:s,t:a,orphan:l={}}){const[d,c]=u.useState(""),[p,f]=u.useState("string"),[b,g]=u.useState(null),[m,h]=u.useState(!1),v=Object.keys(o),y=v,_=(x,$)=>{s(e,{...o,[x]:$})},w=x=>{const $={...o};delete $[x],s(e,$)},k=()=>{const x=d.trim();if(!x){g(a("layout_editor.initstate.name_required"));return}if(!Ds(x)){g(a("layout_editor.initstate.name_invalid"));return}if(x in o){g(a("layout_editor.initstate.name_duplicate"));return}const $={string:"",number:0,boolean:!1,null:null,list:[],object:{}};s(e,{...o,[x]:$[p]}),c(""),g(null)};return i.jsxs("div",{"data-testid":`g7le-initstate-section-${e}`,style:$S,children:[i.jsxs("div",{style:ES,children:[i.jsx("div",{style:IS,children:t}),i.jsx("button",{type:"button","data-testid":`g7le-initstate-${e}-mode-toggle`,onClick:()=>h(x=>!x),style:TS,children:a(m?"layout_editor.json_block.mode_block":"layout_editor.json_block.mode_code")})]}),n?i.jsxs("p",{style:AS,children:["ⓘ ",n]}):null,m?i.jsx(Hs,{value:o,shape:"object",emptyValue:{},onChange:x=>s(e,x??{}),t:a,testidPrefix:`g7le-initstate-${e}-code`,placeholder:`{ +var RM=Object.defineProperty;var e5=(un,i,u)=>i in un?RM(un,i,{enumerable:!0,configurable:!0,writable:!0,value:u}):un[i]=u;var Bi=(un,i,u)=>e5(un,typeof i!="symbol"?i+"":i,u);(function(un,i,u,En){"use strict";function Lt(){const e=typeof window<"u"?window.G7Core?.__runtime:void 0;if(!e)throw new Error("[layout-editor] window.G7Core.__runtime 이 없습니다. 코어 번들(template-engine.min.js)이 편집기 번들보다 먼저 로드되어야 합니다.");return e}const Wi=Lt();Wi.TranslationProvider;const et=Wi.useTranslation;Wi.TranslationReactContext;function rt(){return typeof window>"u"?null:window.__g7Devtools??null}function zl(e,t){const n=rt();if(!n?.trackEditorState)return;const o={templateIdentifier:e.templateIdentifier,editMode:e.editMode,selectedRoutePath:e.selectedRoute?.path??null,selectedLayoutName:e.selectedRoute?.layoutName??null,routeTreeSize:e.routeTree.length,isRouteTreeCollapsed:e.isRouteTreeCollapsed,locale:e.locale,previewDevice:e.previewDevice,previewZoom:e.previewZoom,lastAction:t,timestamp:Date.now()};try{n.trackEditorState(o)}catch{}}function gy(){const e=rt();if(e?.clearEditorStateData)try{e.clearEditorStateData()}catch{}}function hy(e){const t=rt();if(t?.trackEditorSampleMatch)try{t.trackEditorSampleMatch(e)}catch{}}function yy(){const e=rt();if(e?.clearEditorSampleData)try{e.clearEditorSampleData()}catch{}}function by(e){const t=rt();if(t?.trackEditorHistoryEntry)try{t.trackEditorHistoryEntry(e)}catch{}}function my(){const e=rt();if(e?.clearEditorHistoryData)try{e.clearEditorHistoryData()}catch{}}function Nl(e){const t=rt();if(t?.trackEditorSelection)try{t.trackEditorSelection(e)}catch{}}function vy(){const e=rt();if(e?.clearEditorSelectionData)try{e.clearEditorSelectionData()}catch{}}function pr(e){const t=rt();if(t?.trackEditorPropertyPatch)try{t.trackEditorPropertyPatch(e)}catch{}}function pn(e){const t=rt();if(t?.trackEditorDnd)try{t.trackEditorDnd(e)}catch{}}function _y(){const e=rt();if(e?.clearEditorDndData)try{e.clearEditorDndData()}catch{}}function st(e){const t=rt();if(t?.trackEditorDocument)try{t.trackEditorDocument(e)}catch{}}function xy(){const e=rt();if(e?.clearEditorDocumentData)try{e.clearEditorDocumentData()}catch{}}function wy(e){const t=rt();if(t?.trackEditorSpecMerge)try{t.trackEditorSpecMerge(e)}catch{}}function ky(){const e=rt();if(e?.clearEditorSpecMergeData)try{e.clearEditorSpecMergeData()}catch{}}function ji(e){let t=5381;for(let n=0;n>>0;return t}function Et(e){const t=rt();if(t?.trackEditorI18n)try{t.trackEditorI18n(e)}catch{}}function Sy(){const e=rt();if(e?.clearEditorI18nData)try{e.clearEditorI18nData()}catch{}}function Ml(e){const t=rt();if(t?.trackPageState)try{t.trackPageState(e)}catch{}}function Cy(){const e=rt();if(e?.clearPageStateData)try{e.clearPageStateData()}catch{}}const Ll="g7le.routeTree.collapsed";function $y(){if(typeof window>"u")return!1;try{return window.localStorage?.getItem(Ll)==="1"}catch{return!1}}function Ey(e){if(!(typeof window>"u"))try{window.localStorage?.setItem(Ll,e?"1":"0")}catch{}}function Iy(e,t){return{templateIdentifier:e,routeTree:[],routesError:null,selectedRoute:null,isRouteTreeCollapsed:$y(),editMode:"route",returnRoute:null,returnEditMode:null,locale:t,previewDevice:"desktop",previewZoom:1,previewCustomWidth:1024,previewColorScheme:"light",history:{canUndo:!1,canRedo:!1},isPaletteOpen:!1,availableStates:[],activeStateId:null,layoutVersions:{},extensionVersions:{}}}function Ay(e,t){switch(t.type){case"SET_ROUTE_TREE":return{...e,routeTree:t.tree,routesError:null};case"SET_ROUTES_ERROR":return{...e,routesError:t.error};case"SELECT_ROUTE":return{...e,editMode:"route",selectedRoute:t.route,returnRoute:null,returnEditMode:null};case"TOGGLE_ROUTE_TREE":return{...e,isRouteTreeCollapsed:!e.isRouteTreeCollapsed};case"SET_LOCALE":return{...e,locale:t.locale};case"ENTER_BASE_EDIT":return{...e,editMode:"base",returnRoute:t.returnRoute!==void 0?t.returnRoute:e.selectedRoute,selectedRoute:{path:`__base__/${t.layoutName}`,layoutName:t.layoutName}};case"EXIT_BASE_EDIT":return{...e,editMode:"route",selectedRoute:e.returnRoute,returnRoute:null};case"ENTER_MODAL_EDIT":return{...e,editMode:"modal",returnRoute:t.returnRoute!==void 0?t.returnRoute:e.selectedRoute,selectedRoute:{path:`__modal__/${t.modalId}`,layoutName:t.hostLayout}};case"EXIT_MODAL_EDIT":return{...e,editMode:"route",selectedRoute:e.returnRoute,returnRoute:null};case"ENTER_EXTENSION_EDIT":return{...e,editMode:"extension",returnRoute:t.returnRoute!==void 0?t.returnRoute:e.selectedRoute,selectedRoute:{path:`__extension__/${t.extensionId}`,layoutName:t.extensionHost??null}};case"SET_RETURN_ROUTE":return e.editMode==="route"||e.returnRoute!==null?e:{...e,returnRoute:t.route};case"EXIT_EXTENSION_EDIT":return{...e,editMode:"route",selectedRoute:e.returnRoute,returnRoute:null};case"ENTER_ITERATION_ITEM_EDIT":return{...e,editMode:"iteration_item",returnRoute:t.returnRoute!==void 0?t.returnRoute:e.selectedRoute,returnEditMode:e.editMode,selectedRoute:{path:`__iteration__/${t.sourcePath}`,layoutName:t.hostLayout??e.selectedRoute?.layoutName??null}};case"EXIT_ITERATION_ITEM_EDIT":return{...e,editMode:e.returnEditMode??"route",selectedRoute:e.returnRoute,returnRoute:null,returnEditMode:null};case"SET_PREVIEW_DEVICE":return{...e,previewDevice:t.device};case"SET_PREVIEW_ZOOM":return{...e,previewZoom:t.zoom};case"SET_PREVIEW_CUSTOM_WIDTH":return{...e,previewCustomWidth:t.width};case"SET_PREVIEW_COLOR_SCHEME":return{...e,previewColorScheme:t.scheme};case"TOGGLE_PALETTE":return{...e,isPaletteOpen:!e.isPaletteOpen};case"SET_PALETTE_OPEN":return{...e,isPaletteOpen:t.open};case"SET_AVAILABLE_STATES":return{...e,availableStates:t.states,activeStateId:t.activeStateId};case"SET_ACTIVE_STATE":return{...e,activeStateId:t.activeStateId};case"SET_LAYOUT_VERSIONS":return{...e,layoutVersions:t.versions};case"SET_LAYOUT_VERSION":return{...e,layoutVersions:{...e.layoutVersions,[t.layoutName]:t.version}};case"SET_EXTENSION_VERSIONS":return{...e,extensionVersions:t.versions};case"SET_EXTENSION_VERSION":return{...e,extensionVersions:{...e.extensionVersions,[t.extensionId]:t.version}};default:return e}}function Ty(e,t){const n=Ay(e,t);return((n.selectedRoute?.path??null)!==(e.selectedRoute?.path??null)||n.editMode!==e.editMode)&&(n.availableStates.length>0||n.activeStateId!==null)?{...n,availableStates:[],activeStateId:null}:n}const Pl=u.createContext(null);function Dy(e,t){const n=Ty(e,t);return zl(n,t.type),n}function zy({templateIdentifier:e,initialLocale:t,children:n}){const[o,r]=u.useReducer(Dy,void 0,()=>{const a=Iy(e,t);return zl(a,void 0),a});u.useEffect(()=>{Ey(o.isRouteTreeCollapsed)},[o.isRouteTreeCollapsed]);const s=u.useMemo(()=>({state:o,dispatch:r}),[o]);return u.createElement(Pl.Provider,{value:s},n)}function Qe(){const e=u.useContext(Pl);if(!e)throw new Error("useLayoutEditor must be used within LayoutEditorProvider");return e}const Ol=u.createContext(null);function Ny({value:e,children:t}){return u.createElement(Ol.Provider,{value:e},t)}function Kt(){return u.useContext(Ol)}const Hi=u.createContext(null);let My=1;function Ly({children:e,t}){const[n,o]=u.useState([]),r=u.useRef([]),[s,a]=u.useState({}),l=u.useCallback(y=>{const _=y.id??`editor-modal-${My++}`,w={id:_,content:y.content,ariaLabel:y.ariaLabel??"",closeOnBackdrop:y.closeOnBackdrop??!0,closeOnEscape:y.closeOnEscape??!0,width:y.width??"auto",height:y.height??"auto",maxHeightRatio:y.maxHeightRatio??.85,draggable:y.draggable??!1,avoidRect:y.avoidRect,onClose:y.onClose};return o(k=>{const $=[...k.filter(C=>C.id!==_),w];return r.current=$,$}),_},[]),d=u.useCallback(y=>{o(_=>{const w=_.find(x=>x.id===y),k=_.filter(x=>x.id!==y);return r.current=k,w?.onClose&&queueMicrotask(()=>w.onClose?.()),k})},[]),c=u.useCallback(()=>{const y=r.current[r.current.length-1];y&&d(y.id)},[d]),p=u.useCallback(()=>{o(y=>{for(let _=y.length-1;_>=0;_--){const w=y[_];w?.onClose&&queueMicrotask(()=>w.onClose?.())}return r.current=[],[]})},[]),f=u.useCallback((y,_)=>{a(w=>{const k=r.current.find($=>$.id===y),x=_??k?.ariaLabel??"";return{...w,[y]:x}})},[]),b=u.useCallback(y=>{a(_=>{if(!(y in _))return _;const w={..._};return delete w[y],w})},[]),g=u.useCallback(y=>{b(y),d(y)},[b,d]),m=u.useCallback(()=>{a({}),p()},[p]),h=u.useMemo(()=>Object.keys(s),[s]),v=u.useMemo(()=>({open:l,close:g,closeTop:c,closeAll:m,stack:n,minimize:f,restore:b,minimizedStack:h}),[l,g,c,m,n,f,b,h]);return u.createElement(Hi.Provider,{value:v},e,u.createElement(Oy,{minimized:s,onRestore:b,t,key:"__min_bar"}))}function vo(){const e=u.useContext(Hi);if(!e)throw new Error("useEditorModal must be used within EditorModalProvider");return e}function Py(){const e=u.useContext(Hi);if(!e)return null;const{stack:t,close:n,minimizedStack:o}=e,r=u.useMemo(()=>new Set(o),[o]);return u.useEffect(()=>{if(t.length===0)return;const s=a=>{if(a.key!=="Escape"&&a.key!=="Esc")return;const l=t.filter(c=>!r.has(c.id)),d=l[l.length-1];d?.closeOnEscape&&(a.preventDefault(),a.stopPropagation(),n(d.id))};return window.addEventListener("keydown",s,!0),()=>window.removeEventListener("keydown",s,!0)},[t,n,r]),t.length===0?null:i.jsx(i.Fragment,{children:t.map((s,a)=>i.jsx(Wy,{entry:s,depth:a,hidden:r.has(s.id),onClose:()=>n(s.id)},s.id))})}function Oy({minimized:e,onRestore:t,t:n}){const o=n??(s=>s),r=Object.keys(e);return r.length===0?null:i.jsx("div",{className:"g7le-minimized-bar","data-testid":"g7le-minimized-bar",style:{position:"fixed",left:16,bottom:16,display:"flex",gap:8,zIndex:9300},children:r.map(s=>i.jsxs("button",{type:"button","data-testid":`g7le-minimized-${s}`,onClick:()=>t(s),style:{display:"flex",alignItems:"center",gap:6,padding:"8px 12px",background:"#1e293b",color:"#fff",border:"none",borderRadius:8,boxShadow:"0 8px 24px rgba(15, 23, 42, 0.3)",cursor:"pointer",fontSize:13},children:[i.jsx("span",{"aria-hidden":"true",children:"🗗"}),i.jsx("span",{children:e[s]||o("layout_editor.modal.minimized_default")}),i.jsx("span",{style:{opacity:.7},children:o("layout_editor.modal.restore")})]},s))})}function By(e,t,n){if(!e||typeof window>"u")return null;const o=window.innerWidth,r=window.innerHeight,s=16,a=e.left,l=o-(e.left+e.width),d=t+s;let c;if(l>=a&&l>=d)c=e.left+e.width+s;else if(a>=d)c=Math.max(s,e.left-s-t);else return null;c=Math.min(Math.max(s,c),Math.max(s,o-t-s));let p=e.top;return p=Math.min(Math.max(s,p),Math.max(s,r-n-s)),{left:c,top:p}}const Bl="clamp(16px, 6vh, 56px)";function Wy({entry:e,depth:t,hidden:n,onClose:o}){const r=9100+t*10,s=e.maxHeightRatio>0?`${e.maxHeightRatio*100}vh`:void 0,a=e.draggable?s:`calc(100vh - (${Bl}) * 2)`,[l,d]=u.useState(null),c=u.useRef(null),p=u.useRef(null);u.useEffect(()=>{if(!e.draggable)return;const v=c.current;if(!v)return;const y=v.getBoundingClientRect(),_=By(e.avoidRect,y.width,y.height);_&&d(_)},[e.id,e.draggable]);const f=u.useCallback(v=>{if(!e.draggable)return;const y=v.target;if(!y.closest("[data-modal-drag-handle]")||y.closest("button, a, input, textarea, select"))return;const w=c.current,k=w?.getBoundingClientRect(),x=l?.left??k?.left??0,$=l?.top??k?.top??0;p.current={startX:v.clientX,startY:v.clientY,baseLeft:x,baseTop:$};const C=D=>{const E=p.current;if(!E)return;const I=window.innerWidth,N=window.innerHeight,T=w?.offsetWidth??0,B=w?.offsetHeight??0;let M=E.baseLeft+(D.clientX-E.startX),O=E.baseTop+(D.clientY-E.startY);M=Math.min(Math.max(0,M),Math.max(0,I-T)),O=Math.min(Math.max(0,O),Math.max(0,N-B)),d({left:M,top:O})},S=()=>{p.current=null,window.removeEventListener("pointermove",C),window.removeEventListener("pointerup",S)};window.addEventListener("pointermove",C),window.addEventListener("pointerup",S)},[e.draggable,l]),b=v=>{e.closeOnBackdrop&&v.target===v.currentTarget&&o()},g=e.draggable&&l!==null,m=e.draggable?{position:"fixed",inset:0,background:"transparent",pointerEvents:"none",zIndex:r,...n?{display:"none"}:{}}:{position:"fixed",inset:0,background:"rgba(15, 23, 42, 0.45)",display:n?"none":"flex",alignItems:"flex-start",justifyContent:"center",paddingTop:Bl,boxSizing:"border-box",zIndex:r},h={background:"#fff",borderRadius:10,boxShadow:"0 20px 60px rgba(15, 23, 42, 0.25)",width:e.width,height:e.height,maxHeight:a,maxWidth:"92vw",overflow:"hidden",display:"flex",flexDirection:"column",...e.draggable?{position:"absolute",pointerEvents:"auto",left:g?l.left:"50%",top:g?l.top:"50%",transform:g?void 0:"translate(-50%, -50%)"}:{}};return i.jsx("div",{className:"g7le-modal-backdrop",role:"presentation","data-testid":`g7le-modal-backdrop-${e.id}`,"data-draggable":e.draggable?"true":"false",onClick:b,style:m,children:i.jsx("div",{ref:c,className:"g7le-modal",role:"dialog","aria-modal":"true","aria-label":e.ariaLabel||void 0,"data-testid":`g7le-modal-${e.id}`,"data-positioned":g?"true":"false",onClick:v=>v.stopPropagation(),onPointerDown:e.draggable?f:void 0,style:h,children:e.content})})}function ht({baseStyle:e,hoverStyle:t,disabled:n,style:o,children:r,...s}){const[a,l]=u.useState(!1),d={outline:"none",...e,...o,...a&&!n?t:{}};return i.jsx("button",{type:"button",disabled:n,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:d,...s,children:r})}function jy({templateIdentifier:e,templateName:t,templateVersion:n,templateList:o,onSwitch:r}){const{t:s}=et(),[a,l]=u.useState(!1),[d,c]=u.useState(!1),p=u.useRef(null);u.useEffect(()=>{if(!a)return;const v=_=>{p.current&&!p.current.contains(_.target)&&l(!1)},y=_=>{_.key==="Escape"&&l(!1)};return document.addEventListener("mousedown",v),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("keydown",y)}},[a]);const f=o??[],b=f.some(v=>v.identifier!==e),g=!!r&&b,m=t||e,h=v=>{if(v===e){l(!1);return}l(!1),r?.(v)};return i.jsxs("div",{ref:p,className:"g7le-toolbar__template-switcher",style:{position:"relative",display:"inline-flex"},children:[i.jsxs("button",{type:"button",className:"g7le-toolbar__template","data-testid":"g7le-toolbar-template-label","data-can-switch":g?"true":"false","aria-haspopup":g?"listbox":void 0,"aria-expanded":g?a:void 0,disabled:!g,onClick:()=>g&&l(v=>!v),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),title:g?s("layout_editor.chrome.toolbar.switch_template"):m,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"4px 8px",fontSize:13,fontWeight:600,color:"#0f172a",letterSpacing:.1,borderRadius:6,borderWidth:1,borderStyle:"solid",borderColor:g&&(d||a)?"#cbd5e1":"transparent",backgroundColor:g&&(d||a)?"#f1f5f9":"transparent",cursor:g?"pointer":"default",outline:"none",transition:"background-color 120ms, border-color 120ms"},children:[i.jsx("span",{className:"g7le-toolbar__template-name","data-testid":"g7le-toolbar-template-name",children:m}),n&&i.jsxs("span",{className:"g7le-toolbar__template-version","data-testid":"g7le-toolbar-template-version",style:{fontSize:11,fontWeight:500,color:"#64748b",padding:"1px 6px",borderRadius:999,background:"#f1f5f9",border:"1px solid #e2e8f0"},children:["v",n]}),g&&i.jsx("span",{className:"g7le-toolbar__template-caret","aria-hidden":"true",style:{fontSize:9,color:"#94a3b8",marginLeft:1},children:"▼"})]}),g&&a&&i.jsx("div",{className:"g7le-toolbar__template-menu","data-testid":"g7le-toolbar-template-menu",role:"listbox",style:{position:"absolute",top:"calc(100% + 4px)",left:0,minWidth:240,maxWidth:360,maxHeight:360,overflowY:"auto",background:"#ffffff",border:"1px solid #e2e8f0",borderRadius:8,boxShadow:"0 8px 24px rgba(15, 23, 42, 0.14)",zIndex:30,padding:4},children:f.map(v=>{const y=v.identifier===e;return i.jsxs("button",{type:"button",role:"option","aria-selected":y,"aria-current":y?"true":void 0,className:"g7le-toolbar__template-menu-item","data-testid":"g7le-toolbar-template-menu-item","data-identifier":v.identifier,"data-current":y?"true":"false",onClick:()=>h(v.identifier),style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,width:"100%",padding:"8px 10px",fontSize:13,color:"#1e293b",background:y?"#eff6ff":"transparent",border:"none",borderRadius:6,cursor:y?"default":"pointer",textAlign:"left",outline:"none"},onMouseEnter:_=>{y||(_.currentTarget.style.background="#f1f5f9")},onMouseLeave:_=>{_.currentTarget.style.background=y?"#eff6ff":"transparent"},children:[i.jsxs("span",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[i.jsx("span",{"aria-hidden":"true",style:{width:12,flex:"0 0 auto",color:"#2563eb",fontSize:12,textAlign:"center"},children:y?"✓":""}),i.jsxs("span",{style:{display:"flex",flexDirection:"column",gap:2,minWidth:0},children:[i.jsx("span",{style:{fontWeight:600,color:y?"#1d4ed8":"#1e293b",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:v.name||v.identifier}),i.jsx("span",{style:{fontSize:11,color:"#94a3b8",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:v.identifier})]})]}),i.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,flex:"0 0 auto"},children:[i.jsx("span",{style:{fontSize:10,fontWeight:600,color:v.type==="admin"?"#7c3aed":"#0891b2",textTransform:"uppercase",letterSpacing:.4},children:v.type}),v.version&&i.jsxs("span",{style:{fontSize:11,color:"#64748b"},children:["v",v.version]})]})]},v.identifier)})})]})}function Hy(e={}){const{onSave:t,isDirty:n=!1,onExit:o,onEditCode:r,onManageImages:s,onManageTranslations:a,onPageSettings:l,onReset:d,onShowShortcuts:c,onPreview:p,onShowVersions:f,templateName:b,templateVersion:g,templateList:m,onSwitchTemplate:h,onToggleCustomAssets:v,customAssetsDisabled:y=!1,onManageCustomAssets:_}=e,[w,k]=u.useState(!1),[x,$]=u.useState(!1),{t:C}=et(),{state:S,dispatch:D}=Qe(),[E,I]=u.useState(null);u.useEffect(()=>{const V=()=>{const Z=window.__g7LayoutEditorHistory;I(Z?{undo:Z.undo,redo:Z.redo,canUndo:!!Z.canUndo,canRedo:!!Z.canRedo}:null)};V();const X=window.setInterval(V,250);return()=>window.clearInterval(X)},[]);const N=()=>{D({type:"TOGGLE_ROUTE_TREE"})},T=()=>S.editMode==="base"?C("layout_editor.chrome.toolbar.mode_badge.base"):S.editMode==="modal"?C("layout_editor.chrome.toolbar.mode_badge.modal"):S.editMode==="extension"?C("layout_editor.chrome.toolbar.mode_badge.extension"):S.editMode==="iteration_item"?C("layout_editor.chrome.toolbar.mode_badge.iteration_item"):null,B=()=>{S.editMode==="base"?D({type:"EXIT_BASE_EDIT"}):S.editMode==="modal"?D({type:"EXIT_MODAL_EDIT"}):S.editMode==="extension"?D({type:"EXIT_EXTENSION_EDIT"}):S.editMode==="iteration_item"&&D({type:"EXIT_ITERATION_ITEM_EDIT"})},M=T(),O=S.editMode!=="route",z={display:"inline-flex",alignItems:"center",gap:6,padding:"6px 12px",fontSize:13,fontWeight:500,borderRadius:6,borderWidth:1,borderStyle:"solid",borderColor:"transparent",backgroundColor:"transparent",color:"#475569",cursor:"pointer",transition:"background-color 120ms, color 120ms, border-color 120ms"},H={...z,backgroundColor:"#2563eb",color:"#ffffff",borderColor:"#2563eb",fontWeight:600},P={backgroundColor:"#fef3c7",borderColor:"#f59e0b",color:"#92400e",fontWeight:600},A={...z,borderColor:"#e2e8f0",backgroundColor:"#ffffff",color:"#0f172a"},L={backgroundColor:"#f1f5f9",color:"#0f172a",borderColor:"#cbd5e1"},F={backgroundColor:"#1d4ed8",borderColor:"#1d4ed8"},Y={backgroundColor:"#f8fafc",borderColor:"#cbd5e1"};return i.jsxs("div",{className:"g7le-toolbar","data-testid":"g7le-toolbar",role:"toolbar",style:{display:"flex",alignItems:"center",gap:6,padding:"8px 12px",borderBottom:"1px solid #e2e8f0",background:"#ffffff",boxShadow:"0 1px 2px rgba(15, 23, 42, 0.04)"},children:[i.jsx("style",{children:"@keyframes g7le-spin { to { transform: rotate(360deg); } }.g7le-toolbar > * { flex-shrink: 0; white-space: nowrap; }"}),i.jsx("button",{type:"button",className:"g7le-toolbar__route-tree-toggle","data-testid":"g7le-toolbar-toggle-route-tree","aria-label":C("layout_editor.chrome.toolbar.toggle_route_tree"),title:C("layout_editor.chrome.toolbar.toggle_route_tree"),onClick:N,style:{...z,outline:"none",padding:"6px 10px",fontSize:16,lineHeight:1,color:"#64748b"},children:"☰"}),i.jsx(jy,{templateIdentifier:S.templateIdentifier,templateName:b,templateVersion:g,templateList:m,onSwitch:h}),M&&i.jsx("span",{className:"g7le-toolbar__mode-badge","data-testid":"g7le-toolbar-mode-badge","data-mode":S.editMode,style:{padding:"2px 8px",borderRadius:999,background:"#fef3c7",color:"#92400e",fontSize:11,fontWeight:600,border:"1px solid #fde68a"},children:M}),i.jsx("div",{style:{flex:1}}),i.jsxs(i.Fragment,{children:[i.jsx(ht,{"data-testid":"g7le-toolbar-undo","aria-label":C("layout_editor.chrome.toolbar.undo"),title:C("layout_editor.chrome.toolbar.undo"),disabled:!E?.canUndo,onClick:()=>E?.undo?.(),baseStyle:z,hoverStyle:L,style:{opacity:E?.canUndo?1:.4},children:"↶"}),i.jsx(ht,{"data-testid":"g7le-toolbar-redo","aria-label":C("layout_editor.chrome.toolbar.redo"),title:C("layout_editor.chrome.toolbar.redo"),disabled:!E?.canRedo,onClick:()=>E?.redo?.(),baseStyle:z,hoverStyle:L,style:{opacity:E?.canRedo?1:.4},children:"↷"}),i.jsxs(ht,{"data-testid":"g7le-toolbar-add-element","data-open":S.isPaletteOpen?"true":"false",disabled:!S.selectedRoute,onClick:()=>D({type:"TOGGLE_PALETTE"}),"aria-pressed":S.isPaletteOpen,baseStyle:z,hoverStyle:L,style:S.isPaletteOpen?{backgroundColor:"#eff6ff",color:"#1d4ed8",borderColor:"#93c5fd"}:void 0,children:["+ ",C("layout_editor.chrome.toolbar.add_element")]}),i.jsx(ht,{"data-testid":"g7le-toolbar-preview","data-previewing":x?"true":"false",disabled:!p||!S.selectedRoute?.layoutName||x,onClick:()=>{const V=p?.();V&&typeof V.then=="function"&&($(!0),V.finally(()=>$(!1)))},baseStyle:z,hoverStyle:L,style:{opacity:x?.7:1},children:x?i.jsxs(i.Fragment,{children:[i.jsx("span",{"data-testid":"g7le-toolbar-preview-spinner","aria-hidden":"true",style:{display:"inline-block",width:12,height:12,border:"2px solid rgba(71,85,105,0.35)",borderTopColor:"#475569",borderRadius:"50%",animation:"g7le-spin 600ms linear infinite"}}),C("layout_editor.chrome.toolbar.previewing")]}):i.jsxs(i.Fragment,{children:["👁 ",C("layout_editor.chrome.toolbar.preview")]})}),i.jsxs(ht,{"data-testid":"g7le-toolbar-versions",disabled:!f||!(S.selectedRoute?.layoutName||S.selectedRoute?.path?.startsWith("__extension__/")),onClick:()=>f?.(),"aria-label":C("layout_editor.chrome.toolbar.version_history"),title:C("layout_editor.chrome.toolbar.version_history"),baseStyle:z,hoverStyle:L,children:["🕘 ",C("layout_editor.chrome.toolbar.version_history")]}),i.jsxs(ht,{"data-testid":"g7le-toolbar-edit-code",disabled:!r,onClick:()=>r?.(),baseStyle:z,hoverStyle:L,children:["⟨/⟩ ",C("layout_editor.chrome.toolbar.edit_code")]}),i.jsxs(ht,{"data-testid":"g7le-toolbar-images",disabled:!s||!S.selectedRoute,onClick:()=>s?.(),baseStyle:z,hoverStyle:L,children:["🖼 ",C("layout_editor.chrome.toolbar.images")]}),i.jsxs(ht,{"data-testid":"g7le-toolbar-translations",disabled:!a||!S.selectedRoute,onClick:()=>a?.(),baseStyle:z,hoverStyle:L,children:["🌐 ",C("layout_editor.chrome.toolbar.translations")]}),i.jsxs(ht,{"data-testid":"g7le-toolbar-custom-assets",disabled:!_,onClick:()=>_?.(),title:C("layout_editor.chrome.toolbar.custom_assets_hint"),baseStyle:z,hoverStyle:L,children:["🎨 ",C("layout_editor.chrome.toolbar.custom_assets")]}),i.jsxs(ht,{"data-testid":"g7le-toolbar-toggle-custom-assets","data-custom-disabled":y?"true":"false",disabled:!v,onClick:()=>v?.(),"aria-pressed":y,title:C(y?"layout_editor.chrome.toolbar.custom_assets_on_hint":"layout_editor.chrome.toolbar.custom_assets_off_hint"),baseStyle:z,hoverStyle:L,style:y?{...z,...P}:void 0,children:[y?"👁":"🚫"," ",C(y?"layout_editor.chrome.toolbar.custom_assets_on":"layout_editor.chrome.toolbar.custom_assets_off")]}),i.jsxs(ht,{"data-testid":"g7le-toolbar-page-settings",disabled:!l||!S.selectedRoute||S.editMode==="extension"||S.editMode==="iteration_item",onClick:()=>l?.(),baseStyle:z,hoverStyle:L,children:["⚙ ",C("layout_editor.chrome.toolbar.page_settings")]}),i.jsxs(ht,{"data-testid":"g7le-toolbar-reset",disabled:!d||!n,onClick:()=>d?.(),"aria-label":C("layout_editor.chrome.toolbar.reset"),title:C("layout_editor.chrome.toolbar.reset"),baseStyle:z,hoverStyle:L,style:{opacity:n?1:.4},children:["↺ ",C("layout_editor.chrome.toolbar.reset")]}),i.jsx(ht,{"data-testid":"g7le-toolbar-save","data-dirty":n?"true":"false","data-saving":w?"true":"false",disabled:!t||w,onClick:()=>{const V=t?.();V&&typeof V.then=="function"&&(k(!0),V.finally(()=>k(!1)))},baseStyle:H,hoverStyle:F,style:{opacity:w?.7:n?1:.7},children:w?i.jsxs(i.Fragment,{children:[i.jsx("span",{"data-testid":"g7le-toolbar-save-spinner","aria-hidden":"true",className:"g7le-toolbar__spinner",style:{display:"inline-block",width:12,height:12,border:"2px solid rgba(255,255,255,0.4)",borderTopColor:"#ffffff",borderRadius:"50%",animation:"g7le-spin 600ms linear infinite"}}),C("layout_editor.chrome.toolbar.saving")]}):i.jsxs(i.Fragment,{children:["💾 ",C("layout_editor.chrome.toolbar.save")]})}),i.jsx(ht,{"data-testid":"g7le-toolbar-shortcuts",disabled:!c,onClick:()=>c?.(),"aria-label":C("layout_editor.shortcuts.title"),title:C("layout_editor.shortcuts.title"),baseStyle:z,hoverStyle:L,children:"⌨"}),i.jsxs(ht,{"data-testid":"g7le-toolbar-exit",disabled:!o,onClick:()=>o?.(),baseStyle:A,hoverStyle:Y,children:["✕ ",C("layout_editor.chrome.toolbar.exit")]})]}),O&&i.jsxs(ht,{"data-testid":"g7le-toolbar-exit-alt-mode",onClick:B,baseStyle:A,hoverStyle:Y,children:["← ",S.editMode==="base"&&C("layout_editor.chrome.toolbar.exit_base_edit"),S.editMode==="modal"&&C("layout_editor.chrome.toolbar.exit_modal_edit"),S.editMode==="extension"&&C("layout_editor.chrome.toolbar.exit_extension_edit"),S.editMode==="iteration_item"&&C("layout_editor.chrome.toolbar.exit_iteration_item_edit")]})]})}function fr(){if(typeof window>"u")return null;try{return window.localStorage?.getItem("auth_token")??null}catch{return null}}function Me(e){const t={Accept:"application/json",...e??{}},n=fr();return n&&(t.Authorization=`Bearer ${n}`),t}function Fi(e){return encodeURIComponent(e)}async function Wl(e,t){const n=`/api/admin/templates/${Fi(e)}/layout-attachments?layout_name=${encodeURIComponent(t)}`;try{const o=await fetch(n,{method:"GET",headers:Me(),credentials:"same-origin"}),r=await o.json().catch(()=>null);return!o.ok||!r?.success?{ok:!1,status:o.status,message:Ki(r,o.status)}:{ok:!0,data:Array.isArray(r?.data)?r.data:[]}}catch(o){return{ok:!1,status:0,message:o instanceof Error?o.message:"network error"}}}async function jl(e,t,n){const o=`/api/admin/templates/${Fi(e)}/layout-attachments`,r=new FormData;r.append("file",n),r.append("layout_name",t);try{const s=await fetch(o,{method:"POST",headers:Me(),body:r,credentials:"same-origin"}),a=await s.json().catch(()=>null);return!s.ok||!a?.success||!a?.data?.url?{ok:!1,status:s.status,message:Ki(a,s.status)}:{ok:!0,data:a.data}}catch(s){return{ok:!1,status:0,message:s instanceof Error?s.message:"network error"}}}async function Hl(e){const t=`/api/admin/templates/layout-attachments/${Fi(String(e))}`;try{const n=await fetch(t,{method:"DELETE",headers:Me(),credentials:"same-origin"}),o=await n.json().catch(()=>null);return!n.ok||o&&o.success===!1?{ok:!1,status:n.status,message:Ki(o,n.status)}:{ok:!0,data:!0}}catch(n){return{ok:!1,status:0,message:n instanceof Error?n.message:"network error"}}}function Ki(e,t){if(e&&typeof e=="object"&&"message"in e){const n=e.message;if(typeof n=="string"&&n.length>0)return n}return`HTTP ${t}`}function Fy(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Ky(e){if(!e)return"";const t=e.match(/^(\d{4})-(\d{2})-(\d{2})/);return t?`${t[2]}-${t[3]}`:""}function Fl({templateIdentifier:e,layoutName:t,t:n,onSelect:o,onChanged:r,onClose:s}){const[a,l]=u.useState([]),[d,c]=u.useState("idle"),[p,f]=u.useState(!1),[b,g]=u.useState(null),m=u.useRef(null),h=u.useCallback(async()=>{c("loading"),g(null);const _=await Wl(e,t);_.ok?(l(_.data),c("idle")):(g(_.message),c("error"))},[e,t]);u.useEffect(()=>{h()},[h]);const v=async _=>{const w=_.target.files?.[0];if(!w)return;f(!0),g(null);const k=await jl(e,t,w);k.ok?(l(x=>[k.data,...x.filter($=>$.id!==k.data.id)]),r?.()):g(k.message),f(!1),m.current&&(m.current.value="")},y=async _=>{if(!(typeof window<"u"&&typeof window.confirm=="function"?window.confirm(n("layout_editor.attachment_manager.delete_confirm")):!0))return;const k=await Hl(_.id);k.ok?(l(x=>x.filter($=>$.id!==_.id)),r?.()):g(k.message)};return i.jsxs("div",{className:"g7le-attachment-manager","data-testid":"g7le-attachment-manager",style:Vy,children:[i.jsxs("div",{"data-modal-drag-handle":!0,style:Uy,children:[i.jsx("span",{style:{fontSize:14,fontWeight:700},"data-testid":"g7le-attachment-manager-title",children:n("layout_editor.attachment_manager.title")}),i.jsx("button",{type:"button","aria-label":"close",onClick:s,style:qy,"data-testid":"g7le-attachment-manager-close",children:"✕"})]}),i.jsx("div",{style:Gy,children:i.jsxs("label",{style:Yy,"data-testid":"g7le-attachment-upload",children:[p?"…":`⬆ ${n("layout_editor.attachment_manager.upload")}`,i.jsx("input",{ref:m,type:"file",accept:"image/*",onChange:v,disabled:p,style:{display:"none"},"data-testid":"g7le-attachment-upload-input"})]})}),b&&i.jsx("div",{style:Xy,"data-testid":"g7le-attachment-manager-error",children:b}),i.jsx("div",{style:Jy,children:d==="loading"?i.jsx("div",{style:Kl,"data-testid":"g7le-attachment-manager-loading",children:n("layout_editor.attachment_manager.loading")}):a.length===0&&d!=="error"?i.jsx("div",{style:Kl,"data-testid":"g7le-attachment-manager-empty",children:n("layout_editor.attachment_manager.empty")}):i.jsx("div",{style:Zy,"data-testid":"g7le-attachment-grid",children:a.map(_=>i.jsxs("div",{style:Qy,"data-testid":`g7le-attachment-card-${_.id}`,children:[i.jsx("div",{style:{...Ry,backgroundImage:`url(${_.url})`}}),i.jsx("div",{style:eb,title:_.original_name,children:_.original_name}),i.jsxs("div",{style:tb,children:[Fy(_.size),_.created_at?` · ${Ky(_.created_at)}`:""]}),i.jsxs("div",{style:nb,children:[o&&i.jsx("button",{type:"button",onClick:()=>o(_.url),style:ob,"data-testid":`g7le-attachment-use-${_.id}`,children:n("layout_editor.attachment_manager.use_as_bg")}),i.jsx("button",{type:"button",onClick:()=>y(_),style:rb,"data-testid":`g7le-attachment-delete-${_.id}`,children:"🗑"})]})]},_.id))})}),i.jsx("div",{style:ib,children:i.jsx("button",{type:"button",onClick:s,style:sb,"data-testid":"g7le-attachment-manager-footer-close",children:n("layout_editor.attachment_manager.close")})})]})}const Vy={display:"flex",flexDirection:"column",minHeight:0,flex:1},Uy={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:"1px solid #e2e8f0"},qy={border:"none",background:"transparent",fontSize:16,color:"#94a3b8",cursor:"pointer"},Gy={padding:"10px 16px",borderBottom:"1px solid #f1f5f9",display:"flex",gap:8},Yy={padding:"6px 12px",fontSize:13,border:"1px solid #2563eb",borderRadius:6,background:"#fff",color:"#2563eb",cursor:"pointer",display:"inline-flex",alignItems:"center"},Xy={padding:"8px 16px",fontSize:12,color:"#b91c1c",background:"#fef2f2"},Jy={padding:16,overflow:"auto",flex:1,minHeight:120},Kl={fontSize:13,color:"#94a3b8",textAlign:"center",padding:"32px 0"},Zy={display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(140px, 1fr))",gap:12},Qy={display:"flex",flexDirection:"column",gap:4,border:"1px solid #e2e8f0",borderRadius:8,padding:8},Ry={width:"100%",height:88,borderRadius:6,border:"1px solid #cbd5e1",backgroundSize:"cover",backgroundPosition:"center",backgroundColor:"#f8fafc"},eb={fontSize:12,fontWeight:600,color:"#0f172a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},tb={fontSize:11,color:"#64748b"},nb={display:"flex",gap:6,marginTop:2},ob={flex:1,padding:"4px 6px",fontSize:11,border:"1px solid #2563eb",borderRadius:6,background:"#2563eb",color:"#fff",cursor:"pointer"},rb={padding:"4px 8px",fontSize:12,border:"1px solid #fecaca",borderRadius:6,background:"#fff",color:"#dc2626",cursor:"pointer"},ib={padding:"10px 16px",borderTop:"1px solid #e2e8f0",display:"flex",justifyContent:"flex-end"},sb={padding:"6px 14px",fontSize:13,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"};function gr(e){return encodeURIComponent(e)}async function ab(e,t,n){const o=new URLSearchParams;t&&o.set("layout_name",t);const r=o.toString(),s=`/api/admin/templates/${gr(e)}/custom-translations`+(r?`?${r}`:"");try{const a=await fetch(s,{method:"GET",headers:Me(),credentials:"same-origin"}),l=await a.json().catch(()=>null);return!a.ok||!l?.success?{ok:!1,status:a.status,message:hr(l,a.status)}:{ok:!0,data:Array.isArray(l?.data)?l.data:[]}}catch(a){return{ok:!1,status:0,message:a instanceof Error?a.message:"network error"}}}async function lb(e,t,n,o){const r=`/api/admin/templates/${gr(e)}/custom-translations/${t}`;try{const s=await fetch(r,{method:"PUT",headers:Me({"Content-Type":"application/json"}),body:JSON.stringify({values:n,expected_lock_version:o}),credentials:"same-origin"}),a=await s.json().catch(()=>null);return!s.ok||!a?.success||!a?.data?{ok:!1,status:s.status,message:hr(a,s.status)}:{ok:!0,data:a.data}}catch(s){return{ok:!1,status:0,message:s instanceof Error?s.message:"network error"}}}async function db(e,t){const n=`/api/admin/templates/${gr(e)}/custom-translations/${t}`;try{const o=await fetch(n,{method:"DELETE",headers:Me(),credentials:"same-origin"}),r=await o.json().catch(()=>null);return!o.ok||r&&r.success===!1?{ok:!1,status:o.status,message:hr(r,o.status)}:{ok:!0,data:!0}}catch(o){return{ok:!1,status:0,message:o instanceof Error?o.message:"network error"}}}async function cb(e,t){const n=`/api/admin/templates/${gr(e)}/custom-translations`;try{const o=await fetch(n,{method:"DELETE",headers:Me({"Content-Type":"application/json"}),body:JSON.stringify({ids:t}),credentials:"same-origin"}),r=await o.json().catch(()=>null);return!o.ok||!r?.success?{ok:!1,status:o.status,message:hr(r,o.status)}:{ok:!0,data:{deleted:typeof r?.data?.deleted=="number"?r.data.deleted:t.length}}}catch(o){return{ok:!1,status:0,message:o instanceof Error?o.message:"network error"}}}const Vl=/\$t:(custom\.[A-Za-z0-9_\-]+\.\d+)/g;function ub(e){const t=new Set,n=o=>{if(typeof o=="string"){if(o.includes("$t:custom.")){let r;for(Vl.lastIndex=0;(r=Vl.exec(o))!==null;)t.add(r[1])}return}if(Array.isArray(o)){for(const r of o)n(r);return}if(o&&typeof o=="object")for(const r of Object.values(o))n(r)};return n(e),t}function hr(e,t){if(e&&typeof e=="object"&&"message"in e){const n=e.message;if(typeof n=="string"&&n.length>0)return n}return`HTTP ${t}`}const Pt=Lt().TranslationEngine,_o=Lt().createLogger,Vi=_o("EditorSpecLoader"),pb=["controls","componentCapabilities","actionRecipes","conditionRecipes","pageSettings","initActionRecipes","errorRecipes","computedRecipes","loadingComponents"],fb=["actionRecipes","initActionRecipes","errorRecipes","computedRecipes","loadingComponents"];function Ul(e){if(typeof window>"u")return[];const n=window.G7Config?.[e];if(!Array.isArray(n))return[];const o=[];for(const r of n){const s=r?.identifier;typeof s=="string"&&s.length>0&&o.push(s)}return o}async function gb(e,t,n,o){const s=`${n}/${e==="template"?"templates":e==="module"?"modules":"plugins"}/${encodeURIComponent(t)}/editor-spec`;try{const a=await o(s);if(!a.ok)return a.status!==404&&Vi.warn(`fetchOneSpec: HTTP ${a.status}`,s),null;const l=await a.json();return!l?.success||!l.data?null:l.data.spec??null}catch(a){return Vi.warn("fetchOneSpec: fetch failed",s,a),null}}function hb(e){return fb.includes(e)}function yb(e,t){return e==null||typeof e!="object"?e:{...e,__source:t}}function bb(e,t,n,o){const r=t[n];if(!r||typeof r!="object")return;const s=e[n]??{};if(o&&hb(n)){const a={};for(const[l,d]of Object.entries(r))a[l]=yb(d,o);e[n]={...s,...a};return}e[n]={...s,...r}}function mb(e,t){if(!t.nesting)return;const n=e.nesting??{},o=new Set(n.draggable??[]);for(const r of t.nesting.draggable??[])o.add(r);n.draggable=Array.from(o),n.containers={...n.containers??{},...t.nesting.containers??{}},e.nesting=n}function vb(e,t){if(!t.componentPalette)return;const n=e.componentPalette??{},o=[...n.groups??[],...t.componentPalette.groups??[]];n.groups=o,n.entries={...n.entries??{},...t.componentPalette.entries??{}},e.componentPalette=n}function _b(e,t){if(!t.states)return;const n=e.states??{},o=[...n.groups??[],...t.states.groups??[]];n.groups=o,e.states=n}function xb(e,t){if(!Array.isArray(t.stateLabels)||t.stateLabels.length===0)return;const n=[...e.stateLabels??[],...t.stateLabels],o=new Map;for(const r of n)!r||typeof r.key!="string"||typeof r.scope!="string"||o.set(`${r.scope}:${r.key}`,r);e.stateLabels=Array.from(o.values())}function wb(e,t){if(!t.actionChipCandidates)return;const n=e.actionChipCandidates??{};for(const o of["response","error","payload"]){const r=t.actionChipCandidates[o];!Array.isArray(r)||r.length===0||(n[o]=[...n[o]??[],...r])}e.actionChipCandidates=n}function kb(e,t){if(!t.sampleData)return;const n=e.sampleData??{};n.byDataSourceId={...n.byDataSourceId??{},...t.sampleData.byDataSourceId??{}},n.byEndpointPattern={...n.byEndpointPattern??{},...t.sampleData.byEndpointPattern??{}},e.sampleData=n}function ql(e,t,n){for(const o of pb)bb(e,t,o,n);mb(e,t),vb(e,t),_b(e,t),xb(e,t),wb(e,t),kb(e,t),t.version&&(e.version=t.version)}async function Sb(e){const t=e.apiBaseUrl??"/api",n=e.fetcher??(typeof fetch<"u"?fetch:void 0);if(!n)return Vi.warn("loadEditorSpecBundle: fetch unavailable, returning null spec"),{spec:null,sampleGlobalSources:[]};const o=e.activeModuleIdentifiers??Ul("activeModules"),r=e.activePluginIdentifiers??Ul("activePlugins"),s=[...o.map(p=>({kind:"module",id:p})),...r.map(p=>({kind:"plugin",id:p})),{kind:"template",id:e.templateIdentifier}],a=await Promise.all(s.map(p=>gb(p.kind,p.id,t,n)));let l=null;const d=[],c={};if(e.coreSeed&&(l={},ql(l,e.coreSeed,{kind:"core"})),s.forEach((p,f)=>{const b=a[f];if(!b)return;b.sampleGlobal&&typeof b.sampleGlobal=="object"&&d.push({id:p.id,kind:p.kind,sampleGlobal:b.sampleGlobal});const g=b.sampleData?.byDataSourceId;if(g&&typeof g=="object"){const m=p.kind==="template"?"template":`${p.kind}:${p.id}`;c[m]={...c[m]??{},...g}}l===null&&(l={}),ql(l,b,{kind:p.kind,id:p.id})}),l!==null&&Object.keys(c).length>0){const p=l;p.sampleData={...p.sampleData??{},bySource:c}}return{spec:l,sampleGlobalSources:d}}function Ui(e,t){return e?.componentCapabilities?.[t]??null}function Ct(e,t){return e?.controls?.[t]??null}function Cb(e){return e?.initActionRecipes??{}}function $b(e){return e?.computedRecipes??{}}function Eb(e){return e?.errorRecipes??{}}function Ib(e){const t=e?.loadingComponents;return!t||typeof t!="object"?[]:Object.values(t).filter(n=>n!=null&&typeof n=="object"&&typeof n.name=="string")}function Ab(e,t,n){const o=e?.stateLabels;if(!Array.isArray(o))return null;for(const r of o)if(r?.scope===t&&r?.key===n)return typeof r.label_key=="string"?r.label_key:null;return null}function qi(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Tb(e){return e===null?"null":typeof e=="string"?e.length>40?`${e.slice(0,40)}…`:e:typeof e=="number"||typeof e=="boolean"?String(e):""}function Db(e){const t=e.find(n=>qi(n));if(qi(t))return Object.keys(t).slice(0,8)}function zb(e){return Object.keys(e).slice(0,8)}function Nb(e){const t=Object.entries(e);return t.length===0?!1:t.some(([,n])=>n===null||typeof n!="object")}function Gi(e,t,n,o,r){if(Array.isArray(e)){r(t,"array",`[${e.length}]`,Db(e));return}if(qi(e)){if(t&&Nb(e)){const s=zb(e);r(t,"object",`{${s.length}}`,s)}if(n>=o)return;for(const[s,a]of Object.entries(e)){const l=t?`${t}.${s}`:s;Gi(a,l,n+1,o,r)}return}r(t,"scalar",Tb(e))}function Mb(e,t,n){const o=[];let r=e;for(const s of t){if(!r||(r=(Array.isArray(r.children)?r.children:[])[s],!r))break;const l=r.iteration;if(!(!l||l.source===void 0)&&(typeof l.index_var=="string"&&l.index_var.length>0&&o.push({name:l.index_var,kind:"index"}),typeof l.item_var=="string"&&l.item_var.length>0)){const d=typeof l.source=="string"?l.source:"",c=d&&n?.get(Gl(d))||[];o.push({name:l.item_var,kind:"item",itemFields:c})}}return o}function Gl(e){return e.replace(/^\{\{|\}\}$/g,"").trim()}function Lb(e){const t=new Map;for(const n of e)n.shape==="array"&&n.itemFields&&n.itemFields.length>0&&t.set(Gl(n.expression),n.itemFields);return t}function Yi(e){const t=e.maxDepth??4,n=[];for(const o of e.dataSources??[])!o||typeof o.id!="string"||o.id.length===0||Gi(o.sample,"",0,t,(r,s,a,l)=>{const d=r?`{{${o.id}.${r}}}`:`{{${o.id}}}`;n.push({expression:d,source:"data_source",sourceId:o.id,path:r,shape:s,groupLabelKey:o.labelKey?.startsWith("$t:")?o.labelKey.slice(3):o.labelKey,preview:a,itemFields:l})});for(const o of e.states??[])!o||typeof o.scope!="string"||Gi(o.tree,"",0,t,(r,s,a,l)=>{if(!r)return;const d=Ab(e.spec,o.scope,r)??void 0;n.push({expression:`{{${o.scope}.${r}}}`,source:o.scope,sourceId:o.scope,path:r,shape:s,labelKey:d?.startsWith("$t:")?d.slice(3):d,preview:a,itemFields:l})});for(const o of e.iterationVars??[])if(!(!o||typeof o.name!="string"||o.name.length===0)){if(o.kind==="index"){n.push({expression:`{{${o.name}}}`,source:"iteration",sourceId:o.name,path:"",shape:"scalar",preview:"0"});continue}for(const r of o.itemFields??[])n.push({expression:`{{${o.name}.${r}}}`,source:"iteration",sourceId:o.name,path:r,shape:"scalar",preview:""})}return n}const Pb=["$localized"];function Ob(e){const t=e.trim(),n=t.indexOf("(");if(n===-1||!t.endsWith(")"))return{fn:null,inner:t};const o=t.slice(0,n).trim();if(!Pb.includes(o))return{fn:null,inner:t};const r=t.slice(n+1,-1);let s=0,a=null;for(let l=0;ln.shape===t)}function Zi(e,t){const n=t.trim().toLowerCase();return n===""?e:e.filter(o=>[o.resolvedLabel??"",o.sourceId,o.path,o.preview].join(" ").toLowerCase().includes(n))}function Yl(e,t,n){const o={response:[{path:"data",labelKey:"layout_editor.action_chip.response_data",shape:"object"},{path:"message",labelKey:"layout_editor.action_chip.response_message",shape:"scalar"}],error:[{path:"status",labelKey:"layout_editor.action_chip.error_status",shape:"scalar"},{path:"message",labelKey:"layout_editor.action_chip.error_message",shape:"scalar"},{path:"errors",labelKey:"layout_editor.action_chip.error_errors",shape:"object"},{path:"data",labelKey:"layout_editor.action_chip.error_data",shape:"object"},{path:"statusText",labelKey:"layout_editor.action_chip.error_status_text",shape:"scalar"}],payload:[{path:"data",labelKey:"layout_editor.action_chip.payload_data",shape:"object"}]},r=e==="response"?"response":e==="error"?"error":"message",s=new Set,a=[];for(const d of o[e])s.has(d.path)||(s.add(d.path),a.push(d));const l=n?.[e];if(Array.isArray(l))for(const d of l)!d||typeof d.path!="string"||typeof d.labelKey!="string"||s.has(d.path)||(s.add(d.path),a.push({path:d.path,labelKey:d.labelKey,shape:d.shape??"scalar"}));return a.map(d=>({expression:`{{${r}.${d.path}}}`,source:"_local",sourceId:r,path:d.path,shape:d.shape,labelKey:d.labelKey,preview:t(d.labelKey)}))}const Qi=/\{\{(?:[^}]|\}(?!\}))*\}\}/g;function An(e){const t=[];if(typeof e!="string"||e.length===0)return t;let n=0,o=0;const r=new RegExp(Qi.source,"g");let s;for(;(s=r.exec(e))!==null;){const a=s.index,l=a+s[0].length;a>n&&t.push({kind:"literal",raw:e.slice(n,a),start:n,end:a}),t.push({kind:"binding",raw:s[0],start:a,end:l,parsed:Vt(s[0]),bindingIndex:o++}),n=l}return nt.kind==="binding")}function br(e){return typeof e!="string"?!1:new RegExp(Qi.source).test(e)}function Wb(e){const t=new Set(e.map(o=>o.trim()));let n=0;for(;t.has(`p${n}`);)n+=1;return`p${n}`}function Xl(e,t,n){const o=typeof e=="string"?e:"",r=Math.max(0,Math.min(t,o.length)),s=o.slice(0,r),a=o.slice(r),l=s.length>0&&!/\s$/.test(s)?" ":"",d=a.length>0&&!/^\s/.test(a)?" ":"";return`${s}${l}{${n}}${d}${a}`}function Ri(e,t){const n=typeof e=="string"?e:"";return Tn(n).includes(t)?n:n.length===0?`{${t}}`:/\s$/.test(n)?`${n}{${t}}`:`${n} {${t}}`}function Jl(e){return yr(e).map(t=>({bindingIndex:t.bindingIndex??0,expression:t.raw,parsed:t.parsed??null,isComplex:(t.parsed??null)===null}))}function mr(e){return typeof e!="string"?"":e.replace(new RegExp(Qi.source,"g")," ").replace(/\s+/g," ").trim()}const jb=/\$t:([a-zA-Z0-9._-]+)/g,Zl="custom.";function es(e,t){return typeof e!="string"||e.length===0?typeof e=="string"?e:"":t?An(e).map(n=>n.kind!=="literal"?n.raw:n.raw.replace(jb,(o,r)=>{if(r.startsWith(Zl))return o;const s=t(r);return s&&s!==r?s:o})).join(""):e}const Un="(?:(?!\\|[a-zA-Z0-9_]+=).)*",Hb=new RegExp(`^\\s*\\$t:([a-zA-Z0-9._-]+)((?:\\|[a-zA-Z0-9_]+=${Un})*)`),Fb=new RegExp(`\\|([a-zA-Z0-9_]+)=(${Un})`,"g");function Ut(e){if(typeof e!="string")return"";const t=Vt(e);if(t)return t.path||t.sourceId;const n=e.trim().replace(/^\{\{\s*/,"").replace(/\s*\}\}$/,"");let o=-1;for(let l=0;l0){const l=n.slice(0,o).trim(),d=Vt(`{{${l}}}`);if(d)return d.path||d.sourceId;const c=l.replace(/\?\./g,".").replace(/\s*\?\?.*$/,"").trim();if(/^[A-Za-z_$][\w$.]*$/.test(c)){const p=c.split(".").filter(Boolean);return p.length>1&&p.slice(1).join(".")||c}}const r=n.replace(/\s+/g," ").trim(),s=r.replace(/\s*(\?\?|\|\|)\s*(\[\s*\]|\{\s*\}|'[^']*'|"[^"]*"|\d+|null|undefined)\s*$/,"").trim(),a=/\.([A-Za-z_$][\w$]*)\s*$/.exec(s);return a?a[1]:r}const Ql=/\$(?:core|module|plugin)_settings:[a-zA-Z0-9._:-]+/g;function ts(e){return typeof e=="string"&&new RegExp(Ql.source).test(e)}function Kb(e){return typeof e!="string"?"":e.replace(/^\$(?:core|module|plugin)_settings:/,"").split(/[.:]/).filter(Boolean).pop()||e}function Rl(e){const t=[];for(const n of An(e)){if(n.kind==="binding"){t.push({kind:"chip",label:Ut(n.raw)});continue}let o=0;const r=n.raw,s=new RegExp(Ql.source,"g");let a;for(;(a=s.exec(r))!==null;)a.index>o&&t.push({kind:"text",label:r.slice(o,a.index)}),t.push({kind:"chip",label:Kb(a[0])}),o=a.index+a[0].length;o{const m=`p${o.length}`;return o.push(g),r[m]=Ut(g),`{${m}}`};let a=e,l="";const d=Hb.exec(e);if(d&&!d[1].startsWith(Zl)){const g=d[1],m=d[2]??"",h=e.slice(d[0].length),v=new Map,y=new RegExp(Fb.source,"g");let _;for(;(_=y.exec(m))!==null;)_[2]&&_[2].includes("{{")&&v.set(_[1],_[2]);const w=t?t(g):"";if(w&&w!==g&&!w.startsWith("$t:"))l=w.replace(/\{\{?([a-zA-Z0-9_]+)\}?\}/g,(k,x)=>{const $=v.get(x);return $?s($):k});else return n;a=h}const c=es(a,t),p=An(c).map(g=>g.kind==="binding"?s(g.raw):g.raw).join(""),f=`${l}${p}`;return/\$t:[a-zA-Z0-9._-]+/.test(f)||o.length===0?n:{chipValue:f,bindings:o,paramLabels:r,keyifiable:!0}}function ed(e,t){return t.bindings.length?e+t.bindings.map((n,o)=>`|p${o}=${n}`).join(""):e}function td(e,t){const n=yr(t).map(r=>r.raw);if(n.length===0)return e;const o=n.map((r,s)=>`|p${s}=${r}`).join("");return`${e}${o}`}function nd(e){if(typeof e!="string")return"";const t=An(e);let n=0;return t.map(o=>o.kind==="binding"?`{p${n++}}`:o.raw).join("")}const od=new RegExp(`^\\s*\\$t:([a-zA-Z0-9._-]+)((?:\\|[a-zA-Z0-9_]+=${Un})+)\\s*$`),Ub=new RegExp(`\\|([a-zA-Z0-9_]+)=(${Un})`,"g");function vt(e){if(typeof e!="string")return null;const t=od.exec(e);if(!t)return null;const n=t[1],o=t[2],r=[],s=new RegExp(Ub.source,"g");let a;for(;(a=s.exec(o))!==null;){const l=a[1],d=a[2];r.push({name:l,expression:d,parsed:Vt(d)})}return{key:n,params:r}}function rd(e){return typeof e=="string"&&od.test(e)}function Tn(e){if(typeof e!="string")return[];const t=[],n=/\{\{?(p\d+)\}?\}/g;let o;for(;(o=n.exec(e))!==null;)t.push(o[1]);return t.sort()}function qb(e,t,n){if(typeof e!="string")return e;const o=new RegExp(`(\\|${t}=)${Un}`);return o.test(e)?e.replace(o,`$1${n}`):e}function xo(e,t){if(typeof e!="string")return e;const n=new RegExp(`\\|${t}=${Un}`);return e.replace(n,"")}function id(e,t){return typeof e!="string"?e:e.replace(new RegExp(`\\s*\\{\\{?${t}\\}?\\}\\s*`,"g")," ").replace(/\s+/g," ").trim()}function Gb(e,t){const n=s=>yr(typeof s=="string"?s:"").map(a=>a.raw.replace(/\s+/g,"")).sort(),o=n(e),r=n(t);return o.length!==r.length?!1:o.every((s,a)=>s===r[a])}function sd(e){return e.__source?.kind==="base"}function ad(e){return e.__source?.kind==="partial"}function Yb(e){return e.__source?.kind==="route"}function vr(e,t){return e.__source?.kind!=="extension"?!1:t==null?!0:e.__source.extensionId!==t}function ld(e){return e.type==="extension_point"}function os(e=[]){for(const t of e)if(t.iteration&&t.iteration.source!==void 0)return!0;return!1}function Xb(e,t=[]){for(const n of t)if(n.iteration&&n.iteration.source!==void 0)return!0;return e.iteration&&e.iteration.source!==void 0?!0:dd(e)}function dd(e){if(typeof e.text=="string"&&cd(e.text)&&!Jb(e.text))return!0;if(e.props&&typeof e.props=="object"){for(const t of Object.values(e.props))if(typeof t=="string"&&cd(t))return!0}return!1}function cd(e){return/\{\{[\s\S]*?\}\}/.test(e)}function Jb(e){const t=vt(e);return t!==null&&t.key.startsWith("custom.")}function Zb(e,t){return e??t??null}function ud(e,t,n){if(ld(e))return!0;switch(t){case"route":return sd(e)||ad(e)||vr(e);case"base":return vr(e);case"modal":return vr(e);case"extension":return vr(e,n)?!0:sd(e)||Yb(e)||ad(e);default:return!1}}function tt(e){return typeof e=="object"&&e!==null&&typeof e.responsive=="string"}function _r(e,t){return tt(e)?tt(t)&&e.responsive===t.responsive:!tt(t)&&e===t}function at(e){const t=[];let n=!1;for(const o of e){if(tt(o)){t.push("responsive",o.responsive),n=!0;continue}n?t.push("children",String(o)):(t.push(String(o)),n=!0)}return t.join(".")}function Ot(e){return Array.isArray(e.children)?e.children:[]}function wo(e,t){const n=e.responsive?.[t];return n&&Array.isArray(n.children)?n.children:[]}function Dn(e,t){const n=[];let o=e,r=Ot(e);for(let s=0;s=o.length||(n=o[r],!n))return null;o=Ot(n)}return n}function Qb(e,t,n){if(!e||t.length===0)return t;let o=e,r=Ot(e),s;for(let a=0;a=2?t[t.length-2]:void 0;if(r!==void 0&&tt(r)){const a=Pe(e,t.slice(0,-2));return a?{owner:a,children:wo(a,r.responsive),branchKey:r.responsive,index:o}:null}const s=Pe(e,t.slice(0,-1));return s?{owner:s,children:Ot(s),index:o}:null}function rs(e,t){if(e.branchKey!==void 0){const n={...e.owner.responsive??{}};n[e.branchKey]={...n[e.branchKey]??{},children:t},e.owner.responsive=n}else e.owner.children=t}function tn(e){const t={...e};t.props&&typeof t.props=="object"&&(t.props={...t.props});const n=Ot(e);if(n.length>0&&(t.children=n.map(tn)),e.responsive&&typeof e.responsive=="object"){const o={};for(const r of Object.keys(e.responsive)){const s=e.responsive[r];if(!s||typeof s!="object"){o[r]=s;continue}const a={...s};Array.isArray(s.children)&&(a.children=s.children.map(tn)),a.props&&typeof a.props=="object"&&(a.props={...a.props}),o[r]=a}t.responsive=o}return t}function is(e,t,n,o){const r=tn(e),s=t.length>0?t[t.length-1]:void 0;if(s!==void 0&&tt(s)){const p=Pe(r,t.slice(0,-1));if(!p)return r;const f=wo(p,s.responsive),b=Math.max(0,Math.min(n,f.length)),g=[...f];return g.splice(b,0,o),rs({owner:p,branchKey:s.responsive},g),r}const a=Pe(r,t);if(!a)return r;const l=Ot(a),d=Math.max(0,Math.min(n,l.length)),c=[...l];return c.splice(d,0,o),a.children=c,r}function ss(e,t){if(t.length===0)return e;const n=tn(e),o=pd(n,t);if(!o||o.index<0||o.index>=o.children.length)return n;const r=[...o.children];return r.splice(o.index,1),rs(o,r),n}function Rb(e,t,n,o){if(t.length===0||!n||tt(t[t.length-1]))return e;const r=tn(e),s=Pe(r,t);if(!s)return r;const a=s.responsive&&typeof s.responsive=="object"?s.responsive[n]:void 0;if(a&&Array.isArray(a.children))return r;const l=o&&s.responsive&&typeof s.responsive=="object"?s.responsive[o]:void 0,c=(l&&Array.isArray(l.children)?l.children:Ot(s)).map(tn),p={...s.responsive??{}};return p[n]={...p[n]??{},children:c},s.responsive=p,r}function em(e,t,n){if(t.length===0||!n||tt(t[t.length-1]))return e;const o=tn(e),r=Pe(o,t);if(!r||!r.responsive||typeof r.responsive!="object")return o;const s=r.responsive[n];if(!s||!Array.isArray(s.children))return o;const a={...r.responsive},l={...a[n]};return delete l.children,Object.keys(l).length===0?delete a[n]:a[n]=l,r.responsive=Object.keys(a).length>0?a:void 0,o}function tm(e,t,n,o){if(t.length===0)return e;const r=Pe(e,t);if(!r||nm(t,n))return e;const s=tn(r),a=ss(e,t),l=fd(n,t);let d=o;const c=t.slice(0,-1);if(gd(c,n)){const p=t[t.length-1];(typeof p=="number"?p:0)o){const s=[...e];return s[n]=r-1,s}return e}function gd(e,t){if(e.length!==t.length)return!1;for(let n=0;ne.length||gd(e,t)}function as(e){const t={...e};if(t.props&&typeof t.props=="object"&&(t.props={...t.props}),typeof t.id=="string"&&t.id.length>0){const o=typeof t.name=="string"?t.name:"node";t.id=`${o}_${om()}`}const n=Ot(e);return n.length>0&&(t.children=n.map(as)),t}function Bt(e,t,n){if(t.length===0)return n(e);const o=tn(e),r=Pe(o,t);if(!r)return o;const s=n(r),a=pd(o,t);if(!a||a.index<0||a.index>=a.children.length)return o;const l=[...a.children];return l[a.index]=s,rs(a,l),o}function om(){return Math.floor(Math.random()*2821109907456).toString(36).padStart(8,"0")}function qn(e){if(!Array.isArray(e)||e.length===0)return[];const t=[];for(const n of e){const o=rm(n);o.length>0&&t.push(...o)}return t}function rm(e){if(!e||typeof e!="object")return[];const t=e.__source,n=e._fromBase===!0,o=t?.kind;if(o==="extension"||o==="partial")return[];if(o==="base"||n){const s=Array.isArray(e.children)?e.children:[];return qn(s)}const r={...e};return delete r.__source,delete r._fromBase,delete r.__injectedProps,Array.isArray(r.children)&&(r.children=qn(r.children)),[r]}function ko(e){if(!e||typeof e!="object")return e;const t=e.__editor,n=t&&typeof t=="object"&&!Array.isArray(t)?t.original:void 0,o=n&&typeof n=="object"&&!Array.isArray(n)?n:void 0,r=Array.isArray(e.components)?e.components:[],s=r.length>0,a=qn(r),l=o?{...o}:{...e};if(typeof l.extends=="string"&&l.extends.length>0){delete l.components;const c=l.slots&&typeof l.slots=="object"&&!Array.isArray(l.slots)?l.slots:{},p=Object.keys(c);if(!s&&p.length>0){const f={};for(const[b,g]of Object.entries(c))f[b]=Array.isArray(g)?qn(g):g;l.slots=f}else if(p.length===1)l.slots={[p[0]]:a};else if(p.length===0)l.slots={content:a};else{const f={};for(const[b,g]of Object.entries(c))f[b]=Array.isArray(g)?qn(g):g;l.slots=f}}else l.components=a,delete l.slots;return delete l.lock_version,delete l.__editor,l}const hd="extension",Gn="extensionless";function im(){const e=globalThis?.G7Config;if(globalThis?.__g7AssetUrlMode===Gn)return Gn;const n=e?.assetUrlMode;return n===Gn||n===hd?n:e?.settings?.general?.asset_url_mode===Gn?Gn:hd}function sm(){return im()===Gn}function nn(e,t,n,o){const r=e.replace(/\/+$/,""),s=t.replace(/^\.+/,""),a=sm()?r:`${r}.${s}`,l=[];return o&&l.push(o.replace(/^[?&]+/,"")),n!=null&&n!==""&&l.push(`v=${n}`),l.length>0?`${a}?${l.join("&")}`:a}const yd=/^\s*\$t:([a-zA-Z0-9._-]+)\s*$/,xr="custom.",am=/\{\{.*?\}\}/;function lm(e){return!!(!e||e.iteration&&typeof e.iteration=="object")}function bd(e,t){const n=e?.text,o=typeof n=="string"?n:"";if(lm(e)||typeof n!="string")return{sourceState:"plain_text",editable:!1,customKey:null,displayValue:o};const r=vt(o);if(r&&r.key.startsWith(xr)){const a=t?t(r.key):r.key;return{sourceState:"custom_key",editable:!0,customKey:r.key,displayValue:a,isParamKey:!0}}const s=yd.exec(o);if(s){const a=s[1];if(a.startsWith(xr)){const d=t?t(a):a;return{sourceState:"custom_key",editable:!0,customKey:a,displayValue:d}}const l=t?t(a):"";return{sourceState:"plain_text",editable:!0,customKey:null,displayValue:l&&l!==a?l:""}}if(am.test(o)){const a=mr(o),l=yd.exec(a);if(l&&l[1].startsWith(xr)){const f=l[1],b=t?t(f):f;return{sourceState:"custom_key",editable:!0,customKey:f,displayValue:b}}const d=es(o,t),c=mr(d),p=/\$t:[a-zA-Z0-9._-]+/.test(c);if(c.length>0){const f=ns(o,t);return{sourceState:"plain_with_binding",editable:!0,customKey:null,displayValue:p?"":c,chipValue:f.keyifiable?f.chipValue:void 0,chipParamLabels:f.keyifiable?f.paramLabels:void 0}}return{sourceState:"binding_expression",editable:!1,customKey:null,displayValue:o}}return{sourceState:"plain_text",editable:!0,customKey:null,displayValue:o}}function dm(){const{state:e}=Qe(),t=Kt(),n=e.templateIdentifier,o=e.locale,r=e.selectedRoute?.layoutName??null,s=u.useCallback(p=>{try{const b=Pt.getInstance().translate(p,{templateId:n,locale:o});return b&&b!==p?b:""}catch{return""}},[n,o]),a=u.useCallback(p=>bd(p,s),[s]),l=u.useCallback(p=>{Et({op:"inline_edit_cancel",componentPath:p?at(p):null,timestamp:Date.now()})},[]),d=u.useCallback(async(p,f)=>{if(!t)return{kind:"error",message:"no document context"};const g={children:t.document?.raw?.components??[]},m=Pe(g,p),h=bd(m,s);if(!h.editable)return Et({op:"inline_edit_blocked_binding",sourceState:h.sourceState,componentPath:at(p),timestamp:Date.now()}),{kind:"blocked"};if(h.customKey){if(f===h.displayValue)return{kind:"noop",translationKey:h.customKey};So(n,o,h.customKey,f);const C=await wr(n,h.customKey,o,f);return C.kind==="error"?{kind:"error",message:C.message}:(await on(n,o),Et({op:"inline_edit_update_value",sourceState:"custom_key",componentPath:at(p),translationKey:h.customKey,toLocale:o,valueLength:f.length,valueHash:ji(f),timestamp:Date.now()}),{kind:"updated",translationKey:h.customKey})}const v=typeof m?.text=="string"?m.text:"",y=h.sourceState==="plain_with_binding",_=es(v,s),w=y?nd(_):f,k=C=>y?td(C,v):C;t.patchLayout(C=>Bt({children:C},p,E=>({...E,text:f})).children??[]);const x=await Yn(n,r,o,w);if(x.kind==="error"||!x.resource)return{kind:"error",message:x.message};const $=x.resource.translation_key;return So(n,o,$,w),t.patchLayout(C=>Bt({children:C},p,E=>({...E,text:k(`$t:${$}`)})).children??[]),await on(n,o),Et({op:"inline_edit_create_key",sourceState:h.sourceState,componentPath:at(p),translationKey:$,toLocale:o,valueLength:f.length,valueHash:ji(f),timestamp:Date.now()}),{kind:"created",translationKey:$,id:x.resource.id}},[t,n,o,r,s]),c=u.useCallback(async(p,f)=>{if(!t)return{kind:"error",message:"no document context"};const g={children:t.document?.raw?.components??[]},m=Pe(g,p),h=typeof m?.text=="string"?m.text:"",v=vt(h);if(v&&v.key.startsWith(xr))return kr(n,v.key,o,f),So(n,o,v.key,f),t.markDirty?.(),{kind:"updated",translationKey:v.key};const y=ns(h,s),_=mr(f.replace(/\{\{?p\d+\}?\}/g," ")).replace(/\s+/g," ").trim(),w=await Yn(n,r,o,_);if(w.kind==="error"||!w.resource)return{kind:"error",message:w.message};const k=w.resource.translation_key,x=Tn(f),$=w.resource.values??{},C={[o]:f};for(const S of Object.keys($)){if(S===o)continue;let D=$[S]??"";for(const E of x)D=Ri(D,E);C[S]=D}return Co(n,k,C),So(n,o,k,f),t.patchLayout(S=>Bt({children:S},p,I=>({...I,text:ed(`$t:${k}`,y)})).children??[]),t.markDirty?.(),await on(n,o),So(n,o,k,f),Et({op:"inline_edit_create_key",sourceState:"plain_with_binding",componentPath:at(p),translationKey:k,toLocale:o,valueLength:f.length,valueHash:ji(f),timestamp:Date.now()}),{kind:"created",translationKey:k}},[t,n,o,r]);return{classify:a,commit:d,trackCancel:l,keyifyChipValue:c}}async function Yn(e,t,n,o){const r=`/api/admin/templates/${encodeURIComponent(e)}/custom-translations`;try{const s=await fetch(r,{method:"POST",credentials:"same-origin",headers:Me({"Content-Type":"application/json"}),body:JSON.stringify({layout_name:t,locale:n,value:o})}),a=await s.json().catch(()=>null);if(!s.ok)return{kind:"error",message:a?.message??`HTTP ${s.status}`};const l=a?.data;return!l||typeof l.translation_key!="string"?{kind:"error",message:"invalid response"}:{kind:"ok",resource:l}}catch(s){return{kind:"error",message:s instanceof Error?s.message:"network error"}}}async function wr(e,t,n,o){const r=await fn(e,t);if(!r)return{kind:"error",message:"custom key not found"};const s=`/api/admin/templates/${encodeURIComponent(e)}/custom-translations/${r.id}`,a={...r.values??{},[n]:o};try{const l=await fetch(s,{method:"PUT",credentials:"same-origin",headers:Me({"Content-Type":"application/json"}),body:JSON.stringify({values:a,expected_lock_version:r.lock_version})}),d=await l.json().catch(()=>null);return l.status===409?{kind:"error",message:"concurrent_modification"}:l.ok?{kind:"ok"}:{kind:"error",message:d?.message??`HTTP ${l.status}`}}catch(l){return{kind:"error",message:l instanceof Error?l.message:"network error"}}}async function fn(e,t){const n=`/api/admin/templates/${encodeURIComponent(e)}/custom-translations`;try{const o=await fetch(n,{method:"GET",credentials:"same-origin",headers:Me()});if(!o.ok)return null;const s=(await o.json().catch(()=>null))?.data;return Array.isArray(s)?s.find(a=>a.translation_key===t)??null:null}catch{return null}}function So(e,t,n,o){try{Pt.getInstance().setTranslationValue(e,t,n,o)}catch{}if(typeof window<"u")try{window.dispatchEvent(new CustomEvent(kt,{detail:{templateIdentifier:e,locale:t}}))}catch{}}const kt="g7le:translations-refreshed";async function on(e,t){if(typeof window>"u")return;const n=t??window.__g7EditorContentLocale;if(n){try{const o=Pt.getInstance();try{const r=await fetch(nn(`/api/templates/${encodeURIComponent(e)}/config`,"json"),{headers:{Accept:"application/json"},credentials:"same-origin"}).then(a=>a.ok?a.json():null),s=r?.data?.cache_version??r?.cache_version;if(typeof s=="number"&&s>0){o.setCacheVersion(s);const a=window;a.G7Config&&(a.G7Config.cache_version=s)}}catch{}await o.loadTranslations(e,n,"/api",!0)}catch{}try{window.dispatchEvent(new CustomEvent(kt,{detail:{templateIdentifier:e,locale:n}}))}catch{}}}const rn=new Map;function kr(e,t,n,o){const r=rn.get(t)??{};r[n]=o,rn.set(t,r);try{Pt.getInstance().setTranslationValue(e,n,t,o)}catch{}if(typeof window<"u")try{window.dispatchEvent(new CustomEvent(kt,{detail:{templateIdentifier:e,locale:n}}))}catch{}}function Co(e,t,n){for(const[o,r]of Object.entries(n))kr(e,t,o,r)}function It(e,t){return rn.get(e)?.[t]}function cm(e){const t=rn.get(e);return t?{...t}:void 0}function um(){return rn.size>0}function md(e,t){for(const[n,o]of rn.entries())for(const[r,s]of Object.entries(o))try{e.setTranslationValue(t,r,n,s)}catch{}}async function pm(e){if(rn.size===0)return{ok:0,failed:[]};const t=Array.from(rn.entries());let n=0;const o=[];for(const[r,s]of t)try{const a=await fn(e,r);if(!a){o.push(r);continue}const l={...a.values??{},...s},d=`/api/admin/templates/${encodeURIComponent(e)}/custom-translations/${a.id}`;if(!(await fetch(d,{method:"PUT",credentials:"same-origin",headers:Me({"Content-Type":"application/json"}),body:JSON.stringify({values:l,expected_lock_version:a.lock_version})})).ok){o.push(r);continue}n+=1}catch{o.push(r)}for(const[r]of t)o.includes(r)||rn.delete(r);try{await on(e)}catch{}return{ok:n,failed:o}}function Xn(e,t){const n=`layout_editor.locale.${e}`,o=t(n);return o&&o!==n?o:e.toUpperCase()}function vd(){if(typeof window>"u")return[];const t=window.G7Config?.appConfig?.supportedLocales;return Array.isArray(t)?t.filter(n=>typeof n=="string"&&n.length>0):[]}function fm({locales:e}={}){const{t}=et(),{state:n,dispatch:o}=Qe();u.useEffect(()=>{window.__g7EditorContentLocale=n.locale},[n.locale]);const r=e??vd(),s=r.includes(n.locale)?r:[n.locale,...r];if(s.length<=1)return i.jsxs("span",{className:"g7le-locale-switcher g7le-locale-switcher--single","data-testid":"g7le-locale-switcher-single",style:{fontSize:11,color:"#475569",padding:"0 4px"},children:[t("layout_editor.chrome.toolbar.locale_switcher_label"),": ",Xn(n.locale,t)]});const a=l=>{if(l===n.locale)return;const d=n.locale;o({type:"SET_LOCALE",locale:l}),Et({op:"locale_switch",fromLocale:d,toLocale:l,timestamp:Date.now()})};return i.jsxs("div",{className:"g7le-locale-switcher","data-testid":"g7le-locale-switcher",role:"group","aria-label":t("layout_editor.chrome.toolbar.locale_switcher_label"),style:{display:"inline-flex",alignItems:"center",gap:4},children:[i.jsx("span",{style:{fontSize:11,color:"#475569"},children:t("layout_editor.chrome.toolbar.locale_switcher_label")}),i.jsx("div",{style:{display:"inline-flex",gap:2},children:s.map(l=>{const d=l===n.locale;return i.jsx("button",{type:"button","data-testid":`g7le-locale-${l}`,"aria-pressed":d,onClick:()=>a(l),style:{padding:"2px 8px",fontSize:12,cursor:"pointer",background:d?"#0f172a":"#f8fafc",color:d?"#fff":"#0f172a",border:"1px solid #cbd5e1",borderRadius:4},children:Xn(l,t)},l)})})]})}const gm=/\{\{?(p\d+)\}?\}/g;function hm(e){const t=[];if(typeof e!="string"||e.length===0)return t;const n=new RegExp(gm.source,"g");let o=0,r;for(;(r=n.exec(e))!==null;){const s=r.index,a=s+r[0].length;s>o&&t.push({kind:"text",raw:e.slice(o,s),start:o,end:s}),t.push({kind:"chip",raw:r[0],paramName:r[1],start:s,end:a}),o=a}return o{n.push({kind:"text",text:a}),r=!0};for(const a of t)a.kind==="text"?(o=a.raw,s(o),o=""):(r||s(""),n.push({kind:"chip",paramName:a.paramName}),r=!1);return r||s(""),n}function bm(e,t,n,o){const r=[];return e.forEach((s,a)=>{if(s.kind==="chip"){if(s.paramName===t)return;r.push(`{${s.paramName}}`)}else{const l=s.text??"";if(a===n){const d=Math.max(0,Math.min(o,l.length));r.push(l.slice(0,d),`{${t}}`,l.slice(d))}else r.push(l)}}),r.join("")}function Sr({value:e,onChange:t,t:n,paramLabels:o,onRequestInsert:r,onRemoveChip:s,testIdSuffix:a="pc",disabled:l=!1,hideInsertButton:d=!1,caretRef:c}){const p=u.useMemo(()=>ym(e),[e]),f=u.useRef(null),[b,g]=u.useState(null),[m,h]=u.useState(null),[v,y]=u.useState(null),_=u.useMemo(()=>p.map(O=>O.kind==="chip"?`c:${O.paramName}`:"t").join("|"),[p]),w=u.useRef(null),k=u.useRef([]),x=u.useRef(!1);u.useLayoutEffect(()=>{const O=x.current;x.current=!1,!(!O&&w.current===_)&&(w.current=_,p.forEach((z,H)=>{if(z.kind!=="text")return;const P=k.current[H];P&&P.textContent!==(z.text??"")&&(P.textContent=z.text??"")}))},[_,p,e]);const $=()=>{const O=f.current;if(!O)return e;const z=[];for(const H of Array.from(O.querySelectorAll("[data-seg]")))H.dataset.seg==="chip"?z.push(`{${H.dataset.param??""}}`):z.push(H.textContent??"");return z.join("")},C=()=>{l||t($())},S=u.useRef(null),D=u.useRef(!1),E=(O,z)=>{if(!l){O.preventDefault(),O.stopPropagation(),S.current={param:z,pointerId:O.pointerId},D.current=!1,g(z);try{O.currentTarget.setPointerCapture(O.pointerId)}catch{}}},I=O=>{const z=S.current;if(!z||O.pointerId!==z.pointerId)return;D.current=!0;const H=B(O.clientX,O.clientY);H&&(h({slotIdx:H.slotIdx,offset:H.offset}),y(vm(f.current,H.slotIdx,H.offset)))},N=(O,z)=>{if(O.stopPropagation(),D.current){D.current=!1;return}s?.(z)},T=O=>{const z=S.current;if(!z||O.pointerId!==z.pointerId)return;try{O.currentTarget.releasePointerCapture(O.pointerId)}catch{}S.current=null,D.current&&typeof setTimeout=="function"&&setTimeout(()=>{D.current=!1},0);const H=B(O.clientX,O.clientY);if(g(null),h(null),y(null),!H)return;const P=f.current;if(!P)return;const L=Array.from(P.querySelectorAll("[data-seg]")).map(Y=>Y.dataset.seg==="chip"?{kind:"chip",paramName:Y.dataset.param??""}:{kind:"text",text:Y.textContent??""}),F=bm(L,z.param,H.slotIdx,H.offset);F!==e&&(x.current=!0,t(F))},B=(O,z)=>{const H=f.current;if(!H)return null;const P=Array.from(H.querySelectorAll("[data-seg]")),A=H.ownerDocument,L=A.elementFromPoint(O,z);let F=L?.closest('[data-seg="text"]');if(F)return{slotIdx:P.indexOf(F),offset:mm(A,F,O,z)};const Y=L?.closest('[data-seg="chip"]');if(Y){const X=P.indexOf(Y),Z=Y.getBoundingClientRect();if(O=0){const ie=P[X-1];return{slotIdx:X-1,offset:(ie.textContent??"").length}}if(X+1({s:X,i:Z})).filter(X=>X.s.dataset.seg==="text").pop();return V?{slotIdx:V.i,offset:(V.s.textContent??"").length}:null},M=()=>{l||!r||r(_d(f.current,e.length))};return u.useEffect(()=>{if(c)return c.current=()=>_d(f.current,e.length),()=>{c.current=null}},[c,e.length]),i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[i.jsxs("div",{ref:f,"data-testid":`g7le-chip-input-${a}`,className:"g7le-chip-input",style:_m,children:[p.map((O,z)=>O.kind==="chip"?i.jsxs("span",{"data-seg":"chip","data-param":O.paramName,"data-testid":`g7le-chip-${a}-${O.paramName}`,contentEditable:!1,onPointerDown:H=>E(H,O.paramName??""),onPointerMove:I,onPointerUp:T,title:n("layout_editor.translation.placeholder_locked"),style:{...Sm,...b===O.paramName?Cm:null,touchAction:"none"},children:[i.jsx("span",{"aria-hidden":"true",style:$m,children:"⠿"}),i.jsx("span",{"aria-hidden":"true",style:{marginRight:3},children:"🔗"}),i.jsx("span",{style:Em,children:o?.[O.paramName??""]??O.paramName}),s&&!l&&i.jsx("button",{type:"button","data-testid":`g7le-chip-remove-${a}-${O.paramName}`,"aria-label":n("layout_editor.inline_binding.clear"),title:n("layout_editor.inline_binding.clear"),onPointerDown:H=>{H.stopPropagation(),H.preventDefault()},onClick:H=>N(H,O.paramName??""),style:Im,children:"✕"})]},`chip-${O.paramName}`):i.jsx("span",{ref:H=>{k.current[z]=H},"data-seg":"text",contentEditable:!l,suppressContentEditableWarning:!0,onInput:C,"data-testid":`g7le-chip-text-${a}-${z}`,style:{...xm,...b?wm:null,...m?.slotIdx===z?km:null}},`text-slot-${z}`)),v&&i.jsx("span",{"aria-hidden":"true","data-testid":`g7le-chip-caret-${a}`,style:{position:"absolute",left:v.left,top:v.top,width:2,height:v.height,background:"#2563eb",borderRadius:1,pointerEvents:"none",boxShadow:"0 0 0 1px rgba(37,99,235,0.3)"}})]}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[r&&!d&&i.jsxs("button",{type:"button","data-testid":`g7le-chip-insert-${a}`,onClick:M,disabled:l,style:Am,children:["+ ",n("layout_editor.inline_binding.insert_data")]}),i.jsx("span",{style:Tm,children:n("layout_editor.translation.placeholder_locked")})]})]})}function mm(e,t,n,o){const r=(t.textContent??"").length;try{const a=e;let l=null,d=0;if(typeof a.caretRangeFromPoint=="function"){const c=a.caretRangeFromPoint(n,o);c&&(l=c.startContainer,d=c.startOffset)}else if(typeof a.caretPositionFromPoint=="function"){const c=a.caretPositionFromPoint(n,o);c&&(l=c.offsetNode,d=c.offset)}if(l&&t.contains(l))return Math.max(0,Math.min(d,r))}catch{}const s=t.getBoundingClientRect();return n>s.left+s.width/2?r:0}function vm(e,t,n){if(!e)return null;const r=Array.from(e.querySelectorAll("[data-seg]"))[t];if(!r)return null;const s=e.getBoundingClientRect();try{const d=r.firstChild,c=e.ownerDocument;if(d&&d.nodeType===Node.TEXT_NODE&&(d.textContent??"").length>0){const p=c.createRange(),f=Math.max(0,Math.min(n,(d.textContent??"").length));p.setStart(d,f),p.setEnd(d,f);const b=p.getClientRects(),g=b.length>0?b[0]:p.getBoundingClientRect();if(g&&(g.height>0||g.width>=0))return{left:g.left-s.left,top:g.top-s.top,height:g.height||r.getBoundingClientRect().height}}}catch{}const a=r.getBoundingClientRect();return{left:(n>0?a.right:a.left)-s.left,top:a.top-s.top,height:a.height||16}}function _d(e,t){if(!e)return t;try{const n=e.ownerDocument.defaultView?.getSelection();if(!n||n.rangeCount===0)return t;const o=n.getRangeAt(0);let r=o.startContainer,s=null;for(;r&&r!==e;){if(r instanceof HTMLElement&&r.dataset.seg==="text"){s=r;break}r=r.parentNode}if(!s||!e.contains(s))return t;const a=Array.from(e.querySelectorAll("[data-seg]"));let l=0;for(const d of a){if(d===s)break;l+=d.dataset.seg==="chip"?`{${d.dataset.param??""}}`.length:(d.textContent??"").length}return l+o.startOffset}catch{return t}}const _m={position:"relative",display:"flex",flexWrap:"wrap",alignItems:"center",gap:2,minHeight:30,padding:"4px 8px",border:"1px solid #cbd5e1",borderRadius:4,background:"#fff",fontSize:13,lineHeight:1.6},xm={outline:"none",minWidth:8,minHeight:"1.2em",whiteSpace:"pre-wrap",color:"#0f172a",display:"inline-block"},wm={boxShadow:"inset 0 -2px 0 #93c5fd",background:"#eff6ff",borderRadius:2},km={background:"#dbeafe",boxShadow:"inset 0 -2px 0 #2563eb"},Sm={display:"inline-flex",alignItems:"center",gap:1,background:"linear-gradient(180deg,#eff6ff,#dbeafe)",color:"#1d4ed8",border:"1px dashed #60a5fa",borderRadius:9999,padding:"1px 8px 1px 4px",margin:"0 1px",fontSize:12,fontWeight:600,cursor:"grab",userSelect:"none",whiteSpace:"nowrap",boxShadow:"0 1px 2px rgba(37,99,235,0.18)",verticalAlign:"middle"},Cm={opacity:.5,borderStyle:"solid",cursor:"grabbing"},$m={color:"#2563eb",opacity:.7,fontSize:11,marginRight:1,cursor:"grab"},Em={textDecoration:"none"},Im={marginLeft:4,width:14,height:14,lineHeight:"12px",padding:0,border:"none",borderRadius:9999,background:"rgba(29,78,216,0.12)",color:"#1d4ed8",fontSize:9,fontWeight:700,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",flex:"0 0 auto"},Am={fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#334155",padding:"3px 10px",cursor:"pointer"},Tm={fontSize:10,color:"#94a3b8"};function xd(e){e&&(e.style.height="auto",e.style.height=`${Math.max(e.scrollHeight,28)}px`)}function Dm(e){xd(e)}function zm(e){const t=new Set;for(const n of e)for(const o of Object.keys(n.values??{}))t.add(o);return Array.from(t).sort()}function Nm({templateIdentifier:e,layoutName:t,t:n,referencedKeys:o,onClose:r}){const[s,a]=u.useState([]),[l,d]=u.useState("idle"),[c,p]=u.useState(null),[f,b]=u.useState("all"),[g,m]=u.useState(new Set),[h,v]=u.useState({}),[y,_]=u.useState(null),[w,k]=u.useState({}),x=u.useCallback(async()=>{d("loading"),p(null);const z=await ab(e,t);z.ok?(a(z.data),v({}),m(new Set),k({}),d("idle")):(p(z.message),d("error"))},[e,t]);u.useEffect(()=>{x()},[x]);const $=u.useMemo(()=>zm(s),[s]),C=u.useMemo(()=>s.filter(z=>f==="all"?!0:z.status===f).slice().sort((z,H)=>{const P=z.updated_at?Date.parse(z.updated_at):0,A=H.updated_at?Date.parse(H.updated_at):0;return A!==P?A-P:H.id-z.id}),[s,f]),S=u.useMemo(()=>s.filter(z=>z.status==="orphaned"),[s]),D=u.useCallback(z=>{const H={...z.values??{}};for(const P of Object.keys(H)){const A=It(z.translation_key,P);A!==void 0&&(H[P]=A)}return H},[]),E=u.useCallback(z=>h[z.id]??D(z),[h,D]),I=u.useCallback((z,H,P)=>{v(A=>{const L=A[z]??s.find(F=>F.id===z)?.values??{};return{...A,[z]:{...L,[H]:P}}})},[s]),N=u.useCallback(async z=>{_(z.id),k(A=>({...A,[z.id]:""}));const H=E(z),P=await lb(e,z.id,H,z.lock_version);if(P.ok)a(A=>A.map(L=>L.id===z.id?P.data:L)),v(A=>{const L={...A};return delete L[z.id],L});else{const A=P.status===409?n("layout_editor.translation_manager.conflict"):P.message;k(L=>({...L,[z.id]:A}))}_(null)},[e,E,n]),T=u.useCallback(z=>typeof window<"u"&&typeof window.confirm=="function"?window.confirm(n("layout_editor.translation_manager.delete_confirm",{count:z})):!0,[n]),B=u.useCallback(async z=>{if(!T(1))return;const H=await db(e,z.id);H.ok?(a(P=>P.filter(A=>A.id!==z.id)),m(P=>{const A=new Set(P);return A.delete(z.id),A})):p(H.message)},[e,T]),M=u.useCallback(async z=>{if(z.length===0||!T(z.length))return;const H=await cb(e,z);if(H.ok){const P=new Set(z);a(A=>A.filter(L=>!P.has(L.id))),m(new Set)}else p(H.message)},[e,T]),O=u.useCallback(z=>{m(H=>{const P=new Set(H);return P.has(z)?P.delete(z):P.add(z),P})},[]);return i.jsxs("div",{className:"g7le-translation-manager","data-testid":"g7le-translation-manager",style:Mm,children:[i.jsxs("div",{"data-modal-drag-handle":!0,style:Lm,children:[i.jsx("span",{style:{fontSize:14,fontWeight:700},"data-testid":"g7le-translation-manager-title",children:n("layout_editor.translation_manager.title")}),i.jsx("button",{type:"button","aria-label":"close",onClick:r,style:Pm,"data-testid":"g7le-translation-manager-close",children:"✕"})]}),i.jsxs("div",{style:Om,children:[i.jsx("div",{style:{display:"inline-flex",gap:4},role:"tablist","aria-label":n("layout_editor.translation_manager.filter_label"),children:["all","active","orphaned"].map(z=>i.jsx("button",{type:"button",role:"tab","aria-selected":f===z,"data-active":f===z?"true":"false",onClick:()=>b(z),style:f===z?Bm:wd,"data-testid":`g7le-translation-filter-${z}`,children:n(`layout_editor.translation_manager.filter_${z}`)},z))}),i.jsx("div",{style:{flex:1}}),g.size>0&&i.jsxs("button",{type:"button",onClick:()=>void M(Array.from(g)),style:kd,"data-testid":"g7le-translation-bulk-delete",children:["🗑 ",n("layout_editor.translation_manager.delete_selected",{count:g.size})]}),S.length>0&&i.jsxs("button",{type:"button",onClick:()=>void M(S.map(z=>z.id)),style:kd,"data-testid":"g7le-translation-purge-orphaned",children:["🧹 ",n("layout_editor.translation_manager.purge_orphaned",{count:S.length})]})]}),c&&i.jsx("div",{style:Wm,"data-testid":"g7le-translation-manager-error",children:c}),i.jsx("div",{style:jm,children:l==="loading"?i.jsx("div",{style:Sd,"data-testid":"g7le-translation-manager-loading",children:n("layout_editor.translation_manager.loading")}):C.length===0&&l!=="error"?i.jsx("div",{style:Sd,"data-testid":"g7le-translation-manager-empty",children:n("layout_editor.translation_manager.empty")}):i.jsx("div",{"data-testid":"g7le-translation-list",style:Hm,children:C.map(z=>{const H=E(z),P=z.status==="orphaned",A=o?o.has(z.translation_key):null;return i.jsxs("div",{style:Fm,"data-testid":`g7le-translation-row-${z.id}`,children:[i.jsxs("div",{style:Km,children:[i.jsx("input",{type:"checkbox",checked:g.has(z.id),onChange:()=>O(z.id),"aria-label":n("layout_editor.translation_manager.select_aria",{key:z.translation_key}),"data-testid":`g7le-translation-select-${z.id}`}),i.jsx("code",{style:Vm,children:z.translation_key}),P&&i.jsx("span",{style:Um,"data-testid":`g7le-translation-badge-orphaned-${z.id}`,children:n("layout_editor.translation_manager.badge_orphaned")}),A===!0&&i.jsx("span",{style:qm,"data-testid":`g7le-translation-badge-live-inuse-${z.id}`,children:n("layout_editor.translation_manager.badge_live_in_use")}),A===!1&&i.jsx("span",{style:Gm,"data-testid":`g7le-translation-badge-live-unused-${z.id}`,children:n("layout_editor.translation_manager.badge_live_unused")}),i.jsx("div",{style:{flex:1}}),i.jsx("button",{type:"button",onClick:()=>void B(z),style:ev,"data-testid":`g7le-translation-delete-${z.id}`,children:"🗑"})]}),i.jsxs("div",{style:Ym,children:[$.map(L=>{const F=H[L]??"",Y=Tn(F).length>0;return i.jsxs("div",{style:Xm,"data-testid":`g7le-translation-field-${z.id}-${L}`,children:[i.jsxs("label",{style:Jm,title:L,children:[Xn(L,n),i.jsxs("span",{style:Zm,children:["(",L,")"]})]}),Y?i.jsx("div",{style:{flex:1},"data-testid":`g7le-translation-chip-${z.id}-${L}`,children:i.jsx(Sr,{value:F,onChange:V=>I(z.id,L,V),t:n,testIdSuffix:`${z.id}-${L}`})}):i.jsx("textarea",{value:F,rows:1,ref:Dm,onChange:V=>{I(z.id,L,V.currentTarget.value),xd(V.currentTarget)},style:Qm,"data-testid":`g7le-translation-input-${z.id}-${L}`})]},L)}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i.jsx("button",{type:"button",disabled:y===z.id,onClick:()=>void N(z),style:Rm,"data-testid":`g7le-translation-save-${z.id}`,children:y===z.id?n("layout_editor.translation_manager.saving"):n("layout_editor.translation_manager.save")}),w[z.id]?i.jsx("span",{style:{fontSize:11,color:"#dc2626"},"data-testid":`g7le-translation-row-error-${z.id}`,children:w[z.id]}):null]})]})]},z.id)})})}),i.jsx("div",{style:tv,children:i.jsx("button",{type:"button",onClick:r,style:nv,"data-testid":"g7le-translation-manager-footer-close",children:n("layout_editor.translation_manager.close")})})]})}const Mm={display:"flex",flexDirection:"column",minHeight:0,flex:1},Lm={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:"1px solid #e2e8f0"},Pm={border:"none",background:"transparent",fontSize:16,color:"#94a3b8",cursor:"pointer"},Om={padding:"10px 16px",borderBottom:"1px solid #f1f5f9",display:"flex",gap:8,alignItems:"center"},wd={padding:"4px 10px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},Bm={...wd,borderColor:"#2563eb",background:"#eff6ff",color:"#1d4ed8",fontWeight:600},kd={padding:"4px 10px",fontSize:12,border:"1px solid #fecaca",borderRadius:6,background:"#fff",color:"#dc2626",cursor:"pointer"},Wm={padding:"8px 16px",fontSize:12,color:"#b91c1c",background:"#fef2f2"},jm={padding:16,overflow:"auto",flex:1,minHeight:120,display:"flex",flexDirection:"column",gap:12},Sd={fontSize:13,color:"#94a3b8",textAlign:"center",padding:"32px 0"},Hm={display:"flex",flexDirection:"column",gap:20},Fm={border:"1px solid #e2e8f0",borderRadius:8,padding:10,display:"flex",flexDirection:"column",gap:6},Km={display:"flex",alignItems:"center",gap:8},Vm={fontSize:11,background:"#f1f5f9",padding:"2px 6px",borderRadius:4,color:"#0f172a"},Um={fontSize:10,color:"#b45309",background:"#fef3c7",padding:"1px 6px",borderRadius:4,fontWeight:600},qm={fontSize:10,color:"#15803d",background:"#dcfce7",padding:"1px 6px",borderRadius:4,fontWeight:600},Gm={fontSize:10,color:"#9f1239",background:"#ffe4e6",padding:"1px 6px",borderRadius:4,fontWeight:600},Ym={display:"flex",flexDirection:"column",gap:6},Xm={display:"flex",alignItems:"flex-start",gap:8},Jm={fontSize:12,color:"#475569",minWidth:88,fontWeight:600,paddingTop:4,display:"flex",flexDirection:"column",lineHeight:1.2},Zm={fontSize:10,color:"#94a3b8",fontWeight:400},Qm={flex:1,padding:"4px 8px",fontSize:13,border:"1px solid #cbd5e1",borderRadius:4,color:"#0f172a",resize:"vertical",overflow:"hidden",minHeight:28,lineHeight:1.4,fontFamily:"inherit",boxSizing:"border-box"},Rm={padding:"5px 12px",fontSize:12,border:"none",borderRadius:6,background:"#2563eb",color:"#fff",cursor:"pointer"},ev={padding:"4px 8px",fontSize:12,border:"1px solid #fecaca",borderRadius:6,background:"#fff",color:"#dc2626",cursor:"pointer"},tv={padding:"10px 16px",borderTop:"1px solid #e2e8f0",display:"flex",justifyContent:"flex-end"},nv={padding:"6px 14px",fontSize:13,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"};function ov(){const e=Kt(),{state:t}=Qe(),n=e?.document?.raw??null,o=t.templateIdentifier??"",r=t.selectedRoute?.layoutName??"",s=u.useCallback((c,p)=>{const f=n?.[c];return f===void 0?p:f},[n]),a=u.useCallback((c,p,...f)=>{e&&(f.length>=1?e.patchDocumentRaw(c,p,f[0]):e.patchDocumentRaw(c,p))},[e]),l=u.useCallback(async(c,p)=>!o||!r?null:Yn(o,r,c,p),[o,r]),d=u.useCallback(async(c,p,f)=>o?wr(o,c,p,f):null,[o]);return{raw:n,getValue:s,patch:a,createI18nKey:l,updateI18nKeyValue:d}}function rv(e){const t=e.__source;return t&&(t.kind==="module"||t.kind==="plugin")&&t.identifier?`${t.kind}:${t.identifier}`:"template"}function Cd(e,t){if(!t)return null;const n=rv(e);if(n&&t.bySource){const a=t.bySource[n]?.[e.id];if(a!==void 0)return{value:a,match:{dataSourceId:e.id,resolvedBy:"spec_byId",sourceKey:n}}}const o=t.byDataSourceId?.[e.id];if(o!==void 0)return{value:o,match:{dataSourceId:e.id,resolvedBy:"spec_byId"}};const r=e.endpoint??"";if(t.byEndpointPattern&&typeof r=="string"&&r.length>0){for(const[s,a]of Object.entries(t.byEndpointPattern))if(iv(r,s))return{value:a,match:{dataSourceId:e.id,resolvedBy:"spec_byEndpoint"}}}return null}function ls(e,t){const n=Cd(e,t);if(n)return n;const o=e.fallback?.data;return o!==void 0?{value:{data:Array.isArray(o)?o:[o]},match:{dataSourceId:e.id,resolvedBy:"fallback"}}:{value:{},match:{dataSourceId:e.id,resolvedBy:"inferred"}}}function iv(e,t){const n=t.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${n}$`).test(e)}function sv(e={}){const{spec:t,overrideSpec:n,onMatch:o}=e;return{has(r){return!0},resolve(r){const s=n?Cd(r,n):null,{value:a,match:l}=s??ls(r,t);if(o)try{o(l)}catch{}return a}}}const $d=Lt(),Ed=$d.DataBindingEngine,Id=$d.dataBindingEngine;_o("PipeRegistry");function av(e){let t=null,n=0;for(let o=0;o0?e[o-1]:"",a=o{const a=t[r],l=a==null?[]:String(a).split(",").map(d=>d.trim()).filter(Boolean);return l.length===0?"":l.join(" ?? ")+(s?" ?? ":"")});return n=n.replace(/\{(\w+)\}/g,(o,r)=>{const s=t[r];return s===void 0?o:s}),n}function Cr(e){const t=e.trim(),n=/^\{\{([\s\S]*)\}\}$/.exec(t);return n?n[1].trim():t}function Td(e){const t=e.trim();return/^\{\{[\s\S]*\}\}$/.test(t)?t:`{{ ${t} }}`}function Dd(e,t){const n={};for(const[r,s]of Object.entries(t))n[r]=typeof s=="string"?Cr(s):s;const o=dv(e.expr,n);return Td(o)}function cv(e,t){if(typeof e!="string")return null;const n=zd(Cr(e));for(const o of t){const r=uv(n,o.expr,o.params);if(r)return{recipeId:o.id,params:r}}return null}function zd(e){return e.replace(/\s+/g," ").trim()}function Nd(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function uv(e,t,n){const o=[],r=new Set;let s="";const a=/\{(\w+)(\*?)\}(\s*\?\?\s*)?/g;let l=0,d;const c=zd(t);for(;(d=a.exec(c))!==null;){const g=c.slice(l,d.index);s+=Nd(g).replace(/\\ /g,"\\s*");const m=d[2]==="*",h=!!d[3];m?(r.add(d[1]),s+="(.*?)",h&&(s+="(?:\\s*\\?\\?\\s*)?")):(s+="(.+?)",h&&(s+="\\s*\\?\\?\\s*")),o.push(d[1]),l=a.lastIndex}s+=Nd(c.slice(l)).replace(/\\ /g,"\\s*");let p;try{p=new RegExp(`^${s}$`)}catch{return null}const f=p.exec(e);if(!f)return null;const b={};if(o.forEach((g,m)=>{let h=(f[m+1]??"").trim();r.has(g)&&(h=h.split(/\s*\?\?\s*/).map(v=>v.trim()).filter(Boolean).join(", ")),b[g]=h}),n.length>0){const g=new Set(n.map(m=>m.key));for(const m of Object.keys(b))g.has(m)||delete b[m]}return b}function pv(e){const t=`x.${e.field}`,n=fv(e.value);switch(e.cmp){case"=":return`${t} === ${n}`;case"!=":return`${t} !== ${n}`;case">":return`${t} > ${n}`;case"<":return`${t} < ${n}`;case">=":return`${t} >= ${n}`;case"<=":return`${t} <= ${n}`;case"includes":return`(${t} ?? []).includes(${n})`;default:return`${t} === ${n}`}}function fv(e){const t=e.trim();return t==="true"||t==="false"||t!==""&&!Number.isNaN(Number(t))||/^['"].*['"]$/.test(t)||/[.([{]/.test(t)?t:`'${t.replace(/'/g,"\\'")}'`}function ds(e){return!e||e.length===0?"true":e.map(pv).join(" && ")}function gv(e){const n=`(${(e.source??"").trim()||"[]"} ?? [])`;let o;switch(e.op){case"count":o=`${n}.filter(x => ${ds(e.conditions)}).length`;break;case"sum":{const r=(e.sumField??"").trim()||"value";o=`${n}.filter(x => ${ds(e.conditions)}).reduce((s, x) => s + (x.${r} ?? 0), 0)`;break}case"filter":o=`${n}.filter(x => ${ds(e.conditions)})`;break;case"toOptions":{const r=(e.valueField??"").trim()||"value",s=(e.labelField??"").trim()||"label";o=`${n}.map(x => ({ value: x.${r}, label: x.${s} }))`;break}case"nth":{const r=(e.index??"").trim()||"0",s=(e.prop??"").trim();o=`${n}[${r}]${s?`?.${s}`:""}`;break}case"firstOf":{const r=(e.candidates??[]).map(l=>l.trim()).filter(Boolean),s=r.length>0?r.join(" ?? "):"''",a=(e.fallback??"").trim();o=a?`${s} ?? '${a.replace(/'/g,"\\'")}'`:s;break}case"literal":{const r=e.literalKind??"string",s=(e.literalValue??"").trim();r==="number"?o=s===""?"0":s:r==="boolean"?o=s==="true"?"true":"false":o=`'${s.replace(/'/g,"\\'")}'`;break}default:o="[]"}return Td(o)}function hv(e){if(typeof e!="string")return null;const t=Cr(e).trim();let n=/^\((.+?)\s*\?\?\s*\[\]\)\.filter\(x => (.+)\)\.length$/.exec(t);return n?{key:"",op:"count",source:n[1].trim(),conditions:cs(n[2])}:(n=/^\((.+?)\s*\?\?\s*\[\]\)\.filter\(x => (.+)\)\.reduce\(\(s, x\) => s \+ \(x\.(\w+(?:\.\w+)*) \?\? 0\), 0\)$/.exec(t),n?{key:"",op:"sum",source:n[1].trim(),conditions:cs(n[2]),sumField:n[3]}:(n=/^\((.+?)\s*\?\?\s*\[\]\)\.filter\(x => (.+)\)$/.exec(t),n?{key:"",op:"filter",source:n[1].trim(),conditions:cs(n[2])}:(n=/^\((.+?)\s*\?\?\s*\[\]\)\.map\(x => \(\{ value: x\.(\w+(?:\.\w+)*), label: x\.(\w+(?:\.\w+)*) \}\)\)$/.exec(t),n?{key:"",op:"toOptions",source:n[1].trim(),valueField:n[2],labelField:n[3]}:(n=/^\((.+?)\s*\?\?\s*\[\]\)\[(.+?)\](?:\?\.(\w+(?:\.\w+)*))?$/.exec(t),n?{key:"",op:"nth",source:n[1].trim(),index:n[2].trim(),prop:n[3]}:null))))}function cs(e){const t=e.trim();if(t==="true")return[];const n=[];for(const o of yv(t)){const r=bv(o.trim());r&&n.push(r)}return n}function yv(e){const t=[];let n=0,o=0;for(let r=0;r=|<=|>|<)\s*(.+)$/.exec(e),t){const n={"===":"=","!==":"!=",">":">","<":"<",">=":">=","<=":"<="};return{field:t[1],cmp:n[t[2]]??"=",value:Md(t[3])}}return null}function Md(e){const t=e.trim(),n=/^'(.*)'$/.exec(t)||/^"(.*)"$/.exec(t);return n?n[1]:t}function Ld(e,t){const n=cv(e,t);if(n)return{kind:"preset",recipeId:n.recipeId,params:n.params};const o=hv(e);return o?{kind:"custom",model:o}:{kind:"advanced"}}function mv(e){if(e==null)return"null";if(Array.isArray(e))return"list";switch(typeof e){case"number":return"number";case"boolean":return"boolean";case"string":return"string";default:return"object"}}function Pd(e,t){if(typeof e!="string"||e.trim()==="")return{ok:!1,reason:"empty"};const n=Cr(e);try{const o=av(n)?Id.evaluatePipeExpression(n,t??{},{skipCache:!0}):Id.evaluateExpression(n,t??{},{skipCache:!0});return{ok:!0,value:o,type:mv(o)}}catch(o){return{ok:!1,reason:o instanceof Error?o.message:String(o)}}}function Od(e,t){const n=Array.isArray(e?.data_sources)?e.data_sources:[],o=[];for(const r of n){const s=r?.id;if(typeof s!="string"||s.length===0)continue;const{value:a}=ls(r,t?.sampleData),l=typeof r.label_key=="string"?r.label_key:void 0;o.push({id:s,sample:a,labelKey:l})}return o}function Bd(e,t){const n=[];t?.sampleGlobal&&typeof t.sampleGlobal=="object"&&n.push({scope:"_global",tree:t.sampleGlobal});const o={},r={},s={},a=(l,d)=>{if(!(!d||typeof d!="object"||Array.isArray(d)))for(const[c,p]of Object.entries(d))if(p&&typeof p=="object"&&!Array.isArray(p)){const f=l[c]&&typeof l[c]=="object"&&!Array.isArray(l[c])?l[c]:l[c]={};a(f,p)}else c in l||(l[c]=p)};for(const l of t?.states?.groups??[])for(const d of l.items??[]){const c=d.initialState;c?.local&&a(o,c.local),c?.query&&a(r,c.query),c?.route&&a(s,c.route)}return Object.keys(o).length&&n.push({scope:"_local",tree:o}),Object.keys(r).length&&n.push({scope:"query",tree:r}),Object.keys(s).length&&n.push({scope:"route",tree:s}),e?.computed&&typeof e.computed=="object"&&!Array.isArray(e.computed)&&n.push({scope:"_computed",tree:e.computed}),n}function Wd(e,t){const n={};for(const r of t)r.scope!=="_computed"&&(n[r.scope]=r.tree);const o={};for(const[r,s]of Object.entries(e)){if(typeof s!="string"){o[r]=s;continue}const a=Pd(s,n);o[r]=a.ok?a.value:s}return o}function vv(e,t){const n=Od(e,t),o=Bd(e,t),r={};for(const s of n)s.sample!==void 0&&(r[s.id]=s.sample);for(const s of o)s.scope==="_computed"?r[s.scope]=Wd(s.tree,o):r[s.scope]=s.tree;return r}function jd(e){const{raw:t,spec:n,evaluateComputed:o}=e;return u.useMemo(()=>{const r=Od(t,n),s=Bd(t,n);if(o){const a=s.findIndex(l=>l.scope==="_computed");if(a>=0){const l=Wd(s[a].tree,s);s[a]={scope:"_computed",tree:l}}}return Yi({dataSources:r,states:s,spec:n??void 0})},[t,n,o])}function _v(e){const{raw:t,spec:n,pageType:o}=e;return u.useMemo(()=>{const r=Array.isArray(t?.data_sources)?t.data_sources:[],s=[];for(const d of r){const c=d?.id;if(typeof c!="string"||c.length===0)continue;const{value:p}=ls(d,n?.sampleData),f=typeof d.label_key=="string"?d.label_key:void 0;s.push({id:c,sample:p,labelKey:f})}const a=[];n?.sampleGlobal&&typeof n.sampleGlobal=="object"&&a.push({scope:"_global",tree:n.sampleGlobal}),t?.computed&&typeof t.computed=="object"&&!Array.isArray(t.computed)&&a.push({scope:"_computed",tree:t.computed});const l=Yi({dataSources:s,states:a,spec:n??void 0});if(typeof o=="string"&&o!=="")for(const d of["title","description"])l.push({expression:`{{_seo.${o}.${d}}}`,source:"_seo",sourceId:"_seo",path:`${o}.${d}`,shape:"scalar",preview:""});return l},[t,n,o])}function Hd(e,t){const n=[],o=new Set,r=s=>{for(const a of s??[]){if(a.kind==="route"&&!a.isRedirect&&typeof a.path=="string"&&a.path.startsWith("/")&&!o.has(a.path)){o.add(a.path);const l=a.label.startsWith("$t:")?a.label.slice(3):a.label,d=a.label.startsWith("$t:")?t(l):l,c=d&&d!==l&&!d.startsWith("$t:")?d:"";n.push({value:a.path,label:c?`${c} (${a.path})`:a.path})}r(a.children)}};return r(e),n}function Fd(e){const t=Array.isArray(e?.data_sources)?e.data_sources:[],n=[];for(const o of t){const r=o?.id;typeof r=="string"&&r.length>0&&n.push({value:r,label:r})}return n}function us(e,t){const n=typeof e.id=="string"?e.id:"",o=typeof e.label_key=="string"?e.label_key:"";if(!o)return null;const r=o.startsWith("$t:")?o.slice(3):o,s=t(r);return s&&s!==r&&!s.startsWith("$t:")&&s!==n?s:null}function ps(e,t){const n=e.__source;if(!n||typeof n!="object"||Array.isArray(n))return null;const o=n;if(o.kind!=="extension")return null;const r=o.extensionSourceType==="plugin"?t("layout_editor.data_sources.source.plugin"):t("layout_editor.data_sources.source.module"),s=typeof o.extensionIdentifier=="string"?o.extensionIdentifier:"",a=typeof o.extensionName=="string"?o.extensionName:"",l=a&&a!==s?`${a} (${s})`:s;return l?`${r}: ${l}`:r}function xv(e,t,n){const o=Array.isArray(e?.data_sources)?e.data_sources:[],r=[],s=new Set;for(const a of o){const l=a?.id;typeof l!="string"||l.length===0||s.has(l)||(s.add(l),r.push({id:l,friendly:us(a,t),source:ps(a,n)}))}return r}function Kd(e){const t=e?.states?.groups??[],n=new Set;for(const o of t)for(const r of o.items??[]){for(const s of Object.keys(r.initialState?.local??{}))n.add(s);for(const s of Object.keys(r.initialState?.global??{}))n.add(s)}return Array.from(n).map(o=>({value:o,label:o}))}function wv(e,t){const n=Array.isArray(e?.modals)?e.modals:[],o=[],r=new Set;for(const s of n){const a=s?.id;typeof a!="string"||a.length===0||r.has(a)||(r.add(a),o.push({value:a,label:kv(s,a,t)}))}return o}function kv(e,t,n){const r=e?.meta?.editor_label;if(typeof r=="string"&&r.length>0)return Vd(r,n);const s=e?.title;return typeof s=="string"&&s.length>0?Vd(s,n):t}function Vd(e,t){if(e.startsWith("$t:")){const n=e.slice(3),o=t?t(n):n;return o&&o!==n?o:n}return e}const Ud=_o("ActionRecipeEngine"),Sv={api:"apiCall",nav:"navigate",showToast:"toast",setLocalState:"setState"},Cv=new Set(["comment"]);function $o(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,o]of Object.entries(e)){if(Cv.has(n)||!o||typeof o!="object")continue;const r=o,s=r.build&&typeof r.build=="object"?r.build:typeof r.handler=="string"?{handler:r.handler}:void 0;!s||typeof s.handler!="string"||s.handler.length===0||t.push({id:n,label:typeof r.label=="string"?r.label:void 0,params:Array.isArray(r.params)?r.params:[],build:s})}return t}function sn(e){const t=/^\{\{\s*([\w.]+)\s*\}\}$/.exec(e);return t?t[1]:null}const $r="...";function $v(e,t){return e.replace(/\{\{\s*([\w.]+)\s*\}\}/g,(n,o)=>{const r=t[o];return r==null?"":String(r)})}function fs(e,t){if(typeof e=="string"){const n=sn(e);return n!==null?n in t?t[n]:void 0:e.includes("{{")?$v(e,t):e}if(Array.isArray(e))return e.map(n=>fs(n,t)).filter(n=>n!==void 0);if(e&&typeof e=="object"){const n={};for(const[o,r]of Object.entries(e)){if(o===$r&&typeof r=="string"){const d=sn(r),c=d!==null?t[d]:void 0;if(c&&typeof c=="object"&&!Array.isArray(c))for(const[p,f]of Object.entries(c))f===void 0||p===""||(n[p]=f);continue}const s=fs(r,t);if(s===void 0||Array.isArray(s)&&s.length===0&&(o==="onSuccess"||o==="onError"))continue;const a=sn(o),l=a!==null?a in t?String(t[a]):null:o;l===null||l===""||s&&typeof s=="object"&&!Array.isArray(s)&&Object.keys(s).length===0||(n[l]=s)}return n}return e}function Ev(e){const t=e.handler;if(typeof t!="string")return e;const n=Sv[t];if(n)return Ud.warn(`action recipe used forbidden handler "${t}" — corrected to "${n}" (core handler rules)`),{...e,handler:n};if(t==="apiCall"||t==="navigate"){const o=e.params;if(o&&typeof o=="object")for(const r of["target","onSuccess","onError"])r in o&&Ud.warn(`action recipe build placed "${r}" inside params for handler "${t}" — should be top-level (core handler rules)`)}return e}function Er(e,t){const n=fs(e.build,t);if(typeof n.handler!="string"&&e.build.handler.includes("{{")&&(n.handler=e.build.handler),e.build.handler.includes("{{")){const o=new Set(e.params.filter(r=>r.required).map(r=>r.key));o.size>0&&qd(e.build,n,o)}return Ev(n)}function qd(e,t,n){if(!e||typeof e!="object"||Array.isArray(e)||!t||typeof t!="object"||Array.isArray(t))return;const o=e,r=t;for(const[s,a]of Object.entries(o))if(s!=="handler"){if(typeof a=="string"){const l=sn(a);l!==null&&n.has(l)&&!(s in r)&&(r[s]=a)}else if(a&&typeof a=="object"){if(!(s in r)||typeof r[s]!="object"||r[s]===null)if(JSON.stringify(a).includes("{{"))r[s]={};else continue;qd(a,r[s],n)}}}function Iv(e,t){if(!e||typeof e!="object")return null;const n=e.handler;if(typeof n!="string")return null;let o=null,r=-1;for(const s of t){const a=s.build.handler.includes("{{");if(!a&&s.build.handler!==n||a&&!Av(s.build,e))continue;const l=Tv(s.build,e);if(l===null)continue;const d=Object.keys(l).length;d>r&&(r=d,o={recipeId:s.id,values:l})}return o}function Av(e,t){if(typeof t.handler=="string"&&t.handler===e.handler)return!0;const n=e.params;if(!n||typeof n!="object")return!1;const o=t.params;if(!o||typeof o!="object")return!1;const r=o,s=Object.entries(n).filter(([,a])=>typeof a=="string"&&sn(a)!==null);return s.length===0?!1:s.every(([a])=>a in r)}function Tv(e,t){const n={},o=(r,s)=>{if(typeof r=="string"){const a=sn(r);return a!==null?(n[a]=s,!0):r.includes("{{")?typeof s=="string":r===s}if(Array.isArray(r))return Array.isArray(s);if(r&&typeof r=="object"){if(!s||typeof s!="object"||Array.isArray(s))return!1;const a=s,l=r[$r],d=typeof l=="string"?sn(l):null,c=new Set(Object.keys(r).filter(p=>p!==$r));for(const[p,f]of Object.entries(r))if(p!==$r){if(typeof f=="string"&&sn(f)!==null){const b=sn(f);p in a&&(n[b]=a[p]);continue}if(!(p in a)){if(p==="onSuccess"||p==="onError"||p==="params"||p==="identity_target")continue;return!1}if(!o(f,a[p]))return!1}if(d!==null){const p={};for(const[f,b]of Object.entries(a))c.has(f)||(p[f]=b);Object.keys(p).length>0&&(n[d]=p)}return!0}return r===s};return o(e,t)?n:null}function Jn(e,t){const n=typeof e?.handler=="string"?e.handler:"",o=Iv(e,t);return o?{kind:"preset",recipeId:o.recipeId,values:o.values,handler:n}:{kind:"advanced",handler:n}}function Gd(e,t,n){const o=e?.label,r=o?n?n(o):o:"",s=[],a=e?.params??[];for(const l of a){if(l.advanced||l.widget==="action-list")continue;const d=t[l.key];if(d==null||d==="")continue;const c=Dv(d);if(c!==""&&(s.push(c),s.length>=2))break}return s.length===0?r:`${r} (${s.join(", ")})`}function Dv(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):Array.isArray(e)?`[${e.length}]`:e&&typeof e=="object"?"{…}":""}function Yd(e,t){const n={...e};return typeof t=="string"&&t.trim().length>0?n.if=t.trim():delete n.if,n}function gs(e){const t=e?.if;return typeof t=="string"&&t.trim().length>0?t:null}const zv=/^\s*\$t:(custom\.[a-zA-Z0-9._-]+)\s*$/,Nv=/^\s*\$t:([a-zA-Z0-9._-]+)\s*$/,Mv=/\{\{.*?\}\}/;function Xd(e,t){const n=typeof e=="string"?e:"",o=zv.exec(n);if(o){const a=o[1],l=t?t(a):"";return{customKey:a,binding:!1,paramKey:!1,displayValue:l}}const r=vt(n);if(r&&r.key.startsWith("custom.")){const a=t?t(r.key):"";return{customKey:r.key,binding:!1,paramKey:!0,displayValue:a}}if(Mv.test(n))return{customKey:null,binding:!0,paramKey:!1,displayValue:n};const s=Nv.exec(n);if(s){const a=s[1],l=t?t(a):"";return{customKey:null,binding:!1,paramKey:!1,displayValue:l&&l!==a?l:""}}return{customKey:null,binding:!1,paramKey:!1,displayValue:n}}function Lv(){const{state:e}=Qe(),t=e.templateIdentifier,n=e.locale,o=e.selectedRoute?.layoutName??null,r=u.useCallback(l=>{try{const c=Pt.getInstance().translate(l,{templateId:t,locale:n});return c&&c!==l?c:""}catch{return""}},[t,n]),s=u.useCallback(l=>Xd(l,r),[r]),a=u.useCallback(async(l,d)=>{const c=Xd(l,r);if(c.binding)return{kind:"blocked"};if(c.customKey){if(d===c.displayValue)return{kind:"noop",customKey:c.customKey};const b=await wr(t,c.customKey,n,d);return b.kind==="error"?{kind:"error",message:b.message}:(await on(t,n),{kind:"updated",customKey:c.customKey})}const p=await Yn(t,o,n,d);if(p.kind==="error"||!p.resource)return{kind:"error",message:p.message};const f=p.resource.translation_key;return await on(t,n),{kind:"created",customKey:f,token:`$t:${f}`}},[t,n,o,r]);return{locale:n,templateIdentifier:t,translate:r,classify:s,commitText:a}}async function hs(e,t,n,o,r,s,a,l,d,c){const p=c?ns(o,c):null,f=!!(p&&p.keyifiable),b=d?d(o):o,g=f?p.chipValue:nd(b),h=`p${f?p.bindings.length:yr(b).length}`,v=Math.max(0,Math.min(r,g.length)),y=Xl(g,v,h),_=mr(y).replace(/\{\{?p\d+\}?\}/g," ").replace(/\s+/g," ").trim(),w=_.length>0?_:y,k=await Yn(e,t,n,w);if(k.kind==="error"||!k.resource)return{kind:"error",message:k.message};const x=k.resource.translation_key,$=Tn(y),C=k.resource.values??{},S={[n]:y};for(const N of Object.keys(C)){if(N===n)continue;let T=C[N]??"";for(const B of $)T=Ri(T,B);S[N]=T}Co(e,x,S);const D=In(s,a,l);return{kind:"ok",text:`${f?ed(`$t:${x}`,p):td(`$t:${x}`,b)}|${h}=${D}`,key:x}}async function Ir(e,t,n,o,r,s,a){let l=vt(n);if(!l&&typeof n=="string"){const h=/^\s*\$t:(custom\.[A-Za-z0-9._-]+)\s*$/.exec(n);h&&(l={key:h[1],params:[]})}if(!l)return{kind:"error",message:"not a param key"};if(!l.key.startsWith("custom."))return{kind:"error",message:"not a custom param key"};const d=Wb(l.params.map(h=>h.name)),c=In(r,s,a),p=`${n.trim()}|${d}=${c}`,f=await fn(e,l.key),b=cm(l.key)??{},g=new Set([...Object.keys(f?.values??{}),...Object.keys(b),t]);if(g.size===0)return{kind:"error",message:"custom key not found"};const m={};for(const h of g){const v=It(l.key,h)??f?.values?.[h]??"";m[h]=h===t?Xl(v,o,d):Ri(v,d)}return Co(e,l.key,m),{kind:"ok",text:p,paramName:d}}async function Eo(e,t,n,o){return kr(e,t,n,o),{kind:"ok"}}async function Pv(e,t,n){const o=await fn(e,t);if(!o)return{kind:"error",message:"custom key not found"};const r={};for(const[s,a]of Object.entries(o.values??{})){const l=It(t,s)??a;r[s]=n(l)}Co(e,t,r);try{const s=Pt.getInstance();for(const[a,l]of Object.entries(r))s.setTranslationValue(e,a,t,l)}catch{}return{kind:"ok"}}function Jd(e,t,n){return Pv(e,t,o=>id(o,n))}function Zd(e,t){if(!(typeof window>"u"))try{window.dispatchEvent(new CustomEvent(kt,{detail:{templateIdentifier:e,locale:t}}))}catch{}}async function Ar(e,t,n,o){const r=await Jd(e,t,n);return Zd(e,o),r}const Ov=/^\s*\$t:(custom\.[a-zA-Z0-9._-]+)\s*$/;function Bv(e,t){const n=s=>{const a=[],l=/\{\{?(p\d+)\}?\}/g;let d;for(;(d=l.exec(s))!==null;)a.push(d[1]);return a},o=n(e),r=n(t);return o.length!==r.length?!0:o.some((s,a)=>s!==r[a])}function Qd(e){const t=e.text;if(typeof t!="string")return null;const n=Ov.exec(t);if(n)return n[1];const o=vt(t);return o&&o.key.startsWith("custom.")?o.key:null}function ys(e){const t={},n=vt(typeof e=="string"?e:"");for(const o of n?.params??[])t[o.name]=Ut(o.expression);return t}function Wv(e){return ys(typeof e.text=="string"?e.text:"")}function Rd({customKey:e,templateIdentifier:t,t:n,paramLabels:o,locales:r,onRemoveParam:s}){const a=r??vd(),l=Kt(),d=o??{},[c,p]=u.useState({status:"idle",values:{}}),[f,b]=u.useState(!1),[g,m]=u.useState(!1),[h,v]=u.useState(null),y=u.useRef({});u.useEffect(()=>{let E=!1;if(!e){p({status:"not_a_key",values:{}});return}return p({status:"loading",values:{}}),(async()=>{const I=await fn(t,e);if(E)return;if(!I){p({status:"error",values:{}});return}const N={...I.values??{}};for(const T of Object.keys(N)){const B=It(e,T);B!==void 0&&(N[T]=B)}for(const T of a){const B=It(e,T);B!==void 0&&(N[T]=B)}y.current={...N},p({status:"loaded",id:I.id,lockVersion:I.lock_version,values:N})})(),()=>{E=!0}},[e,t]),u.useEffect(()=>{if(typeof window>"u"||!e)return;const E=I=>{const N=I.detail;N?.templateIdentifier&&N.templateIdentifier!==t||p(T=>{if(T.status!=="loaded")return T;let B=!1;const M={...T.values};for(const O of Object.keys(M)){const z=It(e,O);z!==void 0&&z!==M[O]&&(M[O]=z,B=!0)}return B?(y.current={...y.current,...M},{...T,values:M}):T})};return window.addEventListener(kt,E),()=>window.removeEventListener(kt,E)},[e,t]);const _=u.useCallback((E,I)=>{p(N=>{const T=N.values[E]??"",B={...N,values:{...N.values,[E]:I}};return e&&Bv(T,I)&&(kr(t,e,E,I),y.current={...y.current,[E]:I},l?.markDirty?.(),Zd(t,E)),B})},[e,t,l]),w=u.useCallback(E=>{p(I=>{const N={};for(const[T,B]of Object.entries(I.values))N[T]=id(B,E);return y.current={...N},{...I,values:N}}),s?.(E)},[s]),k=u.useMemo(()=>[...Object.values(c.values),...Object.values(y.current)].some(I=>Tn(I).length>0),[c.values]),x=u.useRef(null),$=u.useCallback(()=>{m(!0),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>m(!1),1500)},[]);u.useEffect(()=>()=>{x.current&&clearTimeout(x.current)},[]);const C=u.useCallback(async()=>{if(m(!1),c.status!=="loaded"||c.id===void 0)return;const E=y.current;for(const[N,T]of Object.entries(c.values)){const B=E[N]??"";if(k){const M=Tn(B);if(M.length===0)continue;const O=Tn(T);if(!(M.length===O.length&&M.every((H,P)=>H===O[P]))){v(n("layout_editor.translation.placeholder_mismatch"));return}continue}if(br(B)&&!Gb(B,T)){v(n("layout_editor.translation.token_mismatch"));return}}if(b(!0),v(null),k){Co(t,e??"",c.values),y.current={...c.values},l?.markDirty?.(),Et({op:"translation_field_update",translationKey:e,changedLocales:Object.keys(c.values),timestamp:Date.now()}),await new Promise(N=>setTimeout(N,0)),b(!1),$();return}const I=`/api/admin/templates/${encodeURIComponent(t)}/custom-translations/${c.id}`;try{const N=await fetch(I,{method:"PUT",credentials:"same-origin",headers:Me({"Content-Type":"application/json"}),body:JSON.stringify({values:c.values,expected_lock_version:c.lockVersion??0})}),T=await N.json().catch(()=>null);if(N.status===409){v(n("layout_editor.translation.conflict"));return}if(!N.ok){v(T?.message??n("layout_editor.translation.save_failed"));return}const B=typeof T?.data?.lock_version=="number"?T.data.lock_version:(c.lockVersion??0)+1;p(M=>({...M,lockVersion:B})),y.current={...c.values},await on(t),Et({op:"translation_field_update",translationKey:e,changedLocales:Object.keys(c.values),timestamp:Date.now()}),$()}catch(N){v(N instanceof Error?N.message:n("layout_editor.translation.save_failed"))}finally{b(!1)}},[c,t,e,n]);if(c.status==="not_a_key"||!e)return i.jsx("div",{"data-testid":"g7le-translation-not-a-key",style:bs,children:n("layout_editor.translation.not_a_key")});if(c.status==="loading"||c.status==="idle")return i.jsx("div",{"data-testid":"g7le-translation-loading",style:bs,children:n("layout_editor.translation.loading")});if(c.status==="error")return i.jsx("div",{"data-testid":"g7le-translation-error",style:bs,children:n("layout_editor.translation.load_failed")});const S=new Set([...a,...Object.keys(c.values)]),D=Array.from(S);return i.jsxs("div",{"data-testid":"g7le-translation-field",style:{display:"flex",flexDirection:"column",gap:8},children:[i.jsxs("div",{"data-testid":"g7le-translation-key",style:jv,children:[n("layout_editor.translation.key_label"),": ",i.jsx("code",{style:Hv,children:e})]}),D.map(E=>{const I=c.values[E]??"",N=I.trim().length===0;return i.jsxs("div",{className:"g7le-translation-row","data-testid":`g7le-translation-row-${E}`,style:Fv,children:[i.jsxs("label",{htmlFor:`g7le-translation-input-${E}`,style:{fontSize:12,color:"#475569",minWidth:72,display:"inline-flex",alignItems:"center",gap:4},children:[Xn(E,n),N&&i.jsx("span",{"data-testid":`g7le-translation-missing-${E}`,style:Kv,children:n("layout_editor.translation.needs_translation")})]}),k?i.jsx("div",{style:{flex:1},"data-testid":`g7le-translation-chip-${E}`,children:i.jsx(Sr,{value:I,onChange:T=>_(E,T),t:n,paramLabels:d,testIdSuffix:E,onRemoveChip:s?w:void 0})}):i.jsx("input",{id:`g7le-translation-input-${E}`,type:"text","data-testid":`g7le-translation-input-${E}`,value:I,placeholder:N?n("layout_editor.translation.needs_translation"):"",onChange:T=>_(E,T.currentTarget.value),onBlur:C,style:{flex:1,padding:"4px 8px",fontSize:13,border:"1px solid #cbd5e1",borderRadius:4,color:N?"#94a3b8":"#0f172a"}})]},E)}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i.jsx("button",{type:"button","data-testid":"g7le-translation-save",disabled:f,onClick:C,style:Vv,children:n(f?"layout_editor.translation.saving":"layout_editor.translation.save")}),g&&!f&&i.jsxs("span",{"data-testid":"g7le-translation-saved",style:{fontSize:11,color:"#16a34a",display:"inline-flex",alignItems:"center",gap:4},children:["✓ ",n("layout_editor.translation.saved")]}),h&&i.jsx("span",{"data-testid":"g7le-translation-save-error",style:{fontSize:11,color:"#dc2626"},children:h})]})]})}const bs={fontSize:12,color:"#94a3b8",padding:"16px 0",textAlign:"center"},jv={fontSize:12,color:"#475569"},Hv={fontSize:11,background:"#f1f5f9",padding:"1px 4px",borderRadius:3,color:"#0f172a"},Fv={display:"flex",alignItems:"center",gap:8},Kv={fontSize:10,color:"#b45309",background:"#fef3c7",padding:"0 4px",borderRadius:3},Vv={padding:"6px 12px",fontSize:12,border:"none",borderRadius:6,background:"#2563eb",color:"#fff",cursor:"pointer"};function Zn({anchorRef:e,open:t,onClose:n,children:o,placement:r="bottom",minWidth:s=240,maxWidth:a=360,margin:l=8,testid:d}){const c=u.useRef(null),[p,f]=u.useState(null),b=u.useCallback(()=>{const m=e.current,h=c.current;if(!m||!h)return;const v=m.getBoundingClientRect(),y=window.innerWidth,_=window.innerHeight,w=h.getBoundingClientRect(),k=Math.min(Math.max(w.width,s),a),x=w.height;let $=v.left;$+k+l>y&&($=v.right-k),$=Math.min(Math.max($,l),y-k-l);const C=_-v.bottom-l,S=v.top-l;let D,E;const I=r==="bottom",N=C>=Math.min(x,160),T=S>=Math.min(x,160);I&&N||I&&!T?(D=v.bottom+4,E=C):!I&&T||T?(D=v.top-4-Math.min(x,S),E=S):C>=S?(D=v.bottom+4,E=C):(D=l,E=S),f({left:$,top:D,maxHeight:Math.max(E,120)})},[e,r,s,a,l]);if(u.useLayoutEffect(()=>{if(!t){f(null);return}b()},[t,b]),u.useEffect(()=>{if(!t)return;const m=()=>b();window.addEventListener("resize",m),window.addEventListener("scroll",m,!0);const h=y=>{const _=c.current,w=e.current,k=y.target;_?.contains(k)||w?.contains(k)||n()},v=y=>{y.key==="Escape"&&n()};return document.addEventListener("pointerdown",h,!0),document.addEventListener("keydown",v),()=>{window.removeEventListener("resize",m),window.removeEventListener("scroll",m,!0),document.removeEventListener("pointerdown",h,!0),document.removeEventListener("keydown",v)}},[t,b,n,e]),!t)return null;const g={...Uv,minWidth:s,maxWidth:`min(${a}px, calc(100vw - ${l*2}px))`,...p?{left:p.left,top:p.top,maxHeight:p.maxHeight,visibility:"visible"}:{left:-9999,top:-9999,visibility:"hidden"}};return i.jsx("div",{ref:c,"data-testid":d,style:g,role:"dialog",children:o})}const Uv={position:"fixed",zIndex:1e3,background:"#fff",border:"1px solid #cbd5e1",borderRadius:8,boxShadow:"0 4px 16px rgba(0,0,0,0.14)",padding:6,overflowY:"auto",boxSizing:"border-box"};function ec(e,t,n){if(!t)return n;const o=e(t);return!o||o===t||o.startsWith("$t:")?n:o}function $t({candidates:e,t,onSelect:n,testIdSuffix:o,defaultOpen:r=!1,floating:s=!0}){const[a,l]=u.useState(r),[d,c]=u.useState(""),p=u.useRef(null),f=u.useMemo(()=>Ji(e,"scalar").map(h=>({...h,resolvedLabel:ec(t,h.labelKey,h.path||h.sourceId)})),[e,t]),b=u.useMemo(()=>Zi(f,d),[f,d]),g=i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"text",autoFocus:!0,"data-testid":`g7le-inline-binding-search-input-${o}`,value:d,placeholder:t("layout_editor.inline_binding.search_placeholder"),onChange:m=>c(m.target.value),style:Xv}),i.jsx("div",{style:Jv,children:b.length===0?i.jsx("div",{style:Zv,children:t("layout_editor.inline_binding.no_results")}):b.map(m=>i.jsxs("button",{type:"button","data-testid":`g7le-inline-binding-candidate-${m.expression}`,onClick:()=>{n(m),l(!1),c("")},style:Qv,children:[i.jsxs("span",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start"},children:[i.jsx("span",{style:{fontSize:12},children:m.resolvedLabel}),i.jsxs("span",{style:Rv,children:[ec(t,m.groupLabelKey,m.sourceId)," · ",m.path||m.sourceId]})]}),i.jsx("span",{style:e_,children:m.preview})]},m.expression))})]});return i.jsxs("div",{style:s?Yv:{marginTop:4},children:[i.jsx("button",{ref:p,type:"button","data-testid":`g7le-inline-binding-search-toggle-${o}`,onClick:()=>l(m=>!m),title:t("layout_editor.inline_binding.search"),"aria-label":t("layout_editor.inline_binding.search"),"aria-expanded":a,style:qv,children:"🔍"}),s?i.jsx(Zn,{anchorRef:p,open:a,onClose:()=>l(!1),testid:`g7le-inline-binding-picker-${o}`,children:g}):a&&i.jsx("div",{"data-testid":`g7le-inline-binding-picker-${o}`,style:Gv,children:g})]})}const qv={fontSize:13,lineHeight:1,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#334155",padding:"4px 8px",cursor:"pointer",textAlign:"center",whiteSpace:"nowrap"},Gv={marginTop:4,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",padding:6},Yv={display:"inline-block"},Xv={width:"100%",padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,boxSizing:"border-box"},Jv={marginTop:4,maxHeight:200,overflowY:"auto",display:"flex",flexDirection:"column",gap:2},Zv={fontSize:11,color:"#94a3b8",padding:"8px 0",textAlign:"center"},Qv={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,border:"none",background:"transparent",cursor:"pointer",padding:"6px 8px",borderRadius:4,textAlign:"left"},Rv={fontSize:10,color:"#94a3b8"},e_={fontSize:10,color:"#64748b",fontFamily:"monospace",whiteSpace:"nowrap"},t_=["$localized"];function Qn(e){const t=e.trim();if(!t.startsWith("{{")||!t.endsWith("}}")||t.length<4)return null;let n=0;for(let o=0;ogn(n).decomposed)}function Io(e,t,n,o){switch(e.kind){case"leaf":nc(e.text,t,n,o);return;case"conditional":Io(e.then,t,n,o),o.push({kind:"ellipsis",text:"⋯"});return;case"fallback":Io(e.primary,t,n,o);return;case"concat":e.parts.forEach(r=>Io(r,t,n,o));return;case"raw":default:o.push({kind:"text",text:e.source});return}}function nc(e,t,n,o){const r=e.trim();if(/^\{\{([\s\S]*)\}\}$/.exec(r)&&!r.slice(2,-2).includes("}}")){o.push({kind:"chip",text:n(r)});return}if(r.startsWith("$t:")){const a=r.slice(3).split("|")[0];o.push({kind:"text",text:t(a)||a});return}for(const a of e.split(/(\{\{(?:[^}]|\}(?!\}))*\}\})/g))a!==""&&(/^\{\{[\s\S]*\}\}$/.test(a)?o.push({kind:"chip",text:n(a)}):o.push({kind:"text",text:a}))}function ms(e,t,n){const o=[];if(typeof e!="string"||e==="")return o;if(Qn(e)===null&&/\{\{/.test(e)){for(const a of e.split(/(\{\{(?:[^}]|\}(?!\}))*\}\})/g))if(!(a===void 0||a===""))if(/^\{\{[\s\S]*\}\}$/.test(a)){const l=gn(a);Io(l.node,t,n,o)}else nc(a,t,n,o);return o}const s=gn(e);return Io(s.node,t,n,o),o}function n_(e){if(typeof e!="string"||e.trim()==="")return"empty";const t=e.trim();if(Qn(t)===null)return"simple";const n=gn(e);return n.node.kind==="leaf"?"simple":n.decomposed?"expression":"raw"}function gn(e){const t=typeof e=="string"?e:"",n=t.trim();if(n==="")return{node:{kind:"leaf",text:t},decomposed:!1,original:t};const o=Qn(n);if(o===null)return{node:{kind:"leaf",text:t},decomposed:!1,original:t};let r;try{r=u_(o)}catch{r=null}if(r===null)return{node:{kind:"raw",source:o},decomposed:!1,original:t};if(r.kind==="leaf"||r.kind==="raw")return{node:r,decomposed:!1,original:t};if(r.kind==="fallback"&&r.op==="??"&&o_(r.primary)&&r_(r.fallback))return{node:{kind:"leaf",text:t},decomposed:!1,original:t};const s=Rn(r,!0);return y_(o,s)?{node:r,decomposed:!0,original:t}:{node:{kind:"raw",source:o},decomposed:!1,original:t}}function Rn(e,t=!1){const n=rc(e);return t?n:e.kind==="leaf"?e.text:`{{${n}}}`}function Ao(e){return Rn({kind:"conditional",condition:{kind:"simple",left:"",op:"truthy",right:""},then:{kind:"leaf",text:typeof e=="string"?e:""},else:{kind:"leaf",text:""}},!1)}function vs(e){return Rn({kind:"fallback",op:"??",primary:{kind:"leaf",text:typeof e=="string"?e:""},fallback:{kind:"leaf",text:""}},!1)}function To(e){switch(e.kind){case"leaf":return e.text;case"conditional":return To(e.then);case"fallback":return To(e.primary);case"concat":return e.parts.map(To).join("");case"raw":default:return e.kind==="raw"?`{{${e.source}}}`:""}}function t5(e){return e}function Tr(e){if(typeof e!="string"||e.trim()==="")return"";if(Qn(e)===null&&/\{\{/.test(e)){for(const n of e.split(/(\{\{(?:[^}]|\}(?!\}))*\}\})/g))if(!(n===void 0||n===""))return/^\{\{[\s\S]*\}\}$/.test(n)?To(gn(n).node):n;return""}return To(gn(e).node)}function o_(e){if(e.kind!=="leaf")return!1;const t=/^\{\{([\s\S]*)\}\}$/.exec(e.text.trim());return t?eo(t[1].trim()):!1}function r_(e){if(e.kind!=="leaf")return!1;const t=e.text.trim();return!(/\{\{/.test(t)||t.startsWith("$t:"))}function Dr(e){return`'${e.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}'`}function i_(e){const t=[];let n=0,o=0;const r=e.length;for(;on&&t.push(Dr(e.slice(n,o)));let s=o+2;for(;s=r)break;const a=e.slice(o+2,s).trim();t.push(a),o=s+2,n=o;continue}o++}return nDo(t,"concat")).join(" + ");case"fallback":return`${Do(e.primary,"fallback")} ${e.op} ${Do(e.fallback,"fallback")}`;case"conditional":return`${a_(e.condition)} ? ${Do(e.then,"conditional")} : ${Do(e.else,"conditional")}`;default:return""}}function Do(e,t){const n=rc(e);return e.kind==="leaf"||e.kind==="raw"?n:e.kind==="conditional"?t==="conditional"?n:`(${n})`:e.kind==="fallback"?t==="concat"?`(${n})`:n:(e.kind==="concat",n)}const d_=["===","!==","??","||","&&","==","!=",">=","<="];function ic(e){const t=[];let n=0;const o=e.length;for(;n=o)throw new Error("unterminated-binding-in-string");d+=e.slice(l,c+2),l=c+2;continue}if(e[l]===a){d+=a,l++;break}if(a==="`"&&e[l]==="$"&&e[l+1]==="{")throw new Error("template-literal-interpolation-unsupported");d+=e[l],l++}if(l>o||d[d.length-1]!==a)throw new Error("unterminated-string");t.push({kind:"string",value:d,start:n,end:l}),n=l;continue}if(r==="{"&&e[n+1]==="{"){let a=n+2;for(;a"||r==="<"){t.push({kind:"op",value:r,start:n,end:n+1}),n++;continue}if(r==="!"){t.push({kind:"op",value:"!",start:n,end:n+1}),n++;continue}if(r==="("){t.push({kind:"lparen",value:"(",start:n,end:n+1}),n++;continue}if(r===")"){t.push({kind:"rparen",value:")",start:n,end:n+1}),n++;continue}if(r==="["){t.push({kind:"lbracket",value:"[",start:n,end:n+1}),n++;continue}if(r==="]"){t.push({kind:"rbracket",value:"]",start:n,end:n+1}),n++;continue}if(r==="."){t.push({kind:"dot",value:".",start:n,end:n+1}),n++;continue}if(/[0-9]/.test(r)){let a=n;for(;a=n)return"";const o=this.toks[t].start,r=this.toks[n-1].end;return this.src.slice(o,r)}parseFallback(){let t=this.parseConcat(),n=this.peek();for(;n&&n.kind==="op"&&(n.value==="??"||n.value==="||");){const o=n.value;this.next();const r=this.parseConcat();t={kind:"fallback",op:o,primary:t,fallback:r},n=this.peek()}return t}parseConcat(){const t=this.parseUnaryOrPrimary(),n=[t];let o=this.peek();for(;o&&o.kind==="op"&&o.value==="+";)this.next(),n.push(this.parseUnaryOrPrimary()),o=this.peek();return n.length===1?t:{kind:"concat",parts:n}}parseUnaryOrPrimary(){return this.parsePrimary()}parsePrimary(){const t=this.peek();if(!t)throw new Error("unexpected-end");if(t.kind==="lparen"){this.next();const n=this.parseTernary(),o=this.next();if(!o||o.kind!=="rparen")throw new Error("expected-rparen");return n}if(t.kind==="string")return this.next(),{kind:"leaf",text:ac(t.value)};if(t.kind==="tkey")return this.next(),{kind:"leaf",text:t.value};if(t.kind==="binding")return this.next(),{kind:"leaf",text:t.value};if(t.kind==="ident"&&t_.includes(t.value)&&this.toks[this.pos+1]?.kind==="lparen"){const n=this.tryParsePathWrapperCall(t.value);if(n!==null)return n;throw new Error("path-wrapper-non-simple-arg")}if(t.kind==="ident")return{kind:"leaf",text:`{{${this.parsePath()}}}`};if(t.kind==="number")return this.next(),{kind:"leaf",text:t.value};throw new Error(`unparseable-primary:${t.kind}`)}parsePath(){let t="";const n=this.next();if(!n||n.kind!=="ident")throw new Error("expected-ident");for(t+=n.value;;){const o=this.peek();if(!o)break;if(o.kind==="op"&&o.value==="?"&&this.toks[this.pos+1]?.kind==="dot"){this.next(),this.next();const r=this.next();if(!r||r.kind!=="ident")throw new Error("expected-ident-after-optional");t+="?."+r.value;continue}if(o.kind==="dot"){this.next();const r=this.next();if(!r||r.kind!=="ident")throw new Error("expected-ident-after-dot");t+="."+r.value;continue}if(o.kind==="lbracket"){this.next();const r=this.next(),s=this.next();if(!s||s.kind!=="rbracket")throw new Error("expected-rbracket");if(r&&(r.kind==="number"||r.kind==="string")){t+=`[${r.value}]`;continue}throw new Error("non-literal-index")}if(o.kind==="lparen")throw new Error("call-expression");break}return t}tryParsePathWrapperCall(t){const n=this.pos;this.next();const o=this.next();if(!o||o.kind!=="lparen")return this.pos=n,null;let r;try{if(this.peek()?.kind!=="ident")return this.pos=n,null;r=this.parsePath()}catch{return this.pos=n,null}const s=this.next();return!s||s.kind!=="rparen"?(this.pos=n,null):{kind:"leaf",text:`{{${t}(${r})}}`}}}function u_(e){return new c_(e).parse()}const p_=["===","!==","==","!=",">=","<=",">","<"];function f_(e,t){const n=e.trim();if(n==="")return{kind:"raw",source:n};if(n===oc)return{kind:"simple",left:"",op:"truthy",right:""};if(n.startsWith("!")){const s=n.slice(1).trim(),a=sc(s);return eo(a)?{kind:"simple",left:a,op:"falsy",right:""}:{kind:"raw",source:n}}const o=g_(n);if(o){const{left:s,op:a,right:l}=o,d=s.trim(),c=l.trim();return eo(d)&&(c==="''"||c==='""')?{kind:"simple",left:d,op:a,right:""}:eo(d)&&h_(c)?{kind:"simple",left:d,op:a,right:c}:{kind:"raw",source:n}}const r=sc(n);return eo(r)?{kind:"simple",left:r,op:"truthy",right:""}:{kind:"raw",source:n}}function g_(e){let t=0,n=null;for(let o=0;o=o||!/[A-Za-z_$]/.test(t[n]))return!1;for(n++;n=o||!/[A-Za-z_$]/.test(t[n]))return!1;for(n++;n=2&&(t[0]==="'"||t[0]==='"'||t[0]==="`")?t.slice(1,-1).replace(/\\(['"`\\])/g,"$1"):t}function y_(e,t){try{return zr(e)===zr(t)}catch{return!1}}function zr(e){const t=Qn(e);return t!==null?zr(t):ic(e).map(o=>{if(o.kind==="string")return`S:${ac(o.value)}`;if(o.kind==="binding"){const r=/^\{\{([\s\S]*)\}\}$/.exec(o.value);return`B:${r?zr(r[1].trim()):o.value.replace(/\s+/g,"")}`}return o.kind==="tkey"?`S:${o.value}`:o.kind==="op"?`O:${o.value}`:o.kind==="ident"||o.kind==="number"?`I:${o.value}`:o.kind==="dot"?".":o.kind==="lbracket"?"[":o.kind==="rbracket"?"]":o.kind==="lparen"||o.kind==="rparen"?"":`X:${o.value}`}).join("")}function to({active:e,testid:t}){return i.jsx("div",{"data-testid":t,"data-active":e?"true":"false","aria-hidden":"true",style:e?m_:b_})}const b_={height:0,margin:0,transition:"height 80ms"},m_={height:3,margin:"1px 0",borderRadius:2,background:"#2563eb",boxShadow:"0 0 0 1px #93c5fd"};function _s(e){const{length:t,onMove:n,canDrag:o,canDropAt:r}=e,[s,a]=u.useState(null),[l,d]=u.useState(null),c=u.useCallback(m=>{o&&!o(m)||(a(m),d(m))},[o]),p=u.useCallback(()=>{a(null),d(null)},[]),f=u.useCallback((m,h)=>{if(s===null)return;const v=h==="before"?m:m+1;if(r&&!r(s,v)){d(null);return}d(v)},[s,r]),b=u.useCallback(()=>{if(s!==null&&l!==null){const m=l>s?l-1:l;m!==s&&(!r||r(s,l))&&n(s,m)}a(null),d(null)},[s,l,n,r]),g=u.useCallback(m=>s!==null&&l===m&&m<=t,[s,l,t]);return{dragIndex:s,dropIndex:l,dragging:s!==null,onDragStart:c,onDragEnd:p,onDragOverItem:f,onDrop:b,isDropTarget:g}}const v_={text:"",expression:"{{false ? '' : ''}}",fallback:"{{'' ?? ''}}",data:""};function lc(e,t){const n=An(e);let o=t;const r=n.map(s=>({id:o++,kind:s.kind==="literal"?"text":"expression",value:s.raw}));return r.length===0&&r.push({id:o++,kind:"text",value:""}),{segs:r,nextSeq:o}}function xs({value:e,onChange:t,t:n,candidates:o,testidPrefix:r="g7le-seg-value",renderLeafInput:s}){const a=u.useRef(0),l=u.useRef(e),d=u.useMemo(()=>{const w=lc(e,a.current);return a.current=w.nextSeq,w.segs},[]),[c,p]=u.useState(d),[f,b]=u.useState(!1);if(e!==l.current){l.current=e;const w=c.map(k=>k.value).join("");if(e!==w){const k=lc(e,a.current);a.current=k.nextSeq,p(k.segs)}}const g=u.useCallback(w=>{p(w);const k=w.map(x=>x.value).join("");l.current=k,t(k)},[t]),m=u.useCallback((w,k)=>{g(c.map(x=>x.id===w?{...x,value:k??""}:x))},[c,g]),h=u.useCallback(w=>{const k=c.filter(x=>x.id!==w);g(k.length>0?k:[{id:a.current++,kind:"text",value:""}])},[c,g]),v=u.useCallback(w=>{g([...c,{id:a.current++,kind:w,value:v_[w]}])},[c,g]),y=u.useCallback((w,k)=>{if(w===k||w<0||k<0||w>=c.length||k>=c.length)return;const x=c.slice(),[$]=x.splice(w,1);x.splice(k,0,$),g(x)},[c,g]),_=_s({length:c.length,onMove:y});return i.jsxs("div",{"data-testid":r,style:w_,children:[i.jsx("div",{style:k_,children:n("layout_editor.value_tree.segmented_hint")}),c.map((w,k)=>i.jsxs(u.Fragment,{children:[i.jsx(to,{active:_.isDropTarget(k),testid:`${r}-dropline-${k}`}),i.jsx(x_,{seg:w,index:k,t:n,candidates:o,testidPrefix:r,renderLeafInput:s,onValueChange:x=>m(w.id,x),onRemove:()=>h(w.id),dragging:_.dragIndex===k,onDragStartCard:()=>_.onDragStart(k),onDragEndCard:_.onDragEnd,onDragOverCard:x=>_.onDragOverItem(k,x),onDropCard:_.onDrop})]},w.id)),i.jsx(to,{active:_.isDropTarget(c.length),testid:`${r}-dropline-end`}),i.jsxs("div",{style:A_,"data-testid":`${r}-add-row`,children:[i.jsxs("button",{type:"button","data-testid":`${r}-add-text`,onClick:()=>v("text"),style:Nr,children:["+ ",n("layout_editor.value_tree.segment.text")]}),i.jsxs("button",{type:"button","data-testid":`${r}-add-expression`,onClick:()=>v("expression"),style:Nr,children:["+ ",n("layout_editor.value_tree.segment.expression")]}),i.jsxs("button",{type:"button","data-testid":`${r}-add-fallback`,onClick:()=>v("fallback"),style:Nr,children:["+ ",n("layout_editor.value_tree.segment.fallback")]}),i.jsxs("button",{type:"button","data-testid":`${r}-add-data`,onClick:()=>v("data"),style:Nr,children:["+ ",n("layout_editor.value_tree.segment.data")]})]}),i.jsxs("div",{style:z_,children:[i.jsxs("button",{type:"button","data-testid":`${r}-source-toggle`,"aria-expanded":f,onClick:()=>b(w=>!w),style:N_,children:[""," ",n("layout_editor.value_tree.show_source")," ",f?"▴":"▾"]}),f&&i.jsx("code",{"data-testid":`${r}-source-code`,style:M_,children:c.map(w=>w.value).join("")})]})]})}function __({t:e,candidates:t,onPick:n,testidPrefix:o}){return!t||t.length===0?i.jsx("div",{"data-testid":`${o}-data-empty`,style:D_,children:e("layout_editor.value_tree.segment.data_no_candidates")}):i.jsxs("div",{"data-testid":`${o}-data-picker`,style:{minWidth:0},children:[i.jsx("div",{style:T_,children:e("layout_editor.value_tree.segment.data_pick_hint")}),i.jsx($t,{candidates:t,t:e,onSelect:r=>{n(In(r.sourceId,r.path,"scalar"))},testIdSuffix:`${o}-data`,defaultOpen:!0,floating:!0})]})}function x_({seg:e,index:t,t:n,candidates:o,testidPrefix:r,renderLeafInput:s,onValueChange:a,onRemove:l,dragging:d,onDragStartCard:c,onDragEndCard:p,onDragOverCard:f,onDropCard:b}){const g=e.kind==="text"?"layout_editor.value_tree.segment.text":e.kind==="data"?"layout_editor.value_tree.segment.data":e.kind==="fallback"?"layout_editor.value_tree.segment.fallback":"layout_editor.value_tree.segment.expression";return i.jsxs("div",{"data-testid":`${r}-card-${t}`,"data-seg-kind":e.kind,style:d?{...dc,opacity:.5}:dc,onDragOver:m=>{m.preventDefault();const h=m.currentTarget.getBoundingClientRect();f(m.clientY{m.preventDefault(),b()},children:[i.jsxs("div",{style:S_,children:[i.jsx("span",{"data-testid":`${r}-drag-${t}`,style:E_,draggable:!0,onDragStart:c,onDragEnd:p,title:n("layout_editor.value_tree.drag_reorder"),"aria-label":n("layout_editor.value_tree.drag_reorder"),role:"button",children:"⠿"}),i.jsx("span",{style:C_,children:n(g)}),i.jsx("button",{type:"button","data-testid":`${r}-remove-${t}`,onClick:l,title:n("layout_editor.value_tree.segment.remove"),"aria-label":n("layout_editor.value_tree.segment.remove"),style:I_,children:"✕"})]}),i.jsx("div",{style:$_,children:e.kind==="data"&&e.value.trim()===""?i.jsx(__,{t:n,candidates:o,onPick:a,testidPrefix:`${r}-field-${t}`}):s?s({value:e.value,onChange:a,t:n,candidates:o,testidPrefix:`${r}-field-${t}`}):i.jsx(_t,{value:e.value,onChange:a,t:n,candidates:o,testidPrefix:`${r}-field-${t}`,enableExpressionTree:!0,expressionSourceToggle:!1})})]})}const w_={display:"flex",flexDirection:"column",gap:6,width:"100%",minWidth:0},k_={fontSize:11,color:"#64748b"},dc={display:"flex",flexDirection:"column",gap:4,padding:"6px 8px",border:"1px solid #e2e8f0",borderLeft:"3px solid #6366f1",borderRadius:6,background:"#f8fafc",minWidth:0},S_={display:"flex",alignItems:"center",gap:6,minWidth:0},C_={fontSize:10,fontWeight:600,color:"#6366f1",flex:1,minWidth:0},$_={minWidth:0},E_={color:"#94a3b8",cursor:"grab",fontSize:14,userSelect:"none"},I_={border:"none",background:"transparent",color:"#94a3b8",cursor:"pointer",fontSize:12,padding:2,flexShrink:0},A_={display:"flex",flexWrap:"wrap",gap:6,marginTop:2},T_={fontSize:11,color:"#64748b",marginBottom:2},D_={fontSize:11,color:"#94a3b8",padding:"4px 0"},Nr={padding:"4px 10px",fontSize:11,border:"1px dashed #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",whiteSpace:"nowrap"},z_={display:"flex",flexDirection:"column",gap:4,marginTop:2},N_={alignSelf:"flex-start",padding:"3px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer",fontFamily:"monospace"},M_={fontSize:11,background:"#0f172a",color:"#e2e8f0",padding:"6px 8px",borderRadius:4,wordBreak:"break-all",fontFamily:"monospace"},L_=[{value:"truthy",labelKey:"layout_editor.value_tree.cond.op_truthy"},{value:"falsy",labelKey:"layout_editor.value_tree.cond.op_falsy"},{value:"===",labelKey:"layout_editor.value_tree.cond.op_eq"},{value:"!==",labelKey:"layout_editor.value_tree.cond.op_neq"},{value:">",labelKey:"layout_editor.value_tree.cond.op_gt"},{value:"<",labelKey:"layout_editor.value_tree.cond.op_lt"},{value:">=",labelKey:"layout_editor.value_tree.cond.op_gte"},{value:"<=",labelKey:"layout_editor.value_tree.cond.op_lte"}];function cc({node:e,onChange:t,t:n,candidates:o,testidPrefix:r="g7le-value-tree",depth:s=0,showSourceToggle:a=!0,renderLeafInput:l}){const[d,c]=u.useState(!1),p=s===0,f=i.jsx(no,{node:e,onChange:t,t:n,candidates:o,testidPrefix:r,depth:s,renderLeafInput:l});return p?a?i.jsxs("div",{"data-testid":r,style:pc,children:[f,i.jsxs("div",{style:tx,children:[i.jsxs("button",{type:"button","data-testid":`${r}-source-toggle`,"aria-expanded":d,onClick:()=>c(b=>!b),style:nx,children:[""," ",n("layout_editor.value_tree.show_source")," ",d?"▴":"▾"]}),d&&i.jsx("code",{"data-testid":`${r}-source-code`,style:ox,children:Rn(e,!1)})]})]}):i.jsx("div",{"data-testid":r,style:pc,children:f}):f}function no({node:e,onChange:t,t:n,candidates:o,testidPrefix:r,depth:s,renderLeafInput:a}){switch(e.kind){case"leaf":return i.jsx(xs,{value:e.text,onChange:l=>t({kind:"leaf",text:l}),t:n,candidates:o,testidPrefix:`${r}-leaf`,renderLeafInput:a});case"conditional":return i.jsx(P_,{node:e,onChange:t,t:n,candidates:o,testidPrefix:r,depth:s,renderLeafInput:a});case"fallback":return i.jsx(O_,{node:e,onChange:t,t:n,candidates:o,testidPrefix:r,depth:s,renderLeafInput:a});case"concat":return i.jsx(W_,{node:e,onChange:t,t:n,candidates:o,testidPrefix:r,depth:s,renderLeafInput:a});case"raw":default:return i.jsxs("div",{"data-testid":`${r}-raw`,style:rx,children:[i.jsx("code",{style:hc,children:e.source??""}),i.jsxs("span",{style:yc,children:["🔒 ",n("layout_editor.value_tree.raw_code_only")]})]})}}function P_({node:e,onChange:t,t:n,candidates:o,testidPrefix:r,depth:s,renderLeafInput:a}){const l=u.useCallback(p=>t({...e,condition:p}),[e,t]),d=u.useCallback(p=>t({...e,then:p}),[e,t]),c=u.useCallback(p=>t({...e,else:p}),[e,t]);return i.jsxs("div",{"data-testid":`${r}-conditional`,style:ws(s),children:[i.jsx(j_,{condition:e.condition,onChange:l,t:n,candidates:o,testidPrefix:r}),i.jsx(Mr,{label:n("layout_editor.value_tree.cond.when_true"),testid:`${r}-then`,children:i.jsx(no,{node:e.then,onChange:d,t:n,candidates:o,testidPrefix:`${r}-then`,depth:s+1,renderLeafInput:a})}),i.jsx(Mr,{label:n("layout_editor.value_tree.cond.when_false"),testid:`${r}-else`,children:i.jsx(no,{node:e.else,onChange:c,t:n,candidates:o,testidPrefix:`${r}-else`,depth:s+1,renderLeafInput:a})})]})}function O_({node:e,onChange:t,t:n,candidates:o,testidPrefix:r,depth:s,renderLeafInput:a}){const l=u.useCallback(c=>t({...e,primary:c}),[e,t]),d=u.useCallback(c=>t({...e,fallback:c}),[e,t]);return i.jsxs("div",{"data-testid":`${r}-fallback`,style:ws(s),children:[i.jsx(Mr,{label:n("layout_editor.value_tree.fallback.primary"),testid:`${r}-primary`,children:i.jsx(no,{node:e.primary,onChange:l,t:n,candidates:o,testidPrefix:`${r}-primary`,depth:s+1,renderLeafInput:a})}),i.jsx(Mr,{label:n(e.op==="??"?"layout_editor.value_tree.fallback.when_empty":"layout_editor.value_tree.fallback.when_falsy"),testid:`${r}-fallback-branch`,children:i.jsx(no,{node:e.fallback,onChange:d,t:n,candidates:o,testidPrefix:`${r}-fallbackb`,depth:s+1,renderLeafInput:a})})]})}const B_={text:()=>({kind:"leaf",text:""}),data:()=>({kind:"leaf",text:""}),expression:()=>({kind:"conditional",condition:{kind:"simple",left:"",op:"truthy",right:""},then:{kind:"leaf",text:""},else:{kind:"leaf",text:""}}),fallback:()=>({kind:"fallback",op:"??",primary:{kind:"leaf",text:""},fallback:{kind:"leaf",text:""}})};function W_({node:e,onChange:t,t:n,candidates:o,testidPrefix:r,depth:s,renderLeafInput:a}){const l=u.useCallback((g,m)=>{const h=e.parts.slice();h[g]=m,t({...e,parts:h})},[e,t]),d=u.useCallback(g=>{g.length===0?t({kind:"leaf",text:""}):g.length===1?t(g[0]):t({...e,parts:g})},[e,t]),c=u.useCallback(g=>d(e.parts.filter((m,h)=>h!==g)),[e.parts,d]),p=u.useCallback(g=>d([...e.parts,B_[g]()]),[e.parts,d]),f=u.useCallback((g,m)=>{if(g===m||g<0||m<0||g>=e.parts.length||m>=e.parts.length)return;const h=e.parts.slice(),[v]=h.splice(g,1);h.splice(m,0,v),d(h)},[e.parts,d]),b=_s({length:e.parts.length,onMove:f});return i.jsxs("div",{"data-testid":`${r}-concat`,style:ws(s),children:[i.jsx("div",{style:X_,children:n("layout_editor.value_tree.concat.hint")}),e.parts.map((g,m)=>i.jsxs(u.Fragment,{children:[i.jsx(to,{active:b.isDropTarget(m),testid:`${r}-part-dropline-${m}`}),i.jsxs("div",{"data-testid":`${r}-part-card-${m}`,style:b.dragIndex===m?{...gc,opacity:.5}:gc,onDragOver:h=>{h.preventDefault();const v=h.currentTarget.getBoundingClientRect();b.onDragOverItem(m,h.clientY{h.preventDefault(),b.onDrop()},children:[i.jsxs("div",{style:J_,children:[i.jsx("span",{"data-testid":`${r}-part-handle-${m}`,style:R_,draggable:!0,onDragStart:()=>b.onDragStart(m),onDragEnd:b.onDragEnd,title:n("layout_editor.value_tree.drag_reorder"),"aria-label":n("layout_editor.value_tree.drag_reorder"),role:"button",children:"⠿"}),i.jsx("span",{style:Z_,children:n("layout_editor.value_tree.concat.part",{n:m+1})}),i.jsx("button",{type:"button","data-testid":`${r}-part-remove-${m}`,onClick:()=>c(m),title:n("layout_editor.value_tree.segment.remove"),"aria-label":n("layout_editor.value_tree.segment.remove"),style:ex,children:"✕"})]}),i.jsx("div",{style:{minWidth:0},children:i.jsx(no,{node:g,onChange:h=>l(m,h),t:n,candidates:o,testidPrefix:`${r}-part-${m}`,depth:s+1,renderLeafInput:a})})]})]},m)),i.jsx(to,{active:b.isDropTarget(e.parts.length),testid:`${r}-part-dropline-end`}),i.jsxs("div",{style:Q_,"data-testid":`${r}-part-add-row`,children:[i.jsxs("button",{type:"button","data-testid":`${r}-part-add-text`,onClick:()=>p("text"),style:Lr,children:["+ ",n("layout_editor.value_tree.segment.text")]}),i.jsxs("button",{type:"button","data-testid":`${r}-part-add-expression`,onClick:()=>p("expression"),style:Lr,children:["+ ",n("layout_editor.value_tree.segment.expression")]}),i.jsxs("button",{type:"button","data-testid":`${r}-part-add-fallback`,onClick:()=>p("fallback"),style:Lr,children:["+ ",n("layout_editor.value_tree.segment.fallback")]}),i.jsxs("button",{type:"button","data-testid":`${r}-part-add-data`,onClick:()=>p("data"),style:Lr,children:["+ ",n("layout_editor.value_tree.segment.data")]})]})]})}function j_({condition:e,onChange:t,t:n,candidates:o,testidPrefix:r}){if(e.kind==="raw")return i.jsxs("div",{"data-testid":`${r}-cond-raw`,style:U_,children:[i.jsx("span",{style:fc,children:n("layout_editor.value_tree.cond.label")}),i.jsx("code",{style:hc,children:e.source}),i.jsxs("span",{style:yc,children:["🔒 ",n("layout_editor.value_tree.cond.code_only")]})]});const s=e,a=s.op!=="truthy"&&s.op!=="falsy";return i.jsxs("div",{"data-testid":`${r}-cond`,style:V_,children:[i.jsx("span",{style:fc,children:n("layout_editor.value_tree.cond.label")}),i.jsx(uc,{testid:`${r}-cond-left`,value:s.left,onCommit:l=>t({...s,left:l}),placeholder:n("layout_editor.value_tree.cond.field_placeholder"),candidates:o,t:n}),i.jsx("select",{"data-testid":`${r}-cond-op`,value:s.op,onChange:l=>t({...s,op:l.target.value}),style:Y_,children:L_.map(l=>i.jsx("option",{value:l.value,children:n(l.labelKey)},l.value))}),a&&i.jsx(uc,{testid:`${r}-cond-right`,value:s.right,onCommit:l=>t({...s,right:l}),placeholder:n("layout_editor.value_tree.cond.value_placeholder"),candidates:o,t:n,quoteDataPick:!0})]})}function uc({testid:e,value:t,onCommit:n,placeholder:o,candidates:r,t:s,quoteDataPick:a=!1}){const[l,d]=u.useState(null),c=l!==null?l:t,p=()=>{l!==null&&(l!==t&&n(l),d(null))},f=(b,g)=>{const m=In(b,g,"scalar"),h=/^\{\{\s*([\s\S]*?)\s*\}\}$/.exec(m.trim());let v=h?h[1]:m;v=v.replace(/\s*\?\?\s*''$/,"").trim(),n(a?`'${v}'`:v),d(null)};return i.jsxs("span",{style:q_,children:[i.jsx("input",{type:"text","data-testid":e,value:c,onChange:b=>d(b.target.value),onBlur:p,onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),p())},placeholder:o,style:G_}),r&&r.length>0&&s&&i.jsx($t,{candidates:r,t:s,onSelect:b=>f(b.sourceId,b.path),testIdSuffix:`${e}-data`,floating:!0})]})}function Mr({label:e,testid:t,children:n}){return i.jsxs("div",{"data-testid":t,style:H_,children:[i.jsx("span",{style:F_,children:e}),i.jsx("div",{style:K_,children:n})]})}const pc={display:"flex",flexDirection:"column",gap:6,width:"100%",minWidth:0},ws=e=>({display:"flex",flexDirection:"column",gap:6,padding:"8px",border:"1px solid #e2e8f0",borderLeft:`3px solid ${e%2===0?"#6366f1":"#0ea5e9"}`,borderRadius:6,background:e%2===0?"#f8fafc":"#fefefe",minWidth:0}),H_={display:"flex",flexDirection:"column",gap:3,minWidth:0},F_={fontSize:11,fontWeight:600,color:"#475569"},K_={paddingLeft:8,minWidth:0},V_={display:"flex",flexWrap:"wrap",gap:4,alignItems:"center",minWidth:0},U_={display:"flex",flexWrap:"wrap",gap:4,alignItems:"center",minWidth:0},fc={fontSize:11,fontWeight:600,color:"#0f172a",whiteSpace:"nowrap"},q_={display:"inline-flex",alignItems:"flex-start",gap:2,flex:"1 1 80px",minWidth:60},G_={flex:"1 1 80px",minWidth:60,padding:"4px 6px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6},Y_={padding:"4px 6px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff"},X_={fontSize:11,color:"#94a3b8"},gc={display:"flex",flexDirection:"column",gap:4,padding:"6px 8px",border:"1px solid #e2e8f0",borderLeft:"3px solid #6366f1",borderRadius:6,background:"#fff",minWidth:0},J_={display:"flex",alignItems:"center",gap:6,minWidth:0},Z_={fontSize:10,fontWeight:600,color:"#6366f1",flex:1,minWidth:0},Q_={display:"flex",flexWrap:"wrap",gap:6,marginTop:2},R_={color:"#94a3b8",cursor:"grab",fontSize:14,userSelect:"none"},ex={border:"none",background:"transparent",color:"#94a3b8",cursor:"pointer",fontSize:12,padding:2,flexShrink:0},Lr={padding:"4px 10px",fontSize:11,border:"1px dashed #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",whiteSpace:"nowrap"},tx={display:"flex",flexDirection:"column",gap:4,marginTop:2},nx={alignSelf:"flex-start",padding:"3px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer",fontFamily:"monospace"},ox={fontSize:11,background:"#0f172a",color:"#e2e8f0",padding:"6px 8px",borderRadius:4,wordBreak:"break-all",fontFamily:"monospace"},rx={display:"flex",flexDirection:"column",gap:2,minWidth:0},hc={fontSize:11,background:"#f1f5f9",padding:"3px 6px",borderRadius:4,color:"#0f172a",wordBreak:"break-all",fontFamily:"monospace"},yc={fontSize:10,color:"#64748b"};function _t({value:e,onChange:t,t:n,placeholder:o,testidPrefix:r="g7le-i18n-text-field",locales:s,candidates:a,enableExpressionTree:l=!1,expressionTreeCollapsible:d=!1,expressionSourceToggle:c=!0}){const{locale:p,templateIdentifier:f,commitText:b,classify:g,translate:m}=Lv(),[h,v]=u.useState(null),[y,_]=u.useState(!1),[w,k]=u.useState(!1),[x,$]=u.useState(!1),[C,S]=u.useState(!1),[D,E]=u.useState(!1),[,I]=u.useState(0);u.useEffect(()=>{if(typeof window>"u")return;const z=H=>{const P=H.detail;P?.templateIdentifier&&P.templateIdentifier!==f||I(A=>A+1)};return window.addEventListener(kt,z),()=>window.removeEventListener(kt,z)},[f]);const N=g(e);u.useEffect(()=>{v(null),E(!1)},[p,e]);const T=h!==null?h:N.displayValue,B=u.useCallback(async()=>{if(h!==null){if(h===N.displayValue){v(null);return}_(!0);try{const z=await b(e,h);z.kind==="created"&&z.token?(t(z.token),Et({op:"prop_i18n_create_key",sourceState:"plain_text",translationKey:z.customKey,toLocale:p,valueLength:h.length,timestamp:Date.now()})):z.kind==="updated"&&Et({op:"prop_i18n_update_value",sourceState:"custom_key",translationKey:z.customKey,toLocale:p,valueLength:h.length,timestamp:Date.now()})}finally{_(!1),v(null)}}},[h,N.displayValue,b,e,t,p]),M=u.useCallback(z=>{typeof e=="string"&&(t(xo(e,z)),N.customKey&&Ar(f,N.customKey,z,p))},[e,t,N.customKey,f,p]);if(N.binding){if(l&&typeof e=="string"){const z=tc(e),H=gn(e),P=!z&&Vt(e)!==null,A=(z||H.decomposed)&&!P;if(A&&d&&!x)return i.jsx(ax,{value:e,t:n,translate:m,onEdit:()=>$(!0),testidPrefix:`${r}-preview`});const F=A&&(d||z)?i.jsx(xs,{value:e,onChange:Y=>t(Y),t:n,candidates:a,testidPrefix:`${r}-seg`}):H.decomposed?i.jsx(cc,{node:H.node,onChange:Y=>t(Rn(Y,!1)),t:n,candidates:a,testidPrefix:`${r}-tree`,showSourceToggle:c}):null;if(F){if(!d)return F;const Y=Tr(e),V=Y?ms(Y,X=>{const Z=m(X);return Z&&Z!==X&&!Z.startsWith("$t:")?Z:""},X=>Ut(X)):[];return i.jsxs("div",{"data-testid":`${r}-builder`,style:{display:"flex",flexDirection:"column",gap:6,width:"100%",minWidth:0},children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:6},children:[i.jsxs("button",{type:"button","data-testid":`${r}-to-plain`,onClick:()=>S(!0),style:gx,title:n("layout_editor.value_tree.to_plain"),"aria-label":n("layout_editor.value_tree.to_plain"),children:["↩ ",n("layout_editor.value_tree.to_plain")]}),i.jsxs("button",{type:"button","data-testid":`${r}-builder-collapse`,onClick:()=>$(!1),style:vc,title:n("layout_editor.value_tree.collapse"),"aria-label":n("layout_editor.value_tree.collapse"),children:["▴ ",n("layout_editor.value_tree.collapse")]})]}),C&&i.jsxs("div",{"data-testid":`${r}-to-plain-confirm`,style:hx,children:[i.jsx("p",{style:yx,children:n("layout_editor.value_tree.to_plain_lead")}),i.jsx("div",{style:bx,children:V.length===0?i.jsx("span",{style:{color:"#94a3b8"},children:n("layout_editor.prop_i18n.placeholder")}):V.map((X,Z)=>X.kind==="chip"?i.jsxs("span",{style:bc,children:["🔗 ",X.text]},Z):i.jsx("span",{style:X.kind==="ellipsis"?mc:void 0,children:X.text},Z))}),i.jsxs("p",{style:mx,children:["⚠ ",n("layout_editor.value_tree.to_plain_warn")]}),i.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:6},children:[i.jsx("button",{type:"button","data-testid":`${r}-to-plain-confirm-cancel`,onClick:()=>S(!1),style:vc,children:n("layout_editor.value_tree.to_plain_cancel")}),i.jsx("button",{type:"button","data-testid":`${r}-to-plain-confirm-ok`,onClick:()=>{S(!1),$(!1),t(Tr(e)||void 0)},style:vx,children:n("layout_editor.value_tree.to_plain_ok")})]})]}),F]})}}return l&&typeof e=="string"&&a&&a.length>0&&Vt(e)!==null?i.jsx(lx,{value:e,onChange:t,t:n,candidates:a,testidPrefix:`${r}-data`}):i.jsxs("div",{"data-testid":`${r}-binding`,style:Cx,children:[i.jsx("code",{style:$x,children:typeof e=="string"?e:""}),i.jsxs("span",{style:Ex,children:["🔗 ",n("layout_editor.prop_i18n.bound_code_only")]})]})}if(!D&&typeof e=="string"&&ts(e)){const z=Rl(e);return i.jsxs("div",{"data-testid":`${r}-settings-ref`,style:wx,children:[i.jsx("div",{"data-testid":`${r}-settings-ref-chips`,style:kx,children:z.map((H,P)=>H.kind==="chip"?i.jsxs("span",{style:Sx,children:["🔗 ",H.label]},P):i.jsx("span",{children:H.label},P))}),i.jsxs("button",{type:"button","data-testid":`${r}-settings-ref-edit`,onClick:()=>E(!0),style:_c,title:n("layout_editor.value_tree.edit"),"aria-label":n("layout_editor.value_tree.edit"),children:["✎ ",n("layout_editor.value_tree.edit")]})]})}const O=i.jsxs("button",{type:"button","data-testid":`${r}-toggle`,title:`${n("layout_editor.prop_i18n.edit_languages")} (${Xn(p,n)})`,"aria-label":`${n("layout_editor.prop_i18n.edit_languages")} (${Xn(p,n)})`,"aria-expanded":w,onClick:()=>k(z=>!z),style:_c,children:["🌐 ",N.customKey?w?"⌃":"⌄":"+"]});return i.jsxs("div",{"data-testid":r,style:{display:"flex",flexDirection:"column",gap:4,width:"100%"},children:[i.jsx("div",{style:_x,children:N.paramKey&&N.customKey?i.jsx(ix,{customKey:N.customKey,value:typeof e=="string"?e:"",onChange:t,t:n,candidates:a,testidPrefix:r,showExprButton:l&&d,onToExpression:()=>{$(!0),t(Ao(typeof e=="string"?e:""))},langToggle:O}):i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"text","data-testid":`${r}-preview`,value:T,placeholder:o??n("layout_editor.prop_i18n.placeholder"),onChange:z=>v(z.target.value),onBlur:()=>{B(),D&&E(!1)},disabled:y,style:xx}),a&&a.length>0&&i.jsx(sx,{value:typeof e=="string"?e:"",customKey:N.customKey,onChange:t,t:n,candidates:a,testidPrefix:r}),l&&d&&i.jsx("button",{type:"button","data-testid":`${r}-to-expr`,onClick:()=>{$(!0),t(Ao(typeof e=="string"?e:""))},title:n("layout_editor.value_tree.to_expression"),"aria-label":n("layout_editor.value_tree.to_expression"),style:zo,children:"ƒx"}),O]})}),w&&(N.customKey?i.jsx(Rd,{customKey:N.customKey,templateIdentifier:f,t:n,paramLabels:ys(e),locales:s,onRemoveParam:M},N.customKey):i.jsx("div",{"data-testid":`${r}-expand-hint`,style:Ix,children:n("layout_editor.prop_i18n.create_first")}))]})}function ix({customKey:e,value:t,onChange:n,t:o,candidates:r,testidPrefix:s,showExprButton:a=!1,onToExpression:l,langToggle:d}){const{state:c}=Qe(),p=c.templateIdentifier,f=c.locale,b=Kt(),[g,m]=u.useState(null),h=u.useRef(""),v=u.useRef(null),y=u.useRef(null),_=u.useRef(null),[w,k]=u.useState(null),[x,$]=u.useState(!1),C=ys(t),S=u.useCallback(async()=>{const T=It(e,f);if(T!==void 0){h.current=T,m(T);return}const M=(await fn(p,e))?.values?.[f]??"";h.current=M,m(M)},[e,p,f]);u.useEffect(()=>{let T=!1;return(async()=>{const B=It(e,f);if(B!==void 0){T||(h.current=B,m(B));return}const M=await fn(p,e);if(T)return;const O=M?.values?.[f]??"";h.current=O,m(O)})(),()=>{T=!0}},[e,p,f]),u.useEffect(()=>{if(typeof window>"u")return;const T=B=>{const M=B.detail;if(M?.templateIdentifier&&M.templateIdentifier!==p)return;const O=It(e,f);O!==void 0&&O!==g&&(h.current=O,m(O))};return window.addEventListener(kt,T),()=>window.removeEventListener(kt,T)},[e,p,f,g]);const D=u.useCallback(T=>{m(T),Eo(p,e,f,T).then(()=>{b?.markDirty?.()})},[p,e,f,b]),E=u.useCallback(T=>{n(xo(t,T)),Ar(p,e,T,f).then(()=>{S(),b?.markDirty?.()})},[t,n,p,e,f,S,b]),I=u.useCallback(async T=>{if(!(w===null||x)){$(!0);try{g!==null&&g!==h.current&&(await Eo(p,e,f,g),h.current=g);const B=await Ir(p,f,t,w,T.sourceId,T.path,"scalar");B.kind==="ok"&&(n(B.text),await S(),b?.markDirty?.())}finally{$(!1),k(null)}}},[w,x,g,t,p,e,f,n,S,b]),N=!!r&&r.length>0;return i.jsxs("div",{"data-testid":`${s}-chipfield-wrap`,style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:4},children:[i.jsx("div",{ref:v,"data-testid":`${s}-chipfield`,style:{flex:1,minWidth:0},children:g===null?i.jsx("div",{"data-testid":`${s}-chipfield-loading`,style:{fontSize:11,color:"#94a3b8",padding:"4px 0"},children:o("layout_editor.translation.loading")}):i.jsx(Sr,{value:g,onChange:D,t:o,paramLabels:C,testIdSuffix:`${s}-field`,onRequestInsert:N?T=>k(T):void 0,onRemoveChip:E,hideInsertButton:!0,caretRef:_})}),N&&i.jsx("button",{ref:y,type:"button","data-testid":`${s}-plus-data-btn`,onClick:()=>k(_.current?_.current():g?.length??0),title:o("layout_editor.inline_binding.insert_data"),"aria-label":o("layout_editor.inline_binding.insert_data"),style:zo,children:"+"}),a&&l&&i.jsx("button",{type:"button","data-testid":`${s}-to-expr`,onClick:l,title:o("layout_editor.value_tree.to_expression"),"aria-label":o("layout_editor.value_tree.to_expression"),style:zo,children:"ƒx"}),d,N&&i.jsx(Zn,{anchorRef:y,open:w!==null,onClose:()=>k(null),children:i.jsx("div",{"data-testid":`${s}-chipfield-picker`,children:i.jsx($t,{candidates:r,t:o,onSelect:T=>void I(T),testIdSuffix:`${s}-field-insert`,defaultOpen:!0,floating:!1})})})]})}function sx({value:e,customKey:t,onChange:n,t:o,candidates:r,testidPrefix:s}){const{state:a}=Qe(),l=a.templateIdentifier,d=a.selectedRoute?.layoutName??null,c=a.locale,p=Kt(),[f,b]=u.useState(!1),[g,m]=u.useState(!1),h=u.useRef(null),v=u.useCallback(w=>{const k=o(w);return k&&k!==w&&!k.startsWith("$t:")?k:""},[o]),y=u.useCallback(w=>w.replace(/\$t:[a-zA-Z0-9._-]+/g,k=>v(k.slice(3))).replace(/\s+/g," ").trim(),[v]),_=u.useCallback(async w=>{if(!g){m(!0);try{if(t){const k=await Ir(l,c,e,Number.MAX_SAFE_INTEGER,w.sourceId,w.path,"scalar");k.kind==="ok"&&(n(k.text),p?.markDirty?.())}else{const k=await hs(l,d,c,e,e.length,w.sourceId,w.path,"scalar",y,x=>o(x));k.kind==="ok"&&(n(k.text),p?.markDirty?.())}}finally{m(!1),b(!1)}}},[g,t,l,d,c,e,n,p,o,y]);return i.jsxs("div",{"data-testid":`${s}-plus-data`,style:{display:"inline-block"},children:[i.jsx("button",{ref:h,type:"button","data-testid":`${s}-plus-data-btn`,disabled:g,onClick:()=>b(w=>!w),title:o("layout_editor.inline_binding.insert_data"),"aria-label":o("layout_editor.inline_binding.insert_data"),style:zo,children:"+"}),i.jsx(Zn,{anchorRef:h,open:f,onClose:()=>b(!1),children:i.jsx($t,{candidates:r,t:o,onSelect:w=>void _(w),testIdSuffix:`${s}-plus-insert`,defaultOpen:!0,floating:!1})})]})}function ax({value:e,t,translate:n,onEdit:o,testidPrefix:r}){const s=ms(e,a=>{const l=n(a);return l&&l!==a&&!l.startsWith("$t:")?l:""},a=>Ut(a));return i.jsxs("div",{"data-testid":r,style:ux,children:[i.jsx("div",{"data-testid":`${r}-text`,style:px,children:s.length===0?i.jsx("span",{style:{color:"#94a3b8"},children:t("layout_editor.prop_i18n.placeholder")}):s.map((a,l)=>a.kind==="chip"?i.jsxs("span",{style:bc,children:["🔗 ",a.text]},l):i.jsx("span",{style:a.kind==="ellipsis"?mc:void 0,children:a.text},l))}),i.jsxs("button",{type:"button","data-testid":`${r}-edit`,onClick:o,style:fx,title:t("layout_editor.value_tree.edit"),"aria-label":t("layout_editor.value_tree.edit"),children:["✎ ",t("layout_editor.value_tree.edit")]})]})}function lx({value:e,onChange:t,t:n,candidates:o,testidPrefix:r}){const[s,a]=u.useState(!1),l=u.useRef(null),d=Ut(e);return i.jsxs("div",{"data-testid":r,style:{display:"flex",flexDirection:"column",gap:4,width:"100%",minWidth:0},children:[i.jsxs("div",{style:dx,children:[i.jsxs("span",{"data-testid":`${r}-chip`,style:cx,children:["🔗 ",d]}),i.jsx("button",{ref:l,type:"button","data-testid":`${r}-change`,onClick:()=>a(c=>!c),style:zo,title:n("layout_editor.value_tree.change_data"),"aria-label":n("layout_editor.value_tree.change_data"),children:n("layout_editor.value_tree.change_data")})]}),i.jsx(Zn,{anchorRef:l,open:s,onClose:()=>a(!1),children:i.jsx($t,{candidates:o,t:n,onSelect:c=>{const p=c.path?c.path.split(".").filter(Boolean):[],f=[c.sourceId,...p].join("?.");t(`{{${f}}}`),a(!1)},testIdSuffix:`${r}-pick`,defaultOpen:!0,floating:!1})})]})}const dx={display:"flex",alignItems:"center",gap:6,width:"100%",minWidth:0,flexWrap:"wrap"},cx={fontSize:11,background:"#eef2ff",color:"#4338ca",padding:"3px 8px",borderRadius:12,wordBreak:"break-all"},ux={display:"flex",alignItems:"center",gap:8,width:"100%",minWidth:0},px={flex:1,minWidth:0,display:"flex",flexWrap:"wrap",alignItems:"center",gap:4,padding:"5px 8px",fontSize:12,color:"#334155",border:"1px solid #e2e8f0",borderRadius:6,background:"#f8fafc",overflow:"hidden"},bc={fontSize:11,background:"#eef2ff",color:"#4338ca",padding:"1px 6px",borderRadius:10,whiteSpace:"nowrap"},mc={color:"#94a3b8"},fx={padding:"4px 10px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#2563eb",cursor:"pointer",whiteSpace:"nowrap",flexShrink:0},vc={padding:"3px 10px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer",whiteSpace:"nowrap"},gx={padding:"3px 10px",fontSize:11,border:"1px solid #fca5a5",borderRadius:6,background:"#fef2f2",color:"#b91c1c",cursor:"pointer",whiteSpace:"nowrap"},hx={display:"flex",flexDirection:"column",gap:6,padding:10,border:"1px solid #fca5a5",borderRadius:8,background:"#fffbeb"},yx={margin:0,fontSize:12,color:"#334155"},bx={padding:"5px 8px",fontSize:12,color:"#0f172a",background:"#fff",border:"1px solid #e2e8f0",borderRadius:6,wordBreak:"break-all"},mx={margin:0,fontSize:11,color:"#b45309"},vx={padding:"3px 12px",fontSize:11,border:"1px solid #dc2626",borderRadius:6,background:"#dc2626",color:"#fff",cursor:"pointer",whiteSpace:"nowrap"},_x={display:"flex",gap:4,alignItems:"center",width:"100%",minWidth:0},xx={flex:1,padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,minWidth:0,width:"100%"},_c={padding:"4px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer",whiteSpace:"nowrap"},zo={padding:"4px 8px",fontSize:13,lineHeight:1,border:"1px solid #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer",whiteSpace:"nowrap"},wx={display:"flex",alignItems:"center",gap:6,width:"100%",minWidth:0,flexWrap:"wrap"},kx={flex:1,minWidth:0,display:"flex",flexWrap:"wrap",alignItems:"center",gap:4,fontSize:12,color:"#334155"},Sx={fontSize:11,background:"#eef2ff",color:"#4338ca",padding:"2px 8px",borderRadius:12,whiteSpace:"nowrap"},Cx={display:"flex",flexDirection:"column",gap:2,width:"100%"},$x={fontSize:11,background:"#f1f5f9",padding:"3px 6px",borderRadius:4,color:"#0f172a",wordBreak:"break-all"},Ex={fontSize:10,color:"#64748b"},Ix={fontSize:11,color:"#94a3b8",padding:"6px 8px",border:"1px dashed #cbd5e1",borderRadius:6,background:"#f8fafc"};function ks({value:e,onChange:t,candidates:n,t:o}){const r=Array.isArray(e)?e:[],s=n??[],[a,l]=u.useState(!1),d=g=>s.find(m=>m.value===g)?.label??g,c=g=>d(g)!==g,p=g=>{const m=r.filter(h=>h!==g);t(m.length===0?void 0:m)},f=g=>{r.includes(g)||(t([...r,g]),l(!1))},b=s.filter(g=>!r.includes(g.value));return i.jsxs("div",{className:"g7le-widget g7le-widget--tag-input","data-testid":"g7le-widget-tag-input",style:Ax,children:[i.jsxs("div",{style:Tx,children:[r.map(g=>i.jsxs("span",{"data-testid":`g7le-tag-chip-${g}`,style:Dx,children:[i.jsx("span",{style:zx,children:d(g)}),c(g)&&i.jsx("code",{"data-testid":`g7le-tag-chip-id-${g}`,style:Nx,children:g}),i.jsx("button",{type:"button","aria-label":`remove ${g}`,"data-testid":`g7le-tag-remove-${g}`,onClick:()=>p(g),style:Mx,children:"✕"})]},g)),i.jsx("button",{type:"button","data-testid":"g7le-tag-add",onClick:()=>l(g=>!g),disabled:b.length===0,style:Lx,children:o("layout_editor.control.tag_add")})]}),a&&b.length>0&&i.jsx("div",{"data-testid":"g7le-tag-candidates",style:Px,children:b.map(g=>{const m=g.value!==g.label;return i.jsxs("button",{type:"button","data-testid":`g7le-tag-candidate-${g.value}`,onClick:()=>f(g.value),style:Ox,children:[i.jsx("span",{style:Bx,children:g.label}),m&&i.jsx("code",{"data-testid":`g7le-tag-candidate-id-${g.value}`,style:Wx,children:g.value})]},g.value)})})]})}const Ax={display:"flex",flexDirection:"column",gap:6},Tx={display:"flex",flexWrap:"wrap",gap:4,alignItems:"center"},Dx={display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px",fontSize:12,background:"#e0e7ff",color:"#1d4ed8",borderRadius:12},zx={fontSize:12},Nx={fontSize:10,color:"#4f46e5",background:"#c7d2fe",borderRadius:4,padding:"0 4px",fontFamily:"monospace"},Mx={border:"none",background:"transparent",color:"#1d4ed8",cursor:"pointer",fontSize:10,padding:0,lineHeight:1},Lx={padding:"2px 8px",fontSize:12,border:"1px dashed #94a3b8",borderRadius:12,background:"#fff",cursor:"pointer",color:"#475569"},Px={display:"flex",flexDirection:"column",maxHeight:180,overflowY:"auto",border:"1px solid #cbd5e1",borderRadius:6,background:"#fff"},Ox={display:"flex",flexDirection:"column",gap:1,textAlign:"left",padding:"6px 10px",fontSize:12,border:"none",borderBottom:"1px solid #f1f5f9",background:"transparent",cursor:"pointer",color:"#0f172a"},Bx={fontSize:12,color:"#0f172a"},Wx={fontSize:10,color:"#64748b",fontFamily:"monospace"},xc=new Map;function Ge(e,t){xc.set(e,t)}function zn(e){return e?xc.get(e)??null:null}function Pr(e,t){const o=e("meta",{})?.[t];return typeof o=="string"?o:""}function jx({getValue:e,patch:t,t:n,fieldT:o,spec:r,permissionCandidates:s,bindingCandidates:a}){const l=o??n,d=Pr(e,"title"),c=Pr(e,"description"),p=Pr(e,"icon"),f=Pr(e,"editor_label"),b=e("permissions",[]),g=u.useCallback((y,_)=>{const w={...e("meta",{})??{}};_===void 0||_===""?delete w[y]:w[y]=_,t("meta",w)},[e,t]),m=u.useCallback(y=>{const _=Array.isArray(y)?y:[];_.length===0?t("permissions",void 0):t("permissions",_)},[t]),h=zn("icon-picker"),v=Ct(r,"icon-picker")??Ct(r,"icon")??(r?.controls?Object.values(r.controls).find(y=>y&&typeof y=="object"&&y.widget==="icon-picker")??null:null);return i.jsxs("div",{className:"g7le-meta-form","data-testid":"g7le-meta-form",style:Fx,children:[i.jsx(No,{label:n("layout_editor.page_settings.meta.title"),children:i.jsx(_t,{value:d,onChange:y=>g("title",y),t:l,testidPrefix:"g7le-meta-title",candidates:a,enableExpressionTree:!0,expressionTreeCollapsible:!0})}),i.jsx(No,{label:n("layout_editor.page_settings.meta.description"),children:i.jsx(_t,{value:c,onChange:y=>g("description",y),t:l,testidPrefix:"g7le-meta-description",candidates:a,enableExpressionTree:!0,expressionTreeCollapsible:!0})}),i.jsx(No,{label:n("layout_editor.page_settings.meta.icon"),children:h?i.jsx(Hx,{icon:p,t:n,onChange:y=>g("icon",typeof y=="string"?y:void 0),IconWidget:h,iconControl:v??{widget:"icon-picker"}}):i.jsx("input",{type:"text","data-testid":"g7le-meta-icon",value:p,placeholder:n("layout_editor.page_settings.meta.icon_placeholder"),onChange:y=>g("icon",y.target.value),style:qx})}),i.jsx(No,{label:n("layout_editor.page_settings.meta.editor_label"),hint:n("layout_editor.page_settings.meta.editor_label_hint"),children:i.jsx(_t,{value:f,onChange:y=>g("editor_label",y),t:l,testidPrefix:"g7le-meta-editor-label",candidates:a,enableExpressionTree:!0,expressionTreeCollapsible:!0})}),i.jsx(No,{label:n("layout_editor.page_settings.meta.permissions"),hint:n("layout_editor.page_settings.meta.permissions_hint"),children:i.jsx("div",{"data-testid":"g7le-meta-permissions",children:i.jsx(ks,{control:{widget:"tag-input"},value:b,onChange:m,t:n,candidates:s})})})]})}function No({label:e,hint:t,children:n}){return i.jsxs("div",{className:"g7le-meta-field",style:Kx,children:[i.jsx("label",{style:Vx,children:e}),n,t?i.jsxs("p",{style:Ux,children:["ⓘ ",t]}):null]})}function Hx({icon:e,onChange:t,t:n,IconWidget:o,iconControl:r}){const[s,a]=u.useState(!1),l=e?/\bfa-/.test(e)?i.jsx("i",{className:e,"aria-hidden":"true"}):e:"📄";return i.jsxs("div",{"data-testid":"g7le-meta-icon",style:{display:"flex",flexDirection:"column",gap:6,minWidth:0},children:[i.jsxs("button",{type:"button","data-testid":"g7le-meta-icon-toggle","aria-expanded":s,onClick:()=>a(d=>!d),style:{display:"flex",alignItems:"center",gap:8,padding:"5px 8px",border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",cursor:"pointer",fontSize:12,color:"#475569",width:"fit-content"},children:[i.jsx("span",{style:{fontSize:16},"aria-hidden":"true",children:l}),i.jsx("span",{children:e||n("layout_editor.page_settings.meta.icon_placeholder")}),i.jsx("span",{"aria-hidden":"true",children:s?"▴":"▾"})]}),s?i.jsx(o,{control:r,value:e,onChange:d=>{t(d),a(!1)},t:n}):null]})}const Fx={display:"flex",flexDirection:"column",gap:16,minWidth:0},Kx={display:"flex",flexDirection:"column",gap:6,minWidth:0},Vx={fontSize:13,fontWeight:600,color:"#0f172a"},Ux={margin:0,fontSize:11,color:"#94a3b8"},qx={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,minWidth:0,width:"100%"};function Or({checked:e,onChange:t,label:n,testid:o,ariaLabel:r,disabled:s=!1}){return i.jsxs("label",{style:{...Zx,...s?{cursor:"not-allowed"}:{}},children:[i.jsx("button",{type:"button","data-testid":o,role:"switch","aria-checked":e,"aria-label":r,disabled:s,onClick:()=>t(!e),style:Qx(e,s),children:i.jsx("span",{style:Rx(e)})}),n!=null?i.jsx("span",{style:ew(s),children:n}):null]})}function Br({disabled:e,children:t,testid:n,style:o}){return i.jsx("div",{"data-testid":n,"data-disabled":e?"true":"false","aria-disabled":e,style:{...o,...e?{opacity:.5,pointerEvents:"none",userSelect:"none"}:{}},children:t})}function Gx({filled:e,sourceLabel:t,onRevert:n,revertLabel:o,hint:r,children:s,testid:a}){const l=e&&typeof n=="function",d=!e&&t!=null&&t!=="";return i.jsxs("div",{"data-testid":a,style:Yx,children:[s,l?i.jsxs("button",{type:"button","data-testid":a?`${a}-revert`:void 0,onClick:n,title:r??o,"aria-label":o,style:Jx,children:["↩ ",o]}):d?i.jsx("span",{"data-testid":a?`${a}-source`:void 0,title:r,style:Xx,children:t}):null]})}const Yx={position:"relative",minWidth:0,width:"100%"},Xx={position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",fontSize:10,color:"#94a3b8",background:"#f1f5f9",borderRadius:4,padding:"1px 6px",pointerEvents:"none",maxWidth:"45%",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},Jx={position:"absolute",right:6,top:"50%",transform:"translateY(-50%)",fontSize:10,color:"#0369a1",background:"#e0f2fe",border:"1px solid #bae6fd",borderRadius:4,padding:"1px 6px",cursor:"pointer",whiteSpace:"nowrap"},Zx={display:"inline-flex",alignItems:"center",gap:8,cursor:"pointer"},Qx=(e,t)=>({position:"relative",width:38,height:22,flexShrink:0,borderRadius:999,border:"none",padding:0,background:t?"#e2e8f0":e?"#2563eb":"#cbd5e1",cursor:t?"not-allowed":"pointer",transition:"background 0.15s ease"}),Rx=e=>({position:"absolute",top:2,left:e?18:2,width:18,height:18,borderRadius:"50%",background:"#fff",boxShadow:"0 1px 2px rgba(0,0,0,0.2)",transition:"left 0.15s ease"}),ew=e=>({fontSize:13,fontWeight:600,color:e?"#94a3b8":"#0f172a"}),tw=/\$(?:core|module|plugin)_settings:[a-zA-Z0-9._:-]+/;function nw(e){const t=[];let n=!1;const o=s=>{t.push({kind:"text",text:s}),n=!0},r=(s,a,l)=>{n||o(""),t.push({kind:"chip",raw:s,text:a,removable:l}),n=!1};for(const s of ow(e))s.kind==="text"?o(s.raw):r(s.raw,s.label,s.removable);return n||o(""),t}function ow(e){const t=[];if(typeof e!="string"||e.length===0)return t;const n=e.length;let o=0,r=0;const s=a=>{a>r&&t.push({kind:"text",raw:e.slice(r,a),label:"",removable:!1})};for(;o=n){o++;continue}s(o);const l=e.slice(o,a+2);t.push({kind:"chip",raw:l,label:Ut(l),removable:!0}),o=a+2,r=o;continue}if(e[o]==="$"){const a=tw.exec(e.slice(o));if(a&&a.index===0){s(o);const l=a[0],d=l.split(":").pop()||l;t.push({kind:"chip",raw:l,label:d,removable:!1}),o+=l.length,r=o;continue}}o++}return s(n),t}function rw(e,t,n,o){const r=[];let s=!1;return e.forEach((a,l)=>{if(a.kind==="chip"){if(!s&&a.raw===t){s=!0;return}r.push(a.raw??"")}else{const d=a.text??"";if(l===n){const c=Math.max(0,Math.min(o,d.length));r.push(d.slice(0,c),t,d.slice(c))}else r.push(d)}}),r.join("")}function iw(e,t,n){const o=Math.max(0,Math.min(t,e.length));return e.slice(0,o)+n+e.slice(o)}function sw(e,t){const n=e.indexOf(t);return n<0?e:e.slice(0,n)+e.slice(n+t.length)}function Ss({value:e,onChange:t,t:n,candidates:o,onDone:r,testidPrefix:s="g7le-binding-chip-text",disabled:a=!1}){const l=u.useMemo(()=>nw(e),[e]),d=u.useRef(null),c=!!o&&o.length>0,[p,f]=u.useState(null),[b,g]=u.useState(null),[m,h]=u.useState(null),[v,y]=u.useState(!1),_=u.useRef(0),w=u.useRef(null),k=u.useMemo(()=>l.map(P=>P.kind==="chip"?`c:${P.raw}`:"t").join("|"),[l]),x=u.useRef(null),$=u.useRef([]),C=u.useRef(!1);u.useLayoutEffect(()=>{const P=C.current;C.current=!1,!(!P&&x.current===k)&&(x.current=k,l.forEach((A,L)=>{if(A.kind!=="text")return;const F=$.current[L];F&&F.textContent!==(A.text??"")&&(F.textContent=A.text??"")}))},[k,l,e]);const S=u.useCallback(()=>{const P=d.current;if(!P)return e;const A=[];for(const L of Array.from(P.querySelectorAll("[data-seg]")))L.dataset.seg==="chip"?A.push(L.dataset.raw??""):A.push(L.textContent??"");return A.join("")},[e]),D=u.useCallback(()=>{a||t(S())},[a,t,S]),E=u.useRef(null),I=u.useRef(!1),N=(P,A)=>{if(!a){P.preventDefault(),P.stopPropagation(),E.current={raw:A,pointerId:P.pointerId},I.current=!1,f(A);try{P.currentTarget.setPointerCapture(P.pointerId)}catch{}}},T=P=>{const A=E.current;if(!A||P.pointerId!==A.pointerId)return;I.current=!0;const L=O(P.clientX,P.clientY);L&&(g({slotIdx:L.slotIdx,offset:L.offset}),h(lw(d.current,L.slotIdx,L.offset)))},B=(P,A)=>{if(P.stopPropagation(),I.current){I.current=!1;return}C.current=!0,t(sw(e,A))},M=P=>{const A=E.current;if(!A||P.pointerId!==A.pointerId)return;try{P.currentTarget.releasePointerCapture(P.pointerId)}catch{}E.current=null,I.current&&typeof setTimeout=="function"&&setTimeout(()=>{I.current=!1},0);const L=O(P.clientX,P.clientY);if(f(null),g(null),h(null),!L)return;const F=d.current;if(!F)return;const V=Array.from(F.querySelectorAll("[data-seg]")).map(Z=>Z.dataset.seg==="chip"?{kind:"chip",raw:Z.dataset.raw??""}:{kind:"text",text:Z.textContent??""}),X=rw(V,A.raw,L.slotIdx,L.offset);X!==e&&(C.current=!0,t(X))},O=(P,A)=>{const L=d.current;if(!L)return null;const F=Array.from(L.querySelectorAll("[data-seg]")),Y=L.ownerDocument,V=Y.elementFromPoint(P,A),X=V?.closest('[data-seg="text"]');if(X)return{slotIdx:F.indexOf(X),offset:aw(Y,X,P,A)};const Z=V?.closest('[data-seg="chip"]');if(Z){const oe=F.indexOf(Z),G=Z.getBoundingClientRect();if(P=0){const ee=F[oe-1];return{slotIdx:oe-1,offset:(ee.textContent??"").length}}if(oe+1({s:oe,i:G})).filter(oe=>oe.s.dataset.seg==="text").pop();return ie?{slotIdx:ie.i,offset:(ie.s.textContent??"").length}:null},z=()=>{a||!c||(_.current=dw(d.current,e.length),y(P=>!P))},H=P=>{const A=P.path?P.path.split(".").filter(Boolean):[],L=[P.sourceId,...A].join("?.");C.current=!0,t(iw(e,_.current,`{{${L}}}`)),y(!1)};return i.jsxs("div",{"data-testid":s,style:{display:"flex",flexDirection:"column",gap:4},children:[i.jsxs("div",{ref:d,"data-testid":`${s}-box`,className:"g7le-binding-chip-input",style:cw,children:[l.map((P,A)=>P.kind==="chip"?i.jsxs("span",{"data-seg":"chip","data-raw":P.raw,"data-testid":`${s}-chip-${A}`,contentEditable:!1,onPointerDown:L=>N(L,P.raw??""),onPointerMove:T,onPointerUp:M,title:P.removable?n("layout_editor.value_tree.change_data"):n("layout_editor.prop_i18n.bound_code_only"),style:{...gw,...p===P.raw?hw:null,touchAction:"none"},children:[i.jsx("span",{"aria-hidden":"true",style:yw,children:"⠿"}),i.jsx("span",{"aria-hidden":"true",style:{marginRight:3},children:"🔗"}),i.jsx("span",{children:P.text}),P.removable&&!a&&i.jsx("button",{type:"button","data-testid":`${s}-chip-remove-${A}`,"aria-label":n("layout_editor.inline_binding.clear"),title:n("layout_editor.inline_binding.clear"),onPointerDown:L=>{L.stopPropagation(),L.preventDefault()},onClick:L=>B(L,P.raw??""),style:bw,children:"✕"})]},`chip-${P.raw}-${A}`):i.jsx("span",{ref:L=>{$.current[A]=L},"data-seg":"text",contentEditable:!a,suppressContentEditableWarning:!0,onInput:D,"data-testid":`${s}-text-${A}`,style:{...uw,...p?pw:null,...b?.slotIdx===A?fw:null}},`text-slot-${A}`)),m&&i.jsx("span",{"aria-hidden":"true","data-testid":`${s}-caret`,style:{position:"absolute",left:m.left,top:m.top,width:2,height:m.height,background:"#2563eb",borderRadius:1,pointerEvents:"none",boxShadow:"0 0 0 1px rgba(37,99,235,0.3)"}})]}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[r&&i.jsxs("button",{type:"button","data-testid":`${s}-done`,onClick:r,style:wc,title:n("layout_editor.value_tree.done"),"aria-label":n("layout_editor.value_tree.done"),children:["✓ ",n("layout_editor.value_tree.done")]}),c&&i.jsxs("div",{style:{position:"relative"},children:[i.jsxs("button",{ref:w,type:"button","data-testid":`${s}-insert`,onClick:z,disabled:a,style:wc,title:n("layout_editor.inline_binding.insert_data"),"aria-label":n("layout_editor.inline_binding.insert_data"),children:["+ ",n("layout_editor.inline_binding.insert_data")]}),i.jsx(Zn,{anchorRef:w,open:v,onClose:()=>y(!1),children:i.jsx($t,{candidates:o,t:n,onSelect:H,testIdSuffix:`${s}-insert`,defaultOpen:!0,floating:!1})})]}),i.jsx("span",{style:mw,children:n("layout_editor.translation.placeholder_locked")})]})]})}function aw(e,t,n,o){const r=(t.textContent??"").length;try{const a=e;let l=null,d=0;if(typeof a.caretRangeFromPoint=="function"){const c=a.caretRangeFromPoint(n,o);c&&(l=c.startContainer,d=c.startOffset)}else if(typeof a.caretPositionFromPoint=="function"){const c=a.caretPositionFromPoint(n,o);c&&(l=c.offsetNode,d=c.offset)}if(l&&t.contains(l))return Math.max(0,Math.min(d,r))}catch{}const s=t.getBoundingClientRect();return n>s.left+s.width/2?r:0}function lw(e,t,n){if(!e)return null;const r=Array.from(e.querySelectorAll("[data-seg]"))[t];if(!r)return null;const s=e.getBoundingClientRect();try{const d=r.firstChild,c=e.ownerDocument;if(d&&d.nodeType===Node.TEXT_NODE&&(d.textContent??"").length>0){const p=c.createRange(),f=Math.max(0,Math.min(n,(d.textContent??"").length));p.setStart(d,f),p.setEnd(d,f);const b=p.getClientRects(),g=b.length>0?b[0]:p.getBoundingClientRect();if(g&&(g.height>0||g.width>=0))return{left:g.left-s.left,top:g.top-s.top,height:g.height||r.getBoundingClientRect().height}}}catch{}const a=r.getBoundingClientRect();return{left:(n>0?a.right:a.left)-s.left,top:a.top-s.top,height:a.height||16}}function dw(e,t){if(!e)return t;try{const n=e.ownerDocument.defaultView?.getSelection();if(!n||n.rangeCount===0)return t;const o=n.getRangeAt(0);let r=o.startContainer,s=null;for(;r&&r!==e;){if(r instanceof HTMLElement&&r.dataset.seg==="text"){s=r;break}r=r.parentNode}if(!s||!e.contains(s))return t;const a=Array.from(e.querySelectorAll("[data-seg]"));let l=0;for(const d of a){if(d===s)break;l+=d.dataset.seg==="chip"?(d.dataset.raw??"").length:(d.textContent??"").length}return l+o.startOffset}catch{return t}}const cw={position:"relative",display:"flex",flexWrap:"wrap",alignItems:"center",gap:2,minHeight:30,padding:"4px 8px",border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",fontSize:12,lineHeight:1.6,minWidth:0,width:"100%",boxSizing:"border-box"},uw={outline:"none",minWidth:8,minHeight:"1.2em",whiteSpace:"pre-wrap",color:"#0f172a",display:"inline-block",wordBreak:"break-all"},pw={boxShadow:"inset 0 -2px 0 #93c5fd",background:"#eff6ff",borderRadius:2},fw={background:"#dbeafe",boxShadow:"inset 0 -2px 0 #2563eb"},gw={display:"inline-flex",alignItems:"center",gap:1,background:"linear-gradient(180deg,#eff6ff,#dbeafe)",color:"#1d4ed8",border:"1px dashed #60a5fa",borderRadius:9999,padding:"1px 8px 1px 4px",margin:"0 1px",fontSize:11,fontWeight:600,cursor:"grab",userSelect:"none",whiteSpace:"nowrap",boxShadow:"0 1px 2px rgba(37,99,235,0.18)",verticalAlign:"middle"},hw={opacity:.5,borderStyle:"solid",cursor:"grabbing"},yw={color:"#2563eb",opacity:.7,fontSize:11,marginRight:1,cursor:"grab"},bw={marginLeft:4,width:14,height:14,lineHeight:"12px",padding:0,border:"none",borderRadius:9999,background:"rgba(29,78,216,0.12)",color:"#1d4ed8",fontSize:9,fontWeight:700,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",flex:"0 0 auto"},wc={padding:"4px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer",whiteSpace:"nowrap"},mw={fontSize:10,color:"#94a3b8"},vw=Rl;function Cs(e){return Vb(e)}function Ke({value:e,onChange:t,t:n,candidates:o,placeholder:r,testidPrefix:s="g7le-data-chip-value",readOnly:a=!1,enableExpressionTree:l=!0}){const d=typeof e=="string"?e:"",c=!!o&&o.length>0,[p,f]=u.useState(!1),[b,g]=u.useState(!1),[m,h]=u.useState(!1),v=u.useCallback(C=>i.jsx(Ke,{value:C.value,onChange:S=>C.onChange(S),t:C.t,candidates:C.candidates,testidPrefix:C.testidPrefix,enableExpressionTree:!0}),[]),y=()=>i.jsx("div",{style:{display:"flex",gap:4,alignItems:"center",width:"100%",minWidth:0},children:i.jsx("input",{type:"text","data-testid":`${s}-input`,value:d,placeholder:r??n("layout_editor.page_settings.seo.value_placeholder"),readOnly:a,onChange:C=>t(C.target.value),onFocus:()=>f(!0),onBlur:()=>f(!1),style:{flex:1,padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,minWidth:0,width:"100%",background:a?"#f1f5f9":"#fff",color:a?"#64748b":"#0f172a"}})}),_=u.useCallback(C=>{const S=d?`${d} ${C.expression}`:C.expression;t(S)},[d,t]);if(!l||a)return i.jsxs("div",{"data-testid":s,style:hn,children:[y(),!a&&c&&i.jsx($t,{candidates:o,t:n,onSelect:_,testIdSuffix:`${s}-pick`})]});const w=n_(d),k=tc(d),x=Vt(d),$=C=>{const S=Tr(d),D=S?ms(S,()=>"",E=>Ut(E)):[];return i.jsxs(i.Fragment,{children:[i.jsx("div",{style:{display:"flex",justifyContent:"flex-start"},children:i.jsxs("button",{type:"button","data-testid":`${C}-to-plain`,onClick:()=>h(!0),style:kw,title:n("layout_editor.value_tree.to_plain"),"aria-label":n("layout_editor.value_tree.to_plain"),children:["↩ ",n("layout_editor.value_tree.to_plain")]})}),m&&i.jsxs("div",{"data-testid":`${C}-to-plain-confirm`,style:Sw,children:[i.jsx("p",{style:Cw,children:n("layout_editor.value_tree.to_plain_lead")}),i.jsx("div",{style:$w,children:D.length===0?i.jsx("span",{style:{color:"#94a3b8"},children:n("layout_editor.page_settings.seo.value_placeholder")}):D.map((E,I)=>E.kind==="chip"?i.jsxs("span",{style:$s,children:["🔗 ",E.text]},I):i.jsx("span",{style:E.kind==="ellipsis"?{color:"#94a3b8"}:void 0,children:E.text},I))}),i.jsxs("p",{style:Ew,children:["⚠ ",n("layout_editor.value_tree.to_plain_warn")]}),i.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:6},children:[i.jsx("button",{type:"button","data-testid":`${C}-to-plain-confirm-cancel`,onClick:()=>h(!1),style:qt,children:n("layout_editor.value_tree.to_plain_cancel")}),i.jsx("button",{type:"button","data-testid":`${C}-to-plain-confirm-ok`,onClick:()=>{h(!1),t(Tr(d)||"")},style:Iw,children:n("layout_editor.value_tree.to_plain_ok")})]})]})]})};if(!p&&(w==="expression"||k)){if(k)return i.jsxs("div",{"data-testid":s,style:hn,children:[!a&&$(`${s}-seg`),i.jsx(xs,{value:d,onChange:S=>t(S),t:n,candidates:o,testidPrefix:`${s}-seg`,renderLeafInput:v})]});const C=gn(d);return i.jsxs("div",{"data-testid":s,style:hn,children:[!a&&$(`${s}-tree`),i.jsx(cc,{node:C.node,onChange:S=>t(Rn(S,!1)),t:n,candidates:o,testidPrefix:`${s}-tree`,renderLeafInput:v})]})}if(x&&!p&&!b)return i.jsx(_w,{value:d,onChange:t,t:n,candidates:o,testidPrefix:s,onEditRaw:()=>g(!0)});if(!p&&!b&&Cs(d)){const C=vw(d);return i.jsx("div",{"data-testid":s,style:hn,children:i.jsxs("div",{style:kc,children:[i.jsx("div",{"data-testid":`${s}-chips`,style:xw,children:C.map((S,D)=>S.kind==="chip"?i.jsxs("span",{style:$s,children:["🔗 ",S.label]},D):i.jsx("span",{children:S.label},D))}),i.jsxs("button",{type:"button","data-testid":`${s}-edit-raw`,onClick:()=>g(!0),style:qt,title:n("layout_editor.value_tree.edit"),"aria-label":n("layout_editor.value_tree.edit"),children:["✎ ",n("layout_editor.value_tree.edit")]})]})})}return b&&Cs(d)?i.jsxs("div",{"data-testid":s,style:hn,children:[i.jsx(Ss,{value:d,onChange:t,t:n,candidates:o,disabled:a,onDone:()=>g(!1),testidPrefix:`${s}-chipedit`}),!a&&w!=="raw"&&i.jsxs("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:[i.jsxs("button",{type:"button","data-testid":`${s}-to-expr`,onClick:()=>t(Ao(d)),style:qt,title:n("layout_editor.value_tree.to_expression"),"aria-label":n("layout_editor.value_tree.to_expression"),children:["ƒx ",n("layout_editor.value_tree.to_expression")]}),i.jsxs("button",{type:"button","data-testid":`${s}-to-fallback`,onClick:()=>t(vs(d)),style:qt,title:n("layout_editor.value_tree.segment.fallback"),"aria-label":n("layout_editor.value_tree.segment.fallback"),children:["?? ",n("layout_editor.value_tree.segment.fallback")]})]}),w==="raw"&&i.jsxs("p",{"data-testid":`${s}-raw-hint`,style:Es,children:["ⓘ ",n("layout_editor.value_tree.raw_expression_hint")]})]}):!p&&Cs(d)?i.jsxs("div",{"data-testid":s,style:hn,children:[i.jsx(Ss,{value:d,onChange:t,t:n,candidates:o,disabled:a,onDone:()=>{g(!1),f(!1)},testidPrefix:`${s}-chipedit`}),!a&&w!=="raw"&&i.jsxs("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:[i.jsxs("button",{type:"button","data-testid":`${s}-to-expr`,onClick:()=>t(Ao(d)),style:qt,title:n("layout_editor.value_tree.to_expression"),"aria-label":n("layout_editor.value_tree.to_expression"),children:["ƒx ",n("layout_editor.value_tree.to_expression")]}),i.jsxs("button",{type:"button","data-testid":`${s}-to-fallback`,onClick:()=>t(vs(d)),style:qt,title:n("layout_editor.value_tree.segment.fallback"),"aria-label":n("layout_editor.value_tree.segment.fallback"),children:["?? ",n("layout_editor.value_tree.segment.fallback")]})]}),w==="raw"&&i.jsxs("p",{"data-testid":`${s}-raw-hint`,style:Es,children:["ⓘ ",n("layout_editor.value_tree.raw_expression_hint")]})]}):i.jsxs("div",{"data-testid":s,style:hn,children:[y(),i.jsxs("div",{style:ww,children:[c&&i.jsx($t,{candidates:o,t:n,onSelect:_,testIdSuffix:`${s}-pick`}),w!=="raw"&&i.jsxs("div",{style:{display:"flex",gap:4},children:[i.jsxs("button",{type:"button","data-testid":`${s}-to-expr`,onClick:()=>t(Ao(d)),style:qt,title:n("layout_editor.value_tree.to_expression"),"aria-label":n("layout_editor.value_tree.to_expression"),children:["ƒx ",n("layout_editor.value_tree.to_expression")]}),i.jsxs("button",{type:"button","data-testid":`${s}-to-fallback`,onClick:()=>t(vs(d)),style:qt,title:n("layout_editor.value_tree.segment.fallback"),"aria-label":n("layout_editor.value_tree.segment.fallback"),children:["?? ",n("layout_editor.value_tree.segment.fallback")]})]})]}),w==="raw"&&!p&&i.jsxs("p",{"data-testid":`${s}-raw-hint`,style:Es,children:["ⓘ ",n("layout_editor.value_tree.raw_expression_hint")]})]})}function _w({value:e,onChange:t,t:n,candidates:o,testidPrefix:r,onEditRaw:s}){const[a,l]=u.useState(!1),d=u.useRef(null),c=Ut(e),p=!!o&&o.length>0,f=Vt(e)?.localeFn;return i.jsxs("div",{"data-testid":r,style:hn,children:[i.jsxs("div",{style:kc,children:[i.jsxs("span",{"data-testid":`${r}-chip`,style:$s,children:["🔗 ",c]}),p&&i.jsx("button",{ref:d,type:"button","data-testid":`${r}-change`,onClick:()=>l(b=>!b),style:qt,title:n("layout_editor.value_tree.change_data"),"aria-label":n("layout_editor.value_tree.change_data"),children:n("layout_editor.value_tree.change_data")}),i.jsx("button",{type:"button","data-testid":`${r}-edit-raw`,onClick:s,style:qt,title:n("layout_editor.value_tree.edit"),"aria-label":n("layout_editor.value_tree.edit"),children:"✎"})]}),p&&i.jsx(Zn,{anchorRef:d,open:a,onClose:()=>l(!1),children:i.jsx($t,{candidates:o,t:n,onSelect:b=>{if(f){const h=[b.sourceId,...b.path?b.path.split(".").filter(Boolean):[]].join(".");t(`{{${f}(${h})}}`),l(!1);return}const g=b.path?b.path.split(".").filter(Boolean):[],m=[b.sourceId,...g].join("?.");t(`{{${m}}}`),l(!1)},testIdSuffix:`${r}-pick`,defaultOpen:!0,floating:!1})})]})}const hn={display:"flex",flexDirection:"column",gap:4,width:"100%",minWidth:0},kc={display:"flex",alignItems:"center",gap:6,width:"100%",minWidth:0,flexWrap:"wrap"},xw={flex:1,minWidth:0,display:"flex",flexWrap:"wrap",alignItems:"center",gap:4,padding:"5px 8px",fontSize:12,color:"#334155",border:"1px solid #e2e8f0",borderRadius:6,background:"#f8fafc"},$s={fontSize:11,background:"#eef2ff",color:"#4338ca",padding:"2px 8px",borderRadius:12,whiteSpace:"nowrap"},qt={padding:"4px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer",whiteSpace:"nowrap"},ww={display:"flex",flexWrap:"wrap",alignItems:"center",gap:6},Es={margin:"2px 0 0",fontSize:11,color:"#94a3b8",lineHeight:1.4},kw={padding:"3px 10px",fontSize:11,border:"1px solid #fca5a5",borderRadius:6,background:"#fef2f2",color:"#b91c1c",cursor:"pointer",whiteSpace:"nowrap"},Sw={display:"flex",flexDirection:"column",gap:6,padding:10,border:"1px solid #fca5a5",borderRadius:8,background:"#fffbeb"},Cw={margin:0,fontSize:12,color:"#334155"},$w={padding:"5px 8px",fontSize:12,color:"#0f172a",background:"#fff",border:"1px solid #e2e8f0",borderRadius:6,wordBreak:"break-all",display:"flex",flexWrap:"wrap",gap:4,alignItems:"center"},Ew={margin:0,fontSize:11,color:"#b45309"},Iw={padding:"3px 12px",fontSize:11,border:"1px solid #dc2626",borderRadius:6,background:"#dc2626",color:"#fff",cursor:"pointer",whiteSpace:"nowrap"};let Sc=0;function Wr({value:e,onChange:t,keyField:n,valueField:o="content",t:r,candidates:s,testidPrefix:a="g7le-kv-chip-editor",keyPlaceholder:l,valuePlaceholder:d,addLabel:c,renderKeyInput:p}){const f=u.useMemo(()=>(Array.isArray(e)?e:[]).map(w=>({id:Sc++,k:typeof w[n]=="string"?w[n]:"",v:typeof w[o]=="string"?w[o]:""})),[]),[b,g]=u.useState(f),m=u.useCallback(w=>{g(w);const k=w.filter(x=>x.k.trim()!=="").map(x=>({[n]:x.k,[o]:x.v}));t(k)},[n,o,t]),h=u.useCallback(()=>{m([...b,{id:Sc++,k:"",v:""}])},[b,m]),v=u.useCallback(w=>{m(b.filter(k=>k.id!==w))},[b,m]),y=u.useCallback((w,k)=>{m(b.map(x=>x.id===w?{...x,k}:x))},[b,m]),_=u.useCallback((w,k)=>{m(b.map(x=>x.id===w?{...x,v:k}:x))},[b,m]);return i.jsxs("div",{"data-testid":a,style:{display:"flex",flexDirection:"column",gap:6},children:[b.map(w=>i.jsxs("div",{"data-testid":`${a}-row-${w.id}`,style:{display:"flex",gap:6,alignItems:"flex-start",border:"1px solid #e2e8f0",borderRadius:8,padding:8},children:[i.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:6},children:[i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:2,minWidth:0},children:p?i.jsx("div",{style:{minWidth:0},children:p({value:w.k,onChange:k=>y(w.id,k),testid:`${a}-key-${w.id}`,placeholder:l??r(`layout_editor.page_settings.seo.extra_${n}`)})}):i.jsx("input",{type:"text","data-testid":`${a}-key-${w.id}`,value:w.k,placeholder:l??r(`layout_editor.page_settings.seo.extra_${n}`),onChange:k=>y(w.id,k.target.value),style:{width:"100%",padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,minWidth:0,boxSizing:"border-box"}})}),i.jsx("div",{style:{minWidth:0},children:i.jsx(Ke,{value:w.v,onChange:k=>_(w.id,k),t:r,candidates:s,placeholder:d??r("layout_editor.page_settings.seo.extra_content"),testidPrefix:`${a}-value-${w.id}`})})]}),i.jsx("button",{type:"button","data-testid":`${a}-remove-${w.id}`,onClick:()=>v(w.id),title:r("layout_editor.page_settings.seo.remove"),"aria-label":r("layout_editor.page_settings.seo.remove"),style:{flex:"0 0 auto",padding:"4px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#64748b",cursor:"pointer"},children:"✕"})]},w.id)),i.jsxs("button",{type:"button","data-testid":`${a}-add`,onClick:h,style:{alignSelf:"flex-start",padding:"5px 10px",fontSize:12,border:"1px dashed #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer"},children:["+ ",c??r("layout_editor.page_settings.seo.add_extra")]})]})}const Aw=["website","article","product","profile"],Tw=["summary","summary_large_image","app","player"];function Dw(e){switch(e){case"core":return"layout_editor.page_settings.seo.og_source_core";case"inherited":return"layout_editor.page_settings.seo.og_source_inherited";case"filter":return"layout_editor.page_settings.seo.og_source_filter";case"layout":return null;default:return e?"layout_editor.page_settings.seo.og_source_module":null}}function Cc(e){const t={};for(const n of e??[])t[n.key]=n;return t}function $c(e,t){return!!e&&t&&typeof e.sourceExpr=="string"&&e.sourceExpr!==""&&!e.overriddenByLayout&&!e.lockedByFilter}function Ec({label:e,sourceExpr:t,onReplace:n,t:o,testid:r}){return i.jsxs("div",{"data-testid":r,style:Hw,children:[i.jsxs("span",{"data-testid":`${r}-chip`,style:Fw,title:t,children:["🔗 ",e||t]}),i.jsx("span",{"data-testid":`${r}-badge`,style:Kw,children:o("layout_editor.page_settings.seo.auto_chip_source")}),i.jsx("button",{type:"button","data-testid":`${r}-replace`,onClick:n,style:Vw,children:o("layout_editor.page_settings.seo.auto_chip_replace")})]})}function zw({og:e,twitter:t,onChangeOg:n,onChangeTwitter:o,ogPreview:r,twitterPreview:s,defaultsAvailable:a=!1,candidates:l,t:d,testidPrefix:c="g7le-seo-og"}){const p=e&&typeof e=="object"?e:{},f=t&&typeof t=="object"?t:{},[b,g]=u.useState(p.image_height!=null||p.image_type!=null||p.image_secure_url!=null),m=Cc(r),h=Cc(s),v=u.useCallback((D,E)=>{const I={...p};E===void 0||E===""||E===null?delete I[D]:I[D]=E,n(I)},[p,n]),y=u.useCallback((D,E)=>{const I={...f};E===void 0||E===""||E===null?delete I[D]:I[D]=E,o(I)},[f,o]),_=(D,E,I)=>!I||!a||!I.lockedByFilter?null:i.jsx("div",{style:{display:"flex",gap:6,alignItems:"center",marginTop:2},children:i.jsxs("span",{"data-testid":`${D}-locked-${E}`,style:Bw,children:["🔒 ",d("layout_editor.page_settings.seo.og_locked")]})}),w=D=>{if(!D||!a||D.lockedByFilter||D.overriddenByLayout)return;const E=Dw(D.source);return E?d(E):void 0},k=(D,E)=>D&&a?D.overriddenByLayout===!0:E!=="",x=(D,E,I,N,T,B)=>{const M=B[E],O=!!M?.lockedByFilter,z=typeof N[E]=="string"?N[E]:"";return i.jsxs("div",{"data-testid":`${D}-${E}`,style:Nn,children:[i.jsx("label",{style:oo,children:d(I)}),O?i.jsx("div",{"data-testid":`${D}-locked-value-${E}`,style:Ow,children:String(M?.effectiveValue??"")}):$c(M,a)?i.jsx(Ec,{label:M.label??"",sourceExpr:M.sourceExpr,onReplace:()=>T(E,M.sourceExpr),t:d,testid:`${D}-${E}-auto`}):i.jsx(_t,{value:z,onChange:H=>T(E,H??""),t:d,candidates:l,placeholder:a&&M?.effectiveValue!=null?String(M.effectiveValue):void 0,testidPrefix:`${D}-${E}-field`,enableExpressionTree:!0,expressionTreeCollapsible:!0}),_(D,E,M)]})},$=(D,E,I,N,T,B)=>{const M=B[E],O=!!M?.lockedByFilter,z=typeof N[E]=="string"?N[E]:"";return i.jsxs("div",{"data-testid":`${D}-${E}`,style:Nn,children:[i.jsx("label",{style:oo,children:d(I)}),$c(M,a)?i.jsx(Ec,{label:M.label??"",sourceExpr:M.sourceExpr,onReplace:()=>T(E,M.sourceExpr),t:d,testid:`${D}-${E}-auto`}):i.jsx(Ke,{value:z,onChange:H=>T(E,H),t:d,candidates:l,readOnly:O,placeholder:a&&M?.effectiveValue!=null?String(M.effectiveValue):void 0,testidPrefix:`${D}-${E}-field`}),_(D,E,M)]})},C=(D,E,I,N,T,B)=>{const M=B[E],O=!!M?.lockedByFilter,z=typeof N[E]=="string"?N[E]:"",H=k(M,z),P=H?z:"";return i.jsxs("div",{"data-testid":`${D}-${E}`,style:Nn,children:[i.jsx("label",{style:oo,children:d(I)}),i.jsx(Gx,{filled:H,sourceLabel:w(M),onRevert:O?void 0:()=>T(E,void 0),revertLabel:d("layout_editor.page_settings.seo.revert_default"),testid:`${D}-${E}-overlay`,children:i.jsx("div",{"data-testid":`${D}-${E}-input`,style:{minWidth:0},children:i.jsx(Ke,{value:P,onChange:A=>T(E,A),t:d,candidates:l,readOnly:O,placeholder:a&&M?.effectiveValue!=null?String(M.effectiveValue):void 0,testidPrefix:`${D}-${E}-chip`})})}),_(D,E,M)]})},S=(D,E,I,N,T,B,M)=>{const O=M[E],z=typeof T[E]=="string"?T[E]:"",H=k(O,z),P=w(O),A=H?z:"";return i.jsxs("div",{"data-testid":`${D}-${E}`,style:Nn,children:[i.jsxs("div",{style:Mw,children:[i.jsx("label",{style:oo,children:d(I)}),P?i.jsxs("span",{"data-testid":`${D}-${E}-source-inline`,style:Lw,children:["· ",P]}):null]}),i.jsxs("select",{"data-testid":`${D}-${E}-select`,value:A,onChange:L=>B(E,L.target.value),style:Pw,children:[i.jsx("option",{value:"",children:a&&O?.effectiveValue!=null&&O.effectiveValue!==""?`${d("layout_editor.page_settings.seo.use_default")} (${String(O.effectiveValue)})`:d("layout_editor.page_settings.seo.use_default")}),N.map(L=>i.jsx("option",{value:L,children:L},L))]}),_(D,E,O)]})};return i.jsxs("div",{"data-testid":c,style:{display:"flex",flexDirection:"column",gap:12},children:[i.jsxs("div",{"data-testid":`${c}-og-section`,style:Ic,children:[i.jsx("div",{style:Ac,children:d("layout_editor.page_settings.seo.og_section")}),i.jsxs("p",{"data-testid":`${c}-intro`,style:Nw,children:["ⓘ ",d("layout_editor.page_settings.seo.og_intro")]}),S(c,"type","layout_editor.page_settings.seo.og_type",Aw,p,v,m),x(c,"title","layout_editor.page_settings.seo.og_title",p,v,m),x(c,"description","layout_editor.page_settings.seo.og_description",p,v,m),$(c,"image","layout_editor.page_settings.seo.og_image",p,v,m),x(c,"image_alt","layout_editor.page_settings.seo.og_image_alt",p,v,m),i.jsxs("div",{style:Nn,children:[i.jsxs("button",{type:"button","data-testid":`${c}-image-adv-toggle`,"aria-expanded":b,onClick:()=>g(D=>!D),style:Ww,children:[b?"▾":"▸"," ",d("layout_editor.page_settings.seo.og_image_adv")]}),b?i.jsxs("div",{"data-testid":`${c}-image-adv`,style:jw,children:[C(c,"image_height","layout_editor.page_settings.seo.og_image_height",p,v,m),C(c,"image_type","layout_editor.page_settings.seo.og_image_type",p,v,m),C(c,"image_secure_url","layout_editor.page_settings.seo.og_image_secure_url",p,v,m)]}):null]}),C(c,"site_name","layout_editor.page_settings.seo.og_site_name",p,v,m),C(c,"locale","layout_editor.page_settings.seo.og_locale",p,v,m),i.jsxs("div",{"data-testid":`${c}-extra`,style:Nn,children:[i.jsx("label",{style:oo,children:d("layout_editor.page_settings.seo.og_extra")}),i.jsx(Wr,{value:Array.isArray(p.extra)?p.extra:[],onChange:D=>v("extra",D.length>0?D:void 0),keyField:"property",t:d,candidates:l,testidPrefix:`${c}-extra-editor`})]})]}),i.jsxs("div",{"data-testid":`${c}-tw-section`,style:Ic,children:[i.jsx("div",{style:Ac,children:d("layout_editor.page_settings.seo.tw_section")}),i.jsx("p",{style:{margin:"0 0 6px",fontSize:11,color:"#94a3b8"},children:d("layout_editor.page_settings.seo.tw_fallback_note")}),S("g7le-seo-tw","card","layout_editor.page_settings.seo.tw_card",Tw,f,y,h),C("g7le-seo-tw","site","layout_editor.page_settings.seo.tw_site",f,y,h),C("g7le-seo-tw","creator","layout_editor.page_settings.seo.tw_creator",f,y,h),x("g7le-seo-tw","title","layout_editor.page_settings.seo.tw_title",f,y,h),x("g7le-seo-tw","description","layout_editor.page_settings.seo.tw_description",f,y,h),$("g7le-seo-tw","image","layout_editor.page_settings.seo.tw_image",f,y,h),x("g7le-seo-tw","image_alt","layout_editor.page_settings.seo.tw_image_alt",f,y,h),i.jsxs("div",{"data-testid":"g7le-seo-tw-extra",style:Nn,children:[i.jsx("label",{style:oo,children:d("layout_editor.page_settings.seo.tw_extra")}),i.jsx(Wr,{value:Array.isArray(f.extra)?f.extra:[],onChange:D=>y("extra",D.length>0?D:void 0),keyField:"name",t:d,candidates:l,testidPrefix:"g7le-seo-tw-extra-editor"})]})]})]})}const Ic={border:"1px solid #e2e8f0",borderRadius:8,padding:12,display:"flex",flexDirection:"column",gap:10},Ac={fontSize:13,fontWeight:600,color:"#0f172a"},Nw={margin:0,fontSize:11,color:"#64748b",background:"#f8fafc",borderRadius:6,padding:"6px 8px"},Nn={display:"flex",flexDirection:"column",gap:4},oo={fontSize:12,color:"#475569"},Mw={display:"flex",alignItems:"center",gap:6},Lw={fontSize:11,color:"#94a3b8"},Pw={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,width:"100%",minWidth:0,boxSizing:"border-box"},Ow={padding:"5px 8px",fontSize:12,border:"1px solid #e2e8f0",borderRadius:6,background:"#f1f5f9",color:"#64748b"},Bw={fontSize:11,color:"#7c3aed"},Ww={alignSelf:"flex-start",padding:"2px 0",fontSize:12,fontWeight:600,color:"#475569",background:"transparent",border:"none",cursor:"pointer"},jw={display:"flex",flexDirection:"column",gap:8,paddingLeft:14,marginTop:4,minWidth:0},Hw={display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",minWidth:0},Fw={display:"inline-flex",alignItems:"center",maxWidth:"100%",padding:"3px 8px",fontSize:12,color:"#1d4ed8",background:"#eff6ff",border:"1px solid #bfdbfe",borderRadius:6,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},Kw={fontSize:11,color:"#94a3b8"},Vw={padding:"2px 8px",fontSize:11,color:"#475569",background:"#fff",border:"1px solid #cbd5e1",borderRadius:6,cursor:"pointer"},Uw=["WebPage","WebSite","ItemList","BreadcrumbList","Organization","Person","CollectionPage","AboutPage","ContactPage","SearchAction"];function jr(e){const t=[],n=(o,r)=>{for(const[s,a]of Object.entries(o)){if(s==="@type"||s==="@context")continue;const l=r?`${r}.${s}`:s;a!==null&&typeof a=="object"&&!Array.isArray(a)?n(a,l):t.push({key:l,value:a==null?"":String(a)})}};return n(e,""),t}function Tc(e,t){const n={"@type":e};for(const{key:o,value:r}of t){if(o.trim()==="")continue;const s=o.split(".");let a=n;for(let l=0;lp?jr(e).map(T=>({id:Is++,...T})):[]),_=u.useCallback((T,B)=>{h(T),y(B),t(Tc(T,B.map(M=>({key:M.key,value:M.value}))))},[t]),w=u.useCallback(()=>{const T=n,B=typeof T["@type"]=="string"?T["@type"]:m,M=jr(T).map(O=>({id:Is++,key:O.key,value:o?.[O.key]?.expr??O.value}));return{type:B,rows:M}},[n,o,m]),k=u.useCallback(T=>{if(b(T),T){if(v.length===0&&n&&typeof n=="object"){const B=w();_(B.type,B.rows);return}t(Tc(m,v.map(B=>({key:B.key,value:B.value}))))}else t(null)},[m,v,n,w,_,t]),x=u.useCallback(()=>{if(!n)return;const T=w();_(T.type,T.rows)},[n,w,_]),$=u.useCallback(()=>{_(m,[...v,{id:Is++,key:"",value:""}])},[m,v,_]),C=u.useCallback(T=>{_(m,v.filter(B=>B.id!==T))},[m,v,_]),S=u.useCallback((T,B)=>{_(m,v.map(M=>M.id===T?{...M,key:B}:M))},[m,v,_]),D=u.useCallback((T,B)=>{_(m,v.map(M=>M.id===T?{...M,value:B}:M))},[m,v,_]),E=u.useMemo(()=>n?jr(n):[],[n]),I=u.useMemo(()=>s?jr(s):[],[s]),N=v.some(T=>T.key.trim()!==""&&T.value.trim()==="");if(r){const T=s&&typeof s["@type"]=="string"?s["@type"]:"";return i.jsxs("div",{"data-testid":c,style:Dc,children:[i.jsxs("div",{style:zc,children:[i.jsx("span",{style:Gw,children:"🔒"}),i.jsx("span",{style:{fontSize:13,fontWeight:600},children:d("layout_editor.page_settings.seo.sd_mode")}),i.jsx("span",{"data-testid":`${c}-locked-badge`,style:Yw,children:d("layout_editor.page_settings.seo.sd_filter_locked")})]}),i.jsxs("div",{"data-testid":`${c}-locked`,style:Xw,children:[i.jsxs("p",{style:{margin:"0 0 6px",fontSize:12,color:"#475569"},children:["ⓘ ",d("layout_editor.page_settings.seo.sd_filter_locked_note")]}),i.jsxs("div",{"data-testid":`${c}-filtered-block`,children:[T?i.jsxs("div",{style:{fontSize:12,fontWeight:600,marginBottom:4},children:["@type: ",T]}):null,I.map(B=>i.jsxs("div",{"data-testid":`${c}-filtered-row-${B.key}`,style:Nc,children:[i.jsx("code",{style:Mc,children:B.key}),i.jsx("span",{style:Lc,children:B.value})]},B.key))]})]})]})}return i.jsxs("div",{"data-testid":c,style:Dc,children:[i.jsx("div",{style:zc,children:i.jsx(Or,{checked:f,onChange:k,testid:`${c}-mode`,label:d("layout_editor.page_settings.seo.sd_manual_toggle")})}),!f&&i.jsxs("div",{"data-testid":`${c}-auto`,style:{marginTop:8},children:[i.jsxs("div",{"data-testid":`${c}-auto-preview`,style:Jw,children:[i.jsxs("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:[d("layout_editor.page_settings.seo.sd_auto_title"),n&&typeof n["@type"]=="string"?`: ${n["@type"]}`:"",a?i.jsxs("span",{style:{marginLeft:6,color:"#94a3b8",fontWeight:400},children:["(",a,")"]}):null]}),E.length===0?i.jsx("p",{style:{margin:0,fontSize:12,color:"#94a3b8"},children:d("layout_editor.page_settings.seo.sd_auto_empty")}):E.map(T=>{const B=o?.[T.key];return i.jsxs("div",{"data-testid":`${c}-auto-row-${T.key}`,style:Nc,children:[i.jsx("code",{style:Mc,children:T.key}),B?i.jsxs("span",{"data-testid":`${c}-auto-chip-${T.key}`,style:Zw,title:B.expr,children:["🔗 ",B.label||B.expr]}):i.jsx("span",{style:Lc,children:T.value})]},T.key)})]}),i.jsxs("p",{"data-testid":`${c}-replace-warn`,style:Qw,children:["ⓘ ",d("layout_editor.page_settings.seo.sd_replace_pre_warn")]})]}),f&&i.jsxs("div",{"data-testid":`${c}-manual`,style:{marginTop:8},children:[i.jsxs("p",{"data-testid":`${c}-replace-warn`,style:Rw,children:["⚠ ",d("layout_editor.page_settings.seo.sd_replace_warn")]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[i.jsx("label",{style:{fontSize:12,color:"#475569"},children:d("layout_editor.page_settings.seo.sd_type")}),i.jsx("input",{type:"text","data-testid":`${c}-type`,list:`${c}-type-options`,value:m,onChange:T=>_(T.target.value,v),style:e0}),i.jsx("datalist",{id:`${c}-type-options`,children:Uw.map(T=>i.jsx("option",{value:T},T))})]}),i.jsx("div",{style:{marginTop:8,display:"flex",flexDirection:"column",gap:6},children:v.map(T=>i.jsxs("div",{"data-testid":`${c}-prop-${T.id}`,style:t0,children:[i.jsx("input",{type:"text","data-testid":`${c}-prop-key-${T.id}`,value:T.key,placeholder:d("layout_editor.page_settings.seo.sd_prop_key"),onChange:B=>S(T.id,B.target.value),style:{width:160,padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,minWidth:0}}),i.jsx("div",{style:{flex:1,minWidth:0},children:i.jsx(Ke,{value:T.value,onChange:B=>D(T.id,B),t:d,candidates:l,placeholder:d("layout_editor.page_settings.seo.sd_prop_value"),testidPrefix:`${c}-prop-value-${T.id}`})}),i.jsx("button",{type:"button","data-testid":`${c}-prop-remove-${T.id}`,onClick:()=>C(T.id),title:d("layout_editor.page_settings.seo.remove"),"aria-label":d("layout_editor.page_settings.seo.remove"),style:n0,children:"✕"})]},T.id))}),i.jsxs("div",{style:{marginTop:8,display:"flex",gap:8},children:[i.jsxs("button",{type:"button","data-testid":`${c}-add`,onClick:$,style:Pc,children:["+ ",d("layout_editor.page_settings.seo.sd_add_prop")]}),n?i.jsxs("button",{type:"button","data-testid":`${c}-seed-from-module`,onClick:x,style:Pc,children:["↩ ",d("layout_editor.page_settings.seo.sd_seed_from_module")]}):null]}),i.jsxs("p",{"data-testid":`${c}-empty-note`,style:o0,children:["ⓘ ",d("layout_editor.page_settings.seo.sd_empty_note"),N?i.jsxs("span",{style:{color:"#b45309"},children:[" ",d("layout_editor.page_settings.seo.sd_has_empty")]}):null]})]})]})}const Dc={display:"flex",flexDirection:"column"},zc={display:"flex",alignItems:"center",gap:8},Gw={fontSize:14},Yw={fontSize:11,padding:"2px 6px",borderRadius:4,background:"#f1f5f9",color:"#64748b"},Xw={marginTop:8,border:"1px solid #fcd34d",borderRadius:8,padding:10,background:"#fffbeb"},Jw={border:"1px solid #e2e8f0",borderRadius:8,padding:10,background:"#f8fafc"},Nc={display:"flex",gap:8,alignItems:"center",padding:"2px 0"},Mc={fontSize:11,color:"#475569",background:"#fff",padding:"2px 6px",borderRadius:4,minWidth:120},Lc={fontSize:11,color:"#0f172a",fontFamily:"monospace",wordBreak:"break-all"},Zw={display:"inline-flex",alignItems:"center",padding:"2px 8px",fontSize:11,color:"#1d4ed8",background:"#eff6ff",border:"1px solid #bfdbfe",borderRadius:6},Qw={margin:"6px 0 0",fontSize:12,color:"#64748b"},Rw={margin:"0 0 8px",fontSize:12,color:"#b45309",background:"#fffbeb",border:"1px solid #fcd34d",borderRadius:6,padding:"6px 8px"},e0={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,width:"100%",minWidth:0},t0={display:"flex",gap:6,alignItems:"flex-start",border:"1px solid #e2e8f0",borderRadius:8,padding:8},n0={padding:"4px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#64748b",cursor:"pointer"},Pc={padding:"5px 10px",fontSize:12,border:"1px dashed #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer"},o0={margin:"8px 0 0",fontSize:11,color:"#94a3b8"},Oc=new Set(["core_setting","setting","query","route"]);function r0({vars:e,onChange:t,varCandidates:n,gatingMet:o=!1,candidates:r,t:s,testidPrefix:a="g7le-seo-vars"}){const l=u.useMemo(()=>e&&typeof e=="object"?{...e}:{},[e]),d=u.useMemo(()=>Array.isArray(n)?n:[],[n]),c=u.useMemo(()=>o?d.filter(x=>Oc.has(x.source)):[],[d,o]),p=u.useMemo(()=>o?d.filter(x=>x.source==="data"):[],[d,o]);u.useMemo(()=>new Set(c.map(x=>x.name)),[c]);const f=u.useMemo(()=>new Set(p.map(x=>x.name)),[p]),b=u.useMemo(()=>{const x=new Set;for(const $ of d)Oc.has($.source)&&x.add($.name);return x},[d]),g=u.useMemo(()=>Object.keys(l).filter(x=>!f.has(x)),[l,f]),m=u.useCallback((x,$)=>{const C={...l};$===void 0?delete C[x]:C[x]=$,t(C)},[l,t]),[h,v]=u.useState(""),y=h.trim()!==""&&b.has(h.trim()),_=h.trim()!==""&&Object.prototype.hasOwnProperty.call(l,h.trim()),w=h.trim()!==""&&!y&&!_&&!f.has(h.trim()),k=u.useCallback(()=>{const x=h.trim();x===""||b.has(x)||Object.prototype.hasOwnProperty.call(l,x)||(t({...l,[x]:""}),v(""))},[h,b,l,t]);return i.jsxs("div",{"data-testid":a,style:{display:"flex",flexDirection:"column",gap:10},children:[i.jsx("span",{"data-testid":"g7le-seo-var-list",hidden:!0,"data-gating":o?"1":"0"}),!o&&i.jsxs("div",{"data-testid":`${a}-precondition`,style:i0,children:["⚠ ",s("layout_editor.page_settings.seo.vars_precondition")]}),c.length>0&&i.jsxs("div",{"data-testid":`${a}-auto-group`,style:As,children:[i.jsx("div",{style:Ts,children:s("layout_editor.page_settings.seo.vars_auto_group")}),c.map(x=>i.jsxs("div",{"data-testid":`g7le-seo-var-auto-${x.name}`,style:s0,children:[i.jsx("span",{style:a0,children:"🔒"}),i.jsx("code",{style:Ds,children:x.name}),i.jsxs("span",{style:l0,children:["〔",s("layout_editor.page_settings.seo.vars_auto"),"·",x.source,"〕"]}),x.owner?.name?i.jsx("span",{style:d0,children:x.owner.name}):null]},x.name))]}),p.length>0&&i.jsxs("div",{"data-testid":`${a}-data-group`,style:As,children:[i.jsx("div",{style:Ts,children:s("layout_editor.page_settings.seo.vars_data_group")}),p.map(x=>{const $=l[x.name]??"",C=$.trim()==="";return i.jsxs("div",{"data-testid":`g7le-seo-var-data-${x.name}`,style:Bc,children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[i.jsx("code",{style:Ds,children:x.name}),x.required?i.jsx("span",{"data-testid":`g7le-seo-var-required-${x.name}`,style:c0,children:"*"}):null]}),i.jsx(Ke,{value:$,onChange:S=>m(x.name,S??""),t:s,candidates:r,testidPrefix:`g7le-seo-var-data-field-${x.name}`}),x.required&&C?i.jsxs("p",{"data-testid":`g7le-seo-var-empty-warn-${x.name}`,style:zs,children:["⚠ ",s("layout_editor.page_settings.seo.vars_required_empty")]}):null]},x.name)})]}),i.jsxs("div",{"data-testid":`${a}-custom-group`,style:As,children:[i.jsx("div",{style:Ts,children:s("layout_editor.page_settings.seo.vars_custom_group")}),g.map(x=>i.jsxs("div",{"data-testid":`g7le-seo-var-custom-${x}`,style:Bc,children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[i.jsx("code",{style:Ds,children:x}),i.jsx("button",{type:"button","data-testid":`g7le-seo-var-custom-remove-${x}`,onClick:()=>m(x,void 0),title:s("layout_editor.page_settings.seo.remove"),"aria-label":s("layout_editor.page_settings.seo.remove"),style:{marginLeft:"auto",padding:"2px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#64748b",cursor:"pointer"},children:"✕"})]}),i.jsx(Ke,{value:l[x]??"",onChange:$=>m(x,$??""),t:s,candidates:r,testidPrefix:`g7le-seo-var-custom-field-${x}`})]},x)),i.jsxs("div",{"data-testid":"g7le-seo-var-add",style:{display:"flex",flexDirection:"column",gap:4,marginTop:6},children:[i.jsxs("div",{style:{display:"flex",gap:6},children:[i.jsx("input",{type:"text","data-testid":"g7le-seo-var-add-name",value:h,placeholder:s("layout_editor.page_settings.seo.vars_add_name"),onChange:x=>v(x.target.value),style:{flex:1,padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,minWidth:0}}),i.jsxs("button",{type:"button","data-testid":"g7le-seo-var-add-confirm",onClick:k,disabled:h.trim()===""||y||_,style:u0,children:["+ ",s("layout_editor.page_settings.seo.vars_add")]})]}),y?i.jsxs("p",{"data-testid":"g7le-seo-var-add-reserved-warn",style:zs,children:["⚠ ",s("layout_editor.page_settings.seo.vars_name_reserved",{name:h.trim()})]}):null,_&&!y?i.jsxs("p",{"data-testid":"g7le-seo-var-add-duplicate-warn",style:zs,children:["⚠ ",s("layout_editor.page_settings.seo.vars_name_duplicate",{name:h.trim()})]}):null,w?i.jsxs("p",{"data-testid":"g7le-seo-var-add-not-provided-hint",style:{margin:0,fontSize:11,color:"#94a3b8"},children:["ⓘ ",s("layout_editor.page_settings.seo.vars_name_not_provided",{name:h.trim()})]}):null]})]}),i.jsxs("p",{style:{margin:0,fontSize:11,color:"#94a3b8"},children:["ⓘ ",s("layout_editor.page_settings.seo.vars_value_hint")]})]})}const i0={fontSize:12,color:"#b45309",background:"#fffbeb",border:"1px solid #fcd34d",borderRadius:6,padding:"6px 8px"},As={border:"1px solid #e2e8f0",borderRadius:8,padding:10,display:"flex",flexDirection:"column",gap:6},Ts={fontSize:12,fontWeight:600,color:"#475569"},s0={display:"flex",alignItems:"center",gap:6,padding:"2px 0"},Bc={display:"flex",flexDirection:"column",border:"1px solid #f1f5f9",borderRadius:6,padding:8},a0={fontSize:13},Ds={fontSize:12,color:"#0f172a",background:"#f1f5f9",padding:"2px 6px",borderRadius:4},l0={fontSize:11,color:"#64748b"},d0={fontSize:11,color:"#94a3b8"},c0={color:"#dc2626",fontWeight:700},zs={margin:"4px 0 0",fontSize:11,color:"#b45309"},u0={padding:"5px 10px",fontSize:12,border:"1px dashed #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer",whiteSpace:"nowrap"};function p0({templateIdentifier:e,layout:t,url:n,locale:o,seedContext:r,routeParams:s,settingsSignature:a,t:l,debounceMs:d=400,fetchImpl:c,testidPrefix:p="g7le-seo-bot-preview"}){const[f,b]=u.useState(!0),[g,m]=u.useState(null),[h,v]=u.useState(!1),[y,_]=u.useState(null),w=u.useRef(null),k=u.useRef({templateIdentifier:e,layout:t,url:n,locale:o,seedContext:r,routeParams:s});k.current={templateIdentifier:e,layout:t,url:n,locale:o,seedContext:r,routeParams:s};const x=u.useCallback(async()=>{const D=c??(typeof fetch<"u"?fetch:void 0);if(!D)return;const{templateIdentifier:E,layout:I,url:N,locale:T,seedContext:B,routeParams:M}=k.current;v(!0),_(null);try{const O=`/api/admin/templates/${encodeURIComponent(E)}/editor/seo-bot-preview`,z=await D(O,{method:"POST",credentials:"same-origin",headers:Me({"Content-Type":"application/json"}),body:JSON.stringify({layout:I,url:N,locale:T,seed_context:B??{},route_params:M??{}})}),H=await z.json().catch(()=>null);if(!z.ok){_(H?.message??`HTTP ${z.status}`);return}const P=H?.data??null;m(P)}catch(O){_(O instanceof Error?O.message:String(O))}finally{v(!1)}},[c]);u.useEffect(()=>{if(f)return w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{x()},d),()=>{w.current&&clearTimeout(w.current)}},[a,f,d,x]);const $=u.useCallback(()=>{w.current&&clearTimeout(w.current),x()},[x]),C=g?.html??null,S=g?.enabled??!0;return i.jsxs("div",{"data-testid":p,style:f0,children:[i.jsxs("div",{style:g0,children:[i.jsxs("button",{type:"button","data-testid":`${p}-toggle`,onClick:()=>b(D=>!D),"aria-expanded":f,style:h0,children:[f?"▾":"▸"," ",l("layout_editor.page_settings.seo.bot_preview_title")]}),f?i.jsxs("button",{type:"button","data-testid":`${p}-refresh`,onClick:$,disabled:h,style:y0,children:["⟳ ",l("layout_editor.page_settings.seo.bot_preview_refresh")]}):null]}),f&&i.jsxs("div",{style:{marginTop:8},children:[g&&!S?i.jsxs("p",{"data-testid":`${p}-disabled`,style:b0,children:["ⓘ ",l("layout_editor.page_settings.seo.bot_preview_disabled")]}):i.jsx("div",{"data-testid":`${p}-body`,style:m0,children:h&&!C?i.jsx("p",{style:Ns,children:l("layout_editor.translation.loading")}):y?i.jsx("p",{"data-testid":`${p}-error`,style:{...Ns,color:"#dc2626"},children:y}):C==null?i.jsx("p",{style:Ns,children:l("layout_editor.page_settings.seo.bot_preview_empty")}):i.jsx("pre",{"data-testid":`${p}-code`,style:v0,children:C})}),i.jsxs("p",{"data-testid":`${p}-sample-note`,style:_0,children:["ⓘ ",l("layout_editor.page_settings.seo.bot_preview_sample_note")]})]})]})}const f0={borderTop:"1px solid #e2e8f0",paddingTop:10,marginTop:12},g0={display:"flex",alignItems:"center",gap:8},h0={background:"none",border:"none",cursor:"pointer",fontSize:13,fontWeight:600,color:"#0f172a",padding:0},y0={marginLeft:"auto",padding:"4px 10px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},b0={margin:0,fontSize:12,color:"#64748b",background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:6,padding:"8px 10px"},m0={border:"1px solid #e2e8f0",borderRadius:8,background:"#0b1020",padding:0,minHeight:80,overflow:"hidden"},v0={margin:0,padding:12,fontSize:11,lineHeight:1.5,color:"#d1fae5",fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:360,overflow:"auto"},Ns={margin:0,padding:12,fontSize:12,color:"#94a3b8"},_0={margin:"8px 0 0",fontSize:11,color:"#94a3b8"};function Wc({option:e,testIdPrefix:t}){const{id:n,friendly:o,source:r}=e;return i.jsxs("span",{style:x0,children:[i.jsx("span",{"data-testid":t?`${t}-title`:void 0,style:w0,children:o??n}),o?i.jsx("span",{"data-testid":t?`${t}-id`:void 0,style:k0,children:n}):null,r?i.jsx("span",{"data-testid":t?`${t}-source`:void 0,style:S0,children:r}):null]})}const x0={display:"inline-flex",alignItems:"baseline",gap:4,flexWrap:"wrap",minWidth:0},w0={fontSize:12,color:"#0f172a"},k0={fontSize:10,color:"#94a3b8",fontFamily:"ui-monospace, monospace"},S0={fontSize:9,fontWeight:600,color:"#7c3aed",background:"#f5f3ff",border:"1px solid #ddd6fe",borderRadius:4,padding:"0 5px",whiteSpace:"nowrap"},C0=["always","hourly","daily","weekly","monthly","yearly","never"];function $0({getValue:e,patch:t,t:n,templateIdentifier:o,candidates:r,availableExtensions:s=[],dataSourceOptions:a=[],previewUrl:l="/",previewLocale:d="ko",seedContext:c,candidatesFetcher:p,ogPreviewFetcher:f,botFetchImpl:b,testidPrefix:g="g7le-seo"}){const m=e("meta",{}).seo,h=m&&typeof m=="object"?m:{},v=u.useCallback((K,te)=>{const ye={...e("meta",{})},Se={...ye.seo??{}};te==null||te===""?delete Se[K]:Se[K]=te,ye.seo=Se,t("meta",ye)},[e,t]),y=h.enabled===!0,_=typeof h.page_type=="string"?h.page_type:"",w=Array.isArray(h.extensions)?h.extensions:[],k=Array.isArray(h.data_sources)?h.data_sources:[],x=w.length>0&&_!=="",[$,C]=u.useState(null),[S,D]=u.useState(null),E=u.useCallback(async(K,te)=>{if(p)return p(K,te);if(typeof fetch>"u")return null;const ye=new URLSearchParams;K&&ye.set("page_type",K),Array.isArray(te)&&te.length>0&&ye.set("extensions",JSON.stringify(te.map(Ve=>({type:Ve.type,id:Ve.id}))));const Se=ye.toString()?`?${ye.toString()}`:"",De=await fetch(nn(`/api/admin/templates/${encodeURIComponent(o)}/editor/seo-candidates`,"json",null,Se.replace(/^[?&]+/,"")),{credentials:"same-origin",headers:Me()}),Ie=await De.json().catch(()=>null);return De.ok?Ie?.data??null:null},[p,o]),I=u.useMemo(()=>{const ye=(e("__editor",{})??{}).original?.meta?.seo;return ye&&typeof ye=="object"?ye:void 0},[e]),N=u.useRef(I);N.current=I;const T=u.useCallback(async K=>{if(f)return f(K);if(typeof fetch>"u")return null;const te=await fetch(`/api/admin/templates/${encodeURIComponent(o)}/editor/seo-og-preview`,{method:"POST",credentials:"same-origin",headers:Me({"Content-Type":"application/json"}),body:JSON.stringify({seo:K,own_seo:N.current??null,seed_context:c??{},route_params:{}})}),ye=await te.json().catch(()=>null);return te.ok?ye?.data??null:null},[f,o,c]),B=u.useMemo(()=>JSON.stringify(w),[w]),M=u.useRef(h);M.current=h,u.useEffect(()=>{let K=!1;return(async()=>{const te=await E(_,w);K||C(te)})(),()=>{K=!0}},[_,B]);const O=u.useMemo(()=>JSON.stringify({og:h.og??null,twitter:h.twitter??null,structured_data:h.structured_data??null}),[h.og,h.twitter,h.structured_data]),z=u.useRef(!1);u.useEffect(()=>{let K=!1;const te=()=>{(async()=>{const Se=await T(M.current);K||D(Se)})()};if(!z.current)return z.current=!0,te(),()=>{K=!0};const ye=setTimeout(te,180);return()=>{K=!0,clearTimeout(ye)}},[_,B,O]);const H=$?.page_types??[],P=$?.toggle_settings??[],A=$?.vars??[],L=u.useMemo(()=>JSON.stringify(h),[h]),F=u.useMemo(()=>e("meta")?{meta:e("meta"),components:e("components",[])}:{meta:{},components:[]},[e]),Y=u.useCallback(K=>{w.some(te=>te.type===K.type&&te.id===K.id)||v("extensions",[...w,{type:K.type,id:K.id}])},[w,v]),V=u.useCallback(K=>{const te=w.filter(ye=>!(ye.type===K.type&&ye.id===K.id));v("extensions",te.length>0?te:void 0)},[w,v]),[X,Z]=u.useState(!1),[ie,oe]=u.useState(""),G=u.useMemo(()=>{const K=ie.trim().toLowerCase();return K?P.filter(te=>`${te.ref} ${te.label??""}`.toLowerCase().includes(K)):P},[P,ie]),ee=typeof h.toggle_setting=="string"?h.toggle_setting:"",fe=u.useCallback(K=>{const ye=k.includes(K)?k.filter(Se=>Se!==K):[...k,K];v("data_sources",ye.length>0?ye:void 0)},[k,v]);return i.jsxs("div",{"data-testid":g,style:{display:"flex",flexDirection:"column",gap:14},children:[i.jsxs("div",{style:Wt,children:[i.jsx(Or,{checked:y,onChange:K=>v("enabled",K),testid:`${g}-enabled`,label:n("layout_editor.page_settings.seo.enabled")}),y?null:i.jsxs("p",{"data-testid":`${g}-disabled-note`,style:ro,children:["ⓘ ",n("layout_editor.page_settings.seo.disabled_note")]})]}),i.jsx(Br,{disabled:!y,testid:`${g}-body`,style:{display:"flex",flexDirection:"column",gap:14},children:i.jsxs(i.Fragment,{children:[i.jsxs("div",{style:Wt,children:[i.jsx("label",{style:Gt,children:n("layout_editor.page_settings.seo.page_type")}),H.length>0?i.jsxs("select",{"data-testid":`${g}-page-type`,value:_,onChange:K=>v("page_type",K.target.value),style:Hr,children:[i.jsx("option",{value:"",children:n("layout_editor.page_settings.seo.page_type_none")}),H.map(K=>i.jsxs("option",{value:K.value,children:[K.label??K.value,K.owner?.name?` (${K.owner.name})`:""]},K.value))]}):i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"text","data-testid":`${g}-page-type-free`,value:_,placeholder:n("layout_editor.page_settings.seo.page_type_free_placeholder"),onChange:K=>v("page_type",K.target.value),style:Hr}),i.jsxs("p",{"data-testid":`${g}-page-type-free-note`,style:ro,children:["ⓘ ",n("layout_editor.page_settings.seo.page_type_free_note")]})]})]}),i.jsxs("div",{style:Wt,children:[i.jsxs("label",{style:Gt,children:["★ ",n("layout_editor.page_settings.seo.extensions")]}),i.jsxs("div",{"data-testid":`${g}-extensions`,style:{display:"flex",flexWrap:"wrap",gap:6},children:[w.map(K=>i.jsxs("span",{"data-testid":`${g}-extension-${K.type}-${K.id}`,style:jc,children:[K.name??`${K.type}:${K.id}`,i.jsx("button",{type:"button","data-testid":`${g}-extension-remove-${K.type}-${K.id}`,onClick:()=>V(K),style:Hc,children:"✕"})]},`${K.type}:${K.id}`)),i.jsxs("button",{type:"button","data-testid":`${g}-extension-add`,onClick:()=>Z(K=>!K),style:A0,children:["+ ",n("layout_editor.page_settings.seo.add_extension")]})]}),X&&i.jsx("div",{"data-testid":`${g}-extension-picker`,style:Fc,children:s.length===0?i.jsx("p",{style:ro,children:n("layout_editor.page_settings.seo.no_extension_candidate")}):s.map(K=>i.jsx("button",{type:"button","data-testid":`${g}-extension-option-${K.type}-${K.id}`,onClick:()=>{Y(K),Z(!1)},style:Kc,children:K.name??`${K.type}:${K.id}`},`${K.type}:${K.id}`))})]}),!x&&i.jsxs("div",{"data-testid":`${g}-defaults-precondition`,style:I0,children:["⚠ ",n("layout_editor.page_settings.seo.defaults_precondition"),i.jsxs("div",{"data-testid":`${g}-defaults-missing`,style:{fontSize:11,marginTop:4},children:[w.length===0?n("layout_editor.page_settings.seo.missing_extensions"):"",_===""?` ${n("layout_editor.page_settings.seo.missing_page_type")}`:""]})]}),i.jsxs("div",{style:Wt,children:[i.jsx("label",{style:Gt,children:n("layout_editor.page_settings.seo.toggle_setting")}),i.jsxs("div",{"data-testid":`${g}-toggle-setting`,children:[ee?i.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center",marginBottom:4},children:[i.jsx("code",{style:jc,children:ee}),i.jsx("button",{type:"button","data-testid":`${g}-toggle-setting-clear`,onClick:()=>v("toggle_setting",void 0),style:Hc,children:"✕"})]}):null,i.jsx("input",{type:"text","data-testid":`${g}-toggle-setting-search`,value:ie,placeholder:n("layout_editor.page_settings.seo.toggle_setting_search"),onChange:K=>oe(K.target.value),style:Hr}),ie.trim()!==""&&i.jsx("div",{"data-testid":`${g}-toggle-setting-results`,style:Fc,children:G.length===0?i.jsx("p",{style:ro,children:n("layout_editor.inline_binding.no_results")}):G.map(K=>i.jsx("button",{type:"button","data-testid":`${g}-toggle-setting-option-${K.ref}`,onClick:()=>{v("toggle_setting",K.ref),oe("")},style:Kc,children:K.label??K.ref},K.ref))})]})]}),i.jsxs("div",{style:Wt,children:[i.jsx("label",{style:Gt,children:n("layout_editor.page_settings.seo.data_sources")}),i.jsx("p",{style:ro,children:n("layout_editor.page_settings.seo.data_sources_hint")}),i.jsx("div",{"data-testid":`${g}-data-sources`,style:{display:"flex",flexDirection:"column",gap:6},children:a.length===0?i.jsx("span",{style:ro,children:n("layout_editor.page_settings.seo.data_sources_empty")}):a.map(K=>{const te=k.includes(K.id);return i.jsxs("label",{"data-testid":`${g}-data-source-${K.id}`,style:E0(te),children:[i.jsx("input",{type:"checkbox","data-testid":`${g}-data-source-check-${K.id}`,checked:te,onChange:()=>fe(K.id)}),i.jsx(Wc,{option:K,testIdPrefix:`${g}-data-source-${K.id}`})]},K.id)})})]}),i.jsxs("div",{style:Wt,children:[i.jsx("label",{style:Gt,children:n("layout_editor.page_settings.seo.priority")}),i.jsx("input",{type:"range","data-testid":`${g}-priority`,min:0,max:1,step:.1,value:typeof h.priority=="number"?h.priority:.5,onChange:K=>v("priority",Number(K.target.value))}),i.jsx("span",{"data-testid":`${g}-priority-value`,style:{fontSize:12,color:"#475569"},children:typeof h.priority=="number"?h.priority:.5})]}),i.jsxs("div",{style:Wt,children:[i.jsx("label",{style:Gt,children:n("layout_editor.page_settings.seo.changefreq")}),i.jsxs("select",{"data-testid":`${g}-changefreq`,value:typeof h.changefreq=="string"?h.changefreq:"",onChange:K=>v("changefreq",K.target.value),style:Hr,children:[i.jsx("option",{value:"",children:n("layout_editor.page_settings.seo.use_default")}),C0.map(K=>i.jsx("option",{value:K,children:K},K))]})]}),i.jsxs("div",{style:Wt,children:[i.jsx("label",{style:Gt,children:n("layout_editor.page_settings.seo.title")}),i.jsx(_t,{value:typeof h.title=="string"?h.title:"",onChange:K=>v("title",K??""),t:n,candidates:r,testidPrefix:`${g}-title`,enableExpressionTree:!0,expressionTreeCollapsible:!0})]}),i.jsxs("div",{style:Wt,children:[i.jsx("label",{style:Gt,children:n("layout_editor.page_settings.seo.description")}),i.jsx(_t,{value:typeof h.description=="string"?h.description:"",onChange:K=>v("description",K??""),t:n,candidates:r,testidPrefix:`${g}-description`,enableExpressionTree:!0,expressionTreeCollapsible:!0})]}),i.jsx(zw,{og:h.og,twitter:h.twitter,onChangeOg:K=>v("og",Object.keys(K).length>0?K:void 0),onChangeTwitter:K=>v("twitter",Object.keys(K).length>0?K:void 0),ogPreview:S?.og,twitterPreview:S?.twitter,defaultsAvailable:S?.defaultsAvailable??!1,candidates:r,t:n}),i.jsxs("div",{style:Wt,children:[i.jsx("label",{style:Gt,children:n("layout_editor.page_settings.seo.structured_data")}),i.jsx(qw,{value:h.structured_data,onChange:K=>v("structured_data",K??void 0),autoBlock:S?.structured?.autoBlock,autoMeta:S?.structured?.autoMeta,lockedByFilter:S?.structured?.lockedByFilter,filteredBlock:S?.structured?.filteredBlock,pageType:_,candidates:r,t:n})]}),i.jsxs("div",{style:Wt,children:[i.jsx("label",{style:Gt,children:n("layout_editor.page_settings.seo.vars")}),i.jsx(r0,{vars:h.vars,onChange:K=>v("vars",Object.keys(K).length>0?K:void 0),varCandidates:A,gatingMet:x,candidates:r,t:n})]}),i.jsx(p0,{templateIdentifier:o,layout:F,url:l,locale:d,seedContext:c,settingsSignature:L,t:n,fetchImpl:b})]})})]})}const Wt={display:"flex",flexDirection:"column",gap:4},Gt={fontSize:12,fontWeight:600,color:"#334155"},Hr={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,width:"100%",minWidth:0,boxSizing:"border-box"},ro={margin:"4px 0 0",fontSize:11,color:"#94a3b8"},E0=e=>({display:"flex",alignItems:"center",gap:8,padding:"6px 10px",fontSize:12,border:`1px solid ${e?"#3b82f6":"#e2e8f0"}`,borderRadius:8,background:e?"#eff6ff":"#fff",cursor:"pointer",minWidth:0}),I0={fontSize:12,color:"#b45309",background:"#fffbeb",border:"1px solid #fcd34d",borderRadius:6,padding:"8px 10px"},jc={display:"inline-flex",alignItems:"center",gap:4,fontSize:11,padding:"3px 8px",borderRadius:999,background:"#eef2ff",color:"#3730a3"},Hc={border:"none",background:"transparent",cursor:"pointer",color:"#6366f1",fontSize:11,padding:0},A0={fontSize:11,padding:"3px 10px",borderRadius:999,border:"1px dashed #cbd5e1",background:"#f8fafc",color:"#475569",cursor:"pointer"},Fc={marginTop:4,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",padding:6,display:"flex",flexDirection:"column",gap:2},Kc={textAlign:"left",border:"none",background:"transparent",cursor:"pointer",padding:"5px 8px",borderRadius:4,fontSize:12,color:"#0f172a"},T0={setState:"state",loadFromLocalStorage:"state",saveToLocalStorage:"state",navigate:"nav",openWindow:"nav",navigateBack:"nav",navigateForward:"nav",replaceUrl:"nav",toast:"notify",openModal:"notify",closeModal:"notify",showAlert:"notify",setError:"notify",refetchDataSource:"data",appendDataSource:"data",updateDataSource:"data",apiCall:"data",scrollIntoView:"etc",login:"etc",loginTwoFactor:"etc",loginTwoFactorResend:"etc",logout:"etc",setLocale:"locale",emitEvent:"etc",conditions:"flow",sequence:"flow",parallel:"flow",switch:"flow",suppress:"flow",showErrorPage:"error"},D0={state:"layout_editor.action.group.state",nav:"layout_editor.action.group.nav",notify:"layout_editor.action.group.notify",data:"layout_editor.action.group.data",locale:"layout_editor.action.group.locale",etc:"layout_editor.action.group.etc",flow:"layout_editor.action.group.flow",error:"layout_editor.action.group.error",extension:"layout_editor.action.group.extension"},z0={init:["state","data","notify","nav","locale","etc","flow","error","extension"],component:["nav","notify","data","state","locale","etc","flow","error","extension"]};function N0(e,t){const n=e?.[t];if(n&&typeof n=="object"){const o=n.__source;if(o&&typeof o=="object")return o}return null}function M0(e,t){return!e||e.kind==="core"?t("layout_editor.action.source_core"):e.id??t(`layout_editor.action.source_${e.kind}`)}function Vc(e,t,n){return typeof e!="string"?n:e.startsWith("$t:")?t(e.slice(3)):e}function L0({recipes:e,t,onAdd:n,context:o="init",testIdPrefix:r="g7le-action-add"}){const[s,a]=u.useState(!1),[l,d]=u.useState(""),c=u.useMemo(()=>$o(e),[e]),p=u.useMemo(()=>{const f=z0[o],b=new Map;for(const m of c){const h=N0(e,m.id),y=h!=null&&h.kind!=="core"?"extension":T0[m.id]??"etc",_=b.get(y)??[];_.push({recipe:m,source:h}),b.set(y,_)}const g=l.trim().toLowerCase();return f.map(m=>{let h=b.get(m)??[];return g&&(h=h.filter(({recipe:v})=>Vc(v.label,t,v.id).toLowerCase().includes(g)||v.id.toLowerCase().includes(g)||v.build.handler.toLowerCase().includes(g))),{groupKey:m,items:h}}).filter(m=>m.items.length>0)},[c,e,o,l,t]);return c.length===0?i.jsx("div",{"data-testid":`${r}-empty`,style:U0,children:t("layout_editor.action.no_recipes")}):i.jsxs("div",{className:r,"data-testid":r,style:{minWidth:0},children:[i.jsxs("button",{type:"button","data-testid":`${r}-toggle`,onClick:()=>a(f=>!f),style:P0,children:[t("layout_editor.action.add_action")," ▾"]}),s?i.jsxs("div",{"data-testid":`${r}-list`,style:O0,children:[i.jsx("input",{type:"text","data-testid":`${r}-search`,value:l,placeholder:t("layout_editor.action.add_search"),onChange:f=>d(f.target.value),style:B0}),p.map(({groupKey:f,items:b})=>i.jsxs("div",{"data-testid":`${r}-group-${f}`,children:[i.jsxs("div",{style:W0,children:["━━ ",t(D0[f]??f)," ━━"]}),b.map(({recipe:g,source:m})=>i.jsxs("button",{type:"button","data-testid":`g7le-init-action-spec-${g.id}`,onClick:()=>{n(Er(g,{})),a(!1),d("")},style:j0,children:[i.jsx("span",{style:H0,children:Vc(g.label,t,g.id)}),i.jsxs("span",{"data-testid":`g7le-init-action-spec-source-${g.id}`,style:F0,children:["〔",M0(m,t),"〕"]}),i.jsx("code",{style:K0,children:g.build.handler})]},g.id))]},f)),p.length===0?i.jsx("div",{"data-testid":`${r}-no-match`,style:V0,children:t("layout_editor.action.add_no_match")}):null]}):null]})}const P0={padding:"6px 12px",fontSize:12,border:"1px dashed #94a3b8",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},O0={marginTop:6,border:"1px solid #cbd5e1",borderRadius:8,background:"#fff",maxHeight:320,overflowY:"auto",padding:8},B0={width:"100%",padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,marginBottom:6,boxSizing:"border-box"},W0={fontSize:11,fontWeight:700,color:"#94a3b8",padding:"6px 4px 2px"},j0={display:"flex",alignItems:"center",gap:6,width:"100%",textAlign:"left",padding:"6px 8px",fontSize:12,border:"none",background:"transparent",cursor:"pointer",borderRadius:6},H0={flex:1,minWidth:0,color:"#0f172a"},F0={fontSize:10,color:"#64748b",whiteSpace:"nowrap"},K0={fontSize:10,color:"#cbd5e1",fontFamily:"monospace",whiteSpace:"nowrap"},V0={fontSize:12,color:"#94a3b8",padding:"8px 4px"},U0={fontSize:12,color:"#94a3b8",padding:"8px 0"};function q0(e,t){return t.startsWith("$t:")?e(t.slice(3)):t}function G0({action:e,recipe:t,values:n={},t:o,missingRequired:r=!1,showCodeButton:s=!0,testIdPrefix:a="g7le-action-preview"}){const[l,d]=u.useState(!1),c=t?Gd(t,n,p=>q0(o,p)):typeof e.handler=="string"?e.handler:o("layout_editor.action.advanced_action");return i.jsxs("div",{className:a,"data-testid":a,style:Y0,children:[r?i.jsxs("span",{"data-testid":`${a}-missing`,style:J0,children:["⚠ ",o("layout_editor.action.summary_missing_required")]}):i.jsx("span",{"data-testid":`${a}-summary`,style:X0,children:c}),s?i.jsx("button",{type:"button","data-testid":`${a}-code-toggle`,onClick:()=>d(p=>!p),style:Z0,"aria-expanded":l,"aria-label":o("layout_editor.action.view_code"),children:""}):null,s&&l?i.jsx("pre",{"data-testid":`${a}-code`,style:Q0,children:JSON.stringify(e,null,2)}):null]})}const Y0={display:"flex",flexWrap:"wrap",alignItems:"center",gap:6,minWidth:0},X0={flex:1,minWidth:0,fontSize:12,color:"#475569"},J0={flex:1,minWidth:0,fontSize:12,color:"#b45309"},Z0={border:"1px solid #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer",fontSize:11,padding:"2px 6px",whiteSpace:"nowrap"},Q0={flexBasis:"100%",margin:"6px 0 0",padding:8,background:"#0f172a",color:"#e2e8f0",borderRadius:6,fontSize:11,overflow:"auto"},Uc="__g7le_custom__";function Fr({value:e,onChange:t,candidates:n,placeholder:o,testid:r,t:s,bindingCandidates:a}){const l=e==null?"":String(e),d=Array.isArray(n)&&n.length>0,c=d&&n.some(b=>b.value===l),[p,f]=u.useState(!d||l!==""&&!c);return u.useEffect(()=>{l!==""&&d&&!c&&f(!0)},[l,d,c]),d&&!p?i.jsxs("div",{style:Xc,children:[i.jsxs("select",{className:"g7le-widget g7le-widget--picker","data-testid":r,value:c?l:"",onChange:b=>{const g=b.target.value;if(g===Uc){f(!0);return}t(g===""?void 0:g)},style:{...Gc,flex:1,minWidth:0},children:[i.jsx("option",{value:"",children:s("layout_editor.control.default")}),n.map(b=>i.jsx("option",{value:b.value,children:b.label},b.value)),i.jsx("option",{value:Uc,children:s("layout_editor.recipe.custom_input")})]}),i.jsx("button",{type:"button","data-testid":`${r}-to-custom`,title:s("layout_editor.recipe.custom_input"),"aria-label":s("layout_editor.recipe.custom_input"),onClick:()=>f(!0),style:Jc,children:"✎"})]}):i.jsxs("div",{style:Xc,children:[i.jsx("div",{style:{flex:1,minWidth:0},children:i.jsx(Ke,{value:l,onChange:b=>t(b===""?void 0:b),t:s,candidates:a,placeholder:o,testidPrefix:`${r}-input`})}),d&&i.jsx("button",{type:"button","data-testid":`${r}-pick`,title:s("layout_editor.recipe.pick_from_list"),onClick:()=>{f(!1),t(void 0)},style:Jc,children:"≡"})]})}function R0({value:e,onChange:t,candidates:n,t:o,bindingCandidates:r}){return i.jsx(Fr,{value:e,onChange:t,candidates:n,placeholder:o("layout_editor.recipe.page_placeholder"),testid:"g7le-widget-page-picker",t:o,bindingCandidates:r})}function qc({value:e,onChange:t,candidates:n,t:o,bindingCandidates:r}){return i.jsx(Fr,{value:e,onChange:t,candidates:n,placeholder:o("layout_editor.recipe.datasource_placeholder"),testid:"g7le-widget-datasource-picker",t:o,bindingCandidates:r})}function Ms({value:e,onChange:t,candidates:n,t:o,bindingCandidates:r}){return i.jsx(Fr,{value:e,onChange:t,candidates:n,placeholder:o("layout_editor.recipe.state_key_placeholder"),testid:"g7le-widget-state-key-picker",t:o,bindingCandidates:r})}function ek({value:e,onChange:t,candidates:n,t:o,bindingCandidates:r}){return i.jsx(Fr,{value:e,onChange:t,candidates:n,placeholder:o("layout_editor.recipe.modal_placeholder"),testid:"g7le-widget-modal-picker",t:o,bindingCandidates:r})}function tk({value:e,onChange:t,t:n,bindingCandidates:o}){const r=typeof e=="string"?e:e==null?"":String(e);return i.jsx("div",{className:"g7le-widget g7le-widget--i18n-text","data-testid":"g7le-widget-i18n-text",style:{flex:1,minWidth:100,width:"100%"},children:i.jsx(_t,{value:r,onChange:s=>t(s===""?void 0:s),t:n,placeholder:n("layout_editor.recipe.i18n_text_placeholder"),testidPrefix:"g7le-widget-i18n-text-field",candidates:o,enableExpressionTree:!0,expressionTreeCollapsible:!0})})}function nk({value:e,onChange:t,candidates:n,t:o}){const r=e==null?"":String(e),s=r.split(",").map(d=>d.trim()).filter(Boolean),a=Array.isArray(n)&&n.length>0,l=d=>{if(!d)return;const c=[...s,d];t(c.join(", "))};return i.jsxs("div",{className:"g7le-widget g7le-widget--binding-list","data-testid":"g7le-widget-binding-list",style:{display:"flex",flexDirection:"column",gap:4,width:"100%"},children:[i.jsx("input",{type:"text","data-testid":"g7le-widget-binding-list-input",value:r,placeholder:o("layout_editor.recipe.datasource_placeholder"),onChange:d=>t(d.target.value===""?void 0:d.target.value),style:Yc}),a?i.jsxs("select",{className:"g7le-widget g7le-widget--picker","data-testid":"g7le-widget-binding-list-add",value:"",onChange:d=>{l(d.target.value),d.target.value=""},style:{...Gc,minWidth:0},children:[i.jsx("option",{value:"",children:o("layout_editor.recipe.pick_from_list")}),n.map(d=>i.jsx("option",{value:d.value,children:d.label},d.value))]}):null]})}function ok({value:e,onChange:t}){const n=e==null?"":String(e);return i.jsx("input",{type:"text",className:"g7le-widget g7le-widget--text","data-testid":"g7le-widget-text",value:n,onChange:o=>t(o.target.value===""?void 0:o.target.value),style:Yc})}const Gc={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",minWidth:140,width:"100%"},Yc={flex:1,padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,minWidth:100,width:"100%"},Xc={display:"flex",gap:4,alignItems:"flex-start",width:"100%"},Jc={padding:"4px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#64748b",cursor:"pointer"};function rk(e){if(e==null)return"null";if(Array.isArray(e))return"list";switch(typeof e){case"number":return"number";case"boolean":return"boolean";case"string":return"string";default:return"object"}}function Zc(e){switch(e){case"string":return"";case"number":return 0;case"boolean":return!1;case"null":return null;case"list":return[];case"object":return{};default:return null}}function Ls(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)}function ik(e,t,n){return t.includes(n)?"self":e.includes(n)?"inherited":"self"}function sk(e){const t=e.state&&typeof e.state=="object"&&Object.keys(e.state).length>0,n=e.initLocal&&typeof e.initLocal=="object"?e.initLocal:void 0;if(!t)return{initLocal:n??{},migrated:!1};const o={...e.state};if(n)for(const[r,s]of Object.entries(n))o[r]=s;return{initLocal:o,migrated:!0}}const Qc=[{kind:"string",labelKey:"layout_editor.initstate.kind_string"},{kind:"number",labelKey:"layout_editor.initstate.kind_number"},{kind:"boolean",labelKey:"layout_editor.initstate.kind_boolean"},{kind:"null",labelKey:"layout_editor.initstate.kind_null"},{kind:"list",labelKey:"layout_editor.initstate.kind_list"},{kind:"object",labelKey:"layout_editor.initstate.kind_object"}];function Mn({value:e,onChange:t,t:n,path:o,scope:r,depth:s=0,renderStringLeaf:a}){const l=rk(e),d=c=>{t(Zc(c))};return i.jsxs("div",{className:"g7le-initstate-value",style:{paddingLeft:s>0?12:0,minWidth:0},children:[i.jsxs("div",{style:lk,children:[i.jsx("select",{"data-testid":`g7le-initstate-type-${o}`,value:l,onChange:c=>d(c.target.value),style:Rc,children:Qc.map(({kind:c,labelKey:p})=>i.jsx("option",{value:c,children:n(p)},c))}),l==="string"?a?i.jsx("div",{style:{flex:1,minWidth:0},children:a({value:String(e??""),onChange:c=>t(c),testidPrefix:`g7le-initstate-value-${o}`})}):i.jsx("input",{type:"text","data-testid":`g7le-initstate-value-${o}`,value:String(e??""),onChange:c=>t(c.target.value),style:eu}):l==="number"?i.jsx("input",{type:"number","data-testid":`g7le-initstate-value-${o}`,value:typeof e=="number"?e:"",onChange:c=>{const p=parseFloat(c.target.value);t(Number.isNaN(p)?0:p)},style:eu}):l==="boolean"?i.jsx(Or,{checked:!!e,onChange:t,testid:`g7le-initstate-value-${o}`,label:n(e?"layout_editor.overlay.on":"layout_editor.overlay.off")}):l==="null"?i.jsx("span",{"data-testid":`g7le-initstate-value-${o}`,style:dk,children:"null"}):null]}),l==="list"?i.jsxs("div",{style:tu,children:[e.map((c,p)=>i.jsxs("div",{style:ck,children:[i.jsxs("span",{style:uk,children:["[",p,"]"]}),i.jsx("div",{style:{flex:1,minWidth:0},children:i.jsx(Mn,{value:c,onChange:f=>{const b=e.slice();b[p]=f,t(b)},t:n,path:`${o}.${p}`,scope:r,depth:s+1,renderStringLeaf:a})}),i.jsx("button",{type:"button","data-testid":`g7le-initstate-item-remove-${o}.${p}`,onClick:()=>t(e.filter((f,b)=>b!==p)),style:nu,children:"✕"})]},p)),i.jsxs("button",{type:"button","data-testid":`g7le-initstate-item-add-${o}`,onClick:()=>t([...e,""]),style:ou,children:["+ ",n("layout_editor.initstate.add_item")]})]}):null,l==="object"?i.jsx(ak,{value:e,onChange:t,t:n,path:o,scope:r,depth:s+1,renderStringLeaf:a}):null]})}function ak({value:e,onChange:t,t:n,path:o,scope:r,depth:s,renderStringLeaf:a}){const[l,d]=u.useState(""),[c,p]=u.useState("string"),[f,b]=u.useState(null),g=Object.entries(e),m=()=>{const h=l.trim();if(!h){b(n("layout_editor.initstate.name_required"));return}if(!Ls(h)){b(n("layout_editor.initstate.name_invalid"));return}if(h in e){b(n("layout_editor.initstate.name_duplicate"));return}t({...e,[h]:Zc(c)}),d(""),b(null)};return i.jsxs("div",{style:tu,children:[g.map(([h,v])=>i.jsxs("div",{style:pk,children:[i.jsx("code",{style:fk,children:h}),i.jsx("div",{style:{flex:1,minWidth:0},children:i.jsx(Mn,{value:v,onChange:y=>t({...e,[h]:y}),t:n,path:`${o}.${h}`,scope:r,depth:s,renderStringLeaf:a})}),i.jsx("button",{type:"button","data-testid":`g7le-initstate-subremove-${o}.${h}`,onClick:()=>{const y={...e};delete y[h],t(y)},style:nu,children:"✕"})]},h)),i.jsxs("div",{style:gk,children:[i.jsx("input",{type:"text","data-testid":`g7le-initstate-subkey-input-${o}`,value:l,placeholder:n("layout_editor.initstate.subkey_name"),onChange:h=>{d(h.target.value),f&&b(null)},onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),m())},"aria-invalid":f?!0:void 0,style:{...hk,...f?yk:null}}),i.jsx("select",{"data-testid":`g7le-initstate-subkey-kind-${o}`,value:c,onChange:h=>p(h.target.value),"aria-label":n("layout_editor.initstate.value_kind"),style:Rc,children:Qc.map(({kind:h,labelKey:v})=>i.jsx("option",{value:h,children:n(v)},h))}),i.jsxs("button",{type:"button","data-testid":`g7le-initstate-subkey-add-${o}`,onClick:m,style:ou,children:["+ ",n("layout_editor.initstate.add_subkey")]})]}),f?i.jsx("p",{"data-testid":`g7le-initstate-subkey-error-${o}`,style:bk,children:f}):null]})}const lk={display:"flex",gap:6,alignItems:"center",minWidth:0},Rc={padding:"4px 6px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,color:"#64748b"},eu={flex:1,minWidth:0,padding:"4px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,boxSizing:"border-box"},dk={fontSize:12,color:"#94a3b8",fontFamily:"monospace"},tu={display:"flex",flexDirection:"column",gap:6,marginTop:6,paddingLeft:8,borderLeft:"2px solid #e2e8f0"},ck={display:"flex",gap:6,alignItems:"flex-start",minWidth:0},uk={fontSize:11,color:"#94a3b8",minWidth:28,paddingTop:4},pk={display:"flex",gap:6,alignItems:"flex-start",minWidth:0},fk={fontSize:11,color:"#475569",fontFamily:"monospace",minWidth:72,paddingTop:4},nu={border:"none",background:"transparent",color:"#94a3b8",cursor:"pointer",fontSize:12},ou={alignSelf:"flex-start",padding:"2px 8px",fontSize:11,border:"1px dashed #94a3b8",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},gk={display:"flex",gap:6,alignItems:"center"},hk={padding:"4px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6},yk={border:"1px solid #dc2626"},bk={margin:"2px 0 0",fontSize:11,color:"#dc2626"},mk=new Set(["text","data-chip","number"]),vk=new Set(["select","toggle","page-picker","datasource-picker","state-key-picker","modal-picker","component-target-picker","tag-input","locale-picker","i18n-text","segmented","slider","color","image"]);function _k(e,t,n){return typeof e!="string"?n:e.startsWith("$t:")?t(e.slice(3)):e}function xk(e,t){if(e==="page-picker")return t.pageCandidates;if(e==="datasource-picker")return t.dataSourceCandidates;if(e==="state-key-picker")return t.stateKeyCandidates;if(e==="modal-picker")return t.modalCandidates}function wk({param:e,value:t,t:n,pools:o,onChange:r,testIdPrefix:s,renderActionList:a,siblingValues:l}){const d=_k(e.label,n,e.key);if(e.advanced)return i.jsxs("div",{"data-testid":`${s}-locked-${e.key}`,style:zk,children:[i.jsx("span",{style:Nk,children:d}),i.jsxs("span",{style:Mk,children:["[",n("layout_editor.action.advanced"),"] ",n("layout_editor.init_actions.advanced_param_hint")]})]});if(e.widget==="action-list"&&a){const f=Array.isArray(t)?t.filter(b=>!!b&&typeof b=="object"):[];return i.jsxs("div",{"data-testid":`${s}-param-${e.key}`,style:{display:"flex",flexDirection:"column",gap:4},children:[i.jsx("span",{style:io,children:d}),a(f,b=>r(b.length===0?void 0:b),`${s}-${e.key}`,e.key)]})}if(e.widget==="branch-list"&&a){const f=Array.isArray(t)?t.filter(b=>!!b&&typeof b=="object"):[];return i.jsxs("div",{"data-testid":`${s}-param-${e.key}`,style:{display:"flex",flexDirection:"column",gap:4},children:[i.jsx("span",{style:io,children:d}),i.jsx(kk,{branches:f,onChange:b=>r(b.length===0?void 0:b),t:n,pools:o,renderActionList:a,testIdPrefix:`${s}-${e.key}`})]})}if(e.widget==="key-value")return i.jsxs("div",{"data-testid":`${s}-param-${e.key}`,style:{display:"flex",flexDirection:"column",gap:4},children:[i.jsx("span",{style:io,children:d}),i.jsx(Ik,{value:t,onChange:r,t:n,candidates:o.bindingCandidates,testIdPrefix:`${s}-kv-${e.key}`})]});if(e.widget==="state-key-value")return i.jsxs("div",{"data-testid":`${s}-param-${e.key}`,style:{display:"flex",flexDirection:"column",gap:4},children:[i.jsx("span",{style:io,children:d}),i.jsx(Ak,{value:t,onChange:r,t:n,candidates:o.bindingCandidates,stateKeyCandidates:o.stateKeyCandidates,param:e,siblingTarget:l?.target,testIdPrefix:`${s}-skv-${e.key}`})]});if(mk.has(e.widget??"")||!vk.has(e.widget??""))return i.jsxs("div",{"data-testid":`${s}-param-${e.key}`,style:iu,children:[i.jsx("span",{style:io,children:d}),i.jsx("div",{style:{flex:1,minWidth:0},children:i.jsx(Ke,{value:typeof t=="string"?t:t==null?"":String(t),onChange:f=>r(f===""?void 0:f),t:n,candidates:o.bindingCandidates,placeholder:e.widget==="number"?n("layout_editor.action_param.number_placeholder"):void 0,testidPrefix:`${s}-chip-${e.key}`})})]});const p=zn(e.widget);return i.jsxs("div",{"data-testid":`${s}-param-${e.key}`,style:iu,children:[i.jsx("span",{style:io,children:d}),i.jsx("div",{style:{flex:1,minWidth:0},children:p?i.jsx(p,{control:{...e},value:t,onChange:r,t:n,candidates:xk(e.widget,o),bindingCandidates:o.bindingCandidates}):i.jsx(Ke,{value:typeof t=="string"?t:t==null?"":String(t),onChange:f=>r(f===""?void 0:f),t:n,candidates:o.bindingCandidates,testidPrefix:`${s}-chip-${e.key}`})})]})}function kk({branches:e,onChange:t,t:n,pools:o,renderActionList:r,testIdPrefix:s}){const a=b=>Array.isArray(b)?b.filter(g=>!!g&&typeof g=="object"):b&&typeof b=="object"?[b]:[],l=b=>{if(b.length!==0)return b.length===1?b[0]:b},d=(b,g)=>{const m=e.slice();m[b]=g,t(m)},c=b=>{t(e.filter((g,m)=>m!==b))},p=(b,g)=>{if(g<0||g>=e.length)return;const m=e.slice(),[h]=m.splice(b,1);m.splice(g,0,h),t(m)},f=()=>{t([...e,{if:"",then:void 0}])};return i.jsxs("div",{"data-testid":`${s}-branches`,style:{display:"flex",flexDirection:"column",gap:8},children:[e.map((b,g)=>{const m=typeof b.if=="string"?b.if:"",h=a(b.then);return i.jsxs("div",{"data-testid":`${s}-branch-${g}`,style:Sk,children:[i.jsxs("div",{style:Ck,children:[i.jsxs("span",{style:$k,children:[n(m?"layout_editor.action_recipe.conditions.branch_when":"layout_editor.action_recipe.conditions.branch_else")," ",g+1]}),i.jsxs("span",{style:{display:"flex",gap:4},children:[i.jsx("button",{type:"button","data-testid":`${s}-branch-${g}-up`,onClick:()=>p(g,g-1),disabled:g===0,style:Ps,title:n("layout_editor.action_recipe.conditions.move_up"),children:"↑"}),i.jsx("button",{type:"button","data-testid":`${s}-branch-${g}-down`,onClick:()=>p(g,g+1),disabled:g===e.length-1,style:Ps,title:n("layout_editor.action_recipe.conditions.move_down"),children:"↓"}),i.jsx("button",{type:"button","data-testid":`${s}-branch-${g}-remove`,onClick:()=>c(g),style:Ps,title:n("layout_editor.action_recipe.conditions.remove_branch"),children:"✕"})]})]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:3},children:[i.jsx("span",{style:ru,children:n("layout_editor.action_recipe.conditions.param_if")}),i.jsx(Ke,{value:m,onChange:v=>d(g,{...b,if:v}),t:n,candidates:o.bindingCandidates,testidPrefix:`${s}-branch-${g}-if`})]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:3},children:[i.jsx("span",{style:ru,children:n("layout_editor.action_recipe.conditions.param_then")}),r(h,v=>d(g,{...b,then:l(v)}),`${s}-branch-${g}-then`)]})]},g)}),i.jsxs("button",{type:"button","data-testid":`${s}-add-branch`,onClick:f,style:Ek,children:["+ ",n("layout_editor.action_recipe.conditions.add_branch")]})]})}const Sk={border:"1px solid #e2e8f0",borderRadius:6,padding:8,display:"flex",flexDirection:"column",gap:6,background:"#f8fafc"},Ck={display:"flex",justifyContent:"space-between",alignItems:"center"},$k={fontSize:12,fontWeight:700,color:"#475569"},ru={fontSize:11,color:"#64748b"},Ps={border:"1px solid #cbd5e1",background:"#fff",borderRadius:4,width:22,height:22,cursor:"pointer",fontSize:12,lineHeight:"1",color:"#475569"},Ek={border:"1px dashed #94a3b8",background:"#fff",borderRadius:6,padding:"6px 10px",cursor:"pointer",fontSize:12,color:"#475569",alignSelf:"flex-start"};function Ik({value:e,onChange:t,t:n,candidates:o,testIdPrefix:r,renderKeyInput:s}){const a=e&&typeof e=="object"&&!Array.isArray(e)?Object.entries(e).map(([l,d])=>({key:l,value:typeof d=="string"?d:d==null?"":String(d)})):[];return i.jsx(Wr,{value:a,onChange:l=>{const d={};for(const c of l)c.key.trim()!==""&&(d[c.key]=c.value??"");t(Object.keys(d).length===0?void 0:d)},keyField:"key",valueField:"value",t:n,candidates:o,testidPrefix:r,keyPlaceholder:n("layout_editor.action_param.key_placeholder"),valuePlaceholder:n("layout_editor.action_param.value_placeholder"),addLabel:n("layout_editor.action_param.add_pair"),renderKeyInput:s})}function Ak({value:e,onChange:t,t:n,candidates:o,stateKeyCandidates:r,param:s,siblingTarget:a,testIdPrefix:l}){const d=e&&typeof e=="object"&&!Array.isArray(e)?Object.entries(e):[],c=typeof a=="string"?a:"";if((c.startsWith("_local.")||c.startsWith("global.")||c.startsWith("$parent._local.")||c.startsWith("$root._local."))&&d.length===1&&d[0][0]==="value"){const y=d[0][1];return i.jsx("div",{"data-testid":`${l}-path-value`,style:{display:"flex",flexDirection:"column",gap:4},children:i.jsx(Mn,{value:y,onChange:_=>t(_===void 0?void 0:{value:_}),t:n,path:"value",scope:`${l}-path-value-val`,renderStringLeaf:_=>i.jsx(Ke,{value:_.value,onChange:_.onChange,t:n,candidates:o,testidPrefix:_.testidPrefix})})})}const b=(y,_)=>{const w={};for(const[k,x]of d)w[k]=k===y?_:x;t(Object.keys(w).length===0?void 0:w)},g=y=>{const _={};for(const[w,k]of d)w!==y&&(_[w]=k);t(Object.keys(_).length===0?void 0:_)},[m,h]=u.useState(""),v=()=>{const y=m.trim();if(y===""||d.some(([w])=>w===y))return;const _={};for(const[w,k]of d)_[w]=k;_[y]="",t(_),h("")};return i.jsxs("div",{"data-testid":l,style:{display:"flex",flexDirection:"column",gap:6},children:[d.map(([y,_])=>i.jsxs("div",{"data-testid":`${l}-row-${y}`,style:{display:"flex",gap:6,alignItems:"flex-start",border:"1px solid #e2e8f0",borderRadius:8,padding:8},children:[i.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:6},children:[i.jsx("div",{style:{minWidth:0},children:i.jsx(Ms,{control:{...s},value:y,onChange:w=>{const k=w==null?"":String(w);if(k===""||k===y||d.some(([$])=>$===k))return;const x={};for(const[$,C]of d)x[$===y?k:$]=C;t(x)},t:n,candidates:r})}),i.jsx("div",{style:{minWidth:0},children:i.jsx(Mn,{value:_,onChange:w=>b(y,w),t:n,path:y,scope:`${l}-val`,renderStringLeaf:w=>i.jsx(Ke,{value:w.value,onChange:w.onChange,t:n,candidates:o,testidPrefix:w.testidPrefix})})})]}),i.jsx("button",{type:"button","data-testid":`${l}-remove-${y}`,onClick:()=>g(y),title:n("layout_editor.page_settings.seo.remove"),"aria-label":n("layout_editor.page_settings.seo.remove"),style:{flex:"0 0 auto",padding:"4px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#64748b",cursor:"pointer"},children:"✕"})]},y)),i.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[i.jsx("div",{style:{flex:1,minWidth:0},children:i.jsx(Ms,{control:{...s},value:m,onChange:y=>h(y==null?"":String(y)),t:n,candidates:r})}),i.jsxs("button",{type:"button","data-testid":`${l}-add`,onClick:v,style:{flex:"0 0 auto",padding:"5px 10px",fontSize:12,border:"1px dashed #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer"},children:["+ ",n("layout_editor.action_param.add_pair")]})]})]})}function Os({raw:e,recipe:t,values:n,t:o,pools:r,onChange:s,testIdPrefix:a,renderActionList:l}){const d=(c,p)=>{const f={...n,[c]:p},b=Er(t,f),g=gs(e);s(g?Yd(b,g):b)};return i.jsx(i.Fragment,{children:t.params.filter(c=>Tk(c,n)).map(c=>i.jsx(wk,{param:c,value:n[c.key],t:o,pools:r,onChange:p=>d(c.key,p),testIdPrefix:a,renderActionList:l,siblingValues:n},c.key))})}function Tk(e,t){const n=e.dependsOn;return!n||typeof n!="object"||typeof n.param!="string"?!0:t[n.param]===n.equals}function Dk({raw:e,t,onChange:n,testIdPrefix:o,candidates:r}){const[s,a]=u.useState(!1);return i.jsxs("div",{"data-testid":`${o}-if`,style:Lk,children:[i.jsxs("button",{type:"button",onClick:()=>a(l=>!l),style:Pk,children:["▸ ",t("layout_editor.init_actions.if_label")]}),s?i.jsx("div",{"data-testid":`${o}-if-input`,style:{minWidth:0},children:i.jsx(Ke,{value:gs(e)??"",onChange:l=>n(Yd(e,l)),t,candidates:r,placeholder:t("layout_editor.init_actions.if_placeholder"),testidPrefix:`${o}-if-chip`})}):null]})}const iu={display:"flex",alignItems:"center",gap:8,minWidth:0},io={fontSize:11,color:"#64748b",minWidth:80},zk={display:"flex",alignItems:"center",gap:8,padding:"4px 0"},Nk={fontSize:11,color:"#64748b",minWidth:80},Mk={fontSize:11,color:"#92400e"},Lk={display:"flex",flexDirection:"column",gap:4},Pk={textAlign:"left",border:"none",background:"transparent",color:"#475569",cursor:"pointer",fontSize:11,padding:0};function Ok(e,t,n){if(!t)return n("layout_editor.action.source_core");const o=e?.[t],r=o&&typeof o=="object"&&o.__source?o.__source:null;return!r||r.kind==="core"?n("layout_editor.action.source_core"):r.id??n(`layout_editor.action.source_${r.kind}`)}function Bk(e,t,n){const o=Jn(e,t);if(o.kind==="preset"){const r=t.find(s=>s.id===o.recipeId);return Gd(r??null,o.values,s=>n(s.startsWith("$t:")?s.slice(3):s))}return typeof e.handler=="string"?e.handler:n("layout_editor.action_list.unknown")}function Yt({actions:e,onChange:t,t:n,recipes:o,chipContext:r,actionChipCandidates:s,addContext:a="init",renderAddPicker:l,renderEditor:d,candidatePools:c,showSourceBadge:p=!1,canDrag:f,canDropAt:b,isLocked:g,hideAddPicker:m=!1,testIdPrefix:h="g7le-action-list"}){const v=u.useMemo(()=>$o(o),[o]),y=u.useMemo(()=>{if(r==null||r==="init")return c;const B=Yl(r,n,s??null);if(B.length===0)return c;const M=c??{},O=new Set((M.bindingCandidates??[]).map(H=>H.expression)),z=B.filter(H=>!O.has(H.expression));return z.length===0?c:{...M,bindingCandidates:[...z,...M.bindingCandidates??[]]}},[r,s,c,n]),[_,w]=u.useState(null),[k,x]=u.useState(null),$=u.useCallback((B,M)=>{if(B===M||B<0||M<0||B>=e.length||M>=e.length)return;const O=e.slice(),[z]=O.splice(B,1);O.splice(M,0,z),t(O)},[e,t]),C=_s({length:e.length,onMove:$,canDrag:f,canDropAt:b}),S=u.useCallback(B=>{t(e.filter((M,O)=>O!==B))},[e,t]),D=u.useCallback((B,M)=>{const O=e.slice();O[B]=M,t(O)},[e,t]),E=u.useCallback(B=>{t([...e,B])},[e,t]),I=u.useCallback((B,M)=>{const O=Jn(B,v),z=O.kind==="preset"?v.find(P=>P.id===O.recipeId)??null:null;if(!z)return null;const H=O.kind==="preset"?O.values:{};return i.jsxs("div",{style:Fk,children:[i.jsx(Os,{raw:B,recipe:z,values:H,t:n,pools:y??{},onChange:M,testIdPrefix:`${h}-edit`,renderActionList:(P,A,L,F)=>{const Y=F==="onSuccess"?"response":F==="onError"?"error":void 0;return i.jsx(Yt,{actions:P,onChange:A,t:n,recipes:o,chipContext:Y,actionChipCandidates:Y?s:void 0,candidatePools:Y?c:y,addContext:a,showSourceBadge:p,testIdPrefix:L})}}),i.jsx(Dk,{raw:B,t:n,onChange:M,testIdPrefix:`${h}-edit`,candidates:y?.bindingCandidates})]})},[v,n,y,c,s,h,o,a,p]),N=d??(o?I:void 0),T=m?null:l?l(E):o?i.jsx(L0,{recipes:o,t:n,onAdd:E,context:a,testIdPrefix:`${h}-add-picker`}):null;return i.jsxs("div",{className:h,"data-testid":h,children:[i.jsxs("ul",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:6},children:[e.map((B,M)=>{const O=Jn(B,v),z=O.kind==="preset"?O.recipeId:null,H=z?v.find(Y=>Y.id===z)??null:null,P=H===null,A=g?.(M)??!1,L=gs(B)!==null,F=N?N(B,Y=>D(M,Y)):null;return i.jsxs(u.Fragment,{children:[A?null:i.jsx("li",{"aria-hidden":"true",style:{listStyle:"none",margin:0,padding:0},children:i.jsx(to,{active:C.isDropTarget(M),testid:`${h}-dropline-${M}`})}),i.jsxs("li",{"data-testid":`${h}-item-${M}`,"data-drag-source":C.dragIndex===M?"true":void 0,style:{border:"1px solid #e2e8f0",borderRadius:8,padding:"8px 10px",...C.dragIndex===M?{opacity:.5}:{}},onDragOver:C.dragging&&!A?Y=>{Y.preventDefault();const V=Y.currentTarget.getBoundingClientRect();C.onDragOverItem(M,Y.clientY{Y.preventDefault(),C.onDrop()}:void 0,children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[A?i.jsx("span",{style:{fontSize:12},children:"🔒"}):i.jsx("span",{"data-testid":`${h}-drag-${M}`,style:{color:"#94a3b8",cursor:"grab",fontSize:14,userSelect:"none"},draggable:!0,onDragStart:()=>C.onDragStart(M),onDragEnd:C.onDragEnd,"aria-label":n("layout_editor.action_list.drag_reorder"),role:"button",children:"⠿"}),i.jsx("span",{style:{flex:1,minWidth:0,fontSize:13},"data-testid":`${h}-summary-${M}`,children:Bk(B,v,n)}),p?i.jsxs("span",{"data-testid":`${h}-source-${M}`,style:Wk,children:["〔",Ok(o,z,n),"〕"]}):null,L?i.jsxs("span",{"data-testid":`${h}-cond-badge-${M}`,style:jk,children:["〔",n("layout_editor.init_actions.cond_badge"),"〕"]}):null,P?i.jsxs("span",{"data-testid":`${h}-advanced-${M}`,style:Hk,children:["[",n("layout_editor.action.advanced"),"]"]}):null,!A&&F?i.jsxs("button",{type:"button","data-testid":`${h}-edit-${M}`,onClick:()=>x(k===M?null:M),"aria-label":n("layout_editor.init_actions.edit"),title:n("layout_editor.init_actions.edit"),style:k===M?Kk:su,children:["✎ ",n("layout_editor.init_actions.edit")]}):null,i.jsx("button",{type:"button","data-testid":`${h}-code-${M}`,onClick:()=>w(_===M?null:M),"aria-label":n("layout_editor.action_list.view_code"),title:n("layout_editor.action_list.view_code"),style:_===M?Vk:Bs,children:""}),A?null:i.jsx("button",{type:"button","data-testid":`${h}-remove-${M}`,onClick:()=>S(M),"aria-label":n("layout_editor.action_list.remove"),title:n("layout_editor.action_list.remove"),style:Uk,children:"✕"})]}),H?i.jsx(G0,{action:B,recipe:H,values:O.kind==="preset"?O.values:{},t:n,showCodeButton:!1,testIdPrefix:`${h}-preview-${M}`}):null,k===M&&!A&&F?i.jsx("div",{"data-testid":`${h}-edit-body-${M}`,children:F}):null,d&&k!==M?d(B,Y=>D(M,Y)):null,_===M?i.jsx("pre",{"data-testid":`${h}-code-view-${M}`,style:{margin:"8px 0 0",padding:8,background:"#0f172a",color:"#e2e8f0",borderRadius:6,fontSize:12,overflow:"auto"},children:JSON.stringify(B,null,2)}):null]})]},M)}),i.jsx("li",{"aria-hidden":"true",style:{listStyle:"none",margin:0,padding:0},children:i.jsx(to,{active:C.isDropTarget(e.length),testid:`${h}-dropline-end`})})]}),T?i.jsx("div",{style:{marginTop:8},children:T}):null]})}const Wk={fontSize:10,color:"#64748b",whiteSpace:"nowrap"},jk={fontSize:10,color:"#7c3aed",whiteSpace:"nowrap"},Hk={fontSize:10,color:"#92400e",whiteSpace:"nowrap"},Fk={display:"flex",flexDirection:"column",gap:6,paddingTop:6,borderTop:"1px dashed #e2e8f0",marginTop:6},su={flex:"0 0 auto",padding:"3px 8px",fontSize:11,fontWeight:500,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",whiteSpace:"nowrap",lineHeight:1.4},Kk={...su,background:"#eff6ff",borderColor:"#bfdbfe",color:"#2563eb"},Bs={flex:"0 0 auto",width:26,height:24,display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:11,border:"1px solid #e2e8f0",borderRadius:6,background:"#fff",color:"#64748b",cursor:"pointer",fontFamily:"ui-monospace, monospace"},Vk={...Bs,background:"#0f172a",borderColor:"#0f172a",color:"#e2e8f0"},Uk={...Bs,color:"#dc2626",borderColor:"#fecaca",fontFamily:"inherit"};function au(e){const t=e.__source;return t&&typeof t=="object"?t:null}function qk({actions:e,onChange:t,recipes:n,t:o,bindingCandidates:r,pageCandidates:s,dataSourceCandidates:a,stateKeyCandidates:l,modalCandidates:d}){const c=u.useMemo(()=>({pageCandidates:s,dataSourceCandidates:a,stateKeyCandidates:l,modalCandidates:d,bindingCandidates:r}),[s,a,l,d,r]),p=u.useMemo(()=>e.filter(h=>au(h)?.kind==="base"),[e]),f=u.useMemo(()=>e.filter(h=>au(h)?.kind!=="base"),[e]),b=p.length>0,g=u.useCallback(h=>{t(b?[...p,...h]:h)},[t,b,p]),m=u.useCallback(()=>{},[]);return i.jsxs("div",{className:"g7le-init-actions-form","data-testid":"g7le-init-actions-form",style:Gk,children:[i.jsx("p",{style:Yk,children:o("layout_editor.page_settings.init_actions.heading")}),b?i.jsxs(i.Fragment,{children:[i.jsxs("div",{"data-testid":"g7le-init-action-group-base",style:lu,children:[i.jsx("div",{style:du,children:o("layout_editor.init_actions.group_base")}),i.jsx(Yt,{actions:p,onChange:m,t:o,recipes:n,candidatePools:c,addContext:"init",showSourceBadge:!0,isLocked:()=>!0,hideAddPicker:!0,testIdPrefix:"g7le-init-action-base"}),i.jsxs("p",{"data-testid":"g7le-init-action-base-hint",style:Xk,children:["ⓘ ",o("layout_editor.init_actions.base_readonly_hint")]})]}),i.jsxs("div",{"data-testid":"g7le-init-action-group-self",style:lu,children:[i.jsx("div",{style:du,children:o("layout_editor.init_actions.group_self")}),f.length===0?i.jsx("p",{style:cu,children:o("layout_editor.init_actions.empty_self")}):null,i.jsx(Yt,{actions:f,onChange:g,t:o,recipes:n,candidatePools:c,addContext:"init",showSourceBadge:!0,testIdPrefix:"g7le-init-action-self"})]}),i.jsxs("p",{"data-testid":"g7le-init-action-merge-order",style:Jk,children:["ⓘ ",o("layout_editor.init_actions.merge_order")]})]}):i.jsxs(i.Fragment,{children:[e.length===0?i.jsx("p",{"data-testid":"g7le-init-action-empty",style:cu,children:o("layout_editor.init_actions.empty")}):null,i.jsx(Yt,{actions:e,onChange:t,t:o,recipes:n,candidatePools:c,addContext:"init",showSourceBadge:!0,testIdPrefix:"g7le-init-action"})]})]})}const Gk={display:"flex",flexDirection:"column",gap:12,minWidth:0},Yk={margin:0,fontSize:13,fontWeight:700,color:"#0f172a"},lu={border:"1px solid #e2e8f0",borderRadius:10,padding:10,display:"flex",flexDirection:"column",gap:8},du={fontSize:12,fontWeight:700,color:"#475569"},Xk={margin:0,fontSize:11,color:"#64748b"},cu={margin:0,fontSize:12,color:"#94a3b8"},Jk={margin:0,fontSize:11,color:"#64748b"};function Zk(e){return e==="spinner"?new Set(["spinner","page"]):new Set(["skeleton"])}function uu(e,t,n){return typeof e!="string"?n:e.startsWith("$t:")?t(e.slice(3)):e}function pu({candidates:e,value:t,onSelect:n,styleKind:o,t:r,testIdPrefix:s="g7le-loading-component-picker"}){const a=vo(),l=()=>{const d=a.open({ariaLabel:r("layout_editor.overlay.loading_picker.select"),width:520,maxHeightRatio:.7,content:i.jsx(Qk,{candidates:e,value:t,styleKind:o,t:r,testIdPrefix:s,onPick:c=>{n(c),a.close(d)},onClose:()=>a.close(d)})})};return i.jsx("div",{className:s,"data-testid":s,style:{minWidth:0},children:i.jsxs("div",{style:Rk,children:[i.jsx("span",{"data-testid":`${s}-current`,style:e1,children:t&&t.length>0?t:r("layout_editor.overlay.loading_picker.none")}),i.jsxs("button",{type:"button","data-testid":`${s}-open`,onClick:l,style:t1,children:["🔍 ",r("layout_editor.overlay.loading_picker.select")]})]})})}function Qk({candidates:e,value:t,styleKind:n,t:o,testIdPrefix:r,onPick:s,onClose:a}){const[l,d]=u.useState(""),c=Zk(n),p=u.useMemo(()=>{const f=l.trim().toLowerCase();return e.filter(b=>c.has(b.role)).filter(b=>f?uu(b.label,o,b.name).toLowerCase().includes(f)||b.name.toLowerCase().includes(f):!0)},[e,n,l,o]);return i.jsxs("div",{"data-testid":`${r}-modal`,style:n1,children:[i.jsxs("div",{style:o1,children:[i.jsxs("span",{style:r1,children:["🔍 ",o("layout_editor.overlay.loading_picker.select")]}),i.jsx("button",{type:"button","data-testid":`${r}-close`,onClick:a,"aria-label":o("layout_editor.overlay.loading_picker.select"),style:i1,children:"✕"})]}),i.jsx("input",{type:"text","data-testid":`${r}-search`,value:l,placeholder:o("layout_editor.overlay.loading_picker.search"),onChange:f=>d(f.target.value),style:s1,autoFocus:!0}),p.length===0?i.jsx("p",{"data-testid":`${r}-empty`,style:f1,children:o("layout_editor.overlay.loading_picker.empty")}):i.jsx("ul",{style:a1,children:p.map(f=>i.jsx("li",{children:i.jsxs("button",{type:"button","data-testid":`${r}-item-${f.name}`,onClick:()=>s(f.name),style:{...l1,...t===f.name?d1:{}},children:[i.jsx("span",{style:c1,children:uu(f.label,o,f.name)}),i.jsx("code",{style:u1,children:f.name}),i.jsx("span",{style:p1,children:f.role})]})},f.name))})]})}const Rk={display:"flex",alignItems:"center",gap:6,minWidth:0},e1={flex:1,minWidth:0,fontSize:12,color:"#0f172a",fontFamily:"monospace"},t1={padding:"4px 10px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer",whiteSpace:"nowrap"},n1={display:"flex",flexDirection:"column",minHeight:0,padding:16,boxSizing:"border-box",fontFamily:"system-ui, -apple-system, sans-serif"},o1={display:"flex",alignItems:"center",gap:8,paddingBottom:8,borderBottom:"1px solid #e2e8f0",marginBottom:10},r1={flex:1,fontSize:14,fontWeight:700,color:"#0f172a",minWidth:0},i1={border:"none",background:"transparent",color:"#64748b",cursor:"pointer",fontSize:15,lineHeight:1,padding:4},s1={width:"100%",padding:"6px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,marginBottom:8,boxSizing:"border-box"},a1={listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:2,overflowY:"auto",minHeight:0},l1={display:"flex",alignItems:"center",gap:6,width:"100%",textAlign:"left",padding:"8px 10px",fontSize:12,border:"1px solid transparent",background:"transparent",cursor:"pointer",borderRadius:6},d1={border:"1px solid #3b82f6",background:"#eff6ff"},c1={flex:1,minWidth:0,color:"#0f172a"},u1={fontSize:10,color:"#94a3b8",fontFamily:"monospace"},p1={fontSize:10,color:"#64748b",background:"#f1f5f9",borderRadius:4,padding:"0 4px"},f1={margin:0,fontSize:12,color:"#94a3b8",padding:"8px 4px"};function fu(e){return e===!0?{enabled:!0}:e===!1||e===void 0?{}:e}const g1=["opaque","blur","fade","skeleton","spinner"];function h1({value:e,patch:t,t:n,baseValue:o,ownValue:r,loadingComponents:s=[],progressiveDataSources:a=[],bindingCandidates:l}){const d=fu(e),c=d.enabled??!1,p=!!o&&Object.keys(o).length>0,f=zn("component-target-picker"),[b,g]=u.useState((d.wait_for??[]).length>0),m=u.useCallback(k=>{const x={...fu(e)};k(x),t(x)},[e,t]),h=r&&typeof r=="object"?r:e&&typeof e=="object"?e:{},v=u.useCallback(k=>p&&o!==void 0&&k in o&&!(k in h),[p,o,h]),y=u.useCallback(k=>{o&&m(x=>{x[k]=o[k]})},[o,m]),_=u.useCallback(k=>m(x=>{x.enabled=k}),[m]),w=d.target!==void 0?"region":"full";return i.jsxs("div",{className:"g7le-overlay-form","data-testid":"g7le-overlay-form",style:y1,children:[p?i.jsxs("p",{"data-testid":"g7le-overlay-inherit-banner",style:b1,children:["ⓘ ",n("layout_editor.overlay.inherit_banner")]}):null,i.jsxs("div",{style:Vr,children:[i.jsx(Ws,{label:n("layout_editor.overlay.enabled_label"),inherited:v("enabled"),hasInheritance:p,onOverride:()=>y("enabled"),testidKey:"enabled",t:n}),i.jsx(Br,{disabled:v("enabled"),children:i.jsx(Or,{checked:c,onChange:_,testid:"g7le-overlay-enabled",ariaLabel:n("layout_editor.overlay.enabled_label"),label:n(c?"layout_editor.overlay.on":"layout_editor.overlay.off")})}),i.jsxs("p",{style:Ur,children:["ⓘ ",n("layout_editor.overlay.enabled_hint")]})]}),i.jsx(Br,{disabled:!c,testid:"g7le-overlay-body",style:{display:"flex",flexDirection:"column",gap:16,minWidth:0},children:i.jsxs(i.Fragment,{children:[i.jsxs("div",{style:Vr,children:[i.jsx(Ws,{label:n("layout_editor.overlay.scope_label"),inherited:v("target"),hasInheritance:p,onOverride:()=>y("target"),testidKey:"target",t:n}),i.jsxs("div",{"data-testid":"g7le-overlay-scope",style:js,children:[i.jsx(Kr,{active:w==="full",onClick:()=>m(k=>{delete k.target,delete k.fallback_target}),testid:"g7le-overlay-scope-full",children:n("layout_editor.overlay.scope_full")}),i.jsx(Kr,{active:w==="region",onClick:()=>m(k=>{k.target=k.target??""}),testid:"g7le-overlay-scope-region",children:n("layout_editor.overlay.scope_region")})]}),i.jsx(Br,{disabled:w!=="region",testid:"g7le-overlay-region-box",style:x1,children:i.jsxs(i.Fragment,{children:[i.jsx(Ln,{label:n("layout_editor.overlay.target_label"),children:i.jsx("div",{"data-testid":"g7le-overlay-target-picker",children:f?i.jsx(f,{control:{label:n("layout_editor.overlay.target_label")},value:d.target??"",onChange:k=>m(x=>{x.target=typeof k=="string"?k:""}),t:n}):i.jsx("input",{type:"text","data-testid":"g7le-overlay-target-input",value:d.target??"",onChange:k=>m(x=>{x.target=k.target.value}),style:S1})})}),i.jsx(Ln,{label:n("layout_editor.overlay.fallback_label"),children:i.jsx("div",{"data-testid":"g7le-overlay-fallback-picker",children:f?i.jsx(f,{control:{label:n("layout_editor.overlay.fallback_label")},value:d.fallback_target??"",onChange:k=>m(x=>{const $=typeof k=="string"?k:"";$===""?delete x.fallback_target:x.fallback_target=$}),t:n}):null})}),i.jsxs("p",{style:Ur,children:["ⓘ ",n("layout_editor.overlay.fallback_hint")]})]})})]}),i.jsxs("div",{style:Vr,children:[i.jsx(Ws,{label:n("layout_editor.overlay.style_label"),inherited:v("style"),hasInheritance:p,onOverride:()=>y("style"),testidKey:"style",t:n}),i.jsx("div",{"data-testid":"g7le-overlay-style",style:js,children:g1.map(k=>i.jsx(Kr,{active:(d.style??"opaque")===k,onClick:()=>m(x=>{x.style=k}),testid:`g7le-overlay-style-${k}`,children:n(`layout_editor.overlay.style_${k}`)},k))}),d.style==="skeleton"?i.jsxs("div",{style:gu,children:[i.jsx(Ln,{label:n("layout_editor.overlay.skeleton_component"),children:i.jsx(pu,{candidates:s,value:d.skeleton?.component,styleKind:"skeleton",onSelect:k=>m(x=>{x.skeleton={...x.skeleton,component:k}}),t:n,testIdPrefix:"g7le-overlay-skeleton-component"})}),i.jsx(Ln,{label:n("layout_editor.overlay.skeleton_animation"),children:i.jsx("div",{"data-testid":"g7le-overlay-skeleton-anim",style:js,children:["wave","pulse","none"].map(k=>i.jsx(Kr,{active:(d.skeleton?.animation??"wave")===k,onClick:()=>m(x=>{x.skeleton={...x.skeleton,animation:k}}),testid:`g7le-overlay-skeleton-anim-${k}`,children:n(`layout_editor.overlay.anim_${k}`)},k))})}),i.jsx(Ln,{label:n("layout_editor.overlay.skeleton_count"),children:i.jsx("input",{type:"number","data-testid":"g7le-overlay-skeleton-count",value:d.skeleton?.iteration_count??"",onChange:k=>m(x=>{const $=parseInt(k.target.value,10);x.skeleton={...x.skeleton,iteration_count:Number.isNaN($)?void 0:$}}),style:C1})})]}):null,d.style==="spinner"?i.jsxs("div",{style:gu,children:[i.jsx(Ln,{label:n("layout_editor.overlay.spinner_component"),children:i.jsx(pu,{candidates:s,value:d.spinner?.component,styleKind:"spinner",onSelect:k=>m(x=>{x.spinner={...x.spinner,component:k}}),t:n,testIdPrefix:"g7le-overlay-spinner-component"})}),i.jsx(Ln,{label:n("layout_editor.overlay.spinner_text"),children:i.jsx("div",{"data-testid":"g7le-overlay-spinner-text",style:{minWidth:0},children:i.jsx(_t,{value:d.spinner?.text??"",onChange:k=>m(x=>{x.spinner={...x.spinner,text:k===void 0||k===""?void 0:k}}),t:n,candidates:l,enableExpressionTree:!0,expressionTreeCollapsible:!0,testidPrefix:"g7le-overlay-spinner-text-field"})})})]}):null]}),i.jsxs("div",{style:Vr,children:[i.jsxs("button",{type:"button","data-testid":"g7le-overlay-waitfor-toggle","aria-expanded":b,onClick:()=>g(k=>!k),style:I1,children:[b?"▾":"▸"," ",n("layout_editor.overlay.waitfor_label")]}),b?i.jsxs("div",{"data-testid":"g7le-overlay-waitfor-body",style:A1,children:[i.jsxs("p",{"data-testid":"g7le-overlay-waitfor-hint",style:Ur,children:["ⓘ ",n("layout_editor.overlay.waitfor_hint")]}),a.length===0?i.jsx("p",{"data-testid":"g7le-overlay-waitfor-empty",style:Ur,children:n("layout_editor.overlay.waitfor_empty")}):i.jsx("div",{"data-testid":"g7le-overlay-waitfor",style:{display:"flex",flexWrap:"wrap",gap:6},children:a.map(k=>{const x=(d.wait_for??[]).includes(k.id);return i.jsxs("label",{"data-testid":`g7le-overlay-waitfor-${k.id}`,style:$1(x),children:[i.jsx("input",{type:"checkbox",checked:x,onChange:()=>m($=>{const C=new Set($.wait_for??[]);C.has(k.id)?C.delete(k.id):C.add(k.id);const S=Array.from(C);S.length===0?delete $.wait_for:$.wait_for=S})}),i.jsx(Wc,{option:k,testIdPrefix:`g7le-overlay-waitfor-${k.id}`})]},k.id)})})]}):null]}),p?i.jsxs("button",{type:"button","data-testid":"g7le-overlay-reset-inherit",onClick:()=>t(void 0),style:E1,children:["⟲ ",n("layout_editor.overlay.reset_inherit")]}):null]})})]})}function Kr({active:e,onClick:t,children:n,testid:o}){return i.jsx("button",{type:"button","data-testid":o,"aria-pressed":e,onClick:t,style:{...v1,...e?_1:{}},children:n})}function Ws({label:e,inherited:t,hasInheritance:n,onOverride:o,testidKey:r,t:s}){return i.jsxs("div",{style:T1,children:[i.jsx("label",{style:m1,children:e}),n?t?i.jsxs(i.Fragment,{children:[i.jsxs("span",{"data-testid":`g7le-overlay-inherited-${r}`,style:D1,children:["〔",s("layout_editor.overlay.inherited_badge"),"〕"]}),i.jsx("button",{type:"button","data-testid":`g7le-overlay-override-${r}`,onClick:o,style:N1,children:s("layout_editor.overlay.override_field")})]}):i.jsxs("span",{"data-testid":`g7le-overlay-overridden-${r}`,style:z1,children:["〔",s("layout_editor.overlay.overridden_badge"),"〕"]}):null]})}function Ln({label:e,children:t}){return i.jsxs("div",{style:w1,children:[i.jsx("span",{style:k1,children:e}),i.jsx("div",{style:{flex:1,minWidth:0},children:t})]})}const y1={display:"flex",flexDirection:"column",gap:16,minWidth:0},b1={margin:0,fontSize:12,color:"#1d4ed8",background:"#eff6ff",padding:"8px 10px",borderRadius:6},Vr={display:"flex",flexDirection:"column",gap:6,minWidth:0},m1={fontSize:13,fontWeight:600,color:"#0f172a"},Ur={margin:0,fontSize:11,color:"#94a3b8"},js={display:"flex",gap:4,flexWrap:"wrap"},v1={padding:"4px 10px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},_1={border:"1px solid #3b82f6",background:"#eff6ff",color:"#1d4ed8"},x1={display:"flex",flexDirection:"column",gap:8,padding:8,border:"1px dashed #e2e8f0",borderRadius:8},gu={display:"flex",flexDirection:"column",gap:8,padding:8,border:"1px dashed #e2e8f0",borderRadius:8},w1={display:"flex",alignItems:"center",gap:8,minWidth:0},k1={fontSize:11,color:"#64748b",minWidth:90},S1={width:"100%",padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,boxSizing:"border-box"},C1={width:80,padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6},$1=e=>({display:"inline-flex",alignItems:"center",gap:4,padding:"4px 8px",fontSize:12,border:`1px solid ${e?"#3b82f6":"#cbd5e1"}`,borderRadius:12,background:e?"#eff6ff":"#fff",cursor:"pointer"}),E1={alignSelf:"flex-start",padding:"6px 12px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},I1={alignSelf:"flex-start",padding:"4px 0",fontSize:13,fontWeight:600,color:"#0f172a",background:"transparent",border:"none",cursor:"pointer"},A1={display:"flex",flexDirection:"column",gap:6,paddingLeft:14,minWidth:0},T1={display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",minWidth:0},D1={fontSize:11,color:"#64748b",background:"#f1f5f9",borderRadius:4,padding:"1px 6px"},z1={fontSize:11,color:"#0369a1",background:"#e0f2fe",borderRadius:4,padding:"1px 6px"},N1={padding:"2px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},M1="g7le:computed-effect-preview",L1={number:"layout_editor.computed.type_number",string:"layout_editor.computed.type_string",boolean:"layout_editor.computed.type_boolean",list:"layout_editor.computed.type_list",object:"layout_editor.computed.type_object",null:"layout_editor.computed.type_null"};function P1(e,t,n){if(t==="list"){const o=e,r=o.slice(0,2).map(s=>JSON.stringify(s)).join(", ");return o.length<=2?`[${r}]`:`[${r}, ${n("layout_editor.computed.list_more",{count:o.length})}]`}return t==="object"?JSON.stringify(e):t==="boolean"?e?"true":"false":t==="null"?n("layout_editor.computed.value_none"):String(e)}function hu({expr:e,computedKey:t,sampleContext:n,t:o,isEffect:r=!1,testIdPrefix:s="g7le-computed-preview"}){const a=Pd(e,n),l=()=>{typeof window>"u"||!t||window.dispatchEvent(new CustomEvent(M1,{detail:{key:t}}))};return a.ok?i.jsxs("div",{className:s,"data-testid":s,style:O1,children:[i.jsx("span",{style:B1,children:o("layout_editor.computed.preview_label")}),i.jsx("span",{"data-testid":`${s}-value`,style:W1,children:P1(a.value,a.type,o)}),i.jsxs("span",{"data-testid":`${s}-type`,style:j1,children:["(",o(L1[a.type]),")"]}),r&&a.type==="boolean"?i.jsxs("button",{type:"button","data-testid":`${s}-effect`,onClick:l,style:H1,children:["▷ ",o("layout_editor.computed.effect_preview")]}):null]}):i.jsxs("div",{"data-testid":`${s}-error`,style:F1,children:["⚠ ",o("layout_editor.computed.preview_error")]})}const O1={display:"flex",alignItems:"center",flexWrap:"wrap",gap:6,minWidth:0},B1={fontSize:11,color:"#94a3b8"},W1={fontSize:12,color:"#0f172a",fontFamily:"monospace",wordBreak:"break-all"},j1={fontSize:10,color:"#64748b"},H1={padding:"2px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer"},F1={fontSize:12,color:"#b45309"},K1=[{op:"count",labelKey:"layout_editor.computed.op_count"},{op:"sum",labelKey:"layout_editor.computed.op_sum"},{op:"filter",labelKey:"layout_editor.computed.op_filter"},{op:"toOptions",labelKey:"layout_editor.computed.op_to_options"},{op:"nth",labelKey:"layout_editor.computed.op_nth"},{op:"firstOf",labelKey:"layout_editor.computed.op_first_of"},{op:"literal",labelKey:"layout_editor.computed.op_literal"}],V1=["=","!=",">","<",">=","<=","includes"],U1=new Set(["count","sum","filter"]);function yu({model:e,onChange:t,t:n,dataSourceCandidates:o,bindingCandidates:r,existingKeys:s=[]}){const a=u.useCallback(g=>{const m={...e};g(m),t(m)},[e,t]),l=e.conditions??[],d=zn("datasource-picker"),c=e.key!==""&&s.includes(e.key),p=()=>a(g=>{g.conditions=[...g.conditions??[],{field:"",cmp:"=",value:""}]}),f=(g,m)=>a(h=>{const v=(h.conditions??[]).slice(),y={...v[g]};m(y),v[g]=y,h.conditions=v}),b=g=>a(m=>{m.conditions=(m.conditions??[]).filter((h,v)=>v!==g)});return i.jsxs("div",{className:"g7le-computed-custom","data-testid":"g7le-computed-custom",style:q1,children:[i.jsx(Hs,{label:`① ${n("layout_editor.computed.custom_step1")}`,children:i.jsx("div",{"data-testid":"g7le-computed-custom-source",children:d?i.jsx(d,{control:{},value:e.source,onChange:g=>a(m=>{m.source=typeof g=="string"?g:void 0}),t:n,candidates:o}):i.jsx("input",{type:"text",value:e.source??"",onChange:g=>a(m=>{m.source=g.target.value}),style:so})})}),i.jsxs(Hs,{label:`② ${n("layout_editor.computed.custom_step2")}`,children:[i.jsx("select",{"data-testid":"g7le-computed-custom-op",value:e.op,onChange:g=>a(m=>{m.op=g.target.value}),style:so,children:K1.map(({op:g,labelKey:m})=>i.jsx("option",{value:g,children:n(m)},g))}),e.op==="sum"?i.jsx("div",{"data-testid":"g7le-computed-custom-sumfield",style:{minWidth:0},children:i.jsx(Ke,{value:e.sumField??"",onChange:g=>a(m=>{m.sumField=g}),t:n,candidates:r,placeholder:n("layout_editor.computed.custom_sum_field"),testidPrefix:"g7le-computed-custom-sumfield-chip"})}):null,e.op==="toOptions"?i.jsxs("div",{style:{display:"flex",gap:6},children:[i.jsx("div",{"data-testid":"g7le-computed-custom-valuefield",style:{flex:1,minWidth:0},children:i.jsx(Ke,{value:e.valueField??"",onChange:g=>a(m=>{m.valueField=g}),t:n,candidates:r,placeholder:n("layout_editor.computed.custom_value_field"),testidPrefix:"g7le-computed-custom-valuefield-chip"})}),i.jsx("div",{"data-testid":"g7le-computed-custom-labelfield",style:{flex:1,minWidth:0},children:i.jsx(Ke,{value:e.labelField??"",onChange:g=>a(m=>{m.labelField=g}),t:n,candidates:r,placeholder:n("layout_editor.computed.custom_label_field"),testidPrefix:"g7le-computed-custom-labelfield-chip"})})]}):null,e.op==="nth"?i.jsxs("div",{style:{display:"flex",gap:6},children:[i.jsx("input",{type:"text","data-testid":"g7le-computed-custom-index",value:e.index??"",placeholder:"0",onChange:g=>a(m=>{m.index=g.target.value}),style:so}),i.jsx("div",{"data-testid":"g7le-computed-custom-prop",style:{flex:1,minWidth:0},children:i.jsx(Ke,{value:e.prop??"",onChange:g=>a(m=>{m.prop=g}),t:n,candidates:r,placeholder:n("layout_editor.computed.custom_prop"),testidPrefix:"g7le-computed-custom-prop-chip"})})]}):null,e.op==="literal"?i.jsxs("div",{style:{display:"flex",gap:6},children:[i.jsxs("select",{"data-testid":"g7le-computed-custom-literalkind",value:e.literalKind??"string",onChange:g=>a(m=>{m.literalKind=g.target.value}),style:so,children:[i.jsx("option",{value:"string",children:n("layout_editor.computed.kind_string")}),i.jsx("option",{value:"number",children:n("layout_editor.computed.kind_number")}),i.jsx("option",{value:"boolean",children:n("layout_editor.computed.kind_boolean")})]}),i.jsx("div",{"data-testid":"g7le-computed-custom-literalvalue",style:{flex:1,minWidth:0},children:i.jsx(Ke,{value:e.literalValue??"",onChange:g=>a(m=>{m.literalValue=g}),t:n,candidates:r,testidPrefix:"g7le-computed-custom-literalvalue-chip"})})]}):null,e.op==="firstOf"?i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[i.jsx("input",{type:"text","data-testid":"g7le-computed-custom-candidates",value:(e.candidates??[]).join(", "),placeholder:n("layout_editor.computed.custom_candidates"),onChange:g=>a(m=>{m.candidates=g.target.value.split(",").map(h=>h.trim()).filter(Boolean)}),style:so}),i.jsx("div",{"data-testid":"g7le-computed-custom-fallback",style:{minWidth:0},children:i.jsx(Ke,{value:e.fallback??"",onChange:g=>a(m=>{m.fallback=g}),t:n,candidates:r,placeholder:n("layout_editor.computed.custom_fallback"),testidPrefix:"g7le-computed-custom-fallback-chip"})})]}):null,U1.has(e.op)?i.jsxs("div",{style:J1,children:[l.map((g,m)=>i.jsxs("div",{"data-testid":`g7le-computed-custom-cond-${m}`,style:Z1,children:[i.jsx("div",{"data-testid":`g7le-computed-custom-cond-field-${m}`,style:{flex:1,minWidth:0},children:i.jsx(Ke,{value:g.field,onChange:h=>f(m,v=>{v.field=h}),t:n,candidates:r,placeholder:n("layout_editor.computed.cond_field"),testidPrefix:`g7le-computed-custom-cond-field-${m}-chip`})}),i.jsx("select",{value:g.cmp,onChange:h=>f(m,v=>{v.cmp=h.target.value}),style:Q1,children:V1.map(h=>i.jsx("option",{value:h,children:h},h))}),i.jsx("div",{"data-testid":`g7le-computed-custom-cond-value-${m}`,style:{flex:1,minWidth:0},children:i.jsx(Ke,{value:g.value,onChange:h=>f(m,v=>{v.value=h}),t:n,candidates:r,placeholder:n("layout_editor.computed.cond_value"),testidPrefix:`g7le-computed-custom-cond-value-${m}-chip`})}),i.jsx("button",{type:"button","data-testid":`g7le-computed-custom-cond-remove-${m}`,onClick:()=>b(m),style:R1,children:"✕"})]},m)),i.jsxs("button",{type:"button","data-testid":"g7le-computed-custom-cond-add",onClick:p,style:eS,children:["+ ",n("layout_editor.computed.cond_add")]})]}):null]}),i.jsxs(Hs,{label:`③ ${n("layout_editor.computed.custom_step3")}`,children:[i.jsx("input",{type:"text","data-testid":"g7le-computed-custom-key",value:e.key,onChange:g=>a(m=>{m.key=g.target.value}),style:{...so,...c?X1:{}}}),c?i.jsxs("p",{"data-testid":"g7le-computed-custom-key-dup",style:tS,children:["⚠ ",n("layout_editor.computed.key_duplicate")]}):null]})]})}function Hs({label:e,children:t}){return i.jsxs("div",{style:G1,children:[i.jsx("div",{style:Y1,children:e}),i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,minWidth:0},children:t})]})}function Fs(e){return gv(e)}const q1={display:"flex",flexDirection:"column",gap:12,padding:10,border:"1px solid #cbd5e1",borderRadius:8,background:"#fff"},G1={display:"flex",flexDirection:"column",gap:4,minWidth:0},Y1={fontSize:12,fontWeight:600,color:"#475569"},so={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,minWidth:0,width:"100%",boxSizing:"border-box"},X1={border:"1px solid #ef4444"},J1={display:"flex",flexDirection:"column",gap:6,marginTop:4},Z1={display:"flex",gap:4,alignItems:"center",minWidth:0},Q1={padding:"4px 6px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6},R1={border:"none",background:"transparent",color:"#94a3b8",cursor:"pointer",fontSize:12},eS={alignSelf:"flex-start",padding:"2px 8px",fontSize:11,border:"1px dashed #94a3b8",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},tS={margin:0,fontSize:11,color:"#b45309"};function Ks(e,t,n){return typeof e!="string"?n:e.startsWith("$t:")?t(e.slice(3)):e}function nS(e){if(e&&typeof e=="object"){const t=e.__source;if(t&&typeof t=="object")return t}return null}function oS({computed:e,onChange:t,recipes:n,t:o,sampleContext:r,dataSourceCandidates:s,bindingCandidates:a,computedSource:l={},effectKeys:d=[],onRevert:c}){const p=u.useMemo(()=>Ad(n),[n]),[f,b]=u.useState(!1),[g,m]=u.useState(null),h=Object.keys(e),v=u.useCallback((x,$)=>{t({...e,[x]:$})},[e,t]),y=u.useCallback(x=>{const $={...e};delete $[x],t($)},[e,t]),_=u.useCallback((x,$,C)=>{const S={...e};x&&x!==$&&delete S[x],S[$]=C,t(S)},[e,t]),w=u.useCallback(x=>{const $=Dd(x,{});let C=x.id,S=1;for(;C in e;)C=`${x.id}${++S}`;t({...e,[C]:$}),b(!1)},[e,t]),k=u.useCallback(()=>{!g||!g.key||(t({...e,[g.key]:Fs(g)}),m(null),b(!1))},[g,e,t]);return i.jsxs("div",{className:"g7le-computed-form","data-testid":"g7le-computed-form",style:aS,children:[i.jsx("p",{style:lS,children:o("layout_editor.page_settings.computed.heading")}),h.length>0?h.map(x=>i.jsx(rS,{computedKey:x,expr:e[x],recipes:p,rawRecipes:n,t:o,sampleContext:r,dataSourceCandidates:s,bindingCandidates:a,source:l[x],isEffect:d.includes(x),existingKeys:h,onPatchExpr:$=>v(x,$),onRename:($,C)=>_(x,$,C),onRemove:()=>y(x),onRevert:c?()=>c(x):void 0},x)):i.jsx("p",{"data-testid":"g7le-computed-empty",style:DS,children:o("layout_editor.computed.empty")}),i.jsxs("div",{style:{minWidth:0},children:[i.jsxs("button",{type:"button","data-testid":"g7le-computed-add",onClick:()=>b(x=>!x),style:kS,children:["+ ",o("layout_editor.computed.add")," ▾"]}),f?i.jsxs("div",{"data-testid":"g7le-computed-add-list",style:SS,children:[["common","more"].map(x=>{const $=p.filter(C=>(C.group??"more")===x);return $.length===0?null:i.jsxs("div",{children:[i.jsxs("div",{style:CS,children:["━━ ",o(`layout_editor.computed.group_${x}`)," ━━"]}),$.map(C=>{const S=nS(n?.[C.id]);return i.jsxs("button",{type:"button","data-testid":`g7le-computed-preset-${C.id}`,onClick:()=>w(C),style:$S,children:[i.jsx("span",{style:ES,children:Ks(C.label,o,C.id)}),S&&S.kind!=="core"?i.jsxs("span",{"data-testid":`g7le-computed-preset-source-${C.id}`,style:IS,children:["〔",S.id??S.kind,"〕"]}):null]},C.id)})]},x)}),i.jsxs("div",{style:{borderTop:"1px solid #e2e8f0",marginTop:6,paddingTop:6},children:[i.jsxs("button",{type:"button","data-testid":"g7le-computed-custom-open",onClick:()=>m(g?null:{key:"",op:"count",source:"",conditions:[]}),style:AS,children:["⚙ ",o("layout_editor.computed.custom_open")," ▾"]}),g?i.jsxs("div",{style:{marginTop:6},children:[i.jsx(yu,{model:g,onChange:m,t:o,dataSourceCandidates:s,bindingCandidates:a,existingKeys:h}),i.jsx("div",{"data-testid":"g7le-computed-custom-preview",style:{marginTop:6},children:i.jsx(hu,{expr:Fs(g),sampleContext:r,t:o,testIdPrefix:"g7le-computed-custom-preview-eval"})}),i.jsx("button",{type:"button","data-testid":"g7le-computed-custom-commit",disabled:!g.key||h.includes(g.key),onClick:k,style:TS,children:o("layout_editor.computed.custom_add")})]}):null]})]}):null]})]})}function rS({computedKey:e,expr:t,recipes:n,rawRecipes:o,t:r,sampleContext:s,dataSourceCandidates:a,bindingCandidates:l,source:d,isEffect:c,existingKeys:p,onPatchExpr:f,onRename:b,onRemove:g,onRevert:m}){const[h,v]=u.useState(!1),[y,_]=u.useState(!1),w=u.useMemo(()=>Ld(t,n),[t,n]),k=d==="base",x=d==="route-override",$=w.kind==="advanced",C=w.kind==="preset"?n.find(E=>E.id===w.recipeId)??null:null,S=C?Ks(C.label,r,e):e,D=(E,I)=>{if(w.kind!=="preset"||!C)return;const N={...w.params,[E]:I};f(Dd(C,N))};return i.jsxs("div",{"data-testid":`g7le-computed-item-${e}`,style:dS,children:[i.jsxs("div",{style:cS,children:[i.jsx("span",{style:uS,children:S}),i.jsx("code",{style:pS,children:e}),k?i.jsxs("span",{"data-testid":`g7le-computed-source-${e}`,style:fS,children:["〔",r("layout_editor.computed.source_base"),"〕"]}):null,x?i.jsxs("span",{"data-testid":`g7le-computed-overridden-${e}`,style:gS,children:["〔",r("layout_editor.computed.source_overridden"),"〕"]}):null,$?i.jsxs("span",{"data-testid":"g7le-computed-advanced",style:hS,children:["[",r("layout_editor.action.advanced"),"]"]}):null,i.jsx("span",{style:{flex:1}}),i.jsx("button",{type:"button","data-testid":`g7le-computed-code-${e}`,onClick:()=>_(E=>!E),style:Vs,"aria-label":r("layout_editor.value_tree.show_source"),title:r("layout_editor.value_tree.show_source"),children:""}),$?null:i.jsx("button",{type:"button","data-testid":`g7le-computed-edit-${e}`,onClick:()=>v(E=>!E),style:Vs,children:r("layout_editor.init_actions.edit")}),i.jsx("button",{type:"button","data-testid":`g7le-computed-remove-${e}`,onClick:g,style:Vs,"aria-label":r("layout_editor.init_actions.remove"),children:"✕"})]}),y?i.jsx("pre",{"data-testid":`g7le-computed-code-block-${e}`,style:zS,children:t}):null,i.jsx("div",{"data-testid":`g7le-computed-preview-${e}`,children:i.jsx(hu,{expr:t,computedKey:e,sampleContext:s,t:r,isEffect:c,testIdPrefix:`g7le-computed-preview-${e}-eval`})}),x&&m?i.jsxs("div",{style:yS,children:[i.jsxs("span",{style:bS,children:["ⓘ ",r("layout_editor.computed.overridden_hint")]}),i.jsx("button",{type:"button","data-testid":`g7le-computed-revert-${e}`,onClick:m,style:mS,children:r("layout_editor.computed.revert")})]}):null,h&&!$?i.jsxs("div",{style:vS,children:[k?i.jsxs("p",{"data-testid":`g7le-computed-override-notice-${e}`,style:_S,children:["⚠ ",r("layout_editor.computed.override_notice")]}):null,w.kind==="preset"&&C?i.jsx(i.Fragment,{children:C.params.map(E=>i.jsx(sS,{param:E,value:w.params[E.key]??"",t:r,dataSourceCandidates:a,bindingCandidates:l,onChange:I=>D(E.key,I)},E.key))}):w.kind==="custom"?i.jsx(yu,{model:{...w.model,key:e},onChange:E=>b(E.key,Fs(E)),t:r,dataSourceCandidates:a,bindingCandidates:l,existingKeys:p.filter(E=>E!==e)}):null]}):null]})}const iS=new Set(["datasource-picker","binding-picker","select","toggle","state-key-picker","page-picker"]);function sS({param:e,value:t,t:n,dataSourceCandidates:o,bindingCandidates:r,onChange:s}){const a=Ks(e.label,n,e.key),l=e.widget??"",c=iS.has(l)?zn(e.widget):null,p=l==="datasource-picker"||l==="binding-picker"?o:void 0;return i.jsxs("div",{"data-testid":`g7le-computed-param-${e.key}`,style:xS,children:[i.jsx("span",{style:wS,children:a}),i.jsx("div",{style:{flex:1,minWidth:0},children:c?i.jsx(c,{control:{...e},value:t,onChange:f=>s(typeof f=="string"?f:""),t:n,candidates:p}):i.jsx(Ke,{value:t,onChange:f=>s(f),t:n,candidates:r,testidPrefix:`g7le-computed-param-${e.key}-chip`})})]})}const aS={display:"flex",flexDirection:"column",gap:12,minWidth:0},lS={margin:0,fontSize:13,fontWeight:700,color:"#0f172a"},dS={border:"1px solid #e2e8f0",borderRadius:8,padding:"8px 10px",display:"flex",flexDirection:"column",gap:6,background:"#f8fafc"},cS={display:"flex",alignItems:"center",gap:6},uS={fontSize:13,fontWeight:600,color:"#0f172a"},pS={fontSize:10,color:"#64748b",fontFamily:"monospace"},fS={fontSize:10,color:"#0891b2",whiteSpace:"nowrap"},gS={fontSize:10,color:"#7c3aed",whiteSpace:"nowrap"},hS={fontSize:10,color:"#92400e",whiteSpace:"nowrap"},yS={display:"flex",alignItems:"center",gap:8,marginTop:4,minWidth:0},bS={fontSize:11,color:"#7c3aed",flex:1,minWidth:0},mS={border:"1px solid #c4b5fd",borderRadius:6,background:"#f5f3ff",color:"#6d28d9",cursor:"pointer",fontSize:11,padding:"2px 8px",whiteSpace:"nowrap"},Vs={border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",fontSize:11,padding:"2px 6px"},vS={display:"flex",flexDirection:"column",gap:6,paddingTop:6,borderTop:"1px dashed #e2e8f0"},_S={margin:0,fontSize:11,color:"#b45309",background:"#fef3c7",padding:"6px 8px",borderRadius:6},xS={display:"flex",alignItems:"center",gap:8,minWidth:0},wS={fontSize:11,color:"#64748b",minWidth:90},kS={padding:"6px 12px",fontSize:12,border:"1px dashed #94a3b8",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},SS={marginTop:6,border:"1px solid #cbd5e1",borderRadius:8,background:"#fff",padding:8,maxHeight:380,overflowY:"auto"},CS={fontSize:11,fontWeight:700,color:"#94a3b8",padding:"6px 4px 2px"},$S={display:"flex",alignItems:"center",gap:6,width:"100%",textAlign:"left",padding:"6px 8px",fontSize:12,border:"none",background:"transparent",cursor:"pointer",borderRadius:6},ES={flex:1,minWidth:0,color:"#0f172a"},IS={fontSize:10,color:"#64748b",whiteSpace:"nowrap"},AS={padding:"6px 10px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer"},TS={marginTop:6,padding:"6px 12px",fontSize:12,border:"1px solid #3b82f6",borderRadius:6,background:"#3b82f6",color:"#fff",cursor:"pointer"},DS={margin:0,fontSize:12,color:"#94a3b8"},zS={margin:"2px 0 0",padding:"6px 8px",fontSize:11,fontFamily:"monospace",color:"#0f172a",background:"#f1f5f9",border:"1px solid #e2e8f0",borderRadius:6,whiteSpace:"pre-wrap",wordBreak:"break-all",overflowX:"auto"};function NS(e,t){return t==="any"?!0:e===null||typeof e!="object"?!1:t==="object"?!Array.isArray(e):!0}function Us({value:e,onChange:t,onValidityChange:n,t:o,shape:r="any",emptyValue:s=void 0,placeholder:a,minHeight:l=80,testidPrefix:d="g7le-json-block",shapeErrorKey:c,invalidErrorKey:p,ariaLabel:f,id:b,validate:g}){const[m,h]=u.useState(()=>qr(e)),[v,y]=u.useState(null),_=u.useRef(!1),w=u.useRef(e);u.useEffect(()=>{if(!_.current&&!Object.is(e,w.current)){if(qr(e)===qr(w.current)){w.current=e;return}h(qr(e)),y(null),w.current=e,n?.(!0)}},[e]);const k=x=>{if(_.current=!0,h(x),x.trim()===""){y(null),w.current=s,n?.(!0),t(s);return}let $;try{$=JSON.parse(x)}catch{y(o(p??"layout_editor.json_block.invalid")),n?.(!1);return}if(!NS($,r)){y(o(c??"layout_editor.json_block.invalid")),n?.(!1);return}const C=g?.($)??null;if(C){y(C),n?.(!1);return}y(null),w.current=$,n?.(!0),t($)};return i.jsxs("div",{className:"g7le-json-block",style:MS,children:[i.jsx("textarea",{id:b,"data-testid":d,style:{...LS,minHeight:l},value:m,spellCheck:!1,"aria-label":f,"aria-invalid":v?!0:void 0,placeholder:a,onChange:x=>k(x.target.value),onBlur:()=>{_.current=!1}}),v?i.jsx("div",{"data-testid":`${d}-error`,style:PS,children:v}):null]})}function qr(e){if(e===void 0)return"";try{return JSON.stringify(e,null,2)??""}catch{return""}}const MS={display:"flex",flexDirection:"column",gap:4,minWidth:0},LS={width:"100%",boxSizing:"border-box",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:12,lineHeight:1.5,color:"#0f172a",background:"#fff",border:"1px solid #cbd5e1",borderRadius:6,padding:"6px 8px",resize:"vertical"},PS={fontSize:11,color:"#dc2626"},OS=[{kind:"string",labelKey:"layout_editor.initstate.kind_string"},{kind:"number",labelKey:"layout_editor.initstate.kind_number"},{kind:"boolean",labelKey:"layout_editor.initstate.kind_boolean"},{kind:"null",labelKey:"layout_editor.initstate.kind_null"},{kind:"list",labelKey:"layout_editor.initstate.kind_list"},{kind:"object",labelKey:"layout_editor.initstate.kind_object"}],qs={local:"initLocal",global:"initGlobal",isolated:"initIsolated"};function BS({raw:e,own:t,patch:n,t:o,isolatedOrphan:r={}}){const s=u.useMemo(()=>{const f=t?.state&&typeof t.state=="object"?t.state:void 0,b=e?.state&&typeof e.state=="object"?e.state:void 0;if(!(!f&&!b))return{...b??{},...f??{}}},[t,e]),{initLocal:a,migrated:l}=u.useMemo(()=>sk({initLocal:e?.initLocal,state:s}),[e,s]),d=f=>{if(f==="local")return a;const b=e?.[qs[f]];return b&&typeof b=="object"?b:{}},c=f=>{if(f==="local"){const b=t?.initLocal??{},g=s?Object.keys(s):[];return Array.from(new Set([...Object.keys(b),...g]))}return Object.keys(t?.[qs[f]]??{})},p=u.useCallback((f,b)=>{const g=qs[f];f==="local"&&l&&n("state",void 0),n(g,Object.keys(b).length===0?void 0:b)},[n,l]);return i.jsxs("div",{className:"g7le-initstate-form","data-testid":"g7le-initstate-form",style:jS,children:[i.jsx("p",{style:HS,children:o("layout_editor.page_settings.initstate.heading")}),l?i.jsxs("p",{"data-testid":"g7le-initstate-legacy-state",style:FS,children:["ⓘ ",o("layout_editor.initstate.legacy_state")]}):null,i.jsx(Gs,{scope:"local",label:o("layout_editor.initstate.section_local"),value:d("local"),ownKeys:c("local"),patchSection:p,t:o}),i.jsx(Gs,{scope:"global",label:o("layout_editor.initstate.section_global"),value:d("global"),ownKeys:c("global"),patchSection:p,t:o}),i.jsx(Gs,{scope:"isolated",label:o("layout_editor.initstate.section_isolated"),description:o("layout_editor.initstate.section_isolated_desc"),value:d("isolated"),ownKeys:c("isolated"),patchSection:p,t:o,orphan:r}),i.jsxs("p",{style:sC,children:["ⓘ ",o("layout_editor.initstate.isolated_dynamic_hint")]})]})}function Gs({scope:e,label:t,description:n,value:o,ownKeys:r,patchSection:s,t:a,orphan:l={}}){const[d,c]=u.useState(""),[p,f]=u.useState("string"),[b,g]=u.useState(null),[m,h]=u.useState(!1),v=Object.keys(o),y=v,_=(x,$)=>{s(e,{...o,[x]:$})},w=x=>{const $={...o};delete $[x],s(e,$)},k=()=>{const x=d.trim();if(!x){g(a("layout_editor.initstate.name_required"));return}if(!Ls(x)){g(a("layout_editor.initstate.name_invalid"));return}if(x in o){g(a("layout_editor.initstate.name_duplicate"));return}const $={string:"",number:0,boolean:!1,null:null,list:[],object:{}};s(e,{...o,[x]:$[p]}),c(""),g(null)};return i.jsxs("div",{"data-testid":`g7le-initstate-section-${e}`,style:KS,children:[i.jsxs("div",{style:VS,children:[i.jsx("div",{style:US,children:t}),i.jsx("button",{type:"button","data-testid":`g7le-initstate-${e}-mode-toggle`,onClick:()=>h(x=>!x),style:GS,children:a(m?"layout_editor.json_block.mode_block":"layout_editor.json_block.mode_code")})]}),n?i.jsxs("p",{style:qS,children:["ⓘ ",n]}):null,m?i.jsx(Us,{value:o,shape:"object",emptyValue:{},onChange:x=>s(e,x??{}),t:a,testidPrefix:`g7le-initstate-${e}-code`,placeholder:`{ "keyword": "", "page": 1 -}`,shapeErrorKey:"layout_editor.json_block.must_be_object",validate:x=>{const $=Object.keys(x??{}).filter(S=>!Ds(S));return $.length?a("layout_editor.json_block.invalid_keys",{keys:$.join(", ")}):null}}):i.jsxs(i.Fragment,{children:[v.length===0?i.jsx("p",{"data-testid":`g7le-initstate-${e}-empty`,style:FS,children:a("layout_editor.initstate.no_values")}):v.map(x=>{const S=F0(y,r,x)==="inherited",C=e==="isolated"&&l[x];return i.jsx(wS,{scope:e,itemKey:x,value:o[x],inherited:S,isOrphan:!!C,onChangeValue:T=>_(x,T),onRemove:()=>w(x),t:a},x)}),i.jsxs("div",{style:PS,children:[i.jsx("input",{type:"text","data-testid":`g7le-initstate-${e}-add-name`,value:d,placeholder:a("layout_editor.initstate.value_name"),onChange:x=>{c(x.target.value),b&&g(null)},onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),k())},"aria-invalid":b?!0:void 0,style:{...OS,...b?BS:null}}),i.jsx("select",{"data-testid":`g7le-initstate-${e}-add-kind`,value:p,onChange:x=>f(x.target.value),"aria-label":a("layout_editor.initstate.value_kind"),style:jS,children:_S.map(x=>i.jsx("option",{value:x.kind,children:a(x.labelKey)},x.kind))}),i.jsxs("button",{type:"button","data-testid":`g7le-initstate-${e}-add`,onClick:k,style:HS,children:["+ ",a("layout_editor.initstate.add_value")]})]}),b?i.jsx("p",{"data-testid":`g7le-initstate-${e}-add-error`,style:WS,children:b}):null]})]})}function wS({scope:e,itemKey:t,value:n,inherited:o,isOrphan:r,onChangeValue:s,onRemove:a,t:l}){const[d,c]=u.useState(!1);let p;try{p=JSON.stringify(n,null,2)??String(n)}catch{p=String(n)}return i.jsxs("div",{"data-testid":`g7le-initstate-${e}-item-${t}`,style:DS,children:[i.jsxs("div",{style:zS,children:[o?i.jsx("span",{"data-testid":`g7le-initstate-inherited-${t}`,style:NS,children:"🔗"}):null,i.jsx("code",{style:MS,children:t}),i.jsx("span",{style:{flex:1}}),i.jsx("button",{type:"button","data-testid":`g7le-initstate-code-${t}`,onClick:()=>c(f=>!f),style:Vs,"aria-label":l("layout_editor.value_tree.show_source"),title:l("layout_editor.value_tree.show_source"),children:""}),o?i.jsx("button",{type:"button","data-testid":`g7le-initstate-revert-${t}`,onClick:a,style:Vs,children:l("layout_editor.initstate.revert")}):i.jsx("button",{type:"button","data-testid":`g7le-initstate-remove-${t}`,onClick:a,style:Vs,"aria-label":l("layout_editor.init_actions.remove"),children:"✕"})]}),d?i.jsx("pre",{"data-testid":`g7le-initstate-code-block-${t}`,style:VS,children:p}):null,i.jsx(zn,{value:n,onChange:s,t:l,path:t,scope:e}),r?i.jsxs("p",{"data-testid":`g7le-initstate-isolated-orphan-${t}`,style:LS,children:["⚠ ",l("layout_editor.initstate.isolated_orphan")]}):null]})}const kS={display:"flex",flexDirection:"column",gap:14,minWidth:0},SS={margin:0,fontSize:13,fontWeight:700,color:"#0f172a"},CS={margin:0,fontSize:11,color:"#1d4ed8",background:"#eff6ff",padding:"6px 8px",borderRadius:6},$S={display:"flex",flexDirection:"column",gap:8,padding:10,border:"1px solid #e2e8f0",borderRadius:10,minWidth:0},ES={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},IS={fontSize:12,fontWeight:700,color:"#475569"},AS={margin:0,fontSize:11,color:"#94a3b8"},TS={padding:"2px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},DS={display:"flex",flexDirection:"column",gap:4,padding:"6px 8px",border:"1px solid #f1f5f9",borderRadius:6,minWidth:0},zS={display:"flex",alignItems:"center",gap:6},NS={fontSize:12},MS={fontSize:12,color:"#0f172a",fontFamily:"monospace"},Vs={border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",fontSize:11,padding:"2px 6px"},LS={margin:0,fontSize:11,color:"#b45309",background:"#fef3c7",padding:"4px 6px",borderRadius:6},PS={display:"flex",gap:6,alignItems:"center"},OS={padding:"4px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6},BS={border:"1px solid #dc2626"},WS={margin:0,fontSize:11,color:"#dc2626"},jS={padding:"4px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#0f172a"},HS={padding:"2px 10px",fontSize:11,border:"1px dashed #94a3b8",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},FS={margin:0,fontSize:12,color:"#94a3b8"},KS={margin:0,fontSize:11,color:"#94a3b8"},VS={margin:"2px 0",padding:"6px 8px",fontSize:11,fontFamily:"monospace",color:"#0f172a",background:"#f1f5f9",border:"1px solid #e2e8f0",borderRadius:6,whiteSpace:"pre-wrap",wordBreak:"break-all",overflowX:"auto"},US={self:"layout_editor.error_rows.source_self",inherited:"layout_editor.error_rows.source_inherited",template:"layout_editor.error_rows.source_template",none:"layout_editor.error_rows.source_none"};function Us({value:e,onChange:t,t:n,codes:o,mode:r="local",sourceOf:s,renderActionList:a,testIdPrefix:l="g7le-error-rows"}){const d=o??Object.keys(e),c=u.useCallback((f,b)=>{t({...e,[f]:b})},[e,t]),p=u.useCallback(f=>{const b={...e};delete b[f],t(b)},[e,t]);return i.jsx("div",{className:l,"data-testid":l,children:d.map(f=>{const b=e[f],g=b!==void 0,m=r==="badge"&&s?s(f):null;return i.jsxs("div",{"data-testid":`${l}-row-${f}`,style:{border:"1px solid #e2e8f0",borderRadius:8,padding:"8px 10px",marginBottom:6},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i.jsx("strong",{"data-testid":`${l}-code-${f}`,style:{fontSize:13},children:f==="default"?n("layout_editor.error_rows.default"):f}),m?i.jsxs("span",{"data-testid":`${l}-source-${f}`,style:{fontSize:11,padding:"2px 6px",borderRadius:4,background:"#f1f5f9",color:"#475569"},children:["〔",n(US[m]),"〕"]}):null,g?i.jsx("button",{type:"button","data-testid":`${l}-clear-${f}`,onClick:()=>p(f),style:{marginLeft:"auto",fontSize:12},children:n("layout_editor.error_rows.clear")}):i.jsx("span",{style:{marginLeft:"auto",fontSize:12,color:"#94a3b8"},children:n("layout_editor.error_rows.no_action")})]}),m==="inherited"||m==="template"?i.jsxs("div",{"data-testid":`${l}-override-${f}`,style:{marginTop:6,display:"flex",alignItems:"flex-start",gap:8},children:[i.jsxs("p",{style:{margin:0,flex:1,fontSize:12,color:"#64748b"},children:["ⓘ ",n(m==="inherited"?"layout_editor.error_rows.override_inherited":"layout_editor.error_rows.override_template")]}),g?i.jsx("button",{type:"button","data-testid":`${l}-revert-${f}`,onClick:()=>p(f),style:{fontSize:12,padding:"2px 8px",border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",whiteSpace:"nowrap"},children:n("layout_editor.error_rows.revert")}):i.jsx("button",{type:"button","data-testid":`${l}-override-here-${f}`,onClick:()=>c(f,{}),style:{fontSize:12,padding:"2px 8px",border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",whiteSpace:"nowrap"},children:n("layout_editor.error_rows.override_here")})]}):null,f==="default"?i.jsxs("p",{"data-testid":`${l}-default-warn-${f}`,style:{margin:"6px 0 0",fontSize:12,color:"#b45309"},children:["⚠ ",n("layout_editor.error_rows.default_warning")]}):null,i.jsx("div",{style:{marginTop:6},children:a?a(f,b,h=>c(f,h)):i.jsx("pre",{"data-testid":`${l}-json-${f}`,style:{margin:0,fontSize:12,color:"#475569"},children:g?JSON.stringify(b):""})})]},f)})})}function qS(e){return[...e.filter(n=>n!=="maintenance"),"default"]}function GS({value:e,onChange:t,t:n,errorConfigCodes:o=[],ownCodes:r=[],templateCodes:s=[],recipes:a,pageCandidates:l,modalCandidates:d,dataSourceCandidates:c,stateKeyCandidates:p}){const f=u.useMemo(()=>ko(a),[a]),b=u.useMemo(()=>qS(o),[o]),g=f.length>0,m=u.useMemo(()=>Vl("error",n),[n]),h=u.useMemo(()=>({pageCandidates:l,dataSourceCandidates:c,stateKeyCandidates:p,modalCandidates:d,bindingCandidates:m}),[l,c,p,d,m]),v=u.useCallback(y=>r.includes(y)?"self":y in e?"inherited":s.includes(y)?"template":"none",[r,e,s]);return g?i.jsxs("div",{className:"g7le-error-form","data-testid":"g7le-error-form",style:fu,children:[i.jsx("p",{style:gu,children:n("layout_editor.page_settings.error.heading")}),i.jsxs("p",{style:XS,children:["ⓘ ",n("layout_editor.error.intro")]}),i.jsx(Us,{value:e,onChange:t,t:n,codes:b,mode:"badge",sourceOf:v,testIdPrefix:"g7le-error-rows",renderActionList:(y,_,w)=>i.jsx(YS,{code:y,action:_,recipes:a,normalized:f,t:n,pools:h,onPatch:w})})]}):i.jsxs("div",{className:"g7le-error-form","data-testid":"g7le-error-form",style:fu,children:[i.jsx("p",{style:gu,children:n("layout_editor.page_settings.error.heading")}),i.jsxs("p",{"data-testid":"g7le-error-degrade",style:JS,children:["ⓘ ",n("layout_editor.error.degrade")]}),i.jsx(Us,{value:e,onChange:t,t:n,codes:b,mode:"badge",sourceOf:v,testIdPrefix:"g7le-error-rows"})]})}function YS({code:e,action:t,recipes:n,normalized:o,t:r,pools:s,onPatch:a}){const[l,d]=u.useState(!1),c=Array.isArray(t)?t[0]:t,p=typeof c?.handler=="string"?c.handler:"",f=o.find(_=>_.id===p)??null,b=c?Yn(c,o):null,g=b?.kind==="preset"?b.values:{},m=p==="sequence"||p==="parallel",h=_=>{if(_===""){a({});return}const w=o.find(k=>k.id===_);w&&a(Sr(w,{}))},v=["","showErrorPage","navigate","openModal","toast","setState","sequence","parallel"],y=m&&c?Array.isArray(c.params?.actions)?c.params.actions:[]:[];return i.jsxs("div",{"data-testid":`g7le-error-action-${e}`,style:ZS,children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[i.jsx("select",{"data-testid":`g7le-error-handler-${e}`,value:p,onChange:_=>h(_.target.value),style:{...QS,flex:1},children:v.map(_=>i.jsx("option",{value:_,children:r(_===""?"layout_editor.error.handler_none":`layout_editor.error.handler_${_}`)},_))}),p!==""?i.jsx("button",{type:"button","data-testid":`g7le-error-code-${e}`,onClick:()=>d(_=>!_),"aria-label":r("layout_editor.action_list.view_code"),title:r("layout_editor.action_list.view_code"),style:l?RS:hu,children:""}):null]}),m?i.jsx("div",{"data-testid":`g7le-error-actions-${e}`,children:i.jsx(Gt,{actions:y,onChange:_=>a({handler:p,params:{actions:_}}),t:r,recipes:n,candidatePools:s,chipContext:"error",testIdPrefix:`g7le-error-seq-${e}`})}):f&&c?i.jsx(Ns,{raw:c,recipe:f,values:g,t:r,pools:s,onChange:_=>a(_),testIdPrefix:`g7le-error-action-${e}-edit`}):null,l&&c?i.jsx("pre",{"data-testid":`g7le-error-code-view-${e}`,style:eC,children:JSON.stringify(t,null,2)}):null]})}const fu={display:"flex",flexDirection:"column",gap:12,minWidth:0},gu={margin:0,fontSize:13,fontWeight:700,color:"#0f172a"},XS={margin:0,fontSize:11,color:"#94a3b8"},JS={margin:0,fontSize:12,color:"#b45309",background:"#fef3c7",padding:"8px 10px",borderRadius:6},ZS={display:"flex",flexDirection:"column",gap:6,minWidth:0},QS={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6},hu={flex:"0 0 auto",width:26,height:26,display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:11,border:"1px solid #e2e8f0",borderRadius:6,background:"#fff",color:"#64748b",cursor:"pointer",fontFamily:"ui-monospace, monospace"},RS={...hu,background:"#0f172a",borderColor:"#0f172a",color:"#e2e8f0"},eC={margin:"4px 0 0",padding:8,background:"#0f172a",color:"#e2e8f0",borderRadius:6,fontSize:12,overflow:"auto",fontFamily:"ui-monospace, monospace"};function Vr(e){const t=e.trim(),n=/^\{\{([\s\S]*)\}\}$/.exec(t);return n?n[1].trim():t}function tC(e){let t=e;for(;t.length>=2&&t[0]==="("&&t[t.length-1]===")";){let n=0,o=!0;for(let r=0;r!!o&&typeof o.value=="string"&&typeof o.expr=="string").map(o=>({value:o.value,label:typeof o.label=="string"?o.label:void 0,params:Array.isArray(o.params)?o.params:[],expr:Vr(o.expr),aliases:yu(o.aliases)}));const n=[];for(const[o,r]of Object.entries(e)){if(o==="comment"||o==="operators"||!r||typeof r!="object")continue;const s=r;typeof s.expr=="string"&&n.push({value:o,label:typeof s.label=="string"?s.label:void 0,params:Array.isArray(s.params)?s.params:[],expr:Vr(s.expr),aliases:yu(s.aliases)})}return n}function yu(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(typeof n!="string")continue;const o=Vr(n);o.trim().length>0&&t.push(o)}return t}function oC(e){const t=e.params.length*1e3;return Ur(e.expr).replace(/\{\w+\}/g,"").length-t}function rC(e){return e.map((t,n)=>({op:t,idx:n,score:oC(t)})).sort((t,n)=>n.score-t.score||t.idx-n.idx).map(t=>t.op)}function iC(e,t){return e.replace(/\{(\w+)\}/g,(n,o)=>{const r=t[o];return r===void 0?n:r})}function sC(e,t){const n=t.find(o=>o.value===e.operator);return n?iC(n.expr,e.params??{}):null}function bu(e,t,n){const o=e.map(a=>sC(a,n)).filter(a=>typeof a=="string"&&a.trim().length>0);if(o.length===0)return"";if(o.length===1)return`{{ ${o[0]} }}`;const r=t==="or"?" || ":" && ";return`{{ ${o.map(a=>`(${a})`).join(r)} }}`}function mu(e,t){const n=Ur(e);for(const o of rC(t)){if(o.params.length===0){for(const r of[o.expr,...o.aliases])if(Ur(r)===n)return{operator:o.value,params:{}};continue}for(const r of[o.expr,...o.aliases]){const s=aC(o,r,n);if(s)return s}}return null}function aC(e,t,n){const o=t.trim(),r=[];let s="",a=0;for(;a=|<=|>|<|\?|:|\(|\)|!/.test(b))return null;return{operator:e.value,params:c}}function lC(e){const t=new Set,n=/(['"])\{(\w+)\}\1/g;let o;for(;(o=n.exec(e))!==null;)t.add(o[2]);return t}function dC(e,t){if(typeof e!="string"||e.trim()==="")return null;const n=Vr(e),o=mu(n,t);if(o)return{clauses:[o],combinator:"and"};const r=n.includes(") || (")?"or":(n.includes(") && ("),"and"),s=r==="or"?") || (":") && (";if(!n.startsWith("(")||!n.endsWith(")")||!n.includes(s))return null;const l=n.slice(1,-1).split(s),d=[];for(const c of l){const p=mu(c.trim(),t);if(!p)return null;d.push(p)}return{clauses:d,combinator:r}}const vu=Lt(),Mn=vu.responsiveManager,Do=vu.BREAKPOINT_PRESETS;function _u(e){const t=e.groupPrefixes;return{group:typeof e.group=="string"?e.group:void 0,apply:e.apply&&typeof e.apply=="object"?e.apply:void 0,options:Array.isArray(e.options)?e.options:void 0,scale:Array.isArray(e.scale)?e.scale:void 0,groupPrefixes:Array.isArray(t)?t.filter(n=>typeof n=="string"&&n.length>0):void 0,groupTokens:Array.isArray(e.groupTokens)?e.groupTokens.filter(n=>typeof n=="string"&&n.length>0):void 0}}function xu(e){const t={...e??{}},n=t.style&&typeof t.style=="object"&&!Array.isArray(t.style)?{...t.style}:{};return t.style=n,{props:t,style:n}}function qr(e){return typeof e!="string"?[]:e.split(/\s+/).filter(t=>t.length>0)}function wu(e,t=!1){const n=new Set,o=[],r=s=>{if(s){for(const a of s.tokens??[])n.add(a);s.tokenTemplate&&s.tokenTemplate.includes("{value}")&&o.push(s.tokenTemplate.split("{value}")[0]??"")}};r(e.apply);for(const s of e.options??[])r(s.apply);for(const s of e.groupPrefixes??[])o.push(s);for(const s of e.groupTokens??[])n.add(s);return s=>{if(t){if(!Yt(s))return!1;const a=Xs(s);return n.has(a)?!0:o.some(l=>l.length>0&&a.startsWith(l))}return Yt(s)?!1:n.has(s)?!0:o.some(a=>a.length>0&&s.startsWith(a))}}function cC(e,t,n,o,r=!1){const s=wu(t,r),a=qr(e.className).filter(p=>!s(p)),l=[];if(Array.isArray(n.tokens))l.push(...n.tokens);else if(n.tokenTemplate&&n.tokenTemplate.includes("{value}")&&o!=null){const p=String(o).split(/\s+/).filter(f=>f.length>0);for(const f of p)l.push(n.tokenTemplate.replace("{value}",f))}const d=r?l.map(Iu):l,c=[...a,...d];c.length===0?delete e.className:e.className=c.join(" ")}const qs={url:"backgroundImage",size:"backgroundSize",repeat:"backgroundRepeat",position:"backgroundPosition"};function uC(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.keys(qs).some(t=>t in e)}function pC(e){return/^url\(/i.test(e.trim())?e:`url(${e})`}function ku(e){const t=/^url\(\s*(['"]?)(.*?)\1\s*\)$/i.exec(e.trim());return t?t[2]:e}function fC(e){return e.includes("backgroundImage")}function Gs(e,t){if(e!=null){if(typeof e=="object"){const n=e[t];return typeof n=="string"||typeof n=="number"?n:void 0}return e}}function gC(e){const t=e.backgroundImage,n=Gs(e.backgroundSize,"size"),o=Gs(e.backgroundRepeat,"repeat"),r=Gs(e.backgroundPosition,"position");let s;if(typeof t=="string"?s=ku(t):t&&typeof t=="object"?s=t.url:s=void 0,s===void 0&&n===void 0&&o===void 0&&r===void 0)return;const a={};return s!==void 0&&(a.url=typeof s=="string"?ku(s):s),n!==void 0&&(a.size=n),o!==void 0&&(a.repeat=o),r!==void 0&&(a.position=r),a}function hC(e,t,n){const o=(r,s)=>{s==null||s===""?delete e[r]:e[r]=s};if(Array.isArray(t.props)){if(!t.values&&uC(n)){for(const r of t.props){const s=Object.keys(qs).find(d=>qs[d]===r);let a=s?n[s]:void 0;a!==null&&typeof a=="object"&&(a=void 0);const l=r==="backgroundImage"&&typeof a=="string"&&a!==""?pC(a):a;o(r,l)}return}for(const r of t.props){const s=t.values&&r in t.values?t.values[r]:n;o(r,s)}return}typeof t.prop=="string"&&o(t.prop,t.value!==void 0?t.value:n)}function yC(e,t,n){if(typeof t.varName!="string")return;const o=t.value!==void 0?t.value:n;o==null||o===""?delete e[t.varName]:e[t.varName]=o}function bC(e,t,n){if(typeof t.propKey!="string")return;const o=t.value!==void 0?t.value:n;o==null||o===""?delete e[t.propKey]:e[t.propKey]=o}function fn(e,t,n,o=Wt){const r=_u(t),s=o.colorScheme==="dark";let a,l=!1;if(r.options){const b=r.options.find(g=>g.value===n);l=b!==void 0,a=b?.apply??r.apply}else a=r.apply;const d=n==null||n===""||l&&a===void 0,p=(d?r.apply:a)?.type==="classToken"||(r.options?.some(b=>b.apply?.type==="classToken")??!1);if(s&&!p)return e;const f=o.breakpoint!=="base"&&p?(()=>{const b=e.props??{};return typeof b.className=="string"?b.className:void 0})():void 0;return Eu(e,o,(b,g)=>{if(f!==void 0&&typeof b.className!="string"&&(b.className=f),d){const m=wu(r,s),h=qr(b.className).filter(v=>!m(v));if(h.length===0?delete b.className:b.className=h.join(" "),!s&&r.apply){const v=r.apply;if(v.type==="styleProp")for(const y of v.props??(v.prop?[v.prop]:[]))delete g[y];else v.type==="cssVar"&&v.varName?delete g[v.varName]:v.type==="propValue"&&v.propKey&&delete b[v.propKey]}}else if(a)switch(a.type){case"classToken":cC(b,r,a,n,s);break;case"styleProp":hC(g,a,n);break;case"cssVar":yC(g,a,n);break;case"propValue":bC(b,a,n);break}})}function Gr(e,t){const n=qr(e);return t?n.filter(Yt).map(Xs):n.filter(o=>!Yt(o))}function mC(e,t,n,o){const r=new Set(t.filter(l=>typeof l=="string"&&l.length>0)),s=l=>o?Yt(l)?r.has(Xs(l)):!1:Yt(l)?!1:r.has(l),a=qr(e).filter(l=>!s(l));return n&&n.length>0&&a.push(o?Iu(n):n),a.join(" ").trim()}function Su(e,t,n,o){if(e.options&&e.options.some(s=>s.apply)){const s=Gr(t.className,o),a=[];for(const l of e.options)l.apply&&_C(l.apply,s,n,t)&&a.push(l.value);if(a.length>0)return{value:a[0],matched:!0,conflict:a.length>1?!0:void 0};if(!e.apply)return{value:void 0,matched:!1}}const r=e.apply;if(!r)return{value:void 0,matched:!1};switch(r.type){case"styleProp":{if(!r.values&&Array.isArray(r.props)&&fC(r.props)){const l=gC(n);return l===void 0?{value:void 0,matched:!1}:{value:l,matched:!0}}const s=r.prop??r.props?.[0];if(!s)return{value:void 0,matched:!1};const a=n[s];return a===void 0?{value:void 0,matched:!1}:{value:a,matched:!0}}case"cssVar":{if(!r.varName)return{value:void 0,matched:!1};const s=n[r.varName];return s===void 0?{value:void 0,matched:!1}:{value:s,matched:!0}}case"propValue":{if(!r.propKey)return{value:void 0,matched:!1};const s=t[r.propKey];return s===void 0?{value:void 0,matched:!1}:{value:s,matched:!0}}case"classToken":{const s=Gr(t.className,o);if(r.tokenTemplate&&r.tokenTemplate.includes("{value}")){const[a,l]=r.tokenTemplate.split("{value}");if((a??"")===""&&(l??"")===""&&e.groupPrefixes?.length){const d=s.filter(c=>e.groupPrefixes.some(p=>c.startsWith(p)));return d.length>0?{value:d.join(" "),matched:!0}:{value:void 0,matched:!1}}for(const d of s)if(d.startsWith(a)&&d.endsWith(l??""))return{value:d.slice(a.length,l?d.length-l.length:void 0),matched:!0}}return Array.isArray(r.tokens)&&r.tokens.every(a=>s.includes(a))?{value:!0,matched:!0}:{value:void 0,matched:!1}}default:return{value:void 0,matched:!1}}}function Cu(e){return e.style&&typeof e.style=="object"&&!Array.isArray(e.style)?e.style:{}}function zo(e,t,n=Wt){const o=_u(t),r=n.colorScheme==="dark";if(r&&!Ys(o.apply)&&!o.options?.some(m=>Ys(m.apply)))return{value:void 0,matched:!1,darkReadonly:!0};const s=CC(e,n),a=Cu(s),l=Su(o,s,a,r);if(n.breakpoint==="base")return l;const d=l.matched?l.value:void 0,c=e.props??{},p=Cu(c),f=Su(o,c,p,r),b=l.matched&&l.value!==void 0,g=b&&!vC(l.value,f.value);return{value:b?l.value:f.value,matched:g?l.matched:f.matched,conflict:g?l.conflict:f.conflict,scopedValue:g?l.value:void 0,baseFallback:g?void 0:f.value,scopedRawValue:d}}function vC(e,t){if(e===t)return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}function _C(e,t,n,o){switch(e.type){case"classToken":return Array.isArray(e.tokens)&&e.tokens.length>0?e.tokens.every(r=>t.includes(r)):!1;case"styleProp":{const r=e.prop??e.props?.[0];if(!r)return!1;const s=e.value;return s!==void 0?n[r]===s:n[r]!==void 0}case"cssVar":return e.varName?n[e.varName]!==void 0:!1;case"propValue":return e.propKey?e.value!==void 0?o[e.propKey]===e.value:o[e.propKey]!==void 0:!1;default:return!1}}const Wt={colorScheme:"base",breakpoint:"base"},No="dark:";function xC(e){return e==="base"?!0:Mn.parseRange(e)!==null}function $u(e){return e in Do}function Yr(e,t,n){if(e==="custom"){if(typeof n=="number"){const o=t.responsive;if(o&&typeof o=="object"){const r=Mn.getMatchingKey(o,n);if(r)return r}}return"base"}return e}function wC(e){return!!e&&typeof e=="object"&&Array.isArray(e.children)}function kC(e,t,n){let o,r,s;if(e!=="custom"&&e in Do){o=e;const l=Do[e];r=l.min,s=l.max}else if(e!=="custom"){const l=Mn.parseRange(e);if(l)o=e,r=l.min,s=l.max;else{const d=typeof n=="number"?n:Mn.getWidth();o=`${d}-${d}`,r=d,s=d}}else{const l=typeof n=="number"?n:Mn.getWidth();r=l,s=l,o=`${l}-${l}`}const a=t.responsive;if(a&&typeof a=="object"){let l=null,d=1/0;for(const c of Object.keys(a)){if(!wC(a[c]))continue;const p=Mn.parseRange(c);if(p){if(p.min===r&&p.max===s)return{mode:"merge",key:c};if(p.min<=r&&p.max>=s){const f=p.max-p.min;ft.length>0):[]}function IC(e,t){if(t.colorScheme==="dark")return Eu(e,t,l=>{const d=Xr(l.className).filter(c=>!Yt(c));d.length===0?delete l.className:l.className=d.join(" ")});if(t.breakpoint==="base")return e;const o=t.breakpoint;if(!e.responsive?.[o])return e;const r={...e.responsive},s={...r[o]};delete s.props,Object.keys(s).length===0?delete r[o]:r[o]=s;const a={...e};return Object.keys(r).length===0?delete a.responsive:a.responsive=r,a}function Js(e,t){if(t.colorScheme==="dark"){const c=t.breakpoint==="base"?e.props:e.responsive?.[t.breakpoint]?.props;return Xr(c?.className).some(Yt)}if(t.breakpoint==="base")return!1;const o=e.responsive?.[t.breakpoint];if(!o)return!1;const r=o.props;if(Object.keys(o).filter(c=>c!=="props").length>0)return!0;if(!r)return!1;if(Object.keys(r).filter(c=>c!=="className").length>0)return!0;const l=new Set(Xr(e.props?.className).filter(c=>!Yt(c))),d=Xr(r.className).filter(c=>!Yt(c));return d.length!==l.size?!0:d.some(c=>!l.has(c))}function Au(e,t,n=""){return typeof e!="string"?n:e.startsWith("$t:")?t(e.slice(3)):e}function Tu(e,t,n){if(n.breakpoint!=="base")return EC(e,n,t.trim());const o={...e};if(o.props&&typeof o.props=="object"&&"if"in o.props){const r={...o.props};delete r.if,o.props=r}return t.trim()===""?delete o.if:o.if=t,o}function Du({node:e,spec:t,t:n,onPatchNode:o,dataSourceCandidates:r,stateKeyCandidates:s,scope:a=Wt}){const l=u.useMemo(()=>nC(t?.conditionRecipes),[t]),d=a.breakpoint!=="base"?$C(e,a):e.if??e.props?.if,c=u.useMemo(()=>dC(d,l),[d,l]),p=c?.clauses??[],f=c?.combinator??"and",b=typeof d=="string"&&d.trim()!==""&&c===null;if(l.length===0)return i.jsx("div",{"data-testid":"g7le-condition-no-recipes",style:AC,children:n("layout_editor.visibility.no_recipes")});const g=(w,k)=>{o(Tu(e,bu(w,k,l),a))},m=(w,k)=>{g(p.map((x,$)=>$===w?k:x),f)},h=w=>{g(p.filter((k,x)=>x!==w),f)},v=w=>{const k=l[0];g([...p,{operator:k.value,params:{}}],w)},y=w=>{if(w==="datasource-picker")return r;if(w==="state-key-picker")return s};if(b)return i.jsxs("div",{className:"g7le-condition-advanced","data-testid":"g7le-condition-advanced",style:{display:"flex",flexDirection:"column",gap:8},children:[i.jsx("div",{style:BC,children:n("layout_editor.visibility.advanced_preserved")}),i.jsx("code",{"data-testid":"g7le-condition-advanced-expr",style:Nu,children:String(d)}),i.jsx("button",{type:"button","data-testid":"g7le-condition-clear-advanced",onClick:()=>o(Tu(e,"",a)),style:WC,children:n("layout_editor.visibility.clear")})]});const _=bu(p,f,l);return i.jsxs("div",{className:"g7le-condition-builder","data-testid":"g7le-condition-builder",style:{display:"flex",flexDirection:"column",gap:10},children:[i.jsx("div",{style:TC,children:n("layout_editor.visibility.show_when")}),p.map((w,k)=>{const x=l.find($=>$.value===w.operator)??l[0];return i.jsxs("div",{className:"g7le-condition-clause","data-testid":`g7le-condition-clause-${k}`,style:DC,children:[i.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[k>0&&i.jsx("span",{"data-testid":`g7le-condition-combinator-${k}`,style:NC,children:n(f==="or"?"layout_editor.visibility.or":"layout_editor.visibility.and")}),i.jsx("select",{"data-testid":`g7le-condition-select-${k}`,value:w.operator,onChange:$=>m(k,{operator:$.target.value,params:{}}),style:zC,children:l.map($=>i.jsx("option",{value:$.value,children:Au($.label,n,$.value)},$.value))}),i.jsx("button",{type:"button","data-testid":`g7le-condition-remove-${k}`,"aria-label":n("layout_editor.visibility.remove"),onClick:()=>h(k),style:MC,children:"✕"})]}),x.params.map($=>{const S=Tn($.widget);return i.jsxs("div",{className:"g7le-condition-param","data-testid":`g7le-condition-param-${k}-${$.key}`,style:LC,children:[i.jsx("span",{style:PC,children:Au($.label,n,$.key)}),i.jsx("div",{style:{flex:1},children:S?i.jsx(S,{control:{...$},value:w.params[$.key],onChange:C=>m(k,{operator:w.operator,params:{...w.params,[$.key]:C===void 0?"":String(C)}}),t:n,candidates:y($.widget)}):i.jsx("span",{style:{fontSize:11,color:"#94a3b8"},children:n("layout_editor.property_modal.unsupported_widget")})})]},$.key)})]},k)}),i.jsxs("div",{style:{display:"flex",gap:6},children:[i.jsxs("button",{type:"button","data-testid":"g7le-condition-add-and",onClick:()=>v("and"),style:zu,children:["+ ",n("layout_editor.visibility.and")]}),i.jsxs("button",{type:"button","data-testid":"g7le-condition-add-or",onClick:()=>v("or"),style:zu,children:["+ ",n("layout_editor.visibility.or")]})]}),_!==""&&i.jsxs("div",{"data-testid":"g7le-condition-preview",style:OC,children:[i.jsx("span",{style:{fontSize:11,color:"#64748b"},children:n("layout_editor.visibility.preview")}),i.jsx("code",{style:Nu,children:_})]})]})}const AC={fontSize:12,color:"#94a3b8",padding:"16px 0",textAlign:"center"},TC={fontSize:12,fontWeight:600,color:"#0f172a"},DC={border:"1px solid #e2e8f0",borderRadius:8,padding:10,display:"flex",flexDirection:"column",gap:8,background:"#f8fafc"},zC={flex:1,padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff"},NC={fontSize:11,fontWeight:700,color:"#2563eb",background:"#dbeafe",padding:"2px 8px",borderRadius:999},MC={border:"none",background:"transparent",color:"#94a3b8",cursor:"pointer",fontSize:12},zu={padding:"5px 12px",fontSize:12,border:"1px dashed #94a3b8",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},LC={display:"flex",alignItems:"center",gap:8},PC={fontSize:11,color:"#64748b",minWidth:64},OC={display:"flex",flexDirection:"column",gap:4,padding:10,background:"#f1f5f9",borderRadius:6},Nu={fontSize:11,color:"#0f172a",fontFamily:"monospace",wordBreak:"break-all"},BC={fontSize:11,color:"#92400e",background:"#fef3c7",padding:"6px 8px",borderRadius:6},WC={padding:"5px 12px",fontSize:12,border:"1px solid #fecaca",borderRadius:6,background:"#fff",color:"#dc2626",cursor:"pointer",alignSelf:"flex-start"};function jC(e){return typeof e=="string"?e:e===void 0?"":JSON.stringify(e)}function HC(e){const t=e.trim();if(t==="")return"";if(/^-?\d+(\.\d+)?$/.test(t)||t==="true"||t==="false"||t==="null")try{return JSON.parse(t)}catch{return e}return e}function Mu(e){return!e||typeof e!="object"||Array.isArray(e)?[]:Object.entries(e).map(([t,n])=>({key:t,value:jC(n)}))}function Zs(e){const t={};for(const n of e){const o=n.key.trim();o!==""&&(t[o]=HC(n.value))}return t}function Lu(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.values(e).some(t=>t!==null&&typeof t=="object")}function FC(e){const t={};return typeof e.if=="string"&&e.if.trim().length>0&&(t.if=e.if),t}function KC(e,t){const n={...t},o=e.if;return typeof o=="string"&&o.trim().length>0?n.if=o:delete n.if,n}const VC=["api","static","route_params","query_params","websocket"],UC=["GET","POST","PUT","PATCH","DELETE"],qC=["none","optional","required"],GC=["progressive","blocking","background"],YC=["application/json","multipart/form-data"],XC=["public","private","presence"];function JC(e){if(!e||typeof e!="object")return{own:[],inherited:[]};const t=e.__editor,n=t&&typeof t=="object"&&!Array.isArray(t)?t.original:void 0,o=n&&typeof n=="object"&&!Array.isArray(n)?n.data_sources:e.data_sources,r=Array.isArray(o)?o.filter(c=>c&&typeof c=="object"):[],s=new Set(r.map(c=>typeof c.id=="string"?c.id:"").filter(Boolean)),a=e.data_sources,d=(Array.isArray(a)?a.filter(c=>c&&typeof c=="object"):[]).filter(c=>typeof c.id=="string"&&!s.has(c.id));return{own:r,inherited:d}}function ZC(e,t){const n=(o,r="")=>typeof o=="string"?o:r;return{index:t,id:n(e.id),type:n(e.type,"api"),label_key:n(e.label_key),endpoint:n(e.endpoint),method:n(e.method,"GET"),auth_mode:n(e.auth_mode,"none"),loading_strategy:n(e.loading_strategy,"progressive"),auto_fetch:e.auto_fetch!==!1,paramRows:Mu(e.params),paramsRaw:Lu(e.params),paramsRawValue:e.params&&typeof e.params=="object"&&!Array.isArray(e.params)?e.params:{},paramsRawValid:!0,fallbackEnabled:e.fallback!==void 0,fallbackValue:e.fallback,if:n(e.if),contentType:n(e.contentType),refetchOnMount:e.refetchOnMount===!0,onSuccess:Array.isArray(e.onSuccess)?e.onSuccess.filter(o=>!!o&&typeof o=="object"):[],onError:Array.isArray(e.onError)?e.onError.filter(o=>!!o&&typeof o=="object"):[],errorHandling:e.errorHandling&&typeof e.errorHandling=="object"&&!Array.isArray(e.errorHandling)?e.errorHandling:{},channel:n(e.channel),event:n(e.event),channel_type:n(e.channel_type,"public"),target_source:n(e.target_source),onReceive:Array.isArray(e.onReceive)?e.onReceive.filter(o=>!!o&&typeof o=="object"):[]}}function QC(){return{index:-1,id:"",type:"api",label_key:"",endpoint:"",method:"GET",auth_mode:"none",loading_strategy:"progressive",auto_fetch:!0,paramRows:[],paramsRaw:!1,paramsRawValue:{},paramsRawValid:!0,fallbackEnabled:!1,fallbackValue:void 0,if:"",contentType:"",refetchOnMount:!1,onSuccess:[],onError:[],errorHandling:{},channel:"",event:"",channel_type:"public",target_source:"",onReceive:[]}}function RC(e,t,n,o){const r=e.id.trim();if(!r)return{error:o("layout_editor.data_sources.error.id_required")};if(!/^[A-Za-z_][\w]*$/.test(r))return{error:o("layout_editor.data_sources.error.id_invalid")};if(n.has(r))return{error:o("layout_editor.data_sources.error.id_duplicate",{id:r})};const s=t?{...t}:{};if(s.id=r,s.type=e.type,e.label_key.trim()?s.label_key=e.label_key.trim():delete s.label_key,e.type==="api"||e.type==="websocket"?(e.endpoint.trim()?s.endpoint=e.endpoint.trim():delete s.endpoint,s.method=e.method,s.auth_mode=e.auth_mode,s.loading_strategy=e.loading_strategy):(delete s.endpoint,delete s.method),s.auto_fetch=e.auto_fetch,e.paramsRaw){if(!e.paramsRawValid)return{error:o("layout_editor.data_sources.error.params_json")};const a=e.paramsRawValue;a&&typeof a=="object"&&Object.keys(a).length>0?s.params=a:delete s.params}else{const a=Zs(e.paramRows);Object.keys(a).length>0?s.params=a:delete s.params}return e.fallbackEnabled?s.fallback=e.fallbackValue===void 0?{}:e.fallbackValue:delete s.fallback,e.if.trim()?s.if=e.if.trim():delete s.if,e.type==="api"&&e.contentType?s.contentType=e.contentType:delete s.contentType,e.refetchOnMount?s.refetchOnMount=!0:delete s.refetchOnMount,e.onSuccess.length>0?s.onSuccess=e.onSuccess:delete s.onSuccess,e.onError.length>0?s.onError=e.onError:delete s.onError,Object.keys(e.errorHandling).length>0?s.errorHandling=e.errorHandling:delete s.errorHandling,e.type==="websocket"?(e.channel?s.channel=e.channel:delete s.channel,e.event?s.event=e.event:delete s.event,s.channel_type=e.channel_type,e.target_source?s.target_source=e.target_source:delete s.target_source,e.onReceive.length>0?s.onReceive=e.onReceive:delete s.onReceive):(delete s.channel,delete s.event,delete s.channel_type,delete s.target_source,delete s.onReceive),{entry:s}}const jt={width:"100%",padding:"6px 8px",fontSize:13,border:"1px solid #cbd5e1",borderRadius:6,outline:"none",boxSizing:"border-box",fontFamily:"inherit",color:"#0f172a",background:"#ffffff"},ct={display:"block",fontSize:12,fontWeight:600,color:"#475569",marginBottom:4},ut={marginBottom:12},rn={padding:"6px 12px",fontSize:13,fontWeight:500,borderRadius:6,border:"1px solid #cbd5e1",background:"#ffffff",color:"#0f172a",cursor:"pointer"},Pu={...rn,background:"#2563eb",borderColor:"#2563eb",color:"#ffffff",fontWeight:600},Mo={marginTop:12,padding:10,border:"1px solid #e2e8f0",borderRadius:8,background:"#f8fafc"},Lo={fontSize:12,fontWeight:700,color:"#475569",marginBottom:8},e$={margin:"0 0 6px",fontSize:11,color:"#94a3b8"},Ou={marginTop:8},Bu={alignSelf:"flex-start",padding:"2px 0",fontSize:11,border:"none",background:"none",color:"#64748b",cursor:"pointer"},Wu={margin:0,padding:8,background:"#0f172a",color:"#e2e8f0",borderRadius:6,fontSize:11,lineHeight:1.5,overflow:"auto",fontFamily:"ui-monospace, monospace"};function t$({code:e,action:t,recipes:n,pools:o,t:r,onPatch:s}){const[a,l]=u.useState(!1),d=u.useMemo(()=>ko(n),[n]),c=Array.isArray(t)?t[0]:t,p=typeof c?.handler=="string"?c.handler:"",f=d.find(_=>_.id===p)??null,b=c?Yn(c,d):null,g=b?.kind==="preset"?b.values:{},m=p==="sequence"||p==="parallel",h=["","showErrorPage","navigate","openModal","toast","setState","sequence","parallel"],v=_=>{if(_===""){s({});return}const w=d.find(k=>k.id===_);s(w?Sr(w,{}):{handler:_})},y=m&&c?Array.isArray(c.params?.actions)?c.params.actions:[]:[];return i.jsxs("div",{"data-testid":`g7le-ds-errorhandling-${e}`,style:{display:"flex",flexDirection:"column",gap:6},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[i.jsx("select",{"data-testid":`g7le-ds-eh-handler-${e}`,style:{...jt,flex:1},value:p,onChange:_=>v(_.target.value),children:h.map(_=>i.jsx("option",{value:_,children:r(_===""?"layout_editor.error.handler_none":`layout_editor.error.handler_${_}`)},_))}),p!==""?i.jsx("button",{type:"button","data-testid":`g7le-ds-eh-code-${e}`,onClick:()=>l(_=>!_),"aria-label":r("layout_editor.action_list.view_code"),title:r("layout_editor.action_list.view_code"),style:a?n$:ju,children:""}):null]}),m?i.jsx("div",{"data-testid":`g7le-ds-eh-actions-${e}`,children:i.jsx(Gt,{actions:y,onChange:_=>s({handler:p,params:{actions:_}}),t:r,recipes:n,candidatePools:o,chipContext:"error",testIdPrefix:`g7le-ds-eh-seq-${e}`})}):f&&c?i.jsx(Ns,{raw:c,recipe:f,values:g,t:r,pools:o,onChange:_=>s(_),testIdPrefix:`g7le-ds-eh-action-${e}-edit`}):null,a&&c?i.jsx("pre",{"data-testid":`g7le-ds-eh-code-view-${e}`,style:o$,children:JSON.stringify(t,null,2)}):null]})}const ju={flex:"0 0 auto",width:26,height:26,display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:11,border:"1px solid #e2e8f0",borderRadius:6,background:"#fff",color:"#64748b",cursor:"pointer",fontFamily:"ui-monospace, monospace"},n$={...ju,background:"#0f172a",borderColor:"#0f172a",color:"#e2e8f0"},o$={margin:"4px 0 0",padding:8,background:"#0f172a",color:"#e2e8f0",borderRadius:6,fontSize:12,overflow:"auto",fontFamily:"ui-monospace, monospace"};function r$({raw:e,onChange:t,t:n,resolveLabel:o,onClose:r,actionRecipes:s,errorRecipes:a,conditionSpec:l,bindingCandidates:d,pageCandidates:c,dataSourceCandidates:p,stateKeyCandidates:f}){const b=o??n,g=u.useMemo(()=>JC(e),[e]),m=g.inherited,[h,v]=u.useState(g.own),[y,_]=u.useState(null),[w,k]=u.useState(null),[x,$]=u.useState(!1),[S,C]=u.useState(!1),[T,E]=u.useState(()=>new Set),A=u.useCallback(I=>{E(L=>{const F=new Set(L);return F.has(I)?F.delete(I):F.add(I),F})},[]),N=u.useMemo(()=>({pageCandidates:c,dataSourceCandidates:p,stateKeyCandidates:f,bindingCandidates:d}),[c,p,f,d]),D=u.useCallback(I=>{v(I),t([...m,...I],I)},[m,t]),B=u.useCallback(()=>{k(null),_(QC())},[]),M=u.useCallback((I,L)=>{k(null),_(ZC(I,L))},[]),O=u.useCallback(I=>{const L=h.filter((F,Y)=>Y!==I);D(L)},[h,D]),z=u.useCallback(()=>{_(null),k(null)},[]),H=u.useCallback(()=>{if(!y)return;const I=new Set;h.forEach((K,X)=>{X!==y.index&&typeof K.id=="string"&&I.add(K.id)}),m.forEach(K=>{typeof K.id=="string"&&I.add(K.id)});const L=y.index>=0?h[y.index]??null:null,F=RC(y,L,I,n);if("error"in F){k(F.error);return}const Y=y.index>=0?h.map((K,X)=>X===y.index?F.entry:K):[...h,F.entry];D(Y),_(null),k(null)},[y,h,m,D,n]),P=y?.type==="api"||y?.type==="websocket";return i.jsxs("div",{className:"g7le-data-sources","data-testid":"g7le-data-sources-panel",style:{flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column",fontSize:13,color:"#0f172a",boxSizing:"border-box"},children:[i.jsxs("div",{className:"g7le-data-sources__header",style:{flex:"0 0 auto",padding:"16px 16px 12px",borderBottom:"1px solid #e2e8f0"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[i.jsx("h2",{style:{margin:0,fontSize:16,fontWeight:700},children:n("layout_editor.data_sources.title")}),i.jsx("button",{type:"button","data-testid":"g7le-data-sources-close",onClick:r,"aria-label":n("layout_editor.data_sources.close"),style:{...rn,padding:"4px 10px"},children:"✕"})]}),i.jsx("p",{style:{margin:0,fontSize:12,color:"#64748b",lineHeight:1.5},children:n("layout_editor.data_sources.description")})]}),i.jsxs("div",{className:"g7le-data-sources__body",style:{flex:"1 1 auto",minHeight:0,overflowY:"auto",padding:16},children:[y&&i.jsxs("div",{className:"g7le-data-sources__form","data-testid":"g7le-data-sources-form",children:[i.jsx("div",{style:{fontSize:13,fontWeight:700,marginBottom:12},children:y.index>=0?n("layout_editor.data_sources.form.edit_title"):n("layout_editor.data_sources.form.add_title")}),i.jsxs("div",{style:ut,children:[i.jsx("label",{style:ct,htmlFor:"g7le-ds-id",children:n("layout_editor.data_sources.field.id")}),i.jsx("input",{id:"g7le-ds-id","data-testid":"g7le-data-sources-field-id",style:jt,value:y.id,onChange:I=>_({...y,id:I.target.value}),placeholder:"products"})]}),i.jsxs("div",{style:ut,children:[i.jsx("label",{style:ct,htmlFor:"g7le-ds-label",children:n("layout_editor.data_sources.field.label_key")}),i.jsx(_t,{value:y.label_key,onChange:I=>_({...y,label_key:I??""}),t:n,placeholder:n("layout_editor.data_sources.field.label_key_placeholder"),testidPrefix:"g7le-data-sources-field-label",candidates:d,enableExpressionTree:!0,expressionTreeCollapsible:!0}),i.jsx("div",{style:{fontSize:11,color:"#94a3b8",marginTop:4},children:n("layout_editor.data_sources.field.label_key_hint")})]}),i.jsxs("div",{style:ut,children:[i.jsx("label",{style:ct,htmlFor:"g7le-ds-type",children:n("layout_editor.data_sources.field.type")}),i.jsx("select",{id:"g7le-ds-type","data-testid":"g7le-data-sources-field-type",style:jt,value:y.type,onChange:I=>_({...y,type:I.target.value}),children:VC.map(I=>i.jsx("option",{value:I,children:n(`layout_editor.data_sources.ds_type.${I}`)},I))})]}),P&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{style:ut,children:[i.jsx("label",{style:ct,children:n("layout_editor.data_sources.field.endpoint")}),i.jsx("div",{"data-testid":"g7le-data-sources-field-endpoint",children:i.jsx(Ke,{value:y.endpoint,onChange:I=>_({...y,endpoint:I}),t:n,candidates:d,placeholder:"/api/shop/products/{{route.id}}",testidPrefix:"g7le-ds-endpoint"})})]}),i.jsxs("div",{style:{display:"flex",gap:12},children:[i.jsxs("div",{style:{...ut,flex:1},children:[i.jsx("label",{style:ct,htmlFor:"g7le-ds-method",children:n("layout_editor.data_sources.field.method")}),i.jsx("select",{id:"g7le-ds-method","data-testid":"g7le-data-sources-field-method",style:jt,value:y.method,onChange:I=>_({...y,method:I.target.value}),children:UC.map(I=>i.jsx("option",{value:I,children:I},I))})]}),i.jsxs("div",{style:{...ut,flex:1},children:[i.jsx("label",{style:ct,htmlFor:"g7le-ds-auth",children:n("layout_editor.data_sources.field.auth_mode")}),i.jsx("select",{id:"g7le-ds-auth","data-testid":"g7le-data-sources-field-auth",style:jt,value:y.auth_mode,onChange:I=>_({...y,auth_mode:I.target.value}),children:qC.map(I=>i.jsx("option",{value:I,children:n(`layout_editor.data_sources.auth_mode.${I}`)},I))})]})]}),i.jsxs("div",{style:ut,children:[i.jsx("label",{style:ct,htmlFor:"g7le-ds-loading",children:n("layout_editor.data_sources.field.loading_strategy")}),i.jsx("select",{id:"g7le-ds-loading","data-testid":"g7le-data-sources-field-loading",style:jt,value:y.loading_strategy,onChange:I=>_({...y,loading_strategy:I.target.value}),children:GC.map(I=>i.jsx("option",{value:I,children:n(`layout_editor.data_sources.loading_strategy.${I}`)},I))})]}),y.type==="api"&&i.jsxs("div",{style:ut,children:[i.jsx("label",{style:ct,htmlFor:"g7le-ds-contenttype",children:n("layout_editor.data_sources.field.content_type")}),i.jsx("select",{id:"g7le-ds-contenttype","data-testid":"g7le-ds-contenttype",style:jt,value:y.contentType||"application/json",onChange:I=>_({...y,contentType:I.target.value}),children:YC.map(I=>i.jsx("option",{value:I,children:I},I))})]})]}),i.jsx("div",{style:ut,children:i.jsxs("label",{style:{...ct,display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[i.jsx("input",{type:"checkbox","data-testid":"g7le-data-sources-field-autofetch",checked:y.auto_fetch,onChange:I=>_({...y,auto_fetch:I.target.checked})}),n("layout_editor.data_sources.field.auto_fetch")]})}),i.jsx("div",{style:ut,children:i.jsxs("label",{style:{...ct,display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[i.jsx("input",{type:"checkbox","data-testid":"g7le-ds-refetch",checked:y.refetchOnMount,onChange:I=>_({...y,refetchOnMount:I.target.checked})}),n("layout_editor.data_sources.field.refetch_on_mount")]})}),i.jsxs("div",{style:ut,children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[i.jsx("label",{style:ct,htmlFor:"g7le-ds-params",children:n("layout_editor.data_sources.field.params")}),i.jsx("button",{type:"button","data-testid":"g7le-ds-params-mode-toggle",onClick:()=>{if(y.paramsRaw){if(y.paramsRawValid){const I=y.paramsRawValue;I&&typeof I=="object"&&!Array.isArray(I)&&!Lu(I)&&_({...y,paramsRaw:!1,paramRows:Mu(I)})}}else{const I=Zs(y.paramRows);_({...y,paramsRaw:!0,paramsRawValue:I,paramsRawValid:!0})}},style:{...rn,padding:"2px 8px",fontSize:11},children:y.paramsRaw?n("layout_editor.data_sources.field.params_mode_block"):n("layout_editor.data_sources.field.params_mode_code")})]}),y.paramsRaw?i.jsx(Hs,{id:"g7le-ds-params",value:y.paramsRawValue,shape:"object",emptyValue:{},minHeight:64,testidPrefix:"g7le-data-sources-field-params",placeholder:`{ +}`,shapeErrorKey:"layout_editor.json_block.must_be_object",validate:x=>{const $=Object.keys(x??{}).filter(C=>!Ls(C));return $.length?a("layout_editor.json_block.invalid_keys",{keys:$.join(", ")}):null}}):i.jsxs(i.Fragment,{children:[v.length===0?i.jsx("p",{"data-testid":`g7le-initstate-${e}-empty`,style:iC,children:a("layout_editor.initstate.no_values")}):v.map(x=>{const C=ik(y,r,x)==="inherited",S=e==="isolated"&&l[x];return i.jsx(WS,{scope:e,itemKey:x,value:o[x],inherited:C,isOrphan:!!S,onChangeValue:D=>_(x,D),onRemove:()=>w(x),t:a},x)}),i.jsxs("div",{style:RS,children:[i.jsx("input",{type:"text","data-testid":`g7le-initstate-${e}-add-name`,value:d,placeholder:a("layout_editor.initstate.value_name"),onChange:x=>{c(x.target.value),b&&g(null)},onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),k())},"aria-invalid":b?!0:void 0,style:{...eC,...b?tC:null}}),i.jsx("select",{"data-testid":`g7le-initstate-${e}-add-kind`,value:p,onChange:x=>f(x.target.value),"aria-label":a("layout_editor.initstate.value_kind"),style:oC,children:OS.map(x=>i.jsx("option",{value:x.kind,children:a(x.labelKey)},x.kind))}),i.jsxs("button",{type:"button","data-testid":`g7le-initstate-${e}-add`,onClick:k,style:rC,children:["+ ",a("layout_editor.initstate.add_value")]})]}),b?i.jsx("p",{"data-testid":`g7le-initstate-${e}-add-error`,style:nC,children:b}):null]})]})}function WS({scope:e,itemKey:t,value:n,inherited:o,isOrphan:r,onChangeValue:s,onRemove:a,t:l}){const[d,c]=u.useState(!1);let p;try{p=JSON.stringify(n,null,2)??String(n)}catch{p=String(n)}return i.jsxs("div",{"data-testid":`g7le-initstate-${e}-item-${t}`,style:YS,children:[i.jsxs("div",{style:XS,children:[o?i.jsx("span",{"data-testid":`g7le-initstate-inherited-${t}`,style:JS,children:"🔗"}):null,i.jsx("code",{style:ZS,children:t}),i.jsx("span",{style:{flex:1}}),i.jsx("button",{type:"button","data-testid":`g7le-initstate-code-${t}`,onClick:()=>c(f=>!f),style:Ys,"aria-label":l("layout_editor.value_tree.show_source"),title:l("layout_editor.value_tree.show_source"),children:""}),o?i.jsx("button",{type:"button","data-testid":`g7le-initstate-revert-${t}`,onClick:a,style:Ys,children:l("layout_editor.initstate.revert")}):i.jsx("button",{type:"button","data-testid":`g7le-initstate-remove-${t}`,onClick:a,style:Ys,"aria-label":l("layout_editor.init_actions.remove"),children:"✕"})]}),d?i.jsx("pre",{"data-testid":`g7le-initstate-code-block-${t}`,style:aC,children:p}):null,i.jsx(Mn,{value:n,onChange:s,t:l,path:t,scope:e}),r?i.jsxs("p",{"data-testid":`g7le-initstate-isolated-orphan-${t}`,style:QS,children:["⚠ ",l("layout_editor.initstate.isolated_orphan")]}):null]})}const jS={display:"flex",flexDirection:"column",gap:14,minWidth:0},HS={margin:0,fontSize:13,fontWeight:700,color:"#0f172a"},FS={margin:0,fontSize:11,color:"#1d4ed8",background:"#eff6ff",padding:"6px 8px",borderRadius:6},KS={display:"flex",flexDirection:"column",gap:8,padding:10,border:"1px solid #e2e8f0",borderRadius:10,minWidth:0},VS={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},US={fontSize:12,fontWeight:700,color:"#475569"},qS={margin:0,fontSize:11,color:"#94a3b8"},GS={padding:"2px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},YS={display:"flex",flexDirection:"column",gap:4,padding:"6px 8px",border:"1px solid #f1f5f9",borderRadius:6,minWidth:0},XS={display:"flex",alignItems:"center",gap:6},JS={fontSize:12},ZS={fontSize:12,color:"#0f172a",fontFamily:"monospace"},Ys={border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",fontSize:11,padding:"2px 6px"},QS={margin:0,fontSize:11,color:"#b45309",background:"#fef3c7",padding:"4px 6px",borderRadius:6},RS={display:"flex",gap:6,alignItems:"center"},eC={padding:"4px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6},tC={border:"1px solid #dc2626"},nC={margin:0,fontSize:11,color:"#dc2626"},oC={padding:"4px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#0f172a"},rC={padding:"2px 10px",fontSize:11,border:"1px dashed #94a3b8",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},iC={margin:0,fontSize:12,color:"#94a3b8"},sC={margin:0,fontSize:11,color:"#94a3b8"},aC={margin:"2px 0",padding:"6px 8px",fontSize:11,fontFamily:"monospace",color:"#0f172a",background:"#f1f5f9",border:"1px solid #e2e8f0",borderRadius:6,whiteSpace:"pre-wrap",wordBreak:"break-all",overflowX:"auto"},lC={self:"layout_editor.error_rows.source_self",inherited:"layout_editor.error_rows.source_inherited",template:"layout_editor.error_rows.source_template",none:"layout_editor.error_rows.source_none"};function Xs({value:e,onChange:t,t:n,codes:o,mode:r="local",sourceOf:s,renderActionList:a,testIdPrefix:l="g7le-error-rows"}){const d=o??Object.keys(e),c=u.useCallback((f,b)=>{t({...e,[f]:b})},[e,t]),p=u.useCallback(f=>{const b={...e};delete b[f],t(b)},[e,t]);return i.jsx("div",{className:l,"data-testid":l,children:d.map(f=>{const b=e[f],g=b!==void 0,m=r==="badge"&&s?s(f):null;return i.jsxs("div",{"data-testid":`${l}-row-${f}`,style:{border:"1px solid #e2e8f0",borderRadius:8,padding:"8px 10px",marginBottom:6},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i.jsx("strong",{"data-testid":`${l}-code-${f}`,style:{fontSize:13},children:f==="default"?n("layout_editor.error_rows.default"):f}),m?i.jsxs("span",{"data-testid":`${l}-source-${f}`,style:{fontSize:11,padding:"2px 6px",borderRadius:4,background:"#f1f5f9",color:"#475569"},children:["〔",n(lC[m]),"〕"]}):null,g?i.jsx("button",{type:"button","data-testid":`${l}-clear-${f}`,onClick:()=>p(f),style:{marginLeft:"auto",fontSize:12},children:n("layout_editor.error_rows.clear")}):i.jsx("span",{style:{marginLeft:"auto",fontSize:12,color:"#94a3b8"},children:n("layout_editor.error_rows.no_action")})]}),m==="inherited"||m==="template"?i.jsxs("div",{"data-testid":`${l}-override-${f}`,style:{marginTop:6,display:"flex",alignItems:"flex-start",gap:8},children:[i.jsxs("p",{style:{margin:0,flex:1,fontSize:12,color:"#64748b"},children:["ⓘ ",n(m==="inherited"?"layout_editor.error_rows.override_inherited":"layout_editor.error_rows.override_template")]}),g?i.jsx("button",{type:"button","data-testid":`${l}-revert-${f}`,onClick:()=>p(f),style:{fontSize:12,padding:"2px 8px",border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",whiteSpace:"nowrap"},children:n("layout_editor.error_rows.revert")}):i.jsx("button",{type:"button","data-testid":`${l}-override-here-${f}`,onClick:()=>c(f,{}),style:{fontSize:12,padding:"2px 8px",border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",whiteSpace:"nowrap"},children:n("layout_editor.error_rows.override_here")})]}):null,f==="default"?i.jsxs("p",{"data-testid":`${l}-default-warn-${f}`,style:{margin:"6px 0 0",fontSize:12,color:"#b45309"},children:["⚠ ",n("layout_editor.error_rows.default_warning")]}):null,i.jsx("div",{style:{marginTop:6},children:a?a(f,b,h=>c(f,h)):i.jsx("pre",{"data-testid":`${l}-json-${f}`,style:{margin:0,fontSize:12,color:"#475569"},children:g?JSON.stringify(b):""})})]},f)})})}function dC(e){return[...e.filter(n=>n!=="maintenance"),"default"]}function cC({value:e,onChange:t,t:n,errorConfigCodes:o=[],ownCodes:r=[],templateCodes:s=[],recipes:a,pageCandidates:l,modalCandidates:d,dataSourceCandidates:c,stateKeyCandidates:p}){const f=u.useMemo(()=>$o(a),[a]),b=u.useMemo(()=>dC(o),[o]),g=f.length>0,m=u.useMemo(()=>Yl("error",n),[n]),h=u.useMemo(()=>({pageCandidates:l,dataSourceCandidates:c,stateKeyCandidates:p,modalCandidates:d,bindingCandidates:m}),[l,c,p,d,m]),v=u.useCallback(y=>r.includes(y)?"self":y in e?"inherited":s.includes(y)?"template":"none",[r,e,s]);return g?i.jsxs("div",{className:"g7le-error-form","data-testid":"g7le-error-form",style:bu,children:[i.jsx("p",{style:mu,children:n("layout_editor.page_settings.error.heading")}),i.jsxs("p",{style:pC,children:["ⓘ ",n("layout_editor.error.intro")]}),i.jsx(Xs,{value:e,onChange:t,t:n,codes:b,mode:"badge",sourceOf:v,testIdPrefix:"g7le-error-rows",renderActionList:(y,_,w)=>i.jsx(uC,{code:y,action:_,recipes:a,normalized:f,t:n,pools:h,onPatch:w})})]}):i.jsxs("div",{className:"g7le-error-form","data-testid":"g7le-error-form",style:bu,children:[i.jsx("p",{style:mu,children:n("layout_editor.page_settings.error.heading")}),i.jsxs("p",{"data-testid":"g7le-error-degrade",style:fC,children:["ⓘ ",n("layout_editor.error.degrade")]}),i.jsx(Xs,{value:e,onChange:t,t:n,codes:b,mode:"badge",sourceOf:v,testIdPrefix:"g7le-error-rows"})]})}function uC({code:e,action:t,recipes:n,normalized:o,t:r,pools:s,onPatch:a}){const[l,d]=u.useState(!1),c=Array.isArray(t)?t[0]:t,p=typeof c?.handler=="string"?c.handler:"",f=o.find(_=>_.id===p)??null,b=c?Jn(c,o):null,g=b?.kind==="preset"?b.values:{},m=p==="sequence"||p==="parallel",h=_=>{if(_===""){a({});return}const w=o.find(k=>k.id===_);w&&a(Er(w,{}))},v=["","showErrorPage","navigate","openModal","toast","setState","sequence","parallel"],y=m&&c?Array.isArray(c.params?.actions)?c.params.actions:[]:[];return i.jsxs("div",{"data-testid":`g7le-error-action-${e}`,style:gC,children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[i.jsx("select",{"data-testid":`g7le-error-handler-${e}`,value:p,onChange:_=>h(_.target.value),style:{...hC,flex:1},children:v.map(_=>i.jsx("option",{value:_,children:r(_===""?"layout_editor.error.handler_none":`layout_editor.error.handler_${_}`)},_))}),p!==""?i.jsx("button",{type:"button","data-testid":`g7le-error-code-${e}`,onClick:()=>d(_=>!_),"aria-label":r("layout_editor.action_list.view_code"),title:r("layout_editor.action_list.view_code"),style:l?yC:vu,children:""}):null]}),m?i.jsx("div",{"data-testid":`g7le-error-actions-${e}`,children:i.jsx(Yt,{actions:y,onChange:_=>a({handler:p,params:{actions:_}}),t:r,recipes:n,candidatePools:s,chipContext:"error",testIdPrefix:`g7le-error-seq-${e}`})}):f&&c?i.jsx(Os,{raw:c,recipe:f,values:g,t:r,pools:s,onChange:_=>a(_),testIdPrefix:`g7le-error-action-${e}-edit`}):null,l&&c?i.jsx("pre",{"data-testid":`g7le-error-code-view-${e}`,style:bC,children:JSON.stringify(t,null,2)}):null]})}const bu={display:"flex",flexDirection:"column",gap:12,minWidth:0},mu={margin:0,fontSize:13,fontWeight:700,color:"#0f172a"},pC={margin:0,fontSize:11,color:"#94a3b8"},fC={margin:0,fontSize:12,color:"#b45309",background:"#fef3c7",padding:"8px 10px",borderRadius:6},gC={display:"flex",flexDirection:"column",gap:6,minWidth:0},hC={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6},vu={flex:"0 0 auto",width:26,height:26,display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:11,border:"1px solid #e2e8f0",borderRadius:6,background:"#fff",color:"#64748b",cursor:"pointer",fontFamily:"ui-monospace, monospace"},yC={...vu,background:"#0f172a",borderColor:"#0f172a",color:"#e2e8f0"},bC={margin:"4px 0 0",padding:8,background:"#0f172a",color:"#e2e8f0",borderRadius:6,fontSize:12,overflow:"auto",fontFamily:"ui-monospace, monospace"};function Gr(e){const t=e.trim(),n=/^\{\{([\s\S]*)\}\}$/.exec(t);return n?n[1].trim():t}function mC(e){let t=e;for(;t.length>=2&&t[0]==="("&&t[t.length-1]===")";){let n=0,o=!0;for(let r=0;r!!o&&typeof o.value=="string"&&typeof o.expr=="string").map(o=>({value:o.value,label:typeof o.label=="string"?o.label:void 0,params:Array.isArray(o.params)?o.params:[],expr:Gr(o.expr),aliases:_u(o.aliases)}));const n=[];for(const[o,r]of Object.entries(e)){if(o==="comment"||o==="operators"||!r||typeof r!="object")continue;const s=r;typeof s.expr=="string"&&n.push({value:o,label:typeof s.label=="string"?s.label:void 0,params:Array.isArray(s.params)?s.params:[],expr:Gr(s.expr),aliases:_u(s.aliases)})}return n}function _u(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(typeof n!="string")continue;const o=Gr(n);o.trim().length>0&&t.push(o)}return t}function _C(e){const t=e.params.length*1e3;return Yr(e.expr).replace(/\{\w+\}/g,"").length-t}function xC(e){return e.map((t,n)=>({op:t,idx:n,score:_C(t)})).sort((t,n)=>n.score-t.score||t.idx-n.idx).map(t=>t.op)}function wC(e,t){return e.replace(/\{(\w+)\}/g,(n,o)=>{const r=t[o];return r===void 0?n:r})}function kC(e,t){const n=t.find(o=>o.value===e.operator);return n?wC(n.expr,e.params??{}):null}function xu(e,t,n){const o=e.map(a=>kC(a,n)).filter(a=>typeof a=="string"&&a.trim().length>0);if(o.length===0)return"";if(o.length===1)return`{{ ${o[0]} }}`;const r=t==="or"?" || ":" && ";return`{{ ${o.map(a=>`(${a})`).join(r)} }}`}function wu(e,t){const n=Yr(e);for(const o of xC(t)){if(o.params.length===0){for(const r of[o.expr,...o.aliases])if(Yr(r)===n)return{operator:o.value,params:{}};continue}for(const r of[o.expr,...o.aliases]){const s=SC(o,r,n);if(s)return s}}return null}function SC(e,t,n){const o=t.trim(),r=[];let s="",a=0;for(;a=|<=|>|<|\?|:|\(|\)|!/.test(b))return null;return{operator:e.value,params:c}}function CC(e){const t=new Set,n=/(['"])\{(\w+)\}\1/g;let o;for(;(o=n.exec(e))!==null;)t.add(o[2]);return t}function $C(e,t){if(typeof e!="string"||e.trim()==="")return null;const n=Gr(e),o=wu(n,t);if(o)return{clauses:[o],combinator:"and"};const r=n.includes(") || (")?"or":(n.includes(") && ("),"and"),s=r==="or"?") || (":") && (";if(!n.startsWith("(")||!n.endsWith(")")||!n.includes(s))return null;const l=n.slice(1,-1).split(s),d=[];for(const c of l){const p=wu(c.trim(),t);if(!p)return null;d.push(p)}return{clauses:d,combinator:r}}const ku=Lt(),Pn=ku.responsiveManager,Mo=ku.BREAKPOINT_PRESETS;function Su(e){const t=e.groupPrefixes;return{group:typeof e.group=="string"?e.group:void 0,widget:typeof e.widget=="string"?e.widget:void 0,apply:e.apply&&typeof e.apply=="object"?e.apply:void 0,options:Array.isArray(e.options)?e.options:void 0,scale:Array.isArray(e.scale)?e.scale:void 0,groupPrefixes:Array.isArray(t)?t.filter(n=>typeof n=="string"&&n.length>0):void 0,groupTokens:Array.isArray(e.groupTokens)?e.groupTokens.filter(n=>typeof n=="string"&&n.length>0):void 0}}function Cu(e){const t={...e??{}},n=t.style&&typeof t.style=="object"&&!Array.isArray(t.style)?{...t.style}:{};return t.style=n,{props:t,style:n}}function Xr(e){return typeof e!="string"?[]:e.split(/\s+/).filter(t=>t.length>0)}function $u(e,t=!1){const n=new Set,o=[],r=s=>{if(s){for(const a of s.tokens??[])n.add(a);s.tokenTemplate&&s.tokenTemplate.includes("{value}")&&o.push(s.tokenTemplate.split("{value}")[0]??"")}};r(e.apply);for(const s of e.options??[])r(s.apply);for(const s of e.groupPrefixes??[])o.push(s);for(const s of e.groupTokens??[])n.add(s);return s=>{if(t){if(!Xt(s))return!1;const a=ea(s);return n.has(a)?!0:o.some(l=>l.length>0&&a.startsWith(l))}return Xt(s)?!1:n.has(s)?!0:o.some(a=>a.length>0&&s.startsWith(a))}}function EC(e,t,n,o,r=!1){const s=$u(t,r),a=Xr(e.className).filter(p=>!s(p)),l=[];if(Array.isArray(n.tokens))l.push(...n.tokens);else if(n.tokenTemplate&&n.tokenTemplate.includes("{value}")&&o!=null){const p=String(o).split(/\s+/).filter(f=>f.length>0);for(const f of p)l.push(n.tokenTemplate.replace("{value}",f))}const d=r?l.map(Mu):l,c=[...a,...d];c.length===0?delete e.className:e.className=c.join(" ")}const Js={url:"backgroundImage",size:"backgroundSize",repeat:"backgroundRepeat",position:"backgroundPosition"};function Eu(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.keys(Js).some(t=>t in e)}function Iu(e){return/^url\(/i.test(e.trim())?e:`url(${e})`}function Jr(e){const t=/^url\(\s*(['"]?)(.*?)\1\s*\)$/i.exec(e.trim());return t?t[2]:e}function IC(e){return e.includes("backgroundImage")}function Zs(e,t){if(!Eu(e))return e;const n=e.url;if(typeof n!="string"||n.trim()==="")return"";const o=Jr(n);return t?Iu(o):o}function Qs(e,t){if(e!=null){if(typeof e=="object"){const n=e[t];return typeof n=="string"||typeof n=="number"?n:void 0}return e}}function AC(e){const t=e.backgroundImage,n=Qs(e.backgroundSize,"size"),o=Qs(e.backgroundRepeat,"repeat"),r=Qs(e.backgroundPosition,"position");let s;if(typeof t=="string"?s=Jr(t):t&&typeof t=="object"?s=t.url:s=void 0,s===void 0&&n===void 0&&o===void 0&&r===void 0)return;const a={};return s!==void 0&&(a.url=typeof s=="string"?Jr(s):s),n!==void 0&&(a.size=n),o!==void 0&&(a.repeat=o),r!==void 0&&(a.position=r),a}const Au=new Set(["type","name","props","children","text","if","iteration","responsive","__source","__injectedProps"]);function TC(e,t,n){const o=t.nodeKey;if(typeof o!="string"||o===""||Au.has(o))return e;const r={...e};return n==null||n===""?delete r[o]:r[o]=n,r}function DC(e,t,n,o=!1){const r=(s,a)=>{a==null||a===""?delete e[s]:e[s]=a};if(Array.isArray(t.props)){if(!t.values&&Eu(n)){for(const s of t.props){const a=Object.keys(Js).find(c=>Js[c]===s);let l=a?n[a]:void 0;l!==null&&typeof l=="object"&&(l=void 0);const d=s==="backgroundImage"&&typeof l=="string"&&l!==""?Iu(l):l;r(s,d)}return}for(const s of t.props){const a=t.values&&s in t.values?t.values[s]:n;r(s,a)}return}if(typeof t.prop=="string"){const s=t.value!==void 0?t.value:n;r(t.prop,o?Zs(s,!0):s)}}function zC(e,t,n,o=!1){if(typeof t.varName!="string")return;const r=t.value!==void 0?t.value:n,s=o?Zs(r,!0):r;s==null||s===""?delete e[t.varName]:e[t.varName]=s}function NC(e,t,n,o=!1){if(typeof t.propKey!="string")return;const r=t.value!==void 0?t.value:n,s=o?Zs(r,!1):r;s==null||s===""?delete e[t.propKey]:e[t.propKey]=s}function yn(e,t,n,o=jt){const r=Su(t),s=o.colorScheme==="dark";let a,l=!1;if(r.options){const b=r.options.find(g=>g.value===n);l=b!==void 0,a=b?.apply??r.apply}else a=r.apply;const d=n==null||n===""||l&&a===void 0,c=d?r.apply:a,p=c?.type==="classToken"||(r.options?.some(b=>b.apply?.type==="classToken")??!1);if(s&&!p)return e;if(c?.type==="nodeKey")return TC(e,c,d?void 0:n);const f=o.breakpoint!=="base"&&p?(()=>{const b=e.props??{};return typeof b.className=="string"?b.className:void 0})():void 0;return Nu(e,o,(b,g)=>{if(f!==void 0&&typeof b.className!="string"&&(b.className=f),d){const m=$u(r,s),h=Xr(b.className).filter(v=>!m(v));if(h.length===0?delete b.className:b.className=h.join(" "),!s&&r.apply){const v=r.apply;if(v.type==="styleProp")for(const y of v.props??(v.prop?[v.prop]:[]))delete g[y];else v.type==="cssVar"&&v.varName?delete g[v.varName]:v.type==="propValue"&&v.propKey&&delete b[v.propKey]}}else if(a){const m=r.widget==="image";switch(a.type){case"classToken":EC(b,r,a,n,s);break;case"styleProp":DC(g,a,n,m);break;case"cssVar":zC(g,a,n,m);break;case"propValue":NC(b,a,n,m);break}}})}function Zr(e,t){const n=Xr(e);return t?n.filter(Xt).map(ea):n.filter(o=>!Xt(o))}function MC(e,t,n,o){const r=new Set(t.filter(l=>typeof l=="string"&&l.length>0)),s=l=>o?Xt(l)?r.has(ea(l)):!1:Xt(l)?!1:r.has(l),a=Xr(e).filter(l=>!s(l));return n&&n.length>0&&a.push(o?Mu(n):n),a.join(" ").trim()}function Tu(e,t,n,o){if(e.options&&e.options.some(s=>s.apply)){const s=Zr(t.className,o),a=[];for(const l of e.options)l.apply&&PC(l.apply,s,n,t)&&a.push(l.value);if(a.length>0)return{value:a[0],matched:!0,conflict:a.length>1?!0:void 0};if(!e.apply)return{value:void 0,matched:!1}}const r=e.apply;if(!r)return{value:void 0,matched:!1};switch(r.type){case"styleProp":{if(!r.values&&Array.isArray(r.props)&&IC(r.props)){const l=AC(n);return l===void 0?{value:void 0,matched:!1}:{value:l,matched:!0}}const s=r.prop??r.props?.[0];if(!s)return{value:void 0,matched:!1};const a=n[s];return a===void 0?{value:void 0,matched:!1}:{value:a,matched:!0}}case"cssVar":{if(!r.varName)return{value:void 0,matched:!1};const s=n[r.varName];return s===void 0?{value:void 0,matched:!1}:{value:s,matched:!0}}case"propValue":{if(!r.propKey)return{value:void 0,matched:!1};const s=t[r.propKey];return s===void 0?{value:void 0,matched:!1}:e.widget==="image"&&typeof s=="string"?{value:{url:Jr(s)},matched:!0}:{value:s,matched:!0}}case"classToken":{const s=Zr(t.className,o);if(r.tokenTemplate&&r.tokenTemplate.includes("{value}")){const[a,l]=r.tokenTemplate.split("{value}");if((a??"")===""&&(l??"")===""&&e.groupPrefixes?.length){const d=s.filter(c=>e.groupPrefixes.some(p=>c.startsWith(p)));return d.length>0?{value:d.join(" "),matched:!0}:{value:void 0,matched:!1}}for(const d of s)if(d.startsWith(a)&&d.endsWith(l??""))return{value:d.slice(a.length,l?d.length-l.length:void 0),matched:!0}}return Array.isArray(r.tokens)&&r.tokens.every(a=>s.includes(a))?{value:!0,matched:!0}:{value:void 0,matched:!1}}default:return{value:void 0,matched:!1}}}function Du(e){return e.style&&typeof e.style=="object"&&!Array.isArray(e.style)?e.style:{}}function Lo(e,t,n=jt){const o=Su(t),r=n.colorScheme==="dark";if(r&&!Rs(o.apply)&&!o.options?.some(m=>Rs(m.apply)))return{value:void 0,matched:!1,darkReadonly:!0};if(o.apply?.type==="nodeKey"){const m=o.apply.nodeKey;if(typeof m!="string"||m===""||Au.has(m))return{value:void 0,matched:!1};const h=e[m];return h===void 0?{value:void 0,matched:!1}:{value:h,matched:!0}}const s=HC(e,n),a=Du(s),l=Tu(o,s,a,r);if(n.breakpoint==="base")return l;const d=l.matched?l.value:void 0,c=e.props??{},p=Du(c),f=Tu(o,c,p,r),b=l.matched&&l.value!==void 0,g=b&&!LC(l.value,f.value);return{value:b?l.value:f.value,matched:g?l.matched:f.matched,conflict:g?l.conflict:f.conflict,scopedValue:g?l.value:void 0,baseFallback:g?void 0:f.value,scopedRawValue:d}}function LC(e,t){if(e===t)return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}function PC(e,t,n,o){switch(e.type){case"classToken":return Array.isArray(e.tokens)&&e.tokens.length>0?e.tokens.every(r=>t.includes(r)):!1;case"styleProp":{const r=e.prop??e.props?.[0];if(!r)return!1;const s=e.value;return s!==void 0?n[r]===s:n[r]!==void 0}case"cssVar":return e.varName?n[e.varName]!==void 0:!1;case"propValue":return e.propKey?e.value!==void 0?o[e.propKey]===e.value:o[e.propKey]!==void 0:!1;default:return!1}}const jt={colorScheme:"base",breakpoint:"base"},Po="dark:";function OC(e){return e==="base"?!0:Pn.parseRange(e)!==null}function zu(e){return e in Mo}function Qr(e,t,n){if(e==="custom"){if(typeof n=="number"){const o=t.responsive;if(o&&typeof o=="object"){const r=Pn.getMatchingKey(o,n);if(r)return r}}return"base"}return e}function BC(e){return!!e&&typeof e=="object"&&Array.isArray(e.children)}function WC(e,t,n){let o,r,s;if(e!=="custom"&&e in Mo){o=e;const l=Mo[e];r=l.min,s=l.max}else if(e!=="custom"){const l=Pn.parseRange(e);if(l)o=e,r=l.min,s=l.max;else{const d=typeof n=="number"?n:Pn.getWidth();o=`${d}-${d}`,r=d,s=d}}else{const l=typeof n=="number"?n:Pn.getWidth();r=l,s=l,o=`${l}-${l}`}const a=t.responsive;if(a&&typeof a=="object"){let l=null,d=1/0;for(const c of Object.keys(a)){if(!BC(a[c]))continue;const p=Pn.parseRange(c);if(p){if(p.min===r&&p.max===s)return{mode:"merge",key:c};if(p.min<=r&&p.max>=s){const f=p.max-p.min;ft.length>0):[]}function VC(e,t){if(t.colorScheme==="dark")return Nu(e,t,l=>{const d=Rr(l.className).filter(c=>!Xt(c));d.length===0?delete l.className:l.className=d.join(" ")});if(t.breakpoint==="base")return e;const o=t.breakpoint;if(!e.responsive?.[o])return e;const r={...e.responsive},s={...r[o]};delete s.props,Object.keys(s).length===0?delete r[o]:r[o]=s;const a={...e};return Object.keys(r).length===0?delete a.responsive:a.responsive=r,a}function ta(e,t){if(t.colorScheme==="dark"){const c=t.breakpoint==="base"?e.props:e.responsive?.[t.breakpoint]?.props;return Rr(c?.className).some(Xt)}if(t.breakpoint==="base")return!1;const o=e.responsive?.[t.breakpoint];if(!o)return!1;const r=o.props;if(Object.keys(o).filter(c=>c!=="props").length>0)return!0;if(!r)return!1;if(Object.keys(r).filter(c=>c!=="className").length>0)return!0;const l=new Set(Rr(e.props?.className).filter(c=>!Xt(c))),d=Rr(r.className).filter(c=>!Xt(c));return d.length!==l.size?!0:d.some(c=>!l.has(c))}function Lu(e,t,n=""){return typeof e!="string"?n:e.startsWith("$t:")?t(e.slice(3)):e}function Pu(e,t,n){if(n.breakpoint!=="base")return KC(e,n,t.trim());const o={...e};if(o.props&&typeof o.props=="object"&&"if"in o.props){const r={...o.props};delete r.if,o.props=r}return t.trim()===""?delete o.if:o.if=t,o}function Ou({node:e,spec:t,t:n,onPatchNode:o,dataSourceCandidates:r,stateKeyCandidates:s,scope:a=jt}){const l=u.useMemo(()=>vC(t?.conditionRecipes),[t]),d=a.breakpoint!=="base"?FC(e,a):e.if??e.props?.if,c=u.useMemo(()=>$C(d,l),[d,l]),p=c?.clauses??[],f=c?.combinator??"and",b=typeof d=="string"&&d.trim()!==""&&c===null;if(l.length===0)return i.jsx("div",{"data-testid":"g7le-condition-no-recipes",style:UC,children:n("layout_editor.visibility.no_recipes")});const g=(w,k)=>{o(Pu(e,xu(w,k,l),a))},m=(w,k)=>{g(p.map((x,$)=>$===w?k:x),f)},h=w=>{g(p.filter((k,x)=>x!==w),f)},v=w=>{const k=l[0];g([...p,{operator:k.value,params:{}}],w)},y=w=>{if(w==="datasource-picker")return r;if(w==="state-key-picker")return s};if(b)return i.jsxs("div",{className:"g7le-condition-advanced","data-testid":"g7le-condition-advanced",style:{display:"flex",flexDirection:"column",gap:8},children:[i.jsx("div",{style:e$,children:n("layout_editor.visibility.advanced_preserved")}),i.jsx("code",{"data-testid":"g7le-condition-advanced-expr",style:Wu,children:String(d)}),i.jsx("button",{type:"button","data-testid":"g7le-condition-clear-advanced",onClick:()=>o(Pu(e,"",a)),style:t$,children:n("layout_editor.visibility.clear")})]});const _=xu(p,f,l);return i.jsxs("div",{className:"g7le-condition-builder","data-testid":"g7le-condition-builder",style:{display:"flex",flexDirection:"column",gap:10},children:[i.jsx("div",{style:qC,children:n("layout_editor.visibility.show_when")}),p.map((w,k)=>{const x=l.find($=>$.value===w.operator)??l[0];return i.jsxs("div",{className:"g7le-condition-clause","data-testid":`g7le-condition-clause-${k}`,style:GC,children:[i.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[k>0&&i.jsx("span",{"data-testid":`g7le-condition-combinator-${k}`,style:XC,children:n(f==="or"?"layout_editor.visibility.or":"layout_editor.visibility.and")}),i.jsx("select",{"data-testid":`g7le-condition-select-${k}`,value:w.operator,onChange:$=>m(k,{operator:$.target.value,params:{}}),style:YC,children:l.map($=>i.jsx("option",{value:$.value,children:Lu($.label,n,$.value)},$.value))}),i.jsx("button",{type:"button","data-testid":`g7le-condition-remove-${k}`,"aria-label":n("layout_editor.visibility.remove"),onClick:()=>h(k),style:JC,children:"✕"})]}),x.params.map($=>{const C=zn($.widget);return i.jsxs("div",{className:"g7le-condition-param","data-testid":`g7le-condition-param-${k}-${$.key}`,style:ZC,children:[i.jsx("span",{style:QC,children:Lu($.label,n,$.key)}),i.jsx("div",{style:{flex:1},children:C?i.jsx(C,{control:{...$},value:w.params[$.key],onChange:S=>m(k,{operator:w.operator,params:{...w.params,[$.key]:S===void 0?"":String(S)}}),t:n,candidates:y($.widget)}):i.jsx("span",{style:{fontSize:11,color:"#94a3b8"},children:n("layout_editor.property_modal.unsupported_widget")})})]},$.key)})]},k)}),i.jsxs("div",{style:{display:"flex",gap:6},children:[i.jsxs("button",{type:"button","data-testid":"g7le-condition-add-and",onClick:()=>v("and"),style:Bu,children:["+ ",n("layout_editor.visibility.and")]}),i.jsxs("button",{type:"button","data-testid":"g7le-condition-add-or",onClick:()=>v("or"),style:Bu,children:["+ ",n("layout_editor.visibility.or")]})]}),_!==""&&i.jsxs("div",{"data-testid":"g7le-condition-preview",style:RC,children:[i.jsx("span",{style:{fontSize:11,color:"#64748b"},children:n("layout_editor.visibility.preview")}),i.jsx("code",{style:Wu,children:_})]})]})}const UC={fontSize:12,color:"#94a3b8",padding:"16px 0",textAlign:"center"},qC={fontSize:12,fontWeight:600,color:"#0f172a"},GC={border:"1px solid #e2e8f0",borderRadius:8,padding:10,display:"flex",flexDirection:"column",gap:8,background:"#f8fafc"},YC={flex:1,padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff"},XC={fontSize:11,fontWeight:700,color:"#2563eb",background:"#dbeafe",padding:"2px 8px",borderRadius:999},JC={border:"none",background:"transparent",color:"#94a3b8",cursor:"pointer",fontSize:12},Bu={padding:"5px 12px",fontSize:12,border:"1px dashed #94a3b8",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},ZC={display:"flex",alignItems:"center",gap:8},QC={fontSize:11,color:"#64748b",minWidth:64},RC={display:"flex",flexDirection:"column",gap:4,padding:10,background:"#f1f5f9",borderRadius:6},Wu={fontSize:11,color:"#0f172a",fontFamily:"monospace",wordBreak:"break-all"},e$={fontSize:11,color:"#92400e",background:"#fef3c7",padding:"6px 8px",borderRadius:6},t$={padding:"5px 12px",fontSize:12,border:"1px solid #fecaca",borderRadius:6,background:"#fff",color:"#dc2626",cursor:"pointer",alignSelf:"flex-start"};function n$(e){return typeof e=="string"?e:e===void 0?"":JSON.stringify(e)}function o$(e){const t=e.trim();if(t==="")return"";if(/^-?\d+(\.\d+)?$/.test(t)||t==="true"||t==="false"||t==="null")try{return JSON.parse(t)}catch{return e}return e}function ju(e){return!e||typeof e!="object"||Array.isArray(e)?[]:Object.entries(e).map(([t,n])=>({key:t,value:n$(n)}))}function na(e){const t={};for(const n of e){const o=n.key.trim();o!==""&&(t[o]=o$(n.value))}return t}function Hu(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.values(e).some(t=>t!==null&&typeof t=="object")}function r$(e){const t={};return typeof e.if=="string"&&e.if.trim().length>0&&(t.if=e.if),t}function i$(e,t){const n={...t},o=e.if;return typeof o=="string"&&o.trim().length>0?n.if=o:delete n.if,n}const s$=["api","static","route_params","query_params","websocket"],a$=["GET","POST","PUT","PATCH","DELETE"],l$=["none","optional","required"],d$=["progressive","blocking","background"],c$=["application/json","multipart/form-data"],u$=["public","private","presence"];function p$(e){if(!e||typeof e!="object")return{own:[],inherited:[]};const t=e.__editor,n=t&&typeof t=="object"&&!Array.isArray(t)?t.original:void 0,o=n&&typeof n=="object"&&!Array.isArray(n)?n.data_sources:e.data_sources,r=Array.isArray(o)?o.filter(c=>c&&typeof c=="object"):[],s=new Set(r.map(c=>typeof c.id=="string"?c.id:"").filter(Boolean)),a=e.data_sources,d=(Array.isArray(a)?a.filter(c=>c&&typeof c=="object"):[]).filter(c=>typeof c.id=="string"&&!s.has(c.id));return{own:r,inherited:d}}function f$(e,t){const n=(o,r="")=>typeof o=="string"?o:r;return{index:t,id:n(e.id),type:n(e.type,"api"),label_key:n(e.label_key),endpoint:n(e.endpoint),method:n(e.method,"GET"),auth_mode:n(e.auth_mode,"none"),loading_strategy:n(e.loading_strategy,"progressive"),auto_fetch:e.auto_fetch!==!1,paramRows:ju(e.params),paramsRaw:Hu(e.params),paramsRawValue:e.params&&typeof e.params=="object"&&!Array.isArray(e.params)?e.params:{},paramsRawValid:!0,fallbackEnabled:e.fallback!==void 0,fallbackValue:e.fallback,if:n(e.if),contentType:n(e.contentType),refetchOnMount:e.refetchOnMount===!0,onSuccess:Array.isArray(e.onSuccess)?e.onSuccess.filter(o=>!!o&&typeof o=="object"):[],onError:Array.isArray(e.onError)?e.onError.filter(o=>!!o&&typeof o=="object"):[],errorHandling:e.errorHandling&&typeof e.errorHandling=="object"&&!Array.isArray(e.errorHandling)?e.errorHandling:{},channel:n(e.channel),event:n(e.event),channel_type:n(e.channel_type,"public"),target_source:n(e.target_source),onReceive:Array.isArray(e.onReceive)?e.onReceive.filter(o=>!!o&&typeof o=="object"):[]}}function g$(){return{index:-1,id:"",type:"api",label_key:"",endpoint:"",method:"GET",auth_mode:"none",loading_strategy:"progressive",auto_fetch:!0,paramRows:[],paramsRaw:!1,paramsRawValue:{},paramsRawValid:!0,fallbackEnabled:!1,fallbackValue:void 0,if:"",contentType:"",refetchOnMount:!1,onSuccess:[],onError:[],errorHandling:{},channel:"",event:"",channel_type:"public",target_source:"",onReceive:[]}}function h$(e,t,n,o){const r=e.id.trim();if(!r)return{error:o("layout_editor.data_sources.error.id_required")};if(!/^[A-Za-z_][\w]*$/.test(r))return{error:o("layout_editor.data_sources.error.id_invalid")};if(n.has(r))return{error:o("layout_editor.data_sources.error.id_duplicate",{id:r})};const s=t?{...t}:{};if(s.id=r,s.type=e.type,e.label_key.trim()?s.label_key=e.label_key.trim():delete s.label_key,e.type==="api"||e.type==="websocket"?(e.endpoint.trim()?s.endpoint=e.endpoint.trim():delete s.endpoint,s.method=e.method,s.auth_mode=e.auth_mode,s.loading_strategy=e.loading_strategy):(delete s.endpoint,delete s.method),s.auto_fetch=e.auto_fetch,e.paramsRaw){if(!e.paramsRawValid)return{error:o("layout_editor.data_sources.error.params_json")};const a=e.paramsRawValue;a&&typeof a=="object"&&Object.keys(a).length>0?s.params=a:delete s.params}else{const a=na(e.paramRows);Object.keys(a).length>0?s.params=a:delete s.params}return e.fallbackEnabled?s.fallback=e.fallbackValue===void 0?{}:e.fallbackValue:delete s.fallback,e.if.trim()?s.if=e.if.trim():delete s.if,e.type==="api"&&e.contentType?s.contentType=e.contentType:delete s.contentType,e.refetchOnMount?s.refetchOnMount=!0:delete s.refetchOnMount,e.onSuccess.length>0?s.onSuccess=e.onSuccess:delete s.onSuccess,e.onError.length>0?s.onError=e.onError:delete s.onError,Object.keys(e.errorHandling).length>0?s.errorHandling=e.errorHandling:delete s.errorHandling,e.type==="websocket"?(e.channel?s.channel=e.channel:delete s.channel,e.event?s.event=e.event:delete s.event,s.channel_type=e.channel_type,e.target_source?s.target_source=e.target_source:delete s.target_source,e.onReceive.length>0?s.onReceive=e.onReceive:delete s.onReceive):(delete s.channel,delete s.event,delete s.channel_type,delete s.target_source,delete s.onReceive),{entry:s}}const Ht={width:"100%",padding:"6px 8px",fontSize:13,border:"1px solid #cbd5e1",borderRadius:6,outline:"none",boxSizing:"border-box",fontFamily:"inherit",color:"#0f172a",background:"#ffffff"},ct={display:"block",fontSize:12,fontWeight:600,color:"#475569",marginBottom:4},ut={marginBottom:12},an={padding:"6px 12px",fontSize:13,fontWeight:500,borderRadius:6,border:"1px solid #cbd5e1",background:"#ffffff",color:"#0f172a",cursor:"pointer"},Fu={...an,background:"#2563eb",borderColor:"#2563eb",color:"#ffffff",fontWeight:600},Oo={marginTop:12,padding:10,border:"1px solid #e2e8f0",borderRadius:8,background:"#f8fafc"},Bo={fontSize:12,fontWeight:700,color:"#475569",marginBottom:8},y$={margin:"0 0 6px",fontSize:11,color:"#94a3b8"},Ku={marginTop:8},Vu={alignSelf:"flex-start",padding:"2px 0",fontSize:11,border:"none",background:"none",color:"#64748b",cursor:"pointer"},Uu={margin:0,padding:8,background:"#0f172a",color:"#e2e8f0",borderRadius:6,fontSize:11,lineHeight:1.5,overflow:"auto",fontFamily:"ui-monospace, monospace"};function b$({code:e,action:t,recipes:n,pools:o,t:r,onPatch:s}){const[a,l]=u.useState(!1),d=u.useMemo(()=>$o(n),[n]),c=Array.isArray(t)?t[0]:t,p=typeof c?.handler=="string"?c.handler:"",f=d.find(_=>_.id===p)??null,b=c?Jn(c,d):null,g=b?.kind==="preset"?b.values:{},m=p==="sequence"||p==="parallel",h=["","showErrorPage","navigate","openModal","toast","setState","sequence","parallel"],v=_=>{if(_===""){s({});return}const w=d.find(k=>k.id===_);s(w?Er(w,{}):{handler:_})},y=m&&c?Array.isArray(c.params?.actions)?c.params.actions:[]:[];return i.jsxs("div",{"data-testid":`g7le-ds-errorhandling-${e}`,style:{display:"flex",flexDirection:"column",gap:6},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[i.jsx("select",{"data-testid":`g7le-ds-eh-handler-${e}`,style:{...Ht,flex:1},value:p,onChange:_=>v(_.target.value),children:h.map(_=>i.jsx("option",{value:_,children:r(_===""?"layout_editor.error.handler_none":`layout_editor.error.handler_${_}`)},_))}),p!==""?i.jsx("button",{type:"button","data-testid":`g7le-ds-eh-code-${e}`,onClick:()=>l(_=>!_),"aria-label":r("layout_editor.action_list.view_code"),title:r("layout_editor.action_list.view_code"),style:a?m$:qu,children:""}):null]}),m?i.jsx("div",{"data-testid":`g7le-ds-eh-actions-${e}`,children:i.jsx(Yt,{actions:y,onChange:_=>s({handler:p,params:{actions:_}}),t:r,recipes:n,candidatePools:o,chipContext:"error",testIdPrefix:`g7le-ds-eh-seq-${e}`})}):f&&c?i.jsx(Os,{raw:c,recipe:f,values:g,t:r,pools:o,onChange:_=>s(_),testIdPrefix:`g7le-ds-eh-action-${e}-edit`}):null,a&&c?i.jsx("pre",{"data-testid":`g7le-ds-eh-code-view-${e}`,style:v$,children:JSON.stringify(t,null,2)}):null]})}const qu={flex:"0 0 auto",width:26,height:26,display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:11,border:"1px solid #e2e8f0",borderRadius:6,background:"#fff",color:"#64748b",cursor:"pointer",fontFamily:"ui-monospace, monospace"},m$={...qu,background:"#0f172a",borderColor:"#0f172a",color:"#e2e8f0"},v$={margin:"4px 0 0",padding:8,background:"#0f172a",color:"#e2e8f0",borderRadius:6,fontSize:12,overflow:"auto",fontFamily:"ui-monospace, monospace"};function _$({raw:e,onChange:t,t:n,resolveLabel:o,onClose:r,actionRecipes:s,errorRecipes:a,conditionSpec:l,bindingCandidates:d,pageCandidates:c,dataSourceCandidates:p,stateKeyCandidates:f}){const b=o??n,g=u.useMemo(()=>p$(e),[e]),m=g.inherited,[h,v]=u.useState(g.own),[y,_]=u.useState(null),[w,k]=u.useState(null),[x,$]=u.useState(!1),[C,S]=u.useState(!1),[D,E]=u.useState(()=>new Set),I=u.useCallback(A=>{E(L=>{const F=new Set(L);return F.has(A)?F.delete(A):F.add(A),F})},[]),N=u.useMemo(()=>({pageCandidates:c,dataSourceCandidates:p,stateKeyCandidates:f,bindingCandidates:d}),[c,p,f,d]),T=u.useCallback(A=>{v(A),t([...m,...A],A)},[m,t]),B=u.useCallback(()=>{k(null),_(g$())},[]),M=u.useCallback((A,L)=>{k(null),_(f$(A,L))},[]),O=u.useCallback(A=>{const L=h.filter((F,Y)=>Y!==A);T(L)},[h,T]),z=u.useCallback(()=>{_(null),k(null)},[]),H=u.useCallback(()=>{if(!y)return;const A=new Set;h.forEach((V,X)=>{X!==y.index&&typeof V.id=="string"&&A.add(V.id)}),m.forEach(V=>{typeof V.id=="string"&&A.add(V.id)});const L=y.index>=0?h[y.index]??null:null,F=h$(y,L,A,n);if("error"in F){k(F.error);return}const Y=y.index>=0?h.map((V,X)=>X===y.index?F.entry:V):[...h,F.entry];T(Y),_(null),k(null)},[y,h,m,T,n]),P=y?.type==="api"||y?.type==="websocket";return i.jsxs("div",{className:"g7le-data-sources","data-testid":"g7le-data-sources-panel",style:{flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column",fontSize:13,color:"#0f172a",boxSizing:"border-box"},children:[i.jsxs("div",{className:"g7le-data-sources__header",style:{flex:"0 0 auto",padding:"16px 16px 12px",borderBottom:"1px solid #e2e8f0"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[i.jsx("h2",{style:{margin:0,fontSize:16,fontWeight:700},children:n("layout_editor.data_sources.title")}),i.jsx("button",{type:"button","data-testid":"g7le-data-sources-close",onClick:r,"aria-label":n("layout_editor.data_sources.close"),style:{...an,padding:"4px 10px"},children:"✕"})]}),i.jsx("p",{style:{margin:0,fontSize:12,color:"#64748b",lineHeight:1.5},children:n("layout_editor.data_sources.description")})]}),i.jsxs("div",{className:"g7le-data-sources__body",style:{flex:"1 1 auto",minHeight:0,overflowY:"auto",padding:16},children:[y&&i.jsxs("div",{className:"g7le-data-sources__form","data-testid":"g7le-data-sources-form",children:[i.jsx("div",{style:{fontSize:13,fontWeight:700,marginBottom:12},children:y.index>=0?n("layout_editor.data_sources.form.edit_title"):n("layout_editor.data_sources.form.add_title")}),i.jsxs("div",{style:ut,children:[i.jsx("label",{style:ct,htmlFor:"g7le-ds-id",children:n("layout_editor.data_sources.field.id")}),i.jsx("input",{id:"g7le-ds-id","data-testid":"g7le-data-sources-field-id",style:Ht,value:y.id,onChange:A=>_({...y,id:A.target.value}),placeholder:"products"})]}),i.jsxs("div",{style:ut,children:[i.jsx("label",{style:ct,htmlFor:"g7le-ds-label",children:n("layout_editor.data_sources.field.label_key")}),i.jsx(_t,{value:y.label_key,onChange:A=>_({...y,label_key:A??""}),t:n,placeholder:n("layout_editor.data_sources.field.label_key_placeholder"),testidPrefix:"g7le-data-sources-field-label",candidates:d,enableExpressionTree:!0,expressionTreeCollapsible:!0}),i.jsx("div",{style:{fontSize:11,color:"#94a3b8",marginTop:4},children:n("layout_editor.data_sources.field.label_key_hint")})]}),i.jsxs("div",{style:ut,children:[i.jsx("label",{style:ct,htmlFor:"g7le-ds-type",children:n("layout_editor.data_sources.field.type")}),i.jsx("select",{id:"g7le-ds-type","data-testid":"g7le-data-sources-field-type",style:Ht,value:y.type,onChange:A=>_({...y,type:A.target.value}),children:s$.map(A=>i.jsx("option",{value:A,children:n(`layout_editor.data_sources.ds_type.${A}`)},A))})]}),P&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{style:ut,children:[i.jsx("label",{style:ct,children:n("layout_editor.data_sources.field.endpoint")}),i.jsx("div",{"data-testid":"g7le-data-sources-field-endpoint",children:i.jsx(Ke,{value:y.endpoint,onChange:A=>_({...y,endpoint:A}),t:n,candidates:d,placeholder:"/api/shop/products/{{route.id}}",testidPrefix:"g7le-ds-endpoint"})})]}),i.jsxs("div",{style:{display:"flex",gap:12},children:[i.jsxs("div",{style:{...ut,flex:1},children:[i.jsx("label",{style:ct,htmlFor:"g7le-ds-method",children:n("layout_editor.data_sources.field.method")}),i.jsx("select",{id:"g7le-ds-method","data-testid":"g7le-data-sources-field-method",style:Ht,value:y.method,onChange:A=>_({...y,method:A.target.value}),children:a$.map(A=>i.jsx("option",{value:A,children:A},A))})]}),i.jsxs("div",{style:{...ut,flex:1},children:[i.jsx("label",{style:ct,htmlFor:"g7le-ds-auth",children:n("layout_editor.data_sources.field.auth_mode")}),i.jsx("select",{id:"g7le-ds-auth","data-testid":"g7le-data-sources-field-auth",style:Ht,value:y.auth_mode,onChange:A=>_({...y,auth_mode:A.target.value}),children:l$.map(A=>i.jsx("option",{value:A,children:n(`layout_editor.data_sources.auth_mode.${A}`)},A))})]})]}),i.jsxs("div",{style:ut,children:[i.jsx("label",{style:ct,htmlFor:"g7le-ds-loading",children:n("layout_editor.data_sources.field.loading_strategy")}),i.jsx("select",{id:"g7le-ds-loading","data-testid":"g7le-data-sources-field-loading",style:Ht,value:y.loading_strategy,onChange:A=>_({...y,loading_strategy:A.target.value}),children:d$.map(A=>i.jsx("option",{value:A,children:n(`layout_editor.data_sources.loading_strategy.${A}`)},A))})]}),y.type==="api"&&i.jsxs("div",{style:ut,children:[i.jsx("label",{style:ct,htmlFor:"g7le-ds-contenttype",children:n("layout_editor.data_sources.field.content_type")}),i.jsx("select",{id:"g7le-ds-contenttype","data-testid":"g7le-ds-contenttype",style:Ht,value:y.contentType||"application/json",onChange:A=>_({...y,contentType:A.target.value}),children:c$.map(A=>i.jsx("option",{value:A,children:A},A))})]})]}),i.jsx("div",{style:ut,children:i.jsxs("label",{style:{...ct,display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[i.jsx("input",{type:"checkbox","data-testid":"g7le-data-sources-field-autofetch",checked:y.auto_fetch,onChange:A=>_({...y,auto_fetch:A.target.checked})}),n("layout_editor.data_sources.field.auto_fetch")]})}),i.jsx("div",{style:ut,children:i.jsxs("label",{style:{...ct,display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[i.jsx("input",{type:"checkbox","data-testid":"g7le-ds-refetch",checked:y.refetchOnMount,onChange:A=>_({...y,refetchOnMount:A.target.checked})}),n("layout_editor.data_sources.field.refetch_on_mount")]})}),i.jsxs("div",{style:ut,children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[i.jsx("label",{style:ct,htmlFor:"g7le-ds-params",children:n("layout_editor.data_sources.field.params")}),i.jsx("button",{type:"button","data-testid":"g7le-ds-params-mode-toggle",onClick:()=>{if(y.paramsRaw){if(y.paramsRawValid){const A=y.paramsRawValue;A&&typeof A=="object"&&!Array.isArray(A)&&!Hu(A)&&_({...y,paramsRaw:!1,paramRows:ju(A)})}}else{const A=na(y.paramRows);_({...y,paramsRaw:!0,paramsRawValue:A,paramsRawValid:!0})}},style:{...an,padding:"2px 8px",fontSize:11},children:y.paramsRaw?n("layout_editor.data_sources.field.params_mode_block"):n("layout_editor.data_sources.field.params_mode_code")})]}),y.paramsRaw?i.jsx(Us,{id:"g7le-ds-params",value:y.paramsRawValue,shape:"object",emptyValue:{},minHeight:64,testidPrefix:"g7le-data-sources-field-params",placeholder:`{ "page": "{{query.page ?? 1}}" -}`,shapeErrorKey:"layout_editor.data_sources.error.params_object",invalidErrorKey:"layout_editor.data_sources.error.params_json",t:n,onChange:I=>_(L=>L&&{...L,paramsRawValue:I??{},paramsRawValid:!0}),onValidityChange:I=>_(L=>L&&{...L,paramsRawValid:I})}):i.jsxs("div",{"data-testid":"g7le-data-sources-field-params",children:[y.paramRows.length===0&&i.jsx("p",{"data-testid":"g7le-ds-params-empty",style:e$,children:n("layout_editor.data_sources.field.params_empty")}),i.jsx(Pr,{value:y.paramRows.map(I=>({key:I.key,value:I.value})),onChange:I=>_({...y,paramRows:I.map(L=>({key:L.key??"",value:L.value??""}))}),keyField:"key",valueField:"value",t:n,candidates:d,testidPrefix:"g7le-ds-params-kv",keyPlaceholder:n("layout_editor.data_sources.field.param_key_placeholder"),valuePlaceholder:"{{query.page ?? 1}}",addLabel:n("layout_editor.data_sources.field.param_add")}),(()=>{const I=Zs(y.paramRows);return Object.keys(I).length===0?null:i.jsxs("div",{style:Ou,children:[i.jsxs("button",{type:"button","data-testid":"g7le-ds-params-preview-toggle","aria-expanded":x,onClick:()=>$(L=>!L),style:Bu,children:[x?"▴":"▾"," ",n("layout_editor.data_sources.field.params_preview")]}),x&&i.jsx("pre",{"data-testid":"g7le-ds-params-preview",style:{...Wu,marginTop:4},children:JSON.stringify(I,null,2)})]})})()]}),i.jsx("div",{style:{fontSize:11,color:"#94a3b8",marginTop:4},children:n("layout_editor.data_sources.field.params_hint")})]}),i.jsxs("div",{style:ut,children:[i.jsx("label",{style:ct,children:n("layout_editor.data_sources.field.fallback")}),y.fallbackEnabled?i.jsxs("div",{"data-testid":"g7le-data-sources-field-fallback",style:{display:"flex",flexDirection:"column",gap:6},children:[i.jsx(zn,{value:y.fallbackValue===void 0?{}:y.fallbackValue,onChange:I=>_({...y,fallbackValue:I}),t:n,path:"fallback",scope:"ds-fallback",renderStringLeaf:I=>i.jsx(Ke,{value:I.value,onChange:I.onChange,t:n,candidates:d,testidPrefix:I.testidPrefix})}),(()=>{const I=y.fallbackValue===void 0?{}:y.fallbackValue;return i.jsxs("div",{style:Ou,children:[i.jsxs("button",{type:"button","data-testid":"g7le-ds-fallback-preview-toggle","aria-expanded":S,onClick:()=>C(L=>!L),style:Bu,children:[S?"▴":"▾"," ",n("layout_editor.data_sources.field.fallback_preview")]}),S&&i.jsx("pre",{"data-testid":"g7le-ds-fallback-preview",style:{...Wu,marginTop:4},children:JSON.stringify(I,null,2)})]})})(),i.jsx("button",{type:"button","data-testid":"g7le-data-sources-field-fallback-clear",onClick:()=>_({...y,fallbackEnabled:!1,fallbackValue:void 0}),style:{...rn,padding:"2px 8px",fontSize:11,alignSelf:"flex-start",color:"#dc2626",borderColor:"#fecaca"},children:n("layout_editor.data_sources.field.fallback_clear")})]}):i.jsxs("button",{type:"button","data-testid":"g7le-data-sources-field-fallback-add",onClick:()=>_({...y,fallbackEnabled:!0,fallbackValue:{}}),style:{...rn,padding:"4px 10px",display:"block"},children:["+ ",n("layout_editor.data_sources.field.fallback_add")]})]}),y.type==="websocket"&&i.jsxs("div",{"data-testid":"g7le-ds-ws-section",style:Mo,children:[i.jsx("div",{style:Lo,children:n("layout_editor.data_sources.section.websocket")}),i.jsxs("div",{style:ut,children:[i.jsx("label",{style:ct,children:n("layout_editor.data_sources.field.channel")}),i.jsx("input",{"data-testid":"g7le-ds-ws-channel",style:jt,value:y.channel,onChange:I=>_({...y,channel:I.target.value}),placeholder:"core.admin.dashboard"})]}),i.jsxs("div",{style:ut,children:[i.jsx("label",{style:ct,children:n("layout_editor.data_sources.field.event")}),i.jsx("input",{"data-testid":"g7le-ds-ws-event",style:jt,value:y.event,onChange:I=>_({...y,event:I.target.value}),placeholder:"dashboard.stats.updated"})]}),i.jsxs("div",{style:ut,children:[i.jsx("label",{style:ct,children:n("layout_editor.data_sources.field.channel_type")}),i.jsx("select",{"data-testid":"g7le-ds-ws-channeltype",style:jt,value:y.channel_type,onChange:I=>_({...y,channel_type:I.target.value}),children:XC.map(I=>i.jsx("option",{value:I,children:I},I))})]}),i.jsxs("div",{style:ut,children:[i.jsx("label",{style:ct,children:n("layout_editor.data_sources.field.target_source")}),i.jsx("input",{"data-testid":"g7le-ds-ws-target",style:jt,value:y.target_source,onChange:I=>_({...y,target_source:I.target.value}),list:"g7le-ds-ws-target-list"}),i.jsx("datalist",{id:"g7le-ds-ws-target-list",children:h.filter(I=>I.id!==y.id).map(I=>typeof I.id=="string"?i.jsx("option",{value:I.id},I.id):null)})]}),i.jsxs("div",{style:ut,children:[i.jsx("label",{style:ct,children:n("layout_editor.data_sources.field.on_receive")}),i.jsx("div",{"data-testid":"g7le-ds-ws-onreceive",children:i.jsx(Gt,{actions:y.onReceive,onChange:I=>_({...y,onReceive:I}),t:n,recipes:s,candidatePools:N,chipContext:"payload",actionChipCandidates:l?.actionChipCandidates??null,testIdPrefix:"g7le-ds-onreceive-list"})})]})]}),i.jsxs("div",{style:Mo,children:[i.jsx("div",{style:Lo,children:n("layout_editor.data_sources.section.on_success")}),i.jsx("div",{"data-testid":"g7le-ds-onsuccess",children:i.jsx(Gt,{actions:y.onSuccess,onChange:I=>_({...y,onSuccess:I}),t:n,recipes:s,candidatePools:N,chipContext:"response",actionChipCandidates:l?.actionChipCandidates??null,testIdPrefix:"g7le-ds-onsuccess-list"})})]}),i.jsxs("div",{style:Mo,children:[i.jsx("div",{style:Lo,children:n("layout_editor.data_sources.section.on_error")}),i.jsx("div",{"data-testid":"g7le-ds-onerror",children:i.jsx(Gt,{actions:y.onError,onChange:I=>_({...y,onError:I}),t:n,recipes:s,candidatePools:N,chipContext:"error",actionChipCandidates:l?.actionChipCandidates??null,testIdPrefix:"g7le-ds-onerror-list"})})]}),i.jsxs("div",{style:Mo,children:[i.jsx("div",{style:Lo,children:n("layout_editor.data_sources.section.error_handling")}),i.jsxs("div",{"data-testid":"g7le-ds-errorhandling",children:[i.jsx(Us,{value:y.errorHandling,onChange:I=>_({...y,errorHandling:I}),t:n,mode:"local",testIdPrefix:"g7le-ds-eh",renderActionList:(I,L,F)=>i.jsx(t$,{code:I,action:L,recipes:a,pools:N,t:n,onPatch:F})}),i.jsxs("button",{type:"button","data-testid":"g7le-ds-errorhandling-add",onClick:()=>{const I=Object.keys(y.errorHandling),L=["403","404","500","422","default"].find(F=>!I.includes(F))??"default";_({...y,errorHandling:{...y.errorHandling,[L]:{handler:"toast"}}})},style:{...rn,padding:"4px 10px",marginTop:6},children:["+ ",n("layout_editor.data_sources.add_error_code")]})]})]}),i.jsxs("div",{style:Mo,children:[i.jsx("div",{style:Lo,children:n("layout_editor.data_sources.section.load_condition")}),i.jsx("div",{"data-testid":"g7le-ds-loadcondition",children:i.jsx(Du,{node:FC({if:y.if||void 0}),spec:l??null,t:n,dataSourceCandidates:p,stateKeyCandidates:f,onPatchNode:I=>{const L=KC(I,{});_({...y,if:typeof L.if=="string"?L.if:""})}})})]})]}),!y&&i.jsxs("button",{type:"button","data-testid":"g7le-data-sources-add",onClick:B,style:{...Pu,marginBottom:16},children:["+ ",n("layout_editor.data_sources.add")]}),i.jsxs("div",{className:"g7le-data-sources__list","data-testid":"g7le-data-sources-list",style:{display:"flex",flexDirection:"column",gap:8},children:[h.length===0&&!y&&i.jsx("div",{"data-testid":"g7le-data-sources-empty",style:{fontSize:12,color:"#94a3b8",padding:"12px 0",textAlign:"center"},children:n("layout_editor.data_sources.empty")}),h.map((I,L)=>{const F=typeof I.id=="string"?I.id:`#${L}`,Y=typeof I.endpoint=="string"?I.endpoint:"",K=typeof I.label_key=="string"?I.label_key:"",X=as(I,b);return i.jsxs("div",{"data-testid":"g7le-data-sources-item","data-ds-id":F,style:{border:"1px solid #e2e8f0",borderRadius:8,padding:"10px 12px",display:"flex",alignItems:"center",gap:8,background:"#ffffff"},children:[i.jsxs("div",{style:{flex:1,minWidth:0},children:[i.jsxs("div",{"data-testid":"g7le-data-sources-item-title",style:{fontWeight:600,fontSize:13,display:"flex",alignItems:"baseline",gap:6,flexWrap:"wrap"},children:[i.jsx("span",{children:X??F}),X&&i.jsx("span",{"data-testid":"g7le-data-sources-item-id",style:{fontSize:11,fontWeight:400,color:"#94a3b8"},children:F}),(()=>{const Z=ls(I,n);return Z?i.jsx("span",{"data-testid":"g7le-data-sources-ext-badge",style:{fontSize:10,fontWeight:600,color:"#7c3aed",background:"#f5f3ff",border:"1px solid #ddd6fe",borderRadius:4,padding:"1px 6px"},children:Z}):null})()]}),Y&&i.jsx("div",{style:{fontSize:11,color:"#94a3b8",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Y}),!K&&i.jsx("div",{"data-testid":"g7le-data-sources-nolabel",style:{fontSize:11,color:"#f59e0b"},children:n("layout_editor.data_sources.no_label")})]}),i.jsx("button",{type:"button","data-testid":"g7le-data-sources-edit",onClick:()=>M(I,L),style:{...rn,padding:"4px 10px"},children:n("layout_editor.data_sources.edit")}),i.jsx("button",{type:"button","data-testid":"g7le-data-sources-remove",onClick:()=>O(L),style:{...rn,padding:"4px 10px",color:"#dc2626",borderColor:"#fecaca"},children:n("layout_editor.data_sources.remove")})]},`${F}-${L}`)})]}),m.length>0&&i.jsxs("div",{style:{marginTop:16},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#64748b",textTransform:"uppercase",letterSpacing:.4,marginBottom:8},children:n("layout_editor.data_sources.inherited_title")}),i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:m.map((I,L)=>{const F=typeof I.id=="string"?I.id:`#${L}`,Y=T.has(F),K=[],X=(Z,ae)=>{const oe=I[Z];oe!=null&&K.push([ae,typeof oe=="object"?JSON.stringify(oe):String(oe)])};return X("type",n("layout_editor.data_sources.field.type")),X("endpoint",n("layout_editor.data_sources.field.endpoint")),X("method",n("layout_editor.data_sources.field.method")),X("auth_mode",n("layout_editor.data_sources.field.auth_mode")),X("loading_strategy",n("layout_editor.data_sources.field.loading_strategy")),X("auto_fetch",n("layout_editor.data_sources.field.auto_fetch")),X("params",n("layout_editor.data_sources.field.params")),i.jsxs("div",{"data-testid":"g7le-data-sources-inherited-item","data-ds-id":F,"data-expanded":Y?"true":"false",style:{border:"1px dashed #e2e8f0",borderRadius:6,fontSize:12,color:"#64748b",background:"#f8fafc",overflow:"hidden"},children:[i.jsxs("button",{type:"button","data-testid":"g7le-data-sources-inherited-toggle",onClick:()=>A(F),"aria-expanded":Y,style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"8px 12px",background:"transparent",border:"none",cursor:"pointer",color:"inherit",fontSize:12,textAlign:"left",outline:"none"},children:[i.jsx("span",{style:{flex:"0 0 auto",width:12,transition:"transform 120ms",transform:Y?"rotate(90deg)":"none"},children:"▶"}),(()=>{const Z=as(I,b),ae=ls(I,n);return i.jsxs("span",{style:{flex:1,display:"inline-flex",alignItems:"baseline",gap:6,flexWrap:"wrap"},children:[i.jsx("span",{style:{fontWeight:600},children:Z??F}),Z&&i.jsx("span",{style:{fontSize:11,fontWeight:400,color:"#94a3b8"},children:F}),ae&&i.jsx("span",{"data-testid":"g7le-data-sources-ext-badge",style:{fontSize:10,fontWeight:600,color:"#7c3aed",background:"#f5f3ff",border:"1px solid #ddd6fe",borderRadius:4,padding:"1px 6px"},children:ae})]})})()]}),Y&&i.jsxs("div",{"data-testid":"g7le-data-sources-inherited-info",style:{padding:"0 12px 10px 32px",display:"flex",flexDirection:"column",gap:3},children:[K.length===0&&i.jsx("span",{style:{color:"#94a3b8"},children:"—"}),K.map(([Z,ae])=>i.jsxs("div",{style:{display:"flex",gap:6},children:[i.jsxs("span",{style:{flex:"0 0 auto",color:"#94a3b8"},children:[Z,":"]}),i.jsx("span",{style:{flex:1,minWidth:0,wordBreak:"break-all",color:"#475569"},children:ae})]},Z))]})]},`inh-${F}-${L}`)})})]})]}),y&&i.jsxs("div",{className:"g7le-data-sources__footer",style:{flex:"0 0 auto",padding:"12px 16px",borderTop:"1px solid #e2e8f0",background:"#ffffff"},children:[w&&i.jsx("div",{"data-testid":"g7le-data-sources-form-error",role:"alert",style:{fontSize:12,color:"#dc2626",marginBottom:10},children:w}),i.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[i.jsx("button",{type:"button","data-testid":"g7le-data-sources-form-cancel",onClick:z,style:rn,children:n("layout_editor.data_sources.form.cancel")}),i.jsx("button",{type:"button","data-testid":"g7le-data-sources-form-submit",onClick:H,style:Pu,children:n("layout_editor.data_sources.form.save")})]})]})]})}function i$(e){const t=e?.globalHeaders;return Array.isArray(t)?t:[]}function s$(e){const t=e?.scripts;return Array.isArray(t)?t:[]}function a$(e){const t=i$(e.raw),n=s$(e.raw);return i.jsxs("div",{className:"g7le-data-source-tab","data-testid":"g7le-data-source-tab",style:l$,children:[i.jsx(r$,{...e}),i.jsxs("div",{style:Hu,"data-testid":"g7le-global-headers",children:[i.jsx("div",{style:Fu,children:e.t("layout_editor.data_sources.global_headers")}),t.length===0?i.jsx("p",{"data-testid":"g7le-global-header-empty",style:Gu,children:e.t("layout_editor.data_sources.global_headers_empty")}):t.map((o,r)=>i.jsxs("div",{"data-testid":`g7le-global-header-${r}`,style:Ku,children:[i.jsx("code",{style:Vu,children:o.pattern??"*"}),i.jsx("span",{style:d$,children:"→"}),i.jsx("span",{style:Uu,children:Object.keys(o.headers??{}).join(", ")})]},r)),i.jsxs("p",{style:qu,children:["ⓘ ",e.t("layout_editor.data_sources.global_headers_hint")]})]}),i.jsxs("div",{style:Hu,"data-testid":"g7le-scripts",children:[i.jsx("div",{style:Fu,children:e.t("layout_editor.data_sources.scripts")}),n.length===0?i.jsx("p",{"data-testid":"g7le-script-empty",style:Gu,children:e.t("layout_editor.data_sources.scripts_empty")}):n.map((o,r)=>i.jsxs("div",{"data-testid":`g7le-script-${o.id??r}`,style:Ku,children:[i.jsx("code",{style:Vu,children:o.id??`#${r}`}),i.jsx("span",{style:Uu,children:o.src??""}),o.loading?i.jsx("span",{style:c$,children:o.loading}):null]},o.id??r)),i.jsxs("p",{style:qu,children:["ⓘ ",e.t("layout_editor.data_sources.scripts_hint")]})]})]})}const l$={display:"flex",flexDirection:"column",gap:16,minWidth:0},Hu={borderTop:"1px solid #e2e8f0",paddingTop:12,display:"flex",flexDirection:"column",gap:6},Fu={fontSize:12,fontWeight:700,color:"#475569"},Ku={display:"flex",alignItems:"center",gap:8,fontSize:12,padding:"4px 8px",border:"1px solid #f1f5f9",borderRadius:6},Vu={fontSize:11,color:"#0f172a",fontFamily:"monospace"},d$={color:"#94a3b8"},Uu={flex:1,minWidth:0,color:"#475569",wordBreak:"break-all"},c$={fontSize:10,color:"#64748b",background:"#f1f5f9",borderRadius:4,padding:"0 4px"},qu={margin:0,fontSize:11,color:"#94a3b8"},Gu={margin:0,fontSize:12,color:"#94a3b8"},u$=["meta","seo","init","overlay","computed","state","error","data"],p$=["401","403","404","500","503"],f$={meta:"layout_editor.page_settings.tab.meta",seo:"layout_editor.page_settings.tab.seo",init:"layout_editor.page_settings.tab.init",overlay:"layout_editor.page_settings.tab.overlay",computed:"layout_editor.page_settings.tab.computed",state:"layout_editor.page_settings.tab.state",error:"layout_editor.page_settings.tab.error",data:"layout_editor.page_settings.tab.data"};async function g$(e){if(typeof fetch!="function"||!e)return[];try{const t=await fetch(en(`/api/admin/templates/${encodeURIComponent(e)}/editor/seo-candidates`,"json"),{credentials:"same-origin",headers:Ne()});if(!t.ok)return[];const o=(await t.json().catch(()=>null))?.data?.extensions;if(!Array.isArray(o))return[];const r=[];for(const s of o)if(s&&typeof s=="object"){const a=s.type,l=s.id,d=s.label;typeof a=="string"&&typeof l=="string"&&l.length>0&&r.push({type:a,id:l,name:typeof d=="string"?d:l})}return r}catch{return[]}}function h$(e,t){let n=0;for(const o of e)Yn(o,t).kind==="advanced"&&(n+=1);return n}function y$(e,t){let n=0;for(const o of Object.keys(e))Dd(e[o],t).kind==="advanced"&&(n+=1);return n}function b$(e,t,n){const o=e("meta",{})??{},r=o.title;if(typeof r=="string"&&r.length>0){if(r.startsWith("$t:")){const a=n(r.slice(3));if(a&&a!==r.slice(3))return a}else if(!/\{\{[\s\S]*\}\}/.test(r))return r}const s=o.editor_label;return typeof s=="string"&&s.length>0?s.startsWith("$t:")?n(s.slice(3)):s:t||""}function m$({templateIdentifier:e,spec:t,t:n,resolveLabel:o,permissionCandidates:r,onClose:s,initialTab:a="meta",extensionsFetcher:l}){const{state:d}=Qe(),{raw:c,getValue:p,patch:f}=jm(),[b,g]=u.useState(a),m=d.selectedRoute?.path??"",h=u.useMemo(()=>Od(d.routeTree,o),[d.routeTree,o]),v=u.useMemo(()=>Bd(c),[c]),y=u.useMemo(()=>Wd(t),[t]),_=u.useMemo(()=>iv(c,o),[c,o]),w=Pd({raw:c,spec:t}),k=u.useMemo(()=>lb(t),[t]),x=u.useMemo(()=>db(t),[t]),$=u.useMemo(()=>cb(t),[t]),S=u.useMemo(()=>ub(t),[t]),C=u.useMemo(()=>ko(k),[k]),T=u.useMemo(()=>Cd(x),[x]),E=p("init_actions",void 0)??p("initActions",[]),A=p("computed",{}),N=p("__computedSource",{}),D=p("errorHandling",{}),B=p("transition_overlay",void 0),M=(p("__editor",{})??{}).original,O=u.useMemo(()=>{if(M===void 0)return;const G=M.transition_overlay;return G&&typeof G=="object"&&!Array.isArray(G)?G:{}},[M]),z=u.useMemo(()=>{const G=B;if(!G||typeof G!="object"||Array.isArray(G))return;const ee=O??{},ge={};for(const[V,te]of Object.entries(G))V in ee||(ge[V]=te);return Object.keys(ge).length>0?ge:void 0},[B,O]),[H,P]=u.useState([]);u.useEffect(()=>{let G=!1;const ee=l??g$;return(async()=>{const ge=await ee(e);G||P(ge)})(),()=>{G=!0}},[e,l]);const I=(p("meta",{})??{}).seo?.page_type,L=ov({raw:c,spec:t,pageType:typeof I=="string"?I:null}),F=u.useMemo(()=>nv(c,t),[c,t]),Y=u.useMemo(()=>({meta:0,seo:0,init:h$(E,C),overlay:0,computed:y$(A,T),state:0,error:0,data:0}),[E,C,A,T]),K=u.useMemo(()=>Object.values(Y).reduce((G,ee)=>G+ee,0),[Y]),X=u.useMemo(()=>rv(c,o,n),[c,o,n]),Z=u.useCallback(G=>{const ge={...M?.computed??{}};delete ge[G];const V={...A};delete V[G],f("computed",V,Object.keys(ge).length===0?void 0:ge)},[M,A,f]),ae=b$(p,m,n),oe=()=>{switch(b){case"meta":return i.jsx(kx,{getValue:p,patch:f,t:n,fieldT:o,spec:t,permissionCandidates:r,bindingCandidates:w});case"seo":return i.jsx(d0,{getValue:p,patch:f,t:n,templateIdentifier:e,candidates:L,availableExtensions:H,dataSourceOptions:X,previewUrl:m||"/",seedContext:F});case"init":return i.jsx(Ak,{actions:E,onChange:G=>f("init_actions",G),recipes:k,t:o,bindingCandidates:w,pageCandidates:h,dataSourceCandidates:v,stateKeyCandidates:y,modalCandidates:_});case"overlay":return i.jsx(Qk,{value:B,ownValue:O,baseValue:z,patch:G=>f("transition_overlay",G),t:o,loadingComponents:S,progressiveDataSources:X,bindingCandidates:w});case"computed":return i.jsx(j1,{computed:A,onChange:G=>f("computed",G),recipes:x,t:o,sampleContext:F,dataSourceCandidates:v,bindingCandidates:w,computedSource:N,onRevert:Z});case"state":return i.jsx(xS,{raw:c,own:M?{initLocal:M.initLocal,initGlobal:M.initGlobal,initIsolated:M.initIsolated,state:M.state}:void 0,patch:f,t:n});case"error":return i.jsx(GS,{value:D,onChange:G=>f("errorHandling",G),t:o,errorConfigCodes:p$,templateCodes:Object.keys(D),ownCodes:Object.keys(M?.errorHandling??{}),recipes:$,pageCandidates:h,modalCandidates:_,dataSourceCandidates:v,stateKeyCandidates:y});case"data":return i.jsx(a$,{raw:c,t:n,resolveLabel:o,onChange:(G,ee)=>f("data_sources",G,ee),onClose:s,actionRecipes:k,errorRecipes:$,conditionSpec:t,bindingCandidates:w,pageCandidates:h,dataSourceCandidates:v,stateKeyCandidates:y});default:return i.jsx("div",{})}};return i.jsxs("div",{className:"g7le-page-settings","data-testid":"g7le-page-settings",style:v$,children:[i.jsxs("div",{style:_$,children:[i.jsx("span",{"data-testid":"g7le-page-settings-title",style:x$,children:n("layout_editor.page_settings.title",{name:ae})}),i.jsx("button",{type:"button","data-testid":"g7le-page-settings-close-x",onClick:s,"aria-label":n("layout_editor.page_settings.close"),style:w$,children:"✕"})]}),i.jsx("div",{role:"tablist",style:k$,children:u$.map(G=>{const ee=Y[G];return i.jsxs("button",{type:"button",role:"tab","aria-selected":b===G,"data-testid":`g7le-page-settings-tab-${G}`,"data-active":b===G?"true":"false",onClick:()=>g(G),style:b===G?S$:Yu,children:[n(f$[G]),ee>0?i.jsxs("span",{"data-testid":`g7le-page-settings-tab-badge-${G}`,style:C$,children:["(",ee,")"]}):null]},G)})}),K>0?i.jsxs("p",{"data-testid":"g7le-page-settings-advanced-summary",style:$$,children:["⚠ ",n("layout_editor.page_settings.advanced_summary",{count:K})," ⓘ"]}):null,i.jsx("div",{"data-testid":"g7le-page-settings-panel",style:E$,children:oe()}),i.jsx("div",{style:I$,children:i.jsx("button",{type:"button","data-testid":"g7le-page-settings-close",onClick:s,style:A$,children:n("layout_editor.page_settings.close")})})]})}const v$={display:"flex",flexDirection:"column",minWidth:0,maxWidth:"100%",padding:"20px 24px",boxSizing:"border-box",flex:1,minHeight:0,maxHeight:"100%",overflow:"hidden",fontFamily:"system-ui, -apple-system, sans-serif"},_$={display:"flex",alignItems:"center",gap:8,paddingBottom:8,borderBottom:"1px solid #e2e8f0"},x$={flex:1,fontSize:15,fontWeight:700,color:"#0f172a",minWidth:0},w$={border:"none",background:"transparent",color:"#64748b",cursor:"pointer",fontSize:16,lineHeight:1,padding:4},k$={display:"flex",gap:2,paddingTop:8,borderBottom:"1px solid #e2e8f0",flexWrap:"nowrap",overflowX:"auto",overflowY:"hidden",flexShrink:0,minWidth:0},Yu={border:"none",borderBottomWidth:"2px",borderBottomStyle:"solid",borderBottomColor:"transparent",background:"transparent",color:"#64748b",cursor:"pointer",fontSize:12,padding:"6px 10px",whiteSpace:"nowrap"},S$={...Yu,color:"#2563eb",borderBottomColor:"#2563eb",fontWeight:600},C$={marginLeft:4,fontSize:10,color:"#b45309"},$$={margin:0,marginTop:8,fontSize:11,color:"#b45309",background:"#fffbeb",padding:"6px 8px",borderRadius:6},E$={flex:1,overflowY:"auto",paddingTop:12,minWidth:0,minHeight:0},I$={display:"flex",justifyContent:"flex-end",paddingTop:8,borderTop:"1px solid #e2e8f0"},A$={border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",fontSize:13,padding:"6px 16px"};function Qs(e,t){const n=`/api/admin/templates/${encodeURIComponent(e)}`;return t.kind==="layout"?`${n}/layouts/${t.layoutName}/versions`:`${n}/layout-extensions/${encodeURIComponent(t.extensionId)}/versions`}const Xu=100,Ju=500;function T$(e,t,n){const[o,r]=u.useState([]),[s,a]=u.useState(!1),[l,d]=u.useState(!1),[c,p]=u.useState(null),[f,b]=u.useState(null),[g,m]=u.useState(Xu),[h,v]=u.useState(!1),y=u.useCallback(async($,S)=>{if(!t){r([]),p(null),v(!1);return}S==="more"?d(!0):a(!0),p(null);try{const C=`${Qs(e,t)}?limit=${$}`,T=await fetch(C,{credentials:"same-origin",headers:Ne()}),E=await T.json().catch(()=>null);if(!T.ok){p(E?.message??`HTTP ${T.status}`),S==="reload"&&r([]);return}const A=E?.data,N=Array.isArray(A)?A:[];r(N),v(N.length>=$&&${await y(g,"reload")},[y,g]),w=u.useCallback(async()=>{const $=Math.min(g+Xu,Ju);if($<=g){v(!1);return}await y($,"more")},[y,g]),k=u.useCallback(async $=>{if(!t)return{kind:"not_found"};b($);try{const S=`${Qs(e,t)}/${$}/restore`,C=await fetch(S,{method:"POST",credentials:"same-origin",headers:Ne({"Content-Type":"application/json"})}),T=await C.json().catch(()=>null);if(C.status===404)return{kind:"not_found"};if(!C.ok)return{kind:"network_error",message:T?.message??`HTTP ${C.status}`};const E=typeof T?.data?.version=="number"?T.data.version:-1;return await n?.(E>=0?E:void 0),{kind:"success",newVersion:E}}catch(S){return{kind:"network_error",message:S instanceof Error?S.message:"network error"}}finally{b(null)}},[e,t,n]),x=u.useCallback(async $=>{if(!t)return{kind:"not_found"};try{const S=`${Qs(e,t)}/${$}`,C=await fetch(S,{credentials:"same-origin",headers:Ne()}),T=await C.json().catch(()=>null);if(C.status===404)return{kind:"not_found"};if(!C.ok)return{kind:"network_error",message:T?.message??`HTTP ${C.status}`};const E=T?.data;if(!E)return{kind:"not_found"};if(t.kind==="extension"&&!E.full_content){const A=E.content;if(typeof A=="string")try{const N=JSON.parse(A);N&&typeof N=="object"&&(E.full_content=N)}catch{}}return{kind:"success",detail:E}}catch(S){return{kind:"network_error",message:S instanceof Error?S.message:"network error"}}},[e,t]);return{versions:o,isLoading:s,isLoadingMore:l,error:c,restoringId:f,hasMore:h,loadVersions:_,loadMore:w,restore:k,loadVersionDetail:x}}function D$(e,t){const n=e.length,o=t.length,r=Array.from({length:n+1},()=>new Array(o+1).fill(0));for(let s=n-1;s>=0;s--)for(let a=o-1;a>=0;a--)e[s]===t[a]?r[s][a]=r[s+1][a+1]+1:r[s][a]=Math.max(r[s+1][a],r[s][a+1]);return r}function z$(e,t,n){const o=[];let r=0,s=0;const a=e.length,l=t.length;for(;r=n[r][s+1]?(o.push({kind:"remove",oldIndex:r,content:e[r]}),r++):(o.push({kind:"add",newIndex:s,content:t[s]}),s++);for(;r_(L=>L&&{...L,paramsRawValue:A??{},paramsRawValid:!0}),onValidityChange:A=>_(L=>L&&{...L,paramsRawValid:A})}):i.jsxs("div",{"data-testid":"g7le-data-sources-field-params",children:[y.paramRows.length===0&&i.jsx("p",{"data-testid":"g7le-ds-params-empty",style:y$,children:n("layout_editor.data_sources.field.params_empty")}),i.jsx(Wr,{value:y.paramRows.map(A=>({key:A.key,value:A.value})),onChange:A=>_({...y,paramRows:A.map(L=>({key:L.key??"",value:L.value??""}))}),keyField:"key",valueField:"value",t:n,candidates:d,testidPrefix:"g7le-ds-params-kv",keyPlaceholder:n("layout_editor.data_sources.field.param_key_placeholder"),valuePlaceholder:"{{query.page ?? 1}}",addLabel:n("layout_editor.data_sources.field.param_add")}),(()=>{const A=na(y.paramRows);return Object.keys(A).length===0?null:i.jsxs("div",{style:Ku,children:[i.jsxs("button",{type:"button","data-testid":"g7le-ds-params-preview-toggle","aria-expanded":x,onClick:()=>$(L=>!L),style:Vu,children:[x?"▴":"▾"," ",n("layout_editor.data_sources.field.params_preview")]}),x&&i.jsx("pre",{"data-testid":"g7le-ds-params-preview",style:{...Uu,marginTop:4},children:JSON.stringify(A,null,2)})]})})()]}),i.jsx("div",{style:{fontSize:11,color:"#94a3b8",marginTop:4},children:n("layout_editor.data_sources.field.params_hint")})]}),i.jsxs("div",{style:ut,children:[i.jsx("label",{style:ct,children:n("layout_editor.data_sources.field.fallback")}),y.fallbackEnabled?i.jsxs("div",{"data-testid":"g7le-data-sources-field-fallback",style:{display:"flex",flexDirection:"column",gap:6},children:[i.jsx(Mn,{value:y.fallbackValue===void 0?{}:y.fallbackValue,onChange:A=>_({...y,fallbackValue:A}),t:n,path:"fallback",scope:"ds-fallback",renderStringLeaf:A=>i.jsx(Ke,{value:A.value,onChange:A.onChange,t:n,candidates:d,testidPrefix:A.testidPrefix})}),(()=>{const A=y.fallbackValue===void 0?{}:y.fallbackValue;return i.jsxs("div",{style:Ku,children:[i.jsxs("button",{type:"button","data-testid":"g7le-ds-fallback-preview-toggle","aria-expanded":C,onClick:()=>S(L=>!L),style:Vu,children:[C?"▴":"▾"," ",n("layout_editor.data_sources.field.fallback_preview")]}),C&&i.jsx("pre",{"data-testid":"g7le-ds-fallback-preview",style:{...Uu,marginTop:4},children:JSON.stringify(A,null,2)})]})})(),i.jsx("button",{type:"button","data-testid":"g7le-data-sources-field-fallback-clear",onClick:()=>_({...y,fallbackEnabled:!1,fallbackValue:void 0}),style:{...an,padding:"2px 8px",fontSize:11,alignSelf:"flex-start",color:"#dc2626",borderColor:"#fecaca"},children:n("layout_editor.data_sources.field.fallback_clear")})]}):i.jsxs("button",{type:"button","data-testid":"g7le-data-sources-field-fallback-add",onClick:()=>_({...y,fallbackEnabled:!0,fallbackValue:{}}),style:{...an,padding:"4px 10px",display:"block"},children:["+ ",n("layout_editor.data_sources.field.fallback_add")]})]}),y.type==="websocket"&&i.jsxs("div",{"data-testid":"g7le-ds-ws-section",style:Oo,children:[i.jsx("div",{style:Bo,children:n("layout_editor.data_sources.section.websocket")}),i.jsxs("div",{style:ut,children:[i.jsx("label",{style:ct,children:n("layout_editor.data_sources.field.channel")}),i.jsx("input",{"data-testid":"g7le-ds-ws-channel",style:Ht,value:y.channel,onChange:A=>_({...y,channel:A.target.value}),placeholder:"core.admin.dashboard"})]}),i.jsxs("div",{style:ut,children:[i.jsx("label",{style:ct,children:n("layout_editor.data_sources.field.event")}),i.jsx("input",{"data-testid":"g7le-ds-ws-event",style:Ht,value:y.event,onChange:A=>_({...y,event:A.target.value}),placeholder:"dashboard.stats.updated"})]}),i.jsxs("div",{style:ut,children:[i.jsx("label",{style:ct,children:n("layout_editor.data_sources.field.channel_type")}),i.jsx("select",{"data-testid":"g7le-ds-ws-channeltype",style:Ht,value:y.channel_type,onChange:A=>_({...y,channel_type:A.target.value}),children:u$.map(A=>i.jsx("option",{value:A,children:A},A))})]}),i.jsxs("div",{style:ut,children:[i.jsx("label",{style:ct,children:n("layout_editor.data_sources.field.target_source")}),i.jsx("input",{"data-testid":"g7le-ds-ws-target",style:Ht,value:y.target_source,onChange:A=>_({...y,target_source:A.target.value}),list:"g7le-ds-ws-target-list"}),i.jsx("datalist",{id:"g7le-ds-ws-target-list",children:h.filter(A=>A.id!==y.id).map(A=>typeof A.id=="string"?i.jsx("option",{value:A.id},A.id):null)})]}),i.jsxs("div",{style:ut,children:[i.jsx("label",{style:ct,children:n("layout_editor.data_sources.field.on_receive")}),i.jsx("div",{"data-testid":"g7le-ds-ws-onreceive",children:i.jsx(Yt,{actions:y.onReceive,onChange:A=>_({...y,onReceive:A}),t:n,recipes:s,candidatePools:N,chipContext:"payload",actionChipCandidates:l?.actionChipCandidates??null,testIdPrefix:"g7le-ds-onreceive-list"})})]})]}),i.jsxs("div",{style:Oo,children:[i.jsx("div",{style:Bo,children:n("layout_editor.data_sources.section.on_success")}),i.jsx("div",{"data-testid":"g7le-ds-onsuccess",children:i.jsx(Yt,{actions:y.onSuccess,onChange:A=>_({...y,onSuccess:A}),t:n,recipes:s,candidatePools:N,chipContext:"response",actionChipCandidates:l?.actionChipCandidates??null,testIdPrefix:"g7le-ds-onsuccess-list"})})]}),i.jsxs("div",{style:Oo,children:[i.jsx("div",{style:Bo,children:n("layout_editor.data_sources.section.on_error")}),i.jsx("div",{"data-testid":"g7le-ds-onerror",children:i.jsx(Yt,{actions:y.onError,onChange:A=>_({...y,onError:A}),t:n,recipes:s,candidatePools:N,chipContext:"error",actionChipCandidates:l?.actionChipCandidates??null,testIdPrefix:"g7le-ds-onerror-list"})})]}),i.jsxs("div",{style:Oo,children:[i.jsx("div",{style:Bo,children:n("layout_editor.data_sources.section.error_handling")}),i.jsxs("div",{"data-testid":"g7le-ds-errorhandling",children:[i.jsx(Xs,{value:y.errorHandling,onChange:A=>_({...y,errorHandling:A}),t:n,mode:"local",testIdPrefix:"g7le-ds-eh",renderActionList:(A,L,F)=>i.jsx(b$,{code:A,action:L,recipes:a,pools:N,t:n,onPatch:F})}),i.jsxs("button",{type:"button","data-testid":"g7le-ds-errorhandling-add",onClick:()=>{const A=Object.keys(y.errorHandling),L=["403","404","500","422","default"].find(F=>!A.includes(F))??"default";_({...y,errorHandling:{...y.errorHandling,[L]:{handler:"toast"}}})},style:{...an,padding:"4px 10px",marginTop:6},children:["+ ",n("layout_editor.data_sources.add_error_code")]})]})]}),i.jsxs("div",{style:Oo,children:[i.jsx("div",{style:Bo,children:n("layout_editor.data_sources.section.load_condition")}),i.jsx("div",{"data-testid":"g7le-ds-loadcondition",children:i.jsx(Ou,{node:r$({if:y.if||void 0}),spec:l??null,t:n,dataSourceCandidates:p,stateKeyCandidates:f,onPatchNode:A=>{const L=i$(A,{});_({...y,if:typeof L.if=="string"?L.if:""})}})})]})]}),!y&&i.jsxs("button",{type:"button","data-testid":"g7le-data-sources-add",onClick:B,style:{...Fu,marginBottom:16},children:["+ ",n("layout_editor.data_sources.add")]}),i.jsxs("div",{className:"g7le-data-sources__list","data-testid":"g7le-data-sources-list",style:{display:"flex",flexDirection:"column",gap:8},children:[h.length===0&&!y&&i.jsx("div",{"data-testid":"g7le-data-sources-empty",style:{fontSize:12,color:"#94a3b8",padding:"12px 0",textAlign:"center"},children:n("layout_editor.data_sources.empty")}),h.map((A,L)=>{const F=typeof A.id=="string"?A.id:`#${L}`,Y=typeof A.endpoint=="string"?A.endpoint:"",V=typeof A.label_key=="string"?A.label_key:"",X=us(A,b);return i.jsxs("div",{"data-testid":"g7le-data-sources-item","data-ds-id":F,style:{border:"1px solid #e2e8f0",borderRadius:8,padding:"10px 12px",display:"flex",alignItems:"center",gap:8,background:"#ffffff"},children:[i.jsxs("div",{style:{flex:1,minWidth:0},children:[i.jsxs("div",{"data-testid":"g7le-data-sources-item-title",style:{fontWeight:600,fontSize:13,display:"flex",alignItems:"baseline",gap:6,flexWrap:"wrap"},children:[i.jsx("span",{children:X??F}),X&&i.jsx("span",{"data-testid":"g7le-data-sources-item-id",style:{fontSize:11,fontWeight:400,color:"#94a3b8"},children:F}),(()=>{const Z=ps(A,n);return Z?i.jsx("span",{"data-testid":"g7le-data-sources-ext-badge",style:{fontSize:10,fontWeight:600,color:"#7c3aed",background:"#f5f3ff",border:"1px solid #ddd6fe",borderRadius:4,padding:"1px 6px"},children:Z}):null})()]}),Y&&i.jsx("div",{style:{fontSize:11,color:"#94a3b8",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Y}),!V&&i.jsx("div",{"data-testid":"g7le-data-sources-nolabel",style:{fontSize:11,color:"#f59e0b"},children:n("layout_editor.data_sources.no_label")})]}),i.jsx("button",{type:"button","data-testid":"g7le-data-sources-edit",onClick:()=>M(A,L),style:{...an,padding:"4px 10px"},children:n("layout_editor.data_sources.edit")}),i.jsx("button",{type:"button","data-testid":"g7le-data-sources-remove",onClick:()=>O(L),style:{...an,padding:"4px 10px",color:"#dc2626",borderColor:"#fecaca"},children:n("layout_editor.data_sources.remove")})]},`${F}-${L}`)})]}),m.length>0&&i.jsxs("div",{style:{marginTop:16},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#64748b",textTransform:"uppercase",letterSpacing:.4,marginBottom:8},children:n("layout_editor.data_sources.inherited_title")}),i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:m.map((A,L)=>{const F=typeof A.id=="string"?A.id:`#${L}`,Y=D.has(F),V=[],X=(Z,ie)=>{const oe=A[Z];oe!=null&&V.push([ie,typeof oe=="object"?JSON.stringify(oe):String(oe)])};return X("type",n("layout_editor.data_sources.field.type")),X("endpoint",n("layout_editor.data_sources.field.endpoint")),X("method",n("layout_editor.data_sources.field.method")),X("auth_mode",n("layout_editor.data_sources.field.auth_mode")),X("loading_strategy",n("layout_editor.data_sources.field.loading_strategy")),X("auto_fetch",n("layout_editor.data_sources.field.auto_fetch")),X("params",n("layout_editor.data_sources.field.params")),i.jsxs("div",{"data-testid":"g7le-data-sources-inherited-item","data-ds-id":F,"data-expanded":Y?"true":"false",style:{border:"1px dashed #e2e8f0",borderRadius:6,fontSize:12,color:"#64748b",background:"#f8fafc",overflow:"hidden"},children:[i.jsxs("button",{type:"button","data-testid":"g7le-data-sources-inherited-toggle",onClick:()=>I(F),"aria-expanded":Y,style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"8px 12px",background:"transparent",border:"none",cursor:"pointer",color:"inherit",fontSize:12,textAlign:"left",outline:"none"},children:[i.jsx("span",{style:{flex:"0 0 auto",width:12,transition:"transform 120ms",transform:Y?"rotate(90deg)":"none"},children:"▶"}),(()=>{const Z=us(A,b),ie=ps(A,n);return i.jsxs("span",{style:{flex:1,display:"inline-flex",alignItems:"baseline",gap:6,flexWrap:"wrap"},children:[i.jsx("span",{style:{fontWeight:600},children:Z??F}),Z&&i.jsx("span",{style:{fontSize:11,fontWeight:400,color:"#94a3b8"},children:F}),ie&&i.jsx("span",{"data-testid":"g7le-data-sources-ext-badge",style:{fontSize:10,fontWeight:600,color:"#7c3aed",background:"#f5f3ff",border:"1px solid #ddd6fe",borderRadius:4,padding:"1px 6px"},children:ie})]})})()]}),Y&&i.jsxs("div",{"data-testid":"g7le-data-sources-inherited-info",style:{padding:"0 12px 10px 32px",display:"flex",flexDirection:"column",gap:3},children:[V.length===0&&i.jsx("span",{style:{color:"#94a3b8"},children:"—"}),V.map(([Z,ie])=>i.jsxs("div",{style:{display:"flex",gap:6},children:[i.jsxs("span",{style:{flex:"0 0 auto",color:"#94a3b8"},children:[Z,":"]}),i.jsx("span",{style:{flex:1,minWidth:0,wordBreak:"break-all",color:"#475569"},children:ie})]},Z))]})]},`inh-${F}-${L}`)})})]})]}),y&&i.jsxs("div",{className:"g7le-data-sources__footer",style:{flex:"0 0 auto",padding:"12px 16px",borderTop:"1px solid #e2e8f0",background:"#ffffff"},children:[w&&i.jsx("div",{"data-testid":"g7le-data-sources-form-error",role:"alert",style:{fontSize:12,color:"#dc2626",marginBottom:10},children:w}),i.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[i.jsx("button",{type:"button","data-testid":"g7le-data-sources-form-cancel",onClick:z,style:an,children:n("layout_editor.data_sources.form.cancel")}),i.jsx("button",{type:"button","data-testid":"g7le-data-sources-form-submit",onClick:H,style:Fu,children:n("layout_editor.data_sources.form.save")})]})]})]})}function x$(e){const t=e?.globalHeaders;return Array.isArray(t)?t:[]}function w$(e){const t=e?.scripts;return Array.isArray(t)?t:[]}function k$(e){const t=x$(e.raw),n=w$(e.raw);return i.jsxs("div",{className:"g7le-data-source-tab","data-testid":"g7le-data-source-tab",style:S$,children:[i.jsx(_$,{...e}),i.jsxs("div",{style:Gu,"data-testid":"g7le-global-headers",children:[i.jsx("div",{style:Yu,children:e.t("layout_editor.data_sources.global_headers")}),t.length===0?i.jsx("p",{"data-testid":"g7le-global-header-empty",style:Ru,children:e.t("layout_editor.data_sources.global_headers_empty")}):t.map((o,r)=>i.jsxs("div",{"data-testid":`g7le-global-header-${r}`,style:Xu,children:[i.jsx("code",{style:Ju,children:o.pattern??"*"}),i.jsx("span",{style:C$,children:"→"}),i.jsx("span",{style:Zu,children:Object.keys(o.headers??{}).join(", ")})]},r)),i.jsxs("p",{style:Qu,children:["ⓘ ",e.t("layout_editor.data_sources.global_headers_hint")]})]}),i.jsxs("div",{style:Gu,"data-testid":"g7le-scripts",children:[i.jsx("div",{style:Yu,children:e.t("layout_editor.data_sources.scripts")}),n.length===0?i.jsx("p",{"data-testid":"g7le-script-empty",style:Ru,children:e.t("layout_editor.data_sources.scripts_empty")}):n.map((o,r)=>i.jsxs("div",{"data-testid":`g7le-script-${o.id??r}`,style:Xu,children:[i.jsx("code",{style:Ju,children:o.id??`#${r}`}),i.jsx("span",{style:Zu,children:o.src??""}),o.loading?i.jsx("span",{style:$$,children:o.loading}):null]},o.id??r)),i.jsxs("p",{style:Qu,children:["ⓘ ",e.t("layout_editor.data_sources.scripts_hint")]})]})]})}const S$={display:"flex",flexDirection:"column",gap:16,minWidth:0},Gu={borderTop:"1px solid #e2e8f0",paddingTop:12,display:"flex",flexDirection:"column",gap:6},Yu={fontSize:12,fontWeight:700,color:"#475569"},Xu={display:"flex",alignItems:"center",gap:8,fontSize:12,padding:"4px 8px",border:"1px solid #f1f5f9",borderRadius:6},Ju={fontSize:11,color:"#0f172a",fontFamily:"monospace"},C$={color:"#94a3b8"},Zu={flex:1,minWidth:0,color:"#475569",wordBreak:"break-all"},$$={fontSize:10,color:"#64748b",background:"#f1f5f9",borderRadius:4,padding:"0 4px"},Qu={margin:0,fontSize:11,color:"#94a3b8"},Ru={margin:0,fontSize:12,color:"#94a3b8"},E$=["meta","seo","init","overlay","computed","state","error","data"],I$=["401","403","404","500","503"],A$={meta:"layout_editor.page_settings.tab.meta",seo:"layout_editor.page_settings.tab.seo",init:"layout_editor.page_settings.tab.init",overlay:"layout_editor.page_settings.tab.overlay",computed:"layout_editor.page_settings.tab.computed",state:"layout_editor.page_settings.tab.state",error:"layout_editor.page_settings.tab.error",data:"layout_editor.page_settings.tab.data"};async function T$(e){if(typeof fetch!="function"||!e)return[];try{const t=await fetch(nn(`/api/admin/templates/${encodeURIComponent(e)}/editor/seo-candidates`,"json"),{credentials:"same-origin",headers:Me()});if(!t.ok)return[];const o=(await t.json().catch(()=>null))?.data?.extensions;if(!Array.isArray(o))return[];const r=[];for(const s of o)if(s&&typeof s=="object"){const a=s.type,l=s.id,d=s.label;typeof a=="string"&&typeof l=="string"&&l.length>0&&r.push({type:a,id:l,name:typeof d=="string"?d:l})}return r}catch{return[]}}function D$(e,t){let n=0;for(const o of e)Jn(o,t).kind==="advanced"&&(n+=1);return n}function z$(e,t){let n=0;for(const o of Object.keys(e))Ld(e[o],t).kind==="advanced"&&(n+=1);return n}function N$(e,t,n){const o=e("meta",{})??{},r=o.title;if(typeof r=="string"&&r.length>0){if(r.startsWith("$t:")){const a=n(r.slice(3));if(a&&a!==r.slice(3))return a}else if(!/\{\{[\s\S]*\}\}/.test(r))return r}const s=o.editor_label;return typeof s=="string"&&s.length>0?s.startsWith("$t:")?n(s.slice(3)):s:t||""}function M$({templateIdentifier:e,spec:t,t:n,resolveLabel:o,permissionCandidates:r,onClose:s,initialTab:a="meta",extensionsFetcher:l}){const{state:d}=Qe(),{raw:c,getValue:p,patch:f}=ov(),[b,g]=u.useState(a),m=d.selectedRoute?.path??"",h=u.useMemo(()=>Hd(d.routeTree,o),[d.routeTree,o]),v=u.useMemo(()=>Fd(c),[c]),y=u.useMemo(()=>Kd(t),[t]),_=u.useMemo(()=>wv(c,o),[c,o]),w=jd({raw:c,spec:t}),k=u.useMemo(()=>Cb(t),[t]),x=u.useMemo(()=>$b(t),[t]),$=u.useMemo(()=>Eb(t),[t]),C=u.useMemo(()=>Ib(t),[t]),S=u.useMemo(()=>$o(k),[k]),D=u.useMemo(()=>Ad(x),[x]),E=p("init_actions",void 0)??p("initActions",[]),I=p("computed",{}),N=p("__computedSource",{}),T=p("errorHandling",{}),B=p("transition_overlay",void 0),M=(p("__editor",{})??{}).original,O=u.useMemo(()=>{if(M===void 0)return;const G=M.transition_overlay;return G&&typeof G=="object"&&!Array.isArray(G)?G:{}},[M]),z=u.useMemo(()=>{const G=B;if(!G||typeof G!="object"||Array.isArray(G))return;const ee=O??{},fe={};for(const[K,te]of Object.entries(G))K in ee||(fe[K]=te);return Object.keys(fe).length>0?fe:void 0},[B,O]),[H,P]=u.useState([]);u.useEffect(()=>{let G=!1;const ee=l??T$;return(async()=>{const fe=await ee(e);G||P(fe)})(),()=>{G=!0}},[e,l]);const A=(p("meta",{})??{}).seo?.page_type,L=_v({raw:c,spec:t,pageType:typeof A=="string"?A:null}),F=u.useMemo(()=>vv(c,t),[c,t]),Y=u.useMemo(()=>({meta:0,seo:0,init:D$(E,S),overlay:0,computed:z$(I,D),state:0,error:0,data:0}),[E,S,I,D]),V=u.useMemo(()=>Object.values(Y).reduce((G,ee)=>G+ee,0),[Y]),X=u.useMemo(()=>xv(c,o,n),[c,o,n]),Z=u.useCallback(G=>{const fe={...M?.computed??{}};delete fe[G];const K={...I};delete K[G],f("computed",K,Object.keys(fe).length===0?void 0:fe)},[M,I,f]),ie=N$(p,m,n),oe=()=>{switch(b){case"meta":return i.jsx(jx,{getValue:p,patch:f,t:n,fieldT:o,spec:t,permissionCandidates:r,bindingCandidates:w});case"seo":return i.jsx($0,{getValue:p,patch:f,t:n,templateIdentifier:e,candidates:L,availableExtensions:H,dataSourceOptions:X,previewUrl:m||"/",seedContext:F});case"init":return i.jsx(qk,{actions:E,onChange:G=>f("init_actions",G),recipes:k,t:o,bindingCandidates:w,pageCandidates:h,dataSourceCandidates:v,stateKeyCandidates:y,modalCandidates:_});case"overlay":return i.jsx(h1,{value:B,ownValue:O,baseValue:z,patch:G=>f("transition_overlay",G),t:o,loadingComponents:C,progressiveDataSources:X,bindingCandidates:w});case"computed":return i.jsx(oS,{computed:I,onChange:G=>f("computed",G),recipes:x,t:o,sampleContext:F,dataSourceCandidates:v,bindingCandidates:w,computedSource:N,onRevert:Z});case"state":return i.jsx(BS,{raw:c,own:M?{initLocal:M.initLocal,initGlobal:M.initGlobal,initIsolated:M.initIsolated,state:M.state}:void 0,patch:f,t:n});case"error":return i.jsx(cC,{value:T,onChange:G=>f("errorHandling",G),t:o,errorConfigCodes:I$,templateCodes:Object.keys(T),ownCodes:Object.keys(M?.errorHandling??{}),recipes:$,pageCandidates:h,modalCandidates:_,dataSourceCandidates:v,stateKeyCandidates:y});case"data":return i.jsx(k$,{raw:c,t:n,resolveLabel:o,onChange:(G,ee)=>f("data_sources",G,ee),onClose:s,actionRecipes:k,errorRecipes:$,conditionSpec:t,bindingCandidates:w,pageCandidates:h,dataSourceCandidates:v,stateKeyCandidates:y});default:return i.jsx("div",{})}};return i.jsxs("div",{className:"g7le-page-settings","data-testid":"g7le-page-settings",style:L$,children:[i.jsxs("div",{style:P$,children:[i.jsx("span",{"data-testid":"g7le-page-settings-title",style:O$,children:n("layout_editor.page_settings.title",{name:ie})}),i.jsx("button",{type:"button","data-testid":"g7le-page-settings-close-x",onClick:s,"aria-label":n("layout_editor.page_settings.close"),style:B$,children:"✕"})]}),i.jsx("div",{role:"tablist",style:W$,children:E$.map(G=>{const ee=Y[G];return i.jsxs("button",{type:"button",role:"tab","aria-selected":b===G,"data-testid":`g7le-page-settings-tab-${G}`,"data-active":b===G?"true":"false",onClick:()=>g(G),style:b===G?j$:ep,children:[n(A$[G]),ee>0?i.jsxs("span",{"data-testid":`g7le-page-settings-tab-badge-${G}`,style:H$,children:["(",ee,")"]}):null]},G)})}),V>0?i.jsxs("p",{"data-testid":"g7le-page-settings-advanced-summary",style:F$,children:["⚠ ",n("layout_editor.page_settings.advanced_summary",{count:V})," ⓘ"]}):null,i.jsx("div",{"data-testid":"g7le-page-settings-panel",style:K$,children:oe()}),i.jsx("div",{style:V$,children:i.jsx("button",{type:"button","data-testid":"g7le-page-settings-close",onClick:s,style:U$,children:n("layout_editor.page_settings.close")})})]})}const L$={display:"flex",flexDirection:"column",minWidth:0,maxWidth:"100%",padding:"20px 24px",boxSizing:"border-box",flex:1,minHeight:0,maxHeight:"100%",overflow:"hidden",fontFamily:"system-ui, -apple-system, sans-serif"},P$={display:"flex",alignItems:"center",gap:8,paddingBottom:8,borderBottom:"1px solid #e2e8f0"},O$={flex:1,fontSize:15,fontWeight:700,color:"#0f172a",minWidth:0},B$={border:"none",background:"transparent",color:"#64748b",cursor:"pointer",fontSize:16,lineHeight:1,padding:4},W$={display:"flex",gap:2,paddingTop:8,borderBottom:"1px solid #e2e8f0",flexWrap:"nowrap",overflowX:"auto",overflowY:"hidden",flexShrink:0,minWidth:0},ep={border:"none",borderBottomWidth:"2px",borderBottomStyle:"solid",borderBottomColor:"transparent",background:"transparent",color:"#64748b",cursor:"pointer",fontSize:12,padding:"6px 10px",whiteSpace:"nowrap"},j$={...ep,color:"#2563eb",borderBottomColor:"#2563eb",fontWeight:600},H$={marginLeft:4,fontSize:10,color:"#b45309"},F$={margin:0,marginTop:8,fontSize:11,color:"#b45309",background:"#fffbeb",padding:"6px 8px",borderRadius:6},K$={flex:1,overflowY:"auto",paddingTop:12,minWidth:0,minHeight:0},V$={display:"flex",justifyContent:"flex-end",paddingTop:8,borderTop:"1px solid #e2e8f0"},U$={border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",fontSize:13,padding:"6px 16px"};function oa(e,t){const n=`/api/admin/templates/${encodeURIComponent(e)}`;return t.kind==="layout"?`${n}/layouts/${t.layoutName}/versions`:`${n}/layout-extensions/${encodeURIComponent(t.extensionId)}/versions`}const tp=100,np=500;function q$(e,t,n){const[o,r]=u.useState([]),[s,a]=u.useState(!1),[l,d]=u.useState(!1),[c,p]=u.useState(null),[f,b]=u.useState(null),[g,m]=u.useState(tp),[h,v]=u.useState(!1),y=u.useCallback(async($,C)=>{if(!t){r([]),p(null),v(!1);return}C==="more"?d(!0):a(!0),p(null);try{const S=`${oa(e,t)}?limit=${$}`,D=await fetch(S,{credentials:"same-origin",headers:Me()}),E=await D.json().catch(()=>null);if(!D.ok){p(E?.message??`HTTP ${D.status}`),C==="reload"&&r([]);return}const I=E?.data,N=Array.isArray(I)?I:[];r(N),v(N.length>=$&&${await y(g,"reload")},[y,g]),w=u.useCallback(async()=>{const $=Math.min(g+tp,np);if($<=g){v(!1);return}await y($,"more")},[y,g]),k=u.useCallback(async $=>{if(!t)return{kind:"not_found"};b($);try{const C=`${oa(e,t)}/${$}/restore`,S=await fetch(C,{method:"POST",credentials:"same-origin",headers:Me({"Content-Type":"application/json"})}),D=await S.json().catch(()=>null);if(S.status===404)return{kind:"not_found"};if(!S.ok)return{kind:"network_error",message:D?.message??`HTTP ${S.status}`};const E=typeof D?.data?.version=="number"?D.data.version:-1;return await n?.(E>=0?E:void 0),{kind:"success",newVersion:E}}catch(C){return{kind:"network_error",message:C instanceof Error?C.message:"network error"}}finally{b(null)}},[e,t,n]),x=u.useCallback(async $=>{if(!t)return{kind:"not_found"};try{const C=`${oa(e,t)}/${$}`,S=await fetch(C,{credentials:"same-origin",headers:Me()}),D=await S.json().catch(()=>null);if(S.status===404)return{kind:"not_found"};if(!S.ok)return{kind:"network_error",message:D?.message??`HTTP ${S.status}`};const E=D?.data;if(!E)return{kind:"not_found"};if(t.kind==="extension"&&!E.full_content){const I=E.content;if(typeof I=="string")try{const N=JSON.parse(I);N&&typeof N=="object"&&(E.full_content=N)}catch{}}return{kind:"success",detail:E}}catch(C){return{kind:"network_error",message:C instanceof Error?C.message:"network error"}}},[e,t]);return{versions:o,isLoading:s,isLoadingMore:l,error:c,restoringId:f,hasMore:h,loadVersions:_,loadMore:w,restore:k,loadVersionDetail:x}}function G$(e,t){const n=e.length,o=t.length,r=Array.from({length:n+1},()=>new Array(o+1).fill(0));for(let s=n-1;s>=0;s--)for(let a=o-1;a>=0;a--)e[s]===t[a]?r[s][a]=r[s+1][a+1]+1:r[s][a]=Math.max(r[s+1][a],r[s][a+1]);return r}function Y$(e,t,n){const o=[];let r=0,s=0;const a=e.length,l=t.length;for(;r=n[r][s+1]?(o.push({kind:"remove",oldIndex:r,content:e[r]}),r++):(o.push({kind:"add",newIndex:s,content:t[s]}),s++);for(;r0&&t[t.length-1]===""&&t.pop(),t}const Qu=4e3;function N$(e,t,n=3){const o=Zu(e),r=Zu(t);let s=0;const a=Math.min(o.length,r.length);for(;sQu||p.length>Qu)return{hunks:[],addedCount:-1,removedCount:-1,identical:!1};const f=D$(c,p),b=z$(c,p,f),g=[];let m=s,h=s,v=0,y=0;for(let k=0;k{const s=e.slice(r.start,r.end+1);let a=0,l=0,d=0,c=0;for(const g of s)g.oldLine!==null&&(a===0&&(a=g.oldLine),d++),g.newLine!==null&&(l===0&&(l=g.newLine),c++);const p=a||(d===0?0:1),f=l||(c===0?0:1);return{header:`@@ -${p},${d} +${f},${c} @@`,oldStart:p,oldCount:d,newStart:f,newCount:c,lines:s}})}function Ru(e){return JSON.stringify(Rs(e),null,2)}function Rs(e){if(Array.isArray(e))return e.map(Rs);if(e&&typeof e=="object"){const t=e,n={};for(const o of Object.keys(t).sort())n[o]=Rs(t[o]);return n}return e}const L$={display:"flex",flexDirection:"column",height:"100%",minHeight:0},P$={display:"flex",alignItems:"center",gap:8,padding:"12px 16px",borderBottom:"1px solid #e2e8f0",background:"#f8fafc"},O$={display:"inline-flex",alignItems:"center",gap:4,padding:"4px 10px",borderRadius:6,border:"1px solid #cbd5e1",background:"#ffffff",color:"#0f172a",fontSize:12,fontWeight:600,cursor:"pointer",outline:"none"},B$={marginLeft:"auto",border:"none",background:"transparent",fontSize:16,color:"#64748b",cursor:"pointer",outline:"none"},W$={display:"flex",alignItems:"center",gap:12,padding:"8px 16px",borderBottom:"1px solid #e2e8f0",background:"#ffffff",fontSize:12,fontWeight:600},j$={flex:1,minHeight:0,overflow:"auto",background:"#ffffff",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace',fontSize:12,lineHeight:1.5},ep={padding:"24px 12px",textAlign:"center",color:"#94a3b8",fontSize:13},H$={padding:"2px 12px",background:"#f1f5f9",color:"#64748b",borderTop:"1px solid #e2e8f0",borderBottom:"1px solid #e2e8f0",userSelect:"none"};function F$(e){return e==="add"?{row:{background:"#e6ffed"},gutter:{background:"#cdffd8",color:"#22863a"},sign:"+",signColor:"#22863a"}:e==="remove"?{row:{background:"#ffeef0"},gutter:{background:"#ffdce0",color:"#b31d28"},sign:"-",signColor:"#b31d28"}:{row:{background:"#ffffff"},gutter:{background:"#f8fafc",color:"#94a3b8"},sign:" ",signColor:"#94a3b8"}}const tp={display:"inline-block",width:44,textAlign:"right",padding:"0 6px",color:"#94a3b8",userSelect:"none",borderRight:"1px solid #e2e8f0",whiteSpace:"nowrap"};function K$({oldVersion:e,newVersion:t,oldContent:n,newContent:o,t:r,onBack:s,onClose:a}){const l=u.useMemo(()=>{const c=Ru(n),p=Ru(o);return N$(c,p)},[n,o]),d=l.addedCount<0;return i.jsxs("div",{className:"g7le-version-diff","data-testid":"g7le-version-diff",style:L$,children:[i.jsxs("div",{"data-modal-drag-handle":!0,style:P$,children:[i.jsxs("button",{type:"button",onClick:s,style:O$,"data-testid":"g7le-version-diff-back",children:["← ",r("layout_editor.version_history.diff_back")]}),i.jsx("span",{style:{fontSize:14,fontWeight:700},"data-testid":"g7le-version-diff-title",children:r("layout_editor.version_history.diff_title",{old:e,new:t})}),i.jsx("button",{type:"button","aria-label":r("layout_editor.version_history.close"),onClick:a,style:B$,"data-testid":"g7le-version-diff-close",children:"✕"})]}),!d&&i.jsxs("div",{style:W$,"data-testid":"g7le-version-diff-summary",children:[i.jsx("span",{style:{color:"#16a34a"},"data-testid":"g7le-version-diff-added",children:r("layout_editor.version_history.added",{count:Math.max(0,l.addedCount)})}),i.jsx("span",{style:{color:"#dc2626"},"data-testid":"g7le-version-diff-removed",children:r("layout_editor.version_history.removed",{count:Math.max(0,l.removedCount)})})]}),i.jsx("div",{style:j$,children:d?i.jsx("div",{style:ep,"data-testid":"g7le-version-diff-too-large",children:r("layout_editor.version_history.diff_too_large")}):l.identical?i.jsx("div",{style:ep,"data-testid":"g7le-version-diff-identical",children:r("layout_editor.version_history.diff_identical")}):l.hunks.map((c,p)=>i.jsxs("div",{"data-testid":`g7le-version-diff-hunk-${p}`,children:[i.jsx("div",{style:H$,"data-testid":`g7le-version-diff-hunk-header-${p}`,children:c.header}),c.lines.map((f,b)=>{const g=F$(f.kind);return i.jsxs("div",{style:{display:"flex",alignItems:"stretch",...g.row},"data-kind":f.kind,"data-testid":`g7le-version-diff-line-${p}-${b}`,children:[i.jsx("span",{style:{...tp,...g.gutter},"aria-hidden":"true",children:f.oldLine??""}),i.jsx("span",{style:{...tp,...g.gutter},"aria-hidden":"true",children:f.newLine??""}),i.jsx("span",{style:{display:"inline-block",width:16,textAlign:"center",color:g.signColor,userSelect:"none",fontWeight:700},"aria-hidden":"true",children:g.sign}),i.jsx("span",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",flex:1,padding:"0 4px"},children:f.content})]},b)})]},p))})]})}const V$={display:"flex",flexDirection:"column",height:"100%",minHeight:0},U$={display:"flex",alignItems:"center",gap:8,padding:"12px 16px",borderBottom:"1px solid #e2e8f0",background:"#f8fafc"},q$={marginLeft:"auto",border:"none",background:"transparent",fontSize:16,color:"#64748b",cursor:"pointer",outline:"none"},G$={flex:1,minHeight:0,overflowY:"auto",padding:12},np={padding:"24px 12px",textAlign:"center",color:"#94a3b8",fontSize:13},Y$={margin:"8px 16px 0",padding:"8px 12px",borderRadius:6,background:"#fef2f2",color:"#b91c1c",fontSize:12,border:"1px solid #fecaca"},X$={display:"flex",flexDirection:"column",gap:8},J$={display:"flex",alignItems:"center",gap:12,padding:"10px 12px",borderRadius:8,border:"1px solid #e2e8f0",background:"#ffffff"},Z$={display:"inline-flex",alignItems:"center",justifyContent:"center",minWidth:44,padding:"2px 8px",borderRadius:999,background:"#eff6ff",color:"#1d4ed8",fontSize:12,fontWeight:700},Q$={display:"inline-flex",alignItems:"center",padding:"1px 8px",borderRadius:999,background:"#0f172a",color:"#ffffff",fontSize:10,fontWeight:700,letterSpacing:.3},R$={display:"flex",alignItems:"center",gap:10,fontSize:11,fontWeight:600},eE={display:"flex",flexDirection:"column",gap:2,minWidth:0,flex:1},op={padding:"6px 12px",borderRadius:6,border:"1px solid #cbd5e1",background:"#ffffff",color:"#0f172a",fontSize:12,fontWeight:600,cursor:"pointer",outline:"none",whiteSpace:"nowrap"};function rp(e){return e.full_content&&typeof e.full_content=="object"?e.full_content:{endpoint:e.endpoint,components:e.components,data_sources:e.data_sources,metadata:e.metadata}}function tE(e){if(!e)return"";const t=Date.parse(e);if(Number.isNaN(t))return e;try{return new Date(t).toLocaleString()}catch{return e}}function nE({templateIdentifier:e,target:t,t:n,onRestored:o,onClose:r}){const{versions:s,isLoading:a,isLoadingMore:l,error:d,restoringId:c,hasMore:p,loadVersions:f,loadMore:b,restore:g,loadVersionDetail:m}=T$(e,t,o),[h,v]=u.useState(null),[y,_]=u.useState(null),[w,k]=u.useState(null);u.useEffect(()=>{f()},[f]);const x=u.useCallback(async C=>{v(null),k(C.version);try{const T=await m(C.version);if(T.kind!=="success"){v(T.kind==="not_found"?n("layout_editor.version_history.restore_not_found"):T.message);return}const E=C.version-1,A=s.some(D=>D.version===E);let N={};if(A){const D=await m(E);if(D.kind==="success")N=rp(D.detail);else if(D.kind==="network_error"){v(D.message);return}}_({oldVersion:A?E:0,newVersion:C.version,oldContent:N,newContent:rp(T.detail)})}finally{k(null)}},[m,s,n]),$=u.useCallback(async C=>{v(null);const T=n("layout_editor.version_history.restore_confirm");if(!(typeof window<"u"?window.confirm(T):!0))return;const A=await g(C);A.kind==="success"?r():A.kind==="not_found"?v(n("layout_editor.version_history.restore_not_found")):v(A.message)},[g,r,n]),S=h??d;return y?i.jsx(K$,{oldVersion:y.oldVersion,newVersion:y.newVersion,oldContent:y.oldContent,newContent:y.newContent,t:n,onBack:()=>_(null),onClose:r}):i.jsxs("div",{className:"g7le-version-history","data-testid":"g7le-version-history",style:V$,children:[i.jsxs("div",{"data-modal-drag-handle":!0,style:U$,children:[i.jsxs("span",{style:{fontSize:14,fontWeight:700},"data-testid":"g7le-version-history-title",children:["🕘 ",n("layout_editor.version_history.title")]}),i.jsx("button",{type:"button","aria-label":n("layout_editor.version_history.close"),onClick:r,style:q$,"data-testid":"g7le-version-history-close",children:"✕"})]}),S&&i.jsx("div",{style:Y$,"data-testid":"g7le-version-history-error",children:S}),i.jsx("div",{style:G$,children:a?i.jsx("div",{style:np,"data-testid":"g7le-version-history-loading",children:n("layout_editor.version_history.loading")}):s.length===0?i.jsx("div",{style:np,"data-testid":"g7le-version-history-empty",children:n("layout_editor.version_history.empty")}):i.jsxs("div",{"data-testid":"g7le-version-history-list",style:X$,children:[s.map((C,T)=>{const E=C.changes_summary,A=E?.added_count??0,N=E?.removed_count??0,D=E?.char_diff??0,B=tE(C.created_at),M=c===C.id,O=T===0;return i.jsxs("div",{style:J$,"data-testid":`g7le-version-row-${C.id}`,children:[i.jsxs("span",{style:Z$,"data-testid":`g7le-version-badge-${C.id}`,children:["v",C.version]}),i.jsxs("div",{style:eE,children:[i.jsxs("span",{style:{display:"flex",alignItems:"center",gap:8},children:[B&&i.jsx("span",{style:{fontSize:12,color:"#475569",fontWeight:600},children:B}),O&&i.jsx("span",{style:Q$,"data-testid":`g7le-version-latest-${C.id}`,children:n("layout_editor.version_history.latest")})]}),i.jsxs("span",{style:R$,"data-testid":`g7le-version-summary-${C.id}`,children:[i.jsx("span",{style:{color:"#16a34a"},"data-testid":`g7le-version-added-${C.id}`,children:n("layout_editor.version_history.added",{count:A})}),i.jsx("span",{style:{color:"#dc2626"},"data-testid":`g7le-version-removed-${C.id}`,children:n("layout_editor.version_history.removed",{count:N})}),i.jsx("span",{style:{color:"#94a3b8",fontWeight:500},"data-testid":`g7le-version-chars-${C.id}`,children:n("layout_editor.version_history.chars",{diff:`${D>=0?"+":""}${D}`})})]}),i.jsx("span",{style:{fontSize:11,color:"#94a3b8"},"data-testid":`g7le-version-author-${C.id}`,children:n("layout_editor.version_history.saved_by",{name:C.created_by_name??n("layout_editor.version_history.unknown_author")})})]}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[i.jsx("button",{type:"button",onClick:()=>void x(C),disabled:w!==null,style:{...op,background:"#f8fafc",opacity:w!==null?.6:1},"data-testid":`g7le-version-compare-${C.id}`,children:w===C.version?n("layout_editor.version_history.comparing"):n("layout_editor.version_history.compare")}),!O&&i.jsx("button",{type:"button",onClick:()=>void $(C.id),disabled:M||c!==null,style:{...op,opacity:M||c!==null?.6:1},"data-testid":`g7le-version-restore-${C.id}`,children:n(M?"layout_editor.version_history.restoring":"layout_editor.version_history.restore")})]})]},C.id)}),p&&i.jsx("button",{type:"button","data-testid":"g7le-version-history-load-more",style:oE,disabled:l,onClick:()=>{b()},children:n(l?"layout_editor.version_history.loading":"layout_editor.version_history.load_more")})]})})]})}const oE={width:"100%",marginTop:8,padding:"8px 12px",fontSize:12,color:"#475569",background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:6,cursor:"pointer"};function Po(e){return`/api/admin/extensions/${encodeURIComponent(e.type)}/${encodeURIComponent(e.identifier)}/custom-assets`}function Oo(e,t){const n=e?.message;return typeof n=="string"&&n!==""?n:`HTTP ${t}`}function rE(e){const[t,n]=u.useState([]),[o,r]=u.useState(null),[s,a]=u.useState(!1),[l,d]=u.useState(!1),[c,p]=u.useState(null),f=u.useCallback(async()=>{a(!0),p(null);try{const v=await fetch(Po(e),{credentials:"same-origin",headers:Ne()}),y=await v.json().catch(()=>null);if(v.status===401||v.status===403){d(!0),n([]);return}if(d(!1),!v.ok){p(Oo(y,v.status)),n([]);return}const _=y?.data??{},w=_.files;n(Array.isArray(w)?w:[]),r({editable_extensions:_.editable_extensions??[],uploadable_extensions:_.uploadable_extensions??[],max_text_bytes:_.max_text_bytes??0,max_upload_bytes:_.max_upload_bytes??0})}catch(v){p(v instanceof Error?v.message:"network error"),n([])}finally{a(!1)}},[e.type,e.identifier]),b=u.useCallback(async v=>{p(null);try{const y=`${Po(e)}/content?path=${encodeURIComponent(v)}`,_=await fetch(y,{credentials:"same-origin",headers:Ne()}),w=await _.json().catch(()=>null);if(!_.ok)return p(Oo(w,_.status)),null;const k=w?.data?.content;return typeof k=="string"?k:""}catch(y){return p(y instanceof Error?y.message:"network error"),null}},[e.type,e.identifier]),g=u.useCallback(async(v,y)=>{p(null);try{const _=await fetch(`${Po(e)}/content`,{method:"PUT",credentials:"same-origin",headers:Ne({"Content-Type":"application/json"}),body:JSON.stringify({path:v,content:y})}),w=await _.json().catch(()=>null);return _.ok?(await f(),!0):(p(Oo(w,_.status)),!1)}catch(_){return p(_ instanceof Error?_.message:"network error"),!1}},[e.type,e.identifier,f]),m=u.useCallback(async(v,y)=>{p(null);try{const _=new FormData;_.append("file",v),y&&_.append("directory",y);const w=await fetch(`${Po(e)}/upload`,{method:"POST",credentials:"same-origin",headers:Ne(),body:_}),k=await w.json().catch(()=>null);return w.ok?(await f(),!0):(p(Oo(k,w.status)),!1)}catch(_){return p(_ instanceof Error?_.message:"network error"),!1}},[e.type,e.identifier,f]),h=u.useCallback(async v=>{p(null);try{const y=`${Po(e)}?path=${encodeURIComponent(v)}`,_=await fetch(y,{method:"DELETE",credentials:"same-origin",headers:Ne()}),w=await _.json().catch(()=>null);return _.ok?(await f(),!0):(p(Oo(w,_.status)),!1)}catch(y){return p(y instanceof Error?y.message:"network error"),!1}},[e.type,e.identifier,f]);return{files:t,meta:o,isLoading:s,forbidden:l,error:c,reload:f,read:b,save:g,upload:m,remove:h}}const iE={display:"flex",flexDirection:"column",height:"100%",minHeight:0},sE={display:"flex",alignItems:"center",gap:8,padding:"12px 16px",borderBottom:"1px solid #e2e8f0",background:"#f8fafc",fontWeight:600,color:"#0f172a"},aE={marginLeft:"auto",border:"none",background:"transparent",fontSize:16,color:"#64748b",cursor:"pointer",outline:"none"},lE={flex:1,minHeight:0,display:"flex"},dE={width:260,flexShrink:0,borderRight:"1px solid #e2e8f0",overflowY:"auto",padding:8},cE={flex:1,minWidth:0,display:"flex",flexDirection:"column",padding:12,gap:8},ip={display:"flex",alignItems:"center",gap:6,width:"100%",padding:"6px 8px",borderRadius:6,borderWidth:1,borderStyle:"solid",borderColor:"transparent",backgroundColor:"transparent",fontSize:12,color:"#334155",cursor:"pointer",textAlign:"left"},uE={...ip,backgroundColor:"#eff6ff",borderColor:"#bfdbfe",color:"#1d4ed8",fontWeight:600},pE={margin:16,padding:16,borderRadius:8,border:"1px solid #fcd34d",background:"#fffbeb",color:"#92400e",fontSize:13,lineHeight:1.7},fE={padding:"8px 12px",borderRadius:6,border:"1px solid #fecaca",background:"#fef2f2",color:"#b91c1c",fontSize:12},gE={flex:1,minHeight:220,width:"100%",boxSizing:"border-box",padding:10,borderRadius:6,borderWidth:1,borderStyle:"solid",borderColor:"#cbd5e1",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:12,lineHeight:1.6,resize:"vertical"},sp={display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},io={padding:"6px 12px",borderRadius:6,borderWidth:1,borderStyle:"solid",borderColor:"#cbd5e1",backgroundColor:"#ffffff",color:"#334155",fontSize:12,cursor:"pointer"},hE={...io,backgroundColor:"#2563eb",borderColor:"#2563eb",color:"#ffffff",fontWeight:600},yE={...io,borderColor:"#fca5a5",color:"#b91c1c"},bE={...io,cursor:"text",minWidth:200},mE={...io,cursor:"pointer",minWidth:220};function vE(e,t){if(typeof e=="string"&&e!=="")return e;if(e&&typeof e=="object"){const n=e,o=window?.G7Config?.locale??"ko",r=n[o]??n.ko??n.en??Object.values(n)[0];if(typeof r=="string"&&r!=="")return r}return t}function _E(e){const t=(typeof window<"u"?window.G7Config:null)??{},n=[{type:"template",identifier:e,label:e}];for(const[o,r]of[["module",t.activeModules],["plugin",t.activePlugins]])if(Array.isArray(r))for(const s of r){const a=typeof s?.identifier=="string"?s.identifier:"";a&&n.push({type:o,identifier:a,label:vE(s?.display_name,a)})}return n}function xE(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function wE(e){const{templateIdentifier:t,t:n,onClose:o}=e,r=u.useMemo(()=>_E(t),[t]),[s,a]=u.useState(`template:${t}`),l=u.useMemo(()=>r.find(S=>`${S.type}:${S.identifier}`===s)??r[0],[r,s]),d=rE({type:l.type,identifier:l.identifier}),{reload:c}=d,[p,f]=u.useState(null),[b,g]=u.useState(""),[m,h]=u.useState(""),[v,y]=u.useState(!1),_=u.useRef(null);u.useEffect(()=>{c()},[c]),u.useEffect(()=>{f(null),g(""),h("")},[s]);const w=u.useCallback(async S=>{if(f(S),!S.editable){g("");return}y(!0);const C=await d.read(S.path);y(!1),g(C??"")},[d]),k=u.useCallback(async()=>{const S=p?.path??m.trim();if(!S)return;y(!0);const C=await d.save(S,b);y(!1),C&&!p&&(h(""),f({path:S,name:S.split("/").pop()??S,extension:(S.split(".").pop()??"").toLowerCase(),size:b.length,modified_at:new Date().toISOString(),editable:!0,loaded:!0}))},[d,p,m,b]),x=u.useCallback(async()=>{if(!p||typeof window<"u"&&!window.confirm(n("layout_editor.custom_assets.delete_confirm")))return;y(!0);const S=await d.remove(p.path);y(!1),S&&(f(null),g(""))},[d,p,n]),$=u.useCallback(async S=>{const C=S.target.files?.[0];C&&(y(!0),await d.upload(C),y(!1),_.current&&(_.current.value=""))},[d]);return i.jsxs("div",{className:"g7le-custom-assets",style:iE,"data-testid":"g7le-custom-assets-modal",children:[i.jsxs("div",{style:sE,children:[i.jsxs("span",{children:["🎨 ",n("layout_editor.custom_assets.title")]}),i.jsx("select",{value:s,onChange:S=>a(S.target.value),style:mE,"aria-label":n("layout_editor.custom_assets.target_label"),"data-testid":"g7le-custom-assets-target",children:r.map(S=>i.jsxs("option",{value:`${S.type}:${S.identifier}`,children:[n(`layout_editor.custom_assets.type_${S.type}`)," · ",S.label]},`${S.type}:${S.identifier}`))}),i.jsx("button",{type:"button",style:aE,onClick:o,"aria-label":n("layout_editor.custom_assets.close"),"data-testid":"g7le-custom-assets-close",children:"✕"})]}),d.forbidden?i.jsx("div",{style:pE,"data-testid":"g7le-custom-assets-forbidden",children:n("layout_editor.custom_assets.forbidden")}):i.jsxs("div",{style:lE,children:[i.jsxs("div",{style:dE,"data-testid":"g7le-custom-assets-list",children:[d.isLoading&&d.files.length===0?i.jsx("div",{style:{padding:12,color:"#94a3b8",fontSize:12},children:n("layout_editor.custom_assets.loading")}):null,!d.isLoading&&d.files.length===0?i.jsx("div",{style:{padding:12,color:"#94a3b8",fontSize:12},children:n("layout_editor.custom_assets.empty")}):null,d.files.map(S=>i.jsxs("button",{type:"button",style:p?.path===S.path?uE:ip,onClick:()=>void w(S),"data-testid":`g7le-custom-asset-row-${S.path}`,"data-loaded":S.loaded?"true":"false",children:[i.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:S.path}),i.jsx("span",{style:{color:"#94a3b8",fontSize:11},children:xE(S.size)})]},S.path))]}),i.jsxs("div",{style:cE,children:[d.error?i.jsx("div",{style:fE,"data-testid":"g7le-custom-assets-error",children:d.error}):null,i.jsxs("div",{style:sp,children:[i.jsx("input",{type:"text",value:p?p.path:m,readOnly:!!p,onChange:S=>h(S.target.value),placeholder:n("layout_editor.custom_assets.new_path_placeholder"),style:bE,"aria-label":n("layout_editor.custom_assets.path_label"),"data-testid":"g7le-custom-assets-path"}),p?i.jsx("button",{type:"button",style:io,onClick:()=>{f(null),g("")},"data-testid":"g7le-custom-assets-new",children:n("layout_editor.custom_assets.new_file")}):null]}),p&&!p.editable?i.jsx("div",{style:{color:"#64748b",fontSize:12,lineHeight:1.7},children:n("layout_editor.custom_assets.binary_hint",{extension:p.extension})}):i.jsx("textarea",{value:b,onChange:S=>g(S.target.value),style:gE,spellCheck:!1,"aria-label":n("layout_editor.custom_assets.content_label"),"data-testid":"g7le-custom-assets-content"}),i.jsxs("div",{style:sp,children:[i.jsx("button",{type:"button",style:hE,disabled:v||(p?!p.editable:m.trim()===""),onClick:()=>void k(),"data-testid":"g7le-custom-assets-save",children:n("layout_editor.custom_assets.save")}),i.jsx("button",{type:"button",style:io,disabled:v,onClick:()=>_.current?.click(),"data-testid":"g7le-custom-assets-upload",children:n("layout_editor.custom_assets.upload")}),i.jsx("input",{ref:_,type:"file",style:{display:"none"},onChange:S=>void $(S),"data-testid":"g7le-custom-assets-file-input"}),i.jsx("button",{type:"button",style:yE,disabled:v||!p,onClick:()=>void x(),"data-testid":"g7le-custom-assets-delete",children:n("layout_editor.custom_assets.delete")}),i.jsx("span",{style:{color:"#94a3b8",fontSize:11},children:n("layout_editor.custom_assets.apply_hint")})]})]})]})]})}const ap=[{id:"copy",group:"clipboard",combos:[{key:"c",mod:!0}],labelKey:"layout_editor.shortcuts.action.copy",requiresSelection:!0},{id:"cut",group:"clipboard",combos:[{key:"x",mod:!0}],labelKey:"layout_editor.shortcuts.action.cut",requiresSelection:!0},{id:"paste",group:"clipboard",combos:[{key:"v",mod:!0}],labelKey:"layout_editor.shortcuts.action.paste"},{id:"openProps",group:"element",combos:[{key:"enter"}],labelKey:"layout_editor.shortcuts.action.open_props",requiresSelection:!0},{id:"delete",group:"element",combos:[{key:"delete"},{key:"backspace"}],labelKey:"layout_editor.shortcuts.action.delete",requiresSelection:!0},{id:"selectParent",group:"element",combos:[{key:"arrowup"}],labelKey:"layout_editor.shortcuts.action.select_parent",requiresSelection:!0},{id:"deselect",group:"element",combos:[{key:"escape"}],labelKey:"layout_editor.shortcuts.action.deselect"},{id:"addElement",group:"element",combos:[{key:"/",mod:!0}],labelKey:"layout_editor.shortcuts.action.add_element"},{id:"undo",group:"history",combos:[{key:"z",mod:!0}],labelKey:"layout_editor.shortcuts.action.undo"},{id:"redo",group:"history",combos:[{key:"z",mod:!0,shift:!0},{key:"y",mod:!0}],labelKey:"layout_editor.shortcuts.action.redo"},{id:"editCode",group:"view",combos:[{key:"e",mod:!0}],labelKey:"layout_editor.shortcuts.action.edit_code"},{id:"preview",group:"view",combos:[{key:"p",mod:!0}],labelKey:"layout_editor.shortcuts.action.preview"},{id:"translations",group:"view",combos:[{key:"l",mod:!0}],labelKey:"layout_editor.shortcuts.action.translations"},{id:"help",group:"view",combos:[{key:"?"}],labelKey:"layout_editor.shortcuts.action.help"},{id:"reset",group:"document",combos:[{key:"r",mod:!0,shift:!0}],labelKey:"layout_editor.shortcuts.action.reset"},{id:"save",group:"document",combos:[{key:"s",mod:!0}],labelKey:"layout_editor.shortcuts.action.save"},{id:"exit",group:"document",combos:[{key:"escape"}],labelKey:"layout_editor.shortcuts.action.exit"}];function kE(e){return{key:(e.key||"").toLowerCase(),mod:e.ctrlKey||e.metaKey,shift:e.shiftKey,alt:e.altKey}}function SE(e,t){return e.key===t.key&&!!e.mod==!!t.mod&&!!e.shift==!!t.shift&&!!e.alt==!!t.alt}function CE(e){for(const t of ap)if(t.combos.some(n=>SE(n,e)))return t;return null}function $E(e,t){const n=[];return e.mod&&n.push(t?"⌘":"Ctrl"),e.shift&&n.push(t?"⇧":"Shift"),e.alt&&n.push(t?"⌥":"Alt"),n.push(EE(e.key)),n.join(" + ")}function EE(e){return{arrowup:"↑",arrowdown:"↓",arrowleft:"←",arrowright:"→",enter:"Enter",escape:"Esc",delete:"Delete",backspace:"Backspace"," ":"Space"}[e]??(e.length===1?e.toUpperCase():e)}const IE=["clipboard","element","history","view","document"],AE={clipboard:"layout_editor.shortcuts.group.clipboard",element:"layout_editor.shortcuts.group.element",history:"layout_editor.shortcuts.group.history",view:"layout_editor.shortcuts.group.view",document:"layout_editor.shortcuts.group.document"};function TE(){return typeof navigator>"u"?!1:/mac|iphone|ipad|ipod/i.test(navigator.platform||navigator.userAgent||"")}function DE({t:e,onClose:t,isMac:n}){const o=n??TE(),r=u.useMemo(()=>{const s=new Map;for(const a of ap){const l=s.get(a.group)??[];l.push(a),s.set(a.group,l)}return s},[]);return i.jsxs("div",{className:"g7le-shortcut-help","data-testid":"g7le-shortcut-help",style:zE,children:[i.jsxs("div",{style:NE,children:[i.jsx("span",{style:ME,children:e("layout_editor.shortcuts.title")}),i.jsx("button",{type:"button","data-testid":"g7le-shortcut-help-close",onClick:t,"aria-label":e("layout_editor.shortcuts.close"),style:LE,children:"✕"})]}),i.jsx("div",{style:PE,children:IE.map(s=>{const a=r.get(s);return!a||a.length===0?null:i.jsxs("div",{style:OE,"data-testid":`g7le-shortcut-group-${s}`,children:[i.jsx("div",{style:BE,children:e(AE[s])}),i.jsx("table",{style:WE,children:i.jsx("tbody",{children:a.map(l=>i.jsxs("tr",{"data-testid":`g7le-shortcut-row-${l.id}`,children:[i.jsx("td",{style:jE,children:e(l.labelKey)}),i.jsx("td",{style:HE,children:l.combos.map((d,c)=>i.jsxs(u.Fragment,{children:[c>0&&i.jsx("span",{style:KE,children:e("layout_editor.shortcuts.or")}),i.jsx("kbd",{style:FE,children:$E(d,o)})]},c))})]},l.id))})})]},s)})}),i.jsx("div",{style:VE,children:e("layout_editor.shortcuts.footnote")})]})}const zE={display:"flex",flexDirection:"column",padding:20,gap:16,width:"100%",boxSizing:"border-box"},NE={display:"flex",alignItems:"center",justifyContent:"space-between",paddingBottom:12,borderBottom:"1px solid #e2e8f0"},ME={fontSize:15,fontWeight:700,color:"#0f172a"},LE={width:28,height:28,border:"none",background:"transparent",color:"#64748b",cursor:"pointer",fontSize:14,borderRadius:6},PE={display:"grid",gridTemplateColumns:"1fr 1fr",columnGap:28,rowGap:18,alignItems:"start"},OE={display:"flex",flexDirection:"column",gap:6},BE={fontSize:12,fontWeight:700,color:"#2563eb"},WE={width:"100%",borderCollapse:"collapse"},jE={padding:"4px 0",fontSize:12.5,color:"#334155",textAlign:"left",whiteSpace:"nowrap",verticalAlign:"middle"},HE={padding:"4px 0",paddingLeft:12,textAlign:"right",verticalAlign:"middle"},FE={display:"inline-block",padding:"1px 6px",fontSize:11,fontFamily:"ui-monospace, monospace",color:"#0f172a",background:"#f1f5f9",border:"1px solid #cbd5e1",borderBottomWidth:2,borderRadius:5,whiteSpace:"nowrap"},KE={fontSize:11,color:"#94a3b8",margin:"0 4px"},VE={fontSize:11,color:"#94a3b8",paddingTop:12,borderTop:"1px solid #f1f5f9"};function UE(e){if(!e||!(e instanceof HTMLElement))return!1;const t=e.tagName;return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable)}function qE(){return typeof document>"u"?!1:!!document.querySelector(".g7le-modal-backdrop, .g7le-modal")}function lp(e){const{handlers:t,hasSelection:n,enabled:o=!0}=e;u.useEffect(()=>{if(!o||typeof window>"u")return;const r=s=>{if(UE(s.target))return;const a=kE(s),l=CE(a);if(!l||qE()||l.requiresSelection&&!n)return;if(l.key==="escape"||a.key==="escape"){if(n){const c=t.deselect;c&&(s.preventDefault(),c())}else{const c=t.exit;c&&(s.preventDefault(),c())}return}const d=t[l.id];d&&(s.preventDefault(),d())};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[t,n,o])}function GE(e){const{result:t,onDismiss:n,onLoadLatest:o,onKeepMyChanges:r}=e,{t:s}=tt();if(u.useEffect(()=>{if(!t||t.kind==="concurrent_modification"||t.kind==="validation_failed")return;const a=setTimeout(n,5e3);return()=>clearTimeout(a)},[t,n]),!t)return null;if(t.kind==="success")return i.jsx(Bo,{tone:"success",testId:"g7le-save-banner-success",onDismiss:n,children:s("layout_editor.save.success")});if(t.kind==="validation_failed"){const a=t.errors??{},l=Object.entries(a);return i.jsxs(Bo,{tone:"error",testId:"g7le-save-banner-validation",onDismiss:n,children:[i.jsx("strong",{children:s("layout_editor.save.validation_failed")}),l.length>0&&i.jsx("ul",{style:dp,"data-testid":"g7le-save-banner-validation-errors",children:l.map(([d,c])=>i.jsxs("li",{children:[i.jsx("code",{style:cp,children:d}),": ",c.join(", ")]},d))})]})}return t.kind==="blocked_inactive_extension"?i.jsxs(Bo,{tone:"warning",testId:"g7le-save-banner-blocked",onDismiss:n,children:[i.jsx("strong",{children:s("layout_editor.save.blocked_inactive_extension")}),t.blockedPaths.length>0&&i.jsx("ul",{style:dp,"data-testid":"g7le-save-banner-blocked-paths",children:t.blockedPaths.map(a=>i.jsx("li",{children:i.jsx("code",{style:cp,children:a})},a))})]}):t.kind==="network_error"?i.jsxs(Bo,{tone:"error",testId:"g7le-save-banner-network",onDismiss:n,children:[i.jsx("strong",{children:s("layout_editor.save.network_error_title")}),i.jsx("div",{style:{marginTop:4,fontSize:12},children:t.message})]}):t.kind==="guard_no_document"?i.jsx(Bo,{tone:"neutral",testId:"g7le-save-banner-guard-no-document",onDismiss:n,children:s("layout_editor.save.guard_no_document")}):i.jsx("div",{role:"dialog","aria-modal":"true","aria-label":s("layout_editor.save.concurrent.title"),"data-testid":"g7le-save-banner-concurrent",style:ZE,children:i.jsxs("div",{style:QE,children:[i.jsx("h2",{style:RE,children:s("layout_editor.save.concurrent.title")}),i.jsx("p",{style:e7,children:s("layout_editor.save.concurrent.message")}),i.jsx("div",{style:t7,children:s("layout_editor.save.concurrent.version_info",{current:String(t.currentVersion),yours:String(t.yourVersion)})}),i.jsxs("div",{style:n7,children:[i.jsx("button",{type:"button","data-testid":"g7le-save-banner-concurrent-load-latest",onClick:()=>{o?.(),n()},style:o7,children:s("layout_editor.save.concurrent.load_latest")}),i.jsx("button",{type:"button","data-testid":"g7le-save-banner-concurrent-keep-mine",onClick:()=>{r?.(),n()},style:r7,children:s("layout_editor.save.concurrent.view_my_changes")}),i.jsx("button",{type:"button","data-testid":"g7le-save-banner-concurrent-cancel",onClick:n,style:i7,children:s("layout_editor.save.concurrent.cancel")})]})]})})}function Bo(e){const{tone:t,testId:n,onDismiss:o,children:r}=e,s=YE[t];return i.jsxs("div",{role:"status","data-testid":n,style:{...XE,background:s.bg,borderColor:s.border,color:s.fg},children:[i.jsx("div",{style:{flex:1,minWidth:0},children:r}),i.jsx("button",{type:"button",onClick:o,"aria-label":"close","data-testid":`${n}-close`,style:JE,children:"×"})]})}const YE={success:{bg:"#dcfce7",border:"#86efac",fg:"#14532d"},error:{bg:"#fee2e2",border:"#fca5a5",fg:"#7f1d1d"},warning:{bg:"#fef3c7",border:"#fcd34d",fg:"#78350f"},neutral:{bg:"#f1f5f9",border:"#cbd5e1",fg:"#334155"}},XE={display:"flex",alignItems:"flex-start",gap:12,padding:"12px 16px",border:"1px solid",borderRadius:0,fontSize:13,lineHeight:1.5},JE={background:"transparent",border:"none",fontSize:18,cursor:"pointer",lineHeight:1,color:"inherit",padding:"0 4px",flexShrink:0},dp={margin:"8px 0 0",paddingLeft:20,fontSize:12},cp={background:"rgba(0, 0, 0, 0.06)",padding:"1px 4px",borderRadius:3,fontFamily:"monospace"},ZE={position:"fixed",inset:0,background:"rgba(15, 23, 42, 0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},QE={background:"#fff",borderRadius:8,padding:24,width:"min(480px, 90vw)",boxShadow:"0 10px 25px rgba(0,0,0,0.15)"},RE={margin:"0 0 8px",fontSize:16,fontWeight:600,color:"#0f172a"},e7={margin:"0 0 12px",color:"#334155",fontSize:13,lineHeight:1.5},t7={marginBottom:16,padding:"8px 12px",background:"#f8fafc",borderRadius:6,fontSize:12,color:"#64748b",fontFamily:"monospace"},n7={display:"flex",gap:8,justifyContent:"flex-end"},o7={padding:"8px 14px",background:"#2563eb",color:"#fff",border:"none",borderRadius:6,fontSize:13,fontWeight:600,cursor:"pointer"},r7={padding:"8px 14px",background:"#fff",color:"#334155",border:"1px solid #cbd5e1",borderRadius:6,fontSize:13,fontWeight:500,cursor:"pointer"},i7={padding:"8px 14px",background:"transparent",color:"#64748b",border:"none",borderRadius:6,fontSize:13,cursor:"pointer"};function up(e){if(!e)return null;const n=new URLSearchParams(e).get("route");return n&&n.length>0?n:null}function ea(e,t,n){const o=`/admin/layout-editor/${encodeURIComponent(e)}`;if(!t||t.length===0)return o;if(t.startsWith("__")){let r=`${o}?edit=${encodeURIComponent(t)}`;return(t.startsWith("__modal__/")||t.startsWith("__iteration__/"))&&n&&(r+=`&host=${encodeURIComponent(n)}`),r}return`${o}?route=${encodeURIComponent(t)}`}function pp(e){if(!e)return null;const n=new URLSearchParams(e).get("host");return n&&n.length>0?n:null}function fp(e){if(!e)return null;const n=new URLSearchParams(e).get("edit");return n&&n.length>0&&n.startsWith("__")?n:null}function s7(e,t){const n=`/admin/templates/${encodeURIComponent(e)}/edit`;if(!t||t.length===0||t.startsWith("__"))return n;const o=t.replace(/^\*+/,"");return o.length===0?n:`${n}?route=${encodeURIComponent(o)}`}const a7="g7le-editor-route",l7=new Set;function ta(e){return e.path.startsWith("__group__/")||e.path.startsWith("__conngroup__/")}function gp(e,t){const{t:n,translationEngine:o,translationContext:r,templateIdentifier:s}=t,a=ta(e);if(!e.label.startsWith("$t:"))return e.label;const l=e.label.slice(3),d=l.indexOf("|"),c=d===-1?l:l.slice(0,d),p={};if(d!==-1)for(const b of l.slice(d+1).split("|")){const g=b.indexOf("=");g!==-1&&(p[b.slice(0,g)]=b.slice(g+1))}if((e.kind==="route"||e.kind==="modal")&&!a&&o&&r&&s!==r.templateId){const b={templateId:s,locale:r.locale},g=Object.keys(p).length>0?"|"+Object.entries(p).map(([h,v])=>`${h}=${v}`).join("|"):void 0,m=o.translate(c,b,g);if(m!==c)return m}const f=n(c,p);if(f===c&&typeof window<"u"){const b=window.G7Core?.t;if(typeof b=="function")try{const g=b(c,p);if(g!==c)return g}catch{}}if(f===c&&e.kind==="route"&&!a){const b=e.path;if(b&&b!=="/"){const g=b.split("/").filter(Boolean);return g[g.length-1]??b}return b==="/"?"/":c}return f}function d7(e){return e.trim().toLocaleLowerCase()}function hp(e,t){if(!t)return e;const n=e.toLocaleLowerCase(),o=[];let r=0,s=n.indexOf(t,r);if(s===-1)return e;let a=0;for(;s!==-1;)s>r&&o.push(e.slice(r,s)),o.push(i.jsx("mark",{className:"g7le-route-tree__highlight",style:{background:"#fde68a",color:"inherit",borderRadius:2,padding:"0 1px"},children:e.slice(s,s+t.length)},`m${a++}`)),r=s+t.length,s=n.indexOf(t,r);return r{const z=f.selectedRoute?.path??"";return z.startsWith("__extension__/")||z.startsWith("__modal__/")?z.slice(z.lastIndexOf("/")+1):null},[f.selectedRoute?.path]),h=u.useMemo(()=>!g||!m?!1:(e.children??[]).some(z=>z.kind==="extension"&&z.extensionId===m||z.kind==="modal"&&z.modalId===m),[g,m,e.children]),[v,y]=u.useState(!0);u.useEffect(()=>{h&&y(!1)},[h]);const _=f.editMode==="extension"?f.selectedRoute?.layoutName??null:null,w=e.kind==="extension"?bp(e,f.routeTree)??null:null,k=e.kind==="extension"&&o===e.path&&(_===null||w===null||_===w),x=f.editMode==="modal"&&o?.startsWith("__modal__/")?o.slice(o.lastIndexOf("/")+1):null,$=f.editMode==="modal"?f.selectedRoute?.layoutName??null:null,S=e.kind==="modal"&&!!x&&e.modalId===x&&($===null||e.modalHostLayout==null||$===e.modalHostLayout),C=e.kind!=="extension"&&e.kind!=="modal"&&o===e.path||k||S||e.kind==="route"&&!b&&r===e.path,E=(e.children?.length??0)>0&&(!g||l||!v),A=!b&&!!e.layoutName&&s.has(e.layoutName),N=b?void 0:e.kind==="extension"?e.extensionId?f.extensionVersions[e.extensionId]:void 0:e.layoutName?f.layoutVersions[e.layoutName]:void 0,D=()=>{if(g){y(z=>!z);return}b||n(e)},B=gp(e,{t:d,translationEngine:c,translationContext:p,templateIdentifier:f.templateIdentifier}),M=b?null:c7(e),O={paddingLeft:12+t*14,paddingRight:12,paddingTop:4,paddingBottom:4,opacity:e.isHidden?.55:1,cursor:g?"pointer":b?"default":"pointer",background:C?"#eff6ff":"transparent",borderLeft:C?"2px solid #2563eb":"2px solid transparent",fontWeight:b||C?600:400,fontSize:b?11:13,color:b?"#64748b":C?"#1d4ed8":"#1e293b",textTransform:b?"uppercase":"none",letterSpacing:b?.6:void 0,transition:"background-color 100ms, color 100ms",display:"flex",flexDirection:"column",alignItems:"stretch",gap:2,userSelect:"none"};return i.jsxs("li",{children:[i.jsxs("div",{"data-testid":b?"g7le-route-tree-group":"g7le-route-tree-item","data-route-path":e.path,"data-route-kind":e.kind,"data-conn-collapsed":g?l?"false":String(v):void 0,role:g||!b?"button":void 0,tabIndex:g||!b?0:void 0,"aria-expanded":g?l?!0:!v:void 0,onClick:D,onKeyDown:z=>{g&&(z.key==="Enter"||z.key===" ")?(z.preventDefault(),y(H=>!H)):!b&&(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),n(e))},style:O,children:[i.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},children:[g&&i.jsx("span",{"aria-hidden":"true",style:{flex:"0 0 auto",fontSize:9,color:"#94a3b8",width:10,display:"inline-block"},children:l||!v?"▾":"▸"}),A&&i.jsx("span",{className:"g7le-route-tree__dirty-dot","data-testid":"g7le-route-tree-dirty",title:d("layout_editor.chrome.route_tree.badge.modified"),"aria-label":d("layout_editor.chrome.route_tree.badge.modified"),style:{width:7,height:7,borderRadius:"50%",background:"#f59e0b",flex:"0 0 auto"}}),b?B:hp(B,a),typeof N=="number"&&i.jsxs("span",{className:"g7le-route-tree__version-badge","data-testid":"g7le-route-tree-version",title:d("layout_editor.chrome.route_tree.badge.version_tooltip",{version:String(N)}),style:{flex:"0 0 auto",padding:"0 5px",fontSize:10,fontWeight:600,lineHeight:"16px",borderRadius:4,background:"#eef2ff",color:"#4f46e5",border:"1px solid #e0e7ff",letterSpacing:.2},children:["v",N]}),i.jsx(u7,{node:e})]}),M&&i.jsx("span",{className:"g7le-route-tree__layout-path","data-testid":"g7le-route-tree-layout-path",title:M,style:{fontSize:11,fontWeight:400,color:"#94a3b8",textTransform:"none",letterSpacing:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:hp(M,a)})]}),E&&i.jsx("ul",{style:{listStyle:"none",margin:0,padding:0},children:e.children.map(z=>i.jsx(yp,{node:z,depth:t+1,onSelect:n,selectedRoutePath:o,activeHostRoutePath:r,dirtyLayoutNames:s,query:a,forceExpand:l},z.path))})]})}function p7(e,t){if(!t||!t.startsWith("__"))return null;const n=t.startsWith("__modal__/"),o=t.startsWith("__extension__/");if(!n&&!o)return null;const r=t.slice(t.lastIndexOf("/")+1),s=a=>{for(const l of a){if(l.connectedHostRoutePath&&(n&&l.kind==="modal"&&l.modalId===r||o&&l.kind==="extension"&&l.extensionId===r))return l.connectedHostRoutePath;if(l.children&&l.children.length>0){const d=s(l.children);if(d)return d}}return null};return s(e)}function bp(e,t){if(e.connectedHostRoutePath){const n=mp(t,e.connectedHostRoutePath);if(n?.layoutName)return n.layoutName}if(e.extensionType==="overlay"&&e.extensionTargetName)return e.extensionTargetName}function mp(e,t){for(const n of e){if(n.kind==="route"&&n.path===t)return n;if(n.children&&n.children.length>0){const o=mp(n.children,t);if(o)return o}}return null}function vp(e,t,n){const o=[];for(const r of e){const s=ta(r),a=r.children&&r.children.length>0?vp(r.children,t,n):[];if(s){a.length>0&&o.push({...r,children:a});continue}const l=gp(r,n).toLocaleLowerCase(),d=r.path.toLocaleLowerCase();(l.includes(t)||!d.startsWith("__")&&d.includes(t)||a.length>0)&&o.push({...r,children:a})}return o}function f7(){const{t:e,translationEngine:t,translationContext:n}=tt(),{state:o,dispatch:r}=Qe(),a=Ft()?.dirtyLayoutNames??l7,[l,d]=u.useState(""),c=d7(l),p=u.useMemo(()=>c?vp(o.routeTree,c,{t:e,translationEngine:t,translationContext:n,templateIdentifier:o.templateIdentifier}):o.routeTree,[c,o.routeTree,o.templateIdentifier,e,t,n]),f=h=>{if(h.kind==="base"&&h.layoutName){r({type:"ENTER_BASE_EDIT",layoutName:h.layoutName});return}if(h.kind==="modal"&&h.modalId&&h.modalHostLayout){r({type:"ENTER_MODAL_EDIT",modalId:h.modalId,hostLayout:h.modalHostLayout});return}if(h.kind==="extension"&&h.extensionId){const v=bp(h,o.routeTree);r({type:"ENTER_EXTENSION_EDIT",extensionId:h.extensionId,extensionHost:v});return}if(r({type:"SELECT_ROUTE",route:{path:h.path,layoutName:h.layoutName}}),typeof window<"u"&&window.history?.pushState){const v=ea(o.templateIdentifier,h.path);`${window.location.pathname}${window.location.search}`!==v&&window.history.pushState({source:a7,routePath:h.path},"",v)}},b=o.selectedRoute?.path??null,g=u.useMemo(()=>p7(o.routeTree,b),[o.routeTree,b]);if(o.isRouteTreeCollapsed)return i.jsx("aside",{className:"g7le-route-tree g7le-route-tree--collapsed","data-testid":"g7le-route-tree-panel","data-collapsed":"true",style:{width:28,borderRight:"1px solid #e2e8f0",background:"#ffffff"}});const m=o.routeTree.length>0;return i.jsxs("aside",{className:"g7le-route-tree","data-testid":"g7le-route-tree-panel","data-collapsed":"false",style:{width:280,borderRight:"1px solid #e2e8f0",background:"#ffffff",position:"sticky",top:"var(--g7le-header-h, 0px)",alignSelf:"start",height:"calc(100vh - var(--g7le-header-h, 0px))",overflow:"hidden",minHeight:0,display:"flex",flexDirection:"column"},"aria-label":e("layout_editor.chrome.route_tree.panel_title"),children:[i.jsx("div",{className:"g7le-route-tree__title",style:{padding:"10px 14px",fontSize:12,fontWeight:600,color:"#475569",textTransform:"uppercase",letterSpacing:.6,borderBottom:"1px solid #e2e8f0",background:"#f8fafc",flex:"0 0 auto"},children:e("layout_editor.chrome.route_tree.panel_title")}),m&&i.jsxs("div",{className:"g7le-route-tree__search",style:{padding:"8px 10px",borderBottom:"1px solid #e2e8f0",background:"#ffffff",flex:"0 0 auto",position:"relative"},children:[i.jsx("input",{type:"text",className:"g7le-route-tree__search-input","data-testid":"g7le-route-tree-search",value:l,onChange:h=>d(h.target.value),placeholder:e("layout_editor.chrome.route_tree.search_placeholder"),"aria-label":e("layout_editor.chrome.route_tree.search_placeholder"),style:{width:"100%",boxSizing:"border-box",padding:l?"6px 26px 6px 10px":"6px 10px",fontSize:12,lineHeight:1.4,color:"#1e293b",border:"1px solid #cbd5e1",borderRadius:6,outline:"none",background:"#f8fafc"}}),l&&i.jsx("button",{type:"button",className:"g7le-route-tree__search-clear","data-testid":"g7le-route-tree-search-clear",onClick:()=>d(""),"aria-label":e("layout_editor.chrome.route_tree.search_clear"),title:e("layout_editor.chrome.route_tree.search_clear"),style:{position:"absolute",right:16,top:"50%",transform:"translateY(-50%)",width:18,height:18,display:"inline-flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",color:"#94a3b8",cursor:"pointer",fontSize:14,lineHeight:1,padding:0},children:"✕"})]}),!m&&i.jsx("div",{className:"g7le-route-tree__empty","data-testid":"g7le-route-tree-empty",style:{padding:16,fontSize:12,color:"#94a3b8",textAlign:"center"},children:e("layout_editor.chrome.route_tree.empty")}),m&&c&&p.length===0&&i.jsx("div",{className:"g7le-route-tree__no-results","data-testid":"g7le-route-tree-no-results",style:{padding:16,fontSize:12,color:"#94a3b8",textAlign:"center"},children:e("layout_editor.chrome.route_tree.search_no_results")}),m&&p.length>0&&i.jsx("nav",{className:"g7le-route-tree__scroll","data-testid":"g7le-route-tree-scroll",style:{flex:"1 1 auto",minHeight:0,overflowY:"auto"},children:i.jsx("ul",{style:{listStyle:"none",margin:0,padding:0},children:p.map(h=>i.jsx(yp,{node:h,depth:0,onSelect:f,selectedRoutePath:b,activeHostRoutePath:g,dirtyLayoutNames:a,query:c,forceExpand:!!c},h.path))})})]})}const g7=Lt().DynamicRenderer,na=Lt(),h7=na.ResponsiveProvider;na.useResponsive,na.ResponsiveContext;const y7=Lt().ActionDispatcher,_p=Lt(),b7=_p.DataSourceManager;_p.dataSourceManager;function Jr(e,t,n){const o=t??{},r=o.message||o.error||`HTTP ${e}`,s=o?.data?.required_permissions??o?.required_permissions;let a;return e===401?a="unauthorized":e===403?a="forbidden":e===404?a="not_found":e>=500?a="server_error":a="unknown",{kind:a,status:e,message:String(r),requiredPermissions:s?String(s):void 0,source:n}}function so(e,t){return{kind:"network",status:0,message:e instanceof Error?e.message:String(e??"Unknown network error"),source:t}}function xp(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.kind=="string"&&typeof t.status=="number"&&typeof t.message=="string"}function Re(e){if(!e)return[];const t=[],n=e.split(".");for(let o=0;o0&&(t.push({responsive:a}),o+=1);continue}const s=Number(r);Number.isFinite(s)&&Number.isInteger(s)&&s>=0&&t.push(s)}return t}function m7(e,t){if(!e)return{affordance:"none",targetPath:null};const n=v7(e);return n?_7(n)?{affordance:"dynamic_path",targetPath:n}:/^(https?:)?\/\//.test(n)?{affordance:"external_url",targetPath:n}:n.startsWith("/")?t?{affordance:t(n),targetPath:n}:{affordance:"route_not_in_tree",targetPath:n}:{affordance:"route_not_in_tree",targetPath:n}:{affordance:"none",targetPath:null}}function v7(e){const t=e.actions;if(Array.isArray(t)){for(const n of t)if(n&&typeof n=="object"&&n.handler==="navigate"){const o=n.params?.path;if(typeof o=="string"&&o.length>0)return o}}if(e.name==="A"||e.type==="A"){const n=e.props?.href;if(typeof n=="string"&&n.length>0)return n}return null}function _7(e){return/\{\{[\s\S]*?\}\}/.test(e)}function x7(e,t,n){const o=s=>!!(s?.iteration&&s.iteration.source!==void 0),r=s=>{if(!s)return s;const a=s.indexOf(".iteration."),l=s.indexOf(".sortable."),d=[a,l].filter(c=>c>=0).sort((c,p)=>c-p)[0];return d===void 0?s:s.slice(0,d)};return o(e)?{isIteration:!0,iterationSourcePath:r(n)}:n&&n.includes(".iteration.")?{isIteration:!0,iterationSourcePath:r(n)}:t.some(o)?{isIteration:!0,iterationSourcePath:r(n)}:{isIteration:!1,iterationSourcePath:null}}function w7(e,t){const n=a=>{const l=a?.iteration&&a.iteration.source;return typeof l=="string"&&l.length>0?l:null},o=n(e)??t.map(n).find(a=>a!==null)??null;if(o!==null){const a=S7(o);if(a!==null)return a}const r=[];if(typeof e.text=="string"&&r.push(...wp(e.text)),e.props&&typeof e.props=="object")for(const a of Object.values(e.props))typeof a=="string"&&r.push(...wp(a));return r.length===0?null:r.find(a=>!k7.has(a))??r[0]}const k7=new Set(["_local","_global","_computed","route","query","props","item","index","event","$event","$response","response"]);function wp(e){const t=[],n=/\{\{([\s\S]*?)\}\}/g;let o;for(;(o=n.exec(e))!==null;){const r=kp(o[1]);r!==null&&t.push(r)}return t}function S7(e){const t=e.replace(/\{\{|\}\}/g,"");return kp(t)}function kp(e){const t=/[A-Za-z_$][A-Za-z0-9_$]*/.exec(e.trim());return t?t[0]:null}function gn(e,t,n,o=[]){if(!e)return"none";if(id(e)||typeof e.slot=="string"||typeof e.__editorSlotName=="string")return"extension_point";if(t!=="route"&&Ri(e,t,n)){const s=e.__source?.kind;return s==="base"?"base":s==="partial"?"partial":s==="extension"?"extension":"base"}if(zb(e,o))return"data_bound";if(!Ri(e,t,n))return"none";const r=e.__source?.kind;return r==="base"?"base":r==="partial"?"partial":r==="extension"?"extension":"none"}function Sp(e){if(!e)return null;if(e.__source?.kind==="extension"&&typeof e.__source.extensionId=="number")return e.__source.extensionId;const t=e.__injectedProps;if(Array.isArray(t)&&t.length>0){const n=t[0]?.extensionId;if(typeof n=="number")return n}return null}function C7(e,t){if(t<=0)return e;const n=e.split(".");let o=0;const r=[];for(let s=0;s=t)break;r.push(a);continue}if(a==="iteration"||a==="sortable"){if(o>=t)break;r.push(a);continue}r.push(a);const l=n[s-1];if((l===void 0||l==="children")&&(o+=1),o>=t)break}return r.join(".")}function Cp(e,t,n,o){if(!e||!t)return t;const r=n(t),s=Lb(e,r,o);return s.length===r.length?t:C7(t,s.length)}function $p(e){return e==="none"||e==="data_bound"}function $7(e){const{rootNode:t,editMode:n,currentExtensionId:o,editableRootPath:r,pathParser:s=Re,resolveRouteMatch:a}=e,[l,d]=u.useState(null),[c,p]=u.useState(null),f=u.useCallback(_=>{if(_===null||n==="route")return!0;if(n==="iteration_item"||n==="modal"){if(!r||r.length===0)return!0;const $=s(_);return Ep($,r)}const w=oa(t,_,s);if(!w)return!0;const k=ra(t,_,s),x=gn(w,n,o,k);return x==="none"||x==="data_bound"},[t,s,n,o,r]),b=u.useCallback((_,w)=>{const x=(w?.currentTarget?.dataset??w?.dataset)?.editorPath??null,$=Cp(t,x,s,o);f($)&&d($)},[t,s,o,f]),g=u.useCallback((_,w)=>{if(_===null){p(null);return}const x=(w?.currentTarget?.dataset??w?.dataset)?.editorPath??null,$=Cp(t,x,s,o);if(!f($)){p(null);return}p($)},[t,s,o,f]),m=u.useCallback(()=>{d(null)},[]),h=u.useMemo(()=>{const _=oa(t,l,s),w=oa(t,c,s),k=_?ra(t,l,s):[];let x=gn(_,n,o,k);(n==="iteration_item"||n==="modal")&&l!==null&&_&&r&&r.length>0&&Ep(s(l),r)&&(sd(_)?x="data_bound":x==="data_bound"&&(x="none"));const{affordance:$,targetPath:S}=m7(_,a),C=x==="base"&&typeof _?.__source?.layout=="string"?_.__source.layout:null,T=x==="data_bound"&&_?w7(_,k):null,{isIteration:E,iterationSourcePath:A}=x==="data_bound"&&_?x7(_,k,l):{isIteration:!1,iterationSourcePath:null};return{selectedNode:_,hoverNode:w,selectedLockKind:x,selectedNavAffordance:$,selectedNavTargetPath:S,selectedBaseLayout:C,selectedDataSourceId:T,selectedIsIteration:E,selectedIterationSourcePath:A}},[t,l,c,n,o,r,s,a]),v=u.useRef(void 0);v.current!==l&&(v.current=l,Al({op:l===null?"clear":"select",componentPath:l,componentName:Ip(h.selectedNode),lockKind:h.selectedLockKind,navAffordance:h.selectedNavAffordance,sourceExtensionId:Sp(h.selectedNode),timestamp:Date.now()}));const y=u.useRef(void 0);return y.current!==c&&(y.current=c,c!==null&&Al({op:"hover",componentPath:c,componentName:Ip(h.hoverNode),lockKind:gn(h.hoverNode,n,o,ra(t,c,s)),navAffordance:"none",sourceExtensionId:Sp(h.hoverNode),timestamp:Date.now()})),{selectedPath:l,hoverPath:c,...h,handleSelect:b,handleHover:g,clearSelection:m}}function oa(e,t,n){if(!e||!t)return null;const o=n(t);return Be(e,o)}function Ep(e,t){if(e.length0?e.name:typeof e.type=="string"&&e.type.length>0?e.type:null:null}let Ap=0;function Tp(){return Ap}function ia(){Ap+=1}function E7(e){if(typeof e!="string")return null;const t="__modal__/";if(!e.startsWith(t))return null;const n=e.slice(t.length);return n===""||n.includes("/")?null:n}function I7(e){if(typeof e!="string")return null;const t="__iteration__/";if(!e.startsWith(t))return null;const n=e.slice(t.length);return n!==""?n:null}function Dp(){const{state:e}=Qe(),t=e.templateIdentifier,n=e.selectedRoute?.layoutName??null,o=e.editMode,r=o==="modal"?E7(e.selectedRoute?.path):null,s=o==="iteration_item"?I7(e.selectedRoute?.path):null,[a,l]=u.useState(null),[d,c]=u.useState(!1),[p,f]=u.useState(null),[b,g]=u.useState(!1),[m,h]=u.useState(0),[v,y]=u.useState(0),_=u.useRef(new Map),[w,k]=u.useState(()=>new Set),x=u.useCallback((P,I)=>`${P}|${I??""}`,[]),$=u.useRef(null);u.useEffect(()=>{$.current=a},[a]);const S=u.useCallback((P,I)=>{const L=x(o,n);_.current.set(L,{raw:P,lockVersion:I}),k(F=>{if(F.has(L))return F;const Y=new Set(F);return Y.add(L),Y})},[x,o,n]),C=u.useCallback(P=>{_.current.delete(P),k(I=>{if(!I.has(P))return I;const L=new Set(I);return L.delete(P),L})},[]),T=u.useCallback(P=>{const I=`|${P??""}`,L=[];for(const F of _.current.keys())F.endsWith(I)&&L.push(F);for(const F of L)_.current.delete(F);L.length>0&&k(F=>{let Y=!1;const K=new Set(F);for(const X of L)K.delete(X)&&(Y=!0);return Y?K:F})},[]),E=u.useCallback(async()=>{if(!n){l(null),f(null),g(!1);return}const P=x(o,n),I=_.current.get(P);if(I){l({layoutName:n,raw:I.raw,lockVersion:I.lockVersion}),g(!0),f(null),c(!1),st({op:"load",layoutName:n,editMode:o,statusCode:0,isDirty:!0,timestamp:Date.now()});return}c(!0),f(null);try{const L=window.G7Config?.cache_version??0,F=en(`/api/layouts/${encodeURIComponent(t)}/${n}`,"json",`${L}.${Tp()}`,"with_source_meta=1"),Y=cr(),K={Accept:"application/json"};Y&&(K.Authorization=`Bearer ${Y}`);const X=await fetch(F,{headers:K,credentials:"same-origin"}),Z=await X.json().catch(()=>null);if(!X.ok){f(Jr(X.status,Z,"layout")),l(null),g(!1);return}const ae=(Z&&(Z.data||Z))??{},oe=typeof ae.lock_version=="number"?ae.lock_version:0;if(o==="modal"&&r){const ee=ae,ge=Array.isArray(ee.modals)?ee.modals:[],V=ge.findIndex(te=>te&&(te.id===r||te.modal_id===r));if(V>=0){const te=ge[V],be={...te,props:{...te.props??{},isOpen:!0}},De=[...Array.isArray(ee.components)?ee.components:[],be],Se=[De.length-1];l({layoutName:n,raw:{...ee,components:De},lockVersion:oe,modalContext:{modalId:r,modalIndex:V,hostRaw:ee,originalModalNode:te,editIndexPath:Se}}),g(!1),st({op:"load",layoutName:n,editMode:o,statusCode:X.status,timestamp:Date.now()});return}}if(o==="iteration_item"&&s){const ee=ae,ge=Re(s),V={children:ee.components??[]},te=Be(V,ge);if(te&&Array.isArray(te.children)){l({layoutName:n,raw:ee,lockVersion:oe,iterationContext:{sourcePath:s,sourceIndexPath:ge,hostRaw:ee}}),g(!1),st({op:"load",layoutName:n,editMode:o,statusCode:X.status,timestamp:Date.now()});return}}l({layoutName:n,raw:ae,lockVersion:oe}),g(!1),st({op:"load",layoutName:n,editMode:o,statusCode:X.status,timestamp:Date.now()})}catch(L){f(so(L,"layout")),l(null),g(!1)}finally{c(!1)}},[t,n,o,r,s,x]);u.useEffect(()=>{E()},[E]);const A=u.useCallback(async()=>{C(x(o,n)),ia(),y(P=>P+1),await E()},[C,x,o,n,E]),N=u.useCallback(()=>{C(x(o,n))},[C,x,o,n]),D=u.useCallback(P=>{l(I=>{if(!I)return I;const L=I.raw.components??[],F=P(L),Y={...I.raw,components:F};return S(Y,I.lockVersion),{...I,raw:Y}}),g(!0),st({op:"patch",layoutName:n,editMode:o,isDirty:!0,timestamp:Date.now()})},[n,o,S]),B=u.useCallback(()=>{g(!0),st({op:"patch",layoutName:n,editMode:o,isDirty:!0,timestamp:Date.now()})},[n,o]),M=u.useCallback(P=>{l(I=>{if(!I)return I;const L={...I.raw,components:P};return S(L,I.lockVersion),{...I,raw:L}}),g(!0),st({op:"patch",layoutName:n,editMode:o,isDirty:!0,timestamp:Date.now()})},[n,o,S]),O=u.useCallback((P,I,...L)=>{const F=L.length>=1?L[0]:I;l(Y=>{if(!Y)return Y;const K={...Y.raw,[P]:I},X=Y.raw.__editor;if(X&&typeof X=="object"&&!Array.isArray(X)){const Z=X,ae=Z.original;ae&&typeof ae=="object"&&!Array.isArray(ae)&&(K.__editor={...Z,original:{...ae,[P]:F}})}return S(K,Y.lockVersion),{...Y,raw:K}}),g(!0),st({op:"patch",layoutName:n,editMode:o,isDirty:!0,timestamp:Date.now()})},[n,o,S]),z=u.useCallback(async P=>{const I=$.current;if(!I)return st({op:"save_guard_result",layoutName:n,editMode:o,guardBlocked:!1,timestamp:Date.now()}),{kind:"guard_no_document"};if(P?.resolveActiveExtensions&&P.sessionAddedPaths?.length)try{const ge=await P.resolveActiveExtensions(),V=A7(I.raw.components,P.sessionAddedPaths,ge);if(V.length>0)return st({op:"save_guard_result",layoutName:n,editMode:o,guardBlocked:!0,guardBlockedPaths:V,timestamp:Date.now()}),{kind:"blocked_inactive_extension",blockedPaths:V}}catch{}if(Yb())try{await Xb(t)}catch{}const L=`/api/admin/templates/${encodeURIComponent(t)}/layouts/${I.layoutName}`,F=cr(),Y={Accept:"application/json","Content-Type":"application/json"};F&&(Y.Authorization=`Bearer ${F}`);const K=!!I.modalContext,X=!!I.iterationContext,Z=K||X?"host_layout_modal_patch":"layout";st({op:"save",layoutName:I.layoutName,editMode:o,saveTarget:Z,endpoint:L,isDirty:b,timestamp:Date.now()});let ae;if(K&&I.modalContext){const{modalIndex:ge,hostRaw:V,originalModalNode:te,editIndexPath:be}=I.modalContext,Ee=Array.isArray(V.modals)?[...V.modals]:[],De=Array.isArray(I.raw.components)?I.raw.components:[],Se=be&&be.length===1?be[0]:0,Ue=De.length>Se?De[Se]:void 0,Me=Ue?Vn([Ue]):[],Oe=Me.length>0?{...Me[0]}:void 0;if(ge>=0&&ge({...ze,children:De})).children??[];ae={...Se,components:Ye}}else ae=_o(I.raw);const oe=ae;let G;try{G=await fetch(L,{method:"PUT",headers:Y,credentials:"same-origin",body:JSON.stringify({content:JSON.stringify(oe),expected_lock_version:I.lockVersion})})}catch(ge){const V=ge instanceof Error?ge.message:"network error";return st({op:"save_response",layoutName:I.layoutName,editMode:o,endpoint:L,statusCode:0,timestamp:Date.now()}),{kind:"network_error",message:V}}const ee=await G.json().catch(()=>null);if(st({op:"save_response",layoutName:I.layoutName,editMode:o,endpoint:L,statusCode:G.status,conflict:G.status===409?{currentVersion:ee?.current_version,yourVersion:ee?.your_version}:void 0,timestamp:Date.now()}),G.ok){const ge=typeof ee?.data?.lock_version=="number"?ee.data.lock_version:I.lockVersion+1;l({...I,lockVersion:ge}),g(!1),C(x(o,I.layoutName)),T(I.layoutName),ia(),h(te=>te+1);const V=typeof ee?.data?.current_version=="number"?ee.data.current_version:void 0;return{kind:"success",newLockVersion:ge,newContentVersion:V,savedLayoutName:I.layoutName}}return G.status===409?{kind:"concurrent_modification",currentVersion:ee?.current_version??-1,yourVersion:ee?.your_version??I.lockVersion}:G.status===422?{kind:"validation_failed",status:422,errors:ee?.errors??null}:{kind:"network_error",message:ee?.message??`HTTP ${G.status}`}},[t,n,o,b,C,T,x,r,s]),H=u.useMemo(()=>{const P=new Set,I="route|";for(const L of w)if(L.startsWith(I)){const F=L.slice(I.length);F&&P.add(F)}return P},[w]);return{document:a,isLoading:d,error:p,isDirty:b,saveSuccessCounter:m,reloadCounter:v,dirtyKeys:w,dirtyLayoutNames:H,invalidateCurrentCache:N,reload:A,patchLayout:D,setLayoutComponents:M,patchDocumentRaw:O,save:z,markDirty:B}}function A7(e,t,n){if(!e||e.length===0)return[];const o=[],r=new Set([...n.moduleIds,...n.pluginIds]);for(const s of t){const a=T7(e,s);if(!a)continue;const l=a.__source;if(!l||l.kind!=="extension")continue;const d=String(l.extensionId??"");d.length!==0&&(r.has(d)||o.push(s))}return o}function T7(e,t){const n=Re(t);return n.length===0?null:Be({children:e},n)}function ao(e,t){if(!e)return null;const n=e.getBoundingClientRect();if(n.width===0&&n.height===0)return null;if(!t)return{left:n.left,top:n.top,width:n.width,height:n.height,scale:1};const o=t.getBoundingClientRect();return{left:n.left-o.left,top:n.top-o.top,width:n.width,height:n.height,scale:1}}function lo(e,t){if(!e)return!1;if(!t)return!0;const n=t.getBoundingClientRect(),o=1;return!(e.left>=n.width-o||e.left+e.width<=o||e.top>=n.height-o||e.top+e.height<=o)}function zp(e,t){if(typeof window>"u")return()=>{};const n=()=>{e()};window.addEventListener("scroll",n,!0),window.addEventListener("resize",n);let o=null;t&&typeof ResizeObserver<"u"&&(o=new ResizeObserver(()=>e()),o.observe(t));let r=null,s=null;const a=typeof requestAnimationFrame<"u",l=()=>{if(!a){e();return}s===null&&(s=requestAnimationFrame(()=>{s=null,e()}))};return t&&typeof MutationObserver<"u"&&(r=new MutationObserver(l),r.observe(t,{childList:!0,subtree:!0})),()=>{window.removeEventListener("scroll",n,!0),window.removeEventListener("resize",n),o&&(o.disconnect(),o=null),r&&(r.disconnect(),r=null),s!==null&&a&&typeof cancelAnimationFrame<"u"&&(cancelAnimationFrame(s),s=null)}}const Np=44;function Mp(e){if(!e)return"inside";const t=e.scale||1,n=e.width*t,o=e.height*t;return n"u"||typeof window.getComputedStyle!="function")return{kind:"unknown",display:"",flexDirection:"",flexWrap:""};let t=e,n=(window.getComputedStyle(t).display??"").toLowerCase();for(;n==="contents"&&t.parentElement;)t=t.parentElement,n=(window.getComputedStyle(t).display??"").toLowerCase();const o=window.getComputedStyle(t),r=(o.display??"").toLowerCase(),s=(o.flexDirection??"").toLowerCase(),a=(o.flexWrap??"").toLowerCase(),l=r==="flex"||r==="inline-flex";if(r==="grid"||r==="inline-grid"){const f=Array.from(e.children).filter(h=>h.offsetParent!==null||h.getClientRects().length>0);if(f.length<=1)return{kind:"grid_2d",display:r,flexDirection:s,flexWrap:a};const b=f.map(h=>h.getBoundingClientRect()),g=new Set(b.map(h=>Math.round(h.top))),m=new Set(b.map(h=>Math.round(h.left)));return g.size===1?{kind:"grid_single_row",display:r,flexDirection:s,flexWrap:a}:m.size===1?{kind:"grid_single_column",display:r,flexDirection:s,flexWrap:a}:{kind:"grid_2d",display:r,flexDirection:s,flexWrap:a}}if(!l)return{kind:"block",display:r,flexDirection:s,flexWrap:a};const c=a==="wrap"||a==="wrap-reverse";return s==="column"||s==="column-reverse"?{kind:c?"flex_column_wrap":"flex_column_single",display:r,flexDirection:s,flexWrap:a}:{kind:c?"flex_row_wrap":"flex_row_single",display:r,flexDirection:s,flexWrap:a}}function z7(e){const{parentEl:t,selectedPath:n,selectedEl:o,explicitFlow:r}=e;return u.useMemo(()=>{if(!n||n.length===0)return{points:[],flow:"unknown"};const s=r??Op(t).kind,a=n.slice(0,-1),l=n[n.length-1]??0;if((s==="flex_row_wrap"||s==="flex_column_wrap"||s==="grid_2d")&&!!o){const p=N7(s,o,a,l);if(p)return{points:p,flow:s}}return{points:M7(s,a,l),flow:s}},[t,n,o,r])}function N7(e,t,n,o){let r=t.parentElement;for(;r&&Bp(r)==="contents";)r=r.parentElement;if(!r)return null;const s=[];if(Wp(r,s),s.length===0)return null;const a=t.getBoundingClientRect(),l=a.top+a.height/2,d=[],c=[],p=[];for(const v of s){const y=v.rect,_=y.top+y.height/2,w=Math.min(a.bottom,y.bottom)-Math.max(a.top,y.top),k=Math.min(a.height,y.height)||1;w/k>.4?d.push({rect:y,path:v.path}):_v.rect.left-y.rect.left),c.sort((v,y)=>v.rect.top-y.rect.top),p.sort((v,y)=>v.rect.top-y.rect.top);const f=d.findIndex(v=>Math.abs(v.rect.left-a.left)<1&&Math.abs(v.rect.top-a.top)<1),b={direction:"above",disabled:!0,insertion:null},g={direction:"below",disabled:!0,insertion:null},m={direction:"left",disabled:!0,insertion:null},h={direction:"right",disabled:!0,insertion:null};if(f>0){const v=d[f-1],y=Qr(v.path);y&&(m.disabled=!1,m.insertion=y)}else if(d.length>0){const v=d[0],y=Zr(v.path);y&&(m.disabled=!1,m.insertion=y)}if(f>=0&&f0){const v=d[d.length-1],y=Qr(v.path);y&&(h.disabled=!1,h.insertion=y)}if(c.length>0){const v=c[c.length-1],y=Qr(v.path);y&&(b.disabled=!1,b.insertion=y)}else if(s.length>0){const v=s[0],y=Zr(v.path);y&&(b.disabled=!1,b.insertion=y)}if(p.length>0){const v=p[0],y=Zr(v.path);y&&(g.disabled=!1,g.insertion=y)}else if(s.length>0){const v=s[s.length-1],y=Qr(v.path);y&&(g.disabled=!1,g.insertion=y)}else g.disabled=!1,g.insertion={parentPath:n,index:o+1};return b.disabled&&g.disabled&&m.disabled&&h.disabled?null:[b,g,m,h]}function Bp(e){return typeof window>"u"?"":(window.getComputedStyle(e).display??"").toLowerCase()}function Wp(e,t){const n=Array.from(e.children);for(const o of n){if(Bp(o)==="contents"){Wp(o,t);continue}const s=o.getAttribute("data-editor-path");if(s&&/\.iteration\.\d+(?:$|\.)/.test(s)||!s)continue;const a=o.getBoundingClientRect();a.width===0&&a.height===0||t.push({el:o,rect:a,path:Re(s)})}}function Zr(e){if(!e||e.length===0)return null;const t=e[e.length-1];return typeof t!="number"?null:{parentPath:e.slice(0,-1),index:t}}function Qr(e){if(!e||e.length===0)return null;const t=e[e.length-1];return typeof t!="number"?null:{parentPath:e.slice(0,-1),index:t+1}}function M7(e,t,n){const o={direction:"above",disabled:!0,insertion:null},r={direction:"below",disabled:!0,insertion:null},s={direction:"left",disabled:!0,insertion:null},a={direction:"right",disabled:!0,insertion:null},l=d=>({parentPath:t,index:d});switch(e){case"block":case"unknown":{o.disabled=!1,o.insertion=l(n),r.disabled=!1,r.insertion=l(n+1);break}case"flex_row_single":case"grid_single_row":{s.disabled=!1,s.insertion=l(n),a.disabled=!1,a.insertion=l(n+1);break}case"flex_column_single":case"grid_single_column":{o.disabled=!1,o.insertion=l(n),r.disabled=!1,r.insertion=l(n+1);break}case"flex_row_wrap":case"grid_2d":{s.disabled=!1,s.insertion=l(n),a.disabled=!1,a.insertion=l(n+1),o.disabled=!1,o.insertion=l(0),r.disabled=!1,r.insertion=l(-1);break}case"flex_column_wrap":{o.disabled=!1,o.insertion=l(n),r.disabled=!1,r.insertion=l(n+1),s.disabled=!1,s.insertion=l(0),a.disabled=!1,a.insertion=l(-1);break}}return[o,r,s,a]}function L7(e=50){const t=u.useRef([]),n=u.useRef(-1),[,o]=u.useState(0),r=()=>{o(p=>(p+1)%1e6)},s=(p,f)=>{const b=t.current.length,g=n.current;ey({op:p,actionKind:f?.actionKind,label:f?.label,stackSize:b,cursor:g,canUndo:g>0,canRedo:g>=0&&g{const b=t.current.slice(0,n.current+1);for(b.push(p);b.length>e;)b.shift();t.current=b,n.current=b.length-1,r(),s("push",p)},[e]),l=u.useCallback(()=>{if(n.current<=0)return null;n.current-=1,r();const p=t.current[n.current]??null;return s("undo",p??void 0),p},[]),d=u.useCallback(()=>{const p=n.current+1;if(p>=t.current.length)return null;n.current=p,r();const f=t.current[p]??null;return s("redo",f??void 0),f},[]),c=u.useCallback(()=>{t.current=[],n.current=-1,r(),s("clear")},[]);return{push:a,undo:l,redo:d,clear:c,canUndo:n.current>0,canRedo:n.current>=0&&n.current{if(!o||typeof window>"u")return;const r=s=>{if(P7(s.target)||!(s.ctrlKey||s.metaKey))return;const l=s.key.toLowerCase();if(l==="z"&&!s.shiftKey){s.preventDefault(),t();return}if(l==="z"&&s.shiftKey||l==="y"){s.preventDefault(),n();return}};return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r)}},[t,n,o])}const B7=20,jp=50,W7=90,Ln=120,j7=130,Hp=80,H7=9e3,Fp=1e4;function F7(e){const t=e<0?0:e>jp?jp:e;return B7+t}function K7(e){const{anchor:t,open:n,onClose:o,onEditProps:r,onDuplicate:s,onDelete:a,onSeparateBranch:l,separateBranchLabel:d,onMergeBranch:c,mergeBranchLabel:p}=e,{t:f}=tt(),[b,g]=u.useState(null);if(!n||!t)return null;const m=[{index:0,testid:"g7le-context-menu-edit-props",label:f("layout_editor.context_menu.edit_props"),onSelect:r},{index:1,testid:"g7le-context-menu-duplicate",label:f("layout_editor.context_menu.duplicate"),onSelect:s}];return l?m.push({index:m.length,testid:"g7le-context-menu-separate-branch",label:d??f("layout_editor.context_menu.separate_branch"),onSelect:l,hint:f("layout_editor.context_menu.separate_branch_hint")}):c&&m.push({index:m.length,testid:"g7le-context-menu-merge-branch",label:p??f("layout_editor.context_menu.merge_branch"),onSelect:c,hint:f("layout_editor.context_menu.merge_branch_hint")}),m.push({index:m.length,testid:"g7le-context-menu-delete",label:f("layout_editor.context_menu.delete"),onSelect:a,danger:!0}),i.jsx("div",{className:"g7le-context-menu","data-testid":"g7le-context-menu",role:"menu",style:{position:"absolute",left:t.left,top:t.top,background:"#fff",border:"1px solid #cbd5e1",borderRadius:6,boxShadow:"0 4px 12px rgba(0,0,0,0.15)",zIndex:1200,minWidth:160,padding:4,pointerEvents:"auto"},onMouseLeave:()=>{g(null),o()},children:m.map(h=>{const v=b===h.index,y=h.danger?"#dc2626":"#0f172a",_=h.danger?"#fee2e2":"#e0e7ff",w=h.danger?"#b91c1c":"#1d4ed8";return i.jsx("button",{type:"button",role:"menuitem","data-testid":h.testid,title:h.hint,onClick:k=>{k.stopPropagation(),h.onSelect(),g(null),o()},onMouseEnter:()=>g(h.index),onFocus:()=>g(h.index),style:{...V7,color:v?w:y,background:v?_:"transparent"},children:h.label},h.testid)})})}const V7={display:"block",width:"100%",textAlign:"left",padding:"6px 12px",border:"none",fontSize:13,cursor:"pointer",borderRadius:4,pointerEvents:"auto",transition:"background-color 120ms ease, color 120ms ease"};function U7(e){const{hoverBox:t,selectedBox:n,lockKind:o,navAffordance:r,onEditProps:s,onDuplicate:a,onDelete:l,onSeparateBranch:d,separateBranchLabel:c,onMergeBranch:p,mergeBranchLabel:f,definedDeviceBranches:b,onJumpToDevice:g,onLinkEditDestination:m,onEditBase:h,onEditExtension:v,extensionLabel:y,baseLayoutLabel:_,dataSourceLabel:w,branchLabel:k,onEditIteration:x,resizeEnabledAxes:$,onResizeHandlePointerDown:S,selectedName:C,onSelectParent:T}=e,{t:E}=tt(),[A,N]=u.useState(!1),D=$p(o),B=A&&D,M=Mp(n),O=M==="outside",z=O&&n?Pp(n):null,H=z?{left:z.right.left,top:z.above.top}:{right:-30,top:-30},P={top:-28,left:0},L=O&&!!C?{top:-50,left:0}:P,F=z?{top:z.below.top+28,left:0}:{top:"auto",bottom:-28},Y=z?{top:z.below.top+56,left:0}:{top:"auto",bottom:-56};return i.jsxs("div",{className:"g7le-element-overlay","data-testid":"g7le-element-overlay",style:{position:"absolute",inset:0,pointerEvents:"none"},children:[t&&i.jsx("div",{"data-testid":"g7le-overlay-hover",style:{position:"absolute",left:t.left,top:t.top,width:t.width,height:t.height,border:"1px dashed #2563eb",pointerEvents:"none"}}),n&&i.jsxs("div",{"data-testid":"g7le-overlay-selected","data-lock-kind":o,style:{position:"absolute",left:n.left,top:n.top,width:n.width,height:n.height,border:o==="none"?"2px solid #2563eb":"2px dashed #f59e0b",pointerEvents:"none"},children:[k?i.jsxs("span",{"data-testid":"g7le-overlay-branch-badge",style:G7,children:["📱 ",k]}):null,C&&(T?i.jsxs("button",{type:"button","data-testid":"g7le-overlay-type-label","data-placement":O?"outside":"inside",title:E("layout_editor.overlay.select_parent"),"aria-label":E("layout_editor.overlay.select_parent"),onClick:K=>{K.preventDefault(),K.stopPropagation(),T()},style:O?X7:Y7,children:[i.jsx("span",{"aria-hidden":!0,style:{marginRight:3,opacity:.85},children:"↑"}),C]}):i.jsx("span",{"data-testid":"g7le-overlay-type-label","data-placement":O?"outside":"inside",style:O?Vp:Kp,children:C})),D&&i.jsx("button",{type:"button","data-testid":"g7le-overlay-info-button","aria-label":"info",onClick:K=>{K.stopPropagation(),N(X=>!X)},"data-placement":M,style:{position:"absolute",...H,width:20,height:20,borderRadius:10,border:"1px solid #2563eb",background:"#fff",color:"#2563eb",fontSize:12,fontWeight:700,cursor:"pointer",pointerEvents:"auto",padding:0,lineHeight:"18px",zIndex:Ln},children:"ⓘ"}),o==="none"&&i.jsx(q7,{enabledAxes:$,onHandlePointerDown:S}),o==="base"&&h&&i.jsxs("button",{type:"button","data-testid":"g7le-overlay-edit-base",onClick:K=>{K.stopPropagation(),h()},style:{...Wo,...P},children:["🔒 ",E("layout_editor.overlay.edit_common_layout"),_?i.jsx("span",{"data-testid":"g7le-overlay-base-layout-label",style:aa,children:_}):null]}),o==="extension"&&v&&i.jsxs("button",{type:"button","data-testid":"g7le-overlay-edit-extension",onClick:K=>{K.stopPropagation(),v()},style:{...Wo,...P},children:["🔒 ",E("layout_editor.overlay.edit_extension"),y?i.jsx("span",{"data-testid":"g7le-overlay-extension-label",style:aa,children:y}):null]}),o==="data_bound"&&i.jsxs("span",{"data-testid":"g7le-overlay-data-bound-notice",style:{...Wo,...L,pointerEvents:"none",cursor:"default"},children:[E("layout_editor.overlay.locked_data_bound"),w?i.jsx("span",{"data-testid":"g7le-overlay-data-source-label",style:aa,children:w}):null]}),o==="data_bound"&&x&&i.jsxs("button",{type:"button","data-testid":"g7le-overlay-edit-iteration",onClick:K=>{K.stopPropagation(),x()},style:{...Wo,...F},children:["↳ ",E("layout_editor.overlay.edit_iteration_item")]}),r==="route_in_tree"&&i.jsx("button",{type:"button","data-testid":"g7le-overlay-link-edit-destination",onClick:K=>{K.stopPropagation(),m()},style:{...Wo,...F},children:E("layout_editor.overlay.edit_destination_route")}),(d||p||g&&(b??[]).length>0)&&i.jsxs("div",{"data-testid":"g7le-overlay-branch-affordances",style:{position:"absolute",...Y,display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4,pointerEvents:"none"},children:[g&&(b??[]).map(K=>i.jsxs("button",{type:"button","data-testid":`g7le-overlay-jump-device-${K.key}`,title:E("layout_editor.overlay.jump_device_hint",{device:K.label}),onClick:X=>{X.stopPropagation(),g(K.key)},style:sa,children:["↗ ",E("layout_editor.overlay.jump_device",{device:K.label})]},K.key)),d&&i.jsxs("button",{type:"button","data-testid":"g7le-overlay-separate-branch",title:E("layout_editor.context_menu.separate_branch_hint"),onClick:K=>{K.stopPropagation(),d()},style:sa,children:["📱 ",c??E("layout_editor.context_menu.separate_branch")]}),p&&i.jsxs("button",{type:"button","data-testid":"g7le-overlay-merge-branch",title:E("layout_editor.context_menu.merge_branch_hint"),onClick:K=>{K.stopPropagation(),p()},style:sa,children:["↩️ ",f??E("layout_editor.context_menu.merge_branch")]})]})]}),i.jsx(K7,{anchor:n&&B?{left:n.left+n.width+8,top:n.top-4}:null,open:B,onClose:()=>N(!1),onEditProps:s,onDuplicate:a,onDelete:l,onSeparateBranch:d,separateBranchLabel:c,onMergeBranch:p,mergeBranchLabel:f})]})}function q7(e){const{enabledAxes:t,onHandlePointerDown:n}=e,o=t?.width??!1,r=t?.height??!1,s=[{key:"nw",style:{left:-4,top:-4},cursor:"nwse-resize",needsWidth:!0,needsHeight:!0},{key:"n",style:{left:"50%",top:-4,transform:"translateX(-50%)"},cursor:"ns-resize",needsWidth:!1,needsHeight:!0},{key:"ne",style:{right:-4,top:-4},cursor:"nesw-resize",needsWidth:!0,needsHeight:!0},{key:"e",style:{right:-4,top:"50%",transform:"translateY(-50%)"},cursor:"ew-resize",needsWidth:!0,needsHeight:!1},{key:"se",style:{right:-4,bottom:-4},cursor:"nwse-resize",needsWidth:!0,needsHeight:!0},{key:"s",style:{left:"50%",bottom:-4,transform:"translateX(-50%)"},cursor:"ns-resize",needsWidth:!1,needsHeight:!0},{key:"sw",style:{left:-4,bottom:-4},cursor:"nesw-resize",needsWidth:!0,needsHeight:!0},{key:"w",style:{left:-4,top:"50%",transform:"translateY(-50%)"},cursor:"ew-resize",needsWidth:!0,needsHeight:!1}];return i.jsx(i.Fragment,{children:s.map(a=>{const l=!a.needsWidth||o,d=!a.needsHeight||r,c=l&&d&&!!n;return!l||!d?null:i.jsx("span",{"data-testid":`g7le-resize-handle-${a.key}`,"data-resize-handle-active":c?"true":"false",onPointerDown:c?p=>{p.preventDefault(),p.stopPropagation(),n?.(a.key,{clientX:p.clientX,clientY:p.clientY})}:void 0,style:{position:"absolute",...a.style,width:8,height:8,background:"#fff",border:"1px solid #2563eb",cursor:a.cursor,pointerEvents:c?"auto":"none",zIndex:Ln}},a.key)})})}const Wo={position:"absolute",top:-28,left:0,background:"#fff",border:"1px solid #2563eb",color:"#2563eb",padding:"2px 6px",fontSize:11,borderRadius:4,cursor:"pointer",pointerEvents:"auto",whiteSpace:"nowrap",zIndex:Ln},sa={background:"#fff",border:"1px solid #2563eb",color:"#2563eb",padding:"2px 6px",fontSize:11,borderRadius:4,cursor:"pointer",pointerEvents:"auto",whiteSpace:"nowrap",zIndex:Ln},aa={marginLeft:6,padding:"0 5px",borderRadius:3,background:"#eef2ff",border:"1px solid #c7d2fe",fontSize:10,fontWeight:600,color:"#3730a3"},G7={position:"absolute",top:0,right:0,transform:"translateY(-100%)",background:"rgba(124,58,237,0.92)",color:"#fff",padding:"1px 6px",borderRadius:"3px 3px 0 0",fontSize:10,fontWeight:600,whiteSpace:"nowrap",pointerEvents:"none"},Kp={position:"absolute",top:0,left:0,background:"rgba(37,99,235,0.55)",color:"#fff",padding:"1px 6px",fontSize:10,fontWeight:600,lineHeight:"14px",borderBottomRightRadius:4,letterSpacing:"0.02em",whiteSpace:"nowrap",pointerEvents:"none",userSelect:"none",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis"},Vp={position:"absolute",bottom:"100%",left:0,marginBottom:2,background:"rgba(37,99,235,0.55)",color:"#fff",padding:"1px 6px",fontSize:10,fontWeight:600,lineHeight:"14px",borderRadius:4,letterSpacing:"0.02em",whiteSpace:"nowrap",pointerEvents:"none",userSelect:"none"},Y7={...Kp,pointerEvents:"auto",cursor:"pointer",background:"rgba(37,99,235,0.82)",border:"none",display:"inline-flex",alignItems:"center",font:"inherit",fontSize:10,fontWeight:600,zIndex:Ln},X7={...Vp,pointerEvents:"auto",cursor:"pointer",background:"rgba(37,99,235,0.82)",border:"none",display:"inline-flex",alignItems:"center",font:"inherit",fontSize:10,fontWeight:600,zIndex:Ln},J7={above:{top:-30,left:"50%",transform:"translateX(-50%)"},below:{bottom:-30,left:"50%",transform:"translateX(-50%)"},left:{left:-30,top:"50%",transform:"translateY(-50%)"},right:{right:-30,top:"50%",transform:"translateY(-50%)"}};function Z7(e){const{selectedBox:t,points:n,onAddRequest:o}=e,{t:r}=tt();if(!t||n.length===0)return null;const s=Mp(t),l=s==="outside"?Pp(t):null;return i.jsx("div",{className:"g7le-insertion-affordances","data-testid":"g7le-insertion-affordances",style:{position:"absolute",left:t.left,top:t.top,width:t.width,height:t.height,pointerEvents:"none"},children:n.map(d=>{const c=l?{left:l[d.direction].left,top:l[d.direction].top}:J7[d.direction],p=r(`layout_editor.insertion.${d.direction}`);return i.jsx("button",{type:"button",disabled:d.disabled,"data-testid":`g7le-insertion-${d.direction}`,"data-disabled":d.disabled?"true":"false","data-placement":s,"aria-label":p,title:p,onClick:f=>{f.stopPropagation(),d.disabled||o(d)},style:{position:"absolute",...c,width:24,height:24,borderRadius:12,border:"1px solid #2563eb",background:d.disabled?"#cbd5e1":"#fff",color:d.disabled?"#94a3b8":"#2563eb",cursor:d.disabled?"not-allowed":"pointer",opacity:d.disabled?.4:1,fontSize:16,fontWeight:700,lineHeight:"20px",padding:0,pointerEvents:"auto",boxShadow:"0 1px 3px rgba(0,0,0,0.15)",zIndex:Ln},children:"+"},d.direction)})})}const Rr=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function co(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function la(e){return"nodeType"in e}function xt(e){var t,n;return e?co(e)?e:la(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function da(e){const{Document:t}=xt(e);return e instanceof t}function jo(e){return co(e)?!1:e instanceof xt(e).HTMLElement}function Up(e){return e instanceof xt(e).SVGElement}function uo(e){return e?co(e)?e.document:la(e)?da(e)?e:jo(e)||Up(e)?e.ownerDocument:document:document:document}const sn=Rr?u.useLayoutEffect:u.useEffect;function ei(e){const t=u.useRef(e);return sn(()=>{t.current=e}),u.useCallback(function(){for(var n=arguments.length,o=new Array(n),r=0;r{e.current=setInterval(o,r)},[]),n=u.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Ho(e,t){t===void 0&&(t=[e]);const n=u.useRef(e);return sn(()=>{n.current!==e&&(n.current=e)},t),n}function Fo(e,t){const n=u.useRef();return u.useMemo(()=>{const o=e(n.current);return n.current=o,o},[...t])}function ti(e){const t=ei(e),n=u.useRef(null),o=u.useCallback(r=>{r!==n.current&&t?.(r,n.current),n.current=r},[]);return[n,o]}function ni(e){const t=u.useRef();return u.useEffect(()=>{t.current=e},[e]),t.current}let ca={};function oi(e,t){return u.useMemo(()=>{if(t)return t;const n=ca[e]==null?0:ca[e]+1;return ca[e]=n,e+"-"+n},[e,t])}function qp(e){return function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r{const l=Object.entries(a);for(const[d,c]of l){const p=s[d];p!=null&&(s[d]=p+e*c)}return s},{...t})}}const po=qp(1),ri=qp(-1);function R7(e){return"clientX"in e&&"clientY"in e}function ua(e){if(!e)return!1;const{KeyboardEvent:t}=xt(e.target);return t&&e instanceof t}function e2(e){if(!e)return!1;const{TouchEvent:t}=xt(e.target);return t&&e instanceof t}function ii(e){if(e2(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return R7(e)?{x:e.clientX,y:e.clientY}:null}const Ko=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Ko.Translate.toString(e),Ko.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:o}=e;return t+" "+n+"ms "+o}}}),Gp="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function t2(e){return e.matches(Gp)?e:e.querySelector(Gp)}const n2={display:"none"};function o2(e){let{id:t,value:n}=e;return u.createElement("div",{id:t,style:n2},n)}function r2(e){let{id:t,announcement:n,ariaLiveType:o="assertive"}=e;const r={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return u.createElement("div",{id:t,style:r,role:"status","aria-live":o,"aria-atomic":!0},n)}function i2(){const[e,t]=u.useState("");return{announce:u.useCallback(o=>{o!=null&&t(o)},[]),announcement:e}}const Yp=u.createContext(null);function s2(e){const t=u.useContext(Yp);u.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of ");return t(e)},[e,t])}function a2(){const[e]=u.useState(()=>new Set),t=u.useCallback(o=>(e.add(o),()=>e.delete(o)),[e]);return[u.useCallback(o=>{let{type:r,event:s}=o;e.forEach(a=>{var l;return(l=a[r])==null?void 0:l.call(a,s)})},[e]),t]}const l2={draggable:` +`);return t.length>0&&t[t.length-1]===""&&t.pop(),t}const rp=4e3;function X$(e,t,n=3){const o=op(e),r=op(t);let s=0;const a=Math.min(o.length,r.length);for(;srp||p.length>rp)return{hunks:[],addedCount:-1,removedCount:-1,identical:!1};const f=G$(c,p),b=Y$(c,p,f),g=[];let m=s,h=s,v=0,y=0;for(let k=0;k{const s=e.slice(r.start,r.end+1);let a=0,l=0,d=0,c=0;for(const g of s)g.oldLine!==null&&(a===0&&(a=g.oldLine),d++),g.newLine!==null&&(l===0&&(l=g.newLine),c++);const p=a||(d===0?0:1),f=l||(c===0?0:1);return{header:`@@ -${p},${d} +${f},${c} @@`,oldStart:p,oldCount:d,newStart:f,newCount:c,lines:s}})}function ip(e){return JSON.stringify(ra(e),null,2)}function ra(e){if(Array.isArray(e))return e.map(ra);if(e&&typeof e=="object"){const t=e,n={};for(const o of Object.keys(t).sort())n[o]=ra(t[o]);return n}return e}const Z$={display:"flex",flexDirection:"column",height:"100%",minHeight:0},Q$={display:"flex",alignItems:"center",gap:8,padding:"12px 16px",borderBottom:"1px solid #e2e8f0",background:"#f8fafc"},R$={display:"inline-flex",alignItems:"center",gap:4,padding:"4px 10px",borderRadius:6,border:"1px solid #cbd5e1",background:"#ffffff",color:"#0f172a",fontSize:12,fontWeight:600,cursor:"pointer",outline:"none"},eE={marginLeft:"auto",border:"none",background:"transparent",fontSize:16,color:"#64748b",cursor:"pointer",outline:"none"},tE={display:"flex",alignItems:"center",gap:12,padding:"8px 16px",borderBottom:"1px solid #e2e8f0",background:"#ffffff",fontSize:12,fontWeight:600},nE={flex:1,minHeight:0,overflow:"auto",background:"#ffffff",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace',fontSize:12,lineHeight:1.5},sp={padding:"24px 12px",textAlign:"center",color:"#94a3b8",fontSize:13},oE={padding:"2px 12px",background:"#f1f5f9",color:"#64748b",borderTop:"1px solid #e2e8f0",borderBottom:"1px solid #e2e8f0",userSelect:"none"};function rE(e){return e==="add"?{row:{background:"#e6ffed"},gutter:{background:"#cdffd8",color:"#22863a"},sign:"+",signColor:"#22863a"}:e==="remove"?{row:{background:"#ffeef0"},gutter:{background:"#ffdce0",color:"#b31d28"},sign:"-",signColor:"#b31d28"}:{row:{background:"#ffffff"},gutter:{background:"#f8fafc",color:"#94a3b8"},sign:" ",signColor:"#94a3b8"}}const ap={display:"inline-block",width:44,textAlign:"right",padding:"0 6px",color:"#94a3b8",userSelect:"none",borderRight:"1px solid #e2e8f0",whiteSpace:"nowrap"};function iE({oldVersion:e,newVersion:t,oldContent:n,newContent:o,t:r,onBack:s,onClose:a}){const l=u.useMemo(()=>{const c=ip(n),p=ip(o);return X$(c,p)},[n,o]),d=l.addedCount<0;return i.jsxs("div",{className:"g7le-version-diff","data-testid":"g7le-version-diff",style:Z$,children:[i.jsxs("div",{"data-modal-drag-handle":!0,style:Q$,children:[i.jsxs("button",{type:"button",onClick:s,style:R$,"data-testid":"g7le-version-diff-back",children:["← ",r("layout_editor.version_history.diff_back")]}),i.jsx("span",{style:{fontSize:14,fontWeight:700},"data-testid":"g7le-version-diff-title",children:r("layout_editor.version_history.diff_title",{old:e,new:t})}),i.jsx("button",{type:"button","aria-label":r("layout_editor.version_history.close"),onClick:a,style:eE,"data-testid":"g7le-version-diff-close",children:"✕"})]}),!d&&i.jsxs("div",{style:tE,"data-testid":"g7le-version-diff-summary",children:[i.jsx("span",{style:{color:"#16a34a"},"data-testid":"g7le-version-diff-added",children:r("layout_editor.version_history.added",{count:Math.max(0,l.addedCount)})}),i.jsx("span",{style:{color:"#dc2626"},"data-testid":"g7le-version-diff-removed",children:r("layout_editor.version_history.removed",{count:Math.max(0,l.removedCount)})})]}),i.jsx("div",{style:nE,children:d?i.jsx("div",{style:sp,"data-testid":"g7le-version-diff-too-large",children:r("layout_editor.version_history.diff_too_large")}):l.identical?i.jsx("div",{style:sp,"data-testid":"g7le-version-diff-identical",children:r("layout_editor.version_history.diff_identical")}):l.hunks.map((c,p)=>i.jsxs("div",{"data-testid":`g7le-version-diff-hunk-${p}`,children:[i.jsx("div",{style:oE,"data-testid":`g7le-version-diff-hunk-header-${p}`,children:c.header}),c.lines.map((f,b)=>{const g=rE(f.kind);return i.jsxs("div",{style:{display:"flex",alignItems:"stretch",...g.row},"data-kind":f.kind,"data-testid":`g7le-version-diff-line-${p}-${b}`,children:[i.jsx("span",{style:{...ap,...g.gutter},"aria-hidden":"true",children:f.oldLine??""}),i.jsx("span",{style:{...ap,...g.gutter},"aria-hidden":"true",children:f.newLine??""}),i.jsx("span",{style:{display:"inline-block",width:16,textAlign:"center",color:g.signColor,userSelect:"none",fontWeight:700},"aria-hidden":"true",children:g.sign}),i.jsx("span",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",flex:1,padding:"0 4px"},children:f.content})]},b)})]},p))})]})}const sE={display:"flex",flexDirection:"column",height:"100%",minHeight:0},aE={display:"flex",alignItems:"center",gap:8,padding:"12px 16px",borderBottom:"1px solid #e2e8f0",background:"#f8fafc"},lE={marginLeft:"auto",border:"none",background:"transparent",fontSize:16,color:"#64748b",cursor:"pointer",outline:"none"},dE={flex:1,minHeight:0,overflowY:"auto",padding:12},lp={padding:"24px 12px",textAlign:"center",color:"#94a3b8",fontSize:13},cE={margin:"8px 16px 0",padding:"8px 12px",borderRadius:6,background:"#fef2f2",color:"#b91c1c",fontSize:12,border:"1px solid #fecaca"},uE={display:"flex",flexDirection:"column",gap:8},pE={display:"flex",alignItems:"center",gap:12,padding:"10px 12px",borderRadius:8,border:"1px solid #e2e8f0",background:"#ffffff"},fE={display:"inline-flex",alignItems:"center",justifyContent:"center",minWidth:44,padding:"2px 8px",borderRadius:999,background:"#eff6ff",color:"#1d4ed8",fontSize:12,fontWeight:700},gE={display:"inline-flex",alignItems:"center",padding:"1px 8px",borderRadius:999,background:"#0f172a",color:"#ffffff",fontSize:10,fontWeight:700,letterSpacing:.3},hE={display:"flex",alignItems:"center",gap:10,fontSize:11,fontWeight:600},yE={display:"flex",flexDirection:"column",gap:2,minWidth:0,flex:1},dp={padding:"6px 12px",borderRadius:6,border:"1px solid #cbd5e1",background:"#ffffff",color:"#0f172a",fontSize:12,fontWeight:600,cursor:"pointer",outline:"none",whiteSpace:"nowrap"};function cp(e){return e.full_content&&typeof e.full_content=="object"?e.full_content:{endpoint:e.endpoint,components:e.components,data_sources:e.data_sources,metadata:e.metadata}}function bE(e){if(!e)return"";const t=Date.parse(e);if(Number.isNaN(t))return e;try{return new Date(t).toLocaleString()}catch{return e}}function mE({templateIdentifier:e,target:t,t:n,onRestored:o,onClose:r}){const{versions:s,isLoading:a,isLoadingMore:l,error:d,restoringId:c,hasMore:p,loadVersions:f,loadMore:b,restore:g,loadVersionDetail:m}=q$(e,t,o),[h,v]=u.useState(null),[y,_]=u.useState(null),[w,k]=u.useState(null);u.useEffect(()=>{f()},[f]);const x=u.useCallback(async S=>{v(null),k(S.version);try{const D=await m(S.version);if(D.kind!=="success"){v(D.kind==="not_found"?n("layout_editor.version_history.restore_not_found"):D.message);return}const E=S.version-1,I=s.some(T=>T.version===E);let N={};if(I){const T=await m(E);if(T.kind==="success")N=cp(T.detail);else if(T.kind==="network_error"){v(T.message);return}}_({oldVersion:I?E:0,newVersion:S.version,oldContent:N,newContent:cp(D.detail)})}finally{k(null)}},[m,s,n]),$=u.useCallback(async S=>{v(null);const D=n("layout_editor.version_history.restore_confirm");if(!(typeof window<"u"?window.confirm(D):!0))return;const I=await g(S);I.kind==="success"?r():I.kind==="not_found"?v(n("layout_editor.version_history.restore_not_found")):v(I.message)},[g,r,n]),C=h??d;return y?i.jsx(iE,{oldVersion:y.oldVersion,newVersion:y.newVersion,oldContent:y.oldContent,newContent:y.newContent,t:n,onBack:()=>_(null),onClose:r}):i.jsxs("div",{className:"g7le-version-history","data-testid":"g7le-version-history",style:sE,children:[i.jsxs("div",{"data-modal-drag-handle":!0,style:aE,children:[i.jsxs("span",{style:{fontSize:14,fontWeight:700},"data-testid":"g7le-version-history-title",children:["🕘 ",n("layout_editor.version_history.title")]}),i.jsx("button",{type:"button","aria-label":n("layout_editor.version_history.close"),onClick:r,style:lE,"data-testid":"g7le-version-history-close",children:"✕"})]}),C&&i.jsx("div",{style:cE,"data-testid":"g7le-version-history-error",children:C}),i.jsx("div",{style:dE,children:a?i.jsx("div",{style:lp,"data-testid":"g7le-version-history-loading",children:n("layout_editor.version_history.loading")}):s.length===0?i.jsx("div",{style:lp,"data-testid":"g7le-version-history-empty",children:n("layout_editor.version_history.empty")}):i.jsxs("div",{"data-testid":"g7le-version-history-list",style:uE,children:[s.map((S,D)=>{const E=S.changes_summary,I=E?.added_count??0,N=E?.removed_count??0,T=E?.char_diff??0,B=bE(S.created_at),M=c===S.id,O=D===0;return i.jsxs("div",{style:pE,"data-testid":`g7le-version-row-${S.id}`,children:[i.jsxs("span",{style:fE,"data-testid":`g7le-version-badge-${S.id}`,children:["v",S.version]}),i.jsxs("div",{style:yE,children:[i.jsxs("span",{style:{display:"flex",alignItems:"center",gap:8},children:[B&&i.jsx("span",{style:{fontSize:12,color:"#475569",fontWeight:600},children:B}),O&&i.jsx("span",{style:gE,"data-testid":`g7le-version-latest-${S.id}`,children:n("layout_editor.version_history.latest")})]}),i.jsxs("span",{style:hE,"data-testid":`g7le-version-summary-${S.id}`,children:[i.jsx("span",{style:{color:"#16a34a"},"data-testid":`g7le-version-added-${S.id}`,children:n("layout_editor.version_history.added",{count:I})}),i.jsx("span",{style:{color:"#dc2626"},"data-testid":`g7le-version-removed-${S.id}`,children:n("layout_editor.version_history.removed",{count:N})}),i.jsx("span",{style:{color:"#94a3b8",fontWeight:500},"data-testid":`g7le-version-chars-${S.id}`,children:n("layout_editor.version_history.chars",{diff:`${T>=0?"+":""}${T}`})})]}),i.jsx("span",{style:{fontSize:11,color:"#94a3b8"},"data-testid":`g7le-version-author-${S.id}`,children:n("layout_editor.version_history.saved_by",{name:S.created_by_name??n("layout_editor.version_history.unknown_author")})})]}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[i.jsx("button",{type:"button",onClick:()=>void x(S),disabled:w!==null,style:{...dp,background:"#f8fafc",opacity:w!==null?.6:1},"data-testid":`g7le-version-compare-${S.id}`,children:w===S.version?n("layout_editor.version_history.comparing"):n("layout_editor.version_history.compare")}),!O&&i.jsx("button",{type:"button",onClick:()=>void $(S.id),disabled:M||c!==null,style:{...dp,opacity:M||c!==null?.6:1},"data-testid":`g7le-version-restore-${S.id}`,children:n(M?"layout_editor.version_history.restoring":"layout_editor.version_history.restore")})]})]},S.id)}),p&&i.jsx("button",{type:"button","data-testid":"g7le-version-history-load-more",style:vE,disabled:l,onClick:()=>{b()},children:n(l?"layout_editor.version_history.loading":"layout_editor.version_history.load_more")})]})})]})}const vE={width:"100%",marginTop:8,padding:"8px 12px",fontSize:12,color:"#475569",background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:6,cursor:"pointer"};function Wo(e){return`/api/admin/extensions/${encodeURIComponent(e.type)}/${encodeURIComponent(e.identifier)}/custom-assets`}function jo(e,t){const n=e?.message;return typeof n=="string"&&n!==""?n:`HTTP ${t}`}function _E(e){const[t,n]=u.useState([]),[o,r]=u.useState(null),[s,a]=u.useState(!1),[l,d]=u.useState(!1),[c,p]=u.useState(null),f=u.useCallback(async()=>{a(!0),p(null);try{const v=await fetch(Wo(e),{credentials:"same-origin",headers:Me()}),y=await v.json().catch(()=>null);if(v.status===401||v.status===403){d(!0),n([]);return}if(d(!1),!v.ok){p(jo(y,v.status)),n([]);return}const _=y?.data??{},w=_.files;n(Array.isArray(w)?w:[]),r({editable_extensions:_.editable_extensions??[],uploadable_extensions:_.uploadable_extensions??[],max_text_bytes:_.max_text_bytes??0,max_upload_bytes:_.max_upload_bytes??0})}catch(v){p(v instanceof Error?v.message:"network error"),n([])}finally{a(!1)}},[e.type,e.identifier]),b=u.useCallback(async v=>{p(null);try{const y=`${Wo(e)}/content?path=${encodeURIComponent(v)}`,_=await fetch(y,{credentials:"same-origin",headers:Me()}),w=await _.json().catch(()=>null);if(!_.ok)return p(jo(w,_.status)),null;const k=w?.data?.content;return typeof k=="string"?k:""}catch(y){return p(y instanceof Error?y.message:"network error"),null}},[e.type,e.identifier]),g=u.useCallback(async(v,y)=>{p(null);try{const _=await fetch(`${Wo(e)}/content`,{method:"PUT",credentials:"same-origin",headers:Me({"Content-Type":"application/json"}),body:JSON.stringify({path:v,content:y})}),w=await _.json().catch(()=>null);return _.ok?(await f(),!0):(p(jo(w,_.status)),!1)}catch(_){return p(_ instanceof Error?_.message:"network error"),!1}},[e.type,e.identifier,f]),m=u.useCallback(async(v,y)=>{p(null);try{const _=new FormData;_.append("file",v),y&&_.append("directory",y);const w=await fetch(`${Wo(e)}/upload`,{method:"POST",credentials:"same-origin",headers:Me(),body:_}),k=await w.json().catch(()=>null);return w.ok?(await f(),!0):(p(jo(k,w.status)),!1)}catch(_){return p(_ instanceof Error?_.message:"network error"),!1}},[e.type,e.identifier,f]),h=u.useCallback(async v=>{p(null);try{const y=`${Wo(e)}?path=${encodeURIComponent(v)}`,_=await fetch(y,{method:"DELETE",credentials:"same-origin",headers:Me()}),w=await _.json().catch(()=>null);return _.ok?(await f(),!0):(p(jo(w,_.status)),!1)}catch(y){return p(y instanceof Error?y.message:"network error"),!1}},[e.type,e.identifier,f]);return{files:t,meta:o,isLoading:s,forbidden:l,error:c,reload:f,read:b,save:g,upload:m,remove:h}}const xE={display:"flex",flexDirection:"column",height:"100%",minHeight:0},wE={display:"flex",alignItems:"center",gap:8,padding:"12px 16px",borderBottom:"1px solid #e2e8f0",background:"#f8fafc",fontWeight:600,color:"#0f172a"},kE={marginLeft:"auto",border:"none",background:"transparent",fontSize:16,color:"#64748b",cursor:"pointer",outline:"none"},SE={flex:1,minHeight:0,display:"flex"},CE={width:260,flexShrink:0,borderRight:"1px solid #e2e8f0",overflowY:"auto",padding:8},$E={flex:1,minWidth:0,display:"flex",flexDirection:"column",padding:12,gap:8},up={display:"flex",alignItems:"center",gap:6,width:"100%",padding:"6px 8px",borderRadius:6,borderWidth:1,borderStyle:"solid",borderColor:"transparent",backgroundColor:"transparent",fontSize:12,color:"#334155",cursor:"pointer",textAlign:"left"},EE={...up,backgroundColor:"#eff6ff",borderColor:"#bfdbfe",color:"#1d4ed8",fontWeight:600},IE={margin:16,padding:16,borderRadius:8,border:"1px solid #fcd34d",background:"#fffbeb",color:"#92400e",fontSize:13,lineHeight:1.7},AE={padding:"8px 12px",borderRadius:6,border:"1px solid #fecaca",background:"#fef2f2",color:"#b91c1c",fontSize:12},TE={flex:1,minHeight:220,width:"100%",boxSizing:"border-box",padding:10,borderRadius:6,borderWidth:1,borderStyle:"solid",borderColor:"#cbd5e1",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:12,lineHeight:1.6,resize:"vertical"},pp={display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},ao={padding:"6px 12px",borderRadius:6,borderWidth:1,borderStyle:"solid",borderColor:"#cbd5e1",backgroundColor:"#ffffff",color:"#334155",fontSize:12,cursor:"pointer"},DE={...ao,backgroundColor:"#2563eb",borderColor:"#2563eb",color:"#ffffff",fontWeight:600},zE={...ao,borderColor:"#fca5a5",color:"#b91c1c"},NE={...ao,cursor:"text",minWidth:200},ME={...ao,cursor:"pointer",minWidth:220};function LE(e,t){if(typeof e=="string"&&e!=="")return e;if(e&&typeof e=="object"){const n=e,o=window?.G7Config?.locale??"ko",r=n[o]??n.ko??n.en??Object.values(n)[0];if(typeof r=="string"&&r!=="")return r}return t}function PE(e){const t=(typeof window<"u"?window.G7Config:null)??{},n=[{type:"template",identifier:e,label:e}];for(const[o,r]of[["module",t.activeModules],["plugin",t.activePlugins]])if(Array.isArray(r))for(const s of r){const a=typeof s?.identifier=="string"?s.identifier:"";a&&n.push({type:o,identifier:a,label:LE(s?.display_name,a)})}return n}function OE(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function BE(e){const{templateIdentifier:t,t:n,onClose:o}=e,r=u.useMemo(()=>PE(t),[t]),[s,a]=u.useState(`template:${t}`),l=u.useMemo(()=>r.find(C=>`${C.type}:${C.identifier}`===s)??r[0],[r,s]),d=_E({type:l.type,identifier:l.identifier}),{reload:c}=d,[p,f]=u.useState(null),[b,g]=u.useState(""),[m,h]=u.useState(""),[v,y]=u.useState(!1),_=u.useRef(null);u.useEffect(()=>{c()},[c]),u.useEffect(()=>{f(null),g(""),h("")},[s]);const w=u.useCallback(async C=>{if(f(C),!C.editable){g("");return}y(!0);const S=await d.read(C.path);y(!1),g(S??"")},[d]),k=u.useCallback(async()=>{const C=p?.path??m.trim();if(!C)return;y(!0);const S=await d.save(C,b);y(!1),S&&!p&&(h(""),f({path:C,name:C.split("/").pop()??C,extension:(C.split(".").pop()??"").toLowerCase(),size:b.length,modified_at:new Date().toISOString(),editable:!0,loaded:!0}))},[d,p,m,b]),x=u.useCallback(async()=>{if(!p||typeof window<"u"&&!window.confirm(n("layout_editor.custom_assets.delete_confirm")))return;y(!0);const C=await d.remove(p.path);y(!1),C&&(f(null),g(""))},[d,p,n]),$=u.useCallback(async C=>{const S=C.target.files?.[0];S&&(y(!0),await d.upload(S),y(!1),_.current&&(_.current.value=""))},[d]);return i.jsxs("div",{className:"g7le-custom-assets",style:xE,"data-testid":"g7le-custom-assets-modal",children:[i.jsxs("div",{style:wE,children:[i.jsxs("span",{children:["🎨 ",n("layout_editor.custom_assets.title")]}),i.jsx("select",{value:s,onChange:C=>a(C.target.value),style:ME,"aria-label":n("layout_editor.custom_assets.target_label"),"data-testid":"g7le-custom-assets-target",children:r.map(C=>i.jsxs("option",{value:`${C.type}:${C.identifier}`,children:[n(`layout_editor.custom_assets.type_${C.type}`)," · ",C.label]},`${C.type}:${C.identifier}`))}),i.jsx("button",{type:"button",style:kE,onClick:o,"aria-label":n("layout_editor.custom_assets.close"),"data-testid":"g7le-custom-assets-close",children:"✕"})]}),d.forbidden?i.jsx("div",{style:IE,"data-testid":"g7le-custom-assets-forbidden",children:n("layout_editor.custom_assets.forbidden")}):i.jsxs("div",{style:SE,children:[i.jsxs("div",{style:CE,"data-testid":"g7le-custom-assets-list",children:[d.isLoading&&d.files.length===0?i.jsx("div",{style:{padding:12,color:"#94a3b8",fontSize:12},children:n("layout_editor.custom_assets.loading")}):null,!d.isLoading&&d.files.length===0?i.jsx("div",{style:{padding:12,color:"#94a3b8",fontSize:12},children:n("layout_editor.custom_assets.empty")}):null,d.files.map(C=>i.jsxs("button",{type:"button",style:p?.path===C.path?EE:up,onClick:()=>void w(C),"data-testid":`g7le-custom-asset-row-${C.path}`,"data-loaded":C.loaded?"true":"false",children:[i.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:C.path}),i.jsx("span",{style:{color:"#94a3b8",fontSize:11},children:OE(C.size)})]},C.path))]}),i.jsxs("div",{style:$E,children:[d.error?i.jsx("div",{style:AE,"data-testid":"g7le-custom-assets-error",children:d.error}):null,i.jsxs("div",{style:pp,children:[i.jsx("input",{type:"text",value:p?p.path:m,readOnly:!!p,onChange:C=>h(C.target.value),placeholder:n("layout_editor.custom_assets.new_path_placeholder"),style:NE,"aria-label":n("layout_editor.custom_assets.path_label"),"data-testid":"g7le-custom-assets-path"}),p?i.jsx("button",{type:"button",style:ao,onClick:()=>{f(null),g("")},"data-testid":"g7le-custom-assets-new",children:n("layout_editor.custom_assets.new_file")}):null]}),p&&!p.editable?i.jsx("div",{style:{color:"#64748b",fontSize:12,lineHeight:1.7},children:n("layout_editor.custom_assets.binary_hint",{extension:p.extension})}):i.jsx("textarea",{value:b,onChange:C=>g(C.target.value),style:TE,spellCheck:!1,"aria-label":n("layout_editor.custom_assets.content_label"),"data-testid":"g7le-custom-assets-content"}),i.jsxs("div",{style:pp,children:[i.jsx("button",{type:"button",style:DE,disabled:v||(p?!p.editable:m.trim()===""),onClick:()=>void k(),"data-testid":"g7le-custom-assets-save",children:n("layout_editor.custom_assets.save")}),i.jsx("button",{type:"button",style:ao,disabled:v,onClick:()=>_.current?.click(),"data-testid":"g7le-custom-assets-upload",children:n("layout_editor.custom_assets.upload")}),i.jsx("input",{ref:_,type:"file",style:{display:"none"},onChange:C=>void $(C),"data-testid":"g7le-custom-assets-file-input"}),i.jsx("button",{type:"button",style:zE,disabled:v||!p,onClick:()=>void x(),"data-testid":"g7le-custom-assets-delete",children:n("layout_editor.custom_assets.delete")}),i.jsx("span",{style:{color:"#94a3b8",fontSize:11},children:n("layout_editor.custom_assets.apply_hint")})]})]})]})]})}const fp=[{id:"copy",group:"clipboard",combos:[{key:"c",mod:!0}],labelKey:"layout_editor.shortcuts.action.copy",requiresSelection:!0},{id:"cut",group:"clipboard",combos:[{key:"x",mod:!0}],labelKey:"layout_editor.shortcuts.action.cut",requiresSelection:!0},{id:"paste",group:"clipboard",combos:[{key:"v",mod:!0}],labelKey:"layout_editor.shortcuts.action.paste"},{id:"openProps",group:"element",combos:[{key:"enter"}],labelKey:"layout_editor.shortcuts.action.open_props",requiresSelection:!0},{id:"delete",group:"element",combos:[{key:"delete"},{key:"backspace"}],labelKey:"layout_editor.shortcuts.action.delete",requiresSelection:!0},{id:"selectParent",group:"element",combos:[{key:"arrowup"}],labelKey:"layout_editor.shortcuts.action.select_parent",requiresSelection:!0},{id:"deselect",group:"element",combos:[{key:"escape"}],labelKey:"layout_editor.shortcuts.action.deselect"},{id:"addElement",group:"element",combos:[{key:"/",mod:!0}],labelKey:"layout_editor.shortcuts.action.add_element"},{id:"undo",group:"history",combos:[{key:"z",mod:!0}],labelKey:"layout_editor.shortcuts.action.undo"},{id:"redo",group:"history",combos:[{key:"z",mod:!0,shift:!0},{key:"y",mod:!0}],labelKey:"layout_editor.shortcuts.action.redo"},{id:"editCode",group:"view",combos:[{key:"e",mod:!0}],labelKey:"layout_editor.shortcuts.action.edit_code"},{id:"preview",group:"view",combos:[{key:"p",mod:!0}],labelKey:"layout_editor.shortcuts.action.preview"},{id:"translations",group:"view",combos:[{key:"l",mod:!0}],labelKey:"layout_editor.shortcuts.action.translations"},{id:"help",group:"view",combos:[{key:"?"}],labelKey:"layout_editor.shortcuts.action.help"},{id:"reset",group:"document",combos:[{key:"r",mod:!0,shift:!0}],labelKey:"layout_editor.shortcuts.action.reset"},{id:"save",group:"document",combos:[{key:"s",mod:!0}],labelKey:"layout_editor.shortcuts.action.save"},{id:"exit",group:"document",combos:[{key:"escape"}],labelKey:"layout_editor.shortcuts.action.exit"}];function WE(e){return{key:(e.key||"").toLowerCase(),mod:e.ctrlKey||e.metaKey,shift:e.shiftKey,alt:e.altKey}}function jE(e,t){return e.key===t.key&&!!e.mod==!!t.mod&&!!e.shift==!!t.shift&&!!e.alt==!!t.alt}function HE(e){for(const t of fp)if(t.combos.some(n=>jE(n,e)))return t;return null}function FE(e,t){const n=[];return e.mod&&n.push(t?"⌘":"Ctrl"),e.shift&&n.push(t?"⇧":"Shift"),e.alt&&n.push(t?"⌥":"Alt"),n.push(KE(e.key)),n.join(" + ")}function KE(e){return{arrowup:"↑",arrowdown:"↓",arrowleft:"←",arrowright:"→",enter:"Enter",escape:"Esc",delete:"Delete",backspace:"Backspace"," ":"Space"}[e]??(e.length===1?e.toUpperCase():e)}const VE=["clipboard","element","history","view","document"],UE={clipboard:"layout_editor.shortcuts.group.clipboard",element:"layout_editor.shortcuts.group.element",history:"layout_editor.shortcuts.group.history",view:"layout_editor.shortcuts.group.view",document:"layout_editor.shortcuts.group.document"};function qE(){return typeof navigator>"u"?!1:/mac|iphone|ipad|ipod/i.test(navigator.platform||navigator.userAgent||"")}function GE({t:e,onClose:t,isMac:n}){const o=n??qE(),r=u.useMemo(()=>{const s=new Map;for(const a of fp){const l=s.get(a.group)??[];l.push(a),s.set(a.group,l)}return s},[]);return i.jsxs("div",{className:"g7le-shortcut-help","data-testid":"g7le-shortcut-help",style:YE,children:[i.jsxs("div",{style:XE,children:[i.jsx("span",{style:JE,children:e("layout_editor.shortcuts.title")}),i.jsx("button",{type:"button","data-testid":"g7le-shortcut-help-close",onClick:t,"aria-label":e("layout_editor.shortcuts.close"),style:ZE,children:"✕"})]}),i.jsx("div",{style:QE,children:VE.map(s=>{const a=r.get(s);return!a||a.length===0?null:i.jsxs("div",{style:RE,"data-testid":`g7le-shortcut-group-${s}`,children:[i.jsx("div",{style:e7,children:e(UE[s])}),i.jsx("table",{style:t7,children:i.jsx("tbody",{children:a.map(l=>i.jsxs("tr",{"data-testid":`g7le-shortcut-row-${l.id}`,children:[i.jsx("td",{style:n7,children:e(l.labelKey)}),i.jsx("td",{style:o7,children:l.combos.map((d,c)=>i.jsxs(u.Fragment,{children:[c>0&&i.jsx("span",{style:i7,children:e("layout_editor.shortcuts.or")}),i.jsx("kbd",{style:r7,children:FE(d,o)})]},c))})]},l.id))})})]},s)})}),i.jsx("div",{style:s7,children:e("layout_editor.shortcuts.footnote")})]})}const YE={display:"flex",flexDirection:"column",padding:20,gap:16,width:"100%",boxSizing:"border-box"},XE={display:"flex",alignItems:"center",justifyContent:"space-between",paddingBottom:12,borderBottom:"1px solid #e2e8f0"},JE={fontSize:15,fontWeight:700,color:"#0f172a"},ZE={width:28,height:28,border:"none",background:"transparent",color:"#64748b",cursor:"pointer",fontSize:14,borderRadius:6},QE={display:"grid",gridTemplateColumns:"1fr 1fr",columnGap:28,rowGap:18,alignItems:"start"},RE={display:"flex",flexDirection:"column",gap:6},e7={fontSize:12,fontWeight:700,color:"#2563eb"},t7={width:"100%",borderCollapse:"collapse"},n7={padding:"4px 0",fontSize:12.5,color:"#334155",textAlign:"left",whiteSpace:"nowrap",verticalAlign:"middle"},o7={padding:"4px 0",paddingLeft:12,textAlign:"right",verticalAlign:"middle"},r7={display:"inline-block",padding:"1px 6px",fontSize:11,fontFamily:"ui-monospace, monospace",color:"#0f172a",background:"#f1f5f9",border:"1px solid #cbd5e1",borderBottomWidth:2,borderRadius:5,whiteSpace:"nowrap"},i7={fontSize:11,color:"#94a3b8",margin:"0 4px"},s7={fontSize:11,color:"#94a3b8",paddingTop:12,borderTop:"1px solid #f1f5f9"};function a7(e){if(!e||!(e instanceof HTMLElement))return!1;const t=e.tagName;return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable)}function l7(){return typeof document>"u"?!1:!!document.querySelector(".g7le-modal-backdrop, .g7le-modal")}function gp(e){const{handlers:t,hasSelection:n,enabled:o=!0}=e;u.useEffect(()=>{if(!o||typeof window>"u")return;const r=s=>{if(a7(s.target))return;const a=WE(s),l=HE(a);if(!l||l7()||l.requiresSelection&&!n)return;if(l.key==="escape"||a.key==="escape"){if(n){const c=t.deselect;c&&(s.preventDefault(),c())}else{const c=t.exit;c&&(s.preventDefault(),c())}return}const d=t[l.id];d&&(s.preventDefault(),d())};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[t,n,o])}function d7(e){const{result:t,onDismiss:n,onLoadLatest:o,onKeepMyChanges:r}=e,{t:s}=et();if(u.useEffect(()=>{if(!t||t.kind==="concurrent_modification"||t.kind==="validation_failed")return;const a=setTimeout(n,5e3);return()=>clearTimeout(a)},[t,n]),!t)return null;if(t.kind==="success")return i.jsx(Ho,{tone:"success",testId:"g7le-save-banner-success",onDismiss:n,children:s("layout_editor.save.success")});if(t.kind==="validation_failed"){const a=t.errors??{},l=Object.entries(a);return i.jsxs(Ho,{tone:"error",testId:"g7le-save-banner-validation",onDismiss:n,children:[i.jsx("strong",{children:s("layout_editor.save.validation_failed")}),l.length>0&&i.jsx("ul",{style:hp,"data-testid":"g7le-save-banner-validation-errors",children:l.map(([d,c])=>i.jsxs("li",{children:[i.jsx("code",{style:yp,children:d}),": ",c.join(", ")]},d))})]})}return t.kind==="blocked_inactive_extension"?i.jsxs(Ho,{tone:"warning",testId:"g7le-save-banner-blocked",onDismiss:n,children:[i.jsx("strong",{children:s("layout_editor.save.blocked_inactive_extension")}),t.blockedPaths.length>0&&i.jsx("ul",{style:hp,"data-testid":"g7le-save-banner-blocked-paths",children:t.blockedPaths.map(a=>i.jsx("li",{children:i.jsx("code",{style:yp,children:a})},a))})]}):t.kind==="network_error"?i.jsxs(Ho,{tone:"error",testId:"g7le-save-banner-network",onDismiss:n,children:[i.jsx("strong",{children:s("layout_editor.save.network_error_title")}),i.jsx("div",{style:{marginTop:4,fontSize:12},children:t.message})]}):t.kind==="guard_no_document"?i.jsx(Ho,{tone:"neutral",testId:"g7le-save-banner-guard-no-document",onDismiss:n,children:s("layout_editor.save.guard_no_document")}):i.jsx("div",{role:"dialog","aria-modal":"true","aria-label":s("layout_editor.save.concurrent.title"),"data-testid":"g7le-save-banner-concurrent",style:f7,children:i.jsxs("div",{style:g7,children:[i.jsx("h2",{style:h7,children:s("layout_editor.save.concurrent.title")}),i.jsx("p",{style:y7,children:s("layout_editor.save.concurrent.message")}),i.jsx("div",{style:b7,children:s("layout_editor.save.concurrent.version_info",{current:String(t.currentVersion),yours:String(t.yourVersion)})}),i.jsxs("div",{style:m7,children:[i.jsx("button",{type:"button","data-testid":"g7le-save-banner-concurrent-load-latest",onClick:()=>{o?.(),n()},style:v7,children:s("layout_editor.save.concurrent.load_latest")}),i.jsx("button",{type:"button","data-testid":"g7le-save-banner-concurrent-keep-mine",onClick:()=>{r?.(),n()},style:_7,children:s("layout_editor.save.concurrent.view_my_changes")}),i.jsx("button",{type:"button","data-testid":"g7le-save-banner-concurrent-cancel",onClick:n,style:x7,children:s("layout_editor.save.concurrent.cancel")})]})]})})}function Ho(e){const{tone:t,testId:n,onDismiss:o,children:r}=e,s=c7[t];return i.jsxs("div",{role:"status","data-testid":n,style:{...u7,background:s.bg,borderColor:s.border,color:s.fg},children:[i.jsx("div",{style:{flex:1,minWidth:0},children:r}),i.jsx("button",{type:"button",onClick:o,"aria-label":"close","data-testid":`${n}-close`,style:p7,children:"×"})]})}const c7={success:{bg:"#dcfce7",border:"#86efac",fg:"#14532d"},error:{bg:"#fee2e2",border:"#fca5a5",fg:"#7f1d1d"},warning:{bg:"#fef3c7",border:"#fcd34d",fg:"#78350f"},neutral:{bg:"#f1f5f9",border:"#cbd5e1",fg:"#334155"}},u7={display:"flex",alignItems:"flex-start",gap:12,padding:"12px 16px",border:"1px solid",borderRadius:0,fontSize:13,lineHeight:1.5},p7={background:"transparent",border:"none",fontSize:18,cursor:"pointer",lineHeight:1,color:"inherit",padding:"0 4px",flexShrink:0},hp={margin:"8px 0 0",paddingLeft:20,fontSize:12},yp={background:"rgba(0, 0, 0, 0.06)",padding:"1px 4px",borderRadius:3,fontFamily:"monospace"},f7={position:"fixed",inset:0,background:"rgba(15, 23, 42, 0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},g7={background:"#fff",borderRadius:8,padding:24,width:"min(480px, 90vw)",boxShadow:"0 10px 25px rgba(0,0,0,0.15)"},h7={margin:"0 0 8px",fontSize:16,fontWeight:600,color:"#0f172a"},y7={margin:"0 0 12px",color:"#334155",fontSize:13,lineHeight:1.5},b7={marginBottom:16,padding:"8px 12px",background:"#f8fafc",borderRadius:6,fontSize:12,color:"#64748b",fontFamily:"monospace"},m7={display:"flex",gap:8,justifyContent:"flex-end"},v7={padding:"8px 14px",background:"#2563eb",color:"#fff",border:"none",borderRadius:6,fontSize:13,fontWeight:600,cursor:"pointer"},_7={padding:"8px 14px",background:"#fff",color:"#334155",border:"1px solid #cbd5e1",borderRadius:6,fontSize:13,fontWeight:500,cursor:"pointer"},x7={padding:"8px 14px",background:"transparent",color:"#64748b",border:"none",borderRadius:6,fontSize:13,cursor:"pointer"};function bp(e){if(!e)return null;const n=new URLSearchParams(e).get("route");return n&&n.length>0?n:null}function ia(e,t,n){const o=`/admin/layout-editor/${encodeURIComponent(e)}`;if(!t||t.length===0)return o;if(t.startsWith("__")){let r=`${o}?edit=${encodeURIComponent(t)}`;return(t.startsWith("__modal__/")||t.startsWith("__iteration__/"))&&n&&(r+=`&host=${encodeURIComponent(n)}`),r}return`${o}?route=${encodeURIComponent(t)}`}function mp(e){if(!e)return null;const n=new URLSearchParams(e).get("host");return n&&n.length>0?n:null}function vp(e){if(!e)return null;const n=new URLSearchParams(e).get("edit");return n&&n.length>0&&n.startsWith("__")?n:null}function w7(e,t){const n=`/admin/templates/${encodeURIComponent(e)}/edit`;if(!t||t.length===0||t.startsWith("__"))return n;const o=t.replace(/^\*+/,"");return o.length===0?n:`${n}?route=${encodeURIComponent(o)}`}const k7="g7le-editor-route",S7=new Set;function sa(e){return e.path.startsWith("__group__/")||e.path.startsWith("__conngroup__/")}function _p(e,t){const{t:n,translationEngine:o,translationContext:r,templateIdentifier:s}=t,a=sa(e);if(!e.label.startsWith("$t:"))return e.label;const l=e.label.slice(3),d=l.indexOf("|"),c=d===-1?l:l.slice(0,d),p={};if(d!==-1)for(const b of l.slice(d+1).split("|")){const g=b.indexOf("=");g!==-1&&(p[b.slice(0,g)]=b.slice(g+1))}if((e.kind==="route"||e.kind==="modal")&&!a&&o&&r&&s!==r.templateId){const b={templateId:s,locale:r.locale},g=Object.keys(p).length>0?"|"+Object.entries(p).map(([h,v])=>`${h}=${v}`).join("|"):void 0,m=o.translate(c,b,g);if(m!==c)return m}const f=n(c,p);if(f===c&&typeof window<"u"){const b=window.G7Core?.t;if(typeof b=="function")try{const g=b(c,p);if(g!==c)return g}catch{}}if(f===c&&e.kind==="route"&&!a){const b=e.path;if(b&&b!=="/"){const g=b.split("/").filter(Boolean);return g[g.length-1]??b}return b==="/"?"/":c}return f}function C7(e){return e.trim().toLocaleLowerCase()}function xp(e,t){if(!t)return e;const n=e.toLocaleLowerCase(),o=[];let r=0,s=n.indexOf(t,r);if(s===-1)return e;let a=0;for(;s!==-1;)s>r&&o.push(e.slice(r,s)),o.push(i.jsx("mark",{className:"g7le-route-tree__highlight",style:{background:"#fde68a",color:"inherit",borderRadius:2,padding:"0 1px"},children:e.slice(s,s+t.length)},`m${a++}`)),r=s+t.length,s=n.indexOf(t,r);return r{const z=f.selectedRoute?.path??"";return z.startsWith("__extension__/")||z.startsWith("__modal__/")?z.slice(z.lastIndexOf("/")+1):null},[f.selectedRoute?.path]),h=u.useMemo(()=>!g||!m?!1:(e.children??[]).some(z=>z.kind==="extension"&&z.extensionId===m||z.kind==="modal"&&z.modalId===m),[g,m,e.children]),[v,y]=u.useState(!0);u.useEffect(()=>{h&&y(!1)},[h]);const _=f.editMode==="extension"?f.selectedRoute?.layoutName??null:null,w=e.kind==="extension"?kp(e,f.routeTree)??null:null,k=e.kind==="extension"&&o===e.path&&(_===null||w===null||_===w),x=f.editMode==="modal"&&o?.startsWith("__modal__/")?o.slice(o.lastIndexOf("/")+1):null,$=f.editMode==="modal"?f.selectedRoute?.layoutName??null:null,C=e.kind==="modal"&&!!x&&e.modalId===x&&($===null||e.modalHostLayout==null||$===e.modalHostLayout),S=e.kind!=="extension"&&e.kind!=="modal"&&o===e.path||k||C||e.kind==="route"&&!b&&r===e.path,E=(e.children?.length??0)>0&&(!g||l||!v),I=!b&&!!e.layoutName&&s.has(e.layoutName),N=b?void 0:e.kind==="extension"?e.extensionId?f.extensionVersions[e.extensionId]:void 0:e.layoutName?f.layoutVersions[e.layoutName]:void 0,T=()=>{if(g){y(z=>!z);return}b||n(e)},B=_p(e,{t:d,translationEngine:c,translationContext:p,templateIdentifier:f.templateIdentifier}),M=b?null:$7(e),O={paddingLeft:12+t*14,paddingRight:12,paddingTop:4,paddingBottom:4,opacity:e.isHidden?.55:1,cursor:g?"pointer":b?"default":"pointer",background:S?"#eff6ff":"transparent",borderLeft:S?"2px solid #2563eb":"2px solid transparent",fontWeight:b||S?600:400,fontSize:b?11:13,color:b?"#64748b":S?"#1d4ed8":"#1e293b",textTransform:b?"uppercase":"none",letterSpacing:b?.6:void 0,transition:"background-color 100ms, color 100ms",display:"flex",flexDirection:"column",alignItems:"stretch",gap:2,userSelect:"none"};return i.jsxs("li",{children:[i.jsxs("div",{"data-testid":b?"g7le-route-tree-group":"g7le-route-tree-item","data-route-path":e.path,"data-route-kind":e.kind,"data-conn-collapsed":g?l?"false":String(v):void 0,role:g||!b?"button":void 0,tabIndex:g||!b?0:void 0,"aria-expanded":g?l?!0:!v:void 0,onClick:T,onKeyDown:z=>{g&&(z.key==="Enter"||z.key===" ")?(z.preventDefault(),y(H=>!H)):!b&&(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),n(e))},style:O,children:[i.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},children:[g&&i.jsx("span",{"aria-hidden":"true",style:{flex:"0 0 auto",fontSize:9,color:"#94a3b8",width:10,display:"inline-block"},children:l||!v?"▾":"▸"}),I&&i.jsx("span",{className:"g7le-route-tree__dirty-dot","data-testid":"g7le-route-tree-dirty",title:d("layout_editor.chrome.route_tree.badge.modified"),"aria-label":d("layout_editor.chrome.route_tree.badge.modified"),style:{width:7,height:7,borderRadius:"50%",background:"#f59e0b",flex:"0 0 auto"}}),b?B:xp(B,a),typeof N=="number"&&i.jsxs("span",{className:"g7le-route-tree__version-badge","data-testid":"g7le-route-tree-version",title:d("layout_editor.chrome.route_tree.badge.version_tooltip",{version:String(N)}),style:{flex:"0 0 auto",padding:"0 5px",fontSize:10,fontWeight:600,lineHeight:"16px",borderRadius:4,background:"#eef2ff",color:"#4f46e5",border:"1px solid #e0e7ff",letterSpacing:.2},children:["v",N]}),i.jsx(E7,{node:e})]}),M&&i.jsx("span",{className:"g7le-route-tree__layout-path","data-testid":"g7le-route-tree-layout-path",title:M,style:{fontSize:11,fontWeight:400,color:"#94a3b8",textTransform:"none",letterSpacing:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:xp(M,a)})]}),E&&i.jsx("ul",{style:{listStyle:"none",margin:0,padding:0},children:e.children.map(z=>i.jsx(wp,{node:z,depth:t+1,onSelect:n,selectedRoutePath:o,activeHostRoutePath:r,dirtyLayoutNames:s,query:a,forceExpand:l},z.path))})]})}function I7(e,t){if(!t||!t.startsWith("__"))return null;const n=t.startsWith("__modal__/"),o=t.startsWith("__extension__/");if(!n&&!o)return null;const r=t.slice(t.lastIndexOf("/")+1),s=a=>{for(const l of a){if(l.connectedHostRoutePath&&(n&&l.kind==="modal"&&l.modalId===r||o&&l.kind==="extension"&&l.extensionId===r))return l.connectedHostRoutePath;if(l.children&&l.children.length>0){const d=s(l.children);if(d)return d}}return null};return s(e)}function kp(e,t){if(e.connectedHostRoutePath){const n=Sp(t,e.connectedHostRoutePath);if(n?.layoutName)return n.layoutName}if(e.extensionType==="overlay"&&e.extensionTargetName)return e.extensionTargetName}function Sp(e,t){for(const n of e){if(n.kind==="route"&&n.path===t)return n;if(n.children&&n.children.length>0){const o=Sp(n.children,t);if(o)return o}}return null}function Cp(e,t,n){const o=[];for(const r of e){const s=sa(r),a=r.children&&r.children.length>0?Cp(r.children,t,n):[];if(s){a.length>0&&o.push({...r,children:a});continue}const l=_p(r,n).toLocaleLowerCase(),d=r.path.toLocaleLowerCase();(l.includes(t)||!d.startsWith("__")&&d.includes(t)||a.length>0)&&o.push({...r,children:a})}return o}function A7(){const{t:e,translationEngine:t,translationContext:n}=et(),{state:o,dispatch:r}=Qe(),a=Kt()?.dirtyLayoutNames??S7,[l,d]=u.useState(""),c=C7(l),p=u.useMemo(()=>c?Cp(o.routeTree,c,{t:e,translationEngine:t,translationContext:n,templateIdentifier:o.templateIdentifier}):o.routeTree,[c,o.routeTree,o.templateIdentifier,e,t,n]),f=h=>{if(h.kind==="base"&&h.layoutName){r({type:"ENTER_BASE_EDIT",layoutName:h.layoutName});return}if(h.kind==="modal"&&h.modalId&&h.modalHostLayout){r({type:"ENTER_MODAL_EDIT",modalId:h.modalId,hostLayout:h.modalHostLayout});return}if(h.kind==="extension"&&h.extensionId){const v=kp(h,o.routeTree);r({type:"ENTER_EXTENSION_EDIT",extensionId:h.extensionId,extensionHost:v});return}if(r({type:"SELECT_ROUTE",route:{path:h.path,layoutName:h.layoutName}}),typeof window<"u"&&window.history?.pushState){const v=ia(o.templateIdentifier,h.path);`${window.location.pathname}${window.location.search}`!==v&&window.history.pushState({source:k7,routePath:h.path},"",v)}},b=o.selectedRoute?.path??null,g=u.useMemo(()=>I7(o.routeTree,b),[o.routeTree,b]);if(o.isRouteTreeCollapsed)return i.jsx("aside",{className:"g7le-route-tree g7le-route-tree--collapsed","data-testid":"g7le-route-tree-panel","data-collapsed":"true",style:{width:28,borderRight:"1px solid #e2e8f0",background:"#ffffff"}});const m=o.routeTree.length>0;return i.jsxs("aside",{className:"g7le-route-tree","data-testid":"g7le-route-tree-panel","data-collapsed":"false",style:{width:280,borderRight:"1px solid #e2e8f0",background:"#ffffff",position:"sticky",top:"var(--g7le-header-h, 0px)",alignSelf:"start",height:"calc(100vh - var(--g7le-header-h, 0px))",overflow:"hidden",minHeight:0,display:"flex",flexDirection:"column"},"aria-label":e("layout_editor.chrome.route_tree.panel_title"),children:[i.jsx("div",{className:"g7le-route-tree__title",style:{padding:"10px 14px",fontSize:12,fontWeight:600,color:"#475569",textTransform:"uppercase",letterSpacing:.6,borderBottom:"1px solid #e2e8f0",background:"#f8fafc",flex:"0 0 auto"},children:e("layout_editor.chrome.route_tree.panel_title")}),m&&i.jsxs("div",{className:"g7le-route-tree__search",style:{padding:"8px 10px",borderBottom:"1px solid #e2e8f0",background:"#ffffff",flex:"0 0 auto",position:"relative"},children:[i.jsx("input",{type:"text",className:"g7le-route-tree__search-input","data-testid":"g7le-route-tree-search",value:l,onChange:h=>d(h.target.value),placeholder:e("layout_editor.chrome.route_tree.search_placeholder"),"aria-label":e("layout_editor.chrome.route_tree.search_placeholder"),style:{width:"100%",boxSizing:"border-box",padding:l?"6px 26px 6px 10px":"6px 10px",fontSize:12,lineHeight:1.4,color:"#1e293b",border:"1px solid #cbd5e1",borderRadius:6,outline:"none",background:"#f8fafc"}}),l&&i.jsx("button",{type:"button",className:"g7le-route-tree__search-clear","data-testid":"g7le-route-tree-search-clear",onClick:()=>d(""),"aria-label":e("layout_editor.chrome.route_tree.search_clear"),title:e("layout_editor.chrome.route_tree.search_clear"),style:{position:"absolute",right:16,top:"50%",transform:"translateY(-50%)",width:18,height:18,display:"inline-flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",color:"#94a3b8",cursor:"pointer",fontSize:14,lineHeight:1,padding:0},children:"✕"})]}),!m&&i.jsx("div",{className:"g7le-route-tree__empty","data-testid":"g7le-route-tree-empty",style:{padding:16,fontSize:12,color:"#94a3b8",textAlign:"center"},children:e("layout_editor.chrome.route_tree.empty")}),m&&c&&p.length===0&&i.jsx("div",{className:"g7le-route-tree__no-results","data-testid":"g7le-route-tree-no-results",style:{padding:16,fontSize:12,color:"#94a3b8",textAlign:"center"},children:e("layout_editor.chrome.route_tree.search_no_results")}),m&&p.length>0&&i.jsx("nav",{className:"g7le-route-tree__scroll","data-testid":"g7le-route-tree-scroll",style:{flex:"1 1 auto",minHeight:0,overflowY:"auto"},children:i.jsx("ul",{style:{listStyle:"none",margin:0,padding:0},children:p.map(h=>i.jsx(wp,{node:h,depth:0,onSelect:f,selectedRoutePath:b,activeHostRoutePath:g,dirtyLayoutNames:a,query:c,forceExpand:!!c},h.path))})})]})}const T7=Lt().DynamicRenderer,aa=Lt(),D7=aa.ResponsiveProvider;aa.useResponsive,aa.ResponsiveContext;const z7=Lt().ActionDispatcher,$p=Lt(),N7=$p.DataSourceManager;$p.dataSourceManager;function ei(e,t,n){const o=t??{},r=o.message||o.error||`HTTP ${e}`,s=o?.data?.required_permissions??o?.required_permissions;let a;return e===401?a="unauthorized":e===403?a="forbidden":e===404?a="not_found":e>=500?a="server_error":a="unknown",{kind:a,status:e,message:String(r),requiredPermissions:s?String(s):void 0,source:n}}function lo(e,t){return{kind:"network",status:0,message:e instanceof Error?e.message:String(e??"Unknown network error"),source:t}}function Ep(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.kind=="string"&&typeof t.status=="number"&&typeof t.message=="string"}function Re(e){if(!e)return[];const t=[],n=e.split(".");for(let o=0;o0&&(t.push({responsive:a}),o+=1);continue}const s=Number(r);Number.isFinite(s)&&Number.isInteger(s)&&s>=0&&t.push(s)}return t}function M7(e,t){if(!e)return{affordance:"none",targetPath:null};const n=L7(e);return n?P7(n)?{affordance:"dynamic_path",targetPath:n}:/^(https?:)?\/\//.test(n)?{affordance:"external_url",targetPath:n}:n.startsWith("/")?t?{affordance:t(n),targetPath:n}:{affordance:"route_not_in_tree",targetPath:n}:{affordance:"route_not_in_tree",targetPath:n}:{affordance:"none",targetPath:null}}function L7(e){const t=e.actions;if(Array.isArray(t)){for(const n of t)if(n&&typeof n=="object"&&n.handler==="navigate"){const o=n.params?.path;if(typeof o=="string"&&o.length>0)return o}}if(e.name==="A"||e.type==="A"){const n=e.props?.href;if(typeof n=="string"&&n.length>0)return n}return null}function P7(e){return/\{\{[\s\S]*?\}\}/.test(e)}function O7(e,t,n){const o=s=>!!(s?.iteration&&s.iteration.source!==void 0),r=s=>{if(!s)return s;const a=s.indexOf(".iteration."),l=s.indexOf(".sortable."),d=[a,l].filter(c=>c>=0).sort((c,p)=>c-p)[0];return d===void 0?s:s.slice(0,d)};return o(e)?{isIteration:!0,iterationSourcePath:r(n)}:n&&n.includes(".iteration.")?{isIteration:!0,iterationSourcePath:r(n)}:t.some(o)?{isIteration:!0,iterationSourcePath:r(n)}:{isIteration:!1,iterationSourcePath:null}}function B7(e,t){const n=a=>{const l=a?.iteration&&a.iteration.source;return typeof l=="string"&&l.length>0?l:null},o=n(e)??t.map(n).find(a=>a!==null)??null;if(o!==null){const a=j7(o);if(a!==null)return a}const r=[];if(typeof e.text=="string"&&r.push(...Ip(e.text)),e.props&&typeof e.props=="object")for(const a of Object.values(e.props))typeof a=="string"&&r.push(...Ip(a));return r.length===0?null:r.find(a=>!W7.has(a))??r[0]}const W7=new Set(["_local","_global","_computed","route","query","props","item","index","event","$event","$response","response"]);function Ip(e){const t=[],n=/\{\{([\s\S]*?)\}\}/g;let o;for(;(o=n.exec(e))!==null;){const r=Ap(o[1]);r!==null&&t.push(r)}return t}function j7(e){const t=e.replace(/\{\{|\}\}/g,"");return Ap(t)}function Ap(e){const t=/[A-Za-z_$][A-Za-z0-9_$]*/.exec(e.trim());return t?t[0]:null}function Jt(e,t,n,o=[]){if(!e)return"none";if(ld(e)||typeof e.slot=="string"||typeof e.__editorSlotName=="string")return"extension_point";if(ud(e,t,n)){const r=e.__source?.kind;return r==="base"?"base":r==="partial"?"partial":r==="extension"?"extension":"base"}return Xb(e,o)?"data_bound":"none"}function Zt(e){return e==="none"||e==="data_bound"}function Tp(e){return Zt(e)?null:e==="extension"||e==="extension_point"?"denied_extension_locked":"denied_base_locked"}function Dp(e){if(!e)return null;if(e.__source?.kind==="extension"&&typeof e.__source.extensionId=="number")return e.__source.extensionId;const t=e.__injectedProps;if(Array.isArray(t)&&t.length>0){const n=t[0]?.extensionId;if(typeof n=="number")return n}return null}function H7(e,t){if(t<=0)return e;const n=e.split(".");let o=0;const r=[];for(let s=0;s=t)break;r.push(a);continue}if(a==="iteration"||a==="sortable"){if(o>=t)break;r.push(a);continue}r.push(a);const l=n[s-1];if((l===void 0||l==="children")&&(o+=1),o>=t)break}return r.join(".")}function zp(e,t,n,o){if(!e||!t)return t;const r=n(t),s=Qb(e,r,o);return s.length===r.length?t:H7(t,s.length)}function Np(e){return Zt(e)}function F7(e){const{rootNode:t,editMode:n,currentExtensionId:o,editableRootPath:r,pathParser:s=Re,resolveRouteMatch:a}=e,[l,d]=u.useState(null),[c,p]=u.useState(null),f=u.useCallback(_=>{if(_===null||n==="route")return!0;if(n==="iteration_item"||n==="modal"){if(!r||r.length===0)return!0;const $=s(_);return Mp($,r)}const w=la(t,_,s);if(!w)return!0;const k=da(t,_,s),x=Jt(w,n,o,k);return Zt(x)},[t,s,n,o,r]),b=u.useCallback((_,w)=>{const x=(w?.currentTarget?.dataset??w?.dataset)?.editorPath??null,$=zp(t,x,s,o);f($)&&d($)},[t,s,o,f]),g=u.useCallback((_,w)=>{if(_===null){p(null);return}const x=(w?.currentTarget?.dataset??w?.dataset)?.editorPath??null,$=zp(t,x,s,o);if(!f($)){p(null);return}p($)},[t,s,o,f]),m=u.useCallback(()=>{d(null)},[]),h=u.useMemo(()=>{const _=la(t,l,s),w=la(t,c,s),k=_?da(t,l,s):[];let x=Jt(_,n,o,k);(n==="iteration_item"||n==="modal")&&l!==null&&_&&r&&r.length>0&&Mp(s(l),r)&&(dd(_)?x="data_bound":x==="data_bound"&&(x="none"));const{affordance:$,targetPath:C}=M7(_,a),S=x==="base"&&typeof _?.__source?.layout=="string"?_.__source.layout:null,D=x==="data_bound"&&_?B7(_,k):null,{isIteration:E,iterationSourcePath:I}=x==="data_bound"&&_?O7(_,k,l):{isIteration:!1,iterationSourcePath:null};return{selectedNode:_,hoverNode:w,selectedLockKind:x,selectedNavAffordance:$,selectedNavTargetPath:C,selectedBaseLayout:S,selectedDataSourceId:D,selectedIsIteration:E,selectedIterationSourcePath:I}},[t,l,c,n,o,r,s,a]),v=u.useRef(void 0);v.current!==l&&(v.current=l,Nl({op:l===null?"clear":"select",componentPath:l,componentName:Lp(h.selectedNode),lockKind:h.selectedLockKind,navAffordance:h.selectedNavAffordance,sourceExtensionId:Dp(h.selectedNode),timestamp:Date.now()}));const y=u.useRef(void 0);return y.current!==c&&(y.current=c,c!==null&&Nl({op:"hover",componentPath:c,componentName:Lp(h.hoverNode),lockKind:Jt(h.hoverNode,n,o,da(t,c,s)),navAffordance:"none",sourceExtensionId:Dp(h.hoverNode),timestamp:Date.now()})),{selectedPath:l,hoverPath:c,...h,handleSelect:b,handleHover:g,clearSelection:m}}function la(e,t,n){if(!e||!t)return null;const o=n(t);return Pe(e,o)}function Mp(e,t){if(e.length0?e.name:typeof e.type=="string"&&e.type.length>0?e.type:null:null}let Pp=0;function Op(){return Pp}function ca(){Pp+=1}function K7(e){if(typeof e!="string")return null;const t="__modal__/";if(!e.startsWith(t))return null;const n=e.slice(t.length);return n===""||n.includes("/")?null:n}function V7(e){if(typeof e!="string")return null;const t="__iteration__/";if(!e.startsWith(t))return null;const n=e.slice(t.length);return n!==""?n:null}function Bp(){const{state:e}=Qe(),t=e.templateIdentifier,n=e.selectedRoute?.layoutName??null,o=e.editMode,r=o==="modal"?K7(e.selectedRoute?.path):null,s=o==="iteration_item"?V7(e.selectedRoute?.path):null,[a,l]=u.useState(null),[d,c]=u.useState(!1),[p,f]=u.useState(null),[b,g]=u.useState(!1),[m,h]=u.useState(0),[v,y]=u.useState(0),_=u.useRef(new Map),[w,k]=u.useState(()=>new Set),x=u.useCallback((P,A)=>`${P}|${A??""}`,[]),$=u.useRef(null);u.useEffect(()=>{$.current=a},[a]);const C=u.useCallback((P,A)=>{const L=x(o,n);_.current.set(L,{raw:P,lockVersion:A}),k(F=>{if(F.has(L))return F;const Y=new Set(F);return Y.add(L),Y})},[x,o,n]),S=u.useCallback(P=>{_.current.delete(P),k(A=>{if(!A.has(P))return A;const L=new Set(A);return L.delete(P),L})},[]),D=u.useCallback(P=>{const A=`|${P??""}`,L=[];for(const F of _.current.keys())F.endsWith(A)&&L.push(F);for(const F of L)_.current.delete(F);L.length>0&&k(F=>{let Y=!1;const V=new Set(F);for(const X of L)V.delete(X)&&(Y=!0);return Y?V:F})},[]),E=u.useCallback(async()=>{if(!n){l(null),f(null),g(!1);return}const P=x(o,n),A=_.current.get(P);if(A){l({layoutName:n,raw:A.raw,lockVersion:A.lockVersion}),g(!0),f(null),c(!1),st({op:"load",layoutName:n,editMode:o,statusCode:0,isDirty:!0,timestamp:Date.now()});return}c(!0),f(null);try{const L=window.G7Config?.cache_version??0,F=nn(`/api/layouts/${encodeURIComponent(t)}/${n}`,"json",`${L}.${Op()}`,"with_source_meta=1"),Y=fr(),V={Accept:"application/json"};Y&&(V.Authorization=`Bearer ${Y}`);const X=await fetch(F,{headers:V,credentials:"same-origin"}),Z=await X.json().catch(()=>null);if(!X.ok){f(ei(X.status,Z,"layout")),l(null),g(!1);return}const ie=(Z&&(Z.data||Z))??{},oe=typeof ie.lock_version=="number"?ie.lock_version:0;if(o==="modal"&&r){const ee=ie,fe=Array.isArray(ee.modals)?ee.modals:[],K=fe.findIndex(te=>te&&(te.id===r||te.modal_id===r));if(K>=0){const te=fe[K],ye={...te,props:{...te.props??{},isOpen:!0}},De=[...Array.isArray(ee.components)?ee.components:[],ye],Ie=[De.length-1];l({layoutName:n,raw:{...ee,components:De},lockVersion:oe,modalContext:{modalId:r,modalIndex:K,hostRaw:ee,originalModalNode:te,editIndexPath:Ie}}),g(!1),st({op:"load",layoutName:n,editMode:o,statusCode:X.status,timestamp:Date.now()});return}}if(o==="iteration_item"&&s){const ee=ie,fe=Re(s),K={children:ee.components??[]},te=Pe(K,fe);if(te&&Array.isArray(te.children)){l({layoutName:n,raw:ee,lockVersion:oe,iterationContext:{sourcePath:s,sourceIndexPath:fe,hostRaw:ee}}),g(!1),st({op:"load",layoutName:n,editMode:o,statusCode:X.status,timestamp:Date.now()});return}}l({layoutName:n,raw:ie,lockVersion:oe}),g(!1),st({op:"load",layoutName:n,editMode:o,statusCode:X.status,timestamp:Date.now()})}catch(L){f(lo(L,"layout")),l(null),g(!1)}finally{c(!1)}},[t,n,o,r,s,x]);u.useEffect(()=>{E()},[E]);const I=u.useCallback(async()=>{S(x(o,n)),ca(),y(P=>P+1),await E()},[S,x,o,n,E]),N=u.useCallback(()=>{S(x(o,n))},[S,x,o,n]),T=u.useCallback(P=>{l(A=>{if(!A)return A;const L=A.raw.components??[],F=P(L),Y={...A.raw,components:F};return C(Y,A.lockVersion),{...A,raw:Y}}),g(!0),st({op:"patch",layoutName:n,editMode:o,isDirty:!0,timestamp:Date.now()})},[n,o,C]),B=u.useCallback(()=>{g(!0),st({op:"patch",layoutName:n,editMode:o,isDirty:!0,timestamp:Date.now()})},[n,o]),M=u.useCallback(P=>{l(A=>{if(!A)return A;const L={...A.raw,components:P};return C(L,A.lockVersion),{...A,raw:L}}),g(!0),st({op:"patch",layoutName:n,editMode:o,isDirty:!0,timestamp:Date.now()})},[n,o,C]),O=u.useCallback((P,A,...L)=>{const F=L.length>=1?L[0]:A;l(Y=>{if(!Y)return Y;const V={...Y.raw,[P]:A},X=Y.raw.__editor;if(X&&typeof X=="object"&&!Array.isArray(X)){const Z=X,ie=Z.original;ie&&typeof ie=="object"&&!Array.isArray(ie)&&(V.__editor={...Z,original:{...ie,[P]:F}})}return C(V,Y.lockVersion),{...Y,raw:V}}),g(!0),st({op:"patch",layoutName:n,editMode:o,isDirty:!0,timestamp:Date.now()})},[n,o,C]),z=u.useCallback(async P=>{const A=$.current;if(!A)return st({op:"save_guard_result",layoutName:n,editMode:o,guardBlocked:!1,timestamp:Date.now()}),{kind:"guard_no_document"};if(P?.resolveActiveExtensions&&P.sessionAddedPaths?.length)try{const fe=await P.resolveActiveExtensions(),K=U7(A.raw.components,P.sessionAddedPaths,fe);if(K.length>0)return st({op:"save_guard_result",layoutName:n,editMode:o,guardBlocked:!0,guardBlockedPaths:K,timestamp:Date.now()}),{kind:"blocked_inactive_extension",blockedPaths:K}}catch{}if(um())try{await pm(t)}catch{}const L=`/api/admin/templates/${encodeURIComponent(t)}/layouts/${A.layoutName}`,F=fr(),Y={Accept:"application/json","Content-Type":"application/json"};F&&(Y.Authorization=`Bearer ${F}`);const V=!!A.modalContext,X=!!A.iterationContext,Z=V||X?"host_layout_modal_patch":"layout";st({op:"save",layoutName:A.layoutName,editMode:o,saveTarget:Z,endpoint:L,isDirty:b,timestamp:Date.now()});let ie;if(V&&A.modalContext){const{modalIndex:fe,hostRaw:K,originalModalNode:te,editIndexPath:ye}=A.modalContext,Se=Array.isArray(K.modals)?[...K.modals]:[],De=Array.isArray(A.raw.components)?A.raw.components:[],Ie=ye&&ye.length===1?ye[0]:0,Ve=De.length>Ie?De[Ie]:void 0,ze=Ve?qn([Ve]):[],Be=ze.length>0?{...ze[0]}:void 0;if(fe>=0&&fe({...Ne,children:De})).children??[];ie={...Ie,components:Xe}}else ie=ko(A.raw);const oe=ie;let G;try{G=await fetch(L,{method:"PUT",headers:Y,credentials:"same-origin",body:JSON.stringify({content:JSON.stringify(oe),expected_lock_version:A.lockVersion})})}catch(fe){const K=fe instanceof Error?fe.message:"network error";return st({op:"save_response",layoutName:A.layoutName,editMode:o,endpoint:L,statusCode:0,timestamp:Date.now()}),{kind:"network_error",message:K}}const ee=await G.json().catch(()=>null);if(st({op:"save_response",layoutName:A.layoutName,editMode:o,endpoint:L,statusCode:G.status,conflict:G.status===409?{currentVersion:ee?.current_version,yourVersion:ee?.your_version}:void 0,timestamp:Date.now()}),G.ok){const fe=typeof ee?.data?.lock_version=="number"?ee.data.lock_version:A.lockVersion+1;l({...A,lockVersion:fe}),g(!1),S(x(o,A.layoutName)),D(A.layoutName),ca(),h(te=>te+1);const K=typeof ee?.data?.current_version=="number"?ee.data.current_version:void 0;return{kind:"success",newLockVersion:fe,newContentVersion:K,savedLayoutName:A.layoutName}}return G.status===409?{kind:"concurrent_modification",currentVersion:ee?.current_version??-1,yourVersion:ee?.your_version??A.lockVersion}:G.status===422?{kind:"validation_failed",status:422,errors:ee?.errors??null}:{kind:"network_error",message:ee?.message??`HTTP ${G.status}`}},[t,n,o,b,S,D,x,r,s]),H=u.useMemo(()=>{const P=new Set,A="route|";for(const L of w)if(L.startsWith(A)){const F=L.slice(A.length);F&&P.add(F)}return P},[w]);return{document:a,isLoading:d,error:p,isDirty:b,saveSuccessCounter:m,reloadCounter:v,dirtyKeys:w,dirtyLayoutNames:H,invalidateCurrentCache:N,reload:I,patchLayout:T,setLayoutComponents:M,patchDocumentRaw:O,save:z,markDirty:B}}function U7(e,t,n){if(!e||e.length===0)return[];const o=[],r=new Set([...n.moduleIds,...n.pluginIds]);for(const s of t){const a=q7(e,s);if(!a)continue;const l=a.__source;if(!l||l.kind!=="extension")continue;const d=String(l.extensionId??"");d.length!==0&&(r.has(d)||o.push(s))}return o}function q7(e,t){const n=Re(t);return n.length===0?null:Pe({children:e},n)}function co(e,t){if(!e)return null;const n=e.getBoundingClientRect();if(n.width===0&&n.height===0)return null;if(!t)return{left:n.left,top:n.top,width:n.width,height:n.height,scale:1};const o=t.getBoundingClientRect();return{left:n.left-o.left,top:n.top-o.top,width:n.width,height:n.height,scale:1}}function uo(e,t){if(!e)return!1;if(!t)return!0;const n=t.getBoundingClientRect(),o=1;return!(e.left>=n.width-o||e.left+e.width<=o||e.top>=n.height-o||e.top+e.height<=o)}function Wp(e,t){if(typeof window>"u")return()=>{};const n=()=>{e()};window.addEventListener("scroll",n,!0),window.addEventListener("resize",n);let o=null;t&&typeof ResizeObserver<"u"&&(o=new ResizeObserver(()=>e()),o.observe(t));let r=null,s=null;const a=typeof requestAnimationFrame<"u",l=()=>{if(!a){e();return}s===null&&(s=requestAnimationFrame(()=>{s=null,e()}))};return t&&typeof MutationObserver<"u"&&(r=new MutationObserver(l),r.observe(t,{childList:!0,subtree:!0})),()=>{window.removeEventListener("scroll",n,!0),window.removeEventListener("resize",n),o&&(o.disconnect(),o=null),r&&(r.disconnect(),r=null),s!==null&&a&&typeof cancelAnimationFrame<"u"&&(cancelAnimationFrame(s),s=null)}}const jp=44;function Hp(e){if(!e)return"inside";const t=e.scale||1,n=e.width*t,o=e.height*t;return n"u"||typeof window.getComputedStyle!="function")return{kind:"unknown",display:"",flexDirection:"",flexWrap:""};let t=e,n=(window.getComputedStyle(t).display??"").toLowerCase();for(;n==="contents"&&t.parentElement;)t=t.parentElement,n=(window.getComputedStyle(t).display??"").toLowerCase();const o=window.getComputedStyle(t),r=(o.display??"").toLowerCase(),s=(o.flexDirection??"").toLowerCase(),a=(o.flexWrap??"").toLowerCase(),l=r==="flex"||r==="inline-flex";if(r==="grid"||r==="inline-grid"){const f=Array.from(e.children).filter(h=>h.offsetParent!==null||h.getClientRects().length>0);if(f.length<=1)return{kind:"grid_2d",display:r,flexDirection:s,flexWrap:a};const b=f.map(h=>h.getBoundingClientRect()),g=new Set(b.map(h=>Math.round(h.top))),m=new Set(b.map(h=>Math.round(h.left)));return g.size===1?{kind:"grid_single_row",display:r,flexDirection:s,flexWrap:a}:m.size===1?{kind:"grid_single_column",display:r,flexDirection:s,flexWrap:a}:{kind:"grid_2d",display:r,flexDirection:s,flexWrap:a}}if(!l)return{kind:"block",display:r,flexDirection:s,flexWrap:a};const c=a==="wrap"||a==="wrap-reverse";return s==="column"||s==="column-reverse"?{kind:c?"flex_column_wrap":"flex_column_single",display:r,flexDirection:s,flexWrap:a}:{kind:c?"flex_row_wrap":"flex_row_single",display:r,flexDirection:s,flexWrap:a}}function Y7(e){const{parentEl:t,selectedPath:n,selectedEl:o,explicitFlow:r}=e;return u.useMemo(()=>{if(!n||n.length===0)return{points:[],flow:"unknown"};const s=r??Vp(t).kind,a=n.slice(0,-1),l=n[n.length-1]??0;if((s==="flex_row_wrap"||s==="flex_column_wrap"||s==="grid_2d")&&!!o){const p=X7(s,o,a,l);if(p)return{points:p,flow:s}}return{points:J7(s,a,l),flow:s}},[t,n,o,r])}function X7(e,t,n,o){let r=t.parentElement;for(;r&&Up(r)==="contents";)r=r.parentElement;if(!r)return null;const s=[];if(qp(r,s),s.length===0)return null;const a=t.getBoundingClientRect(),l=a.top+a.height/2,d=[],c=[],p=[];for(const v of s){const y=v.rect,_=y.top+y.height/2,w=Math.min(a.bottom,y.bottom)-Math.max(a.top,y.top),k=Math.min(a.height,y.height)||1;w/k>.4?d.push({rect:y,path:v.path}):_v.rect.left-y.rect.left),c.sort((v,y)=>v.rect.top-y.rect.top),p.sort((v,y)=>v.rect.top-y.rect.top);const f=d.findIndex(v=>Math.abs(v.rect.left-a.left)<1&&Math.abs(v.rect.top-a.top)<1),b={direction:"above",disabled:!0,insertion:null},g={direction:"below",disabled:!0,insertion:null},m={direction:"left",disabled:!0,insertion:null},h={direction:"right",disabled:!0,insertion:null};if(f>0){const v=d[f-1],y=ni(v.path);y&&(m.disabled=!1,m.insertion=y)}else if(d.length>0){const v=d[0],y=ti(v.path);y&&(m.disabled=!1,m.insertion=y)}if(f>=0&&f0){const v=d[d.length-1],y=ni(v.path);y&&(h.disabled=!1,h.insertion=y)}if(c.length>0){const v=c[c.length-1],y=ni(v.path);y&&(b.disabled=!1,b.insertion=y)}else if(s.length>0){const v=s[0],y=ti(v.path);y&&(b.disabled=!1,b.insertion=y)}if(p.length>0){const v=p[0],y=ti(v.path);y&&(g.disabled=!1,g.insertion=y)}else if(s.length>0){const v=s[s.length-1],y=ni(v.path);y&&(g.disabled=!1,g.insertion=y)}else g.disabled=!1,g.insertion={parentPath:n,index:o+1};return b.disabled&&g.disabled&&m.disabled&&h.disabled?null:[b,g,m,h]}function Up(e){return typeof window>"u"?"":(window.getComputedStyle(e).display??"").toLowerCase()}function qp(e,t){const n=Array.from(e.children);for(const o of n){if(Up(o)==="contents"){qp(o,t);continue}const s=o.getAttribute("data-editor-path");if(s&&/\.iteration\.\d+(?:$|\.)/.test(s)||!s)continue;const a=o.getBoundingClientRect();a.width===0&&a.height===0||t.push({el:o,rect:a,path:Re(s)})}}function ti(e){if(!e||e.length===0)return null;const t=e[e.length-1];return typeof t!="number"?null:{parentPath:e.slice(0,-1),index:t}}function ni(e){if(!e||e.length===0)return null;const t=e[e.length-1];return typeof t!="number"?null:{parentPath:e.slice(0,-1),index:t+1}}function J7(e,t,n){const o={direction:"above",disabled:!0,insertion:null},r={direction:"below",disabled:!0,insertion:null},s={direction:"left",disabled:!0,insertion:null},a={direction:"right",disabled:!0,insertion:null},l=d=>({parentPath:t,index:d});switch(e){case"block":case"unknown":{o.disabled=!1,o.insertion=l(n),r.disabled=!1,r.insertion=l(n+1);break}case"flex_row_single":case"grid_single_row":{s.disabled=!1,s.insertion=l(n),a.disabled=!1,a.insertion=l(n+1);break}case"flex_column_single":case"grid_single_column":{o.disabled=!1,o.insertion=l(n),r.disabled=!1,r.insertion=l(n+1);break}case"flex_row_wrap":case"grid_2d":{s.disabled=!1,s.insertion=l(n),a.disabled=!1,a.insertion=l(n+1),o.disabled=!1,o.insertion=l(0),r.disabled=!1,r.insertion=l(-1);break}case"flex_column_wrap":{o.disabled=!1,o.insertion=l(n),r.disabled=!1,r.insertion=l(n+1),s.disabled=!1,s.insertion=l(0),a.disabled=!1,a.insertion=l(-1);break}}return[o,r,s,a]}function Z7(e=50){const t=u.useRef([]),n=u.useRef(-1),[,o]=u.useState(0),r=()=>{o(p=>(p+1)%1e6)},s=(p,f)=>{const b=t.current.length,g=n.current;by({op:p,actionKind:f?.actionKind,label:f?.label,stackSize:b,cursor:g,canUndo:g>0,canRedo:g>=0&&g{const b=t.current.slice(0,n.current+1);for(b.push(p);b.length>e;)b.shift();t.current=b,n.current=b.length-1,r(),s("push",p)},[e]),l=u.useCallback(()=>{if(n.current<=0)return null;n.current-=1,r();const p=t.current[n.current]??null;return s("undo",p??void 0),p},[]),d=u.useCallback(()=>{const p=n.current+1;if(p>=t.current.length)return null;n.current=p,r();const f=t.current[p]??null;return s("redo",f??void 0),f},[]),c=u.useCallback(()=>{t.current=[],n.current=-1,r(),s("clear")},[]);return{push:a,undo:l,redo:d,clear:c,canUndo:n.current>0,canRedo:n.current>=0&&n.current{if(!o||typeof window>"u")return;const r=s=>{if(Q7(s.target)||!(s.ctrlKey||s.metaKey))return;const l=s.key.toLowerCase();if(l==="z"&&!s.shiftKey){s.preventDefault(),t();return}if(l==="z"&&s.shiftKey||l==="y"){s.preventDefault(),n();return}};return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r)}},[t,n,o])}const e2=20,Gp=50,t2=90,On=120,n2=130,Yp=80,o2=9e3,Xp=1e4;function r2(e){const t=e<0?0:e>Gp?Gp:e;return e2+t}function i2(e){const{anchor:t,open:n,onClose:o,onEditProps:r,onDuplicate:s,onDelete:a,onSeparateBranch:l,separateBranchLabel:d,onMergeBranch:c,mergeBranchLabel:p}=e,{t:f}=et(),[b,g]=u.useState(null);if(!n||!t)return null;const m=[{index:0,testid:"g7le-context-menu-edit-props",label:f("layout_editor.context_menu.edit_props"),onSelect:r},{index:1,testid:"g7le-context-menu-duplicate",label:f("layout_editor.context_menu.duplicate"),onSelect:s}];return l?m.push({index:m.length,testid:"g7le-context-menu-separate-branch",label:d??f("layout_editor.context_menu.separate_branch"),onSelect:l,hint:f("layout_editor.context_menu.separate_branch_hint")}):c&&m.push({index:m.length,testid:"g7le-context-menu-merge-branch",label:p??f("layout_editor.context_menu.merge_branch"),onSelect:c,hint:f("layout_editor.context_menu.merge_branch_hint")}),m.push({index:m.length,testid:"g7le-context-menu-delete",label:f("layout_editor.context_menu.delete"),onSelect:a,danger:!0}),i.jsx("div",{className:"g7le-context-menu","data-testid":"g7le-context-menu",role:"menu",style:{position:"absolute",left:t.left,top:t.top,background:"#fff",border:"1px solid #cbd5e1",borderRadius:6,boxShadow:"0 4px 12px rgba(0,0,0,0.15)",zIndex:1200,minWidth:160,padding:4,pointerEvents:"auto"},onMouseLeave:()=>{g(null),o()},children:m.map(h=>{const v=b===h.index,y=h.danger?"#dc2626":"#0f172a",_=h.danger?"#fee2e2":"#e0e7ff",w=h.danger?"#b91c1c":"#1d4ed8";return i.jsx("button",{type:"button",role:"menuitem","data-testid":h.testid,title:h.hint,onClick:k=>{k.stopPropagation(),h.onSelect(),g(null),o()},onMouseEnter:()=>g(h.index),onFocus:()=>g(h.index),style:{...s2,color:v?w:y,background:v?_:"transparent"},children:h.label},h.testid)})})}const s2={display:"block",width:"100%",textAlign:"left",padding:"6px 12px",border:"none",fontSize:13,cursor:"pointer",borderRadius:4,pointerEvents:"auto",transition:"background-color 120ms ease, color 120ms ease"};function a2(e){const{hoverBox:t,selectedBox:n,lockKind:o,navAffordance:r,onEditProps:s,onDuplicate:a,onDelete:l,onSeparateBranch:d,separateBranchLabel:c,onMergeBranch:p,mergeBranchLabel:f,definedDeviceBranches:b,onJumpToDevice:g,onLinkEditDestination:m,onEditBase:h,onEditExtension:v,extensionLabel:y,baseLayoutLabel:_,dataSourceLabel:w,branchLabel:k,onEditIteration:x,resizeEnabledAxes:$,onResizeHandlePointerDown:C,selectedName:S,onSelectParent:D}=e,{t:E}=et(),[I,N]=u.useState(!1),T=Np(o),B=I&&T,M=Hp(n),O=M==="outside",z=O&&n?Kp(n):null,H=z?{left:z.right.left,top:z.above.top}:{right:-30,top:-30},P={top:-28,left:0},L=O&&!!S?{top:-50,left:0}:P,F=z?{top:z.below.top+28,left:0}:{top:"auto",bottom:-28},Y=z?{top:z.below.top+56,left:0}:{top:"auto",bottom:-56};return i.jsxs("div",{className:"g7le-element-overlay","data-testid":"g7le-element-overlay",style:{position:"absolute",inset:0,pointerEvents:"none"},children:[t&&i.jsx("div",{"data-testid":"g7le-overlay-hover",style:{position:"absolute",left:t.left,top:t.top,width:t.width,height:t.height,border:"1px dashed #2563eb",pointerEvents:"none"}}),n&&i.jsxs("div",{"data-testid":"g7le-overlay-selected","data-lock-kind":o,style:{position:"absolute",left:n.left,top:n.top,width:n.width,height:n.height,border:o==="none"?"2px solid #2563eb":"2px dashed #f59e0b",pointerEvents:"none"},children:[k?i.jsxs("span",{"data-testid":"g7le-overlay-branch-badge",style:d2,children:["📱 ",k]}):null,S&&(D?i.jsxs("button",{type:"button","data-testid":"g7le-overlay-type-label","data-placement":O?"outside":"inside",title:E("layout_editor.overlay.select_parent"),"aria-label":E("layout_editor.overlay.select_parent"),onClick:V=>{V.preventDefault(),V.stopPropagation(),D()},style:O?u2:c2,children:[i.jsx("span",{"aria-hidden":!0,style:{marginRight:3,opacity:.85},children:"↑"}),S]}):i.jsx("span",{"data-testid":"g7le-overlay-type-label","data-placement":O?"outside":"inside",style:O?Zp:Jp,children:S})),T&&i.jsx("button",{type:"button","data-testid":"g7le-overlay-info-button","aria-label":"info",onClick:V=>{V.stopPropagation(),N(X=>!X)},"data-placement":M,style:{position:"absolute",...H,width:20,height:20,borderRadius:10,border:"1px solid #2563eb",background:"#fff",color:"#2563eb",fontSize:12,fontWeight:700,cursor:"pointer",pointerEvents:"auto",padding:0,lineHeight:"18px",zIndex:On},children:"ⓘ"}),o==="none"&&i.jsx(l2,{enabledAxes:$,onHandlePointerDown:C}),o==="base"&&h&&i.jsxs("button",{type:"button","data-testid":"g7le-overlay-edit-base",onClick:V=>{V.stopPropagation(),h()},style:{...Fo,...P},children:["🔒 ",E("layout_editor.overlay.edit_common_layout"),_?i.jsx("span",{"data-testid":"g7le-overlay-base-layout-label",style:pa,children:_}):null]}),o==="extension"&&v&&i.jsxs("button",{type:"button","data-testid":"g7le-overlay-edit-extension",onClick:V=>{V.stopPropagation(),v()},style:{...Fo,...P},children:["🔒 ",E("layout_editor.overlay.edit_extension"),y?i.jsx("span",{"data-testid":"g7le-overlay-extension-label",style:pa,children:y}):null]}),o==="data_bound"&&i.jsxs("span",{"data-testid":"g7le-overlay-data-bound-notice",style:{...Fo,...L,pointerEvents:"none",cursor:"default"},children:[E("layout_editor.overlay.locked_data_bound"),w?i.jsx("span",{"data-testid":"g7le-overlay-data-source-label",style:pa,children:w}):null]}),o==="data_bound"&&x&&i.jsxs("button",{type:"button","data-testid":"g7le-overlay-edit-iteration",onClick:V=>{V.stopPropagation(),x()},style:{...Fo,...F},children:["↳ ",E("layout_editor.overlay.edit_iteration_item")]}),r==="route_in_tree"&&i.jsx("button",{type:"button","data-testid":"g7le-overlay-link-edit-destination",onClick:V=>{V.stopPropagation(),m()},style:{...Fo,...F},children:E("layout_editor.overlay.edit_destination_route")}),(d||p||g&&(b??[]).length>0)&&i.jsxs("div",{"data-testid":"g7le-overlay-branch-affordances",style:{position:"absolute",...Y,display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4,pointerEvents:"none"},children:[g&&(b??[]).map(V=>i.jsxs("button",{type:"button","data-testid":`g7le-overlay-jump-device-${V.key}`,title:E("layout_editor.overlay.jump_device_hint",{device:V.label}),onClick:X=>{X.stopPropagation(),g(V.key)},style:ua,children:["↗ ",E("layout_editor.overlay.jump_device",{device:V.label})]},V.key)),d&&i.jsxs("button",{type:"button","data-testid":"g7le-overlay-separate-branch",title:E("layout_editor.context_menu.separate_branch_hint"),onClick:V=>{V.stopPropagation(),d()},style:ua,children:["📱 ",c??E("layout_editor.context_menu.separate_branch")]}),p&&i.jsxs("button",{type:"button","data-testid":"g7le-overlay-merge-branch",title:E("layout_editor.context_menu.merge_branch_hint"),onClick:V=>{V.stopPropagation(),p()},style:ua,children:["↩️ ",f??E("layout_editor.context_menu.merge_branch")]})]})]}),i.jsx(i2,{anchor:n&&B?{left:n.left+n.width+8,top:n.top-4}:null,open:B,onClose:()=>N(!1),onEditProps:s,onDuplicate:a,onDelete:l,onSeparateBranch:d,separateBranchLabel:c,onMergeBranch:p,mergeBranchLabel:f})]})}function l2(e){const{enabledAxes:t,onHandlePointerDown:n}=e,o=t?.width??!1,r=t?.height??!1,s=[{key:"nw",style:{left:-4,top:-4},cursor:"nwse-resize",needsWidth:!0,needsHeight:!0},{key:"n",style:{left:"50%",top:-4,transform:"translateX(-50%)"},cursor:"ns-resize",needsWidth:!1,needsHeight:!0},{key:"ne",style:{right:-4,top:-4},cursor:"nesw-resize",needsWidth:!0,needsHeight:!0},{key:"e",style:{right:-4,top:"50%",transform:"translateY(-50%)"},cursor:"ew-resize",needsWidth:!0,needsHeight:!1},{key:"se",style:{right:-4,bottom:-4},cursor:"nwse-resize",needsWidth:!0,needsHeight:!0},{key:"s",style:{left:"50%",bottom:-4,transform:"translateX(-50%)"},cursor:"ns-resize",needsWidth:!1,needsHeight:!0},{key:"sw",style:{left:-4,bottom:-4},cursor:"nesw-resize",needsWidth:!0,needsHeight:!0},{key:"w",style:{left:-4,top:"50%",transform:"translateY(-50%)"},cursor:"ew-resize",needsWidth:!0,needsHeight:!1}];return i.jsx(i.Fragment,{children:s.map(a=>{const l=!a.needsWidth||o,d=!a.needsHeight||r,c=l&&d&&!!n;return!l||!d?null:i.jsx("span",{"data-testid":`g7le-resize-handle-${a.key}`,"data-resize-handle-active":c?"true":"false",onPointerDown:c?p=>{p.preventDefault(),p.stopPropagation(),n?.(a.key,{clientX:p.clientX,clientY:p.clientY})}:void 0,style:{position:"absolute",...a.style,width:8,height:8,background:"#fff",border:"1px solid #2563eb",cursor:a.cursor,pointerEvents:c?"auto":"none",zIndex:On}},a.key)})})}const Fo={position:"absolute",top:-28,left:0,background:"#fff",border:"1px solid #2563eb",color:"#2563eb",padding:"2px 6px",fontSize:11,borderRadius:4,cursor:"pointer",pointerEvents:"auto",whiteSpace:"nowrap",zIndex:On},ua={background:"#fff",border:"1px solid #2563eb",color:"#2563eb",padding:"2px 6px",fontSize:11,borderRadius:4,cursor:"pointer",pointerEvents:"auto",whiteSpace:"nowrap",zIndex:On},pa={marginLeft:6,padding:"0 5px",borderRadius:3,background:"#eef2ff",border:"1px solid #c7d2fe",fontSize:10,fontWeight:600,color:"#3730a3"},d2={position:"absolute",top:0,right:0,transform:"translateY(-100%)",background:"rgba(124,58,237,0.92)",color:"#fff",padding:"1px 6px",borderRadius:"3px 3px 0 0",fontSize:10,fontWeight:600,whiteSpace:"nowrap",pointerEvents:"none"},Jp={position:"absolute",top:0,left:0,background:"rgba(37,99,235,0.55)",color:"#fff",padding:"1px 6px",fontSize:10,fontWeight:600,lineHeight:"14px",borderBottomRightRadius:4,letterSpacing:"0.02em",whiteSpace:"nowrap",pointerEvents:"none",userSelect:"none",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis"},Zp={position:"absolute",bottom:"100%",left:0,marginBottom:2,background:"rgba(37,99,235,0.55)",color:"#fff",padding:"1px 6px",fontSize:10,fontWeight:600,lineHeight:"14px",borderRadius:4,letterSpacing:"0.02em",whiteSpace:"nowrap",pointerEvents:"none",userSelect:"none"},c2={...Jp,pointerEvents:"auto",cursor:"pointer",background:"rgba(37,99,235,0.82)",border:"none",display:"inline-flex",alignItems:"center",font:"inherit",fontSize:10,fontWeight:600,zIndex:On},u2={...Zp,pointerEvents:"auto",cursor:"pointer",background:"rgba(37,99,235,0.82)",border:"none",display:"inline-flex",alignItems:"center",font:"inherit",fontSize:10,fontWeight:600,zIndex:On},p2={above:{top:-30,left:"50%",transform:"translateX(-50%)"},below:{bottom:-30,left:"50%",transform:"translateX(-50%)"},left:{left:-30,top:"50%",transform:"translateY(-50%)"},right:{right:-30,top:"50%",transform:"translateY(-50%)"}};function f2(e){const{selectedBox:t,points:n,onAddRequest:o}=e,{t:r}=et();if(!t||n.length===0)return null;const s=Hp(t),l=s==="outside"?Kp(t):null;return i.jsx("div",{className:"g7le-insertion-affordances","data-testid":"g7le-insertion-affordances",style:{position:"absolute",left:t.left,top:t.top,width:t.width,height:t.height,pointerEvents:"none"},children:n.map(d=>{const c=l?{left:l[d.direction].left,top:l[d.direction].top}:p2[d.direction],p=r(`layout_editor.insertion.${d.direction}`);return i.jsx("button",{type:"button",disabled:d.disabled,"data-testid":`g7le-insertion-${d.direction}`,"data-disabled":d.disabled?"true":"false","data-placement":s,"aria-label":p,title:p,onClick:f=>{f.stopPropagation(),d.disabled||o(d)},style:{position:"absolute",...c,width:24,height:24,borderRadius:12,border:"1px solid #2563eb",background:d.disabled?"#cbd5e1":"#fff",color:d.disabled?"#94a3b8":"#2563eb",cursor:d.disabled?"not-allowed":"pointer",opacity:d.disabled?.4:1,fontSize:16,fontWeight:700,lineHeight:"20px",padding:0,pointerEvents:"auto",boxShadow:"0 1px 3px rgba(0,0,0,0.15)",zIndex:On},children:"+"},d.direction)})})}const oi=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function po(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function fa(e){return"nodeType"in e}function xt(e){var t,n;return e?po(e)?e:fa(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function ga(e){const{Document:t}=xt(e);return e instanceof t}function Ko(e){return po(e)?!1:e instanceof xt(e).HTMLElement}function Qp(e){return e instanceof xt(e).SVGElement}function fo(e){return e?po(e)?e.document:fa(e)?ga(e)?e:Ko(e)||Qp(e)?e.ownerDocument:document:document:document}const ln=oi?u.useLayoutEffect:u.useEffect;function ri(e){const t=u.useRef(e);return ln(()=>{t.current=e}),u.useCallback(function(){for(var n=arguments.length,o=new Array(n),r=0;r{e.current=setInterval(o,r)},[]),n=u.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Vo(e,t){t===void 0&&(t=[e]);const n=u.useRef(e);return ln(()=>{n.current!==e&&(n.current=e)},t),n}function Uo(e,t){const n=u.useRef();return u.useMemo(()=>{const o=e(n.current);return n.current=o,o},[...t])}function ii(e){const t=ri(e),n=u.useRef(null),o=u.useCallback(r=>{r!==n.current&&t?.(r,n.current),n.current=r},[]);return[n,o]}function si(e){const t=u.useRef();return u.useEffect(()=>{t.current=e},[e]),t.current}let ha={};function ai(e,t){return u.useMemo(()=>{if(t)return t;const n=ha[e]==null?0:ha[e]+1;return ha[e]=n,e+"-"+n},[e,t])}function Rp(e){return function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r{const l=Object.entries(a);for(const[d,c]of l){const p=s[d];p!=null&&(s[d]=p+e*c)}return s},{...t})}}const go=Rp(1),li=Rp(-1);function h2(e){return"clientX"in e&&"clientY"in e}function ya(e){if(!e)return!1;const{KeyboardEvent:t}=xt(e.target);return t&&e instanceof t}function y2(e){if(!e)return!1;const{TouchEvent:t}=xt(e.target);return t&&e instanceof t}function di(e){if(y2(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return h2(e)?{x:e.clientX,y:e.clientY}:null}const qo=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[qo.Translate.toString(e),qo.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:o}=e;return t+" "+n+"ms "+o}}}),ef="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function b2(e){return e.matches(ef)?e:e.querySelector(ef)}const m2={display:"none"};function v2(e){let{id:t,value:n}=e;return u.createElement("div",{id:t,style:m2},n)}function _2(e){let{id:t,announcement:n,ariaLiveType:o="assertive"}=e;const r={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return u.createElement("div",{id:t,style:r,role:"status","aria-live":o,"aria-atomic":!0},n)}function x2(){const[e,t]=u.useState("");return{announce:u.useCallback(o=>{o!=null&&t(o)},[]),announcement:e}}const tf=u.createContext(null);function w2(e){const t=u.useContext(tf);u.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of ");return t(e)},[e,t])}function k2(){const[e]=u.useState(()=>new Set),t=u.useCallback(o=>(e.add(o),()=>e.delete(o)),[e]);return[u.useCallback(o=>{let{type:r,event:s}=o;e.forEach(a=>{var l;return(l=a[r])==null?void 0:l.call(a,s)})},[e]),t]}const S2={draggable:` To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel. - `},d2={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function c2(e){let{announcements:t=d2,container:n,hiddenTextDescribedById:o,screenReaderInstructions:r=l2}=e;const{announce:s,announcement:a}=i2(),l=oi("DndLiveRegion"),[d,c]=u.useState(!1);if(u.useEffect(()=>{c(!0)},[]),s2(u.useMemo(()=>({onDragStart(f){let{active:b}=f;s(t.onDragStart({active:b}))},onDragMove(f){let{active:b,over:g}=f;t.onDragMove&&s(t.onDragMove({active:b,over:g}))},onDragOver(f){let{active:b,over:g}=f;s(t.onDragOver({active:b,over:g}))},onDragEnd(f){let{active:b,over:g}=f;s(t.onDragEnd({active:b,over:g}))},onDragCancel(f){let{active:b,over:g}=f;s(t.onDragCancel({active:b,over:g}))}}),[s,t])),!d)return null;const p=u.createElement(u.Fragment,null,u.createElement(o2,{id:o,value:r.draggable}),u.createElement(r2,{id:l,announcement:a}));return n?Cn.createPortal(p,n):p}var it;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(it||(it={}));function si(){}function u2(e,t){return u.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function p2(){for(var e=arguments.length,t=new Array(e),n=0;n[...t].filter(o=>o!=null),[...t])}const Ht=Object.freeze({x:0,y:0});function f2(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function g2(e,t){const n=ii(e);if(!n)return"0 0";const o={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return o.x+"% "+o.y+"%"}function h2(e,t){let{data:{value:n}}=e,{data:{value:o}}=t;return n-o}function y2(e,t){let{data:{value:n}}=e,{data:{value:o}}=t;return o-n}function b2(e){let{left:t,top:n,height:o,width:r}=e;return[{x:t,y:n},{x:t+r,y:n},{x:t,y:n+o},{x:t+r,y:n+o}]}function m2(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function v2(e,t){const n=Math.max(t.top,e.top),o=Math.max(t.left,e.left),r=Math.min(t.left+t.width,e.left+e.width),s=Math.min(t.top+t.height,e.top+e.height),a=r-o,l=s-n;if(o{let{collisionRect:t,droppableRects:n,droppableContainers:o}=e;const r=[];for(const s of o){const{id:a}=s,l=n.get(a);if(l){const d=v2(l,t);d>0&&r.push({id:a,data:{droppableContainer:s,value:d}})}}return r.sort(y2)};function x2(e,t){const{top:n,left:o,bottom:r,right:s}=t;return n<=e.y&&e.y<=r&&o<=e.x&&e.x<=s}const w2=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:o}=e;if(!o)return[];const r=[];for(const s of t){const{id:a}=s,l=n.get(a);if(l&&x2(o,l)){const c=b2(l).reduce((f,b)=>f+f2(o,b),0),p=Number((c/4).toFixed(4));r.push({id:a,data:{droppableContainer:s,value:p}})}}return r.sort(h2)};function k2(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Xp(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Ht}function S2(e){return function(n){for(var o=arguments.length,r=new Array(o>1?o-1:0),s=1;s({...a,top:a.top+e*l.y,bottom:a.bottom+e*l.y,left:a.left+e*l.x,right:a.right+e*l.x}),{...n})}}const C2=S2(1);function Jp(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function $2(e,t,n){const o=Jp(t);if(!o)return e;const{scaleX:r,scaleY:s,x:a,y:l}=o,d=e.left-a-(1-r)*parseFloat(n),c=e.top-l-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),p=r?e.width/r:e.width,f=s?e.height/s:e.height;return{width:p,height:f,top:c,right:d+p,bottom:c+f,left:d}}const E2={ignoreTransform:!1};function Vo(e,t){t===void 0&&(t=E2);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:p}=xt(e).getComputedStyle(e);c&&(n=$2(n,c,p))}const{top:o,left:r,width:s,height:a,bottom:l,right:d}=n;return{top:o,left:r,width:s,height:a,bottom:l,right:d}}function Zp(e){return Vo(e,{ignoreTransform:!0})}function I2(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function A2(e,t){return t===void 0&&(t=xt(e).getComputedStyle(e)),t.position==="fixed"}function T2(e,t){t===void 0&&(t=xt(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(r=>{const s=t[r];return typeof s=="string"?n.test(s):!1})}function pa(e,t){const n=[];function o(r){if(t!=null&&n.length>=t||!r)return n;if(da(r)&&r.scrollingElement!=null&&!n.includes(r.scrollingElement))return n.push(r.scrollingElement),n;if(!jo(r)||Up(r)||n.includes(r))return n;const s=xt(e).getComputedStyle(r);return r!==e&&T2(r,s)&&n.push(r),A2(r,s)?n:o(r.parentNode)}return e?o(e):n}function Qp(e){const[t]=pa(e,1);return t??null}function fa(e){return!Rr||!e?null:co(e)?e:la(e)?da(e)||e===uo(e).scrollingElement?window:jo(e)?e:null:null}function Rp(e){return co(e)?e.scrollX:e.scrollLeft}function ef(e){return co(e)?e.scrollY:e.scrollTop}function ga(e){return{x:Rp(e),y:ef(e)}}var lt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(lt||(lt={}));function tf(e){return!Rr||!e?!1:e===document.scrollingElement}function nf(e){const t={x:0,y:0},n=tf(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},o={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},r=e.scrollTop<=t.y,s=e.scrollLeft<=t.x,a=e.scrollTop>=o.y,l=e.scrollLeft>=o.x;return{isTop:r,isLeft:s,isBottom:a,isRight:l,maxScroll:o,minScroll:t}}const D2={x:.2,y:.2};function z2(e,t,n,o,r){let{top:s,left:a,right:l,bottom:d}=n;o===void 0&&(o=10),r===void 0&&(r=D2);const{isTop:c,isBottom:p,isLeft:f,isRight:b}=nf(e),g={x:0,y:0},m={x:0,y:0},h={height:t.height*r.y,width:t.width*r.x};return!c&&s<=t.top+h.height?(g.y=lt.Backward,m.y=o*Math.abs((t.top+h.height-s)/h.height)):!p&&d>=t.bottom-h.height&&(g.y=lt.Forward,m.y=o*Math.abs((t.bottom-h.height-d)/h.height)),!b&&l>=t.right-h.width?(g.x=lt.Forward,m.x=o*Math.abs((t.right-h.width-l)/h.width)):!f&&a<=t.left+h.width&&(g.x=lt.Backward,m.x=o*Math.abs((t.left+h.width-a)/h.width)),{direction:g,speed:m}}function N2(e){if(e===document.scrollingElement){const{innerWidth:s,innerHeight:a}=window;return{top:0,left:0,right:s,bottom:a,width:s,height:a}}const{top:t,left:n,right:o,bottom:r}=e.getBoundingClientRect();return{top:t,left:n,right:o,bottom:r,width:e.clientWidth,height:e.clientHeight}}function of(e){return e.reduce((t,n)=>po(t,ga(n)),Ht)}function M2(e){return e.reduce((t,n)=>t+Rp(n),0)}function L2(e){return e.reduce((t,n)=>t+ef(n),0)}function rf(e,t){if(t===void 0&&(t=Vo),!e)return;const{top:n,left:o,bottom:r,right:s}=t(e);Qp(e)&&(r<=0||s<=0||n>=window.innerHeight||o>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const P2=[["x",["left","right"],M2],["y",["top","bottom"],L2]];class ha{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const o=pa(n),r=of(o);this.rect={...t},this.width=t.width,this.height=t.height;for(const[s,a,l]of P2)for(const d of a)Object.defineProperty(this,d,{get:()=>{const c=l(o),p=r[s]-c;return this.rect[d]+p},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Uo{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var o;return(o=this.target)==null?void 0:o.removeEventListener(...n)})},this.target=t}add(t,n,o){var r;(r=this.target)==null||r.addEventListener(t,n,o),this.listeners.push([t,n,o])}}function O2(e){const{EventTarget:t}=xt(e);return e instanceof t?e:uo(e)}function ya(e,t){const n=Math.abs(e.x),o=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+o**2)>t:"x"in t&&"y"in t?n>t.x&&o>t.y:"x"in t?n>t.x:"y"in t?o>t.y:!1}var At;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(At||(At={}));function sf(e){e.preventDefault()}function B2(e){e.stopPropagation()}var Fe;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(Fe||(Fe={}));const af={start:[Fe.Space,Fe.Enter],cancel:[Fe.Esc],end:[Fe.Space,Fe.Enter,Fe.Tab]},W2=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Fe.Right:return{...n,x:n.x+25};case Fe.Left:return{...n,x:n.x-25};case Fe.Down:return{...n,y:n.y+25};case Fe.Up:return{...n,y:n.y-25}}};class lf{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new Uo(uo(n)),this.windowListeners=new Uo(xt(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(At.Resize,this.handleCancel),this.windowListeners.add(At.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(At.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,o=t.node.current;o&&rf(o),n(Ht)}handleKeyDown(t){if(ua(t)){const{active:n,context:o,options:r}=this.props,{keyboardCodes:s=af,coordinateGetter:a=W2,scrollBehavior:l="smooth"}=r,{code:d}=t;if(s.end.includes(d)){this.handleEnd(t);return}if(s.cancel.includes(d)){this.handleCancel(t);return}const{collisionRect:c}=o.current,p=c?{x:c.left,y:c.top}:Ht;this.referenceCoordinates||(this.referenceCoordinates=p);const f=a(t,{active:n,context:o.current,currentCoordinates:p});if(f){const b=ri(f,p),g={x:0,y:0},{scrollableAncestors:m}=o.current;for(const h of m){const v=t.code,{isTop:y,isRight:_,isLeft:w,isBottom:k,maxScroll:x,minScroll:$}=nf(h),S=N2(h),C={x:Math.min(v===Fe.Right?S.right-S.width/2:S.right,Math.max(v===Fe.Right?S.left:S.left+S.width/2,f.x)),y:Math.min(v===Fe.Down?S.bottom-S.height/2:S.bottom,Math.max(v===Fe.Down?S.top:S.top+S.height/2,f.y))},T=v===Fe.Right&&!_||v===Fe.Left&&!w,E=v===Fe.Down&&!k||v===Fe.Up&&!y;if(T&&C.x!==f.x){const A=h.scrollLeft+b.x,N=v===Fe.Right&&A<=x.x||v===Fe.Left&&A>=$.x;if(N&&!b.y){h.scrollTo({left:A,behavior:l});return}N?g.x=h.scrollLeft-A:g.x=v===Fe.Right?h.scrollLeft-x.x:h.scrollLeft-$.x,g.x&&h.scrollBy({left:-g.x,behavior:l});break}else if(E&&C.y!==f.y){const A=h.scrollTop+b.y,N=v===Fe.Down&&A<=x.y||v===Fe.Up&&A>=$.y;if(N&&!b.x){h.scrollTo({top:A,behavior:l});return}N?g.y=h.scrollTop-A:g.y=v===Fe.Down?h.scrollTop-x.y:h.scrollTop-$.y,g.y&&h.scrollBy({top:-g.y,behavior:l});break}}this.handleMove(t,po(ri(f,this.referenceCoordinates),g))}}}handleMove(t,n){const{onMove:o}=this.props;t.preventDefault(),o(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}lf.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:o=af,onActivation:r}=t,{active:s}=n;const{code:a}=e.nativeEvent;if(o.start.includes(a)){const l=s.activatorNode.current;return l&&e.target!==l?!1:(e.preventDefault(),r?.({event:e.nativeEvent}),!0)}return!1}}];function df(e){return!!(e&&"distance"in e)}function cf(e){return!!(e&&"delay"in e)}class ba{constructor(t,n,o){var r;o===void 0&&(o=O2(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:s}=t,{target:a}=s;this.props=t,this.events=n,this.document=uo(a),this.documentListeners=new Uo(this.document),this.listeners=new Uo(o),this.windowListeners=new Uo(xt(a)),this.initialCoordinates=(r=ii(s))!=null?r:Ht,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:o}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(At.Resize,this.handleCancel),this.windowListeners.add(At.DragStart,sf),this.windowListeners.add(At.VisibilityChange,this.handleCancel),this.windowListeners.add(At.ContextMenu,sf),this.documentListeners.add(At.Keydown,this.handleKeydown),n){if(o!=null&&o({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(cf(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(df(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:o,onPending:r}=this.props;r(o,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(At.Click,B2,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(At.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:o,initialCoordinates:r,props:s}=this,{onMove:a,options:{activationConstraint:l}}=s;if(!r)return;const d=(n=ii(t))!=null?n:Ht,c=ri(r,d);if(!o&&l){if(df(l)){if(l.tolerance!=null&&ya(c,l.tolerance))return this.handleCancel();if(ya(c,l.distance))return this.handleStart()}if(cf(l)&&ya(c,l.tolerance))return this.handleCancel();this.handlePending(l,c);return}t.cancelable&&t.preventDefault(),a(d)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===Fe.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const j2={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class ma extends ba{constructor(t){const{event:n}=t,o=uo(n.target);super(t,j2,o)}}ma.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:o}=t;return!n.isPrimary||n.button!==0?!1:(o?.({event:n}),!0)}}];const H2={move:{name:"mousemove"},end:{name:"mouseup"}};var va;(function(e){e[e.RightClick=2]="RightClick"})(va||(va={}));class F2 extends ba{constructor(t){super(t,H2,uo(t.event.target))}}F2.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:o}=t;return n.button===va.RightClick?!1:(o?.({event:n}),!0)}}];const _a={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class K2 extends ba{constructor(t){super(t,_a)}static setup(){return window.addEventListener(_a.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(_a.move.name,t)};function t(){}}}K2.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:o}=t;const{touches:r}=n;return r.length>1?!1:(o?.({event:n}),!0)}}];var qo;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(qo||(qo={}));var ai;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(ai||(ai={}));function V2(e){let{acceleration:t,activator:n=qo.Pointer,canScroll:o,draggingRect:r,enabled:s,interval:a=5,order:l=ai.TreeOrder,pointerCoordinates:d,scrollableAncestors:c,scrollableAncestorRects:p,delta:f,threshold:b}=e;const g=q2({delta:f,disabled:!s}),[m,h]=Q7(),v=u.useRef({x:0,y:0}),y=u.useRef({x:0,y:0}),_=u.useMemo(()=>{switch(n){case qo.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case qo.DraggableRect:return r}},[n,r,d]),w=u.useRef(null),k=u.useCallback(()=>{const $=w.current;if(!$)return;const S=v.current.x*y.current.x,C=v.current.y*y.current.y;$.scrollBy(S,C)},[]),x=u.useMemo(()=>l===ai.TreeOrder?[...c].reverse():c,[l,c]);u.useEffect(()=>{if(!s||!c.length||!_){h();return}for(const $ of x){if(o?.($)===!1)continue;const S=c.indexOf($),C=p[S];if(!C)continue;const{direction:T,speed:E}=z2($,C,_,t,b);for(const A of["x","y"])g[A][T[A]]||(E[A]=0,T[A]=0);if(E.x>0||E.y>0){h(),w.current=$,m(k,a),v.current=E,y.current=T;return}}v.current={x:0,y:0},y.current={x:0,y:0},h()},[t,k,o,h,s,a,JSON.stringify(_),JSON.stringify(g),m,c,x,p,JSON.stringify(b)])}const U2={x:{[lt.Backward]:!1,[lt.Forward]:!1},y:{[lt.Backward]:!1,[lt.Forward]:!1}};function q2(e){let{delta:t,disabled:n}=e;const o=ni(t);return Fo(r=>{if(n||!o||!r)return U2;const s={x:Math.sign(t.x-o.x),y:Math.sign(t.y-o.y)};return{x:{[lt.Backward]:r.x[lt.Backward]||s.x===-1,[lt.Forward]:r.x[lt.Forward]||s.x===1},y:{[lt.Backward]:r.y[lt.Backward]||s.y===-1,[lt.Forward]:r.y[lt.Forward]||s.y===1}}},[n,t,o])}function G2(e,t){const n=t!=null?e.get(t):void 0,o=n?n.node.current:null;return Fo(r=>{var s;return t==null?null:(s=o??r)!=null?s:null},[o,t])}function Y2(e,t){return u.useMemo(()=>e.reduce((n,o)=>{const{sensor:r}=o,s=r.activators.map(a=>({eventName:a.eventName,handler:t(a.handler,o)}));return[...n,...s]},[]),[e,t])}var Go;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Go||(Go={}));var xa;(function(e){e.Optimized="optimized"})(xa||(xa={}));const uf=new Map;function X2(e,t){let{dragging:n,dependencies:o,config:r}=t;const[s,a]=u.useState(null),{frequency:l,measure:d,strategy:c}=r,p=u.useRef(e),f=v(),b=Ho(f),g=u.useCallback(function(y){y===void 0&&(y=[]),!b.current&&a(_=>_===null?y:_.concat(y.filter(w=>!_.includes(w))))},[b]),m=u.useRef(null),h=Fo(y=>{if(f&&!n)return uf;if(!y||y===uf||p.current!==e||s!=null){const _=new Map;for(let w of e){if(!w)continue;if(s&&s.length>0&&!s.includes(w.id)&&w.rect.current){_.set(w.id,w.rect.current);continue}const k=w.node.current,x=k?new ha(d(k),k):null;w.rect.current=x,x&&_.set(w.id,x)}return _}return y},[e,s,n,f,d]);return u.useEffect(()=>{p.current=e},[e]),u.useEffect(()=>{f||g()},[n,f]),u.useEffect(()=>{s&&s.length>0&&a(null)},[JSON.stringify(s)]),u.useEffect(()=>{f||typeof l!="number"||m.current!==null||(m.current=setTimeout(()=>{g(),m.current=null},l))},[l,f,g,...o]),{droppableRects:h,measureDroppableContainers:g,measuringScheduled:s!=null};function v(){switch(c){case Go.Always:return!1;case Go.BeforeDragging:return n;default:return!n}}}function wa(e,t){return Fo(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function J2(e,t){return wa(e,t)}function Z2(e){let{callback:t,disabled:n}=e;const o=ei(t),r=u.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:s}=window;return new s(o)},[o,n]);return u.useEffect(()=>()=>r?.disconnect(),[r]),r}function li(e){let{callback:t,disabled:n}=e;const o=ei(t),r=u.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:s}=window;return new s(o)},[n]);return u.useEffect(()=>()=>r?.disconnect(),[r]),r}function Q2(e){return new ha(Vo(e),e)}function pf(e,t,n){t===void 0&&(t=Q2);const[o,r]=u.useState(null);function s(){r(d=>{if(!e)return null;if(e.isConnected===!1){var c;return(c=d??n)!=null?c:null}const p=t(e);return JSON.stringify(d)===JSON.stringify(p)?d:p})}const a=Z2({callback(d){if(e)for(const c of d){const{type:p,target:f}=c;if(p==="childList"&&f instanceof HTMLElement&&f.contains(e)){s();break}}}}),l=li({callback:s});return sn(()=>{s(),e?(l?.observe(e),a?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),a?.disconnect())},[e]),o}function R2(e){const t=wa(e);return Xp(e,t)}const ff=[];function eI(e){const t=u.useRef(e),n=Fo(o=>e?o&&o!==ff&&e&&t.current&&e.parentNode===t.current.parentNode?o:pa(e):ff,[e]);return u.useEffect(()=>{t.current=e},[e]),n}function tI(e){const[t,n]=u.useState(null),o=u.useRef(e),r=u.useCallback(s=>{const a=fa(s.target);a&&n(l=>l?(l.set(a,ga(a)),new Map(l)):null)},[]);return u.useEffect(()=>{const s=o.current;if(e!==s){a(s);const l=e.map(d=>{const c=fa(d);return c?(c.addEventListener("scroll",r,{passive:!0}),[c,ga(c)]):null}).filter(d=>d!=null);n(l.length?new Map(l):null),o.current=e}return()=>{a(e),a(s)};function a(l){l.forEach(d=>{const c=fa(d);c?.removeEventListener("scroll",r)})}},[r,e]),u.useMemo(()=>e.length?t?Array.from(t.values()).reduce((s,a)=>po(s,a),Ht):of(e):Ht,[e,t])}function gf(e,t){t===void 0&&(t=[]);const n=u.useRef(null);return u.useEffect(()=>{n.current=null},t),u.useEffect(()=>{const o=e!==Ht;o&&!n.current&&(n.current=e),!o&&n.current&&(n.current=null)},[e]),n.current?ri(e,n.current):Ht}function nI(e){u.useEffect(()=>{if(!Rr)return;const t=e.map(n=>{let{sensor:o}=n;return o.setup==null?void 0:o.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function oI(e,t){return u.useMemo(()=>e.reduce((n,o)=>{let{eventName:r,handler:s}=o;return n[r]=a=>{s(a,t)},n},{}),[e,t])}function hf(e){return u.useMemo(()=>e?I2(e):null,[e])}const yf=[];function rI(e,t){t===void 0&&(t=Vo);const[n]=e,o=hf(n?xt(n):null),[r,s]=u.useState(yf);function a(){s(()=>e.length?e.map(d=>tf(d)?o:new ha(t(d),d)):yf)}const l=li({callback:a});return sn(()=>{l?.disconnect(),a(),e.forEach(d=>l?.observe(d))},[e]),r}function bf(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return jo(t)?t:e}function iI(e){let{measure:t}=e;const[n,o]=u.useState(null),r=u.useCallback(c=>{for(const{target:p}of c)if(jo(p)){o(f=>{const b=t(p);return f?{...f,width:b.width,height:b.height}:b});break}},[t]),s=li({callback:r}),a=u.useCallback(c=>{const p=bf(c);s?.disconnect(),p&&s?.observe(p),o(p?t(p):null)},[t,s]),[l,d]=ti(a);return u.useMemo(()=>({nodeRef:l,rect:n,setRef:d}),[n,l,d])}const sI=[{sensor:ma,options:{}},{sensor:lf,options:{}}],aI={current:{}},di={draggable:{measure:Zp},droppable:{measure:Zp,strategy:Go.WhileDragging,frequency:xa.Optimized},dragOverlay:{measure:Vo}};class Yo extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,o;return(n=(o=this.get(t))==null?void 0:o.node.current)!=null?n:void 0}}const lI={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Yo,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:si},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:di,measureDroppableContainers:si,windowRect:null,measuringScheduled:!1},mf={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:si,draggableNodes:new Map,over:null,measureDroppableContainers:si},Xo=u.createContext(mf),vf=u.createContext(lI);function dI(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Yo}}}function cI(e,t){switch(t.type){case it.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case it.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case it.DragEnd:case it.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case it.RegisterDroppable:{const{element:n}=t,{id:o}=n,r=new Yo(e.droppable.containers);return r.set(o,n),{...e,droppable:{...e.droppable,containers:r}}}case it.SetDroppableDisabled:{const{id:n,key:o,disabled:r}=t,s=e.droppable.containers.get(n);if(!s||o!==s.key)return e;const a=new Yo(e.droppable.containers);return a.set(n,{...s,disabled:r}),{...e,droppable:{...e.droppable,containers:a}}}case it.UnregisterDroppable:{const{id:n,key:o}=t,r=e.droppable.containers.get(n);if(!r||o!==r.key)return e;const s=new Yo(e.droppable.containers);return s.delete(n),{...e,droppable:{...e.droppable,containers:s}}}default:return e}}function uI(e){let{disabled:t}=e;const{active:n,activatorEvent:o,draggableNodes:r}=u.useContext(Xo),s=ni(o),a=ni(n?.id);return u.useEffect(()=>{if(!t&&!o&&s&&a!=null){if(!ua(s)||document.activeElement===s.target)return;const l=r.get(a);if(!l)return;const{activatorNode:d,node:c}=l;if(!d.current&&!c.current)return;requestAnimationFrame(()=>{for(const p of[d.current,c.current]){if(!p)continue;const f=t2(p);if(f){f.focus();break}}})}},[o,t,r,a,s]),null}function _f(e,t){let{transform:n,...o}=t;return e!=null&&e.length?e.reduce((r,s)=>s({transform:r,...o}),n):n}function pI(e){return u.useMemo(()=>({draggable:{...di.draggable,...e?.draggable},droppable:{...di.droppable,...e?.droppable},dragOverlay:{...di.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function fI(e){let{activeNode:t,measure:n,initialRect:o,config:r=!0}=e;const s=u.useRef(!1),{x:a,y:l}=typeof r=="boolean"?{x:r,y:r}:r;sn(()=>{if(!a&&!l||!t){s.current=!1;return}if(s.current||!o)return;const c=t?.node.current;if(!c||c.isConnected===!1)return;const p=n(c),f=Xp(p,o);if(a||(f.x=0),l||(f.y=0),s.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const b=Qp(c);b&&b.scrollBy({top:f.y,left:f.x})}},[t,a,l,o,n])}const ci=u.createContext({...Ht,scaleX:1,scaleY:1});var hn;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(hn||(hn={}));const gI=u.memo(function(t){var n,o,r,s;let{id:a,accessibility:l,autoScroll:d=!0,children:c,sensors:p=sI,collisionDetection:f=_2,measuring:b,modifiers:g,...m}=t;const h=u.useReducer(cI,void 0,dI),[v,y]=h,[_,w]=a2(),[k,x]=u.useState(hn.Uninitialized),$=k===hn.Initialized,{draggable:{active:S,nodes:C,translate:T},droppable:{containers:E}}=v,A=S!=null?C.get(S):null,N=u.useRef({initial:null,translated:null}),D=u.useMemo(()=>{var Q;return S!=null?{id:S,data:(Q=A?.data)!=null?Q:aI,rect:N}:null},[S,A]),B=u.useRef(null),[M,O]=u.useState(null),[z,H]=u.useState(null),P=Ho(m,Object.values(m)),I=oi("DndDescribedBy",a),L=u.useMemo(()=>E.getEnabled(),[E]),F=pI(b),{droppableRects:Y,measureDroppableContainers:K,measuringScheduled:X}=X2(L,{dragging:$,dependencies:[T.x,T.y],config:F.droppable}),Z=G2(C,S),ae=u.useMemo(()=>z?ii(z):null,[z]),oe=pe(),G=J2(Z,F.draggable.measure);fI({activeNode:S!=null?C.get(S):null,config:oe.layoutShiftCompensation,initialRect:G,measure:F.draggable.measure});const ee=pf(Z,F.draggable.measure,G),ge=pf(Z?Z.parentElement:null),V=u.useRef({activatorEvent:null,active:null,activeNode:Z,collisionRect:null,collisions:null,droppableRects:Y,draggableNodes:C,draggingNode:null,draggingNodeRect:null,droppableContainers:E,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),te=E.getNodeFor((n=V.current.over)==null?void 0:n.id),be=iI({measure:F.dragOverlay.measure}),Ee=(o=be.nodeRef.current)!=null?o:Z,De=$?(r=be.rect)!=null?r:ee:null,Se=!!(be.nodeRef.current&&be.rect),Ue=R2(Se?null:ee),Me=hf(Ee?xt(Ee):null),Oe=eI($?te??Z:null),Ye=rI(Oe),ze=_f(g,{transform:{x:T.x-Ue.x,y:T.y-Ue.y,scaleX:1,scaleY:1},activatorEvent:z,active:D,activeNodeRect:ee,containerNodeRect:ge,draggingNodeRect:De,over:V.current.over,overlayNodeRect:be.rect,scrollableAncestors:Oe,scrollableAncestorRects:Ye,windowRect:Me}),Xe=ae?po(ae,T):null,ve=tI(Oe),qe=gf(ve),We=gf(ve,[ee]),ce=po(ze,qe),q=De?C2(De,ze):null,ie=D&&q?f({active:D,collisionRect:q,droppableRects:Y,droppableContainers:L,pointerCoordinates:Xe}):null,se=m2(ie,"id"),[me,Ce]=u.useState(null),$e=Se?ze:po(ze,We),U=k2($e,(s=me?.rect)!=null?s:null,ee),ue=u.useRef(null),fe=u.useCallback((Q,le)=>{let{sensor:Ae,options:dt}=le;if(B.current==null)return;const pt=C.get(B.current);if(!pt)return;const ot=Q.nativeEvent,Le=new Ae({active:B.current,activeNode:pt,event:ot,options:dt,context:V,onAbort(Je){if(!C.get(Je))return;const{onDragAbort:Dt}=P.current,zt={id:Je};Dt?.(zt),_({type:"onDragAbort",event:zt})},onPending(Je,Tt,Dt,zt){if(!C.get(Je))return;const{onDragPending:wn}=P.current,Zt={id:Je,constraint:Tt,initialCoordinates:Dt,offset:zt};wn?.(Zt),_({type:"onDragPending",event:Zt})},onStart(Je){const Tt=B.current;if(Tt==null)return;const Dt=C.get(Tt);if(!Dt)return;const{onDragStart:zt}=P.current,xn={activatorEvent:ot,active:{id:Tt,data:Dt.data,rect:N}};Cn.unstable_batchedUpdates(()=>{zt?.(xn),x(hn.Initializing),y({type:it.DragStart,initialCoordinates:Je,active:Tt}),_({type:"onDragStart",event:xn}),O(ue.current),H(ot)})},onMove(Je){y({type:it.DragMove,coordinates:Je})},onEnd:je(it.DragEnd),onCancel:je(it.DragCancel)});ue.current=Le;function je(Je){return async function(){const{active:Dt,collisions:zt,over:xn,scrollAdjustedTranslate:wn}=V.current;let Zt=null;if(Dt&&wn){const{cancelDrop:Hn}=P.current;Zt={activatorEvent:ot,active:Dt,collisions:zt,delta:wn,over:xn},Je===it.DragEnd&&typeof Hn=="function"&&await Promise.resolve(Hn(Zt))&&(Je=it.DragCancel)}B.current=null,Cn.unstable_batchedUpdates(()=>{y({type:Je}),x(hn.Uninitialized),Ce(null),O(null),H(null),ue.current=null;const Hn=Je===it.DragEnd?"onDragEnd":"onDragCancel";if(Zt){const ln=P.current[Hn];ln?.(Zt),_({type:Hn,event:Zt})}})}}},[C]),xe=u.useCallback((Q,le)=>(Ae,dt)=>{const pt=Ae.nativeEvent,ot=C.get(dt);if(B.current!==null||!ot||pt.dndKit||pt.defaultPrevented)return;const Le={active:ot};Q(Ae,le.options,Le)===!0&&(pt.dndKit={capturedBy:le.sensor},B.current=dt,fe(Ae,le))},[C,fe]),he=Y2(p,xe);nI(p),sn(()=>{ee&&k===hn.Initializing&&x(hn.Initialized)},[ee,k]),u.useEffect(()=>{const{onDragMove:Q}=P.current,{active:le,activatorEvent:Ae,collisions:dt,over:pt}=V.current;if(!le||!Ae)return;const ot={active:le,activatorEvent:Ae,collisions:dt,delta:{x:ce.x,y:ce.y},over:pt};Cn.unstable_batchedUpdates(()=>{Q?.(ot),_({type:"onDragMove",event:ot})})},[ce.x,ce.y]),u.useEffect(()=>{const{active:Q,activatorEvent:le,collisions:Ae,droppableContainers:dt,scrollAdjustedTranslate:pt}=V.current;if(!Q||B.current==null||!le||!pt)return;const{onDragOver:ot}=P.current,Le=dt.get(se),je=Le&&Le.rect.current?{id:Le.id,rect:Le.rect.current,data:Le.data,disabled:Le.disabled}:null,Je={active:Q,activatorEvent:le,collisions:Ae,delta:{x:pt.x,y:pt.y},over:je};Cn.unstable_batchedUpdates(()=>{Ce(je),ot?.(Je),_({type:"onDragOver",event:Je})})},[se]),sn(()=>{V.current={activatorEvent:z,active:D,activeNode:Z,collisionRect:q,collisions:ie,droppableRects:Y,draggableNodes:C,draggingNode:Ee,draggingNodeRect:De,droppableContainers:E,over:me,scrollableAncestors:Oe,scrollAdjustedTranslate:ce},N.current={initial:De,translated:q}},[D,Z,ie,q,C,Ee,De,Y,E,me,Oe,ce]),V2({...oe,delta:T,draggingRect:q,pointerCoordinates:Xe,scrollableAncestors:Oe,scrollableAncestorRects:Ye});const j=u.useMemo(()=>({active:D,activeNode:Z,activeNodeRect:ee,activatorEvent:z,collisions:ie,containerNodeRect:ge,dragOverlay:be,draggableNodes:C,droppableContainers:E,droppableRects:Y,over:me,measureDroppableContainers:K,scrollableAncestors:Oe,scrollableAncestorRects:Ye,measuringConfiguration:F,measuringScheduled:X,windowRect:Me}),[D,Z,ee,z,ie,ge,be,C,E,Y,me,K,Oe,Ye,F,X,Me]),ne=u.useMemo(()=>({activatorEvent:z,activators:he,active:D,activeNodeRect:ee,ariaDescribedById:{draggable:I},dispatch:y,draggableNodes:C,over:me,measureDroppableContainers:K}),[z,he,D,ee,y,I,C,me,K]);return u.createElement(Yp.Provider,{value:w},u.createElement(Xo.Provider,{value:ne},u.createElement(vf.Provider,{value:j},u.createElement(ci.Provider,{value:U},c)),u.createElement(uI,{disabled:l?.restoreFocus===!1})),u.createElement(c2,{...l,hiddenTextDescribedById:I}));function pe(){const Q=M?.autoScrollEnabled===!1,le=typeof d=="object"?d.enabled===!1:d===!1,Ae=$&&!Q&&!le;return typeof d=="object"?{...d,enabled:Ae}:{enabled:Ae}}}),hI=u.createContext(null),xf="button",yI="Draggable";function bI(e){let{id:t,data:n,disabled:o=!1,attributes:r}=e;const s=oi(yI),{activators:a,activatorEvent:l,active:d,activeNodeRect:c,ariaDescribedById:p,draggableNodes:f,over:b}=u.useContext(Xo),{role:g=xf,roleDescription:m="draggable",tabIndex:h=0}=r??{},v=d?.id===t,y=u.useContext(v?ci:hI),[_,w]=ti(),[k,x]=ti(),$=oI(a,t),S=Ho(n);sn(()=>(f.set(t,{id:t,key:s,node:_,activatorNode:k,data:S}),()=>{const T=f.get(t);T&&T.key===s&&f.delete(t)}),[f,t]);const C=u.useMemo(()=>({role:g,tabIndex:h,"aria-disabled":o,"aria-pressed":v&&g===xf?!0:void 0,"aria-roledescription":m,"aria-describedby":p.draggable}),[o,g,h,v,m,p.draggable]);return{active:d,activatorEvent:l,activeNodeRect:c,attributes:C,isDragging:v,listeners:o?void 0:$,node:_,over:b,setNodeRef:w,setActivatorNodeRef:x,transform:y}}function mI(){return u.useContext(vf)}const vI="Droppable",_I={timeout:25};function xI(e){let{data:t,disabled:n=!1,id:o,resizeObserverConfig:r}=e;const s=oi(vI),{active:a,dispatch:l,over:d,measureDroppableContainers:c}=u.useContext(Xo),p=u.useRef({disabled:n}),f=u.useRef(!1),b=u.useRef(null),g=u.useRef(null),{disabled:m,updateMeasurementsFor:h,timeout:v}={..._I,...r},y=Ho(h??o),_=u.useCallback(()=>{if(!f.current){f.current=!0;return}g.current!=null&&clearTimeout(g.current),g.current=setTimeout(()=>{c(Array.isArray(y.current)?y.current:[y.current]),g.current=null},v)},[v]),w=li({callback:_,disabled:m||!a}),k=u.useCallback((C,T)=>{w&&(T&&(w.unobserve(T),f.current=!1),C&&w.observe(C))},[w]),[x,$]=ti(k),S=Ho(t);return u.useEffect(()=>{!w||!x.current||(w.disconnect(),f.current=!1,w.observe(x.current))},[x,w]),u.useEffect(()=>(l({type:it.RegisterDroppable,element:{id:o,key:s,disabled:n,node:x,rect:b,data:S}}),()=>l({type:it.UnregisterDroppable,key:s,id:o})),[o]),u.useEffect(()=>{n!==p.current.disabled&&(l({type:it.SetDroppableDisabled,id:o,key:s,disabled:n}),p.current.disabled=n)},[o,s,n,l]),{active:a,rect:b,isOver:d?.id===o,node:x,over:d,setNodeRef:$}}function wI(e){let{animation:t,children:n}=e;const[o,r]=u.useState(null),[s,a]=u.useState(null),l=ni(n);return!n&&!o&&l&&r(l),sn(()=>{if(!s)return;const d=o?.key,c=o?.props.id;if(d==null||c==null){r(null);return}Promise.resolve(t(c,s)).then(()=>{r(null)})},[t,o,s]),u.createElement(u.Fragment,null,n,o?u.cloneElement(o,{ref:a}):null)}const kI={x:0,y:0,scaleX:1,scaleY:1};function SI(e){let{children:t}=e;return u.createElement(Xo.Provider,{value:mf},u.createElement(ci.Provider,{value:kI},t))}const CI={position:"fixed",touchAction:"none"},$I=e=>ua(e)?"transform 250ms ease":void 0,EI=u.forwardRef((e,t)=>{let{as:n,activatorEvent:o,adjustScale:r,children:s,className:a,rect:l,style:d,transform:c,transition:p=$I}=e;if(!l)return null;const f=r?c:{...c,scaleX:1,scaleY:1},b={...CI,width:l.width,height:l.height,top:l.top,left:l.left,transform:Ko.Transform.toString(f),transformOrigin:r&&o?g2(o,l):void 0,transition:typeof p=="function"?p(o):p,...d};return u.createElement(n,{className:a,style:b,ref:t},s)}),II={duration:250,easing:"ease",keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:Ko.Transform.toString(t)},{transform:Ko.Transform.toString(n)}]},sideEffects:(e=>t=>{let{active:n,dragOverlay:o}=t;const r={},{styles:s,className:a}=e;if(s!=null&&s.active)for(const[l,d]of Object.entries(s.active))d!==void 0&&(r[l]=n.node.style.getPropertyValue(l),n.node.style.setProperty(l,d));if(s!=null&&s.dragOverlay)for(const[l,d]of Object.entries(s.dragOverlay))d!==void 0&&o.node.style.setProperty(l,d);return a!=null&&a.active&&n.node.classList.add(a.active),a!=null&&a.dragOverlay&&o.node.classList.add(a.dragOverlay),function(){for(const[d,c]of Object.entries(r))n.node.style.setProperty(d,c);a!=null&&a.active&&n.node.classList.remove(a.active)}})({styles:{active:{opacity:"0"}}})};function AI(e){let{config:t,draggableNodes:n,droppableContainers:o,measuringConfiguration:r}=e;return ei((s,a)=>{if(t===null)return;const l=n.get(s);if(!l)return;const d=l.node.current;if(!d)return;const c=bf(a);if(!c)return;const{transform:p}=xt(a).getComputedStyle(a),f=Jp(p);if(!f)return;const b=typeof t=="function"?t:TI(t);return rf(d,r.draggable.measure),b({active:{id:s,data:l.data,node:d,rect:r.draggable.measure(d)},draggableNodes:n,dragOverlay:{node:a,rect:r.dragOverlay.measure(c)},droppableContainers:o,measuringConfiguration:r,transform:f})})}function TI(e){const{duration:t,easing:n,sideEffects:o,keyframes:r}={...II,...e};return s=>{let{active:a,dragOverlay:l,transform:d,...c}=s;if(!t)return;const p={x:l.rect.left-a.rect.left,y:l.rect.top-a.rect.top},f={scaleX:d.scaleX!==1?a.rect.width*d.scaleX/l.rect.width:1,scaleY:d.scaleY!==1?a.rect.height*d.scaleY/l.rect.height:1},b={x:d.x-p.x,y:d.y-p.y,...f},g=r({...c,active:a,dragOverlay:l,transform:{initial:d,final:b}}),[m]=g,h=g[g.length-1];if(JSON.stringify(m)===JSON.stringify(h))return;const v=o?.({active:a,dragOverlay:l,...c}),y=l.node.animate(g,{duration:t,easing:n,fill:"forwards"});return new Promise(_=>{y.onfinish=()=>{v?.(),_()}})}}let wf=0;function DI(e){return u.useMemo(()=>{if(e!=null)return wf++,wf},[e])}const zI=u.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:o,style:r,transition:s,modifiers:a,wrapperElement:l="div",className:d,zIndex:c=999}=e;const{activatorEvent:p,active:f,activeNodeRect:b,containerNodeRect:g,draggableNodes:m,droppableContainers:h,dragOverlay:v,over:y,measuringConfiguration:_,scrollableAncestors:w,scrollableAncestorRects:k,windowRect:x}=mI(),$=u.useContext(ci),S=DI(f?.id),C=_f(a,{activatorEvent:p,active:f,activeNodeRect:b,containerNodeRect:g,draggingNodeRect:v.rect,over:y,overlayNodeRect:v.rect,scrollableAncestors:w,scrollableAncestorRects:k,transform:$,windowRect:x}),T=wa(b),E=AI({config:o,draggableNodes:m,droppableContainers:h,measuringConfiguration:_}),A=T?v.setRef:void 0;return u.createElement(SI,null,u.createElement(wI,{animation:E},f&&S?u.createElement(EI,{key:S,id:f.id,ref:A,as:l,activatorEvent:p,adjustScale:t,className:d,transition:s,rect:T,style:{zIndex:c,...r},transform:C},n):null))});function Jo(e,t){return!t||!Array.isArray(t.draggable)?!1:t.draggable.includes(e)}function NI({draggedComponentName:e,targetContainerName:t,nesting:n}){if(!n||!Jo(e,n))return!1;const o=n.containers;if(!o||typeof o!="object")return!1;const r=o[t];return!r||!Array.isArray(r.accepts)?!1:r.accepts.includes(e)}function kf(e,t){if(!t?.containers)return!1;const n=t.containers[e];return!!(n&&Array.isArray(n.accepts)&&n.accepts.length>0)}function MI(e,t,n,o,r){if(!n||n.length===0)return{parentPath:[],index:r};if(e&&kf(e,o))return{parentPath:n,index:t};const s=n.slice(0,-1),a=n[n.length-1]??0;return{parentPath:s,index:a+1}}function Sf(e,t){return e===t||e.startsWith(`${t}.`)}function Cf(e,t){if(e==="")return/^\d+$/.test(t)?Number(t):null;const n=`${e}.children.`;if(!t.startsWith(n))return null;const o=t.slice(n.length);return/^\d+$/.test(o)?Number(o):null}function LI(e,t){const n=[];return e.querySelectorAll("[data-editor-path]").forEach(o=>{if(o.hasAttribute("data-dnd-placeholder")||o.closest("[data-dnd-placeholder]"))return;const r=o.dataset.editorPath;typeof r=="string"&&n.push({path:t(r),domPath:r,rect:o.getBoundingClientRect()})}),n}const PI=16;function OI(e){const{frameEl:t,draggedPath:n,acceptsContainer:o,allowsNestSlot:r,includeContainer:s}=e,a=e.normalizeContainerPath??(g=>g),l=t.getBoundingClientRect(),d=LI(t,a),c=new Map;for(const g of d)c.has(g.path)||c.set(g.path,g.domPath);const p=a(n),f=new Set([""]);for(const g of d){const m=WI(g.path);m!==null&&f.add(m)}for(const g of d)f.add(g.path);const b=[];for(const g of f){const m=g==="",h=m?null:c.get(g)??g,v=m?t:t.querySelector(`[data-editor-path="${If(h)}"]`);if(!v&&!m||!m&&Sf(g,p))continue;const y=g;if(!m&&s&&!s(y))continue;const _=$=>{const S=c.get($);if(!S||typeof window>"u")return!1;const C=t.querySelector(`[data-editor-path="${If(S)}"]`);return C?(window.getComputedStyle(C).display??"").toLowerCase()==="contents":!1},w=d.filter($=>Cf(g,$.path)!==null).filter($=>!Sf($.path,p)).filter($=>!_($.path)).map($=>({origIndex:Cf(g,$.path),rect:BI($.rect,$.path,d)})).filter($=>$.rect.width>0||$.rect.height>0).sort(($,S)=>$.origIndex-S.origIndex),k=Op(m?t:v).kind,x=k==="flex_row_single"||k==="flex_row_wrap"||k==="grid_single_row"||k==="grid_2d";if(w.length>0){if(o(y)){w.forEach(S=>{b.push($f(y,S.origIndex,S.rect,l,x,"before"))});const $=w[w.length-1];b.push($f(y,$.origIndex+1,$.rect,l,x,"after"))}}else if(!m&&r(y)&&v){const $=v.getBoundingClientRect();$.width>0&&$.height>0&&b.push({id:`slot:${y}:0`,kind:"nest",containerPath:y,index:0,box:Ef($,l),orientation:"area"})}else m&&b.push({id:"slot::0",kind:"gap",containerPath:"",index:0,box:Ef(l,l),orientation:"area"})}return b.filter(g=>lo(g.box,t))}function $f(e,t,n,o,r,s){const a=PI;let l;if(r)l={left:(s==="before"?n.left:n.right)-a/2,top:n.top,width:a,height:n.height};else{const d=s==="before"?n.top:n.bottom;l={left:n.left,top:d-a/2,width:n.width,height:a}}return{id:`slot:${e}:${t}`,kind:"gap",containerPath:e,index:t,box:{left:l.left-o.left,top:l.top-o.top,width:l.width,height:l.height,scale:1},orientation:r?"vertical":"horizontal"}}function BI(e,t,n){if(e.width>0||e.height>0)return e;const o=`${t}.children.`;let r=1/0,s=1/0,a=-1/0,l=-1/0;for(const d of n)d.path.startsWith(o)&&(d.rect.width===0&&d.rect.height===0||(r=Math.min(r,d.rect.left),s=Math.min(s,d.rect.top),a=Math.max(a,d.rect.right),l=Math.max(l,d.rect.bottom)));return r===1/0?e:{left:r,top:s,width:a-r,height:l-s,right:a,bottom:l,x:r,y:s,toJSON:()=>({})}}function Ef(e,t){return{left:e.left-t.left,top:e.top-t.top,width:e.width,height:e.height,scale:1}}function WI(e){if(e==="")return null;const t=e.lastIndexOf(".children.");return t<0?"":e.slice(0,t)}function jI(e){if(!e.startsWith("slot:"))return null;const t=e.slice(5),n=t.lastIndexOf(":");if(n<0)return null;const o=t.slice(0,n),r=Number(t.slice(n+1));return Number.isFinite(r)?{containerPath:o,index:r}:null}function If(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[^a-zA-Z0-9_\-.]/g,t=>`\\${t}`)}function ka(e){return typeof e=="string"&&e.length>0?e:null}function Sa(e,t){return t&&e.startsWith(`${t}.`)?t:e}function Af(e){if(typeof e!="string")return null;const t=jI(e);return t?{containerPath:t.containerPath,index:t.index}:null}function Ca(e,t){return t?e.startsWith(`${t}.iteration.`):!1}function $a(e,t,n){return t?n==="iteration_item"?Ca(e,t):e===t||e.startsWith(`${t}.`):!1}function HI(e){const{frameEl:t,nesting:n,editMode:o,currentExtensionId:r,editableRootPath:s,components:a,patchLayout:l,pushHistory:d,onMovePath:c,selectedPath:p,showBranchBoundaryHint:f}=e,b=(o==="iteration_item"||o==="modal")&&s&&s.length>0?at(s):null,[g,m]=u.useState(null),[h,v]=u.useState(null),[y,_]=u.useState(null),w=u.useRef({components:a,nesting:n,editMode:o,currentExtensionId:r,selectedPath:p,editableRootSourcePath:b});w.current={components:a,nesting:n,editMode:o,currentExtensionId:r,selectedPath:p,editableRootSourcePath:b};const k=u.useRef(null),x=u.useCallback(M=>({children:M}),[]),$=u.useCallback((M,O)=>{const z=Be(x(M),O);return z?typeof z.name=="string"?z.name:typeof z.type=="string"?z.type:null:null},[x]),S=u.useCallback(M=>O=>{const z=w.current;if(O==="")return Jo(M,z.nesting);const H=Re(O),P=Be(x(z.components),H);if(!P)return!1;const I=typeof P.name=="string"?P.name:typeof P.type=="string"?P.type:"";if(!I)return!1;const L=!!z.editableRootSourcePath&&(O===z.editableRootSourcePath||O.startsWith(`${z.editableRootSourcePath}.`));if(z.editableRootSourcePath&&!L)return!1;if(!L){const F=Ea(x(z.components),H);if(gn(P,z.editMode,z.currentExtensionId,F)!=="none")return!1}return kf(I,z.nesting)?NI({draggedComponentName:M,targetContainerName:I,nesting:z.nesting}):!1},[x]),C=u.useCallback(M=>{if(M==="")return!0;const O=w.current,z=Re(M),H=k.current;if(H&&H.length>0){const L=H.slice(0,-1);if(ui(z,L))return!0}const P=Be(x(O.components),z);return P?(typeof P.name=="string"?P.name:typeof P.type=="string"?P.type:"").length>0:!1},[x]),T=u.useCallback(M=>{const O=S(M),z=w.current,H=k.current,P=H?H.slice(0,-1):null,I=new Set;if(P)for(let K=P.length;K>=0;K--)I.add(pi(P.slice(0,K)));const L=pi(H??[]),F=K=>!!H&&(K===L||K.startsWith(`${L}.`)),Y=(K,X)=>{for(let Z=0;ZK===""?!0:F(K)?!1:I.has(K),allowsNestSlot:K=>{if(!O(K))return!1;if(P){const X=Re(K);if(ui(X,P))return!1}return C(K)}}},[S,C,x]),E=u.useCallback(M=>{const O=ka(M.active.id),z=w.current;if(!O)return;const H=Sa(O,z.selectedPath),P=Re(H),I=Be(x(z.components),P),L=I&&typeof I.name=="string"?I.name:I&&typeof I.type=="string"?I.type:null;m(H),v(L),_(null),k.current=I?P:null;let F="allowed";if(!L||!Jo(L,z.nesting))F="denied_no_draggable";else if(I){const Y=Ea(x(z.components),P),K=gn(I,z.editMode,z.currentExtensionId,Y);z.editableRootSourcePath&&!$a(H,z.editableRootSourcePath,z.editMode)||Qi(Y)&&!Ca(H,z.editableRootSourcePath)?F="denied_data_bound":K==="base"||K==="partial"?F="denied_base_locked":(K==="extension"||K==="extension_point")&&(F="denied_extension_locked")}$n({source:"drag",draggedComponentName:L,targetContainerName:null,targetContainerPath:null,decision:F,result:F==="allowed"?"completed":"denied",timestamp:Date.now()})},[x]),A=u.useCallback(M=>{if(!t)return;const O=ka(M.active.id);if(!O)return;const z=h;if(!z){_(null);return}const H=w.current,P=Sa(O,H.selectedPath),I=Re(P),L=Be(x(H.components),I);if(!L||!Jo(z,H.nesting)){_(null);return}const F=Ea(x(H.components),I);if(H.editableRootSourcePath&&!$a(P,H.editableRootSourcePath,H.editMode)){_(null);return}const Y=gn(L,H.editMode,H.currentExtensionId,F),K=Ca(P,H.editableRootSourcePath);if(Qi(F)&&!K||Y!=="none"&&Y!=="data_bound"&&!K){_(null);return}_(Af(M.over?.id))},[t,h,x]),N=u.useCallback(()=>{m(null),v(null),_(null),k.current=null},[]),D=u.useCallback(M=>{const O=ka(M.active.id),z=h,H=w.current,P=O?Sa(O,H.selectedPath):null;if(!t||!P||!z){N();return}const I=Af(M.over?.id),L=Re(P);if(!I){$n({source:"drag",draggedComponentName:z,targetContainerName:null,targetContainerPath:null,decision:"denied_no_accepts",result:"cancelled",timestamp:Date.now()}),N();return}const F=I.containerPath===""?[]:Re(I.containerPath),Y=I.containerPath===""?null:$(H.components,F);if(!FI(L.slice(0,-1),F)){$n({source:"drag",draggedComponentName:z,targetContainerName:Y,targetContainerPath:I.containerPath||null,decision:"denied_responsive_branch_boundary",result:"denied",timestamp:Date.now()}),f?.(),N();return}if(H.editableRootSourcePath&&!$a(I.containerPath,H.editableRootSourcePath,H.editMode)){$n({source:"drag",draggedComponentName:z,targetContainerName:Y,targetContainerPath:I.containerPath||null,decision:"denied_data_bound",result:"denied",timestamp:Date.now()}),N();return}const K=L.slice(0,-1),X=L[L.length-1]??-1;if(ui(K,F)&&(I.index===X||I.index===X+1)){$n({source:"drag",draggedComponentName:z,targetContainerName:Y,targetContainerPath:I.containerPath||null,decision:"allowed",insertionIndex:I.index,result:"cancelled",timestamp:Date.now()}),N();return}const oe=ui(K,F),G=I.index;let ee=[];l(be=>{const Se=Bb({children:be},L,F,G).children??[];return ee=Se,Se}),d(ee,`move ${z}`);const ge=dd(F,L),V=oe&&X{N()},[N]);return{activeDragPath:g,activeDragName:h,activeDropZone:y,onDragStart:E,onDragMove:A,onDragEnd:D,onDragCancel:B,buildSlotPredicates:T}}function Ea(e,t){const n=[];let o=e,r=Array.isArray(e.children)?e.children:[];for(let s=0;s0?at(s):null,{t:m}=tt(),[h,v]=u.useState(!1),y=u.useRef(null),_=u.useCallback(()=>{v(!0),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>v(!1),2600)},[]);u.useEffect(()=>()=>{y.current&&clearTimeout(y.current)},[]);const w=HI({frameEl:t,nesting:n,editMode:o,currentExtensionId:r,editableRootPath:s,components:a,patchLayout:l,pushHistory:d,onMovePath:p,selectedPath:b,showBranchBoundaryHint:_}),k=p2(u2(ma,{activationConstraint:{distance:8}})),[x,$]=u.useState([]),S=u.useCallback(()=>{if(!t){$([]);return}if(w.activeDragPath!==null)return;const P={children:a},I=t.querySelectorAll("[data-editor-path]"),L=[],F=new Map;I.forEach(Y=>{const K=Y.dataset.editorPath;if(typeof K!="string"||o!=="iteration_item"&&g&&!UI(K,g,o))return;const X=KI(K);if(X!==null&&!Zo(K,g)){if(/\.iteration\.\d+$/.test(K)){const V=ao(Y,t);if(V&&lo(V,t)){const te=F.get(X)??[];te.push(V),F.set(X,te)}}return}if(Zo(K,g)&&/\.iteration\.\d+$/.test(K))return;const Z=Re(K),ae=Be(P,Z);if(!ae||ae.iteration&&ae.iteration.source!==void 0)return;const oe=typeof ae.name=="string"?ae.name:typeof ae.type=="string"?ae.type:null;if(!oe||!Jo(oe,n))return;const G=Df(P,Z);if(Qi(G)&&!Zo(K,g))return;const ee=gn(ae,o,r,G);if(ee!=="none"&&ee!=="data_bound"&&!Zo(K,g))return;const ge=ao(Y,t);ge&&lo(ge,t)&&L.push({path:K,name:oe,box:ge})});for(const[Y,K]of F){const X=Re(Y),Z=Be(P,X);if(!Z)continue;const ae=typeof Z.name=="string"?Z.name:typeof Z.type=="string"?Z.type:null;if(!ae)continue;const oe=Df(P,X),G=gn(Z,o,r,oe);if(G!=="none"&&G!=="data_bound")continue;const ee=qI(K);ee&&lo(ee,t)&&L.push({path:Y,name:ae,box:ee,isIterationGroup:!0})}$(L)},[t,a,n,o,r,g,w.activeDragPath]);u.useEffect(()=>{S()},[S]),u.useEffect(()=>{if(t)return zp(S,t)},[t,S]);const C=w.activeDragPath!==null,T=w.activeDragName,E=w.activeDragPath,[A,N]=u.useState(null),D=u.useRef(null);u.useEffect(()=>{if(!E||!t){E||(D.current=null,N(null));return}if(D.current===E)return;D.current=E;const P=t.querySelector(`[data-editor-path="${Tf(E)}"]`);if(P){const oe=P.getBoundingClientRect();N({node:P.cloneNode(!0),width:oe.width,height:oe.height});return}const I=Array.from(t.querySelectorAll(`[data-editor-path^="${Tf(E)}.iteration."]`)).filter(oe=>/\.iteration\.\d+$/.test(oe.dataset.editorPath??""));if(I.length===0){N(null);return}let L=1/0,F=1/0,Y=-1/0,K=-1/0;for(const oe of I){const G=oe.getBoundingClientRect();L=Math.min(L,G.left),F=Math.min(F,G.top),Y=Math.max(Y,G.right),K=Math.max(K,G.bottom)}const X=Y-L,Z=K-F,ae=document.createElement("div");ae.style.position="relative",ae.style.width=`${X}px`,ae.style.height=`${Z}px`;for(const oe of I){const G=oe.getBoundingClientRect(),ee=oe.cloneNode(!0);ee.style.position="absolute",ee.style.left=`${G.left-L}px`,ee.style.top=`${G.top-F}px`,ee.style.width=`${G.width}px`,ee.style.height=`${G.height}px`,ee.style.margin="0",ae.appendChild(ee)}N({node:ae,width:X,height:Z})},[E,t]);const[B,M]=u.useState([]),O=u.useRef(null),z=u.useRef(w.buildSlotPredicates);if(z.current=w.buildSlotPredicates,u.useEffect(()=>{if(!E||!T||!t){O.current=null,M(F=>F.length===0?F:[]);return}if(O.current===E)return;O.current=E;const{acceptsContainer:P,allowsNestSlot:I,includeContainer:L}=z.current(T);M(OI({frameEl:t,draggedPath:E,acceptsContainer:P,allowsNestSlot:I,includeContainer:L,normalizeContainerPath:F=>VI(F)}))},[E,T,t]),!t)return null;const H=w.activeDropZone?`slot:${w.activeDropZone.containerPath}:${w.activeDropZone.index}`:null;return i.jsxs(gI,{sensors:k,collisionDetection:w2,onDragStart:w.onDragStart,onDragMove:w.onDragMove,onDragEnd:w.onDragEnd,onDragCancel:w.onDragCancel,children:[x.map(P=>i.jsx(JI,{path:P.path,name:P.name,box:P.box,dimmed:C&&w.activeDragPath!==P.path,isIterationGroup:P.isIterationGroup,onSelect:c,onRequestInlineEdit:f},P.path)),C&&B.map(P=>i.jsx(XI,{slot:P,active:P.id===H},P.id)),Cn.createPortal(i.jsx(zI,{dropAnimation:null,zIndex:Fp,children:T?A?i.jsx(YI,{name:T,node:A.node,width:A.width,height:A.height}):i.jsx("div",{className:"g7le-dnd-drag-ghost","data-testid":"g7le-dnd-drag-ghost",style:{padding:"4px 10px",background:"rgba(79,70,229,0.95)",color:"#fff",fontSize:12,fontWeight:600,borderRadius:4,pointerEvents:"none",whiteSpace:"nowrap"},children:`<${T}>`}):null}),document.body),h&&Cn.createPortal(i.jsxs("div",{"data-testid":"g7le-branch-boundary-hint",role:"status",style:{position:"absolute",left:"50%",top:12,transform:"translateX(-50%)",background:"rgba(245,158,11,0.97)",color:"#fff",fontSize:13,fontWeight:600,padding:"8px 16px",borderRadius:8,boxShadow:"0 4px 14px rgba(0,0,0,0.2)",pointerEvents:"none",whiteSpace:"nowrap",zIndex:Fp},children:["⚠️ ",m("layout_editor.overlay.branch_boundary_denied")]}),t)]})}function YI(e){const{node:t,width:n,height:o}=e,r=u.useRef(null);return u.useEffect(()=>{const s=r.current;if(s)return s.replaceChildren(),s.appendChild(t.cloneNode(!0)),()=>{s.replaceChildren()}},[t]),i.jsx("div",{ref:r,className:"g7le-dnd-drag-ghost","data-testid":"g7le-dnd-drag-ghost",style:{width:n,height:o,opacity:.7,pointerEvents:"none",boxShadow:"0 6px 18px rgba(0,0,0,0.25)",borderRadius:4,overflow:"hidden",cursor:"grabbing"}})}function XI(e){const{slot:t,active:n}=e,{setNodeRef:o}=xI({id:t.id}),r=t.orientation!=="area";return i.jsx("div",{ref:o,"data-testid":`g7le-dnd-slot-${t.id}`,"data-dnd-slot-id":t.id,style:{position:"absolute",left:t.box.left,top:t.box.top,width:t.box.width,height:t.box.height,pointerEvents:"auto",zIndex:H7,boxSizing:"border-box",...r?{background:n?"rgba(79,70,229,0.15)":"transparent",...n?t.orientation==="vertical"?{borderLeft:"2px solid #4f46e5"}:{borderTop:"2px solid #4f46e5"}:{}}:{border:n?"2px dashed #4f46e5":"1px dashed transparent",background:n?"rgba(79,70,229,0.08)":"transparent",borderRadius:4}}})}function Tf(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[^a-zA-Z0-9_\-.]/g,t=>`\\${t}`)}function JI(e){const{path:t,box:n,dimmed:o,isIterationGroup:r,onSelect:s,onRequestInlineEdit:a}=e,{attributes:l,listeners:d,setNodeRef:c,isDragging:p}=bI({id:t}),f=(t.match(/\.children\./g)||[]).length,b=F7(f);return i.jsx("div",{ref:c,"data-testid":`g7le-dnd-handle-${t}`,"data-dnd-handle-path":t,"data-dnd-iteration-group":r?"true":void 0,...d,...l,onClick:g=>{if(g.stopPropagation(),!r&&typeof document<"u"&&typeof document.elementsFromPoint=="function"){const m=document.elementsFromPoint(g.clientX,g.clientY);for(const h of m){const y=h.closest?.("[data-editor-path]")?.dataset?.editorPath;if(typeof y=="string"&&(y===t||y.startsWith(`${t}.`))){s(y);return}}}s(t)},onDoubleClick:g=>{g.stopPropagation(),g.preventDefault(),a?.(t)},style:{position:"absolute",left:n.left,top:n.top,width:n.width,height:n.height,cursor:"grab",pointerEvents:"auto",background:p?"rgba(79,70,229,0.06)":"transparent",...r?{border:"1px dashed rgba(79,70,229,0.5)",borderRadius:4}:{},opacity:o?.6:1,zIndex:b,touchAction:"none"}})}function Df(e,t){const n=[];let o=e,r=Array.isArray(e.children)?e.children:[];for(let s=0;s0?[o]:[];const r=[],s=(a,l)=>{a.forEach((d,c)=>{const p=[...l,c];if(!Ri(d,t,n)){r.push(p);return}const b=Array.isArray(d.children)?d.children:[];b.length>0&&s(b,p)})};return s(e,[]),r}function QI(e){return at(e)}function fi(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["\\]/g,"\\$&")}function RI({frameEl:e,components:t,editMode:n,currentExtensionId:o,editableRootPath:r}){const[s,a]=u.useState(null),[l]=u.useState(()=>`g7le-dim-mask-${Math.floor(Math.random()*1e9)}`);if(u.useEffect(()=>{if(!e){a(null);return}let g=0;const m=()=>{const _=ZI(t,n,o,r);if(_.length===0){a(null);return}const w=e.getBoundingClientRect(),k={left:0,top:0,width:w.width,height:w.height},x=[];for(const $ of _){const S=QI($),C=e.querySelector(`[data-editor-path="${fi(S)}"]`);let T=null;if(C){const E=C.getBoundingClientRect();E.width>0&&E.height>0&&(T={left:E.left,top:E.top,width:E.width,height:E.height})}if(!T){const E=Array.from(e.querySelectorAll(`[data-editor-path^="${fi(S)}.iteration."], [data-editor-path^="${fi(S)}.sortable."], [data-editor-path^="${fi(S)}.children."]`));let A=1/0,N=1/0,D=-1/0,B=-1/0;for(const M of E){const O=M.getBoundingClientRect();O.width<=0||O.height<=0||(A=Math.min(A,O.left),N=Math.min(N,O.top),D=Math.max(D,O.right),B=Math.max(B,O.bottom))}if(D>A&&B>N&&(T={left:A,top:N,width:D-A,height:B-N}),T&&E.length>0){const M=E[0].closest('[role="dialog"]');if(M&&e.contains(M)){const O=M.getBoundingClientRect();O.width>0&&O.height>0&&(T={left:O.left,top:O.top,width:O.width,height:O.height})}}}T&&x.push({left:T.left-w.left,top:T.top-w.top,width:T.width,height:T.height})}if(x.length===0){a(null);return}a({frame:k,holes:x})},h=()=>{g&&cancelAnimationFrame(g),g=requestAnimationFrame(m)};h();const v=typeof ResizeObserver<"u"?new ResizeObserver(h):null;v?.observe(e);const y=typeof MutationObserver<"u"?new MutationObserver(h):null;return y?.observe(e,{childList:!0,subtree:!0,attributes:!0}),window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{g&&cancelAnimationFrame(g),v?.disconnect(),y?.disconnect(),window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[e,t,n,o,r?.join(".")??""]),!s||s.holes.length===0)return null;const{frame:d,holes:c}=s,p=n==="modal"||n==="iteration_item";let f=[];if(p){let g=1/0,m=1/0,h=-1/0,v=-1/0;for(const $ of c)g=Math.min(g,$.left),m=Math.min(m,$.top),h=Math.max(h,$.left+$.width),v=Math.max(v,$.top+$.height);const y=($,S,C)=>Math.max(S,Math.min(C,$)),_=y(g,0,d.width),w=y(m,0,d.height),k=y(h,0,d.width),x=y(v,0,d.height);f=[{left:0,top:0,width:d.width,height:w},{left:0,top:x,width:d.width,height:d.height-x},{left:0,top:w,width:_,height:x-w},{left:k,top:w,width:d.width-k,height:x-w}].filter($=>$.width>0&&$.height>0)}const b=g=>{g.preventDefault(),g.stopPropagation()};return i.jsxs(i.Fragment,{children:[f.map((g,m)=>i.jsx("div",{className:"g7le-source-lock-block","data-testid":"g7le-source-lock-block",onClickCapture:b,onPointerDownCapture:b,onMouseDownCapture:b,onDragStartCapture:b,style:{position:"absolute",left:g.left,top:g.top,width:g.width,height:g.height,zIndex:Hp,pointerEvents:"auto",cursor:"not-allowed",background:"transparent"}},m)),i.jsxs("svg",{className:"g7le-source-lock-dim","data-testid":"g7le-source-lock-dim",width:d.width,height:d.height,style:{position:"absolute",left:0,top:0,width:d.width,height:d.height,zIndex:Hp,pointerEvents:"none"},children:[i.jsx("defs",{children:i.jsxs("mask",{id:l,children:[i.jsx("rect",{x:0,y:0,width:d.width,height:d.height,fill:"white"}),c.map((g,m)=>i.jsx("rect",{"data-testid":"g7le-source-lock-dim-hole",x:g.left,y:g.top,width:g.width,height:g.height,rx:4,fill:"black"},m))]})}),i.jsx("rect",{"data-testid":"g7le-source-lock-dim-box",x:0,y:0,width:d.width,height:d.height,fill:"rgba(15, 23, 42, 0.45)",mask:`url(#${l})`})]})]})}function zf(e){const t={type:e.type??"basic",name:e.name},n={};if(e.props)for(const[o,r]of Object.entries(e.props))o!=="children"&&r?.default!==void 0&&(n[o]=r.default);return Object.keys(n).length>0&&(t.props=n),t}function eA(e){if(!e?.components)return[];const t=[];for(const[n,o]of Object.entries(e.components))if(Array.isArray(o))for(const r of o)t.push({...r,type:r.type??n});return t}function tA(e,t,n,o,r){const s=eA(e);let a=null;if(n&&t?.containers){const l=t.containers[n];l&&Array.isArray(l.accepts)?a=new Set(l.accepts):a=new Set}else!n&&t?.draggable&&(a=new Set(t.draggable));return s.filter(l=>{if(a&&!a.has(l.name))return!1;if(o){const d=o.toLowerCase(),c=r(l).toLowerCase(),p=l.name.toLowerCase();if(!c.includes(d)&&!p.includes(d)&&!`<${p}>`.includes(d)&&!(l.description??"").toLowerCase().includes(d))return!1}return!0})}function nA(e,t){const n={key:"all",label:"layout_editor.palette.category.all",entries:e,isI18nKey:!0};if(t?.groups&&t.groups.length>0){const a=new Map(e.map(p=>[p.name,p])),l=new Set,d=[];for(const p of t.groups){const f=[];for(const b of p.components??[]){const g=a.get(b);g&&(f.push(g),l.add(b))}f.length!==0&&d.push({key:p.kind??p.label,label:p.label,entries:f,isI18nKey:p.label.startsWith("$t:")||/^[a-z_.]+$/i.test(p.label)})}const c=e.filter(p=>!l.has(p.name));return c.length>0&&d.push({key:"other",label:"layout_editor.palette.category.other",entries:c,isI18nKey:!0}),[n,...d]}const o=new Map;for(const a of e){const l=(a.type??"basic").toLowerCase(),d=o.get(l)??[];d.push(a),o.set(l,d)}const r=["basic","composite","layout"],s=[];for(const a of r){const l=o.get(a);l&&l.length>0&&(s.push({key:a,label:`layout_editor.palette.category.fallback.${a}`,entries:l,isI18nKey:!0}),o.delete(a))}for(const[a,l]of o.entries())s.push({key:a,label:a,entries:l,isI18nKey:!1});return[n,...s]}function Nf(e){const{manifest:t,nesting:n,componentPalette:o,targetParentPath:r,targetContainerName:s,onInsert:a,insertionIndex:l,onClose:d,editorTemplateId:c,editorLocale:p}=e,{t:f,translationEngine:b}=tt(),g=u.useMemo(()=>{if(!c||!b)return f;const A=p??null;return N=>{const D={templateId:c,locale:A??"ko"},B=b.translate(N,D);return B!==N?B:f(N)}},[c,p,b,f]),[m,h]=u.useState(""),[v,y]=u.useState("all"),_=o?.entries??null,w=u.useMemo(()=>A=>{const N=_?.[A.name];return N?.label?gi(N.label,g):A.description??A.name},[_,g]),k=u.useMemo(()=>tA(t,n,s,m,w),[t,n,s,m,w]),x=u.useMemo(()=>nA(k,o??null),[k,o]),$=x.find(A=>A.key===v)??x[0]??null,S=!n||!n.draggable&&!n.containers,C=k.length===0,T=$?.entries??[],E=A=>{const N=_?.[A.name],D=!!N?.defaultNode&&typeof N.defaultNode=="object";if(N?.requiresDefaultNode&&!D)return;const B=D?JSON.parse(JSON.stringify(N.defaultNode)):zf(A),M=r??[];a(B,M,l),$n({source:"palette",draggedComponentName:A.name,targetContainerName:s,targetContainerPath:M.length===0?null:M.join("/"),decision:"allowed",insertionIndex:l,result:"completed",timestamp:Date.now()}),d()};return i.jsxs("div",{className:"g7le-palette","data-testid":"g7le-palette",style:sA,children:[i.jsxs("div",{style:aA,children:[i.jsx("strong",{style:{fontSize:16},children:f("layout_editor.palette.title")}),i.jsx("button",{type:"button",onClick:d,"aria-label":"close","data-testid":"g7le-palette-close",style:lA,children:"×"})]}),i.jsxs("div",{style:dA,children:[i.jsx("aside",{style:cA,"data-testid":"g7le-palette-sidebar",children:i.jsx("nav",{children:i.jsx("ul",{style:uA,children:x.map(A=>{const N=$?.key===A.key,D=A.isI18nKey?gi(A.label,g):A.label;return i.jsx("li",{children:i.jsxs("button",{type:"button","data-testid":`g7le-palette-category-${A.key}`,"data-active":N?"true":"false",onClick:()=>y(A.key),style:{...pA,background:N?"#eff6ff":"transparent",color:N?"#1d4ed8":"#334155",fontWeight:N?600:500},children:[i.jsx("span",{children:D}),i.jsx("span",{style:yA,children:A.entries.length})]})},A.key)})})})}),i.jsxs("main",{style:fA,children:[i.jsx("input",{type:"text",placeholder:f("layout_editor.palette.search_placeholder"),value:m,onChange:A=>h(A.target.value),"data-testid":"g7le-palette-search",style:gA}),i.jsx("div",{style:hA,children:S?i.jsx("div",{style:Mf,"data-testid":"g7le-palette-spec-missing",children:f("layout_editor.palette.spec_missing")}):C||T.length===0?i.jsx("div",{style:Mf,"data-testid":"g7le-palette-empty",children:f("layout_editor.palette.empty")}):i.jsx("div",{"data-testid":`g7le-palette-group-${$?.key??"all"}`,style:{marginBottom:16},children:i.jsx("div",{style:bA,children:T.map(A=>i.jsx(oA,{entry:A,entrySpec:_?.[A.name]??null,onClick:E,t:f,entryT:g},A.name))})})})]})]})]})}function oA(e){const{entry:t,entrySpec:n,onClick:o,t:r,entryT:s}=e,a=n?.label?gi(n.label,s):t.description??t.name,l=(t.type??"").toLowerCase(),d=l==="basic"||l==="composite"||l==="layout",c=!!n?.defaultNode&&typeof n.defaultNode=="object",p=!!n?.requiresDefaultNode&&!c,f=!c,b=p?r("layout_editor.palette.requires_default_node_missing"):n?.label?gi(n.label,s):t.name;return i.jsxs("button",{type:"button",onClick:()=>o(t),disabled:p,"aria-disabled":p||void 0,"data-testid":`g7le-palette-item-${t.name}`,"data-component-type":l||void 0,"data-blocked":p?"true":void 0,"data-default-node-missing":f?"true":void 0,title:b,style:p?vA:mA,children:[i.jsx("div",{style:xA,"aria-hidden":"true",children:iA(t)}),i.jsx("div",{style:wA,children:a}),i.jsx("div",{"data-testid":`g7le-palette-item-${t.name}-tag`,style:kA,children:`<${t.name}>`}),d&&i.jsx("div",{"data-testid":`g7le-palette-item-${t.name}-badge`,style:rA(l),children:l}),f&&i.jsx("div",{"data-testid":`g7le-palette-item-${t.name}-default-missing-badge`,style:_A,children:r("layout_editor.palette.default_node_missing_badge")})]})}function gi(e,t){return e.startsWith("$t:")?t(e.slice(3)):t(e)}function rA(e){const n={basic:{bg:"#dbeafe",fg:"#1e40af"},composite:{bg:"#dcfce7",fg:"#14532d"},layout:{bg:"#fef3c7",fg:"#854d0e"}}[e]??{bg:"#e2e8f0",fg:"#334155"};return{fontSize:9,fontWeight:600,color:n.fg,background:n.bg,padding:"1px 6px",borderRadius:999,textTransform:"uppercase",letterSpacing:.4,lineHeight:1.6}}function iA(e){const t=e.name;return{Button:"🔘",A:"🔗",Img:"🖼",Icon:"✨",Hr:"➖",P:"📄",Span:"T",H1:"H₁",H2:"H₂",H3:"H₃",H4:"H₄",Ul:"☰",Li:"•",Nav:"🧭",Div:"▢",Container:"▢",Flex:"⇆",Grid:"▦",SectionLayout:"▤",ThreeColumnLayout:"⫼",Form:"📝",Input:"⎕",Textarea:"▭",Select:"⏷",Checkbox:"☑",PasswordInput:"🔒",Label:"🏷",DataGrid:"▦",Pagination:"↔",SearchBar:"🔍",ProductCard:"🛍",ImageGallery:"🖼",Avatar:"👤",UserInfo:"👥",HtmlContent:"⟨/⟩",HtmlEditor:"✏",RichTextEditor:"✏",TabNavigation:"◰",QuantitySelector:"#",ProductImageViewer:"🖼",FileUploader:"📎",AvatarUploader:"📷",SocialLoginButtons:"🌐",PostReactions:"❤"}[t]??"◻"}const sA={display:"flex",flexDirection:"column",width:"100%",height:"100%",minHeight:0,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif'},aA={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"14px 20px",borderBottom:"1px solid #e2e8f0",flexShrink:0},lA={background:"transparent",border:"none",fontSize:24,cursor:"pointer",lineHeight:1,color:"#64748b",padding:"0 4px"},dA={display:"flex",flex:1,minHeight:0},cA={width:180,flexShrink:0,borderRight:"1px solid #e2e8f0",padding:"14px 8px",background:"#f8fafc",overflowY:"auto"},uA={listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:4},pA={display:"flex",width:"100%",alignItems:"center",justifyContent:"space-between",textAlign:"left",padding:"8px 12px",border:"none",borderRadius:6,fontSize:13,cursor:"pointer",transition:"background-color 120ms"},fA={flex:1,display:"flex",flexDirection:"column",minHeight:0,padding:"14px 20px"},gA={width:"100%",padding:"8px 10px",border:"1px solid #cbd5e1",borderRadius:6,marginBottom:12,fontSize:13,flexShrink:0,boxSizing:"border-box"},hA={flex:1,overflowY:"auto",minHeight:0},yA={fontSize:11,color:"#94a3b8",marginLeft:8,fontWeight:500},bA={display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(96px, 1fr))",gap:10},mA={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:6,padding:"14px 6px",background:"#fff",border:"1px solid #e2e8f0",borderRadius:8,cursor:"pointer",fontSize:12,minHeight:84,transition:"border-color 120ms, box-shadow 120ms"},vA={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:6,padding:"14px 6px",background:"#f8fafc",border:"1px dashed #cbd5e1",borderRadius:8,cursor:"not-allowed",fontSize:12,minHeight:84,color:"#94a3b8",opacity:.65},_A={fontSize:9,fontWeight:600,color:"#92400e",background:"#fef3c7",padding:"1px 6px",borderRadius:999,textTransform:"none",letterSpacing:0,lineHeight:1.6},xA={fontSize:22,lineHeight:1,color:"#475569"},wA={fontSize:12,fontWeight:500,color:"#0f172a",textAlign:"center",wordBreak:"break-word"},kA={fontFamily:'ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace',fontSize:10,color:"#64748b",textAlign:"center",wordBreak:"break-all"},Mf={padding:24,color:"#64748b",fontSize:13,textAlign:"center"};function SA(e){const t=[],n=r=>{if(Array.isArray(r))for(const s of r)s&&typeof s=="object"&&t.push(s)};n(e.children);const o=e.responsive;if(o&&typeof o=="object")for(const r of Object.values(o))r&&typeof r=="object"&&n(r.children);return t}function Lf(e){const t=[],n=o=>{const r="isolatedState"in o&&o.isolatedState!=null,s=o.isolatedScopeId;(r||typeof s=="string"&&s.length>0)&&t.push({scopeId:typeof s=="string"?s:void 0,initialState:o.isolatedState&&typeof o.isolatedState=="object"?o.isolatedState:void 0});for(const a of SA(o))n(a)};if(Array.isArray(e))for(const o of e)o&&typeof o=="object"&&n(o);return t}const CA=["scroll","selector","wizard","slider"];function $A(e,t){const n=new Set;for(const o of e)o.scopeId&&n.add(o.scopeId);for(const o of t){n.add(o);for(const r of CA)n.add(`${o}-${r}`)}return Array.from(n)}function EA(e,t,n){const o=t.label;return typeof o=="string"?o.startsWith("$t:")?n(o.slice(3)):o:e}function hi({controlKey:e,control:t,node:n,t:o,onPatch:r,candidates:s,bindingCandidates:a,scope:l=Wt}){const d=Tn(t.widget),c=EA(e,t,o),p=u.useMemo(()=>zo(n,t,l),[n,t,l]),f=t.widget==="i18n-text"&&t.apply?.type==="propValue",b=t.widget==="text"&&t.apply?.type==="propValue",g=p.darkReadonly===!0||l.colorScheme==="dark"&&t.apply!==void 0&&!Ys(t.apply),m=t.apply,h=l.colorScheme==="dark"&&!g&&m?.type==="classToken"&&typeof m.tokenTemplate=="string"&&m.tokenTemplate.includes("{value}"),v=p.scopedValue===void 0&&p.baseFallback!==void 0,y=u.useCallback(_=>{if(g)return;const w=fn(n,t,_,l);r(w)},[n,t,r,l,g]);return i.jsxs("div",{className:"g7le-control-row","data-testid":`g7le-control-${e}`,style:IA,children:[i.jsxs("span",{className:"g7le-control-label",style:AA,children:[c,p.conflict&&i.jsx("span",{"data-testid":`g7le-control-conflict-${e}`,title:o("layout_editor.property_modal.value_conflict"),style:TA,children:"!"})]}),i.jsx("div",{className:"g7le-control-widget",style:{flex:1,minWidth:0,opacity:v?.45:1},"data-placeholder":v?"true":void 0,children:f?i.jsx(_t,{value:typeof p.value=="string"?p.value:"",onChange:_=>y(_),t:o,testidPrefix:`g7le-prop-i18n-${e}`,candidates:a,enableExpressionTree:!0,expressionTreeCollapsible:!0}):b?i.jsx(Ke,{value:typeof p.value=="string"?p.value:"",onChange:_=>y(_===""?void 0:_),t:o,testidPrefix:`g7le-prop-value-${e}`,candidates:a}):g?i.jsx("span",{"data-testid":`g7le-control-dark-readonly-${e}`,style:zA,children:o("layout_editor.property_modal.dark_code_only")}):d?i.jsx(d,{control:t,value:p.value,onChange:y,t:o,candidates:s,bindingCandidates:a,freeValueDisabled:h}):i.jsx("span",{"data-testid":`g7le-control-unsupported-${e}`,style:DA,children:o("layout_editor.property_modal.unsupported_widget")})})]})}const IA={display:"flex",alignItems:"center",gap:12,padding:"6px 0",minHeight:32,minWidth:0},AA={fontSize:12,color:"#475569",minWidth:88,display:"inline-flex",alignItems:"center",gap:4},TA={display:"inline-flex",width:14,height:14,borderRadius:7,background:"#f59e0b",color:"#fff",fontSize:10,alignItems:"center",justifyContent:"center",fontWeight:700},DA={fontSize:11,color:"#94a3b8",fontStyle:"italic"},zA={fontSize:11,color:"#94a3b8",fontStyle:"italic"};function yi(e,t,n){return typeof e=="string"?e.startsWith("$t:")?n(e.slice(3)):e:t}function NA(e,t){const n=e.props??{};return t.key in n?n[t.key]:t.default}function MA({spec:e,node:t,t:n,onPatchProp:o}){const r=e.groups??[];return i.jsx("div",{className:"g7le-composite-settings","data-testid":"g7le-composite-settings",style:PA,children:r.map((s,a)=>i.jsxs("div",{className:"g7le-settings-group",style:OA,children:[i.jsx("div",{style:BA,children:yi(s.label,n("layout_editor.property_modal.settings_group",{index:a+1}),n)}),(s.fields??[]).map(l=>i.jsxs("div",{className:"g7le-settings-field","data-testid":`g7le-setting-${l.key}`,style:WA,children:[i.jsx("span",{style:jA,children:yi(l.label,l.key,n)}),i.jsx("div",{style:{flex:1},children:LA(l,t,n,o)})]},l.key))]},a))})}function LA(e,t,n,o){const r=NA(t,e);switch(e.type){case"number":return i.jsx("input",{type:"number","data-testid":`g7le-setting-input-${e.key}`,value:typeof r=="number"?r:"",min:e.min,max:e.max,onChange:s=>o(e.key,s.target.value===""?void 0:Number(s.target.value)),style:Ia});case"text":return i.jsx("input",{type:"text","data-testid":`g7le-setting-input-${e.key}`,value:typeof r=="string"?r:"",onChange:s=>o(e.key,s.target.value===""?void 0:s.target.value),style:Ia});case"toggle":return i.jsx("input",{type:"checkbox","data-testid":`g7le-setting-input-${e.key}`,checked:r===!0,onChange:s=>o(e.key,s.target.checked)});case"checkbox-group":{const s=Array.isArray(r)?r:[];return i.jsx("div",{style:HA,"data-testid":`g7le-setting-input-${e.key}`,children:(e.options??[]).map(a=>{const l=s.includes(a.value);return i.jsxs("label",{style:FA,children:[i.jsx("input",{type:"checkbox",checked:l,onChange:d=>{const c=d.target.checked?[...s,a.value]:s.filter(p=>p!==a.value);o(e.key,c)}}),yi(a.label,String(a.value),n)]},String(a.value))})})}case"select":case"board-select":case"datasource-select":default:return i.jsxs("select",{"data-testid":`g7le-setting-input-${e.key}`,value:r==null?"":String(r),onChange:s=>{const a=s.target.value;if(a===""){o(e.key,void 0);return}const l=(e.options??[]).find(d=>String(d.value)===a);o(e.key,l?l.value:a)},style:Ia,children:[i.jsx("option",{value:"",children:"—"}),(e.options??[]).map(s=>i.jsx("option",{value:String(s.value),children:yi(s.label,String(s.value),n)},String(s.value)))]})}}const PA={display:"flex",flexDirection:"column",gap:16},OA={display:"flex",flexDirection:"column",gap:6},BA={fontSize:12,fontWeight:700,color:"#0f172a",borderBottom:"1px solid #e2e8f0",paddingBottom:4},WA={display:"flex",alignItems:"center",gap:12,minHeight:30},jA={fontSize:12,color:"#475569",minWidth:96},Ia={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,width:"100%",boxSizing:"border-box"},HA={display:"flex",flexWrap:"wrap",gap:10},FA={display:"inline-flex",alignItems:"center",gap:4,fontSize:12,color:"#0f172a"},KA=["data_binding","isolatedScopeId","parentFormContextProp","skipBindingKeys","isolatedState","component_layout","sortable","itemTemplate"],VA=/\{\{|\$switch|\$get|\|\s*(date|number|truncate|currency|relative)\b/;function bi(e,t=0){return t>6?!1:typeof e=="string"?VA.test(e):Array.isArray(e)?e.some(n=>bi(n,t+1)):e&&typeof e=="object"?Object.values(e).some(n=>bi(n,t+1)):!1}function UA(e){if(td(e))return!1;const t=ql(e);return t.length===0?!1:t.some(n=>n.isComplex)}function Pf(e){const t=[],n=e.props??{};for(const o of KA)o in e&&e[o]!==void 0?t.push({key:o,kind:"developer_prop"}):o in n&&n[o]!==void 0&&t.push({key:`props.${o}`,kind:"developer_prop"});typeof e.text=="string"?UA(e.text)&&t.push({key:"text",kind:"complex_expression"}):bi(e.text)&&t.push({key:"text",kind:"complex_expression"});for(const[o,r]of Object.entries(n))o==="style"||o==="className"||bi(r)&&t.push({key:`props.${o}`,kind:"complex_expression"});return t}function qA(e){return Pf(e).length>0}const GA=new Set(["permissions","blur_until_loaded","comment"]);function YA({node:e,advanced:t,t:n,onPatch:o,permissionCandidates:r}){const s=u.useMemo(()=>Pf(e),[e]),a=(l,d)=>{const c={...e};d===void 0?delete c[l]:c[l]=d,o(c)};return i.jsxs("div",{className:"g7le-advanced-props","data-testid":"g7le-advanced-props",style:XA,children:[t.map(l=>{if(!GA.has(l))return i.jsxs("div",{"data-testid":`g7le-advanced-deferred-${l}`,style:ZA,children:[n("layout_editor.property_modal.advanced_deferred"),":",l]},l);if(l==="permissions")return i.jsxs("div",{className:"g7le-advanced-group","data-testid":"g7le-advanced-permissions",style:Aa,children:[i.jsx("div",{style:Ta,children:n("layout_editor.property_modal.advanced.permissions")}),i.jsx(vs,{control:{widget:"tag-input"},value:e.permissions,onChange:d=>a("permissions",d),t:n,candidates:r})]},l);if(l==="blur_until_loaded"){const d=e.blur_until_loaded===!0||e.blur_until_loaded!=null&&e.blur_until_loaded!==!1;return i.jsxs("div",{className:"g7le-advanced-group","data-testid":"g7le-advanced-blur",style:Aa,children:[i.jsx("div",{style:Ta,children:n("layout_editor.property_modal.advanced.blur_until_loaded")}),i.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:12},children:[i.jsx("input",{type:"checkbox","data-testid":"g7le-advanced-blur-toggle",checked:!!d,onChange:c=>a("blur_until_loaded",c.target.checked?!0:void 0)}),n("layout_editor.property_modal.advanced.blur_hint")]})]},l)}return i.jsxs("div",{className:"g7le-advanced-group","data-testid":"g7le-advanced-comment",style:Aa,children:[i.jsx("div",{style:Ta,children:n("layout_editor.property_modal.advanced.comment")}),i.jsx("input",{type:"text","data-testid":"g7le-advanced-comment-input",value:typeof e.comment=="string"?e.comment:"",onChange:d=>a("comment",d.target.value===""?void 0:d.target.value),style:JA})]},l)}),s.length>0&&i.jsxs("div",{className:"g7le-advanced-preserved","data-testid":"g7le-advanced-preserved",style:QA,children:[i.jsx("div",{style:RA,children:n("layout_editor.property_modal.advanced_preserved_title",{count:s.length})}),i.jsx("ul",{style:e6,children:s.map(l=>i.jsxs("li",{"data-testid":`g7le-advanced-preserved-${l.key}`,style:t6,children:[i.jsx("code",{style:{fontSize:11},children:l.key}),i.jsx("span",{style:{fontSize:11,color:"#94a3b8"},children:l.kind==="developer_prop"?n("layout_editor.property_modal.advanced_kind_developer"):n("layout_editor.property_modal.advanced_kind_expression")})]},l.key))})]})]})}const XA={display:"flex",flexDirection:"column",gap:14},Aa={display:"flex",flexDirection:"column",gap:6},Ta={fontSize:12,fontWeight:700,color:"#0f172a"},JA={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,width:"100%",boxSizing:"border-box"},ZA={fontSize:11,color:"#94a3b8",fontStyle:"italic"},QA={borderTop:"1px dashed #cbd5e1",paddingTop:10,marginTop:4},RA={fontSize:11,color:"#b45309",marginBottom:6},e6={listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:4},t6={display:"flex",justifyContent:"space-between",gap:8,padding:"3px 0"},n6={onClick:"click",onHover:"mouseenter",onChange:"change",onSubmit:"submit",onMount:"mount",onUnmount:"unmount",onFocus:"focus",onBlur:"blur"};function Da(e){return n6[e]??e.replace(/^on/,"").toLowerCase()}function Of(e){const t=e.actions;if(Array.isArray(t))return t.filter(r=>!!r&&typeof r=="object");const n=e.props??{};if(Array.isArray(n.actions))return n.actions.filter(r=>!!r&&typeof r=="object");const o=n.events;if(o&&typeof o=="object"){const r=[];for(const[s,a]of Object.entries(o)){if(!Array.isArray(a))continue;const l=Da(s);for(const d of a)d&&typeof d=="object"&&r.push("type"in d?d:{type:l,...d})}return r}return[]}function o6(e,t){const n=Da(t);return Of(e).filter(o=>o.type===n||t==="onClick"&&o.type===void 0)}function r6(e,t,n){const o=Da(t),r=Of(e).filter(d=>!(d.type===o||t==="onClick"&&d.type===void 0)),s=n.map(d=>"type"in d?d:{type:o,...d}),a={...e};if(a.props&&typeof a.props=="object"){const d={...a.props};let c=!1;"actions"in d&&(delete d.actions,c=!0),"events"in d&&(delete d.events,c=!0),c&&(a.props=d)}const l=[...r,...s];return l.length===0?delete a.actions:a.actions=l,a}function i6({node:e,spec:t,capability:n,t:o,onPatchNode:r,pageCandidates:s,dataSourceCandidates:a,stateKeyCandidates:l,bindingCandidates:d}){const c=t?.actionRecipes,p=u.useMemo(()=>({pageCandidates:s,dataSourceCandidates:a,stateKeyCandidates:l,bindingCandidates:d}),[s,a,l,d]),f=Array.isArray(n?.events)?n.events:[];return f.length===0?i.jsx("div",{"data-testid":"g7le-action-no-events",style:Bf,children:o("layout_editor.action.no_events")}):!c||Object.keys(c).length===0?i.jsx("div",{"data-testid":"g7le-action-no-recipes",style:Bf,children:o("layout_editor.action.no_recipes")}):i.jsx("div",{className:"g7le-action-editor","data-testid":"g7le-action-editor",style:{display:"flex",flexDirection:"column",gap:14},children:f.map(b=>i.jsxs("div",{className:"g7le-action-event-slot","data-testid":`g7le-action-event-${b}`,children:[i.jsx("div",{style:s6,children:o(`layout_editor.action.event.${b}`)}),i.jsx(Gt,{actions:o6(e,b),onChange:g=>r(r6(e,b,g)),t:o,recipes:c,candidatePools:p,actionChipCandidates:t?.actionChipCandidates??null,addContext:"component",showSourceBadge:!0,testIdPrefix:`g7le-action-slot-${b}`})]},b))})}const Bf={fontSize:12,color:"#94a3b8",padding:"16px 0",textAlign:"center"},s6={fontSize:12,fontWeight:700,color:"#475569",marginBottom:6};function za(e,t,n){if(!t)return n;const o=e(t);return!o||o===t||o.startsWith("$t:")?n:o}function a6(e,t){return za(t,e.labelKey,e.path||e.sourceId)}function l6({node:e,spec:t,candidates:n,t:o,onPatchNode:r}){const a=(e.props??{})[t.propKey],l=typeof a=="string"?a:void 0,d=u.useMemo(()=>Kt(a),[a]),c=l!==void 0&&l!==""&&d===null,[p,f]=u.useState(!1),[b,g]=u.useState(""),m=za(o,t.label,t.propKey),h=o(t.shape==="array"?"layout_editor.binding.shape_array":t.shape==="object"?"layout_editor.binding.shape_object":"layout_editor.binding.shape_scalar"),v=u.useMemo(()=>Ui(n,t.shape).map(x=>({...x,resolvedLabel:a6(x,o)})),[n,t.shape,o]),y=u.useMemo(()=>qi(v,b),[v,b]),_=k=>{const x={...e.props??{}};k===void 0?delete x[t.propKey]:x[t.propKey]=k,r({...e,props:x})},w=k=>{_(En(k.sourceId,k.path,t.shape)),f(!1),g("")};return i.jsxs("div",{"data-testid":`g7le-binding-row-${t.propKey}`,style:p6,children:[i.jsxs("div",{style:f6,children:[i.jsx("span",{style:{fontWeight:600,fontSize:12},children:m}),i.jsx("span",{style:g6,children:h}),t.required&&i.jsx("span",{"data-testid":`g7le-binding-required-${t.propKey}`,style:h6,children:o("layout_editor.binding.required")})]}),c?i.jsxs("div",{"data-testid":`g7le-binding-complex-${t.propKey}`,style:v6,children:[o("layout_editor.binding.complex"),i.jsx("code",{style:Wf,children:l})]}):d?i.jsxs("div",{style:y6,children:[i.jsx("code",{"data-testid":`g7le-binding-expr-${t.propKey}`,style:Wf,children:l}),i.jsx("button",{type:"button","data-testid":`g7le-binding-clear-${t.propKey}`,onClick:()=>_(void 0),style:m6,children:o("layout_editor.binding.clear")})]}):i.jsx("div",{"data-testid":`g7le-binding-empty-${t.propKey}`,style:b6,children:o("layout_editor.binding.not_connected")}),d&&(t.shape==="array"||t.shape==="object")&&t.itemFields&&t.itemFields.length>0&&i.jsxs("div",{style:_6,children:[o("layout_editor.binding.item_fields"),": ",t.itemFields.join(", ")]}),!c&&i.jsxs("div",{style:{marginTop:4},children:[i.jsxs("button",{type:"button","data-testid":`g7le-binding-search-toggle-${t.propKey}`,onClick:()=>f(k=>!k),style:x6,children:["🔍 ",o("layout_editor.binding.search")]}),p&&i.jsxs("div",{"data-testid":`g7le-binding-picker-${t.propKey}`,style:w6,children:[i.jsx("input",{type:"text",autoFocus:!0,"data-testid":`g7le-binding-search-input-${t.propKey}`,value:b,placeholder:o("layout_editor.binding.search_placeholder"),onChange:k=>g(k.target.value),style:k6}),i.jsx("div",{style:S6,children:y.length===0?i.jsx("div",{style:C6,children:o("layout_editor.binding.no_results")}):y.map(k=>i.jsxs("button",{type:"button","data-testid":`g7le-binding-candidate-${k.expression}`,onClick:()=>w(k),style:$6,children:[i.jsxs("span",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start"},children:[i.jsx("span",{style:{fontSize:12},children:k.resolvedLabel}),i.jsxs("span",{style:E6,children:[za(o,k.groupLabelKey,k.sourceId)," · ",k.path||k.sourceId]})]}),i.jsx("span",{style:I6,children:k.preview})]},k.expression))})]})]})]})}function d6({node:e,dataProps:t,candidates:n,t:o,onPatchNode:r}){return!Array.isArray(t)||t.length===0?null:i.jsxs("div",{"data-testid":"g7le-data-binding-section",style:c6,children:[i.jsxs("div",{style:u6,children:["🔗 ",o("layout_editor.binding.section_title")]}),t.map(s=>i.jsx(l6,{node:e,spec:s,candidates:n,t:o,onPatchNode:r},s.propKey)),i.jsx("div",{style:A6})]})}const c6={display:"flex",flexDirection:"column",marginBottom:8},u6={fontSize:12,fontWeight:700,color:"#0f172a",marginBottom:6},p6={display:"flex",flexDirection:"column",gap:4,padding:"8px 0"},f6={display:"flex",alignItems:"center",gap:6},g6={fontSize:10,padding:"1px 6px",borderRadius:4,background:"#e0e7ff",color:"#3730a3"},h6={fontSize:10,padding:"1px 6px",borderRadius:4,background:"#fef3c7",color:"#92400e"},y6={display:"flex",alignItems:"center",gap:6},b6={fontSize:11,color:"#94a3b8"},Wf={fontSize:11,fontFamily:"monospace",background:"#f1f5f9",padding:"2px 6px",borderRadius:4,color:"#0f172a",wordBreak:"break-all"},m6={fontSize:11,border:"1px solid #e2e8f0",borderRadius:4,background:"#fff",color:"#dc2626",padding:"2px 8px",cursor:"pointer"},v6={display:"flex",flexDirection:"column",gap:2,fontSize:11,color:"#64748b"},_6={fontSize:10,color:"#94a3b8"},x6={fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#334155",padding:"4px 10px",cursor:"pointer",textAlign:"left",width:"100%"},w6={marginTop:4,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",padding:6},k6={width:"100%",padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,boxSizing:"border-box"},S6={marginTop:4,maxHeight:200,overflowY:"auto",display:"flex",flexDirection:"column",gap:2},C6={fontSize:11,color:"#94a3b8",padding:"8px 0",textAlign:"center"},$6={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,border:"none",background:"transparent",cursor:"pointer",padding:"6px 8px",borderRadius:4,textAlign:"left"},E6={fontSize:10,color:"#94a3b8"},I6={fontSize:10,color:"#64748b",fontFamily:"monospace",whiteSpace:"nowrap"},A6={borderTop:"1px solid #e2e8f0",marginTop:4};function T6({node:e,candidates:t,t:n,onPatchNode:o,templateIdentifier:r}){const s=typeof e.text=="string"?e.text:"",{state:a}=Qe(),l=r??a.templateIdentifier,d=a.selectedRoute?.layoutName??null,c=a.locale,[p,f]=u.useState(!1),b=/^\s*\$t:custom\.[A-Za-z0-9._-]+\s*$/.test(s),m=td(s)&&(vt(s)?.key.startsWith("custom.")??!1)||b,h=u.useMemo(()=>m?vt(s):null,[m,s]),v=u.useMemo(()=>m?[]:ql(s),[m,s]),y=T=>{o({...e,text:T})},_=()=>{if(!(typeof window>"u"))try{window.dispatchEvent(new CustomEvent(kt,{detail:{templateIdentifier:l,locale:c}}))}catch{}},w=(T,E)=>{const A=En(E.sourceId,E.path,"scalar");y(Ab(s,T,A))},k=T=>{const E=vt(s);y(vo(s,T));const A=E?.key;l&&A&&qd(l,A,T).then(_)},x=T=>{const E=n(T);return E&&E!==T&&!E.startsWith("$t:")?E:""},$=T=>T.replace(/\$t:[a-zA-Z0-9._-]+/g,E=>x(E.slice(3))).replace(/\s+/g," ").trim(),S=T=>{p||(f(!0),us(l,d,c,s,s.length,T.sourceId,T.path,"scalar",$,E=>n(E)).then(E=>{E.kind==="ok"&&(y(E.text),_())}).finally(()=>f(!1)))},C=T=>{p||!h&&!b||(f(!0),Cr(l,c,s,Number.MAX_SAFE_INTEGER,T.sourceId,T.path,"scalar").then(E=>{E.kind==="ok"&&(y(E.text),_())}).finally(()=>f(!1)))};if(m){const T=h?.params??[];return i.jsxs("div",{"data-testid":"g7le-inline-binding-section",style:jf,children:[i.jsxs("div",{style:Hf,children:["🔗 ",n("layout_editor.inline_binding.section_title")]}),T.length===0?i.jsx("div",{"data-testid":"g7le-inline-binding-none",style:Vf,children:n("layout_editor.inline_binding.none")}):T.map(E=>i.jsx("div",{"data-testid":`g7le-inline-binding-param-${E.name}`,style:Ff,children:E.parsed===null?i.jsxs("div",{"data-testid":`g7le-inline-binding-param-complex-${E.name}`,style:z6,children:[n("layout_editor.inline_binding.complex"),i.jsx("code",{style:Na,children:E.expression})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{style:Kf,children:[i.jsx("code",{"data-testid":`g7le-inline-binding-param-expr-${E.name}`,style:Na,children:E.expression}),i.jsx("button",{type:"button","data-testid":`g7le-inline-binding-param-clear-${E.name}`,onClick:()=>k(E.name),style:D6,children:n("layout_editor.inline_binding.clear")})]}),i.jsx($t,{candidates:t,t:n,onSelect:A=>w(E.name,A),testIdSuffix:`param-${E.name}`})]})},E.name)),i.jsxs("div",{"data-testid":"g7le-inline-binding-param-append",style:Uf,children:[i.jsx("div",{style:Ma,children:n("layout_editor.inline_binding.append_hint")}),i.jsx($t,{candidates:t,t:n,onSelect:C,testIdSuffix:"param-append"})]}),i.jsx("div",{"data-testid":"g7le-inline-binding-param-hint",style:Ma,children:n("layout_editor.inline_binding.param_hint")}),i.jsx("div",{style:qf})]})}return i.jsxs("div",{"data-testid":"g7le-inline-binding-section",style:jf,children:[i.jsxs("div",{style:Hf,children:["🔗 ",n("layout_editor.inline_binding.section_title")]}),v.length===0?i.jsx("div",{"data-testid":"g7le-inline-binding-none",style:Vf,children:n("layout_editor.inline_binding.none")}):v.map(T=>i.jsx("div",{"data-testid":`g7le-inline-binding-row-${T.bindingIndex}`,style:Ff,children:i.jsx("div",{style:Kf,children:i.jsx("code",{"data-testid":`g7le-inline-binding-expr-${T.bindingIndex}`,style:Na,children:T.expression})})},T.bindingIndex)),i.jsxs("div",{"data-testid":"g7le-inline-binding-append",style:Uf,children:[i.jsx("div",{style:Ma,children:n("layout_editor.inline_binding.append_hint")}),i.jsx($t,{candidates:t,t:n,onSelect:S,testIdSuffix:"append"})]}),i.jsx("div",{style:qf})]})}const jf={display:"flex",flexDirection:"column",marginBottom:8},Hf={fontSize:12,fontWeight:700,color:"#0f172a",marginBottom:6},Ff={display:"flex",flexDirection:"column",gap:4,padding:"8px 0"},Kf={display:"flex",alignItems:"center",gap:6},Vf={fontSize:11,color:"#94a3b8"},Na={fontSize:11,fontFamily:"monospace",background:"#f1f5f9",padding:"2px 6px",borderRadius:4,color:"#0f172a",wordBreak:"break-all"},D6={fontSize:11,border:"1px solid #e2e8f0",borderRadius:4,background:"#fff",color:"#dc2626",padding:"2px 8px",cursor:"pointer"},z6={display:"flex",flexDirection:"column",gap:2,fontSize:11,color:"#64748b"},Uf={display:"flex",flexDirection:"column",gap:2,padding:"8px 0 0"},Ma={fontSize:11,color:"#475569",fontWeight:600},qf={borderTop:"1px solid #e2e8f0",marginTop:4};function Gf(e,t,n){if(!t)return n;const o=e(t);return!o||o===t||o.startsWith("$t:")?n:o}function N6(e,t){return Gf(t,e.labelKey,e.path||e.sourceId)}function M6(e){const t=e.iteration;return t&&typeof t=="object"?t:null}function L6({node:e,candidates:t,t:n,onPatchNode:o}){const r=M6(e),s=r?.source,a=typeof s=="string"?s:void 0,l=u.useMemo(()=>Kt(s),[s]),d=a!==void 0&&a!==""&&l===null,[c,p]=u.useState(!1),[f,b]=u.useState(""),g=u.useMemo(()=>Ui(t,"array").map(k=>({...k,resolvedLabel:N6(k,n)})),[t,n]),m=u.useMemo(()=>qi(g,f),[g,f]);if(!r)return null;const h=typeof r.item_var=="string"?r.item_var:void 0,v=typeof r.index_var=="string"?r.index_var:void 0,y=w=>{const k={...r};w===void 0?delete k.source:k.source=w,o({...e,iteration:k})},_=w=>{y(En(w.sourceId,w.path,"array")),p(!1),b("")};return i.jsxs("div",{"data-testid":"g7le-iteration-binding-section",style:P6,children:[i.jsxs("div",{style:O6,children:["🔁 ",n("layout_editor.binding.iteration_title")]}),i.jsx("div",{style:B6,children:n("layout_editor.binding.iteration_hint")}),i.jsxs("div",{style:W6,children:[i.jsxs("div",{style:j6,children:[i.jsx("span",{style:{fontWeight:600,fontSize:12},children:n("layout_editor.binding.iteration_label")}),i.jsx("span",{style:H6,children:n("layout_editor.binding.shape_array")})]}),d?i.jsxs("div",{"data-testid":"g7le-iteration-binding-complex",style:U6,children:[n("layout_editor.binding.complex"),i.jsx("code",{style:Yf,children:a})]}):l?i.jsxs("div",{style:F6,children:[i.jsx("code",{"data-testid":"g7le-iteration-binding-expr",style:Yf,children:a}),i.jsx("button",{type:"button","data-testid":"g7le-iteration-binding-clear",onClick:()=>y(void 0),style:V6,children:n("layout_editor.binding.clear")})]}):i.jsx("div",{"data-testid":"g7le-iteration-binding-empty",style:K6,children:n("layout_editor.binding.not_connected")}),(h||v)&&i.jsxs("div",{"data-testid":"g7le-iteration-vars",style:q6,children:[h&&i.jsxs("span",{children:[n("layout_editor.binding.iteration_item_var"),": ",i.jsx("code",{style:Xf,children:h})]}),v&&i.jsxs("span",{children:[n("layout_editor.binding.iteration_index_var"),": ",i.jsx("code",{style:Xf,children:v})]})]}),!d&&i.jsxs("div",{style:{marginTop:4},children:[i.jsxs("button",{type:"button","data-testid":"g7le-iteration-binding-search-toggle",onClick:()=>p(w=>!w),style:G6,children:["🔍 ",n("layout_editor.binding.search")]}),c&&i.jsxs("div",{"data-testid":"g7le-iteration-binding-picker",style:Y6,children:[i.jsx("input",{type:"text",autoFocus:!0,"data-testid":"g7le-iteration-binding-search-input",value:f,placeholder:n("layout_editor.binding.search_placeholder"),onChange:w=>b(w.target.value),style:X6}),i.jsx("div",{style:J6,children:m.length===0?i.jsx("div",{style:Z6,children:n("layout_editor.binding.no_results")}):m.map(w=>i.jsxs("button",{type:"button","data-testid":`g7le-iteration-binding-candidate-${w.expression}`,onClick:()=>_(w),style:Q6,children:[i.jsxs("span",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start"},children:[i.jsx("span",{style:{fontSize:12},children:w.resolvedLabel}),i.jsxs("span",{style:R6,children:[Gf(n,w.groupLabelKey,w.sourceId)," · ",w.path||w.sourceId]})]}),i.jsx("span",{style:eT,children:w.preview})]},w.expression))})]})]})]}),i.jsx("div",{style:tT})]})}const P6={display:"flex",flexDirection:"column",marginBottom:8},O6={fontSize:12,fontWeight:700,color:"#0f172a",marginBottom:4},B6={fontSize:10,color:"#94a3b8",marginBottom:6,lineHeight:1.4},W6={display:"flex",flexDirection:"column",gap:4,padding:"8px 0"},j6={display:"flex",alignItems:"center",gap:6},H6={fontSize:10,padding:"1px 6px",borderRadius:4,background:"#e0e7ff",color:"#3730a3"},F6={display:"flex",alignItems:"center",gap:6},K6={fontSize:11,color:"#94a3b8"},Yf={fontSize:11,fontFamily:"monospace",background:"#f1f5f9",padding:"2px 6px",borderRadius:4,color:"#0f172a",wordBreak:"break-all"},V6={fontSize:11,border:"1px solid #e2e8f0",borderRadius:4,background:"#fff",color:"#dc2626",padding:"2px 8px",cursor:"pointer"},U6={display:"flex",flexDirection:"column",gap:2,fontSize:11,color:"#64748b"},q6={display:"flex",gap:12,fontSize:10,color:"#94a3b8",marginTop:2},Xf={fontSize:10,fontFamily:"monospace",background:"#f1f5f9",padding:"1px 4px",borderRadius:3,color:"#475569"},G6={fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#334155",padding:"4px 10px",cursor:"pointer",textAlign:"left",width:"100%"},Y6={marginTop:4,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",padding:6},X6={width:"100%",padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,boxSizing:"border-box"},J6={marginTop:4,maxHeight:200,overflowY:"auto",display:"flex",flexDirection:"column",gap:2},Z6={fontSize:11,color:"#94a3b8",padding:"8px 0",textAlign:"center"},Q6={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,border:"none",background:"transparent",cursor:"pointer",padding:"6px 8px",borderRadius:4,textAlign:"left"},R6={fontSize:10,color:"#94a3b8"},eT={fontSize:10,color:"#64748b",fontFamily:"monospace",whiteSpace:"nowrap"},tT={borderTop:"1px solid #e2e8f0",marginTop:4},nT=new Set(["Span","P","H1","H2","H3","H4","H5","H6","A","Button","Li","Label"]);function oT(e,t){if(!e||e.iteration&&typeof e.iteration=="object")return!1;const n=t?.textBinding;if(n===!1)return!1;if(n===!0)return!0;const o=typeof e.name=="string"?e.name:"";return nT.has(o)?!0:typeof e.text=="string"}const yn={direction:"flexDirection",justify:"flexJustify",align:"flexAlign",wrap:"flexWrap",gap:"flexGap",enable:"flexEnable"},mi={grow:"flexItemGrow",selfAlign:"flexItemAlign",order:"flexItemOrder"};function Jf(e){const t=e?.flexEditor;return t==="container"||t==="item"||t==="auto"?t:null}function rT(e){if(!e||typeof window>"u"||typeof window.getComputedStyle!="function")return!1;const t=(window.getComputedStyle(e).display??"").toLowerCase();return t==="flex"||t==="inline-flex"}function iT(e,t,n=Wt){if(!e||!t)return!1;const o=zo(e,t,n),r=t.options,s=Array.isArray(r)?t.onValue??r[0]?.value:void 0,a=l=>s!==void 0?l===s:l!==void 0&&l!==!1;return n.breakpoint!=="base"?a(o.scopedRawValue):o.matched&&a(o.value)}function sT(e,t,n=!1,o=!1,r=Wt){if(e==="container")return{showContainer:!0,showEnableButton:!1,showDisableButton:!1};if(e==="item")return{showContainer:!1,showEnableButton:!1,showDisableButton:!1};if(e==="auto"){const s=r.breakpoint==="base";return!o&&!s?{showContainer:!1,showEnableButton:!1,showDisableButton:!1}:(o?n:rT(t))?{showContainer:!0,showEnableButton:!1,showDisableButton:o}:{showContainer:!1,showEnableButton:!0,showDisableButton:!1}}return{showContainer:!1,showEnableButton:!1,showDisableButton:!1}}const aT={[yn.direction]:"layout_editor.flex.direction",[yn.justify]:"layout_editor.flex.justify",[yn.align]:"layout_editor.flex.align",[yn.wrap]:"layout_editor.flex.wrap",[yn.gap]:"layout_editor.flex.gap"},lT={[mi.grow]:"layout_editor.flex.item_grow",[mi.selfAlign]:"layout_editor.flex.item_align",[mi.order]:"layout_editor.flex.item_order"};function dT({node:e,spec:t,capability:n,t:o,onPatchNode:r,liveElement:s,scope:a=Wt}){const l=Jf(n),d=Ct(t,yn.enable),c=iT(e,d,a),{showContainer:p,showEnableButton:f,showDisableButton:b}=sT(l,s,c,!!d,a),g=Object.values(yn).filter(x=>x!==yn.enable&&Ct(t,x)),m=Object.values(mi).filter(x=>Ct(t,x)),h=d?.options,v=d?.onValue??h?.[0]?.value??!0,y=Array.isArray(h)&&h.length>=2?h[1].value:void 0,_=()=>{if(!d)return;const x=fn(e,d,v,a);r(x)},w=()=>{if(!d)return;const x=a.breakpoint!=="base"&&y!==void 0?y:void 0,$=fn(e,d,x,a);r($)},k=(x,$,S)=>i.jsx("div",{"data-testid":S,style:{display:"flex",flexDirection:"column"},children:x.map(C=>{const T=Ct(t,C);if(!T)return null;const E=T.label?T:{...T,label:`$t:${$[C]}`};return i.jsx(hi,{controlKey:C,control:E,node:e,t:o,onPatch:r,scope:a},C)})});return i.jsxs("div",{className:"g7le-flex-editor","data-testid":"g7le-flex-editor",style:{display:"flex",flexDirection:"column",gap:12},children:[f&&i.jsx("button",{type:"button","data-testid":"g7le-flex-enable",onClick:_,style:cT,children:o("layout_editor.flex.make_flex")}),p&&g.length>0&&i.jsxs("div",{className:"g7le-flex-container-section","data-testid":"g7le-flex-container-section",children:[i.jsx("div",{style:Zf,children:o("layout_editor.flex.container_title")}),k(g,aT,"g7le-flex-container-controls"),b&&i.jsx("button",{type:"button","data-testid":"g7le-flex-disable",onClick:w,style:uT,children:o("layout_editor.flex.unmake_flex")})]}),l==="item"&&m.length>0&&i.jsxs("div",{className:"g7le-flex-item-section","data-testid":"g7le-flex-item-section",children:[i.jsx("div",{style:Zf,children:o("layout_editor.flex.item_title")}),k(m,lT,"g7le-flex-item-controls")]}),!p&&!f&&l!=="item"&&i.jsx("div",{"data-testid":"g7le-flex-empty",style:pT,children:o("layout_editor.flex.not_flex")})]})}const Zf={fontSize:12,fontWeight:700,color:"#0f172a",marginBottom:6},cT={padding:"8px 12px",fontSize:12,border:"1px dashed #2563eb",borderRadius:6,background:"#eff6ff",color:"#2563eb",cursor:"pointer"},uT={marginTop:8,padding:"6px 10px",fontSize:12,border:"1px solid #e2e8f0",borderRadius:6,background:"#f8fafc",color:"#64748b",cursor:"pointer"},pT={fontSize:12,color:"#94a3b8",padding:"16px 0",textAlign:"center"},Qf=["desktop","tablet","mobile","portable"],La=1280,fT=820,gT=390,hT=1920,yT=320;function bT(e){const t=[],n=new Set,o=r=>{if(!r||typeof r!="object")return;const s=r.responsive;if(s&&typeof s=="object")for(const a of Object.keys(s)){n.has(a)||(n.add(a),t.push(a));const l=s[a]?.children;if(Array.isArray(l))for(const d of l)o(d)}if(Array.isArray(r.children))for(const a of r.children)o(a)};if(Array.isArray(e))for(const r of e)o(r);return t}function mT(e){const t=[...Qf],n=new Set(Qf);for(const o of bT(e))!n.has(o)&&!t.includes(o)&&t.push(o);return t}function vT(e,t){const n=e?.responsive;if(!n||typeof n!="object")return[];const o=[];for(const r of Object.keys(n)){const s=n[r];!s||!Array.isArray(s.children)||r!==t&&o.push(r)}return o}function _T(e){switch(e){case"desktop":return La;case"tablet":return fT;case"mobile":return gT}const t=e in Do?Do[e]:Mn.parseRange(e);return!t||!Number.isFinite(t.max)?La:Math.round(Math.max(yT,Math.min(hT,t.max)))}function Rf(){const t=Ft()?.document?.raw?.components;return u.useMemo(()=>mT(t??null),[t])}const xT={desktop:"layout_editor.property_modal.scope.device_desktop",tablet:"layout_editor.property_modal.scope.device_tablet",mobile:"layout_editor.property_modal.scope.device_mobile",portable:"layout_editor.property_modal.scope.device_portable"},wT=[{key:"base",labelKey:"layout_editor.property_modal.scope.scheme_light"},{key:"dark",labelKey:"layout_editor.property_modal.scope.scheme_dark"}];function eg({scope:e,onChange:t,node:n,t:o,showColorScheme:r=!0,onClearScope:s}){const[a,l]=u.useState(!1),[d,c]=u.useState(""),[p,f]=u.useState(""),[b,g]=u.useState(null),m=Rf(),h=u.useMemo(()=>{const w=["base",...m],k=new Set(w);for(const x of Object.keys(n.responsive??{}))x!=="base"&&!k.has(x)&&(k.add(x),w.push(x));return e.breakpoint!=="base"&&!k.has(e.breakpoint)&&w.push(e.breakpoint),w},[m,n.responsive,e.breakpoint]),v=w=>t({...e,colorScheme:w}),y=w=>t({...e,breakpoint:w}),_=()=>{const w=d.trim(),k=p.trim();if(w===""&&k===""){g(o("layout_editor.property_modal.scope.custom_invalid"));return}const x=`${w}-${k}`;if(!xC(x)){g(o("layout_editor.property_modal.scope.custom_invalid"));return}g(null),l(!1),c(""),f(""),y(x)};return i.jsxs("div",{className:"g7le-style-scope-tabs","data-testid":"g7le-style-scope-tabs",style:kT,children:[r&&i.jsx("div",{className:"g7le-style-scope-scheme","data-testid":"g7le-style-scope-scheme",role:"tablist","aria-label":o("layout_editor.property_modal.scope.scheme_light"),style:tg,children:wT.map(w=>{const k=e.colorScheme===w.key;return i.jsxs("button",{type:"button",role:"tab","aria-selected":k,"data-testid":`g7le-style-scheme-${w.key}`,"data-active":k?"true":"false",onClick:()=>v(w.key),style:ng(k),children:[o(w.labelKey),w.key==="dark"&&Js(n,{colorScheme:"dark",breakpoint:e.breakpoint})&&i.jsx("span",{"data-testid":"g7le-style-scheme-dark-dot",style:og})]},w.key)})}),i.jsxs("div",{className:"g7le-style-scope-device","data-testid":"g7le-style-scope-device",role:"tablist","aria-label":o("layout_editor.property_modal.scope.device_base"),style:tg,children:[h.map(w=>{const k=e.breakpoint===w,x=w==="base"||$u(w),$=w==="base"?"layout_editor.property_modal.scope.device_base":xT[w],S=$?o($):w,C=x?`g7le-style-bp-${w}`:`g7le-style-bp-custom-${w}`;return i.jsxs("button",{type:"button",role:"tab","aria-selected":k,"data-testid":C,"data-active":k?"true":"false",onClick:()=>y(w),style:ng(k),children:[S,Js(n,{colorScheme:"base",breakpoint:w})&&i.jsx("span",{"data-testid":`${C}-dot`,style:og})]},String(w))}),i.jsxs("button",{type:"button","data-testid":"g7le-style-bp-add-custom",onClick:()=>l(w=>!w),style:$T,children:["+ ",o("layout_editor.property_modal.scope.add_custom")]})]}),a&&i.jsxs("div",{className:"g7le-style-scope-custom-input","data-testid":"g7le-style-scope-custom-input",style:ST,children:[i.jsx("input",{type:"number","data-testid":"g7le-style-custom-min",placeholder:o("layout_editor.property_modal.scope.custom_min"),value:d,onChange:w=>c(w.target.value),style:rg}),i.jsx("span",{style:{color:"#94a3b8"},children:"—"}),i.jsx("input",{type:"number","data-testid":"g7le-style-custom-max",placeholder:o("layout_editor.property_modal.scope.custom_max"),value:p,onChange:w=>f(w.target.value),style:rg}),i.jsx("button",{type:"button","data-testid":"g7le-style-custom-confirm",onClick:_,style:ET,children:o("layout_editor.property_modal.scope.add_custom")})]}),b&&i.jsx("div",{"data-testid":"g7le-style-custom-error",style:IT,children:b}),e.breakpoint!=="base"&&!$u(e.breakpoint)&&i.jsx("div",{"data-testid":"g7le-style-custom-priority-note",style:AT,children:o("layout_editor.property_modal.scope.custom_priority_note")}),s&&Js(n,e)&&i.jsxs("button",{type:"button","data-testid":"g7le-style-scope-reset",onClick:s,style:CT,children:["↺ ",o("layout_editor.property_modal.scope.reset_to_base")]})]})}const kT={display:"flex",flexDirection:"column",gap:0,padding:"0 0 8px",borderBottom:"1px solid #e2e8f0",marginBottom:8},ST={display:"flex",gap:6,alignItems:"center",marginTop:4},tg={display:"flex",gap:2,flexWrap:"wrap",borderBottom:"1px solid #e2e8f0",margin:"0 -16px",padding:"0 12px"};function ng(e){return{display:"inline-flex",alignItems:"center",gap:4,padding:"6px 12px",fontSize:12,border:"none",borderBottom:`2px solid ${e?"#2563eb":"transparent"}`,background:"transparent",color:e?"#2563eb":"#64748b",cursor:"pointer",fontWeight:e?700:500,marginBottom:-1}}const og={display:"inline-block",width:5,height:5,borderRadius:3,background:"#f59e0b"},CT={alignSelf:"flex-start",marginTop:2,padding:"3px 8px",fontSize:10,border:"1px solid #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer"},$T={padding:"6px 12px",fontSize:11,border:"none",borderBottom:"2px dashed #cbd5e1",background:"transparent",color:"#475569",cursor:"pointer",marginBottom:-1},rg={width:70,padding:"4px 6px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6},ET={padding:"4px 10px",fontSize:11,border:"none",borderRadius:6,background:"#2563eb",color:"#fff",cursor:"pointer"},IT={fontSize:11,color:"#dc2626"},AT={fontSize:10,color:"#94a3b8"},ig=new Map;function Pn(e,t){ig.set(e,t)}function TT(e){return e?ig.get(e)??null:null}const Pa={id:{label:"$t:layout_editor.core_props.id.label",widget:"core-id",placeholder:"$t:layout_editor.core_props.id.placeholder",apply:{type:"propValue",propKey:"id"}},dataKey:{label:"$t:layout_editor.core_props.dataKey.label",widget:"core-datakey",placeholder:"$t:layout_editor.core_props.dataKey.placeholder",apply:{type:"nodeKey",nodeKey:"dataKey"}},isolatedState:{label:"$t:layout_editor.core_props.isolatedState.label",widget:"toggle",apply:{type:"nodeKey",nodeKey:"isolatedState"}},isolatedScopeId:{label:"$t:layout_editor.core_props.isolatedScopeId.label",widget:"core-scopeid",placeholder:"$t:layout_editor.core_props.isolatedScopeId.placeholder",apply:{type:"nodeKey",nodeKey:"isolatedScopeId"}}},DT=["id"];function zT(e){return e===!1?[]:Array.isArray(e)?e.filter(t=>t in Pa):[...DT]}function sg(e){const t=e.props?.id??e.id;return typeof t=="string"&&t.length>0?`${t}-scope`:"scope"}function NT({node:e,onPatchNode:t,t:n,scopeIdCandidates:o=[],usedScopeIds:r=[]}){const s=e,a="isolatedState"in s&&s.isolatedState!=null,l=typeof s.isolatedScopeId=="string"?s.isolatedScopeId:"",[d,c]=u.useState(""),p=()=>{const h={...e};a?(delete h.isolatedState,delete h.isolatedScopeId):(h.isolatedState={},h.isolatedScopeId=sg(e)),t(h)},f=h=>{const v={...e};v.isolatedScopeId=h.trim()===""?sg(e):h,t(v)},b=h=>{const v={...e};v.isolatedState=h,t(v)},g=u.useMemo(()=>{const h=d.trim().toLowerCase();return o.filter(v=>!h||v.toLowerCase().includes(h))},[o,d]),m=l!==""&&r.includes(l);return i.jsxs("div",{className:"g7le-isolated-scope","data-testid":"g7le-isolated-scope-control",style:MT,children:[i.jsx("div",{style:LT,children:n("layout_editor.core_props.isolatedState.label")}),i.jsxs("div",{style:PT,children:[i.jsx("button",{type:"button","data-testid":"g7le-isolated-toggle",role:"switch","aria-checked":a,onClick:p,style:OT(a),children:n(a?"layout_editor.overlay.on":"layout_editor.overlay.off")}),a?null:i.jsx("span",{"data-testid":"g7le-isolated-off-hint",style:BT,children:n("layout_editor.core_props.isolatedState.off_hint")})]}),a?i.jsxs(i.Fragment,{children:[i.jsxs("div",{style:ag,children:[i.jsx("label",{style:lg,children:n("layout_editor.core_props.isolatedScopeId.label")}),i.jsx("input",{type:"text","data-testid":"g7le-isolated-scopeid-input",value:l,placeholder:n("layout_editor.core_props.isolatedScopeId.placeholder"),onChange:h=>f(h.target.value),style:WT}),g.length>0?i.jsxs("div",{"data-testid":"g7le-isolated-scopeid-picker",style:jT,children:[i.jsx("input",{type:"text","data-testid":"g7le-isolated-scopeid-search",value:d,placeholder:n("layout_editor.core_props.isolatedScopeId.search"),onChange:h=>c(h.target.value),style:HT}),i.jsx("div",{style:FT,children:g.map(h=>i.jsx("button",{type:"button","data-testid":`g7le-isolated-scopeid-candidate-${h}`,onClick:()=>{f(h),c("")},style:KT,children:h},h))})]}):null,m?i.jsxs("p",{"data-testid":"g7le-isolated-scopeid-dup",style:VT,children:["ⓘ ",n("layout_editor.core_props.isolatedScopeId.duplicate")]}):null]}),i.jsxs("div",{style:ag,children:[i.jsx("label",{style:lg,children:n("layout_editor.core_props.isolatedState.initial_label")}),i.jsx("div",{"data-testid":"g7le-isolated-initial-value",children:i.jsx(zn,{value:s.isolatedState??{},onChange:b,t:n,path:"isolatedState",scope:"isolated-node"})})]})]}):null]})}const MT={display:"flex",flexDirection:"column",gap:8,padding:10,border:"1px solid #e2e8f0",borderRadius:8,minWidth:0},LT={fontSize:12,fontWeight:700,color:"#0f172a"},PT={display:"flex",gap:8,alignItems:"center"},OT=e=>({padding:"4px 12px",fontSize:11,border:`1px solid ${e?"#3b82f6":"#cbd5e1"}`,borderRadius:14,background:e?"#eff6ff":"#fff",color:e?"#1d4ed8":"#64748b",cursor:"pointer"}),BT={fontSize:11,color:"#94a3b8"},ag={display:"flex",flexDirection:"column",gap:4,minWidth:0},lg={fontSize:11,color:"#64748b"},WT={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,boxSizing:"border-box",width:"100%"},jT={border:"1px solid #e2e8f0",borderRadius:6,padding:4,background:"#fff"},HT={width:"100%",padding:"4px 6px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,marginBottom:4,boxSizing:"border-box"},FT={display:"flex",flexDirection:"column",maxHeight:120,overflowY:"auto"},KT={textAlign:"left",padding:"4px 6px",fontSize:12,border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"#0f172a"},VT={margin:0,fontSize:11,color:"#64748b"},UT={borderTop:"2px solid #c7d2fe",background:"#eef2ff",padding:"10px 12px",display:"flex",flexDirection:"column",gap:8},dg={fontSize:13,fontWeight:700,color:"#3730a3",display:"flex",alignItems:"center",gap:6},qT={fontSize:11,fontWeight:600,color:"#4338ca",background:"#e0e7ff",border:"1px solid #c7d2fe",borderRadius:4,padding:"1px 6px"},Oa={fontSize:11,color:"#6366f1"},GT={alignSelf:"flex-start",fontSize:12,fontWeight:600,color:"#fff",background:"#4f46e5",border:"none",borderRadius:4,padding:"4px 10px",cursor:"pointer"},YT={opacity:.5,cursor:"not-allowed"},XT={fontSize:11,color:"#dc2626"};function JT({entry:e,t,onSave:n}){const[o,r]=u.useState(()=>e.props),[s,a]=u.useState(!0),[l,d]=u.useState(null),[c,p]=u.useState(!1),[f,b]=u.useState(!1),g=e.extensionName??e.extensionIdentifier??`#${e.extensionId}`,m=async()=>{if(!s){d(t("layout_editor.property_modal.injected_props.invalid_json"));return}d(null),p(!0),b(!1);try{await n(o),b(!0)}catch(h){d(h instanceof Error?h.message:String(h))}finally{p(!1)}};return i.jsxs("div",{"data-testid":`g7le-injected-props-entry-${e.extensionId}`,style:{display:"flex",flexDirection:"column",gap:6},children:[i.jsx("div",{style:dg,children:i.jsx("span",{style:qT,"data-testid":"g7le-injected-props-origin-badge",children:t("layout_editor.property_modal.injected_props.origin",{source:g})})}),i.jsx(Hs,{value:o,shape:"object",emptyValue:{},testidPrefix:"g7le-injected-props-json",minHeight:80,invalidErrorKey:"layout_editor.property_modal.injected_props.invalid_json",shapeErrorKey:"layout_editor.property_modal.injected_props.invalid_json",t,onChange:h=>{r(h??{}),b(!1)},onValidityChange:h=>{a(h),h&&d(null),b(!1)}}),l&&i.jsx("div",{style:XT,"data-testid":"g7le-injected-props-error",children:l}),f&&i.jsx("div",{style:{...Oa,color:"#16a34a"},"data-testid":"g7le-injected-props-saved",children:t("layout_editor.property_modal.injected_props.saved")}),i.jsx("div",{style:Oa,children:t("layout_editor.property_modal.injected_props.save_target")}),i.jsx("button",{type:"button","data-testid":"g7le-injected-props-save",style:{...GT,...c||!s?YT:null},disabled:c||!s,onClick:m,children:c?t("layout_editor.property_modal.injected_props.saving"):t("layout_editor.property_modal.injected_props.save_button",{source:g})})]})}function ZT({injectedProps:e,t,onSaveInjectedProps:n}){return!Array.isArray(e)||e.length===0?null:i.jsxs("div",{style:UT,"data-testid":"g7le-injected-props-section",children:[i.jsxs("div",{style:dg,children:["🧩 ",t("layout_editor.property_modal.injected_props.title")]}),i.jsx("div",{style:Oa,children:t("layout_editor.property_modal.injected_props.help")}),e.map(o=>i.jsx(JT,{entry:o,t,onSave:r=>n(o.extensionId,r)},o.extensionId))]})}function QT(e,t){const n=e?.components??{};for(const o of Object.values(n)){const r=o?.find(s=>s.name===t);if(r)return r}return null}function RT({node:e,spec:t,manifest:n,t:o,onPatchNode:r,onClose:s,onDelete:a,permissionCandidates:l,pageCandidates:d,dataSourceCandidates:c,stateKeyCandidates:p,bindingCandidates:f,liveElement:b,scope:g=Wt,onScopeChange:m,templateIdentifier:h,initialTab:v,onSaveInjectedProps:y,branchLabel:_,isolatedScopeIdCandidates:w,usedScopeIds:k}){const x=e.__injectedProps,$=Array.isArray(x)&&x.length>0&&!!y,S=ve=>{m?.(ve)},C=()=>{r(IC(e,g))},T=typeof e.name=="string"?e.name:"",E=ji(t,T),N=QT(n,T)?.settings,D=!!(N?.groups&&N.groups.length>0),B=Array.isArray(E?.propControls)?E.propControls:[],M=zT(E?.coreProps),O=new Set(M.map(ve=>Pa[ve].apply?.propKey)),z=B.filter(ve=>{const We=Ct(t,ve)?.apply?.propKey;return!(We!==void 0&&O.has(We))}),H=typeof E?.nodeEditor?.kind=="string"?E.nodeEditor.kind:void 0,P=E?.nodeEditor?.params,I=H?TT(H):null,L=!!I,F=Array.isArray(E?.dataProps)?E.dataProps:[],Y=F.length>0,K=!!(e.iteration&&typeof e.iteration=="object"),X=oT(e,E),Z=M.length>0||z.length>0||L||Y||X||K,ae=Array.isArray(E?.styleControls)?E.styleControls:[],oe=Array.isArray(E?.advanced)?E.advanced:[],ee=(Array.isArray(E?.events)?E.events:[]).length>0,ge=Jf(E),V=ae.length>0||ge!==null,be=!(E?.visibilityCondition===!1)&&(Z||V||ee||D||oe.length>0),Ee=u.useMemo(()=>{const ve=[];return D&&ve.push("settings"),Z&&ve.push("props"),V&&ve.push("style"),ee&&ve.push("action"),be&&ve.push("visibility"),ve.push("translation"),oe.length>0&&ve.push("advanced"),ve},[D,Z,V,ee,be,oe.length]),De=z.length>0||L||Y||K,[Se,Ue]=u.useState(v&&Ee.includes(v)?v:D?"settings":De?"props":V?"style":Z?"props":Ee[0]??"style"),Me=qA(e),Oe=!Z&&!V&&!D&&!ee&&!be&&oe.length===0,Ye=E?.label?E.label.startsWith("$t:")?o(E.label.slice(3)):E.label:T||o("layout_editor.property_modal.element"),ze=(ve,qe)=>{const We={...e.props??{}};qe===void 0?delete We[ve]:We[ve]=qe,r({...e,props:We})},Xe={settings:o("layout_editor.property_modal.tab.settings"),props:o("layout_editor.property_modal.tab.props"),style:o("layout_editor.property_modal.tab.style"),action:o("layout_editor.property_modal.tab.action"),visibility:o("layout_editor.property_modal.tab.visibility"),translation:o("layout_editor.property_modal.tab.translation"),advanced:o("layout_editor.property_modal.tab.advanced")};return i.jsxs("div",{className:"g7le-property-modal","data-testid":"g7le-property-modal",style:e4,children:[i.jsxs("div",{"data-modal-drag-handle":!0,"data-testid":"g7le-property-modal-header",style:t4,children:[i.jsx("span",{"data-testid":"g7le-property-modal-title",style:{fontSize:14,fontWeight:700},children:D&&Se==="settings"?o("layout_editor.property_modal.settings_title",{name:Ye}):o("layout_editor.property_modal.title",{name:Ye})}),i.jsx("button",{type:"button","data-testid":"g7le-property-modal-close","aria-label":"close",onClick:s,style:n4,children:"✕"})]}),Me&&i.jsx("div",{"data-testid":"g7le-property-modal-advanced-badge",style:o4,children:o("layout_editor.property_modal.advanced_badge")}),_&&i.jsx("div",{"data-testid":"g7le-property-modal-branch-badge",style:r4,children:o("layout_editor.property_modal.branch_badge",{device:_})}),i.jsx("div",{style:i4,role:"tablist",children:Ee.map(ve=>i.jsx("button",{type:"button",role:"tab","aria-selected":Se===ve,"data-testid":`g7le-property-tab-${ve}`,"data-active":Se===ve?"true":"false",onClick:()=>Ue(ve),style:{...s4,color:Se===ve?"#2563eb":"#64748b",borderBottomColor:Se===ve?"#2563eb":"transparent"},children:Xe[ve]},ve))}),i.jsxs("div",{style:a4,"data-testid":"g7le-property-modal-body",children:[Oe&&!$&&i.jsx("div",{"data-testid":"g7le-property-modal-no-editable",style:ug,children:o("layout_editor.property_modal.no_editable_props")}),$&&i.jsx(ZT,{injectedProps:x,t:o,onSaveInjectedProps:y}),Se==="settings"&&N&&i.jsx(MA,{spec:N,node:e,t:o,onPatchProp:ze}),Se==="props"&&i.jsxs("div",{"data-testid":"g7le-property-props-tab",style:{display:"flex",flexDirection:"column"},children:[K&&i.jsx(L6,{node:e,candidates:f??[],t:o,onPatchNode:r}),Y&&i.jsx(d6,{node:e,dataProps:F,candidates:f??[],t:o,onPatchNode:r}),X&&i.jsx(T6,{node:e,candidates:f??[],t:o,onPatchNode:r,templateIdentifier:h}),L&&I&&i.jsx(I,{node:e,params:P,spec:t,manifest:n,t:o,onPatchNode:r,templateIdentifier:h,candidates:f}),M.map(ve=>i.jsx(hi,{controlKey:`core-${ve}`,control:Pa[ve],node:e,t:o,onPatch:r,scope:Wt,bindingCandidates:f},`core-${ve}`)),z.map(ve=>{const qe=Ct(t,ve);return qe?i.jsx(hi,{controlKey:ve,control:qe,node:e,t:o,onPatch:r,scope:Wt,bindingCandidates:f},ve):null}),i.jsx(NT,{node:e,onPatchNode:r,t:o,scopeIdCandidates:w,usedScopeIds:k})]}),Se==="style"&&i.jsxs("div",{"data-testid":"g7le-property-style-tab",style:{display:"flex",flexDirection:"column"},children:[i.jsx("div",{style:cg,children:i.jsx(eg,{scope:g,onChange:S,node:e,t:o,onClearScope:C})}),ge!==null&&i.jsx(dT,{node:e,spec:t,capability:E,t:o,onPatchNode:r,liveElement:b,scope:g}),ae.map(ve=>{const qe=Ct(t,ve);return qe?i.jsx(hi,{controlKey:ve,control:qe,node:e,t:o,onPatch:r,scope:g},ve):null})]}),Se==="action"&&i.jsx(i6,{node:e,spec:t,capability:E,t:o,onPatchNode:r,pageCandidates:d,dataSourceCandidates:c,stateKeyCandidates:p,bindingCandidates:f}),Se==="visibility"&&i.jsxs("div",{"data-testid":"g7le-property-visibility-tab",style:{display:"flex",flexDirection:"column"},children:[i.jsx("div",{style:cg,children:i.jsx(eg,{scope:g,onChange:S,node:e,t:o,showColorScheme:!1})}),i.jsx(Du,{node:e,spec:t,t:o,onPatchNode:r,dataSourceCandidates:c,stateKeyCandidates:p,scope:g})]}),Se==="translation"&&(h?i.jsx(Xd,{customKey:Yd(e),templateIdentifier:h,t:o,paramLabels:wv(e),onRemoveParam:ve=>{const qe=typeof e.text=="string"?e.text:"";r({...e,text:vo(qe,ve)});const We=Yd(e);h&&We&&$r(h,We,ve)}}):i.jsx("div",{"data-testid":"g7le-property-translation-deferred",style:ug,children:o("layout_editor.translation.not_a_key")})),Se==="advanced"&&i.jsx(YA,{node:e,advanced:oe,t:o,onPatch:r,permissionCandidates:l})]}),i.jsxs("div",{style:l4,children:[i.jsx("span",{"data-testid":"g7le-property-modal-node-id",style:{fontSize:11,color:"#94a3b8"},children:typeof e.id=="string"||typeof e.id=="number"?`ID: ${e.id}`:""}),i.jsxs("div",{style:{display:"flex",gap:8},children:[i.jsx("button",{type:"button","data-testid":"g7le-property-modal-delete",onClick:a,style:d4,children:o("layout_editor.property_modal.delete_element")}),i.jsx("button",{type:"button","data-testid":"g7le-property-modal-done",onClick:s,style:c4,children:o("layout_editor.property_modal.close")})]})]})]})}const e4={display:"flex",flexDirection:"column",width:420,maxWidth:"92vw"},t4={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:"1px solid #e2e8f0",cursor:"move",userSelect:"none"},n4={border:"none",background:"transparent",fontSize:14,cursor:"pointer",color:"#64748b"},o4={margin:"8px 16px 0",padding:"6px 10px",fontSize:11,background:"#fef3c7",color:"#92400e",borderRadius:6},r4={margin:"8px 16px 0",padding:"6px 10px",fontSize:11,background:"#dbeafe",color:"#1e40af",borderRadius:6},i4={display:"flex",gap:2,padding:"0 12px",borderBottom:"1px solid #e2e8f0",overflowX:"auto"},s4={padding:"8px 10px",fontSize:12,border:"none",borderBottom:"2px solid transparent",background:"transparent",cursor:"pointer",whiteSpace:"nowrap"},a4={padding:16,overflowY:"auto",maxHeight:"60vh"},cg={position:"sticky",top:-16,zIndex:2,background:"#fff",margin:"-16px -16px 0",padding:"6px 16px 0"},ug={fontSize:12,color:"#94a3b8",padding:"16px 0",textAlign:"center"},l4={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderTop:"1px solid #e2e8f0"},d4={padding:"6px 12px",fontSize:12,border:"1px solid #fecaca",borderRadius:6,background:"#fff",color:"#dc2626",cursor:"pointer"},c4={padding:"6px 12px",fontSize:12,border:"none",borderRadius:6,background:"#2563eb",color:"#fff",cursor:"pointer"},Ba="g7le:component-target-picked",Wa="g7le:component-target-pick-request";let u4=1;function p4({value:e,onChange:t,t:n,control:o}){const r=bo(),s=e==null?"":String(e),a=o?.allowManualInput!==!1,l=u.useCallback(()=>{if(typeof window>"u")return;const d=`pick-${u4++}`,p=r.stack[r.stack.length-1]?.id;p&&r.minimize(p,n("layout_editor.target_picker.minimized_hint"));const f=b=>{const g=b.detail;g?.requestId===d&&(window.removeEventListener(Ba,f),p&&r.restore(p),!g.cancelled&&typeof g.id=="string"&&t(g.id))};window.addEventListener(Ba,f),window.dispatchEvent(new CustomEvent(Wa,{detail:{requestId:d}}))},[r,t,n]);return i.jsx("div",{className:"g7le-component-target-picker","data-testid":"g7le-component-target-picker",children:i.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[a?i.jsx("input",{type:"text",className:"g7le-widget g7le-widget--text","data-testid":"g7le-component-target-input",value:s,placeholder:n("layout_editor.target_picker.id_placeholder"),onChange:d=>t(d.target.value===""?void 0:d.target.value),style:{flex:1,minWidth:0,padding:"6px 8px",border:"1px solid #cbd5e1",borderRadius:6,fontSize:13}}):i.jsx("span",{"data-testid":"g7le-component-target-value",style:{flex:1,minWidth:0},children:s||n("layout_editor.target_picker.none")}),i.jsxs("button",{type:"button","data-testid":"g7le-component-target-pick",onClick:l,style:{display:"flex",alignItems:"center",gap:4,padding:"6px 10px",background:"#1e293b",color:"#fff",border:"none",borderRadius:6,cursor:"pointer",fontSize:13,whiteSpace:"nowrap"},children:[i.jsx("span",{"aria-hidden":"true",children:"🎯"}),n("layout_editor.target_picker.select_area")]})]})})}async function f4(e,t,n,o,r=fetch){const s=`/api/admin/templates/${encodeURIComponent(e)}/layout-extensions/${t}`;let a;try{a=await r(s,{headers:Ne(),credentials:"same-origin"})}catch(y){return{kind:"error",message:y instanceof Error?y.message:String(y)}}if(a.status===404)return{kind:"not_found"};if(!a.ok)return{kind:"error",message:`HTTP ${a.status}`};const l=await a.json().catch(()=>null),d=(l&&(l.data||l))??{};let c={};const p=d.content;if(typeof p=="string")try{c=JSON.parse(p)}catch{return{kind:"error",message:"invalid extension content"}}else p&&typeof p=="object"&&(c=p);const f=typeof d.lock_version=="number"?d.lock_version:0,b=Array.isArray(c.injections)?[...c.injections]:[],g=b.findIndex(y=>y&&y.position==="inject_props"&&y.target_id===n);if(g<0)return{kind:"injection_not_found"};b[g]={...b[g],props:o};const m={...c,injections:b};let h;try{h=await r(s,{method:"PUT",headers:Ne({"Content-Type":"application/json"}),credentials:"same-origin",body:JSON.stringify({content:m,expected_lock_version:f})})}catch(y){return{kind:"error",message:y instanceof Error?y.message:String(y)}}const v=await h.json().catch(()=>null);return h.ok?{kind:"success",newLockVersion:typeof v?.data?.lock_version=="number"?v.data.lock_version:f+1}:h.status===409?{kind:"conflict",currentVersion:v?.current_version??-1,yourVersion:v?.your_version??f}:{kind:"error",message:v?.message??`HTTP ${h.status}`}}const pg=new Map;function ja(e,t){pg.set(e,t)}function g4(e){return e?pg.get(e)??null:null}const fg="g7le.clipboard";function gg(){try{return typeof window>"u"||!window.sessionStorage?null:window.sessionStorage}catch{return null}}function h4(e){const t=JSON.parse(JSON.stringify(e)),n=o=>{for(const r of Object.keys(o))r.startsWith("__")&&delete o[r];Array.isArray(o.children)&&o.children.forEach(n)};return n(t),t}function hg(e,t=0){const n=gg();if(!n)return!1;try{const o={node:h4(e),copiedAt:t};return n.setItem(fg,JSON.stringify(o)),!0}catch{return!1}}function y4(){const e=gg();if(!e)return null;try{const t=e.getItem(fg);if(!t)return null;const n=JSON.parse(t);return!n||typeof n.node!="object"||n.node===null?null:JSON.parse(JSON.stringify(n.node))}catch{return null}}const Qo={nw:{width:-1,height:-1},n:{width:0,height:-1},ne:{width:1,height:-1},e:{width:1,height:0},se:{width:1,height:1},s:{width:0,height:1},sw:{width:-1,height:1},w:{width:-1,height:0}};function Ha(e){if(typeof e=="number")return e;if(typeof e=="string"){const t=e.match(/^(-?\d+(?:\.\d+)?)px$/);if(t)return Number(t[1])}return null}function b4(e,t){const n=Array.isArray(e.options)?e.options:[],o=Array.isArray(e.scale)?e.scale:[],r=n.length>0?n.map(l=>l.value):o;if(r.length===0)return;let s=r[0],a=1/0;return r.forEach((l,d)=>{const c=Ha(l)??d*40,p=Math.abs(c-t);p{if(!t)return;const m=Qo[b];if(m.width!==0&&!n||m.height!==0&&!o)return;const h=t.props?.style??{},v=s?.()??null,y=Ha(h.width)??(v?Math.round(v.width):0),_=Ha(h.height)??(v?Math.round(v.height):0);p.current={handle:b,startX:g.clientX,startY:g.clientY,startW:y,startH:_,node:t};const w=m.width!==0&&m.height!==0?"both":m.width!==0?"width":"height";d?.(w);let k=null;const x=S=>{const C=p.current;if(!C)return;const T=r||1,E=(S.clientX-C.startX)/T*Qo[C.handle].width,A=(S.clientY-C.startY)/T*Qo[C.handle].height;let N=C.node;if(Qo[C.handle].width!==0&&n){const D=yg(n,C.startW+E);N=fn(N,n,D)}if(Qo[C.handle].height!==0&&o){const D=yg(o,C.startH+A);N=fn(N,o,D)}k=N,a(N,w)},$=()=>{p.current=null,d?.(null),window.removeEventListener("pointermove",x),window.removeEventListener("pointerup",$),k&&l?.(k,w)};window.addEventListener("pointermove",x),window.addEventListener("pointerup",$)},[t,n,o,r,a,l,d]);return{enabledAxes:c,onHandlePointerDown:f}}const bg=320,mg=1920,_4=1024;function Fa(e){return Number.isFinite(e)?Math.round(Math.max(bg,Math.min(mg,e))):_4}function Ka(e={}){const{state:t,dispatch:n}=Qe(),{previewDevice:o,previewZoom:r,previewCustomWidth:s,previewColorScheme:a}=t,l=o==="custom"?Fa(s):_T(o),d=u.useMemo(()=>{const g=e.availableWidth??l,m=l*r;return r>=1||m<=g?r:Math.min(r,g/l)},[l,r,e.availableWidth]),c=u.useCallback(g=>{n({type:"SET_PREVIEW_DEVICE",device:g})},[n]),p=u.useCallback(g=>{const m=Math.max(.5,Math.min(1,g));n({type:"SET_PREVIEW_ZOOM",zoom:m})},[n]),f=u.useCallback(g=>{n({type:"SET_PREVIEW_CUSTOM_WIDTH",width:Fa(g)})},[n]),b=u.useCallback(g=>{n({type:"SET_PREVIEW_COLOR_SCHEME",scheme:g})},[n]);return{device:o,deviceWidth:l,zoom:r,scale:d,customWidth:Fa(s),setDevice:c,setZoom:p,setCustomWidth:f,colorScheme:a,setColorScheme:b}}const vi="g7le-dnd-handle-";function x4(e){if(typeof e!="string"||!e.startsWith(vi))return null;const t=e.slice(vi.length);return t.length>0?t:null}function w4(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["\\\]]/g,"\\$&")}function k4(e,t,n,o){const r=o?.handleFallback??!1;if(e instanceof HTMLElement){const s=e.closest("[data-editor-path]");if(s)return s;const a=e.closest('[data-testid^="g7le-"]');if(a&&!(a.getAttribute("data-testid")??"").startsWith(vi))return null;if(r){const l=e.closest(`[data-testid^="${vi}"]`);if(l&&t){const d=x4(l.getAttribute("data-testid"));if(d){const c=t.querySelector(`[data-editor-path="${w4(d)}"]`);if(c)return c}}}}if(r&&n&&typeof document<"u"&&typeof document.elementsFromPoint=="function")for(const s of document.elementsFromPoint(n.x,n.y)){const a=s.closest?.("[data-editor-path]");if(a)return a}return null}function S4(e,t,n){if(typeof e=="string"&&e.trim().length>0)return{color:e};const o=typeof n?.color=="string"&&n.color.length>0,r=typeof t=="string"&&t.trim().length>0;return o||r?{}:{color:"#0f172a"}}const C4="#ffffff",$4="#0f172a";function E4(e){const t=e.trim(),n=t.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i);if(n)return[Number(n[1]),Number(n[2]),Number(n[3])];const o=t.replace(/^#/,"");return/^[0-9a-f]{3}$/i.test(o)?[parseInt(o[0]+o[0],16),parseInt(o[1]+o[1],16),parseInt(o[2]+o[2],16)]:/^[0-9a-f]{6}$/i.test(o)?[parseInt(o.slice(0,2),16),parseInt(o.slice(2,4),16),parseInt(o.slice(4,6),16)]:null}function I4(e){if(!e||/transparent/i.test(e))return!1;const t=e.trim().match(/^oklch\(\s*([\d.]+)(%?)/i);if(t)return(t[2]==="%"?Number(t[1])/100:Number(t[1]))>=.62;const n=E4(e);if(!n)return!1;const[o,r,s]=n;return .299*o+.587*r+.114*s>=180}function A4(e,t,n){const o=typeof n?.color=="string"?n.color:null;return I4(e??o??t)?$4:C4}function T4({box:e,initialValue:t,isCustomKey:n,t:o,onCommit:r,onCancel:s,mirrorClassName:a,mirrorStyle:l,nodeEffectiveColor:d,onOpenTranslations:c}){const p=u.useRef(null),f=u.useRef(!1),[b,g]=u.useState(t.trim().length>0),[m,h]=u.useState(null);u.useEffect(()=>{const k=p.current;if(k){k.textContent=t,k.focus();try{const x=window.document.createRange();x.selectNodeContents(k);const $=window.getSelection();$?.removeAllRanges(),$?.addRange(x)}catch{}f.current=!1}},[t]),u.useEffect(()=>{const k=p.current;if(!k||typeof window.getComputedStyle!="function"){h(null);return}try{h(window.getComputedStyle(k).color||null)}catch{h(null)}},[a,l]);const v=()=>(p.current?.textContent??"").trim(),y=()=>{f.current||(f.current=!0,r(v()))},_=()=>{f.current||(f.current=!0,s())},w=k=>{k.key==="Enter"&&!k.shiftKey?(k.preventDefault(),y()):k.key==="Escape"&&(k.preventDefault(),_())};return i.jsxs("div",{className:"g7le-inline-text-editor","data-testid":"g7le-inline-text-editor","data-custom-key":n?"true":"false",style:{position:"absolute",left:e.left,top:e.top,minWidth:Math.max(e.width,60),minHeight:e.height,pointerEvents:"auto",zIndex:1e4},children:[i.jsx("div",{ref:p,role:"textbox","aria-label":o("layout_editor.inline_edit.aria_label"),"aria-multiline":"false","data-testid":"g7le-inline-text-editable",className:a,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!1,onInput:()=>g(v().length>0),onKeyDown:w,onBlur:y,style:{outline:"2px solid #2563eb",outlineOffset:1,borderRadius:3,background:A4(d,m,l),padding:"2px 4px",minHeight:e.height,whiteSpace:"pre-wrap",wordBreak:"break-word",boxShadow:"0 2px 8px rgba(37, 99, 235, 0.25)",...l??{},...S4(d,a,l)}}),i.jsxs("div",{className:"g7le-inline-text-editor__hint","data-testid":"g7le-inline-text-editor-hint",style:{marginTop:2,display:"inline-flex",alignItems:"center",gap:4,whiteSpace:"nowrap"},children:[c?i.jsxs("button",{type:"button","data-testid":"g7le-inline-text-editor-open-translations",onMouseDown:k=>k.preventDefault(),onClick:k=>{k.preventDefault(),k.stopPropagation(),c()},title:o("layout_editor.inline_edit.open_translations"),style:{padding:"2px 8px",fontSize:11,background:n?"#eff6ff":"#f0fdf4",color:n?"#1d4ed8":"#15803d",border:`1px solid ${n?"#bfdbfe":"#bbf7d0"}`,borderRadius:4,display:"inline-flex",alignItems:"center",gap:4,cursor:"pointer",whiteSpace:"nowrap"},children:[i.jsx("span",{"aria-hidden":"true",children:"🌐"}),i.jsx("span",{children:o(n?"layout_editor.inline_edit.existing_key_hint":"layout_editor.inline_edit.new_key_hint")}),i.jsxs("span",{"aria-hidden":"true",style:{opacity:.7},children:["· ",o("layout_editor.inline_edit.open_translations")," ›"]})]}):i.jsx("span",{style:{padding:"2px 6px",fontSize:11,background:n?"#eff6ff":"#f0fdf4",color:n?"#1d4ed8":"#15803d",border:`1px solid ${n?"#bfdbfe":"#bbf7d0"}`,borderRadius:4,display:"inline-flex",alignItems:"center",gap:4,whiteSpace:"nowrap"},children:n?i.jsxs(i.Fragment,{children:["⌐ ",o("layout_editor.inline_edit.existing_key_hint")]}):i.jsxs(i.Fragment,{children:["✎ ",o("layout_editor.inline_edit.new_key_hint")]})}),!b&&i.jsx("span",{"data-testid":"g7le-inline-text-editor-empty-warn",style:{color:"#b91c1c",marginLeft:4},children:o("layout_editor.inline_edit.empty_warning")})]})]})}function D4({box:e,node:t,customKey:n,initialChipValue:o,chipParamLabels:r,onKeyify:s,templateIdentifier:a,locale:l,t:d,candidates:c,onInsertBinding:p,onRemoveBinding:f,onCommit:b,onCancel:g}){const[m,h]=u.useState(null),v=u.useRef(""),[y,_]=u.useState(!1),w=u.useRef(!1),k=u.useRef(null),x=Ft(),$=u.useRef(()=>{}),[S,C]=u.useState(null),[T,E]=u.useState(!1),A=u.useRef(n??null);u.useEffect(()=>{n&&A.current!==n&&(A.current=n)},[n]);const N=u.useMemo(()=>{if(!n&&r)return r;const P={},I=vt(typeof t.text=="string"?t.text:"");for(const L of I?.params??[])P[L.name]=Vt(L.expression);return P},[t.text,n,r]);u.useEffect(()=>{let P=!1;if(!n){const I=o??"";return v.current=I,h(I),()=>{P=!0}}return(async()=>{const I=It(n,l);if(I!==void 0){v.current=I,h(I);return}const L=await cn(a,n);if(P)return;const F=L?.values?.[l]??"";v.current=F,h(F)})(),()=>{P=!0}},[a,n,l,o]);const D=async()=>{if(w.current)return;w.current=!0;const P=m??"";if(P===v.current){b();return}_(!0);let I=A.current;if(!I){if(!s){_(!1),w.current=!1;return}if(I=await s(P),_(!1),!I){w.current=!1;return}A.current=I,b();return}const L=await So(a,I,l,P);if(_(!1),L.kind==="error"){w.current=!1;return}x?.markDirty?.(),b()},B=()=>{w.current||(w.current=!0,g())},M=P=>{C(P)},O=async P=>{if(!(S===null||!p||T)){E(!0);try{const I=A.current;I&&m!==null&&m!==v.current&&(await So(a,I,l,m),v.current=m);const L=await p(S,P);L!==null&&(h(L),v.current=L,x?.markDirty?.())}finally{E(!1),C(null)}}},z=async P=>{if(!(!f||T)){E(!0);try{const I=A.current;I&&m!==null&&m!==v.current&&(await So(a,I,l,m),v.current=m);const L=await f(P);L!==null&&(h(L),v.current=L,x?.markDirty?.())}finally{E(!1)}}},H=P=>{P.key==="Enter"&&!P.shiftKey?(P.preventDefault(),D()):P.key==="Escape"&&(P.preventDefault(),B())};return $.current=()=>{D()},u.useEffect(()=>{const P=L=>{const F=k.current;if(!F)return;const Y=L.target;if(Y&&F.contains(Y))return;const K=Y;K&&K.closest&&K.closest('[data-testid="g7le-inline-toolbar"], .g7le-inline-toolbar')||$.current()},I=k.current?.ownerDocument??document;return I.addEventListener("pointerdown",P,!0),()=>I.removeEventListener("pointerdown",P,!0)},[]),i.jsxs("div",{ref:k,className:"g7le-inline-param-chip-editor","data-testid":"g7le-inline-param-chip-editor",onKeyDown:H,style:{position:"absolute",left:e.left,top:e.top,minWidth:Math.max(e.width,120),pointerEvents:"auto",zIndex:1e4,background:"#fff",border:"2px solid #2563eb",borderRadius:4,boxShadow:"0 2px 8px rgba(37,99,235,0.25)",padding:4},children:[m===null?i.jsx("div",{"data-testid":"g7le-inline-param-chip-loading",style:{fontSize:12,color:"#94a3b8",padding:4},children:d("layout_editor.translation.loading")}):i.jsx(xr,{value:m,onChange:h,t:d,paramLabels:N,testIdSuffix:"inline",onRequestInsert:p?M:void 0,onRemoveChip:f?P=>void z(P):void 0}),S!==null&&p&&i.jsx("div",{"data-testid":"g7le-inline-param-chip-insert-picker",style:{marginTop:4},children:i.jsx($t,{candidates:c??[],t:d,onSelect:P=>void O(P),testIdSuffix:"inline-insert",defaultOpen:!0,floating:!1})}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:4},children:[i.jsx("button",{type:"button","data-testid":"g7le-inline-param-chip-save",disabled:y,onMouseDown:P=>P.preventDefault(),onClick:()=>void D(),style:{fontSize:11,border:"none",borderRadius:6,background:"#2563eb",color:"#fff",padding:"4px 12px",cursor:"pointer"},children:d(y?"layout_editor.translation.saving":"layout_editor.translation.save")}),i.jsx("span",{style:{fontSize:10,color:"#94a3b8"},children:d("layout_editor.translation.placeholder_locked")})]})]})}const z4=["fontWeight","fontBold","fontStyle","fontItalic","textDecoration","textUnderline","textAlign","fontSize","textColor"],N4={fontWeight:"B",fontBold:"B",fontStyle:"I",fontItalic:"I",textDecoration:"U",textUnderline:"U",textAlign:"≡",fontSize:"T",textColor:"A"},M4=[["fontWeight","fontBold"],["fontItalic","fontStyle"],["textUnderline","textDecoration"]];function vg({node:e,spec:t,t:n,onApplyControl:o,box:r,scope:s=Wt}){const a=typeof e.name=="string"?e.name:"",l=ji(t,a),d=Array.isArray(l?.styleControls)?l.styleControls:[];let c=z4.filter(p=>d.includes(p)&&Ct(t,p)!==null);for(const p of M4){const f=p.filter(b=>c.includes(b));if(f.length>1){const b=f[0];c=c.filter(g=>!p.includes(g)||g===b)}}return c.length===0?null:i.jsx("div",{className:"g7le-inline-toolbar","data-testid":"g7le-inline-toolbar",role:"toolbar","aria-label":n("layout_editor.inline_edit.toolbar_label"),style:{position:"absolute",left:r.left,top:r.top-40,display:"inline-flex",gap:2,padding:4,background:"#0f172a",borderRadius:8,boxShadow:"0 4px 12px rgba(15, 23, 42, 0.35)",pointerEvents:"auto",zIndex:10001},children:c.map(p=>i.jsx(P4,{controlKey:p,node:e,spec:t,t:n,scope:s,onApplyControl:o},p))})}const L4={fontWeight:"bold",fontBold:"bold",fontStyle:"italic",fontItalic:"italic",textDecoration:"underline",textUnderline:"underline"};function _g(e,t){const n=r=>(r.split(/[-\s]/).pop()??r)===t||r===t;return e.find(r=>{const s=typeof r.value=="string"?r.value:"",a=Array.isArray(r.apply?.tokens)?r.apply.tokens:[];return n(s)||a.some(n)})?.value}function P4({controlKey:e,node:t,spec:n,t:o,scope:r,onApplyControl:s}){const[a,l]=u.useState(!1),d=Ct(n,e);if(!d)return null;const c=d.options,p=Array.isArray(c),f=zo(t,d,r),b=L4[e],g=b&&Array.isArray(c)?_g(c,b):void 0,m=!b,h=g!==void 0?f.value===g:p&&f.matched&&f.value!==void 0&&f.value!=="",v=o(`layout_editor.inline_edit.format.${e}`),y=x=>typeof x.label=="string"?x.label.startsWith("$t:")?o(x.label.slice(3)):x.label:String(x.value??""),_=()=>{s(e,x=>{const $=zo(x,d,r),S=Array.isArray(c)?_g(c,b):void 0,C=S!==void 0&&$.value===S?void 0:S;return fn(x,d,C,r)})},w=x=>{s(e,$=>{const C=zo($,d,r).value===x?void 0:x;return fn($,d,C,r)}),l(!1)},k=x=>{if(x.preventDefault(),x.stopPropagation(),!m&&Array.isArray(c)){_();return}l($=>!$)};return i.jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[i.jsxs("button",{type:"button","data-testid":`g7le-inline-format-${e}`,"data-active":h?"true":"false","aria-label":v,"aria-pressed":p?h:void 0,title:v,onMouseDown:x=>x.preventDefault(),onClick:k,style:{display:"inline-flex",alignItems:"center",gap:5,height:28,padding:"0 9px",fontSize:12,border:"none",borderRadius:5,cursor:"pointer",background:h?"#2563eb":"transparent",color:"#ffffff",whiteSpace:"nowrap"},children:[i.jsx("span",{"aria-hidden":"true",style:{fontWeight:e==="fontWeight"||e==="fontBold"?700:600,fontStyle:e==="fontStyle"||e==="fontItalic"?"italic":"normal",textDecoration:e==="textDecoration"||e==="textUnderline"?"underline":"none"},children:N4[e]}),i.jsx("span",{children:v}),m&&i.jsx("span",{"aria-hidden":"true",style:{fontSize:9,opacity:.8},children:"▾"})]}),m&&a&&i.jsx("div",{"data-testid":`g7le-inline-popover-${e}`,role:"listbox",onMouseDown:x=>x.preventDefault(),style:{position:"absolute",top:32,left:0,minWidth:140,maxHeight:240,overflowY:"auto",background:"#0f172a",border:"1px solid #334155",borderRadius:8,boxShadow:"0 8px 24px rgba(15,23,42,0.45)",padding:4,zIndex:10002},children:Array.isArray(c)&&c.length>0?c.map((x,$)=>{const S=f.value===x.value;return i.jsxs("button",{type:"button",role:"option","aria-selected":S,"data-testid":`g7le-inline-option-${e}-${String(x.value??$)}`,onMouseDown:C=>C.preventDefault(),onClick:C=>{C.preventDefault(),C.stopPropagation(),w(x.value)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 8px",fontSize:12,textAlign:"left",border:"none",borderRadius:5,cursor:"pointer",background:S?"#2563eb":"transparent",color:"#ffffff"},children:[typeof x.swatch=="string"&&i.jsx("span",{"aria-hidden":"true",style:{width:14,height:14,borderRadius:3,background:x.swatch,border:"1px solid rgba(255,255,255,0.3)"}}),i.jsx("span",{children:y(x)}),S&&i.jsx("span",{"aria-hidden":"true",style:{marginLeft:"auto"},children:"✓"})]},String(x.value??$))}):i.jsx(O4,{testid:`g7le-inline-freeinput-${e}`,placeholder:o(`layout_editor.inline_edit.prompt.${e}`),initial:typeof f.value=="string"?f.value:"",onSubmit:x=>{s(e,$=>fn($,d,x,r)),l(!1)}})})]})}function O4({testid:e,placeholder:t,initial:n,onSubmit:o}){const[r,s]=u.useState(n);return i.jsx("input",{type:"text","data-testid":e,value:r,placeholder:t,autoFocus:!0,onMouseDown:a=>a.stopPropagation(),onChange:a=>s(a.currentTarget.value),onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),o(r.trim()))},style:{width:130,padding:"6px 8px",fontSize:12,border:"1px solid #334155",borderRadius:5,background:"#1e293b",color:"#ffffff"}})}function B4(e){const{frameEl:t,manifest:n,nesting:o,componentPalette:r,spec:s=null,permissionCandidates:a,resolveRouteMatch:l,onNavigateToDestination:d,onSessionAddedPathsChange:c,onEditProps:p}=e,{state:f,dispatch:b}=Qe(),{t:g}=tt(),m=Ka(),h=u.useCallback((W,J)=>{const R=window.G7Core;if(R&&typeof R.t=="function"){const de=R.t(W,J);if(de&&de!==W&&!de.startsWith("$t:"))return de}return g(W,J)},[g]),v=Ft(),y=L7(50),_=bo(),w=u.useRef([]),k=u.useMemo(()=>v?.document?.raw?.components??[],[v?.document?.raw?.components]),x=u.useMemo(()=>k.length===0?null:{children:k},[k]),$=u.useMemo(()=>{if(f.editMode!=="extension")return;const W=/^__extension__\/(\d+)/.exec(f.selectedRoute?.path??"");return W?Number(W[1]):void 0},[f.editMode,f.selectedRoute?.path]),S=u.useMemo(()=>{if(f.editMode==="iteration_item"){const W=v?.document?.iterationContext?.sourceIndexPath;return Array.isArray(W)&&W.length>0?W:null}if(f.editMode==="modal"){const W=v?.document?.modalContext?.editIndexPath;return Array.isArray(W)&&W.length>0?W:null}return null},[f.editMode,v?.document?.iterationContext?.sourceIndexPath,v?.document?.modalContext?.editIndexPath]),C=$7({rootNode:x,editMode:f.editMode,currentExtensionId:$,editableRootPath:S,pathParser:Re,resolveRouteMatch:l}),[T,E]=u.useState(null),[A,N]=u.useState(null),[D,B]=u.useState(null),M=u.useRef(null);M.current=D;const[O,z]=u.useState(null),H=u.useRef(null),P=u.useRef(null);P.current=C.selectedPath;const I=qb(),[L,F]=u.useState(null),Y=u.useCallback(W=>{if(!t)return;const J=Re(W);if(!J)return;const R={children:ze.current.components},de=Be(R,J),ye=I.classify(de);if(!ye.editable){Et({op:"inline_edit_blocked_binding",sourceState:ye.sourceState,componentPath:at(J),timestamp:Date.now()});return}const we=fo(t,W);if(!we)return;const Te=de?.props??{},ke=wg(t,W);F({path:J,domPath:W,box:we,initialValue:ye.displayValue,isCustomKey:ye.sourceState==="custom_key",isParamKey:ye.isParamKey===!0,customKey:ye.customKey,chipValue:ye.chipValue,chipParamLabels:ye.chipParamLabels,mirrorClassName:typeof Te.className=="string"?Te.className:void 0,mirrorStyle:Te.style??void 0,nodeEffectiveColor:ke}),Et({op:"inline_edit_enter",sourceState:ye.sourceState,componentPath:at(J),timestamp:Date.now()})},[t,I]),K=u.useCallback(()=>{if(!t){E(null),N(null);return}N(fo(t,C.selectedPath)),E(fo(t,C.hoverPath))},[t,C.selectedPath,C.hoverPath,k]);u.useEffect(()=>{if(K(),typeof window<"u"&&typeof window.requestAnimationFrame=="function"){const W=window.requestAnimationFrame(()=>K());return()=>window.cancelAnimationFrame(W)}},[K]),u.useEffect(()=>{if(t)return zp(K,t)},[t,K]);const X=u.useCallback((W,J)=>{if(typeof window>"u")return;window.dispatchEvent(new CustomEvent(Ba,{detail:J===null?{requestId:W,cancelled:!0}:{requestId:W,id:J}})),B(null),z(null);const R=H.current;R?C.handleSelect("",{dataset:{editorPath:R}}):C.clearSelection(),H.current=null},[C]);u.useEffect(()=>{if(typeof window>"u")return;const W=J=>{const R=J.detail;if(typeof R?.requestId!="string")return;const de=M.current;de&&de!==R.requestId&&X(de,null),H.current=P.current,B(R.requestId)};return window.addEventListener(Wa,W),()=>window.removeEventListener(Wa,W)},[X]),u.useEffect(()=>{if(!D)return;const W=J=>{J.key==="Escape"&&(J.preventDefault(),X(D,null))};return window.addEventListener("keydown",W,!0),()=>window.removeEventListener("keydown",W,!0)},[D,X]),u.useEffect(()=>{if(!t)return;const W=f.editMode==="iteration_item"||f.editMode==="modal",J=(_e,Ie)=>k4(_e,t,Ie?{x:Ie.clientX,y:Ie.clientY}:void 0,{handleFallback:W}),R=_e=>{const Ie=_e.dataset.editorPath??"",He=Ie?Re(Ie):null,Nt={children:ze.current.components},gt=He?Be(Nt,He):null,Mt=gt&&typeof gt.props?.id=="string"?gt.props.id:typeof gt?.id=="string"?gt.id:"";return Mt.startsWith("auto_")?"":Mt},de=_e=>{const Ie=J(_e.target,_e);if(!Ie)return;const He=M.current;if(He){_e.preventDefault(),_e.stopPropagation();const Nt=R(Ie);Nt&&X(He,Nt);return}_e.preventDefault(),_e.stopPropagation(),C.handleSelect(Ie.dataset.editorId??"",{currentTarget:Ie,dataset:Ie.dataset})},ye=_e=>{const Ie=J(_e.target,_e);if(M.current){if(!Ie){z(null);return}const He=fo(t,Ie.dataset.editorPath??null);if(!He){z(null);return}z({box:He,hasId:R(Ie)!==""});return}if(!Ie){C.handleHover(null,{});return}C.handleHover(Ie.dataset.editorId??"",{currentTarget:Ie,dataset:Ie.dataset})},we=()=>{if(M.current){z(null);return}C.handleHover(null,{})},Te=_e=>{const Ie=J(_e.target,_e);if(!Ie)return;const He=Ie.dataset.editorPath??"";He&&(_e.preventDefault(),_e.stopPropagation(),Y(He))},ke=t.parentElement??t;return ke.addEventListener("click",de,!0),ke.addEventListener("mousemove",ye,!0),ke.addEventListener("mouseleave",we,!0),ke.addEventListener("dblclick",Te,!0),()=>{ke.removeEventListener("click",de,!0),ke.removeEventListener("mousemove",ye,!0),ke.removeEventListener("mouseleave",we,!0),ke.removeEventListener("dblclick",Te,!0)}},[t,C,Y,f.editMode,X]);const Z=u.useMemo(()=>{const W=C.selectedPath;if(!W)return null;const J=W.match(/^(.*)\.children\.\d+$/);return J?J[1]:null},[C.selectedPath]),ae=u.useCallback(()=>{Z&&C.handleSelect("",{dataset:{editorPath:Z}})},[Z,C]),oe=u.useMemo(()=>!t||!C.selectedPath?null:t.querySelector(`[data-editor-path="${an(C.selectedPath)}"]`),[t,C.selectedPath]),G=u.useMemo(()=>C.selectedPath?Re(C.selectedPath):null,[C.selectedPath]),ee=u.useMemo(()=>{if(!G)return null;const W=G.find(et);if(!W)return null;const{i18nKey:J,raw:R}=SC(W.responsive);return J?g(J):g("layout_editor.overlay.branch_custom",{range:R})},[G,g]),ge=u.useMemo(()=>C.selectedPath?C.selectedIsIteration&&C.selectedIterationSourcePath?C.selectedIterationSourcePath:C.selectedPath:null,[C.selectedPath,C.selectedIsIteration,C.selectedIterationSourcePath]),V=u.useMemo(()=>ge?Re(ge):null,[ge]),te=u.useMemo(()=>!t||!ge?null:t.querySelector(`[data-editor-path="${an(ge)}"]`),[t,ge]),be=u.useMemo(()=>{if(te?.parentElement)return te.parentElement;if(!t||!ge)return null;const W=ge.match(/^(.*)\.children\.\d+$/);return W?t.querySelector(`[data-editor-path="${an(W[1])}"]`):null},[te,t,ge]),Ee=u.useMemo(()=>{const W=C.selectedNode;return W&&(typeof W.name=="string"?W.name:typeof W.type=="string"?W.type:"")||null},[C.selectedNode]),De=u.useMemo(()=>{if(C.selectedLockKind!=="extension")return null;const W=C.selectedNode?.__source;if(!W||W.kind!=="extension")return null;const J=W.extensionName?.trim(),R=W.extensionIdentifier?.trim();return J&&R?`${J} (${R})`:J||R||W.extensionSourceType||null},[C.selectedLockKind,C.selectedNode]),Se=z7({parentEl:be,selectedPath:V,selectedEl:te}),Ue=u.useMemo(()=>!t||!ge||ge===C.selectedPath?A:fo(t,ge),[t,ge,A,C.selectedPath,k]),Me=u.useRef(null),Oe=u.useCallback(()=>{const W=Me.current;W&&(_.close(W),Me.current=null)},[_]),Ye=u.useRef(()=>{}),ze=u.useRef({manifest:n,nesting:o,componentPalette:r,components:k});ze.current={manifest:n,nesting:o,componentPalette:r,components:k};const Xe=u.useCallback(W=>{const J=W.insertion?.parentPath??[],R=W.insertion?.index??0,de=ze.current,ye=xg(de.components,J);Oe();const we=_.open({ariaLabel:h("layout_editor.palette.title"),width:880,maxHeightRatio:.82,content:u.createElement(Nf,{manifest:de.manifest,nesting:de.nesting,componentPalette:de.componentPalette??null,targetParentPath:J,targetContainerName:ye,onInsert:(Te,ke,_e)=>{Ye.current(Te,ke,_e)},insertionIndex:R,onClose:()=>Oe(),editorTemplateId:f.templateIdentifier,editorLocale:f.locale}),onClose:()=>{Me.current=null}});Me.current=we},[_,Oe]),ve=u.useMemo(()=>{if(!f.isPaletteOpen)return null;if(!G)return{parentPath:[],index:k.length};if(C.selectedLockKind!=="none"){const de=V;return!de||de.length===0?{parentPath:[],index:k.length}:{parentPath:de.slice(0,-1),index:(de[de.length-1]??0)+1}}const J=C.selectedNode,R=Array.isArray(J?.children)?J.children.length:0;return MI(J?.name,R,G,o,k.length)},[f.isPaletteOpen,G,V,C.selectedLockKind,C.selectedNode,k.length,o]),qe=u.useCallback(()=>{b({type:"SET_PALETTE_OPEN",open:!1})},[b]),We=u.useRef(null);u.useEffect(()=>{if(!f.isPaletteOpen){const ye=We.current;ye&&(_.close(ye),We.current=null);return}if(!ve||We.current)return;const W=ve,J=ze.current,R=xg(J.components,W.parentPath),de=_.open({ariaLabel:h("layout_editor.palette.title"),width:880,maxHeightRatio:.82,content:u.createElement(Nf,{manifest:J.manifest,nesting:J.nesting,componentPalette:J.componentPalette??null,targetParentPath:W.parentPath,targetContainerName:R,onInsert:(ye,we,Te)=>{Ye.current(ye,we,Te),qe()},insertionIndex:W.index,onClose:()=>qe(),editorTemplateId:f.templateIdentifier,editorLocale:f.locale}),onClose:()=>{We.current=null,b({type:"SET_PALETTE_OPEN",open:!1})}});We.current=de},[f.isPaletteOpen,ve,_,qe,b]);const ce=u.useRef({layoutName:null,pushed:!1});u.useEffect(()=>{const W=v?.document?.layoutName??null;if(!W){ce.current={layoutName:null,pushed:!1};return}ce.current.layoutName!==W&&(y.clear(),y.push({actionKind:"inline_text_edit",label:"baseline",snapshot:k}),ce.current={layoutName:W,pushed:!0})},[v?.document?.layoutName,k,y]);const q=u.useRef(0);u.useEffect(()=>{const W=v?.saveSuccessCounter??0;W!==q.current&&(q.current=W,W!==0&&(y.clear(),y.push({actionKind:"inline_text_edit",label:"save_baseline",snapshot:k}),w.current=[],c?.([])))},[v?.saveSuccessCounter,k,y,c]);const ie=u.useRef(0);u.useEffect(()=>{const W=v?.reloadCounter??0;W!==ie.current&&(ie.current=W,W!==0&&(ce.current={layoutName:null,pushed:!1},w.current=[],c?.([])))},[v?.reloadCounter,c]);const se=u.useCallback((W,J,R)=>{if(!v)return;let de=[];v.patchLayout(ke=>{const _e={children:ke},Ie=Va(_e,J),He=R<0?Array.isArray(Ie?.children)?Ie.children.length:0:R,gt=ts(_e,J,He,W).children??[];return de=gt,gt}),y.push({actionKind:"insert",label:`insert ${W.name??W.type??""}`,snapshot:de});const ye=Va({children:de},J),we=R<0?Array.isArray(ye?.children)?ye.children.length-1:0:R,Te=at([...J,we]);if(w.current=[...w.current,Te],c?.(w.current),t){const ke=`[data-editor-path="${an(Te)}"]`,_e=()=>{const Ie=t.querySelector(ke);Ie&&typeof Ie.scrollIntoView=="function"&&Ie.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(()=>window.requestAnimationFrame(_e)):setTimeout(_e,32)}},[v,y,c,t]);Ye.current=se;const me=u.useCallback(()=>{if(!v||!C.selectedNode||!G)return;const W=os(C.selectedNode);let J=[];v.patchLayout(R=>{const de={children:R},ye=G.slice(0,-1),we=G[G.length-1]??0,ke=ts(de,ye,we+1,W).children??[];return J=ke,ke}),y.push({actionKind:"insert",label:"duplicate",snapshot:J})},[v,C.selectedNode,G,y]),Ce=u.useCallback(()=>{if(!v||!G)return;let W=[];v.patchLayout(J=>{const ye=ns({children:J},G).children??[];return W=ye,ye}),y.push({actionKind:"remove",label:"remove",snapshot:W}),C.clearSelection()},[v,G,y,C]),$e=u.useMemo(()=>{if(!C.selectedNode||!G||G.some(et))return null;const W=C.selectedNode;if(!Array.isArray(W.children))return null;const J=kC(f.previewDevice,W,f.previewCustomWidth);return{mode:J.mode,key:J.key,sourceKey:J.sourceKey}},[C.selectedNode,G,f.previewDevice,f.previewCustomWidth]),U=u.useCallback(()=>{if(!v||!G||$e?.mode!=="separate")return;const W=$e.key,J=$e.sourceKey;let R=[];v.patchLayout(de=>(R=Pb({children:de},G,W,J).children??[],R)),y.push({actionKind:"insert",label:"separate_branch",snapshot:R})},[v,G,$e,y]),ue=u.useCallback(()=>{if(!v||!G||$e?.mode!=="merge")return;const W=$e.key;let J=[];v.patchLayout(R=>(J=Ob({children:R},G,W).children??[],J)),y.push({actionKind:"remove",label:"merge_branch",snapshot:J})},[v,G,$e,y]),fe=u.useCallback(W=>{switch(W){case"mobile":return g("layout_editor.context_menu.device_mobile");case"portable":return g("layout_editor.context_menu.device_portable");case"tablet":return g("layout_editor.context_menu.device_tablet");case"desktop":return g("layout_editor.context_menu.device_desktop");default:return g("layout_editor.context_menu.device_custom",{range:W})}},[g]),xe=u.useMemo(()=>{if(!$e)return null;const W=fe($e.key);return{separate:g("layout_editor.context_menu.separate_branch_device",{device:W}),merge:g("layout_editor.context_menu.merge_branch_device",{device:W})}},[$e,g,fe]),he=u.useMemo(()=>{if(!C.selectedNode||!G)return[];if(G.some(et))return[];const W=Yr(f.previewDevice,C.selectedNode,f.previewCustomWidth);return vT(C.selectedNode,W).map(J=>({key:J,label:fe(J)}))},[C.selectedNode,G,f.previewDevice,f.previewCustomWidth,fe]),j=u.useCallback(W=>{if(W==="desktop"||W==="tablet"||W==="mobile"||W==="portable"){m.setDevice(W);return}m.setDevice(W)},[m]),ne=u.useCallback(()=>{C.selectedNode&&hg(C.selectedNode)},[C.selectedNode]),pe=u.useCallback(()=>{C.selectedNode&&(hg(C.selectedNode),Ce())},[C.selectedNode,Ce]),Q=u.useCallback(()=>{if(!v)return;const W=y4();if(!W)return;const J=os(W);if(G&&G.length>0){const R=G.slice(0,-1),de=(G[G.length-1]??0)+1;se(J,R,de)}else se(J,[],k.length)},[v,G,se,k.length]),le=u.useCallback((W,J)=>{y.push({actionKind:"move",label:J,snapshot:W})},[y]),Ae=u.useCallback(()=>{if(C.selectedNavAffordance==="route_in_tree"&&C.selectedNavTargetPath){if(d){d(C.selectedNavTargetPath);return}b({type:"SELECT_ROUTE",route:{path:C.selectedNavTargetPath,layoutName:null}})}},[C.selectedNavAffordance,C.selectedNavTargetPath,d,b]),dt=u.useCallback(()=>{const W=Mb(C.selectedBaseLayout,f.selectedRoute?.layoutName);W&&b({type:"ENTER_BASE_EDIT",layoutName:W})},[C.selectedBaseLayout,f.selectedRoute?.layoutName,b]),pt=u.useCallback(()=>{const W=C.selectedNode?.__source?.extensionId;W!=null&&b({type:"ENTER_EXTENSION_EDIT",extensionId:String(W)})},[C.selectedNode,b]),ot=u.useCallback(()=>{const W=C.selectedIterationSourcePath;W&&b({type:"ENTER_ITERATION_ITEM_EDIT",sourcePath:W})},[C.selectedIterationSourcePath,b]),Le=u.useRef(null),je=u.useRef(null),Je=u.useRef(null),Tt=u.useRef({colorScheme:"base",breakpoint:"base"}),Dt=Le.current!==null?_.stack.some(W=>W.id===Le.current):!1,zt=u.useMemo(()=>Od(f.routeTree,h),[f.routeTree,h]),xn=u.useMemo(()=>Bd(v?.document?.raw),[v?.document?.raw]),wn=u.useMemo(()=>Wd(s),[s?.states]),Zt=u.useMemo(()=>{const W=v?.document?.raw,J=Lf(W?.components),R=W?.initIsolated,de=R&&typeof R=="object"&&!Array.isArray(R)?Object.keys(R):[];return $A(J,de)},[v?.document?.raw]),Hn=u.useMemo(()=>{const W=v?.document?.raw;return Lf(W?.components).map(J=>J.scopeId).filter(J=>typeof J=="string"&&J.length>0)},[v?.document?.raw]),ln=Pd({raw:v?.document?.raw,spec:s}),Di=u.useCallback((W,J)=>{if(!v)return;const R={children:ze.current.components},de=Be(R,W);if(!de)return;Tt.current={colorScheme:f.previewColorScheme==="dark"?"dark":"base",breakpoint:Yr(f.previewDevice,de,f.previewCustomWidth)};const ye=t?.getBoundingClientRect(),we=A&&ye?{left:ye.left+A.left,top:ye.top+A.top,width:A.width,height:A.height}:void 0,Te=oe,ke=W.find(et),_e=ke?fe(ke.responsive):null,Ie=W.filter(kn=>typeof kn=="number"),He=bb({children:ze.current.components},Ie,mb(ln)),Nt=He.length>0?[...Ki({iterationVars:He}),...ln]:ln,gt=(kn,PM)=>u.createElement(RT,{key:`pem-${at(je.current??[])}`,node:kn,spec:s,manifest:ze.current.manifest,t:h,permissionCandidates:a,pageCandidates:zt,dataSourceCandidates:xn,stateKeyCandidates:wn,bindingCandidates:Nt,liveElement:Te,templateIdentifier:f.templateIdentifier,initialTab:PM,branchLabel:_e,isolatedScopeIdCandidates:Zt,usedScopeIds:Hn,onSaveInjectedProps:async(mt,Sn)=>{const zi=typeof kn.id=="string"?kn.id:"",Fn=await f4(f.templateIdentifier,mt,zi,Sn);if(st({op:"save",layoutName:`extension:${mt}`,editMode:f.editMode,saveTarget:"layout_extension",endpoint:`/api/admin/templates/${f.templateIdentifier}/layout-extensions/${mt}`,isDirty:!0,timestamp:Date.now()}),Fn.kind!=="success")throw new Error(Fn.kind==="conflict"?h("layout_editor.save.conflict"):Fn.kind==="injection_not_found"?"injection not found":Fn.kind==="not_found"?"extension not found":Fn.message??"save failed")},scope:Tt.current,onScopeChange:mt=>{Tt.current=mt;const Sn=Le.current;Sn&&_.open({id:Sn,ariaLabel:h("layout_editor.property_modal.title"),width:420,draggable:!0,avoidRect:we,content:gt(kn),onClose:()=>{Le.current=null,je.current=null}})},onPatchNode:mt=>{let Sn=[];v.patchLayout(Fn=>(Sn=Ot({children:Fn},W,()=>mt).children??[],Sn)),y.push({actionKind:"inline_text_edit",label:"edit_props",snapshot:Sn}),dr({source:"style_control",componentPath:at(W),componentName:typeof mt.name=="string"?mt.name:null,patchKey:null,timestamp:Date.now()});const zi=Le.current;zi&&_.open({id:zi,ariaLabel:h("layout_editor.property_modal.title"),width:420,draggable:!0,avoidRect:we,content:gt(mt),onClose:()=>{Le.current=null,je.current=null}})},onDelete:()=>{const mt=Le.current;mt&&_.close(mt),Ce()},onClose:()=>{const mt=Le.current;mt&&_.close(mt)}});je.current=W;const Mt=_.open({ariaLabel:h("layout_editor.property_modal.title"),width:420,draggable:!0,avoidRect:we,content:gt(de,J),onClose:()=>{Le.current=null,je.current=null,Je.current=null}});Le.current=Mt,Je.current=kn=>{_.open({id:Mt,ariaLabel:h("layout_editor.property_modal.title"),width:420,draggable:!0,avoidRect:we,content:gt(kn),onClose:()=>{Le.current=null,je.current=null,Je.current=null}})}},[v,s,h,a,zt,xn,wn,ln,oe,y,_,Ce,t,A,f.previewColorScheme,f.previewDevice,f.previewCustomWidth,fe]);u.useEffect(()=>{const W=Je.current,J=je.current;if(!W||!J)return;const R={children:ze.current.components},de=Be(R,J);de?W(de):Le.current&&_.close(Le.current)},[k]);const vM=()=>{if(!Dt)return null;const J={position:"absolute",background:"rgba(15, 23, 42, 0.45)",pointerEvents:"auto",zIndex:W7},R=ke=>{ke.preventDefault(),ke.stopPropagation()};if(!A)return i.jsx("div",{"data-testid":"g7le-edit-lock-full",onClick:R,onMouseMove:R,style:{...J,inset:0}});const{left:de,top:ye,width:we,height:Te}=A;return i.jsxs("div",{"data-testid":"g7le-edit-lock",style:{position:"absolute",inset:0,pointerEvents:"none"},children:[i.jsx("div",{"data-testid":"g7le-edit-lock-top",onClick:R,onMouseMove:R,style:{...J,left:0,top:0,right:0,height:Math.max(0,ye)}}),i.jsx("div",{"data-testid":"g7le-edit-lock-bottom",onClick:R,onMouseMove:R,style:{...J,left:0,top:ye+Te,right:0,bottom:0}}),i.jsx("div",{"data-testid":"g7le-edit-lock-left",onClick:R,onMouseMove:R,style:{...J,left:0,top:ye,width:Math.max(0,de),height:Te}}),i.jsx("div",{"data-testid":"g7le-edit-lock-right",onClick:R,onMouseMove:R,style:{...J,left:de+we,top:ye,right:0,height:Te}})]})},wl=u.useCallback(()=>{if(G&&$p(C.selectedLockKind)){if(p&&C.selectedPath){p(C.selectedPath);return}Di(G)}},[G,C.selectedPath,C.selectedLockKind,p,Di]),{scale:kl}=m,Sl=typeof C.selectedNode?.name=="string"?C.selectedNode.name:"",Uh=s?.componentCapabilities?.[Sl]??null,qh=Array.isArray(Uh?.styleControls)?Uh.styleControls:[],_M=qh.includes("width")?Ct(s,"width"):null,xM=qh.includes("height")?Ct(s,"height"):null,wM=u.useCallback((W,J)=>{if(!v||!G)return;let R=[];v.patchLayout(de=>(R=Ot({children:de},G,()=>W).children??[],R)),dr({source:"resize",componentPath:at(G),componentName:Sl||null,patchKey:J==="height"?"height":"width",resizeAxis:J,timestamp:Date.now()})},[v,G,Sl]),kM=u.useCallback((W,J)=>{if(!v||!G)return;let R=[];v.patchLayout(de=>(R=Ot({children:de},G,()=>W).children??[],R)),y.push({actionKind:"inline_text_edit",label:`resize ${J}`,snapshot:R})},[v,G,y]),SM=u.useCallback(()=>{if(!oe)return null;const W=oe.getBoundingClientRect(),J=kl||1;return{width:W.width/J,height:W.height/J}},[oe,kl]),lr=v4({node:C.selectedNode,widthControl:_M,heightControl:xM,scale:kl,measureStartSize:SM,onResize:wM,onResizeEnd:kM}),CM=u.useCallback((W,J)=>{lr.onHandlePointerDown(W,J)},[lr]),Cl=u.useCallback(()=>{const W=y.undo();!W||!v||v.setLayoutComponents(W.snapshot)},[y,v]),$l=u.useCallback(()=>{const W=y.redo();!W||!v||v.setLayoutComponents(W.snapshot)},[y,v]);O7({onUndo:Cl,onRedo:$l});const $M=u.useMemo(()=>({copy:ne,cut:pe,paste:Q,delete:Ce,openProps:wl,selectParent:Z?ae:void 0,deselect:C.clearSelection}),[ne,pe,Q,Ce,wl,Z,ae,C.clearSelection]);lp({handlers:$M,hasSelection:!!C.selectedPath}),u.useEffect(()=>(window.__g7LayoutEditorHasSelection=!!C.selectedPath,()=>{try{delete window.__g7LayoutEditorHasSelection}catch{}}),[C.selectedPath]),u.useEffect(()=>(window.__g7LayoutEditorHistory={undo:Cl,redo:$l,canUndo:y.canUndo,canRedo:y.canRedo},()=>{try{delete window.__g7LayoutEditorHistory}catch{}}),[Cl,$l,y.canUndo,y.canRedo]);const EM=u.useCallback(W=>{const J=L;F(null),J&&(async()=>{if((await I.commit(J.path,W)).kind==="created"&&v){const de=v.document?.raw?.components??[];y.push({actionKind:"inline_text_edit",label:"inline_create_key",snapshot:de})}})()},[L,I,v,y]),Gh=u.useCallback(()=>{const W=L;F(null),I.trackCancel(W?.path??null)},[L,I]),IM=u.useCallback(()=>{F(null)},[]),AM=u.useCallback(async W=>{const J=L;if(!J)return null;const R=await I.keyifyChipValue(J.path,W);if(R.kind!=="created"||!R.translationKey)return null;const de=v?.document?.raw?.components??[];return y.push({actionKind:"inline_text_edit",label:"inline_keyify_chip",snapshot:de}),R.translationKey},[L,I,v,y]),TM=u.useCallback(()=>{const W=L;W&&(F(null),C.handleSelect("",{dataset:{editorPath:W.domPath}}),Di(W.path,"translation"))},[L,C,Di]),wt=u.useMemo(()=>{if(!L)return null;const W=v?.document?.raw?.components??k;return Be({children:W},L.path)},[L,v?.document,k]),DM=u.useCallback(async(W,J)=>{const R=L;if(!v||!R)return null;const de=typeof wt?.text=="string"?wt.text:"";let ye;if(R.isParamKey)ye=await Cr(f.templateIdentifier,f.locale,de,W,J.sourceId,J.path,"scalar");else{const He=Nt=>Nt.replace(/\$t:[a-zA-Z0-9._-]+/g,gt=>{const Mt=h(gt.slice(3));return Mt&&Mt!==gt.slice(3)&&!Mt.startsWith("$t:")?Mt:""}).replace(/\s+/g," ").trim();ye=await us(f.templateIdentifier,f.selectedRoute?.layoutName??null,f.locale,de,W,J.sourceId,J.path,"scalar",He,h)}if(ye.kind==="error")return null;const we=R.path;let Te=[];v.patchLayout(He=>(Te=Ot({children:He},we,Mt=>({...Mt,text:ye.text})).children??[],Te)),y.push({actionKind:"inline_text_edit",label:"inline_insert_binding",snapshot:Te});const ke=ye.kind==="ok"&&"key"in ye?ye.key:void 0;!R.isParamKey&&ke&&F(He=>He&&He.path===we?{...He,isParamKey:!0,customKey:ke,chipValue:void 0,chipParamLabels:void 0}:He);try{window.dispatchEvent(new CustomEvent(kt,{detail:{templateIdentifier:f.templateIdentifier,locale:f.locale}}))}catch{}const _e=vt(ye.text),Ie=R.customKey??_e?.key??"";return Ie?It(Ie,f.locale)??null:null},[v,L,wt,f.templateIdentifier,f.locale,f.selectedRoute,y,h]),zM=u.useCallback(async W=>{const J=L;if(!v||!J)return null;const R=typeof wt?.text=="string"?wt.text:"",de=vt(R),ye=J.customKey??de?.key??null,we=vo(R,W),Te=J.path;let ke=[];return v.patchLayout(_e=>(ke=Ot({children:_e},Te,Nt=>({...Nt,text:we})).children??[],ke)),y.push({actionKind:"inline_text_edit",label:"inline_remove_binding",snapshot:ke}),ye&&await $r(f.templateIdentifier,ye,W,f.locale),ye?It(ye,f.locale)??null:null},[v,L,wt,f.templateIdentifier,f.locale,y]),[El,Yh]=u.useState({}),NM=["fontSize","color","fontStyle","textDecoration","textAlign","letterSpacing","lineHeight","fontFamily"];u.useEffect(()=>{if(!L||!t||typeof MutationObserver>"u"){Yh({});return}const W=`[data-editor-path="${an(L.domPath)}"]`,J=()=>{const ye=t.querySelector(W);if(!ye)return;const we={};for(const ke of NM){const _e=ye.style.getPropertyValue(ke.replace(/([A-Z])/g,"-$1").toLowerCase());_e&&(we[ke]=_e)}const Te=wg(t,L.domPath)??void 0;Yh({className:ye.className,style:we,effectiveColor:Te})};J();const R=t.querySelector(W);if(!R)return;const de=new MutationObserver(J);return de.observe(R,{attributes:!0,attributeFilter:["class","style"]}),de.observe(t,{childList:!0,subtree:!0}),()=>de.disconnect()},[L?.path?at(L.path):null,t]);const Xh=u.useCallback((W,J)=>{if(!v||!L)return;const R=L.path;let de=[],ye=null;v.patchLayout(we=>(de=Ot({children:we},R,_e=>{const Ie=J(_e);return ye=typeof Ie.name=="string"?Ie.name:null,Ie}).children??[],de)),y.push({actionKind:"inline_text_edit",label:`inline_format ${W}`,snapshot:de}),dr({source:"style_control",componentPath:at(R),componentName:ye,patchKey:W,timestamp:Date.now()})},[v,L,y]),ft=u.useMemo(()=>{const W=C.selectedPath;if(!W||!x)return null;const J=[];let R=W;for(;R;){J.push(R);const de=R.match(/^(.*)\.children\.\d+$/);R=de?de[1]:null}for(const de of J){const ye=Re(de);if(!ye)continue;const we=Be(x,ye),Te=typeof we?.name=="string"?we.name:null;if(!Te)continue;const ke=ji(s,Te),_e=ke?.canvasOverlay?.kind;if(typeof _e!="string"||!_e||!we)continue;const Ie=ke.canvasOverlay.params&&typeof ke.canvasOverlay.params=="object"?ke.canvasOverlay.params:void 0,He=de===W?null:W.slice(de.length+1);return{kind:_e,params:Ie,tablePath:de,tableNode:we,selectedCellRel:He}}return null},[C.selectedPath,x,s]),yo=ft?g4(ft.kind):null,Jh=u.useMemo(()=>!yo||!t||!ft?null:fo(t,ft.tablePath),[yo,t,ft,A,k]),MM=u.useMemo(()=>{if(!yo||!t||!ft)return[];const W=ft.tablePath,J=an(W),R=[];return t.querySelectorAll(`[data-editor-path^="${J}.children."]`).forEach(we=>{const Te=we.dataset.editorPath??"";if(!Te.startsWith(W+"."))return;const ke=Te.slice(W.length+1),_e=ao(we,t);_e&&R.push({path:ke,top:_e.top,left:_e.left,width:_e.width,height:_e.height})}),t.querySelectorAll(`[data-editor-item-path^="${J}."]`).forEach(we=>{const Te=we.dataset.editorItemPath??"";if(!Te.startsWith(W+"."))return;const ke=Te.slice(W.length+1),_e=ao(we,t);_e&&R.push({path:ke,top:_e.top,left:_e.left,width:_e.width,height:_e.height})}),R},[yo,t,ft,A,k]),LM=u.useCallback(W=>{const J=ft?Re(ft.tablePath):null;if(!v||!J)return;let R=[];v.patchLayout(de=>(R=Ot({children:de},J,()=>W).children??[],R)),y.push({actionKind:"inline_text_edit",label:"inplace_edit",snapshot:R}),dr({source:"style_control",componentPath:ft?.tablePath??"",componentName:typeof W.name=="string"?W.name:null,patchKey:"canvas_inplace",timestamp:Date.now()})},[v,G,y]);return t?i.jsxs("div",{className:"g7le-editor-canvas-overlay","data-testid":"g7le-editor-canvas-overlay",style:{position:"absolute",inset:0,pointerEvents:"none"},children:[!D&&vM(),D&&i.jsxs("div",{"data-testid":"g7le-canvas-pick-banner",style:{position:"absolute",top:8,left:"50%",transform:"translateX(-50%)",zIndex:9999,display:"flex",alignItems:"center",gap:12,padding:"8px 14px",background:"#1e293b",color:"#fff",borderRadius:8,fontSize:13,boxShadow:"0 4px 12px rgba(0,0,0,0.25)",pointerEvents:"auto"},children:[i.jsxs("span",{children:["🎯 ",h("layout_editor.target_picker.canvas_pick_hint")]}),i.jsx("button",{type:"button","data-testid":"g7le-canvas-pick-cancel",onClick:()=>X(D,null),style:{border:"1px solid #475569",borderRadius:6,background:"transparent",color:"#cbd5e1",cursor:"pointer",fontSize:12,padding:"3px 10px"},children:h("layout_editor.target_picker.cancel")})]}),f.editMode!=="route"&&i.jsx(RI,{frameEl:t,components:k,editMode:f.editMode,currentExtensionId:$,editableRootPath:S}),L&&((L.isParamKey&&L.customKey||L.chipValue)&&wt?i.jsxs(i.Fragment,{children:[wt&&i.jsx(vg,{node:wt,spec:s,t:h,onApplyControl:Xh,box:L.box,scope:{colorScheme:f.previewColorScheme==="dark"?"dark":"base",breakpoint:Yr(f.previewDevice,wt,f.previewCustomWidth)}}),i.jsx(D4,{box:L.box,node:wt,customKey:L.customKey??null,initialChipValue:L.chipValue,chipParamLabels:L.chipParamLabels,onKeyify:AM,templateIdentifier:f.templateIdentifier,locale:f.locale,t:h,candidates:ln,onInsertBinding:DM,onRemoveBinding:zM,onCommit:IM,onCancel:Gh})]}):i.jsxs(i.Fragment,{children:[wt&&i.jsx(vg,{node:wt,spec:s,t:h,onApplyControl:Xh,box:L.box,scope:{colorScheme:f.previewColorScheme==="dark"?"dark":"base",breakpoint:wt?Yr(f.previewDevice,wt,f.previewCustomWidth):"base"}}),i.jsx(T4,{box:L.box,initialValue:L.initialValue,isCustomKey:L.isCustomKey,t:h,onCommit:EM,onCancel:Gh,mirrorClassName:El.className,mirrorStyle:El.style,nodeEffectiveColor:El.effectiveColor??L.nodeEffectiveColor,onOpenTranslations:TM})]})),!D&&i.jsx(U7,{hoverBox:T,selectedBox:A,lockKind:C.selectedLockKind,navAffordance:C.selectedNavAffordance,onEditProps:wl,onDuplicate:me,onDelete:Ce,onSeparateBranch:$e?.mode==="separate"?U:void 0,separateBranchLabel:xe?.separate,onMergeBranch:$e?.mode==="merge"?ue:void 0,mergeBranchLabel:xe?.merge,definedDeviceBranches:he,onJumpToDevice:he.length>0?j:void 0,onLinkEditDestination:Ae,onEditBase:dt,onEditExtension:pt,extensionLabel:De,baseLayoutLabel:C.selectedBaseLayout,dataSourceLabel:C.selectedDataSourceId,branchLabel:ee,onEditIteration:C.selectedIsIteration&&f.editMode!=="iteration_item"?ot:void 0,resizeEnabledAxes:lr.enabledAxes,onResizeHandlePointerDown:lr.enabledAxes.width||lr.enabledAxes.height?CM:void 0,selectedName:Ee,onSelectParent:Z?ae:void 0}),D&&O&&i.jsx("div",{"data-testid":"g7le-canvas-pick-hover","data-pick-has-id":O.hasId?"true":"false",style:{position:"absolute",left:O.box.left,top:O.box.top,width:O.box.width,height:O.box.height,pointerEvents:"none",zIndex:9998,boxSizing:"border-box",border:O.hasId?"2px solid #2563eb":"2px dashed #94a3b8",background:O.hasId?"rgba(37,99,235,0.10)":"repeating-linear-gradient(45deg, rgba(148,163,184,0.18) 0, rgba(148,163,184,0.18) 6px, transparent 6px, transparent 12px)",cursor:O.hasId?"pointer":"not-allowed"},children:!O.hasId&&i.jsx("span",{"data-testid":"g7le-canvas-pick-hover-hint",style:{position:"absolute",top:0,left:0,transform:"translateY(-100%)",background:"#475569",color:"#fff",fontSize:11,lineHeight:1.4,padding:"2px 6px",borderRadius:4,whiteSpace:"nowrap"},children:h("layout_editor.target_picker.needs_id")})}),!D&&i.jsx(Z7,{selectedBox:Ue,points:Se.points,onAddRequest:Xe}),yo&&ft&&Jh&&C.selectedLockKind==="none"&&i.jsx(yo,{node:ft.tableNode,params:ft.params,nodeBox:Jh,cellBoxes:MM,selectedCellPath:ft.selectedCellRel??void 0,colorScheme:f.previewColorScheme==="dark"?"dark":"light",t:h,onPatchNode:LM,onInsertChild:se,onRemoveChild:W=>{const J=Re(W);if(!v||!J)return;let R=[];v.patchLayout(de=>(R=ns({children:de},J).children??[],R)),y.push({actionKind:"remove",label:"inplace_remove",snapshot:R})},onRequestInlineEdit:W=>{ft&&Y(`${ft.tablePath}.${W}`)}}),v&&i.jsx(GI,{frameEl:t,nesting:o,editMode:f.editMode,currentExtensionId:$,editableRootPath:S,components:k,patchLayout:v.patchLayout,pushHistory:le,selectedPath:C.selectedPath,onSelectPath:W=>C.handleSelect("",{dataset:{editorPath:W}}),onMovePath:W=>C.handleSelect("",{dataset:{editorPath:W}}),onRequestInlineEdit:Y})]}):null}function xg(e,t){if(t.length===0)return null;const o=Va({children:e},t);return o&&typeof o.name=="string"?o.name:null}function Va(e,t){return Be(e,t)}function an(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[^a-zA-Z0-9_\-.]/g,t=>`\\${t}`)}function wg(e,t){if(!t)return null;const n=e.querySelector(`[data-editor-path="${an(t)}"]`);if(!n||typeof window.getComputedStyle!="function")return null;let o=n;const r=n.ownerDocument.createTreeWalker(n,NodeFilter.SHOW_TEXT);let s=r.nextNode();for(;s;){if((s.textContent??"").trim().length>0){const a=s.parentElement;if(a&&n.contains(a)){o=a;break}}s=r.nextNode()}try{return window.getComputedStyle(o).color||null}catch{return null}}function fo(e,t){if(!t)return null;const n=e.querySelector(`[data-editor-path="${an(t)}"]`);if(n){const c=ao(n,e);return c&&lo(c,e)?c:null}const o=e.querySelectorAll(`[data-editor-path^="${an(t)}.iteration."]`);let r=1/0,s=1/0,a=-1/0,l=-1/0,d=!1;return o.forEach(c=>{const p=c.dataset.editorPath??"";if(!new RegExp("\\.iteration\\.\\d+$").test(p))return;const f=ao(c,e);f&&lo(f,e)&&(d=!0,r=Math.min(r,f.left),s=Math.min(s,f.top),a=Math.max(a,f.left+f.width),l=Math.max(l,f.top+f.height))}),d?{left:r,top:s,width:a-r,height:l-s,scale:1}:null}function W4({isEditMode:e,editorSpec:t,sampleOverride:n}){const o=t?.sampleData;return u.useMemo(()=>Km({spec:o,overrideSpec:n,onMatch:r=>{Qh(r)}}),[e,o,n])}const j4=Lt().ComponentRegistry;function H4(e){return e.replace(/[\t\n\r]/g,"").replace(/\\/g,"/").replace(/^([a-z][a-z0-9+.\-]*:)?\/{2,}/i,"$1//")}function F4(e,t){try{const n=typeof window<"u"&&window.location?.protocol||"https:",o=t||(typeof window<"u"?window.location?.origin:void 0)||"https://localhost",r=e.startsWith("//")?`${n}${e}`:e,s=new URL(r,o);return s.protocol!=="http:"&&s.protocol!=="https:"?null:s.hostname.toLowerCase()}catch{return null}}function Ua(){const e=typeof window<"u"?window.G7Config?.trustedScriptHosts:void 0;return Array.isArray(e)?e.map(t=>String(t).toLowerCase()):[]}function kg(e,t){if(typeof e!="string")return!1;const n=e.trim();if(n==="")return!1;const o=H4(n),r=o.startsWith("//"),s=/^[a-z][a-z0-9+.-]*:/i.test(o);if(!r&&!s&&o.startsWith("/"))return!0;const a=F4(o),l=t??Ua();return a!==null&&l.map(d=>String(d).toLowerCase()).includes(a)}function K4(e){return e.split(/[-_]/).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}async function V4(e){const t=typeof window<"u"?window.localStorage?.getItem("auth_token"):null,n={Accept:"application/json"};t&&(n.Authorization=`Bearer ${t}`);const o=await fetch(`/api/admin/templates/${encodeURIComponent(e)}/editor-assets`,{headers:n,credentials:"same-origin"});if(!o.ok){const s=await o.json().catch(()=>null);throw Jr(o.status,s,"assets")}const r=await o.json();return r.data||r}async function U4(e){try{if(typeof fetch!="function")return 0;const t=await fetch(en(`/api/templates/${encodeURIComponent(e)}/config`,"json"),{credentials:"same-origin",headers:{Accept:"application/json"}});if(!t.ok)return 0;const n=await t.json().catch(()=>null),o=n?.data?.cache_version??n?.cache_version;return typeof o=="number"&&o>0?o:0}catch{return 0}}function q4(e){return new Promise((t,n)=>{if(typeof document>"u"){n(new Error("document undefined"));return}if(!kg(e,Ua())){n(new Error(`Blocked untrusted script src (same-origin path or declared trusted host required): ${e}`));return}if(document.querySelector(`script[data-g7le-asset="${e}"]`)){t();return}const r=document.createElement("script");r.src=e,r.async=!1,r.setAttribute("data-g7le-asset",e),r.addEventListener("load",()=>t()),r.addEventListener("error",()=>n(new Error(`script load failed: ${e}`))),document.head.appendChild(r)})}async function G4(e){if(typeof document>"u")return;const t=`[data-g7le-asset="${e}"]`;if(document.querySelector(`link${t}, style${t}`))return;if(e.includes("/api/admin/"))try{const r=typeof window<"u"?window.localStorage?.getItem("auth_token"):null,s={Accept:"text/css"};r&&(s.Authorization=`Bearer ${r}`);const a=await fetch(e,{headers:s,credentials:"same-origin"});if(a.ok){const l=await a.text(),d=document.createElement("style");d.textContent=l,d.setAttribute("data-g7le-asset",e),document.head.appendChild(d);return}}catch{}const o=document.createElement("link");o.rel="stylesheet",o.href=e,o.setAttribute("data-g7le-asset",e),document.head.appendChild(o)}function Y4(e,t,n="user"){const[o,r]=u.useState({componentRegistry:null,translationEngine:null,isReady:!1,error:null});return u.useEffect(()=>{let s=!1;return(async()=>{r(a=>({...a,isReady:!1,error:null}));try{const a=await V4(e);if(s)return;for(const b of a.css??[])if(await G4(b),s)return;const l=K4(e);if(!(typeof window<"u"&&typeof window[l]=="object")){for(const b of a.js??[])if(await q4(b),s)return}const c=j4.createIsolatedInstance();if(await c.loadComponents(e,n),s)return;const p=await U4(e);if(s)return;const f=new Pt({defaultLocale:t});if(p>0&&f.setCacheVersion(p),await f.loadTranslations(e,t),s)return;gd(f,e);try{const b=Pt.getInstance();p>b.getCacheVersion()&&b.setCacheVersion(p),await b.loadTranslations(e,t),gd(b,e)}catch{}if(s)return;r({componentRegistry:c,translationEngine:f,isReady:!0,error:null})}catch(a){if(s)return;const l=xp(a)?a:so(a,"assets");r({componentRegistry:null,translationEngine:null,isReady:!1,error:l})}})(),()=>{s=!0}},[e,t,n]),o}const Sg=Lt().AuthManager;function X4(e){switch(e){case"unauthorized":return{icon:"🔒",tone:"blue",titleKey:"layout_editor.access_error.unauthorized.title",messageKey:"layout_editor.access_error.unauthorized.message",showRequiredPermissions:!0};case"forbidden":return{icon:"⛔",tone:"rose",titleKey:"layout_editor.access_error.forbidden.title",messageKey:"layout_editor.access_error.forbidden.message",showRequiredPermissions:!0};case"not_found":return{icon:"🗂️",tone:"slate",titleKey:"layout_editor.access_error.not_found.title",messageKey:"layout_editor.access_error.not_found.message",showRequiredPermissions:!1};case"server_error":return{icon:"🛠️",tone:"amber",titleKey:"layout_editor.access_error.server_error.title",messageKey:"layout_editor.access_error.server_error.message",showRequiredPermissions:!1};case"network":return{icon:"📡",tone:"amber",titleKey:"layout_editor.access_error.network.title",messageKey:"layout_editor.access_error.network.message",showRequiredPermissions:!1};default:return{icon:"⚠️",tone:"slate",titleKey:"layout_editor.access_error.unknown.title",messageKey:"layout_editor.access_error.unknown.message",showRequiredPermissions:!1}}}const J4={blue:{bg:"#eff6ff",border:"#bfdbfe",iconBg:"#dbeafe"},rose:{bg:"#fff1f2",border:"#fecdd3",iconBg:"#ffe4e6"},amber:{bg:"#fffbeb",border:"#fde68a",iconBg:"#fef3c7"},slate:{bg:"#f8fafc",border:"#e2e8f0",iconBg:"#f1f5f9"}};function Z4({error:e}){return u.useEffect(()=>{if(e.kind!=="unauthorized"||typeof window>"u")return;const t=Sg.getInstance(),n=`${window.location.pathname}${window.location.search}`,o=t.getLoginRedirectUrl("admin",n,"session_expired"),r=window.setTimeout(()=>{window.location.href=o},600);return()=>window.clearTimeout(r)},[e.kind]),null}function qa({error:e}){const{t}=tt(),n=X4(e.kind),o=J4[n.tone],r=()=>{typeof window<"u"&&(window.location.href="/admin")},s=()=>{typeof window<"u"&&window.location.reload()},a=()=>{if(typeof window>"u")return;const l=Sg.getInstance(),d=`${window.location.pathname}${window.location.search}`;window.location.href=l.getLoginRedirectUrl("admin",d)};return i.jsxs("div",{className:"g7le-access-error","data-testid":"g7le-access-error","data-error-kind":e.kind,style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:24,background:"#f1f5f9"},children:[i.jsx(Z4,{error:e}),i.jsxs("div",{style:{maxWidth:480,width:"100%",background:o.bg,border:`1px solid ${o.border}`,borderRadius:12,padding:"28px 32px",boxShadow:"0 2px 8px rgba(15, 23, 42, 0.05)",textAlign:"center"},children:[i.jsx("div",{style:{width:64,height:64,margin:"0 auto 16px",borderRadius:"50%",background:o.iconBg,display:"flex",alignItems:"center",justifyContent:"center",fontSize:32,lineHeight:1},"aria-hidden":"true",children:n.icon}),i.jsx("h2",{"data-testid":"g7le-access-error-title",style:{margin:"0 0 8px",fontSize:18,fontWeight:700,color:"#0f172a"},children:t(n.titleKey)}),i.jsx("p",{"data-testid":"g7le-access-error-message",style:{margin:"0 0 16px",fontSize:13,lineHeight:1.6,color:"#475569"},children:t(n.messageKey)}),n.showRequiredPermissions&&e.requiredPermissions&&i.jsxs("div",{"data-testid":"g7le-access-error-permissions",style:{display:"inline-flex",flexWrap:"wrap",gap:6,justifyContent:"center",padding:"8px 12px",marginBottom:16,background:"rgba(15, 23, 42, 0.04)",borderRadius:8,fontSize:12,color:"#475569"},children:[i.jsx("span",{style:{fontWeight:600},children:t("layout_editor.access_error.required_permission_label")}),e.requiredPermissions.split(/[,\s]+/).filter(Boolean).map(l=>i.jsx("code",{style:{padding:"2px 6px",background:"#fff",border:"1px solid #e2e8f0",borderRadius:4,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:11,color:"#1e293b"},children:l},l))]}),e.message&&i.jsxs("details",{"data-testid":"g7le-access-error-detail",style:{marginBottom:16,fontSize:11,color:"#94a3b8"},children:[i.jsx("summary",{style:{cursor:"pointer"},children:t("layout_editor.access_error.detail_summary")}),i.jsxs("pre",{style:{marginTop:8,padding:8,background:"#fff",border:"1px solid #e2e8f0",borderRadius:6,overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",textAlign:"left",fontSize:11,color:"#475569"},children:[e.status>0?`HTTP ${e.status} -`:"",e.message]})]}),i.jsxs("div",{style:{display:"flex",justifyContent:"center",gap:8,flexWrap:"wrap"},children:[e.kind==="unauthorized"&&i.jsx("button",{type:"button","data-testid":"g7le-access-error-action-signin",onClick:a,style:Ga,children:t("layout_editor.access_error.action.sign_in")}),e.kind==="forbidden"&&i.jsx("button",{type:"button","data-testid":"g7le-access-error-action-home",onClick:r,style:Ga,children:t("layout_editor.access_error.action.go_home")}),(e.kind==="not_found"||e.kind==="server_error"||e.kind==="network"||e.kind==="unknown")&&i.jsx("button",{type:"button","data-testid":"g7le-access-error-action-retry",onClick:s,style:Ga,children:t("layout_editor.access_error.action.retry")}),e.kind!=="unauthorized"&&i.jsx("button",{type:"button","data-testid":"g7le-access-error-action-home-secondary",onClick:r,style:Q4,children:t("layout_editor.access_error.action.go_admin_home")})]})]})]})}const Ga={padding:"8px 16px",background:"#2563eb",color:"#fff",border:"1px solid #1d4ed8",borderRadius:6,fontSize:13,fontWeight:600,cursor:"pointer"},Q4={padding:"8px 16px",background:"#fff",color:"#475569",border:"1px solid #cbd5e1",borderRadius:6,fontSize:13,fontWeight:500,cursor:"pointer"};function R4(e){const t=window;if(typeof t>"u")return{getSnapshot:()=>({globalState:{},localState:{}}),restore:()=>{}};const n=t.G7Core||{},o={templateApp:t.__templateApp,g7CoreState:n.state,g7CoreDispatch:n.dispatch,g7CoreData:n.data,g7CoreModal:n.modal,g7CoreToast:n.toast};let r={...e.initialGlobalState??{}};r._local||(r._local={});const s=[],a=()=>{const c={globalState:{...r},localState:{...r._local??{}}};for(const p of s)try{p(r)}catch{}e.onChange?.(c)},l={},d={getGlobalState:()=>r,setGlobalState:(c,p)=>{typeof c=="function"?r=c(r):r={...r,...c},a()},onGlobalStateChange:c=>(s.push(c),()=>{const p=s.indexOf(c);p>=0&&s.splice(p,1)}),get globalState(){return r},getActionDispatcher:()=>e.actionDispatcher,getDataSource:c=>l[c]??null,setDataSource:(c,p)=>{l[c]=p},refetchDataSource:async c=>null,updateDataSourceItem:(c,p,f)=>l[c]??null,getLocale:()=>e.locale,changeLocale:c=>{},getRouter:()=>({navigate:()=>{},replace:()=>{},push:()=>{}}),updateQueryParams:()=>{}};return t.__templateApp=d,n&&typeof n.dispatch=="function"&&(n.dispatch=(c,p)=>{try{return e.actionDispatcher.executeAction(c,p??{})}catch{return}}),n&&typeof n.modal=="object"&&n.modal!==null&&(n.modal={...n.modal,open:()=>{},close:()=>{},closeAll:()=>{}}),n&&typeof n.toast=="object"&&n.toast!==null&&(n.toast={...n.toast,push:()=>{},dismiss:()=>{}}),{getSnapshot:()=>({globalState:{...r},localState:{...r._local??{}}}),restore:()=>{t.__templateApp===d&&(t.__templateApp=o.templateApp),t.G7Core&&(o.g7CoreState!==void 0&&(t.G7Core.state=o.g7CoreState),o.g7CoreDispatch!==void 0&&(t.G7Core.dispatch=o.g7CoreDispatch),o.g7CoreData!==void 0&&(t.G7Core.data=o.g7CoreData),o.g7CoreModal!==void 0&&(t.G7Core.modal=o.g7CoreModal),o.g7CoreToast!==void 0&&(t.G7Core.toast=o.g7CoreToast)),s.length=0}}}const eD=new Set(["id","userId","postId","orderId","productId","categoryId","commentId","noticeId","inquiryId","addressId","wishlistId","notificationId","roleId","menuId"]);function tD(e){if(!e)return{};const t={},n=/:([a-zA-Z_][a-zA-Z0-9_]*)/g;let o;for(;(o=n.exec(e))!==null;){const r=o[1];t[r]=nD(r)}return t}function nD(e){return eD.has(e)||/Id$|_id$/.test(e)?"1":"sample"}const oD=mo("LayoutEditor");function Ro(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function _i(e){if(Array.isArray(e))return e.map(t=>_i(t));if(Ro(e)){const t={};for(const[n,o]of Object.entries(e))t[n]=_i(o);return t}return e}function Cg(e,t="",n=new Set){for(const[o,r]of Object.entries(e)){const s=t?`${t}.${o}`:o;Ro(r)?Cg(r,s,n):n.add(s)}return n}function $g(e,t,n,o,r,s=""){for(const[a,l]of Object.entries(t)){const d=s?`${s}.${a}`:a;if(n.has(d)){r(`[LayoutEditor] sampleGlobal key conflict: extension '${o}' override of core key '${d}' ignored`);continue}const c=e[a];Ro(l)&&Ro(c)?$g(c,l,n,o,r,d):e[a]=_i(l)}}function Ya(e){const t=e.warn??(r=>oD.warn(r)),n=_i(e.coreSeed??{});e.isGuestOnly&&"currentUser"in n&&delete n.currentUser;const o=Cg(n);for(const r of e.sources)Ro(r.sampleGlobal)&&$g(n,r.sampleGlobal,o,r.id,t);return e.isGuestOnly&&"currentUser"in n&&delete n.currentUser,n}function rD(e){const t={};if(!e||typeof e!="object"||Array.isArray(e))return t;for(const[n,o]of Object.entries(e))n.startsWith("$")&&(t[n]=o);return t}function iD(e){const t={};if(!e||typeof e!="object"||Array.isArray(e))return t;for(const[n,o]of Object.entries(e))n.startsWith("$")||(t[n]=o);return t}function sD(e){if(typeof e!="string")return null;const t=/^\s*\{\{\s*([\s\S]*?)\s*\}\}\s*$/.exec(e);if(!t)return null;let n=t[1];const o=n.indexOf("??");return o>=0&&(n=n.slice(0,o)),n=n.replace(/\?\./g,".").replace(/\s+/g,""),n===""||!/^[A-Za-z_$][A-Za-z0-9_$]*(\.[A-Za-z_$][A-Za-z0-9_$]*)*$/.test(n)?null:n.split(".")}function aD(e,t){const n=sD(t);if(!n||n.length===0)return e;let o=e;for(let a=0;ao.map(r=>{if(!r||typeof r!="object")return r;const s=r;let a=s;if(typeof s.slot=="string"&&!t.has(s.slot)){const{slot:l,...d}=s;a={...d,__editorSlotName:l}}if(Array.isArray(a.children)){const l=n(a.children);l!==a.children&&(a={...a,children:l})}return a});return n(e)}function St(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Xt(e){if(Array.isArray(e))return e.map(t=>Xt(t));if(St(e)){const t={};for(const[n,o]of Object.entries(e))t[n]=Xt(o);return t}return e}function xi(e,t){for(const[n,o]of Object.entries(t)){const r=e[n];St(o)&&St(r)?xi(r,o):e[n]=Xt(o)}}function cD(e){const t=[];let n="";for(let o=0;o0&&(t.push(n),n="");const s=e[o+1];if(s==="'"||s==='"'){const l=e.indexOf(`${s}]`,o+2);if(l!==-1){t.push(e.slice(o+2,l)),o=l+1;continue}}const a=e.indexOf("]",o+1);if(a!==-1){t.push(e.slice(o+1,a)),o=a;continue}n+=r}else r==="."?n.length>0&&(t.push(n),n=""):n+=r}return n.length>0&&t.push(n),t.filter(o=>o.length>0)}function Xa(e,t,n){const o=cD(t);if(o.length===0)return;let r=e;for(let s=0;s0?t:void 0}const Za="g7le:editor-t-ready",Ag="data-g7le-vh-expanded";function pD(e,t){if(!e||!t)return;const n=t;e.querySelectorAll("*").forEach(r=>{const s=window.getComputedStyle(r),a=parseFloat(s.height),l=Number.isFinite(a)&&Math.abs(a-n)<=2,d=parseFloat(s.minHeight),c=Number.isFinite(d)&&Math.abs(d-n)<=2,p=s.overflowY==="auto"||s.overflowY==="scroll"||s.overflowY==="hidden"||s.overflow==="auto"||s.overflow==="scroll"||s.overflow==="hidden";l&&p?(r.style.setProperty("height","auto","important"),c&&r.style.setProperty("min-height","0","important"),r.style.setProperty("overflow","visible","important"),r.setAttribute(Ag,"1")):(s.overflowY==="auto"||s.overflowY==="scroll")&&r.scrollHeight>r.clientHeight+4&&r.clientHeight>120&&(r.style.setProperty("overflow","visible","important"),r.style.setProperty("height","auto","important"),r.setAttribute(Ag,"1"))})}const fD=[];function gD(e={}){const{manifest:t=null,nesting:n=null,componentPalette:o=null,spec:r=null,permissionCandidates:s,sampleGlobalSources:a=fD,resolveRouteMatch:l,onNavigateToDestination:d,onSessionAddedPathsChange:c}=e,{state:p}=Qe(),f=Ft(),b=Dp(),{document:g,isLoading:m,error:h}=f??b,v=u.useRef(null),[y,_]=u.useState(null),{deviceWidth:w,scale:k,colorScheme:x}=Ka(),$=u.useMemo(()=>p.activeStateId?p.availableStates.find(ce=>ce.id===p.activeStateId)??null:null,[p.activeStateId,p.availableStates]),S=u.useMemo(()=>Ig($),[$]),C=W4({isEditMode:!0,editorSpec:r??void 0,sampleOverride:S}),{t:T}=tt(),{componentRegistry:E,translationEngine:A,isReady:N,error:D}=Y4(p.templateIdentifier,p.locale),B=u.useRef(null);B.current===null&&(B.current=new kd);const M=u.useRef(null);if(M.current===null){M.current=new y7({navigate:()=>{}}),M.current.setPreviewMode(!0);try{const q=window.__templateApp?.getActionDispatcher?.();if(q&&typeof q.getRegisteredHandlers=="function"){const ie=q.getRegisteredHandlers();for(const se of ie){if(!se.includes("."))continue;const me=typeof q.getHandler=="function"?q.getHandler(se):void 0;typeof me=="function"&&M.current.registerHandler(se,me,{category:"plugin",source:"preview-canvas-cloned-from-host"})}}}catch{}}u.useEffect(()=>{if(!N)return;const ce=M.current;if(ce)try{const q=window.G7Core?.getActionDispatcher?.();if(!q||typeof q.getRegisteredHandlers!="function")return;const ie=q.getRegisteredHandlers();for(const se of ie){if(!se.includes(".")||typeof ce.getHandler=="function"&&ce.getHandler(se))continue;const me=typeof q.getHandler=="function"?q.getHandler(se):void 0;typeof me=="function"&&ce.registerHandler(se,me,{category:"plugin",source:"preview-canvas-iife-reclone"})}}catch{}},[N]);const O=u.useMemo(()=>new b7({sampleProvider:C,actionDispatcher:M.current}),[C]),z=u.useMemo(()=>g?.raw?.meta?.guest_only===!0,[g]),H=u.useMemo(()=>Ya({sources:a,isGuestOnly:z}),[a,z]),P=u.useMemo(()=>{const ce=hD(Ja($),A,{templateId:p.templateIdentifier,locale:p.locale}),q=H._local,{global:ie,local:se}=uD({globalBaseline:H,localBaseline:q??{},patch:$?.initialState??null,formErrors:ce});return{...ie,_local:se}},[H,$,A,p.templateIdentifier,p.locale]),I=u.useMemo(()=>!$||!(!!$.initialState?.local||!!Ja($))?null:{...P._local??{},_forceLocalInit:$.id,_merge:"deep"},[$,P]),L=ce=>typeof ce=="object"&&ce!==null&&!Array.isArray(ce),F=u.useMemo(()=>L($?.initialState?.query)?$.initialState.query:null,[$]),Y=u.useMemo(()=>L($?.initialState?.route)?$.initialState.route:null,[$]),[K,X]=u.useState(()=>Ya({sources:[],isGuestOnly:!1})),Z=u.useRef(null);u.useEffect(()=>{const ce={...P},q=R4({actionDispatcher:M.current,locale:p.locale,initialGlobalState:ce,onChange:se=>{X(se.globalState)}});Z.current=q;const ie=window.__templateApp;return ie?.setGlobalState&&M.current.setGlobalStateUpdater((se,me)=>{ie.setGlobalState(se,me)}),X(ce),Tl({kind:"applyPatch",activeStateId:p.activeStateId,routePath:p.selectedRoute?.path??null,hasInitialPatch:!!$?.initialState,hasFormErrors:!!Ja($),hasSampleOverride:!!Ig($)}),()=>{q.restore(),Z.current=null}},[p.locale,P]),u.useEffect(()=>{if(!A)return;const ce=window.G7Core;if(!ce||typeof ce.t!="function")return;const q=ce.t,ie=p.templateIdentifier,se=p.locale;return ce.t=(me,Ce)=>{try{const $e=Ce?"|"+Object.entries(Ce).map(([ue,fe])=>`${ue}=${fe}`).join("|"):void 0,U=A.translate(me,{templateId:ie,locale:se},$e);if(U!==me&&!U.startsWith("$t:"))return U}catch{}return q(me,Ce)},typeof window<"u"&&window.dispatchEvent(new CustomEvent(Za)),()=>{window.G7Core?.t&&window.G7Core.t!==q&&(window.G7Core.t=q)}},[A,p.templateIdentifier,p.locale]);const ae=u.useMemo(()=>{const ce=g?.raw?.components??[];return p.editMode!=="base"?ce:dD(ce)},[g,p.editMode]),oe=g?.raw?.__editability,G=g?.raw?.__extensionId,ee=u.useMemo(()=>p.editMode!=="extension"||oe!=="ok"?[]:typeof G!="number"?[]:yD(ae,G),[p.editMode,oe,G,ae]),[ge,V]=u.useState(null),[te,be]=u.useState(!1),Ee=g?.layoutName??null,De=u.useMemo(()=>{const ce=g?.raw?.scripts??[];return Array.isArray(ce)?ce.map(q=>q&&typeof q.src=="string"?q.src:"").join("|"):""},[g]);u.useEffect(()=>{be(!1)},[Ee,De]),u.useEffect(()=>{let ce=!1;const q=g?.raw?.scripts??[];if(!Array.isArray(q)||q.length===0){be(!0);return}const ie=[];for(const se of q){if(!se?.src||typeof se.src!="string")continue;if(!kg(se.src,Ua())){console.warn(`[PreviewCanvas] Blocked untrusted script src (same-origin path or declared trusted host required): ${se.src}`);continue}const me=se.id?`script#${CSS.escape(se.id)}, script[data-g7le-canvas-script="${se.src}"]`:`script[data-g7le-canvas-script="${se.src}"], script[src="${se.src}"]`,Ce=window.document.querySelector(me);if(Ce){const $e=Ce.hasAttribute("data-g7le-canvas-script");if(Ce.hasAttribute("data-g7le-script-loaded")||!$e)continue;ie.push(new Promise(ue=>{if(Ce.hasAttribute("data-g7le-script-loaded")){ue();return}Ce.addEventListener("load",()=>ue()),Ce.addEventListener("error",()=>ue())}));continue}ie.push(new Promise($e=>{const U=window.document.createElement("script");U.src=se.src,U.async=!1,se.id&&(U.id=se.id),U.setAttribute("data-g7le-canvas-script",se.src);const ue=()=>{U.setAttribute("data-g7le-script-loaded","1"),$e()};U.addEventListener("load",ue),U.addEventListener("error",ue),window.document.head.appendChild(U)}))}if(ie.length===0){be(!0);return}return Promise.all(ie).then(()=>{ce||requestAnimationFrame(()=>{requestAnimationFrame(()=>{ce||be(!0)})})}),()=>{ce=!0}},[g]);const Se=u.useMemo(()=>g?.raw?.data_sources??[],[g]),Ue=u.useMemo(()=>g?.raw?.computed??{},[g]),[Me,Oe]=u.useState({}),Ye=u.useMemo(()=>{if(p.editMode!=="iteration_item")return Me;const ce=g?.iterationContext;if(!ce)return Me;const q=g?.raw?.components??[],ie=Be({children:q},ce.sourceIndexPath),se=ie&&ie.iteration&&typeof ie.iteration.source=="string"?ie.iteration.source:null;return se?aD(Me,se):Me},[p.editMode,Me,g]),[ze,Xe]=u.useState(0);u.useEffect(()=>{if(typeof window>"u")return;const ce=()=>Xe(q=>q+1);return window.addEventListener(kt,ce),()=>window.removeEventListener(kt,ce)},[]);const ve=u.useMemo(()=>tD(p.selectedRoute?.path??null),[p.selectedRoute?.path]);if(u.useEffect(()=>{let ce=!1;return(async()=>{if(Se.length===0){ce||Oe({});return}try{const q=await O.fetchDataSources(Se,ve,new URLSearchParams,void 0,void 0);ce||Oe(q)}catch{ce||Oe({})}})(),()=>{ce=!0}},[Se,O,ve]),u.useEffect(()=>{const ce=y;if(!ce||typeof window>"u")return;let q=0,ie=0,se=0;const me=()=>pD(ce,window.innerHeight);q=window.requestAnimationFrame(()=>{ie=window.requestAnimationFrame(me)});let Ce=null;return typeof MutationObserver<"u"&&(Ce=new MutationObserver(()=>{se||(se=window.requestAnimationFrame(()=>{se=0,me()}))}),Ce.observe(ce,{childList:!0,subtree:!0})),()=>{window.cancelAnimationFrame(q),window.cancelAnimationFrame(ie),se&&window.cancelAnimationFrame(se),Ce&&Ce.disconnect()}},[y,ae,te,w,Me]),u.useEffect(()=>{const ce=y;if(!ce||typeof window>"u"||p.editMode!=="extension"||oe!=="ok"||ee.length===0){V(null);return}let q=0,ie=0;const se=ue=>{if(!ue)return!1;const fe=ue.getBoundingClientRect();return fe.width>0&&fe.height>0},me=ue=>{const fe=ce.querySelector(`[data-editor-path="${ue}"]`);if(se(fe))return!0;const xe=ce.querySelectorAll(`[data-editor-path^="${ue}.children."]`);for(const he of Array.from(xe))if(se(he))return!0;return!1},Ce=()=>{V(ee.some(me))};q=window.requestAnimationFrame(()=>{ie=window.requestAnimationFrame(Ce)});let $e=null,U=0;return typeof MutationObserver<"u"&&($e=new MutationObserver(()=>{U||(U=window.requestAnimationFrame(()=>{U=0,Ce()}))}),$e.observe(ce,{childList:!0,subtree:!0})),()=>{window.cancelAnimationFrame(q),window.cancelAnimationFrame(ie),U&&window.cancelAnimationFrame(U),$e&&$e.disconnect()}},[y,p.editMode,oe,ee,te,Me]),u.useEffect(()=>{if(typeof window>"u"||p.editMode!=="base")return;const ce=window.document,q="g7le-base-slot-style";if(ce.getElementById(q))return;const ie=ce.createElement("style");ie.id=q;const se=T("layout_editor.preview.slot_area_label");return ie.textContent=`.g7le-preview-frame [data-editor-slot]{position:relative;min-height:96px;outline:2px dashed #94a3b8;outline-offset:-2px;}.g7le-preview-frame [data-editor-slot]::after{content:'${se.replace(/'/g,"\\'")} · ' attr(data-editor-slot);position:absolute;top:8px;left:50%;transform:translateX(-50%);font-size:12px;line-height:1;color:#64748b;background:rgba(241,245,249,0.92);border:1px solid #cbd5e1;border-radius:9999px;padding:4px 12px;pointer-events:none;white-space:nowrap;}`,ce.head.appendChild(ie),()=>{ce.getElementById(q)?.remove()}},[p.editMode,T]),!(p.editMode==="extension"||p.editMode==="iteration_item")&&(p.selectedRoute?.layoutName===null||p.selectedRoute===null))return i.jsx("div",{className:"g7le-preview-canvas g7le-preview-canvas--empty","data-testid":"g7le-preview-empty",style:er,children:T("layout_editor.preview.empty")});if(m)return i.jsx("div",{className:"g7le-preview-canvas g7le-preview-canvas--loading","data-testid":"g7le-preview-loading",style:er,children:T("layout_editor.preview.loading")});if(h)return i.jsx(qa,{error:h});if(D)return i.jsx(qa,{error:D});if(!N||E===null||A===null)return i.jsx("div",{className:"g7le-preview-canvas g7le-preview-canvas--assets-loading","data-testid":"g7le-preview-assets-loading",style:er,children:T("layout_editor.preview.assets_loading")});if(ae.length===0)return i.jsx("div",{className:"g7le-preview-canvas g7le-preview-canvas--empty-layout","data-testid":"g7le-preview-empty-layout",style:er,children:T("layout_editor.preview.empty_layout")});const We=p.editMode==="extension"?oe==="no-injection"?"no-injection":oe==="ok"&&ee.length>0&&ge!==!0?"gated-no-state":null:null;return te?i.jsx("div",{className:"g7le-preview-canvas","data-testid":"g7le-preview-canvas",style:{overflow:"visible",background:"#f1f5f9",padding:24,display:"flex",justifyContent:"center",alignItems:"flex-start",minHeight:"calc(100vh - var(--g7le-header-h, 0px))",boxSizing:"border-box"},children:i.jsxs("div",{className:"g7le-preview-frame-wrapper","data-testid":"g7le-preview-frame-wrapper",style:{position:"relative",width:w,transform:`scale(${k})`,transformOrigin:"top center"},children:[i.jsx("div",{className:x==="dark"?"g7le-preview-frame g7le-preview-dark":"g7le-preview-frame","data-testid":"g7le-preview-frame","data-color-scheme":x,ref:ce=>{v.current=ce,_(ce)},style:{width:w,background:"#fff",border:"1px solid #cbd5e1",boxShadow:"0 1px 3px rgba(0,0,0,0.05)",minHeight:400,position:"relative",transform:"translateZ(0)",overflow:"hidden"},children:i.jsx(h7,{overrideWidth:w,children:ae.map((ce,q)=>i.jsx(g7,{componentDef:ce,dataContext:{...Ye,...rD(K),_global:iD(K),_computedDefinitions:Ue,...I?{_localInit:I,_local:{...Me._local??{},...K._local??{}}}:{},route:bD({...Me.route??{},...ve,path:p.selectedRoute?.path??""},Y),query:{...Me.query??{},...F??{}}},translationContext:{templateId:p.templateIdentifier,locale:p.locale},registry:E,bindingEngine:B.current,translationEngine:Pt.getInstance(),actionDispatcher:M.current,isEditMode:!0,isRootRenderer:q===0,componentPath:`${q}`,onComponentSelect:(ie,se)=>{},onComponentHover:(ie,se)=>{}},`${ce.id??`preview-${q}`}:t${ze}${p.editMode==="extension"?`:s${te?1:0}`:""}`))})}),i.jsx("div",{className:"g7le-overlay-layer","data-testid":"g7le-overlay-layer",style:{position:"absolute",left:0,top:0,width:w,height:y?y.getBoundingClientRect().height/(k||1):"100%",overflow:"visible",pointerEvents:"none"},children:i.jsx(B4,{frameEl:y,manifest:t,nesting:n,componentPalette:o,spec:r,permissionCandidates:s,resolveRouteMatch:l,onNavigateToDestination:d,onSessionAddedPathsChange:c})}),We!==null&&i.jsx("div",{className:"g7le-preview-canvas--extension-fallback","data-testid":"g7le-preview-extension-fallback","data-fallback-reason":We,style:{position:"absolute",left:0,top:0,right:0,bottom:0,minHeight:y?y.getBoundingClientRect().height/(k||1):400,background:"#f1f5f9",display:"flex",alignItems:"flex-start",justifyContent:"center",padding:24,boxSizing:"border-box",pointerEvents:"auto",zIndex:50},children:i.jsxs("div",{className:"g7le-extension-fallback-card",style:{maxWidth:440,textAlign:"center",position:"sticky",top:"calc(40vh - var(--g7le-header-h, 0px))"},children:[i.jsx("p",{className:"g7le-extension-fallback-title",style:{fontWeight:600,marginBottom:8,color:"#0f172a"},children:T(We==="no-injection"?"layout_editor.preview.extension_no_injection_title":"layout_editor.preview.extension_gated_title")}),i.jsx("p",{className:"g7le-extension-fallback-desc",style:{color:"#475569",lineHeight:1.6},children:We==="no-injection"?T("layout_editor.preview.extension_no_injection_desc"):p.availableStates.length>1?T("layout_editor.preview.extension_gated_desc_with_states"):T("layout_editor.preview.extension_gated_desc")})]})})]})}):i.jsx("div",{className:"g7le-preview-canvas g7le-preview-canvas--scripts-loading","data-testid":"g7le-preview-scripts-loading",style:er,children:T("layout_editor.preview.loading")})}function hD(e,t,n){if(!e)return;if(!t)return e;const o=s=>{if(typeof s=="string"&&s.startsWith("$t:"))try{const a=s.slice(3),l=a.indexOf("|");if(l===-1)return t.translate(a,n);const d=a.slice(0,l),c=a.slice(l);return t.translate(d,n,c)}catch{return s}return Array.isArray(s)?s.map(o):s},r={};for(const[s,a]of Object.entries(e))r[s]=o(a);return r}function yD(e,t){const n=[],o=(r,s)=>{Array.isArray(r)&&r.forEach((a,l)=>{if(!a||typeof a!="object")return;const d=s?`${s}.children.${l}`:`${l}`,c=a.__source;if(c?.kind==="extension"&&c.extensionId===t){n.push(d);return}Array.isArray(a.children)&&o(a.children,d)})};return o(e,""),n}function bD(e,t){if(!t)return e;const n={...e};for(const[o,r]of Object.entries(t))r===null?delete n[o]:n[o]=r;return n}const er={flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:24,background:"#f1f5f9",color:"#64748b",fontSize:13},mD={desktop:"layout_editor.device.desktop",tablet:"layout_editor.device.tablet",mobile:"layout_editor.device.mobile",portable:"layout_editor.device.portable"};function vD(){const{device:e,zoom:t,customWidth:n,setDevice:o,setZoom:r,setCustomWidth:s,colorScheme:a,setColorScheme:l}=Ka(),{t:d}=tt(),c=Rf();return i.jsxs("div",{className:"g7le-device-toolbar","data-testid":"g7le-device-toolbar",style:{display:"inline-flex",alignItems:"center",gap:8,padding:"4px 8px",background:"#fff",border:"1px solid #cbd5e1",borderRadius:6},children:[i.jsxs("div",{role:"group","aria-label":d("layout_editor.device.group_label"),children:[c.map(p=>{const f=e===p,b=mD[p],g=b?d(b):p;return i.jsx("button",{type:"button","data-testid":`g7le-device-${p}`,"aria-pressed":f,onClick:()=>o(p),style:{padding:"2px 8px",marginRight:2,fontSize:12,cursor:"pointer",background:f?"#0f172a":"#f8fafc",color:f?"#fff":"#0f172a",border:"1px solid #cbd5e1",borderRadius:4},children:g},p)}),(()=>{const p=e==="custom";return i.jsx("button",{type:"button","data-testid":"g7le-device-custom","aria-pressed":p,onClick:()=>o("custom"),style:{padding:"2px 8px",marginRight:2,fontSize:12,cursor:"pointer",background:p?"#0f172a":"#f8fafc",color:p?"#fff":"#0f172a",border:"1px solid #cbd5e1",borderRadius:4},children:d("layout_editor.device.custom")})})()]}),e==="custom"&&i.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[i.jsx("label",{htmlFor:"g7le-custom-width-input",style:{fontSize:11,color:"#475569"},children:d("layout_editor.device.custom_width_label")}),i.jsx("input",{id:"g7le-custom-width-input",type:"number",min:bg,max:mg,step:10,value:n,"data-testid":"g7le-custom-width-input","aria-label":d("layout_editor.device.custom_width_label"),onChange:p=>{const f=parseInt(p.currentTarget.value,10);Number.isFinite(f)&&s(f)},style:{width:72,padding:"2px 6px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:4}}),i.jsx("span",{style:{fontSize:11,color:"#475569"},children:"px"})]}),i.jsx("div",{role:"group","aria-label":d("layout_editor.toolbar.color_scheme_group"),style:{display:"inline-flex",gap:2},children:["light","dark"].map(p=>{const f=a===p;return i.jsx("button",{type:"button","data-testid":`g7le-toolbar-scheme-${p}`,"aria-pressed":f,onClick:()=>l(p),style:{padding:"2px 8px",fontSize:12,cursor:"pointer",background:f?"#0f172a":"#f8fafc",color:f?"#fff":"#0f172a",border:"1px solid #cbd5e1",borderRadius:4},children:d(p==="light"?"layout_editor.toolbar.color_scheme_light":"layout_editor.toolbar.color_scheme_dark")},p)})}),i.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[i.jsx("span",{style:{fontSize:11,color:"#475569"},children:d("layout_editor.zoom.label")}),i.jsx("input",{type:"range",min:.5,max:1,step:.05,value:t,"data-testid":"g7le-zoom-slider","aria-label":d("layout_editor.zoom.aria_label"),onChange:p=>r(parseFloat(p.currentTarget.value)),style:{width:100}}),i.jsxs("span",{style:{fontSize:11,color:"#475569",minWidth:36,textAlign:"right"},children:[Math.round(t*100),"%"]})]}),i.jsx(Jb,{})]})}function _D(){const{t:e}=tt(),{state:t,dispatch:n}=Qe(),{availableStates:o,activeStateId:r}=t,[,s]=u.useState(0);u.useEffect(()=>{if(typeof window>"u")return;const p=()=>s(b=>b+1),f=window.requestAnimationFrame(p);return window.addEventListener(Za,p),()=>{window.cancelAnimationFrame(f),window.removeEventListener(Za,p)}},[]);const a=u.useCallback((p,f)=>{if(!p)return f;if(!p.startsWith("$t:"))return p;const b=p.slice(3),g=window.G7Core;if(g&&typeof g.t=="function"){const h=g.t(b);if(h&&h!==b&&!h.startsWith("$t:"))return h}const m=e(b);return m&&m!==b?m:f},[e]);if(!Array.isArray(o)||o.length<=1)return null;const l=p=>{const f=p.target.value;n({type:"SET_ACTIVE_STATE",activeStateId:f}),Tl({kind:"change",activeStateId:f,routePath:t.selectedRoute?.path??null,availableCount:o.length})},d=o.find(p=>p.id===r)??o[0],c=d?.description?a(d.description,""):"";return i.jsxs("div",{className:"g7le-state-switcher","data-testid":"g7le-state-switcher","data-active-state":r??"",style:{display:"inline-flex",alignItems:"center",gap:6,padding:"4px 8px",background:"#fff",border:"1px solid #cbd5e1",borderRadius:6},children:[i.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#475569",whiteSpace:"nowrap"},children:e("layout_editor.toolbar.state")}),i.jsx("select",{"data-testid":"g7le-state-switcher-select","aria-label":e("layout_editor.toolbar.state"),value:r??o[0].id,onChange:l,style:{fontSize:12,padding:"2px 6px",border:"1px solid #cbd5e1",borderRadius:4,background:"#fff",color:"#0f172a",cursor:"pointer",outline:"none"},children:o.map(p=>i.jsx("option",{value:p.id,children:a(p.label,p.id)},p.id))}),c&&i.jsx("span",{"data-testid":"g7le-state-switcher-description",style:{fontSize:11,color:"#94a3b8",whiteSpace:"nowrap"},children:c})]})}function xD(e,t,n){if(e==="extension"){if(typeof n=="string"&&n.length>0){const o=Qa(n,"__base__/");return o?{kind:"base",match:o}:{kind:"route",match:n}}return null}if(!t)return null;switch(e){case"route":return{kind:"route",match:t};case"base":{const o=Qa(t,"__base__/");return o?{kind:"base",match:o}:null}case"modal":{const o=Qa(t,"__modal__/");return o?{kind:"modal",match:o}:null}default:return null}}function wD(e,t){if(!t||!Array.isArray(e)||e.length===0)return[];const n=[];for(const o of e)if(SD(o.scope,t))for(const r of o.items??[])r&&typeof r.id=="string"&&r.id.length>0&&n.push(r);return n}function kD(e){if(e.length===0)return null;const t=e.find(n=>n.default===!0);return t?t.id:e[0].id}function SD(e,t){if(!e||e.kind!==t.kind)return!1;const n=e.match;return typeof n!="string"||n.length===0?!1:t.kind==="route"?CD(t.match,n):n===t.match}function CD(e,t){if(t===e)return!0;if(!t.includes("*"))return!1;const n=t.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\/\*\\\?/g,"(?:/[^/]+)?").replace(/\*/g,"[^/]+");return new RegExp(`^${n}$`).test(e)}function Qa(e,t){return e.startsWith(t)?e.slice(t.length):""}const $D="__conngroup__/modals/",ED="__conngroup__/extensions/";function ID(e){return e.meta?.editor_label?{label:e.meta.editor_label,labelSource:"editor_label"}:e.meta?.title?{label:e.meta.title,labelSource:"title"}:{label:e.path,labelSource:"path"}}function AD(e){switch(e.source.kind){case"template":return"template";case"module":return`module:${e.source.identifier??""}`;case"plugin":return`plugin:${e.source.identifier??""}`;case"core":return null;default:return null}}function TD(e,t){if(e.meta?.parent&&t.has(e.meta.parent))return e.meta.parent;const n=e.path.split("/").filter(Boolean);for(let o=n.length-1;o>=1;o--){const r="/"+n.slice(0,o).join("/");if(r!==e.path&&t.has(r))return r}return null}function DD(e){const t=new Map;for(const n of e)n.layout&&t.set(n.layout,(t.get(n.layout)??0)+1);return t}function zD(e){const t=new Map;for(const n of e){if(!n.hostLayout)continue;const o=t.get(n.hostLayout)??[];o.push(n),t.set(n.hostLayout,o)}return t}function ND(e){const t=new Map;for(const n of e)for(const o of n.extensions)for(const r of o.hostLayouts??[]){if(!r)continue;const s=t.get(r)??[];s.push({extension:o,group:n}),t.set(r,s)}return t}function MD(e,t){return{path:`__modal__/${e.hostLayout}/${e.modalId}`,layoutName:e.hostLayout,label:e.label??e.modalId,labelSource:e.label?"editor_label":"path",source:{kind:"core",identifier:null},kind:"modal",modalId:e.modalId,modalHostLayout:e.hostLayout,connectedHostRoutePath:t,children:[]}}function LD(e,t){const{extension:n,group:o}=e,r=o.sourceType==="plugin"?"🔌":"🧩";return{path:`__extension__/${n.id}`,layoutName:null,label:`${r} ${o.sourceLabel} · ${n.targetName}`,labelSource:"path",source:{kind:o.sourceType,identifier:o.sourceIdentifier},kind:"extension",extensionId:String(n.id),extensionType:n.extensionType,extensionPriority:n.priority,extensionTargetName:n.targetName,isModified:n.isModified,isInactive:!n.isActive,connectedHostRoutePath:t,children:[]}}function Tg(e,t,n){if(e.kind!=="route"&&e.kind!=="base"||!e.layoutName)return;const o=[],r=t.get(e.layoutName)??[];r.length>0&&o.push({path:`${$D}${e.path}`,layoutName:null,label:`$t:layout_editor.chrome.route_tree.connected.modals|count=${r.length}`,labelSource:"editor_label",source:{kind:"core",identifier:null},kind:"route",children:r.map(a=>MD(a,e.path))});const s=n.get(e.layoutName)??[];s.length>0&&o.push({path:`${ED}${e.path}`,layoutName:null,label:`$t:layout_editor.chrome.route_tree.connected.extensions|count=${s.length}`,labelSource:"editor_label",source:{kind:"core",identifier:null},kind:"route",children:s.map(a=>LD(a,e.path))}),o.length>0&&(e.children=[...o,...e.children??[]])}function PD(e){const t=[],n=new Set(e.routes.map(o=>o.path));for(const o of e.routes){const r=AD(o);if(!r)continue;const{label:s,labelSource:a}=ID(o),l=TD(o,n),d={path:o.path,layoutName:o.layout??null,label:s,labelSource:a,icon:o.meta?.icon??null,source:o.source,isRedirect:!!o.redirect,isHidden:!!o.meta?.hidden,kind:"route",children:[]};t.push({node:d,parentKey:l,groupKey:r})}return t}function OD(e,t){if(e==="template")return"$t:layout_editor.chrome.route_tree.group.template";if(e.startsWith("module:")){const n=e.slice(7);return`$t:layout_editor.chrome.route_tree.group.module|name=${t.moduleDisplayNames[n]??n}`}if(e.startsWith("plugin:")){const n=e.slice(7);return`$t:layout_editor.chrome.route_tree.group.plugin|name=${t.pluginDisplayNames[n]??n}`}return e}function BD(e,t){DD(e.routes);const n=zD(e.modals),o=ND(e.extensionGroups??[]),r=new Map;for(const d of t)r.has(d.groupKey)||r.set(d.groupKey,[]),r.get(d.groupKey).push(d);const s=Array.from(r.keys()).sort((d,c)=>{const p=g=>g==="template"?1:g.startsWith("module:")?2:g.startsWith("plugin:")?3:4,f=p(d),b=p(c);return f!==b?f-b:d.localeCompare(c)}),a=[];if(e.baseLayouts.length>0){const d=e.baseLayouts.map(c=>({path:`__base__/${c.layoutName}`,layoutName:c.layoutName,label:c.label??c.layoutName,labelSource:c.label?"editor_label":"path",source:{kind:"core",identifier:null},kind:"base",children:[]}));for(const c of d)Tg(c,n,o);a.push({path:"__group__/base",layoutName:null,label:"$t:layout_editor.chrome.route_tree.group.base",labelSource:"editor_label",source:{kind:"core",identifier:null},kind:"route",children:d})}for(const d of s){const c=r.get(d),p=new Map;for(const b of c)p.set(b.node.path,b);const f=[];for(const b of c)if(b.parentKey&&p.has(b.parentKey)){const g=p.get(b.parentKey);g.node.children=g.node.children??[],g.node.children.push(b.node)}else f.push(b.node);for(const b of c)Tg(b.node,n,o);a.push({path:`__group__/${d}`,layoutName:null,label:OD(d,e),labelSource:"editor_label",source:{kind:"core",identifier:null},kind:"route",children:f})}if(e.modals.length>0){const d=e.modals.map(c=>({path:`__modal__/${c.hostLayout}/${c.modalId}`,layoutName:c.hostLayout,label:c.label??c.modalId,labelSource:c.label?"editor_label":"path",source:{kind:"core",identifier:null},kind:"modal",modalId:c.modalId,modalHostLayout:c.hostLayout,children:[]}));a.push({path:"__group__/modal",layoutName:null,label:"$t:layout_editor.chrome.route_tree.group.modal",labelSource:"editor_label",source:{kind:"core",identifier:null},kind:"route",children:d})}const l=e.extensionGroups??[];if(l.length>0){const d=l.map(c=>{const p=c.sourceType==="plugin"?"🔌":"🧩",f=c.extensions.map(b=>({path:`__extension__/${b.id}`,layoutName:null,label:`${c.sourceLabel} · ${b.targetName}`,labelSource:"path",source:{kind:c.sourceType,identifier:c.sourceIdentifier},kind:"extension",extensionId:String(b.id),extensionType:b.extensionType,extensionPriority:b.priority,extensionTargetName:b.targetName,isModified:b.isModified,isInactive:!b.isActive,children:[]}));return{path:`__extgroup__/${c.sourceType}/${c.sourceIdentifier}`,layoutName:null,label:`${p} ${c.sourceLabel}`,labelSource:"path",source:{kind:c.sourceType,identifier:c.sourceIdentifier},kind:"route",children:f}});a.push({path:"__group__/extension",layoutName:null,label:"$t:layout_editor.chrome.route_tree.group.extension",labelSource:"editor_label",source:{kind:"core",identifier:null},kind:"route",children:d})}return a}function WD(e){const t=PD(e);return BD(e,t)}const On=mo("useEditorRoutes");function jD(e,t){if(typeof e=="string")return e.length>0?e:null;if(e&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n.length>0)return n;if(typeof e.en=="string"&&e.en.length>0)return e.en;for(const o of Object.values(e))if(typeof o=="string"&&o.length>0)return o}return null}function Dg(e,t){const n={};if(typeof window>"u")return n;const r=window.G7Config?.[e];if(!Array.isArray(r))return n;for(const s of r)s&&typeof s.identifier=="string"&&(n[s.identifier]=jD(s.display_name,t)??s.identifier);return n}function HD(e){const t=new kd,n=typeof window<"u"?window.G7Config:void 0,o={_global:{settings:n?.settings??{},plugins:n?.plugins??{},modules:n?.modules??{},appConfig:n?.appConfig??{}}};return e.map(r=>{const s={...r};if(typeof s.path=="string"&&s.path.includes("{{")){const a=s.path;let l=t.resolveBindings(s.path,o);l=l.replace(/\/\/+/g,"/")||"/",l.includes("{{")&&(On.warn("편집기 route path 표현식 평가 실패 — fallback 적용",{originalPath:a}),l=a.replace(/\{\{[^}]+\}\}/g,"").replace(/\/\/+/g,"/")||"/"),s.path=l}if(typeof s.redirect=="string"&&s.redirect.includes("{{")){const a=s.redirect;let l=t.resolveBindings(a,o);l=l.replace(/\/\/+/g,"/")||"/",l.includes("{{")&&(On.warn("편집기 route redirect 표현식 평가 실패 — fallback 적용",{originalRedirect:a}),l=a.replace(/\{\{[^}]+\}\}/g,"").replace(/\/\/+/g,"/")||"/"),s.redirect=l}return s})}function FD(e){const{dispatch:t}=Qe(),{translationEngine:n,translationContext:o}=tt(),{templateIdentifier:r,cacheVersion:s}=e;u.useEffect(()=>{let a=!1;const l=s??(typeof window<"u"?window.G7Config?.cache_version:void 0)??"",d=l!==""?`?v=${encodeURIComponent(String(l))}`:"",c=en(`/api/admin/templates/${encodeURIComponent(r)}/editor/routes`,"json",null,d.replace(/^[?&]+/,"")),p=o?.locale??"ko",f=n&&r!==o?.templateId?n.loadTranslations(r,p).then(()=>{On.log("편집 대상 lang 로드 완료",{targetTemplate:r,locale:p})}).catch(h=>{On.warn("편집 대상 lang 로드 실패 — 라우트 라벨 fallback 사용",h)}):Promise.resolve(),b=(()=>{if(typeof fetch!="function")return Promise.reject(so(new Error("fetch unavailable"),"routes"));try{const h=fetch(c,{credentials:"same-origin",headers:Ne()});return!h||typeof h.then!="function"?Promise.reject(so(new Error("fetch returned non-Promise (test stub?)"),"routes")):h.then(async v=>{if(!v.ok){const y=await v.json().catch(()=>null);throw Jr(v.status,y,"routes")}return v.json()})}catch(h){return Promise.reject(h)}})(),g=`/api/admin/templates/${encodeURIComponent(r)}/layout-extensions${d}`,m=(()=>{if(typeof fetch!="function")return Promise.resolve(null);try{const h=fetch(g,{credentials:"same-origin",headers:Ne()});return!h||typeof h.then!="function"?Promise.resolve(null):h.then(async v=>v.ok?await v.json():null).catch(()=>null)}catch{return Promise.resolve(null)}})();return Promise.all([b,f,m]).then(([h,,v])=>{if(a)return;if(!h||!h.success||!Array.isArray(h.data?.routes)){On.warn("routes 응답 형식이 비정상 — empty tree 로 둠",h),t({type:"SET_ROUTES_ERROR",error:{kind:"unknown",status:200,message:"routes 응답 형식이 비정상입니다.",source:"routes"}});return}const y=HD(h.data.routes),_=Dg("activeModules",p),w=Dg("activePlugins",p),k=(h.data.base_layouts??[]).map(A=>({layoutName:A.layout_name,label:A.label??void 0})),x=(h.data.modals??[]).map(A=>({modalId:A.modal_id,hostLayout:A.host_layout,label:A.label??void 0})),$=(v?.success&&Array.isArray(v.data)?v.data:[]).map(A=>({sourceIdentifier:A.source_identifier,sourceType:A.source_type,sourceLabel:A.source_label,extensions:(A.extensions??[]).map(N=>({id:N.id,extensionType:N.extension_type,targetName:N.target_name,priority:N.priority,isActive:N.is_active,isModified:N.is_modified,hostLayouts:Array.isArray(N.host_layouts)?N.host_layouts:[],currentVersion:typeof N.current_version=="number"?N.current_version:void 0}))})),S=WD({routes:y,modals:x,baseLayouts:k,extensionGroups:$,moduleDisplayNames:_,pluginDisplayNames:w});t({type:"SET_ROUTE_TREE",tree:S});const C=h.data.layout_versions,T={};if(C&&typeof C=="object"&&!Array.isArray(C))for(const[A,N]of Object.entries(C))typeof N=="number"&&Number.isFinite(N)&&(T[A]=N);t({type:"SET_LAYOUT_VERSIONS",versions:T});const E={};for(const A of $)for(const N of A.extensions){const D=N.currentVersion;typeof D=="number"&&Number.isFinite(D)&&(E[String(N.id)]=D)}t({type:"SET_EXTENSION_VERSIONS",versions:E}),On.log("routes 로드 완료",{count:y.length,groups:S.length})}).catch(h=>{if(a)return;On.error("routes 로드 실패",h);const v=xp(h)?h:so(h,"routes");t({type:"SET_ROUTES_ERROR",error:v})}),()=>{a=!0}},[r,s,t,n,o?.locale,o?.templateId])}function zg(e,t,n,o=[]){const r=t?Ng(o,t):null,s=r!==null?{path:r.path,layoutName:r.layoutName}:void 0;if(e.startsWith("__base__/")){const a=e.slice(9);if(a)return n({type:"ENTER_BASE_EDIT",layoutName:a,returnRoute:s}),!0}else if(e.startsWith("__modal__/")){const a=e.slice(10);return a&&!a.includes("/")&&t?(n({type:"ENTER_MODAL_EDIT",modalId:a,hostLayout:t,returnRoute:s}),!0):!1}else if(e.startsWith("__extension__/")){const a=e.slice(14);if(a&&!a.includes("/"))return n({type:"ENTER_EXTENSION_EDIT",extensionId:a,returnRoute:s}),!0}else if(e.startsWith("__iteration__/")){const a=e.slice(14);return a&&t?(n({type:"ENTER_ITERATION_ITEM_EDIT",sourcePath:a,hostLayout:t,returnRoute:s}),!0):!1}return!1}function Ng(e,t){for(const n of e){if(n.kind==="route"&&n.layoutName===t)return n;if(n.children&&n.children.length>0){const o=Ng(n.children,t);if(o)return o}}return null}function Ra(e,t){for(const n of e){if(n.kind==="route"&&n.path===t)return n;if(n.children&&n.children.length>0){const o=Ra(n.children,t);if(o)return o}}return null}function KD(e){const{state:t,dispatch:n}=Qe(),o=u.useRef(!1),r=u.useRef(t.editMode);r.current=t.editMode,u.useEffect(()=>{if(o.current||t.routeTree.length===0||typeof window>"u")return;const a=fp(window.location.search);if(a){const c=pp(window.location.search),p=zg(a,c,n,t.routeTree);if(o.current=!0,p)return}const l=up(window.location.search);if(!l){o.current=!0;return}const d=Ra(t.routeTree,l);d&&n({type:"SELECT_ROUTE",route:{path:d.path,layoutName:d.layoutName}}),o.current=!0},[t.routeTree,n]),u.useEffect(()=>{if(typeof window>"u")return;const a=()=>{const l=fp(window.location.search);if(l){const p=pp(window.location.search);if(zg(l,p,n,t.routeTree))return}if(r.current!=="route")switch(r.current){case"base":n({type:"EXIT_BASE_EDIT"});return;case"modal":n({type:"EXIT_MODAL_EDIT"});return;case"extension":n({type:"EXIT_EXTENSION_EDIT"});return;case"iteration_item":n({type:"EXIT_ITERATION_ITEM_EDIT"});return}const d=up(window.location.search);if(!d){n({type:"SELECT_ROUTE",route:null});return}const c=Ra(t.routeTree,d);c&&n({type:"SELECT_ROUTE",route:{path:c.path,layoutName:c.layoutName}})};return window.addEventListener("popstate",a),()=>{window.removeEventListener("popstate",a)}},[t.routeTree,n]);const s=u.useRef("route");u.useEffect(()=>{if(typeof window>"u"||!window.history?.replaceState||t.routeTree.length===0)return;const a=ea(e,t.selectedRoute?.path??null,t.selectedRoute?.layoutName??null),l=`${window.location.pathname}${window.location.search}`,d=s.current;if(s.current=t.editMode,l===a)return;d==="route"&&t.editMode!=="route"&&window.history.pushState?window.history.pushState(window.history.state,"",a):window.history.replaceState(window.history.state,"",a)},[t.selectedRoute,t.editMode,t.routeTree,e])}function VD(){u.useEffect(()=>{if(typeof document>"u")return;const e=document.documentElement;let t=e.classList.contains("dark");const n=()=>{e.classList.contains("dark")&&(t=!0,e.classList.remove("dark"))};n();let o=null;return typeof MutationObserver<"u"&&(o=new MutationObserver(n),o.observe(e,{attributes:!0,attributeFilter:["class"]})),()=>{o?.disconnect(),t&&e.classList.add("dark")}},[])}function UD(){u.useEffect(()=>{if(typeof document>"u"||!document.body)return;const e=document.body,t=()=>{e.style.overflow==="hidden"&&(e.style.overflow=""),e.style.overflowY==="hidden"&&(e.style.overflowY="")};t();let n=null;return typeof MutationObserver<"u"&&(n=new MutationObserver(t),n.observe(e,{attributes:!0,attributeFilter:["style"]})),()=>{n?.disconnect()}},[])}function qD(e){if(typeof e!="string")return null;const t="__extension__/";if(!e.startsWith(t))return null;const n=e.slice(t.length);return n===""||n.includes("/")?null:n}function GD(e){if(Array.isArray(e.components))return e.components;if(Array.isArray(e.injections)){const t=[];return e.injections.forEach((n,o)=>{if(n&&Array.isArray(n.components))for(const r of n.components)t.push({...r,__injectionIndex:o})}),t}return[]}function YD(e,t){if(Array.isArray(e.components)){const n=t.map(o=>el(o));return{...e,components:n}}if(Array.isArray(e.injections)){const n=e.injections.map(o=>({...o}));n.forEach(o=>{Array.isArray(o.components)&&(o.components=[])});for(const o of t){const r=o.__injectionIndex,s=typeof r=="number"&&r>=0&&rel(n))),t}function Mg(e,t){const n=[],o=r=>{if(Array.isArray(r))for(const s of r){if(!s||typeof s!="object")continue;const a=s.__source;if(a?.kind==="extension"&&a.extensionId===t){n.push(s);continue}Array.isArray(s.children)&&o(s.children)}};return o(e),n}function Lg(e,t){const o=Mg(e,t)[0]?.__source;return o&&o.kind==="extension"&&o.extensionId===t?o:{kind:"extension",extensionId:t}}function tl(e,t){for(const n of e){const o=n?.__source;if(o?.kind==="extension"&&o.extensionId===t||Array.isArray(n.children)&&tl(n.children,t))return!0}return!1}function XD(){const{state:e}=Qe(),t=e.templateIdentifier,n=e.editMode==="extension"?qD(e.selectedRoute?.path):null,o=e.editMode==="extension"&&typeof e.selectedRoute?.layoutName=="string"?e.selectedRoute.layoutName:null,[r,s]=u.useState(null),[a,l]=u.useState(!1),[d,c]=u.useState(null),[p,f]=u.useState(!1),[b,g]=u.useState(0),[m,h]=u.useState(null),v=u.useRef({}),y=u.useRef({kind:"extension",extensionId:0}),_=u.useRef(null);u.useEffect(()=>{_.current=r},[r]),u.useEffect(()=>{h(null)},[n]);const w=u.useCallback(async A=>{const N=window.G7Config?.cache_version??0,D=en(`/api/layouts/${encodeURIComponent(t)}/${A}`,"json",`${N}.${Tp()}`,"with_source_meta=1"),B=cr(),M={Accept:"application/json"};B&&(M.Authorization=`Bearer ${B}`);const O=await fetch(D,{headers:M,credentials:"same-origin"});if(!O.ok)return null;const z=await O.json().catch(()=>null);return(z&&(z.data||z))??{}},[t]),k=u.useCallback(async()=>{if(!n){s(null),c(null),f(!1);return}l(!0),c(null);try{const A=window.G7Config?.cache_version??0,N=`/api/admin/templates/${encodeURIComponent(t)}/layout-extensions/${encodeURIComponent(n)}?v=${A}`,D=await fetch(N,{headers:Ne(),credentials:"same-origin"}),B=await D.json().catch(()=>null);if(!D.ok){c(Jr(D.status,B,"layout")),s(null),f(!1);return}const M=(B&&(B.data||B))??{};let O={};const z=M.content;if(typeof z=="string")try{O=JSON.parse(z)}catch{O={}}else z&&typeof z=="object"&&(O=z);const H=M.extension_type==="overlay"?"overlay":"extension_point",P=typeof M.lock_version=="number"?M.lock_version:0,I=Array.isArray(M?.host_layouts)?M.host_layouts.filter(oe=>typeof oe=="string"):[],L=o??(I.length===1?I[0]:m&&I.includes(m)?m:null),F=Number(n);v.current=O;let K=GD(O),X={},Z="pending";const ae={kind:"extension",extensionId:F};if(y.current=ae,L){const oe=await w(L);if(oe){X=oe;const G=Array.isArray(oe.components)?oe.components:[],ee=Lg(G,F);if(y.current=ee,tl(G,F))K=G,Z="ok";else{const V=(Array.isArray(oe.modals)?oe.modals:[]).filter(te=>te&&typeof te=="object"&&tl([te],F));if(V.length>0){const te=V.map(be=>({...be,props:{...be.props??{},isOpen:!0}}));K=[...G,...te],y.current=Lg(V,F),Z="ok"}else K=G,Z="no-injection"}}}s({extensionId:F,content:O,extensionType:H,components:K,lockVersion:P,hostLayouts:I,hostLayoutName:L,hostRaw:X,editability:Z}),f(!1),st({op:"load",layoutName:`extension:${n}`,editMode:"extension",statusCode:D.status,timestamp:Date.now()})}catch(A){c(so(A,"layout")),s(null),f(!1)}finally{l(!1)}},[t,n,m,o,w]);u.useEffect(()=>{k()},[k]);const x=u.useCallback(A=>{h(A)},[]),$=u.useCallback(A=>{s(N=>N&&{...N,components:A}),f(!0),st({op:"patch",layoutName:`extension:${_.current?.extensionId??""}`,editMode:"extension",isDirty:!0,timestamp:Date.now()})},[]),S=u.useCallback(A=>{s(N=>N&&{...N,components:A(N.components)}),f(!0)},[]),C=u.useCallback(async()=>{const A=_.current;if(!A)return{kind:"guard_no_document"};const N=`/api/admin/templates/${encodeURIComponent(t)}/layout-extensions/${A.extensionId}`,D=Mg(A.components,A.extensionId),B=D.length>0?D:A.components,M=YD(v.current,B);st({op:"save",layoutName:`extension:${A.extensionId}`,editMode:"extension",saveTarget:"layout_extension",endpoint:N,isDirty:p,timestamp:Date.now()});let O;try{O=await fetch(N,{method:"PUT",headers:Ne({"Content-Type":"application/json"}),credentials:"same-origin",body:JSON.stringify({content:M,expected_lock_version:A.lockVersion})})}catch(H){return{kind:"network_error",message:H instanceof Error?H.message:"network error"}}const z=await O.json().catch(()=>null);if(st({op:"save_response",layoutName:`extension:${A.extensionId}`,editMode:"extension",endpoint:N,statusCode:O.status,conflict:O.status===409?{currentVersion:z?.errors?.current_version??z?.current_version,yourVersion:z?.errors?.your_version??z?.your_version}:void 0,timestamp:Date.now()}),O.ok){const H=z?.data??{},P=typeof H.lock_version=="number"?H.lock_version:A.lockVersion+1;s(L=>L&&{...L,lockVersion:P}),f(!1),g(L=>L+1);const I=typeof H.current_version=="number"?H.current_version:void 0;return{kind:"success",newLockVersion:P,newContentVersion:I,savedExtensionId:String(A.extensionId)}}return O.status===409?{kind:"concurrent_modification",currentVersion:z?.current_version??-1,yourVersion:z?.your_version??A.lockVersion}:O.status===422?{kind:"validation_failed",status:422,errors:z?.errors??null}:{kind:"network_error",message:z?.message??`HTTP ${O.status}`}},[t,p]),T=u.useCallback(async()=>{ia(),await k()},[k]),E=!!r&&r.hostLayouts.length>1&&r.hostLayoutName===null;return{document:r,isLoading:a,error:d,isDirty:p,saveSuccessCounter:b,setLayoutComponents:$,patchLayout:S,save:C,reload:T,needsHostPicker:E,selectHost:x}}const Pg=new Set;function JD(e,t,n){const r=e&&Object.keys(e).length>0?e:t,s=Array.isArray(r.data_sources)?r.data_sources:[],a=Array.isArray(t.data_sources)?t.data_sources:[],l=new Set,d=[];for(const c of[...s,...a]){const p=c&&typeof c=="object"?c.id:void 0,f=typeof p=="string"?p:`__anon_${d.length}`;l.has(f)||(l.add(f),d.push(c))}return{...r,components:n,...d.length>0?{data_sources:d}:{},lock_version:void 0}}function ZD(e){return{document:e.document?{layoutName:`extension:${e.document.extensionId}`,raw:{...JD(e.document.hostRaw,e.document.content,e.document.components),__editability:e.document.editability,__extensionId:e.document.extensionId},lockVersion:e.document.lockVersion}:null,isLoading:e.isLoading,error:e.error,isDirty:e.isDirty,saveSuccessCounter:e.saveSuccessCounter,reload:e.reload,patchLayout:e.patchLayout,setLayoutComponents:e.setLayoutComponents,patchDocumentRaw:()=>{},dirtyKeys:Pg,dirtyLayoutNames:Pg,invalidateCurrentCache:()=>{},reloadCounter:0,save:()=>e.save(),markDirty:()=>{}}}function QD({hostLayouts:e,extensionLabel:t,onSelect:n}){const{t:o}=tt();return i.jsx("div",{className:"g7le-host-picker__backdrop","data-testid":"g7le-host-picker",role:"dialog","aria-modal":"true","aria-label":o("layout_editor.host_picker.title"),style:{position:"fixed",inset:0,zIndex:9500,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(15, 23, 42, 0.55)"},children:i.jsxs("div",{className:"g7le-host-picker__panel",style:{width:"min(520px, 92vw)",maxHeight:"80vh",overflow:"auto",background:"#ffffff",color:"#0f172a",borderRadius:12,boxShadow:"0 20px 48px rgba(15, 23, 42, 0.28)",padding:"20px 22px"},children:[i.jsx("h2",{className:"g7le-host-picker__title",style:{margin:"0 0 6px",fontSize:16,fontWeight:700},children:o("layout_editor.host_picker.title")}),i.jsx("p",{className:"g7le-host-picker__desc",style:{margin:"0 0 16px",fontSize:13,color:"#475569",lineHeight:1.6},children:t?o("layout_editor.host_picker.description_with_label",{label:t}):o("layout_editor.host_picker.description")}),i.jsx("ul",{className:"g7le-host-picker__list",style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:8},children:e.map(r=>i.jsx("li",{children:i.jsxs("button",{type:"button",className:"g7le-host-picker__item","data-testid":"g7le-host-picker-item","data-host":r,onClick:()=>n(r),style:{width:"100%",textAlign:"left",padding:"12px 14px",border:"1px solid #e2e8f0",borderRadius:8,background:"#f8fafc",cursor:"pointer",fontSize:13,fontWeight:600,color:"#0f172a",display:"flex",alignItems:"center",gap:8},children:[i.jsx("span",{"aria-hidden":!0,style:{fontSize:14},children:"🖼"}),i.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:r}),i.jsx("span",{"aria-hidden":!0,style:{color:"#94a3b8"},children:"→"})]})},r))})]})})}function RD(e,t){const[n,o]=u.useState(!1),[r,s]=u.useState(null),a=u.useCallback(async l=>{if(!t||!l)return{kind:"no_document"};o(!0),s(null);try{const d=_o(l),c=`/api/admin/templates/${encodeURIComponent(e)}/layouts/${t}/preview`,p=await fetch(c,{method:"POST",credentials:"same-origin",headers:Ne({"Content-Type":"application/json"}),body:JSON.stringify({content:JSON.stringify(d)})}),f=await p.json().catch(()=>null);if(!p.ok){const h=f?.message??`HTTP ${p.status}`;return s(h),{kind:"network_error",message:h}}const b=f?.data,g=typeof b?.token=="string"?b.token:"",m=typeof b?.preview_url=="string"&&b.preview_url?b.preview_url:g?`/preview/${g}`:"";return m?(window.G7Core?.dispatch?.({handler:"openWindow",params:{path:m}}),{kind:"success",previewUrl:m,token:g}):(s("invalid preview response"),{kind:"network_error",message:"invalid preview response"})}catch(d){const c=d instanceof Error?d.message:"network error";return s(c),{kind:"network_error",message:c}}finally{o(!1)}},[e,t]);return{isCreating:n,error:r,createPreview:a}}const re="layout_editor.action_recipe",bn={setState:{label:`$t:${re}.set_state.label`,params:[{key:"target",label:`$t:${re}.set_state.param_target`,widget:"select",options:[{value:"local"},{value:"global"}]},{key:"state",label:`$t:${re}.set_state.param_state`,widget:"state-key-value"},{key:"merge",label:`$t:${re}.set_state.param_merge`,widget:"toggle"}],build:{handler:"setState",params:{target:"{{target}}",merge:"{{merge}}","...":"{{state}}"}}},loadFromLocalStorage:{label:`$t:${re}.load_local.label`,params:[{key:"key",label:`$t:${re}.load_local.param_key`,widget:"text",required:!0},{key:"stateKey",label:`$t:${re}.load_local.param_state_key`,widget:"state-key-picker"},{key:"defaultValue",label:`$t:${re}.load_local.param_default`,widget:"text"}],build:{handler:"loadFromLocalStorage",params:{key:"{{key}}",stateKey:"{{stateKey}}",defaultValue:"{{defaultValue}}"}}},saveToLocalStorage:{label:`$t:${re}.save_local.label`,params:[{key:"key",label:`$t:${re}.save_local.param_key`,widget:"text",required:!0},{key:"value",label:`$t:${re}.save_local.param_value`,widget:"data-chip"}],build:{handler:"saveToLocalStorage",params:{key:"{{key}}",value:"{{value}}"}}},navigate:{label:`$t:${re}.navigate.label`,params:[{key:"path",label:`$t:${re}.navigate.param_path`,widget:"page-picker",required:!0},{key:"query",label:`$t:${re}.navigate.param_query`,widget:"key-value"},{key:"mergeQuery",label:`$t:${re}.navigate.param_merge_query`,widget:"toggle"},{key:"scroll",label:`$t:${re}.navigate.param_scroll`,widget:"select",options:[{value:"top"},{value:"preserve"},{value:"none"}]},{key:"replace",label:`$t:${re}.navigate.param_replace`,widget:"toggle"},{key:"transition_overlay_target",label:`$t:${re}.navigate.param_overlay_target`,widget:"component-target-picker",dependsOn:{param:"replace",equals:!0}}],build:{handler:"navigate",params:{path:"{{path}}",query:"{{query}}",mergeQuery:"{{mergeQuery}}",scroll:"{{scroll}}",replace:"{{replace}}",transition_overlay_target:"{{transition_overlay_target}}"}}},openWindow:{label:`$t:${re}.open_window.label`,params:[{key:"target",label:`$t:${re}.open_window.param_target`,widget:"page-picker",required:!0},{key:"windowTarget",label:`$t:${re}.open_window.param_window_target`,widget:"select",options:[{value:"_blank"},{value:"_self"}]}],build:{handler:"openWindow",target:"{{target}}",params:{windowTarget:"{{windowTarget}}"}}},navigateBack:{label:`$t:${re}.navigate_back.label`,params:[],build:{handler:"navigateBack"}},navigateForward:{label:`$t:${re}.navigate_forward.label`,params:[],build:{handler:"navigateForward"}},replaceUrl:{label:`$t:${re}.replace_url.label`,params:[{key:"path",label:`$t:${re}.replace_url.param_path`,widget:"page-picker"},{key:"query",label:`$t:${re}.replace_url.param_query`,widget:"key-value"}],build:{handler:"replaceUrl",params:{path:"{{path}}",query:"{{query}}"}}},toast:{label:`$t:${re}.toast.label`,params:[{key:"message",label:`$t:${re}.toast.param_message`,widget:"i18n-text",required:!0},{key:"type",label:`$t:${re}.toast.param_type`,widget:"select",options:[{value:"info"},{value:"success"},{value:"warning"},{value:"error"}]},{key:"duration",label:`$t:${re}.toast.param_duration`,widget:"number"},{key:"icon",label:`$t:${re}.toast.param_icon`,widget:"text"}],build:{handler:"toast",params:{message:"{{message}}",type:"{{type}}",duration:"{{duration}}",icon:"{{icon}}"}}},openModal:{label:`$t:${re}.open_modal.label`,params:[{key:"target",label:`$t:${re}.open_modal.param_target`,widget:"modal-picker",required:!0}],build:{handler:"openModal",target:"{{target}}"}},closeModal:{label:`$t:${re}.close_modal.label`,params:[],build:{handler:"closeModal"}},showAlert:{label:`$t:${re}.show_alert.label`,params:[{key:"target",label:`$t:${re}.show_alert.param_message`,widget:"i18n-text",required:!0}],build:{handler:"showAlert",target:"{{target}}"}},setError:{label:`$t:${re}.set_error.label`,params:[{key:"target",label:`$t:${re}.set_error.param_message`,widget:"i18n-text"},{key:"stateTarget",label:`$t:${re}.set_error.param_state_target`,widget:"select",options:[{value:"local"},{value:"global"}]}],build:{handler:"setError",target:"{{target}}",params:{stateTarget:"{{stateTarget}}"}}},refetchDataSource:{label:`$t:${re}.refetch.label`,params:[{key:"dataSourceId",label:`$t:${re}.refetch.param_data_source`,widget:"datasource-picker",required:!0},{key:"sync",label:`$t:${re}.refetch.param_sync`,widget:"toggle"}],build:{handler:"refetchDataSource",params:{dataSourceId:"{{dataSourceId}}",sync:"{{sync}}"}}},appendDataSource:{label:`$t:${re}.append_data.label`,params:[{key:"dataSourceId",label:`$t:${re}.append_data.param_data_source`,widget:"datasource-picker",required:!0},{key:"dataPath",label:`$t:${re}.append_data.param_data_path`,widget:"text"},{key:"newData",label:`$t:${re}.append_data.param_new_data`,widget:"data-chip"}],build:{handler:"appendDataSource",params:{dataSourceId:"{{dataSourceId}}",dataPath:"{{dataPath}}",newData:"{{newData}}"}}},updateDataSource:{label:`$t:${re}.update_data.label`,params:[{key:"dataSourceId",label:`$t:${re}.update_data.param_data_source`,widget:"datasource-picker",required:!0},{key:"data",label:`$t:${re}.update_data.param_data`,widget:"data-chip"},{key:"merge",label:`$t:${re}.update_data.param_merge`,widget:"toggle"}],build:{handler:"updateDataSource",params:{dataSourceId:"{{dataSourceId}}",data:"{{data}}",merge:"{{merge}}"}}},scrollIntoView:{label:`$t:${re}.scroll.label`,params:[{key:"selector",label:`$t:${re}.scroll.param_selector`,widget:"text",required:!0},{key:"behavior",label:`$t:${re}.scroll.param_behavior`,widget:"select",options:[{value:"smooth"},{value:"auto"}]},{key:"block",label:`$t:${re}.scroll.param_block`,widget:"select",options:[{value:"start"},{value:"center"},{value:"end"},{value:"nearest"}]}],build:{handler:"scrollIntoView",params:{selector:"{{selector}}",behavior:"{{behavior}}",block:"{{block}}"}}},login:{label:`$t:${re}.login.label`,params:[{key:"body",label:`$t:${re}.login.param_body`,widget:"key-value"}],build:{handler:"login",params:{body:"{{body}}"}}},loginTwoFactor:{label:`$t:${re}.login_two_factor.label`,params:[{key:"body",label:`$t:${re}.login_two_factor.param_body`,widget:"key-value"}],build:{handler:"loginTwoFactor",params:{body:"{{body}}"}}},loginTwoFactorResend:{label:`$t:${re}.login_two_factor_resend.label`,params:[{key:"body",label:`$t:${re}.login_two_factor_resend.param_body`,widget:"key-value"}],build:{handler:"loginTwoFactorResend",params:{body:"{{body}}"}}},logout:{label:`$t:${re}.logout.label`,params:[{key:"target",label:`$t:${re}.logout.param_target`,widget:"text"}],build:{handler:"logout",target:"{{target}}"}},setLocale:{label:`$t:${re}.set_locale.label`,params:[{key:"target",label:`$t:${re}.set_locale.param_target`,widget:"locale-picker",required:!0}],build:{handler:"setLocale",target:"{{target}}"}},emitEvent:{label:`$t:${re}.emit_event.label`,params:[{key:"event",label:`$t:${re}.emit_event.param_event`,widget:"text",required:!0},{key:"data",label:`$t:${re}.emit_event.param_data`,widget:"data-chip"}],build:{handler:"emitEvent",params:{event:"{{event}}",data:"{{data}}"}}},apiCall:{label:`$t:${re}.api_call.label`,params:[{key:"target",label:`$t:${re}.api_call.param_target`,widget:"page-picker",required:!0},{key:"method",label:`$t:${re}.api_call.param_method`,widget:"select",options:[{value:"GET"},{value:"POST"},{value:"PUT"},{value:"PATCH"},{value:"DELETE"}]},{key:"body",label:`$t:${re}.api_call.param_body`,widget:"key-value"},{key:"query",label:`$t:${re}.api_call.param_query`,widget:"key-value"},{key:"identity_target_email",label:`$t:${re}.api_call.param_identity_target_email`,widget:"data-chip"},{key:"identity_target_phone",label:`$t:${re}.api_call.param_identity_target_phone`,widget:"data-chip"},{key:"onSuccess",label:`$t:${re}.api_call.param_on_success`,widget:"action-list"},{key:"onError",label:`$t:${re}.api_call.param_on_error`,widget:"action-list"}],build:{handler:"apiCall",target:"{{target}}",identity_target:{email:"{{identity_target_email}}",phone:"{{identity_target_phone}}"},onSuccess:"{{onSuccess}}",onError:"{{onError}}",params:{method:"{{method}}",body:"{{body}}",query:"{{query}}"}}},conditions:{label:`$t:${re}.conditions.label`,params:[{key:"branches",label:`$t:${re}.conditions.param_branches`,widget:"branch-list"}],build:{handler:"conditions",conditions:"{{branches}}"}},sequence:{label:`$t:${re}.sequence.label`,params:[{key:"actions",label:`$t:${re}.sequence.param_actions`,widget:"action-list"}],build:{handler:"sequence",params:{actions:"{{actions}}"}}},parallel:{label:`$t:${re}.parallel.label`,params:[{key:"actions",label:`$t:${re}.parallel.param_actions`,widget:"action-list"}],build:{handler:"parallel",params:{actions:"{{actions}}"}}},switch:{label:`$t:${re}.switch.label`,params:[{key:"value",label:`$t:${re}.switch.param_value`,widget:"data-chip"},{key:"cases",label:`$t:${re}.switch.param_cases`,widget:"action-list",advanced:!0}],build:{handler:"switch",params:{value:"{{value}}",cases:"{{cases}}"}}},suppress:{label:`$t:${re}.suppress.label`,params:[],build:{handler:"suppress"}}};function e8(){return{actionRecipes:bn,initActionRecipes:bn,errorRecipes:{navigate:bn.navigate,openModal:bn.openModal,toast:bn.toast,setState:bn.setState,sequence:bn.sequence,parallel:bn.parallel,showErrorPage:{label:`$t:${re}.show_error_page.label`,params:[{key:"target",label:`$t:${re}.show_error_page.param_target`,widget:"select",options:[{value:"content"},{value:"full"}]}],build:{handler:"showErrorPage",params:{target:"{{target}}"}}}}}}function nl(e,t){return typeof e.label=="string"?e.label.startsWith("$t:")?t(e.label.slice(3)):e.label:String(e.value)}function wi(e){return Array.isArray(e.options)?e.options:[]}function t8({control:e,value:t,onChange:n,t:o}){const r=wi(e);return i.jsx("div",{className:"g7le-widget g7le-widget--segmented","data-testid":"g7le-widget-segmented",style:f8,children:r.map(s=>{const a=s.value===t;return i.jsx("button",{type:"button","data-testid":`g7le-segment-${String(s.value)}`,"data-active":a?"true":"false",onClick:()=>n(a?void 0:s.value),style:{...x8,background:a?"#2563eb":"#fff",color:a?"#fff":"#0f172a",borderColor:a?"#2563eb":"#cbd5e1"},children:nl(s,o)},String(s.value))})})}function n8({control:e,value:t,onChange:n,t:o}){const r=Array.isArray(e.scale)?e.scale:[],s=r.findIndex(l=>l===t),a=t!=null;return i.jsxs("div",{className:"g7le-widget g7le-widget--slider","data-testid":"g7le-widget-slider",style:Bg,children:[i.jsxs("label",{style:ol,children:[i.jsx("input",{type:"checkbox","data-testid":"g7le-slider-enabled",checked:a,onChange:l=>{l.target.checked?n(r.length>0?r[Math.max(0,s===-1?0:s)]:void 0):n(void 0)}}),i.jsx("span",{style:{fontSize:12,color:"#64748b"},children:o("layout_editor.control.use")})]}),i.jsx("input",{type:"range","data-testid":"g7le-slider-range",min:0,max:Math.max(0,r.length-1),step:1,disabled:!a||r.length===0,value:s===-1?0:s,onChange:l=>{const d=Number(l.target.value);n(r[d])},style:{flex:1}}),i.jsx("span",{"data-testid":"g7le-slider-value",style:{fontSize:12,color:"#0f172a",minWidth:48,textAlign:"right"},children:a?String(t):o("layout_editor.control.default")})]})}function o8({control:e,value:t,onChange:n,t:o}){const r=wi(e);return i.jsxs("select",{className:"g7le-widget g7le-widget--select","data-testid":"g7le-widget-select",value:t==null?"":String(t),onChange:s=>{const a=s.target.value;if(a===""){n(void 0);return}const l=r.find(d=>String(d.value)===a);n(l?l.value:a)},style:w8,children:[i.jsx("option",{value:"",children:o("layout_editor.control.default")}),r.map(s=>i.jsx("option",{value:String(s.value),children:nl(s,o)},String(s.value)))]})}function r8({control:e,value:t,onChange:n}){const o=wi(e),r=o[1]?.value??!0,s=o[0]?.value??void 0,a=t===r;return i.jsx("button",{type:"button",className:"g7le-widget g7le-widget--toggle","data-testid":"g7le-widget-toggle",role:"switch","aria-checked":a,onClick:()=>n(a?s:r),style:{...k8,background:a?"#2563eb":"#cbd5e1"},children:i.jsx("span",{style:{...S8,transform:a?"translateX(18px)":"translateX(0)"}})})}function i8({control:e,value:t,onChange:n,t:o,freeValueDisabled:r}){const s=wi(e),a=t==null?"":String(t),[l,d]=u.useState(a);u.useEffect(()=>{d(a)},[a]);const c=p=>{const f=p.trim();if(f===""){n(void 0);return}n(f)};return i.jsxs("div",{className:"g7le-widget g7le-widget--dimension","data-testid":"g7le-widget-dimension",style:g8,children:[r?i.jsx("div",{"data-testid":"g7le-dimension-free-disabled",style:v8,children:o("layout_editor.property_modal.dark_preset_only")}):i.jsxs("div",{style:h8,children:[i.jsx("input",{type:"text","data-testid":"g7le-dimension-input",value:l,placeholder:o("layout_editor.control.dimension.placeholder"),onChange:p=>d(p.target.value),onBlur:p=>c(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),c(p.target.value))},style:y8}),i.jsx("button",{type:"button","data-testid":"g7le-dimension-clear",title:o("layout_editor.control.default"),onClick:()=>{d(""),n(void 0)},style:b8,children:o("layout_editor.control.default")})]}),s.length>0&&i.jsx("div",{style:m8,"data-testid":"g7le-dimension-chips",children:s.map(p=>{const f=String(p.value),b=f===a;return i.jsx("button",{type:"button","data-testid":`g7le-dimension-chip-${f}`,"data-active":b?"true":"false",onClick:()=>{d(f),n(f)},style:{..._8,background:b?"#2563eb":"#fff",color:b?"#fff":"#0f172a",borderColor:b?"#2563eb":"#cbd5e1"},children:nl(p,o)},f)})})]})}function s8(e){return[{key:"t",infix:`${e}t-`,labelKey:"layout_editor.control.spacing.top"},{key:"r",infix:`${e}r-`,labelKey:"layout_editor.control.spacing.right"},{key:"b",infix:`${e}b-`,labelKey:"layout_editor.control.spacing.bottom"},{key:"l",infix:`${e}l-`,labelKey:"layout_editor.control.spacing.left"}]}function a8(e,t,n,o){const r={all:-1,sides:{}};if(typeof e!="string"||e.trim()==="")return r;const s=e.split(/\s+/).filter(a=>a.length>0);for(const a of s){const l=n.find(d=>a.startsWith(d.infix));if(l){r.sides[l.key]=o.indexOf(a.slice(l.infix.length));continue}if(a.startsWith(`${t}x-`)){const d=o.indexOf(a.slice(`${t}x-`.length));r.sides.l=d,r.sides.r=d;continue}if(a.startsWith(`${t}y-`)){const d=o.indexOf(a.slice(`${t}y-`.length));r.sides.t=d,r.sides.b=d;continue}a.startsWith(`${t}-`)&&(r.all=o.indexOf(a.slice(`${t}-`.length)))}return r}function l8({control:e,value:t,onChange:n,t:o}){const r=typeof e.spacingPrefix=="string"?e.spacingPrefix:"p",s=(Array.isArray(e.scale)?e.scale:[]).map(y=>String(y)),a=s8(r),l=a8(t,r,a,s),d=Object.values(l.sides).some(y=>y>=0),c=l.all>=0||d,[p,f]=u.useState(d);u.useEffect(()=>{d&&f(!0)},[d]);const b=Math.min(4,Math.max(0,s.length-1)),g=y=>{const _=[];for(const w of a){const k=y[w.key];k!==void 0&&k>=0&&_.push(`${w.infix}${s[k]}`)}n(_.length>0?_.join(" "):void 0)},m=y=>{n(y>=0?`${r}-${s[Math.max(0,Math.min(y,s.length-1))]}`:void 0)},h=()=>({...l.sides}),v=(y,_,w,k,x)=>{const $=w>=0;return i.jsxs("div",{style:p8,"data-testid":y,children:[i.jsxs("label",{style:{...ol,minWidth:64},children:[i.jsx("input",{type:"checkbox","data-testid":`${y}-enabled`,checked:$,onChange:S=>x(S.target.checked)}),i.jsx("span",{style:{fontSize:12,color:"#0f172a"},children:o(_)})]}),i.jsx("input",{type:"range","data-testid":`${y}-range`,min:0,max:Math.max(0,s.length-1),step:1,disabled:!$||s.length===0,value:w<0?0:w,onChange:S=>k(Number(S.target.value)),style:{flex:1}}),i.jsx("span",{"data-testid":`${y}-value`,style:{fontSize:12,color:$?"#0f172a":"#94a3b8",minWidth:28,textAlign:"right"},children:$?s[w]:"–"})]},y)};return i.jsxs("div",{className:"g7le-widget g7le-widget--spacing","data-testid":"g7le-widget-spacing",style:d8,children:[i.jsxs("div",{style:c8,children:[i.jsxs("div",{style:u8,"data-testid":"g7le-spacing-mode",children:[i.jsx("button",{type:"button","data-testid":"g7le-spacing-mode-all","data-active":p?"false":"true",onClick:()=>{f(!1),d&&n(void 0)},style:{...Og,background:p?"#fff":"#2563eb",color:p?"#0f172a":"#fff",borderColor:p?"#cbd5e1":"#2563eb"},children:o("layout_editor.control.spacing.mode_all")}),i.jsx("button",{type:"button","data-testid":"g7le-spacing-mode-sides","data-active":p?"true":"false",onClick:()=>{if(f(!0),l.all>=0){const y={};for(const _ of a)y[_.key]=l.all;g(y)}},style:{...Og,background:p?"#2563eb":"#fff",color:p?"#fff":"#0f172a",borderColor:p?"#2563eb":"#cbd5e1"},children:o("layout_editor.control.spacing.mode_sides")})]}),i.jsx("span",{"data-testid":"g7le-spacing-value",style:{fontSize:11,color:"#64748b",minWidth:80,textAlign:"right"},children:c?String(t):o("layout_editor.control.default")})]}),p?i.jsx("div",{"data-testid":"g7le-spacing-sides",style:{display:"flex",flexDirection:"column",gap:4},children:a.map(y=>v(`g7le-spacing-side-${y.key}`,y.labelKey,l.sides[y.key]??-1,_=>{const w=h();w[y.key]=_,g(w)},_=>{const w=h();_?w[y.key]=l.sides[y.key]>=0?l.sides[y.key]:b:delete w[y.key],g(w)}))}):i.jsxs("div",{style:Bg,children:[i.jsxs("label",{style:{...ol,minWidth:64},children:[i.jsx("input",{type:"checkbox","data-testid":"g7le-spacing-all-enabled",checked:l.all>=0,onChange:y=>m(y.target.checked?b:-1)}),i.jsx("span",{style:{fontSize:12,color:"#64748b"},children:o("layout_editor.control.spacing.all")})]}),i.jsx("input",{type:"range","data-testid":"g7le-spacing-all-range",min:0,max:Math.max(0,s.length-1),step:1,disabled:l.all<0||s.length===0,value:l.all<0?0:l.all,onChange:y=>m(Number(y.target.value)),style:{flex:1}}),i.jsx("span",{"data-testid":"g7le-spacing-all-value",style:{fontSize:12,color:l.all>=0?"#0f172a":"#94a3b8",minWidth:28,textAlign:"right"},children:l.all>=0?s[l.all]:"–"})]})]})}const d8={display:"flex",flexDirection:"column",gap:6,width:"100%"},c8={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},u8={display:"inline-flex",gap:0,border:"1px solid #cbd5e1",borderRadius:6,overflow:"hidden"},Og={padding:"3px 10px",fontSize:11,border:"none",borderRight:"1px solid #e2e8f0",cursor:"pointer"},p8={display:"flex",alignItems:"center",gap:8,width:"100%"},f8={display:"inline-flex",gap:0,border:"1px solid #cbd5e1",borderRadius:6,overflow:"hidden"},g8={display:"flex",flexDirection:"column",gap:6,width:"100%"},h8={display:"flex",gap:6,alignItems:"center"},y8={flex:1,padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,minWidth:80},b8={padding:"4px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#64748b",cursor:"pointer",whiteSpace:"nowrap"},m8={display:"flex",flexWrap:"wrap",gap:4},v8={fontSize:11,color:"#94a3b8",fontStyle:"italic",padding:"2px 0"},_8={padding:"3px 9px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:999,background:"#fff",cursor:"pointer"},x8={padding:"4px 10px",fontSize:12,border:"none",borderRight:"1px solid #e2e8f0",cursor:"pointer"},Bg={display:"flex",alignItems:"center",gap:8,width:"100%"},ol={display:"inline-flex",alignItems:"center",gap:4},w8={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",minWidth:120},k8={position:"relative",width:38,height:20,borderRadius:10,border:"none",cursor:"pointer",padding:2,display:"inline-flex",alignItems:"center",transition:"background 120ms ease"},S8={display:"block",width:16,height:16,borderRadius:8,background:"#fff",transition:"transform 120ms ease"},C8=["#0f172a","#334155","#64748b","#94a3b8","#e2e8f0","#ffffff","#dc2626","#ea580c","#d97706","#16a34a","#0891b2","#2563eb","#7c3aed","#db2777"],Wg=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;function $8(e){return Array.isArray(e.options)?e.options.filter(t=>typeof t.value=="string").map(t=>({value:t.value,swatch:typeof t.swatch=="string"?t.swatch:void 0,label:typeof t.label=="string"?t.label:void 0})):[]}function E8({control:e,value:t,onChange:n,t:o,freeValueDisabled:r}){const s=$8(e),a=s.length>0,l=typeof t=="string"&&s.some(g=>g.value===t)?t:"",d=typeof t=="string"&&Wg.test(t)?t:"",[c,p]=u.useState(d);u.useEffect(()=>{p(d)},[d]);const f=g=>{const m=g.trim();if(m===""){n(void 0);return}const h=m.startsWith("#")?m:`#${m}`;Wg.test(h)&&n(h)},b=C8;return i.jsxs("div",{className:"g7le-widget g7le-widget--color","data-testid":"g7le-widget-color",style:I8,children:[r?i.jsx("div",{"data-testid":"g7le-color-free-disabled",style:M8,children:o("layout_editor.property_modal.dark_preset_only")}):i.jsxs("div",{style:A8,children:[i.jsxs("label",{style:T8,children:[i.jsx("span",{"data-testid":"g7le-color-swatch",style:{...D8,background:d||"transparent",backgroundImage:d?void 0:"linear-gradient(45deg,#e2e8f0 25%,transparent 25%,transparent 75%,#e2e8f0 75%),linear-gradient(45deg,#e2e8f0 25%,#fff 25%,#fff 75%,#e2e8f0 75%)",backgroundSize:"8px 8px",backgroundPosition:"0 0, 4px 4px"}}),i.jsx("input",{type:"color","data-testid":"g7le-color-native",value:d||"#000000",onChange:g=>n(g.target.value),style:{width:0,height:0,opacity:0,position:"absolute"}})]}),i.jsx("input",{type:"text","data-testid":"g7le-color-hex",value:c,placeholder:o("layout_editor.control.color_hex_placeholder"),onChange:g=>p(g.target.value),onBlur:g=>f(g.target.value),onKeyDown:g=>{g.key==="Enter"&&f(g.target.value)},style:z8}),i.jsx("button",{type:"button","data-testid":"g7le-color-clear",onClick:()=>n(void 0),style:N8,children:o("layout_editor.control.default")})]}),a?i.jsx("div",{style:jg,"data-testid":"g7le-color-token-presets",children:s.map(g=>{const m=l===g.value,h=g.label?g.label.startsWith("$t:")?o(g.label.slice(3)):g.label:g.value;return i.jsx("button",{type:"button","aria-label":h,title:h,"data-testid":`g7le-color-token-${g.value}`,"data-active":m?"true":"false",onClick:()=>n(m?void 0:g.value),style:{...Hg,background:g.swatch||"#e2e8f0",outline:m?"2px solid #2563eb":"none"}},g.value)})}):!r&&i.jsx("div",{style:jg,"data-testid":"g7le-color-presets",children:b.map(g=>i.jsx("button",{type:"button","aria-label":g,"data-testid":`g7le-color-preset-${g}`,onClick:()=>n(g),style:{...Hg,background:g,outline:d.toLowerCase()===g.toLowerCase()?"2px solid #2563eb":"none"}},g))})]})}const I8={display:"flex",flexDirection:"column",gap:8},A8={display:"flex",alignItems:"center",gap:6},T8={position:"relative",display:"inline-flex",cursor:"pointer"},D8={width:24,height:24,borderRadius:4,border:"1px solid #cbd5e1",display:"inline-block"},z8={flex:1,padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,fontFamily:"monospace"},N8={padding:"4px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",cursor:"pointer",color:"#64748b"},jg={display:"grid",gridTemplateColumns:"repeat(7, 1fr)",gap:4},Hg={width:"100%",height:18,borderRadius:4,border:"1px solid #cbd5e1",cursor:"pointer",padding:0},M8={fontSize:11,color:"#94a3b8",fontStyle:"italic",padding:"2px 0"},tr=[{value:"fill",labelKey:"layout_editor.control.background_image.mode_fill",size:"cover",repeat:"no-repeat"},{value:"fit",labelKey:"layout_editor.control.background_image.mode_fit",size:"contain",repeat:"no-repeat"},{value:"tile",labelKey:"layout_editor.control.background_image.mode_tile",size:"auto",repeat:"repeat"}];function L8(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Fg(e){return tr.find(n=>n.size===e.size&&n.repeat===e.repeat)?.value??"fill"}function P8({value:e,onChange:t,t:n}){const o=L8(e),{state:r}=Qe(),s=bo(),[a,l]=u.useState(!1),[d,c]=u.useState(null),[p,f]=u.useState(o.url??""),[b,g]=u.useState([]),m=u.useRef(null),h=r.templateIdentifier,v=r.selectedRoute?.layoutName??"";u.useEffect(()=>{f(o.url??"")},[o.url]);const y=u.useCallback(async()=>{if(!h||!v){g([]);return}const S=await Ll(h,v);S.ok&&g(S.data)},[h,v]);u.useEffect(()=>{y()},[y]);const _=S=>{if(!S){t(void 0);return}const C=tr.find(T=>T.value===Fg(o))??tr[0];t({url:S,size:o.size??C.size,repeat:o.repeat??C.repeat,position:o.position??"center"})},w=S=>{const C=tr.find(T=>T.value===S);!C||!o.url||t({url:o.url,size:C.size,repeat:C.repeat,position:o.position??"center"})},k=async S=>{const C=S.target.files?.[0];if(!C)return;l(!0),c(null);const T=await Pl(h,v,C);T.ok?(_(T.data.url),y()):c(n("layout_editor.control.background_image.upload_failed")),l(!1),m.current&&(m.current.value="")},x=async S=>{(await Ol(S.id)).ok&&g(T=>T.filter(E=>E.id!==S.id))},$=()=>{const S=s.open({ariaLabel:n("layout_editor.attachment_manager.title"),width:720,maxHeightRatio:.82,content:u.createElement(Bl,{templateIdentifier:h,layoutName:v,t:n,onSelect:C=>{_(C),s.close(S)},onChanged:()=>{y()},onClose:()=>s.close(S)})})};return i.jsxs("div",{className:"g7le-widget g7le-widget--image","data-testid":"g7le-widget-image",style:O8,children:[o.url&&i.jsx("div",{"data-testid":"g7le-image-preview",style:{...B8,backgroundImage:`url(${o.url})`,backgroundSize:o.size??"cover",backgroundRepeat:o.repeat??"no-repeat",backgroundPosition:o.position??"center"}}),i.jsxs("div",{style:W8,children:[i.jsxs("label",{style:j8,children:[a?"…":n("layout_editor.control.background_image.upload"),i.jsx("input",{ref:m,type:"file",accept:"image/*","data-testid":"g7le-image-file",onChange:k,disabled:a,style:{display:"none"}})]}),i.jsx("button",{type:"button","data-testid":"g7le-image-clear",onClick:()=>t(void 0),style:H8,children:n("layout_editor.control.background_image.clear")})]}),i.jsx("input",{type:"text","data-testid":"g7le-image-url",placeholder:"https://… / URL",value:p,onChange:S=>f(S.target.value),onBlur:S=>_(S.target.value.trim()||void 0),style:F8}),i.jsx("div",{style:K8,"data-testid":"g7le-image-modes",children:tr.map(S=>{const C=Fg(o)===S.value;return i.jsx("button",{type:"button","data-testid":`g7le-image-mode-${S.value}`,"data-active":C?"true":"false",disabled:!o.url,onClick:()=>w(S.value),style:{...V8,background:C&&o.url?"#2563eb":"#fff",color:C&&o.url?"#fff":"#0f172a"},children:n(S.labelKey)},S.value)})}),i.jsxs("div",{style:U8,"data-testid":"g7le-image-gallery",children:[i.jsxs("div",{style:q8,children:[i.jsx("span",{style:{fontSize:11,color:"#64748b"},children:n("layout_editor.attachment_manager.recent")}),i.jsxs("button",{type:"button","data-testid":"g7le-image-manage",onClick:$,style:G8,children:["🖼 ",n("layout_editor.attachment_manager.manage_link")]})]}),b.length>0?i.jsx("div",{style:Y8,"data-testid":"g7le-image-thumbs",children:b.slice(0,8).map(S=>i.jsxs("div",{style:X8,"data-testid":`g7le-image-thumb-${S.id}`,children:[i.jsx("button",{type:"button",title:S.original_name,onClick:()=>_(S.url),style:{...J8,backgroundImage:`url(${S.url})`},"data-testid":`g7le-image-thumb-use-${S.id}`}),i.jsx("button",{type:"button",title:n("layout_editor.attachment_manager.delete"),onClick:()=>x(S),style:Z8,"data-testid":`g7le-image-thumb-del-${S.id}`,children:"✕"})]},S.id))}):i.jsx("span",{style:{fontSize:11,color:"#94a3b8"},children:n("layout_editor.attachment_manager.empty")})]}),d&&i.jsx("span",{"data-testid":"g7le-image-error",style:{fontSize:11,color:"#dc2626"},children:d})]})}const O8={display:"flex",flexDirection:"column",gap:6},B8={width:"100%",height:80,borderRadius:6,border:"1px solid #cbd5e1"},W8={display:"flex",gap:6},j8={padding:"5px 10px",fontSize:12,border:"1px solid #2563eb",borderRadius:6,background:"#fff",color:"#2563eb",cursor:"pointer",display:"inline-flex",alignItems:"center"},H8={padding:"5px 10px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#64748b",cursor:"pointer"},F8={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6},K8={display:"inline-flex",border:"1px solid #cbd5e1",borderRadius:6,overflow:"hidden"},V8={padding:"4px 10px",fontSize:12,border:"none",borderRight:"1px solid #e2e8f0",cursor:"pointer"},U8={display:"flex",flexDirection:"column",gap:4,border:"1px solid #e2e8f0",borderRadius:6,padding:6,marginTop:2},q8={display:"flex",alignItems:"center",justifyContent:"space-between"},G8={fontSize:11,color:"#2563eb",background:"transparent",border:"none",cursor:"pointer",padding:0},Y8={display:"flex",gap:6,flexWrap:"wrap"},X8={position:"relative",width:44,height:44},J8={width:44,height:44,borderRadius:6,border:"1px solid #cbd5e1",backgroundSize:"cover",backgroundPosition:"center",cursor:"pointer",padding:0},Z8={position:"absolute",top:-6,right:-6,width:16,height:16,borderRadius:"50%",border:"none",background:"#dc2626",color:"#fff",fontSize:9,lineHeight:"16px",cursor:"pointer",padding:0};function Q8(e){return Array.isArray(e)&&e.every(t=>t!==null&&typeof t=="object"&&!Array.isArray(t))}function R8(e){return typeof e=="string"&&/\{\{.*\}\}/.test(e)}function ez({value:e,onChange:t,t:n,bindingCandidates:o}){if(R8(e))return i.jsx("div",{className:"g7le-widget g7le-widget--options-list","data-testid":"g7le-widget-options-list-bound",style:lz,children:n("layout_editor.list_editor.bound_degraded")});const r=Q8(e)?e:[],s=b=>{t(b.length===0?void 0:b)},a=(b,g)=>{const m=r.map((h,v)=>v===b?{...h,...g}:h);s(m)},l=b=>{s(r.filter((g,m)=>m!==b))},d=(b,g)=>{const m=b+g;if(m<0||m>=r.length)return;const h=[...r];[h[b],h[m]]=[h[m],h[b]],s(h)},c=()=>{s([...r,{value:"",label:""}])},p=b=>typeof b.label=="string"?b.label:b.label==null?"":String(b.label),f=b=>b.value===void 0||b.value===null?"":String(b.value);return i.jsxs("div",{className:"g7le-widget g7le-widget--options-list","data-testid":"g7le-widget-options-list",style:tz,children:[r.length===0&&i.jsx("div",{"data-testid":"g7le-options-empty",style:az,children:n("layout_editor.list_editor.empty")}),r.map((b,g)=>i.jsxs("div",{"data-testid":`g7le-options-row-${g}`,style:nz,children:[i.jsxs("div",{style:Kg,children:[i.jsx("span",{style:Vg,children:n("layout_editor.list_editor.option_value")}),i.jsx("input",{type:"text","data-testid":`g7le-options-value-${g}`,value:f(b),placeholder:n("layout_editor.list_editor.option_value"),onChange:m=>a(g,{value:m.target.value}),style:rz})]}),i.jsxs("div",{style:Kg,children:[i.jsx("span",{style:Vg,children:n("layout_editor.list_editor.option_label")}),i.jsx("div",{"data-testid":`g7le-options-label-${g}`,style:{flex:1,minWidth:0},children:i.jsx(_t,{value:p(b),onChange:m=>a(g,{label:m??""}),t:n,placeholder:n("layout_editor.list_editor.option_label"),testidPrefix:`g7le-options-label-i18n-${g}`,candidates:o,enableExpressionTree:!0,expressionTreeCollapsible:!0})})]}),i.jsxs("div",{style:oz,children:[i.jsx("button",{type:"button","data-testid":`g7le-options-up-${g}`,title:n("layout_editor.list_editor.move_up"),disabled:g===0,onClick:()=>d(g,-1),style:Ug,children:"↑"}),i.jsx("button",{type:"button","data-testid":`g7le-options-down-${g}`,title:n("layout_editor.list_editor.move_down"),disabled:g===r.length-1,onClick:()=>d(g,1),style:Ug,children:"↓"}),i.jsx("button",{type:"button","data-testid":`g7le-options-remove-${g}`,title:n("layout_editor.list_editor.remove"),onClick:()=>l(g),style:iz,children:"✕"})]})]},g)),i.jsx("button",{type:"button","data-testid":"g7le-options-add",onClick:c,style:sz,children:n("layout_editor.list_editor.add")})]})}const tz={display:"flex",flexDirection:"column",gap:8,width:"100%"},nz={display:"flex",flexDirection:"column",gap:4,width:"100%",minWidth:0,paddingBottom:6,borderBottom:"1px solid #f1f5f9"},Kg={display:"flex",gap:6,alignItems:"center",width:"100%",minWidth:0},Vg={flexShrink:0,width:36,fontSize:11,color:"#94a3b8",textAlign:"right"},oz={display:"flex",gap:4,alignItems:"center",justifyContent:"flex-end"},rz={flex:1,minWidth:0,padding:"4px 6px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6},Ug={padding:"2px 6px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},iz={padding:"2px 6px",fontSize:12,border:"1px solid #fecaca",borderRadius:6,background:"#fff",color:"#dc2626",cursor:"pointer"},sz={padding:"4px 8px",fontSize:12,border:"1px dashed #94a3b8",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",alignSelf:"flex-start"},az={fontSize:11,color:"#94a3b8",fontStyle:"italic"},lz={fontSize:11,color:"#b45309",fontStyle:"italic",padding:"4px 2px"},qg=/[^A-Za-z0-9\-_:.]/g;function dz(e){return typeof e=="string"&&Yi(e)}function Gg(e){return Yi(e)?In(e).map(t=>t.kind==="binding"?t.raw:t.raw.replace(qg,"")).join(""):e.replace(qg,"")}const cz={width:"100%",padding:"6px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:4,fontFamily:"monospace"},uz={marginTop:4,fontSize:11,color:"#94a3b8"},pz={display:"flex",gap:6,alignItems:"center"},fz={flexShrink:0,padding:"5px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:4,background:"#f8fafc",cursor:"pointer",whiteSpace:"nowrap"};function gz({value:e,onChange:t,t:n,bindingCandidates:o}){const r=e==null?"":String(e),s=dz(e),a=!!o&&o.length>0,[l,d]=u.useState(!1),c=p=>{const f=Gg(p);t(f===""?void 0:f)};return s||l?i.jsxs("div",{"data-testid":"g7le-core-id-chip",children:[i.jsx(_s,{value:r,onChange:c,t:n,candidates:o,onDone:()=>d(!1),testidPrefix:"g7le-core-id-chip-input"}),i.jsx("div",{style:uz,children:n("layout_editor.core_props.id.binding_hint")})]}):i.jsx("div",{children:i.jsxs("div",{style:pz,children:[i.jsx("input",{type:"text",className:"g7le-widget g7le-widget--core-id","data-testid":"g7le-widget-core-id",value:r,onChange:p=>{const f=Gg(p.target.value);t(f===""?void 0:f)},spellCheck:!1,autoComplete:"off",style:cz}),a&&i.jsxs("button",{type:"button","data-testid":"g7le-core-id-add-data",onClick:()=>d(!0),style:fz,title:n("layout_editor.core_props.id.add_data"),children:["🔗 ",n("layout_editor.core_props.id.add_data")]})]})})}const hz=/[^A-Za-z0-9.\-_]/g;function yz(e){return typeof e=="string"&&/\{\{[\s\S]*?\}\}/.test(e)}function bz(e){return e.replace(hz,"")}const Yg={width:"100%",padding:"6px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:4,fontFamily:"monospace",boxSizing:"border-box"},mz={...Yg,background:"#f1f5f9",color:"#64748b",cursor:"not-allowed"},Xg={marginTop:4,fontSize:11,color:"#94a3b8"};function vz({value:e,onChange:t,t:n}){const o=e==null?"":String(e);return yz(e)?i.jsxs("div",{"data-testid":"g7le-core-datakey-bound",children:[i.jsx("input",{type:"text",className:"g7le-widget g7le-widget--core-datakey-bound","data-testid":"g7le-widget-core-datakey",value:o,readOnly:!0,disabled:!0,style:mz}),i.jsx("div",{style:Xg,children:n("layout_editor.core_props.dataKey.bound_degraded")})]}):i.jsxs("div",{children:[i.jsx("input",{type:"text",className:"g7le-widget g7le-widget--core-datakey","data-testid":"g7le-widget-core-datakey",value:o,placeholder:n("layout_editor.core_props.dataKey.placeholder"),onChange:s=>{const a=bz(s.target.value);t(a===""?void 0:a)},spellCheck:!1,autoComplete:"off",style:Yg}),i.jsx("div",{style:Xg,children:n("layout_editor.core_props.dataKey.hint")})]})}let Jg=!1;function _z(){Jg||(Ze("segmented",t8),Ze("slider",n8),Ze("select",o8),Ze("dimension",i8),Ze("spacing",l8),Ze("toggle",r8),Ze("color",E8),Ze("image",P8),Ze("tag-input",vs),Ze("page-picker",P0),Ze("datasource-picker",Fc),Ze("binding-picker",Fc),Ze("binding-list",W0),Ze("state-key-picker",Ts),Ze("modal-picker",O0),Ze("i18n-text",B0),Ze("text",j0),Ze("options-list",ez),Ze("core-id",gz),Ze("core-datakey",vz),Ze("component-target-picker",p4),Jg=!0)}function nr(e){return Array.isArray(e.children)?e.children:[]}function or(e){if(typeof e.text=="string")return[];let t=null;const n=(o,r)=>{const s=nr(o);for(let a=0;ad===o?rr(l,r,n):l);return{...e,children:a}}function Zg(e,t){const n=r=>typeof r.props?.[t]=="string";if(n(e))return[];const o=(r,s)=>{const a=nr(r);for(let l=0;lc===r?Qg(d,s,n,o):d);return{...e,children:l}}function xz(e){return Array.isArray(e.children)?e.children:[]}function wz(e){const t=e?.itemFields;if(!Array.isArray(t))return[{kind:"text"}];const n=[];for(const o of t){if(!o||typeof o!="object")continue;const r=o;r.kind==="text"?n.push({kind:"text",label:typeof r.label=="string"?r.label:void 0}):r.kind==="prop"&&typeof r.prop=="string"&&r.prop.length>0&&n.push({kind:"prop",prop:r.prop,label:typeof r.label=="string"?r.label:void 0})}return n.length>0?n:[{kind:"text"}]}function rl(e,t){if(!(typeof e!="string"||e.length===0))return e.startsWith("$t:")?t(e.slice(3)):e}function Rg({node:e,params:t,spec:n,manifest:o,t:r,onPatchNode:s,templateIdentifier:a,candidates:l}){const d=typeof t?.childComponent=="string"?t.childComponent:null,c=t?.childTemplate&&typeof t.childTemplate=="object"?t.childTemplate:null,p=wz(t),f=rl(typeof t?.childLabel=="string"?t.childLabel:void 0,r)??d??"",b=xz(e),g=u.useCallback(x=>{s({...e,children:x})},[e,s]),m=u.useCallback(()=>{if(c)return JSON.parse(JSON.stringify(c));if(!d)return null;const x=n?.componentPalette?.entries?.[d];if(x?.defaultNode&&typeof x.defaultNode=="object")return JSON.parse(JSON.stringify(x.defaultNode));const $=o?.components??{};let S=null;for(const C of Object.values($))if(Array.isArray(C)){const T=C.find(E=>E.name===d);if(T){S=T;break}}return S?zf(S):{type:"basic",name:d}},[c,d,n,o]),h=u.useCallback(()=>{const x=m();if(x){if(x.text==="")x.text=r("layout_editor.list_editor.new_item");else{const $=or(x);if($!==null&&$.length>0){const S=ki(x,$);if(S&&S.text===""){const C=rr(x,$,r("layout_editor.list_editor.new_item"));g([...b,C]);return}}}g([...b,x])}},[m,g,b,r]),v=u.useCallback(x=>{g(b.filter(($,S)=>S!==x))},[g,b]),y=u.useCallback((x,$)=>{const S=x+$;if(S<0||S>=b.length)return;const C=[...b];[C[x],C[S]]=[C[S],C[x]],g(C)},[g,b]),_=u.useCallback((x,$)=>{if(typeof $!="string"||$.length===0)return;const S=b[x];if(!S)return;const C=or(S);if(C===null)return;const T=b.map((E,A)=>A===x?rr(E,C,$):E);g(T)},[b,g]),w=u.useCallback((x,$,S)=>{if(typeof S!="string"||S.length===0)return;const C=b[x];if(!C)return;const T=Zg(C,$);if(T===null)return;const E=b.map((A,N)=>N===x?Qg(A,T,$,S):A);g(E)},[b,g]);if(!d&&!c)return i.jsx("div",{className:"g7le-node-editor g7le-node-editor--children","data-testid":"g7le-children-editor-misconfigured",style:nh,children:r("layout_editor.list_editor.no_child_component")});const k=p.length>1||p.some(x=>x.label);return i.jsxs("div",{className:"g7le-node-editor g7le-node-editor--children","data-testid":"g7le-children-editor",style:kz,children:[i.jsx("div",{style:Sz,children:r("layout_editor.list_editor.items_title")}),b.length===0&&i.jsx("div",{"data-testid":"g7le-children-empty",style:nh,children:r("layout_editor.list_editor.empty")}),b.map((x,$)=>{const S=[];for(const T of p)if(T.kind==="text"){const E=or(x),A=E!==null?ki(x,E):null;A&&typeof A.text=="string"&&S.push({key:"text",caption:rl(T.label,r)??(k?r("layout_editor.list_editor.item_label"):void 0),value:A.text,onChange:N=>_($,N),testid:`g7le-children-i18n-${$}`})}else if(T.kind==="prop"&&T.prop){const E=Zg(x,T.prop);if(E!==null){const N=ki(x,E)?.props?.[T.prop];S.push({key:`prop-${T.prop}`,caption:rl(T.label,r)??T.prop,value:typeof N=="string"?N:"",onChange:D=>w($,T.prop,D),testid:`g7le-children-prop-${T.prop}-${$}`})}}const C=typeof x?.name=="string"?x.name:r("layout_editor.list_editor.item");return i.jsxs("div",{"data-testid":`g7le-children-row-${$}`,style:Cz,children:[S.length>0?S.map(T=>i.jsx("div",{style:eh,children:i.jsxs("div",{"data-testid":T.key==="text"?`g7le-children-text-${$}`:`g7le-children-field-${T.key}-${$}`,style:$z,children:[T.caption!==void 0&&i.jsx("div",{"data-testid":`g7le-children-caption-${T.key}-${$}`,style:Ez,children:T.caption}),i.jsx(_t,{value:T.value,onChange:T.onChange,t:r,placeholder:r("layout_editor.list_editor.item_text"),testidPrefix:T.testid,candidates:l,enableExpressionTree:!0,expressionTreeCollapsible:!0})]})},T.key)):i.jsx("div",{style:eh,children:i.jsx("span",{"data-testid":`g7le-children-label-${$}`,style:Az,children:C})}),i.jsxs("div",{style:Iz,children:[i.jsx("button",{type:"button","data-testid":`g7le-children-up-${$}`,title:r("layout_editor.list_editor.move_up"),disabled:$===0,onClick:()=>y($,-1),style:th,children:"↑"}),i.jsx("button",{type:"button","data-testid":`g7le-children-down-${$}`,title:r("layout_editor.list_editor.move_down"),disabled:$===b.length-1,onClick:()=>y($,1),style:th,children:"↓"}),i.jsx("button",{type:"button","data-testid":`g7le-children-remove-${$}`,title:r("layout_editor.list_editor.remove"),onClick:()=>v($),style:Tz,children:"✕"})]})]},$)}),i.jsx("button",{type:"button","data-testid":"g7le-children-add",onClick:h,style:Dz,children:r("layout_editor.list_editor.add_child",{component:f})})]})}const kz={display:"flex",flexDirection:"column",gap:6,width:"100%",marginBottom:12},Sz={fontSize:12,fontWeight:700,color:"#0f172a",marginBottom:2},Cz={display:"flex",flexDirection:"column",gap:4,width:"100%",minWidth:0,paddingBottom:6,borderBottom:"1px solid #f1f5f9"},eh={display:"flex",gap:4,alignItems:"flex-start",width:"100%",minWidth:0},$z={flex:1,minWidth:0},Ez={fontSize:11,color:"#64748b",marginBottom:2},Iz={display:"flex",gap:4,alignItems:"center",justifyContent:"flex-end"},Az={flex:1,minWidth:0,padding:"4px 6px",fontSize:12,color:"#475569",fontStyle:"italic",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},th={padding:"2px 6px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},Tz={padding:"2px 6px",fontSize:12,border:"1px solid #fecaca",borderRadius:6,background:"#fff",color:"#dc2626",cursor:"pointer"},Dz={padding:"4px 8px",fontSize:12,border:"1px dashed #94a3b8",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",alignSelf:"flex-start"},nh={fontSize:11,color:"#94a3b8",fontStyle:"italic"},go={rowContainer:"Tbody",row:"Tr",cell:"Td",headerCell:"Th",colSpanProp:"colSpan",rowSpanProp:"rowSpan"};function yt(e){return{rowContainer:e?.rowContainer??go.rowContainer,row:e?.row??go.row,cell:e?.cell??go.cell,headerCell:e?.headerCell??go.headerCell,colSpanProp:e?.colSpanProp??go.colSpanProp,rowSpanProp:e?.rowSpanProp??go.rowSpanProp}}function Bn(e){return e?Array.isArray(e.children)?e.children:[]:[]}function oh(e,t){const n=e.props?.[t],o=typeof n=="number"?n:typeof n=="string"?parseInt(n,10):NaN;return Number.isFinite(o)&&o>=1?Math.floor(o):1}function Pe(e,t){const n=yt(t),o=[],r=Bn(e),s=[];r.forEach((f,b)=>{(Bn(f).some(h=>h.name===n.row)||f.name===n.rowContainer||f.name==="Thead"||f.name==="Tfoot")&&s.push({container:f,containerIndex:b,isHeader:f.name==="Thead"})}),s.length===0&&r.some(f=>f.name===n.row)&&s.push({container:e,containerIndex:-1,isHeader:!1});const a=[],l=[];let d=0,c=0;const p=f=>{for(;a.length<=f;)a.push([]);return a[f]};s.forEach((f,b)=>{Bn(f.container).filter(m=>m.name===n.row).forEach((m,h)=>{const v=[],y=p(d);let _=0;Bn(m).filter(k=>k.name===n.cell||k.name===n.headerCell).forEach((k,x)=>{for(;y[_];)_++;const $=oh(k,n.colSpanProp),S=oh(k,n.rowSpanProp),C={cell:k,sectionIndex:b,rowIndexInSection:h,cellIndexInRow:x,gridRow:d,gridCol:_,colSpan:$,rowSpan:S,isHeader:k.name===n.headerCell};v.push(C);for(let T=0;T=0?(a.push(s.containerIndex),l=Bn(e)[s.containerIndex]??e):l=e;let d=-1,c=-1,p=null;const f=Bn(l);for(let m=0;m=r.gridRow&&t=r.gridCol&&nr){s=!0;break}if(s)break}s||t.add(r)}const n=Array.from(t).sort((r,s)=>r-s),o=[];for(let r=0;re.rows.find(l=>(l.cells[0]?.gridRow??-1)===a)?.sectionIndex??e.rows[a]?.sectionIndex??0,o=new Set([0,t]);for(let a=1;aa){l=!0;break}if(l)break}l||o.add(a)}const r=Array.from(o).sort((a,l)=>a-l),s=[];for(let a=0;at>=a.start&&t=o.length?{ok:!1,reason:"boundary"}:o[r].sectionIndex!==o[s].sectionIndex?{ok:!1,reason:"section"}:{ok:!0}}function Ci(e,t,n){const o=rh(e),r=o.findIndex(a=>t>=a.start&&t=o.length?{ok:!1,reason:"boundary"}:{ok:!0}}function Ge(e){return e?Array.isArray(e.children)?e.children:[]:[]}function mn(e,t,n){const o={...e.props??{}};n<=1?delete o[t]:o[t]=n;const r={...e,props:o};return Object.keys(o).length===0&&delete r.props,r}function $i(e,t,n=!1){const o={type:"basic",name:n?e.headerCell:e.cell},r=t?.props?.className;return typeof r=="string"&&r&&(o.props={className:r}),o.text="",o}function ir(e,t){return e.name===t.cell||e.name===t.headerCell}function nt(e,t,n,o){const r=t.sections[n];if(!r)return e;if(r.containerIndex===-1)return o(e);const s=Ge(e).map((a,l)=>l===r.containerIndex?o(a):a);return{...e,children:s}}function bt(e,t,n,o){let r=-1;const s=Ge(e).map(a=>a.name===t&&(r++,r===n)?o(a):a);return{...e,children:s}}function Ei(e,t,n){let o=-1;const r=Ge(e);for(let s=0;s0?nt(e,r,r.sections.length-1,_=>({..._,children:[...Ge(_),y]})):{...e,children:[...Ge(e),y]}}const s=Math.max(-1,Math.min(n,r.rows.length-1)),a=s<0?r.rows[0]:r.rows[s],l=a.cells[0]?.gridRow??s,d=s<0?0:l+1,c=a.sectionIndex,p=s<0?0:a.rowIndexInSection+1,f=[],b=[];let g=0;for(;g0?Ve(r,d-1,g):null;y&&y.gridRow+y.rowSpan>d&&y.rowSpan>1?(b.push(y),g+=y.colSpan):(f.push($i(o)),g+=1)}let m=e;for(const y of b)m=nt(m,r,y.sectionIndex,_=>bt(_,o.row,y.rowIndexInSection,w=>({...w,children:Ge(w).map((k,x)=>x===y.cellIndexInRow?mn(k,o.rowSpanProp,y.rowSpan+1):k)})));const h={type:"basic",name:o.row,children:f},v=Pe(m,t);return m=nt(m,v,c,y=>{const _=Ge(y);let w=0,k=_.length;for(let x=0;x<_.length;x++)if(_[x].name===o.row){if(w===p){k=x;break}w++}return{...y,children:[..._.slice(0,k),h,..._.slice(k)]}}),m}function sh(e,t,n){const o=yt(t),r=Pe(e,t);if(n<0||n>=r.rows.length||r.rows.length<=1)return e;const s=r.rows[n],a=s.cells[0]?.gridRow??n;let l=e;const d=new Set;for(let p=0;pbt(b,o.row,f.rowIndexInSection,g=>({...g,children:Ge(g).map((m,h)=>h===f.cellIndexInRow?mn(m,o.rowSpanProp,f.rowSpan-1):m)})))),p+=f?f.colSpan:1}const c=Pe(l,t);return l=nt(l,c,s.sectionIndex,p=>{let f=-1;const b=Ge(p).filter(g=>g.name===o.row?(f++,f!==s.rowIndexInSection):!0);return{...p,children:b}}),l}function ah(e,t,n,o){const r=yt(t),s=Pe(e,t);if(!Si(s,n,o).ok)return e;const a=ih(s),l=a.findIndex(h=>n>=h.start&&ns.rows.filter(v=>{const y=v.cells[0]?.gridRow??-1;return v.sectionIndex===f&&y>=h.start&&yv.rowIndexInSection),g=b(c),m=b(p);return g.length===0||m.length===0?e:nt(e,s,f,h=>{const v=[...Ge(h)],y=[];v.forEach((M,O)=>{M.name===r.row&&y.push(O)});const _=g.map(M=>y[M]).filter(M=>M!==void 0),w=m.map(M=>y[M]).filter(M=>M!==void 0);if(_.length===0||w.length===0)return h;const k=_.map(M=>v[M]),x=w.map(M=>v[M]),$=Math.min(..._)n>=m.start&&nk.gridCol>=f.start&&k.gridColk.gridCol>=b.start&&k.gridColk.cellIndexInRow),_=v.map(k=>k.cellIndexInRow),w=Pe(g,t);g=nt(g,w,m.sectionIndex,k=>bt(k,r.row,m.rowIndexInSection,x=>{const $=[...Ge(x)],S=y.map(M=>Ei(x,r,M)).filter(M=>M>=0),C=_.map(M=>Ei(x,r,M)).filter(M=>M>=0);if(S.length===0||C.length===0)return x;const T=S.map(M=>$[M]),E=C.map(M=>$[M]),A=Math.min(...S,...C),N=Math.max(...S,...C),D=[...E,...T],B=[...$.slice(0,A),...D,...$.slice(N+1)];return{...x,children:B}}))}return g}function dh(e,t,n){const o=yt(t),r=Pe(e,t);if(r.rows.length===0||r.colCount===0)return sl(e,t,-1);const s=Math.max(0,Math.min(n+1,r.colCount));let a=e;const l=new Set;for(const d of r.rows){const c=d.cells[0]?.gridRow??0,p=s>0?Ve(r,c,s-1):null,f=s1){if(!l.has(p.cell)){l.add(p.cell);const h=Pe(a,t);a=nt(a,h,p.sectionIndex,v=>bt(v,o.row,p.rowIndexInSection,y=>({...y,children:Ge(y).map((_,w)=>w===p.cellIndexInRow?mn(_,o.colSpanProp,p.colSpan+1):_)})))}continue}if(p&&p.gridRow0&&d.cells.every(h=>h.isHeader),m=Pe(a,t);a=nt(a,m,d.sectionIndex,h=>bt(h,o.row,d.rowIndexInSection,v=>{const y=[...Ge(v)];let _;if(b<0)_=y.findIndex(w=>ir(w,o)),_<0&&(_=y.length);else{const w=Ei(v,o,b);_=w<0?y.length:w+1}return y.splice(_,0,$i(o,void 0,g)),{...v,children:y}}))}return a}function ch(e,t,n){const o=yt(t),r=Pe(e,t);if(n<0||n>=r.colCount||r.colCount<=1)return e;let s=e;const a=new Set;for(const l of r.rows){const d=l.cells[0]?.gridRow??0,c=Ve(r,d,n);if(!(!c||a.has(c.cell)||c.gridRow1){const p=Pe(s,t);s=nt(s,p,c.sectionIndex,f=>bt(f,o.row,c.rowIndexInSection,b=>({...b,children:Ge(b).map((g,m)=>m===c.cellIndexInRow?mn(g,o.colSpanProp,c.colSpan-1):g)})))}else{const p=Pe(s,t);s=nt(s,p,c.sectionIndex,f=>bt(f,o.row,c.rowIndexInSection,b=>{let g=-1;const m=Ge(b).filter(h=>ir(h,o)?(g++,g!==c.cellIndexInRow):!0);return{...b,children:m}}))}}return s}function al(e,t,n,o,r,s){const a=yt(t),l=Pe(e,t),d=Math.min(n,r),c=Math.max(n,r),p=Math.min(o,s),f=Math.max(o,s);if(d===c&&p===f)return{table:e,ok:!1,reason:"single"};if(!l.valid)return{table:e,ok:!1,reason:"invalid-grid"};const b=new Set;for(let y=d;y<=c;y++)for(let _=p;_<=f;_++){const w=Ve(l,y,_);if(!w)return{table:e,ok:!1,reason:"hole"};if(w.gridRowc||w.gridCol+w.colSpan-1>f)return{table:e,ok:!1,reason:"not-rectangular"};b.add(w)}const g=Ve(l,d,p),m=Array.from(b).filter(y=>y!==g);let h=nt(e,l,g.sectionIndex,y=>bt(y,a.row,g.rowIndexInSection,_=>({..._,children:Ge(_).map((w,k)=>{if(k!==g.cellIndexInRow)return w;let x=mn(w,a.colSpanProp,f-p+1);return x=mn(x,a.rowSpanProp,c-d+1),x})})));const v=new Map;for(const y of m){const _=`${y.sectionIndex}:${y.rowIndexInSection}`,w=v.get(_)??[];w.push(y),v.set(_,w)}for(const[y,_]of v){const w=parseInt(y.split(":")[0],10),k=_[0].rowIndexInSection,x=new Set(_.map(S=>S.cellIndexInRow)),$=Pe(h,t);h=nt(h,$,w,S=>bt(S,a.row,k,C=>{let T=-1;const E=Ge(C).filter(A=>ir(A,a)?(T++,!x.has(T)):!0);return{...C,children:E}}))}return{table:h,ok:!0}}function uh(e,t,n,o){const r=yt(t),s=Pe(e,t),a=Ve(s,n,o);if(!a||a.colSpan<=1&&a.rowSpan<=1)return e;const l=a.gridRow,d=a.gridCol,c=a.gridRow+a.rowSpan-1,p=a.gridCol+a.colSpan-1,f=a.isHeader,b=typeof a.cell.props?.className=="string"?a.cell.props.className:void 0;let g=nt(e,s,a.sectionIndex,m=>bt(m,r.row,a.rowIndexInSection,h=>({...h,children:Ge(h).map((v,y)=>{if(y!==a.cellIndexInRow)return v;let _=mn(v,r.colSpanProp,1);return _=mn(_,r.rowSpanProp,1),_})})));for(let m=l;m<=c;m++)for(let h=d;h<=p;h++){if(m===l&&h===d)continue;const v=Pe(g,t),y=v.rows.find(k=>k.cells.some(x=>x.gridRow===m))??v.rows[m];if(!y)continue;let _=-1;for(const k of y.cells)k.gridRow===m&&k.gridColbt(k,r.row,y.rowIndexInSection,x=>{const $=[...Ge(x)];let S;if(_<0)S=$.findIndex(C=>ir(C,r)),S<0&&(S=$.length);else{const C=Ei(x,r,_);S=C<0?$.length:C+1}return $.splice(S,0,$i(r,w,f)),{...x,children:$}}))}return g}function Ii(e,t,n,o,r){const s=yt(t),a=Pe(e,t),l=Ve(a,n,o);return l?nt(e,a,l.sectionIndex,d=>bt(d,s.row,l.rowIndexInSection,c=>({...c,children:Ge(c).map((p,f)=>{if(f!==l.cellIndexInRow)return p;const b={...p.props??{}};r.trim()===""?delete b.className:b.className=r;const g={...p,props:b};return Object.keys(b).length===0&&delete g.props,g})}))):e}function Jt(e,t,n,o,r,s){const a=yt(t),l=Pe(e,t),d=Ve(l,n,o);return d?nt(e,l,d.sectionIndex,c=>bt(c,a.row,d.rowIndexInSection,p=>({...p,children:Ge(p).map((f,b)=>{if(b!==d.cellIndexInRow)return f;const g={...f.props??{}},m={...g.style??{}};!s||s.trim()===""?delete m[r]:m[r]=s,Object.keys(m).length===0?delete g.style:g.style=m;const h={...f,props:g};return Object.keys(g).length===0&&delete h.props,h})}))):e}function ho(e,t,n,o,r,s,a){const l=yt(t),d=Pe(e,t),c=Ve(d,n,o);if(!c)return e;const p=a==="dark";return nt(e,d,c.sectionIndex,f=>bt(f,l.row,c.rowIndexInSection,b=>({...b,children:Ge(b).map((g,m)=>{if(m!==c.cellIndexInRow)return g;const h={...g.props??{}},v=typeof h.className=="string"?h.className:"",y=mC(v,s,r,p);y===""?delete h.className:h.className=y;const _={...g,props:h};return Object.keys(h).length===0&&delete _.props,_})})))}function ph(e,t,n,o,r){const s=yt(t),a=Pe(e,t),l=Ve(a,n,o);return l?nt(e,a,l.sectionIndex,d=>bt(d,s.row,l.rowIndexInSection,c=>({...c,children:Ge(c).map((p,f)=>f===l.cellIndexInRow?{...p,text:r}:p)}))):e}function fh(e,t,n,o,r){const s=yt(t),a=Pe(e,t),l=Ve(a,n,o);return l?nt(e,a,l.sectionIndex,d=>bt(d,s.row,l.rowIndexInSection,c=>({...c,children:Ge(c).map((p,f)=>f===l.cellIndexInRow?r:p)}))):e}const gh=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;function zz(e){return e.split(/\s+/).filter(Boolean)}function hh(e,t){for(const n of t)if(e===n||/^-?\d+$/.test(e.slice(n.length+1))&&e.startsWith(n+"-"))return!0;return!1}function yh({className:e,catalog:t,t:n,onChange:o,colorScheme:r="light",onPresetToken:s,colorStyle:a,onColorStyle:l,disabled:d}){const c=t?.sides??[],p=t?.widths??[],f=t?.colors??[],b=r==="dark",g=u.useMemo(()=>c.map(E=>E.prefix),[c]),m=u.useMemo(()=>new Set(f.map(E=>E.token)),[f]),h=u.useMemo(()=>zz(e),[e]),v=u.useMemo(()=>Gr(e,b),[e,b]),y=u.useMemo(()=>v.find(E=>m.has(E))??null,[v,m]),_=u.useMemo(()=>{const E=new Set;for(const A of c)h.some(D=>D===A.prefix||D.startsWith(A.prefix+"-")&&/^-?\d+$/.test(D.slice(A.prefix.length+1)))&&E.add(A.value);return E},[h,c]),w=u.useMemo(()=>{const E=h.find(N=>hh(N,g));if(!E)return"none";const A=p.filter(N=>N.value!=="none");for(const N of c){if(E===N.prefix)return A.find(D=>(D.suffix??"")==="")?.value??"thin";if(E.startsWith(N.prefix+"-")){const D=E.slice(N.prefix.length),B=A.find(M=>(M.suffix??"")===D);if(B)return B.value}}return"thin"},[h,g,c,p]);if(!t||c.length===0||p.length===0)return null;function k(E){return E.filter(A=>!hh(A,g))}function x(E,A){const N=k(h),D=p.find(O=>O.value===A);if(!D||A==="none"||E.size===0)return N.join(" ").trim();const B=D.suffix??"",M=[...N];for(const O of c)E.has(O.value)&&M.push(B?`${O.prefix}${B}`:O.prefix);return M.join(" ").trim()}const $=E=>{const A=new Set(_);A.has(E)?A.delete(E):(E==="all"?A.clear():A.delete("all"),A.add(E));const N=w==="none"?p.find(D=>D.value!=="none")?.value??"thin":w;o(x(A,N))},S=E=>{const A=_.size===0?new Set(["all"]):_;o(x(A,E))},C=E=>{s?.(E)},T=(E,A)=>E&&E.startsWith("$t:")?n(E.slice(3)):E||A;return i.jsxs("div",{className:"g7le-cell-border","data-testid":"g7le-cell-border",style:Nz,children:[i.jsx("div",{style:Mz,children:i.jsx("span",{style:Lz,children:n("layout_editor.table_editor.cell_border")})}),i.jsx("div",{style:ll,"data-testid":"g7le-cell-border-widths",children:p.map(E=>i.jsx("button",{type:"button",disabled:d,"data-testid":`g7le-cell-border-width-${E.value}`,"aria-pressed":w===E.value,onClick:()=>S(E.value),style:w===E.value?bh:dl,children:T(E.label,E.value)},E.value))}),w!=="none"&&i.jsx("div",{style:ll,"data-testid":"g7le-cell-border-sides",children:c.map(E=>i.jsx("button",{type:"button",disabled:d,"data-testid":`g7le-cell-border-side-${E.value}`,"aria-pressed":_.has(E.value),onClick:()=>$(E.value),style:_.has(E.value)?bh:dl,children:T(E.label,E.value)},E.value))}),w!=="none"&&(f.length>0||l)&&i.jsx(i.Fragment,{children:i.jsxs("div",{style:ll,"data-testid":"g7le-cell-border-colors",children:[f.map(E=>{const A=y===E.token;return i.jsx("button",{type:"button",disabled:d,title:T(E.label,E.value),"data-testid":`g7le-cell-border-color-${E.value}`,"aria-pressed":A,onClick:()=>C(E.token),style:{...mh,background:E.swatch??"#fff",outline:A?"2px solid #2563eb":"1px solid #cbd5e1"}},E.value)}),l&&(()=>{const E=!!a&&f.some(N=>N.swatch&&N.swatch.toLowerCase()===a.toLowerCase()),A=!b&&!!a&&!E;return i.jsx("label",{title:n(b?"layout_editor.table_editor.dark_free_color_hint":"layout_editor.table_inplace.custom_color"),"data-testid":"g7le-cell-border-color-custom",style:{...mh,position:"relative",overflow:"hidden",display:"inline-flex",alignItems:"center",justifyContent:"center",background:A&&gh.test(a)?a:"conic-gradient(red, yellow, lime, aqua, blue, magenta, red)",outline:A?"2px solid #2563eb":"1px solid #cbd5e1",opacity:b?.4:1,cursor:b?"not-allowed":"pointer"},children:i.jsx("input",{type:"color",disabled:d||b,"data-testid":"g7le-cell-border-color-picker",value:a&&gh.test(a)?a:"#000000",onChange:N=>l(N.target.value),style:{position:"absolute",width:0,height:0,opacity:0}})})})()]})})]})}const Nz={display:"flex",flexDirection:"column",gap:6},Mz={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},Lz={fontSize:12,fontWeight:600,color:"#475569"},ll={display:"flex",gap:4,flexWrap:"wrap",alignItems:"center"},dl={padding:"3px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},bh={...dl,border:"1px solid #2563eb",background:"#eff6ff",color:"#1d4ed8",fontWeight:600},mh={width:22,height:22,borderRadius:5,padding:0,cursor:"pointer",boxSizing:"border-box"},vh=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;function _h({colorStyle:e,className:t,catalog:n,t:o,colorScheme:r="light",onPresetToken:s,onCustomColor:a,onClear:l,disabled:d}){const c=n?.colors??[],p=r==="dark",f=e??"",b=Gr(t??"",p),g=c.find(_=>_.token&&b.includes(_.token))?.token??null,m=(_,w)=>_&&_.startsWith("$t:")?o(_.slice(3)):_||w,h=!g&&(p||f.trim()===""),v=!!f&&c.some(_=>_.swatch&&_.swatch.toLowerCase()===f.toLowerCase()),y=!p&&!!f&&!v;return i.jsxs("div",{className:"g7le-cell-fill","data-testid":"g7le-cell-fill",style:Pz,children:[i.jsx("div",{style:Oz,children:i.jsx("span",{style:Bz,children:o("layout_editor.table_editor.cell_fill")})}),i.jsxs("div",{style:Wz,"data-testid":"g7le-cell-fill-colors",children:[i.jsx("button",{type:"button",disabled:d,title:o("layout_editor.table_editor.cell_fill_none"),"data-testid":"g7le-cell-fill-none","aria-pressed":h,onClick:()=>l?.(),style:{...cl,background:"repeating-conic-gradient(#e2e8f0 0% 25%, #ffffff 0% 50%) 50% / 10px 10px",outline:h?"2px solid #2563eb":"1px solid #cbd5e1"}}),c.map(_=>{const w=!!_.token&&g===_.token,k=!p&&!!_.swatch&&f.toLowerCase()===(_.swatch??"").toLowerCase(),x=w||k,$=d||p&&!_.token;return i.jsx("button",{type:"button",disabled:$,title:m(_.label,_.value),"data-testid":`g7le-cell-fill-color-${_.value}`,"aria-pressed":x,onClick:()=>{_.token&&s?s(_.token):!p&&_.swatch&&a&&a(_.swatch)},style:{...cl,background:_.swatch??"#fff",outline:x?"2px solid #2563eb":"1px solid #cbd5e1",opacity:$?.4:1,cursor:$?"not-allowed":"pointer"}},_.value)}),a&&i.jsx("label",{title:o(p?"layout_editor.table_editor.dark_free_color_hint":"layout_editor.table_editor.cell_fill_custom"),"data-testid":"g7le-cell-fill-custom",style:{...cl,position:"relative",overflow:"hidden",display:"inline-flex",alignItems:"center",justifyContent:"center",background:y&&vh.test(f)?f:"conic-gradient(red, yellow, lime, aqua, blue, magenta, red)",outline:y?"2px solid #2563eb":"1px solid #cbd5e1",opacity:p?.4:1,cursor:p?"not-allowed":"pointer"},children:i.jsx("input",{type:"color",disabled:d||p,"data-testid":"g7le-cell-fill-color-picker",value:f&&vh.test(f)?f:"#ffffff",onChange:_=>a(_.target.value),style:{position:"absolute",width:0,height:0,opacity:0}})})]})]})}const Pz={display:"flex",flexDirection:"column",gap:6},Oz={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},Bz={fontSize:12,fontWeight:600,color:"#475569"},Wz={display:"flex",gap:4,flexWrap:"wrap",alignItems:"center"},cl={width:22,height:22,borderRadius:5,padding:0,cursor:"pointer",boxSizing:"border-box"};function jz(e){const t=/^(\d+)px$/.exec(e.trim());return t?parseInt(t[1],10):null}function xh({paddingStyle:e,catalog:t,t:n,onChange:o,disabled:r}){const s=t?.steps??[],a=e??"",l=jz(a),d=(h,v)=>h&&h.startsWith("$t:")?n(h.slice(3)):h||v,c=s.some(h=>(h.px??0)===(l??-1)),p=l!==null&&!c?String(l):"",[f,b]=u.useState(p);u.useEffect(()=>{b(p)},[e]);const g=h=>{o(h&&h>0?`${h}px`:""),b("")},m=h=>{const v=parseInt(h,10);Number.isFinite(v)&&v>=0&&o(v>0?`${v}px`:"")};return i.jsxs("div",{className:"g7le-cell-padding","data-testid":"g7le-cell-padding",style:Hz,children:[i.jsx("div",{style:Fz,children:n("layout_editor.table_editor.cell_padding")}),i.jsxs("div",{style:Kz,"data-testid":"g7le-cell-padding-steps",children:[s.map(h=>{const v=(h.px??0)===(l??-1)||!h.px&&a.trim()==="";return i.jsx("button",{type:"button",disabled:r,"data-testid":`g7le-cell-padding-step-${h.value}`,"aria-pressed":v,onClick:()=>g(h.px),style:v?Vz:wh,children:d(h.label,h.value)},h.value)}),i.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3},children:[i.jsx("input",{type:"number",min:0,disabled:r,"data-testid":"g7le-cell-padding-free",value:f,placeholder:n("layout_editor.table_editor.cell_padding_custom"),onChange:h=>b(h.target.value),onBlur:()=>f.trim()!==""&&m(f),onKeyDown:h=>{h.key==="Enter"&&f.trim()!==""&&m(f)},style:Uz}),i.jsx("span",{style:{fontSize:11,color:"#94a3b8"},children:"px"})]})]})]})}const Hz={display:"flex",flexDirection:"column",gap:6},Fz={fontSize:12,fontWeight:600,color:"#475569"},Kz={display:"flex",gap:4,flexWrap:"wrap",alignItems:"center"},wh={padding:"3px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},Vz={...wh,border:"1px solid #2563eb",background:"#eff6ff",color:"#1d4ed8",fontWeight:600},Uz={width:48,padding:"3px 5px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,boxSizing:"border-box"};function kh({colorScheme:e,onChange:t,t:n,disabled:o}){const r=e==="dark";return i.jsxs("div",{className:"g7le-color-scheme-tabs","data-testid":"g7le-color-scheme-tabs",style:qz,children:[i.jsxs("div",{style:Gz,children:[i.jsx("span",{style:Yz,children:n("layout_editor.table_editor.cell_color")}),i.jsxs("div",{style:Xz,children:[i.jsx("button",{type:"button",disabled:o,"data-testid":"g7le-color-scheme-light","aria-pressed":!r,onClick:()=>t("light"),style:r?ul:Sh,children:n("layout_editor.property_modal.scope.scheme_light")}),i.jsx("button",{type:"button",disabled:o,"data-testid":"g7le-color-scheme-dark","aria-pressed":r,onClick:()=>t("dark"),style:r?Sh:ul,children:n("layout_editor.property_modal.scope.scheme_dark")})]})]}),r&&i.jsx("div",{style:Jz,"data-testid":"g7le-color-scheme-dark-hint",children:n("layout_editor.table_editor.dark_free_color_hint")})]})}const qz={display:"flex",flexDirection:"column",gap:3},Gz={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},Yz={fontSize:12,fontWeight:700,color:"#0f172a"},Xz={display:"flex",gap:2},ul={padding:"2px 9px",fontSize:11,border:"none",borderBottom:"2px solid transparent",background:"transparent",color:"#94a3b8",cursor:"pointer"},Sh={...ul,color:"#1d4ed8",borderBottom:"2px solid #2563eb",fontWeight:600},Jz={fontSize:10,color:"#94a3b8",fontStyle:"italic"},pl="dark:";function Ch(e){return typeof e=="string"?e.split(/\s+/).filter(Boolean):[]}function $h(e,t){return t==="dark"?e.filter(n=>n.startsWith(pl)).map(n=>n.slice(pl.length)):e.filter(n=>!n.startsWith(pl))}const Zz={none:0,thin:1,medium:2,thick:4},Eh={top:{w:"borderTopWidth",s:"borderTopStyle",c:"borderTopColor"},bottom:{w:"borderBottomWidth",s:"borderBottomStyle",c:"borderBottomColor"},left:{w:"borderLeftWidth",s:"borderLeftStyle",c:"borderLeftColor"},right:{w:"borderRightWidth",s:"borderRightStyle",c:"borderRightColor"}},Ih=["top","bottom","left","right"];function Qz(e,t,n="light"){if(!e||!t)return{};const o=t.sides??[],r=t.widths??[],s=t.colors??[],a=Ch(e.props?.className);if(a.length===0&&!e.props?.style)return{};const l=[...r].filter(y=>y.value!=="none").sort((y,_)=>(_.suffix??"").length-(y.suffix??"").length),d={};for(const y of o)for(const _ of l){const w=_.suffix?`${y.prefix}${_.suffix}`:y.prefix;if(a.includes(w)){d[y.value]=_.value;break}}const c=e.props?.style??{},p=$h(a,n),f=s.find(y=>p.includes(y.token))?.swatch??"",g=(n==="light"&&typeof c.borderColor=="string"?c.borderColor:"")||f||"#94a3b8",m=y=>{const _=Eh[y]?.c,w=_?c[_]:void 0;return typeof w=="string"&&w?w:g},h={},v=(y,_)=>{const w=Eh[y];if(!w)return;const k=Zz[_]??1;h[w.w]=`${k}px`,h[w.s]=k>0?"solid":"none",k>0&&(h[w.c]=m(y))};if(d.all)for(const y of Ih)v(y,d.all);for(const y of Ih)d[y]&&v(y,d[y]);return h}function Rz(e,t,n="light"){if(!e?.props)return{};const o=e.props.style??{},r={},s=Ch(e.props.className),a=t?.colors?.find(c=>c.token&&$h(s,n).includes(c.token))?.swatch??"",d=(n==="light"&&typeof o.backgroundColor=="string"?o.backgroundColor:"")||a;return d&&(r.backgroundColor=d),typeof o.padding=="string"&&o.padding&&(r.padding=o.padding),r}const eN=/^\s*\$t:(custom\.[a-zA-Z0-9._-]+)\s*$/,tN=/^\s*\$t:([a-zA-Z0-9._-]+)\s*$/,nN=/\{\{.*?\}\}/;function Ah(e,t,n){const o=e?.text;if(typeof o!="string")return{display:"",editable:!1,isKey:!1};const r=vt(o);if(r&&r.key.startsWith("custom.")){let a="";try{const l=Pt.getInstance().translate(r.key,{templateId:t,locale:n});a=l&&l!==r.key?l:""}catch{a=""}return{display:a,editable:!0,isKey:!0}}if(nN.test(o))return{display:o,editable:!1,isKey:!1};const s=tN.exec(o);if(s){const a=s[1];let l="";try{const d=Pt.getInstance().translate(a,{templateId:t,locale:n});l=d&&d!==a?d:""}catch{l=""}return{display:l,editable:!0,isKey:!0}}return{display:o,editable:!0,isKey:!1}}function fl(e){const t=or(e);return t===null?{node:null,path:null}:{node:ki(e,t),path:t}}function oN(e){if(!e||typeof e.text!="string")return null;const t=eN.exec(e.text);if(t)return t[1];const n=vt(e.text);return n&&n.key.startsWith("custom.")?n.key:null}function rN({node:e,params:t,t:n,onPatchNode:o,templateIdentifier:r,candidates:s}){const{state:a}=Qe(),l=a.selectedRoute?.layoutName??null,d=a.locale,c=r??a.templateIdentifier,p=u.useMemo(()=>t&&typeof t=="object"?t:null,[t]);u.useMemo(()=>yt(p),[p]);const f=u.useMemo(()=>Pe(e,p),[e,p]),b=u.useMemo(()=>{const U=p?.cellBorder;return U&&typeof U=="object"?U:null},[p]),g=u.useMemo(()=>{const U=p?.cellBackground;return U&&typeof U=="object"?U:null},[p]),m=u.useMemo(()=>{const U=p?.cellPadding;return U&&typeof U=="object"?U:null},[p]),[h,v]=u.useState(null),[y,_]=u.useState(null),[w,k]=u.useState({}),[x,$]=u.useState(!1),[S,C]=u.useState(null),[T,E]=u.useState(null),[A,N]=u.useState("light"),D=u.useCallback(U=>o(U),[o]),B=u.useMemo(()=>h?Ve(f,h.r,h.c):null,[f,h]),M=T!==null?T:h?.c??null,O=S!==null?S:h?.r??null,z=u.useMemo(()=>{const U=(b?.sides??[]).find(xe=>xe.value==="all")??(b?.sides??[])[0],ue=(b?.widths??[]).find(xe=>xe.value!=="none");if(!U||!ue)return[];const fe=ue.suffix??"";return[fe?`${U.prefix}${fe}`:U.prefix]},[b]),H=u.useCallback((U,ue,fe)=>{if(z.length===0)return U;const xe=(b?.sides??[]).map(Q=>Q.prefix),he=Ve(Pe(U,p),ue,fe),ne=(typeof he?.cell?.props?.className=="string"?he.cell.props.className:"").split(/\s+/).filter(Boolean);return ne.some(Q=>xe.some(le=>Q===le||Q.startsWith(le+"-")&&/^-?\d+$/.test(Q.slice(le.length+1))))?U:Ii(U,p,ue,fe,[...ne,...z].join(" ").trim())},[z,b,p]),P=u.useCallback(U=>{if(!h)return;const ue=Math.min(h.r,y?.r??h.r),fe=Math.max(h.r,y?.r??h.r),xe=Math.min(h.c,y?.c??h.c),he=Math.max(h.c,y?.c??h.c),j=new Set,ne=[];for(let Q=ue;Q<=fe;Q++)for(let le=xe;le<=he;le++)j.add(`${Q}:${le}`),ne.push({r:Q,c:le});let pe=e;for(const Q of ne){if(pe=H(pe,Q.r,Q.c),pe=Jt(pe,p,Q.r,Q.c,"borderColor",U),Q.r>0&&!j.has(`${Q.r-1}:${Q.c}`)){const le=Ve(Pe(pe,p),Q.r-1,Q.c);le&&(pe=Jt(pe,p,le.gridRow,le.gridCol,"borderBottomColor",U))}if(Q.c>0&&!j.has(`${Q.r}:${Q.c-1}`)){const le=Ve(Pe(pe,p),Q.r,Q.c-1);le&&(pe=Jt(pe,p,le.gridRow,le.gridCol,"borderRightColor",U))}}D(pe)},[h,y,e,p,D,H]),I=u.useCallback(U=>P(U),[P]),L=u.useMemo(()=>(b?.colors??[]).map(U=>U.token).filter(Boolean),[b]),F=u.useCallback(U=>{if(!h||L.length===0)return;const ue=Math.min(h.r,y?.r??h.r),fe=Math.max(h.r,y?.r??h.r),xe=Math.min(h.c,y?.c??h.c),he=Math.max(h.c,y?.c??h.c);let j=e;for(let ne=ue;ne<=fe;ne++)for(let pe=xe;pe<=he;pe++)j=H(j,ne,pe),j=ho(j,p,ne,pe,U,L,A);D(j)},[h,y,e,p,D,H,L,A]),Y=u.useMemo(()=>{if(A==="dark")return"";const U=B?.cell.props?.style;return typeof U?.borderColor=="string"?U.borderColor:""},[B,A]),K=u.useCallback((U,ue)=>{if(!h)return;const fe=Math.min(h.r,y?.r??h.r),xe=Math.max(h.r,y?.r??h.r),he=Math.min(h.c,y?.c??h.c),j=Math.max(h.c,y?.c??h.c);let ne=e;for(let pe=fe;pe<=xe;pe++)for(let Q=he;Q<=j;Q++)ne=Jt(ne,p,pe,Q,U,ue);D(ne)},[h,y,e,p,D]),X=u.useMemo(()=>(g?.colors??[]).map(U=>U.token).filter(U=>!!U),[g]),Z=u.useCallback(()=>h?{r0:Math.min(h.r,y?.r??h.r),r1:Math.max(h.r,y?.r??h.r),c0:Math.min(h.c,y?.c??h.c),c1:Math.max(h.c,y?.c??h.c)}:null,[h,y]),ae=u.useCallback(U=>{const ue=Z();if(!ue||X.length===0)return;let fe=e;for(let xe=ue.r0;xe<=ue.r1;xe++)for(let he=ue.c0;he<=ue.c1;he++)fe=ho(fe,p,xe,he,U,X,A);D(fe)},[Z,e,p,D,X,A]),oe=u.useCallback(U=>K("backgroundColor",U),[K]),G=u.useCallback(()=>{const U=Z();if(!U)return;let ue=e;for(let fe=U.r0;fe<=U.r1;fe++)for(let xe=U.c0;xe<=U.c1;xe++)ue=ho(ue,p,fe,xe,void 0,X,A),A==="light"&&(ue=Jt(ue,p,fe,xe,"backgroundColor",void 0));D(ue)},[Z,e,p,D,X,A]),ee=u.useCallback(U=>K("padding",U),[K]),ge=u.useMemo(()=>{if(A==="dark")return"";const U=B?.cell.props?.style;return typeof U?.backgroundColor=="string"?U.backgroundColor:""},[B,A]),V=u.useMemo(()=>typeof B?.cell.props?.className=="string"?B.cell.props.className:"",[B]),te=u.useMemo(()=>{const U=B?.cell.props?.style;return typeof U?.padding=="string"?U.padding:""},[B]),be=u.useCallback(U=>U==="section"?n("layout_editor.table_editor.move_blocked_section"):"",[n]),Ee=u.useCallback((U,ue)=>Si(f,U,ue),[f]),De=u.useCallback((U,ue)=>Ci(f,U,ue),[f]),Se=u.useCallback(U=>D(sl(e,p,U)),[e,p,D]),Ue=u.useCallback(U=>{D(sh(e,p,U)),v(null),_(null)},[e,p,D]),Me=u.useCallback((U,ue)=>D(ah(e,p,U,ue)),[e,p,D]),Oe=u.useCallback(U=>D(dh(e,p,U)),[e,p,D]),Ye=u.useCallback(U=>{D(ch(e,p,U)),v(null),_(null)},[e,p,D]),ze=u.useCallback((U,ue)=>D(lh(e,p,U,ue)),[e,p,D]),Xe=u.useCallback(()=>{if(!h||!y)return;const U=al(e,p,h.r,h.c,y.r,y.c);U.ok&&(D(U.table),v({r:Math.min(h.r,y.r),c:Math.min(h.c,y.c)}),_(null))},[e,p,h,y,D]),ve=u.useCallback(()=>{h&&(D(uh(e,p,h.r,h.c)),_(null))},[e,p,h,D]),qe=u.useCallback(U=>{if(!h)return;const ue=Math.min(h.r,y?.r??h.r),fe=Math.max(h.r,y?.r??h.r),xe=Math.min(h.c,y?.c??h.c),he=Math.max(h.c,y?.c??h.c);let j=e;for(let ne=ue;ne<=fe;ne++)for(let pe=xe;pe<=he;pe++)j=Ii(j,p,ne,pe,U);D(j)},[e,p,h,y,D]),We=u.useCallback(async(U,ue)=>{const fe=`${U}:${ue}`,xe=w[fe];if(xe===void 0)return;const he=Ve(f,U,ue);if(!he)return;const{node:j,path:ne}=fl(he.cell);if(ne===null)return;const pe=Ah(j,c,d);if(pe.editable){if(xe===pe.display){k(Q=>{const le={...Q};return delete le[fe],le});return}$(!0);try{const Q=oN(j);if(Q)await vr(c,Q,d,xe),await tn(c,d);else{const le=await qn(c,l,d,xe);if(le.kind==="ok"&&le.resource){const Ae=`$t:${le.resource.translation_key}`;if(ne.length===0)D(ph(e,p,U,ue,Ae));else{const dt=rr(he.cell,ne,Ae);D(fh(e,p,U,ue,dt))}await tn(c,d)}}}finally{$(!1),k(Q=>{const le={...Q};return delete le[fe],le})}}},[w,f,c,d,l,e,p,D]),ce=u.useMemo(()=>{if(!B)return null;const{node:U,path:ue}=fl(B.cell);return ue===null?null:{value:typeof U?.text=="string"?U.text:"",editable:!0}},[B]),q=u.useCallback(U=>{if(typeof U!="string"||U.length===0||!h)return;const ue=Ve(f,h.r,h.c);if(!ue)return;const fe=or(ue.cell);if(fe!==null)if(fe.length===0)D(ph(e,p,h.r,h.c,U));else{const xe=rr(ue.cell,fe,U);D(fh(e,p,h.r,h.c,xe))}},[h,f,e,p,D]),ie=u.useCallback((U,ue,fe)=>{fe?_({r:U,c:ue}):(v({r:U,c:ue}),_(null))},[]),se=u.useMemo(()=>Array.from({length:f.colCount},(U,ue)=>ue),[f.colCount]),me=!!(h&&y&&(h.r!==y.r||h.c!==y.c)),Ce=!!(B&&(B.colSpan>1||B.rowSpan>1)),$e=B&&typeof B.cell.props?.className=="string"?B.cell.props.className:"";return i.jsxs("div",{className:"g7le-node-editor g7le-node-editor--table","data-testid":"g7le-table-editor",style:iN,children:[i.jsx("div",{style:sN,children:n("layout_editor.table_editor.title")}),i.jsx("div",{style:{overflowX:"auto"},children:i.jsxs("table",{"data-testid":"g7le-table-editor-grid",style:aN,children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{style:lN}),se.map(U=>{const ue=De(U,-1),fe=De(U,1),xe=M===U;return i.jsx("th",{style:dN,"data-testid":`g7le-table-colgutter-${U}`,onMouseEnter:()=>E(U),onMouseLeave:()=>E(he=>he===U?null:he),children:i.jsxs("div",{style:{...uN,visibility:xe?"visible":"hidden"},children:[i.jsx("button",{type:"button",title:ue.ok?n("layout_editor.table_editor.move_col_left"):be(ue.reason)||n("layout_editor.table_editor.move_col_left"),disabled:!ue.ok||x,onClick:()=>ze(U,-1),"data-testid":`g7le-table-col-left-${U}`,style:ue.ok?vn:Ai,children:"←"}),i.jsx("button",{type:"button",title:n("layout_editor.table_editor.add_col"),disabled:x,onClick:()=>Oe(U),"data-testid":`g7le-table-col-add-${U}`,style:vn,children:"+"}),i.jsx("button",{type:"button",title:n("layout_editor.table_editor.remove_col"),disabled:f.colCount<=1||x,onClick:()=>Ye(U),"data-testid":`g7le-table-col-remove-${U}`,style:Th,children:"✕"}),i.jsx("button",{type:"button",title:fe.ok?n("layout_editor.table_editor.move_col_right"):be(fe.reason)||n("layout_editor.table_editor.move_col_right"),disabled:!fe.ok||x,onClick:()=>ze(U,1),"data-testid":`g7le-table-col-right-${U}`,style:fe.ok?vn:Ai,children:"→"})]})},U)})]})}),i.jsx("tbody",{children:f.rows.map((U,ue)=>{const fe=U.cells[0]?.gridRow??ue,xe=O===fe;return i.jsxs("tr",{"data-testid":`g7le-table-row-${fe}`,onMouseEnter:()=>C(fe),onMouseLeave:()=>C(he=>he===fe?null:he),children:[i.jsx("td",{style:cN,"data-testid":`g7le-table-rowgutter-${fe}`,children:(()=>{const he=Ee(fe,-1),j=Ee(fe,1);return i.jsxs("div",{style:{...pN,visibility:xe?"visible":"hidden"},children:[i.jsx("button",{type:"button",title:he.ok?n("layout_editor.table_editor.move_row_up"):be(he.reason)||n("layout_editor.table_editor.move_row_up"),disabled:!he.ok||x,onClick:()=>Me(fe,-1),"data-testid":`g7le-table-row-up-${fe}`,style:he.ok?vn:Ai,children:"↑"}),i.jsx("button",{type:"button",title:n("layout_editor.table_editor.add_row"),disabled:x,onClick:()=>Se(fe),"data-testid":`g7le-table-row-add-${fe}`,style:vn,children:"+"}),i.jsx("button",{type:"button",title:n("layout_editor.table_editor.remove_row"),disabled:f.rows.length<=1||x,onClick:()=>Ue(fe),"data-testid":`g7le-table-row-remove-${fe}`,style:Th,children:"✕"}),i.jsx("button",{type:"button",title:j.ok?n("layout_editor.table_editor.move_row_down"):be(j.reason)||n("layout_editor.table_editor.move_row_down"),disabled:!j.ok||x,onClick:()=>Me(fe,1),"data-testid":`g7le-table-row-down-${fe}`,style:j.ok?vn:Ai,children:"↓"})]})})()}),U.cells.map(he=>{const j=`${he.gridRow}:${he.gridCol}`,{node:ne,path:pe}=fl(he.cell),Q=Ah(ne,c,d),le=pe!==null&&Q.editable,Ae=pe===null,dt=w[j],pt=dt!==void 0?dt:Q.display,ot=h&&h.r===he.gridRow&&h.c===he.gridCol,Le=h&&y&&he.gridRow>=Math.min(h.r,y.r)&&he.gridRow<=Math.max(h.r,y.r)&&he.gridCol>=Math.min(h.c,y.c)&&he.gridCol<=Math.max(h.c,y.c);return i.jsx("td",{colSpan:he.colSpan,rowSpan:he.rowSpan,"data-testid":`g7le-table-cell-${he.gridRow}-${he.gridCol}`,onClick:je=>ie(he.gridRow,he.gridCol,je.shiftKey),style:{...fN,...Qz(he.cell,b,A),...Rz(he.cell,g,A),...he.isHeader?gN:{},...ot?hN:{},...Le&&!ot?yN:{}},children:le?i.jsx("input",{type:"text","data-testid":`g7le-table-cell-input-${he.gridRow}-${he.gridCol}`,value:pt,placeholder:n("layout_editor.table_editor.cell_text"),disabled:x,onMouseDown:je=>{je.shiftKey&&je.preventDefault(),ie(he.gridRow,he.gridCol,je.shiftKey)},onClick:je=>je.stopPropagation(),onChange:je=>k(Je=>({...Je,[j]:je.target.value})),onBlur:()=>void We(he.gridRow,he.gridCol),style:bN}):Ae?i.jsx("span",{"data-testid":`g7le-table-cell-struct-${he.gridRow}-${he.gridCol}`,style:Dh,children:n("layout_editor.table_editor.structural_cell")}):i.jsx("span",{style:Dh,children:Q.display})},j)})]},ue)})})]})}),i.jsxs("button",{type:"button","data-testid":"g7le-table-add-row-bottom",onClick:()=>Se(f.rows.length-1),disabled:x,style:mN,children:["+ ",n("layout_editor.table_editor.add_row")]}),i.jsxs("div",{style:vN,"data-testid":"g7le-table-cell-tools",children:[i.jsx("button",{type:"button","data-testid":"g7le-table-merge",onClick:Xe,disabled:!me||x,style:zh,children:n("layout_editor.table_editor.merge_cells")}),i.jsx("button",{type:"button","data-testid":"g7le-table-unmerge",onClick:ve,disabled:!Ce||x,style:zh,children:n("layout_editor.table_editor.unmerge_cells")})]}),B&&ce&&i.jsxs("div",{style:xN,"data-testid":"g7le-table-cell-i18n-section",children:[i.jsx("div",{style:wN,children:n("layout_editor.table_editor.cell_i18n_label")}),i.jsx(_t,{value:ce.value,onChange:q,t:n,placeholder:n("layout_editor.table_editor.cell_text"),testidPrefix:"g7le-table-cell-i18n",candidates:s,enableExpressionTree:!0,expressionTreeCollapsible:!0})]}),B&&i.jsxs("div",{style:_N,"data-testid":"g7le-table-cell-color-section",children:[i.jsx(kh,{colorScheme:A,onChange:N,t:n,disabled:x}),b&&i.jsx("div",{style:gl,"data-testid":"g7le-table-cell-border-row",children:i.jsx(yh,{className:$e,catalog:b,t:n,onChange:qe,colorScheme:A,onPresetToken:F,colorStyle:Y,onColorStyle:I,disabled:x})}),i.jsx("div",{style:gl,"data-testid":"g7le-table-cell-fill-row",children:i.jsx(_h,{colorStyle:ge,className:V,catalog:g,t:n,colorScheme:A,onPresetToken:ae,onCustomColor:oe,onClear:G,disabled:x})})]}),B&&i.jsx("div",{style:gl,"data-testid":"g7le-table-cell-padding-row",children:i.jsx(xh,{paddingStyle:te,catalog:m,t:n,onChange:ee,disabled:x})}),B&&!b&&i.jsxs("label",{style:kN,"data-testid":"g7le-table-cell-border-row",children:[i.jsx("span",{style:SN,children:n("layout_editor.table_editor.cell_border")}),i.jsx("input",{type:"text","data-testid":"g7le-table-cell-border-input",value:$e,placeholder:n("layout_editor.table_editor.cell_class_placeholder"),onChange:U=>qe(U.target.value),disabled:x,style:CN})]}),!f.valid&&i.jsx("div",{"data-testid":"g7le-table-grid-warning",style:$N,children:n("layout_editor.table_editor.grid_invalid")}),i.jsx("div",{style:EN,children:n("layout_editor.table_editor.select_hint")})]})}const iN={display:"flex",flexDirection:"column",gap:8,width:"100%",marginBottom:12},sN={fontSize:12,fontWeight:700,color:"#0f172a"},aN={borderCollapse:"collapse",width:"auto"},lN={width:28,background:"transparent",border:"none"},dN={padding:2,border:"none",background:"transparent"},cN={padding:2,border:"none",background:"transparent",verticalAlign:"middle"},uN={display:"flex",gap:2,justifyContent:"center"},pN={display:"grid",gridTemplateColumns:"repeat(2, 16px)",gap:2,justifyContent:"center"},vn={width:16,height:16,lineHeight:"14px",padding:0,fontSize:10,border:"1px solid #cbd5e1",borderRadius:4,background:"#fff",color:"#475569",cursor:"pointer"},Th={...vn,border:"1px solid #fecaca",color:"#dc2626"},Ai={...vn,cursor:"not-allowed",opacity:.4,color:"#94a3b8",borderColor:"#e2e8f0"},fN={border:"1px solid #cbd5e1",padding:0,width:64,minWidth:64,maxWidth:120,height:24,background:"#fff",cursor:"pointer"},gN={background:"#f1f5f9",fontWeight:600},hN={outline:"2px solid #2563eb",outlineOffset:-2},yN={background:"#dbeafe"},bN={width:"100%",boxSizing:"border-box",padding:"2px 5px",fontSize:11,height:22,lineHeight:"18px",border:"none",background:"transparent",outline:"none"},Dh={display:"block",padding:"2px 5px",fontSize:10,color:"#64748b",fontStyle:"italic",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:110},mN={padding:"4px 8px",fontSize:12,border:"1px dashed #94a3b8",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",alignSelf:"flex-start"},vN={display:"flex",gap:6},zh={padding:"4px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},_N={display:"flex",flexDirection:"column",gap:8,borderTop:"1px solid #f1f5f9",paddingTop:8},xN={display:"flex",flexDirection:"column",gap:6,borderTop:"1px solid #f1f5f9",paddingTop:8},wN={fontSize:12,fontWeight:700,color:"#0f172a"},gl={display:"flex",flexDirection:"column",gap:6},kN={display:"flex",alignItems:"center",gap:6},SN={fontSize:12,color:"#475569",minWidth:60},CN={flex:1,minWidth:0,padding:"4px 6px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6},$N={fontSize:11,color:"#b45309",background:"#fffbeb",border:"1px solid #fde68a",borderRadius:6,padding:"4px 6px"},EN={fontSize:11,color:"#94a3b8"},IN=/\{\{.*?\}\}/;function AN(e,t,n){const r=(e.props??{})[t];return Array.isArray(r)?r:r===void 0&&n?JSON.parse(JSON.stringify(n)):[]}function TN(e){return typeof e=="string"&&IN.test(e)}function hl(e,t,n){return e?e.startsWith("$t:")?t(e.slice(3)):e:n}function DN(e,t,n){return typeof e=="object"&&e!==null?e[t.key]:n?e:void 0}function zN(e,t,n,o){if(typeof e=="object"&&e!==null){const r={...e};return o===void 0?delete r[t.key]:r[t.key]=o,r}return n?o:{[t.key]:o}}function Nh({node:e,params:t,t:n,onPatchNode:o,templateIdentifier:r,candidates:s}){const a=typeof t?.arrayProp=="string"?t.arrayProp:null,l=Array.isArray(t?.fields)?t.fields:[],d=hl(typeof t?.itemLabel=="string"?t.itemLabel:void 0,n,n("layout_editor.array_editor.item")),c=t?.newItem,p=c&&typeof c=="object"?c:null,f=typeof c=="string"||typeof c=="number"?c:null,b=(l.find($=>$.primary)??l[0])?.key,g=(e.props??{})[a??""],m=Array.isArray(t?.defaultItems)?t.defaultItems:null,h=a?AN(e,a,m):[],v=u.useCallback($=>{if(!a)return;const S={...e.props??{}};S[a]=$,o({...e,props:S})},[a,e,o]),y=u.useCallback(()=>{if(p)return JSON.parse(JSON.stringify(p));if(f!==null)return f;const $={};for(const S of l)(S.widget??"text")==="boolean"?$[S.key]=!1:$[S.key]="";return $},[p,f,l]),_=u.useCallback(()=>{v([...h,y()])},[v,h,y]),w=u.useCallback($=>{v(h.filter((S,C)=>C!==$))},[v,h]),k=u.useCallback(($,S)=>{const C=$+S;if(C<0||C>=h.length)return;const T=[...h];[T[$],T[C]]=[T[C],T[$]],v(T)},[v,h]),x=u.useCallback(($,S,C)=>{const T=S.key===b,E=h.map((A,N)=>N===$?zN(A,S,T,C):A);v(E)},[h,v,b]);return a?TN(g)||g!==void 0&&!Array.isArray(g)?i.jsx("div",{className:"g7le-node-editor g7le-node-editor--array","data-testid":"g7le-array-editor-bound",style:HN,children:n("layout_editor.array_editor.bound_degraded")}):i.jsxs("div",{className:"g7le-node-editor g7le-node-editor--array","data-testid":"g7le-array-editor",style:NN,children:[i.jsx("div",{style:MN,children:n("layout_editor.array_editor.items_title")}),h.length===0&&i.jsx("div",{"data-testid":"g7le-array-empty",style:Lh,children:n("layout_editor.array_editor.empty")}),h.map(($,S)=>i.jsxs("div",{"data-testid":`g7le-array-row-${S}`,style:LN,children:[i.jsxs("div",{style:PN,children:[i.jsxs("span",{style:ON,children:["#",S+1]}),i.jsx("div",{style:{flex:1}}),i.jsx("button",{type:"button","data-testid":`g7le-array-up-${S}`,title:n("layout_editor.array_editor.move_up"),disabled:S===0,onClick:()=>k(S,-1),style:Mh,children:"↑"}),i.jsx("button",{type:"button","data-testid":`g7le-array-down-${S}`,title:n("layout_editor.array_editor.move_down"),disabled:S===h.length-1,onClick:()=>k(S,1),style:Mh,children:"↓"}),i.jsx("button",{type:"button","data-testid":`g7le-array-remove-${S}`,title:n("layout_editor.array_editor.remove"),onClick:()=>w(S),style:WN,children:"✕"})]}),l.map(C=>{const T=C.widget??"text",E=C.key===b,A=hl(C.label,n,C.key),N=DN($,C,E),D=`g7le-array-field-${S}-${C.key}`;if(T==="boolean")return i.jsxs("label",{style:Wn,children:[i.jsx("span",{style:jn,children:A}),i.jsx("input",{type:"checkbox","data-testid":D,checked:N===!0,onChange:M=>x(S,C,M.target.checked)})]},C.key);if(T==="select"){const M=Array.isArray(C.options)?C.options:[];return i.jsxs("label",{style:Wn,children:[i.jsx("span",{style:jn,children:A}),i.jsxs("select",{"data-testid":D,value:N==null?"":String(N),onChange:O=>x(S,C,O.target.value===""?void 0:O.target.value),style:sr,children:[i.jsx("option",{value:"",children:"—"}),M.map((O,z)=>i.jsx("option",{value:String(O.value),children:hl(O.label,n,String(O.value))},z))]})]},C.key)}if(T==="i18n-text"){const M=typeof N=="string"?N:N==null?"":String(N);return i.jsxs("label",{style:Wn,children:[i.jsx("span",{style:jn,children:A}),i.jsx("div",{"data-testid":D,style:{flex:1,minWidth:0},children:i.jsx(_t,{value:M,onChange:O=>x(S,C,O===""?void 0:O),t:n,placeholder:A,testidPrefix:`${D}-i18n`,candidates:s,enableExpressionTree:!0,expressionTreeCollapsible:!0})})]},C.key)}if(T==="number"){const M=N==null?"":String(N);return i.jsxs("label",{style:Wn,children:[i.jsx("span",{style:jn,children:A}),i.jsx("input",{type:"number","data-testid":D,value:M,onChange:O=>{const z=O.target.value;x(S,C,z===""?void 0:Number(z))},style:sr})]},C.key)}if(T==="color"){const M=typeof N=="string"?N:"",O=/^#[0-9a-fA-F]{6}$/.test(M)?M:"#000000";return i.jsxs("label",{style:Wn,children:[i.jsx("span",{style:jn,children:A}),i.jsx("input",{type:"color","data-testid":`${D}-swatch`,value:O,onChange:z=>x(S,C,z.target.value),style:BN}),i.jsx("input",{type:"text","data-testid":D,value:M,placeholder:"#7C3AED",onChange:z=>x(S,C,z.target.value===""?void 0:z.target.value),style:sr})]},C.key)}if(T==="number-list"){const M=Array.isArray(N)?N.join(", "):"";return i.jsxs("label",{style:Wn,children:[i.jsx("span",{style:jn,children:A}),i.jsx("input",{type:"text","data-testid":D,value:M,placeholder:n("layout_editor.array_editor.number_list_placeholder"),onChange:O=>{const z=O.target.value.split(",").map(H=>H.trim()).filter(H=>H!=="").map(H=>Number(H)).filter(H=>!Number.isNaN(H));x(S,C,z)},style:sr})]},C.key)}const B=N==null?"":String(N);return i.jsxs("label",{style:Wn,children:[i.jsx("span",{style:jn,children:A}),i.jsx("input",{type:"text","data-testid":D,value:B,placeholder:T==="icon"?n("layout_editor.array_editor.icon_placeholder"):A,onChange:M=>x(S,C,M.target.value===""?void 0:M.target.value),style:sr})]},C.key)})]},S)),i.jsx("button",{type:"button","data-testid":"g7le-array-add",onClick:_,style:jN,children:n("layout_editor.array_editor.add",{item:d})})]}):i.jsx("div",{className:"g7le-node-editor g7le-node-editor--array","data-testid":"g7le-array-editor-misconfigured",style:Lh,children:n("layout_editor.array_editor.no_array_prop")})}const NN={display:"flex",flexDirection:"column",gap:8,width:"100%",marginBottom:12},MN={fontSize:12,fontWeight:700,color:"#0f172a",marginBottom:2},LN={display:"flex",flexDirection:"column",gap:4,padding:8,border:"1px solid #e2e8f0",borderRadius:8,background:"#f8fafc"},PN={display:"flex",gap:4,alignItems:"center"},ON={fontSize:11,fontWeight:700,color:"#64748b"},Wn={display:"flex",flexWrap:"wrap",gap:6,alignItems:"center"},jn={fontSize:11,color:"#475569",minWidth:64,flexShrink:0},sr={flex:1,minWidth:0,padding:"4px 6px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6},BN={width:32,height:28,padding:0,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",cursor:"pointer",flexShrink:0},Mh={padding:"2px 6px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},WN={padding:"2px 6px",fontSize:12,border:"1px solid #fecaca",borderRadius:6,background:"#fff",color:"#dc2626",cursor:"pointer"},jN={padding:"4px 8px",fontSize:12,border:"1px dashed #94a3b8",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",alignSelf:"flex-start"},Lh={fontSize:11,color:"#94a3b8",fontStyle:"italic"},HN={fontSize:11,color:"#b45309",fontStyle:"italic",padding:"4px 2px"};function FN(e,t){return e?e.startsWith("$t:")?t(e.slice(3)):e:null}function KN(e){const{params:t,t:n}=e,o=Array.isArray(t?.groups)?t.groups:[];return o.length===0?i.jsx("div",{className:"g7le-node-editor g7le-node-editor--array-group","data-testid":"g7le-array-group-misconfigured",style:GN,children:n("layout_editor.array_editor.no_array_prop")}):i.jsx("div",{className:"g7le-node-editor g7le-node-editor--array-group","data-testid":"g7le-array-group-editor",style:VN,children:o.map((r,s)=>{const a=FN(r.title,n),{title:l,...d}=r;return i.jsxs("div",{"data-testid":`g7le-array-group-${r.arrayProp??s}`,style:UN,children:[a&&i.jsx("div",{style:qN,children:a}),i.jsx(Nh,{...e,params:d})]},r.arrayProp??s)})})}const VN={display:"flex",flexDirection:"column",gap:16,width:"100%",marginBottom:12},UN={display:"flex",flexDirection:"column",gap:4},qN={fontSize:12,fontWeight:700,color:"#1e293b",borderBottom:"1px solid #e2e8f0",paddingBottom:4},GN={fontSize:11,color:"#94a3b8",fontStyle:"italic"},YN=/\{\{.*?\}\}/;function XN(e){return typeof e=="string"&&YN.test(e)}function JN(e,t,n){return e?e.startsWith("$t:")?t(e.slice(3)):e:n}function ZN(e){const{node:t,params:n,t:o,onPatchNode:r}=e,s=typeof n?.arrayProp=="string"?n.arrayProp:null,a=typeof n?.idField=="string"?n.idField:"id",l=typeof n?.cellChildrenProp=="string"?n.cellChildrenProp:"cellChildren",d=typeof n?.cellChildComponent=="string"?n.cellChildComponent:"Div",c=JN(typeof n?.itemLabel=="string"?n.itemLabel:void 0,o,o("layout_editor.array_editor.item")),[p,f]=u.useState(null),b=s?(t.props??{})[s]:void 0,g=Array.isArray(b)?b:[],m=u.useCallback($=>{if(!s)return;const S={...t.props??{}};S[s]=$,r({...t,props:S})},[s,t,r]),h=u.useCallback(()=>{const $=n?.newItem;return $&&typeof $=="object"?JSON.parse(JSON.stringify($)):{[a]:"",[l]:[]}},[n,a,l]),v=u.useCallback(()=>{m([...g,h()])},[m,g,h]),y=u.useCallback($=>{m(g.filter((S,C)=>C!==$)),f(null)},[m,g]),_=u.useCallback(($,S)=>{const C=$+S;if(C<0||C>=g.length)return;const T=[...g];[T[$],T[C]]=[T[C],T[$]],m(T)},[m,g]),w=u.useCallback(($,S)=>{const C=g.map((T,E)=>E===$?{...T,[a]:S}:T);m(C)},[g,m,a]),k=u.useCallback($=>({type:"composite",name:"CardGridCell",children:Array.isArray($[l])?$[l]:[]}),[l]),x=u.useCallback($=>S=>{const C=Array.isArray(S.children)?S.children:[],T=g.map((E,A)=>A===$?{...E,[l]:C}:E);m(T)},[g,m,l]);return s?XN(b)||b!==void 0&&!Array.isArray(b)?i.jsx("div",{className:"g7le-node-editor g7le-node-editor--cell-tree","data-testid":"g7le-cell-tree-bound",style:lM,children:o("layout_editor.array_editor.bound_degraded")}):i.jsxs("div",{className:"g7le-node-editor g7le-node-editor--cell-tree","data-testid":"g7le-cell-tree-editor",style:QN,children:[i.jsx("div",{style:RN,children:o("layout_editor.cell_tree_editor.columns_title")}),g.length===0&&i.jsx("div",{"data-testid":"g7le-cell-tree-empty",style:Oh,children:o("layout_editor.array_editor.empty")}),g.map(($,S)=>{const C=typeof $[a]=="string"?$[a]:"",T=p===S;return i.jsxs("div",{"data-testid":`g7le-cell-tree-row-${S}`,style:eM,children:[i.jsxs("div",{style:tM,children:[i.jsxs("span",{style:nM,children:["#",S+1]}),i.jsx("input",{type:"text","data-testid":`g7le-cell-tree-id-${S}`,value:C,placeholder:o("layout_editor.cell_tree_editor.id_placeholder"),onChange:E=>w(S,E.target.value),style:oM}),i.jsx("button",{type:"button","data-testid":`g7le-cell-tree-up-${S}`,title:o("layout_editor.array_editor.move_up"),disabled:S===0,onClick:()=>_(S,-1),style:Ph,children:"↑"}),i.jsx("button",{type:"button","data-testid":`g7le-cell-tree-down-${S}`,title:o("layout_editor.array_editor.move_down"),disabled:S===g.length-1,onClick:()=>_(S,1),style:Ph,children:"↓"}),i.jsx("button",{type:"button","data-testid":`g7le-cell-tree-remove-${S}`,title:o("layout_editor.array_editor.remove"),onClick:()=>y(S),style:rM,children:"✕"})]}),i.jsx("button",{type:"button","data-testid":`g7le-cell-tree-toggle-${S}`,onClick:()=>f(T?null:S),style:iM,children:o(T?"layout_editor.cell_tree_editor.collapse_cells":"layout_editor.cell_tree_editor.expand_cells")}),T&&i.jsx("div",{"data-testid":`g7le-cell-tree-cells-${S}`,style:sM,children:i.jsx(Rg,{...e,node:k($),params:{childComponent:d},onPatchNode:x(S)})})]},S)}),i.jsx("button",{type:"button","data-testid":"g7le-cell-tree-add",onClick:v,style:aM,children:o("layout_editor.cell_tree_editor.add_column",{item:c})})]}):i.jsx("div",{className:"g7le-node-editor g7le-node-editor--cell-tree","data-testid":"g7le-cell-tree-misconfigured",style:Oh,children:o("layout_editor.array_editor.no_array_prop")})}const QN={display:"flex",flexDirection:"column",gap:8,width:"100%",marginBottom:12},RN={fontSize:12,fontWeight:700,color:"#0f172a",marginBottom:2},eM={display:"flex",flexDirection:"column",gap:6,padding:8,border:"1px solid #e2e8f0",borderRadius:8,background:"#f8fafc"},tM={display:"flex",gap:4,alignItems:"center"},nM={fontSize:11,fontWeight:700,color:"#64748b",flexShrink:0},oM={flex:1,minWidth:0,padding:"4px 6px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6},Ph={padding:"2px 6px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},rM={padding:"2px 6px",fontSize:12,border:"1px solid #fecaca",borderRadius:6,background:"#fff",color:"#dc2626",cursor:"pointer"},iM={padding:"3px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#2563eb",cursor:"pointer",alignSelf:"flex-start"},sM={paddingLeft:8,borderLeft:"2px solid #e2e8f0"},aM={padding:"4px 8px",fontSize:12,border:"1px dashed #94a3b8",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",alignSelf:"flex-start"},Oh={fontSize:11,color:"#94a3b8",fontStyle:"italic"},lM={fontSize:11,color:"#b45309",fontStyle:"italic",padding:"4px 2px"};function dM(e,t,n){const o=Pe(e,t);if(!n||n.length===0)return{measured:[],grid:o};const r=[];for(const s of o.rows)for(const a of s.cells){const d=il(e,a,t).map(p=>`children.${p}`).join("."),c=n.find(p=>p.path===d||p.path.endsWith("."+d));c&&r.push({ref:a,box:{top:c.top,left:c.left,width:c.width,height:c.height}})}return{measured:r,grid:o}}const yl=26,bl=50,ml=6,Bh=44,Wh=18,jh="g7le-table-inplace-empty-cell-style";function cM(){if(typeof document>"u"||document.getElementById(jh))return;const e=document.createElement("style");e.id=jh,e.textContent=".g7le-preview-frame td[data-editor-name],.g7le-preview-frame th[data-editor-name]{min-width:56px;height:38px;}.g7le-preview-frame table[data-editor-name]{min-width:120px;}",document.head.appendChild(e)}function uM({node:e,params:t,nodeBox:n,cellBoxes:o,selectedCellPath:r,colorScheme:s,t:a,onPatchNode:l,onRequestInlineEdit:d}){const c=u.useMemo(()=>t&&typeof t=="object"?t:null,[t]),{measured:p,grid:f}=u.useMemo(()=>dM(e,c,o),[e,c,o]),[b,g]=u.useState(null),[m,h]=u.useState(null),v=u.useMemo(()=>{if(!r)return null;for(const j of f.rows)for(const ne of j.cells){const pe=il(e,ne,c).map(Q=>`children.${Q}`).join(".");if(r===pe||r.startsWith(pe+"."))return{r:ne.gridRow,c:ne.gridCol}}return null},[r,f,e,c]),y=u.useMemo(()=>b&&Ve(f,b.r,b.c)?b:v,[b,v,f]),[_,w]=u.useState(!1),[k,x]=u.useState(s==="dark"?"dark":"light"),[$,S]=u.useState(null),[C,T]=u.useState(null),E=u.useRef(null),A=u.useCallback(()=>{E.current!==null&&(clearTimeout(E.current),E.current=null)},[]),N=u.useCallback(()=>{A(),E.current=setTimeout(()=>{S(null),T(null),E.current=null},240)},[A]);u.useEffect(()=>()=>A(),[A]),u.useEffect(()=>{cM()},[]);const D=u.useCallback(j=>l(j),[l]),B=u.useMemo(()=>y?Ve(f,y.r,y.c):null,[f,y]),M=u.useMemo(()=>B&&typeof B.cell.props?.className=="string"?B.cell.props.className:"",[B]),O=u.useCallback(j=>D(sl(e,c,j)),[e,c,D]),z=u.useCallback(j=>D(sh(e,c,j)),[e,c,D]),H=u.useCallback((j,ne)=>D(ah(e,c,j,ne)),[e,c,D]),P=u.useCallback(j=>D(dh(e,c,j)),[e,c,D]),I=u.useCallback(j=>D(ch(e,c,j)),[e,c,D]),L=u.useCallback((j,ne)=>D(lh(e,c,j,ne)),[e,c,D]),F=u.useCallback(j=>{if(!B)return;const ne=B.gridRow,pe=B.gridCol,Q=j==="down"?ne+B.rowSpan:ne+B.rowSpan-1,le=j==="right"?pe+B.colSpan:pe+B.colSpan-1;if(Q>=f.rows.length||le>=f.colCount)return;const Ae=al(e,c,ne,pe,Q,le);Ae.ok&&D(Ae.table)},[B,f,e,c,D]),Y=!!(B&&B.gridCol+B.colSpan!y||!m||!Ve(f,m.r,m.c)?null:{r0:Math.min(y.r,m.r),c0:Math.min(y.c,m.c),r1:Math.max(y.r,m.r),c1:Math.max(y.c,m.c)},[y,m,f]),Z=u.useMemo(()=>{if(!X)return[];const j=new Set,ne=[];for(const pe of f.rows)for(const Q of pe.cells)if(Q.gridRow>=X.r0&&Q.gridRow<=X.r1&&Q.gridCol>=X.c0&&Q.gridCol<=X.c1){const le=`${Q.gridRow}:${Q.gridCol}`;j.has(le)||(j.add(le),ne.push({r:Q.gridRow,c:Q.gridCol}))}return ne},[X,f]),ae=Z.length>1,oe=u.useCallback(()=>{if(!X)return;const j=al(e,c,X.r0,X.c0,X.r1,X.c1);j.ok&&(D(j.table),h(null))},[X,e,c,D]),G=u.useCallback(()=>{y&&D(uh(e,c,y.r,y.c))},[e,c,y,D]),ee=u.useMemo(()=>{const j=c?.cellBorder;return j&&typeof j=="object"?j:null},[c]),ge=u.useMemo(()=>{const j=c?.cellBackground;return j&&typeof j=="object"?j:null},[c]),V=u.useMemo(()=>{const j=c?.cellPadding;return j&&typeof j=="object"?j:null},[c]),te=u.useMemo(()=>{if(_){const j=new Set,ne=[];for(const pe of f.rows)for(const Q of pe.cells){const le=`${Q.gridRow}:${Q.gridCol}`;j.has(le)||(j.add(le),ne.push({r:Q.gridRow,c:Q.gridCol}))}return ne}return ae?Z:y?[{r:y.r,c:y.c}]:[]},[_,ae,Z,y,f]),be=u.useCallback(j=>{if(te.length===0)return;let ne=e;for(const pe of te){const Q=(ee?.colors??[]).map(Ae=>Ae.token),le=j.split(/\s+/).filter(Ae=>Ae&&!Q.includes(Ae)).join(" ");ne=Ii(ne,c,pe.r,pe.c,le)}D(ne)},[e,c,te,ee,D]),Ee=u.useMemo(()=>{const j=(ee?.sides??[]).find(Q=>Q.value==="all")??(ee?.sides??[])[0],ne=(ee?.widths??[]).find(Q=>Q.value!=="none");if(!j||!ne)return[];const pe=ne.suffix??"";return[pe?`${j.prefix}${pe}`:j.prefix]},[ee]),De=u.useCallback((j,ne,pe)=>{if(Ee.length===0)return j;const Q=(ee?.sides??[]).map(Le=>Le.prefix),le=Ve(Pe(j,c),ne,pe),dt=(typeof le?.cell?.props?.className=="string"?le.cell.props.className:"").split(/\s+/).filter(Boolean);if(dt.some(Le=>Q.some(je=>Le===je||Le.startsWith(je+"-")&&/^-?\d+$/.test(Le.slice(je.length+1)))))return j;const ot=[...dt,...Ee].join(" ").trim();return Ii(j,c,ne,pe,ot)},[Ee,ee,c]),Se=u.useCallback((j,ne)=>{if(j.length===0)return;const pe=new Set(j.map(le=>`${le.r}:${le.c}`));let Q=e;for(const le of j){if(Q=De(Q,le.r,le.c),Q=Jt(Q,c,le.r,le.c,"borderColor",ne),le.r>0&&!pe.has(`${le.r-1}:${le.c}`)){const Ae=Ve(Pe(Q,c),le.r-1,le.c);Ae&&(Q=Jt(Q,c,Ae.gridRow,Ae.gridCol,"borderBottomColor",ne))}if(le.c>0&&!pe.has(`${le.r}:${le.c-1}`)){const Ae=Ve(Pe(Q,c),le.r,le.c-1);Ae&&(Q=Jt(Q,c,Ae.gridRow,Ae.gridCol,"borderRightColor",ne))}}D(Q)},[e,c,D,De]),Ue=u.useMemo(()=>(ee?.colors??[]).map(j=>j.token).filter(Boolean),[ee]),Me=u.useCallback(j=>{if(te.length===0||Ue.length===0)return;let ne=e;for(const pe of te)ne=De(ne,pe.r,pe.c),ne=ho(ne,c,pe.r,pe.c,j,Ue,k);D(ne)},[te,e,c,D,De,Ue,k]),Oe=u.useCallback(j=>Se(te,j),[Se,te]),Ye=u.useMemo(()=>{if(k==="dark")return"";const j=B?.cell.props?.style;return typeof j?.borderColor=="string"?j.borderColor:""},[B,k]),ze=u.useCallback((j,ne)=>{if(te.length===0)return;let pe=e;for(const Q of te)pe=Jt(pe,c,Q.r,Q.c,j,ne);D(pe)},[te,e,c,D]),Xe=u.useMemo(()=>(ge?.colors??[]).map(j=>j.token).filter(j=>!!j),[ge]),ve=u.useCallback(j=>{if(te.length===0||Xe.length===0)return;let ne=e;for(const pe of te)ne=ho(ne,c,pe.r,pe.c,j,Xe,k);D(ne)},[te,e,c,D,Xe,k]),qe=u.useCallback(j=>ze("backgroundColor",j),[ze]),We=u.useCallback(()=>{if(te.length===0)return;let j=e;for(const ne of te)j=ho(j,c,ne.r,ne.c,void 0,Xe,k),k==="light"&&(j=Jt(j,c,ne.r,ne.c,"backgroundColor",void 0));D(j)},[te,e,c,D,Xe,k]),ce=u.useCallback(j=>ze("padding",j),[ze]),q=u.useMemo(()=>{if(k==="dark")return"";const j=B?.cell.props?.style;return typeof j?.backgroundColor=="string"?j.backgroundColor:""},[B,k]),ie=u.useMemo(()=>typeof B?.cell.props?.className=="string"?B.cell.props.className:"",[B]),se=u.useMemo(()=>{const j=B?.cell.props?.style;return typeof j?.padding=="string"?j.padding:""},[B]),me=u.useCallback(j=>{const ne=j.currentTarget,pe=ne.style.pointerEvents;ne.style.pointerEvents="none";const Q=document.elementFromPoint(j.clientX,j.clientY);ne.style.pointerEvents=pe;const le=Q?.closest?.("[data-dnd-handle-path]");le&&le.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:j.clientX,clientY:j.clientY,pointerId:j.pointerId,pointerType:j.pointerType,button:j.button,isPrimary:!0}))},[]),Ce=u.useMemo(()=>{const j=new Map;for(const ne of p)j.has(ne.ref.gridCol)||j.set(ne.ref.gridCol,ne.box);return j},[p]),$e=u.useMemo(()=>{const j=new Map;for(const ne of p)j.has(ne.ref.gridRow)||j.set(ne.ref.gridRow,ne.box);return j},[p]);if(p.length===0)return null;const U=!!(B&&(B.colSpan>1||B.rowSpan>1)),ue=C!==null?C:y?.c??null,fe=$!==null?$:y?.r??null,xe=n.top-yl-ml-Bh,he=n.left-bl-ml-Bh;return i.jsxs("div",{className:"g7le-table-inplace","data-testid":"g7le-table-inplace",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:j7},children:[p.map(j=>{const ne=y&&y.r===j.ref.gridRow&&y.c===j.ref.gridCol,pe=X&&j.ref.gridRow>=X.r0&&j.ref.gridRow<=X.r1&&j.ref.gridCol>=X.c0&&j.ref.gridCol<=X.c1;return i.jsx("div",{"data-testid":`g7le-inplace-cell-${j.ref.gridRow}-${j.ref.gridCol}`,role:"button",tabIndex:-1,"aria-label":a("layout_editor.table_inplace.select_cell"),onMouseEnter:()=>{A(),S(j.ref.gridRow),T(j.ref.gridCol)},onMouseLeave:()=>{N()},onPointerDown:Q=>me(Q),onClick:Q=>{if(Q.stopPropagation(),Q.shiftKey&&(b||y))h({r:j.ref.gridRow,c:j.ref.gridCol});else{g({r:j.ref.gridRow,c:j.ref.gridCol}),h(null);const le=il(e,j.ref,c).map(Ae=>`children.${Ae}`).join(".");d?.(le)}},style:{position:"absolute",top:j.box.top,left:j.box.left,width:j.box.width,height:j.box.height,minWidth:Wh,minHeight:Wh,boxSizing:"border-box",pointerEvents:"auto",cursor:"pointer",outline:ne?"2px solid #2563eb":"none",outlineOffset:-2,background:pe&&!ne?"rgba(37,99,235,0.14)":"transparent"}},`cell-${j.ref.gridRow}-${j.ref.gridCol}`)}),i.jsx("div",{"data-testid":"g7le-inplace-col-rail",onMouseEnter:A,onMouseLeave:N,style:{position:"absolute",top:xe,left:n.left,width:n.width,height:yl,pointerEvents:"none"},children:ue!==null&&Ce.has(ue)&&(()=>{const j=ue,ne=Ce.get(j),pe=Ci(f,j,-1),Q=Ci(f,j,1),le=ne.left-n.left;return i.jsxs("div",{"data-testid":`g7le-inplace-colgutter-${j}`,onMouseEnter:()=>{A(),T(j)},onMouseLeave:N,style:{position:"absolute",top:0,left:le,width:ne.width,minWidth:96,height:yl,display:"flex",gap:3,justifyContent:"center",alignItems:"center",pointerEvents:"auto"},children:[i.jsx("button",{type:"button",title:a("layout_editor.table_inplace.move_col_left"),disabled:!pe.ok,onClick:()=>L(j,-1),"data-testid":`g7le-inplace-col-left-${j}`,style:pe.ok?_n:Ti,children:"←"}),i.jsx("button",{type:"button",title:a("layout_editor.table_inplace.add_col"),onClick:()=>P(j),"data-testid":`g7le-inplace-col-add-${j}`,style:_n,children:"+"}),i.jsx("button",{type:"button",title:a("layout_editor.table_inplace.remove_col"),disabled:f.colCount<=1,onClick:()=>I(j),"data-testid":`g7le-inplace-col-remove-${j}`,style:Hh,children:"✕"}),i.jsx("button",{type:"button",title:a("layout_editor.table_inplace.move_col_right"),disabled:!Q.ok,onClick:()=>L(j,1),"data-testid":`g7le-inplace-col-right-${j}`,style:Q.ok?_n:Ti,children:"→"})]},`colgut-${j}`)})()}),i.jsx("div",{"data-testid":"g7le-inplace-row-rail",style:{position:"absolute",top:n.top,left:he,width:bl,height:n.height,pointerEvents:"none"},children:fe!==null&&$e.has(fe)&&(()=>{const j=fe,ne=$e.get(j),pe=Si(f,j,-1),Q=Si(f,j,1),le=ne.top-n.top;return i.jsxs("div",{"data-testid":`g7le-inplace-rowgutter-${j}`,onMouseEnter:()=>{A(),S(j)},onMouseLeave:N,style:{position:"absolute",top:le,left:0,width:bl,height:ne.height,minHeight:48,display:"grid",gridTemplateColumns:"repeat(2, 22px)",gridAutoRows:"22px",gap:3,justifyContent:"center",alignContent:"center",pointerEvents:"auto"},children:[i.jsx("button",{type:"button",title:a("layout_editor.table_inplace.move_row_up"),disabled:!pe.ok,onClick:()=>H(j,-1),"data-testid":`g7le-inplace-row-up-${j}`,style:pe.ok?_n:Ti,children:"↑"}),i.jsx("button",{type:"button",title:a("layout_editor.table_inplace.add_row"),onClick:()=>O(j),"data-testid":`g7le-inplace-row-add-${j}`,style:_n,children:"+"}),i.jsx("button",{type:"button",title:a("layout_editor.table_inplace.remove_row"),disabled:f.rows.length<=1,onClick:()=>z(j),"data-testid":`g7le-inplace-row-remove-${j}`,style:Hh,children:"✕"}),i.jsx("button",{type:"button",title:a("layout_editor.table_inplace.move_row_down"),disabled:!Q.ok,onClick:()=>H(j,1),"data-testid":`g7le-inplace-row-down-${j}`,style:Q.ok?_n:Ti,children:"↓"})]},`rowgut-${j}`)})()}),i.jsxs("div",{"data-testid":"g7le-inplace-corner-add",style:{position:"absolute",top:n.top+n.height+ml,left:n.left,display:"flex",flexDirection:"column",gap:6,pointerEvents:"auto",minWidth:200,maxWidth:Math.max(240,n.width),background:"#fff",border:"1px solid #e2e8f0",borderRadius:8,padding:8,boxShadow:"0 2px 8px rgba(0,0,0,0.12)"},children:[i.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[i.jsxs("button",{type:"button","data-testid":"g7le-inplace-add-row-bottom",onClick:()=>O(f.rows.length-1),style:Fh,children:["+ ",a("layout_editor.table_inplace.add_row")]}),i.jsxs("button",{type:"button","data-testid":"g7le-inplace-add-col-right",onClick:()=>P(f.colCount-1),style:Fh,children:["+ ",a("layout_editor.table_inplace.add_col")]})]}),!y&&i.jsx("div",{"data-testid":"g7le-inplace-select-hint",style:{fontSize:11,color:"#94a3b8",borderTop:"1px solid #f1f5f9",paddingTop:6},children:a("layout_editor.table_inplace.select_cell_hint")}),y&&i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,borderTop:"1px solid #f1f5f9",paddingTop:6},children:[ae&&i.jsx("div",{"data-testid":"g7le-inplace-range-count",style:{fontSize:11,color:"#2563eb"},children:a("layout_editor.table_inplace.range_selected",{count:Z.length})}),i.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"center"},children:[ae?i.jsx("button",{type:"button","data-testid":"g7le-inplace-merge-range",onClick:oe,style:ar,children:a("layout_editor.table_inplace.merge_range")}):i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button","data-testid":"g7le-inplace-merge-right",disabled:!Y,onClick:()=>F("right"),style:Y?ar:vl,children:a("layout_editor.table_inplace.merge_right")}),i.jsx("button",{type:"button","data-testid":"g7le-inplace-merge-down",disabled:!K,onClick:()=>F("down"),style:K?ar:vl,children:a("layout_editor.table_inplace.merge_down")})]}),i.jsx("button",{type:"button","data-testid":"g7le-inplace-unmerge",disabled:!U,onClick:G,style:U?ar:vl,children:a("layout_editor.table_inplace.unmerge")})]}),i.jsxs("div",{"data-testid":"g7le-inplace-cell-color",style:{borderTop:"1px solid #f1f5f9",paddingTop:6,display:"flex",flexDirection:"column",gap:6},children:[i.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"#475569",cursor:"pointer"},children:[i.jsx("input",{type:"checkbox","data-testid":"g7le-inplace-border-all-toggle",checked:_,onChange:j=>w(j.target.checked)}),a("layout_editor.table_inplace.border_apply_all")]}),i.jsx(kh,{colorScheme:k,onChange:x,t:a}),ee&&i.jsx("div",{"data-testid":"g7le-inplace-cell-border",children:i.jsx(yh,{className:_?"":M,catalog:ee,t:a,onChange:be,colorScheme:k,onPresetToken:Me,colorStyle:_?"":Ye,onColorStyle:Oe})}),i.jsx("div",{"data-testid":"g7le-inplace-cell-fill",children:i.jsx(_h,{colorStyle:_?"":q,className:_?"":ie,catalog:ge,t:a,colorScheme:k,onPresetToken:ve,onCustomColor:qe,onClear:We})})]}),i.jsx("div",{"data-testid":"g7le-inplace-cell-padding",style:{borderTop:"1px solid #f1f5f9",paddingTop:6},children:i.jsx(xh,{paddingStyle:_?"":se,catalog:V,t:a,onChange:ce})})]})]})]})}const _n={width:22,height:22,lineHeight:"20px",padding:0,fontSize:13,border:"1px solid #cbd5e1",borderRadius:5,background:"#fff",color:"#475569",cursor:"pointer",boxShadow:"0 1px 3px rgba(0,0,0,0.18)"},Hh={..._n,border:"1px solid #fecaca",color:"#dc2626"},Ti={..._n,cursor:"not-allowed",opacity:.4,color:"#94a3b8",borderColor:"#e2e8f0"},ar={padding:"4px 10px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",boxShadow:"0 1px 2px rgba(0,0,0,0.12)"},vl={...ar,cursor:"not-allowed",opacity:.4},Fh={padding:"3px 8px",fontSize:11,border:"1px dashed #94a3b8",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"};let Kh=!1;function pM(){Kh||(Pn("children",Rg),Pn("table",rN),Pn("array",Nh),Pn("array-group",KN),Pn("array-cell-tree",ZN),ja("table",uM),Kh=!0)}function fM(){if(typeof window>"u")return;const e=window.G7Core;if(!e)return;const t=e.layoutEditor,n=Array.isArray(t?.__queue)?t.__queue:[],o=Array.isArray(t?.__readyCallbacks)?t.__readyCallbacks:[];e.layoutEditor={registerWidget:Ze,registerNodeEditor:Pn,registerCanvasOverlay:ja,onReady:r=>{typeof r=="function"&&r()}};for(const r of n){const[s,...a]=r;try{s==="widget"?Ze(a[0],a[1]):s==="nodeEditor"?Pn(a[0],a[1]):s==="canvasOverlay"&&ja(a[0],a[1])}catch{}}for(const r of o)try{r()}catch{}}const gM=1280;_z(),pM(),fM();async function hM(e){if(typeof fetch!="function")return[];try{const t=await fetch(en(`/api/admin/templates/${encodeURIComponent(e)}/editor/permission-candidates`,"json"),{credentials:"same-origin",headers:Ne()});if(!t.ok)return[];const o=(await t.json().catch(()=>null))?.data?.permissions;if(!Array.isArray(o))return[];const r=[];for(const s of o)if(s&&typeof s=="object"){const a=s.key,l=s.name;typeof a=="string"&&a.length>0&&r.push({value:a,label:typeof l=="string"&&l?l:a})}return r}catch{return[]}}function yM({templateIdentifier:e}){FD({templateIdentifier:e}),KD(e);const{state:t,dispatch:n}=Qe(),{t:o}=tt(),r=bo(),s=Dp(),a=XD(),l=t.selectedRoute?.layoutName??null,d=RD(e,l),c=t.editMode==="extension",p=u.useMemo(()=>c?ZD(a):s,[c,a,s]),[f,b]=u.useState(null),[g,m]=u.useState(null),[h,v]=u.useState([]),[y,_]=u.useState("user"),[w,k]=u.useState(null),[x,$]=u.useState(null),[S,C]=u.useState([]);u.useEffect(()=>{let q=!1;return(async()=>{try{const ie=await fetch(en(`/api/templates/${encodeURIComponent(e)}/components`,"json"),{credentials:"same-origin",headers:{Accept:"application/json"}});if(!ie.ok)return;const se=await ie.json().catch(()=>null);!q&&se&&typeof se=="object"&&b(se)}catch{}})(),()=>{q=!0}},[e]),u.useEffect(()=>{let q=!1;return(async()=>{const{spec:ie,sampleGlobalSources:se}=await ab({templateIdentifier:e,coreSeed:e8()});q||(m(ie),v(se),mM(e,ie,se))})(),()=>{q=!0}},[e]),u.useEffect(()=>{let q=!1;return(async()=>{if(typeof fetch=="function")try{const ie=await fetch(`/api/admin/templates/${encodeURIComponent(e)}`,{credentials:"same-origin",headers:Ne()});if(!ie.ok)return;const me=(await ie.json().catch(()=>null))?.data,Ce=me?.type;q||((Ce==="admin"||Ce==="user")&&_(Ce),typeof me?.name=="string"&&me.name&&k(me.name),typeof me?.version=="string"&&me.version&&$(me.version))}catch{}})(),()=>{q=!0}},[e]),u.useEffect(()=>{let q=!1;return(async()=>{if(typeof fetch=="function")try{const ie=await fetch("/api/admin/templates/?per_page=100&page=1",{credentials:"same-origin",headers:Ne()});if(!ie.ok)return;const me=(await ie.json().catch(()=>null))?.data?.data;if(!q&&Array.isArray(me)){const Ce=[];for(const $e of me){if(!$e||typeof $e!="object")continue;const U=$e.identifier;if(typeof U!="string"||!U||$e.is_pending===!0)continue;const fe=$e.type==="admin"?"admin":"user",xe=$e.name,he=$e.version;Ce.push({identifier:U,name:typeof xe=="string"?xe:U,version:typeof he=="string"?he:"",type:fe})}C(Ce)}}catch{}})(),()=>{q=!0}},[e]);const T=g?.nesting??null,E=t.selectedRoute?.path??null,A=t.editMode,N=t.selectedRoute?.layoutName??(c?a.document?.hostLayoutName??null:null),D=t.routeTree,B=u.useMemo(()=>{if(A!=="extension"||!N)return null;const q=xl(D,N);return q||`__base__/${N}`},[A,N,D]),M=c&&t.returnRoute===null&&!!N;u.useEffect(()=>{if(!M||!N)return;const q=xl(D,N);q&&n({type:"SET_RETURN_ROUTE",route:{path:q,layoutName:N}})},[M,N,D,n]),u.useEffect(()=>{const q=xD(A,E,B),ie=wD(g?.states?.groups,q);n({type:"SET_AVAILABLE_STATES",states:ie,activeStateId:kD(ie)})},[g,A,E,B,n]);const[O,z]=u.useState([]);u.useEffect(()=>{let q=!1;return(async()=>{const ie=await hM(e);q||z(ie)})(),()=>{q=!0}},[e]),VD(),UD();const H=u.useCallback(q=>{const ie=t.routeTree,se=q.split("?")[0]?.split("#")[0]??q;return bM(ie,se)?"route_in_tree":"route_not_in_tree"},[t.routeTree]),P=u.useCallback(q=>{const ie=q.split("?")[0]?.split("#")[0]??q,se=_l(t.routeTree,ie);se&&(p.isDirty&&!(!(typeof window<"u")||window.confirm(o("layout_editor.chrome.dirty_guard.message")))||n({type:"SELECT_ROUTE",route:{path:se.path,layoutName:se.layoutName}}))},[t.routeTree,p.isDirty,n]),I=u.useRef([]),L=u.useCallback(q=>{I.current=q},[]),[F,Y]=u.useState(null),K=u.useCallback(()=>Y(null),[]),X=u.useRef(null),Z=u.useRef(null);u.useEffect(()=>{const q=Z.current,ie=X.current;if(!q||!ie||typeof ResizeObserver>"u")return;const se=()=>{ie.style.setProperty("--g7le-header-h",`${Math.round(q.getBoundingClientRect().height)}px`)};se();const me=new ResizeObserver(se);return me.observe(q),()=>me.disconnect()},[]);const ae=u.useCallback(()=>{p.reload()},[p]),oe=u.useCallback(()=>{p.isDirty&&!(!(typeof window<"u")||window.confirm(o("layout_editor.chrome.dirty_guard.message")))||window.G7Core?.dispatch?.({handler:"openWindow",params:{path:`/admin/templates/${y}`,target:"_self"}})},[p.isDirty,o,y]),G=u.useCallback(q=>{if(!q||q===e||p.isDirty&&!(typeof window<"u"?window.confirm(o("layout_editor.chrome.dirty_guard.message")):!0))return;const ie=ea(q);window.G7Core?.dispatch?.({handler:"openWindow",params:{path:ie,target:"_self"}})},[e,p.isDirty,o]),ee=u.useCallback(()=>{const q=r.open({ariaLabel:o("layout_editor.custom_assets.title"),width:860,maxHeightRatio:.86,content:u.createElement(wE,{templateIdentifier:e,t:o,onClose:()=>r.close(q)})})},[r,e,o]),ge=typeof window<"u"&&(!!window.G7Config?.customAssetsDisabled||new URLSearchParams(window.location.search).get("custom")==="off"),V=u.useCallback(()=>{if(typeof window>"u"||p.isDirty&&!window.confirm(o("layout_editor.chrome.dirty_guard.message")))return;const q=new URL(window.location.href);if(ge){if(q.searchParams.delete("custom"),q.toString()===window.location.href){window.location.reload();return}}else q.searchParams.set("custom","off");window.G7Core?.dispatch?.({handler:"openWindow",params:{path:`${q.pathname}${q.search}${q.hash}`,target:"_self"}})},[p.isDirty,ge,o]),te=u.useCallback(()=>{const q=s7(e,t.selectedRoute?.path??null);window.G7Core?.dispatch?.({handler:"openWindow",params:{path:q}})},[e,t.selectedRoute]),be=u.useCallback(()=>{const q=t.selectedRoute?.layoutName??"";if(!q)return;const ie=r.open({ariaLabel:o("layout_editor.attachment_manager.title"),width:720,maxHeightRatio:.82,content:u.createElement(Bl,{templateIdentifier:e,layoutName:q,t:o,onClose:()=>r.close(ie)})})},[r,e,t.selectedRoute,o]),Ee=u.useCallback(()=>{const q=t.selectedRoute?.layoutName??"";if(!q)return;const ie=Yy(s.document?.raw??{}),se=r.open({ariaLabel:o("layout_editor.translation_manager.title"),width:720,maxHeightRatio:.82,content:u.createElement(ym,{templateIdentifier:e,layoutName:q,t:o,referencedKeys:ie,onClose:()=>r.close(se)})})},[r,e,t.selectedRoute,o,s.document]),De=u.useCallback((q,ie)=>{const se=window.G7Core;if(se&&typeof se.t=="function"){const me=se.t(q,ie);if(me&&me!==q&&!me.startsWith("$t:"))return me}return o(q,ie)},[o]),Se=u.useCallback(()=>{if(!t.selectedRoute||t.editMode==="extension"||t.editMode==="iteration_item")return;const q=r.open({ariaLabel:o("layout_editor.page_settings.title",{name:t.selectedRoute.path??""}),width:1080,maxHeightRatio:.88,closeOnEscape:!1,content:u.createElement(m$,{templateIdentifier:e,spec:g,t:o,resolveLabel:De,permissionCandidates:O,onClose:()=>r.close(q)})})},[r,t.selectedRoute,t.editMode,o,De,e,g,O]),Ue=u.useCallback(async()=>{const q=await d.createPreview(s.document?.raw??null);if(q.kind!=="success"){const ie=q.kind==="network_error"?q.message:o("layout_editor.preview_action.no_document");typeof window<"u"&&window.alert(ie)}},[d,s.document,o]),Me=u.useCallback(()=>{const q=t.selectedRoute?.layoutName??"",ie=t.selectedRoute?.path??"",se=t.editMode==="extension"&&ie.startsWith("__extension__/")?ie.slice(14):null,me=se?{kind:"extension",extensionId:se}:q?{kind:"layout",layoutName:q}:null;if(!me)return;const Ce=r.open({ariaLabel:o("layout_editor.version_history.title"),width:640,maxHeightRatio:.82,content:u.createElement(nE,{templateIdentifier:e,target:me,t:o,onRestored:async $e=>{typeof $e=="number"&&(me.kind==="extension"?n({type:"SET_EXTENSION_VERSION",extensionId:me.extensionId,version:$e}):n({type:"SET_LAYOUT_VERSION",layoutName:me.layoutName,version:$e})),await p.reload()},onClose:()=>r.close(Ce)})})},[r,e,t.selectedRoute,t.editMode,o,p,n]),Oe=p.dirtyKeys.size>0||p.isDirty;u.useEffect(()=>{if(!Oe)return;const q=ie=>{ie.preventDefault(),ie.returnValue=""};return window.addEventListener("beforeunload",q),()=>window.removeEventListener("beforeunload",q)},[Oe]);const Ye=u.useCallback(()=>{!p.isDirty||!(!(typeof window<"u")||window.confirm(o("layout_editor.chrome.reset_guard.message")))||p.reload()},[p,o]),ze=u.useCallback(async()=>{const q=await p.save({sessionAddedPaths:I.current});Y(q),q.kind==="success"&&typeof q.newContentVersion=="number"&&(q.savedExtensionId?n({type:"SET_EXTENSION_VERSION",extensionId:q.savedExtensionId,version:q.newContentVersion}):q.savedLayoutName&&n({type:"SET_LAYOUT_VERSION",layoutName:q.savedLayoutName,version:q.newContentVersion}))},[p,n]),Xe=u.useCallback(()=>{const q=r.open({ariaLabel:o("layout_editor.shortcuts.title"),width:560,maxHeightRatio:.85,content:u.createElement(DE,{t:o,onClose:()=>r.close(q)})})},[r,o]),ve=u.useMemo(()=>({save:()=>{ze()},exit:oe,editCode:te,reset:Ye,translations:Ee,addElement:()=>{t.selectedRoute&&n({type:"TOGGLE_PALETTE"})},help:Xe,preview:()=>{t.selectedRoute?.layoutName&&Ue()}}),[ze,oe,te,Ye,Ee,t.selectedRoute,n,Xe,Ue]),[qe,We]=u.useState(!1);u.useEffect(()=>{const q=window.setInterval(()=>{We(!!window.__g7LayoutEditorHasSelection)},200);return()=>window.clearInterval(q)},[]),lp({handlers:ve,hasSelection:qe});const ce=p;return t.routesError?i.jsx("div",{className:"g7le-chrome g7le-chrome--routes-error","data-testid":"g7le-chrome-routes-error",style:{position:"fixed",inset:0,display:"flex",background:"#f8fafc",color:"#0f172a",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif',fontSize:13,lineHeight:1.5,zIndex:9e3},children:i.jsx(qa,{error:t.routesError})}):i.jsx("div",{className:"g7le-chrome","data-testid":"g7le-chrome",ref:X,style:{position:"static",minHeight:"100vh",minWidth:gM,background:"#f8fafc",color:"#0f172a",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif',fontSize:13,lineHeight:1.5,zIndex:9e3},children:i.jsxs(yy,{value:ce,children:[c&&a.needsHostPicker&&a.document&&i.jsx(QD,{hostLayouts:a.document.hostLayouts,extensionLabel:null,onSelect:a.selectHost}),i.jsxs("div",{className:"g7le-chrome__header","data-testid":"g7le-chrome-header",ref:Z,style:{position:"sticky",top:0,zIndex:20,background:"#f8fafc"},children:[i.jsx(Sy,{onSave:()=>{ze()},isDirty:p.isDirty,onExit:oe,onEditCode:te,onManageImages:be,onManageTranslations:Ee,onPageSettings:Se,onReset:Ye,onShowShortcuts:Xe,onPreview:Ue,onShowVersions:Me,templateName:w,templateVersion:x,templateList:S,onSwitchTemplate:G,onToggleCustomAssets:V,customAssetsDisabled:ge,onManageCustomAssets:ee}),i.jsx(GE,{result:F,onDismiss:K,onLoadLatest:ae}),i.jsxs("div",{className:"g7le-chrome__device-toolbar","data-testid":"g7le-chrome-device-toolbar",style:{display:"flex",justifyContent:"center",padding:"6px 12px",background:"#f1f5f9",borderBottom:"1px solid #e2e8f0"},children:[i.jsx(vD,{}),i.jsx(_D,{})]})]}),i.jsxs("div",{className:"g7le-chrome__body",style:{display:"grid",gridTemplateColumns:"auto 1fr",alignItems:"stretch"},children:[i.jsx(f7,{}),i.jsx(gD,{manifest:f,nesting:T,componentPalette:g?.componentPalette??null,spec:g,permissionCandidates:O,sampleGlobalSources:h,resolveRouteMatch:H,onNavigateToDestination:P,onSessionAddedPathsChange:L})]}),i.jsx(vy,{})]})})}function _l(e,t){for(const n of e){if(n.kind==="route"&&n.path===t)return n;if(n.children&&n.children.length>0){const o=_l(n.children,t);if(o)return o}}return null}function bM(e,t){return _l(e,t)!==null}function xl(e,t){for(const n of e){if(n.kind==="route"&&n.layoutName===t&&typeof n.path=="string")return n.path;if(n.children&&n.children.length>0){const o=xl(n.children,t);if(o)return o}}return null}function mM(e,t,n){const o=[];Ya({sources:n,isGuestOnly:!1,warn:s=>{const a=/extension '([^']+)' override of core key '([^']+)'/.exec(s);a&&o.push(`${a[1]}:${a[2]}`)}});const r=t?.sampleData?.byDataSourceId?Object.keys(t.sampleData.byDataSourceId).length:0;iy({templateIdentifier:e,mergedSources:[...n.map(s=>({kind:s.kind,id:s.id}))],blockCounts:{controls:t?.controls?Object.keys(t.controls).length:0,componentCapabilities:t?.componentCapabilities?Object.keys(t.componentCapabilities).length:0,actionRecipes:t?.actionRecipes?Object.keys(t.actionRecipes).length:0,conditionRecipes:t?.conditionRecipes?Object.keys(t.conditionRecipes).length:0,paletteGroups:t?.componentPalette?.groups?.length??0,stateGroups:t?.states?.groups?.length??0,sampleDataIds:r},sampleGlobalSourceCount:n.length,sampleGlobalConflicts:o,timestamp:Date.now()})}function Vh({templateIdentifier:e,initialLocale:t}){return u.useEffect(()=>()=>{Zh(),Rh(),ty(),ny(),oy(),ry(),sy(),ay(),ly()},[]),i.jsx(hy,{templateIdentifier:e,initialLocale:t,children:i.jsx(my,{children:i.jsx(yM,{templateIdentifier:e})})})}if(typeof window<"u"){const e=window.G7Core||(window.G7Core={});if(e.__LayoutEditorChrome=Vh,typeof e.__onChromeReady=="function")try{e.__onChromeReady()}catch{}}dn.LayoutEditorChrome=Vh,Object.defineProperty(dn,Symbol.toStringTag,{value:"Module"})})(this.G7LayoutEditor=this.G7LayoutEditor||{},ReactJSXRuntime,React,ReactDOM); + `},C2={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function $2(e){let{announcements:t=C2,container:n,hiddenTextDescribedById:o,screenReaderInstructions:r=S2}=e;const{announce:s,announcement:a}=x2(),l=ai("DndLiveRegion"),[d,c]=u.useState(!1);if(u.useEffect(()=>{c(!0)},[]),w2(u.useMemo(()=>({onDragStart(f){let{active:b}=f;s(t.onDragStart({active:b}))},onDragMove(f){let{active:b,over:g}=f;t.onDragMove&&s(t.onDragMove({active:b,over:g}))},onDragOver(f){let{active:b,over:g}=f;s(t.onDragOver({active:b,over:g}))},onDragEnd(f){let{active:b,over:g}=f;s(t.onDragEnd({active:b,over:g}))},onDragCancel(f){let{active:b,over:g}=f;s(t.onDragCancel({active:b,over:g}))}}),[s,t])),!d)return null;const p=u.createElement(u.Fragment,null,u.createElement(v2,{id:o,value:r.draggable}),u.createElement(_2,{id:l,announcement:a}));return n?En.createPortal(p,n):p}var it;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(it||(it={}));function ci(){}function E2(e,t){return u.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function I2(){for(var e=arguments.length,t=new Array(e),n=0;n[...t].filter(o=>o!=null),[...t])}const Ft=Object.freeze({x:0,y:0});function A2(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function T2(e,t){const n=di(e);if(!n)return"0 0";const o={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return o.x+"% "+o.y+"%"}function D2(e,t){let{data:{value:n}}=e,{data:{value:o}}=t;return n-o}function z2(e,t){let{data:{value:n}}=e,{data:{value:o}}=t;return o-n}function N2(e){let{left:t,top:n,height:o,width:r}=e;return[{x:t,y:n},{x:t+r,y:n},{x:t,y:n+o},{x:t+r,y:n+o}]}function M2(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function L2(e,t){const n=Math.max(t.top,e.top),o=Math.max(t.left,e.left),r=Math.min(t.left+t.width,e.left+e.width),s=Math.min(t.top+t.height,e.top+e.height),a=r-o,l=s-n;if(o{let{collisionRect:t,droppableRects:n,droppableContainers:o}=e;const r=[];for(const s of o){const{id:a}=s,l=n.get(a);if(l){const d=L2(l,t);d>0&&r.push({id:a,data:{droppableContainer:s,value:d}})}}return r.sort(z2)};function O2(e,t){const{top:n,left:o,bottom:r,right:s}=t;return n<=e.y&&e.y<=r&&o<=e.x&&e.x<=s}const B2=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:o}=e;if(!o)return[];const r=[];for(const s of t){const{id:a}=s,l=n.get(a);if(l&&O2(o,l)){const c=N2(l).reduce((f,b)=>f+A2(o,b),0),p=Number((c/4).toFixed(4));r.push({id:a,data:{droppableContainer:s,value:p}})}}return r.sort(D2)};function W2(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function nf(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Ft}function j2(e){return function(n){for(var o=arguments.length,r=new Array(o>1?o-1:0),s=1;s({...a,top:a.top+e*l.y,bottom:a.bottom+e*l.y,left:a.left+e*l.x,right:a.right+e*l.x}),{...n})}}const H2=j2(1);function of(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function F2(e,t,n){const o=of(t);if(!o)return e;const{scaleX:r,scaleY:s,x:a,y:l}=o,d=e.left-a-(1-r)*parseFloat(n),c=e.top-l-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),p=r?e.width/r:e.width,f=s?e.height/s:e.height;return{width:p,height:f,top:c,right:d+p,bottom:c+f,left:d}}const K2={ignoreTransform:!1};function Go(e,t){t===void 0&&(t=K2);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:p}=xt(e).getComputedStyle(e);c&&(n=F2(n,c,p))}const{top:o,left:r,width:s,height:a,bottom:l,right:d}=n;return{top:o,left:r,width:s,height:a,bottom:l,right:d}}function rf(e){return Go(e,{ignoreTransform:!0})}function V2(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function U2(e,t){return t===void 0&&(t=xt(e).getComputedStyle(e)),t.position==="fixed"}function q2(e,t){t===void 0&&(t=xt(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(r=>{const s=t[r];return typeof s=="string"?n.test(s):!1})}function ba(e,t){const n=[];function o(r){if(t!=null&&n.length>=t||!r)return n;if(ga(r)&&r.scrollingElement!=null&&!n.includes(r.scrollingElement))return n.push(r.scrollingElement),n;if(!Ko(r)||Qp(r)||n.includes(r))return n;const s=xt(e).getComputedStyle(r);return r!==e&&q2(r,s)&&n.push(r),U2(r,s)?n:o(r.parentNode)}return e?o(e):n}function sf(e){const[t]=ba(e,1);return t??null}function ma(e){return!oi||!e?null:po(e)?e:fa(e)?ga(e)||e===fo(e).scrollingElement?window:Ko(e)?e:null:null}function af(e){return po(e)?e.scrollX:e.scrollLeft}function lf(e){return po(e)?e.scrollY:e.scrollTop}function va(e){return{x:af(e),y:lf(e)}}var lt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(lt||(lt={}));function df(e){return!oi||!e?!1:e===document.scrollingElement}function cf(e){const t={x:0,y:0},n=df(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},o={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},r=e.scrollTop<=t.y,s=e.scrollLeft<=t.x,a=e.scrollTop>=o.y,l=e.scrollLeft>=o.x;return{isTop:r,isLeft:s,isBottom:a,isRight:l,maxScroll:o,minScroll:t}}const G2={x:.2,y:.2};function Y2(e,t,n,o,r){let{top:s,left:a,right:l,bottom:d}=n;o===void 0&&(o=10),r===void 0&&(r=G2);const{isTop:c,isBottom:p,isLeft:f,isRight:b}=cf(e),g={x:0,y:0},m={x:0,y:0},h={height:t.height*r.y,width:t.width*r.x};return!c&&s<=t.top+h.height?(g.y=lt.Backward,m.y=o*Math.abs((t.top+h.height-s)/h.height)):!p&&d>=t.bottom-h.height&&(g.y=lt.Forward,m.y=o*Math.abs((t.bottom-h.height-d)/h.height)),!b&&l>=t.right-h.width?(g.x=lt.Forward,m.x=o*Math.abs((t.right-h.width-l)/h.width)):!f&&a<=t.left+h.width&&(g.x=lt.Backward,m.x=o*Math.abs((t.left+h.width-a)/h.width)),{direction:g,speed:m}}function X2(e){if(e===document.scrollingElement){const{innerWidth:s,innerHeight:a}=window;return{top:0,left:0,right:s,bottom:a,width:s,height:a}}const{top:t,left:n,right:o,bottom:r}=e.getBoundingClientRect();return{top:t,left:n,right:o,bottom:r,width:e.clientWidth,height:e.clientHeight}}function uf(e){return e.reduce((t,n)=>go(t,va(n)),Ft)}function J2(e){return e.reduce((t,n)=>t+af(n),0)}function Z2(e){return e.reduce((t,n)=>t+lf(n),0)}function pf(e,t){if(t===void 0&&(t=Go),!e)return;const{top:n,left:o,bottom:r,right:s}=t(e);sf(e)&&(r<=0||s<=0||n>=window.innerHeight||o>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Q2=[["x",["left","right"],J2],["y",["top","bottom"],Z2]];class _a{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const o=ba(n),r=uf(o);this.rect={...t},this.width=t.width,this.height=t.height;for(const[s,a,l]of Q2)for(const d of a)Object.defineProperty(this,d,{get:()=>{const c=l(o),p=r[s]-c;return this.rect[d]+p},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Yo{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var o;return(o=this.target)==null?void 0:o.removeEventListener(...n)})},this.target=t}add(t,n,o){var r;(r=this.target)==null||r.addEventListener(t,n,o),this.listeners.push([t,n,o])}}function R2(e){const{EventTarget:t}=xt(e);return e instanceof t?e:fo(e)}function xa(e,t){const n=Math.abs(e.x),o=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+o**2)>t:"x"in t&&"y"in t?n>t.x&&o>t.y:"x"in t?n>t.x:"y"in t?o>t.y:!1}var At;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(At||(At={}));function ff(e){e.preventDefault()}function eI(e){e.stopPropagation()}var Fe;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(Fe||(Fe={}));const gf={start:[Fe.Space,Fe.Enter],cancel:[Fe.Esc],end:[Fe.Space,Fe.Enter,Fe.Tab]},tI=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Fe.Right:return{...n,x:n.x+25};case Fe.Left:return{...n,x:n.x-25};case Fe.Down:return{...n,y:n.y+25};case Fe.Up:return{...n,y:n.y-25}}};class hf{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new Yo(fo(n)),this.windowListeners=new Yo(xt(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(At.Resize,this.handleCancel),this.windowListeners.add(At.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(At.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,o=t.node.current;o&&pf(o),n(Ft)}handleKeyDown(t){if(ya(t)){const{active:n,context:o,options:r}=this.props,{keyboardCodes:s=gf,coordinateGetter:a=tI,scrollBehavior:l="smooth"}=r,{code:d}=t;if(s.end.includes(d)){this.handleEnd(t);return}if(s.cancel.includes(d)){this.handleCancel(t);return}const{collisionRect:c}=o.current,p=c?{x:c.left,y:c.top}:Ft;this.referenceCoordinates||(this.referenceCoordinates=p);const f=a(t,{active:n,context:o.current,currentCoordinates:p});if(f){const b=li(f,p),g={x:0,y:0},{scrollableAncestors:m}=o.current;for(const h of m){const v=t.code,{isTop:y,isRight:_,isLeft:w,isBottom:k,maxScroll:x,minScroll:$}=cf(h),C=X2(h),S={x:Math.min(v===Fe.Right?C.right-C.width/2:C.right,Math.max(v===Fe.Right?C.left:C.left+C.width/2,f.x)),y:Math.min(v===Fe.Down?C.bottom-C.height/2:C.bottom,Math.max(v===Fe.Down?C.top:C.top+C.height/2,f.y))},D=v===Fe.Right&&!_||v===Fe.Left&&!w,E=v===Fe.Down&&!k||v===Fe.Up&&!y;if(D&&S.x!==f.x){const I=h.scrollLeft+b.x,N=v===Fe.Right&&I<=x.x||v===Fe.Left&&I>=$.x;if(N&&!b.y){h.scrollTo({left:I,behavior:l});return}N?g.x=h.scrollLeft-I:g.x=v===Fe.Right?h.scrollLeft-x.x:h.scrollLeft-$.x,g.x&&h.scrollBy({left:-g.x,behavior:l});break}else if(E&&S.y!==f.y){const I=h.scrollTop+b.y,N=v===Fe.Down&&I<=x.y||v===Fe.Up&&I>=$.y;if(N&&!b.x){h.scrollTo({top:I,behavior:l});return}N?g.y=h.scrollTop-I:g.y=v===Fe.Down?h.scrollTop-x.y:h.scrollTop-$.y,g.y&&h.scrollBy({top:-g.y,behavior:l});break}}this.handleMove(t,go(li(f,this.referenceCoordinates),g))}}}handleMove(t,n){const{onMove:o}=this.props;t.preventDefault(),o(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}hf.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:o=gf,onActivation:r}=t,{active:s}=n;const{code:a}=e.nativeEvent;if(o.start.includes(a)){const l=s.activatorNode.current;return l&&e.target!==l?!1:(e.preventDefault(),r?.({event:e.nativeEvent}),!0)}return!1}}];function yf(e){return!!(e&&"distance"in e)}function bf(e){return!!(e&&"delay"in e)}class wa{constructor(t,n,o){var r;o===void 0&&(o=R2(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:s}=t,{target:a}=s;this.props=t,this.events=n,this.document=fo(a),this.documentListeners=new Yo(this.document),this.listeners=new Yo(o),this.windowListeners=new Yo(xt(a)),this.initialCoordinates=(r=di(s))!=null?r:Ft,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:o}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(At.Resize,this.handleCancel),this.windowListeners.add(At.DragStart,ff),this.windowListeners.add(At.VisibilityChange,this.handleCancel),this.windowListeners.add(At.ContextMenu,ff),this.documentListeners.add(At.Keydown,this.handleKeydown),n){if(o!=null&&o({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(bf(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(yf(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:o,onPending:r}=this.props;r(o,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(At.Click,eI,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(At.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:o,initialCoordinates:r,props:s}=this,{onMove:a,options:{activationConstraint:l}}=s;if(!r)return;const d=(n=di(t))!=null?n:Ft,c=li(r,d);if(!o&&l){if(yf(l)){if(l.tolerance!=null&&xa(c,l.tolerance))return this.handleCancel();if(xa(c,l.distance))return this.handleStart()}if(bf(l)&&xa(c,l.tolerance))return this.handleCancel();this.handlePending(l,c);return}t.cancelable&&t.preventDefault(),a(d)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===Fe.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const nI={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class ka extends wa{constructor(t){const{event:n}=t,o=fo(n.target);super(t,nI,o)}}ka.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:o}=t;return!n.isPrimary||n.button!==0?!1:(o?.({event:n}),!0)}}];const oI={move:{name:"mousemove"},end:{name:"mouseup"}};var Sa;(function(e){e[e.RightClick=2]="RightClick"})(Sa||(Sa={}));class rI extends wa{constructor(t){super(t,oI,fo(t.event.target))}}rI.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:o}=t;return n.button===Sa.RightClick?!1:(o?.({event:n}),!0)}}];const Ca={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class iI extends wa{constructor(t){super(t,Ca)}static setup(){return window.addEventListener(Ca.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Ca.move.name,t)};function t(){}}}iI.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:o}=t;const{touches:r}=n;return r.length>1?!1:(o?.({event:n}),!0)}}];var Xo;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Xo||(Xo={}));var ui;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(ui||(ui={}));function sI(e){let{acceleration:t,activator:n=Xo.Pointer,canScroll:o,draggingRect:r,enabled:s,interval:a=5,order:l=ui.TreeOrder,pointerCoordinates:d,scrollableAncestors:c,scrollableAncestorRects:p,delta:f,threshold:b}=e;const g=lI({delta:f,disabled:!s}),[m,h]=g2(),v=u.useRef({x:0,y:0}),y=u.useRef({x:0,y:0}),_=u.useMemo(()=>{switch(n){case Xo.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case Xo.DraggableRect:return r}},[n,r,d]),w=u.useRef(null),k=u.useCallback(()=>{const $=w.current;if(!$)return;const C=v.current.x*y.current.x,S=v.current.y*y.current.y;$.scrollBy(C,S)},[]),x=u.useMemo(()=>l===ui.TreeOrder?[...c].reverse():c,[l,c]);u.useEffect(()=>{if(!s||!c.length||!_){h();return}for(const $ of x){if(o?.($)===!1)continue;const C=c.indexOf($),S=p[C];if(!S)continue;const{direction:D,speed:E}=Y2($,S,_,t,b);for(const I of["x","y"])g[I][D[I]]||(E[I]=0,D[I]=0);if(E.x>0||E.y>0){h(),w.current=$,m(k,a),v.current=E,y.current=D;return}}v.current={x:0,y:0},y.current={x:0,y:0},h()},[t,k,o,h,s,a,JSON.stringify(_),JSON.stringify(g),m,c,x,p,JSON.stringify(b)])}const aI={x:{[lt.Backward]:!1,[lt.Forward]:!1},y:{[lt.Backward]:!1,[lt.Forward]:!1}};function lI(e){let{delta:t,disabled:n}=e;const o=si(t);return Uo(r=>{if(n||!o||!r)return aI;const s={x:Math.sign(t.x-o.x),y:Math.sign(t.y-o.y)};return{x:{[lt.Backward]:r.x[lt.Backward]||s.x===-1,[lt.Forward]:r.x[lt.Forward]||s.x===1},y:{[lt.Backward]:r.y[lt.Backward]||s.y===-1,[lt.Forward]:r.y[lt.Forward]||s.y===1}}},[n,t,o])}function dI(e,t){const n=t!=null?e.get(t):void 0,o=n?n.node.current:null;return Uo(r=>{var s;return t==null?null:(s=o??r)!=null?s:null},[o,t])}function cI(e,t){return u.useMemo(()=>e.reduce((n,o)=>{const{sensor:r}=o,s=r.activators.map(a=>({eventName:a.eventName,handler:t(a.handler,o)}));return[...n,...s]},[]),[e,t])}var Jo;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Jo||(Jo={}));var $a;(function(e){e.Optimized="optimized"})($a||($a={}));const mf=new Map;function uI(e,t){let{dragging:n,dependencies:o,config:r}=t;const[s,a]=u.useState(null),{frequency:l,measure:d,strategy:c}=r,p=u.useRef(e),f=v(),b=Vo(f),g=u.useCallback(function(y){y===void 0&&(y=[]),!b.current&&a(_=>_===null?y:_.concat(y.filter(w=>!_.includes(w))))},[b]),m=u.useRef(null),h=Uo(y=>{if(f&&!n)return mf;if(!y||y===mf||p.current!==e||s!=null){const _=new Map;for(let w of e){if(!w)continue;if(s&&s.length>0&&!s.includes(w.id)&&w.rect.current){_.set(w.id,w.rect.current);continue}const k=w.node.current,x=k?new _a(d(k),k):null;w.rect.current=x,x&&_.set(w.id,x)}return _}return y},[e,s,n,f,d]);return u.useEffect(()=>{p.current=e},[e]),u.useEffect(()=>{f||g()},[n,f]),u.useEffect(()=>{s&&s.length>0&&a(null)},[JSON.stringify(s)]),u.useEffect(()=>{f||typeof l!="number"||m.current!==null||(m.current=setTimeout(()=>{g(),m.current=null},l))},[l,f,g,...o]),{droppableRects:h,measureDroppableContainers:g,measuringScheduled:s!=null};function v(){switch(c){case Jo.Always:return!1;case Jo.BeforeDragging:return n;default:return!n}}}function Ea(e,t){return Uo(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function pI(e,t){return Ea(e,t)}function fI(e){let{callback:t,disabled:n}=e;const o=ri(t),r=u.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:s}=window;return new s(o)},[o,n]);return u.useEffect(()=>()=>r?.disconnect(),[r]),r}function pi(e){let{callback:t,disabled:n}=e;const o=ri(t),r=u.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:s}=window;return new s(o)},[n]);return u.useEffect(()=>()=>r?.disconnect(),[r]),r}function gI(e){return new _a(Go(e),e)}function vf(e,t,n){t===void 0&&(t=gI);const[o,r]=u.useState(null);function s(){r(d=>{if(!e)return null;if(e.isConnected===!1){var c;return(c=d??n)!=null?c:null}const p=t(e);return JSON.stringify(d)===JSON.stringify(p)?d:p})}const a=fI({callback(d){if(e)for(const c of d){const{type:p,target:f}=c;if(p==="childList"&&f instanceof HTMLElement&&f.contains(e)){s();break}}}}),l=pi({callback:s});return ln(()=>{s(),e?(l?.observe(e),a?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),a?.disconnect())},[e]),o}function hI(e){const t=Ea(e);return nf(e,t)}const _f=[];function yI(e){const t=u.useRef(e),n=Uo(o=>e?o&&o!==_f&&e&&t.current&&e.parentNode===t.current.parentNode?o:ba(e):_f,[e]);return u.useEffect(()=>{t.current=e},[e]),n}function bI(e){const[t,n]=u.useState(null),o=u.useRef(e),r=u.useCallback(s=>{const a=ma(s.target);a&&n(l=>l?(l.set(a,va(a)),new Map(l)):null)},[]);return u.useEffect(()=>{const s=o.current;if(e!==s){a(s);const l=e.map(d=>{const c=ma(d);return c?(c.addEventListener("scroll",r,{passive:!0}),[c,va(c)]):null}).filter(d=>d!=null);n(l.length?new Map(l):null),o.current=e}return()=>{a(e),a(s)};function a(l){l.forEach(d=>{const c=ma(d);c?.removeEventListener("scroll",r)})}},[r,e]),u.useMemo(()=>e.length?t?Array.from(t.values()).reduce((s,a)=>go(s,a),Ft):uf(e):Ft,[e,t])}function xf(e,t){t===void 0&&(t=[]);const n=u.useRef(null);return u.useEffect(()=>{n.current=null},t),u.useEffect(()=>{const o=e!==Ft;o&&!n.current&&(n.current=e),!o&&n.current&&(n.current=null)},[e]),n.current?li(e,n.current):Ft}function mI(e){u.useEffect(()=>{if(!oi)return;const t=e.map(n=>{let{sensor:o}=n;return o.setup==null?void 0:o.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function vI(e,t){return u.useMemo(()=>e.reduce((n,o)=>{let{eventName:r,handler:s}=o;return n[r]=a=>{s(a,t)},n},{}),[e,t])}function wf(e){return u.useMemo(()=>e?V2(e):null,[e])}const kf=[];function _I(e,t){t===void 0&&(t=Go);const[n]=e,o=wf(n?xt(n):null),[r,s]=u.useState(kf);function a(){s(()=>e.length?e.map(d=>df(d)?o:new _a(t(d),d)):kf)}const l=pi({callback:a});return ln(()=>{l?.disconnect(),a(),e.forEach(d=>l?.observe(d))},[e]),r}function Sf(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Ko(t)?t:e}function xI(e){let{measure:t}=e;const[n,o]=u.useState(null),r=u.useCallback(c=>{for(const{target:p}of c)if(Ko(p)){o(f=>{const b=t(p);return f?{...f,width:b.width,height:b.height}:b});break}},[t]),s=pi({callback:r}),a=u.useCallback(c=>{const p=Sf(c);s?.disconnect(),p&&s?.observe(p),o(p?t(p):null)},[t,s]),[l,d]=ii(a);return u.useMemo(()=>({nodeRef:l,rect:n,setRef:d}),[n,l,d])}const wI=[{sensor:ka,options:{}},{sensor:hf,options:{}}],kI={current:{}},fi={draggable:{measure:rf},droppable:{measure:rf,strategy:Jo.WhileDragging,frequency:$a.Optimized},dragOverlay:{measure:Go}};class Zo extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,o;return(n=(o=this.get(t))==null?void 0:o.node.current)!=null?n:void 0}}const SI={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Zo,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:ci},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:fi,measureDroppableContainers:ci,windowRect:null,measuringScheduled:!1},Cf={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:ci,draggableNodes:new Map,over:null,measureDroppableContainers:ci},Qo=u.createContext(Cf),$f=u.createContext(SI);function CI(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Zo}}}function $I(e,t){switch(t.type){case it.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case it.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case it.DragEnd:case it.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case it.RegisterDroppable:{const{element:n}=t,{id:o}=n,r=new Zo(e.droppable.containers);return r.set(o,n),{...e,droppable:{...e.droppable,containers:r}}}case it.SetDroppableDisabled:{const{id:n,key:o,disabled:r}=t,s=e.droppable.containers.get(n);if(!s||o!==s.key)return e;const a=new Zo(e.droppable.containers);return a.set(n,{...s,disabled:r}),{...e,droppable:{...e.droppable,containers:a}}}case it.UnregisterDroppable:{const{id:n,key:o}=t,r=e.droppable.containers.get(n);if(!r||o!==r.key)return e;const s=new Zo(e.droppable.containers);return s.delete(n),{...e,droppable:{...e.droppable,containers:s}}}default:return e}}function EI(e){let{disabled:t}=e;const{active:n,activatorEvent:o,draggableNodes:r}=u.useContext(Qo),s=si(o),a=si(n?.id);return u.useEffect(()=>{if(!t&&!o&&s&&a!=null){if(!ya(s)||document.activeElement===s.target)return;const l=r.get(a);if(!l)return;const{activatorNode:d,node:c}=l;if(!d.current&&!c.current)return;requestAnimationFrame(()=>{for(const p of[d.current,c.current]){if(!p)continue;const f=b2(p);if(f){f.focus();break}}})}},[o,t,r,a,s]),null}function Ef(e,t){let{transform:n,...o}=t;return e!=null&&e.length?e.reduce((r,s)=>s({transform:r,...o}),n):n}function II(e){return u.useMemo(()=>({draggable:{...fi.draggable,...e?.draggable},droppable:{...fi.droppable,...e?.droppable},dragOverlay:{...fi.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function AI(e){let{activeNode:t,measure:n,initialRect:o,config:r=!0}=e;const s=u.useRef(!1),{x:a,y:l}=typeof r=="boolean"?{x:r,y:r}:r;ln(()=>{if(!a&&!l||!t){s.current=!1;return}if(s.current||!o)return;const c=t?.node.current;if(!c||c.isConnected===!1)return;const p=n(c),f=nf(p,o);if(a||(f.x=0),l||(f.y=0),s.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const b=sf(c);b&&b.scrollBy({top:f.y,left:f.x})}},[t,a,l,o,n])}const gi=u.createContext({...Ft,scaleX:1,scaleY:1});var bn;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(bn||(bn={}));const TI=u.memo(function(t){var n,o,r,s;let{id:a,accessibility:l,autoScroll:d=!0,children:c,sensors:p=wI,collisionDetection:f=P2,measuring:b,modifiers:g,...m}=t;const h=u.useReducer($I,void 0,CI),[v,y]=h,[_,w]=k2(),[k,x]=u.useState(bn.Uninitialized),$=k===bn.Initialized,{draggable:{active:C,nodes:S,translate:D},droppable:{containers:E}}=v,I=C!=null?S.get(C):null,N=u.useRef({initial:null,translated:null}),T=u.useMemo(()=>{var Q;return C!=null?{id:C,data:(Q=I?.data)!=null?Q:kI,rect:N}:null},[C,I]),B=u.useRef(null),[M,O]=u.useState(null),[z,H]=u.useState(null),P=Vo(m,Object.values(m)),A=ai("DndDescribedBy",a),L=u.useMemo(()=>E.getEnabled(),[E]),F=II(b),{droppableRects:Y,measureDroppableContainers:V,measuringScheduled:X}=uI(L,{dragging:$,dependencies:[D.x,D.y],config:F.droppable}),Z=dI(S,C),ie=u.useMemo(()=>z?di(z):null,[z]),oe=pe(),G=pI(Z,F.draggable.measure);AI({activeNode:C!=null?S.get(C):null,config:oe.layoutShiftCompensation,initialRect:G,measure:F.draggable.measure});const ee=vf(Z,F.draggable.measure,G),fe=vf(Z?Z.parentElement:null),K=u.useRef({activatorEvent:null,active:null,activeNode:Z,collisionRect:null,collisions:null,droppableRects:Y,draggableNodes:S,draggingNode:null,draggingNodeRect:null,droppableContainers:E,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),te=E.getNodeFor((n=K.current.over)==null?void 0:n.id),ye=xI({measure:F.dragOverlay.measure}),Se=(o=ye.nodeRef.current)!=null?o:Z,De=$?(r=ye.rect)!=null?r:ee:null,Ie=!!(ye.nodeRef.current&&ye.rect),Ve=hI(Ie?null:ee),ze=wf(Se?xt(Se):null),Be=yI($?te??Z:null),Xe=_I(Be),Ne=Ef(g,{transform:{x:D.x-Ve.x,y:D.y-Ve.y,scaleX:1,scaleY:1},activatorEvent:z,active:T,activeNodeRect:ee,containerNodeRect:fe,draggingNodeRect:De,over:K.current.over,overlayNodeRect:ye.rect,scrollableAncestors:Be,scrollableAncestorRects:Xe,windowRect:ze}),Je=ie?go(ie,D):null,ve=bI(Be),qe=xf(ve),We=xf(ve,[ee]),ce=go(Ne,qe),q=De?H2(De,Ne):null,se=T&&q?f({active:T,collisionRect:q,droppableRects:Y,droppableContainers:L,pointerCoordinates:Je}):null,ae=M2(se,"id"),[be,Ce]=u.useState(null),$e=Ie?Ne:go(Ne,We),U=W2($e,(s=be?.rect)!=null?s:null,ee),ue=u.useRef(null),ge=u.useCallback((Q,de)=>{let{sensor:Ae,options:dt}=de;if(B.current==null)return;const pt=S.get(B.current);if(!pt)return;const ot=Q.nativeEvent,Le=new Ae({active:B.current,activeNode:pt,event:ot,options:dt,context:K,onAbort(Ze){if(!S.get(Ze))return;const{onDragAbort:Dt}=P.current,zt={id:Ze};Dt?.(zt),_({type:"onDragAbort",event:zt})},onPending(Ze,Tt,Dt,zt){if(!S.get(Ze))return;const{onDragPending:Sn}=P.current,en={id:Ze,constraint:Tt,initialCoordinates:Dt,offset:zt};Sn?.(en),_({type:"onDragPending",event:en})},onStart(Ze){const Tt=B.current;if(Tt==null)return;const Dt=S.get(Tt);if(!Dt)return;const{onDragStart:zt}=P.current,kn={activatorEvent:ot,active:{id:Tt,data:Dt.data,rect:N}};En.unstable_batchedUpdates(()=>{zt?.(kn),x(bn.Initializing),y({type:it.DragStart,initialCoordinates:Ze,active:Tt}),_({type:"onDragStart",event:kn}),O(ue.current),H(ot)})},onMove(Ze){y({type:it.DragMove,coordinates:Ze})},onEnd:je(it.DragEnd),onCancel:je(it.DragCancel)});ue.current=Le;function je(Ze){return async function(){const{active:Dt,collisions:zt,over:kn,scrollAdjustedTranslate:Sn}=K.current;let en=null;if(Dt&&Sn){const{cancelDrop:Kn}=P.current;en={activatorEvent:ot,active:Dt,collisions:zt,delta:Sn,over:kn},Ze===it.DragEnd&&typeof Kn=="function"&&await Promise.resolve(Kn(en))&&(Ze=it.DragCancel)}B.current=null,En.unstable_batchedUpdates(()=>{y({type:Ze}),x(bn.Uninitialized),Ce(null),O(null),H(null),ue.current=null;const Kn=Ze===it.DragEnd?"onDragEnd":"onDragCancel";if(en){const cn=P.current[Kn];cn?.(en),_({type:Kn,event:en})}})}}},[S]),ke=u.useCallback((Q,de)=>(Ae,dt)=>{const pt=Ae.nativeEvent,ot=S.get(dt);if(B.current!==null||!ot||pt.dndKit||pt.defaultPrevented)return;const Le={active:ot};Q(Ae,de.options,Le)===!0&&(pt.dndKit={capturedBy:de.sensor},B.current=dt,ge(Ae,de))},[S,ge]),he=cI(p,ke);mI(p),ln(()=>{ee&&k===bn.Initializing&&x(bn.Initialized)},[ee,k]),u.useEffect(()=>{const{onDragMove:Q}=P.current,{active:de,activatorEvent:Ae,collisions:dt,over:pt}=K.current;if(!de||!Ae)return;const ot={active:de,activatorEvent:Ae,collisions:dt,delta:{x:ce.x,y:ce.y},over:pt};En.unstable_batchedUpdates(()=>{Q?.(ot),_({type:"onDragMove",event:ot})})},[ce.x,ce.y]),u.useEffect(()=>{const{active:Q,activatorEvent:de,collisions:Ae,droppableContainers:dt,scrollAdjustedTranslate:pt}=K.current;if(!Q||B.current==null||!de||!pt)return;const{onDragOver:ot}=P.current,Le=dt.get(ae),je=Le&&Le.rect.current?{id:Le.id,rect:Le.rect.current,data:Le.data,disabled:Le.disabled}:null,Ze={active:Q,activatorEvent:de,collisions:Ae,delta:{x:pt.x,y:pt.y},over:je};En.unstable_batchedUpdates(()=>{Ce(je),ot?.(Ze),_({type:"onDragOver",event:Ze})})},[ae]),ln(()=>{K.current={activatorEvent:z,active:T,activeNode:Z,collisionRect:q,collisions:se,droppableRects:Y,draggableNodes:S,draggingNode:Se,draggingNodeRect:De,droppableContainers:E,over:be,scrollableAncestors:Be,scrollAdjustedTranslate:ce},N.current={initial:De,translated:q}},[T,Z,se,q,S,Se,De,Y,E,be,Be,ce]),sI({...oe,delta:D,draggingRect:q,pointerCoordinates:Je,scrollableAncestors:Be,scrollableAncestorRects:Xe});const j=u.useMemo(()=>({active:T,activeNode:Z,activeNodeRect:ee,activatorEvent:z,collisions:se,containerNodeRect:fe,dragOverlay:ye,draggableNodes:S,droppableContainers:E,droppableRects:Y,over:be,measureDroppableContainers:V,scrollableAncestors:Be,scrollableAncestorRects:Xe,measuringConfiguration:F,measuringScheduled:X,windowRect:ze}),[T,Z,ee,z,se,fe,ye,S,E,Y,be,V,Be,Xe,F,X,ze]),ne=u.useMemo(()=>({activatorEvent:z,activators:he,active:T,activeNodeRect:ee,ariaDescribedById:{draggable:A},dispatch:y,draggableNodes:S,over:be,measureDroppableContainers:V}),[z,he,T,ee,y,A,S,be,V]);return u.createElement(tf.Provider,{value:w},u.createElement(Qo.Provider,{value:ne},u.createElement($f.Provider,{value:j},u.createElement(gi.Provider,{value:U},c)),u.createElement(EI,{disabled:l?.restoreFocus===!1})),u.createElement($2,{...l,hiddenTextDescribedById:A}));function pe(){const Q=M?.autoScrollEnabled===!1,de=typeof d=="object"?d.enabled===!1:d===!1,Ae=$&&!Q&&!de;return typeof d=="object"?{...d,enabled:Ae}:{enabled:Ae}}}),DI=u.createContext(null),If="button",zI="Draggable";function NI(e){let{id:t,data:n,disabled:o=!1,attributes:r}=e;const s=ai(zI),{activators:a,activatorEvent:l,active:d,activeNodeRect:c,ariaDescribedById:p,draggableNodes:f,over:b}=u.useContext(Qo),{role:g=If,roleDescription:m="draggable",tabIndex:h=0}=r??{},v=d?.id===t,y=u.useContext(v?gi:DI),[_,w]=ii(),[k,x]=ii(),$=vI(a,t),C=Vo(n);ln(()=>(f.set(t,{id:t,key:s,node:_,activatorNode:k,data:C}),()=>{const D=f.get(t);D&&D.key===s&&f.delete(t)}),[f,t]);const S=u.useMemo(()=>({role:g,tabIndex:h,"aria-disabled":o,"aria-pressed":v&&g===If?!0:void 0,"aria-roledescription":m,"aria-describedby":p.draggable}),[o,g,h,v,m,p.draggable]);return{active:d,activatorEvent:l,activeNodeRect:c,attributes:S,isDragging:v,listeners:o?void 0:$,node:_,over:b,setNodeRef:w,setActivatorNodeRef:x,transform:y}}function MI(){return u.useContext($f)}const LI="Droppable",PI={timeout:25};function OI(e){let{data:t,disabled:n=!1,id:o,resizeObserverConfig:r}=e;const s=ai(LI),{active:a,dispatch:l,over:d,measureDroppableContainers:c}=u.useContext(Qo),p=u.useRef({disabled:n}),f=u.useRef(!1),b=u.useRef(null),g=u.useRef(null),{disabled:m,updateMeasurementsFor:h,timeout:v}={...PI,...r},y=Vo(h??o),_=u.useCallback(()=>{if(!f.current){f.current=!0;return}g.current!=null&&clearTimeout(g.current),g.current=setTimeout(()=>{c(Array.isArray(y.current)?y.current:[y.current]),g.current=null},v)},[v]),w=pi({callback:_,disabled:m||!a}),k=u.useCallback((S,D)=>{w&&(D&&(w.unobserve(D),f.current=!1),S&&w.observe(S))},[w]),[x,$]=ii(k),C=Vo(t);return u.useEffect(()=>{!w||!x.current||(w.disconnect(),f.current=!1,w.observe(x.current))},[x,w]),u.useEffect(()=>(l({type:it.RegisterDroppable,element:{id:o,key:s,disabled:n,node:x,rect:b,data:C}}),()=>l({type:it.UnregisterDroppable,key:s,id:o})),[o]),u.useEffect(()=>{n!==p.current.disabled&&(l({type:it.SetDroppableDisabled,id:o,key:s,disabled:n}),p.current.disabled=n)},[o,s,n,l]),{active:a,rect:b,isOver:d?.id===o,node:x,over:d,setNodeRef:$}}function BI(e){let{animation:t,children:n}=e;const[o,r]=u.useState(null),[s,a]=u.useState(null),l=si(n);return!n&&!o&&l&&r(l),ln(()=>{if(!s)return;const d=o?.key,c=o?.props.id;if(d==null||c==null){r(null);return}Promise.resolve(t(c,s)).then(()=>{r(null)})},[t,o,s]),u.createElement(u.Fragment,null,n,o?u.cloneElement(o,{ref:a}):null)}const WI={x:0,y:0,scaleX:1,scaleY:1};function jI(e){let{children:t}=e;return u.createElement(Qo.Provider,{value:Cf},u.createElement(gi.Provider,{value:WI},t))}const HI={position:"fixed",touchAction:"none"},FI=e=>ya(e)?"transform 250ms ease":void 0,KI=u.forwardRef((e,t)=>{let{as:n,activatorEvent:o,adjustScale:r,children:s,className:a,rect:l,style:d,transform:c,transition:p=FI}=e;if(!l)return null;const f=r?c:{...c,scaleX:1,scaleY:1},b={...HI,width:l.width,height:l.height,top:l.top,left:l.left,transform:qo.Transform.toString(f),transformOrigin:r&&o?T2(o,l):void 0,transition:typeof p=="function"?p(o):p,...d};return u.createElement(n,{className:a,style:b,ref:t},s)}),VI={duration:250,easing:"ease",keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:qo.Transform.toString(t)},{transform:qo.Transform.toString(n)}]},sideEffects:(e=>t=>{let{active:n,dragOverlay:o}=t;const r={},{styles:s,className:a}=e;if(s!=null&&s.active)for(const[l,d]of Object.entries(s.active))d!==void 0&&(r[l]=n.node.style.getPropertyValue(l),n.node.style.setProperty(l,d));if(s!=null&&s.dragOverlay)for(const[l,d]of Object.entries(s.dragOverlay))d!==void 0&&o.node.style.setProperty(l,d);return a!=null&&a.active&&n.node.classList.add(a.active),a!=null&&a.dragOverlay&&o.node.classList.add(a.dragOverlay),function(){for(const[d,c]of Object.entries(r))n.node.style.setProperty(d,c);a!=null&&a.active&&n.node.classList.remove(a.active)}})({styles:{active:{opacity:"0"}}})};function UI(e){let{config:t,draggableNodes:n,droppableContainers:o,measuringConfiguration:r}=e;return ri((s,a)=>{if(t===null)return;const l=n.get(s);if(!l)return;const d=l.node.current;if(!d)return;const c=Sf(a);if(!c)return;const{transform:p}=xt(a).getComputedStyle(a),f=of(p);if(!f)return;const b=typeof t=="function"?t:qI(t);return pf(d,r.draggable.measure),b({active:{id:s,data:l.data,node:d,rect:r.draggable.measure(d)},draggableNodes:n,dragOverlay:{node:a,rect:r.dragOverlay.measure(c)},droppableContainers:o,measuringConfiguration:r,transform:f})})}function qI(e){const{duration:t,easing:n,sideEffects:o,keyframes:r}={...VI,...e};return s=>{let{active:a,dragOverlay:l,transform:d,...c}=s;if(!t)return;const p={x:l.rect.left-a.rect.left,y:l.rect.top-a.rect.top},f={scaleX:d.scaleX!==1?a.rect.width*d.scaleX/l.rect.width:1,scaleY:d.scaleY!==1?a.rect.height*d.scaleY/l.rect.height:1},b={x:d.x-p.x,y:d.y-p.y,...f},g=r({...c,active:a,dragOverlay:l,transform:{initial:d,final:b}}),[m]=g,h=g[g.length-1];if(JSON.stringify(m)===JSON.stringify(h))return;const v=o?.({active:a,dragOverlay:l,...c}),y=l.node.animate(g,{duration:t,easing:n,fill:"forwards"});return new Promise(_=>{y.onfinish=()=>{v?.(),_()}})}}let Af=0;function GI(e){return u.useMemo(()=>{if(e!=null)return Af++,Af},[e])}const YI=u.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:o,style:r,transition:s,modifiers:a,wrapperElement:l="div",className:d,zIndex:c=999}=e;const{activatorEvent:p,active:f,activeNodeRect:b,containerNodeRect:g,draggableNodes:m,droppableContainers:h,dragOverlay:v,over:y,measuringConfiguration:_,scrollableAncestors:w,scrollableAncestorRects:k,windowRect:x}=MI(),$=u.useContext(gi),C=GI(f?.id),S=Ef(a,{activatorEvent:p,active:f,activeNodeRect:b,containerNodeRect:g,draggingNodeRect:v.rect,over:y,overlayNodeRect:v.rect,scrollableAncestors:w,scrollableAncestorRects:k,transform:$,windowRect:x}),D=Ea(b),E=UI({config:o,draggableNodes:m,droppableContainers:h,measuringConfiguration:_}),I=D?v.setRef:void 0;return u.createElement(jI,null,u.createElement(BI,{animation:E},f&&C?u.createElement(KI,{key:C,id:f.id,ref:I,as:l,activatorEvent:p,adjustScale:t,className:d,transition:s,rect:D,style:{zIndex:c,...r},transform:S},n):null))});function Ro(e,t){return!t||!Array.isArray(t.draggable)?!1:t.draggable.includes(e)}function XI({draggedComponentName:e,targetContainerName:t,nesting:n}){if(!n||!Ro(e,n))return!1;const o=n.containers;if(!o||typeof o!="object")return!1;const r=o[t];return!r||!Array.isArray(r.accepts)?!1:r.accepts.includes(e)}function Tf(e,t){if(!t?.containers)return!1;const n=t.containers[e];return!!(n&&Array.isArray(n.accepts)&&n.accepts.length>0)}function JI(e,t,n,o,r){if(!n||n.length===0)return{parentPath:[],index:r};if(e&&Tf(e,o))return{parentPath:n,index:t};const s=n.slice(0,-1),a=n[n.length-1]??0;return{parentPath:s,index:a+1}}function Df(e,t){return e===t||e.startsWith(`${t}.`)}function zf(e,t){if(e==="")return/^\d+$/.test(t)?Number(t):null;const n=`${e}.children.`;if(!t.startsWith(n))return null;const o=t.slice(n.length);return/^\d+$/.test(o)?Number(o):null}function ZI(e,t){const n=[];return e.querySelectorAll("[data-editor-path]").forEach(o=>{if(o.hasAttribute("data-dnd-placeholder")||o.closest("[data-dnd-placeholder]"))return;const r=o.dataset.editorPath;typeof r=="string"&&n.push({path:t(r),domPath:r,rect:o.getBoundingClientRect()})}),n}const QI=16;function RI(e){const{frameEl:t,draggedPath:n,acceptsContainer:o,allowsNestSlot:r,includeContainer:s}=e,a=e.normalizeContainerPath??(g=>g),l=t.getBoundingClientRect(),d=ZI(t,a),c=new Map;for(const g of d)c.has(g.path)||c.set(g.path,g.domPath);const p=a(n),f=new Set([""]);for(const g of d){const m=tA(g.path);m!==null&&f.add(m)}for(const g of d)f.add(g.path);const b=[];for(const g of f){const m=g==="",h=m?null:c.get(g)??g,v=m?t:t.querySelector(`[data-editor-path="${Lf(h)}"]`);if(!v&&!m||!m&&Df(g,p))continue;const y=g;if(!m&&s&&!s(y))continue;const _=$=>{const C=c.get($);if(!C||typeof window>"u")return!1;const S=t.querySelector(`[data-editor-path="${Lf(C)}"]`);return S?(window.getComputedStyle(S).display??"").toLowerCase()==="contents":!1},w=d.filter($=>zf(g,$.path)!==null).filter($=>!Df($.path,p)).filter($=>!_($.path)).map($=>({origIndex:zf(g,$.path),rect:eA($.rect,$.path,d)})).filter($=>$.rect.width>0||$.rect.height>0).sort(($,C)=>$.origIndex-C.origIndex),k=Vp(m?t:v).kind,x=k==="flex_row_single"||k==="flex_row_wrap"||k==="grid_single_row"||k==="grid_2d";if(w.length>0){if(o(y)){w.forEach(C=>{b.push(Nf(y,C.origIndex,C.rect,l,x,"before"))});const $=w[w.length-1];b.push(Nf(y,$.origIndex+1,$.rect,l,x,"after"))}}else if(!m&&r(y)&&v){const $=v.getBoundingClientRect();$.width>0&&$.height>0&&b.push({id:`slot:${y}:0`,kind:"nest",containerPath:y,index:0,box:Mf($,l),orientation:"area"})}else m&&b.push({id:"slot::0",kind:"gap",containerPath:"",index:0,box:Mf(l,l),orientation:"area"})}return b.filter(g=>uo(g.box,t))}function Nf(e,t,n,o,r,s){const a=QI;let l;if(r)l={left:(s==="before"?n.left:n.right)-a/2,top:n.top,width:a,height:n.height};else{const d=s==="before"?n.top:n.bottom;l={left:n.left,top:d-a/2,width:n.width,height:a}}return{id:`slot:${e}:${t}`,kind:"gap",containerPath:e,index:t,box:{left:l.left-o.left,top:l.top-o.top,width:l.width,height:l.height,scale:1},orientation:r?"vertical":"horizontal"}}function eA(e,t,n){if(e.width>0||e.height>0)return e;const o=`${t}.children.`;let r=1/0,s=1/0,a=-1/0,l=-1/0;for(const d of n)d.path.startsWith(o)&&(d.rect.width===0&&d.rect.height===0||(r=Math.min(r,d.rect.left),s=Math.min(s,d.rect.top),a=Math.max(a,d.rect.right),l=Math.max(l,d.rect.bottom)));return r===1/0?e:{left:r,top:s,width:a-r,height:l-s,right:a,bottom:l,x:r,y:s,toJSON:()=>({})}}function Mf(e,t){return{left:e.left-t.left,top:e.top-t.top,width:e.width,height:e.height,scale:1}}function tA(e){if(e==="")return null;const t=e.lastIndexOf(".children.");return t<0?"":e.slice(0,t)}function nA(e){if(!e.startsWith("slot:"))return null;const t=e.slice(5),n=t.lastIndexOf(":");if(n<0)return null;const o=t.slice(0,n),r=Number(t.slice(n+1));return Number.isFinite(r)?{containerPath:o,index:r}:null}function Lf(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[^a-zA-Z0-9_\-.]/g,t=>`\\${t}`)}function Ia(e){return typeof e=="string"&&e.length>0?e:null}function Aa(e,t){return t&&e.startsWith(`${t}.`)?t:e}function Pf(e){if(typeof e!="string")return null;const t=nA(e);return t?{containerPath:t.containerPath,index:t.index}:null}function Ta(e,t){return t?e.startsWith(`${t}.iteration.`):!1}function Da(e,t,n){return t?n==="iteration_item"?Ta(e,t):e===t||e.startsWith(`${t}.`):!1}function oA(e){const{frameEl:t,nesting:n,editMode:o,currentExtensionId:r,editableRootPath:s,components:a,patchLayout:l,pushHistory:d,onMovePath:c,selectedPath:p,showBranchBoundaryHint:f}=e,b=(o==="iteration_item"||o==="modal")&&s&&s.length>0?at(s):null,[g,m]=u.useState(null),[h,v]=u.useState(null),[y,_]=u.useState(null),w=u.useRef({components:a,nesting:n,editMode:o,currentExtensionId:r,selectedPath:p,editableRootSourcePath:b});w.current={components:a,nesting:n,editMode:o,currentExtensionId:r,selectedPath:p,editableRootSourcePath:b};const k=u.useRef(null),x=u.useCallback(M=>({children:M}),[]),$=u.useCallback((M,O)=>{const z=Pe(x(M),O);return z?typeof z.name=="string"?z.name:typeof z.type=="string"?z.type:null:null},[x]),C=u.useCallback(M=>O=>{const z=w.current;if(O==="")return Ro(M,z.nesting);const H=Re(O),P=Pe(x(z.components),H);if(!P)return!1;const A=typeof P.name=="string"?P.name:typeof P.type=="string"?P.type:"";if(!A)return!1;const L=!!z.editableRootSourcePath&&(O===z.editableRootSourcePath||O.startsWith(`${z.editableRootSourcePath}.`));if(z.editableRootSourcePath&&!L)return!1;if(!L){const F=Dn(x(z.components),H);if(Jt(P,z.editMode,z.currentExtensionId,F)!=="none")return!1}return Tf(A,z.nesting)?XI({draggedComponentName:M,targetContainerName:A,nesting:z.nesting}):!1},[x]),S=u.useCallback(M=>{if(M==="")return!0;const O=w.current,z=Re(M),H=k.current;if(H&&H.length>0){const L=H.slice(0,-1);if(hi(z,L))return!0}const P=Pe(x(O.components),z);return P?(typeof P.name=="string"?P.name:typeof P.type=="string"?P.type:"").length>0:!1},[x]),D=u.useCallback(M=>{const O=C(M),z=w.current,H=k.current,P=H?H.slice(0,-1):null,A=new Set;if(P)for(let V=P.length;V>=0;V--)A.add(yi(P.slice(0,V)));const L=yi(H??[]),F=V=>!!H&&(V===L||V.startsWith(`${L}.`)),Y=(V,X)=>{for(let Z=0;ZV===""?!0:F(V)?!1:A.has(V),allowsNestSlot:V=>{if(!O(V))return!1;if(P){const X=Re(V);if(hi(X,P))return!1}return S(V)}}},[C,S,x]),E=u.useCallback(M=>{const O=Ia(M.active.id),z=w.current;if(!O)return;const H=Aa(O,z.selectedPath),P=Re(H),A=Pe(x(z.components),P),L=A&&typeof A.name=="string"?A.name:A&&typeof A.type=="string"?A.type:null;m(H),v(L),_(null),k.current=A?P:null;let F="allowed";if(!L||!Ro(L,z.nesting))F="denied_no_draggable";else if(A){const Y=Dn(x(z.components),P),V=Jt(A,z.editMode,z.currentExtensionId,Y);if(z.editableRootSourcePath&&!Da(H,z.editableRootSourcePath,z.editMode))F="denied_data_bound";else if(os(Y)&&!Ta(H,z.editableRootSourcePath))F="denied_data_bound";else{const X=Tp(V);X&&(F=X)}}F!=="allowed"&&m(null),pn({source:"drag",draggedComponentName:L,targetContainerName:null,targetContainerPath:null,decision:F,result:F==="allowed"?"completed":"denied",timestamp:Date.now()})},[x]),I=u.useCallback(M=>{if(!t)return;const O=Ia(M.active.id);if(!O)return;const z=h;if(!z){_(null);return}const H=w.current,P=Aa(O,H.selectedPath),A=Re(P),L=Pe(x(H.components),A);if(!L||!Ro(z,H.nesting)){_(null);return}const F=Dn(x(H.components),A);if(H.editableRootSourcePath&&!Da(P,H.editableRootSourcePath,H.editMode)){_(null);return}const Y=Jt(L,H.editMode,H.currentExtensionId,F),V=Ta(P,H.editableRootSourcePath);if(os(F)&&!V||!Zt(Y)&&!V){_(null);return}_(Pf(M.over?.id))},[t,h,x]),N=u.useCallback(()=>{m(null),v(null),_(null),k.current=null},[]),T=u.useCallback(M=>{const O=Ia(M.active.id),z=h,H=w.current,P=O?Aa(O,H.selectedPath):null;if(!t||!P||!z){N();return}const A=Pf(M.over?.id),L=Re(P);if(!A){pn({source:"drag",draggedComponentName:z,targetContainerName:null,targetContainerPath:null,decision:"denied_no_accepts",result:"cancelled",timestamp:Date.now()}),N();return}const F=A.containerPath===""?[]:Re(A.containerPath),Y=A.containerPath===""?null:$(H.components,F);if(!rA(L.slice(0,-1),F)){pn({source:"drag",draggedComponentName:z,targetContainerName:Y,targetContainerPath:A.containerPath||null,decision:"denied_responsive_branch_boundary",result:"denied",timestamp:Date.now()}),f?.(),N();return}if(H.editableRootSourcePath&&!Da(A.containerPath,H.editableRootSourcePath,H.editMode)){pn({source:"drag",draggedComponentName:z,targetContainerName:Y,targetContainerPath:A.containerPath||null,decision:"denied_data_bound",result:"denied",timestamp:Date.now()}),N();return}const V=Pe(x(H.components),L),X=V?Tp(Jt(V,H.editMode,H.currentExtensionId,Dn(x(H.components),L))):null;if(X){pn({source:"drag",draggedComponentName:z,targetContainerName:Y,targetContainerPath:A.containerPath||null,decision:X,result:"denied",timestamp:Date.now()}),N();return}const Z=L.slice(0,-1),ie=L[L.length-1]??-1;if(hi(Z,F)&&(A.index===ie||A.index===ie+1)){pn({source:"drag",draggedComponentName:z,targetContainerName:Y,targetContainerPath:A.containerPath||null,decision:"allowed",insertionIndex:A.index,result:"cancelled",timestamp:Date.now()}),N();return}const ee=hi(Z,F),fe=A.index;let K=[];l(De=>{const ze=tm({children:De},L,F,fe).children??[];return K=ze,ze}),d(K,`move ${z}`);const te=fd(F,L),ye=ee&&ie{N()},[N]);return{activeDragPath:g,activeDragName:h,activeDropZone:y,onDragStart:E,onDragMove:I,onDragEnd:T,onDragCancel:B,buildSlotPredicates:D}}function hi(e,t){if(e.length!==t.length)return!1;for(let n=0;n0?at(s):null,{t:m}=et(),[h,v]=u.useState(!1),y=u.useRef(null),_=u.useCallback(()=>{v(!0),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>v(!1),2600)},[]);u.useEffect(()=>()=>{y.current&&clearTimeout(y.current)},[]);const w=oA({frameEl:t,nesting:n,editMode:o,currentExtensionId:r,editableRootPath:s,components:a,patchLayout:l,pushHistory:d,onMovePath:p,selectedPath:b,showBranchBoundaryHint:_}),k=I2(E2(ka,{activationConstraint:{distance:8}})),[x,$]=u.useState([]),C=u.useCallback(()=>{if(!t){$([]);return}if(w.activeDragPath!==null)return;const P={children:a},A=t.querySelectorAll("[data-editor-path]"),L=[],F=new Map;A.forEach(Y=>{const V=Y.dataset.editorPath;if(typeof V!="string"||o!=="iteration_item"&&g&&!aA(V,g,o))return;const X=iA(V);if(X!==null&&!er(V,g)){if(/\.iteration\.\d+$/.test(V)){const K=co(Y,t);if(K&&uo(K,t)){const te=F.get(X)??[];te.push(K),F.set(X,te)}}return}if(er(V,g)&&/\.iteration\.\d+$/.test(V))return;const Z=Re(V),ie=Pe(P,Z);if(!ie||ie.iteration&&ie.iteration.source!==void 0)return;const oe=typeof ie.name=="string"?ie.name:typeof ie.type=="string"?ie.type:null;if(!oe||!Ro(oe,n))return;const G=Dn(P,Z);if(os(G)&&!er(V,g))return;const ee=Jt(ie,o,r,G);if(!Zt(ee)&&!er(V,g))return;const fe=co(Y,t);fe&&uo(fe,t)&&L.push({path:V,name:oe,box:fe})});for(const[Y,V]of F){const X=Re(Y),Z=Pe(P,X);if(!Z)continue;const ie=typeof Z.name=="string"?Z.name:typeof Z.type=="string"?Z.type:null;if(!ie)continue;const oe=Dn(P,X),G=Jt(Z,o,r,oe);if(!Zt(G))continue;const ee=lA(V);ee&&uo(ee,t)&&L.push({path:Y,name:ie,box:ee,isIterationGroup:!0})}$(L)},[t,a,n,o,r,g,w.activeDragPath]);u.useEffect(()=>{C()},[C]),u.useEffect(()=>{if(t)return Wp(C,t)},[t,C]);const S=w.activeDragPath!==null,D=w.activeDragName,E=w.activeDragPath,[I,N]=u.useState(null),T=u.useRef(null);u.useEffect(()=>{if(!E||!t){E||(T.current=null,N(null));return}if(T.current===E)return;T.current=E;const P=t.querySelector(`[data-editor-path="${Of(E)}"]`);if(P){const oe=P.getBoundingClientRect();N({node:P.cloneNode(!0),width:oe.width,height:oe.height});return}const A=Array.from(t.querySelectorAll(`[data-editor-path^="${Of(E)}.iteration."]`)).filter(oe=>/\.iteration\.\d+$/.test(oe.dataset.editorPath??""));if(A.length===0){N(null);return}let L=1/0,F=1/0,Y=-1/0,V=-1/0;for(const oe of A){const G=oe.getBoundingClientRect();L=Math.min(L,G.left),F=Math.min(F,G.top),Y=Math.max(Y,G.right),V=Math.max(V,G.bottom)}const X=Y-L,Z=V-F,ie=document.createElement("div");ie.style.position="relative",ie.style.width=`${X}px`,ie.style.height=`${Z}px`;for(const oe of A){const G=oe.getBoundingClientRect(),ee=oe.cloneNode(!0);ee.style.position="absolute",ee.style.left=`${G.left-L}px`,ee.style.top=`${G.top-F}px`,ee.style.width=`${G.width}px`,ee.style.height=`${G.height}px`,ee.style.margin="0",ie.appendChild(ee)}N({node:ie,width:X,height:Z})},[E,t]);const[B,M]=u.useState([]),O=u.useRef(null),z=u.useRef(w.buildSlotPredicates);if(z.current=w.buildSlotPredicates,u.useEffect(()=>{if(!E||!D||!t){O.current=null,M(F=>F.length===0?F:[]);return}if(O.current===E)return;O.current=E;const{acceptsContainer:P,allowsNestSlot:A,includeContainer:L}=z.current(D);M(RI({frameEl:t,draggedPath:E,acceptsContainer:P,allowsNestSlot:A,includeContainer:L,normalizeContainerPath:F=>sA(F)}))},[E,D,t]),!t)return null;const H=w.activeDropZone?`slot:${w.activeDropZone.containerPath}:${w.activeDropZone.index}`:null;return i.jsxs(TI,{sensors:k,collisionDetection:B2,onDragStart:w.onDragStart,onDragMove:w.onDragMove,onDragEnd:w.onDragEnd,onDragCancel:w.onDragCancel,children:[x.map(P=>i.jsx(pA,{path:P.path,name:P.name,box:P.box,dimmed:S&&w.activeDragPath!==P.path,isIterationGroup:P.isIterationGroup,onSelect:c,onRequestInlineEdit:f},P.path)),S&&B.map(P=>i.jsx(uA,{slot:P,active:P.id===H},P.id)),En.createPortal(i.jsx(YI,{dropAnimation:null,zIndex:Xp,children:D?I?i.jsx(cA,{name:D,node:I.node,width:I.width,height:I.height}):i.jsx("div",{className:"g7le-dnd-drag-ghost","data-testid":"g7le-dnd-drag-ghost",style:{padding:"4px 10px",background:"rgba(79,70,229,0.95)",color:"#fff",fontSize:12,fontWeight:600,borderRadius:4,pointerEvents:"none",whiteSpace:"nowrap"},children:`<${D}>`}):null}),document.body),h&&En.createPortal(i.jsxs("div",{"data-testid":"g7le-branch-boundary-hint",role:"status",style:{position:"absolute",left:"50%",top:12,transform:"translateX(-50%)",background:"rgba(245,158,11,0.97)",color:"#fff",fontSize:13,fontWeight:600,padding:"8px 16px",borderRadius:8,boxShadow:"0 4px 14px rgba(0,0,0,0.2)",pointerEvents:"none",whiteSpace:"nowrap",zIndex:Xp},children:["⚠️ ",m("layout_editor.overlay.branch_boundary_denied")]}),t)]})}function cA(e){const{node:t,width:n,height:o}=e,r=u.useRef(null);return u.useEffect(()=>{const s=r.current;if(s)return s.replaceChildren(),s.appendChild(t.cloneNode(!0)),()=>{s.replaceChildren()}},[t]),i.jsx("div",{ref:r,className:"g7le-dnd-drag-ghost","data-testid":"g7le-dnd-drag-ghost",style:{width:n,height:o,opacity:.7,pointerEvents:"none",boxShadow:"0 6px 18px rgba(0,0,0,0.25)",borderRadius:4,overflow:"hidden",cursor:"grabbing"}})}function uA(e){const{slot:t,active:n}=e,{setNodeRef:o}=OI({id:t.id}),r=t.orientation!=="area";return i.jsx("div",{ref:o,"data-testid":`g7le-dnd-slot-${t.id}`,"data-dnd-slot-id":t.id,style:{position:"absolute",left:t.box.left,top:t.box.top,width:t.box.width,height:t.box.height,pointerEvents:"auto",zIndex:o2,boxSizing:"border-box",...r?{background:n?"rgba(79,70,229,0.15)":"transparent",...n?t.orientation==="vertical"?{borderLeft:"2px solid #4f46e5"}:{borderTop:"2px solid #4f46e5"}:{}}:{border:n?"2px dashed #4f46e5":"1px dashed transparent",background:n?"rgba(79,70,229,0.08)":"transparent",borderRadius:4}}})}function Of(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[^a-zA-Z0-9_\-.]/g,t=>`\\${t}`)}function pA(e){const{path:t,box:n,dimmed:o,isIterationGroup:r,onSelect:s,onRequestInlineEdit:a}=e,{attributes:l,listeners:d,setNodeRef:c,isDragging:p}=NI({id:t}),f=(t.match(/\.children\./g)||[]).length,b=r2(f);return i.jsx("div",{ref:c,"data-testid":`g7le-dnd-handle-${t}`,"data-dnd-handle-path":t,"data-dnd-iteration-group":r?"true":void 0,...d,...l,onClick:g=>{if(g.stopPropagation(),!r&&typeof document<"u"&&typeof document.elementsFromPoint=="function"){const m=document.elementsFromPoint(g.clientX,g.clientY);for(const h of m){const y=h.closest?.("[data-editor-path]")?.dataset?.editorPath;if(typeof y=="string"&&(y===t||y.startsWith(`${t}.`))){s(y);return}}}s(t)},onDoubleClick:g=>{g.stopPropagation(),g.preventDefault(),a?.(t)},style:{position:"absolute",left:n.left,top:n.top,width:n.width,height:n.height,cursor:"grab",pointerEvents:"auto",background:p?"rgba(79,70,229,0.06)":"transparent",...r?{border:"1px dashed rgba(79,70,229,0.5)",borderRadius:4}:{},opacity:o?.6:1,zIndex:b,touchAction:"none"}})}function fA(e,t,n,o){if(t==="route")return[];if(t==="modal"||t==="iteration_item")return o&&o.length>0?[o]:[];const r=[],s=(a,l)=>{a.forEach((d,c)=>{const p=[...l,c];if(!ud(d,t,n)){r.push(p);return}const b=Array.isArray(d.children)?d.children:[];b.length>0&&s(b,p)})};return s(e,[]),r}function gA(e){return at(e)}function bi(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["\\]/g,"\\$&")}function hA({frameEl:e,components:t,editMode:n,currentExtensionId:o,editableRootPath:r}){const[s,a]=u.useState(null),[l]=u.useState(()=>`g7le-dim-mask-${Math.floor(Math.random()*1e9)}`);if(u.useEffect(()=>{if(!e){a(null);return}let g=0;const m=()=>{const _=fA(t,n,o,r);if(_.length===0){a(null);return}const w=e.getBoundingClientRect(),k={left:0,top:0,width:w.width,height:w.height},x=[];for(const $ of _){const C=gA($),S=e.querySelector(`[data-editor-path="${bi(C)}"]`);let D=null;if(S){const E=S.getBoundingClientRect();E.width>0&&E.height>0&&(D={left:E.left,top:E.top,width:E.width,height:E.height})}if(!D){const E=Array.from(e.querySelectorAll(`[data-editor-path^="${bi(C)}.iteration."], [data-editor-path^="${bi(C)}.sortable."], [data-editor-path^="${bi(C)}.children."]`));let I=1/0,N=1/0,T=-1/0,B=-1/0;for(const M of E){const O=M.getBoundingClientRect();O.width<=0||O.height<=0||(I=Math.min(I,O.left),N=Math.min(N,O.top),T=Math.max(T,O.right),B=Math.max(B,O.bottom))}if(T>I&&B>N&&(D={left:I,top:N,width:T-I,height:B-N}),D&&E.length>0){const M=E[0].closest('[role="dialog"]');if(M&&e.contains(M)){const O=M.getBoundingClientRect();O.width>0&&O.height>0&&(D={left:O.left,top:O.top,width:O.width,height:O.height})}}}D&&x.push({left:D.left-w.left,top:D.top-w.top,width:D.width,height:D.height})}if(x.length===0){a(null);return}a({frame:k,holes:x})},h=()=>{g&&cancelAnimationFrame(g),g=requestAnimationFrame(m)};h();const v=typeof ResizeObserver<"u"?new ResizeObserver(h):null;v?.observe(e);const y=typeof MutationObserver<"u"?new MutationObserver(h):null;return y?.observe(e,{childList:!0,subtree:!0,attributes:!0}),window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{g&&cancelAnimationFrame(g),v?.disconnect(),y?.disconnect(),window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[e,t,n,o,r?.join(".")??""]),!s||s.holes.length===0)return null;const{frame:d,holes:c}=s,p=n==="modal"||n==="iteration_item";let f=[];if(p){let g=1/0,m=1/0,h=-1/0,v=-1/0;for(const $ of c)g=Math.min(g,$.left),m=Math.min(m,$.top),h=Math.max(h,$.left+$.width),v=Math.max(v,$.top+$.height);const y=($,C,S)=>Math.max(C,Math.min(S,$)),_=y(g,0,d.width),w=y(m,0,d.height),k=y(h,0,d.width),x=y(v,0,d.height);f=[{left:0,top:0,width:d.width,height:w},{left:0,top:x,width:d.width,height:d.height-x},{left:0,top:w,width:_,height:x-w},{left:k,top:w,width:d.width-k,height:x-w}].filter($=>$.width>0&&$.height>0)}const b=g=>{g.preventDefault(),g.stopPropagation()};return i.jsxs(i.Fragment,{children:[f.map((g,m)=>i.jsx("div",{className:"g7le-source-lock-block","data-testid":"g7le-source-lock-block",onClickCapture:b,onPointerDownCapture:b,onMouseDownCapture:b,onDragStartCapture:b,style:{position:"absolute",left:g.left,top:g.top,width:g.width,height:g.height,zIndex:Yp,pointerEvents:"auto",cursor:"not-allowed",background:"transparent"}},m)),i.jsxs("svg",{className:"g7le-source-lock-dim","data-testid":"g7le-source-lock-dim",width:d.width,height:d.height,style:{position:"absolute",left:0,top:0,width:d.width,height:d.height,zIndex:Yp,pointerEvents:"none"},children:[i.jsx("defs",{children:i.jsxs("mask",{id:l,children:[i.jsx("rect",{x:0,y:0,width:d.width,height:d.height,fill:"white"}),c.map((g,m)=>i.jsx("rect",{"data-testid":"g7le-source-lock-dim-hole",x:g.left,y:g.top,width:g.width,height:g.height,rx:4,fill:"black"},m))]})}),i.jsx("rect",{"data-testid":"g7le-source-lock-dim-box",x:0,y:0,width:d.width,height:d.height,fill:"rgba(15, 23, 42, 0.45)",mask:`url(#${l})`})]})]})}function Bf(e){const t={type:e.type??"basic",name:e.name},n={};if(e.props)for(const[o,r]of Object.entries(e.props))o!=="children"&&r?.default!==void 0&&(n[o]=r.default);return Object.keys(n).length>0&&(t.props=n),t}function yA(e){if(!e?.components)return[];const t=[];for(const[n,o]of Object.entries(e.components))if(Array.isArray(o))for(const r of o)t.push({...r,type:r.type??n});return t}function bA(e,t,n,o,r){const s=yA(e);let a=null;if(n&&t?.containers){const l=t.containers[n];l&&Array.isArray(l.accepts)?a=new Set(l.accepts):a=new Set}else!n&&t?.draggable&&(a=new Set(t.draggable));return s.filter(l=>{if(a&&!a.has(l.name))return!1;if(o){const d=o.toLowerCase(),c=r(l).toLowerCase(),p=l.name.toLowerCase();if(!c.includes(d)&&!p.includes(d)&&!`<${p}>`.includes(d)&&!(l.description??"").toLowerCase().includes(d))return!1}return!0})}function mA(e,t){const n={key:"all",label:"layout_editor.palette.category.all",entries:e,isI18nKey:!0};if(t?.groups&&t.groups.length>0){const a=new Map(e.map(p=>[p.name,p])),l=new Set,d=[];for(const p of t.groups){const f=[];for(const b of p.components??[]){const g=a.get(b);g&&(f.push(g),l.add(b))}f.length!==0&&d.push({key:p.kind??p.label,label:p.label,entries:f,isI18nKey:p.label.startsWith("$t:")||/^[a-z_.]+$/i.test(p.label)})}const c=e.filter(p=>!l.has(p.name));return c.length>0&&d.push({key:"other",label:"layout_editor.palette.category.other",entries:c,isI18nKey:!0}),[n,...d]}const o=new Map;for(const a of e){const l=(a.type??"basic").toLowerCase(),d=o.get(l)??[];d.push(a),o.set(l,d)}const r=["basic","composite","layout"],s=[];for(const a of r){const l=o.get(a);l&&l.length>0&&(s.push({key:a,label:`layout_editor.palette.category.fallback.${a}`,entries:l,isI18nKey:!0}),o.delete(a))}for(const[a,l]of o.entries())s.push({key:a,label:a,entries:l,isI18nKey:!1});return[n,...s]}function Wf(e){const{manifest:t,nesting:n,componentPalette:o,targetParentPath:r,targetContainerName:s,onInsert:a,insertionIndex:l,onClose:d,editorTemplateId:c,editorLocale:p}=e,{t:f,translationEngine:b}=et(),g=u.useMemo(()=>{if(!c||!b)return f;const I=p??null;return N=>{const T={templateId:c,locale:I??"ko"},B=b.translate(N,T);return B!==N?B:f(N)}},[c,p,b,f]),[m,h]=u.useState(""),[v,y]=u.useState("all"),_=o?.entries??null,w=u.useMemo(()=>I=>{const N=_?.[I.name];return N?.label?mi(N.label,g):I.description??I.name},[_,g]),k=u.useMemo(()=>bA(t,n,s,m,w),[t,n,s,m,w]),x=u.useMemo(()=>mA(k,o??null),[k,o]),$=x.find(I=>I.key===v)??x[0]??null,C=!n||!n.draggable&&!n.containers,S=k.length===0,D=$?.entries??[],E=I=>{const N=_?.[I.name],T=!!N?.defaultNode&&typeof N.defaultNode=="object";if(N?.requiresDefaultNode&&!T)return;const B=T?JSON.parse(JSON.stringify(N.defaultNode)):Bf(I),M=r??[];a(B,M,l),pn({source:"palette",draggedComponentName:I.name,targetContainerName:s,targetContainerPath:M.length===0?null:M.join("/"),decision:"allowed",insertionIndex:l,result:"completed",timestamp:Date.now()}),d()};return i.jsxs("div",{className:"g7le-palette","data-testid":"g7le-palette",style:wA,children:[i.jsxs("div",{style:kA,children:[i.jsx("strong",{style:{fontSize:16},children:f("layout_editor.palette.title")}),i.jsx("button",{type:"button",onClick:d,"aria-label":"close","data-testid":"g7le-palette-close",style:SA,children:"×"})]}),i.jsxs("div",{style:CA,children:[i.jsx("aside",{style:$A,"data-testid":"g7le-palette-sidebar",children:i.jsx("nav",{children:i.jsx("ul",{style:EA,children:x.map(I=>{const N=$?.key===I.key,T=I.isI18nKey?mi(I.label,g):I.label;return i.jsx("li",{children:i.jsxs("button",{type:"button","data-testid":`g7le-palette-category-${I.key}`,"data-active":N?"true":"false",onClick:()=>y(I.key),style:{...IA,background:N?"#eff6ff":"transparent",color:N?"#1d4ed8":"#334155",fontWeight:N?600:500},children:[i.jsx("span",{children:T}),i.jsx("span",{style:zA,children:I.entries.length})]})},I.key)})})})}),i.jsxs("main",{style:AA,children:[i.jsx("input",{type:"text",placeholder:f("layout_editor.palette.search_placeholder"),value:m,onChange:I=>h(I.target.value),"data-testid":"g7le-palette-search",style:TA}),i.jsx("div",{style:DA,children:C?i.jsx("div",{style:jf,"data-testid":"g7le-palette-spec-missing",children:f("layout_editor.palette.spec_missing")}):S||D.length===0?i.jsx("div",{style:jf,"data-testid":"g7le-palette-empty",children:f("layout_editor.palette.empty")}):i.jsx("div",{"data-testid":`g7le-palette-group-${$?.key??"all"}`,style:{marginBottom:16},children:i.jsx("div",{style:NA,children:D.map(I=>i.jsx(vA,{entry:I,entrySpec:_?.[I.name]??null,onClick:E,t:f,entryT:g},I.name))})})})]})]})]})}function vA(e){const{entry:t,entrySpec:n,onClick:o,t:r,entryT:s}=e,a=n?.label?mi(n.label,s):t.description??t.name,l=(t.type??"").toLowerCase(),d=l==="basic"||l==="composite"||l==="layout",c=!!n?.defaultNode&&typeof n.defaultNode=="object",p=!!n?.requiresDefaultNode&&!c,f=!c,b=p?r("layout_editor.palette.requires_default_node_missing"):n?.label?mi(n.label,s):t.name;return i.jsxs("button",{type:"button",onClick:()=>o(t),disabled:p,"aria-disabled":p||void 0,"data-testid":`g7le-palette-item-${t.name}`,"data-component-type":l||void 0,"data-blocked":p?"true":void 0,"data-default-node-missing":f?"true":void 0,title:b,style:p?LA:MA,children:[i.jsx("div",{style:OA,"aria-hidden":"true",children:xA(t)}),i.jsx("div",{style:BA,children:a}),i.jsx("div",{"data-testid":`g7le-palette-item-${t.name}-tag`,style:WA,children:`<${t.name}>`}),d&&i.jsx("div",{"data-testid":`g7le-palette-item-${t.name}-badge`,style:_A(l),children:l}),f&&i.jsx("div",{"data-testid":`g7le-palette-item-${t.name}-default-missing-badge`,style:PA,children:r("layout_editor.palette.default_node_missing_badge")})]})}function mi(e,t){return e.startsWith("$t:")?t(e.slice(3)):t(e)}function _A(e){const n={basic:{bg:"#dbeafe",fg:"#1e40af"},composite:{bg:"#dcfce7",fg:"#14532d"},layout:{bg:"#fef3c7",fg:"#854d0e"}}[e]??{bg:"#e2e8f0",fg:"#334155"};return{fontSize:9,fontWeight:600,color:n.fg,background:n.bg,padding:"1px 6px",borderRadius:999,textTransform:"uppercase",letterSpacing:.4,lineHeight:1.6}}function xA(e){const t=e.name;return{Button:"🔘",A:"🔗",Img:"🖼",Icon:"✨",Hr:"➖",P:"📄",Span:"T",H1:"H₁",H2:"H₂",H3:"H₃",H4:"H₄",Ul:"☰",Li:"•",Nav:"🧭",Div:"▢",Container:"▢",Flex:"⇆",Grid:"▦",SectionLayout:"▤",ThreeColumnLayout:"⫼",Form:"📝",Input:"⎕",Textarea:"▭",Select:"⏷",Checkbox:"☑",PasswordInput:"🔒",Label:"🏷",DataGrid:"▦",Pagination:"↔",SearchBar:"🔍",ProductCard:"🛍",ImageGallery:"🖼",Avatar:"👤",UserInfo:"👥",HtmlContent:"⟨/⟩",HtmlEditor:"✏",RichTextEditor:"✏",TabNavigation:"◰",QuantitySelector:"#",ProductImageViewer:"🖼",FileUploader:"📎",AvatarUploader:"📷",SocialLoginButtons:"🌐",PostReactions:"❤"}[t]??"◻"}const wA={display:"flex",flexDirection:"column",width:"100%",height:"100%",minHeight:0,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif'},kA={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"14px 20px",borderBottom:"1px solid #e2e8f0",flexShrink:0},SA={background:"transparent",border:"none",fontSize:24,cursor:"pointer",lineHeight:1,color:"#64748b",padding:"0 4px"},CA={display:"flex",flex:1,minHeight:0},$A={width:180,flexShrink:0,borderRight:"1px solid #e2e8f0",padding:"14px 8px",background:"#f8fafc",overflowY:"auto"},EA={listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:4},IA={display:"flex",width:"100%",alignItems:"center",justifyContent:"space-between",textAlign:"left",padding:"8px 12px",border:"none",borderRadius:6,fontSize:13,cursor:"pointer",transition:"background-color 120ms"},AA={flex:1,display:"flex",flexDirection:"column",minHeight:0,padding:"14px 20px"},TA={width:"100%",padding:"8px 10px",border:"1px solid #cbd5e1",borderRadius:6,marginBottom:12,fontSize:13,flexShrink:0,boxSizing:"border-box"},DA={flex:1,overflowY:"auto",minHeight:0},zA={fontSize:11,color:"#94a3b8",marginLeft:8,fontWeight:500},NA={display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(96px, 1fr))",gap:10},MA={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:6,padding:"14px 6px",background:"#fff",border:"1px solid #e2e8f0",borderRadius:8,cursor:"pointer",fontSize:12,minHeight:84,transition:"border-color 120ms, box-shadow 120ms"},LA={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:6,padding:"14px 6px",background:"#f8fafc",border:"1px dashed #cbd5e1",borderRadius:8,cursor:"not-allowed",fontSize:12,minHeight:84,color:"#94a3b8",opacity:.65},PA={fontSize:9,fontWeight:600,color:"#92400e",background:"#fef3c7",padding:"1px 6px",borderRadius:999,textTransform:"none",letterSpacing:0,lineHeight:1.6},OA={fontSize:22,lineHeight:1,color:"#475569"},BA={fontSize:12,fontWeight:500,color:"#0f172a",textAlign:"center",wordBreak:"break-word"},WA={fontFamily:'ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace',fontSize:10,color:"#64748b",textAlign:"center",wordBreak:"break-all"},jf={padding:24,color:"#64748b",fontSize:13,textAlign:"center"};function jA(e){const t=[],n=r=>{if(Array.isArray(r))for(const s of r)s&&typeof s=="object"&&t.push(s)};n(e.children);const o=e.responsive;if(o&&typeof o=="object")for(const r of Object.values(o))r&&typeof r=="object"&&n(r.children);return t}function Hf(e){const t=[],n=o=>{const r="isolatedState"in o&&o.isolatedState!=null,s=o.isolatedScopeId;(r||typeof s=="string"&&s.length>0)&&t.push({scopeId:typeof s=="string"?s:void 0,initialState:o.isolatedState&&typeof o.isolatedState=="object"?o.isolatedState:void 0});for(const a of jA(o))n(a)};if(Array.isArray(e))for(const o of e)o&&typeof o=="object"&&n(o);return t}const HA=["scroll","selector","wizard","slider"];function FA(e,t){const n=new Set;for(const o of e)o.scopeId&&n.add(o.scopeId);for(const o of t){n.add(o);for(const r of HA)n.add(`${o}-${r}`)}return Array.from(n)}function Ff(e){return typeof e=="string"&&(br(e)||ts(e))}function Kf(e,t,n=o=>o){const[o,r]=u.useState(!1),[s,a]=u.useState(null),l=n(e),d=Ff(l)&&!o,c=u.useCallback(()=>{a(Ff(l)?l:null),r(!0)},[l]),p=u.useCallback(()=>{s!==null&&l!==s&&t(s),r(!1),a(null)},[s,l,t]);return{bound:d,replacing:o,original:s,beginReplace:c,restore:p}}const KA={display:"flex",flexDirection:"column",gap:4,padding:"8px 10px",border:"1px dashed #cbd5e1",borderRadius:6,background:"#f8fafc"},VA={fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:11,color:"#0f172a",wordBreak:"break-all"},Vf={alignSelf:"flex-start",background:"none",border:"none",padding:0,fontSize:11,color:"#2563eb",cursor:"pointer",textDecoration:"underline"};function Uf({expression:e,t,onReplace:n,testIdPrefix:o}){return i.jsxs("div",{style:KA,children:[i.jsx("code",{"data-testid":`${o}-expression`,style:VA,children:e}),i.jsx("span",{style:{fontSize:11,color:"#64748b"},children:t("layout_editor.control.bound_value.notice")}),i.jsx("button",{type:"button","data-testid":`${o}-expression-replace`,onClick:n,style:Vf,children:t("layout_editor.control.bound_value.replace")})]})}function qf({t:e,onRestore:t,testIdPrefix:n}){return i.jsx("button",{type:"button","data-testid":`${n}-expression-restore`,onClick:t,style:Vf,children:e("layout_editor.control.bound_value.restore")})}function UA(e,t,n){const o=t.label;return typeof o=="string"?o.startsWith("$t:")?n(o.slice(3)):o:e}const qA=new Set(["image","core-id","i18n-text","text"]);function vi({controlKey:e,control:t,node:n,t:o,onPatch:r,candidates:s,bindingCandidates:a,scope:l=jt}){const d=zn(t.widget),c=UA(e,t,o),p=u.useMemo(()=>Lo(n,t,l),[n,t,l]),f=t.widget==="i18n-text"&&t.apply?.type==="propValue",b=t.widget==="text"&&t.apply?.type==="propValue",g=p.darkReadonly===!0||l.colorScheme==="dark"&&t.apply!==void 0&&!Rs(t.apply),m=t.apply,h=l.colorScheme==="dark"&&!g&&m?.type==="classToken"&&typeof m.tokenTemplate=="string"&&m.tokenTemplate.includes("{value}"),v=p.scopedValue===void 0&&p.baseFallback!==void 0,y=u.useCallback(k=>{if(g)return;const x=yn(n,t,k,l);r(x)},[n,t,r,l,g]),_=Kf(p.value,y),w=!qA.has(t.widget??"");return i.jsxs("div",{className:"g7le-control-row","data-testid":`g7le-control-${e}`,style:GA,children:[i.jsxs("span",{className:"g7le-control-label",style:YA,children:[c,p.conflict&&i.jsx("span",{"data-testid":`g7le-control-conflict-${e}`,title:o("layout_editor.property_modal.value_conflict"),style:XA,children:"!"})]}),i.jsx("div",{className:"g7le-control-widget",style:{flex:1,minWidth:0,opacity:v?.45:1},"data-placeholder":v?"true":void 0,children:f?i.jsx(_t,{value:typeof p.value=="string"?p.value:"",onChange:k=>y(k),t:o,testidPrefix:`g7le-prop-i18n-${e}`,candidates:a,enableExpressionTree:!0,expressionTreeCollapsible:!0}):b?i.jsx(Ke,{value:typeof p.value=="string"?p.value:"",onChange:k=>y(k===""?void 0:k),t:o,testidPrefix:`g7le-prop-value-${e}`,candidates:a}):g?i.jsx("span",{"data-testid":`g7le-control-dark-readonly-${e}`,style:ZA,children:o("layout_editor.property_modal.dark_code_only")}):w&&_.bound?i.jsx(Uf,{expression:String(p.value),t:o,onReplace:_.beginReplace,testIdPrefix:`g7le-control-${e}`}):d?i.jsxs(i.Fragment,{children:[i.jsx(d,{control:t,value:p.value,onChange:y,t:o,candidates:s,bindingCandidates:a,freeValueDisabled:h}),w&&_.replacing&&_.original!==null&&i.jsx(qf,{t:o,onRestore:_.restore,testIdPrefix:`g7le-control-${e}`})]}):i.jsx("span",{"data-testid":`g7le-control-unsupported-${e}`,style:JA,children:o("layout_editor.property_modal.unsupported_widget")})})]})}const GA={display:"flex",alignItems:"center",gap:12,padding:"6px 0",minHeight:32,minWidth:0},YA={fontSize:12,color:"#475569",minWidth:88,display:"inline-flex",alignItems:"center",gap:4},XA={display:"inline-flex",width:14,height:14,borderRadius:7,background:"#f59e0b",color:"#fff",fontSize:10,alignItems:"center",justifyContent:"center",fontWeight:700},JA={fontSize:11,color:"#94a3b8",fontStyle:"italic"},ZA={fontSize:11,color:"#94a3b8",fontStyle:"italic"};function _i(e,t,n){return typeof e=="string"?e.startsWith("$t:")?n(e.slice(3)):e:t}function QA(e,t){const n=e.props??{};return t.key in n?n[t.key]:t.default}function RA({spec:e,node:t,t:n,onPatchProp:o}){const r=e.groups??[];return i.jsx("div",{className:"g7le-composite-settings","data-testid":"g7le-composite-settings",style:t6,children:r.map((s,a)=>i.jsxs("div",{className:"g7le-settings-group",style:n6,children:[i.jsx("div",{style:o6,children:_i(s.label,n("layout_editor.property_modal.settings_group",{index:a+1}),n)}),(s.fields??[]).map(l=>i.jsxs("div",{className:"g7le-settings-field","data-testid":`g7le-setting-${l.key}`,style:r6,children:[i.jsx("span",{style:i6,children:_i(l.label,l.key,n)}),i.jsx("div",{style:{flex:1},children:e6(l,t,n,o)})]},l.key))]},a))})}function e6(e,t,n,o){const r=QA(t,e);switch(e.type){case"number":return i.jsx("input",{type:"number","data-testid":`g7le-setting-input-${e.key}`,value:typeof r=="number"?r:"",min:e.min,max:e.max,onChange:s=>o(e.key,s.target.value===""?void 0:Number(s.target.value)),style:za});case"text":return i.jsx("input",{type:"text","data-testid":`g7le-setting-input-${e.key}`,value:typeof r=="string"?r:"",onChange:s=>o(e.key,s.target.value===""?void 0:s.target.value),style:za});case"toggle":return i.jsx("input",{type:"checkbox","data-testid":`g7le-setting-input-${e.key}`,checked:r===!0,onChange:s=>o(e.key,s.target.checked)});case"checkbox-group":{const s=Array.isArray(r)?r:[];return i.jsx("div",{style:s6,"data-testid":`g7le-setting-input-${e.key}`,children:(e.options??[]).map(a=>{const l=s.includes(a.value);return i.jsxs("label",{style:a6,children:[i.jsx("input",{type:"checkbox",checked:l,onChange:d=>{const c=d.target.checked?[...s,a.value]:s.filter(p=>p!==a.value);o(e.key,c)}}),_i(a.label,String(a.value),n)]},String(a.value))})})}case"select":case"board-select":case"datasource-select":default:return i.jsxs("select",{"data-testid":`g7le-setting-input-${e.key}`,value:r==null?"":String(r),onChange:s=>{const a=s.target.value;if(a===""){o(e.key,void 0);return}const l=(e.options??[]).find(d=>String(d.value)===a);o(e.key,l?l.value:a)},style:za,children:[i.jsx("option",{value:"",children:"—"}),(e.options??[]).map(s=>i.jsx("option",{value:String(s.value),children:_i(s.label,String(s.value),n)},String(s.value)))]})}}const t6={display:"flex",flexDirection:"column",gap:16},n6={display:"flex",flexDirection:"column",gap:6},o6={fontSize:12,fontWeight:700,color:"#0f172a",borderBottom:"1px solid #e2e8f0",paddingBottom:4},r6={display:"flex",alignItems:"center",gap:12,minHeight:30},i6={fontSize:12,color:"#475569",minWidth:96},za={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,width:"100%",boxSizing:"border-box"},s6={display:"flex",flexWrap:"wrap",gap:10},a6={display:"inline-flex",alignItems:"center",gap:4,fontSize:12,color:"#0f172a"},l6=["data_binding","isolatedScopeId","parentFormContextProp","skipBindingKeys","isolatedState","component_layout","sortable","itemTemplate"],d6=/\{\{|\$switch|\$get|\|\s*(date|number|truncate|currency|relative)\b/;function xi(e,t=0){return t>6?!1:typeof e=="string"?d6.test(e):Array.isArray(e)?e.some(n=>xi(n,t+1)):e&&typeof e=="object"?Object.values(e).some(n=>xi(n,t+1)):!1}function c6(e){if(rd(e))return!1;const t=Jl(e);return t.length===0?!1:t.some(n=>n.isComplex)}function Gf(e){const t=[],n=e.props??{};for(const o of l6)o in e&&e[o]!==void 0?t.push({key:o,kind:"developer_prop"}):o in n&&n[o]!==void 0&&t.push({key:`props.${o}`,kind:"developer_prop"});typeof e.text=="string"?c6(e.text)&&t.push({key:"text",kind:"complex_expression"}):xi(e.text)&&t.push({key:"text",kind:"complex_expression"});for(const[o,r]of Object.entries(n))o==="style"||o==="className"||xi(r)&&t.push({key:`props.${o}`,kind:"complex_expression"});return t}function u6(e){return Gf(e).length>0}const p6=new Set(["permissions","blur_until_loaded","comment"]);function f6({node:e,advanced:t,t:n,onPatch:o,permissionCandidates:r}){const s=u.useMemo(()=>Gf(e),[e]),a=(l,d)=>{const c={...e};d===void 0?delete c[l]:c[l]=d,o(c)};return i.jsxs("div",{className:"g7le-advanced-props","data-testid":"g7le-advanced-props",style:g6,children:[t.map(l=>{if(!p6.has(l))return i.jsxs("div",{"data-testid":`g7le-advanced-deferred-${l}`,style:y6,children:[n("layout_editor.property_modal.advanced_deferred"),":",l]},l);if(l==="permissions")return i.jsxs("div",{className:"g7le-advanced-group","data-testid":"g7le-advanced-permissions",style:Na,children:[i.jsx("div",{style:Ma,children:n("layout_editor.property_modal.advanced.permissions")}),i.jsx(ks,{control:{widget:"tag-input"},value:e.permissions,onChange:d=>a("permissions",d),t:n,candidates:r})]},l);if(l==="blur_until_loaded"){const d=e.blur_until_loaded===!0||e.blur_until_loaded!=null&&e.blur_until_loaded!==!1;return i.jsxs("div",{className:"g7le-advanced-group","data-testid":"g7le-advanced-blur",style:Na,children:[i.jsx("div",{style:Ma,children:n("layout_editor.property_modal.advanced.blur_until_loaded")}),i.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:12},children:[i.jsx("input",{type:"checkbox","data-testid":"g7le-advanced-blur-toggle",checked:!!d,onChange:c=>a("blur_until_loaded",c.target.checked?!0:void 0)}),n("layout_editor.property_modal.advanced.blur_hint")]})]},l)}return i.jsxs("div",{className:"g7le-advanced-group","data-testid":"g7le-advanced-comment",style:Na,children:[i.jsx("div",{style:Ma,children:n("layout_editor.property_modal.advanced.comment")}),i.jsx("input",{type:"text","data-testid":"g7le-advanced-comment-input",value:typeof e.comment=="string"?e.comment:"",onChange:d=>a("comment",d.target.value===""?void 0:d.target.value),style:h6})]},l)}),s.length>0&&i.jsxs("div",{className:"g7le-advanced-preserved","data-testid":"g7le-advanced-preserved",style:b6,children:[i.jsx("div",{style:m6,children:n("layout_editor.property_modal.advanced_preserved_title",{count:s.length})}),i.jsx("ul",{style:v6,children:s.map(l=>i.jsxs("li",{"data-testid":`g7le-advanced-preserved-${l.key}`,style:_6,children:[i.jsx("code",{style:{fontSize:11},children:l.key}),i.jsx("span",{style:{fontSize:11,color:"#94a3b8"},children:l.kind==="developer_prop"?n("layout_editor.property_modal.advanced_kind_developer"):n("layout_editor.property_modal.advanced_kind_expression")})]},l.key))})]})]})}const g6={display:"flex",flexDirection:"column",gap:14},Na={display:"flex",flexDirection:"column",gap:6},Ma={fontSize:12,fontWeight:700,color:"#0f172a"},h6={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,width:"100%",boxSizing:"border-box"},y6={fontSize:11,color:"#94a3b8",fontStyle:"italic"},b6={borderTop:"1px dashed #cbd5e1",paddingTop:10,marginTop:4},m6={fontSize:11,color:"#b45309",marginBottom:6},v6={listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:4},_6={display:"flex",justifyContent:"space-between",gap:8,padding:"3px 0"},x6={onClick:"click",onHover:"mouseenter",onChange:"change",onSubmit:"submit",onMount:"mount",onUnmount:"unmount",onFocus:"focus",onBlur:"blur"};function La(e){return x6[e]??e.replace(/^on/,"").toLowerCase()}function Yf(e){const t=e.actions;if(Array.isArray(t))return t.filter(r=>!!r&&typeof r=="object");const n=e.props??{};if(Array.isArray(n.actions))return n.actions.filter(r=>!!r&&typeof r=="object");const o=n.events;if(o&&typeof o=="object"){const r=[];for(const[s,a]of Object.entries(o)){if(!Array.isArray(a))continue;const l=La(s);for(const d of a)d&&typeof d=="object"&&r.push("type"in d?d:{type:l,...d})}return r}return[]}function w6(e,t){const n=La(t);return Yf(e).filter(o=>o.type===n||t==="onClick"&&o.type===void 0)}function k6(e,t,n){const o=La(t),r=Yf(e).filter(d=>!(d.type===o||t==="onClick"&&d.type===void 0)),s=n.map(d=>"type"in d?d:{type:o,...d}),a={...e};if(a.props&&typeof a.props=="object"){const d={...a.props};let c=!1;"actions"in d&&(delete d.actions,c=!0),"events"in d&&(delete d.events,c=!0),c&&(a.props=d)}const l=[...r,...s];return l.length===0?delete a.actions:a.actions=l,a}function S6({node:e,spec:t,capability:n,t:o,onPatchNode:r,pageCandidates:s,dataSourceCandidates:a,stateKeyCandidates:l,bindingCandidates:d}){const c=t?.actionRecipes,p=u.useMemo(()=>({pageCandidates:s,dataSourceCandidates:a,stateKeyCandidates:l,bindingCandidates:d}),[s,a,l,d]),f=Array.isArray(n?.events)?n.events:[];return f.length===0?i.jsx("div",{"data-testid":"g7le-action-no-events",style:Xf,children:o("layout_editor.action.no_events")}):!c||Object.keys(c).length===0?i.jsx("div",{"data-testid":"g7le-action-no-recipes",style:Xf,children:o("layout_editor.action.no_recipes")}):i.jsx("div",{className:"g7le-action-editor","data-testid":"g7le-action-editor",style:{display:"flex",flexDirection:"column",gap:14},children:f.map(b=>i.jsxs("div",{className:"g7le-action-event-slot","data-testid":`g7le-action-event-${b}`,children:[i.jsx("div",{style:C6,children:o(`layout_editor.action.event.${b}`)}),i.jsx(Yt,{actions:w6(e,b),onChange:g=>r(k6(e,b,g)),t:o,recipes:c,candidatePools:p,actionChipCandidates:t?.actionChipCandidates??null,addContext:"component",showSourceBadge:!0,testIdPrefix:`g7le-action-slot-${b}`})]},b))})}const Xf={fontSize:12,color:"#94a3b8",padding:"16px 0",textAlign:"center"},C6={fontSize:12,fontWeight:700,color:"#475569",marginBottom:6};function Pa(e,t,n){if(!t)return n;const o=e(t);return!o||o===t||o.startsWith("$t:")?n:o}function $6(e,t){return Pa(t,e.labelKey,e.path||e.sourceId)}function E6({node:e,spec:t,candidates:n,t:o,onPatchNode:r}){const a=(e.props??{})[t.propKey],l=typeof a=="string"?a:void 0,d=u.useMemo(()=>Vt(a),[a]),c=l!==void 0&&l!==""&&d===null,[p,f]=u.useState(!1),[b,g]=u.useState(""),m=Pa(o,t.label,t.propKey),h=o(t.shape==="array"?"layout_editor.binding.shape_array":t.shape==="object"?"layout_editor.binding.shape_object":"layout_editor.binding.shape_scalar"),v=u.useMemo(()=>Ji(n,t.shape).map(x=>({...x,resolvedLabel:$6(x,o)})),[n,t.shape,o]),y=u.useMemo(()=>Zi(v,b),[v,b]),_=k=>{const x={...e.props??{}};k===void 0?delete x[t.propKey]:x[t.propKey]=k,r({...e,props:x})},w=k=>{_(In(k.sourceId,k.path,t.shape)),f(!1),g("")};return i.jsxs("div",{"data-testid":`g7le-binding-row-${t.propKey}`,style:D6,children:[i.jsxs("div",{style:z6,children:[i.jsx("span",{style:{fontWeight:600,fontSize:12},children:m}),i.jsx("span",{style:N6,children:h}),t.required&&i.jsx("span",{"data-testid":`g7le-binding-required-${t.propKey}`,style:M6,children:o("layout_editor.binding.required")})]}),c?i.jsxs("div",{"data-testid":`g7le-binding-complex-${t.propKey}`,style:B6,children:[o("layout_editor.binding.complex"),i.jsx("code",{style:Jf,children:l})]}):d?i.jsxs("div",{style:L6,children:[i.jsx("code",{"data-testid":`g7le-binding-expr-${t.propKey}`,style:Jf,children:l}),i.jsx("button",{type:"button","data-testid":`g7le-binding-clear-${t.propKey}`,onClick:()=>_(void 0),style:O6,children:o("layout_editor.binding.clear")})]}):i.jsx("div",{"data-testid":`g7le-binding-empty-${t.propKey}`,style:P6,children:o("layout_editor.binding.not_connected")}),d&&(t.shape==="array"||t.shape==="object")&&t.itemFields&&t.itemFields.length>0&&i.jsxs("div",{style:W6,children:[o("layout_editor.binding.item_fields"),": ",t.itemFields.join(", ")]}),!c&&i.jsxs("div",{style:{marginTop:4},children:[i.jsxs("button",{type:"button","data-testid":`g7le-binding-search-toggle-${t.propKey}`,onClick:()=>f(k=>!k),style:j6,children:["🔍 ",o("layout_editor.binding.search")]}),p&&i.jsxs("div",{"data-testid":`g7le-binding-picker-${t.propKey}`,style:H6,children:[i.jsx("input",{type:"text",autoFocus:!0,"data-testid":`g7le-binding-search-input-${t.propKey}`,value:b,placeholder:o("layout_editor.binding.search_placeholder"),onChange:k=>g(k.target.value),style:F6}),i.jsx("div",{style:K6,children:y.length===0?i.jsx("div",{style:V6,children:o("layout_editor.binding.no_results")}):y.map(k=>i.jsxs("button",{type:"button","data-testid":`g7le-binding-candidate-${k.expression}`,onClick:()=>w(k),style:U6,children:[i.jsxs("span",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start"},children:[i.jsx("span",{style:{fontSize:12},children:k.resolvedLabel}),i.jsxs("span",{style:q6,children:[Pa(o,k.groupLabelKey,k.sourceId)," · ",k.path||k.sourceId]})]}),i.jsx("span",{style:G6,children:k.preview})]},k.expression))})]})]})]})}function I6({node:e,dataProps:t,candidates:n,t:o,onPatchNode:r}){return!Array.isArray(t)||t.length===0?null:i.jsxs("div",{"data-testid":"g7le-data-binding-section",style:A6,children:[i.jsxs("div",{style:T6,children:["🔗 ",o("layout_editor.binding.section_title")]}),t.map(s=>i.jsx(E6,{node:e,spec:s,candidates:n,t:o,onPatchNode:r},s.propKey)),i.jsx("div",{style:Y6})]})}const A6={display:"flex",flexDirection:"column",marginBottom:8},T6={fontSize:12,fontWeight:700,color:"#0f172a",marginBottom:6},D6={display:"flex",flexDirection:"column",gap:4,padding:"8px 0"},z6={display:"flex",alignItems:"center",gap:6},N6={fontSize:10,padding:"1px 6px",borderRadius:4,background:"#e0e7ff",color:"#3730a3"},M6={fontSize:10,padding:"1px 6px",borderRadius:4,background:"#fef3c7",color:"#92400e"},L6={display:"flex",alignItems:"center",gap:6},P6={fontSize:11,color:"#94a3b8"},Jf={fontSize:11,fontFamily:"monospace",background:"#f1f5f9",padding:"2px 6px",borderRadius:4,color:"#0f172a",wordBreak:"break-all"},O6={fontSize:11,border:"1px solid #e2e8f0",borderRadius:4,background:"#fff",color:"#dc2626",padding:"2px 8px",cursor:"pointer"},B6={display:"flex",flexDirection:"column",gap:2,fontSize:11,color:"#64748b"},W6={fontSize:10,color:"#94a3b8"},j6={fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#334155",padding:"4px 10px",cursor:"pointer",textAlign:"left",width:"100%"},H6={marginTop:4,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",padding:6},F6={width:"100%",padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,boxSizing:"border-box"},K6={marginTop:4,maxHeight:200,overflowY:"auto",display:"flex",flexDirection:"column",gap:2},V6={fontSize:11,color:"#94a3b8",padding:"8px 0",textAlign:"center"},U6={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,border:"none",background:"transparent",cursor:"pointer",padding:"6px 8px",borderRadius:4,textAlign:"left"},q6={fontSize:10,color:"#94a3b8"},G6={fontSize:10,color:"#64748b",fontFamily:"monospace",whiteSpace:"nowrap"},Y6={borderTop:"1px solid #e2e8f0",marginTop:4};function X6({node:e,candidates:t,t:n,onPatchNode:o,templateIdentifier:r}){const s=typeof e.text=="string"?e.text:"",{state:a}=Qe(),l=r??a.templateIdentifier,d=a.selectedRoute?.layoutName??null,c=a.locale,[p,f]=u.useState(!1),b=/^\s*\$t:custom\.[A-Za-z0-9._-]+\s*$/.test(s),m=rd(s)&&(vt(s)?.key.startsWith("custom.")??!1)||b,h=u.useMemo(()=>m?vt(s):null,[m,s]),v=u.useMemo(()=>m?[]:Jl(s),[m,s]),y=D=>{o({...e,text:D})},_=()=>{if(!(typeof window>"u"))try{window.dispatchEvent(new CustomEvent(kt,{detail:{templateIdentifier:l,locale:c}}))}catch{}},w=(D,E)=>{const I=In(E.sourceId,E.path,"scalar");y(qb(s,D,I))},k=D=>{const E=vt(s);y(xo(s,D));const I=E?.key;l&&I&&Jd(l,I,D).then(_)},x=D=>{const E=n(D);return E&&E!==D&&!E.startsWith("$t:")?E:""},$=D=>D.replace(/\$t:[a-zA-Z0-9._-]+/g,E=>x(E.slice(3))).replace(/\s+/g," ").trim(),C=D=>{p||(f(!0),hs(l,d,c,s,s.length,D.sourceId,D.path,"scalar",$,E=>n(E)).then(E=>{E.kind==="ok"&&(y(E.text),_())}).finally(()=>f(!1)))},S=D=>{p||!h&&!b||(f(!0),Ir(l,c,s,Number.MAX_SAFE_INTEGER,D.sourceId,D.path,"scalar").then(E=>{E.kind==="ok"&&(y(E.text),_())}).finally(()=>f(!1)))};if(m){const D=h?.params??[];return i.jsxs("div",{"data-testid":"g7le-inline-binding-section",style:Zf,children:[i.jsxs("div",{style:Qf,children:["🔗 ",n("layout_editor.inline_binding.section_title")]}),D.length===0?i.jsx("div",{"data-testid":"g7le-inline-binding-none",style:tg,children:n("layout_editor.inline_binding.none")}):D.map(E=>i.jsx("div",{"data-testid":`g7le-inline-binding-param-${E.name}`,style:Rf,children:E.parsed===null?i.jsxs("div",{"data-testid":`g7le-inline-binding-param-complex-${E.name}`,style:Z6,children:[n("layout_editor.inline_binding.complex"),i.jsx("code",{style:Oa,children:E.expression})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{style:eg,children:[i.jsx("code",{"data-testid":`g7le-inline-binding-param-expr-${E.name}`,style:Oa,children:E.expression}),i.jsx("button",{type:"button","data-testid":`g7le-inline-binding-param-clear-${E.name}`,onClick:()=>k(E.name),style:J6,children:n("layout_editor.inline_binding.clear")})]}),i.jsx($t,{candidates:t,t:n,onSelect:I=>w(E.name,I),testIdSuffix:`param-${E.name}`})]})},E.name)),i.jsxs("div",{"data-testid":"g7le-inline-binding-param-append",style:ng,children:[i.jsx("div",{style:Ba,children:n("layout_editor.inline_binding.append_hint")}),i.jsx($t,{candidates:t,t:n,onSelect:S,testIdSuffix:"param-append"})]}),i.jsx("div",{"data-testid":"g7le-inline-binding-param-hint",style:Ba,children:n("layout_editor.inline_binding.param_hint")}),i.jsx("div",{style:og})]})}return i.jsxs("div",{"data-testid":"g7le-inline-binding-section",style:Zf,children:[i.jsxs("div",{style:Qf,children:["🔗 ",n("layout_editor.inline_binding.section_title")]}),v.length===0?i.jsx("div",{"data-testid":"g7le-inline-binding-none",style:tg,children:n("layout_editor.inline_binding.none")}):v.map(D=>i.jsx("div",{"data-testid":`g7le-inline-binding-row-${D.bindingIndex}`,style:Rf,children:i.jsx("div",{style:eg,children:i.jsx("code",{"data-testid":`g7le-inline-binding-expr-${D.bindingIndex}`,style:Oa,children:D.expression})})},D.bindingIndex)),i.jsxs("div",{"data-testid":"g7le-inline-binding-append",style:ng,children:[i.jsx("div",{style:Ba,children:n("layout_editor.inline_binding.append_hint")}),i.jsx($t,{candidates:t,t:n,onSelect:C,testIdSuffix:"append"})]}),i.jsx("div",{style:og})]})}const Zf={display:"flex",flexDirection:"column",marginBottom:8},Qf={fontSize:12,fontWeight:700,color:"#0f172a",marginBottom:6},Rf={display:"flex",flexDirection:"column",gap:4,padding:"8px 0"},eg={display:"flex",alignItems:"center",gap:6},tg={fontSize:11,color:"#94a3b8"},Oa={fontSize:11,fontFamily:"monospace",background:"#f1f5f9",padding:"2px 6px",borderRadius:4,color:"#0f172a",wordBreak:"break-all"},J6={fontSize:11,border:"1px solid #e2e8f0",borderRadius:4,background:"#fff",color:"#dc2626",padding:"2px 8px",cursor:"pointer"},Z6={display:"flex",flexDirection:"column",gap:2,fontSize:11,color:"#64748b"},ng={display:"flex",flexDirection:"column",gap:2,padding:"8px 0 0"},Ba={fontSize:11,color:"#475569",fontWeight:600},og={borderTop:"1px solid #e2e8f0",marginTop:4};function rg(e,t,n){if(!t)return n;const o=e(t);return!o||o===t||o.startsWith("$t:")?n:o}function Q6(e,t){return rg(t,e.labelKey,e.path||e.sourceId)}function R6(e){const t=e.iteration;return t&&typeof t=="object"?t:null}function eT({node:e,candidates:t,t:n,onPatchNode:o}){const r=R6(e),s=r?.source,a=typeof s=="string"?s:void 0,l=u.useMemo(()=>Vt(s),[s]),d=a!==void 0&&a!==""&&l===null,[c,p]=u.useState(!1),[f,b]=u.useState(""),g=u.useMemo(()=>Ji(t,"array").map(k=>({...k,resolvedLabel:Q6(k,n)})),[t,n]),m=u.useMemo(()=>Zi(g,f),[g,f]);if(!r)return null;const h=typeof r.item_var=="string"?r.item_var:void 0,v=typeof r.index_var=="string"?r.index_var:void 0,y=w=>{const k={...r};w===void 0?delete k.source:k.source=w,o({...e,iteration:k})},_=w=>{y(In(w.sourceId,w.path,"array")),p(!1),b("")};return i.jsxs("div",{"data-testid":"g7le-iteration-binding-section",style:tT,children:[i.jsxs("div",{style:nT,children:["🔁 ",n("layout_editor.binding.iteration_title")]}),i.jsx("div",{style:oT,children:n("layout_editor.binding.iteration_hint")}),i.jsxs("div",{style:rT,children:[i.jsxs("div",{style:iT,children:[i.jsx("span",{style:{fontWeight:600,fontSize:12},children:n("layout_editor.binding.iteration_label")}),i.jsx("span",{style:sT,children:n("layout_editor.binding.shape_array")})]}),d?i.jsxs("div",{"data-testid":"g7le-iteration-binding-complex",style:cT,children:[n("layout_editor.binding.complex"),i.jsx("code",{style:ig,children:a})]}):l?i.jsxs("div",{style:aT,children:[i.jsx("code",{"data-testid":"g7le-iteration-binding-expr",style:ig,children:a}),i.jsx("button",{type:"button","data-testid":"g7le-iteration-binding-clear",onClick:()=>y(void 0),style:dT,children:n("layout_editor.binding.clear")})]}):i.jsx("div",{"data-testid":"g7le-iteration-binding-empty",style:lT,children:n("layout_editor.binding.not_connected")}),(h||v)&&i.jsxs("div",{"data-testid":"g7le-iteration-vars",style:uT,children:[h&&i.jsxs("span",{children:[n("layout_editor.binding.iteration_item_var"),": ",i.jsx("code",{style:sg,children:h})]}),v&&i.jsxs("span",{children:[n("layout_editor.binding.iteration_index_var"),": ",i.jsx("code",{style:sg,children:v})]})]}),!d&&i.jsxs("div",{style:{marginTop:4},children:[i.jsxs("button",{type:"button","data-testid":"g7le-iteration-binding-search-toggle",onClick:()=>p(w=>!w),style:pT,children:["🔍 ",n("layout_editor.binding.search")]}),c&&i.jsxs("div",{"data-testid":"g7le-iteration-binding-picker",style:fT,children:[i.jsx("input",{type:"text",autoFocus:!0,"data-testid":"g7le-iteration-binding-search-input",value:f,placeholder:n("layout_editor.binding.search_placeholder"),onChange:w=>b(w.target.value),style:gT}),i.jsx("div",{style:hT,children:m.length===0?i.jsx("div",{style:yT,children:n("layout_editor.binding.no_results")}):m.map(w=>i.jsxs("button",{type:"button","data-testid":`g7le-iteration-binding-candidate-${w.expression}`,onClick:()=>_(w),style:bT,children:[i.jsxs("span",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start"},children:[i.jsx("span",{style:{fontSize:12},children:w.resolvedLabel}),i.jsxs("span",{style:mT,children:[rg(n,w.groupLabelKey,w.sourceId)," · ",w.path||w.sourceId]})]}),i.jsx("span",{style:vT,children:w.preview})]},w.expression))})]})]})]}),i.jsx("div",{style:_T})]})}const tT={display:"flex",flexDirection:"column",marginBottom:8},nT={fontSize:12,fontWeight:700,color:"#0f172a",marginBottom:4},oT={fontSize:10,color:"#94a3b8",marginBottom:6,lineHeight:1.4},rT={display:"flex",flexDirection:"column",gap:4,padding:"8px 0"},iT={display:"flex",alignItems:"center",gap:6},sT={fontSize:10,padding:"1px 6px",borderRadius:4,background:"#e0e7ff",color:"#3730a3"},aT={display:"flex",alignItems:"center",gap:6},lT={fontSize:11,color:"#94a3b8"},ig={fontSize:11,fontFamily:"monospace",background:"#f1f5f9",padding:"2px 6px",borderRadius:4,color:"#0f172a",wordBreak:"break-all"},dT={fontSize:11,border:"1px solid #e2e8f0",borderRadius:4,background:"#fff",color:"#dc2626",padding:"2px 8px",cursor:"pointer"},cT={display:"flex",flexDirection:"column",gap:2,fontSize:11,color:"#64748b"},uT={display:"flex",gap:12,fontSize:10,color:"#94a3b8",marginTop:2},sg={fontSize:10,fontFamily:"monospace",background:"#f1f5f9",padding:"1px 4px",borderRadius:3,color:"#475569"},pT={fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#334155",padding:"4px 10px",cursor:"pointer",textAlign:"left",width:"100%"},fT={marginTop:4,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",padding:6},gT={width:"100%",padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,boxSizing:"border-box"},hT={marginTop:4,maxHeight:200,overflowY:"auto",display:"flex",flexDirection:"column",gap:2},yT={fontSize:11,color:"#94a3b8",padding:"8px 0",textAlign:"center"},bT={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,border:"none",background:"transparent",cursor:"pointer",padding:"6px 8px",borderRadius:4,textAlign:"left"},mT={fontSize:10,color:"#94a3b8"},vT={fontSize:10,color:"#64748b",fontFamily:"monospace",whiteSpace:"nowrap"},_T={borderTop:"1px solid #e2e8f0",marginTop:4},xT=new Set(["Span","P","H1","H2","H3","H4","H5","H6","A","Button","Li","Label"]);function wT(e,t){if(!e||e.iteration&&typeof e.iteration=="object")return!1;const n=t?.textBinding;if(n===!1)return!1;if(n===!0)return!0;const o=typeof e.name=="string"?e.name:"";return xT.has(o)?!0:typeof e.text=="string"}const mn={direction:"flexDirection",justify:"flexJustify",align:"flexAlign",wrap:"flexWrap",gap:"flexGap",enable:"flexEnable"},wi={grow:"flexItemGrow",selfAlign:"flexItemAlign",order:"flexItemOrder"};function ag(e){const t=e?.flexEditor;return t==="container"||t==="item"||t==="auto"?t:null}function kT(e){if(!e||typeof window>"u"||typeof window.getComputedStyle!="function")return!1;const t=(window.getComputedStyle(e).display??"").toLowerCase();return t==="flex"||t==="inline-flex"}function ST(e,t,n=jt){if(!e||!t)return!1;const o=Lo(e,t,n),r=t.options,s=Array.isArray(r)?t.onValue??r[0]?.value:void 0,a=l=>s!==void 0?l===s:l!==void 0&&l!==!1;return n.breakpoint!=="base"?a(o.scopedRawValue):o.matched&&a(o.value)}function CT(e,t,n=!1,o=!1,r=jt){if(e==="container")return{showContainer:!0,showEnableButton:!1,showDisableButton:!1};if(e==="item")return{showContainer:!1,showEnableButton:!1,showDisableButton:!1};if(e==="auto"){const s=r.breakpoint==="base";return!o&&!s?{showContainer:!1,showEnableButton:!1,showDisableButton:!1}:(o?n:kT(t))?{showContainer:!0,showEnableButton:!1,showDisableButton:o}:{showContainer:!1,showEnableButton:!0,showDisableButton:!1}}return{showContainer:!1,showEnableButton:!1,showDisableButton:!1}}const $T={[mn.direction]:"layout_editor.flex.direction",[mn.justify]:"layout_editor.flex.justify",[mn.align]:"layout_editor.flex.align",[mn.wrap]:"layout_editor.flex.wrap",[mn.gap]:"layout_editor.flex.gap"},ET={[wi.grow]:"layout_editor.flex.item_grow",[wi.selfAlign]:"layout_editor.flex.item_align",[wi.order]:"layout_editor.flex.item_order"};function IT({node:e,spec:t,capability:n,t:o,onPatchNode:r,liveElement:s,scope:a=jt}){const l=ag(n),d=Ct(t,mn.enable),c=ST(e,d,a),{showContainer:p,showEnableButton:f,showDisableButton:b}=CT(l,s,c,!!d,a),g=Object.values(mn).filter(x=>x!==mn.enable&&Ct(t,x)),m=Object.values(wi).filter(x=>Ct(t,x)),h=d?.options,v=d?.onValue??h?.[0]?.value??!0,y=Array.isArray(h)&&h.length>=2?h[1].value:void 0,_=()=>{if(!d)return;const x=yn(e,d,v,a);r(x)},w=()=>{if(!d)return;const x=a.breakpoint!=="base"&&y!==void 0?y:void 0,$=yn(e,d,x,a);r($)},k=(x,$,C)=>i.jsx("div",{"data-testid":C,style:{display:"flex",flexDirection:"column"},children:x.map(S=>{const D=Ct(t,S);if(!D)return null;const E=D.label?D:{...D,label:`$t:${$[S]}`};return i.jsx(vi,{controlKey:S,control:E,node:e,t:o,onPatch:r,scope:a},S)})});return i.jsxs("div",{className:"g7le-flex-editor","data-testid":"g7le-flex-editor",style:{display:"flex",flexDirection:"column",gap:12},children:[f&&i.jsx("button",{type:"button","data-testid":"g7le-flex-enable",onClick:_,style:AT,children:o("layout_editor.flex.make_flex")}),p&&g.length>0&&i.jsxs("div",{className:"g7le-flex-container-section","data-testid":"g7le-flex-container-section",children:[i.jsx("div",{style:lg,children:o("layout_editor.flex.container_title")}),k(g,$T,"g7le-flex-container-controls"),b&&i.jsx("button",{type:"button","data-testid":"g7le-flex-disable",onClick:w,style:TT,children:o("layout_editor.flex.unmake_flex")})]}),l==="item"&&m.length>0&&i.jsxs("div",{className:"g7le-flex-item-section","data-testid":"g7le-flex-item-section",children:[i.jsx("div",{style:lg,children:o("layout_editor.flex.item_title")}),k(m,ET,"g7le-flex-item-controls")]}),!p&&!f&&l!=="item"&&i.jsx("div",{"data-testid":"g7le-flex-empty",style:DT,children:o("layout_editor.flex.not_flex")})]})}const lg={fontSize:12,fontWeight:700,color:"#0f172a",marginBottom:6},AT={padding:"8px 12px",fontSize:12,border:"1px dashed #2563eb",borderRadius:6,background:"#eff6ff",color:"#2563eb",cursor:"pointer"},TT={marginTop:8,padding:"6px 10px",fontSize:12,border:"1px solid #e2e8f0",borderRadius:6,background:"#f8fafc",color:"#64748b",cursor:"pointer"},DT={fontSize:12,color:"#94a3b8",padding:"16px 0",textAlign:"center"},dg=["desktop","tablet","mobile","portable"],Wa=1280,zT=820,NT=390,MT=1920,LT=320;function PT(e){const t=[],n=new Set,o=r=>{if(!r||typeof r!="object")return;const s=r.responsive;if(s&&typeof s=="object")for(const a of Object.keys(s)){n.has(a)||(n.add(a),t.push(a));const l=s[a]?.children;if(Array.isArray(l))for(const d of l)o(d)}if(Array.isArray(r.children))for(const a of r.children)o(a)};if(Array.isArray(e))for(const r of e)o(r);return t}function OT(e){const t=[...dg],n=new Set(dg);for(const o of PT(e))!n.has(o)&&!t.includes(o)&&t.push(o);return t}function BT(e,t){const n=e?.responsive;if(!n||typeof n!="object")return[];const o=[];for(const r of Object.keys(n)){const s=n[r];!s||!Array.isArray(s.children)||r!==t&&o.push(r)}return o}function WT(e){switch(e){case"desktop":return Wa;case"tablet":return zT;case"mobile":return NT}const t=e in Mo?Mo[e]:Pn.parseRange(e);return!t||!Number.isFinite(t.max)?Wa:Math.round(Math.max(LT,Math.min(MT,t.max)))}function cg(){const t=Kt()?.document?.raw?.components;return u.useMemo(()=>OT(t??null),[t])}const jT={desktop:"layout_editor.property_modal.scope.device_desktop",tablet:"layout_editor.property_modal.scope.device_tablet",mobile:"layout_editor.property_modal.scope.device_mobile",portable:"layout_editor.property_modal.scope.device_portable"},HT=[{key:"base",labelKey:"layout_editor.property_modal.scope.scheme_light"},{key:"dark",labelKey:"layout_editor.property_modal.scope.scheme_dark"}];function ug({scope:e,onChange:t,node:n,t:o,showColorScheme:r=!0,onClearScope:s}){const[a,l]=u.useState(!1),[d,c]=u.useState(""),[p,f]=u.useState(""),[b,g]=u.useState(null),m=cg(),h=u.useMemo(()=>{const w=["base",...m],k=new Set(w);for(const x of Object.keys(n.responsive??{}))x!=="base"&&!k.has(x)&&(k.add(x),w.push(x));return e.breakpoint!=="base"&&!k.has(e.breakpoint)&&w.push(e.breakpoint),w},[m,n.responsive,e.breakpoint]),v=w=>t({...e,colorScheme:w}),y=w=>t({...e,breakpoint:w}),_=()=>{const w=d.trim(),k=p.trim();if(w===""&&k===""){g(o("layout_editor.property_modal.scope.custom_invalid"));return}const x=`${w}-${k}`;if(!OC(x)){g(o("layout_editor.property_modal.scope.custom_invalid"));return}g(null),l(!1),c(""),f(""),y(x)};return i.jsxs("div",{className:"g7le-style-scope-tabs","data-testid":"g7le-style-scope-tabs",style:FT,children:[r&&i.jsx("div",{className:"g7le-style-scope-scheme","data-testid":"g7le-style-scope-scheme",role:"tablist","aria-label":o("layout_editor.property_modal.scope.scheme_light"),style:pg,children:HT.map(w=>{const k=e.colorScheme===w.key;return i.jsxs("button",{type:"button",role:"tab","aria-selected":k,"data-testid":`g7le-style-scheme-${w.key}`,"data-active":k?"true":"false",onClick:()=>v(w.key),style:fg(k),children:[o(w.labelKey),w.key==="dark"&&ta(n,{colorScheme:"dark",breakpoint:e.breakpoint})&&i.jsx("span",{"data-testid":"g7le-style-scheme-dark-dot",style:gg})]},w.key)})}),i.jsxs("div",{className:"g7le-style-scope-device","data-testid":"g7le-style-scope-device",role:"tablist","aria-label":o("layout_editor.property_modal.scope.device_base"),style:pg,children:[h.map(w=>{const k=e.breakpoint===w,x=w==="base"||zu(w),$=w==="base"?"layout_editor.property_modal.scope.device_base":jT[w],C=$?o($):w,S=x?`g7le-style-bp-${w}`:`g7le-style-bp-custom-${w}`;return i.jsxs("button",{type:"button",role:"tab","aria-selected":k,"data-testid":S,"data-active":k?"true":"false",onClick:()=>y(w),style:fg(k),children:[C,ta(n,{colorScheme:"base",breakpoint:w})&&i.jsx("span",{"data-testid":`${S}-dot`,style:gg})]},String(w))}),i.jsxs("button",{type:"button","data-testid":"g7le-style-bp-add-custom",onClick:()=>l(w=>!w),style:UT,children:["+ ",o("layout_editor.property_modal.scope.add_custom")]})]}),a&&i.jsxs("div",{className:"g7le-style-scope-custom-input","data-testid":"g7le-style-scope-custom-input",style:KT,children:[i.jsx("input",{type:"number","data-testid":"g7le-style-custom-min",placeholder:o("layout_editor.property_modal.scope.custom_min"),value:d,onChange:w=>c(w.target.value),style:hg}),i.jsx("span",{style:{color:"#94a3b8"},children:"—"}),i.jsx("input",{type:"number","data-testid":"g7le-style-custom-max",placeholder:o("layout_editor.property_modal.scope.custom_max"),value:p,onChange:w=>f(w.target.value),style:hg}),i.jsx("button",{type:"button","data-testid":"g7le-style-custom-confirm",onClick:_,style:qT,children:o("layout_editor.property_modal.scope.add_custom")})]}),b&&i.jsx("div",{"data-testid":"g7le-style-custom-error",style:GT,children:b}),e.breakpoint!=="base"&&!zu(e.breakpoint)&&i.jsx("div",{"data-testid":"g7le-style-custom-priority-note",style:YT,children:o("layout_editor.property_modal.scope.custom_priority_note")}),s&&ta(n,e)&&i.jsxs("button",{type:"button","data-testid":"g7le-style-scope-reset",onClick:s,style:VT,children:["↺ ",o("layout_editor.property_modal.scope.reset_to_base")]})]})}const FT={display:"flex",flexDirection:"column",gap:0,padding:"0 0 8px",borderBottom:"1px solid #e2e8f0",marginBottom:8},KT={display:"flex",gap:6,alignItems:"center",marginTop:4},pg={display:"flex",gap:2,flexWrap:"wrap",borderBottom:"1px solid #e2e8f0",margin:"0 -16px",padding:"0 12px"};function fg(e){return{display:"inline-flex",alignItems:"center",gap:4,padding:"6px 12px",fontSize:12,border:"none",borderBottom:`2px solid ${e?"#2563eb":"transparent"}`,background:"transparent",color:e?"#2563eb":"#64748b",cursor:"pointer",fontWeight:e?700:500,marginBottom:-1}}const gg={display:"inline-block",width:5,height:5,borderRadius:3,background:"#f59e0b"},VT={alignSelf:"flex-start",marginTop:2,padding:"3px 8px",fontSize:10,border:"1px solid #cbd5e1",borderRadius:6,background:"#f8fafc",color:"#475569",cursor:"pointer"},UT={padding:"6px 12px",fontSize:11,border:"none",borderBottom:"2px dashed #cbd5e1",background:"transparent",color:"#475569",cursor:"pointer",marginBottom:-1},hg={width:70,padding:"4px 6px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6},qT={padding:"4px 10px",fontSize:11,border:"none",borderRadius:6,background:"#2563eb",color:"#fff",cursor:"pointer"},GT={fontSize:11,color:"#dc2626"},YT={fontSize:10,color:"#94a3b8"},yg=new Map;function Bn(e,t){yg.set(e,t)}function XT(e){return e?yg.get(e)??null:null}const ja={id:{label:"$t:layout_editor.core_props.id.label",widget:"core-id",placeholder:"$t:layout_editor.core_props.id.placeholder",apply:{type:"propValue",propKey:"id"}},dataKey:{label:"$t:layout_editor.core_props.dataKey.label",widget:"core-datakey",placeholder:"$t:layout_editor.core_props.dataKey.placeholder",apply:{type:"nodeKey",nodeKey:"dataKey"}},isolatedState:{label:"$t:layout_editor.core_props.isolatedState.label",widget:"toggle",apply:{type:"nodeKey",nodeKey:"isolatedState"}},isolatedScopeId:{label:"$t:layout_editor.core_props.isolatedScopeId.label",widget:"core-scopeid",placeholder:"$t:layout_editor.core_props.isolatedScopeId.placeholder",apply:{type:"nodeKey",nodeKey:"isolatedScopeId"}}},JT=["id"];function ZT(e){return e===!1?[]:Array.isArray(e)?e.filter(t=>t in ja&&!bg.has(t)):JT.filter(t=>!bg.has(t))}const bg=new Set(["isolatedState","isolatedScopeId"]);function mg(e){const t=e.props?.id??e.id;return typeof t=="string"&&t.length>0?`${t}-scope`:"scope"}function QT({node:e,onPatchNode:t,t:n,scopeIdCandidates:o=[],usedScopeIds:r=[]}){const s=e,a="isolatedState"in s&&s.isolatedState!=null,l=typeof s.isolatedScopeId=="string"?s.isolatedScopeId:"",[d,c]=u.useState(""),p=()=>{const h={...e};a?(delete h.isolatedState,delete h.isolatedScopeId):(h.isolatedState={},h.isolatedScopeId=mg(e)),t(h)},f=h=>{const v={...e};v.isolatedScopeId=h.trim()===""?mg(e):h,t(v)},b=h=>{const v={...e};v.isolatedState=h,t(v)},g=u.useMemo(()=>{const h=d.trim().toLowerCase();return o.filter(v=>!h||v.toLowerCase().includes(h))},[o,d]),m=l!==""&&r.includes(l);return i.jsxs("div",{className:"g7le-isolated-scope","data-testid":"g7le-isolated-scope-control",style:RT,children:[i.jsx("div",{style:e4,children:n("layout_editor.core_props.isolatedState.label")}),i.jsxs("div",{style:t4,children:[i.jsx("button",{type:"button","data-testid":"g7le-isolated-toggle",role:"switch","aria-checked":a,onClick:p,style:n4(a),children:n(a?"layout_editor.overlay.on":"layout_editor.overlay.off")}),a?null:i.jsx("span",{"data-testid":"g7le-isolated-off-hint",style:o4,children:n("layout_editor.core_props.isolatedState.off_hint")})]}),a?i.jsxs(i.Fragment,{children:[i.jsxs("div",{style:vg,children:[i.jsx("label",{style:_g,children:n("layout_editor.core_props.isolatedScopeId.label")}),i.jsx("input",{type:"text","data-testid":"g7le-isolated-scopeid-input",value:l,placeholder:n("layout_editor.core_props.isolatedScopeId.placeholder"),onChange:h=>f(h.target.value),style:r4}),g.length>0?i.jsxs("div",{"data-testid":"g7le-isolated-scopeid-picker",style:i4,children:[i.jsx("input",{type:"text","data-testid":"g7le-isolated-scopeid-search",value:d,placeholder:n("layout_editor.core_props.isolatedScopeId.search"),onChange:h=>c(h.target.value),style:s4}),i.jsx("div",{style:a4,children:g.map(h=>i.jsx("button",{type:"button","data-testid":`g7le-isolated-scopeid-candidate-${h}`,onClick:()=>{f(h),c("")},style:l4,children:h},h))})]}):null,m?i.jsxs("p",{"data-testid":"g7le-isolated-scopeid-dup",style:d4,children:["ⓘ ",n("layout_editor.core_props.isolatedScopeId.duplicate")]}):null]}),i.jsxs("div",{style:vg,children:[i.jsx("label",{style:_g,children:n("layout_editor.core_props.isolatedState.initial_label")}),i.jsx("div",{"data-testid":"g7le-isolated-initial-value",children:i.jsx(Mn,{value:s.isolatedState??{},onChange:b,t:n,path:"isolatedState",scope:"isolated-node"})})]})]}):null]})}const RT={display:"flex",flexDirection:"column",gap:8,padding:10,border:"1px solid #e2e8f0",borderRadius:8,minWidth:0},e4={fontSize:12,fontWeight:700,color:"#0f172a"},t4={display:"flex",gap:8,alignItems:"center"},n4=e=>({padding:"4px 12px",fontSize:11,border:`1px solid ${e?"#3b82f6":"#cbd5e1"}`,borderRadius:14,background:e?"#eff6ff":"#fff",color:e?"#1d4ed8":"#64748b",cursor:"pointer"}),o4={fontSize:11,color:"#94a3b8"},vg={display:"flex",flexDirection:"column",gap:4,minWidth:0},_g={fontSize:11,color:"#64748b"},r4={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,boxSizing:"border-box",width:"100%"},i4={border:"1px solid #e2e8f0",borderRadius:6,padding:4,background:"#fff"},s4={width:"100%",padding:"4px 6px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,marginBottom:4,boxSizing:"border-box"},a4={display:"flex",flexDirection:"column",maxHeight:120,overflowY:"auto"},l4={textAlign:"left",padding:"4px 6px",fontSize:12,border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"#0f172a"},d4={margin:0,fontSize:11,color:"#64748b"},c4={borderTop:"2px solid #c7d2fe",background:"#eef2ff",padding:"10px 12px",display:"flex",flexDirection:"column",gap:8},xg={fontSize:13,fontWeight:700,color:"#3730a3",display:"flex",alignItems:"center",gap:6},u4={fontSize:11,fontWeight:600,color:"#4338ca",background:"#e0e7ff",border:"1px solid #c7d2fe",borderRadius:4,padding:"1px 6px"},Ha={fontSize:11,color:"#6366f1"},p4={alignSelf:"flex-start",fontSize:12,fontWeight:600,color:"#fff",background:"#4f46e5",border:"none",borderRadius:4,padding:"4px 10px",cursor:"pointer"},f4={opacity:.5,cursor:"not-allowed"},g4={fontSize:11,color:"#dc2626"};function h4({entry:e,t,onSave:n}){const[o,r]=u.useState(()=>e.props),[s,a]=u.useState(!0),[l,d]=u.useState(null),[c,p]=u.useState(!1),[f,b]=u.useState(!1),g=e.extensionName??e.extensionIdentifier??`#${e.extensionId}`,m=async()=>{if(!s){d(t("layout_editor.property_modal.injected_props.invalid_json"));return}d(null),p(!0),b(!1);try{await n(o),b(!0)}catch(h){d(h instanceof Error?h.message:String(h))}finally{p(!1)}};return i.jsxs("div",{"data-testid":`g7le-injected-props-entry-${e.extensionId}`,style:{display:"flex",flexDirection:"column",gap:6},children:[i.jsx("div",{style:xg,children:i.jsx("span",{style:u4,"data-testid":"g7le-injected-props-origin-badge",children:t("layout_editor.property_modal.injected_props.origin",{source:g})})}),i.jsx(Us,{value:o,shape:"object",emptyValue:{},testidPrefix:"g7le-injected-props-json",minHeight:80,invalidErrorKey:"layout_editor.property_modal.injected_props.invalid_json",shapeErrorKey:"layout_editor.property_modal.injected_props.invalid_json",t,onChange:h=>{r(h??{}),b(!1)},onValidityChange:h=>{a(h),h&&d(null),b(!1)}}),l&&i.jsx("div",{style:g4,"data-testid":"g7le-injected-props-error",children:l}),f&&i.jsx("div",{style:{...Ha,color:"#16a34a"},"data-testid":"g7le-injected-props-saved",children:t("layout_editor.property_modal.injected_props.saved")}),i.jsx("div",{style:Ha,children:t("layout_editor.property_modal.injected_props.save_target")}),i.jsx("button",{type:"button","data-testid":"g7le-injected-props-save",style:{...p4,...c||!s?f4:null},disabled:c||!s,onClick:m,children:c?t("layout_editor.property_modal.injected_props.saving"):t("layout_editor.property_modal.injected_props.save_button",{source:g})})]})}function y4({injectedProps:e,t,onSaveInjectedProps:n}){return!Array.isArray(e)||e.length===0?null:i.jsxs("div",{style:c4,"data-testid":"g7le-injected-props-section",children:[i.jsxs("div",{style:xg,children:["🧩 ",t("layout_editor.property_modal.injected_props.title")]}),i.jsx("div",{style:Ha,children:t("layout_editor.property_modal.injected_props.help")}),e.map(o=>i.jsx(h4,{entry:o,t,onSave:r=>n(o.extensionId,r)},o.extensionId))]})}function b4(e,t){const n=e?.components??{};for(const o of Object.values(n)){const r=o?.find(s=>s.name===t);if(r)return r}return null}function m4({node:e,spec:t,manifest:n,t:o,onPatchNode:r,onClose:s,onDelete:a,permissionCandidates:l,pageCandidates:d,dataSourceCandidates:c,stateKeyCandidates:p,bindingCandidates:f,liveElement:b,scope:g=jt,onScopeChange:m,templateIdentifier:h,initialTab:v,onSaveInjectedProps:y,branchLabel:_,isolatedScopeIdCandidates:w,usedScopeIds:k}){const x=e.__injectedProps,$=Array.isArray(x)&&x.length>0&&!!y,C=ve=>{m?.(ve)},S=()=>{r(VC(e,g))},D=typeof e.name=="string"?e.name:"",E=Ui(t,D),N=b4(n,D)?.settings,T=!!(N?.groups&&N.groups.length>0),B=Array.isArray(E?.propControls)?E.propControls:[],M=ZT(E?.coreProps),O=new Set(M.map(ve=>ja[ve].apply?.propKey)),z=B.filter(ve=>{const We=Ct(t,ve)?.apply?.propKey;return!(We!==void 0&&O.has(We))}),H=typeof E?.nodeEditor?.kind=="string"?E.nodeEditor.kind:void 0,P=E?.nodeEditor?.params,A=H?XT(H):null,L=!!A,F=Array.isArray(E?.dataProps)?E.dataProps:[],Y=F.length>0,V=!!(e.iteration&&typeof e.iteration=="object"),X=wT(e,E),Z=M.length>0||z.length>0||L||Y||X||V,ie=Array.isArray(E?.styleControls)?E.styleControls:[],oe=Array.isArray(E?.advanced)?E.advanced:[],ee=(Array.isArray(E?.events)?E.events:[]).length>0,fe=ag(E),K=ie.length>0||fe!==null,ye=!(E?.visibilityCondition===!1)&&(Z||K||ee||T||oe.length>0),Se=u.useMemo(()=>{const ve=[];return T&&ve.push("settings"),Z&&ve.push("props"),K&&ve.push("style"),ee&&ve.push("action"),ye&&ve.push("visibility"),ve.push("translation"),oe.length>0&&ve.push("advanced"),ve},[T,Z,K,ee,ye,oe.length]),De=z.length>0||L||Y||V,[Ie,Ve]=u.useState(v&&Se.includes(v)?v:T?"settings":De?"props":K?"style":Z?"props":Se[0]??"style"),ze=u6(e),Be=!Z&&!K&&!T&&!ee&&!ye&&oe.length===0,Xe=E?.label?E.label.startsWith("$t:")?o(E.label.slice(3)):E.label:D||o("layout_editor.property_modal.element"),Ne=(ve,qe)=>{const We={...e.props??{}};qe===void 0?delete We[ve]:We[ve]=qe,r({...e,props:We})},Je={settings:o("layout_editor.property_modal.tab.settings"),props:o("layout_editor.property_modal.tab.props"),style:o("layout_editor.property_modal.tab.style"),action:o("layout_editor.property_modal.tab.action"),visibility:o("layout_editor.property_modal.tab.visibility"),translation:o("layout_editor.property_modal.tab.translation"),advanced:o("layout_editor.property_modal.tab.advanced")};return i.jsxs("div",{className:"g7le-property-modal","data-testid":"g7le-property-modal",style:v4,children:[i.jsxs("div",{"data-modal-drag-handle":!0,"data-testid":"g7le-property-modal-header",style:_4,children:[i.jsx("span",{"data-testid":"g7le-property-modal-title",style:{fontSize:14,fontWeight:700},children:T&&Ie==="settings"?o("layout_editor.property_modal.settings_title",{name:Xe}):o("layout_editor.property_modal.title",{name:Xe})}),i.jsx("button",{type:"button","data-testid":"g7le-property-modal-close","aria-label":"close",onClick:s,style:x4,children:"✕"})]}),ze&&i.jsx("div",{"data-testid":"g7le-property-modal-advanced-badge",style:w4,children:o("layout_editor.property_modal.advanced_badge")}),_&&i.jsx("div",{"data-testid":"g7le-property-modal-branch-badge",style:k4,children:o("layout_editor.property_modal.branch_badge",{device:_})}),i.jsx("div",{style:S4,role:"tablist",children:Se.map(ve=>i.jsx("button",{type:"button",role:"tab","aria-selected":Ie===ve,"data-testid":`g7le-property-tab-${ve}`,"data-active":Ie===ve?"true":"false",onClick:()=>Ve(ve),style:{...C4,color:Ie===ve?"#2563eb":"#64748b",borderBottomColor:Ie===ve?"#2563eb":"transparent"},children:Je[ve]},ve))}),i.jsxs("div",{style:$4,"data-testid":"g7le-property-modal-body",children:[Be&&!$&&i.jsx("div",{"data-testid":"g7le-property-modal-no-editable",style:kg,children:o("layout_editor.property_modal.no_editable_props")}),$&&i.jsx(y4,{injectedProps:x,t:o,onSaveInjectedProps:y}),Ie==="settings"&&N&&i.jsx(RA,{spec:N,node:e,t:o,onPatchProp:Ne}),Ie==="props"&&i.jsxs("div",{"data-testid":"g7le-property-props-tab",style:{display:"flex",flexDirection:"column"},children:[V&&i.jsx(eT,{node:e,candidates:f??[],t:o,onPatchNode:r}),Y&&i.jsx(I6,{node:e,dataProps:F,candidates:f??[],t:o,onPatchNode:r}),X&&i.jsx(X6,{node:e,candidates:f??[],t:o,onPatchNode:r,templateIdentifier:h}),L&&A&&i.jsx(A,{node:e,params:P,spec:t,manifest:n,t:o,onPatchNode:r,templateIdentifier:h,candidates:f}),M.map(ve=>i.jsx(vi,{controlKey:`core-${ve}`,control:ja[ve],node:e,t:o,onPatch:r,scope:jt,bindingCandidates:f},`core-${ve}`)),z.map(ve=>{const qe=Ct(t,ve);return qe?i.jsx(vi,{controlKey:ve,control:qe,node:e,t:o,onPatch:r,scope:jt,bindingCandidates:f},ve):null}),i.jsx(QT,{node:e,onPatchNode:r,t:o,scopeIdCandidates:w,usedScopeIds:k})]}),Ie==="style"&&i.jsxs("div",{"data-testid":"g7le-property-style-tab",style:{display:"flex",flexDirection:"column"},children:[i.jsx("div",{style:wg,children:i.jsx(ug,{scope:g,onChange:C,node:e,t:o,onClearScope:S})}),fe!==null&&i.jsx(IT,{node:e,spec:t,capability:E,t:o,onPatchNode:r,liveElement:b,scope:g}),ie.map(ve=>{const qe=Ct(t,ve);return qe?i.jsx(vi,{controlKey:ve,control:qe,node:e,t:o,onPatch:r,scope:g},ve):null})]}),Ie==="action"&&i.jsx(S6,{node:e,spec:t,capability:E,t:o,onPatchNode:r,pageCandidates:d,dataSourceCandidates:c,stateKeyCandidates:p,bindingCandidates:f}),Ie==="visibility"&&i.jsxs("div",{"data-testid":"g7le-property-visibility-tab",style:{display:"flex",flexDirection:"column"},children:[i.jsx("div",{style:wg,children:i.jsx(ug,{scope:g,onChange:C,node:e,t:o,showColorScheme:!1})}),i.jsx(Ou,{node:e,spec:t,t:o,onPatchNode:r,dataSourceCandidates:c,stateKeyCandidates:p,scope:g})]}),Ie==="translation"&&(h?i.jsx(Rd,{customKey:Qd(e),templateIdentifier:h,t:o,paramLabels:Wv(e),onRemoveParam:ve=>{const qe=typeof e.text=="string"?e.text:"";r({...e,text:xo(qe,ve)});const We=Qd(e);h&&We&&Ar(h,We,ve)}}):i.jsx("div",{"data-testid":"g7le-property-translation-deferred",style:kg,children:o("layout_editor.translation.not_a_key")})),Ie==="advanced"&&i.jsx(f6,{node:e,advanced:oe,t:o,onPatch:r,permissionCandidates:l})]}),i.jsxs("div",{style:E4,children:[i.jsx("span",{"data-testid":"g7le-property-modal-node-id",style:{fontSize:11,color:"#94a3b8"},children:typeof e.id=="string"||typeof e.id=="number"?`ID: ${e.id}`:""}),i.jsxs("div",{style:{display:"flex",gap:8},children:[i.jsx("button",{type:"button","data-testid":"g7le-property-modal-delete",onClick:a,style:I4,children:o("layout_editor.property_modal.delete_element")}),i.jsx("button",{type:"button","data-testid":"g7le-property-modal-done",onClick:s,style:A4,children:o("layout_editor.property_modal.close")})]})]})]})}const v4={display:"flex",flexDirection:"column",width:420,maxWidth:"92vw"},_4={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:"1px solid #e2e8f0",cursor:"move",userSelect:"none"},x4={border:"none",background:"transparent",fontSize:14,cursor:"pointer",color:"#64748b"},w4={margin:"8px 16px 0",padding:"6px 10px",fontSize:11,background:"#fef3c7",color:"#92400e",borderRadius:6},k4={margin:"8px 16px 0",padding:"6px 10px",fontSize:11,background:"#dbeafe",color:"#1e40af",borderRadius:6},S4={display:"flex",gap:2,padding:"0 12px",borderBottom:"1px solid #e2e8f0",overflowX:"auto"},C4={padding:"8px 10px",fontSize:12,border:"none",borderBottom:"2px solid transparent",background:"transparent",cursor:"pointer",whiteSpace:"nowrap"},$4={padding:16,overflowY:"auto",maxHeight:"60vh"},wg={position:"sticky",top:-16,zIndex:2,background:"#fff",margin:"-16px -16px 0",padding:"6px 16px 0"},kg={fontSize:12,color:"#94a3b8",padding:"16px 0",textAlign:"center"},E4={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderTop:"1px solid #e2e8f0"},I4={padding:"6px 12px",fontSize:12,border:"1px solid #fecaca",borderRadius:6,background:"#fff",color:"#dc2626",cursor:"pointer"},A4={padding:"6px 12px",fontSize:12,border:"none",borderRadius:6,background:"#2563eb",color:"#fff",cursor:"pointer"},Fa="g7le:component-target-picked",Ka="g7le:component-target-pick-request";let T4=1;function D4({value:e,onChange:t,t:n,control:o}){const r=vo(),s=e==null?"":String(e),a=o?.allowManualInput!==!1,l=u.useCallback(()=>{if(typeof window>"u")return;const d=`pick-${T4++}`,p=r.stack[r.stack.length-1]?.id;p&&r.minimize(p,n("layout_editor.target_picker.minimized_hint"));const f=b=>{const g=b.detail;g?.requestId===d&&(window.removeEventListener(Fa,f),p&&r.restore(p),!g.cancelled&&typeof g.id=="string"&&t(g.id))};window.addEventListener(Fa,f),window.dispatchEvent(new CustomEvent(Ka,{detail:{requestId:d}}))},[r,t,n]);return i.jsx("div",{className:"g7le-component-target-picker","data-testid":"g7le-component-target-picker",children:i.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[a?i.jsx("input",{type:"text",className:"g7le-widget g7le-widget--text","data-testid":"g7le-component-target-input",value:s,placeholder:n("layout_editor.target_picker.id_placeholder"),onChange:d=>t(d.target.value===""?void 0:d.target.value),style:{flex:1,minWidth:0,padding:"6px 8px",border:"1px solid #cbd5e1",borderRadius:6,fontSize:13}}):i.jsx("span",{"data-testid":"g7le-component-target-value",style:{flex:1,minWidth:0},children:s||n("layout_editor.target_picker.none")}),i.jsxs("button",{type:"button","data-testid":"g7le-component-target-pick",onClick:l,style:{display:"flex",alignItems:"center",gap:4,padding:"6px 10px",background:"#1e293b",color:"#fff",border:"none",borderRadius:6,cursor:"pointer",fontSize:13,whiteSpace:"nowrap"},children:[i.jsx("span",{"aria-hidden":"true",children:"🎯"}),n("layout_editor.target_picker.select_area")]})]})})}async function z4(e,t,n,o,r=fetch){const s=`/api/admin/templates/${encodeURIComponent(e)}/layout-extensions/${t}`;let a;try{a=await r(s,{headers:Me(),credentials:"same-origin"})}catch(y){return{kind:"error",message:y instanceof Error?y.message:String(y)}}if(a.status===404)return{kind:"not_found"};if(!a.ok)return{kind:"error",message:`HTTP ${a.status}`};const l=await a.json().catch(()=>null),d=(l&&(l.data||l))??{};let c={};const p=d.content;if(typeof p=="string")try{c=JSON.parse(p)}catch{return{kind:"error",message:"invalid extension content"}}else p&&typeof p=="object"&&(c=p);const f=typeof d.lock_version=="number"?d.lock_version:0,b=Array.isArray(c.injections)?[...c.injections]:[],g=b.findIndex(y=>y&&y.position==="inject_props"&&y.target_id===n);if(g<0)return{kind:"injection_not_found"};b[g]={...b[g],props:o};const m={...c,injections:b};let h;try{h=await r(s,{method:"PUT",headers:Me({"Content-Type":"application/json"}),credentials:"same-origin",body:JSON.stringify({content:m,expected_lock_version:f})})}catch(y){return{kind:"error",message:y instanceof Error?y.message:String(y)}}const v=await h.json().catch(()=>null);return h.ok?{kind:"success",newLockVersion:typeof v?.data?.lock_version=="number"?v.data.lock_version:f+1}:h.status===409?{kind:"conflict",currentVersion:v?.current_version??-1,yourVersion:v?.your_version??f}:{kind:"error",message:v?.message??`HTTP ${h.status}`}}const Sg=new Map;function Va(e,t){Sg.set(e,t)}function N4(e){return e?Sg.get(e)??null:null}const Cg="g7le.clipboard";function $g(){try{return typeof window>"u"||!window.sessionStorage?null:window.sessionStorage}catch{return null}}function M4(e){const t=JSON.parse(JSON.stringify(e)),n=o=>{for(const r of Object.keys(o))r.startsWith("__")&&delete o[r];Array.isArray(o.children)&&o.children.forEach(n)};return n(t),t}function Eg(e,t=0){const n=$g();if(!n)return!1;try{const o={node:M4(e),copiedAt:t};return n.setItem(Cg,JSON.stringify(o)),!0}catch{return!1}}function L4(){const e=$g();if(!e)return null;try{const t=e.getItem(Cg);if(!t)return null;const n=JSON.parse(t);return!n||typeof n.node!="object"||n.node===null?null:JSON.parse(JSON.stringify(n.node))}catch{return null}}const tr={nw:{width:-1,height:-1},n:{width:0,height:-1},ne:{width:1,height:-1},e:{width:1,height:0},se:{width:1,height:1},s:{width:0,height:1},sw:{width:-1,height:1},w:{width:-1,height:0}};function Ua(e){if(typeof e=="number")return e;if(typeof e=="string"){const t=e.match(/^(-?\d+(?:\.\d+)?)px$/);if(t)return Number(t[1])}return null}function P4(e,t){const n=Array.isArray(e.options)?e.options:[],o=Array.isArray(e.scale)?e.scale:[],r=n.length>0?n.map(l=>l.value):o;if(r.length===0)return;let s=r[0],a=1/0;return r.forEach((l,d)=>{const c=Ua(l)??d*40,p=Math.abs(c-t);p{if(!t)return;const m=tr[b];if(m.width!==0&&!n||m.height!==0&&!o)return;const h=t.props?.style??{},v=s?.()??null,y=Ua(h.width)??(v?Math.round(v.width):0),_=Ua(h.height)??(v?Math.round(v.height):0);p.current={handle:b,startX:g.clientX,startY:g.clientY,startW:y,startH:_,node:t};const w=m.width!==0&&m.height!==0?"both":m.width!==0?"width":"height";d?.(w);let k=null;const x=C=>{const S=p.current;if(!S)return;const D=r||1,E=(C.clientX-S.startX)/D*tr[S.handle].width,I=(C.clientY-S.startY)/D*tr[S.handle].height;let N=S.node;if(tr[S.handle].width!==0&&n){const T=Ig(n,S.startW+E);N=yn(N,n,T)}if(tr[S.handle].height!==0&&o){const T=Ig(o,S.startH+I);N=yn(N,o,T)}k=N,a(N,w)},$=()=>{p.current=null,d?.(null),window.removeEventListener("pointermove",x),window.removeEventListener("pointerup",$),k&&l?.(k,w)};window.addEventListener("pointermove",x),window.addEventListener("pointerup",$)},[t,n,o,r,a,l,d]);return{enabledAxes:c,onHandlePointerDown:f}}const Ag=320,Tg=1920,W4=1024;function qa(e){return Number.isFinite(e)?Math.round(Math.max(Ag,Math.min(Tg,e))):W4}function Ga(e={}){const{state:t,dispatch:n}=Qe(),{previewDevice:o,previewZoom:r,previewCustomWidth:s,previewColorScheme:a}=t,l=o==="custom"?qa(s):WT(o),d=u.useMemo(()=>{const g=e.availableWidth??l,m=l*r;return r>=1||m<=g?r:Math.min(r,g/l)},[l,r,e.availableWidth]),c=u.useCallback(g=>{n({type:"SET_PREVIEW_DEVICE",device:g})},[n]),p=u.useCallback(g=>{const m=Math.max(.5,Math.min(1,g));n({type:"SET_PREVIEW_ZOOM",zoom:m})},[n]),f=u.useCallback(g=>{n({type:"SET_PREVIEW_CUSTOM_WIDTH",width:qa(g)})},[n]),b=u.useCallback(g=>{n({type:"SET_PREVIEW_COLOR_SCHEME",scheme:g})},[n]);return{device:o,deviceWidth:l,zoom:r,scale:d,customWidth:qa(s),setDevice:c,setZoom:p,setCustomWidth:f,colorScheme:a,setColorScheme:b}}const ki="g7le-dnd-handle-";function j4(e){if(typeof e!="string"||!e.startsWith(ki))return null;const t=e.slice(ki.length);return t.length>0?t:null}function H4(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["\\\]]/g,"\\$&")}function F4(e,t,n,o){const r=o?.handleFallback??!1;if(e instanceof HTMLElement){const s=e.closest("[data-editor-path]");if(s)return s;const a=e.closest('[data-testid^="g7le-"]');if(a&&!(a.getAttribute("data-testid")??"").startsWith(ki))return null;if(r){const l=e.closest(`[data-testid^="${ki}"]`);if(l&&t){const d=j4(l.getAttribute("data-testid"));if(d){const c=t.querySelector(`[data-editor-path="${H4(d)}"]`);if(c)return c}}}}if(r&&n&&typeof document<"u"&&typeof document.elementsFromPoint=="function")for(const s of document.elementsFromPoint(n.x,n.y)){const a=s.closest?.("[data-editor-path]");if(a)return a}return null}function K4(e,t,n){if(typeof e=="string"&&e.trim().length>0)return{color:e};const o=typeof n?.color=="string"&&n.color.length>0,r=typeof t=="string"&&t.trim().length>0;return o||r?{}:{color:"#0f172a"}}const V4="#ffffff",U4="#0f172a";function q4(e){const t=e.trim(),n=t.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i);if(n)return[Number(n[1]),Number(n[2]),Number(n[3])];const o=t.replace(/^#/,"");return/^[0-9a-f]{3}$/i.test(o)?[parseInt(o[0]+o[0],16),parseInt(o[1]+o[1],16),parseInt(o[2]+o[2],16)]:/^[0-9a-f]{6}$/i.test(o)?[parseInt(o.slice(0,2),16),parseInt(o.slice(2,4),16),parseInt(o.slice(4,6),16)]:null}function G4(e){if(!e||/transparent/i.test(e))return!1;const t=e.trim().match(/^oklch\(\s*([\d.]+)(%?)/i);if(t)return(t[2]==="%"?Number(t[1])/100:Number(t[1]))>=.62;const n=q4(e);if(!n)return!1;const[o,r,s]=n;return .299*o+.587*r+.114*s>=180}function Y4(e,t,n){const o=typeof n?.color=="string"?n.color:null;return G4(e??o??t)?U4:V4}function X4({box:e,initialValue:t,isCustomKey:n,t:o,onCommit:r,onCancel:s,mirrorClassName:a,mirrorStyle:l,nodeEffectiveColor:d,onOpenTranslations:c}){const p=u.useRef(null),f=u.useRef(!1),[b,g]=u.useState(t.trim().length>0),[m,h]=u.useState(null);u.useEffect(()=>{const k=p.current;if(k){k.textContent=t,k.focus();try{const x=window.document.createRange();x.selectNodeContents(k);const $=window.getSelection();$?.removeAllRanges(),$?.addRange(x)}catch{}f.current=!1}},[t]),u.useEffect(()=>{const k=p.current;if(!k||typeof window.getComputedStyle!="function"){h(null);return}try{h(window.getComputedStyle(k).color||null)}catch{h(null)}},[a,l]);const v=()=>(p.current?.textContent??"").trim(),y=()=>{f.current||(f.current=!0,r(v()))},_=()=>{f.current||(f.current=!0,s())},w=k=>{k.key==="Enter"&&!k.shiftKey?(k.preventDefault(),y()):k.key==="Escape"&&(k.preventDefault(),_())};return i.jsxs("div",{className:"g7le-inline-text-editor","data-testid":"g7le-inline-text-editor","data-custom-key":n?"true":"false",style:{position:"absolute",left:e.left,top:e.top,minWidth:Math.max(e.width,60),minHeight:e.height,pointerEvents:"auto",zIndex:1e4},children:[i.jsx("div",{ref:p,role:"textbox","aria-label":o("layout_editor.inline_edit.aria_label"),"aria-multiline":"false","data-testid":"g7le-inline-text-editable",className:a,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!1,onInput:()=>g(v().length>0),onKeyDown:w,onBlur:y,style:{outline:"2px solid #2563eb",outlineOffset:1,borderRadius:3,background:Y4(d,m,l),padding:"2px 4px",minHeight:e.height,whiteSpace:"pre-wrap",wordBreak:"break-word",boxShadow:"0 2px 8px rgba(37, 99, 235, 0.25)",...l??{},...K4(d,a,l)}}),i.jsxs("div",{className:"g7le-inline-text-editor__hint","data-testid":"g7le-inline-text-editor-hint",style:{marginTop:2,display:"inline-flex",alignItems:"center",gap:4,whiteSpace:"nowrap"},children:[c?i.jsxs("button",{type:"button","data-testid":"g7le-inline-text-editor-open-translations",onMouseDown:k=>k.preventDefault(),onClick:k=>{k.preventDefault(),k.stopPropagation(),c()},title:o("layout_editor.inline_edit.open_translations"),style:{padding:"2px 8px",fontSize:11,background:n?"#eff6ff":"#f0fdf4",color:n?"#1d4ed8":"#15803d",border:`1px solid ${n?"#bfdbfe":"#bbf7d0"}`,borderRadius:4,display:"inline-flex",alignItems:"center",gap:4,cursor:"pointer",whiteSpace:"nowrap"},children:[i.jsx("span",{"aria-hidden":"true",children:"🌐"}),i.jsx("span",{children:o(n?"layout_editor.inline_edit.existing_key_hint":"layout_editor.inline_edit.new_key_hint")}),i.jsxs("span",{"aria-hidden":"true",style:{opacity:.7},children:["· ",o("layout_editor.inline_edit.open_translations")," ›"]})]}):i.jsx("span",{style:{padding:"2px 6px",fontSize:11,background:n?"#eff6ff":"#f0fdf4",color:n?"#1d4ed8":"#15803d",border:`1px solid ${n?"#bfdbfe":"#bbf7d0"}`,borderRadius:4,display:"inline-flex",alignItems:"center",gap:4,whiteSpace:"nowrap"},children:n?i.jsxs(i.Fragment,{children:["⌐ ",o("layout_editor.inline_edit.existing_key_hint")]}):i.jsxs(i.Fragment,{children:["✎ ",o("layout_editor.inline_edit.new_key_hint")]})}),!b&&i.jsx("span",{"data-testid":"g7le-inline-text-editor-empty-warn",style:{color:"#b91c1c",marginLeft:4},children:o("layout_editor.inline_edit.empty_warning")})]})]})}function J4({box:e,node:t,customKey:n,initialChipValue:o,chipParamLabels:r,onKeyify:s,templateIdentifier:a,locale:l,t:d,candidates:c,onInsertBinding:p,onRemoveBinding:f,onCommit:b,onCancel:g}){const[m,h]=u.useState(null),v=u.useRef(""),[y,_]=u.useState(!1),w=u.useRef(!1),k=u.useRef(null),x=Kt(),$=u.useRef(()=>{}),[C,S]=u.useState(null),[D,E]=u.useState(!1),I=u.useRef(n??null);u.useEffect(()=>{n&&I.current!==n&&(I.current=n)},[n]);const N=u.useMemo(()=>{if(!n&&r)return r;const P={},A=vt(typeof t.text=="string"?t.text:"");for(const L of A?.params??[])P[L.name]=Ut(L.expression);return P},[t.text,n,r]);u.useEffect(()=>{let P=!1;if(!n){const A=o??"";return v.current=A,h(A),()=>{P=!0}}return(async()=>{const A=It(n,l);if(A!==void 0){v.current=A,h(A);return}const L=await fn(a,n);if(P)return;const F=L?.values?.[l]??"";v.current=F,h(F)})(),()=>{P=!0}},[a,n,l,o]);const T=async()=>{if(w.current)return;w.current=!0;const P=m??"";if(P===v.current){b();return}_(!0);let A=I.current;if(!A){if(!s){_(!1),w.current=!1;return}if(A=await s(P),_(!1),!A){w.current=!1;return}I.current=A,b();return}const L=await Eo(a,A,l,P);if(_(!1),L.kind==="error"){w.current=!1;return}x?.markDirty?.(),b()},B=()=>{w.current||(w.current=!0,g())},M=P=>{S(P)},O=async P=>{if(!(C===null||!p||D)){E(!0);try{const A=I.current;A&&m!==null&&m!==v.current&&(await Eo(a,A,l,m),v.current=m);const L=await p(C,P);L!==null&&(h(L),v.current=L,x?.markDirty?.())}finally{E(!1),S(null)}}},z=async P=>{if(!(!f||D)){E(!0);try{const A=I.current;A&&m!==null&&m!==v.current&&(await Eo(a,A,l,m),v.current=m);const L=await f(P);L!==null&&(h(L),v.current=L,x?.markDirty?.())}finally{E(!1)}}},H=P=>{P.key==="Enter"&&!P.shiftKey?(P.preventDefault(),T()):P.key==="Escape"&&(P.preventDefault(),B())};return $.current=()=>{T()},u.useEffect(()=>{const P=L=>{const F=k.current;if(!F)return;const Y=L.target;if(Y&&F.contains(Y))return;const V=Y;V&&V.closest&&V.closest('[data-testid="g7le-inline-toolbar"], .g7le-inline-toolbar')||$.current()},A=k.current?.ownerDocument??document;return A.addEventListener("pointerdown",P,!0),()=>A.removeEventListener("pointerdown",P,!0)},[]),i.jsxs("div",{ref:k,className:"g7le-inline-param-chip-editor","data-testid":"g7le-inline-param-chip-editor",onKeyDown:H,style:{position:"absolute",left:e.left,top:e.top,minWidth:Math.max(e.width,120),pointerEvents:"auto",zIndex:1e4,background:"#fff",border:"2px solid #2563eb",borderRadius:4,boxShadow:"0 2px 8px rgba(37,99,235,0.25)",padding:4},children:[m===null?i.jsx("div",{"data-testid":"g7le-inline-param-chip-loading",style:{fontSize:12,color:"#94a3b8",padding:4},children:d("layout_editor.translation.loading")}):i.jsx(Sr,{value:m,onChange:h,t:d,paramLabels:N,testIdSuffix:"inline",onRequestInsert:p?M:void 0,onRemoveChip:f?P=>void z(P):void 0}),C!==null&&p&&i.jsx("div",{"data-testid":"g7le-inline-param-chip-insert-picker",style:{marginTop:4},children:i.jsx($t,{candidates:c??[],t:d,onSelect:P=>void O(P),testIdSuffix:"inline-insert",defaultOpen:!0,floating:!1})}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:4},children:[i.jsx("button",{type:"button","data-testid":"g7le-inline-param-chip-save",disabled:y,onMouseDown:P=>P.preventDefault(),onClick:()=>void T(),style:{fontSize:11,border:"none",borderRadius:6,background:"#2563eb",color:"#fff",padding:"4px 12px",cursor:"pointer"},children:d(y?"layout_editor.translation.saving":"layout_editor.translation.save")}),i.jsx("span",{style:{fontSize:10,color:"#94a3b8"},children:d("layout_editor.translation.placeholder_locked")})]})]})}const Z4=["fontWeight","fontBold","fontStyle","fontItalic","textDecoration","textUnderline","textAlign","fontSize","textColor"],Q4={fontWeight:"B",fontBold:"B",fontStyle:"I",fontItalic:"I",textDecoration:"U",textUnderline:"U",textAlign:"≡",fontSize:"T",textColor:"A"},R4=[["fontWeight","fontBold"],["fontItalic","fontStyle"],["textUnderline","textDecoration"]];function Dg({node:e,spec:t,t:n,onApplyControl:o,box:r,scope:s=jt}){const a=typeof e.name=="string"?e.name:"",l=Ui(t,a),d=Array.isArray(l?.styleControls)?l.styleControls:[];let c=Z4.filter(p=>d.includes(p)&&Ct(t,p)!==null);for(const p of R4){const f=p.filter(b=>c.includes(b));if(f.length>1){const b=f[0];c=c.filter(g=>!p.includes(g)||g===b)}}return c.length===0?null:i.jsx("div",{className:"g7le-inline-toolbar","data-testid":"g7le-inline-toolbar",role:"toolbar","aria-label":n("layout_editor.inline_edit.toolbar_label"),style:{position:"absolute",left:r.left,top:r.top-40,display:"inline-flex",gap:2,padding:4,background:"#0f172a",borderRadius:8,boxShadow:"0 4px 12px rgba(15, 23, 42, 0.35)",pointerEvents:"auto",zIndex:10001},children:c.map(p=>i.jsx(tD,{controlKey:p,node:e,spec:t,t:n,scope:s,onApplyControl:o},p))})}const eD={fontWeight:"bold",fontBold:"bold",fontStyle:"italic",fontItalic:"italic",textDecoration:"underline",textUnderline:"underline"};function zg(e,t){const n=r=>(r.split(/[-\s]/).pop()??r)===t||r===t;return e.find(r=>{const s=typeof r.value=="string"?r.value:"",a=Array.isArray(r.apply?.tokens)?r.apply.tokens:[];return n(s)||a.some(n)})?.value}function tD({controlKey:e,node:t,spec:n,t:o,scope:r,onApplyControl:s}){const[a,l]=u.useState(!1),d=Ct(n,e);if(!d)return null;const c=d.options,p=Array.isArray(c),f=Lo(t,d,r),b=eD[e],g=b&&Array.isArray(c)?zg(c,b):void 0,m=!b,h=g!==void 0?f.value===g:p&&f.matched&&f.value!==void 0&&f.value!=="",v=o(`layout_editor.inline_edit.format.${e}`),y=x=>typeof x.label=="string"?x.label.startsWith("$t:")?o(x.label.slice(3)):x.label:String(x.value??""),_=()=>{s(e,x=>{const $=Lo(x,d,r),C=Array.isArray(c)?zg(c,b):void 0,S=C!==void 0&&$.value===C?void 0:C;return yn(x,d,S,r)})},w=x=>{s(e,$=>{const S=Lo($,d,r).value===x?void 0:x;return yn($,d,S,r)}),l(!1)},k=x=>{if(x.preventDefault(),x.stopPropagation(),!m&&Array.isArray(c)){_();return}l($=>!$)};return i.jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[i.jsxs("button",{type:"button","data-testid":`g7le-inline-format-${e}`,"data-active":h?"true":"false","aria-label":v,"aria-pressed":p?h:void 0,title:v,onMouseDown:x=>x.preventDefault(),onClick:k,style:{display:"inline-flex",alignItems:"center",gap:5,height:28,padding:"0 9px",fontSize:12,border:"none",borderRadius:5,cursor:"pointer",background:h?"#2563eb":"transparent",color:"#ffffff",whiteSpace:"nowrap"},children:[i.jsx("span",{"aria-hidden":"true",style:{fontWeight:e==="fontWeight"||e==="fontBold"?700:600,fontStyle:e==="fontStyle"||e==="fontItalic"?"italic":"normal",textDecoration:e==="textDecoration"||e==="textUnderline"?"underline":"none"},children:Q4[e]}),i.jsx("span",{children:v}),m&&i.jsx("span",{"aria-hidden":"true",style:{fontSize:9,opacity:.8},children:"▾"})]}),m&&a&&i.jsx("div",{"data-testid":`g7le-inline-popover-${e}`,role:"listbox",onMouseDown:x=>x.preventDefault(),style:{position:"absolute",top:32,left:0,minWidth:140,maxHeight:240,overflowY:"auto",background:"#0f172a",border:"1px solid #334155",borderRadius:8,boxShadow:"0 8px 24px rgba(15,23,42,0.45)",padding:4,zIndex:10002},children:Array.isArray(c)&&c.length>0?c.map((x,$)=>{const C=f.value===x.value;return i.jsxs("button",{type:"button",role:"option","aria-selected":C,"data-testid":`g7le-inline-option-${e}-${String(x.value??$)}`,onMouseDown:S=>S.preventDefault(),onClick:S=>{S.preventDefault(),S.stopPropagation(),w(x.value)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 8px",fontSize:12,textAlign:"left",border:"none",borderRadius:5,cursor:"pointer",background:C?"#2563eb":"transparent",color:"#ffffff"},children:[typeof x.swatch=="string"&&i.jsx("span",{"aria-hidden":"true",style:{width:14,height:14,borderRadius:3,background:x.swatch,border:"1px solid rgba(255,255,255,0.3)"}}),i.jsx("span",{children:y(x)}),C&&i.jsx("span",{"aria-hidden":"true",style:{marginLeft:"auto"},children:"✓"})]},String(x.value??$))}):i.jsx(nD,{testid:`g7le-inline-freeinput-${e}`,placeholder:o(`layout_editor.inline_edit.prompt.${e}`),initial:typeof f.value=="string"?f.value:"",onSubmit:x=>{s(e,$=>yn($,d,x,r)),l(!1)}})})]})}function nD({testid:e,placeholder:t,initial:n,onSubmit:o}){const[r,s]=u.useState(n);return i.jsx("input",{type:"text","data-testid":e,value:r,placeholder:t,autoFocus:!0,onMouseDown:a=>a.stopPropagation(),onChange:a=>s(a.currentTarget.value),onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),o(r.trim()))},style:{width:130,padding:"6px 8px",fontSize:12,border:"1px solid #334155",borderRadius:5,background:"#1e293b",color:"#ffffff"}})}function oD(e){const{frameEl:t,manifest:n,nesting:o,componentPalette:r,spec:s=null,permissionCandidates:a,resolveRouteMatch:l,onNavigateToDestination:d,onSessionAddedPathsChange:c,onEditProps:p}=e,{state:f,dispatch:b}=Qe(),{t:g}=et(),m=Ga(),h=u.useCallback((W,J)=>{const R=window.G7Core;if(R&&typeof R.t=="function"){const le=R.t(W,J);if(le&&le!==W&&!le.startsWith("$t:"))return le}return g(W,J)},[g]),v=Kt(),y=Z7(50),_=vo(),w=u.useRef([]),k=u.useMemo(()=>v?.document?.raw?.components??[],[v?.document?.raw?.components]),x=u.useMemo(()=>k.length===0?null:{children:k},[k]),$=u.useMemo(()=>{if(f.editMode!=="extension")return;const W=/^__extension__\/(\d+)/.exec(f.selectedRoute?.path??"");return W?Number(W[1]):void 0},[f.editMode,f.selectedRoute?.path]),C=u.useMemo(()=>{if(f.editMode==="iteration_item"){const W=v?.document?.iterationContext?.sourceIndexPath;return Array.isArray(W)&&W.length>0?W:null}if(f.editMode==="modal"){const W=v?.document?.modalContext?.editIndexPath;return Array.isArray(W)&&W.length>0?W:null}return null},[f.editMode,v?.document?.iterationContext?.sourceIndexPath,v?.document?.modalContext?.editIndexPath]),S=F7({rootNode:x,editMode:f.editMode,currentExtensionId:$,editableRootPath:C,pathParser:Re,resolveRouteMatch:l}),[D,E]=u.useState(null),[I,N]=u.useState(null),[T,B]=u.useState(null),M=u.useRef(null);M.current=T;const[O,z]=u.useState(null),H=u.useRef(null),P=u.useRef(null);P.current=S.selectedPath;const A=dm(),[L,F]=u.useState(null),Y=u.useCallback(W=>{if(!t)return;const J=Re(W);if(!J)return;const R={children:Ne.current.components},le=Pe(R,J),me=Jt(le,f.editMode,$,Dn(R,J));if(!Zt(me))return;const xe=A.classify(le);if(!xe.editable){Et({op:"inline_edit_blocked_binding",sourceState:xe.sourceState,componentPath:at(J),timestamp:Date.now()});return}const Te=ho(t,W);if(!Te)return;const we=le?.props??{},_e=Mg(t,W);F({path:J,domPath:W,box:Te,initialValue:xe.displayValue,isCustomKey:xe.sourceState==="custom_key",isParamKey:xe.isParamKey===!0,customKey:xe.customKey,chipValue:xe.chipValue,chipParamLabels:xe.chipParamLabels,mirrorClassName:typeof we.className=="string"?we.className:void 0,mirrorStyle:we.style??void 0,nodeEffectiveColor:_e}),Et({op:"inline_edit_enter",sourceState:xe.sourceState,componentPath:at(J),timestamp:Date.now()})},[t,A,f.editMode,$]),V=u.useCallback(()=>{if(!t){E(null),N(null);return}N(ho(t,S.selectedPath)),E(ho(t,S.hoverPath))},[t,S.selectedPath,S.hoverPath,k]);u.useEffect(()=>{if(V(),typeof window<"u"&&typeof window.requestAnimationFrame=="function"){const W=window.requestAnimationFrame(()=>V());return()=>window.cancelAnimationFrame(W)}},[V]),u.useEffect(()=>{if(t)return Wp(V,t)},[t,V]);const X=u.useCallback((W,J)=>{if(typeof window>"u")return;window.dispatchEvent(new CustomEvent(Fa,{detail:J===null?{requestId:W,cancelled:!0}:{requestId:W,id:J}})),B(null),z(null);const R=H.current;R?S.handleSelect("",{dataset:{editorPath:R}}):S.clearSelection(),H.current=null},[S]);u.useEffect(()=>{if(typeof window>"u")return;const W=J=>{const R=J.detail;if(typeof R?.requestId!="string")return;const le=M.current;le&&le!==R.requestId&&X(le,null),H.current=P.current,B(R.requestId)};return window.addEventListener(Ka,W),()=>window.removeEventListener(Ka,W)},[X]),u.useEffect(()=>{if(!T)return;const W=J=>{J.key==="Escape"&&(J.preventDefault(),X(T,null))};return window.addEventListener("keydown",W,!0),()=>window.removeEventListener("keydown",W,!0)},[T,X]),u.useEffect(()=>{if(!t)return;const W=f.editMode==="iteration_item"||f.editMode==="modal",J=(_e,Ee)=>F4(_e,t,Ee?{x:Ee.clientX,y:Ee.clientY}:void 0,{handleFallback:W}),R=_e=>{const Ee=_e.dataset.editorPath??"",He=Ee?Re(Ee):null,Nt={children:Ne.current.components},gt=He?Pe(Nt,He):null,Mt=gt&&typeof gt.props?.id=="string"?gt.props.id:typeof gt?.id=="string"?gt.id:"";return Mt.startsWith("auto_")?"":Mt},le=_e=>{const Ee=J(_e.target,_e);if(!Ee)return;const He=M.current;if(He){_e.preventDefault(),_e.stopPropagation();const Nt=R(Ee);Nt&&X(He,Nt);return}_e.preventDefault(),_e.stopPropagation(),S.handleSelect(Ee.dataset.editorId??"",{currentTarget:Ee,dataset:Ee.dataset})},me=_e=>{const Ee=J(_e.target,_e);if(M.current){if(!Ee){z(null);return}const He=ho(t,Ee.dataset.editorPath??null);if(!He){z(null);return}z({box:He,hasId:R(Ee)!==""});return}if(!Ee){S.handleHover(null,{});return}S.handleHover(Ee.dataset.editorId??"",{currentTarget:Ee,dataset:Ee.dataset})},xe=()=>{if(M.current){z(null);return}S.handleHover(null,{})},Te=_e=>{const Ee=J(_e.target,_e);if(!Ee)return;const He=Ee.dataset.editorPath??"";He&&(_e.preventDefault(),_e.stopPropagation(),Y(He))},we=t.parentElement??t;return we.addEventListener("click",le,!0),we.addEventListener("mousemove",me,!0),we.addEventListener("mouseleave",xe,!0),we.addEventListener("dblclick",Te,!0),()=>{we.removeEventListener("click",le,!0),we.removeEventListener("mousemove",me,!0),we.removeEventListener("mouseleave",xe,!0),we.removeEventListener("dblclick",Te,!0)}},[t,S,Y,f.editMode,X]);const Z=u.useMemo(()=>{const W=S.selectedPath;if(!W)return null;const J=W.match(/^(.*)\.children\.\d+$/);return J?J[1]:null},[S.selectedPath]),ie=u.useCallback(()=>{Z&&S.handleSelect("",{dataset:{editorPath:Z}})},[Z,S]),oe=u.useMemo(()=>!t||!S.selectedPath?null:t.querySelector(`[data-editor-path="${dn(S.selectedPath)}"]`),[t,S.selectedPath]),G=u.useMemo(()=>S.selectedPath?Re(S.selectedPath):null,[S.selectedPath]),ee=u.useMemo(()=>{if(!G)return null;const W=G.find(tt);if(!W)return null;const{i18nKey:J,raw:R}=jC(W.responsive);return J?g(J):g("layout_editor.overlay.branch_custom",{range:R})},[G,g]),fe=u.useMemo(()=>S.selectedPath?S.selectedIsIteration&&S.selectedIterationSourcePath?S.selectedIterationSourcePath:S.selectedPath:null,[S.selectedPath,S.selectedIsIteration,S.selectedIterationSourcePath]),K=u.useMemo(()=>fe?Re(fe):null,[fe]),te=u.useMemo(()=>!t||!fe?null:t.querySelector(`[data-editor-path="${dn(fe)}"]`),[t,fe]),ye=u.useMemo(()=>{if(te?.parentElement)return te.parentElement;if(!t||!fe)return null;const W=fe.match(/^(.*)\.children\.\d+$/);return W?t.querySelector(`[data-editor-path="${dn(W[1])}"]`):null},[te,t,fe]),Se=u.useMemo(()=>{const W=S.selectedNode;return W&&(typeof W.name=="string"?W.name:typeof W.type=="string"?W.type:"")||null},[S.selectedNode]),De=u.useMemo(()=>{if(S.selectedLockKind!=="extension")return null;const W=S.selectedNode?.__source;if(!W||W.kind!=="extension")return null;const J=W.extensionName?.trim(),R=W.extensionIdentifier?.trim();return J&&R?`${J} (${R})`:J||R||W.extensionSourceType||null},[S.selectedLockKind,S.selectedNode]),Ie=Y7({parentEl:ye,selectedPath:K,selectedEl:te}),Ve=u.useMemo(()=>!t||!fe||fe===S.selectedPath?I:ho(t,fe),[t,fe,I,S.selectedPath,k]),ze=u.useRef(null),Be=u.useCallback(()=>{const W=ze.current;W&&(_.close(W),ze.current=null)},[_]),Xe=u.useRef(()=>{}),Ne=u.useRef({manifest:n,nesting:o,componentPalette:r,components:k});Ne.current={manifest:n,nesting:o,componentPalette:r,components:k};const Je=u.useCallback(W=>{const J=W.insertion?.parentPath??[],R=W.insertion?.index??0,le=Ne.current,me=Ng(le.components,J);Be();const xe=_.open({ariaLabel:h("layout_editor.palette.title"),width:880,maxHeightRatio:.82,content:u.createElement(Wf,{manifest:le.manifest,nesting:le.nesting,componentPalette:le.componentPalette??null,targetParentPath:J,targetContainerName:me,onInsert:(Te,we,_e)=>{Xe.current(Te,we,_e)},insertionIndex:R,onClose:()=>Be(),editorTemplateId:f.templateIdentifier,editorLocale:f.locale}),onClose:()=>{ze.current=null}});ze.current=xe},[_,Be]),ve=u.useMemo(()=>{if(!f.isPaletteOpen)return null;if(!G)return{parentPath:[],index:k.length};if(S.selectedLockKind!=="none"){const le=K;return!le||le.length===0?{parentPath:[],index:k.length}:{parentPath:le.slice(0,-1),index:(le[le.length-1]??0)+1}}const J=S.selectedNode,R=Array.isArray(J?.children)?J.children.length:0;return JI(J?.name,R,G,o,k.length)},[f.isPaletteOpen,G,K,S.selectedLockKind,S.selectedNode,k.length,o]),qe=u.useCallback(()=>{b({type:"SET_PALETTE_OPEN",open:!1})},[b]),We=u.useRef(null);u.useEffect(()=>{if(!f.isPaletteOpen){const me=We.current;me&&(_.close(me),We.current=null);return}if(!ve||We.current)return;const W=ve,J=Ne.current,R=Ng(J.components,W.parentPath),le=_.open({ariaLabel:h("layout_editor.palette.title"),width:880,maxHeightRatio:.82,content:u.createElement(Wf,{manifest:J.manifest,nesting:J.nesting,componentPalette:J.componentPalette??null,targetParentPath:W.parentPath,targetContainerName:R,onInsert:(me,xe,Te)=>{Xe.current(me,xe,Te),qe()},insertionIndex:W.index,onClose:()=>qe(),editorTemplateId:f.templateIdentifier,editorLocale:f.locale}),onClose:()=>{We.current=null,b({type:"SET_PALETTE_OPEN",open:!1})}});We.current=le},[f.isPaletteOpen,ve,_,qe,b]);const ce=u.useRef({layoutName:null,pushed:!1});u.useEffect(()=>{const W=v?.document?.layoutName??null;if(!W){ce.current={layoutName:null,pushed:!1};return}ce.current.layoutName!==W&&(y.clear(),y.push({actionKind:"inline_text_edit",label:"baseline",snapshot:k}),ce.current={layoutName:W,pushed:!0})},[v?.document?.layoutName,k,y]);const q=u.useRef(0);u.useEffect(()=>{const W=v?.saveSuccessCounter??0;W!==q.current&&(q.current=W,W!==0&&(y.clear(),y.push({actionKind:"inline_text_edit",label:"save_baseline",snapshot:k}),w.current=[],c?.([])))},[v?.saveSuccessCounter,k,y,c]);const se=u.useRef(0);u.useEffect(()=>{const W=v?.reloadCounter??0;W!==se.current&&(se.current=W,W!==0&&(ce.current={layoutName:null,pushed:!1},w.current=[],c?.([])))},[v?.reloadCounter,c]);const ae=u.useCallback((W,J,R)=>{if(!v)return;let le=[];v.patchLayout(we=>{const _e={children:we},Ee=Ya(_e,J),He=R<0?Array.isArray(Ee?.children)?Ee.children.length:0:R,gt=is(_e,J,He,W).children??[];return le=gt,gt}),y.push({actionKind:"insert",label:`insert ${W.name??W.type??""}`,snapshot:le});const me=Ya({children:le},J),xe=R<0?Array.isArray(me?.children)?me.children.length-1:0:R,Te=at([...J,xe]);if(w.current=[...w.current,Te],c?.(w.current),t){const we=`[data-editor-path="${dn(Te)}"]`,_e=()=>{const Ee=t.querySelector(we);Ee&&typeof Ee.scrollIntoView=="function"&&Ee.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(()=>window.requestAnimationFrame(_e)):setTimeout(_e,32)}},[v,y,c,t]);Xe.current=ae;const be=u.useCallback(()=>{if(!v||!S.selectedNode||!G||!Zt(S.selectedLockKind))return;const W=as(S.selectedNode);let J=[];v.patchLayout(R=>{const le={children:R},me=G.slice(0,-1),xe=G[G.length-1]??0,we=is(le,me,xe+1,W).children??[];return J=we,we}),y.push({actionKind:"insert",label:"duplicate",snapshot:J})},[v,S.selectedNode,S.selectedLockKind,G,y]),Ce=u.useCallback(()=>{if(!v||!G||!Zt(S.selectedLockKind))return;let W=[];v.patchLayout(J=>{const me=ss({children:J},G).children??[];return W=me,me}),y.push({actionKind:"remove",label:"remove",snapshot:W}),S.clearSelection()},[v,G,y,S]),$e=u.useMemo(()=>{if(!S.selectedNode||!G||G.some(tt))return null;const W=S.selectedNode;if(!Array.isArray(W.children))return null;const J=WC(f.previewDevice,W,f.previewCustomWidth);return{mode:J.mode,key:J.key,sourceKey:J.sourceKey}},[S.selectedNode,G,f.previewDevice,f.previewCustomWidth]),U=u.useCallback(()=>{if(!v||!G||$e?.mode!=="separate")return;const W=$e.key,J=$e.sourceKey;let R=[];v.patchLayout(le=>(R=Rb({children:le},G,W,J).children??[],R)),y.push({actionKind:"insert",label:"separate_branch",snapshot:R})},[v,G,$e,y]),ue=u.useCallback(()=>{if(!v||!G||$e?.mode!=="merge")return;const W=$e.key;let J=[];v.patchLayout(R=>(J=em({children:R},G,W).children??[],J)),y.push({actionKind:"remove",label:"merge_branch",snapshot:J})},[v,G,$e,y]),ge=u.useCallback(W=>{switch(W){case"mobile":return g("layout_editor.context_menu.device_mobile");case"portable":return g("layout_editor.context_menu.device_portable");case"tablet":return g("layout_editor.context_menu.device_tablet");case"desktop":return g("layout_editor.context_menu.device_desktop");default:return g("layout_editor.context_menu.device_custom",{range:W})}},[g]),ke=u.useMemo(()=>{if(!$e)return null;const W=ge($e.key);return{separate:g("layout_editor.context_menu.separate_branch_device",{device:W}),merge:g("layout_editor.context_menu.merge_branch_device",{device:W})}},[$e,g,ge]),he=u.useMemo(()=>{if(!S.selectedNode||!G)return[];if(G.some(tt))return[];const W=Qr(f.previewDevice,S.selectedNode,f.previewCustomWidth);return BT(S.selectedNode,W).map(J=>({key:J,label:ge(J)}))},[S.selectedNode,G,f.previewDevice,f.previewCustomWidth,ge]),j=u.useCallback(W=>{if(W==="desktop"||W==="tablet"||W==="mobile"||W==="portable"){m.setDevice(W);return}m.setDevice(W)},[m]),ne=u.useCallback(()=>{S.selectedNode&&Eg(S.selectedNode)},[S.selectedNode]),pe=u.useCallback(()=>{S.selectedNode&&Zt(S.selectedLockKind)&&(Eg(S.selectedNode),Ce())},[S.selectedNode,S.selectedLockKind,Ce]),Q=u.useCallback(()=>{if(!v)return;const W=L4();if(!W)return;const J=as(W);if(G&&G.length>0){const R=G.slice(0,-1),le=(G[G.length-1]??0)+1;ae(J,R,le)}else ae(J,[],k.length)},[v,G,ae,k.length]),de=u.useCallback((W,J)=>{y.push({actionKind:"move",label:J,snapshot:W})},[y]),Ae=u.useCallback(()=>{if(S.selectedNavAffordance==="route_in_tree"&&S.selectedNavTargetPath){if(d){d(S.selectedNavTargetPath);return}b({type:"SELECT_ROUTE",route:{path:S.selectedNavTargetPath,layoutName:null}})}},[S.selectedNavAffordance,S.selectedNavTargetPath,d,b]),dt=u.useCallback(()=>{const W=Zb(S.selectedBaseLayout,f.selectedRoute?.layoutName);W&&b({type:"ENTER_BASE_EDIT",layoutName:W})},[S.selectedBaseLayout,f.selectedRoute?.layoutName,b]),pt=u.useCallback(()=>{const W=S.selectedNode?.__source?.extensionId;W!=null&&b({type:"ENTER_EXTENSION_EDIT",extensionId:String(W)})},[S.selectedNode,b]),ot=u.useCallback(()=>{const W=S.selectedIterationSourcePath;W&&b({type:"ENTER_ITERATION_ITEM_EDIT",sourcePath:W})},[S.selectedIterationSourcePath,b]),Le=u.useRef(null),je=u.useRef(null),Ze=u.useRef(null),Tt=u.useRef({colorScheme:"base",breakpoint:"base"}),Dt=Le.current!==null?_.stack.some(W=>W.id===Le.current):!1,zt=u.useMemo(()=>Hd(f.routeTree,h),[f.routeTree,h]),kn=u.useMemo(()=>Fd(v?.document?.raw),[v?.document?.raw]),Sn=u.useMemo(()=>Kd(s),[s?.states]),en=u.useMemo(()=>{const W=v?.document?.raw,J=Hf(W?.components),R=W?.initIsolated,le=R&&typeof R=="object"&&!Array.isArray(R)?Object.keys(R):[];return FA(J,le)},[v?.document?.raw]),Kn=u.useMemo(()=>{const W=v?.document?.raw;return Hf(W?.components).map(J=>J.scopeId).filter(J=>typeof J=="string"&&J.length>0)},[v?.document?.raw]),cn=jd({raw:v?.document?.raw,spec:s}),Pi=u.useCallback((W,J)=>{if(!v)return;const R={children:Ne.current.components},le=Pe(R,W);if(!le)return;Tt.current={colorScheme:f.previewColorScheme==="dark"?"dark":"base",breakpoint:Qr(f.previewDevice,le,f.previewCustomWidth)};const me=t?.getBoundingClientRect(),xe=I&&me?{left:me.left+I.left,top:me.top+I.top,width:I.width,height:I.height}:void 0,Te=oe,we=W.find(tt),_e=we?ge(we.responsive):null,Ee=W.filter(Cn=>typeof Cn=="number"),He=Mb({children:Ne.current.components},Ee,Lb(cn)),Nt=He.length>0?[...Yi({iterationVars:He}),...cn]:cn,gt=(Cn,QM)=>u.createElement(m4,{key:`pem-${at(je.current??[])}`,node:Cn,spec:s,manifest:Ne.current.manifest,t:h,permissionCandidates:a,pageCandidates:zt,dataSourceCandidates:kn,stateKeyCandidates:Sn,bindingCandidates:Nt,liveElement:Te,templateIdentifier:f.templateIdentifier,initialTab:QM,branchLabel:_e,isolatedScopeIdCandidates:en,usedScopeIds:Kn,onSaveInjectedProps:async(mt,$n)=>{const Oi=typeof Cn.id=="string"?Cn.id:"",Vn=await z4(f.templateIdentifier,mt,Oi,$n);if(st({op:"save",layoutName:`extension:${mt}`,editMode:f.editMode,saveTarget:"layout_extension",endpoint:`/api/admin/templates/${f.templateIdentifier}/layout-extensions/${mt}`,isDirty:!0,timestamp:Date.now()}),Vn.kind!=="success")throw new Error(Vn.kind==="conflict"?h("layout_editor.save.conflict"):Vn.kind==="injection_not_found"?"injection not found":Vn.kind==="not_found"?"extension not found":Vn.message??"save failed")},scope:Tt.current,onScopeChange:mt=>{Tt.current=mt;const $n=Le.current;$n&&_.open({id:$n,ariaLabel:h("layout_editor.property_modal.title"),width:420,draggable:!0,avoidRect:xe,content:gt(Cn),onClose:()=>{Le.current=null,je.current=null}})},onPatchNode:mt=>{let $n=[];v.patchLayout(Vn=>($n=Bt({children:Vn},W,()=>mt).children??[],$n)),y.push({actionKind:"inline_text_edit",label:"edit_props",snapshot:$n}),pr({source:"style_control",componentPath:at(W),componentName:typeof mt.name=="string"?mt.name:null,patchKey:null,timestamp:Date.now()});const Oi=Le.current;Oi&&_.open({id:Oi,ariaLabel:h("layout_editor.property_modal.title"),width:420,draggable:!0,avoidRect:xe,content:gt(mt),onClose:()=>{Le.current=null,je.current=null}})},onDelete:()=>{const mt=Le.current;mt&&_.close(mt),Ce()},onClose:()=>{const mt=Le.current;mt&&_.close(mt)}});je.current=W;const Mt=_.open({ariaLabel:h("layout_editor.property_modal.title"),width:420,draggable:!0,avoidRect:xe,content:gt(le,J),onClose:()=>{Le.current=null,je.current=null,Ze.current=null}});Le.current=Mt,Ze.current=Cn=>{_.open({id:Mt,ariaLabel:h("layout_editor.property_modal.title"),width:420,draggable:!0,avoidRect:xe,content:gt(Cn),onClose:()=>{Le.current=null,je.current=null,Ze.current=null}})}},[v,s,h,a,zt,kn,Sn,cn,oe,y,_,Ce,t,I,f.previewColorScheme,f.previewDevice,f.previewCustomWidth,ge]);u.useEffect(()=>{const W=Ze.current,J=je.current;if(!W||!J)return;const R={children:Ne.current.components},le=Pe(R,J);le?W(le):Le.current&&_.close(Le.current)},[k]);const LM=()=>{if(!Dt)return null;const J={position:"absolute",background:"rgba(15, 23, 42, 0.45)",pointerEvents:"auto",zIndex:t2},R=we=>{we.preventDefault(),we.stopPropagation()};if(!I)return i.jsx("div",{"data-testid":"g7le-edit-lock-full",onClick:R,onMouseMove:R,style:{...J,inset:0}});const{left:le,top:me,width:xe,height:Te}=I;return i.jsxs("div",{"data-testid":"g7le-edit-lock",style:{position:"absolute",inset:0,pointerEvents:"none"},children:[i.jsx("div",{"data-testid":"g7le-edit-lock-top",onClick:R,onMouseMove:R,style:{...J,left:0,top:0,right:0,height:Math.max(0,me)}}),i.jsx("div",{"data-testid":"g7le-edit-lock-bottom",onClick:R,onMouseMove:R,style:{...J,left:0,top:me+Te,right:0,bottom:0}}),i.jsx("div",{"data-testid":"g7le-edit-lock-left",onClick:R,onMouseMove:R,style:{...J,left:0,top:me,width:Math.max(0,le),height:Te}}),i.jsx("div",{"data-testid":"g7le-edit-lock-right",onClick:R,onMouseMove:R,style:{...J,left:le+xe,top:me,right:0,height:Te}})]})},$l=u.useCallback(()=>{if(G&&Np(S.selectedLockKind)){if(p&&S.selectedPath){p(S.selectedPath);return}Pi(G)}},[G,S.selectedPath,S.selectedLockKind,p,Pi]),{scale:El}=m,Il=typeof S.selectedNode?.name=="string"?S.selectedNode.name:"",ly=s?.componentCapabilities?.[Il]??null,dy=Array.isArray(ly?.styleControls)?ly.styleControls:[],PM=dy.includes("width")?Ct(s,"width"):null,OM=dy.includes("height")?Ct(s,"height"):null,BM=u.useCallback((W,J)=>{if(!v||!G)return;let R=[];v.patchLayout(le=>(R=Bt({children:le},G,()=>W).children??[],R)),pr({source:"resize",componentPath:at(G),componentName:Il||null,patchKey:J==="height"?"height":"width",resizeAxis:J,timestamp:Date.now()})},[v,G,Il]),WM=u.useCallback((W,J)=>{if(!v||!G)return;let R=[];v.patchLayout(le=>(R=Bt({children:le},G,()=>W).children??[],R)),y.push({actionKind:"inline_text_edit",label:`resize ${J}`,snapshot:R})},[v,G,y]),jM=u.useCallback(()=>{if(!oe)return null;const W=oe.getBoundingClientRect(),J=El||1;return{width:W.width/J,height:W.height/J}},[oe,El]),ur=B4({node:S.selectedNode,widthControl:PM,heightControl:OM,scale:El,measureStartSize:jM,onResize:BM,onResizeEnd:WM}),HM=u.useCallback((W,J)=>{ur.onHandlePointerDown(W,J)},[ur]),Al=u.useCallback(()=>{const W=y.undo();!W||!v||v.setLayoutComponents(W.snapshot)},[y,v]),Tl=u.useCallback(()=>{const W=y.redo();!W||!v||v.setLayoutComponents(W.snapshot)},[y,v]);R7({onUndo:Al,onRedo:Tl});const FM=u.useMemo(()=>({copy:ne,cut:pe,paste:Q,delete:Ce,openProps:$l,selectParent:Z?ie:void 0,deselect:S.clearSelection}),[ne,pe,Q,Ce,$l,Z,ie,S.clearSelection]);gp({handlers:FM,hasSelection:!!S.selectedPath}),u.useEffect(()=>(window.__g7LayoutEditorHasSelection=!!S.selectedPath,()=>{try{delete window.__g7LayoutEditorHasSelection}catch{}}),[S.selectedPath]),u.useEffect(()=>(window.__g7LayoutEditorHistory={undo:Al,redo:Tl,canUndo:y.canUndo,canRedo:y.canRedo},()=>{try{delete window.__g7LayoutEditorHistory}catch{}}),[Al,Tl,y.canUndo,y.canRedo]);const KM=u.useCallback(W=>{const J=L;F(null),J&&(async()=>{if((await A.commit(J.path,W)).kind==="created"&&v){const le=v.document?.raw?.components??[];y.push({actionKind:"inline_text_edit",label:"inline_create_key",snapshot:le})}})()},[L,A,v,y]),cy=u.useCallback(()=>{const W=L;F(null),A.trackCancel(W?.path??null)},[L,A]),VM=u.useCallback(()=>{F(null)},[]),UM=u.useCallback(async W=>{const J=L;if(!J)return null;const R=await A.keyifyChipValue(J.path,W);if(R.kind!=="created"||!R.translationKey)return null;const le=v?.document?.raw?.components??[];return y.push({actionKind:"inline_text_edit",label:"inline_keyify_chip",snapshot:le}),R.translationKey},[L,A,v,y]),qM=u.useCallback(()=>{const W=L;W&&(F(null),S.handleSelect("",{dataset:{editorPath:W.domPath}}),Pi(W.path,"translation"))},[L,S,Pi]),wt=u.useMemo(()=>{if(!L)return null;const W=v?.document?.raw?.components??k;return Pe({children:W},L.path)},[L,v?.document,k]),GM=u.useCallback(async(W,J)=>{const R=L;if(!v||!R)return null;const le=typeof wt?.text=="string"?wt.text:"";let me;if(R.isParamKey)me=await Ir(f.templateIdentifier,f.locale,le,W,J.sourceId,J.path,"scalar");else{const He=Nt=>Nt.replace(/\$t:[a-zA-Z0-9._-]+/g,gt=>{const Mt=h(gt.slice(3));return Mt&&Mt!==gt.slice(3)&&!Mt.startsWith("$t:")?Mt:""}).replace(/\s+/g," ").trim();me=await hs(f.templateIdentifier,f.selectedRoute?.layoutName??null,f.locale,le,W,J.sourceId,J.path,"scalar",He,h)}if(me.kind==="error")return null;const xe=R.path;let Te=[];v.patchLayout(He=>(Te=Bt({children:He},xe,Mt=>({...Mt,text:me.text})).children??[],Te)),y.push({actionKind:"inline_text_edit",label:"inline_insert_binding",snapshot:Te});const we=me.kind==="ok"&&"key"in me?me.key:void 0;!R.isParamKey&&we&&F(He=>He&&He.path===xe?{...He,isParamKey:!0,customKey:we,chipValue:void 0,chipParamLabels:void 0}:He);try{window.dispatchEvent(new CustomEvent(kt,{detail:{templateIdentifier:f.templateIdentifier,locale:f.locale}}))}catch{}const _e=vt(me.text),Ee=R.customKey??_e?.key??"";return Ee?It(Ee,f.locale)??null:null},[v,L,wt,f.templateIdentifier,f.locale,f.selectedRoute,y,h]),YM=u.useCallback(async W=>{const J=L;if(!v||!J)return null;const R=typeof wt?.text=="string"?wt.text:"",le=vt(R),me=J.customKey??le?.key??null,xe=xo(R,W),Te=J.path;let we=[];return v.patchLayout(_e=>(we=Bt({children:_e},Te,Nt=>({...Nt,text:xe})).children??[],we)),y.push({actionKind:"inline_text_edit",label:"inline_remove_binding",snapshot:we}),me&&await Ar(f.templateIdentifier,me,W,f.locale),me?It(me,f.locale)??null:null},[v,L,wt,f.templateIdentifier,f.locale,y]),[Dl,uy]=u.useState({}),XM=["fontSize","color","fontStyle","textDecoration","textAlign","letterSpacing","lineHeight","fontFamily"];u.useEffect(()=>{if(!L||!t||typeof MutationObserver>"u"){uy({});return}const W=`[data-editor-path="${dn(L.domPath)}"]`,J=()=>{const me=t.querySelector(W);if(!me)return;const xe={};for(const we of XM){const _e=me.style.getPropertyValue(we.replace(/([A-Z])/g,"-$1").toLowerCase());_e&&(xe[we]=_e)}const Te=Mg(t,L.domPath)??void 0;uy({className:me.className,style:xe,effectiveColor:Te})};J();const R=t.querySelector(W);if(!R)return;const le=new MutationObserver(J);return le.observe(R,{attributes:!0,attributeFilter:["class","style"]}),le.observe(t,{childList:!0,subtree:!0}),()=>le.disconnect()},[L?.path?at(L.path):null,t]);const py=u.useCallback((W,J)=>{if(!v||!L)return;const R=L.path;let le=[],me=null;v.patchLayout(xe=>(le=Bt({children:xe},R,_e=>{const Ee=J(_e);return me=typeof Ee.name=="string"?Ee.name:null,Ee}).children??[],le)),y.push({actionKind:"inline_text_edit",label:`inline_format ${W}`,snapshot:le}),pr({source:"style_control",componentPath:at(R),componentName:me,patchKey:W,timestamp:Date.now()})},[v,L,y]),ft=u.useMemo(()=>{const W=S.selectedPath;if(!W||!x)return null;const J=[];let R=W;for(;R;){J.push(R);const le=R.match(/^(.*)\.children\.\d+$/);R=le?le[1]:null}for(const le of J){const me=Re(le);if(!me)continue;const xe=Pe(x,me),Te=typeof xe?.name=="string"?xe.name:null;if(!Te)continue;const we=Ui(s,Te),_e=we?.canvasOverlay?.kind;if(typeof _e!="string"||!_e||!xe)continue;const Ee=we.canvasOverlay.params&&typeof we.canvasOverlay.params=="object"?we.canvasOverlay.params:void 0,He=le===W?null:W.slice(le.length+1);return{kind:_e,params:Ee,tablePath:le,tableNode:xe,selectedCellRel:He}}return null},[S.selectedPath,x,s]),mo=ft?N4(ft.kind):null,fy=u.useMemo(()=>!mo||!t||!ft?null:ho(t,ft.tablePath),[mo,t,ft,I,k]),JM=u.useMemo(()=>{if(!mo||!t||!ft)return[];const W=ft.tablePath,J=dn(W),R=[];return t.querySelectorAll(`[data-editor-path^="${J}.children."]`).forEach(xe=>{const Te=xe.dataset.editorPath??"";if(!Te.startsWith(W+"."))return;const we=Te.slice(W.length+1),_e=co(xe,t);_e&&R.push({path:we,top:_e.top,left:_e.left,width:_e.width,height:_e.height})}),t.querySelectorAll(`[data-editor-item-path^="${J}."]`).forEach(xe=>{const Te=xe.dataset.editorItemPath??"";if(!Te.startsWith(W+"."))return;const we=Te.slice(W.length+1),_e=co(xe,t);_e&&R.push({path:we,top:_e.top,left:_e.left,width:_e.width,height:_e.height})}),R},[mo,t,ft,I,k]),ZM=u.useCallback(W=>{const J=ft?Re(ft.tablePath):null;if(!v||!J)return;let R=[];v.patchLayout(le=>(R=Bt({children:le},J,()=>W).children??[],R)),y.push({actionKind:"inline_text_edit",label:"inplace_edit",snapshot:R}),pr({source:"style_control",componentPath:ft?.tablePath??"",componentName:typeof W.name=="string"?W.name:null,patchKey:"canvas_inplace",timestamp:Date.now()})},[v,G,y]);return t?i.jsxs("div",{className:"g7le-editor-canvas-overlay","data-testid":"g7le-editor-canvas-overlay",style:{position:"absolute",inset:0,pointerEvents:"none"},children:[!T&&LM(),T&&i.jsxs("div",{"data-testid":"g7le-canvas-pick-banner",style:{position:"absolute",top:8,left:"50%",transform:"translateX(-50%)",zIndex:9999,display:"flex",alignItems:"center",gap:12,padding:"8px 14px",background:"#1e293b",color:"#fff",borderRadius:8,fontSize:13,boxShadow:"0 4px 12px rgba(0,0,0,0.25)",pointerEvents:"auto"},children:[i.jsxs("span",{children:["🎯 ",h("layout_editor.target_picker.canvas_pick_hint")]}),i.jsx("button",{type:"button","data-testid":"g7le-canvas-pick-cancel",onClick:()=>X(T,null),style:{border:"1px solid #475569",borderRadius:6,background:"transparent",color:"#cbd5e1",cursor:"pointer",fontSize:12,padding:"3px 10px"},children:h("layout_editor.target_picker.cancel")})]}),f.editMode!=="route"&&i.jsx(hA,{frameEl:t,components:k,editMode:f.editMode,currentExtensionId:$,editableRootPath:C}),L&&((L.isParamKey&&L.customKey||L.chipValue)&&wt?i.jsxs(i.Fragment,{children:[wt&&i.jsx(Dg,{node:wt,spec:s,t:h,onApplyControl:py,box:L.box,scope:{colorScheme:f.previewColorScheme==="dark"?"dark":"base",breakpoint:Qr(f.previewDevice,wt,f.previewCustomWidth)}}),i.jsx(J4,{box:L.box,node:wt,customKey:L.customKey??null,initialChipValue:L.chipValue,chipParamLabels:L.chipParamLabels,onKeyify:UM,templateIdentifier:f.templateIdentifier,locale:f.locale,t:h,candidates:cn,onInsertBinding:GM,onRemoveBinding:YM,onCommit:VM,onCancel:cy})]}):i.jsxs(i.Fragment,{children:[wt&&i.jsx(Dg,{node:wt,spec:s,t:h,onApplyControl:py,box:L.box,scope:{colorScheme:f.previewColorScheme==="dark"?"dark":"base",breakpoint:wt?Qr(f.previewDevice,wt,f.previewCustomWidth):"base"}}),i.jsx(X4,{box:L.box,initialValue:L.initialValue,isCustomKey:L.isCustomKey,t:h,onCommit:KM,onCancel:cy,mirrorClassName:Dl.className,mirrorStyle:Dl.style,nodeEffectiveColor:Dl.effectiveColor??L.nodeEffectiveColor,onOpenTranslations:qM})]})),!T&&i.jsx(a2,{hoverBox:D,selectedBox:I,lockKind:S.selectedLockKind,navAffordance:S.selectedNavAffordance,onEditProps:$l,onDuplicate:be,onDelete:Ce,onSeparateBranch:$e?.mode==="separate"?U:void 0,separateBranchLabel:ke?.separate,onMergeBranch:$e?.mode==="merge"?ue:void 0,mergeBranchLabel:ke?.merge,definedDeviceBranches:he,onJumpToDevice:he.length>0?j:void 0,onLinkEditDestination:Ae,onEditBase:dt,onEditExtension:pt,extensionLabel:De,baseLayoutLabel:S.selectedBaseLayout,dataSourceLabel:S.selectedDataSourceId,branchLabel:ee,onEditIteration:S.selectedIsIteration&&f.editMode!=="iteration_item"?ot:void 0,resizeEnabledAxes:ur.enabledAxes,onResizeHandlePointerDown:ur.enabledAxes.width||ur.enabledAxes.height?HM:void 0,selectedName:Se,onSelectParent:Z?ie:void 0}),T&&O&&i.jsx("div",{"data-testid":"g7le-canvas-pick-hover","data-pick-has-id":O.hasId?"true":"false",style:{position:"absolute",left:O.box.left,top:O.box.top,width:O.box.width,height:O.box.height,pointerEvents:"none",zIndex:9998,boxSizing:"border-box",border:O.hasId?"2px solid #2563eb":"2px dashed #94a3b8",background:O.hasId?"rgba(37,99,235,0.10)":"repeating-linear-gradient(45deg, rgba(148,163,184,0.18) 0, rgba(148,163,184,0.18) 6px, transparent 6px, transparent 12px)",cursor:O.hasId?"pointer":"not-allowed"},children:!O.hasId&&i.jsx("span",{"data-testid":"g7le-canvas-pick-hover-hint",style:{position:"absolute",top:0,left:0,transform:"translateY(-100%)",background:"#475569",color:"#fff",fontSize:11,lineHeight:1.4,padding:"2px 6px",borderRadius:4,whiteSpace:"nowrap"},children:h("layout_editor.target_picker.needs_id")})}),!T&&i.jsx(f2,{selectedBox:Ve,points:Ie.points,onAddRequest:Je}),mo&&ft&&fy&&S.selectedLockKind==="none"&&i.jsx(mo,{node:ft.tableNode,params:ft.params,nodeBox:fy,cellBoxes:JM,selectedCellPath:ft.selectedCellRel??void 0,colorScheme:f.previewColorScheme==="dark"?"dark":"light",t:h,onPatchNode:ZM,onInsertChild:ae,onRemoveChild:W=>{const J=Re(W);if(!v||!J)return;let R=[];v.patchLayout(le=>(R=ss({children:le},J).children??[],R)),y.push({actionKind:"remove",label:"inplace_remove",snapshot:R})},onRequestInlineEdit:W=>{ft&&Y(`${ft.tablePath}.${W}`)}}),v&&i.jsx(dA,{frameEl:t,nesting:o,editMode:f.editMode,currentExtensionId:$,editableRootPath:C,components:k,patchLayout:v.patchLayout,pushHistory:de,selectedPath:S.selectedPath,onSelectPath:W=>S.handleSelect("",{dataset:{editorPath:W}}),onMovePath:W=>S.handleSelect("",{dataset:{editorPath:W}}),onRequestInlineEdit:Y})]}):null}function Ng(e,t){if(t.length===0)return null;const o=Ya({children:e},t);return o&&typeof o.name=="string"?o.name:null}function Ya(e,t){return Pe(e,t)}function dn(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[^a-zA-Z0-9_\-.]/g,t=>`\\${t}`)}function Mg(e,t){if(!t)return null;const n=e.querySelector(`[data-editor-path="${dn(t)}"]`);if(!n||typeof window.getComputedStyle!="function")return null;let o=n;const r=n.ownerDocument.createTreeWalker(n,NodeFilter.SHOW_TEXT);let s=r.nextNode();for(;s;){if((s.textContent??"").trim().length>0){const a=s.parentElement;if(a&&n.contains(a)){o=a;break}}s=r.nextNode()}try{return window.getComputedStyle(o).color||null}catch{return null}}function ho(e,t){if(!t)return null;const n=e.querySelector(`[data-editor-path="${dn(t)}"]`);if(n){const c=co(n,e);return c&&uo(c,e)?c:null}const o=e.querySelectorAll(`[data-editor-path^="${dn(t)}.iteration."]`);let r=1/0,s=1/0,a=-1/0,l=-1/0,d=!1;return o.forEach(c=>{const p=c.dataset.editorPath??"";if(!new RegExp("\\.iteration\\.\\d+$").test(p))return;const f=co(c,e);f&&uo(f,e)&&(d=!0,r=Math.min(r,f.left),s=Math.min(s,f.top),a=Math.max(a,f.left+f.width),l=Math.max(l,f.top+f.height))}),d?{left:r,top:s,width:a-r,height:l-s,scale:1}:null}function rD({isEditMode:e,editorSpec:t,sampleOverride:n}){const o=t?.sampleData;return u.useMemo(()=>sv({spec:o,overrideSpec:n,onMatch:r=>{hy(r)}}),[e,o,n])}const iD=Lt().ComponentRegistry;function sD(e){return e.replace(/[\t\n\r]/g,"").replace(/\\/g,"/").replace(/^([a-z][a-z0-9+.\-]*:)?\/{2,}/i,"$1//")}function aD(e,t){try{const n=typeof window<"u"&&window.location?.protocol||"https:",o=t||(typeof window<"u"?window.location?.origin:void 0)||"https://localhost",r=e.startsWith("//")?`${n}${e}`:e,s=new URL(r,o);return s.protocol!=="http:"&&s.protocol!=="https:"?null:s.hostname.toLowerCase()}catch{return null}}function Xa(){const e=typeof window<"u"?window.G7Config?.trustedScriptHosts:void 0;return Array.isArray(e)?e.map(t=>String(t).toLowerCase()):[]}function Lg(e,t){if(typeof e!="string")return!1;const n=e.trim();if(n==="")return!1;const o=sD(n),r=o.startsWith("//"),s=/^[a-z][a-z0-9+.-]*:/i.test(o);if(!r&&!s&&o.startsWith("/"))return!0;const a=aD(o),l=t??Xa();return a!==null&&l.map(d=>String(d).toLowerCase()).includes(a)}function lD(e){return e.split(/[-_]/).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}async function dD(e){const t=typeof window<"u"?window.localStorage?.getItem("auth_token"):null,n={Accept:"application/json"};t&&(n.Authorization=`Bearer ${t}`);const o=await fetch(`/api/admin/templates/${encodeURIComponent(e)}/editor-assets`,{headers:n,credentials:"same-origin"});if(!o.ok){const s=await o.json().catch(()=>null);throw ei(o.status,s,"assets")}const r=await o.json();return r.data||r}async function cD(e){try{if(typeof fetch!="function")return 0;const t=await fetch(nn(`/api/templates/${encodeURIComponent(e)}/config`,"json"),{credentials:"same-origin",headers:{Accept:"application/json"}});if(!t.ok)return 0;const n=await t.json().catch(()=>null),o=n?.data?.cache_version??n?.cache_version;return typeof o=="number"&&o>0?o:0}catch{return 0}}function uD(e){return new Promise((t,n)=>{if(typeof document>"u"){n(new Error("document undefined"));return}if(!Lg(e,Xa())){n(new Error(`Blocked untrusted script src (same-origin path or declared trusted host required): ${e}`));return}if(document.querySelector(`script[data-g7le-asset="${e}"]`)){t();return}const r=document.createElement("script");r.src=e,r.async=!1,r.setAttribute("data-g7le-asset",e),r.addEventListener("load",()=>t()),r.addEventListener("error",()=>n(new Error(`script load failed: ${e}`))),document.head.appendChild(r)})}async function pD(e){if(typeof document>"u")return;const t=`[data-g7le-asset="${e}"]`;if(document.querySelector(`link${t}, style${t}`))return;if(e.includes("/api/admin/"))try{const r=typeof window<"u"?window.localStorage?.getItem("auth_token"):null,s={Accept:"text/css"};r&&(s.Authorization=`Bearer ${r}`);const a=await fetch(e,{headers:s,credentials:"same-origin"});if(a.ok){const l=await a.text(),d=document.createElement("style");d.textContent=l,d.setAttribute("data-g7le-asset",e),document.head.appendChild(d);return}}catch{}const o=document.createElement("link");o.rel="stylesheet",o.href=e,o.setAttribute("data-g7le-asset",e),document.head.appendChild(o)}function fD(e,t,n="user"){const[o,r]=u.useState({componentRegistry:null,translationEngine:null,isReady:!1,error:null});return u.useEffect(()=>{let s=!1;return(async()=>{r(a=>({...a,isReady:!1,error:null}));try{const a=await dD(e);if(s)return;for(const b of a.css??[])if(await pD(b),s)return;const l=lD(e);if(!(typeof window<"u"&&typeof window[l]=="object")){for(const b of a.js??[])if(await uD(b),s)return}const c=iD.createIsolatedInstance();if(await c.loadComponents(e,n),s)return;const p=await cD(e);if(s)return;const f=new Pt({defaultLocale:t});if(p>0&&f.setCacheVersion(p),await f.loadTranslations(e,t),s)return;md(f,e);try{const b=Pt.getInstance();p>b.getCacheVersion()&&b.setCacheVersion(p),await b.loadTranslations(e,t),md(b,e)}catch{}if(s)return;r({componentRegistry:c,translationEngine:f,isReady:!0,error:null})}catch(a){if(s)return;const l=Ep(a)?a:lo(a,"assets");r({componentRegistry:null,translationEngine:null,isReady:!1,error:l})}})(),()=>{s=!0}},[e,t,n]),o}const Pg=Lt().AuthManager;function gD(e){switch(e){case"unauthorized":return{icon:"🔒",tone:"blue",titleKey:"layout_editor.access_error.unauthorized.title",messageKey:"layout_editor.access_error.unauthorized.message",showRequiredPermissions:!0};case"forbidden":return{icon:"⛔",tone:"rose",titleKey:"layout_editor.access_error.forbidden.title",messageKey:"layout_editor.access_error.forbidden.message",showRequiredPermissions:!0};case"not_found":return{icon:"🗂️",tone:"slate",titleKey:"layout_editor.access_error.not_found.title",messageKey:"layout_editor.access_error.not_found.message",showRequiredPermissions:!1};case"server_error":return{icon:"🛠️",tone:"amber",titleKey:"layout_editor.access_error.server_error.title",messageKey:"layout_editor.access_error.server_error.message",showRequiredPermissions:!1};case"network":return{icon:"📡",tone:"amber",titleKey:"layout_editor.access_error.network.title",messageKey:"layout_editor.access_error.network.message",showRequiredPermissions:!1};default:return{icon:"⚠️",tone:"slate",titleKey:"layout_editor.access_error.unknown.title",messageKey:"layout_editor.access_error.unknown.message",showRequiredPermissions:!1}}}const hD={blue:{bg:"#eff6ff",border:"#bfdbfe",iconBg:"#dbeafe"},rose:{bg:"#fff1f2",border:"#fecdd3",iconBg:"#ffe4e6"},amber:{bg:"#fffbeb",border:"#fde68a",iconBg:"#fef3c7"},slate:{bg:"#f8fafc",border:"#e2e8f0",iconBg:"#f1f5f9"}};function yD({error:e}){return u.useEffect(()=>{if(e.kind!=="unauthorized"||typeof window>"u")return;const t=Pg.getInstance(),n=`${window.location.pathname}${window.location.search}`,o=t.getLoginRedirectUrl("admin",n,"session_expired"),r=window.setTimeout(()=>{window.location.href=o},600);return()=>window.clearTimeout(r)},[e.kind]),null}function Ja({error:e}){const{t}=et(),n=gD(e.kind),o=hD[n.tone],r=()=>{typeof window<"u"&&(window.location.href="/admin")},s=()=>{typeof window<"u"&&window.location.reload()},a=()=>{if(typeof window>"u")return;const l=Pg.getInstance(),d=`${window.location.pathname}${window.location.search}`;window.location.href=l.getLoginRedirectUrl("admin",d)};return i.jsxs("div",{className:"g7le-access-error","data-testid":"g7le-access-error","data-error-kind":e.kind,style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:24,background:"#f1f5f9"},children:[i.jsx(yD,{error:e}),i.jsxs("div",{style:{maxWidth:480,width:"100%",background:o.bg,border:`1px solid ${o.border}`,borderRadius:12,padding:"28px 32px",boxShadow:"0 2px 8px rgba(15, 23, 42, 0.05)",textAlign:"center"},children:[i.jsx("div",{style:{width:64,height:64,margin:"0 auto 16px",borderRadius:"50%",background:o.iconBg,display:"flex",alignItems:"center",justifyContent:"center",fontSize:32,lineHeight:1},"aria-hidden":"true",children:n.icon}),i.jsx("h2",{"data-testid":"g7le-access-error-title",style:{margin:"0 0 8px",fontSize:18,fontWeight:700,color:"#0f172a"},children:t(n.titleKey)}),i.jsx("p",{"data-testid":"g7le-access-error-message",style:{margin:"0 0 16px",fontSize:13,lineHeight:1.6,color:"#475569"},children:t(n.messageKey)}),n.showRequiredPermissions&&e.requiredPermissions&&i.jsxs("div",{"data-testid":"g7le-access-error-permissions",style:{display:"inline-flex",flexWrap:"wrap",gap:6,justifyContent:"center",padding:"8px 12px",marginBottom:16,background:"rgba(15, 23, 42, 0.04)",borderRadius:8,fontSize:12,color:"#475569"},children:[i.jsx("span",{style:{fontWeight:600},children:t("layout_editor.access_error.required_permission_label")}),e.requiredPermissions.split(/[,\s]+/).filter(Boolean).map(l=>i.jsx("code",{style:{padding:"2px 6px",background:"#fff",border:"1px solid #e2e8f0",borderRadius:4,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:11,color:"#1e293b"},children:l},l))]}),e.message&&i.jsxs("details",{"data-testid":"g7le-access-error-detail",style:{marginBottom:16,fontSize:11,color:"#94a3b8"},children:[i.jsx("summary",{style:{cursor:"pointer"},children:t("layout_editor.access_error.detail_summary")}),i.jsxs("pre",{style:{marginTop:8,padding:8,background:"#fff",border:"1px solid #e2e8f0",borderRadius:6,overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",textAlign:"left",fontSize:11,color:"#475569"},children:[e.status>0?`HTTP ${e.status} +`:"",e.message]})]}),i.jsxs("div",{style:{display:"flex",justifyContent:"center",gap:8,flexWrap:"wrap"},children:[e.kind==="unauthorized"&&i.jsx("button",{type:"button","data-testid":"g7le-access-error-action-signin",onClick:a,style:Za,children:t("layout_editor.access_error.action.sign_in")}),e.kind==="forbidden"&&i.jsx("button",{type:"button","data-testid":"g7le-access-error-action-home",onClick:r,style:Za,children:t("layout_editor.access_error.action.go_home")}),(e.kind==="not_found"||e.kind==="server_error"||e.kind==="network"||e.kind==="unknown")&&i.jsx("button",{type:"button","data-testid":"g7le-access-error-action-retry",onClick:s,style:Za,children:t("layout_editor.access_error.action.retry")}),e.kind!=="unauthorized"&&i.jsx("button",{type:"button","data-testid":"g7le-access-error-action-home-secondary",onClick:r,style:bD,children:t("layout_editor.access_error.action.go_admin_home")})]})]})]})}const Za={padding:"8px 16px",background:"#2563eb",color:"#fff",border:"1px solid #1d4ed8",borderRadius:6,fontSize:13,fontWeight:600,cursor:"pointer"},bD={padding:"8px 16px",background:"#fff",color:"#475569",border:"1px solid #cbd5e1",borderRadius:6,fontSize:13,fontWeight:500,cursor:"pointer"};function mD(e){const t=window;if(typeof t>"u")return{getSnapshot:()=>({globalState:{},localState:{}}),restore:()=>{}};const n=t.G7Core||{},o={templateApp:t.__templateApp,g7CoreState:n.state,g7CoreDispatch:n.dispatch,g7CoreData:n.data,g7CoreModal:n.modal,g7CoreToast:n.toast};let r={...e.initialGlobalState??{}};r._local||(r._local={});const s=[],a=()=>{const c={globalState:{...r},localState:{...r._local??{}}};for(const p of s)try{p(r)}catch{}e.onChange?.(c)},l={},d={getGlobalState:()=>r,setGlobalState:(c,p)=>{typeof c=="function"?r=c(r):r={...r,...c},a()},onGlobalStateChange:c=>(s.push(c),()=>{const p=s.indexOf(c);p>=0&&s.splice(p,1)}),get globalState(){return r},getActionDispatcher:()=>e.actionDispatcher,getDataSource:c=>l[c]??null,setDataSource:(c,p)=>{l[c]=p},refetchDataSource:async c=>null,updateDataSourceItem:(c,p,f)=>l[c]??null,getLocale:()=>e.locale,changeLocale:c=>{},getRouter:()=>({navigate:()=>{},replace:()=>{},push:()=>{}}),updateQueryParams:()=>{}};return t.__templateApp=d,n&&typeof n.dispatch=="function"&&(n.dispatch=(c,p)=>{try{return e.actionDispatcher.executeAction(c,p??{})}catch{return}}),n&&typeof n.modal=="object"&&n.modal!==null&&(n.modal={...n.modal,open:()=>{},close:()=>{},closeAll:()=>{}}),n&&typeof n.toast=="object"&&n.toast!==null&&(n.toast={...n.toast,push:()=>{},dismiss:()=>{}}),{getSnapshot:()=>({globalState:{...r},localState:{...r._local??{}}}),restore:()=>{t.__templateApp===d&&(t.__templateApp=o.templateApp),t.G7Core&&(o.g7CoreState!==void 0&&(t.G7Core.state=o.g7CoreState),o.g7CoreDispatch!==void 0&&(t.G7Core.dispatch=o.g7CoreDispatch),o.g7CoreData!==void 0&&(t.G7Core.data=o.g7CoreData),o.g7CoreModal!==void 0&&(t.G7Core.modal=o.g7CoreModal),o.g7CoreToast!==void 0&&(t.G7Core.toast=o.g7CoreToast)),s.length=0}}}const vD=new Set(["id","userId","postId","orderId","productId","categoryId","commentId","noticeId","inquiryId","addressId","wishlistId","notificationId","roleId","menuId"]);function _D(e){if(!e)return{};const t={},n=/:([a-zA-Z_][a-zA-Z0-9_]*)/g;let o;for(;(o=n.exec(e))!==null;){const r=o[1];t[r]=xD(r)}return t}function xD(e){return vD.has(e)||/Id$|_id$/.test(e)?"1":"sample"}const wD=_o("LayoutEditor");function nr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Si(e){if(Array.isArray(e))return e.map(t=>Si(t));if(nr(e)){const t={};for(const[n,o]of Object.entries(e))t[n]=Si(o);return t}return e}function Og(e,t="",n=new Set){for(const[o,r]of Object.entries(e)){const s=t?`${t}.${o}`:o;nr(r)?Og(r,s,n):n.add(s)}return n}function Bg(e,t,n,o,r,s=""){for(const[a,l]of Object.entries(t)){const d=s?`${s}.${a}`:a;if(n.has(d)){r(`[LayoutEditor] sampleGlobal key conflict: extension '${o}' override of core key '${d}' ignored`);continue}const c=e[a];nr(l)&&nr(c)?Bg(c,l,n,o,r,d):e[a]=Si(l)}}function Qa(e){const t=e.warn??(r=>wD.warn(r)),n=Si(e.coreSeed??{});e.isGuestOnly&&"currentUser"in n&&delete n.currentUser;const o=Og(n);for(const r of e.sources)nr(r.sampleGlobal)&&Bg(n,r.sampleGlobal,o,r.id,t);return e.isGuestOnly&&"currentUser"in n&&delete n.currentUser,n}function kD(e){const t={};if(!e||typeof e!="object"||Array.isArray(e))return t;for(const[n,o]of Object.entries(e))n.startsWith("$")&&(t[n]=o);return t}function SD(e){const t={};if(!e||typeof e!="object"||Array.isArray(e))return t;for(const[n,o]of Object.entries(e))n.startsWith("$")||(t[n]=o);return t}function CD(e){if(typeof e!="string")return null;const t=/^\s*\{\{\s*([\s\S]*?)\s*\}\}\s*$/.exec(e);if(!t)return null;let n=t[1];const o=n.indexOf("??");return o>=0&&(n=n.slice(0,o)),n=n.replace(/\?\./g,".").replace(/\s+/g,""),n===""||!/^[A-Za-z_$][A-Za-z0-9_$]*(\.[A-Za-z_$][A-Za-z0-9_$]*)*$/.test(n)?null:n.split(".")}function $D(e,t){const n=CD(t);if(!n||n.length===0)return e;let o=e;for(let a=0;ao.map(r=>{if(!r||typeof r!="object")return r;const s=r;let a=s;if(typeof s.slot=="string"&&!t.has(s.slot)){const{slot:l,...d}=s;a={...d,__editorSlotName:l}}if(Array.isArray(a.children)){const l=n(a.children);l!==a.children&&(a={...a,children:l})}return a});return n(e)}function St(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Qt(e){if(Array.isArray(e))return e.map(t=>Qt(t));if(St(e)){const t={};for(const[n,o]of Object.entries(e))t[n]=Qt(o);return t}return e}function Ci(e,t){for(const[n,o]of Object.entries(t)){const r=e[n];St(o)&&St(r)?Ci(r,o):e[n]=Qt(o)}}function AD(e){const t=[];let n="";for(let o=0;o0&&(t.push(n),n="");const s=e[o+1];if(s==="'"||s==='"'){const l=e.indexOf(`${s}]`,o+2);if(l!==-1){t.push(e.slice(o+2,l)),o=l+1;continue}}const a=e.indexOf("]",o+1);if(a!==-1){t.push(e.slice(o+1,a)),o=a;continue}n+=r}else r==="."?n.length>0&&(t.push(n),n=""):n+=r}return n.length>0&&t.push(n),t.filter(o=>o.length>0)}function Ra(e,t,n){const o=AD(t);if(o.length===0)return;let r=e;for(let s=0;s0?t:void 0}const tl="g7le:editor-t-ready",Hg="data-g7le-vh-expanded";function DD(e,t){if(!e||!t)return;const n=t;e.querySelectorAll("*").forEach(r=>{const s=window.getComputedStyle(r),a=parseFloat(s.height),l=Number.isFinite(a)&&Math.abs(a-n)<=2,d=parseFloat(s.minHeight),c=Number.isFinite(d)&&Math.abs(d-n)<=2,p=s.overflowY==="auto"||s.overflowY==="scroll"||s.overflowY==="hidden"||s.overflow==="auto"||s.overflow==="scroll"||s.overflow==="hidden";l&&p?(r.style.setProperty("height","auto","important"),c&&r.style.setProperty("min-height","0","important"),r.style.setProperty("overflow","visible","important"),r.setAttribute(Hg,"1")):(s.overflowY==="auto"||s.overflowY==="scroll")&&r.scrollHeight>r.clientHeight+4&&r.clientHeight>120&&(r.style.setProperty("overflow","visible","important"),r.style.setProperty("height","auto","important"),r.setAttribute(Hg,"1"))})}const zD=[];function ND(e={}){const{manifest:t=null,nesting:n=null,componentPalette:o=null,spec:r=null,permissionCandidates:s,sampleGlobalSources:a=zD,resolveRouteMatch:l,onNavigateToDestination:d,onSessionAddedPathsChange:c}=e,{state:p}=Qe(),f=Kt(),b=Bp(),{document:g,isLoading:m,error:h}=f??b,v=u.useRef(null),[y,_]=u.useState(null),{deviceWidth:w,scale:k,colorScheme:x}=Ga(),$=u.useMemo(()=>p.activeStateId?p.availableStates.find(ce=>ce.id===p.activeStateId)??null:null,[p.activeStateId,p.availableStates]),C=u.useMemo(()=>jg($),[$]),S=rD({isEditMode:!0,editorSpec:r??void 0,sampleOverride:C}),{t:D}=et(),{componentRegistry:E,translationEngine:I,isReady:N,error:T}=fD(p.templateIdentifier,p.locale),B=u.useRef(null);B.current===null&&(B.current=new Ed);const M=u.useRef(null);if(M.current===null){M.current=new z7({navigate:()=>{}}),M.current.setPreviewMode(!0);try{const q=window.__templateApp?.getActionDispatcher?.();if(q&&typeof q.getRegisteredHandlers=="function"){const se=q.getRegisteredHandlers();for(const ae of se){if(!ae.includes("."))continue;const be=typeof q.getHandler=="function"?q.getHandler(ae):void 0;typeof be=="function"&&M.current.registerHandler(ae,be,{category:"plugin",source:"preview-canvas-cloned-from-host"})}}}catch{}}u.useEffect(()=>{if(!N)return;const ce=M.current;if(ce)try{const q=window.G7Core?.getActionDispatcher?.();if(!q||typeof q.getRegisteredHandlers!="function")return;const se=q.getRegisteredHandlers();for(const ae of se){if(!ae.includes(".")||typeof ce.getHandler=="function"&&ce.getHandler(ae))continue;const be=typeof q.getHandler=="function"?q.getHandler(ae):void 0;typeof be=="function"&&ce.registerHandler(ae,be,{category:"plugin",source:"preview-canvas-iife-reclone"})}}catch{}},[N]);const O=u.useMemo(()=>new N7({sampleProvider:S,actionDispatcher:M.current}),[S]),z=u.useMemo(()=>g?.raw?.meta?.guest_only===!0,[g]),H=u.useMemo(()=>Qa({sources:a,isGuestOnly:z}),[a,z]),P=u.useMemo(()=>{const ce=MD(el($),I,{templateId:p.templateIdentifier,locale:p.locale}),q=H._local,{global:se,local:ae}=TD({globalBaseline:H,localBaseline:q??{},patch:$?.initialState??null,formErrors:ce});return{...se,_local:ae}},[H,$,I,p.templateIdentifier,p.locale]),A=u.useMemo(()=>!$||!(!!$.initialState?.local||!!el($))?null:{...P._local??{},_forceLocalInit:$.id,_merge:"deep"},[$,P]),L=ce=>typeof ce=="object"&&ce!==null&&!Array.isArray(ce),F=u.useMemo(()=>L($?.initialState?.query)?$.initialState.query:null,[$]),Y=u.useMemo(()=>L($?.initialState?.route)?$.initialState.route:null,[$]),[V,X]=u.useState(()=>Qa({sources:[],isGuestOnly:!1})),Z=u.useRef(null);u.useEffect(()=>{const ce={...P},q=mD({actionDispatcher:M.current,locale:p.locale,initialGlobalState:ce,onChange:ae=>{X(ae.globalState)}});Z.current=q;const se=window.__templateApp;return se?.setGlobalState&&M.current.setGlobalStateUpdater((ae,be)=>{se.setGlobalState(ae,be)}),X(ce),Ml({kind:"applyPatch",activeStateId:p.activeStateId,routePath:p.selectedRoute?.path??null,hasInitialPatch:!!$?.initialState,hasFormErrors:!!el($),hasSampleOverride:!!jg($)}),()=>{q.restore(),Z.current=null}},[p.locale,P]),u.useEffect(()=>{if(!I)return;const ce=window.G7Core;if(!ce||typeof ce.t!="function")return;const q=ce.t,se=p.templateIdentifier,ae=p.locale;return ce.t=(be,Ce)=>{try{const $e=Ce?"|"+Object.entries(Ce).map(([ue,ge])=>`${ue}=${ge}`).join("|"):void 0,U=I.translate(be,{templateId:se,locale:ae},$e);if(U!==be&&!U.startsWith("$t:"))return U}catch{}return q(be,Ce)},typeof window<"u"&&window.dispatchEvent(new CustomEvent(tl)),()=>{window.G7Core?.t&&window.G7Core.t!==q&&(window.G7Core.t=q)}},[I,p.templateIdentifier,p.locale]);const ie=u.useMemo(()=>{const ce=g?.raw?.components??[];return p.editMode!=="base"?ce:ID(ce)},[g,p.editMode]),oe=g?.raw?.__editability,G=g?.raw?.__extensionId,ee=u.useMemo(()=>p.editMode!=="extension"||oe!=="ok"?[]:typeof G!="number"?[]:LD(ie,G),[p.editMode,oe,G,ie]),[fe,K]=u.useState(null),[te,ye]=u.useState(!1),Se=g?.layoutName??null,De=u.useMemo(()=>{const ce=g?.raw?.scripts??[];return Array.isArray(ce)?ce.map(q=>q&&typeof q.src=="string"?q.src:"").join("|"):""},[g]);u.useEffect(()=>{ye(!1)},[Se,De]),u.useEffect(()=>{let ce=!1;const q=g?.raw?.scripts??[];if(!Array.isArray(q)||q.length===0){ye(!0);return}const se=[];for(const ae of q){if(!ae?.src||typeof ae.src!="string")continue;if(!Lg(ae.src,Xa())){console.warn(`[PreviewCanvas] Blocked untrusted script src (same-origin path or declared trusted host required): ${ae.src}`);continue}const be=ae.id?`script#${CSS.escape(ae.id)}, script[data-g7le-canvas-script="${ae.src}"]`:`script[data-g7le-canvas-script="${ae.src}"], script[src="${ae.src}"]`,Ce=window.document.querySelector(be);if(Ce){const $e=Ce.hasAttribute("data-g7le-canvas-script");if(Ce.hasAttribute("data-g7le-script-loaded")||!$e)continue;se.push(new Promise(ue=>{if(Ce.hasAttribute("data-g7le-script-loaded")){ue();return}Ce.addEventListener("load",()=>ue()),Ce.addEventListener("error",()=>ue())}));continue}se.push(new Promise($e=>{const U=window.document.createElement("script");U.src=ae.src,U.async=!1,ae.id&&(U.id=ae.id),U.setAttribute("data-g7le-canvas-script",ae.src);const ue=()=>{U.setAttribute("data-g7le-script-loaded","1"),$e()};U.addEventListener("load",ue),U.addEventListener("error",ue),window.document.head.appendChild(U)}))}if(se.length===0){ye(!0);return}return Promise.all(se).then(()=>{ce||requestAnimationFrame(()=>{requestAnimationFrame(()=>{ce||ye(!0)})})}),()=>{ce=!0}},[g]);const Ie=u.useMemo(()=>g?.raw?.data_sources??[],[g]),Ve=u.useMemo(()=>g?.raw?.computed??{},[g]),[ze,Be]=u.useState({}),Xe=u.useMemo(()=>{if(p.editMode!=="iteration_item")return ze;const ce=g?.iterationContext;if(!ce)return ze;const q=g?.raw?.components??[],se=Pe({children:q},ce.sourceIndexPath),ae=se&&se.iteration&&typeof se.iteration.source=="string"?se.iteration.source:null;return ae?$D(ze,ae):ze},[p.editMode,ze,g]),[Ne,Je]=u.useState(0);u.useEffect(()=>{if(typeof window>"u")return;const ce=()=>Je(q=>q+1);return window.addEventListener(kt,ce),()=>window.removeEventListener(kt,ce)},[]);const ve=u.useMemo(()=>_D(p.selectedRoute?.path??null),[p.selectedRoute?.path]);if(u.useEffect(()=>{let ce=!1;return(async()=>{if(Ie.length===0){ce||Be({});return}try{const q=await O.fetchDataSources(Ie,ve,new URLSearchParams,void 0,void 0);ce||Be(q)}catch{ce||Be({})}})(),()=>{ce=!0}},[Ie,O,ve]),u.useEffect(()=>{const ce=y;if(!ce||typeof window>"u")return;let q=0,se=0,ae=0;const be=()=>DD(ce,window.innerHeight);q=window.requestAnimationFrame(()=>{se=window.requestAnimationFrame(be)});let Ce=null;return typeof MutationObserver<"u"&&(Ce=new MutationObserver(()=>{ae||(ae=window.requestAnimationFrame(()=>{ae=0,be()}))}),Ce.observe(ce,{childList:!0,subtree:!0})),()=>{window.cancelAnimationFrame(q),window.cancelAnimationFrame(se),ae&&window.cancelAnimationFrame(ae),Ce&&Ce.disconnect()}},[y,ie,te,w,ze]),u.useEffect(()=>{const ce=y;if(!ce||typeof window>"u"||p.editMode!=="extension"||oe!=="ok"||ee.length===0){K(null);return}let q=0,se=0;const ae=ue=>{if(!ue)return!1;const ge=ue.getBoundingClientRect();return ge.width>0&&ge.height>0},be=ue=>{const ge=ce.querySelector(`[data-editor-path="${ue}"]`);if(ae(ge))return!0;const ke=ce.querySelectorAll(`[data-editor-path^="${ue}.children."]`);for(const he of Array.from(ke))if(ae(he))return!0;return!1},Ce=()=>{K(ee.some(be))};q=window.requestAnimationFrame(()=>{se=window.requestAnimationFrame(Ce)});let $e=null,U=0;return typeof MutationObserver<"u"&&($e=new MutationObserver(()=>{U||(U=window.requestAnimationFrame(()=>{U=0,Ce()}))}),$e.observe(ce,{childList:!0,subtree:!0})),()=>{window.cancelAnimationFrame(q),window.cancelAnimationFrame(se),U&&window.cancelAnimationFrame(U),$e&&$e.disconnect()}},[y,p.editMode,oe,ee,te,ze]),u.useEffect(()=>{if(typeof window>"u"||p.editMode!=="base")return;const ce=window.document,q="g7le-base-slot-style";if(ce.getElementById(q))return;const se=ce.createElement("style");se.id=q;const ae=D("layout_editor.preview.slot_area_label");return se.textContent=`.g7le-preview-frame [data-editor-slot]{position:relative;min-height:96px;outline:2px dashed #94a3b8;outline-offset:-2px;}.g7le-preview-frame [data-editor-slot]::after{content:'${ae.replace(/'/g,"\\'")} · ' attr(data-editor-slot);position:absolute;top:8px;left:50%;transform:translateX(-50%);font-size:12px;line-height:1;color:#64748b;background:rgba(241,245,249,0.92);border:1px solid #cbd5e1;border-radius:9999px;padding:4px 12px;pointer-events:none;white-space:nowrap;}`,ce.head.appendChild(se),()=>{ce.getElementById(q)?.remove()}},[p.editMode,D]),!(p.editMode==="extension"||p.editMode==="iteration_item")&&(p.selectedRoute?.layoutName===null||p.selectedRoute===null))return i.jsx("div",{className:"g7le-preview-canvas g7le-preview-canvas--empty","data-testid":"g7le-preview-empty",style:or,children:D("layout_editor.preview.empty")});if(m)return i.jsx("div",{className:"g7le-preview-canvas g7le-preview-canvas--loading","data-testid":"g7le-preview-loading",style:or,children:D("layout_editor.preview.loading")});if(h)return i.jsx(Ja,{error:h});if(T)return i.jsx(Ja,{error:T});if(!N||E===null||I===null)return i.jsx("div",{className:"g7le-preview-canvas g7le-preview-canvas--assets-loading","data-testid":"g7le-preview-assets-loading",style:or,children:D("layout_editor.preview.assets_loading")});if(ie.length===0)return i.jsx("div",{className:"g7le-preview-canvas g7le-preview-canvas--empty-layout","data-testid":"g7le-preview-empty-layout",style:or,children:D("layout_editor.preview.empty_layout")});const We=p.editMode==="extension"?oe==="no-injection"?"no-injection":oe==="ok"&&ee.length>0&&fe!==!0?"gated-no-state":null:null;return te?i.jsx("div",{className:"g7le-preview-canvas","data-testid":"g7le-preview-canvas",style:{overflow:"visible",background:"#f1f5f9",padding:24,display:"flex",justifyContent:"center",alignItems:"flex-start",minHeight:"calc(100vh - var(--g7le-header-h, 0px))",boxSizing:"border-box"},children:i.jsxs("div",{className:"g7le-preview-frame-wrapper","data-testid":"g7le-preview-frame-wrapper",style:{position:"relative",width:w,transform:`scale(${k})`,transformOrigin:"top center"},children:[i.jsx("div",{className:x==="dark"?"g7le-preview-frame g7le-preview-dark":"g7le-preview-frame","data-testid":"g7le-preview-frame","data-color-scheme":x,ref:ce=>{v.current=ce,_(ce)},style:{width:w,background:"#fff",border:"1px solid #cbd5e1",boxShadow:"0 1px 3px rgba(0,0,0,0.05)",minHeight:400,position:"relative",transform:"translateZ(0)",overflow:"hidden"},children:i.jsx(D7,{overrideWidth:w,children:ie.map((ce,q)=>i.jsx(T7,{componentDef:ce,dataContext:{...Xe,...kD(V),_global:SD(V),_computedDefinitions:Ve,...A?{_localInit:A,_local:{...ze._local??{},...V._local??{}}}:{},route:PD({...ze.route??{},...ve,path:p.selectedRoute?.path??""},Y),query:{...ze.query??{},...F??{}}},translationContext:{templateId:p.templateIdentifier,locale:p.locale},registry:E,bindingEngine:B.current,translationEngine:Pt.getInstance(),actionDispatcher:M.current,isEditMode:!0,isRootRenderer:q===0,componentPath:`${q}`,onComponentSelect:(se,ae)=>{},onComponentHover:(se,ae)=>{}},`${ce.id??`preview-${q}`}:t${Ne}${p.editMode==="extension"?`:s${te?1:0}`:""}`))})}),i.jsx("div",{className:"g7le-overlay-layer","data-testid":"g7le-overlay-layer",style:{position:"absolute",left:0,top:0,width:w,height:y?y.getBoundingClientRect().height/(k||1):"100%",overflow:"visible",pointerEvents:"none"},children:i.jsx(oD,{frameEl:y,manifest:t,nesting:n,componentPalette:o,spec:r,permissionCandidates:s,resolveRouteMatch:l,onNavigateToDestination:d,onSessionAddedPathsChange:c})}),We!==null&&i.jsx("div",{className:"g7le-preview-canvas--extension-fallback","data-testid":"g7le-preview-extension-fallback","data-fallback-reason":We,style:{position:"absolute",left:0,top:0,right:0,bottom:0,minHeight:y?y.getBoundingClientRect().height/(k||1):400,background:"#f1f5f9",display:"flex",alignItems:"flex-start",justifyContent:"center",padding:24,boxSizing:"border-box",pointerEvents:"auto",zIndex:50},children:i.jsxs("div",{className:"g7le-extension-fallback-card",style:{maxWidth:440,textAlign:"center",position:"sticky",top:"calc(40vh - var(--g7le-header-h, 0px))"},children:[i.jsx("p",{className:"g7le-extension-fallback-title",style:{fontWeight:600,marginBottom:8,color:"#0f172a"},children:D(We==="no-injection"?"layout_editor.preview.extension_no_injection_title":"layout_editor.preview.extension_gated_title")}),i.jsx("p",{className:"g7le-extension-fallback-desc",style:{color:"#475569",lineHeight:1.6},children:We==="no-injection"?D("layout_editor.preview.extension_no_injection_desc"):p.availableStates.length>1?D("layout_editor.preview.extension_gated_desc_with_states"):D("layout_editor.preview.extension_gated_desc")})]})})]})}):i.jsx("div",{className:"g7le-preview-canvas g7le-preview-canvas--scripts-loading","data-testid":"g7le-preview-scripts-loading",style:or,children:D("layout_editor.preview.loading")})}function MD(e,t,n){if(!e)return;if(!t)return e;const o=s=>{if(typeof s=="string"&&s.startsWith("$t:"))try{const a=s.slice(3),l=a.indexOf("|");if(l===-1)return t.translate(a,n);const d=a.slice(0,l),c=a.slice(l);return t.translate(d,n,c)}catch{return s}return Array.isArray(s)?s.map(o):s},r={};for(const[s,a]of Object.entries(e))r[s]=o(a);return r}function LD(e,t){const n=[],o=(r,s)=>{Array.isArray(r)&&r.forEach((a,l)=>{if(!a||typeof a!="object")return;const d=s?`${s}.children.${l}`:`${l}`,c=a.__source;if(c?.kind==="extension"&&c.extensionId===t){n.push(d);return}Array.isArray(a.children)&&o(a.children,d)})};return o(e,""),n}function PD(e,t){if(!t)return e;const n={...e};for(const[o,r]of Object.entries(t))r===null?delete n[o]:n[o]=r;return n}const or={flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:24,background:"#f1f5f9",color:"#64748b",fontSize:13},OD={desktop:"layout_editor.device.desktop",tablet:"layout_editor.device.tablet",mobile:"layout_editor.device.mobile",portable:"layout_editor.device.portable"};function BD(){const{device:e,zoom:t,customWidth:n,setDevice:o,setZoom:r,setCustomWidth:s,colorScheme:a,setColorScheme:l}=Ga(),{t:d}=et(),c=cg();return i.jsxs("div",{className:"g7le-device-toolbar","data-testid":"g7le-device-toolbar",style:{display:"inline-flex",alignItems:"center",gap:8,padding:"4px 8px",background:"#fff",border:"1px solid #cbd5e1",borderRadius:6},children:[i.jsxs("div",{role:"group","aria-label":d("layout_editor.device.group_label"),children:[c.map(p=>{const f=e===p,b=OD[p],g=b?d(b):p;return i.jsx("button",{type:"button","data-testid":`g7le-device-${p}`,"aria-pressed":f,onClick:()=>o(p),style:{padding:"2px 8px",marginRight:2,fontSize:12,cursor:"pointer",background:f?"#0f172a":"#f8fafc",color:f?"#fff":"#0f172a",border:"1px solid #cbd5e1",borderRadius:4},children:g},p)}),(()=>{const p=e==="custom";return i.jsx("button",{type:"button","data-testid":"g7le-device-custom","aria-pressed":p,onClick:()=>o("custom"),style:{padding:"2px 8px",marginRight:2,fontSize:12,cursor:"pointer",background:p?"#0f172a":"#f8fafc",color:p?"#fff":"#0f172a",border:"1px solid #cbd5e1",borderRadius:4},children:d("layout_editor.device.custom")})})()]}),e==="custom"&&i.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[i.jsx("label",{htmlFor:"g7le-custom-width-input",style:{fontSize:11,color:"#475569"},children:d("layout_editor.device.custom_width_label")}),i.jsx("input",{id:"g7le-custom-width-input",type:"number",min:Ag,max:Tg,step:10,value:n,"data-testid":"g7le-custom-width-input","aria-label":d("layout_editor.device.custom_width_label"),onChange:p=>{const f=parseInt(p.currentTarget.value,10);Number.isFinite(f)&&s(f)},style:{width:72,padding:"2px 6px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:4}}),i.jsx("span",{style:{fontSize:11,color:"#475569"},children:"px"})]}),i.jsx("div",{role:"group","aria-label":d("layout_editor.toolbar.color_scheme_group"),style:{display:"inline-flex",gap:2},children:["light","dark"].map(p=>{const f=a===p;return i.jsx("button",{type:"button","data-testid":`g7le-toolbar-scheme-${p}`,"aria-pressed":f,onClick:()=>l(p),style:{padding:"2px 8px",fontSize:12,cursor:"pointer",background:f?"#0f172a":"#f8fafc",color:f?"#fff":"#0f172a",border:"1px solid #cbd5e1",borderRadius:4},children:d(p==="light"?"layout_editor.toolbar.color_scheme_light":"layout_editor.toolbar.color_scheme_dark")},p)})}),i.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[i.jsx("span",{style:{fontSize:11,color:"#475569"},children:d("layout_editor.zoom.label")}),i.jsx("input",{type:"range",min:.5,max:1,step:.05,value:t,"data-testid":"g7le-zoom-slider","aria-label":d("layout_editor.zoom.aria_label"),onChange:p=>r(parseFloat(p.currentTarget.value)),style:{width:100}}),i.jsxs("span",{style:{fontSize:11,color:"#475569",minWidth:36,textAlign:"right"},children:[Math.round(t*100),"%"]})]}),i.jsx(fm,{})]})}function WD(){const{t:e}=et(),{state:t,dispatch:n}=Qe(),{availableStates:o,activeStateId:r}=t,[,s]=u.useState(0);u.useEffect(()=>{if(typeof window>"u")return;const p=()=>s(b=>b+1),f=window.requestAnimationFrame(p);return window.addEventListener(tl,p),()=>{window.cancelAnimationFrame(f),window.removeEventListener(tl,p)}},[]);const a=u.useCallback((p,f)=>{if(!p)return f;if(!p.startsWith("$t:"))return p;const b=p.slice(3),g=window.G7Core;if(g&&typeof g.t=="function"){const h=g.t(b);if(h&&h!==b&&!h.startsWith("$t:"))return h}const m=e(b);return m&&m!==b?m:f},[e]);if(!Array.isArray(o)||o.length<=1)return null;const l=p=>{const f=p.target.value;n({type:"SET_ACTIVE_STATE",activeStateId:f}),Ml({kind:"change",activeStateId:f,routePath:t.selectedRoute?.path??null,availableCount:o.length})},d=o.find(p=>p.id===r)??o[0],c=d?.description?a(d.description,""):"";return i.jsxs("div",{className:"g7le-state-switcher","data-testid":"g7le-state-switcher","data-active-state":r??"",style:{display:"inline-flex",alignItems:"center",gap:6,padding:"4px 8px",background:"#fff",border:"1px solid #cbd5e1",borderRadius:6},children:[i.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#475569",whiteSpace:"nowrap"},children:e("layout_editor.toolbar.state")}),i.jsx("select",{"data-testid":"g7le-state-switcher-select","aria-label":e("layout_editor.toolbar.state"),value:r??o[0].id,onChange:l,style:{fontSize:12,padding:"2px 6px",border:"1px solid #cbd5e1",borderRadius:4,background:"#fff",color:"#0f172a",cursor:"pointer",outline:"none"},children:o.map(p=>i.jsx("option",{value:p.id,children:a(p.label,p.id)},p.id))}),c&&i.jsx("span",{"data-testid":"g7le-state-switcher-description",style:{fontSize:11,color:"#94a3b8",whiteSpace:"nowrap"},children:c})]})}function jD(e,t,n){if(e==="extension"){if(typeof n=="string"&&n.length>0){const o=nl(n,"__base__/");return o?{kind:"base",match:o}:{kind:"route",match:n}}return null}if(!t)return null;switch(e){case"route":return{kind:"route",match:t};case"base":{const o=nl(t,"__base__/");return o?{kind:"base",match:o}:null}case"modal":{const o=nl(t,"__modal__/");return o?{kind:"modal",match:o}:null}default:return null}}function HD(e,t){if(!t||!Array.isArray(e)||e.length===0)return[];const n=[];for(const o of e)if(KD(o.scope,t))for(const r of o.items??[])r&&typeof r.id=="string"&&r.id.length>0&&n.push(r);return n}function FD(e){if(e.length===0)return null;const t=e.find(n=>n.default===!0);return t?t.id:e[0].id}function KD(e,t){if(!e||e.kind!==t.kind)return!1;const n=e.match;return typeof n!="string"||n.length===0?!1:t.kind==="route"?VD(t.match,n):n===t.match}function VD(e,t){if(t===e)return!0;if(!t.includes("*"))return!1;const n=t.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\/\*\\\?/g,"(?:/[^/]+)?").replace(/\*/g,"[^/]+");return new RegExp(`^${n}$`).test(e)}function nl(e,t){return e.startsWith(t)?e.slice(t.length):""}const UD="__conngroup__/modals/",qD="__conngroup__/extensions/";function GD(e){return e.meta?.editor_label?{label:e.meta.editor_label,labelSource:"editor_label"}:e.meta?.title?{label:e.meta.title,labelSource:"title"}:{label:e.path,labelSource:"path"}}function YD(e){switch(e.source.kind){case"template":return"template";case"module":return`module:${e.source.identifier??""}`;case"plugin":return`plugin:${e.source.identifier??""}`;case"core":return null;default:return null}}function XD(e,t){if(e.meta?.parent&&t.has(e.meta.parent))return e.meta.parent;const n=e.path.split("/").filter(Boolean);for(let o=n.length-1;o>=1;o--){const r="/"+n.slice(0,o).join("/");if(r!==e.path&&t.has(r))return r}return null}function JD(e){const t=new Map;for(const n of e)n.layout&&t.set(n.layout,(t.get(n.layout)??0)+1);return t}function ZD(e){const t=new Map;for(const n of e){if(!n.hostLayout)continue;const o=t.get(n.hostLayout)??[];o.push(n),t.set(n.hostLayout,o)}return t}function QD(e){const t=new Map;for(const n of e)for(const o of n.extensions)for(const r of o.hostLayouts??[]){if(!r)continue;const s=t.get(r)??[];s.push({extension:o,group:n}),t.set(r,s)}return t}function RD(e,t){return{path:`__modal__/${e.hostLayout}/${e.modalId}`,layoutName:e.hostLayout,label:e.label??e.modalId,labelSource:e.label?"editor_label":"path",source:{kind:"core",identifier:null},kind:"modal",modalId:e.modalId,modalHostLayout:e.hostLayout,connectedHostRoutePath:t,children:[]}}function e8(e,t){const{extension:n,group:o}=e,r=o.sourceType==="plugin"?"🔌":"🧩";return{path:`__extension__/${n.id}`,layoutName:null,label:`${r} ${o.sourceLabel} · ${n.targetName}`,labelSource:"path",source:{kind:o.sourceType,identifier:o.sourceIdentifier},kind:"extension",extensionId:String(n.id),extensionType:n.extensionType,extensionPriority:n.priority,extensionTargetName:n.targetName,isModified:n.isModified,isInactive:!n.isActive,connectedHostRoutePath:t,children:[]}}function Fg(e,t,n){if(e.kind!=="route"&&e.kind!=="base"||!e.layoutName)return;const o=[],r=t.get(e.layoutName)??[];r.length>0&&o.push({path:`${UD}${e.path}`,layoutName:null,label:`$t:layout_editor.chrome.route_tree.connected.modals|count=${r.length}`,labelSource:"editor_label",source:{kind:"core",identifier:null},kind:"route",children:r.map(a=>RD(a,e.path))});const s=n.get(e.layoutName)??[];s.length>0&&o.push({path:`${qD}${e.path}`,layoutName:null,label:`$t:layout_editor.chrome.route_tree.connected.extensions|count=${s.length}`,labelSource:"editor_label",source:{kind:"core",identifier:null},kind:"route",children:s.map(a=>e8(a,e.path))}),o.length>0&&(e.children=[...o,...e.children??[]])}function t8(e){const t=[],n=new Set(e.routes.map(o=>o.path));for(const o of e.routes){const r=YD(o);if(!r)continue;const{label:s,labelSource:a}=GD(o),l=XD(o,n),d={path:o.path,layoutName:o.layout??null,label:s,labelSource:a,icon:o.meta?.icon??null,source:o.source,isRedirect:!!o.redirect,isHidden:!!o.meta?.hidden,kind:"route",children:[]};t.push({node:d,parentKey:l,groupKey:r})}return t}function n8(e,t){if(e==="template")return"$t:layout_editor.chrome.route_tree.group.template";if(e.startsWith("module:")){const n=e.slice(7);return`$t:layout_editor.chrome.route_tree.group.module|name=${t.moduleDisplayNames[n]??n}`}if(e.startsWith("plugin:")){const n=e.slice(7);return`$t:layout_editor.chrome.route_tree.group.plugin|name=${t.pluginDisplayNames[n]??n}`}return e}function o8(e,t){JD(e.routes);const n=ZD(e.modals),o=QD(e.extensionGroups??[]),r=new Map;for(const d of t)r.has(d.groupKey)||r.set(d.groupKey,[]),r.get(d.groupKey).push(d);const s=Array.from(r.keys()).sort((d,c)=>{const p=g=>g==="template"?1:g.startsWith("module:")?2:g.startsWith("plugin:")?3:4,f=p(d),b=p(c);return f!==b?f-b:d.localeCompare(c)}),a=[];if(e.baseLayouts.length>0){const d=e.baseLayouts.map(c=>({path:`__base__/${c.layoutName}`,layoutName:c.layoutName,label:c.label??c.layoutName,labelSource:c.label?"editor_label":"path",source:{kind:"core",identifier:null},kind:"base",children:[]}));for(const c of d)Fg(c,n,o);a.push({path:"__group__/base",layoutName:null,label:"$t:layout_editor.chrome.route_tree.group.base",labelSource:"editor_label",source:{kind:"core",identifier:null},kind:"route",children:d})}for(const d of s){const c=r.get(d),p=new Map;for(const b of c)p.set(b.node.path,b);const f=[];for(const b of c)if(b.parentKey&&p.has(b.parentKey)){const g=p.get(b.parentKey);g.node.children=g.node.children??[],g.node.children.push(b.node)}else f.push(b.node);for(const b of c)Fg(b.node,n,o);a.push({path:`__group__/${d}`,layoutName:null,label:n8(d,e),labelSource:"editor_label",source:{kind:"core",identifier:null},kind:"route",children:f})}if(e.modals.length>0){const d=e.modals.map(c=>({path:`__modal__/${c.hostLayout}/${c.modalId}`,layoutName:c.hostLayout,label:c.label??c.modalId,labelSource:c.label?"editor_label":"path",source:{kind:"core",identifier:null},kind:"modal",modalId:c.modalId,modalHostLayout:c.hostLayout,children:[]}));a.push({path:"__group__/modal",layoutName:null,label:"$t:layout_editor.chrome.route_tree.group.modal",labelSource:"editor_label",source:{kind:"core",identifier:null},kind:"route",children:d})}const l=e.extensionGroups??[];if(l.length>0){const d=l.map(c=>{const p=c.sourceType==="plugin"?"🔌":"🧩",f=c.extensions.map(b=>({path:`__extension__/${b.id}`,layoutName:null,label:`${c.sourceLabel} · ${b.targetName}`,labelSource:"path",source:{kind:c.sourceType,identifier:c.sourceIdentifier},kind:"extension",extensionId:String(b.id),extensionType:b.extensionType,extensionPriority:b.priority,extensionTargetName:b.targetName,isModified:b.isModified,isInactive:!b.isActive,children:[]}));return{path:`__extgroup__/${c.sourceType}/${c.sourceIdentifier}`,layoutName:null,label:`${p} ${c.sourceLabel}`,labelSource:"path",source:{kind:c.sourceType,identifier:c.sourceIdentifier},kind:"route",children:f}});a.push({path:"__group__/extension",layoutName:null,label:"$t:layout_editor.chrome.route_tree.group.extension",labelSource:"editor_label",source:{kind:"core",identifier:null},kind:"route",children:d})}return a}function r8(e){const t=t8(e);return o8(e,t)}const Wn=_o("useEditorRoutes");function i8(e,t){if(typeof e=="string")return e.length>0?e:null;if(e&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n.length>0)return n;if(typeof e.en=="string"&&e.en.length>0)return e.en;for(const o of Object.values(e))if(typeof o=="string"&&o.length>0)return o}return null}function Kg(e,t){const n={};if(typeof window>"u")return n;const r=window.G7Config?.[e];if(!Array.isArray(r))return n;for(const s of r)s&&typeof s.identifier=="string"&&(n[s.identifier]=i8(s.display_name,t)??s.identifier);return n}function s8(e){const t=new Ed,n=typeof window<"u"?window.G7Config:void 0,o={_global:{settings:n?.settings??{},plugins:n?.plugins??{},modules:n?.modules??{},appConfig:n?.appConfig??{}}};return e.map(r=>{const s={...r};if(typeof s.path=="string"&&s.path.includes("{{")){const a=s.path;let l=t.resolveBindings(s.path,o);l=l.replace(/\/\/+/g,"/")||"/",l.includes("{{")&&(Wn.warn("편집기 route path 표현식 평가 실패 — fallback 적용",{originalPath:a}),l=a.replace(/\{\{[^}]+\}\}/g,"").replace(/\/\/+/g,"/")||"/"),s.path=l}if(typeof s.redirect=="string"&&s.redirect.includes("{{")){const a=s.redirect;let l=t.resolveBindings(a,o);l=l.replace(/\/\/+/g,"/")||"/",l.includes("{{")&&(Wn.warn("편집기 route redirect 표현식 평가 실패 — fallback 적용",{originalRedirect:a}),l=a.replace(/\{\{[^}]+\}\}/g,"").replace(/\/\/+/g,"/")||"/"),s.redirect=l}return s})}function a8(e){const{dispatch:t}=Qe(),{translationEngine:n,translationContext:o}=et(),{templateIdentifier:r,cacheVersion:s}=e;u.useEffect(()=>{let a=!1;const l=s??(typeof window<"u"?window.G7Config?.cache_version:void 0)??"",d=l!==""?`?v=${encodeURIComponent(String(l))}`:"",c=nn(`/api/admin/templates/${encodeURIComponent(r)}/editor/routes`,"json",null,d.replace(/^[?&]+/,"")),p=o?.locale??"ko",f=n&&r!==o?.templateId?n.loadTranslations(r,p).then(()=>{Wn.log("편집 대상 lang 로드 완료",{targetTemplate:r,locale:p})}).catch(h=>{Wn.warn("편집 대상 lang 로드 실패 — 라우트 라벨 fallback 사용",h)}):Promise.resolve(),b=(()=>{if(typeof fetch!="function")return Promise.reject(lo(new Error("fetch unavailable"),"routes"));try{const h=fetch(c,{credentials:"same-origin",headers:Me()});return!h||typeof h.then!="function"?Promise.reject(lo(new Error("fetch returned non-Promise (test stub?)"),"routes")):h.then(async v=>{if(!v.ok){const y=await v.json().catch(()=>null);throw ei(v.status,y,"routes")}return v.json()})}catch(h){return Promise.reject(h)}})(),g=`/api/admin/templates/${encodeURIComponent(r)}/layout-extensions${d}`,m=(()=>{if(typeof fetch!="function")return Promise.resolve(null);try{const h=fetch(g,{credentials:"same-origin",headers:Me()});return!h||typeof h.then!="function"?Promise.resolve(null):h.then(async v=>v.ok?await v.json():null).catch(()=>null)}catch{return Promise.resolve(null)}})();return Promise.all([b,f,m]).then(([h,,v])=>{if(a)return;if(!h||!h.success||!Array.isArray(h.data?.routes)){Wn.warn("routes 응답 형식이 비정상 — empty tree 로 둠",h),t({type:"SET_ROUTES_ERROR",error:{kind:"unknown",status:200,message:"routes 응답 형식이 비정상입니다.",source:"routes"}});return}const y=s8(h.data.routes),_=Kg("activeModules",p),w=Kg("activePlugins",p),k=(h.data.base_layouts??[]).map(I=>({layoutName:I.layout_name,label:I.label??void 0})),x=(h.data.modals??[]).map(I=>({modalId:I.modal_id,hostLayout:I.host_layout,label:I.label??void 0})),$=(v?.success&&Array.isArray(v.data)?v.data:[]).map(I=>({sourceIdentifier:I.source_identifier,sourceType:I.source_type,sourceLabel:I.source_label,extensions:(I.extensions??[]).map(N=>({id:N.id,extensionType:N.extension_type,targetName:N.target_name,priority:N.priority,isActive:N.is_active,isModified:N.is_modified,hostLayouts:Array.isArray(N.host_layouts)?N.host_layouts:[],currentVersion:typeof N.current_version=="number"?N.current_version:void 0}))})),C=r8({routes:y,modals:x,baseLayouts:k,extensionGroups:$,moduleDisplayNames:_,pluginDisplayNames:w});t({type:"SET_ROUTE_TREE",tree:C});const S=h.data.layout_versions,D={};if(S&&typeof S=="object"&&!Array.isArray(S))for(const[I,N]of Object.entries(S))typeof N=="number"&&Number.isFinite(N)&&(D[I]=N);t({type:"SET_LAYOUT_VERSIONS",versions:D});const E={};for(const I of $)for(const N of I.extensions){const T=N.currentVersion;typeof T=="number"&&Number.isFinite(T)&&(E[String(N.id)]=T)}t({type:"SET_EXTENSION_VERSIONS",versions:E}),Wn.log("routes 로드 완료",{count:y.length,groups:C.length})}).catch(h=>{if(a)return;Wn.error("routes 로드 실패",h);const v=Ep(h)?h:lo(h,"routes");t({type:"SET_ROUTES_ERROR",error:v})}),()=>{a=!0}},[r,s,t,n,o?.locale,o?.templateId])}function Vg(e,t,n,o=[]){const r=t?Ug(o,t):null,s=r!==null?{path:r.path,layoutName:r.layoutName}:void 0;if(e.startsWith("__base__/")){const a=e.slice(9);if(a)return n({type:"ENTER_BASE_EDIT",layoutName:a,returnRoute:s}),!0}else if(e.startsWith("__modal__/")){const a=e.slice(10);return a&&!a.includes("/")&&t?(n({type:"ENTER_MODAL_EDIT",modalId:a,hostLayout:t,returnRoute:s}),!0):!1}else if(e.startsWith("__extension__/")){const a=e.slice(14);if(a&&!a.includes("/"))return n({type:"ENTER_EXTENSION_EDIT",extensionId:a,returnRoute:s}),!0}else if(e.startsWith("__iteration__/")){const a=e.slice(14);return a&&t?(n({type:"ENTER_ITERATION_ITEM_EDIT",sourcePath:a,hostLayout:t,returnRoute:s}),!0):!1}return!1}function Ug(e,t){for(const n of e){if(n.kind==="route"&&n.layoutName===t)return n;if(n.children&&n.children.length>0){const o=Ug(n.children,t);if(o)return o}}return null}function ol(e,t){for(const n of e){if(n.kind==="route"&&n.path===t)return n;if(n.children&&n.children.length>0){const o=ol(n.children,t);if(o)return o}}return null}function l8(e){const{state:t,dispatch:n}=Qe(),o=u.useRef(!1),r=u.useRef(t.editMode);r.current=t.editMode,u.useEffect(()=>{if(o.current||t.routeTree.length===0||typeof window>"u")return;const a=vp(window.location.search);if(a){const c=mp(window.location.search),p=Vg(a,c,n,t.routeTree);if(o.current=!0,p)return}const l=bp(window.location.search);if(!l){o.current=!0;return}const d=ol(t.routeTree,l);d&&n({type:"SELECT_ROUTE",route:{path:d.path,layoutName:d.layoutName}}),o.current=!0},[t.routeTree,n]),u.useEffect(()=>{if(typeof window>"u")return;const a=()=>{const l=vp(window.location.search);if(l){const p=mp(window.location.search);if(Vg(l,p,n,t.routeTree))return}if(r.current!=="route")switch(r.current){case"base":n({type:"EXIT_BASE_EDIT"});return;case"modal":n({type:"EXIT_MODAL_EDIT"});return;case"extension":n({type:"EXIT_EXTENSION_EDIT"});return;case"iteration_item":n({type:"EXIT_ITERATION_ITEM_EDIT"});return}const d=bp(window.location.search);if(!d){n({type:"SELECT_ROUTE",route:null});return}const c=ol(t.routeTree,d);c&&n({type:"SELECT_ROUTE",route:{path:c.path,layoutName:c.layoutName}})};return window.addEventListener("popstate",a),()=>{window.removeEventListener("popstate",a)}},[t.routeTree,n]);const s=u.useRef("route");u.useEffect(()=>{if(typeof window>"u"||!window.history?.replaceState||t.routeTree.length===0)return;const a=ia(e,t.selectedRoute?.path??null,t.selectedRoute?.layoutName??null),l=`${window.location.pathname}${window.location.search}`,d=s.current;if(s.current=t.editMode,l===a)return;d==="route"&&t.editMode!=="route"&&window.history.pushState?window.history.pushState(window.history.state,"",a):window.history.replaceState(window.history.state,"",a)},[t.selectedRoute,t.editMode,t.routeTree,e])}function d8(){u.useEffect(()=>{if(typeof document>"u")return;const e=document.documentElement;let t=e.classList.contains("dark");const n=()=>{e.classList.contains("dark")&&(t=!0,e.classList.remove("dark"))};n();let o=null;return typeof MutationObserver<"u"&&(o=new MutationObserver(n),o.observe(e,{attributes:!0,attributeFilter:["class"]})),()=>{o?.disconnect(),t&&e.classList.add("dark")}},[])}function c8(){u.useEffect(()=>{if(typeof document>"u"||!document.body)return;const e=document.body,t=()=>{e.style.overflow==="hidden"&&(e.style.overflow=""),e.style.overflowY==="hidden"&&(e.style.overflowY="")};t();let n=null;return typeof MutationObserver<"u"&&(n=new MutationObserver(t),n.observe(e,{attributes:!0,attributeFilter:["style"]})),()=>{n?.disconnect()}},[])}function u8(e){if(typeof e!="string")return null;const t="__extension__/";if(!e.startsWith(t))return null;const n=e.slice(t.length);return n===""||n.includes("/")?null:n}function p8(e){if(Array.isArray(e.components))return e.components;if(Array.isArray(e.injections)){const t=[];return e.injections.forEach((n,o)=>{if(n&&Array.isArray(n.components))for(const r of n.components)t.push({...r,__injectionIndex:o})}),t}return[]}function f8(e,t){if(Array.isArray(e.components)){const n=t.map(o=>rl(o));return{...e,components:n}}if(Array.isArray(e.injections)){const n=e.injections.map(o=>({...o}));n.forEach(o=>{Array.isArray(o.components)&&(o.components=[])});for(const o of t){const r=o.__injectionIndex,s=typeof r=="number"&&r>=0&&rrl(n))),t}function qg(e,t){const n=[],o=r=>{if(Array.isArray(r))for(const s of r){if(!s||typeof s!="object")continue;const a=s.__source;if(a?.kind==="extension"&&a.extensionId===t){n.push(s);continue}Array.isArray(s.children)&&o(s.children)}};return o(e),n}function Gg(e,t){const o=qg(e,t)[0]?.__source;return o&&o.kind==="extension"&&o.extensionId===t?o:{kind:"extension",extensionId:t}}function il(e,t){for(const n of e){const o=n?.__source;if(o?.kind==="extension"&&o.extensionId===t||Array.isArray(n.children)&&il(n.children,t))return!0}return!1}function g8(){const{state:e}=Qe(),t=e.templateIdentifier,n=e.editMode==="extension"?u8(e.selectedRoute?.path):null,o=e.editMode==="extension"&&typeof e.selectedRoute?.layoutName=="string"?e.selectedRoute.layoutName:null,[r,s]=u.useState(null),[a,l]=u.useState(!1),[d,c]=u.useState(null),[p,f]=u.useState(!1),[b,g]=u.useState(0),[m,h]=u.useState(null),v=u.useRef({}),y=u.useRef({kind:"extension",extensionId:0}),_=u.useRef(null);u.useEffect(()=>{_.current=r},[r]),u.useEffect(()=>{h(null)},[n]);const w=u.useCallback(async I=>{const N=window.G7Config?.cache_version??0,T=nn(`/api/layouts/${encodeURIComponent(t)}/${I}`,"json",`${N}.${Op()}`,"with_source_meta=1"),B=fr(),M={Accept:"application/json"};B&&(M.Authorization=`Bearer ${B}`);const O=await fetch(T,{headers:M,credentials:"same-origin"});if(!O.ok)return null;const z=await O.json().catch(()=>null);return(z&&(z.data||z))??{}},[t]),k=u.useCallback(async()=>{if(!n){s(null),c(null),f(!1);return}l(!0),c(null);try{const I=window.G7Config?.cache_version??0,N=`/api/admin/templates/${encodeURIComponent(t)}/layout-extensions/${encodeURIComponent(n)}?v=${I}`,T=await fetch(N,{headers:Me(),credentials:"same-origin"}),B=await T.json().catch(()=>null);if(!T.ok){c(ei(T.status,B,"layout")),s(null),f(!1);return}const M=(B&&(B.data||B))??{};let O={};const z=M.content;if(typeof z=="string")try{O=JSON.parse(z)}catch{O={}}else z&&typeof z=="object"&&(O=z);const H=M.extension_type==="overlay"?"overlay":"extension_point",P=typeof M.lock_version=="number"?M.lock_version:0,A=Array.isArray(M?.host_layouts)?M.host_layouts.filter(oe=>typeof oe=="string"):[],L=o??(A.length===1?A[0]:m&&A.includes(m)?m:null),F=Number(n);v.current=O;let V=p8(O),X={},Z="pending";const ie={kind:"extension",extensionId:F};if(y.current=ie,L){const oe=await w(L);if(oe){X=oe;const G=Array.isArray(oe.components)?oe.components:[],ee=Gg(G,F);if(y.current=ee,il(G,F))V=G,Z="ok";else{const K=(Array.isArray(oe.modals)?oe.modals:[]).filter(te=>te&&typeof te=="object"&&il([te],F));if(K.length>0){const te=K.map(ye=>({...ye,props:{...ye.props??{},isOpen:!0}}));V=[...G,...te],y.current=Gg(K,F),Z="ok"}else V=G,Z="no-injection"}}}s({extensionId:F,content:O,extensionType:H,components:V,lockVersion:P,hostLayouts:A,hostLayoutName:L,hostRaw:X,editability:Z}),f(!1),st({op:"load",layoutName:`extension:${n}`,editMode:"extension",statusCode:T.status,timestamp:Date.now()})}catch(I){c(lo(I,"layout")),s(null),f(!1)}finally{l(!1)}},[t,n,m,o,w]);u.useEffect(()=>{k()},[k]);const x=u.useCallback(I=>{h(I)},[]),$=u.useCallback(I=>{s(N=>N&&{...N,components:I}),f(!0),st({op:"patch",layoutName:`extension:${_.current?.extensionId??""}`,editMode:"extension",isDirty:!0,timestamp:Date.now()})},[]),C=u.useCallback(I=>{s(N=>N&&{...N,components:I(N.components)}),f(!0)},[]),S=u.useCallback(async()=>{const I=_.current;if(!I)return{kind:"guard_no_document"};const N=`/api/admin/templates/${encodeURIComponent(t)}/layout-extensions/${I.extensionId}`,T=qg(I.components,I.extensionId),B=T.length>0?T:I.components,M=f8(v.current,B);st({op:"save",layoutName:`extension:${I.extensionId}`,editMode:"extension",saveTarget:"layout_extension",endpoint:N,isDirty:p,timestamp:Date.now()});let O;try{O=await fetch(N,{method:"PUT",headers:Me({"Content-Type":"application/json"}),credentials:"same-origin",body:JSON.stringify({content:M,expected_lock_version:I.lockVersion})})}catch(H){return{kind:"network_error",message:H instanceof Error?H.message:"network error"}}const z=await O.json().catch(()=>null);if(st({op:"save_response",layoutName:`extension:${I.extensionId}`,editMode:"extension",endpoint:N,statusCode:O.status,conflict:O.status===409?{currentVersion:z?.errors?.current_version??z?.current_version,yourVersion:z?.errors?.your_version??z?.your_version}:void 0,timestamp:Date.now()}),O.ok){const H=z?.data??{},P=typeof H.lock_version=="number"?H.lock_version:I.lockVersion+1;s(L=>L&&{...L,lockVersion:P}),f(!1),g(L=>L+1);const A=typeof H.current_version=="number"?H.current_version:void 0;return{kind:"success",newLockVersion:P,newContentVersion:A,savedExtensionId:String(I.extensionId)}}return O.status===409?{kind:"concurrent_modification",currentVersion:z?.current_version??-1,yourVersion:z?.your_version??I.lockVersion}:O.status===422?{kind:"validation_failed",status:422,errors:z?.errors??null}:{kind:"network_error",message:z?.message??`HTTP ${O.status}`}},[t,p]),D=u.useCallback(async()=>{ca(),await k()},[k]),E=!!r&&r.hostLayouts.length>1&&r.hostLayoutName===null;return{document:r,isLoading:a,error:d,isDirty:p,saveSuccessCounter:b,setLayoutComponents:$,patchLayout:C,save:S,reload:D,needsHostPicker:E,selectHost:x}}const Yg=new Set;function h8(e,t,n){const r=e&&Object.keys(e).length>0?e:t,s=Array.isArray(r.data_sources)?r.data_sources:[],a=Array.isArray(t.data_sources)?t.data_sources:[],l=new Set,d=[];for(const c of[...s,...a]){const p=c&&typeof c=="object"?c.id:void 0,f=typeof p=="string"?p:`__anon_${d.length}`;l.has(f)||(l.add(f),d.push(c))}return{...r,components:n,...d.length>0?{data_sources:d}:{},lock_version:void 0}}function y8(e){return{document:e.document?{layoutName:`extension:${e.document.extensionId}`,raw:{...h8(e.document.hostRaw,e.document.content,e.document.components),__editability:e.document.editability,__extensionId:e.document.extensionId},lockVersion:e.document.lockVersion}:null,isLoading:e.isLoading,error:e.error,isDirty:e.isDirty,saveSuccessCounter:e.saveSuccessCounter,reload:e.reload,patchLayout:e.patchLayout,setLayoutComponents:e.setLayoutComponents,patchDocumentRaw:()=>{},dirtyKeys:Yg,dirtyLayoutNames:Yg,invalidateCurrentCache:()=>{},reloadCounter:0,save:()=>e.save(),markDirty:()=>{}}}function b8({hostLayouts:e,extensionLabel:t,onSelect:n}){const{t:o}=et();return i.jsx("div",{className:"g7le-host-picker__backdrop","data-testid":"g7le-host-picker",role:"dialog","aria-modal":"true","aria-label":o("layout_editor.host_picker.title"),style:{position:"fixed",inset:0,zIndex:9500,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(15, 23, 42, 0.55)"},children:i.jsxs("div",{className:"g7le-host-picker__panel",style:{width:"min(520px, 92vw)",maxHeight:"80vh",overflow:"auto",background:"#ffffff",color:"#0f172a",borderRadius:12,boxShadow:"0 20px 48px rgba(15, 23, 42, 0.28)",padding:"20px 22px"},children:[i.jsx("h2",{className:"g7le-host-picker__title",style:{margin:"0 0 6px",fontSize:16,fontWeight:700},children:o("layout_editor.host_picker.title")}),i.jsx("p",{className:"g7le-host-picker__desc",style:{margin:"0 0 16px",fontSize:13,color:"#475569",lineHeight:1.6},children:t?o("layout_editor.host_picker.description_with_label",{label:t}):o("layout_editor.host_picker.description")}),i.jsx("ul",{className:"g7le-host-picker__list",style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:8},children:e.map(r=>i.jsx("li",{children:i.jsxs("button",{type:"button",className:"g7le-host-picker__item","data-testid":"g7le-host-picker-item","data-host":r,onClick:()=>n(r),style:{width:"100%",textAlign:"left",padding:"12px 14px",border:"1px solid #e2e8f0",borderRadius:8,background:"#f8fafc",cursor:"pointer",fontSize:13,fontWeight:600,color:"#0f172a",display:"flex",alignItems:"center",gap:8},children:[i.jsx("span",{"aria-hidden":!0,style:{fontSize:14},children:"🖼"}),i.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:r}),i.jsx("span",{"aria-hidden":!0,style:{color:"#94a3b8"},children:"→"})]})},r))})]})})}function m8(e,t){const[n,o]=u.useState(!1),[r,s]=u.useState(null),a=u.useCallback(async l=>{if(!t||!l)return{kind:"no_document"};o(!0),s(null);try{const d=ko(l),c=`/api/admin/templates/${encodeURIComponent(e)}/layouts/${t}/preview`,p=await fetch(c,{method:"POST",credentials:"same-origin",headers:Me({"Content-Type":"application/json"}),body:JSON.stringify({content:JSON.stringify(d)})}),f=await p.json().catch(()=>null);if(!p.ok){const h=f?.message??`HTTP ${p.status}`;return s(h),{kind:"network_error",message:h}}const b=f?.data,g=typeof b?.token=="string"?b.token:"",m=typeof b?.preview_url=="string"&&b.preview_url?b.preview_url:g?`/preview/${g}`:"";return m?(window.G7Core?.dispatch?.({handler:"openWindow",params:{path:m}}),{kind:"success",previewUrl:m,token:g}):(s("invalid preview response"),{kind:"network_error",message:"invalid preview response"})}catch(d){const c=d instanceof Error?d.message:"network error";return s(c),{kind:"network_error",message:c}}finally{o(!1)}},[e,t]);return{isCreating:n,error:r,createPreview:a}}const re="layout_editor.action_recipe",vn={setState:{label:`$t:${re}.set_state.label`,params:[{key:"target",label:`$t:${re}.set_state.param_target`,widget:"select",options:[{value:"local"},{value:"global"}]},{key:"state",label:`$t:${re}.set_state.param_state`,widget:"state-key-value"},{key:"merge",label:`$t:${re}.set_state.param_merge`,widget:"toggle"}],build:{handler:"setState",params:{target:"{{target}}",merge:"{{merge}}","...":"{{state}}"}}},loadFromLocalStorage:{label:`$t:${re}.load_local.label`,params:[{key:"key",label:`$t:${re}.load_local.param_key`,widget:"text",required:!0},{key:"stateKey",label:`$t:${re}.load_local.param_state_key`,widget:"state-key-picker"},{key:"defaultValue",label:`$t:${re}.load_local.param_default`,widget:"text"}],build:{handler:"loadFromLocalStorage",params:{key:"{{key}}",stateKey:"{{stateKey}}",defaultValue:"{{defaultValue}}"}}},saveToLocalStorage:{label:`$t:${re}.save_local.label`,params:[{key:"key",label:`$t:${re}.save_local.param_key`,widget:"text",required:!0},{key:"value",label:`$t:${re}.save_local.param_value`,widget:"data-chip"}],build:{handler:"saveToLocalStorage",params:{key:"{{key}}",value:"{{value}}"}}},navigate:{label:`$t:${re}.navigate.label`,params:[{key:"path",label:`$t:${re}.navigate.param_path`,widget:"page-picker",required:!0},{key:"query",label:`$t:${re}.navigate.param_query`,widget:"key-value"},{key:"mergeQuery",label:`$t:${re}.navigate.param_merge_query`,widget:"toggle"},{key:"scroll",label:`$t:${re}.navigate.param_scroll`,widget:"select",options:[{value:"top"},{value:"preserve"},{value:"none"}]},{key:"replace",label:`$t:${re}.navigate.param_replace`,widget:"toggle"},{key:"transition_overlay_target",label:`$t:${re}.navigate.param_overlay_target`,widget:"component-target-picker",dependsOn:{param:"replace",equals:!0}}],build:{handler:"navigate",params:{path:"{{path}}",query:"{{query}}",mergeQuery:"{{mergeQuery}}",scroll:"{{scroll}}",replace:"{{replace}}",transition_overlay_target:"{{transition_overlay_target}}"}}},openWindow:{label:`$t:${re}.open_window.label`,params:[{key:"target",label:`$t:${re}.open_window.param_target`,widget:"page-picker",required:!0},{key:"windowTarget",label:`$t:${re}.open_window.param_window_target`,widget:"select",options:[{value:"_blank"},{value:"_self"}]}],build:{handler:"openWindow",target:"{{target}}",params:{windowTarget:"{{windowTarget}}"}}},navigateBack:{label:`$t:${re}.navigate_back.label`,params:[],build:{handler:"navigateBack"}},navigateForward:{label:`$t:${re}.navigate_forward.label`,params:[],build:{handler:"navigateForward"}},replaceUrl:{label:`$t:${re}.replace_url.label`,params:[{key:"path",label:`$t:${re}.replace_url.param_path`,widget:"page-picker"},{key:"query",label:`$t:${re}.replace_url.param_query`,widget:"key-value"}],build:{handler:"replaceUrl",params:{path:"{{path}}",query:"{{query}}"}}},toast:{label:`$t:${re}.toast.label`,params:[{key:"message",label:`$t:${re}.toast.param_message`,widget:"i18n-text",required:!0},{key:"type",label:`$t:${re}.toast.param_type`,widget:"select",options:[{value:"info"},{value:"success"},{value:"warning"},{value:"error"}]},{key:"duration",label:`$t:${re}.toast.param_duration`,widget:"number"},{key:"icon",label:`$t:${re}.toast.param_icon`,widget:"text"}],build:{handler:"toast",params:{message:"{{message}}",type:"{{type}}",duration:"{{duration}}",icon:"{{icon}}"}}},openModal:{label:`$t:${re}.open_modal.label`,params:[{key:"target",label:`$t:${re}.open_modal.param_target`,widget:"modal-picker",required:!0}],build:{handler:"openModal",target:"{{target}}"}},closeModal:{label:`$t:${re}.close_modal.label`,params:[],build:{handler:"closeModal"}},showAlert:{label:`$t:${re}.show_alert.label`,params:[{key:"target",label:`$t:${re}.show_alert.param_message`,widget:"i18n-text",required:!0}],build:{handler:"showAlert",target:"{{target}}"}},setError:{label:`$t:${re}.set_error.label`,params:[{key:"target",label:`$t:${re}.set_error.param_message`,widget:"i18n-text"},{key:"stateTarget",label:`$t:${re}.set_error.param_state_target`,widget:"select",options:[{value:"local"},{value:"global"}]}],build:{handler:"setError",target:"{{target}}",params:{stateTarget:"{{stateTarget}}"}}},refetchDataSource:{label:`$t:${re}.refetch.label`,params:[{key:"dataSourceId",label:`$t:${re}.refetch.param_data_source`,widget:"datasource-picker",required:!0},{key:"sync",label:`$t:${re}.refetch.param_sync`,widget:"toggle"}],build:{handler:"refetchDataSource",params:{dataSourceId:"{{dataSourceId}}",sync:"{{sync}}"}}},appendDataSource:{label:`$t:${re}.append_data.label`,params:[{key:"dataSourceId",label:`$t:${re}.append_data.param_data_source`,widget:"datasource-picker",required:!0},{key:"dataPath",label:`$t:${re}.append_data.param_data_path`,widget:"text"},{key:"newData",label:`$t:${re}.append_data.param_new_data`,widget:"data-chip"}],build:{handler:"appendDataSource",params:{dataSourceId:"{{dataSourceId}}",dataPath:"{{dataPath}}",newData:"{{newData}}"}}},updateDataSource:{label:`$t:${re}.update_data.label`,params:[{key:"dataSourceId",label:`$t:${re}.update_data.param_data_source`,widget:"datasource-picker",required:!0},{key:"data",label:`$t:${re}.update_data.param_data`,widget:"data-chip"},{key:"merge",label:`$t:${re}.update_data.param_merge`,widget:"toggle"}],build:{handler:"updateDataSource",params:{dataSourceId:"{{dataSourceId}}",data:"{{data}}",merge:"{{merge}}"}}},scrollIntoView:{label:`$t:${re}.scroll.label`,params:[{key:"selector",label:`$t:${re}.scroll.param_selector`,widget:"text",required:!0},{key:"behavior",label:`$t:${re}.scroll.param_behavior`,widget:"select",options:[{value:"smooth"},{value:"auto"}]},{key:"block",label:`$t:${re}.scroll.param_block`,widget:"select",options:[{value:"start"},{value:"center"},{value:"end"},{value:"nearest"}]}],build:{handler:"scrollIntoView",params:{selector:"{{selector}}",behavior:"{{behavior}}",block:"{{block}}"}}},login:{label:`$t:${re}.login.label`,params:[{key:"body",label:`$t:${re}.login.param_body`,widget:"key-value"}],build:{handler:"login",params:{body:"{{body}}"}}},loginTwoFactor:{label:`$t:${re}.login_two_factor.label`,params:[{key:"body",label:`$t:${re}.login_two_factor.param_body`,widget:"key-value"}],build:{handler:"loginTwoFactor",params:{body:"{{body}}"}}},loginTwoFactorResend:{label:`$t:${re}.login_two_factor_resend.label`,params:[{key:"body",label:`$t:${re}.login_two_factor_resend.param_body`,widget:"key-value"}],build:{handler:"loginTwoFactorResend",params:{body:"{{body}}"}}},logout:{label:`$t:${re}.logout.label`,params:[{key:"target",label:`$t:${re}.logout.param_target`,widget:"text"}],build:{handler:"logout",target:"{{target}}"}},setLocale:{label:`$t:${re}.set_locale.label`,params:[{key:"target",label:`$t:${re}.set_locale.param_target`,widget:"locale-picker",required:!0}],build:{handler:"setLocale",target:"{{target}}"}},emitEvent:{label:`$t:${re}.emit_event.label`,params:[{key:"event",label:`$t:${re}.emit_event.param_event`,widget:"text",required:!0},{key:"data",label:`$t:${re}.emit_event.param_data`,widget:"data-chip"}],build:{handler:"emitEvent",params:{event:"{{event}}",data:"{{data}}"}}},apiCall:{label:`$t:${re}.api_call.label`,params:[{key:"target",label:`$t:${re}.api_call.param_target`,widget:"page-picker",required:!0},{key:"method",label:`$t:${re}.api_call.param_method`,widget:"select",options:[{value:"GET"},{value:"POST"},{value:"PUT"},{value:"PATCH"},{value:"DELETE"}]},{key:"body",label:`$t:${re}.api_call.param_body`,widget:"key-value"},{key:"query",label:`$t:${re}.api_call.param_query`,widget:"key-value"},{key:"identity_target_email",label:`$t:${re}.api_call.param_identity_target_email`,widget:"data-chip"},{key:"identity_target_phone",label:`$t:${re}.api_call.param_identity_target_phone`,widget:"data-chip"},{key:"onSuccess",label:`$t:${re}.api_call.param_on_success`,widget:"action-list"},{key:"onError",label:`$t:${re}.api_call.param_on_error`,widget:"action-list"}],build:{handler:"apiCall",target:"{{target}}",identity_target:{email:"{{identity_target_email}}",phone:"{{identity_target_phone}}"},onSuccess:"{{onSuccess}}",onError:"{{onError}}",params:{method:"{{method}}",body:"{{body}}",query:"{{query}}"}}},conditions:{label:`$t:${re}.conditions.label`,params:[{key:"branches",label:`$t:${re}.conditions.param_branches`,widget:"branch-list"}],build:{handler:"conditions",conditions:"{{branches}}"}},sequence:{label:`$t:${re}.sequence.label`,params:[{key:"actions",label:`$t:${re}.sequence.param_actions`,widget:"action-list"}],build:{handler:"sequence",params:{actions:"{{actions}}"}}},parallel:{label:`$t:${re}.parallel.label`,params:[{key:"actions",label:`$t:${re}.parallel.param_actions`,widget:"action-list"}],build:{handler:"parallel",params:{actions:"{{actions}}"}}},switch:{label:`$t:${re}.switch.label`,params:[{key:"value",label:`$t:${re}.switch.param_value`,widget:"data-chip"},{key:"cases",label:`$t:${re}.switch.param_cases`,widget:"action-list",advanced:!0}],build:{handler:"switch",params:{value:"{{value}}",cases:"{{cases}}"}}},suppress:{label:`$t:${re}.suppress.label`,params:[],build:{handler:"suppress"}}};function v8(){return{actionRecipes:vn,initActionRecipes:vn,errorRecipes:{navigate:vn.navigate,openModal:vn.openModal,toast:vn.toast,setState:vn.setState,sequence:vn.sequence,parallel:vn.parallel,showErrorPage:{label:`$t:${re}.show_error_page.label`,params:[{key:"target",label:`$t:${re}.show_error_page.param_target`,widget:"select",options:[{value:"content"},{value:"full"}]}],build:{handler:"showErrorPage",params:{target:"{{target}}"}}}}}}function sl(e,t){return typeof e.label=="string"?e.label.startsWith("$t:")?t(e.label.slice(3)):e.label:String(e.value)}function $i(e){return Array.isArray(e.options)?e.options:[]}function _8({control:e,value:t,onChange:n,t:o}){const r=$i(e);return i.jsx("div",{className:"g7le-widget g7le-widget--segmented","data-testid":"g7le-widget-segmented",style:N8,children:r.map(s=>{const a=s.value===t;return i.jsx("button",{type:"button","data-testid":`g7le-segment-${String(s.value)}`,"data-active":a?"true":"false",onClick:()=>n(a?void 0:s.value),style:{...O8,background:a?"#2563eb":"#fff",color:a?"#fff":"#0f172a",borderColor:a?"#2563eb":"#cbd5e1"},children:sl(s,o)},String(s.value))})})}function x8({control:e,value:t,onChange:n,t:o}){const r=Array.isArray(e.scale)?e.scale:[],s=r.findIndex(l=>l===t),a=t!=null;return i.jsxs("div",{className:"g7le-widget g7le-widget--slider","data-testid":"g7le-widget-slider",style:eh,children:[i.jsxs("label",{style:al,children:[i.jsx("input",{type:"checkbox","data-testid":"g7le-slider-enabled",checked:a,onChange:l=>{l.target.checked?n(r.length>0?r[Math.max(0,s===-1?0:s)]:void 0):n(void 0)}}),i.jsx("span",{style:{fontSize:12,color:"#64748b"},children:o("layout_editor.control.use")})]}),i.jsx("input",{type:"range","data-testid":"g7le-slider-range",min:0,max:Math.max(0,r.length-1),step:1,disabled:!a||r.length===0,value:s===-1?0:s,onChange:l=>{const d=Number(l.target.value);n(r[d])},style:{flex:1}}),i.jsx("span",{"data-testid":"g7le-slider-value",style:{fontSize:12,color:"#0f172a",minWidth:48,textAlign:"right"},children:a?String(t):o("layout_editor.control.default")})]})}function w8({control:e,value:t,onChange:n,t:o}){const r=$i(e);return i.jsxs("select",{className:"g7le-widget g7le-widget--select","data-testid":"g7le-widget-select",value:t==null?"":String(t),onChange:s=>{const a=s.target.value;if(a===""){n(void 0);return}const l=r.find(d=>String(d.value)===a);n(l?l.value:a)},style:B8,children:[i.jsx("option",{value:"",children:o("layout_editor.control.default")}),r.map(s=>i.jsx("option",{value:String(s.value),children:sl(s,o)},String(s.value)))]})}function k8({control:e,value:t,onChange:n}){const o=$i(e),r=o[1]?.value??!0,s=o[0]?.value??void 0,a=t===r;return i.jsx("button",{type:"button",className:"g7le-widget g7le-widget--toggle","data-testid":"g7le-widget-toggle",role:"switch","aria-checked":a,onClick:()=>n(a?s:r),style:{...W8,background:a?"#2563eb":"#cbd5e1"},children:i.jsx("span",{style:{...j8,transform:a?"translateX(18px)":"translateX(0)"}})})}function S8({control:e,value:t,onChange:n,t:o,freeValueDisabled:r}){const s=$i(e),a=t==null?"":String(t),[l,d]=u.useState(a);u.useEffect(()=>{d(a)},[a]);const c=p=>{const f=p.trim();if(f===""){n(void 0);return}n(f)};return i.jsxs("div",{className:"g7le-widget g7le-widget--dimension","data-testid":"g7le-widget-dimension",style:Jg,children:[r?i.jsx("div",{"data-testid":"g7le-dimension-free-disabled",style:L8,children:o("layout_editor.property_modal.dark_preset_only")}):i.jsxs("div",{style:Zg,children:[i.jsx("input",{type:"text","data-testid":"g7le-dimension-input",value:l,placeholder:o("layout_editor.control.dimension.placeholder"),onChange:p=>d(p.target.value),onBlur:p=>c(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),c(p.target.value))},style:Qg}),i.jsx("button",{type:"button","data-testid":"g7le-dimension-clear",title:o("layout_editor.control.default"),onClick:()=>{d(""),n(void 0)},style:Rg,children:o("layout_editor.control.default")})]}),s.length>0&&i.jsx("div",{style:M8,"data-testid":"g7le-dimension-chips",children:s.map(p=>{const f=String(p.value),b=f===a;return i.jsx("button",{type:"button","data-testid":`g7le-dimension-chip-${f}`,"data-active":b?"true":"false",onClick:()=>{d(f),n(f)},style:{...P8,background:b?"#2563eb":"#fff",color:b?"#fff":"#0f172a",borderColor:b?"#2563eb":"#cbd5e1"},children:sl(p,o)},f)})})]})}function C8({control:e,value:t,onChange:n,t:o}){const r=e,s=t==null?"":String(t),[a,l]=u.useState(s);u.useEffect(()=>{l(s)},[s]);const d=c=>{const p=c.trim();if(p===""){n(void 0);return}const f=Number(p);Number.isFinite(f)&&n(f)};return i.jsx("div",{className:"g7le-widget g7le-widget--number","data-testid":"g7le-widget-number",style:Jg,children:i.jsxs("div",{style:Zg,children:[i.jsx("input",{type:"text",inputMode:"numeric","data-testid":"g7le-number-input",value:a,placeholder:o("layout_editor.control.number.placeholder"),min:typeof r.min=="number"?r.min:void 0,max:typeof r.max=="number"?r.max:void 0,step:typeof r.step=="number"?r.step:void 0,onChange:c=>l(c.target.value),onBlur:c=>d(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),d(c.target.value))},style:Qg}),i.jsx("button",{type:"button","data-testid":"g7le-number-clear",title:o("layout_editor.control.default"),onClick:()=>{l(""),n(void 0)},style:Rg,children:o("layout_editor.control.default")})]})})}function $8(e){return[{key:"t",infix:`${e}t-`,labelKey:"layout_editor.control.spacing.top"},{key:"r",infix:`${e}r-`,labelKey:"layout_editor.control.spacing.right"},{key:"b",infix:`${e}b-`,labelKey:"layout_editor.control.spacing.bottom"},{key:"l",infix:`${e}l-`,labelKey:"layout_editor.control.spacing.left"}]}function E8(e,t,n,o){const r={all:-1,sides:{}};if(typeof e!="string"||e.trim()==="")return r;const s=e.split(/\s+/).filter(a=>a.length>0);for(const a of s){const l=n.find(d=>a.startsWith(d.infix));if(l){r.sides[l.key]=o.indexOf(a.slice(l.infix.length));continue}if(a.startsWith(`${t}x-`)){const d=o.indexOf(a.slice(`${t}x-`.length));r.sides.l=d,r.sides.r=d;continue}if(a.startsWith(`${t}y-`)){const d=o.indexOf(a.slice(`${t}y-`.length));r.sides.t=d,r.sides.b=d;continue}a.startsWith(`${t}-`)&&(r.all=o.indexOf(a.slice(`${t}-`.length)))}return r}function I8({control:e,value:t,onChange:n,t:o}){const r=typeof e.spacingPrefix=="string"?e.spacingPrefix:"p",s=(Array.isArray(e.scale)?e.scale:[]).map(y=>String(y)),a=$8(r),l=E8(t,r,a,s),d=Object.values(l.sides).some(y=>y>=0),c=l.all>=0||d,[p,f]=u.useState(d);u.useEffect(()=>{d&&f(!0)},[d]);const b=Math.min(4,Math.max(0,s.length-1)),g=y=>{const _=[];for(const w of a){const k=y[w.key];k!==void 0&&k>=0&&_.push(`${w.infix}${s[k]}`)}n(_.length>0?_.join(" "):void 0)},m=y=>{n(y>=0?`${r}-${s[Math.max(0,Math.min(y,s.length-1))]}`:void 0)},h=()=>({...l.sides}),v=(y,_,w,k,x)=>{const $=w>=0;return i.jsxs("div",{style:z8,"data-testid":y,children:[i.jsxs("label",{style:{...al,minWidth:64},children:[i.jsx("input",{type:"checkbox","data-testid":`${y}-enabled`,checked:$,onChange:C=>x(C.target.checked)}),i.jsx("span",{style:{fontSize:12,color:"#0f172a"},children:o(_)})]}),i.jsx("input",{type:"range","data-testid":`${y}-range`,min:0,max:Math.max(0,s.length-1),step:1,disabled:!$||s.length===0,value:w<0?0:w,onChange:C=>k(Number(C.target.value)),style:{flex:1}}),i.jsx("span",{"data-testid":`${y}-value`,style:{fontSize:12,color:$?"#0f172a":"#94a3b8",minWidth:28,textAlign:"right"},children:$?s[w]:"–"})]},y)};return i.jsxs("div",{className:"g7le-widget g7le-widget--spacing","data-testid":"g7le-widget-spacing",style:A8,children:[i.jsxs("div",{style:T8,children:[i.jsxs("div",{style:D8,"data-testid":"g7le-spacing-mode",children:[i.jsx("button",{type:"button","data-testid":"g7le-spacing-mode-all","data-active":p?"false":"true",onClick:()=>{f(!1),d&&n(void 0)},style:{...Xg,background:p?"#fff":"#2563eb",color:p?"#0f172a":"#fff",borderColor:p?"#cbd5e1":"#2563eb"},children:o("layout_editor.control.spacing.mode_all")}),i.jsx("button",{type:"button","data-testid":"g7le-spacing-mode-sides","data-active":p?"true":"false",onClick:()=>{if(f(!0),l.all>=0){const y={};for(const _ of a)y[_.key]=l.all;g(y)}},style:{...Xg,background:p?"#2563eb":"#fff",color:p?"#fff":"#0f172a",borderColor:p?"#2563eb":"#cbd5e1"},children:o("layout_editor.control.spacing.mode_sides")})]}),i.jsx("span",{"data-testid":"g7le-spacing-value",style:{fontSize:11,color:"#64748b",minWidth:80,textAlign:"right"},children:c?String(t):o("layout_editor.control.default")})]}),p?i.jsx("div",{"data-testid":"g7le-spacing-sides",style:{display:"flex",flexDirection:"column",gap:4},children:a.map(y=>v(`g7le-spacing-side-${y.key}`,y.labelKey,l.sides[y.key]??-1,_=>{const w=h();w[y.key]=_,g(w)},_=>{const w=h();_?w[y.key]=l.sides[y.key]>=0?l.sides[y.key]:b:delete w[y.key],g(w)}))}):i.jsxs("div",{style:eh,children:[i.jsxs("label",{style:{...al,minWidth:64},children:[i.jsx("input",{type:"checkbox","data-testid":"g7le-spacing-all-enabled",checked:l.all>=0,onChange:y=>m(y.target.checked?b:-1)}),i.jsx("span",{style:{fontSize:12,color:"#64748b"},children:o("layout_editor.control.spacing.all")})]}),i.jsx("input",{type:"range","data-testid":"g7le-spacing-all-range",min:0,max:Math.max(0,s.length-1),step:1,disabled:l.all<0||s.length===0,value:l.all<0?0:l.all,onChange:y=>m(Number(y.target.value)),style:{flex:1}}),i.jsx("span",{"data-testid":"g7le-spacing-all-value",style:{fontSize:12,color:l.all>=0?"#0f172a":"#94a3b8",minWidth:28,textAlign:"right"},children:l.all>=0?s[l.all]:"–"})]})]})}const A8={display:"flex",flexDirection:"column",gap:6,width:"100%"},T8={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},D8={display:"inline-flex",gap:0,border:"1px solid #cbd5e1",borderRadius:6,overflow:"hidden"},Xg={padding:"3px 10px",fontSize:11,border:"none",borderRight:"1px solid #e2e8f0",cursor:"pointer"},z8={display:"flex",alignItems:"center",gap:8,width:"100%"},N8={display:"inline-flex",gap:0,border:"1px solid #cbd5e1",borderRadius:6,overflow:"hidden"},Jg={display:"flex",flexDirection:"column",gap:6,width:"100%"},Zg={display:"flex",gap:6,alignItems:"center"},Qg={flex:1,padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,minWidth:80},Rg={padding:"4px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#64748b",cursor:"pointer",whiteSpace:"nowrap"},M8={display:"flex",flexWrap:"wrap",gap:4},L8={fontSize:11,color:"#94a3b8",fontStyle:"italic",padding:"2px 0"},P8={padding:"3px 9px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:999,background:"#fff",cursor:"pointer"},O8={padding:"4px 10px",fontSize:12,border:"none",borderRight:"1px solid #e2e8f0",cursor:"pointer"},eh={display:"flex",alignItems:"center",gap:8,width:"100%"},al={display:"inline-flex",alignItems:"center",gap:4},B8={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",minWidth:120},W8={position:"relative",width:38,height:20,borderRadius:10,border:"none",cursor:"pointer",padding:2,display:"inline-flex",alignItems:"center",transition:"background 120ms ease"},j8={display:"block",width:16,height:16,borderRadius:8,background:"#fff",transition:"transform 120ms ease"},H8=["#0f172a","#334155","#64748b","#94a3b8","#e2e8f0","#ffffff","#dc2626","#ea580c","#d97706","#16a34a","#0891b2","#2563eb","#7c3aed","#db2777"],th=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;function F8(e){return Array.isArray(e.options)?e.options.filter(t=>typeof t.value=="string").map(t=>({value:t.value,swatch:typeof t.swatch=="string"?t.swatch:void 0,label:typeof t.label=="string"?t.label:void 0})):[]}function K8({control:e,value:t,onChange:n,t:o,freeValueDisabled:r}){const s=F8(e),a=s.length>0,l=typeof t=="string"&&s.some(g=>g.value===t)?t:"",d=typeof t=="string"&&th.test(t)?t:"",[c,p]=u.useState(d);u.useEffect(()=>{p(d)},[d]);const f=g=>{const m=g.trim();if(m===""){n(void 0);return}const h=m.startsWith("#")?m:`#${m}`;th.test(h)&&n(h)},b=H8;return i.jsxs("div",{className:"g7le-widget g7le-widget--color","data-testid":"g7le-widget-color",style:V8,children:[r?i.jsx("div",{"data-testid":"g7le-color-free-disabled",style:J8,children:o("layout_editor.property_modal.dark_preset_only")}):i.jsxs("div",{style:U8,children:[i.jsxs("label",{style:q8,children:[i.jsx("span",{"data-testid":"g7le-color-swatch",style:{...G8,background:d||"transparent",backgroundImage:d?void 0:"linear-gradient(45deg,#e2e8f0 25%,transparent 25%,transparent 75%,#e2e8f0 75%),linear-gradient(45deg,#e2e8f0 25%,#fff 25%,#fff 75%,#e2e8f0 75%)",backgroundSize:"8px 8px",backgroundPosition:"0 0, 4px 4px"}}),i.jsx("input",{type:"color","data-testid":"g7le-color-native",value:d||"#000000",onChange:g=>n(g.target.value),style:{width:0,height:0,opacity:0,position:"absolute"}})]}),i.jsx("input",{type:"text","data-testid":"g7le-color-hex",value:c,placeholder:o("layout_editor.control.color_hex_placeholder"),onChange:g=>p(g.target.value),onBlur:g=>f(g.target.value),onKeyDown:g=>{g.key==="Enter"&&f(g.target.value)},style:Y8}),i.jsx("button",{type:"button","data-testid":"g7le-color-clear",onClick:()=>n(void 0),style:X8,children:o("layout_editor.control.default")})]}),a?i.jsx("div",{style:nh,"data-testid":"g7le-color-token-presets",children:s.map(g=>{const m=l===g.value,h=g.label?g.label.startsWith("$t:")?o(g.label.slice(3)):g.label:g.value;return i.jsx("button",{type:"button","aria-label":h,title:h,"data-testid":`g7le-color-token-${g.value}`,"data-active":m?"true":"false",onClick:()=>n(m?void 0:g.value),style:{...oh,background:g.swatch||"#e2e8f0",outline:m?"2px solid #2563eb":"none"}},g.value)})}):!r&&i.jsx("div",{style:nh,"data-testid":"g7le-color-presets",children:b.map(g=>i.jsx("button",{type:"button","aria-label":g,"data-testid":`g7le-color-preset-${g}`,onClick:()=>n(g),style:{...oh,background:g,outline:d.toLowerCase()===g.toLowerCase()?"2px solid #2563eb":"none"}},g))})]})}const V8={display:"flex",flexDirection:"column",gap:8},U8={display:"flex",alignItems:"center",gap:6},q8={position:"relative",display:"inline-flex",cursor:"pointer"},G8={width:24,height:24,borderRadius:4,border:"1px solid #cbd5e1",display:"inline-block"},Y8={flex:1,padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,fontFamily:"monospace"},X8={padding:"4px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",cursor:"pointer",color:"#64748b"},nh={display:"grid",gridTemplateColumns:"repeat(7, 1fr)",gap:4},oh={width:"100%",height:18,borderRadius:4,border:"1px solid #cbd5e1",cursor:"pointer",padding:0},J8={fontSize:11,color:"#94a3b8",fontStyle:"italic",padding:"2px 0"},rr=[{value:"fill",labelKey:"layout_editor.control.background_image.mode_fill",size:"cover",repeat:"no-repeat"},{value:"fit",labelKey:"layout_editor.control.background_image.mode_fit",size:"contain",repeat:"no-repeat"},{value:"tile",labelKey:"layout_editor.control.background_image.mode_tile",size:"auto",repeat:"repeat"}];function rh(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function ih(e){return rr.find(n=>n.size===e.size&&n.repeat===e.repeat)?.value??"fill"}function Z8(e){if(!e)return!1;const t=[],n=e.apply;n&&typeof n=="object"&&t.push(n);for(const o of e.options??[])o&&typeof o=="object"&&o.apply&&typeof o.apply=="object"&&t.push(o.apply);return t.length===0?!1:t.every(o=>o.type==="propValue"||o.type==="cssVar"||o.type==="styleProp"&&!Array.isArray(o.props))}function Q8({control:e,value:t,onChange:n,t:o}){const r=rh(t),s=Z8(e),a=Kf(t,I=>n({url:I}),I=>rh(I).url),l=a.bound,{state:d}=Qe(),c=vo(),[p,f]=u.useState(!1),[b,g]=u.useState(null),[m,h]=u.useState(r.url??""),[v,y]=u.useState([]),_=u.useRef(null),w=d.templateIdentifier,k=d.selectedRoute?.layoutName??"";u.useEffect(()=>{h(r.url??"")},[r.url]);const x=u.useCallback(async()=>{if(!w||!k){y([]);return}const I=await Wl(w,k);I.ok&&y(I.data)},[w,k]);u.useEffect(()=>{x()},[x]);const $=I=>{if(!I){n(void 0);return}if(s){n({url:I});return}const N=rr.find(T=>T.value===ih(r))??rr[0];n({url:I,size:r.size??N.size,repeat:r.repeat??N.repeat,position:r.position??"center"})},C=I=>{const N=rr.find(T=>T.value===I);!N||!r.url||n({url:r.url,size:N.size,repeat:N.repeat,position:r.position??"center"})},S=async I=>{const N=I.target.files?.[0];if(!N)return;f(!0),g(null);const T=await jl(w,k,N);T.ok?($(T.data.url),x()):g(o("layout_editor.control.background_image.upload_failed")),f(!1),_.current&&(_.current.value="")},D=async I=>{(await Hl(I.id)).ok&&y(T=>T.filter(B=>B.id!==I.id))},E=()=>{const I=c.open({ariaLabel:o("layout_editor.attachment_manager.title"),width:720,maxHeightRatio:.82,content:u.createElement(Fl,{templateIdentifier:w,layoutName:k,t:o,onSelect:N=>{$(N),c.close(I)},onChanged:()=>{x()},onClose:()=>c.close(I)})})};return i.jsxs("div",{className:"g7le-widget g7le-widget--image","data-testid":"g7le-widget-image",style:R8,children:[l?i.jsx(Uf,{expression:r.url??"",t:o,onReplace:a.beginReplace,testIdPrefix:"g7le-image"}):r.url&&i.jsx("div",{"data-testid":"g7le-image-preview",style:{...ez,backgroundImage:`url(${r.url})`,backgroundSize:s?"contain":r.size??"cover",backgroundRepeat:s?"no-repeat":r.repeat??"no-repeat",backgroundPosition:s?"center":r.position??"center"}}),i.jsxs("div",{style:tz,children:[i.jsxs("label",{style:{...nz,...l?Ei:null},children:[p?"…":o("layout_editor.control.background_image.upload"),i.jsx("input",{ref:_,type:"file",accept:"image/*","data-testid":"g7le-image-file",onChange:S,disabled:p||l,style:{display:"none"}})]}),i.jsx("button",{type:"button","data-testid":"g7le-image-clear",disabled:l,onClick:()=>n(void 0),style:{...oz,...l?Ei:null},children:o("layout_editor.control.background_image.clear")})]}),i.jsx("input",{type:"text","data-testid":"g7le-image-url",placeholder:"https://… / URL",value:m,readOnly:l,onChange:I=>h(I.target.value),onBlur:I=>{l||$(I.target.value.trim()||void 0)},style:rz}),a.replacing&&a.original!==null&&i.jsx(qf,{t:o,onRestore:a.restore,testIdPrefix:"g7le-image"}),!s&&i.jsx("div",{style:iz,"data-testid":"g7le-image-modes",children:rr.map(I=>{const N=ih(r)===I.value;return i.jsx("button",{type:"button","data-testid":`g7le-image-mode-${I.value}`,"data-active":N?"true":"false",disabled:!r.url||l,onClick:()=>C(I.value),style:{...sz,background:N&&r.url?"#2563eb":"#fff",color:N&&r.url?"#fff":"#0f172a"},children:o(I.labelKey)},I.value)})}),i.jsxs("div",{style:az,"data-testid":"g7le-image-gallery",children:[i.jsxs("div",{style:lz,children:[i.jsx("span",{style:{fontSize:11,color:"#64748b"},children:o("layout_editor.attachment_manager.recent")}),i.jsxs("button",{type:"button","data-testid":"g7le-image-manage",disabled:l,onClick:E,style:{...dz,...l?Ei:null},children:["🖼 ",o("layout_editor.attachment_manager.manage_link")]})]}),v.length>0?i.jsx("div",{style:cz,"data-testid":"g7le-image-thumbs",children:v.slice(0,8).map(I=>i.jsxs("div",{style:uz,"data-testid":`g7le-image-thumb-${I.id}`,children:[i.jsx("button",{type:"button",title:I.original_name,disabled:l,onClick:()=>$(I.url),style:{...pz,backgroundImage:`url(${I.url})`,...l?Ei:null},"data-testid":`g7le-image-thumb-use-${I.id}`}),i.jsx("button",{type:"button",title:o("layout_editor.attachment_manager.delete"),onClick:()=>D(I),style:fz,"data-testid":`g7le-image-thumb-del-${I.id}`,children:"✕"})]},I.id))}):i.jsx("span",{style:{fontSize:11,color:"#94a3b8"},children:o("layout_editor.attachment_manager.empty")})]}),b&&i.jsx("span",{"data-testid":"g7le-image-error",style:{fontSize:11,color:"#dc2626"},children:b})]})}const R8={display:"flex",flexDirection:"column",gap:6},ez={width:"100%",height:80,borderRadius:6,border:"1px solid #cbd5e1"},tz={display:"flex",gap:6},nz={padding:"5px 10px",fontSize:12,border:"1px solid #2563eb",borderRadius:6,background:"#fff",color:"#2563eb",cursor:"pointer",display:"inline-flex",alignItems:"center"},oz={padding:"5px 10px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#64748b",cursor:"pointer"},rz={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6},Ei={opacity:.45,cursor:"not-allowed"},iz={display:"inline-flex",border:"1px solid #cbd5e1",borderRadius:6,overflow:"hidden"},sz={padding:"4px 10px",fontSize:12,border:"none",borderRight:"1px solid #e2e8f0",cursor:"pointer"},az={display:"flex",flexDirection:"column",gap:4,border:"1px solid #e2e8f0",borderRadius:6,padding:6,marginTop:2},lz={display:"flex",alignItems:"center",justifyContent:"space-between"},dz={fontSize:11,color:"#2563eb",background:"transparent",border:"none",cursor:"pointer",padding:0},cz={display:"flex",gap:6,flexWrap:"wrap"},uz={position:"relative",width:44,height:44},pz={width:44,height:44,borderRadius:6,border:"1px solid #cbd5e1",backgroundSize:"cover",backgroundPosition:"center",cursor:"pointer",padding:0},fz={position:"absolute",top:-6,right:-6,width:16,height:16,borderRadius:"50%",border:"none",background:"#dc2626",color:"#fff",fontSize:9,lineHeight:"16px",cursor:"pointer",padding:0};function gz(e){return Array.isArray(e)&&e.every(t=>t!==null&&typeof t=="object"&&!Array.isArray(t))}function hz(e){return typeof e=="string"&&/\{\{.*\}\}/.test(e)}function yz({value:e,onChange:t,t:n,bindingCandidates:o}){if(hz(e))return i.jsx("div",{className:"g7le-widget g7le-widget--options-list","data-testid":"g7le-widget-options-list-bound",style:Sz,children:n("layout_editor.list_editor.bound_degraded")});const r=gz(e)?e:[],s=b=>{t(b.length===0?void 0:b)},a=(b,g)=>{const m=r.map((h,v)=>v===b?{...h,...g}:h);s(m)},l=b=>{s(r.filter((g,m)=>m!==b))},d=(b,g)=>{const m=b+g;if(m<0||m>=r.length)return;const h=[...r];[h[b],h[m]]=[h[m],h[b]],s(h)},c=()=>{s([...r,{value:"",label:""}])},p=b=>typeof b.label=="string"?b.label:b.label==null?"":String(b.label),f=b=>b.value===void 0||b.value===null?"":String(b.value);return i.jsxs("div",{className:"g7le-widget g7le-widget--options-list","data-testid":"g7le-widget-options-list",style:bz,children:[r.length===0&&i.jsx("div",{"data-testid":"g7le-options-empty",style:kz,children:n("layout_editor.list_editor.empty")}),r.map((b,g)=>i.jsxs("div",{"data-testid":`g7le-options-row-${g}`,style:mz,children:[i.jsxs("div",{style:sh,children:[i.jsx("span",{style:ah,children:n("layout_editor.list_editor.option_value")}),i.jsx("input",{type:"text","data-testid":`g7le-options-value-${g}`,value:f(b),placeholder:n("layout_editor.list_editor.option_value"),onChange:m=>a(g,{value:m.target.value}),style:_z})]}),i.jsxs("div",{style:sh,children:[i.jsx("span",{style:ah,children:n("layout_editor.list_editor.option_label")}),i.jsx("div",{"data-testid":`g7le-options-label-${g}`,style:{flex:1,minWidth:0},children:i.jsx(_t,{value:p(b),onChange:m=>a(g,{label:m??""}),t:n,placeholder:n("layout_editor.list_editor.option_label"),testidPrefix:`g7le-options-label-i18n-${g}`,candidates:o,enableExpressionTree:!0,expressionTreeCollapsible:!0})})]}),i.jsxs("div",{style:vz,children:[i.jsx("button",{type:"button","data-testid":`g7le-options-up-${g}`,title:n("layout_editor.list_editor.move_up"),disabled:g===0,onClick:()=>d(g,-1),style:lh,children:"↑"}),i.jsx("button",{type:"button","data-testid":`g7le-options-down-${g}`,title:n("layout_editor.list_editor.move_down"),disabled:g===r.length-1,onClick:()=>d(g,1),style:lh,children:"↓"}),i.jsx("button",{type:"button","data-testid":`g7le-options-remove-${g}`,title:n("layout_editor.list_editor.remove"),onClick:()=>l(g),style:xz,children:"✕"})]})]},g)),i.jsx("button",{type:"button","data-testid":"g7le-options-add",onClick:c,style:wz,children:n("layout_editor.list_editor.add")})]})}const bz={display:"flex",flexDirection:"column",gap:8,width:"100%"},mz={display:"flex",flexDirection:"column",gap:4,width:"100%",minWidth:0,paddingBottom:6,borderBottom:"1px solid #f1f5f9"},sh={display:"flex",gap:6,alignItems:"center",width:"100%",minWidth:0},ah={flexShrink:0,width:36,fontSize:11,color:"#94a3b8",textAlign:"right"},vz={display:"flex",gap:4,alignItems:"center",justifyContent:"flex-end"},_z={flex:1,minWidth:0,padding:"4px 6px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6},lh={padding:"2px 6px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},xz={padding:"2px 6px",fontSize:12,border:"1px solid #fecaca",borderRadius:6,background:"#fff",color:"#dc2626",cursor:"pointer"},wz={padding:"4px 8px",fontSize:12,border:"1px dashed #94a3b8",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",alignSelf:"flex-start"},kz={fontSize:11,color:"#94a3b8",fontStyle:"italic"},Sz={fontSize:11,color:"#b45309",fontStyle:"italic",padding:"4px 2px"},dh=/[^A-Za-z0-9\-_:.]/g;function Cz(e){return typeof e=="string"&&br(e)}function ch(e){return br(e)?An(e).map(t=>t.kind==="binding"?t.raw:t.raw.replace(dh,"")).join(""):e.replace(dh,"")}const $z={width:"100%",padding:"6px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:4,fontFamily:"monospace"},Ez={marginTop:4,fontSize:11,color:"#94a3b8"},Iz={display:"flex",gap:6,alignItems:"center"},Az={flexShrink:0,padding:"5px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:4,background:"#f8fafc",cursor:"pointer",whiteSpace:"nowrap"};function Tz({value:e,onChange:t,t:n,bindingCandidates:o}){const r=e==null?"":String(e),s=Cz(e),a=!!o&&o.length>0,[l,d]=u.useState(!1),c=p=>{const f=ch(p);t(f===""?void 0:f)};return s||l?i.jsxs("div",{"data-testid":"g7le-core-id-chip",children:[i.jsx(Ss,{value:r,onChange:c,t:n,candidates:o,onDone:()=>d(!1),testidPrefix:"g7le-core-id-chip-input"}),i.jsx("div",{style:Ez,children:n("layout_editor.core_props.id.binding_hint")})]}):i.jsx("div",{children:i.jsxs("div",{style:Iz,children:[i.jsx("input",{type:"text",className:"g7le-widget g7le-widget--core-id","data-testid":"g7le-widget-core-id",value:r,onChange:p=>{const f=ch(p.target.value);t(f===""?void 0:f)},spellCheck:!1,autoComplete:"off",style:$z}),a&&i.jsxs("button",{type:"button","data-testid":"g7le-core-id-add-data",onClick:()=>d(!0),style:Az,title:n("layout_editor.core_props.id.add_data"),children:["🔗 ",n("layout_editor.core_props.id.add_data")]})]})})}const Dz=/[^A-Za-z0-9.\-_]/g;function zz(e){return typeof e=="string"&&/\{\{[\s\S]*?\}\}/.test(e)}function Nz(e){return e.replace(Dz,"")}const uh={width:"100%",padding:"6px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:4,fontFamily:"monospace",boxSizing:"border-box"},Mz={...uh,background:"#f1f5f9",color:"#64748b",cursor:"not-allowed"},ph={marginTop:4,fontSize:11,color:"#94a3b8"};function Lz({value:e,onChange:t,t:n}){const o=e==null?"":String(e);return zz(e)?i.jsxs("div",{"data-testid":"g7le-core-datakey-bound",children:[i.jsx("input",{type:"text",className:"g7le-widget g7le-widget--core-datakey-bound","data-testid":"g7le-widget-core-datakey",value:o,readOnly:!0,disabled:!0,style:Mz}),i.jsx("div",{style:ph,children:n("layout_editor.core_props.dataKey.bound_degraded")})]}):i.jsxs("div",{children:[i.jsx("input",{type:"text",className:"g7le-widget g7le-widget--core-datakey","data-testid":"g7le-widget-core-datakey",value:o,placeholder:n("layout_editor.core_props.dataKey.placeholder"),onChange:s=>{const a=Nz(s.target.value);t(a===""?void 0:a)},spellCheck:!1,autoComplete:"off",style:uh}),i.jsx("div",{style:ph,children:n("layout_editor.core_props.dataKey.hint")})]})}let fh=!1;function Pz(){fh||(Ge("segmented",_8),Ge("slider",x8),Ge("select",w8),Ge("dimension",S8),Ge("number",C8),Ge("spacing",I8),Ge("toggle",k8),Ge("color",K8),Ge("image",Q8),Ge("tag-input",ks),Ge("page-picker",R0),Ge("datasource-picker",qc),Ge("binding-picker",qc),Ge("binding-list",nk),Ge("state-key-picker",Ms),Ge("modal-picker",ek),Ge("i18n-text",tk),Ge("text",ok),Ge("options-list",yz),Ge("core-id",Tz),Ge("core-datakey",Lz),Ge("component-target-picker",D4),fh=!0)}function ir(e){return Array.isArray(e.children)?e.children:[]}function sr(e){if(typeof e.text=="string")return[];let t=null;const n=(o,r)=>{const s=ir(o);for(let a=0;ad===o?ar(l,r,n):l);return{...e,children:a}}function gh(e,t){const n=r=>typeof r.props?.[t]=="string";if(n(e))return[];const o=(r,s)=>{const a=ir(r);for(let l=0;lc===r?hh(d,s,n,o):d);return{...e,children:l}}function Oz(e){return Array.isArray(e.children)?e.children:[]}function Bz(e){const t=e?.itemFields;if(!Array.isArray(t))return[{kind:"text"}];const n=[];for(const o of t){if(!o||typeof o!="object")continue;const r=o;r.kind==="text"?n.push({kind:"text",label:typeof r.label=="string"?r.label:void 0}):r.kind==="prop"&&typeof r.prop=="string"&&r.prop.length>0&&n.push({kind:"prop",prop:r.prop,label:typeof r.label=="string"?r.label:void 0})}return n.length>0?n:[{kind:"text"}]}function ll(e,t){if(!(typeof e!="string"||e.length===0))return e.startsWith("$t:")?t(e.slice(3)):e}function yh({node:e,params:t,spec:n,manifest:o,t:r,onPatchNode:s,templateIdentifier:a,candidates:l}){const d=typeof t?.childComponent=="string"?t.childComponent:null,c=t?.childTemplate&&typeof t.childTemplate=="object"?t.childTemplate:null,p=Bz(t),f=ll(typeof t?.childLabel=="string"?t.childLabel:void 0,r)??d??"",b=Oz(e),g=u.useCallback(x=>{s({...e,children:x})},[e,s]),m=u.useCallback(()=>{if(c)return JSON.parse(JSON.stringify(c));if(!d)return null;const x=n?.componentPalette?.entries?.[d];if(x?.defaultNode&&typeof x.defaultNode=="object")return JSON.parse(JSON.stringify(x.defaultNode));const $=o?.components??{};let C=null;for(const S of Object.values($))if(Array.isArray(S)){const D=S.find(E=>E.name===d);if(D){C=D;break}}return C?Bf(C):{type:"basic",name:d}},[c,d,n,o]),h=u.useCallback(()=>{const x=m();if(x){if(x.text==="")x.text=r("layout_editor.list_editor.new_item");else{const $=sr(x);if($!==null&&$.length>0){const C=Ii(x,$);if(C&&C.text===""){const S=ar(x,$,r("layout_editor.list_editor.new_item"));g([...b,S]);return}}}g([...b,x])}},[m,g,b,r]),v=u.useCallback(x=>{g(b.filter(($,C)=>C!==x))},[g,b]),y=u.useCallback((x,$)=>{const C=x+$;if(C<0||C>=b.length)return;const S=[...b];[S[x],S[C]]=[S[C],S[x]],g(S)},[g,b]),_=u.useCallback((x,$)=>{if(typeof $!="string"||$.length===0)return;const C=b[x];if(!C)return;const S=sr(C);if(S===null)return;const D=b.map((E,I)=>I===x?ar(E,S,$):E);g(D)},[b,g]),w=u.useCallback((x,$,C)=>{if(typeof C!="string"||C.length===0)return;const S=b[x];if(!S)return;const D=gh(S,$);if(D===null)return;const E=b.map((I,N)=>N===x?hh(I,D,$,C):I);g(E)},[b,g]);if(!d&&!c)return i.jsx("div",{className:"g7le-node-editor g7le-node-editor--children","data-testid":"g7le-children-editor-misconfigured",style:vh,children:r("layout_editor.list_editor.no_child_component")});const k=p.length>1||p.some(x=>x.label);return i.jsxs("div",{className:"g7le-node-editor g7le-node-editor--children","data-testid":"g7le-children-editor",style:Wz,children:[i.jsx("div",{style:jz,children:r("layout_editor.list_editor.items_title")}),b.length===0&&i.jsx("div",{"data-testid":"g7le-children-empty",style:vh,children:r("layout_editor.list_editor.empty")}),b.map((x,$)=>{const C=[];for(const D of p)if(D.kind==="text"){const E=sr(x),I=E!==null?Ii(x,E):null;I&&typeof I.text=="string"&&C.push({key:"text",caption:ll(D.label,r)??(k?r("layout_editor.list_editor.item_label"):void 0),value:I.text,onChange:N=>_($,N),testid:`g7le-children-i18n-${$}`})}else if(D.kind==="prop"&&D.prop){const E=gh(x,D.prop);if(E!==null){const N=Ii(x,E)?.props?.[D.prop];C.push({key:`prop-${D.prop}`,caption:ll(D.label,r)??D.prop,value:typeof N=="string"?N:"",onChange:T=>w($,D.prop,T),testid:`g7le-children-prop-${D.prop}-${$}`})}}const S=typeof x?.name=="string"?x.name:r("layout_editor.list_editor.item");return i.jsxs("div",{"data-testid":`g7le-children-row-${$}`,style:Hz,children:[C.length>0?C.map(D=>i.jsx("div",{style:bh,children:i.jsxs("div",{"data-testid":D.key==="text"?`g7le-children-text-${$}`:`g7le-children-field-${D.key}-${$}`,style:Fz,children:[D.caption!==void 0&&i.jsx("div",{"data-testid":`g7le-children-caption-${D.key}-${$}`,style:Kz,children:D.caption}),i.jsx(_t,{value:D.value,onChange:D.onChange,t:r,placeholder:r("layout_editor.list_editor.item_text"),testidPrefix:D.testid,candidates:l,enableExpressionTree:!0,expressionTreeCollapsible:!0})]})},D.key)):i.jsx("div",{style:bh,children:i.jsx("span",{"data-testid":`g7le-children-label-${$}`,style:Uz,children:S})}),i.jsxs("div",{style:Vz,children:[i.jsx("button",{type:"button","data-testid":`g7le-children-up-${$}`,title:r("layout_editor.list_editor.move_up"),disabled:$===0,onClick:()=>y($,-1),style:mh,children:"↑"}),i.jsx("button",{type:"button","data-testid":`g7le-children-down-${$}`,title:r("layout_editor.list_editor.move_down"),disabled:$===b.length-1,onClick:()=>y($,1),style:mh,children:"↓"}),i.jsx("button",{type:"button","data-testid":`g7le-children-remove-${$}`,title:r("layout_editor.list_editor.remove"),onClick:()=>v($),style:qz,children:"✕"})]})]},$)}),i.jsx("button",{type:"button","data-testid":"g7le-children-add",onClick:h,style:Gz,children:r("layout_editor.list_editor.add_child",{component:f})})]})}const Wz={display:"flex",flexDirection:"column",gap:6,width:"100%",marginBottom:12},jz={fontSize:12,fontWeight:700,color:"#0f172a",marginBottom:2},Hz={display:"flex",flexDirection:"column",gap:4,width:"100%",minWidth:0,paddingBottom:6,borderBottom:"1px solid #f1f5f9"},bh={display:"flex",gap:4,alignItems:"flex-start",width:"100%",minWidth:0},Fz={flex:1,minWidth:0},Kz={fontSize:11,color:"#64748b",marginBottom:2},Vz={display:"flex",gap:4,alignItems:"center",justifyContent:"flex-end"},Uz={flex:1,minWidth:0,padding:"4px 6px",fontSize:12,color:"#475569",fontStyle:"italic",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},mh={padding:"2px 6px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},qz={padding:"2px 6px",fontSize:12,border:"1px solid #fecaca",borderRadius:6,background:"#fff",color:"#dc2626",cursor:"pointer"},Gz={padding:"4px 8px",fontSize:12,border:"1px dashed #94a3b8",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",alignSelf:"flex-start"},vh={fontSize:11,color:"#94a3b8",fontStyle:"italic"},yo={rowContainer:"Tbody",row:"Tr",cell:"Td",headerCell:"Th",colSpanProp:"colSpan",rowSpanProp:"rowSpan"};function yt(e){return{rowContainer:e?.rowContainer??yo.rowContainer,row:e?.row??yo.row,cell:e?.cell??yo.cell,headerCell:e?.headerCell??yo.headerCell,colSpanProp:e?.colSpanProp??yo.colSpanProp,rowSpanProp:e?.rowSpanProp??yo.rowSpanProp}}function jn(e){return e?Array.isArray(e.children)?e.children:[]:[]}function _h(e,t){const n=e.props?.[t],o=typeof n=="number"?n:typeof n=="string"?parseInt(n,10):NaN;return Number.isFinite(o)&&o>=1?Math.floor(o):1}function Oe(e,t){const n=yt(t),o=[],r=jn(e),s=[];r.forEach((f,b)=>{(jn(f).some(h=>h.name===n.row)||f.name===n.rowContainer||f.name==="Thead"||f.name==="Tfoot")&&s.push({container:f,containerIndex:b,isHeader:f.name==="Thead"})}),s.length===0&&r.some(f=>f.name===n.row)&&s.push({container:e,containerIndex:-1,isHeader:!1});const a=[],l=[];let d=0,c=0;const p=f=>{for(;a.length<=f;)a.push([]);return a[f]};s.forEach((f,b)=>{jn(f.container).filter(m=>m.name===n.row).forEach((m,h)=>{const v=[],y=p(d);let _=0;jn(m).filter(k=>k.name===n.cell||k.name===n.headerCell).forEach((k,x)=>{for(;y[_];)_++;const $=_h(k,n.colSpanProp),C=_h(k,n.rowSpanProp),S={cell:k,sectionIndex:b,rowIndexInSection:h,cellIndexInRow:x,gridRow:d,gridCol:_,colSpan:$,rowSpan:C,isHeader:k.name===n.headerCell};v.push(S);for(let D=0;D=0?(a.push(s.containerIndex),l=jn(e)[s.containerIndex]??e):l=e;let d=-1,c=-1,p=null;const f=jn(l);for(let m=0;m=r.gridRow&&t=r.gridCol&&nr){s=!0;break}if(s)break}s||t.add(r)}const n=Array.from(t).sort((r,s)=>r-s),o=[];for(let r=0;re.rows.find(l=>(l.cells[0]?.gridRow??-1)===a)?.sectionIndex??e.rows[a]?.sectionIndex??0,o=new Set([0,t]);for(let a=1;aa){l=!0;break}if(l)break}l||o.add(a)}const r=Array.from(o).sort((a,l)=>a-l),s=[];for(let a=0;at>=a.start&&t=o.length?{ok:!1,reason:"boundary"}:o[r].sectionIndex!==o[s].sectionIndex?{ok:!1,reason:"section"}:{ok:!0}}function Ti(e,t,n){const o=xh(e),r=o.findIndex(a=>t>=a.start&&t=o.length?{ok:!1,reason:"boundary"}:{ok:!0}}function Ye(e){return e?Array.isArray(e.children)?e.children:[]:[]}function _n(e,t,n){const o={...e.props??{}};n<=1?delete o[t]:o[t]=n;const r={...e,props:o};return Object.keys(o).length===0&&delete r.props,r}function Di(e,t,n=!1){const o={type:"basic",name:n?e.headerCell:e.cell},r=t?.props?.className;return typeof r=="string"&&r&&(o.props={className:r}),o.text="",o}function lr(e,t){return e.name===t.cell||e.name===t.headerCell}function nt(e,t,n,o){const r=t.sections[n];if(!r)return e;if(r.containerIndex===-1)return o(e);const s=Ye(e).map((a,l)=>l===r.containerIndex?o(a):a);return{...e,children:s}}function bt(e,t,n,o){let r=-1;const s=Ye(e).map(a=>a.name===t&&(r++,r===n)?o(a):a);return{...e,children:s}}function zi(e,t,n){let o=-1;const r=Ye(e);for(let s=0;s0?nt(e,r,r.sections.length-1,_=>({..._,children:[...Ye(_),y]})):{...e,children:[...Ye(e),y]}}const s=Math.max(-1,Math.min(n,r.rows.length-1)),a=s<0?r.rows[0]:r.rows[s],l=a.cells[0]?.gridRow??s,d=s<0?0:l+1,c=a.sectionIndex,p=s<0?0:a.rowIndexInSection+1,f=[],b=[];let g=0;for(;g0?Ue(r,d-1,g):null;y&&y.gridRow+y.rowSpan>d&&y.rowSpan>1?(b.push(y),g+=y.colSpan):(f.push(Di(o)),g+=1)}let m=e;for(const y of b)m=nt(m,r,y.sectionIndex,_=>bt(_,o.row,y.rowIndexInSection,w=>({...w,children:Ye(w).map((k,x)=>x===y.cellIndexInRow?_n(k,o.rowSpanProp,y.rowSpan+1):k)})));const h={type:"basic",name:o.row,children:f},v=Oe(m,t);return m=nt(m,v,c,y=>{const _=Ye(y);let w=0,k=_.length;for(let x=0;x<_.length;x++)if(_[x].name===o.row){if(w===p){k=x;break}w++}return{...y,children:[..._.slice(0,k),h,..._.slice(k)]}}),m}function kh(e,t,n){const o=yt(t),r=Oe(e,t);if(n<0||n>=r.rows.length||r.rows.length<=1)return e;const s=r.rows[n],a=s.cells[0]?.gridRow??n;let l=e;const d=new Set;for(let p=0;pbt(b,o.row,f.rowIndexInSection,g=>({...g,children:Ye(g).map((m,h)=>h===f.cellIndexInRow?_n(m,o.rowSpanProp,f.rowSpan-1):m)})))),p+=f?f.colSpan:1}const c=Oe(l,t);return l=nt(l,c,s.sectionIndex,p=>{let f=-1;const b=Ye(p).filter(g=>g.name===o.row?(f++,f!==s.rowIndexInSection):!0);return{...p,children:b}}),l}function Sh(e,t,n,o){const r=yt(t),s=Oe(e,t);if(!Ai(s,n,o).ok)return e;const a=wh(s),l=a.findIndex(h=>n>=h.start&&ns.rows.filter(v=>{const y=v.cells[0]?.gridRow??-1;return v.sectionIndex===f&&y>=h.start&&yv.rowIndexInSection),g=b(c),m=b(p);return g.length===0||m.length===0?e:nt(e,s,f,h=>{const v=[...Ye(h)],y=[];v.forEach((M,O)=>{M.name===r.row&&y.push(O)});const _=g.map(M=>y[M]).filter(M=>M!==void 0),w=m.map(M=>y[M]).filter(M=>M!==void 0);if(_.length===0||w.length===0)return h;const k=_.map(M=>v[M]),x=w.map(M=>v[M]),$=Math.min(..._)n>=m.start&&nk.gridCol>=f.start&&k.gridColk.gridCol>=b.start&&k.gridColk.cellIndexInRow),_=v.map(k=>k.cellIndexInRow),w=Oe(g,t);g=nt(g,w,m.sectionIndex,k=>bt(k,r.row,m.rowIndexInSection,x=>{const $=[...Ye(x)],C=y.map(M=>zi(x,r,M)).filter(M=>M>=0),S=_.map(M=>zi(x,r,M)).filter(M=>M>=0);if(C.length===0||S.length===0)return x;const D=C.map(M=>$[M]),E=S.map(M=>$[M]),I=Math.min(...C,...S),N=Math.max(...C,...S),T=[...E,...D],B=[...$.slice(0,I),...T,...$.slice(N+1)];return{...x,children:B}}))}return g}function $h(e,t,n){const o=yt(t),r=Oe(e,t);if(r.rows.length===0||r.colCount===0)return cl(e,t,-1);const s=Math.max(0,Math.min(n+1,r.colCount));let a=e;const l=new Set;for(const d of r.rows){const c=d.cells[0]?.gridRow??0,p=s>0?Ue(r,c,s-1):null,f=s1){if(!l.has(p.cell)){l.add(p.cell);const h=Oe(a,t);a=nt(a,h,p.sectionIndex,v=>bt(v,o.row,p.rowIndexInSection,y=>({...y,children:Ye(y).map((_,w)=>w===p.cellIndexInRow?_n(_,o.colSpanProp,p.colSpan+1):_)})))}continue}if(p&&p.gridRow0&&d.cells.every(h=>h.isHeader),m=Oe(a,t);a=nt(a,m,d.sectionIndex,h=>bt(h,o.row,d.rowIndexInSection,v=>{const y=[...Ye(v)];let _;if(b<0)_=y.findIndex(w=>lr(w,o)),_<0&&(_=y.length);else{const w=zi(v,o,b);_=w<0?y.length:w+1}return y.splice(_,0,Di(o,void 0,g)),{...v,children:y}}))}return a}function Eh(e,t,n){const o=yt(t),r=Oe(e,t);if(n<0||n>=r.colCount||r.colCount<=1)return e;let s=e;const a=new Set;for(const l of r.rows){const d=l.cells[0]?.gridRow??0,c=Ue(r,d,n);if(!(!c||a.has(c.cell)||c.gridRow1){const p=Oe(s,t);s=nt(s,p,c.sectionIndex,f=>bt(f,o.row,c.rowIndexInSection,b=>({...b,children:Ye(b).map((g,m)=>m===c.cellIndexInRow?_n(g,o.colSpanProp,c.colSpan-1):g)})))}else{const p=Oe(s,t);s=nt(s,p,c.sectionIndex,f=>bt(f,o.row,c.rowIndexInSection,b=>{let g=-1;const m=Ye(b).filter(h=>lr(h,o)?(g++,g!==c.cellIndexInRow):!0);return{...b,children:m}}))}}return s}function ul(e,t,n,o,r,s){const a=yt(t),l=Oe(e,t),d=Math.min(n,r),c=Math.max(n,r),p=Math.min(o,s),f=Math.max(o,s);if(d===c&&p===f)return{table:e,ok:!1,reason:"single"};if(!l.valid)return{table:e,ok:!1,reason:"invalid-grid"};const b=new Set;for(let y=d;y<=c;y++)for(let _=p;_<=f;_++){const w=Ue(l,y,_);if(!w)return{table:e,ok:!1,reason:"hole"};if(w.gridRowc||w.gridCol+w.colSpan-1>f)return{table:e,ok:!1,reason:"not-rectangular"};b.add(w)}const g=Ue(l,d,p),m=Array.from(b).filter(y=>y!==g);let h=nt(e,l,g.sectionIndex,y=>bt(y,a.row,g.rowIndexInSection,_=>({..._,children:Ye(_).map((w,k)=>{if(k!==g.cellIndexInRow)return w;let x=_n(w,a.colSpanProp,f-p+1);return x=_n(x,a.rowSpanProp,c-d+1),x})})));const v=new Map;for(const y of m){const _=`${y.sectionIndex}:${y.rowIndexInSection}`,w=v.get(_)??[];w.push(y),v.set(_,w)}for(const[y,_]of v){const w=parseInt(y.split(":")[0],10),k=_[0].rowIndexInSection,x=new Set(_.map(C=>C.cellIndexInRow)),$=Oe(h,t);h=nt(h,$,w,C=>bt(C,a.row,k,S=>{let D=-1;const E=Ye(S).filter(I=>lr(I,a)?(D++,!x.has(D)):!0);return{...S,children:E}}))}return{table:h,ok:!0}}function Ih(e,t,n,o){const r=yt(t),s=Oe(e,t),a=Ue(s,n,o);if(!a||a.colSpan<=1&&a.rowSpan<=1)return e;const l=a.gridRow,d=a.gridCol,c=a.gridRow+a.rowSpan-1,p=a.gridCol+a.colSpan-1,f=a.isHeader,b=typeof a.cell.props?.className=="string"?a.cell.props.className:void 0;let g=nt(e,s,a.sectionIndex,m=>bt(m,r.row,a.rowIndexInSection,h=>({...h,children:Ye(h).map((v,y)=>{if(y!==a.cellIndexInRow)return v;let _=_n(v,r.colSpanProp,1);return _=_n(_,r.rowSpanProp,1),_})})));for(let m=l;m<=c;m++)for(let h=d;h<=p;h++){if(m===l&&h===d)continue;const v=Oe(g,t),y=v.rows.find(k=>k.cells.some(x=>x.gridRow===m))??v.rows[m];if(!y)continue;let _=-1;for(const k of y.cells)k.gridRow===m&&k.gridColbt(k,r.row,y.rowIndexInSection,x=>{const $=[...Ye(x)];let C;if(_<0)C=$.findIndex(S=>lr(S,r)),C<0&&(C=$.length);else{const S=zi(x,r,_);C=S<0?$.length:S+1}return $.splice(C,0,Di(r,w,f)),{...x,children:$}}))}return g}function Ni(e,t,n,o,r){const s=yt(t),a=Oe(e,t),l=Ue(a,n,o);return l?nt(e,a,l.sectionIndex,d=>bt(d,s.row,l.rowIndexInSection,c=>({...c,children:Ye(c).map((p,f)=>{if(f!==l.cellIndexInRow)return p;const b={...p.props??{}};r.trim()===""?delete b.className:b.className=r;const g={...p,props:b};return Object.keys(b).length===0&&delete g.props,g})}))):e}function Rt(e,t,n,o,r,s){const a=yt(t),l=Oe(e,t),d=Ue(l,n,o);return d?nt(e,l,d.sectionIndex,c=>bt(c,a.row,d.rowIndexInSection,p=>({...p,children:Ye(p).map((f,b)=>{if(b!==d.cellIndexInRow)return f;const g={...f.props??{}},m={...g.style??{}};!s||s.trim()===""?delete m[r]:m[r]=s,Object.keys(m).length===0?delete g.style:g.style=m;const h={...f,props:g};return Object.keys(g).length===0&&delete h.props,h})}))):e}function bo(e,t,n,o,r,s,a){const l=yt(t),d=Oe(e,t),c=Ue(d,n,o);if(!c)return e;const p=a==="dark";return nt(e,d,c.sectionIndex,f=>bt(f,l.row,c.rowIndexInSection,b=>({...b,children:Ye(b).map((g,m)=>{if(m!==c.cellIndexInRow)return g;const h={...g.props??{}},v=typeof h.className=="string"?h.className:"",y=MC(v,s,r,p);y===""?delete h.className:h.className=y;const _={...g,props:h};return Object.keys(h).length===0&&delete _.props,_})})))}function Ah(e,t,n,o,r){const s=yt(t),a=Oe(e,t),l=Ue(a,n,o);return l?nt(e,a,l.sectionIndex,d=>bt(d,s.row,l.rowIndexInSection,c=>({...c,children:Ye(c).map((p,f)=>f===l.cellIndexInRow?{...p,text:r}:p)}))):e}function Th(e,t,n,o,r){const s=yt(t),a=Oe(e,t),l=Ue(a,n,o);return l?nt(e,a,l.sectionIndex,d=>bt(d,s.row,l.rowIndexInSection,c=>({...c,children:Ye(c).map((p,f)=>f===l.cellIndexInRow?r:p)}))):e}const Dh=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;function Yz(e){return e.split(/\s+/).filter(Boolean)}function zh(e,t){for(const n of t)if(e===n||/^-?\d+$/.test(e.slice(n.length+1))&&e.startsWith(n+"-"))return!0;return!1}function Nh({className:e,catalog:t,t:n,onChange:o,colorScheme:r="light",onPresetToken:s,colorStyle:a,onColorStyle:l,disabled:d}){const c=t?.sides??[],p=t?.widths??[],f=t?.colors??[],b=r==="dark",g=u.useMemo(()=>c.map(E=>E.prefix),[c]),m=u.useMemo(()=>new Set(f.map(E=>E.token)),[f]),h=u.useMemo(()=>Yz(e),[e]),v=u.useMemo(()=>Zr(e,b),[e,b]),y=u.useMemo(()=>v.find(E=>m.has(E))??null,[v,m]),_=u.useMemo(()=>{const E=new Set;for(const I of c)h.some(T=>T===I.prefix||T.startsWith(I.prefix+"-")&&/^-?\d+$/.test(T.slice(I.prefix.length+1)))&&E.add(I.value);return E},[h,c]),w=u.useMemo(()=>{const E=h.find(N=>zh(N,g));if(!E)return"none";const I=p.filter(N=>N.value!=="none");for(const N of c){if(E===N.prefix)return I.find(T=>(T.suffix??"")==="")?.value??"thin";if(E.startsWith(N.prefix+"-")){const T=E.slice(N.prefix.length),B=I.find(M=>(M.suffix??"")===T);if(B)return B.value}}return"thin"},[h,g,c,p]);if(!t||c.length===0||p.length===0)return null;function k(E){return E.filter(I=>!zh(I,g))}function x(E,I){const N=k(h),T=p.find(O=>O.value===I);if(!T||I==="none"||E.size===0)return N.join(" ").trim();const B=T.suffix??"",M=[...N];for(const O of c)E.has(O.value)&&M.push(B?`${O.prefix}${B}`:O.prefix);return M.join(" ").trim()}const $=E=>{const I=new Set(_);I.has(E)?I.delete(E):(E==="all"?I.clear():I.delete("all"),I.add(E));const N=w==="none"?p.find(T=>T.value!=="none")?.value??"thin":w;o(x(I,N))},C=E=>{const I=_.size===0?new Set(["all"]):_;o(x(I,E))},S=E=>{s?.(E)},D=(E,I)=>E&&E.startsWith("$t:")?n(E.slice(3)):E||I;return i.jsxs("div",{className:"g7le-cell-border","data-testid":"g7le-cell-border",style:Xz,children:[i.jsx("div",{style:Jz,children:i.jsx("span",{style:Zz,children:n("layout_editor.table_editor.cell_border")})}),i.jsx("div",{style:pl,"data-testid":"g7le-cell-border-widths",children:p.map(E=>i.jsx("button",{type:"button",disabled:d,"data-testid":`g7le-cell-border-width-${E.value}`,"aria-pressed":w===E.value,onClick:()=>C(E.value),style:w===E.value?Mh:fl,children:D(E.label,E.value)},E.value))}),w!=="none"&&i.jsx("div",{style:pl,"data-testid":"g7le-cell-border-sides",children:c.map(E=>i.jsx("button",{type:"button",disabled:d,"data-testid":`g7le-cell-border-side-${E.value}`,"aria-pressed":_.has(E.value),onClick:()=>$(E.value),style:_.has(E.value)?Mh:fl,children:D(E.label,E.value)},E.value))}),w!=="none"&&(f.length>0||l)&&i.jsx(i.Fragment,{children:i.jsxs("div",{style:pl,"data-testid":"g7le-cell-border-colors",children:[f.map(E=>{const I=y===E.token;return i.jsx("button",{type:"button",disabled:d,title:D(E.label,E.value),"data-testid":`g7le-cell-border-color-${E.value}`,"aria-pressed":I,onClick:()=>S(E.token),style:{...Lh,background:E.swatch??"#fff",outline:I?"2px solid #2563eb":"1px solid #cbd5e1"}},E.value)}),l&&(()=>{const E=!!a&&f.some(N=>N.swatch&&N.swatch.toLowerCase()===a.toLowerCase()),I=!b&&!!a&&!E;return i.jsx("label",{title:n(b?"layout_editor.table_editor.dark_free_color_hint":"layout_editor.table_inplace.custom_color"),"data-testid":"g7le-cell-border-color-custom",style:{...Lh,position:"relative",overflow:"hidden",display:"inline-flex",alignItems:"center",justifyContent:"center",background:I&&Dh.test(a)?a:"conic-gradient(red, yellow, lime, aqua, blue, magenta, red)",outline:I?"2px solid #2563eb":"1px solid #cbd5e1",opacity:b?.4:1,cursor:b?"not-allowed":"pointer"},children:i.jsx("input",{type:"color",disabled:d||b,"data-testid":"g7le-cell-border-color-picker",value:a&&Dh.test(a)?a:"#000000",onChange:N=>l(N.target.value),style:{position:"absolute",width:0,height:0,opacity:0}})})})()]})})]})}const Xz={display:"flex",flexDirection:"column",gap:6},Jz={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},Zz={fontSize:12,fontWeight:600,color:"#475569"},pl={display:"flex",gap:4,flexWrap:"wrap",alignItems:"center"},fl={padding:"3px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},Mh={...fl,border:"1px solid #2563eb",background:"#eff6ff",color:"#1d4ed8",fontWeight:600},Lh={width:22,height:22,borderRadius:5,padding:0,cursor:"pointer",boxSizing:"border-box"},Ph=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;function Oh({colorStyle:e,className:t,catalog:n,t:o,colorScheme:r="light",onPresetToken:s,onCustomColor:a,onClear:l,disabled:d}){const c=n?.colors??[],p=r==="dark",f=e??"",b=Zr(t??"",p),g=c.find(_=>_.token&&b.includes(_.token))?.token??null,m=(_,w)=>_&&_.startsWith("$t:")?o(_.slice(3)):_||w,h=!g&&(p||f.trim()===""),v=!!f&&c.some(_=>_.swatch&&_.swatch.toLowerCase()===f.toLowerCase()),y=!p&&!!f&&!v;return i.jsxs("div",{className:"g7le-cell-fill","data-testid":"g7le-cell-fill",style:Qz,children:[i.jsx("div",{style:Rz,children:i.jsx("span",{style:eN,children:o("layout_editor.table_editor.cell_fill")})}),i.jsxs("div",{style:tN,"data-testid":"g7le-cell-fill-colors",children:[i.jsx("button",{type:"button",disabled:d,title:o("layout_editor.table_editor.cell_fill_none"),"data-testid":"g7le-cell-fill-none","aria-pressed":h,onClick:()=>l?.(),style:{...gl,background:"repeating-conic-gradient(#e2e8f0 0% 25%, #ffffff 0% 50%) 50% / 10px 10px",outline:h?"2px solid #2563eb":"1px solid #cbd5e1"}}),c.map(_=>{const w=!!_.token&&g===_.token,k=!p&&!!_.swatch&&f.toLowerCase()===(_.swatch??"").toLowerCase(),x=w||k,$=d||p&&!_.token;return i.jsx("button",{type:"button",disabled:$,title:m(_.label,_.value),"data-testid":`g7le-cell-fill-color-${_.value}`,"aria-pressed":x,onClick:()=>{_.token&&s?s(_.token):!p&&_.swatch&&a&&a(_.swatch)},style:{...gl,background:_.swatch??"#fff",outline:x?"2px solid #2563eb":"1px solid #cbd5e1",opacity:$?.4:1,cursor:$?"not-allowed":"pointer"}},_.value)}),a&&i.jsx("label",{title:o(p?"layout_editor.table_editor.dark_free_color_hint":"layout_editor.table_editor.cell_fill_custom"),"data-testid":"g7le-cell-fill-custom",style:{...gl,position:"relative",overflow:"hidden",display:"inline-flex",alignItems:"center",justifyContent:"center",background:y&&Ph.test(f)?f:"conic-gradient(red, yellow, lime, aqua, blue, magenta, red)",outline:y?"2px solid #2563eb":"1px solid #cbd5e1",opacity:p?.4:1,cursor:p?"not-allowed":"pointer"},children:i.jsx("input",{type:"color",disabled:d||p,"data-testid":"g7le-cell-fill-color-picker",value:f&&Ph.test(f)?f:"#ffffff",onChange:_=>a(_.target.value),style:{position:"absolute",width:0,height:0,opacity:0}})})]})]})}const Qz={display:"flex",flexDirection:"column",gap:6},Rz={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},eN={fontSize:12,fontWeight:600,color:"#475569"},tN={display:"flex",gap:4,flexWrap:"wrap",alignItems:"center"},gl={width:22,height:22,borderRadius:5,padding:0,cursor:"pointer",boxSizing:"border-box"};function nN(e){const t=/^(\d+)px$/.exec(e.trim());return t?parseInt(t[1],10):null}function Bh({paddingStyle:e,catalog:t,t:n,onChange:o,disabled:r}){const s=t?.steps??[],a=e??"",l=nN(a),d=(h,v)=>h&&h.startsWith("$t:")?n(h.slice(3)):h||v,c=s.some(h=>(h.px??0)===(l??-1)),p=l!==null&&!c?String(l):"",[f,b]=u.useState(p);u.useEffect(()=>{b(p)},[e]);const g=h=>{o(h&&h>0?`${h}px`:""),b("")},m=h=>{const v=parseInt(h,10);Number.isFinite(v)&&v>=0&&o(v>0?`${v}px`:"")};return i.jsxs("div",{className:"g7le-cell-padding","data-testid":"g7le-cell-padding",style:oN,children:[i.jsx("div",{style:rN,children:n("layout_editor.table_editor.cell_padding")}),i.jsxs("div",{style:iN,"data-testid":"g7le-cell-padding-steps",children:[s.map(h=>{const v=(h.px??0)===(l??-1)||!h.px&&a.trim()==="";return i.jsx("button",{type:"button",disabled:r,"data-testid":`g7le-cell-padding-step-${h.value}`,"aria-pressed":v,onClick:()=>g(h.px),style:v?sN:Wh,children:d(h.label,h.value)},h.value)}),i.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3},children:[i.jsx("input",{type:"number",min:0,disabled:r,"data-testid":"g7le-cell-padding-free",value:f,placeholder:n("layout_editor.table_editor.cell_padding_custom"),onChange:h=>b(h.target.value),onBlur:()=>f.trim()!==""&&m(f),onKeyDown:h=>{h.key==="Enter"&&f.trim()!==""&&m(f)},style:aN}),i.jsx("span",{style:{fontSize:11,color:"#94a3b8"},children:"px"})]})]})]})}const oN={display:"flex",flexDirection:"column",gap:6},rN={fontSize:12,fontWeight:600,color:"#475569"},iN={display:"flex",gap:4,flexWrap:"wrap",alignItems:"center"},Wh={padding:"3px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},sN={...Wh,border:"1px solid #2563eb",background:"#eff6ff",color:"#1d4ed8",fontWeight:600},aN={width:48,padding:"3px 5px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,boxSizing:"border-box"};function jh({colorScheme:e,onChange:t,t:n,disabled:o}){const r=e==="dark";return i.jsxs("div",{className:"g7le-color-scheme-tabs","data-testid":"g7le-color-scheme-tabs",style:lN,children:[i.jsxs("div",{style:dN,children:[i.jsx("span",{style:cN,children:n("layout_editor.table_editor.cell_color")}),i.jsxs("div",{style:uN,children:[i.jsx("button",{type:"button",disabled:o,"data-testid":"g7le-color-scheme-light","aria-pressed":!r,onClick:()=>t("light"),style:r?hl:Hh,children:n("layout_editor.property_modal.scope.scheme_light")}),i.jsx("button",{type:"button",disabled:o,"data-testid":"g7le-color-scheme-dark","aria-pressed":r,onClick:()=>t("dark"),style:r?Hh:hl,children:n("layout_editor.property_modal.scope.scheme_dark")})]})]}),r&&i.jsx("div",{style:pN,"data-testid":"g7le-color-scheme-dark-hint",children:n("layout_editor.table_editor.dark_free_color_hint")})]})}const lN={display:"flex",flexDirection:"column",gap:3},dN={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},cN={fontSize:12,fontWeight:700,color:"#0f172a"},uN={display:"flex",gap:2},hl={padding:"2px 9px",fontSize:11,border:"none",borderBottom:"2px solid transparent",background:"transparent",color:"#94a3b8",cursor:"pointer"},Hh={...hl,color:"#1d4ed8",borderBottom:"2px solid #2563eb",fontWeight:600},pN={fontSize:10,color:"#94a3b8",fontStyle:"italic"},yl="dark:";function Fh(e){return typeof e=="string"?e.split(/\s+/).filter(Boolean):[]}function Kh(e,t){return t==="dark"?e.filter(n=>n.startsWith(yl)).map(n=>n.slice(yl.length)):e.filter(n=>!n.startsWith(yl))}const fN={none:0,thin:1,medium:2,thick:4},Vh={top:{w:"borderTopWidth",s:"borderTopStyle",c:"borderTopColor"},bottom:{w:"borderBottomWidth",s:"borderBottomStyle",c:"borderBottomColor"},left:{w:"borderLeftWidth",s:"borderLeftStyle",c:"borderLeftColor"},right:{w:"borderRightWidth",s:"borderRightStyle",c:"borderRightColor"}},Uh=["top","bottom","left","right"];function gN(e,t,n="light"){if(!e||!t)return{};const o=t.sides??[],r=t.widths??[],s=t.colors??[],a=Fh(e.props?.className);if(a.length===0&&!e.props?.style)return{};const l=[...r].filter(y=>y.value!=="none").sort((y,_)=>(_.suffix??"").length-(y.suffix??"").length),d={};for(const y of o)for(const _ of l){const w=_.suffix?`${y.prefix}${_.suffix}`:y.prefix;if(a.includes(w)){d[y.value]=_.value;break}}const c=e.props?.style??{},p=Kh(a,n),f=s.find(y=>p.includes(y.token))?.swatch??"",g=(n==="light"&&typeof c.borderColor=="string"?c.borderColor:"")||f||"#94a3b8",m=y=>{const _=Vh[y]?.c,w=_?c[_]:void 0;return typeof w=="string"&&w?w:g},h={},v=(y,_)=>{const w=Vh[y];if(!w)return;const k=fN[_]??1;h[w.w]=`${k}px`,h[w.s]=k>0?"solid":"none",k>0&&(h[w.c]=m(y))};if(d.all)for(const y of Uh)v(y,d.all);for(const y of Uh)d[y]&&v(y,d[y]);return h}function hN(e,t,n="light"){if(!e?.props)return{};const o=e.props.style??{},r={},s=Fh(e.props.className),a=t?.colors?.find(c=>c.token&&Kh(s,n).includes(c.token))?.swatch??"",d=(n==="light"&&typeof o.backgroundColor=="string"?o.backgroundColor:"")||a;return d&&(r.backgroundColor=d),typeof o.padding=="string"&&o.padding&&(r.padding=o.padding),r}const yN=/^\s*\$t:(custom\.[a-zA-Z0-9._-]+)\s*$/,bN=/^\s*\$t:([a-zA-Z0-9._-]+)\s*$/,mN=/\{\{.*?\}\}/;function qh(e,t,n){const o=e?.text;if(typeof o!="string")return{display:"",editable:!1,isKey:!1};const r=vt(o);if(r&&r.key.startsWith("custom.")){let a="";try{const l=Pt.getInstance().translate(r.key,{templateId:t,locale:n});a=l&&l!==r.key?l:""}catch{a=""}return{display:a,editable:!0,isKey:!0}}if(mN.test(o))return{display:o,editable:!1,isKey:!1};const s=bN.exec(o);if(s){const a=s[1];let l="";try{const d=Pt.getInstance().translate(a,{templateId:t,locale:n});l=d&&d!==a?d:""}catch{l=""}return{display:l,editable:!0,isKey:!0}}return{display:o,editable:!0,isKey:!1}}function bl(e){const t=sr(e);return t===null?{node:null,path:null}:{node:Ii(e,t),path:t}}function vN(e){if(!e||typeof e.text!="string")return null;const t=yN.exec(e.text);if(t)return t[1];const n=vt(e.text);return n&&n.key.startsWith("custom.")?n.key:null}function _N({node:e,params:t,t:n,onPatchNode:o,templateIdentifier:r,candidates:s}){const{state:a}=Qe(),l=a.selectedRoute?.layoutName??null,d=a.locale,c=r??a.templateIdentifier,p=u.useMemo(()=>t&&typeof t=="object"?t:null,[t]);u.useMemo(()=>yt(p),[p]);const f=u.useMemo(()=>Oe(e,p),[e,p]),b=u.useMemo(()=>{const U=p?.cellBorder;return U&&typeof U=="object"?U:null},[p]),g=u.useMemo(()=>{const U=p?.cellBackground;return U&&typeof U=="object"?U:null},[p]),m=u.useMemo(()=>{const U=p?.cellPadding;return U&&typeof U=="object"?U:null},[p]),[h,v]=u.useState(null),[y,_]=u.useState(null),[w,k]=u.useState({}),[x,$]=u.useState(!1),[C,S]=u.useState(null),[D,E]=u.useState(null),[I,N]=u.useState("light"),T=u.useCallback(U=>o(U),[o]),B=u.useMemo(()=>h?Ue(f,h.r,h.c):null,[f,h]),M=D!==null?D:h?.c??null,O=C!==null?C:h?.r??null,z=u.useMemo(()=>{const U=(b?.sides??[]).find(ke=>ke.value==="all")??(b?.sides??[])[0],ue=(b?.widths??[]).find(ke=>ke.value!=="none");if(!U||!ue)return[];const ge=ue.suffix??"";return[ge?`${U.prefix}${ge}`:U.prefix]},[b]),H=u.useCallback((U,ue,ge)=>{if(z.length===0)return U;const ke=(b?.sides??[]).map(Q=>Q.prefix),he=Ue(Oe(U,p),ue,ge),ne=(typeof he?.cell?.props?.className=="string"?he.cell.props.className:"").split(/\s+/).filter(Boolean);return ne.some(Q=>ke.some(de=>Q===de||Q.startsWith(de+"-")&&/^-?\d+$/.test(Q.slice(de.length+1))))?U:Ni(U,p,ue,ge,[...ne,...z].join(" ").trim())},[z,b,p]),P=u.useCallback(U=>{if(!h)return;const ue=Math.min(h.r,y?.r??h.r),ge=Math.max(h.r,y?.r??h.r),ke=Math.min(h.c,y?.c??h.c),he=Math.max(h.c,y?.c??h.c),j=new Set,ne=[];for(let Q=ue;Q<=ge;Q++)for(let de=ke;de<=he;de++)j.add(`${Q}:${de}`),ne.push({r:Q,c:de});let pe=e;for(const Q of ne){if(pe=H(pe,Q.r,Q.c),pe=Rt(pe,p,Q.r,Q.c,"borderColor",U),Q.r>0&&!j.has(`${Q.r-1}:${Q.c}`)){const de=Ue(Oe(pe,p),Q.r-1,Q.c);de&&(pe=Rt(pe,p,de.gridRow,de.gridCol,"borderBottomColor",U))}if(Q.c>0&&!j.has(`${Q.r}:${Q.c-1}`)){const de=Ue(Oe(pe,p),Q.r,Q.c-1);de&&(pe=Rt(pe,p,de.gridRow,de.gridCol,"borderRightColor",U))}}T(pe)},[h,y,e,p,T,H]),A=u.useCallback(U=>P(U),[P]),L=u.useMemo(()=>(b?.colors??[]).map(U=>U.token).filter(Boolean),[b]),F=u.useCallback(U=>{if(!h||L.length===0)return;const ue=Math.min(h.r,y?.r??h.r),ge=Math.max(h.r,y?.r??h.r),ke=Math.min(h.c,y?.c??h.c),he=Math.max(h.c,y?.c??h.c);let j=e;for(let ne=ue;ne<=ge;ne++)for(let pe=ke;pe<=he;pe++)j=H(j,ne,pe),j=bo(j,p,ne,pe,U,L,I);T(j)},[h,y,e,p,T,H,L,I]),Y=u.useMemo(()=>{if(I==="dark")return"";const U=B?.cell.props?.style;return typeof U?.borderColor=="string"?U.borderColor:""},[B,I]),V=u.useCallback((U,ue)=>{if(!h)return;const ge=Math.min(h.r,y?.r??h.r),ke=Math.max(h.r,y?.r??h.r),he=Math.min(h.c,y?.c??h.c),j=Math.max(h.c,y?.c??h.c);let ne=e;for(let pe=ge;pe<=ke;pe++)for(let Q=he;Q<=j;Q++)ne=Rt(ne,p,pe,Q,U,ue);T(ne)},[h,y,e,p,T]),X=u.useMemo(()=>(g?.colors??[]).map(U=>U.token).filter(U=>!!U),[g]),Z=u.useCallback(()=>h?{r0:Math.min(h.r,y?.r??h.r),r1:Math.max(h.r,y?.r??h.r),c0:Math.min(h.c,y?.c??h.c),c1:Math.max(h.c,y?.c??h.c)}:null,[h,y]),ie=u.useCallback(U=>{const ue=Z();if(!ue||X.length===0)return;let ge=e;for(let ke=ue.r0;ke<=ue.r1;ke++)for(let he=ue.c0;he<=ue.c1;he++)ge=bo(ge,p,ke,he,U,X,I);T(ge)},[Z,e,p,T,X,I]),oe=u.useCallback(U=>V("backgroundColor",U),[V]),G=u.useCallback(()=>{const U=Z();if(!U)return;let ue=e;for(let ge=U.r0;ge<=U.r1;ge++)for(let ke=U.c0;ke<=U.c1;ke++)ue=bo(ue,p,ge,ke,void 0,X,I),I==="light"&&(ue=Rt(ue,p,ge,ke,"backgroundColor",void 0));T(ue)},[Z,e,p,T,X,I]),ee=u.useCallback(U=>V("padding",U),[V]),fe=u.useMemo(()=>{if(I==="dark")return"";const U=B?.cell.props?.style;return typeof U?.backgroundColor=="string"?U.backgroundColor:""},[B,I]),K=u.useMemo(()=>typeof B?.cell.props?.className=="string"?B.cell.props.className:"",[B]),te=u.useMemo(()=>{const U=B?.cell.props?.style;return typeof U?.padding=="string"?U.padding:""},[B]),ye=u.useCallback(U=>U==="section"?n("layout_editor.table_editor.move_blocked_section"):"",[n]),Se=u.useCallback((U,ue)=>Ai(f,U,ue),[f]),De=u.useCallback((U,ue)=>Ti(f,U,ue),[f]),Ie=u.useCallback(U=>T(cl(e,p,U)),[e,p,T]),Ve=u.useCallback(U=>{T(kh(e,p,U)),v(null),_(null)},[e,p,T]),ze=u.useCallback((U,ue)=>T(Sh(e,p,U,ue)),[e,p,T]),Be=u.useCallback(U=>T($h(e,p,U)),[e,p,T]),Xe=u.useCallback(U=>{T(Eh(e,p,U)),v(null),_(null)},[e,p,T]),Ne=u.useCallback((U,ue)=>T(Ch(e,p,U,ue)),[e,p,T]),Je=u.useCallback(()=>{if(!h||!y)return;const U=ul(e,p,h.r,h.c,y.r,y.c);U.ok&&(T(U.table),v({r:Math.min(h.r,y.r),c:Math.min(h.c,y.c)}),_(null))},[e,p,h,y,T]),ve=u.useCallback(()=>{h&&(T(Ih(e,p,h.r,h.c)),_(null))},[e,p,h,T]),qe=u.useCallback(U=>{if(!h)return;const ue=Math.min(h.r,y?.r??h.r),ge=Math.max(h.r,y?.r??h.r),ke=Math.min(h.c,y?.c??h.c),he=Math.max(h.c,y?.c??h.c);let j=e;for(let ne=ue;ne<=ge;ne++)for(let pe=ke;pe<=he;pe++)j=Ni(j,p,ne,pe,U);T(j)},[e,p,h,y,T]),We=u.useCallback(async(U,ue)=>{const ge=`${U}:${ue}`,ke=w[ge];if(ke===void 0)return;const he=Ue(f,U,ue);if(!he)return;const{node:j,path:ne}=bl(he.cell);if(ne===null)return;const pe=qh(j,c,d);if(pe.editable){if(ke===pe.display){k(Q=>{const de={...Q};return delete de[ge],de});return}$(!0);try{const Q=vN(j);if(Q)await wr(c,Q,d,ke),await on(c,d);else{const de=await Yn(c,l,d,ke);if(de.kind==="ok"&&de.resource){const Ae=`$t:${de.resource.translation_key}`;if(ne.length===0)T(Ah(e,p,U,ue,Ae));else{const dt=ar(he.cell,ne,Ae);T(Th(e,p,U,ue,dt))}await on(c,d)}}}finally{$(!1),k(Q=>{const de={...Q};return delete de[ge],de})}}},[w,f,c,d,l,e,p,T]),ce=u.useMemo(()=>{if(!B)return null;const{node:U,path:ue}=bl(B.cell);return ue===null?null:{value:typeof U?.text=="string"?U.text:"",editable:!0}},[B]),q=u.useCallback(U=>{if(typeof U!="string"||U.length===0||!h)return;const ue=Ue(f,h.r,h.c);if(!ue)return;const ge=sr(ue.cell);if(ge!==null)if(ge.length===0)T(Ah(e,p,h.r,h.c,U));else{const ke=ar(ue.cell,ge,U);T(Th(e,p,h.r,h.c,ke))}},[h,f,e,p,T]),se=u.useCallback((U,ue,ge)=>{ge?_({r:U,c:ue}):(v({r:U,c:ue}),_(null))},[]),ae=u.useMemo(()=>Array.from({length:f.colCount},(U,ue)=>ue),[f.colCount]),be=!!(h&&y&&(h.r!==y.r||h.c!==y.c)),Ce=!!(B&&(B.colSpan>1||B.rowSpan>1)),$e=B&&typeof B.cell.props?.className=="string"?B.cell.props.className:"";return i.jsxs("div",{className:"g7le-node-editor g7le-node-editor--table","data-testid":"g7le-table-editor",style:xN,children:[i.jsx("div",{style:wN,children:n("layout_editor.table_editor.title")}),i.jsx("div",{style:{overflowX:"auto"},children:i.jsxs("table",{"data-testid":"g7le-table-editor-grid",style:kN,children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{style:SN}),ae.map(U=>{const ue=De(U,-1),ge=De(U,1),ke=M===U;return i.jsx("th",{style:CN,"data-testid":`g7le-table-colgutter-${U}`,onMouseEnter:()=>E(U),onMouseLeave:()=>E(he=>he===U?null:he),children:i.jsxs("div",{style:{...EN,visibility:ke?"visible":"hidden"},children:[i.jsx("button",{type:"button",title:ue.ok?n("layout_editor.table_editor.move_col_left"):ye(ue.reason)||n("layout_editor.table_editor.move_col_left"),disabled:!ue.ok||x,onClick:()=>Ne(U,-1),"data-testid":`g7le-table-col-left-${U}`,style:ue.ok?xn:Mi,children:"←"}),i.jsx("button",{type:"button",title:n("layout_editor.table_editor.add_col"),disabled:x,onClick:()=>Be(U),"data-testid":`g7le-table-col-add-${U}`,style:xn,children:"+"}),i.jsx("button",{type:"button",title:n("layout_editor.table_editor.remove_col"),disabled:f.colCount<=1||x,onClick:()=>Xe(U),"data-testid":`g7le-table-col-remove-${U}`,style:Gh,children:"✕"}),i.jsx("button",{type:"button",title:ge.ok?n("layout_editor.table_editor.move_col_right"):ye(ge.reason)||n("layout_editor.table_editor.move_col_right"),disabled:!ge.ok||x,onClick:()=>Ne(U,1),"data-testid":`g7le-table-col-right-${U}`,style:ge.ok?xn:Mi,children:"→"})]})},U)})]})}),i.jsx("tbody",{children:f.rows.map((U,ue)=>{const ge=U.cells[0]?.gridRow??ue,ke=O===ge;return i.jsxs("tr",{"data-testid":`g7le-table-row-${ge}`,onMouseEnter:()=>S(ge),onMouseLeave:()=>S(he=>he===ge?null:he),children:[i.jsx("td",{style:$N,"data-testid":`g7le-table-rowgutter-${ge}`,children:(()=>{const he=Se(ge,-1),j=Se(ge,1);return i.jsxs("div",{style:{...IN,visibility:ke?"visible":"hidden"},children:[i.jsx("button",{type:"button",title:he.ok?n("layout_editor.table_editor.move_row_up"):ye(he.reason)||n("layout_editor.table_editor.move_row_up"),disabled:!he.ok||x,onClick:()=>ze(ge,-1),"data-testid":`g7le-table-row-up-${ge}`,style:he.ok?xn:Mi,children:"↑"}),i.jsx("button",{type:"button",title:n("layout_editor.table_editor.add_row"),disabled:x,onClick:()=>Ie(ge),"data-testid":`g7le-table-row-add-${ge}`,style:xn,children:"+"}),i.jsx("button",{type:"button",title:n("layout_editor.table_editor.remove_row"),disabled:f.rows.length<=1||x,onClick:()=>Ve(ge),"data-testid":`g7le-table-row-remove-${ge}`,style:Gh,children:"✕"}),i.jsx("button",{type:"button",title:j.ok?n("layout_editor.table_editor.move_row_down"):ye(j.reason)||n("layout_editor.table_editor.move_row_down"),disabled:!j.ok||x,onClick:()=>ze(ge,1),"data-testid":`g7le-table-row-down-${ge}`,style:j.ok?xn:Mi,children:"↓"})]})})()}),U.cells.map(he=>{const j=`${he.gridRow}:${he.gridCol}`,{node:ne,path:pe}=bl(he.cell),Q=qh(ne,c,d),de=pe!==null&&Q.editable,Ae=pe===null,dt=w[j],pt=dt!==void 0?dt:Q.display,ot=h&&h.r===he.gridRow&&h.c===he.gridCol,Le=h&&y&&he.gridRow>=Math.min(h.r,y.r)&&he.gridRow<=Math.max(h.r,y.r)&&he.gridCol>=Math.min(h.c,y.c)&&he.gridCol<=Math.max(h.c,y.c);return i.jsx("td",{colSpan:he.colSpan,rowSpan:he.rowSpan,"data-testid":`g7le-table-cell-${he.gridRow}-${he.gridCol}`,onClick:je=>se(he.gridRow,he.gridCol,je.shiftKey),style:{...AN,...gN(he.cell,b,I),...hN(he.cell,g,I),...he.isHeader?TN:{},...ot?DN:{},...Le&&!ot?zN:{}},children:de?i.jsx("input",{type:"text","data-testid":`g7le-table-cell-input-${he.gridRow}-${he.gridCol}`,value:pt,placeholder:n("layout_editor.table_editor.cell_text"),disabled:x,onMouseDown:je=>{je.shiftKey&&je.preventDefault(),se(he.gridRow,he.gridCol,je.shiftKey)},onClick:je=>je.stopPropagation(),onChange:je=>k(Ze=>({...Ze,[j]:je.target.value})),onBlur:()=>void We(he.gridRow,he.gridCol),style:NN}):Ae?i.jsx("span",{"data-testid":`g7le-table-cell-struct-${he.gridRow}-${he.gridCol}`,style:Yh,children:n("layout_editor.table_editor.structural_cell")}):i.jsx("span",{style:Yh,children:Q.display})},j)})]},ue)})})]})}),i.jsxs("button",{type:"button","data-testid":"g7le-table-add-row-bottom",onClick:()=>Ie(f.rows.length-1),disabled:x,style:MN,children:["+ ",n("layout_editor.table_editor.add_row")]}),i.jsxs("div",{style:LN,"data-testid":"g7le-table-cell-tools",children:[i.jsx("button",{type:"button","data-testid":"g7le-table-merge",onClick:Je,disabled:!be||x,style:Xh,children:n("layout_editor.table_editor.merge_cells")}),i.jsx("button",{type:"button","data-testid":"g7le-table-unmerge",onClick:ve,disabled:!Ce||x,style:Xh,children:n("layout_editor.table_editor.unmerge_cells")})]}),B&&ce&&i.jsxs("div",{style:ON,"data-testid":"g7le-table-cell-i18n-section",children:[i.jsx("div",{style:BN,children:n("layout_editor.table_editor.cell_i18n_label")}),i.jsx(_t,{value:ce.value,onChange:q,t:n,placeholder:n("layout_editor.table_editor.cell_text"),testidPrefix:"g7le-table-cell-i18n",candidates:s,enableExpressionTree:!0,expressionTreeCollapsible:!0})]}),B&&i.jsxs("div",{style:PN,"data-testid":"g7le-table-cell-color-section",children:[i.jsx(jh,{colorScheme:I,onChange:N,t:n,disabled:x}),b&&i.jsx("div",{style:ml,"data-testid":"g7le-table-cell-border-row",children:i.jsx(Nh,{className:$e,catalog:b,t:n,onChange:qe,colorScheme:I,onPresetToken:F,colorStyle:Y,onColorStyle:A,disabled:x})}),i.jsx("div",{style:ml,"data-testid":"g7le-table-cell-fill-row",children:i.jsx(Oh,{colorStyle:fe,className:K,catalog:g,t:n,colorScheme:I,onPresetToken:ie,onCustomColor:oe,onClear:G,disabled:x})})]}),B&&i.jsx("div",{style:ml,"data-testid":"g7le-table-cell-padding-row",children:i.jsx(Bh,{paddingStyle:te,catalog:m,t:n,onChange:ee,disabled:x})}),B&&!b&&i.jsxs("label",{style:WN,"data-testid":"g7le-table-cell-border-row",children:[i.jsx("span",{style:jN,children:n("layout_editor.table_editor.cell_border")}),i.jsx("input",{type:"text","data-testid":"g7le-table-cell-border-input",value:$e,placeholder:n("layout_editor.table_editor.cell_class_placeholder"),onChange:U=>qe(U.target.value),disabled:x,style:HN})]}),!f.valid&&i.jsx("div",{"data-testid":"g7le-table-grid-warning",style:FN,children:n("layout_editor.table_editor.grid_invalid")}),i.jsx("div",{style:KN,children:n("layout_editor.table_editor.select_hint")})]})}const xN={display:"flex",flexDirection:"column",gap:8,width:"100%",marginBottom:12},wN={fontSize:12,fontWeight:700,color:"#0f172a"},kN={borderCollapse:"collapse",width:"auto"},SN={width:28,background:"transparent",border:"none"},CN={padding:2,border:"none",background:"transparent"},$N={padding:2,border:"none",background:"transparent",verticalAlign:"middle"},EN={display:"flex",gap:2,justifyContent:"center"},IN={display:"grid",gridTemplateColumns:"repeat(2, 16px)",gap:2,justifyContent:"center"},xn={width:16,height:16,lineHeight:"14px",padding:0,fontSize:10,border:"1px solid #cbd5e1",borderRadius:4,background:"#fff",color:"#475569",cursor:"pointer"},Gh={...xn,border:"1px solid #fecaca",color:"#dc2626"},Mi={...xn,cursor:"not-allowed",opacity:.4,color:"#94a3b8",borderColor:"#e2e8f0"},AN={border:"1px solid #cbd5e1",padding:0,width:64,minWidth:64,maxWidth:120,height:24,background:"#fff",cursor:"pointer"},TN={background:"#f1f5f9",fontWeight:600},DN={outline:"2px solid #2563eb",outlineOffset:-2},zN={background:"#dbeafe"},NN={width:"100%",boxSizing:"border-box",padding:"2px 5px",fontSize:11,height:22,lineHeight:"18px",border:"none",background:"transparent",outline:"none"},Yh={display:"block",padding:"2px 5px",fontSize:10,color:"#64748b",fontStyle:"italic",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:110},MN={padding:"4px 8px",fontSize:12,border:"1px dashed #94a3b8",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",alignSelf:"flex-start"},LN={display:"flex",gap:6},Xh={padding:"4px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},PN={display:"flex",flexDirection:"column",gap:8,borderTop:"1px solid #f1f5f9",paddingTop:8},ON={display:"flex",flexDirection:"column",gap:6,borderTop:"1px solid #f1f5f9",paddingTop:8},BN={fontSize:12,fontWeight:700,color:"#0f172a"},ml={display:"flex",flexDirection:"column",gap:6},WN={display:"flex",alignItems:"center",gap:6},jN={fontSize:12,color:"#475569",minWidth:60},HN={flex:1,minWidth:0,padding:"4px 6px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6},FN={fontSize:11,color:"#b45309",background:"#fffbeb",border:"1px solid #fde68a",borderRadius:6,padding:"4px 6px"},KN={fontSize:11,color:"#94a3b8"},VN=/\{\{.*?\}\}/;function UN(e,t,n){const r=(e.props??{})[t];return Array.isArray(r)?r:r===void 0&&n?JSON.parse(JSON.stringify(n)):[]}function qN(e){return typeof e=="string"&&VN.test(e)}function vl(e,t,n){return e?e.startsWith("$t:")?t(e.slice(3)):e:n}function GN(e,t,n){return typeof e=="object"&&e!==null?e[t.key]:n?e:void 0}function YN(e,t,n,o){if(typeof e=="object"&&e!==null){const r={...e};return o===void 0?delete r[t.key]:r[t.key]=o,r}return n?o:{[t.key]:o}}function Jh({node:e,params:t,t:n,onPatchNode:o,templateIdentifier:r,candidates:s}){const a=typeof t?.arrayProp=="string"?t.arrayProp:null,l=Array.isArray(t?.fields)?t.fields:[],d=vl(typeof t?.itemLabel=="string"?t.itemLabel:void 0,n,n("layout_editor.array_editor.item")),c=t?.newItem,p=c&&typeof c=="object"?c:null,f=typeof c=="string"||typeof c=="number"?c:null,b=(l.find($=>$.primary)??l[0])?.key,g=(e.props??{})[a??""],m=Array.isArray(t?.defaultItems)?t.defaultItems:null,h=a?UN(e,a,m):[],v=u.useCallback($=>{if(!a)return;const C={...e.props??{}};C[a]=$,o({...e,props:C})},[a,e,o]),y=u.useCallback(()=>{if(p)return JSON.parse(JSON.stringify(p));if(f!==null)return f;const $={};for(const C of l)(C.widget??"text")==="boolean"?$[C.key]=!1:$[C.key]="";return $},[p,f,l]),_=u.useCallback(()=>{v([...h,y()])},[v,h,y]),w=u.useCallback($=>{v(h.filter((C,S)=>S!==$))},[v,h]),k=u.useCallback(($,C)=>{const S=$+C;if(S<0||S>=h.length)return;const D=[...h];[D[$],D[S]]=[D[S],D[$]],v(D)},[v,h]),x=u.useCallback(($,C,S)=>{const D=C.key===b,E=h.map((I,N)=>N===$?YN(I,C,D,S):I);v(E)},[h,v,b]);return a?qN(g)||g!==void 0&&!Array.isArray(g)?i.jsx("div",{className:"g7le-node-editor g7le-node-editor--array","data-testid":"g7le-array-editor-bound",style:oM,children:n("layout_editor.array_editor.bound_degraded")}):i.jsxs("div",{className:"g7le-node-editor g7le-node-editor--array","data-testid":"g7le-array-editor",style:XN,children:[i.jsx("div",{style:JN,children:n("layout_editor.array_editor.items_title")}),h.length===0&&i.jsx("div",{"data-testid":"g7le-array-empty",style:Qh,children:n("layout_editor.array_editor.empty")}),h.map(($,C)=>i.jsxs("div",{"data-testid":`g7le-array-row-${C}`,style:ZN,children:[i.jsxs("div",{style:QN,children:[i.jsxs("span",{style:RN,children:["#",C+1]}),i.jsx("div",{style:{flex:1}}),i.jsx("button",{type:"button","data-testid":`g7le-array-up-${C}`,title:n("layout_editor.array_editor.move_up"),disabled:C===0,onClick:()=>k(C,-1),style:Zh,children:"↑"}),i.jsx("button",{type:"button","data-testid":`g7le-array-down-${C}`,title:n("layout_editor.array_editor.move_down"),disabled:C===h.length-1,onClick:()=>k(C,1),style:Zh,children:"↓"}),i.jsx("button",{type:"button","data-testid":`g7le-array-remove-${C}`,title:n("layout_editor.array_editor.remove"),onClick:()=>w(C),style:tM,children:"✕"})]}),l.map(S=>{const D=S.widget??"text",E=S.key===b,I=vl(S.label,n,S.key),N=GN($,S,E),T=`g7le-array-field-${C}-${S.key}`;if(D==="boolean")return i.jsxs("label",{style:Hn,children:[i.jsx("span",{style:Fn,children:I}),i.jsx("input",{type:"checkbox","data-testid":T,checked:N===!0,onChange:M=>x(C,S,M.target.checked)})]},S.key);if(D==="select"){const M=Array.isArray(S.options)?S.options:[];return i.jsxs("label",{style:Hn,children:[i.jsx("span",{style:Fn,children:I}),i.jsxs("select",{"data-testid":T,value:N==null?"":String(N),onChange:O=>x(C,S,O.target.value===""?void 0:O.target.value),style:dr,children:[i.jsx("option",{value:"",children:"—"}),M.map((O,z)=>i.jsx("option",{value:String(O.value),children:vl(O.label,n,String(O.value))},z))]})]},S.key)}if(D==="i18n-text"){const M=typeof N=="string"?N:N==null?"":String(N);return i.jsxs("label",{style:Hn,children:[i.jsx("span",{style:Fn,children:I}),i.jsx("div",{"data-testid":T,style:{flex:1,minWidth:0},children:i.jsx(_t,{value:M,onChange:O=>x(C,S,O===""?void 0:O),t:n,placeholder:I,testidPrefix:`${T}-i18n`,candidates:s,enableExpressionTree:!0,expressionTreeCollapsible:!0})})]},S.key)}if(D==="number"){const M=N==null?"":String(N);return i.jsxs("label",{style:Hn,children:[i.jsx("span",{style:Fn,children:I}),i.jsx("input",{type:"number","data-testid":T,value:M,onChange:O=>{const z=O.target.value;x(C,S,z===""?void 0:Number(z))},style:dr})]},S.key)}if(D==="color"){const M=typeof N=="string"?N:"",O=/^#[0-9a-fA-F]{6}$/.test(M)?M:"#000000";return i.jsxs("label",{style:Hn,children:[i.jsx("span",{style:Fn,children:I}),i.jsx("input",{type:"color","data-testid":`${T}-swatch`,value:O,onChange:z=>x(C,S,z.target.value),style:eM}),i.jsx("input",{type:"text","data-testid":T,value:M,placeholder:"#7C3AED",onChange:z=>x(C,S,z.target.value===""?void 0:z.target.value),style:dr})]},S.key)}if(D==="number-list"){const M=Array.isArray(N)?N.join(", "):"";return i.jsxs("label",{style:Hn,children:[i.jsx("span",{style:Fn,children:I}),i.jsx("input",{type:"text","data-testid":T,value:M,placeholder:n("layout_editor.array_editor.number_list_placeholder"),onChange:O=>{const z=O.target.value.split(",").map(H=>H.trim()).filter(H=>H!=="").map(H=>Number(H)).filter(H=>!Number.isNaN(H));x(C,S,z)},style:dr})]},S.key)}const B=N==null?"":String(N);return i.jsxs("label",{style:Hn,children:[i.jsx("span",{style:Fn,children:I}),i.jsx("input",{type:"text","data-testid":T,value:B,placeholder:D==="icon"?n("layout_editor.array_editor.icon_placeholder"):I,onChange:M=>x(C,S,M.target.value===""?void 0:M.target.value),style:dr})]},S.key)})]},C)),i.jsx("button",{type:"button","data-testid":"g7le-array-add",onClick:_,style:nM,children:n("layout_editor.array_editor.add",{item:d})})]}):i.jsx("div",{className:"g7le-node-editor g7le-node-editor--array","data-testid":"g7le-array-editor-misconfigured",style:Qh,children:n("layout_editor.array_editor.no_array_prop")})}const XN={display:"flex",flexDirection:"column",gap:8,width:"100%",marginBottom:12},JN={fontSize:12,fontWeight:700,color:"#0f172a",marginBottom:2},ZN={display:"flex",flexDirection:"column",gap:4,padding:8,border:"1px solid #e2e8f0",borderRadius:8,background:"#f8fafc"},QN={display:"flex",gap:4,alignItems:"center"},RN={fontSize:11,fontWeight:700,color:"#64748b"},Hn={display:"flex",flexWrap:"wrap",gap:6,alignItems:"center"},Fn={fontSize:11,color:"#475569",minWidth:64,flexShrink:0},dr={flex:1,minWidth:0,padding:"4px 6px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6},eM={width:32,height:28,padding:0,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",cursor:"pointer",flexShrink:0},Zh={padding:"2px 6px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},tM={padding:"2px 6px",fontSize:12,border:"1px solid #fecaca",borderRadius:6,background:"#fff",color:"#dc2626",cursor:"pointer"},nM={padding:"4px 8px",fontSize:12,border:"1px dashed #94a3b8",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",alignSelf:"flex-start"},Qh={fontSize:11,color:"#94a3b8",fontStyle:"italic"},oM={fontSize:11,color:"#b45309",fontStyle:"italic",padding:"4px 2px"};function rM(e,t){return e?e.startsWith("$t:")?t(e.slice(3)):e:null}function iM(e){const{params:t,t:n}=e,o=Array.isArray(t?.groups)?t.groups:[];return o.length===0?i.jsx("div",{className:"g7le-node-editor g7le-node-editor--array-group","data-testid":"g7le-array-group-misconfigured",style:dM,children:n("layout_editor.array_editor.no_array_prop")}):i.jsx("div",{className:"g7le-node-editor g7le-node-editor--array-group","data-testid":"g7le-array-group-editor",style:sM,children:o.map((r,s)=>{const a=rM(r.title,n),{title:l,...d}=r;return i.jsxs("div",{"data-testid":`g7le-array-group-${r.arrayProp??s}`,style:aM,children:[a&&i.jsx("div",{style:lM,children:a}),i.jsx(Jh,{...e,params:d})]},r.arrayProp??s)})})}const sM={display:"flex",flexDirection:"column",gap:16,width:"100%",marginBottom:12},aM={display:"flex",flexDirection:"column",gap:4},lM={fontSize:12,fontWeight:700,color:"#1e293b",borderBottom:"1px solid #e2e8f0",paddingBottom:4},dM={fontSize:11,color:"#94a3b8",fontStyle:"italic"},cM=/\{\{.*?\}\}/;function uM(e){return typeof e=="string"&&cM.test(e)}function pM(e,t,n){return e?e.startsWith("$t:")?t(e.slice(3)):e:n}function fM(e){const{node:t,params:n,t:o,onPatchNode:r}=e,s=typeof n?.arrayProp=="string"?n.arrayProp:null,a=typeof n?.idField=="string"?n.idField:"id",l=typeof n?.cellChildrenProp=="string"?n.cellChildrenProp:"cellChildren",d=typeof n?.cellChildComponent=="string"?n.cellChildComponent:"Div",c=pM(typeof n?.itemLabel=="string"?n.itemLabel:void 0,o,o("layout_editor.array_editor.item")),[p,f]=u.useState(null),b=s?(t.props??{})[s]:void 0,g=Array.isArray(b)?b:[],m=u.useCallback($=>{if(!s)return;const C={...t.props??{}};C[s]=$,r({...t,props:C})},[s,t,r]),h=u.useCallback(()=>{const $=n?.newItem;return $&&typeof $=="object"?JSON.parse(JSON.stringify($)):{[a]:"",[l]:[]}},[n,a,l]),v=u.useCallback(()=>{m([...g,h()])},[m,g,h]),y=u.useCallback($=>{m(g.filter((C,S)=>S!==$)),f(null)},[m,g]),_=u.useCallback(($,C)=>{const S=$+C;if(S<0||S>=g.length)return;const D=[...g];[D[$],D[S]]=[D[S],D[$]],m(D)},[m,g]),w=u.useCallback(($,C)=>{const S=g.map((D,E)=>E===$?{...D,[a]:C}:D);m(S)},[g,m,a]),k=u.useCallback($=>({type:"composite",name:"CardGridCell",children:Array.isArray($[l])?$[l]:[]}),[l]),x=u.useCallback($=>C=>{const S=Array.isArray(C.children)?C.children:[],D=g.map((E,I)=>I===$?{...E,[l]:S}:E);m(D)},[g,m,l]);return s?uM(b)||b!==void 0&&!Array.isArray(b)?i.jsx("div",{className:"g7le-node-editor g7le-node-editor--cell-tree","data-testid":"g7le-cell-tree-bound",style:SM,children:o("layout_editor.array_editor.bound_degraded")}):i.jsxs("div",{className:"g7le-node-editor g7le-node-editor--cell-tree","data-testid":"g7le-cell-tree-editor",style:gM,children:[i.jsx("div",{style:hM,children:o("layout_editor.cell_tree_editor.columns_title")}),g.length===0&&i.jsx("div",{"data-testid":"g7le-cell-tree-empty",style:ey,children:o("layout_editor.array_editor.empty")}),g.map(($,C)=>{const S=typeof $[a]=="string"?$[a]:"",D=p===C;return i.jsxs("div",{"data-testid":`g7le-cell-tree-row-${C}`,style:yM,children:[i.jsxs("div",{style:bM,children:[i.jsxs("span",{style:mM,children:["#",C+1]}),i.jsx("input",{type:"text","data-testid":`g7le-cell-tree-id-${C}`,value:S,placeholder:o("layout_editor.cell_tree_editor.id_placeholder"),onChange:E=>w(C,E.target.value),style:vM}),i.jsx("button",{type:"button","data-testid":`g7le-cell-tree-up-${C}`,title:o("layout_editor.array_editor.move_up"),disabled:C===0,onClick:()=>_(C,-1),style:Rh,children:"↑"}),i.jsx("button",{type:"button","data-testid":`g7le-cell-tree-down-${C}`,title:o("layout_editor.array_editor.move_down"),disabled:C===g.length-1,onClick:()=>_(C,1),style:Rh,children:"↓"}),i.jsx("button",{type:"button","data-testid":`g7le-cell-tree-remove-${C}`,title:o("layout_editor.array_editor.remove"),onClick:()=>y(C),style:_M,children:"✕"})]}),i.jsx("button",{type:"button","data-testid":`g7le-cell-tree-toggle-${C}`,onClick:()=>f(D?null:C),style:xM,children:o(D?"layout_editor.cell_tree_editor.collapse_cells":"layout_editor.cell_tree_editor.expand_cells")}),D&&i.jsx("div",{"data-testid":`g7le-cell-tree-cells-${C}`,style:wM,children:i.jsx(yh,{...e,node:k($),params:{childComponent:d},onPatchNode:x(C)})})]},C)}),i.jsx("button",{type:"button","data-testid":"g7le-cell-tree-add",onClick:v,style:kM,children:o("layout_editor.cell_tree_editor.add_column",{item:c})})]}):i.jsx("div",{className:"g7le-node-editor g7le-node-editor--cell-tree","data-testid":"g7le-cell-tree-misconfigured",style:ey,children:o("layout_editor.array_editor.no_array_prop")})}const gM={display:"flex",flexDirection:"column",gap:8,width:"100%",marginBottom:12},hM={fontSize:12,fontWeight:700,color:"#0f172a",marginBottom:2},yM={display:"flex",flexDirection:"column",gap:6,padding:8,border:"1px solid #e2e8f0",borderRadius:8,background:"#f8fafc"},bM={display:"flex",gap:4,alignItems:"center"},mM={fontSize:11,fontWeight:700,color:"#64748b",flexShrink:0},vM={flex:1,minWidth:0,padding:"4px 6px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6},Rh={padding:"2px 6px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"},_M={padding:"2px 6px",fontSize:12,border:"1px solid #fecaca",borderRadius:6,background:"#fff",color:"#dc2626",cursor:"pointer"},xM={padding:"3px 8px",fontSize:11,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#2563eb",cursor:"pointer",alignSelf:"flex-start"},wM={paddingLeft:8,borderLeft:"2px solid #e2e8f0"},kM={padding:"4px 8px",fontSize:12,border:"1px dashed #94a3b8",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",alignSelf:"flex-start"},ey={fontSize:11,color:"#94a3b8",fontStyle:"italic"},SM={fontSize:11,color:"#b45309",fontStyle:"italic",padding:"4px 2px"};function CM(e,t,n){const o=Oe(e,t);if(!n||n.length===0)return{measured:[],grid:o};const r=[];for(const s of o.rows)for(const a of s.cells){const d=dl(e,a,t).map(p=>`children.${p}`).join("."),c=n.find(p=>p.path===d||p.path.endsWith("."+d));c&&r.push({ref:a,box:{top:c.top,left:c.left,width:c.width,height:c.height}})}return{measured:r,grid:o}}const _l=26,xl=50,wl=6,ty=44,ny=18,oy="g7le-table-inplace-empty-cell-style";function $M(){if(typeof document>"u"||document.getElementById(oy))return;const e=document.createElement("style");e.id=oy,e.textContent=".g7le-preview-frame td[data-editor-name],.g7le-preview-frame th[data-editor-name]{min-width:56px;height:38px;}.g7le-preview-frame table[data-editor-name]{min-width:120px;}",document.head.appendChild(e)}function EM({node:e,params:t,nodeBox:n,cellBoxes:o,selectedCellPath:r,colorScheme:s,t:a,onPatchNode:l,onRequestInlineEdit:d}){const c=u.useMemo(()=>t&&typeof t=="object"?t:null,[t]),{measured:p,grid:f}=u.useMemo(()=>CM(e,c,o),[e,c,o]),[b,g]=u.useState(null),[m,h]=u.useState(null),v=u.useMemo(()=>{if(!r)return null;for(const j of f.rows)for(const ne of j.cells){const pe=dl(e,ne,c).map(Q=>`children.${Q}`).join(".");if(r===pe||r.startsWith(pe+"."))return{r:ne.gridRow,c:ne.gridCol}}return null},[r,f,e,c]),y=u.useMemo(()=>b&&Ue(f,b.r,b.c)?b:v,[b,v,f]),[_,w]=u.useState(!1),[k,x]=u.useState(s==="dark"?"dark":"light"),[$,C]=u.useState(null),[S,D]=u.useState(null),E=u.useRef(null),I=u.useCallback(()=>{E.current!==null&&(clearTimeout(E.current),E.current=null)},[]),N=u.useCallback(()=>{I(),E.current=setTimeout(()=>{C(null),D(null),E.current=null},240)},[I]);u.useEffect(()=>()=>I(),[I]),u.useEffect(()=>{$M()},[]);const T=u.useCallback(j=>l(j),[l]),B=u.useMemo(()=>y?Ue(f,y.r,y.c):null,[f,y]),M=u.useMemo(()=>B&&typeof B.cell.props?.className=="string"?B.cell.props.className:"",[B]),O=u.useCallback(j=>T(cl(e,c,j)),[e,c,T]),z=u.useCallback(j=>T(kh(e,c,j)),[e,c,T]),H=u.useCallback((j,ne)=>T(Sh(e,c,j,ne)),[e,c,T]),P=u.useCallback(j=>T($h(e,c,j)),[e,c,T]),A=u.useCallback(j=>T(Eh(e,c,j)),[e,c,T]),L=u.useCallback((j,ne)=>T(Ch(e,c,j,ne)),[e,c,T]),F=u.useCallback(j=>{if(!B)return;const ne=B.gridRow,pe=B.gridCol,Q=j==="down"?ne+B.rowSpan:ne+B.rowSpan-1,de=j==="right"?pe+B.colSpan:pe+B.colSpan-1;if(Q>=f.rows.length||de>=f.colCount)return;const Ae=ul(e,c,ne,pe,Q,de);Ae.ok&&T(Ae.table)},[B,f,e,c,T]),Y=!!(B&&B.gridCol+B.colSpan!y||!m||!Ue(f,m.r,m.c)?null:{r0:Math.min(y.r,m.r),c0:Math.min(y.c,m.c),r1:Math.max(y.r,m.r),c1:Math.max(y.c,m.c)},[y,m,f]),Z=u.useMemo(()=>{if(!X)return[];const j=new Set,ne=[];for(const pe of f.rows)for(const Q of pe.cells)if(Q.gridRow>=X.r0&&Q.gridRow<=X.r1&&Q.gridCol>=X.c0&&Q.gridCol<=X.c1){const de=`${Q.gridRow}:${Q.gridCol}`;j.has(de)||(j.add(de),ne.push({r:Q.gridRow,c:Q.gridCol}))}return ne},[X,f]),ie=Z.length>1,oe=u.useCallback(()=>{if(!X)return;const j=ul(e,c,X.r0,X.c0,X.r1,X.c1);j.ok&&(T(j.table),h(null))},[X,e,c,T]),G=u.useCallback(()=>{y&&T(Ih(e,c,y.r,y.c))},[e,c,y,T]),ee=u.useMemo(()=>{const j=c?.cellBorder;return j&&typeof j=="object"?j:null},[c]),fe=u.useMemo(()=>{const j=c?.cellBackground;return j&&typeof j=="object"?j:null},[c]),K=u.useMemo(()=>{const j=c?.cellPadding;return j&&typeof j=="object"?j:null},[c]),te=u.useMemo(()=>{if(_){const j=new Set,ne=[];for(const pe of f.rows)for(const Q of pe.cells){const de=`${Q.gridRow}:${Q.gridCol}`;j.has(de)||(j.add(de),ne.push({r:Q.gridRow,c:Q.gridCol}))}return ne}return ie?Z:y?[{r:y.r,c:y.c}]:[]},[_,ie,Z,y,f]),ye=u.useCallback(j=>{if(te.length===0)return;let ne=e;for(const pe of te){const Q=(ee?.colors??[]).map(Ae=>Ae.token),de=j.split(/\s+/).filter(Ae=>Ae&&!Q.includes(Ae)).join(" ");ne=Ni(ne,c,pe.r,pe.c,de)}T(ne)},[e,c,te,ee,T]),Se=u.useMemo(()=>{const j=(ee?.sides??[]).find(Q=>Q.value==="all")??(ee?.sides??[])[0],ne=(ee?.widths??[]).find(Q=>Q.value!=="none");if(!j||!ne)return[];const pe=ne.suffix??"";return[pe?`${j.prefix}${pe}`:j.prefix]},[ee]),De=u.useCallback((j,ne,pe)=>{if(Se.length===0)return j;const Q=(ee?.sides??[]).map(Le=>Le.prefix),de=Ue(Oe(j,c),ne,pe),dt=(typeof de?.cell?.props?.className=="string"?de.cell.props.className:"").split(/\s+/).filter(Boolean);if(dt.some(Le=>Q.some(je=>Le===je||Le.startsWith(je+"-")&&/^-?\d+$/.test(Le.slice(je.length+1)))))return j;const ot=[...dt,...Se].join(" ").trim();return Ni(j,c,ne,pe,ot)},[Se,ee,c]),Ie=u.useCallback((j,ne)=>{if(j.length===0)return;const pe=new Set(j.map(de=>`${de.r}:${de.c}`));let Q=e;for(const de of j){if(Q=De(Q,de.r,de.c),Q=Rt(Q,c,de.r,de.c,"borderColor",ne),de.r>0&&!pe.has(`${de.r-1}:${de.c}`)){const Ae=Ue(Oe(Q,c),de.r-1,de.c);Ae&&(Q=Rt(Q,c,Ae.gridRow,Ae.gridCol,"borderBottomColor",ne))}if(de.c>0&&!pe.has(`${de.r}:${de.c-1}`)){const Ae=Ue(Oe(Q,c),de.r,de.c-1);Ae&&(Q=Rt(Q,c,Ae.gridRow,Ae.gridCol,"borderRightColor",ne))}}T(Q)},[e,c,T,De]),Ve=u.useMemo(()=>(ee?.colors??[]).map(j=>j.token).filter(Boolean),[ee]),ze=u.useCallback(j=>{if(te.length===0||Ve.length===0)return;let ne=e;for(const pe of te)ne=De(ne,pe.r,pe.c),ne=bo(ne,c,pe.r,pe.c,j,Ve,k);T(ne)},[te,e,c,T,De,Ve,k]),Be=u.useCallback(j=>Ie(te,j),[Ie,te]),Xe=u.useMemo(()=>{if(k==="dark")return"";const j=B?.cell.props?.style;return typeof j?.borderColor=="string"?j.borderColor:""},[B,k]),Ne=u.useCallback((j,ne)=>{if(te.length===0)return;let pe=e;for(const Q of te)pe=Rt(pe,c,Q.r,Q.c,j,ne);T(pe)},[te,e,c,T]),Je=u.useMemo(()=>(fe?.colors??[]).map(j=>j.token).filter(j=>!!j),[fe]),ve=u.useCallback(j=>{if(te.length===0||Je.length===0)return;let ne=e;for(const pe of te)ne=bo(ne,c,pe.r,pe.c,j,Je,k);T(ne)},[te,e,c,T,Je,k]),qe=u.useCallback(j=>Ne("backgroundColor",j),[Ne]),We=u.useCallback(()=>{if(te.length===0)return;let j=e;for(const ne of te)j=bo(j,c,ne.r,ne.c,void 0,Je,k),k==="light"&&(j=Rt(j,c,ne.r,ne.c,"backgroundColor",void 0));T(j)},[te,e,c,T,Je,k]),ce=u.useCallback(j=>Ne("padding",j),[Ne]),q=u.useMemo(()=>{if(k==="dark")return"";const j=B?.cell.props?.style;return typeof j?.backgroundColor=="string"?j.backgroundColor:""},[B,k]),se=u.useMemo(()=>typeof B?.cell.props?.className=="string"?B.cell.props.className:"",[B]),ae=u.useMemo(()=>{const j=B?.cell.props?.style;return typeof j?.padding=="string"?j.padding:""},[B]),be=u.useCallback(j=>{const ne=j.currentTarget,pe=ne.style.pointerEvents;ne.style.pointerEvents="none";const Q=document.elementFromPoint(j.clientX,j.clientY);ne.style.pointerEvents=pe;const de=Q?.closest?.("[data-dnd-handle-path]");de&&de.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:j.clientX,clientY:j.clientY,pointerId:j.pointerId,pointerType:j.pointerType,button:j.button,isPrimary:!0}))},[]),Ce=u.useMemo(()=>{const j=new Map;for(const ne of p)j.has(ne.ref.gridCol)||j.set(ne.ref.gridCol,ne.box);return j},[p]),$e=u.useMemo(()=>{const j=new Map;for(const ne of p)j.has(ne.ref.gridRow)||j.set(ne.ref.gridRow,ne.box);return j},[p]);if(p.length===0)return null;const U=!!(B&&(B.colSpan>1||B.rowSpan>1)),ue=S!==null?S:y?.c??null,ge=$!==null?$:y?.r??null,ke=n.top-_l-wl-ty,he=n.left-xl-wl-ty;return i.jsxs("div",{className:"g7le-table-inplace","data-testid":"g7le-table-inplace",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:n2},children:[p.map(j=>{const ne=y&&y.r===j.ref.gridRow&&y.c===j.ref.gridCol,pe=X&&j.ref.gridRow>=X.r0&&j.ref.gridRow<=X.r1&&j.ref.gridCol>=X.c0&&j.ref.gridCol<=X.c1;return i.jsx("div",{"data-testid":`g7le-inplace-cell-${j.ref.gridRow}-${j.ref.gridCol}`,role:"button",tabIndex:-1,"aria-label":a("layout_editor.table_inplace.select_cell"),onMouseEnter:()=>{I(),C(j.ref.gridRow),D(j.ref.gridCol)},onMouseLeave:()=>{N()},onPointerDown:Q=>be(Q),onClick:Q=>{if(Q.stopPropagation(),Q.shiftKey&&(b||y))h({r:j.ref.gridRow,c:j.ref.gridCol});else{g({r:j.ref.gridRow,c:j.ref.gridCol}),h(null);const de=dl(e,j.ref,c).map(Ae=>`children.${Ae}`).join(".");d?.(de)}},style:{position:"absolute",top:j.box.top,left:j.box.left,width:j.box.width,height:j.box.height,minWidth:ny,minHeight:ny,boxSizing:"border-box",pointerEvents:"auto",cursor:"pointer",outline:ne?"2px solid #2563eb":"none",outlineOffset:-2,background:pe&&!ne?"rgba(37,99,235,0.14)":"transparent"}},`cell-${j.ref.gridRow}-${j.ref.gridCol}`)}),i.jsx("div",{"data-testid":"g7le-inplace-col-rail",onMouseEnter:I,onMouseLeave:N,style:{position:"absolute",top:ke,left:n.left,width:n.width,height:_l,pointerEvents:"none"},children:ue!==null&&Ce.has(ue)&&(()=>{const j=ue,ne=Ce.get(j),pe=Ti(f,j,-1),Q=Ti(f,j,1),de=ne.left-n.left;return i.jsxs("div",{"data-testid":`g7le-inplace-colgutter-${j}`,onMouseEnter:()=>{I(),D(j)},onMouseLeave:N,style:{position:"absolute",top:0,left:de,width:ne.width,minWidth:96,height:_l,display:"flex",gap:3,justifyContent:"center",alignItems:"center",pointerEvents:"auto"},children:[i.jsx("button",{type:"button",title:a("layout_editor.table_inplace.move_col_left"),disabled:!pe.ok,onClick:()=>L(j,-1),"data-testid":`g7le-inplace-col-left-${j}`,style:pe.ok?wn:Li,children:"←"}),i.jsx("button",{type:"button",title:a("layout_editor.table_inplace.add_col"),onClick:()=>P(j),"data-testid":`g7le-inplace-col-add-${j}`,style:wn,children:"+"}),i.jsx("button",{type:"button",title:a("layout_editor.table_inplace.remove_col"),disabled:f.colCount<=1,onClick:()=>A(j),"data-testid":`g7le-inplace-col-remove-${j}`,style:ry,children:"✕"}),i.jsx("button",{type:"button",title:a("layout_editor.table_inplace.move_col_right"),disabled:!Q.ok,onClick:()=>L(j,1),"data-testid":`g7le-inplace-col-right-${j}`,style:Q.ok?wn:Li,children:"→"})]},`colgut-${j}`)})()}),i.jsx("div",{"data-testid":"g7le-inplace-row-rail",style:{position:"absolute",top:n.top,left:he,width:xl,height:n.height,pointerEvents:"none"},children:ge!==null&&$e.has(ge)&&(()=>{const j=ge,ne=$e.get(j),pe=Ai(f,j,-1),Q=Ai(f,j,1),de=ne.top-n.top;return i.jsxs("div",{"data-testid":`g7le-inplace-rowgutter-${j}`,onMouseEnter:()=>{I(),C(j)},onMouseLeave:N,style:{position:"absolute",top:de,left:0,width:xl,height:ne.height,minHeight:48,display:"grid",gridTemplateColumns:"repeat(2, 22px)",gridAutoRows:"22px",gap:3,justifyContent:"center",alignContent:"center",pointerEvents:"auto"},children:[i.jsx("button",{type:"button",title:a("layout_editor.table_inplace.move_row_up"),disabled:!pe.ok,onClick:()=>H(j,-1),"data-testid":`g7le-inplace-row-up-${j}`,style:pe.ok?wn:Li,children:"↑"}),i.jsx("button",{type:"button",title:a("layout_editor.table_inplace.add_row"),onClick:()=>O(j),"data-testid":`g7le-inplace-row-add-${j}`,style:wn,children:"+"}),i.jsx("button",{type:"button",title:a("layout_editor.table_inplace.remove_row"),disabled:f.rows.length<=1,onClick:()=>z(j),"data-testid":`g7le-inplace-row-remove-${j}`,style:ry,children:"✕"}),i.jsx("button",{type:"button",title:a("layout_editor.table_inplace.move_row_down"),disabled:!Q.ok,onClick:()=>H(j,1),"data-testid":`g7le-inplace-row-down-${j}`,style:Q.ok?wn:Li,children:"↓"})]},`rowgut-${j}`)})()}),i.jsxs("div",{"data-testid":"g7le-inplace-corner-add",style:{position:"absolute",top:n.top+n.height+wl,left:n.left,display:"flex",flexDirection:"column",gap:6,pointerEvents:"auto",minWidth:200,maxWidth:Math.max(240,n.width),background:"#fff",border:"1px solid #e2e8f0",borderRadius:8,padding:8,boxShadow:"0 2px 8px rgba(0,0,0,0.12)"},children:[i.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[i.jsxs("button",{type:"button","data-testid":"g7le-inplace-add-row-bottom",onClick:()=>O(f.rows.length-1),style:iy,children:["+ ",a("layout_editor.table_inplace.add_row")]}),i.jsxs("button",{type:"button","data-testid":"g7le-inplace-add-col-right",onClick:()=>P(f.colCount-1),style:iy,children:["+ ",a("layout_editor.table_inplace.add_col")]})]}),!y&&i.jsx("div",{"data-testid":"g7le-inplace-select-hint",style:{fontSize:11,color:"#94a3b8",borderTop:"1px solid #f1f5f9",paddingTop:6},children:a("layout_editor.table_inplace.select_cell_hint")}),y&&i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,borderTop:"1px solid #f1f5f9",paddingTop:6},children:[ie&&i.jsx("div",{"data-testid":"g7le-inplace-range-count",style:{fontSize:11,color:"#2563eb"},children:a("layout_editor.table_inplace.range_selected",{count:Z.length})}),i.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"center"},children:[ie?i.jsx("button",{type:"button","data-testid":"g7le-inplace-merge-range",onClick:oe,style:cr,children:a("layout_editor.table_inplace.merge_range")}):i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button","data-testid":"g7le-inplace-merge-right",disabled:!Y,onClick:()=>F("right"),style:Y?cr:kl,children:a("layout_editor.table_inplace.merge_right")}),i.jsx("button",{type:"button","data-testid":"g7le-inplace-merge-down",disabled:!V,onClick:()=>F("down"),style:V?cr:kl,children:a("layout_editor.table_inplace.merge_down")})]}),i.jsx("button",{type:"button","data-testid":"g7le-inplace-unmerge",disabled:!U,onClick:G,style:U?cr:kl,children:a("layout_editor.table_inplace.unmerge")})]}),i.jsxs("div",{"data-testid":"g7le-inplace-cell-color",style:{borderTop:"1px solid #f1f5f9",paddingTop:6,display:"flex",flexDirection:"column",gap:6},children:[i.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"#475569",cursor:"pointer"},children:[i.jsx("input",{type:"checkbox","data-testid":"g7le-inplace-border-all-toggle",checked:_,onChange:j=>w(j.target.checked)}),a("layout_editor.table_inplace.border_apply_all")]}),i.jsx(jh,{colorScheme:k,onChange:x,t:a}),ee&&i.jsx("div",{"data-testid":"g7le-inplace-cell-border",children:i.jsx(Nh,{className:_?"":M,catalog:ee,t:a,onChange:ye,colorScheme:k,onPresetToken:ze,colorStyle:_?"":Xe,onColorStyle:Be})}),i.jsx("div",{"data-testid":"g7le-inplace-cell-fill",children:i.jsx(Oh,{colorStyle:_?"":q,className:_?"":se,catalog:fe,t:a,colorScheme:k,onPresetToken:ve,onCustomColor:qe,onClear:We})})]}),i.jsx("div",{"data-testid":"g7le-inplace-cell-padding",style:{borderTop:"1px solid #f1f5f9",paddingTop:6},children:i.jsx(Bh,{paddingStyle:_?"":ae,catalog:K,t:a,onChange:ce})})]})]})]})}const wn={width:22,height:22,lineHeight:"20px",padding:0,fontSize:13,border:"1px solid #cbd5e1",borderRadius:5,background:"#fff",color:"#475569",cursor:"pointer",boxShadow:"0 1px 3px rgba(0,0,0,0.18)"},ry={...wn,border:"1px solid #fecaca",color:"#dc2626"},Li={...wn,cursor:"not-allowed",opacity:.4,color:"#94a3b8",borderColor:"#e2e8f0"},cr={padding:"4px 10px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer",boxShadow:"0 1px 2px rgba(0,0,0,0.12)"},kl={...cr,cursor:"not-allowed",opacity:.4},iy={padding:"3px 8px",fontSize:11,border:"1px dashed #94a3b8",borderRadius:6,background:"#fff",color:"#475569",cursor:"pointer"};let sy=!1;function IM(){sy||(Bn("children",yh),Bn("table",_N),Bn("array",Jh),Bn("array-group",iM),Bn("array-cell-tree",fM),Va("table",EM),sy=!0)}function AM(){if(typeof window>"u")return;const e=window.G7Core;if(!e)return;const t=e.layoutEditor,n=Array.isArray(t?.__queue)?t.__queue:[],o=Array.isArray(t?.__readyCallbacks)?t.__readyCallbacks:[];e.layoutEditor={registerWidget:Ge,registerNodeEditor:Bn,registerCanvasOverlay:Va,onReady:r=>{typeof r=="function"&&r()}};for(const r of n){const[s,...a]=r;try{s==="widget"?Ge(a[0],a[1]):s==="nodeEditor"?Bn(a[0],a[1]):s==="canvasOverlay"&&Va(a[0],a[1])}catch{}}for(const r of o)try{r()}catch{}}const TM=1280;Pz(),IM(),AM();async function DM(e){if(typeof fetch!="function")return[];try{const t=await fetch(nn(`/api/admin/templates/${encodeURIComponent(e)}/editor/permission-candidates`,"json"),{credentials:"same-origin",headers:Me()});if(!t.ok)return[];const o=(await t.json().catch(()=>null))?.data?.permissions;if(!Array.isArray(o))return[];const r=[];for(const s of o)if(s&&typeof s=="object"){const a=s.key,l=s.name;typeof a=="string"&&a.length>0&&r.push({value:a,label:typeof l=="string"&&l?l:a})}return r}catch{return[]}}function zM({templateIdentifier:e}){a8({templateIdentifier:e}),l8(e);const{state:t,dispatch:n}=Qe(),{t:o}=et(),r=vo(),s=Bp(),a=g8(),l=t.selectedRoute?.layoutName??null,d=m8(e,l),c=t.editMode==="extension",p=u.useMemo(()=>c?y8(a):s,[c,a,s]),[f,b]=u.useState(null),[g,m]=u.useState(null),[h,v]=u.useState([]),[y,_]=u.useState("user"),[w,k]=u.useState(null),[x,$]=u.useState(null),[C,S]=u.useState([]);u.useEffect(()=>{let q=!1;return(async()=>{try{const se=await fetch(nn(`/api/templates/${encodeURIComponent(e)}/components`,"json"),{credentials:"same-origin",headers:{Accept:"application/json"}});if(!se.ok)return;const ae=await se.json().catch(()=>null);!q&&ae&&typeof ae=="object"&&b(ae)}catch{}})(),()=>{q=!0}},[e]),u.useEffect(()=>{let q=!1;return(async()=>{const{spec:se,sampleGlobalSources:ae}=await Sb({templateIdentifier:e,coreSeed:v8()});q||(m(se),v(ae),MM(e,se,ae))})(),()=>{q=!0}},[e]),u.useEffect(()=>{let q=!1;return(async()=>{if(typeof fetch=="function")try{const se=await fetch(`/api/admin/templates/${encodeURIComponent(e)}`,{credentials:"same-origin",headers:Me()});if(!se.ok)return;const be=(await se.json().catch(()=>null))?.data,Ce=be?.type;q||((Ce==="admin"||Ce==="user")&&_(Ce),typeof be?.name=="string"&&be.name&&k(be.name),typeof be?.version=="string"&&be.version&&$(be.version))}catch{}})(),()=>{q=!0}},[e]),u.useEffect(()=>{let q=!1;return(async()=>{if(typeof fetch=="function")try{const se=await fetch("/api/admin/templates/?per_page=100&page=1",{credentials:"same-origin",headers:Me()});if(!se.ok)return;const be=(await se.json().catch(()=>null))?.data?.data;if(!q&&Array.isArray(be)){const Ce=[];for(const $e of be){if(!$e||typeof $e!="object")continue;const U=$e.identifier;if(typeof U!="string"||!U||$e.is_pending===!0)continue;const ge=$e.type==="admin"?"admin":"user",ke=$e.name,he=$e.version;Ce.push({identifier:U,name:typeof ke=="string"?ke:U,version:typeof he=="string"?he:"",type:ge})}S(Ce)}}catch{}})(),()=>{q=!0}},[e]);const D=g?.nesting??null,E=t.selectedRoute?.path??null,I=t.editMode,N=t.selectedRoute?.layoutName??(c?a.document?.hostLayoutName??null:null),T=t.routeTree,B=u.useMemo(()=>{if(I!=="extension"||!N)return null;const q=Cl(T,N);return q||`__base__/${N}`},[I,N,T]),M=c&&t.returnRoute===null&&!!N;u.useEffect(()=>{if(!M||!N)return;const q=Cl(T,N);q&&n({type:"SET_RETURN_ROUTE",route:{path:q,layoutName:N}})},[M,N,T,n]),u.useEffect(()=>{const q=jD(I,E,B),se=HD(g?.states?.groups,q);n({type:"SET_AVAILABLE_STATES",states:se,activeStateId:FD(se)})},[g,I,E,B,n]);const[O,z]=u.useState([]);u.useEffect(()=>{let q=!1;return(async()=>{const se=await DM(e);q||z(se)})(),()=>{q=!0}},[e]),d8(),c8();const H=u.useCallback(q=>{const se=t.routeTree,ae=q.split("?")[0]?.split("#")[0]??q;return NM(se,ae)?"route_in_tree":"route_not_in_tree"},[t.routeTree]),P=u.useCallback(q=>{const se=q.split("?")[0]?.split("#")[0]??q,ae=Sl(t.routeTree,se);ae&&(p.isDirty&&!(!(typeof window<"u")||window.confirm(o("layout_editor.chrome.dirty_guard.message")))||n({type:"SELECT_ROUTE",route:{path:ae.path,layoutName:ae.layoutName}}))},[t.routeTree,p.isDirty,n]),A=u.useRef([]),L=u.useCallback(q=>{A.current=q},[]),[F,Y]=u.useState(null),V=u.useCallback(()=>Y(null),[]),X=u.useRef(null),Z=u.useRef(null);u.useEffect(()=>{const q=Z.current,se=X.current;if(!q||!se||typeof ResizeObserver>"u")return;const ae=()=>{se.style.setProperty("--g7le-header-h",`${Math.round(q.getBoundingClientRect().height)}px`)};ae();const be=new ResizeObserver(ae);return be.observe(q),()=>be.disconnect()},[]);const ie=u.useCallback(()=>{p.reload()},[p]),oe=u.useCallback(()=>{p.isDirty&&!(!(typeof window<"u")||window.confirm(o("layout_editor.chrome.dirty_guard.message")))||window.G7Core?.dispatch?.({handler:"openWindow",params:{path:`/admin/templates/${y}`,target:"_self"}})},[p.isDirty,o,y]),G=u.useCallback(q=>{if(!q||q===e||p.isDirty&&!(typeof window<"u"?window.confirm(o("layout_editor.chrome.dirty_guard.message")):!0))return;const se=ia(q);window.G7Core?.dispatch?.({handler:"openWindow",params:{path:se,target:"_self"}})},[e,p.isDirty,o]),ee=u.useCallback(()=>{const q=r.open({ariaLabel:o("layout_editor.custom_assets.title"),width:860,maxHeightRatio:.86,content:u.createElement(BE,{templateIdentifier:e,t:o,onClose:()=>r.close(q)})})},[r,e,o]),fe=typeof window<"u"&&(!!window.G7Config?.customAssetsDisabled||new URLSearchParams(window.location.search).get("custom")==="off"),K=u.useCallback(()=>{if(typeof window>"u"||p.isDirty&&!window.confirm(o("layout_editor.chrome.dirty_guard.message")))return;const q=new URL(window.location.href);if(fe){if(q.searchParams.delete("custom"),q.toString()===window.location.href){window.location.reload();return}}else q.searchParams.set("custom","off");window.G7Core?.dispatch?.({handler:"openWindow",params:{path:`${q.pathname}${q.search}${q.hash}`,target:"_self"}})},[p.isDirty,fe,o]),te=u.useCallback(()=>{const q=w7(e,t.selectedRoute?.path??null);window.G7Core?.dispatch?.({handler:"openWindow",params:{path:q}})},[e,t.selectedRoute]),ye=u.useCallback(()=>{const q=t.selectedRoute?.layoutName??"";if(!q)return;const se=r.open({ariaLabel:o("layout_editor.attachment_manager.title"),width:720,maxHeightRatio:.82,content:u.createElement(Fl,{templateIdentifier:e,layoutName:q,t:o,onClose:()=>r.close(se)})})},[r,e,t.selectedRoute,o]),Se=u.useCallback(()=>{const q=t.selectedRoute?.layoutName??"";if(!q)return;const se=ub(s.document?.raw??{}),ae=r.open({ariaLabel:o("layout_editor.translation_manager.title"),width:720,maxHeightRatio:.82,content:u.createElement(Nm,{templateIdentifier:e,layoutName:q,t:o,referencedKeys:se,onClose:()=>r.close(ae)})})},[r,e,t.selectedRoute,o,s.document]),De=u.useCallback((q,se)=>{const ae=window.G7Core;if(ae&&typeof ae.t=="function"){const be=ae.t(q,se);if(be&&be!==q&&!be.startsWith("$t:"))return be}return o(q,se)},[o]),Ie=u.useCallback(()=>{if(!t.selectedRoute||t.editMode==="extension"||t.editMode==="iteration_item")return;const q=r.open({ariaLabel:o("layout_editor.page_settings.title",{name:t.selectedRoute.path??""}),width:1080,maxHeightRatio:.88,closeOnEscape:!1,content:u.createElement(M$,{templateIdentifier:e,spec:g,t:o,resolveLabel:De,permissionCandidates:O,onClose:()=>r.close(q)})})},[r,t.selectedRoute,t.editMode,o,De,e,g,O]),Ve=u.useCallback(async()=>{const q=await d.createPreview(s.document?.raw??null);if(q.kind!=="success"){const se=q.kind==="network_error"?q.message:o("layout_editor.preview_action.no_document");typeof window<"u"&&window.alert(se)}},[d,s.document,o]),ze=u.useCallback(()=>{const q=t.selectedRoute?.layoutName??"",se=t.selectedRoute?.path??"",ae=t.editMode==="extension"&&se.startsWith("__extension__/")?se.slice(14):null,be=ae?{kind:"extension",extensionId:ae}:q?{kind:"layout",layoutName:q}:null;if(!be)return;const Ce=r.open({ariaLabel:o("layout_editor.version_history.title"),width:640,maxHeightRatio:.82,content:u.createElement(mE,{templateIdentifier:e,target:be,t:o,onRestored:async $e=>{typeof $e=="number"&&(be.kind==="extension"?n({type:"SET_EXTENSION_VERSION",extensionId:be.extensionId,version:$e}):n({type:"SET_LAYOUT_VERSION",layoutName:be.layoutName,version:$e})),await p.reload()},onClose:()=>r.close(Ce)})})},[r,e,t.selectedRoute,t.editMode,o,p,n]),Be=p.dirtyKeys.size>0||p.isDirty;u.useEffect(()=>{if(!Be)return;const q=se=>{se.preventDefault(),se.returnValue=""};return window.addEventListener("beforeunload",q),()=>window.removeEventListener("beforeunload",q)},[Be]);const Xe=u.useCallback(()=>{!p.isDirty||!(!(typeof window<"u")||window.confirm(o("layout_editor.chrome.reset_guard.message")))||p.reload()},[p,o]),Ne=u.useCallback(async()=>{const q=await p.save({sessionAddedPaths:A.current});Y(q),q.kind==="success"&&typeof q.newContentVersion=="number"&&(q.savedExtensionId?n({type:"SET_EXTENSION_VERSION",extensionId:q.savedExtensionId,version:q.newContentVersion}):q.savedLayoutName&&n({type:"SET_LAYOUT_VERSION",layoutName:q.savedLayoutName,version:q.newContentVersion}))},[p,n]),Je=u.useCallback(()=>{const q=r.open({ariaLabel:o("layout_editor.shortcuts.title"),width:560,maxHeightRatio:.85,content:u.createElement(GE,{t:o,onClose:()=>r.close(q)})})},[r,o]),ve=u.useMemo(()=>({save:()=>{Ne()},exit:oe,editCode:te,reset:Xe,translations:Se,addElement:()=>{t.selectedRoute&&n({type:"TOGGLE_PALETTE"})},help:Je,preview:()=>{t.selectedRoute?.layoutName&&Ve()}}),[Ne,oe,te,Xe,Se,t.selectedRoute,n,Je,Ve]),[qe,We]=u.useState(!1);u.useEffect(()=>{const q=window.setInterval(()=>{We(!!window.__g7LayoutEditorHasSelection)},200);return()=>window.clearInterval(q)},[]),gp({handlers:ve,hasSelection:qe});const ce=p;return t.routesError?i.jsx("div",{className:"g7le-chrome g7le-chrome--routes-error","data-testid":"g7le-chrome-routes-error",style:{position:"fixed",inset:0,display:"flex",background:"#f8fafc",color:"#0f172a",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif',fontSize:13,lineHeight:1.5,zIndex:9e3},children:i.jsx(Ja,{error:t.routesError})}):i.jsx("div",{className:"g7le-chrome","data-testid":"g7le-chrome",ref:X,style:{position:"static",minHeight:"100vh",minWidth:TM,background:"#f8fafc",color:"#0f172a",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif',fontSize:13,lineHeight:1.5,zIndex:9e3},children:i.jsxs(Ny,{value:ce,children:[c&&a.needsHostPicker&&a.document&&i.jsx(b8,{hostLayouts:a.document.hostLayouts,extensionLabel:null,onSelect:a.selectHost}),i.jsxs("div",{className:"g7le-chrome__header","data-testid":"g7le-chrome-header",ref:Z,style:{position:"sticky",top:0,zIndex:20,background:"#f8fafc"},children:[i.jsx(Hy,{onSave:()=>{Ne()},isDirty:p.isDirty,onExit:oe,onEditCode:te,onManageImages:ye,onManageTranslations:Se,onPageSettings:Ie,onReset:Xe,onShowShortcuts:Je,onPreview:Ve,onShowVersions:ze,templateName:w,templateVersion:x,templateList:C,onSwitchTemplate:G,onToggleCustomAssets:K,customAssetsDisabled:fe,onManageCustomAssets:ee}),i.jsx(d7,{result:F,onDismiss:V,onLoadLatest:ie}),i.jsxs("div",{className:"g7le-chrome__device-toolbar","data-testid":"g7le-chrome-device-toolbar",style:{display:"flex",justifyContent:"center",padding:"6px 12px",background:"#f1f5f9",borderBottom:"1px solid #e2e8f0"},children:[i.jsx(BD,{}),i.jsx(WD,{})]})]}),i.jsxs("div",{className:"g7le-chrome__body",style:{display:"grid",gridTemplateColumns:"auto 1fr",alignItems:"stretch"},children:[i.jsx(A7,{}),i.jsx(ND,{manifest:f,nesting:D,componentPalette:g?.componentPalette??null,spec:g,permissionCandidates:O,sampleGlobalSources:h,resolveRouteMatch:H,onNavigateToDestination:P,onSessionAddedPathsChange:L})]}),i.jsx(Py,{})]})})}function Sl(e,t){for(const n of e){if(n.kind==="route"&&n.path===t)return n;if(n.children&&n.children.length>0){const o=Sl(n.children,t);if(o)return o}}return null}function NM(e,t){return Sl(e,t)!==null}function Cl(e,t){for(const n of e){if(n.kind==="route"&&n.layoutName===t&&typeof n.path=="string")return n.path;if(n.children&&n.children.length>0){const o=Cl(n.children,t);if(o)return o}}return null}function MM(e,t,n){const o=[];Qa({sources:n,isGuestOnly:!1,warn:s=>{const a=/extension '([^']+)' override of core key '([^']+)'/.exec(s);a&&o.push(`${a[1]}:${a[2]}`)}});const r=t?.sampleData?.byDataSourceId?Object.keys(t.sampleData.byDataSourceId).length:0;wy({templateIdentifier:e,mergedSources:[...n.map(s=>({kind:s.kind,id:s.id}))],blockCounts:{controls:t?.controls?Object.keys(t.controls).length:0,componentCapabilities:t?.componentCapabilities?Object.keys(t.componentCapabilities).length:0,actionRecipes:t?.actionRecipes?Object.keys(t.actionRecipes).length:0,conditionRecipes:t?.conditionRecipes?Object.keys(t.conditionRecipes).length:0,paletteGroups:t?.componentPalette?.groups?.length??0,stateGroups:t?.states?.groups?.length??0,sampleDataIds:r},sampleGlobalSourceCount:n.length,sampleGlobalConflicts:o,timestamp:Date.now()})}function ay({templateIdentifier:e,initialLocale:t}){return u.useEffect(()=>()=>{gy(),yy(),my(),vy(),_y(),xy(),ky(),Sy(),Cy()},[]),i.jsx(zy,{templateIdentifier:e,initialLocale:t,children:i.jsx(Ly,{children:i.jsx(zM,{templateIdentifier:e})})})}if(typeof window<"u"){const e=window.G7Core||(window.G7Core={});if(e.__LayoutEditorChrome=ay,typeof e.__onChromeReady=="function")try{e.__onChromeReady()}catch{}}un.LayoutEditorChrome=ay,Object.defineProperty(un,Symbol.toStringTag,{value:"Module"})})(this.G7LayoutEditor=this.G7LayoutEditor||{},ReactJSXRuntime,React,ReactDOM); diff --git a/public/build/core/template-engine.min.js b/public/build/core/template-engine.min.js index 56b21084..62d342e4 100644 --- a/public/build/core/template-engine.min.js +++ b/public/build/core/template-engine.min.js @@ -1,4 +1,4 @@ -var gk=Object.defineProperty;var mk=(Yt,ra,aa)=>ra in Yt?gk(Yt,ra,{enumerable:!0,configurable:!0,writable:!0,value:aa}):Yt[ra]=aa;var $=(Yt,ra,aa)=>mk(Yt,typeof ra!="symbol"?ra+"":ra,aa);(function(Yt){"use strict";function ra(s,e){for(var n=0;nr[i]})}}}return Object.freeze(Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}))}function aa(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var bd={exports:{}},Ke={};/** +var wR=Object.defineProperty;var CR=(tn,na,ra)=>na in tn?wR(tn,na,{enumerable:!0,configurable:!0,writable:!0,value:ra}):tn[na]=ra;var M=(tn,na,ra)=>CR(tn,typeof na!="symbol"?na+"":na,ra);(function(tn){"use strict";function na(s,e){for(var n=0;nr[i]})}}}return Object.freeze(Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}))}function ra(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Ed={exports:{}},Ye={};/** * @license React * react.production.js * @@ -6,7 +6,7 @@ var gk=Object.defineProperty;var mk=(Yt,ra,aa)=>ra in Yt?gk(Yt,ra,{enumerable:!0 * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var gg;function Lw(){if(gg)return Ke;gg=1;var s=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),C=Symbol.iterator;function S(z){return z===null||typeof z!="object"?null:(z=C&&z[C]||z["@@iterator"],typeof z=="function"?z:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,w={};function R(z,T,pe){this.props=z,this.context=T,this.refs=w,this.updater=pe||v}R.prototype.isReactComponent={},R.prototype.setState=function(z,T){if(typeof z!="object"&&typeof z!="function"&&z!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,z,T,"setState")},R.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function L(){}L.prototype=R.prototype;function O(z,T,pe){this.props=z,this.context=T,this.refs=w,this.updater=pe||v}var j=O.prototype=new L;j.constructor=O,x(j,R.prototype),j.isPureReactComponent=!0;var F=Array.isArray;function G(){}var P={H:null,A:null,T:null,S:null},K=Object.prototype.hasOwnProperty;function he(z,T,pe){var fe=pe.ref;return{$$typeof:s,type:z,key:T,ref:fe!==void 0?fe:null,props:pe}}function Ee(z,T){return he(z.type,T,z.props)}function ke(z){return typeof z=="object"&&z!==null&&z.$$typeof===s}function ze(z){var T={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(pe){return T[pe]})}var Be=/\/+/g;function je(z,T){return typeof z=="object"&&z!==null&&z.key!=null?ze(""+z.key):T.toString(36)}function bt(z){switch(z.status){case"fulfilled":return z.value;case"rejected":throw z.reason;default:switch(typeof z.status=="string"?z.then(G,G):(z.status="pending",z.then(function(T){z.status==="pending"&&(z.status="fulfilled",z.value=T)},function(T){z.status==="pending"&&(z.status="rejected",z.reason=T)})),z.status){case"fulfilled":return z.value;case"rejected":throw z.reason}}throw z}function X(z,T,pe,fe,me){var ae=typeof z;(ae==="undefined"||ae==="boolean")&&(z=null);var Re=!1;if(z===null)Re=!0;else switch(ae){case"bigint":case"string":case"number":Re=!0;break;case"object":switch(z.$$typeof){case s:case e:Re=!0;break;case m:return Re=z._init,X(Re(z._payload),T,pe,fe,me)}}if(Re)return me=me(z),Re=fe===""?"."+je(z,0):fe,F(me)?(pe="",Re!=null&&(pe=Re.replace(Be,"$&/")+"/"),X(me,T,pe,"",function(Ge){return Ge})):me!=null&&(ke(me)&&(me=Ee(me,pe+(me.key==null||z&&z.key===me.key?"":(""+me.key).replace(Be,"$&/")+"/")+Re)),T.push(me)),1;Re=0;var Pe=fe===""?".":fe+":";if(F(z))for(var Me=0;Mera in Yt?gk(Yt,ra,{enumerable:!0 * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var yg;function $w(){return yg||(yg=1,(function(s){function e(X,de){var Ce=X.length;X.push(de);e:for(;0>>1,ge=X[Z];if(0>>1;Zi(pe,Ce))fei(me,pe)?(X[Z]=me,X[fe]=Ce,Z=fe):(X[Z]=pe,X[T]=Ce,Z=T);else if(fei(me,Ce))X[Z]=me,X[fe]=Ce,Z=fe;else break e}}return de}function i(X,de){var Ce=X.sortIndex-de.sortIndex;return Ce!==0?Ce:X.id-de.id}if(s.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;s.unstable_now=function(){return l.now()}}else{var c=Date,d=c.now();s.unstable_now=function(){return c.now()-d}}var f=[],p=[],m=1,y=null,C=3,S=!1,v=!1,x=!1,w=!1,R=typeof setTimeout=="function"?setTimeout:null,L=typeof clearTimeout=="function"?clearTimeout:null,O=typeof setImmediate<"u"?setImmediate:null;function j(X){for(var de=n(p);de!==null;){if(de.callback===null)r(p);else if(de.startTime<=X)r(p),de.sortIndex=de.expirationTime,e(f,de);else break;de=n(p)}}function F(X){if(x=!1,j(X),!v)if(n(f)!==null)v=!0,G||(G=!0,ze());else{var de=n(p);de!==null&&bt(F,de.startTime-X)}}var G=!1,P=-1,K=5,he=-1;function Ee(){return w?!0:!(s.unstable_now()-heX&&Ee());){var Z=y.callback;if(typeof Z=="function"){y.callback=null,C=y.priorityLevel;var ge=Z(y.expirationTime<=X);if(X=s.unstable_now(),typeof ge=="function"){y.callback=ge,j(X),de=!0;break t}y===n(f)&&r(f),j(X)}else r(f);y=n(f)}if(y!==null)de=!0;else{var z=n(p);z!==null&&bt(F,z.startTime-X),de=!1}}break e}finally{y=null,C=Ce,S=!1}de=void 0}}finally{de?ze():G=!1}}}var ze;if(typeof O=="function")ze=function(){O(ke)};else if(typeof MessageChannel<"u"){var Be=new MessageChannel,je=Be.port2;Be.port1.onmessage=ke,ze=function(){je.postMessage(null)}}else ze=function(){R(ke,0)};function bt(X,de){P=R(function(){X(s.unstable_now())},de)}s.unstable_IdlePriority=5,s.unstable_ImmediatePriority=1,s.unstable_LowPriority=4,s.unstable_NormalPriority=3,s.unstable_Profiling=null,s.unstable_UserBlockingPriority=2,s.unstable_cancelCallback=function(X){X.callback=null},s.unstable_forceFrameRate=function(X){0>X||125Z?(X.sortIndex=Ce,e(p,X),n(f)===null&&X===n(p)&&(x?(L(P),P=-1):x=!0,bt(F,Ce-Z))):(X.sortIndex=ge,e(f,X),v||S||(v=!0,G||(G=!0,ze()))),X},s.unstable_shouldYield=Ee,s.unstable_wrapCallback=function(X){var de=C;return function(){var Ce=C;C=de;try{return X.apply(this,arguments)}finally{C=Ce}}}})(Cd)),Cd}var bg;function Mw(){return bg||(bg=1,wd.exports=$w()),wd.exports}var Ed={exports:{}},wn={};/** + */var Ng;function s0(){return Ng||(Ng=1,(function(s){function e(Q,ue){var De=Q.length;Q.push(ue);e:for(;0>>1,me=Q[ee];if(0>>1;eei(fe,De))hei(Ae,fe)?(Q[ee]=Ae,Q[he]=De,ee=he):(Q[ee]=fe,Q[T]=De,ee=T);else if(hei(Ae,De))Q[ee]=Ae,Q[he]=De,ee=he;else break e}}return ue}function i(Q,ue){var De=Q.sortIndex-ue.sortIndex;return De!==0?De:Q.id-ue.id}if(s.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;s.unstable_now=function(){return l.now()}}else{var c=Date,d=c.now();s.unstable_now=function(){return c.now()-d}}var f=[],h=[],m=1,y=null,v=3,S=!1,_=!1,x=!1,A=!1,D=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;function L(Q){for(var ue=n(h);ue!==null;){if(ue.callback===null)r(h);else if(ue.startTime<=Q)r(h),ue.sortIndex=ue.expirationTime,e(f,ue);else break;ue=n(h)}}function B(Q){if(x=!1,L(Q),!_)if(n(f)!==null)_=!0,q||(q=!0,je());else{var ue=n(h);ue!==null&&Et(B,ue.startTime-Q)}}var q=!1,z=-1,W=5,de=-1;function _e(){return A?!0:!(s.unstable_now()-deQ&&_e());){var ee=y.callback;if(typeof ee=="function"){y.callback=null,v=y.priorityLevel;var me=ee(y.expirationTime<=Q);if(Q=s.unstable_now(),typeof me=="function"){y.callback=me,L(Q),ue=!0;break t}y===n(f)&&r(f),L(Q)}else r(f);y=n(f)}if(y!==null)ue=!0;else{var H=n(h);H!==null&&Et(B,H.startTime-Q),ue=!1}}break e}finally{y=null,v=De,S=!1}ue=void 0}}finally{ue?je():q=!1}}}var je;if(typeof k=="function")je=function(){k(Se)};else if(typeof MessageChannel<"u"){var Fe=new MessageChannel,ze=Fe.port2;Fe.port1.onmessage=Se,je=function(){ze.postMessage(null)}}else je=function(){D(Se,0)};function Et(Q,ue){z=D(function(){Q(s.unstable_now())},ue)}s.unstable_IdlePriority=5,s.unstable_ImmediatePriority=1,s.unstable_LowPriority=4,s.unstable_NormalPriority=3,s.unstable_Profiling=null,s.unstable_UserBlockingPriority=2,s.unstable_cancelCallback=function(Q){Q.callback=null},s.unstable_forceFrameRate=function(Q){0>Q||125ee?(Q.sortIndex=De,e(h,Q),n(f)===null&&Q===n(h)&&(x?(O(z),z=-1):x=!0,Et(B,De-ee))):(Q.sortIndex=me,e(f,Q),_||S||(_=!0,q||(q=!0,je()))),Q},s.unstable_shouldYield=_e,s.unstable_wrapCallback=function(Q){var ue=v;return function(){var De=v;v=ue;try{return Q.apply(this,arguments)}finally{v=De}}}})(Td)),Td}var Ig;function o0(){return Ig||(Ig=1,xd.exports=s0()),xd.exports}var kd={exports:{}},An={};/** * @license React * react-dom.production.js * @@ -22,7 +22,7 @@ var gk=Object.defineProperty;var mk=(Yt,ra,aa)=>ra in Yt?gk(Yt,ra,{enumerable:!0 * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var vg;function Nw(){if(vg)return wn;vg=1;var s=vd();function e(f){var p="https://react.dev/errors/"+f;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(s)}catch(e){console.error(e)}}return s(),Ed.exports=Nw(),Ed.exports}/** + */var jg;function l0(){if(jg)return An;jg=1;var s=_d();function e(f){var h="https://react.dev/errors/"+f;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(s)}catch(e){console.error(e)}}return s(),kd.exports=l0(),kd.exports}/** * @license React * react-dom-client.production.js * @@ -30,23 +30,26 @@ var gk=Object.defineProperty;var mk=(Yt,ra,aa)=>ra in Yt?gk(Yt,ra,{enumerable:!0 * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Cg;function Iw(){if(Cg)return uo;Cg=1;var s=Mw(),e=vd(),n=wg();function r(t){var a="https://react.dev/errors/"+t;if(1ge||(t.current=Z[ge],Z[ge]=null,ge--)}function pe(t,a){ge++,Z[ge]=t.current,t.current=a}var fe=z(null),me=z(null),ae=z(null),Re=z(null);function Pe(t,a){switch(pe(ae,a),pe(me,t),pe(fe,null),a.nodeType){case 9:case 11:t=(t=a.documentElement)&&(t=t.namespaceURI)?ZS(t):0;break;default:if(t=a.tagName,a=a.namespaceURI)a=ZS(a),t=ew(a,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}T(fe),pe(fe,t)}function Me(){T(fe),T(me),T(ae)}function Ge(t){t.memoizedState!==null&&pe(Re,t);var a=fe.current,o=ew(a,t.type);a!==o&&(pe(me,t),pe(fe,o))}function kt(t){me.current===t&&(T(fe),T(me)),Re.current===t&&(T(Re),Ql._currentValue=Ce)}var vt,hn;function Dt(t){if(vt===void 0)try{throw Error()}catch(o){var a=o.stack.trim().match(/\n( *(at )?)/);vt=a&&a[1]||"",hn=-1me||(t.current=ee[me],ee[me]=null,me--)}function fe(t,a){me++,ee[me]=t.current,t.current=a}var he=H(null),Ae=H(null),se=H(null),ge=H(null);function $e(t,a){switch(fe(se,a),fe(Ae,t),fe(he,null),a.nodeType){case 9:case 11:t=(t=a.documentElement)&&(t=t.namespaceURI)?Aw(t):0;break;default:if(t=a.tagName,a=a.namespaceURI)a=Aw(a),t=xw(a,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}T(he),fe(he,t)}function Te(){T(he),T(Ae),T(se)}function Ie(t){t.memoizedState!==null&&fe(ge,t);var a=he.current,o=xw(a,t.type);a!==o&&(fe(Ae,t),fe(he,o))}function xt(t){Ae.current===t&&(T(he),T(Ae)),ge.current===t&&(T(ge),Yl._currentValue=De)}var rt,gt;function at(t){if(rt===void 0)try{throw Error()}catch(o){var a=o.stack.trim().match(/\n( *(at )?)/);rt=a&&a[1]||"",gt=-1)":-1h||H[u]!==Y[h]){var ne=` -`+H[u].replace(" at new "," at ");return t.displayName&&ne.includes("")&&(ne=ne.replace("",t.displayName)),ne}while(1<=u&&0<=h);break}}}finally{Xt=!1,Error.prepareStackTrace=o}return(o=t?t.displayName||t.name:"")?Dt(o):""}function Ut(t,a){switch(t.tag){case 26:case 27:case 5:return Dt(t.type);case 16:return Dt("Lazy");case 13:return t.child!==a&&a!==null?Dt("Suspense Fallback"):Dt("Suspense");case 19:return Dt("SuspenseList");case 0:case 15:return un(t.type,!1);case 11:return un(t.type.render,!1);case 1:return un(t.type,!0);case 31:return Dt("Activity");default:return""}}function $r(t){try{var a="",o=null;do a+=Ut(t,o),o=t,t=t.return;while(t);return a}catch(u){return` +`+rt+t+gt}var Yt=!1;function Ht(t,a){if(!t||Yt)return"";Yt=!0;var o=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var u={DetermineComponentFrameRoot:function(){try{if(a){var le=function(){throw Error()};if(Object.defineProperty(le.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(le,[])}catch(te){var J=te}Reflect.construct(t,[],le)}else{try{le.call()}catch(te){J=te}t.call(le.prototype)}}else{try{throw Error()}catch(te){J=te}(le=t())&&typeof le.catch=="function"&&le.catch(function(){})}}catch(te){if(te&&J&&typeof te.stack=="string")return[te.stack,J.stack]}return[null,null]}};u.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var p=Object.getOwnPropertyDescriptor(u.DetermineComponentFrameRoot,"name");p&&p.configurable&&Object.defineProperty(u.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var g=u.DetermineComponentFrameRoot(),w=g[0],R=g[1];if(w&&R){var P=w.split(` +`),X=R.split(` +`);for(p=u=0;up||P[u]!==X[p]){var re=` +`+P[u].replace(" at new "," at ");return t.displayName&&re.includes("")&&(re=re.replace("",t.displayName)),re}while(1<=u&&0<=p);break}}}finally{Yt=!1,Error.prepareStackTrace=o}return(o=t?t.displayName||t.name:"")?at(o):""}function bt(t,a){switch(t.tag){case 26:case 27:case 5:return at(t.type);case 16:return at("Lazy");case 13:return t.child!==a&&a!==null?at("Suspense Fallback"):at("Suspense");case 19:return at("SuspenseList");case 0:case 15:return Ht(t.type,!1);case 11:return Ht(t.type.render,!1);case 1:return Ht(t.type,!0);case 31:return at("Activity");default:return""}}function qe(t){try{var a="",o=null;do a+=bt(t,o),o=t,t=t.return;while(t);return a}catch(u){return` Error generating stack: `+u.message+` -`+u.stack}}var En=Object.prototype.hasOwnProperty,dn=s.unstable_scheduleCallback,pn=s.unstable_cancelCallback,fr=s.unstable_shouldYield,er=s.unstable_requestPaint,Pt=s.unstable_now,St=s.unstable_getCurrentPriorityLevel,da=s.unstable_ImmediatePriority,In=s.unstable_UserBlockingPriority,kn=s.unstable_NormalPriority,Rn=s.unstable_LowPriority,jn=s.unstable_IdlePriority,gn=s.log,fa=s.unstable_setDisableYieldValue,zn=null,Vt=null;function _n(t){if(typeof gn=="function"&&fa(t),Vt&&typeof Vt.setStrictMode=="function")try{Vt.setStrictMode(zn,t)}catch{}}var an=Math.clz32?Math.clz32:ce,q=Math.log,oe=Math.LN2;function ce(t){return t>>>=0,t===0?32:31-(q(t)/oe|0)|0}var J=256,ve=262144,ue=4194304;function we(t){var a=t&42;if(a!==0)return a;switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function _e(t,a,o){var u=t.pendingLanes;if(u===0)return 0;var h=0,g=t.suspendedLanes,E=t.pingedLanes;t=t.warmLanes;var k=u&134217727;return k!==0?(u=k&~g,u!==0?h=we(u):(E&=k,E!==0?h=we(E):o||(o=k&~t,o!==0&&(h=we(o))))):(k=u&~g,k!==0?h=we(k):E!==0?h=we(E):o||(o=u&~t,o!==0&&(h=we(o)))),h===0?0:a!==0&&a!==h&&(a&g)===0&&(g=h&-h,o=a&-a,g>=o||g===32&&(o&4194048)!==0)?a:h}function qe(t,a){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&a)===0}function xe(t,a){switch(t){case 1:case 2:case 4:case 8:case 64:return a+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return a+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function De(){var t=ue;return ue<<=1,(ue&62914560)===0&&(ue=4194304),t}function Ae(t){for(var a=[],o=0;31>o;o++)a.push(t);return a}function tt(t,a){t.pendingLanes|=a,a!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function Ne(t,a,o,u,h,g){var E=t.pendingLanes;t.pendingLanes=o,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=o,t.entangledLanes&=o,t.errorRecoveryDisabledLanes&=o,t.shellSuspendCounter=0;var k=t.entanglements,H=t.expirationTimes,Y=t.hiddenUpdates;for(o=E&~o;0"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var Ni=/[\n"\\]/g;function Bn(t){return t.replace(Ni,function(a){return"\\"+a.charCodeAt(0).toString(16)+" "})}function ma(t,a,o,u,h,g,E,k){t.name="",E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"?t.type=E:t.removeAttribute("type"),a!=null?E==="number"?(a===0&&t.value===""||t.value!=a)&&(t.value=""+Pn(a)):t.value!==""+Pn(a)&&(t.value=""+Pn(a)):E!=="submit"&&E!=="reset"||t.removeAttribute("value"),a!=null?rl(t,E,Pn(a)):o!=null?rl(t,E,Pn(o)):u!=null&&t.removeAttribute("value"),h==null&&g!=null&&(t.defaultChecked=!!g),h!=null&&(t.checked=h&&typeof h!="function"&&typeof h!="symbol"),k!=null&&typeof k!="function"&&typeof k!="symbol"&&typeof k!="boolean"?t.name=""+Pn(k):t.removeAttribute("name")}function nu(t,a,o,u,h,g,E,k){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(t.type=g),a!=null||o!=null){if(!(g!=="submit"&&g!=="reset"||a!=null)){tl(t);return}o=o!=null?""+Pn(o):"",a=a!=null?""+Pn(a):o,k||a===t.value||(t.value=a),t.defaultValue=a}u=u??h,u=typeof u!="function"&&typeof u!="symbol"&&!!u,t.checked=k?t.checked:!!u,t.defaultChecked=!!u,E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"&&(t.name=E),tl(t)}function rl(t,a,o){a==="number"&&ga(t.ownerDocument)===t||t.defaultValue===""+o||(t.defaultValue=""+o)}function Va(t,a,o,u){if(t=t.options,a){a={};for(var h=0;h"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ol=!1;if(Ir)try{var ji={};Object.defineProperty(ji,"passive",{get:function(){ol=!0}}),window.addEventListener("test",ji,ji),window.removeEventListener("test",ji,ji)}catch{ol=!1}var jr=null,ll=null,Ls=null;function Fe(){if(Ls)return Ls;var t,a=ll,o=a.length,u,h="value"in jr?jr.value:jr.textContent,g=h.length;for(t=0;t=ct),du=" ",pl=!1;function fu(t,a){switch(t){case"keyup":return Ve.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function gl(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Ja=!1;function hu(t,a){switch(t){case"compositionend":return gl(a);case"keypress":return a.which!==32?null:(pl=!0,du);case"textInput":return t=a.data,t===du&&pl?null:t;default:return null}}function Ch(t,a){if(Ja)return t==="compositionend"||!it&&fu(t,a)?(t=Fe(),Ls=ll=jr=null,Ja=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1=a)return{node:o,offset:a-t};t=u}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=yb(o)}}function vb(t,a){return t&&a?t===a?!0:t&&t.nodeType===3?!1:a&&a.nodeType===3?vb(t,a.parentNode):"contains"in t?t.contains(a):t.compareDocumentPosition?!!(t.compareDocumentPosition(a)&16):!1:!1}function Sb(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var a=ga(t.document);a instanceof t.HTMLIFrameElement;){try{var o=typeof a.contentWindow.location.href=="string"}catch{o=!1}if(o)t=a.contentWindow;else break;a=ga(t.document)}return a}function _h(t){var a=t&&t.nodeName&&t.nodeName.toLowerCase();return a&&(a==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||a==="textarea"||t.contentEditable==="true")}var Wx=Ir&&"documentMode"in document&&11>=document.documentMode,Is=null,Ah=null,El=null,xh=!1;function wb(t,a,o){var u=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;xh||Is==null||Is!==ga(u)||(u=Is,"selectionStart"in u&&_h(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),El&&Cl(El,u)||(El=u,u=rd(Ah,"onSelect"),0>=E,h-=E,Zr=1<<32-an(a)+h|o<Qe?(ot=Le,Le=null):ot=Le.sibling;var pt=Q(V,Le,W[Qe],se);if(pt===null){Le===null&&(Le=ot);break}t&&Le&&pt.alternate===null&&a(V,Le),B=g(pt,B,Qe),ht===null?Ie=pt:ht.sibling=pt,ht=pt,Le=ot}if(Qe===W.length)return o(V,Le),ut&&Sa(V,Qe),Ie;if(Le===null){for(;QeQe?(ot=Le,Le=null):ot=Le.sibling;var Si=Q(V,Le,pt.value,se);if(Si===null){Le===null&&(Le=ot);break}t&&Le&&Si.alternate===null&&a(V,Le),B=g(Si,B,Qe),ht===null?Ie=Si:ht.sibling=Si,ht=Si,Le=ot}if(pt.done)return o(V,Le),ut&&Sa(V,Qe),Ie;if(Le===null){for(;!pt.done;Qe++,pt=W.next())pt=le(V,pt.value,se),pt!==null&&(B=g(pt,B,Qe),ht===null?Ie=pt:ht.sibling=pt,ht=pt);return ut&&Sa(V,Qe),Ie}for(Le=u(Le);!pt.done;Qe++,pt=W.next())pt=te(Le,V,Qe,pt.value,se),pt!==null&&(t&&pt.alternate!==null&&Le.delete(pt.key===null?Qe:pt.key),B=g(pt,B,Qe),ht===null?Ie=pt:ht.sibling=pt,ht=pt);return t&&Le.forEach(function(pk){return a(V,pk)}),ut&&Sa(V,Qe),Ie}function xt(V,B,W,se){if(typeof W=="object"&&W!==null&&W.type===x&&W.key===null&&(W=W.props.children),typeof W=="object"&&W!==null){switch(W.$$typeof){case S:e:{for(var Ie=W.key;B!==null;){if(B.key===Ie){if(Ie=W.type,Ie===x){if(B.tag===7){o(V,B.sibling),se=h(B,W.props.children),se.return=V,V=se;break e}}else if(B.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===K&&Yi(Ie)===B.type){o(V,B.sibling),se=h(B,W.props),Rl(se,W),se.return=V,V=se;break e}o(V,B);break}else a(V,B);B=B.sibling}W.type===x?(se=Gi(W.props.children,V.mode,se,W.key),se.return=V,V=se):(se=Su(W.type,W.key,W.props,null,V.mode,se),Rl(se,W),se.return=V,V=se)}return E(V);case v:e:{for(Ie=W.key;B!==null;){if(B.key===Ie)if(B.tag===4&&B.stateNode.containerInfo===W.containerInfo&&B.stateNode.implementation===W.implementation){o(V,B.sibling),se=h(B,W.children||[]),se.return=V,V=se;break e}else{o(V,B);break}else a(V,B);B=B.sibling}se=$h(W,V.mode,se),se.return=V,V=se}return E(V);case K:return W=Yi(W),xt(V,B,W,se)}if(bt(W))return Te(V,B,W,se);if(ze(W)){if(Ie=ze(W),typeof Ie!="function")throw Error(r(150));return W=Ie.call(W),Ue(V,B,W,se)}if(typeof W.then=="function")return xt(V,B,Tu(W),se);if(W.$$typeof===O)return xt(V,B,Eu(V,W),se);ku(V,W)}return typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint"?(W=""+W,B!==null&&B.tag===6?(o(V,B.sibling),se=h(B,W),se.return=V,V=se):(o(V,B),se=Lh(W,V.mode,se),se.return=V,V=se),E(V)):o(V,B)}return function(V,B,W,se){try{kl=0;var Ie=xt(V,B,W,se);return Ks=null,Ie}catch(Le){if(Le===Vs||Le===Au)throw Le;var ht=nr(29,Le,null,V.mode);return ht.lanes=se,ht.return=V,ht}finally{}}}var Ji=Gb(!0),Fb=Gb(!1),ri=!1;function Fh(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Vh(t,a){t=t.updateQueue,a.updateQueue===t&&(a.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function ai(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function ii(t,a,o){var u=t.updateQueue;if(u===null)return null;if(u=u.shared,(mt&2)!==0){var h=u.pending;return h===null?a.next=a:(a.next=h.next,h.next=a),u.pending=a,a=vu(t),kb(t,null,o),a}return bu(t,u,a,o),vu(t)}function Dl(t,a,o){if(a=a.updateQueue,a!==null&&(a=a.shared,(o&4194048)!==0)){var u=a.lanes;u&=t.pendingLanes,o|=u,a.lanes=o,Se(t,o)}}function Kh(t,a){var o=t.updateQueue,u=t.alternate;if(u!==null&&(u=u.updateQueue,o===u)){var h=null,g=null;if(o=o.firstBaseUpdate,o!==null){do{var E={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};g===null?h=g=E:g=g.next=E,o=o.next}while(o!==null);g===null?h=g=a:g=g.next=a}else h=g=a;o={baseState:u.baseState,firstBaseUpdate:h,lastBaseUpdate:g,shared:u.shared,callbacks:u.callbacks},t.updateQueue=o;return}t=o.lastBaseUpdate,t===null?o.firstBaseUpdate=a:t.next=a,o.lastBaseUpdate=a}var Wh=!1;function Ol(){if(Wh){var t=Fs;if(t!==null)throw t}}function Ll(t,a,o,u){Wh=!1;var h=t.updateQueue;ri=!1;var g=h.firstBaseUpdate,E=h.lastBaseUpdate,k=h.shared.pending;if(k!==null){h.shared.pending=null;var H=k,Y=H.next;H.next=null,E===null?g=Y:E.next=Y,E=H;var ne=t.alternate;ne!==null&&(ne=ne.updateQueue,k=ne.lastBaseUpdate,k!==E&&(k===null?ne.firstBaseUpdate=Y:k.next=Y,ne.lastBaseUpdate=H))}if(g!==null){var le=h.baseState;E=0,ne=Y=H=null,k=g;do{var Q=k.lane&-536870913,te=Q!==k.lane;if(te?(st&Q)===Q:(u&Q)===Q){Q!==0&&Q===Gs&&(Wh=!0),ne!==null&&(ne=ne.next={lane:0,tag:k.tag,payload:k.payload,callback:null,next:null});e:{var Te=t,Ue=k;Q=a;var xt=o;switch(Ue.tag){case 1:if(Te=Ue.payload,typeof Te=="function"){le=Te.call(xt,le,Q);break e}le=Te;break e;case 3:Te.flags=Te.flags&-65537|128;case 0:if(Te=Ue.payload,Q=typeof Te=="function"?Te.call(xt,le,Q):Te,Q==null)break e;le=y({},le,Q);break e;case 2:ri=!0}}Q=k.callback,Q!==null&&(t.flags|=64,te&&(t.flags|=8192),te=h.callbacks,te===null?h.callbacks=[Q]:te.push(Q))}else te={lane:Q,tag:k.tag,payload:k.payload,callback:k.callback,next:null},ne===null?(Y=ne=te,H=le):ne=ne.next=te,E|=Q;if(k=k.next,k===null){if(k=h.shared.pending,k===null)break;te=k,k=te.next,te.next=null,h.lastBaseUpdate=te,h.shared.pending=null}}while(!0);ne===null&&(H=le),h.baseState=H,h.firstBaseUpdate=Y,h.lastBaseUpdate=ne,g===null&&(h.shared.lanes=0),ui|=E,t.lanes=E,t.memoizedState=le}}function Vb(t,a){if(typeof t!="function")throw Error(r(191,t));t.call(a)}function Kb(t,a){var o=t.callbacks;if(o!==null)for(t.callbacks=null,t=0;tg?g:8;var E=X.T,k={};X.T=k,hp(t,!1,a,o);try{var H=h(),Y=X.S;if(Y!==null&&Y(k,H),H!==null&&typeof H=="object"&&typeof H.then=="function"){var ne=rT(H,u);Nl(t,a,ne,or(t))}else Nl(t,a,u,or(t))}catch(le){Nl(t,a,{then:function(){},status:"rejected",reason:le},or())}finally{de.p=g,E!==null&&k.types!==null&&(E.types=k.types),X.T=E}}function cT(){}function dp(t,a,o,u){if(t.tag!==5)throw Error(r(476));var h=Av(t).queue;_v(t,h,a,Ce,o===null?cT:function(){return xv(t),o(u)})}function Av(t){var a=t.memoizedState;if(a!==null)return a;a={memoizedState:Ce,baseState:Ce,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:_a,lastRenderedState:Ce},next:null};var o={};return a.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:_a,lastRenderedState:o},next:null},t.memoizedState=a,t=t.alternate,t!==null&&(t.memoizedState=a),a}function xv(t){var a=Av(t);a.next===null&&(a=t.alternate.memoizedState),Nl(t,a.next.queue,{},or())}function fp(){return bn(Ql)}function Tv(){return Wt().memoizedState}function kv(){return Wt().memoizedState}function uT(t){for(var a=t.return;a!==null;){switch(a.tag){case 24:case 3:var o=or();t=ai(o);var u=ii(a,t,o);u!==null&&(Kn(u,a,o),Dl(u,a,o)),a={cache:Ph()},t.payload=a;return}a=a.return}}function dT(t,a,o){var u=or();o={lane:u,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},zu(t)?Dv(a,o):(o=Dh(t,a,o,u),o!==null&&(Kn(o,t,u),Ov(o,a,u)))}function Rv(t,a,o){var u=or();Nl(t,a,o,u)}function Nl(t,a,o,u){var h={lane:u,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(zu(t))Dv(a,h);else{var g=t.alternate;if(t.lanes===0&&(g===null||g.lanes===0)&&(g=a.lastRenderedReducer,g!==null))try{var E=a.lastRenderedState,k=g(E,o);if(h.hasEagerState=!0,h.eagerState=k,tr(k,E))return bu(t,a,h,0),Rt===null&&yu(),!1}catch{}finally{}if(o=Dh(t,a,h,u),o!==null)return Kn(o,t,u),Ov(o,a,u),!0}return!1}function hp(t,a,o,u){if(u={lane:2,revertLane:Fp(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},zu(t)){if(a)throw Error(r(479))}else a=Dh(t,o,u,2),a!==null&&Kn(a,t,2)}function zu(t){var a=t.alternate;return t===Xe||a!==null&&a===Xe}function Dv(t,a){Ys=Ou=!0;var o=t.pending;o===null?a.next=a:(a.next=o.next,o.next=a),t.pending=a}function Ov(t,a,o){if((o&4194048)!==0){var u=a.lanes;u&=t.pendingLanes,o|=u,a.lanes=o,Se(t,o)}}var Il={readContext:bn,use:Mu,useCallback:qt,useContext:qt,useEffect:qt,useImperativeHandle:qt,useLayoutEffect:qt,useInsertionEffect:qt,useMemo:qt,useReducer:qt,useRef:qt,useState:qt,useDebugValue:qt,useDeferredValue:qt,useTransition:qt,useSyncExternalStore:qt,useId:qt,useHostTransitionStatus:qt,useFormState:qt,useActionState:qt,useOptimistic:qt,useMemoCache:qt,useCacheRefresh:qt};Il.useEffectEvent=qt;var Lv={readContext:bn,use:Mu,useCallback:function(t,a){return Dn().memoizedState=[t,a===void 0?null:a],t},useContext:bn,useEffect:gv,useImperativeHandle:function(t,a,o){o=o!=null?o.concat([t]):null,Iu(4194308,4,vv.bind(null,a,t),o)},useLayoutEffect:function(t,a){return Iu(4194308,4,t,a)},useInsertionEffect:function(t,a){Iu(4,2,t,a)},useMemo:function(t,a){var o=Dn();a=a===void 0?null:a;var u=t();if(Qi){_n(!0);try{t()}finally{_n(!1)}}return o.memoizedState=[u,a],u},useReducer:function(t,a,o){var u=Dn();if(o!==void 0){var h=o(a);if(Qi){_n(!0);try{o(a)}finally{_n(!1)}}}else h=a;return u.memoizedState=u.baseState=h,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:h},u.queue=t,t=t.dispatch=dT.bind(null,Xe,t),[u.memoizedState,t]},useRef:function(t){var a=Dn();return t={current:t},a.memoizedState=t},useState:function(t){t=sp(t);var a=t.queue,o=Rv.bind(null,Xe,a);return a.dispatch=o,[t.memoizedState,o]},useDebugValue:cp,useDeferredValue:function(t,a){var o=Dn();return up(o,t,a)},useTransition:function(){var t=sp(!1);return t=_v.bind(null,Xe,t.queue,!0,!1),Dn().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,a,o){var u=Xe,h=Dn();if(ut){if(o===void 0)throw Error(r(407));o=o()}else{if(o=a(),Rt===null)throw Error(r(349));(st&127)!==0||Zb(u,a,o)}h.memoizedState=o;var g={value:o,getSnapshot:a};return h.queue=g,gv(tv.bind(null,u,g,t),[t]),u.flags|=2048,Js(9,{destroy:void 0},ev.bind(null,u,g,o,a),null),o},useId:function(){var t=Dn(),a=Rt.identifierPrefix;if(ut){var o=ea,u=Zr;o=(u&~(1<<32-an(u)-1)).toString(32)+o,a="_"+a+"R_"+o,o=Lu++,0<\/script>",g=g.removeChild(g.firstChild);break;case"select":g=typeof u.is=="string"?E.createElement("select",{is:u.is}):E.createElement("select"),u.multiple?g.multiple=!0:u.size&&(g.size=u.size);break;default:g=typeof u.is=="string"?E.createElement(h,{is:u.is}):E.createElement(h)}}g[jt]=a,g[mn]=u;e:for(E=a.child;E!==null;){if(E.tag===5||E.tag===6)g.appendChild(E.stateNode);else if(E.tag!==4&&E.tag!==27&&E.child!==null){E.child.return=E,E=E.child;continue}if(E===a)break e;for(;E.sibling===null;){if(E.return===null||E.return===a)break e;E=E.return}E.sibling.return=E.return,E=E.sibling}a.stateNode=g;e:switch(Sn(g,h,u),h){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&xa(a)}}return $t(a),Tp(a,a.type,t===null?null:t.memoizedProps,a.pendingProps,o),null;case 6:if(t&&a.stateNode!=null)t.memoizedProps!==u&&xa(a);else{if(typeof u!="string"&&a.stateNode===null)throw Error(r(166));if(t=ae.current,Bs(a)){if(t=a.stateNode,o=a.memoizedProps,u=null,h=yn,h!==null)switch(h.tag){case 27:case 5:u=h.memoizedProps}t[jt]=a,t=!!(t.nodeValue===o||u!==null&&u.suppressHydrationWarning===!0||JS(t.nodeValue,o)),t||ti(a,!0)}else t=ad(t).createTextNode(u),t[jt]=a,a.stateNode=t}return $t(a),null;case 31:if(o=a.memoizedState,t===null||t.memoizedState!==null){if(u=Bs(a),o!==null){if(t===null){if(!u)throw Error(r(318));if(t=a.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(r(557));t[jt]=a}else Fi(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;$t(a),t=!1}else o=jh(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=o),t=!0;if(!t)return a.flags&256?(ar(a),a):(ar(a),null);if((a.flags&128)!==0)throw Error(r(558))}return $t(a),null;case 13:if(u=a.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(h=Bs(a),u!==null&&u.dehydrated!==null){if(t===null){if(!h)throw Error(r(318));if(h=a.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));h[jt]=a}else Fi(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;$t(a),h=!1}else h=jh(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=h),h=!0;if(!h)return a.flags&256?(ar(a),a):(ar(a),null)}return ar(a),(a.flags&128)!==0?(a.lanes=o,a):(o=u!==null,t=t!==null&&t.memoizedState!==null,o&&(u=a.child,h=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(h=u.alternate.memoizedState.cachePool.pool),g=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(g=u.memoizedState.cachePool.pool),g!==h&&(u.flags|=2048)),o!==t&&o&&(a.child.flags|=8192),qu(a,a.updateQueue),$t(a),null);case 4:return Me(),t===null&&Yp(a.stateNode.containerInfo),$t(a),null;case 10:return Ca(a.type),$t(a),null;case 19:if(T(Kt),u=a.memoizedState,u===null)return $t(a),null;if(h=(a.flags&128)!==0,g=u.rendering,g===null)if(h)zl(u,!1);else{if(Gt!==0||t!==null&&(t.flags&128)!==0)for(t=a.child;t!==null;){if(g=Du(t),g!==null){for(a.flags|=128,zl(u,!1),t=g.updateQueue,a.updateQueue=t,qu(a,t),a.subtreeFlags=0,t=o,o=a.child;o!==null;)Rb(o,t),o=o.sibling;return pe(Kt,Kt.current&1|2),ut&&Sa(a,u.treeForkCount),a.child}t=t.sibling}u.tail!==null&&Pt()>Wu&&(a.flags|=128,h=!0,zl(u,!1),a.lanes=4194304)}else{if(!h)if(t=Du(g),t!==null){if(a.flags|=128,h=!0,t=t.updateQueue,a.updateQueue=t,qu(a,t),zl(u,!0),u.tail===null&&u.tailMode==="hidden"&&!g.alternate&&!ut)return $t(a),null}else 2*Pt()-u.renderingStartTime>Wu&&o!==536870912&&(a.flags|=128,h=!0,zl(u,!1),a.lanes=4194304);u.isBackwards?(g.sibling=a.child,a.child=g):(t=u.last,t!==null?t.sibling=g:a.child=g,u.last=g)}return u.tail!==null?(t=u.tail,u.rendering=t,u.tail=t.sibling,u.renderingStartTime=Pt(),t.sibling=null,o=Kt.current,pe(Kt,h?o&1|2:o&1),ut&&Sa(a,u.treeForkCount),t):($t(a),null);case 22:case 23:return ar(a),Xh(),u=a.memoizedState!==null,t!==null?t.memoizedState!==null!==u&&(a.flags|=8192):u&&(a.flags|=8192),u?(o&536870912)!==0&&(a.flags&128)===0&&($t(a),a.subtreeFlags&6&&(a.flags|=8192)):$t(a),o=a.updateQueue,o!==null&&qu(a,o.retryQueue),o=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(o=t.memoizedState.cachePool.pool),u=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(u=a.memoizedState.cachePool.pool),u!==o&&(a.flags|=2048),t!==null&&T(Wi),null;case 24:return o=null,t!==null&&(o=t.memoizedState.cache),a.memoizedState.cache!==o&&(a.flags|=2048),Ca(Qt),$t(a),null;case 25:return null;case 30:return null}throw Error(r(156,a.tag))}function mT(t,a){switch(Nh(a),a.tag){case 1:return t=a.flags,t&65536?(a.flags=t&-65537|128,a):null;case 3:return Ca(Qt),Me(),t=a.flags,(t&65536)!==0&&(t&128)===0?(a.flags=t&-65537|128,a):null;case 26:case 27:case 5:return kt(a),null;case 31:if(a.memoizedState!==null){if(ar(a),a.alternate===null)throw Error(r(340));Fi()}return t=a.flags,t&65536?(a.flags=t&-65537|128,a):null;case 13:if(ar(a),t=a.memoizedState,t!==null&&t.dehydrated!==null){if(a.alternate===null)throw Error(r(340));Fi()}return t=a.flags,t&65536?(a.flags=t&-65537|128,a):null;case 19:return T(Kt),null;case 4:return Me(),null;case 10:return Ca(a.type),null;case 22:case 23:return ar(a),Xh(),t!==null&&T(Wi),t=a.flags,t&65536?(a.flags=t&-65537|128,a):null;case 24:return Ca(Qt),null;case 25:return null;default:return null}}function nS(t,a){switch(Nh(a),a.tag){case 3:Ca(Qt),Me();break;case 26:case 27:case 5:kt(a);break;case 4:Me();break;case 31:a.memoizedState!==null&&ar(a);break;case 13:ar(a);break;case 19:T(Kt);break;case 10:Ca(a.type);break;case 22:case 23:ar(a),Xh(),t!==null&&T(Wi);break;case 24:Ca(Qt)}}function Hl(t,a){try{var o=a.updateQueue,u=o!==null?o.lastEffect:null;if(u!==null){var h=u.next;o=h;do{if((o.tag&t)===t){u=void 0;var g=o.create,E=o.inst;u=g(),E.destroy=u}o=o.next}while(o!==h)}}catch(k){Ct(a,a.return,k)}}function li(t,a,o){try{var u=a.updateQueue,h=u!==null?u.lastEffect:null;if(h!==null){var g=h.next;u=g;do{if((u.tag&t)===t){var E=u.inst,k=E.destroy;if(k!==void 0){E.destroy=void 0,h=a;var H=o,Y=k;try{Y()}catch(ne){Ct(h,H,ne)}}}u=u.next}while(u!==g)}}catch(ne){Ct(a,a.return,ne)}}function rS(t){var a=t.updateQueue;if(a!==null){var o=t.stateNode;try{Kb(a,o)}catch(u){Ct(t,t.return,u)}}}function aS(t,a,o){o.props=Zi(t.type,t.memoizedProps),o.state=t.memoizedState;try{o.componentWillUnmount()}catch(u){Ct(t,a,u)}}function Ul(t,a){try{var o=t.ref;if(o!==null){switch(t.tag){case 26:case 27:case 5:var u=t.stateNode;break;case 30:u=t.stateNode;break;default:u=t.stateNode}typeof o=="function"?t.refCleanup=o(u):o.current=u}}catch(h){Ct(t,a,h)}}function ta(t,a){var o=t.ref,u=t.refCleanup;if(o!==null)if(typeof u=="function")try{u()}catch(h){Ct(t,a,h)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(h){Ct(t,a,h)}else o.current=null}function iS(t){var a=t.type,o=t.memoizedProps,u=t.stateNode;try{e:switch(a){case"button":case"input":case"select":case"textarea":o.autoFocus&&u.focus();break e;case"img":o.src?u.src=o.src:o.srcSet&&(u.srcset=o.srcSet)}}catch(h){Ct(t,t.return,h)}}function kp(t,a,o){try{var u=t.stateNode;zT(u,t.type,o,a),u[mn]=a}catch(h){Ct(t,t.return,h)}}function sS(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&gi(t.type)||t.tag===4}function Rp(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||sS(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&gi(t.type)||t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Dp(t,a,o){var u=t.tag;if(u===5||u===6)t=t.stateNode,a?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(t,a):(a=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,a.appendChild(t),o=o._reactRootContainer,o!=null||a.onclick!==null||(a.onclick=hr));else if(u!==4&&(u===27&&gi(t.type)&&(o=t.stateNode,a=null),t=t.child,t!==null))for(Dp(t,a,o),t=t.sibling;t!==null;)Dp(t,a,o),t=t.sibling}function Gu(t,a,o){var u=t.tag;if(u===5||u===6)t=t.stateNode,a?o.insertBefore(t,a):o.appendChild(t);else if(u!==4&&(u===27&&gi(t.type)&&(o=t.stateNode),t=t.child,t!==null))for(Gu(t,a,o),t=t.sibling;t!==null;)Gu(t,a,o),t=t.sibling}function oS(t){var a=t.stateNode,o=t.memoizedProps;try{for(var u=t.type,h=a.attributes;h.length;)a.removeAttributeNode(h[0]);Sn(a,u,o),a[jt]=t,a[mn]=o}catch(g){Ct(t,t.return,g)}}var Ta=!1,tn=!1,Op=!1,lS=typeof WeakSet=="function"?WeakSet:Set,fn=null;function yT(t,a){if(t=t.containerInfo,Qp=dd,t=Sb(t),_h(t)){if("selectionStart"in t)var o={start:t.selectionStart,end:t.selectionEnd};else e:{o=(o=t.ownerDocument)&&o.defaultView||window;var u=o.getSelection&&o.getSelection();if(u&&u.rangeCount!==0){o=u.anchorNode;var h=u.anchorOffset,g=u.focusNode;u=u.focusOffset;try{o.nodeType,g.nodeType}catch{o=null;break e}var E=0,k=-1,H=-1,Y=0,ne=0,le=t,Q=null;t:for(;;){for(var te;le!==o||h!==0&&le.nodeType!==3||(k=E+h),le!==g||u!==0&&le.nodeType!==3||(H=E+u),le.nodeType===3&&(E+=le.nodeValue.length),(te=le.firstChild)!==null;)Q=le,le=te;for(;;){if(le===t)break t;if(Q===o&&++Y===h&&(k=E),Q===g&&++ne===u&&(H=E),(te=le.nextSibling)!==null)break;le=Q,Q=le.parentNode}le=te}o=k===-1||H===-1?null:{start:k,end:H}}else o=null}o=o||{start:0,end:0}}else o=null;for(Zp={focusedElem:t,selectionRange:o},dd=!1,fn=a;fn!==null;)if(a=fn,t=a.child,(a.subtreeFlags&1028)!==0&&t!==null)t.return=a,fn=t;else for(;fn!==null;){switch(a=fn,g=a.alternate,t=a.flags,a.tag){case 0:if((t&4)!==0&&(t=a.updateQueue,t=t!==null?t.events:null,t!==null))for(o=0;o title"))),Sn(g,u,o),g[jt]=t,Jt(g),u=g;break e;case"link":var E=pw("link","href",h).get(u+(o.href||""));if(E){for(var k=0;kxt&&(E=xt,xt=Ue,Ue=E);var V=bb(k,Ue),B=bb(k,xt);if(V&&B&&(te.rangeCount!==1||te.anchorNode!==V.node||te.anchorOffset!==V.offset||te.focusNode!==B.node||te.focusOffset!==B.offset)){var W=le.createRange();W.setStart(V.node,V.offset),te.removeAllRanges(),Ue>xt?(te.addRange(W),te.extend(B.node,B.offset)):(W.setEnd(B.node,B.offset),te.addRange(W))}}}}for(le=[],te=k;te=te.parentNode;)te.nodeType===1&&le.push({element:te,left:te.scrollLeft,top:te.scrollTop});for(typeof k.focus=="function"&&k.focus(),k=0;ko?32:o,X.T=null,o=zp,zp=null;var g=fi,E=La;if(on=0,no=fi=null,La=0,(mt&6)!==0)throw Error(r(331));var k=mt;if(mt|=4,vS(g.current),mS(g,g.current,E,o),mt=k,Vl(0,!1),Vt&&typeof Vt.onPostCommitFiberRoot=="function")try{Vt.onPostCommitFiberRoot(zn,g)}catch{}return!0}finally{de.p=h,X.T=u,jS(t,a)}}function HS(t,a,o){a=gr(o,a),a=yp(t.stateNode,a,2),t=ii(t,a,2),t!==null&&(tt(t,2),na(t))}function Ct(t,a,o){if(t.tag===3)HS(t,t,o);else for(;a!==null;){if(a.tag===3){HS(a,t,o);break}else if(a.tag===1){var u=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(di===null||!di.has(u))){t=gr(o,t),o=Uv(2),u=ii(a,o,2),u!==null&&(Pv(o,u,a,t),tt(u,2),na(u));break}}a=a.return}}function Bp(t,a,o){var u=t.pingCache;if(u===null){u=t.pingCache=new ST;var h=new Set;u.set(a,h)}else h=u.get(a),h===void 0&&(h=new Set,u.set(a,h));h.has(o)||(Mp=!0,h.add(o),t=AT.bind(null,t,a,o),a.then(t,t))}function AT(t,a,o){var u=t.pingCache;u!==null&&u.delete(a),t.pingedLanes|=t.suspendedLanes&o,t.warmLanes&=~o,Rt===t&&(st&o)===o&&(Gt===4||Gt===3&&(st&62914560)===st&&300>Pt()-Ku?(mt&2)===0&&ro(t,0):Np|=o,to===st&&(to=0)),na(t)}function US(t,a){a===0&&(a=De()),t=qi(t,a),t!==null&&(tt(t,a),na(t))}function xT(t){var a=t.memoizedState,o=0;a!==null&&(o=a.retryLane),US(t,o)}function TT(t,a){var o=0;switch(t.tag){case 31:case 13:var u=t.stateNode,h=t.memoizedState;h!==null&&(o=h.retryLane);break;case 19:u=t.stateNode;break;case 22:u=t.stateNode._retryCache;break;default:throw Error(r(314))}u!==null&&u.delete(a),US(t,o)}function kT(t,a){return dn(t,a)}var ed=null,io=null,qp=!1,td=!1,Gp=!1,pi=0;function na(t){t!==io&&t.next===null&&(io===null?ed=io=t:io=io.next=t),td=!0,qp||(qp=!0,DT())}function Vl(t,a){if(!Gp&&td){Gp=!0;do for(var o=!1,u=ed;u!==null;){if(t!==0){var h=u.pendingLanes;if(h===0)var g=0;else{var E=u.suspendedLanes,k=u.pingedLanes;g=(1<<31-an(42|t)+1)-1,g&=h&~(E&~k),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(o=!0,GS(u,g))}else g=st,g=_e(u,u===Rt?g:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(g&3)===0||qe(u,g)||(o=!0,GS(u,g));u=u.next}while(o);Gp=!1}}function RT(){PS()}function PS(){td=qp=!1;var t=0;pi!==0&&UT()&&(t=pi);for(var a=Pt(),o=null,u=ed;u!==null;){var h=u.next,g=BS(u,a);g===0?(u.next=null,o===null?ed=h:o.next=h,h===null&&(io=o)):(o=u,(t!==0||(g&3)!==0)&&(td=!0)),u=h}on!==0&&on!==5||Vl(t),pi!==0&&(pi=0)}function BS(t,a){for(var o=t.suspendedLanes,u=t.pingedLanes,h=t.expirationTimes,g=t.pendingLanes&-62914561;0k)break;var ne=H.transferSize,le=H.initiatorType;ne&&QS(le)&&(H=H.responseEnd,E+=ne*(H"u"?null:document;function uw(t,a,o){var u=so;if(u&&typeof a=="string"&&a){var h=Bn(a);h='link[rel="'+t+'"][href="'+h+'"]',typeof o=="string"&&(h+='[crossorigin="'+o+'"]'),cw.has(h)||(cw.add(h),t={rel:t,crossOrigin:o,href:a},u.querySelector(h)===null&&(a=u.createElement("link"),Sn(a,"link",t),Jt(a),u.head.appendChild(a)))}}function YT(t){$a.D(t),uw("dns-prefetch",t,null)}function XT(t,a){$a.C(t,a),uw("preconnect",t,a)}function JT(t,a,o){$a.L(t,a,o);var u=so;if(u&&t&&a){var h='link[rel="preload"][as="'+Bn(a)+'"]';a==="image"&&o&&o.imageSrcSet?(h+='[imagesrcset="'+Bn(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(h+='[imagesizes="'+Bn(o.imageSizes)+'"]')):h+='[href="'+Bn(t)+'"]';var g=h;switch(a){case"style":g=oo(t);break;case"script":g=lo(t)}wr.has(g)||(t=y({rel:"preload",href:a==="image"&&o&&o.imageSrcSet?void 0:t,as:a},o),wr.set(g,t),u.querySelector(h)!==null||a==="style"&&u.querySelector(Xl(g))||a==="script"&&u.querySelector(Jl(g))||(a=u.createElement("link"),Sn(a,"link",t),Jt(a),u.head.appendChild(a)))}}function QT(t,a){$a.m(t,a);var o=so;if(o&&t){var u=a&&typeof a.as=="string"?a.as:"script",h='link[rel="modulepreload"][as="'+Bn(u)+'"][href="'+Bn(t)+'"]',g=h;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=lo(t)}if(!wr.has(g)&&(t=y({rel:"modulepreload",href:t},a),wr.set(g,t),o.querySelector(h)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(Jl(g)))return}u=o.createElement("link"),Sn(u,"link",t),Jt(u),o.head.appendChild(u)}}}function ZT(t,a,o){$a.S(t,a,o);var u=so;if(u&&t){var h=Yr(u).hoistableStyles,g=oo(t);a=a||"default";var E=h.get(g);if(!E){var k={loading:0,preload:null};if(E=u.querySelector(Xl(g)))k.loading=5;else{t=y({rel:"stylesheet",href:t,"data-precedence":a},o),(o=wr.get(g))&&sg(t,o);var H=E=u.createElement("link");Jt(H),Sn(H,"link",t),H._p=new Promise(function(Y,ne){H.onload=Y,H.onerror=ne}),H.addEventListener("load",function(){k.loading|=1}),H.addEventListener("error",function(){k.loading|=2}),k.loading|=4,sd(E,a,u)}E={type:"stylesheet",instance:E,count:1,state:k},h.set(g,E)}}}function ek(t,a){$a.X(t,a);var o=so;if(o&&t){var u=Yr(o).hoistableScripts,h=lo(t),g=u.get(h);g||(g=o.querySelector(Jl(h)),g||(t=y({src:t,async:!0},a),(a=wr.get(h))&&og(t,a),g=o.createElement("script"),Jt(g),Sn(g,"link",t),o.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},u.set(h,g))}}function tk(t,a){$a.M(t,a);var o=so;if(o&&t){var u=Yr(o).hoistableScripts,h=lo(t),g=u.get(h);g||(g=o.querySelector(Jl(h)),g||(t=y({src:t,async:!0,type:"module"},a),(a=wr.get(h))&&og(t,a),g=o.createElement("script"),Jt(g),Sn(g,"link",t),o.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},u.set(h,g))}}function dw(t,a,o,u){var h=(h=ae.current)?id(h):null;if(!h)throw Error(r(446));switch(t){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(a=oo(o.href),o=Yr(h).hoistableStyles,u=o.get(a),u||(u={type:"style",instance:null,count:0,state:null},o.set(a,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){t=oo(o.href);var g=Yr(h).hoistableStyles,E=g.get(t);if(E||(h=h.ownerDocument||h,E={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(t,E),(g=h.querySelector(Xl(t)))&&!g._p&&(E.instance=g,E.state.loading=5),wr.has(t)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},wr.set(t,o),g||nk(h,t,o,E.state))),a&&u===null)throw Error(r(528,""));return E}if(a&&u!==null)throw Error(r(529,""));return null;case"script":return a=o.async,o=o.src,typeof o=="string"&&a&&typeof a!="function"&&typeof a!="symbol"?(a=lo(o),o=Yr(h).hoistableScripts,u=o.get(a),u||(u={type:"script",instance:null,count:0,state:null},o.set(a,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,t))}}function oo(t){return'href="'+Bn(t)+'"'}function Xl(t){return'link[rel="stylesheet"]['+t+"]"}function fw(t){return y({},t,{"data-precedence":t.precedence,precedence:null})}function nk(t,a,o,u){t.querySelector('link[rel="preload"][as="style"]['+a+"]")?u.loading=1:(a=t.createElement("link"),u.preload=a,a.addEventListener("load",function(){return u.loading|=1}),a.addEventListener("error",function(){return u.loading|=2}),Sn(a,"link",o),Jt(a),t.head.appendChild(a))}function lo(t){return'[src="'+Bn(t)+'"]'}function Jl(t){return"script[async]"+t}function hw(t,a,o){if(a.count++,a.instance===null)switch(a.type){case"style":var u=t.querySelector('style[data-href~="'+Bn(o.href)+'"]');if(u)return a.instance=u,Jt(u),u;var h=y({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return u=(t.ownerDocument||t).createElement("style"),Jt(u),Sn(u,"style",h),sd(u,o.precedence,t),a.instance=u;case"stylesheet":h=oo(o.href);var g=t.querySelector(Xl(h));if(g)return a.state.loading|=4,a.instance=g,Jt(g),g;u=fw(o),(h=wr.get(h))&&sg(u,h),g=(t.ownerDocument||t).createElement("link"),Jt(g);var E=g;return E._p=new Promise(function(k,H){E.onload=k,E.onerror=H}),Sn(g,"link",u),a.state.loading|=4,sd(g,o.precedence,t),a.instance=g;case"script":return g=lo(o.src),(h=t.querySelector(Jl(g)))?(a.instance=h,Jt(h),h):(u=o,(h=wr.get(g))&&(u=y({},o),og(u,h)),t=t.ownerDocument||t,h=t.createElement("script"),Jt(h),Sn(h,"link",u),t.head.appendChild(h),a.instance=h);case"void":return null;default:throw Error(r(443,a.type))}else a.type==="stylesheet"&&(a.state.loading&4)===0&&(u=a.instance,a.state.loading|=4,sd(u,o.precedence,t));return a.instance}function sd(t,a,o){for(var u=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),h=u.length?u[u.length-1]:null,g=h,E=0;E title"):null)}function rk(t,a,o){if(o===1||a.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof a.precedence!="string"||typeof a.href!="string"||a.href==="")break;return!0;case"link":if(typeof a.rel!="string"||typeof a.href!="string"||a.href===""||a.onLoad||a.onError)break;switch(a.rel){case"stylesheet":return t=a.disabled,typeof a.precedence=="string"&&t==null;default:return!0}case"script":if(a.async&&typeof a.async!="function"&&typeof a.async!="symbol"&&!a.onLoad&&!a.onError&&a.src&&typeof a.src=="string")return!0}return!1}function mw(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function ak(t,a,o,u){if(o.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var h=oo(u.href),g=a.querySelector(Xl(h));if(g){a=g._p,a!==null&&typeof a=="object"&&typeof a.then=="function"&&(t.count++,t=ld.bind(t),a.then(t,t)),o.state.loading|=4,o.instance=g,Jt(g);return}g=a.ownerDocument||a,u=fw(u),(h=wr.get(h))&&sg(u,h),g=g.createElement("link"),Jt(g);var E=g;E._p=new Promise(function(k,H){E.onload=k,E.onerror=H}),Sn(g,"link",u),o.instance=g}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(o,a),(a=o.state.preload)&&(o.state.loading&3)===0&&(t.count++,o=ld.bind(t),a.addEventListener("load",o),a.addEventListener("error",o))}}var lg=0;function ik(t,a){return t.stylesheets&&t.count===0&&ud(t,t.stylesheets),0lg?50:800)+a);return t.unsuspend=o,function(){t.unsuspend=null,clearTimeout(u),clearTimeout(h)}}:null}function ld(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ud(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var cd=null;function ud(t,a){t.stylesheets=null,t.unsuspend!==null&&(t.count++,cd=new Map,a.forEach(sk,t),cd=null,ld.call(t))}function sk(t,a){if(!(a.state.loading&4)){var o=cd.get(t);if(o)var u=o.get(null);else{o=new Map,cd.set(t,o);for(var h=t.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(s)}catch(e){console.error(e)}}return s(),Sd.exports=Iw(),Sd.exports}var _d=jw();const Ad=aa(_d),fo=[],zw=50;let xd=!1;function _g(){try{return window.G7Core?.devTools}catch{return}}function ns(s,e,n){const r=_g();if(xd&&r?.isEnabled?.()){r.trackLog?.(s,e,n);return}xd||(s==="error"||s==="warn")&&fo.length{n.isDebugEnabled()&&console.log(e,...r),ns("log",s,r)},warn:(...r)=>{n.isDebugEnabled()&&console.warn(e,...r),ns("warn",s,r)},error:(...r)=>{n.isDebugEnabled()&&console.error(e,...r),ns("error",s,r)}}}ho.getInstance();const Ag="extension",rs="extensionless",xg="file";function Hw(){const s=globalThis?.G7Config;if(globalThis?.__g7AssetUrlMode===rs)return rs;const n=s?.assetUrlMode;return n===rs||n===Ag?n:s?.settings?.general?.asset_url_mode===rs?rs:Ag}function kd(){return Hw()===rs}function Uw(s,e,n){return Rd("templates",s,e,n)}function Pw(s,e){const n=e.replace(/^\/+/,"").replace(/\/+$/,""),r=encodeURIComponent(s),i=po(`templates/${s}/assets/${n}`);return i!==null?i:`/api/templates/assets/${r}/${n}`}function Bw(s,e,n){return Rd("modules",s,e,n)}function qw(s,e,n){return Rd("plugins",s,e,n)}function Rd(s,e,n,r){const i=n.replace(/^\/+/,""),l=encodeURIComponent(e);if(!kd())return`/api/${s}/assets/${l}/${i}${Vw(r)}`;let c=`${xg}=${encodeURIComponent(i)}`;return r!=null&&r!==""&&(c+=`&v=${r}`),`/api/${s}/assets/${l}?${c}`}function Pr(s,e,n,r){const i=s.replace(/\/+$/,""),l=e.replace(/^\.+/,""),c=kd()?i:`${i}.${l}`,d=[];return r&&d.push(r.replace(/^[?&]+/,"")),n!=null&&n!==""&&d.push(`v=${n}`),d.length>0?`${c}?${d.join("&")}`:c}function Tg(){const s=globalThis?.G7Config?.staticBase;return typeof s=="string"&&s!==""?s.replace(/\/+$/,""):null}function Gw(){const s=Tg();if(!s)return null;const e=s.match(/\/(\d+)$/);return e?Number(e[1]):null}function po(s,e){const n=Tg();if(!n)return null;const r=s.replace(/^\/+/,"");return e!==void 0&&e>0&&e!==Gw()?`${n.replace(/\/\d+$/,"")}/${e}/${r}`:`${n}/${r}`}function Dd(s){if(!s)return null;const e=globalThis?.location?.origin,r=(e&&s.startsWith(e)?s.slice(e.length):s).match(/^\/build\/ext\/(\d+)\/(.+)$/);if(!r)return null;const i=r[1],l=r[2].split("?")[0],c=l.match(/^(templates|modules|plugins)\/([^/]+)\/assets\/(.+)$/);if(c){const[,p,m,y]=c;return`/api/${p}/assets/${m}/${y}?v=${i}`}const d=l.match(/^bundles\/(modules|plugins)\.(js|css)$/);if(d)return`/api/${d[1]}/bundle.${d[2]}?v=${i}`;const f=l.match(/^templates\/([^/]+)\/(routes\.json|components\.json|lang\/([a-zA-Z-]+)\.json)$/);if(f){const[,p,m]=f,y=m.replace(/\.json$/,"");return`/api/templates/${p}/${y}.json?v=${i}`}return null}function xn(s){if(!s||!kd())return s;const e=globalThis?.location?.origin,n=e&&s.startsWith(e)?s.slice(e.length):s;if(!n.startsWith("/api/"))return s;const[r,i]=Fw(n),l=r.match(/^\/api\/(modules|plugins)\/bundle\.(js|css)$/);if(l)return kg(`/api/${l[1]}/bundle/${l[2]}`,i);const c=r.match(/^\/api\/(templates|modules|plugins)\/assets\/([^/]+)\/(.+)$/);if(c){const[,f,p,m]=c,y=`${xg}=${encodeURIComponent(decodeURIComponent(m))}`;return`/api/${f}/assets/${p}?${y}${i?`&${i}`:""}`}const d=r.match(/^(\/api\/.+)\.(json|js|css)$/);return d?kg(d[1],i):s}function Fw(s){const e=s.indexOf("?");return e===-1?[s,""]:[s.slice(0,e),s.slice(e+1)]}function kg(s,e){return e?`${s}?${e}`:s}function Vw(s){return s==null||s===""?"":`?v=${s}`}const ia=dt("networkResilience"),Od=2,Ld=300,$d=2e3,Kw=15e3;function Md(s){return s?.name==="AbortError"}function Rg(s){if(Md(s))return!1;if(s instanceof TypeError)return!0;const e=s?.code;return e==="ERR_NETWORK"||e==="ECONNABORTED"}let nc=!1,Dg=!1;function rc(){return nc}function Ww(){typeof window>"u"||Dg||(Dg=!0,window.addEventListener("pagehide",()=>{nc=!0}),window.addEventListener("pageshow",s=>{s.persisted&&(nc=!1)}),window.addEventListener("beforeunload",()=>{nc=!0}))}function Nd(s,e,n){const r=Math.min(e*Math.pow(2,s),n),i=r*.25*(Math.random()*2-1);return Math.max(0,Math.round(r+i))}function Id(s){return new Promise(e=>setTimeout(e,s))}async function ac(s,e={}){const{retries:n=Od,baseDelayMs:r=Ld,maxDelayMs:i=$d,timeoutMs:l=Kw,label:c=s,init:d}=e,f=n+1;let p;for(let m=0;m0?new AbortController:null;try{const v={...d};if(S){const w=d?.signal;w&&(w.aborted?S.abort():w.addEventListener("abort",()=>S.abort(),{once:!0})),v.signal=S.signal,C=setTimeout(()=>{y=!0,S.abort()},l)}return await fetch(s,v)}catch(v){if(p=v,Md(v)&&!y||!(y||Rg(v)))throw v;if(rc())throw ia.warn(`Document unloading, aborting retries: ${c}`),v;if(m===f-1)throw ia.warn(`All ${f} attempts failed: ${c}`,v),v;const R=Nd(m,r,i);ia.warn(`Network failure (attempt ${m+1}/${f}), retrying in ${R}ms: ${c}`),await Id(R)}finally{C!==void 0&&clearTimeout(C)}}throw p}async function Cr(s,e={},n={}){const{retries:r=Od,baseDelayMs:i=Ld,maxDelayMs:l=$d,label:c=s}=n,d=r+1;for(let f=0;f{const i=document.createElement("script");i.src=s,i.async=!1;for(const[l,c]of Object.entries(e))l==="id"?i.id=c:i.setAttribute(l,c);i.onload=()=>n(),i.onerror=()=>r(new Error(`Failed to load script: ${s}`)),document.head.appendChild(i)})}async function sa(s,e={},n={}){const{retries:r=Od,baseDelayMs:i=Ld,maxDelayMs:l=$d,label:c=s}=n,d=r+1;for(let f=0;f{s.onload=()=>e(),s.onerror=()=>n(new Error(`Failed to load stylesheet: ${s.href}`))})}async function ic(s,e,n={}){if(!s)return ac(e,n);try{const r=await fetch(s,n.init);if(r.ok){const i=await r.text();try{return JSON.parse(i),new Response(i,{status:r.status,statusText:r.statusText,headers:r.headers})}catch{return console.warn(`[fetchStaticFirst] Static fast path returned malformed JSON — falling back to API: ${s}`),ac(e,n)}}console.warn(`[fetchStaticFirst] Static fast path miss (${r.status}) — falling back to API: ${s}`)}catch(r){console.warn(`[fetchStaticFirst] Static fast path fetch failed — falling back to API: ${s}`,r)}return ac(e,n)}const Br=dt("ComponentRegistry");class ln extends Error{constructor(e,n,r){super(e),this.code=n,this.details=r,this.name="ComponentRegistryError"}}const Zn=class Zn{constructor(){$(this,"registry",{});$(this,"manifest",null);$(this,"cacheVersion",0);$(this,"loadingState","idle");$(this,"error",null);$(this,"templateId",null);$(this,"templateType",null)}static getInstance(){return Zn.instance||(Zn.instance=new Zn),Zn.instance}static createIsolatedInstance(){return new Zn}static resetInstance(){Zn.instance=null}async loadComponents(e,n,r=0){if(this.loadingState==="loading")throw new ln("Components are already being loaded","LOADING_IN_PROGRESS");if(this.loadingState==="loaded"&&this.templateId===e&&this.templateType===n){Br.log("Components already loaded for template:",e,n);return}this.loadingState="loading",this.templateId=e,this.templateType=n,this.cacheVersion=r,this.error=null;try{await this.loadManifest(),await this.loadComponentBundle(),this.loadingState="loaded",Br.log("Successfully loaded components:",Object.keys(this.registry).length)}catch(i){throw this.loadingState="error",this.error=i instanceof Error?i:new Error(String(i)),new ln(`Failed to load components: ${this.error.message}`,"LOAD_FAILED",{originalError:this.error})}}async loadManifest(){try{if(!this.templateId)throw new ln("Template ID not set","TEMPLATE_ID_NOT_SET");const e=`${this.templateId}:${this.templateType}:v${this.cacheVersion||0}`;if(Zn.manifestCache.has(e)){this.manifest=Zn.manifestCache.get(e),Br.log("Manifest loaded from cache:",this.manifest.templateId);return}const n=Pr(`/api/templates/${this.templateId}/components`,"json",this.cacheVersion>0?this.cacheVersion:null),r=await ic(this.cacheVersion>0?po(`templates/${this.templateId}/components.json`,this.cacheVersion):null,n,{label:"components.json"});if(!r.ok)throw new ln(`Failed to fetch manifest: ${r.status} ${r.statusText}`,"MANIFEST_FETCH_FAILED",{status:r.status,statusText:r.statusText});const i=await r.json();this.validateManifest(i),this.manifest=i,Zn.manifestCache.set(e,i),Br.log("Manifest loaded and cached:",i.templateId)}catch(e){throw e instanceof ln?e:new ln("Failed to load component manifest","MANIFEST_LOAD_FAILED",{originalError:e})}}validateManifest(e){if(!e.version)throw new ln("Manifest missing required field: version","MANIFEST_INVALID",{field:"version"});if(!e.templateId)throw new ln("Manifest missing required field: templateId","MANIFEST_INVALID",{field:"templateId"});if(!e.components||typeof e.components!="object")throw new ln("Manifest missing required field: components","MANIFEST_INVALID",{field:"components"});const n=["basic","composite","layout"];for(const r of n){if(!Array.isArray(e.components[r]))throw new ln(`Manifest field 'components.${r}' must be an array`,"MANIFEST_INVALID",{field:`components.${r}`,value:e.components[r]});e.components[r].forEach((i,l)=>{if(!i.name||typeof i.name!="string")throw new ln(`Invalid component metadata at ${r}[${l}]: missing or invalid 'name'`,"MANIFEST_INVALID",{type:r,index:l,metadata:i});if(!i.type||typeof i.type!="string")throw new ln(`Invalid component metadata at ${r}[${l}]: missing or invalid 'type'`,"MANIFEST_INVALID",{type:r,index:l,metadata:i})})}Br.log("Manifest validation passed")}async loadComponentBundle(){try{if(!this.templateId)throw new ln("Template ID not set","TEMPLATE_ID_NOT_SET");const e=this.getGlobalVariableName(),n=window[e];if(!n||typeof n!="object")throw new ln(`Component bundle not loaded. Expected global variable: ${e}. Ensure admin.blade.php includes the IIFE bundle script.`,"BUNDLE_NOT_LOADED",{expectedVariable:e});await this.registerComponentsFromManifest(n),Br.log("Component bundle loaded from global variable:",e)}catch(e){throw e instanceof ln?e:new ln("Failed to load component bundle","BUNDLE_LOAD_FAILED",{originalError:e})}}getGlobalVariableName(){if(!this.templateId)throw new ln("Template ID not set","TEMPLATE_ID_NOT_SET");return this.templateId.split(/[-_]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join("")}async registerComponentsFromManifest(e){if(!this.manifest)throw new ln("Manifest not loaded","MANIFEST_NOT_LOADED");const n=["basic","composite","layout"];for(const r of n){const i=this.manifest.components[r]||[];for(const l of i){const c=l.name,d=e[c];if(!d){Br.warn(`Component '${c}' not found in bundle`);continue}this.registerComponent(c,d,l)}}}registerComponent(e,n,r){this.registry[e]&&Br.warn(`Component '${e}' already registered, overwriting`);const i=We.memo(n);this.registry[e]={component:i,metadata:r},Br.log(`[ComponentRegistry] Registered component: ${e} (${r.type})`)}getComponent(e){const n=this.registry[e];return n?n.component:null}getMetadata(e){const n=this.registry[e];return n?n.metadata:null}hasComponent(e){return e in this.registry}getComponentsByType(e){return Object.entries(this.registry).filter(([n,r])=>r.metadata.type===e).map(([n,r])=>n)}getAllComponents(){return Object.keys(this.registry)}getComponentMap(){const e={};for(const[n,r]of Object.entries(this.registry))e[n]=r.component;return e}getLoadingState(){return this.loadingState}getError(){return this.error}getTemplateId(){return this.templateId}getManifest(){return this.manifest}clear(){this.registry={},this.manifest=null,this.loadingState="idle",this.error=null,this.templateId=null,this.templateType=null,Br.log("Registry cleared")}};$(Zn,"instance",null),$(Zn,"manifestCache",new Map);let Er=Zn;const as=dt("PipeRegistry");function Og(s,e){const n=s.getFullYear(),r=String(s.getMonth()+1).padStart(2,"0"),i=String(s.getDate()).padStart(2,"0"),l=String(s.getHours()).padStart(2,"0"),c=String(s.getMinutes()).padStart(2,"0"),d=String(s.getSeconds()).padStart(2,"0");return e.replace("YYYY",String(n)).replace("YY",String(n).slice(-2)).replace("MM",r).replace("M",String(s.getMonth()+1)).replace("DD",i).replace("D",String(s.getDate())).replace("HH",l).replace("H",String(s.getHours())).replace("mm",c).replace("m",String(s.getMinutes())).replace("ss",d).replace("s",String(s.getSeconds()))}function Qw(s,e="ko"){const r=new Date().getTime()-s.getTime(),i=Math.floor(r/1e3),l=Math.floor(i/60),c=Math.floor(l/60),d=Math.floor(c/24),f=Math.floor(d/7),p=Math.floor(d/30),m=Math.floor(d/365);return e==="ko"?i<60?"방금 전":l<60?`${l}분 전`:c<24?`${c}시간 전`:d<7?`${d}일 전`:f<4?`${f}주 전`:p<12?`${p}개월 전`:`${m}년 전`:i<60?"just now":l<60?`${l} minute${l===1?"":"s"} ago`:c<24?`${c} hour${c===1?"":"s"} ago`:d<7?`${d} day${d===1?"":"s"} ago`:f<4?`${f} week${f===1?"":"s"} ago`:p<12?`${p} month${p===1?"":"s"} ago`:`${m} year${m===1?"":"s"} ago`}function jd(s){if(s==null)return null;if(s instanceof Date)return s;if(typeof s=="number")return new Date(s);if(typeof s=="string"){const e=new Date(s);return isNaN(e.getTime())?null:e}return null}const go={date:{fn:(s,e="YYYY-MM-DD")=>{const n=jd(s);return n?Og(n,e):""},description:"날짜 포맷 (기본: YYYY-MM-DD)"},datetime:{fn:(s,e="YYYY-MM-DD HH:mm")=>{const n=jd(s);return n?Og(n,e):""},description:"날짜+시간 포맷 (기본: YYYY-MM-DD HH:mm)"},relativeTime:{fn:(s,e="ko")=>{const n=jd(s);return n?Qw(n,e):""},description:'상대 시간 표시 (예: "3분 전")'},number:{fn:(s,e)=>{const n=Number(s);if(isNaN(n))return String(s??"");const r={};return e!==void 0&&(r.minimumFractionDigits=e,r.maximumFractionDigits=e),n.toLocaleString(void 0,r)},description:"숫자 포맷 (천단위 구분, 선택적 소수점)"},truncate:{fn:(s,e=100,n="...")=>typeof s!="string"?String(s??""):s.length<=e?s:s.slice(0,e)+n,description:'문자열 자르기 (기본: 100자, 접미사: "...")'},uppercase:{fn:s=>typeof s!="string"?String(s??""):s.toUpperCase(),description:"대문자 변환"},lowercase:{fn:s=>typeof s!="string"?String(s??""):s.toLowerCase(),description:"소문자 변환"},stripHtml:{fn:s=>typeof s!="string"?String(s??""):s.replace(/<[^>]*>/g,""),description:"HTML 태그 제거"},default:{fn:(s,e="")=>s==null||s===""?e:s,description:"기본값 설정 (null, undefined, 빈문자열 시)"},fallback:{fn:(s,e)=>s??e,description:"폴백 값 설정 (null, undefined 시만)"},first:{fn:s=>{if(Array.isArray(s))return s[0]},description:"배열의 첫 번째 요소"},last:{fn:s=>{if(Array.isArray(s))return s[s.length-1]},description:"배열의 마지막 요소"},join:{fn:(s,e=", ")=>Array.isArray(s)?s.join(e):"",description:'배열을 문자열로 결합 (기본 구분자: ", ")'},length:{fn:s=>Array.isArray(s)||typeof s=="string"?s.length:0,description:"배열/문자열 길이"},filterBy:{fn:(s,e,n)=>Array.isArray(s)?Array.isArray(e)?s.filter(r=>{const i=n?r?.[n]:r;return e.includes(i)}):s:[],description:"배열 필터링 (allowList에 포함된 항목만 반환)"},keys:{fn:s=>s==null||typeof s!="object"?[]:Object.keys(s),description:"객체의 키 배열"},values:{fn:s=>s==null||typeof s!="object"?[]:Object.values(s),description:"객체의 값 배열"},json:{fn:(s,e)=>{try{return JSON.stringify(s,null,e)}catch{return""}},description:"JSON 문자열로 변환"},localized:{fn:(s,e)=>s==null?"":typeof s=="string"?s:typeof s!="object"?String(s):s[e||"ko"]||s.ko||s.en||Object.values(s)[0]||"",description:"다국어 객체에서 로케일에 맞는 값 추출"}},is=new Map,Li=class Li{static getInstance(){return Li.instance||(Li.instance=new Li),Li.instance}register(e,n,r){if(go[e]){as.warn(`[PipeRegistry] 내장 파이프를 덮어쓸 수 없습니다: ${e}`);return}is.set(e,{fn:n,description:r}),as.log(`[PipeRegistry] 커스텀 파이프 등록됨: ${e}`)}unregister(e){if(go[e])return as.warn(`[PipeRegistry] 내장 파이프는 해제할 수 없습니다: ${e}`),!1;const n=is.delete(e);return n&&as.log(`[PipeRegistry] 커스텀 파이프 해제됨: ${e}`),n}get(e){const n=go[e];return n?n.fn:is.get(e)?.fn}has(e){return!!go[e]||is.has(e)}execute(e,n,r=[]){const i=this.get(e);if(!i)return as.warn(`[PipeRegistry] 알 수 없는 파이프: ${e}`),n;try{return i(n,...r)}catch(l){return as.error(`[PipeRegistry] 파이프 실행 오류 (${e}):`,l),n}}list(){const e=[];for(const[n,r]of Object.entries(go))e.push({name:n,description:r.description,type:"built-in"});for(const[n,r]of is.entries())e.push({name:n,description:r.description,type:"custom"});return e.sort((n,r)=>n.name.localeCompare(r.name))}clearCustomPipes(){is.clear()}};$(Li,"instance",null);let sc=Li;sc.getInstance();function Zw(s){const e=s.trim(),n=e.indexOf("(");if(n===-1)return{name:e,args:[]};const r=e.slice(0,n).trim(),i=e.slice(n+1,-1);if(!i.trim())return{name:r,args:[]};const l=[];let c="",d=null,f=0;for(let p=0;p0?i[p-1]:"")==="\\"){c+=m;continue}if((m==='"'||m==="'")&&!d){d=m;continue}if(m===d){d=null;continue}if(d){c+=m;continue}if(m==="("||m==="["||m==="{"){f++,c+=m;continue}if(m===")"||m==="]"||m==="}"){f--,c+=m;continue}if(m===","&&f===0){l.push(Lg(c.trim())),c="";continue}c+=m}return c.trim()&&l.push(Lg(c.trim())),{name:r,args:l}}function Lg(s){if(s==="null")return null;if(s==="undefined")return;if(s==="true")return!0;if(s==="false")return!1;const e=Number(s);return!isNaN(e)&&s!==""?e:s}function e0(s){const e=[];let n="",r=null,i=0;for(let l=0;l0?s[l-1]:"",f=l0?s[r-1]:"",c=r",e),this.cacheVersion=e,this.cache.clear())}getCacheVersion(){return this.cacheVersion}async loadTranslations(e,n,r="/api",i=!1){const l=`${e}:${n}`;if(!i){const c=this.getFromCache(l);if(c)return this.translations.set(l,c),c}try{const c=[];i&&c.push(`_=${Date.now()}`);const d=Pr(`${r}/templates/${e}/lang/${n}`,"json",this.cacheVersion>0?this.cacheVersion:null,c.length>0?c.join("&"):void 0),f=!i&&this.cacheVersion>0?po(`templates/${e}/lang/${n}.json`,this.cacheVersion):null,p=f!==null?await ic(f,d,{label:`lang/${n}.json`}):await fetch(d);if(!p.ok)throw new Hd(`Failed to load translations: ${p.statusText}`,void 0,n);const y=await p.json();return this.saveToCache(l,y),this.translations.set(l,y),y}catch(c){throw new Hd(`Failed to fetch translations for ${n}: ${c instanceof Error?c.message:String(c)}`,void 0,n)}}resolveTranslations(e,n,r){let i=e;const l=5;let c=0;for(;c"="+this.translate(m,n,void 0,r)),i===d)break;c++}return i.replace(Nn.TRANSLATION_PATTERN,(d,f,p)=>{const{cleanedParams:m,trailing:y}=this.separateTrailingText(p);return this.translate(f,n,m,r)+y})}translate(e,n,r,i){const l=this.getTranslation(e,n),c=r&&this.cleanParamsStr(r);if(c){const d=this.parseParams(c,i);return this.replaceParams(l,d)}return l}getTranslation(e,n){const{templateId:r,locale:i}=n,l=`${r}:${i}`,c=this.translations.get(l);if(c){const d=this.getNestedValue(c,e);if(d!==null)return d}if(i!==this.options.fallbackLocale){const d=`${r}:${this.options.fallbackLocale}`,f=this.translations.get(d);if(f){const p=this.getNestedValue(f,e);if(p!==null)return p}}return e}getNestedValue(e,n){const r=n.split(".");let i=e;for(const l of r){if(i==null||typeof i!="object")return null;i=i[l]}return typeof i=="string"?i:null}setTranslationValue(e,n,r,i){const l=`${e}:${n}`,c=this.translations.get(l)??{},d=r.split(".");let f=c;for(let p=0;p(l.push(f),`__PLACEHOLDER_${l.length-1}__`)).matchAll(Nn.PARAM_PATTERN);for(const f of d){const[,p,m]=f,y=m.replace(/__PLACEHOLDER_(\d+)__/g,(C,S)=>l[parseInt(S,10)]);r[p.trim()]=this.resolveParamValue(y.trim(),n)}return r}resolveParamValue(e,n){if(e.startsWith("{{")&&e.endsWith("}}")){const r=e.slice(2,-2).trim();if(On(r)&&n)try{const l=uc.evaluatePipeExpression(r,n);return String(l??"")}catch(l){return zd.error("Pipe expression evaluation failed:",r,l),""}if(/[|&()[\]!?:+\-*/%<>=\s]/.test(r)&&n)try{const l=uc.evaluateExpression(r,n);return String(l??"")}catch(l){return zd.error("Expression evaluation failed:",r,l),""}else{const l=this.getNestedDataValue(n,r);return String(l??"")}}return e}separateTrailingText(e){if(!e)return{cleanedParams:void 0,trailing:""};if(e.trimEnd().endsWith("}}"))return{cleanedParams:e,trailing:""};if(!(e.startsWith("|")?e.slice(1):e).includes("="))return{cleanedParams:void 0,trailing:e};const r=e.match(/(\s+[^\p{L}\w=|&\s][^\p{L}\w=]*\s*)$/u);return r?{cleanedParams:e.slice(0,-r[1].length),trailing:r[1]}:{cleanedParams:e,trailing:""}}cleanParamsStr(e){return this.separateTrailingText(e).cleanedParams||""}getNestedDataValue(e,n){if(!e)return;const r=n.split(".");let i=e;for(const l of r){if(i==null)return;i=i[l]}return i}replaceParams(e,n){let r=e;for(const[i,l]of Object.entries(n)){const c=new RegExp(`\\{\\{${i}\\}\\}`,"g");r=r.replace(c,String(l));const d=new RegExp(`\\{${i}\\}`,"g");r=r.replace(d,String(l))}return r}getFromCache(e){const n=this.cache.get(e);return n?Date.now()-n.timestamp>this.options.cacheTTL?(this.cache.delete(e),null):n.data:null}saveToCache(e,n){this.cache.set(e,{data:n,timestamp:Date.now()})}clearCache(){this.cache.clear(),this.translations.clear()}pruneCache(){const e=Date.now(),n=[];for(const[r,i]of this.cache.entries())e-i.timestamp>this.options.cacheTTL&&n.push(r);for(const r of n)this.cache.delete(r)}getCacheStats(){const e=Date.now();let n=0;for(const r of this.cache.values())e-r.timestamp>this.options.cacheTTL&&n++;return{size:this.cache.size,expired:n}}};$(Nn,"instance",null),$(Nn,"TRANSLATION_PATTERN",/\$t:(?:defer:)?([a-zA-Z0-9._-]+)(\|(?:(?!\$t:).)+)?/g),$(Nn,"NESTED_TRANSLATION_PARAM_PATTERN",/=(\$t:([a-zA-Z0-9._-]+))(?=[|&\s]|$)/g),$(Nn,"PARAM_PATTERN",/([^=|&]+)=([^|&]+)/g);let wi=Nn;const $g=Object.freeze(Object.defineProperty({__proto__:null,TranslationEngine:wi,TranslationError:Hd},Symbol.toStringTag,{value:"Module"})),Ud=new Map([["true",!0],["false",!1],["null",null],["undefined",void 0]]);function Ma(s){if(typeof s!="string"||!s.startsWith("{{")||!s.endsWith("}}")||s.length<4)return null;const e=s.slice(2,-2);let n=null,r=0;for(let i=0;i0){r--;continue}return null}}return r===0?e.trim():null}function n0(s){const e=[];if(typeof s!="string")return e;for(let n=0;n0){i--;continue}if(s[c+1]==="}"){l=c;break}break}}l!==-1&&(e.push({start:n,end:l+2,expr:s.slice(n+2,l)}),n=l+1)}return e}function mo(s){return/[?:|&!+\-*/<>=()[\]{}]/.test(s)}function Mg(s){const e=typeof s=="string"?s.trim():"";return e===""?"empty":Ud.has(e)?"literal":On(e)?"pipe":mo(e)?"expression":"path"}function Pd(s,e,n,r){const i=typeof s=="string"?s.trim():"",l=Mg(i),c=r?.skipCache?{skipCache:!0}:void 0;if(l==="empty"){r?.onEmpty?.(s);return}if(l==="literal")return Ud.get(i);try{return l==="pipe"?n.evaluatePipeExpression(i,e,c,r?.trackingInfo):l==="expression"?n.evaluateExpression(i,e,r?.trackingInfo):n.resolve(i,e,c,r?.trackingInfo)}catch(d){if(r?.onError)return r.onError(d,i);throw d}}const lr="raw:";function Ng(s){return s.startsWith(lr)?s.slice(lr.length):s}const yo="﷐",Ci="﷑",Na="﷒";function bo(s){return yo+s+Ci}function oc(s){return s.length>=2&&s.charCodeAt(0)===64976&&s.charCodeAt(s.length-1)===64977}function lc(s){return s.includes(yo)}function Bd(s){return s.slice(1,-1)}function ss(s){if(typeof s=="string")return bo(s);if(Array.isArray(s))return s.map(ss);if(s&&typeof s=="object"){const e={};for(const[n,r]of Object.entries(s))e[n]=ss(r);return e}return s}function Ia(s){if(typeof s=="string")return oc(s)?Bd(s):lc(s)||s.includes(Ci)?s.split(yo).join("").split(Ci).join(""):s;if(Array.isArray(s)){let e=!1;const n=s.map(r=>{const i=Ia(r);return i!==r&&(e=!0),i});return e?n:s}if(s&&typeof s=="object"){if(s.$$typeof!==void 0)return s;let e=!1;const n={};for(const[r,i]of Object.entries(s)){const l=Ia(i);l!==i&&(e=!0),n[r]=l}return e?n:s}return s}const vo=new Set(["constructor","__proto__","prototype","__lookupGetter__","__lookupSetter__","__defineGetter__","__defineSetter__"]),r0=new Set(["Function","eval","globalThis","window","self","document","require","module","process","Reflect","Proxy","WebAssembly","import","constructor"]);function Ig(s,e){if(s!==null&&(typeof s=="object"||typeof s=="function")&&jg.has(s))throw new Error(`Object.${e} on a built-in global object is not allowed`);return s}const a0=Object.freeze({keys:Object.keys,values:Object.values,entries:Object.entries,assign:(s,...e)=>{const n=Ig(s,"assign");for(const r of e)if(r!=null)for(const i of Object.keys(r)){if(vo.has(i))throw new Error(`Access to "${i}" is forbidden`);Xd(n,i,r[i])}return n},freeze:s=>Object.freeze(Ig(s,"freeze")),fromEntries:Object.fromEntries,create:Object.create,isFrozen:Object.isFrozen}),qd={Math,JSON,Date,Array,Object:a0,Number,String,Boolean,Set,Map,WeakSet,WeakMap,parseInt,parseFloat,isNaN,isFinite},Gd={Date,Set,Map,WeakSet,WeakMap,Array,Number,String,Boolean,Object},jg=new Set([...Object.values(qd),...Object.values(Gd)].filter(s=>s!==null&&(typeof s=="object"||typeof s=="function"))),cc=new Set(["function"]),_r=Symbol("short-circuit");class Fd{constructor(e){this.value=e}}class Vd{}class Kd{}function i0(s){return/[A-Za-z_$]/.test(s)}function s0(s){return/[A-Za-z0-9_$]/.test(s)}function Ei(s){return s>="0"&&s<="9"}function o0(s,e,n){let r=e+1;for(;r0;){const p=s[n];if(p==="{")f++,n++;else if(p==="}"){if(f--,f===0)break;n++}else p==='"'||p==="'"?n=o0(s,n,p):p==="`"?n=zg(s,n).end:n++}if(f!==0)throw new Error("Unterminated ${...} in template literal");i.push(s.slice(d,n)),n++;continue}l+=c,n++}throw new Error(`Unterminated template literal at position ${e}`)}function l0(s){const e=[];let n=0;const r=s.length,i=l=>n+l=r)throw new Error(`Unterminated string literal at position ${p}`);n++,e.push({type:"str",value:y,pos:p});continue}if(i0(l)){const p=n;for(n++;n"?(e.push({type:"punct",value:"=>",pos:c}),n+=2):i(1)==="="?i(2)==="="?(e.push({type:"punct",value:"===",pos:c}),n+=3):(e.push({type:"punct",value:"==",pos:c}),n+=2):(e.push({type:"punct",value:"=",pos:c}),n+=1);continue}case"!":{i(1)==="="?i(2)==="="?(e.push({type:"punct",value:"!==",pos:c}),n+=3):(e.push({type:"punct",value:"!=",pos:c}),n+=2):(e.push({type:"punct",value:"!",pos:c}),n+=1);continue}case"<":{if(i(1)==="=")e.push({type:"punct",value:"<=",pos:c}),n+=2;else{if(i(1)==="<")throw new Error("Bitwise/shift operators are not allowed");e.push({type:"punct",value:"<",pos:c}),n+=1}continue}case">":{if(i(1)==="=")e.push({type:"punct",value:">=",pos:c}),n+=2;else{if(i(1)===">")throw new Error("Bitwise/shift operators are not allowed");e.push({type:"punct",value:">",pos:c}),n+=1}continue}case"&":{if(i(1)==="&")e.push({type:"punct",value:"&&",pos:c}),n+=2;else throw new Error("Bitwise operators are not allowed");continue}case"|":{if(i(1)==="|")e.push({type:"punct",value:"||",pos:c}),n+=2;else throw new Error("Bitwise operators are not allowed");continue}case"?":{i(1)==="."&&!Ei(i(2))?(e.push({type:"punct",value:"?.",pos:c}),n+=2):i(1)==="?"?(e.push({type:"punct",value:"??",pos:c}),n+=2):(e.push({type:"punct",value:"?",pos:c}),n+=1);continue}case"+":{if(i(1)==="+")throw new Error("Increment operator is not allowed");if(i(1)==="=")throw new Error("Assignment operators are not allowed");e.push({type:"punct",value:"+",pos:c}),n+=1;continue}case"-":{if(i(1)==="-")throw new Error("Decrement operator is not allowed");if(i(1)==="=")throw new Error("Assignment operators are not allowed");e.push({type:"punct",value:"-",pos:c}),n+=1;continue}case"*":{if(i(1)==="=")throw new Error("Assignment operators are not allowed");if(i(1)==="*")throw new Error("Exponentiation operator is not supported");e.push({type:"punct",value:"*",pos:c}),n+=1;continue}case"/":{if(i(1)==="=")throw new Error("Assignment operators are not allowed");e.push({type:"punct",value:"/",pos:c}),n+=1;continue}case"%":{if(i(1)==="=")throw new Error("Assignment operators are not allowed");e.push({type:"punct",value:"%",pos:c}),n+=1;continue}case"~":case"^":throw new Error("Bitwise operators are not allowed");case".":case":":case"(":case")":case"[":case"]":case"{":case"}":case",":e.push({type:"punct",value:l,pos:c}),n+=1;continue;case";":e.push({type:"punct",value:";",pos:c}),n+=1;continue;default:throw new Error(`Unexpected character "${l}" at position ${c}`)}}return e}const c0={"??":1,"||":1,"&&":2,"===":3,"!==":3,"==":3,"!=":3,"<":4,">":4,"<=":4,">=":4,"+":5,"-":5,"*":6,"/":6,"%":6},u0=new Set(["??","||","&&"]);class d0{constructor(e){$(this,"tokens");$(this,"pos",0);this.tokens=e}atEnd(){return this.pos>=this.tokens.length}peek(e=0){const n=this.pos+e;return n"}"`);this.pos++}parseExpression(){const e=this.tryParseArrow();return e||this.parseTernary()}tryParseArrow(){const e=this.pos,n=this.peek();if(!n)return null;if(n.type==="ident"&&this.isPunct("=>",1)&&!cc.has(String(n.value))){this.pos+=1,this.pos+=1;const{body:r,isBlock:i}=this.parseArrowBody();return{type:"Arrow",params:[{name:String(n.value),default:null}],body:r,isBlock:i}}if(n.type==="punct"&&n.value==="("){this.pos+=1;const r=this.tryParseParamList();if(r&&this.isPunct(")")&&(this.pos+=1,this.isPunct("=>"))){this.pos+=1;const{body:i,isBlock:l}=this.parseArrowBody();return{type:"Arrow",params:r,body:i,isBlock:l}}return this.pos=e,null}return this.pos=e,null}tryParseParamList(){const e=[];if(this.isPunct(")"))return e;for(;;){const n=this.peek();let r=null,i;if(n&&n.type==="punct"&&n.value==="["){const c=this.tryParseArrayPattern();if(!c)return null;i=c}else if(n&&n.type==="ident"&&!cc.has(String(n.value)))r=String(n.value),this.pos+=1;else return null;let l=null;if(this.isPunct("=")&&(this.pos+=1,l=this.parseExpression()),e.push(i?{name:r,elements:i,default:l}:{name:r,default:l}),this.isPunct(",")){this.pos+=1;continue}break}return e}tryParseArrayPattern(){const e=this.pos;this.pos+=1;const n=[];for(;;){if(this.isPunct("]"))return this.pos+=1,n;if(this.isPunct(",")){n.push(null),this.pos+=1;continue}const r=this.peek();if(!r||r.type!=="ident"||cc.has(String(r.value)))return this.pos=e,null;if(n.push(String(r.value)),this.pos+=1,this.isPunct(",")){this.pos+=1;continue}return this.isPunct("]")?(this.pos+=1,n):(this.pos=e,null)}}parseArrowBody(){return this.isPunct("{")?{body:this.parseBlock(),isBlock:!0}:{body:this.parseExpression(),isBlock:!1}}parseBlock(){this.expectPunct("{");const e=[];for(;!this.isPunct("}");){if(this.atEnd())throw new Error("Unterminated block");e.push(this.parseStatement())}return this.expectPunct("}"),{type:"Block",body:e}}parseStatement(){const e=this.peek();if(!e)throw new Error("Unexpected end of statement");if(e.type==="punct"&&e.value==="{")return this.parseBlock();if(e.type==="punct"&&e.value===";")return this.pos+=1,{type:"Empty"};if(e.type==="ident")switch(String(e.value)){case"const":case"let":return this.parseVarDecl();case"if":return this.parseIf();case"for":return this.parseForOf();case"return":return this.parseReturn();case"try":return this.parseTry();case"break":return this.pos+=1,this.consumeSemicolon(),{type:"Break"};case"continue":return this.pos+=1,this.consumeSemicolon(),{type:"Continue"}}const n=this.parseExpression();return this.consumeSemicolon(),{type:"ExprStmt",expression:n}}consumeSemicolon(){this.isPunct(";")&&(this.pos+=1)}parseVarDecl(){this.pos+=1;const e=[];for(;;){const n=this.peek();if(!n||n.type!=="ident")throw new Error("Expected variable name in declaration");const r=String(n.value);this.pos+=1,this.expectPunct("=");const i=this.parseExpression();if(e.push({name:r,init:i}),this.isPunct(",")){this.pos+=1;continue}break}return this.consumeSemicolon(),{type:"VarDecl",declarations:e}}parseIf(){this.pos+=1,this.expectPunct("(");const e=this.parseExpression();this.expectPunct(")");const n=this.parseStatement();let r=null;const i=this.peek();return i&&i.type==="ident"&&i.value==="else"&&(this.pos+=1,r=this.parseStatement()),{type:"If",test:e,consequent:n,alternate:r}}parseForOf(){this.pos+=1,this.expectPunct("(");const e=this.peek();if(!e||e.type!=="ident"||e.value!=="const"&&e.value!=="let")throw new Error('Only "for (const x of …)" / "for (let x of …)" loops are supported');this.pos+=1;const n=this.peek();if(!n||n.type!=="ident")throw new Error("Expected loop variable name");const r=String(n.value);this.pos+=1;const i=this.peek();if(!i||i.type!=="ident"||i.value!=="of")throw new Error("Only for-of loops are supported (for-in / C-style for are not allowed)");this.pos+=1;const l=this.parseExpression();this.expectPunct(")");const c=this.parseStatement();return{type:"ForOf",name:r,iterable:l,body:c}}parseReturn(){if(this.pos+=1,this.isPunct(";")||this.isPunct("}")||this.atEnd())return this.consumeSemicolon(),{type:"Return",argument:null};const e=this.parseExpression();return this.consumeSemicolon(),{type:"Return",argument:e}}parseTry(){this.pos+=1;const e=this.parseBlock();let n=null,r=null,i=null;const l=this.peek();if(l&&l.type==="ident"&&l.value==="catch"){if(this.pos+=1,this.isPunct("(")){this.pos+=1;const d=this.peek();d&&d.type==="ident"&&(n=String(d.value),this.pos+=1),this.expectPunct(")")}r=this.parseBlock()}const c=this.peek();if(c&&c.type==="ident"&&c.value==="finally"&&(this.pos+=1,i=this.parseBlock()),!r&&!i)throw new Error("Missing catch or finally after try");return{type:"Try",block:e,handlerParam:n,handler:r,finalizer:i}}parseFunctionExpression(){this.pos+=1;let e=null;const n=this.peek();n&&n.type==="ident"&&n.value!==void 0&&!this.isPunct("(")&&(e=String(n.value),this.pos+=1),this.expectPunct("(");const r=this.tryParseParamList();if(!r)throw new Error("Invalid function parameter list");this.expectPunct(")");const i=this.parseBlock();return{type:"Function",name:e,params:r,body:i}}parseTernary(){const e=this.parseBinary(0);if(this.isPunct("?")){this.pos+=1;const n=this.parseExpression();this.expectPunct(":");const r=this.parseExpression();return{type:"Conditional",test:e,consequent:n,alternate:r}}return e}parseBinary(e){let n=this.parseUnary();for(;;){const r=this.peek();if(!r||r.type!=="punct")break;const i=String(r.value),l=c0[i];if(l===void 0||lHg(l));return{type:"Template",quasis:n,expressions:i}}if(e.type==="ident"&&e.value==="new")return this.parseNew();if(e.type==="ident"&&e.value==="function")return this.parseFunctionExpression();if(e.type==="ident"){const n=String(e.value);if(cc.has(n))throw new Error(`Keyword "${n}" is not allowed`);switch(this.pos+=1,n){case"true":return{type:"Literal",value:!0};case"false":return{type:"Literal",value:!1};case"null":return{type:"Literal",value:null};case"undefined":return{type:"Literal",value:void 0};default:return{type:"Identifier",name:n}}}if(e.type==="punct"){if(e.value==="("){this.pos+=1;const n=this.parseExpression();return this.expectPunct(")"),n}if(e.value==="[")return this.parseArrayLiteral();if(e.value==="{")return this.parseObjectLiteral()}throw new Error(`Unexpected token "${e.value}"`)}parseArrayLiteral(){this.expectPunct("[");const e=[];for(;!this.isPunct("]");){if(this.isPunct(",")){this.pos+=1,e.push({type:"Literal",value:void 0});continue}if(this.isPunct("...")?(this.pos+=1,e.push({type:"Spread",argument:this.parseExpression()})):e.push(this.parseExpression()),this.isPunct(",")){this.pos+=1;continue}break}return this.expectPunct("]"),{type:"Array",elements:e}}parseObjectLiteral(){this.expectPunct("{");const e=[];for(;!this.isPunct("}");){if(this.isPunct("..."))this.pos+=1,e.push({kind:"spread",value:this.parseExpression()});else{let n,r=!1;const i=this.peek();if(!i)throw new Error("Unexpected end of expression in object literal");if(i.type==="punct"&&i.value==="[")this.pos+=1,n=this.parseExpression(),this.expectPunct("]"),r=!0;else if(i.type==="str")this.pos+=1,n={type:"Literal",value:i.value};else if(i.type==="num")this.pos+=1,n={type:"Literal",value:String(i.value)};else if(i.type==="ident")this.pos+=1,n={type:"Literal",value:String(i.value)};else throw new Error(`Unexpected token "${i.value}" in object literal`);if(this.isPunct(":")){this.pos+=1;const l=this.parseExpression();e.push({kind:"init",key:n,computed:r,value:l})}else{if(r||n.type!=="Literal"||typeof n.value!="string")throw new Error("Invalid shorthand property in object literal");if(i.type!=="ident")throw new Error("Invalid shorthand property in object literal");e.push({kind:"init",key:n,computed:!1,value:{type:"Identifier",name:n.value}})}}if(this.isPunct(",")){this.pos+=1;continue}break}return this.expectPunct("}"),{type:"Object",properties:e}}}function Hg(s){const e=l0(s),n=new d0(e),r=n.parseExpression();if(!n.atEnd()){const i=n.peek();throw i&&i.type==="punct"&&i.value===","?new Error("The comma/sequence operator is not allowed"):new Error(`Unexpected token "${i?i.value:""}" after expression`)}return r}function f0(s,e){let n=e;for(;n;){if(Object.prototype.hasOwnProperty.call(n.vars,s))return n.vars[s];n=n.parent}if(Object.prototype.hasOwnProperty.call(qd,s))return qd[s];if(r0.has(s))throw new Error(`Reference to forbidden global "${s}" is not allowed`)}function Wd(s){const e=typeof s=="symbol"?s:String(s);if(typeof e=="string"&&vo.has(e))throw new Error(`Access to "${e}" is forbidden`);return e}function Yd(s,e){return s.type==="Member"?Ug(s,e):s.type==="Call"?Pg(s,e):Ze(s,e)}function Ug(s,e){const n=Yd(s.object,e);if(n===_r||s.optional&&n==null)return _r;let r;s.computed?r=Ze(s.property,e):r=s.property.value;const i=Wd(r);if(n!=null)return n[i]}function Pg(s,e){let n,r;if(s.callee.type==="Member"){const l=s.callee,c=Yd(l.object,e);if(c===_r||l.optional&&c==null)return _r;let d;l.computed?d=Ze(l.property,e):d=l.property.value;const f=Wd(d);c==null?n=void 0:(n=c[f],r=c)}else if(n=Yd(s.callee,e),n===_r)return _r;if(s.optional&&n==null)return _r;if(typeof n!="function")throw new Error("Attempted to call a non-function value");const i=Bg(s.args,e);return n.apply(r,i)}function Bg(s,e){const n=[];for(const r of s)if(r.type==="Spread"){const i=Ze(r.argument,e);if(i!=null)for(const l of i)n.push(l)}else n.push(Ze(r,e));return n}function qg(s,e,n){for(let r=0;r":return n>r;case"<=":return n<=r;case">=":return n>=r;default:throw new Error(`Unknown binary operator "${s.operator}"`)}}case"Logical":{const n=Ze(s.left,e);switch(s.operator){case"&&":return n&&Ze(s.right,e);case"||":return n||Ze(s.right,e);case"??":return n??Ze(s.right,e);default:throw new Error(`Unknown logical operator "${s.operator}"`)}}case"Conditional":return Ze(s.test,e)?Ze(s.consequent,e):Ze(s.alternate,e);case"Array":{const n=[];for(const r of s.elements)if(r.type==="Spread"){const i=Ze(r.argument,e);if(i!=null)for(const l of i)n.push(l)}else n.push(Ze(r,e));return n}case"Object":{const n={};for(const r of s.properties)if(r.kind==="spread"){const i=Ze(r.value,e);if(i!=null&&typeof i=="object")for(const l of Object.keys(i))Xd(n,l,i[l])}else{let i;r.computed?i=Ze(r.key,e):i=r.key.value;const l=Ze(r.value,e);Xd(n,String(i),l)}return n}case"Arrow":{const n=e,r=s.params,i=s.body,l=s.isBlock;return function(...d){const f={vars:{},parent:n};return qg(r,d,f),l?Gg(i,f):Ze(i,f)}}case"Function":{const n=e,r=s.params,i=s.body,l=s.name,c=function(...f){const p={vars:{},parent:n};return l&&(p.vars[l]=c),qg(r,f,p),Gg(i,p)};return c}case"Delete":{const n=s.argument,r=Ze(n.object,e);let i;n.computed?i=Ze(n.property,e):i=n.property.value;const l=Wd(i);if(r==null||typeof r!="object"&&typeof r!="function")return!0;if(jg.has(r))throw new Error("delete on a built-in global object is not allowed");return delete r[l]}case"Block":{const n={vars:{},parent:e};for(const r of s.body)Ze(r,n);return}case"VarDecl":{for(const n of s.declarations)e.vars[n.name]=Ze(n.init,e);return}case"If":{Ze(s.test,e)?Ze(s.consequent,e):s.alternate&&Ze(s.alternate,e);return}case"ForOf":{const n=Ze(s.iterable,e);if(n!=null)for(const r of n){const i={vars:{},parent:e};i.vars[s.name]=r;try{Ze(s.body,i)}catch(l){if(l instanceof Kd)continue;if(l instanceof Vd)break;throw l}}return}case"Return":throw new Fd(s.argument?Ze(s.argument,e):void 0);case"ExprStmt":Ze(s.expression,e);return;case"Break":throw new Vd;case"Continue":throw new Kd;case"Empty":return;case"Try":{try{try{Ze(s.block,e)}catch(n){if(n instanceof Fd||n instanceof Vd||n instanceof Kd)throw n;if(s.handler){const r={vars:{},parent:e};s.handlerParam&&(r.vars[s.handlerParam]=n),Ze(s.handler,r)}else throw n}}finally{s.finalizer&&Ze(s.finalizer,e)}return}case"New":{const n=Gd[s.ctor];if(typeof n!="function")throw new Error("new on non-whitelisted constructor");const r=Bg(s.args,e);return new n(...r)}case"Template":{let n=s.quasis[0]??"";for(let r=0;r0}getFromRenderCycleCache(e){if(this.isRenderCycleCacheActive())return this.renderCycleCache.get(e)}saveToRenderCycleCache(e,n){this.isRenderCycleCacheActive()&&this.renderCycleCache.set(e,n)}resolveBindings(e,n,r,i){const l={...this.defaultOptions,...r},c=So(),d=n._computed&&!n.$computed?{...n,$computed:n._computed}:n,f=(C,S)=>{const v=S.trim();let x=!1,w=v;if(v.startsWith(lr)&&(x=!0,w=v.slice(lr.length)),On(w))try{const P=this.evaluatePipeExpression(w,d,l,{...i,method:"resolveBindings",displayExpression:`{{${v}}}`}),K=this.formatValue(P);return x?bo(K):K}catch(P){return ja.error("Pipe expression evaluation failed:",w,P),C}if(mo(w)){const P=c?.isEnabled()?performance.now():0;try{let K,he=!1;if(l.skipCache)K=this.evaluateExpression(w,d);else{const ke=`expr:${w}`,ze=this.getFromRenderCycleCache(ke);ze!==void 0?(K=ze,he=!0):(K=this.evaluateExpression(w,d),this.saveToRenderCycleCache(ke,K))}if(c?.isEnabled()){const ke=performance.now()-P;c.trackExpressionEval({expression:`{{${v}}}`,result:this.sanitizeResultForTracking(K),resultType:this.getResultType(K),componentId:i?.componentId,componentName:i?.componentName,propName:i?.propName,fromCache:he,duration:ke,method:"resolveBindings",skipCache:l.skipCache})}const Ee=this.formatValue(K);return x?bo(Ee):Ee}catch(K){return ja.error("Expression evaluation failed:",w,K),C}}if(l.skipCache){const P=c?.isEnabled()?performance.now():0,K=this.resolvePath(w,d,l);if(c?.isEnabled()){const Ee=performance.now()-P;c.trackExpressionEval({expression:`{{${v}}}`,result:this.sanitizeResultForTracking(K),resultType:this.getResultType(K),componentId:i?.componentId,componentName:i?.componentName,propName:i?.propName,fromCache:!1,duration:Ee,method:"resolveBindings",skipCache:!0})}const he=this.formatValue(K);return x?bo(he):he}const L=w.startsWith("_global")||w.startsWith("_local")||w.startsWith("_isolated")||w.startsWith("$parent"),O=c?.isEnabled()?performance.now():0;let j,F=!1;if(L){const P=this.getFromRenderCycleCache(w);P!==void 0?(j=P,F=!0):(j=this.resolvePath(w,d,l),this.saveToRenderCycleCache(w,j))}else{const P=this.getFromCache(w);P!==void 0?(j=P,F=!0):(j=this.resolvePath(w,d,l),this.saveToCache(w,j))}if(c?.isEnabled()){const P=performance.now()-O;c.trackExpressionEval({expression:`{{${v}}}`,result:this.sanitizeResultForTracking(j),resultType:this.getResultType(j),componentId:i?.componentId,componentName:i?.componentName,propName:i?.propName,fromCache:F,duration:P,method:"resolveBindings",skipCache:l.skipCache})}const G=this.formatValue(j);return x?bo(G):G},p=n0(e);if(p.length===0)return e;let m="",y=0;for(const C of p)m+=e.slice(y,C.start),m+=f(e.slice(C.start,C.end),C.expr),y=C.end;return m+e.slice(y)}evaluatePipeExpression(e,n,r,i){const l={...this.defaultOptions,...r},c=So(),d=c?.isEnabled()?performance.now():0,f=n._computed&&!n.$computed?{...n,$computed:n._computed}:n,[p,m]=e0(e);let y,C=!1;const S=mo(p),v=p.startsWith("_global")||p.startsWith("_local")||p.startsWith("_isolated")||p.startsWith("$parent");if(l.skipCache)S?y=this.evaluateExpression(p,f):y=this.resolvePath(p,f,l);else if(S){const w=this.getFromRenderCycleCache(`expr:${p}`);w!==void 0?(y=w,C=!0):(y=this.evaluateExpression(p,f),this.saveToRenderCycleCache(`expr:${p}`,y))}else if(v){const w=this.getFromRenderCycleCache(p);w!==void 0?(y=w,C=!0):(y=this.resolvePath(p,f,l),this.saveToRenderCycleCache(p,y))}else{const w=this.getFromCache(p);w!==void 0?(y=w,C=!0):(y=this.resolvePath(p,f,l),this.saveToCache(p,y))}const x=t0(y,m);if(c?.isEnabled()){const w=performance.now()-d;c.trackExpressionEval({expression:i?.displayExpression??`{{${e}}}`,result:this.sanitizeResultForTracking(x),resultType:this.getResultType(x),componentId:i?.componentId,componentName:i?.componentName,propName:i?.propName,fromCache:C,duration:w,method:i?.method??"evaluatePipeExpression",skipCache:l.skipCache})}return x}resolve(e,n,r,i){const l={...this.defaultOptions,...r},c=So(),d=c?.isEnabled()?performance.now():0;if(l.skipCache){const y=this.resolvePath(e,n,l);return c?.isEnabled()&&c.trackExpressionEval({expression:e,result:this.sanitizeResultForTracking(y),resultType:this.getResultType(y),componentId:i?.componentId,componentName:i?.componentName,propName:i?.propName,fromCache:!1,duration:performance.now()-d,method:"resolve",skipCache:!0}),y}const f=e.startsWith("_global")||e.startsWith("_local")||e.startsWith("_isolated")||e.startsWith("$parent");let p=!1;if(f){const y=this.getFromRenderCycleCache(e);if(y!==void 0)return p=!0,c?.isEnabled()&&c.trackExpressionEval({expression:e,result:this.sanitizeResultForTracking(y),resultType:this.getResultType(y),componentId:i?.componentId,componentName:i?.componentName,propName:i?.propName,fromCache:!0,duration:performance.now()-d,method:"resolve",skipCache:l.skipCache}),y}else{const y=this.getFromCache(e);if(y!==void 0)return p=!0,c?.isEnabled()&&c.trackExpressionEval({expression:e,result:this.sanitizeResultForTracking(y),resultType:this.getResultType(y),componentId:i?.componentId,componentName:i?.componentName,propName:i?.propName,fromCache:!0,duration:performance.now()-d,method:"resolve",skipCache:l.skipCache}),y}const m=this.resolvePath(e,n,l);return f?this.saveToRenderCycleCache(e,m):this.saveToCache(e,m),c?.isEnabled()&&c.trackExpressionEval({expression:e,result:this.sanitizeResultForTracking(m),resultType:this.getResultType(m),componentId:i?.componentId,componentName:i?.componentName,propName:i?.propName,fromCache:p,duration:performance.now()-d,method:"resolve",skipCache:l.skipCache}),m}resolvePath(e,n,r,i=0,l=new WeakSet){if(typeof e!="string"||e.trim()===""){ja.warn("resolvePath: 빈 경로가 전달되었습니다 — undefined 로 해석합니다.");return}if(r.maxDepth&&i>r.maxDepth){if(r.detectCircular)throw new Qd(`Maximum depth exceeded (${r.maxDepth}). Possible circular reference.`,e,n);return r.defaultValue}const c=this.parsePath(e);let d=n;for(let f=0;fua.CACHE_EXPIRY){this.cache.delete(e),r?.isEnabled()&&r.recordCacheMiss();return}return r?.isEnabled()&&r.recordCacheHit(),n.value}saveToCache(e,n){this.cache.set(e,{value:n,timestamp:Date.now()})}isActionDefinition(e){return typeof e.handler!="string"?!1:e.params!==void 0||Array.isArray(e.actions)||typeof e.target=="string"||e.onSuccess!==void 0||e.onError!==void 0}resolveObject(e,n,r){if(this.isSwitchExpression(e)){const d=e;return this.resolveSwitch(d,n,r)}if(this.isActionDefinition(e))return{...e};if("iteration"in e)return{...e};const i={},c=[...["cellChildren","expandChildren","expandContext","render"],...r?.skipBindingKeys||[]];for(const[d,f]of Object.entries(e)){if(c.includes(d)){i[d]=f;continue}try{this.resolveObjectEntry(i,d,f,n,r)}catch(p){ja.warn(`resolveObject: 값 해석 실패 (key: ${d}):`,p),i[d]=void 0}}return i}resolveObjectEntry(e,n,r,i,l){if(typeof r=="string"){const c=Ma(r);if(c!==null){const d=c.trim();let f=!1,p=d;d.startsWith(lr)&&(f=!0,p=d.slice(lr.length));let m;switch(Mg(p)){case"empty":ja.warn(`resolveObject: 빈 바인딩 \`{{}}\` (key: ${n}) — undefined 로 해석합니다.`),m=void 0;break;case"literal":m=Ud.get(p);break;case"pipe":m=this.evaluatePipeExpression(p,i,l);break;case"expression":m=this.evaluateExpression(p,i,l);break;default:m=this.resolve(p,i,l)}e[n]=f&&m!=null?ss(m):m}else e[n]=this.resolveBindings(r,i,l)}else Array.isArray(r)?e[n]=r.map(c=>typeof c=="string"?this.resolveBindings(c,i,l):typeof c=="object"&&c!==null?this.resolveObject(c,i,l):c):r&&typeof r=="object"?e[n]=this.resolveObject(r,i,l):e[n]=r}clearCache(){this.cache.clear()}invalidateCacheByKeys(e){for(const n of this.cache.keys())for(const r of e)if(n===r||n.startsWith(`${r}.`)||n.startsWith(`${r}[`)){this.cache.delete(n);break}}pruneCache(){const e=Date.now();for(const[n,r]of this.cache.entries())e-r.timestamp>ua.CACHE_EXPIRY&&this.cache.delete(n)}getCacheStats(){const e=Date.now();let n=0;for(const r of this.cache.values())e-r.timestamp>ua.CACHE_EXPIRY&&n++;return{size:this.cache.size,expired:n}}evaluateExpression(e,n,r){const i=So(),l=i?.isEnabled()?performance.now():0;i?.isEnabled()&&i.trackBindingEval();try{let c=this.preprocessOptionalChaining(e);c=this.preprocessTranslationTokens(c);const d=this.extractVariablesFromExpression(c),f={...n};for(const w of d)w in f||(f[w]=void 0);n._computed&&!f.$computed&&(f.$computed=n._computed);let p=n.$templateId,m=n.$locale;if(typeof window<"u"&&(!p||!m)){const w=window.__templateApp?.getConfig?.();p??(p=w?.templateId),m??(m=w?.locale)}const y=m||"ko";f.$localized=(w,R)=>{if(w==null&&!R)return"";if(typeof w=="string")return w;if(w&&typeof w=="object"&&w[y])return w[y];if(R&&typeof R=="string"){const L=f.$t?f.$t(R):R;if(L&&L!==R)return L}return w&&typeof w=="object"?w.ko||w.en||Object.values(w)[0]||"":w==null?"":String(w)};const C=typeof window<"u"?window.G7Core:void 0;f.$uuid=()=>C?.uuid?C.uuid():typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,w=>{const R=Math.random()*16|0;return(w==="x"?R:R&3|8).toString(16)});const S={templateId:p||"",locale:y};f.$t=w=>{if(!w||typeof w!="string")return"";try{return wi.getInstance().translate(w,S)}catch(R){return ja.warn("$t() translation failed for key:",w,R),w}},f.$get=(w,R,L=void 0)=>{if(w==null)return L;const O=Array.isArray(R)?R:[R];if(O.length===0)return w;let j=w;for(const F of O){if(j==null||F==null)return L;j=j[F]}return j??L};const v=!1,x=Jd(c,f);if(i?.isEnabled()){const w=performance.now()-l;i.trackExpressionEval({expression:e,result:this.sanitizeResultForTracking(x),resultType:this.getResultType(x),componentId:r?.componentId,componentName:r?.componentName,propName:r?.propName,fromCache:v,duration:w,method:"evaluateExpression",skipCache:r?.skipCache})}return x}catch(c){throw new Error(`Failed to evaluate expression "${e}": ${c instanceof Error?c.message:String(c)}`)}}getResultType(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?"array":typeof e}sanitizeResultForTracking(e){if(e==null||typeof e!="object")return e;try{if(Array.isArray(e))return e.length>10?`[Array(${e.length})]`:e.slice(0,10);const n=Object.keys(e);return n.length>20?`{Object(${n.length} keys)}`:(JSON.stringify(e),e)}catch{return"[Complex Object]"}}preprocessTranslationTokens(e){return e=e.replace(/(['"])(\$t:([a-zA-Z_][a-zA-Z0-9_.\-]*))\1/g,(n,r,i,l)=>`$t('${l}')`),e.replace(/(['"]\s*)?(\$t:[a-zA-Z_][a-zA-Z0-9_.\-]*)(?!\s*['"])/g,(n,r,i)=>r?n:`"${i}"`)}preprocessOptionalChaining(e){const n=[];let r=e.replace(/(['"])(?:(?!\1|\\).|\\.)*\1/g,l=>(n.push(l),`__STRING_LITERAL_${n.length-1}__`));const i=[];return r=r.replace(/\$t:[a-zA-Z_][a-zA-Z0-9_.\-]*(?:\|[^'"\s,)]+)?/g,l=>(i.push(l),`__TRANSLATION_TOKEN_${i.length-1}__`)),r=r.replace(/([a-zA-Z_$][a-zA-Z0-9_$]*)\.(?!\?)/g,"$1?."),r=r.replace(/__TRANSLATION_TOKEN_(\d+)__/g,(l,c)=>i[parseInt(c,10)]),r=r.replace(/__STRING_LITERAL_(\d+)__/g,(l,c)=>n[parseInt(c,10)]),r}extractVariablesFromExpression(e){const n=new Set(["true","false","null","undefined","NaN","Infinity","if","else","for","while","do","switch","case","break","continue","return","function","class","const","let","var","new","delete","typeof","instanceof","this","super","import","export","default","try","catch","finally","throw","Math","Date","JSON","Array","Object","String","Number","Boolean","RegExp","Set","Map","WeakSet","WeakMap","Symbol","Promise","BigInt","Error","parseInt","parseFloat","isNaN","isFinite","encodeURI","decodeURI","encodeURIComponent","decodeURIComponent"]),r=/(^|[^.\w$])([a-zA-Z_$][a-zA-Z0-9_$]*)/g,i=new Set;let l;for(;(l=r.exec(e))!==null;){const c=l[2];n.has(c)||i.add(c)}return Array.from(i)}isSwitchExpression(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&"$switch"in e&&"$cases"in e}resolveSwitch(e,n,r){const i={...r,skipCache:!0};let l;try{l=this.resolveBindings(e.$switch,n,i)?.toString()?.trim()??""}catch(d){ja.warn("resolveSwitch: $switch 키 평가 실패:",e.$switch,d),l=""}let c;if(l&&e.$cases&&l in e.$cases)c=e.$cases[l];else if("$default"in e)c=e.$default;else return;return typeof c=="string"?c.includes("{{")?this.resolveBindings(c,n,i):c:c!==null&&typeof c=="object"?this.resolveObject(c,n,i):c}};$(ua,"PATH_SEGMENT_PATTERN",/([^.[\]]+)|\[(\d+)\]/g),$(ua,"CACHE_EXPIRY",3e4);let Tn=ua;const uc=new Tn,dc={mobile:{min:0,max:767},tablet:{min:768,max:1023},desktop:{min:1024,max:1/0},portable:{min:0,max:1023}},fc=new Map;function h0(s,e){let n=null;return((...r)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{s(...r)},e)})}class p0{constructor(){$(this,"subscribers",new Set);$(this,"currentWidth",1024);$(this,"debouncedHandler",null);$(this,"isInitialized",!1);this.initialize()}initialize(){typeof window>"u"||(this.currentWidth=window.innerWidth,this.isInitialized=!0,this.debouncedHandler=h0(()=>{this.currentWidth=window.innerWidth,this.notifySubscribers()},150),window.addEventListener("resize",this.debouncedHandler))}notifySubscribers(){this.subscribers.forEach(e=>{e(this.currentWidth)})}subscribe(e){return this.subscribers.add(e),e(this.currentWidth),()=>{this.subscribers.delete(e)}}getWidth(){return this.currentWidth}parseRange(e){if(fc.has(e))return fc.get(e)??null;let n=null;if(dc[e])n={...dc[e]};else{const r=e.match(/^(-?\d*)-(-?\d*)$/);if(r){const[,i,l]=r,c=i===""?0:parseInt(i,10),d=l===""?1/0:parseInt(l,10);!isNaN(c)&&!isNaN(d)&&c<=d&&(n={min:c,max:d})}}return fc.set(e,n),n}getMatchingKey(e,n){const r=[];for(const i of Object.keys(e)){const l=this.parseRange(i);l&&n>=l.min&&n<=l.max&&r.push({key:i,range:l,isPreset:!!dc[i]})}return r.length===0?null:(r.sort((i,l)=>{if(i.isPreset!==l.isPreset)return i.isPreset?1:-1;const c=i.range.max-i.range.min,d=l.range.max-l.range.min;return c-d}),r[0].key)}matches(e){const n=this.parseRange(e);return n?this.currentWidth>=n.min&&this.currentWidth<=n.max:!1}clearSubscribers(){this.subscribers.clear()}destroy(){this.debouncedHandler&&typeof window<"u"&&window.removeEventListener("resize",this.debouncedHandler),this.clearSubscribers(),fc.clear()}_setWidthForTesting(e){this.currentWidth=e,this.notifySubscribers()}}const _i=new p0,wo=dt("ConditionEvaluator");function g0(s,e,n,r){return Pd(Ng(s),e,n,{skipCache:!0,onEmpty:()=>{wo.warn(`${r}: 빈 바인딩 \`{{}}\` — undefined 로 해석합니다.`)}})}function Fg(s,e,n){if(!s)return!0;try{const r=Ma(s);let i;if(r!==null?i=g0(r,e,n,"evaluateStringCondition"):i=n.resolveBindings(s,e,{skipCache:!0}),typeof i=="string"){const l=i.toLowerCase().trim();if(l==="false"||l==="0"||l===""||l==="null"||l==="undefined")return!1}return!!i}catch(r){return wo.warn(`evaluateStringCondition: 조건 평가 실패: ${s}`,r),!1}}function hc(s,e,n){if(typeof s=="string")return Fg(s,e,n);if("and"in s){if(!Array.isArray(s.and)||s.and.length===0)return wo.warn("evaluateConditionExpression: AND 그룹이 비어있습니다"),!0;for(const r of s.and)if(!hc(r,e,n))return!1;return!0}if("or"in s){if(!Array.isArray(s.or)||s.or.length===0)return wo.warn("evaluateConditionExpression: OR 그룹이 비어있습니다"),!1;for(const r of s.or)if(hc(r,e,n))return!0;return!1}return wo.warn("evaluateConditionExpression: 알 수 없는 조건 형식",s),!1}function Vg(s,e,n){if(!Array.isArray(s)||s.length===0)return{matched:!1,branchIndex:-1};for(let r=0;r{cr.warn(`evaluateIfCondition: 빈 바인딩 \`{{}}\` (컴포넌트: ${r||"unknown"}) — undefined 로 해석합니다.`)}}):l=n.resolveBindings(s,e,{skipCache:!0}),typeof l=="string"){const c=l.toLowerCase().trim();if(c==="false"||c==="0"||c===""||c==="null"||c==="undefined")return!1}return!!l}catch(i){return cr.warn(`evaluateIfCondition: 조건 평가 실패 (컴포넌트: ${r||"unknown"}):`,i),!1}}function os(s,e,n,r){if(s.if!==void 0)return Xg(s.if,e,n,r);if(s.condition!==void 0)return Xg(s.condition,e,n,r);if(s.conditions===void 0)return!0;const i=s.conditions;try{return m0(i)?hc(i,e,n):y0(i)?Vg(i,e,n).matched:(cr.warn(`evaluateRenderCondition: 알 수 없는 conditions 형식 (컴포넌트: ${r||"unknown"})`),!0)}catch(l){return cr.warn(`evaluateRenderCondition: conditions 평가 실패 (컴포넌트: ${r||"unknown"}):`,l),!1}}function Jg(s){if(!s.responsive)return s;const e=_i.getWidth(),n=_i.getMatchingKey(s.responsive,e);if(!n)return s;const r=s.responsive[n];return{...s,props:{...s.props,...r.props},children:r.children??s.children,text:r.text??s.text,if:r.if??s.if,iteration:r.iteration??s.iteration}}function Co(s,e,n,r,i){if(!s||s.length===0)return[];const l=i?.bindingEngine??new Tn,c=i?.translationEngine??wi.getInstance(),d=i?.translationContext??{templateId:"",locale:"ko"},f=v0(e,i?.componentContext),p=(S,v)=>{if(typeof S=="string")return oc(S)||lc(S)||!/\$t:[a-zA-Z0-9._-]+/.test(S)?S:c.resolveTranslations(S,d,v);if(Array.isArray(S))return S.map(x=>p(x,v));if(S&&typeof S=="object"){const x={};for(const[w,R]of Object.entries(S))x[w]=p(R,v);return x}return S},m=(S,v)=>{if(typeof S=="string"){if(oc(S))return Bd(S);if(lc(S)){const w=[],R=S.replace(new RegExp(`${yo}([^${Ci}]*)${Ci}`,"g"),(O,j)=>(w.push(j),`${Na}${w.length-1}${Na}`));let L=R;return/\$t:[a-zA-Z0-9._-]+/.test(R)&&(L=c.resolveTranslations(R,d,v)),L.replace(new RegExp(`${Na}(\\d+)${Na}`,"g"),(O,j)=>w[parseInt(j)])}if(S.startsWith("$t:defer:")){const w="$t:"+S.slice(9);return c.resolveTranslations(w,d,v)}if(S.startsWith("$t:"))return c.resolveTranslations(S,d,v);if(/\$t:[a-zA-Z0-9._-]+/.test(S)){const w=S.trim();if(!(w.startsWith("{")&&w.endsWith("}")||w.startsWith("[")&&w.endsWith("]"))&&!S.includes("{{"))return c.resolveTranslations(S,d,v)}const x=Yg(S);if(x!==null){let w=!1,R=x;x.startsWith(lr)&&(w=!0,R=x.slice(lr.length));let L=!1,O=Pd(R,v,l,{skipCache:!0,onError:j=>{cr.warn("renderItemChildren: 표현식 평가 실패:",j),L=!0},onEmpty:()=>{cr.warn("renderItemChildren: 빈 바인딩 `{{}}` 은 해석하지 않습니다.")}});return L?void 0:(w||(O=p(O,v)),w&&O!=null?ss(O):O)}if(S.includes("{{")){const w=l.resolveBindings(S,v,{skipCache:!0});return typeof w=="string"&&/\$t:[a-zA-Z0-9._-]+/.test(w)?c.resolveTranslations(w,d,v):w}return S}if(Array.isArray(S))return S.map(x=>m(x,v));if(S&&typeof S=="object"){if(l.isSwitchExpression(S))return l.resolveSwitch(S,v,{skipCache:!0});if(l.isActionDefinition(S))return{...S};const x={};for(const[w,R]of Object.entries(S))x[w]=m(R,v);return x}return S},y=(S,v)=>{if(!S)return{};const x={};for(const[w,R]of Object.entries(S))x[w]=m(R,v);return x},C=(S,v,x)=>{const w=Jg(S),R=w.iteration;if(!R)return[];const L=Zd(R.source,x,l);if(!Array.isArray(L))return cr.warn(`renderItemChildren: iteration.source가 배열이 아닙니다: ${R.source}`),[];const O=Kg();if(O?.isEnabled()){const F=`${v}-iteration`;O.trackIteration(F,R.source,R.item_var,R.index_var,L.length)}const j=n[w.name];return j?L.flatMap((F,G)=>{const P={...x,[R.item_var]:F,[`${R.item_var}_index`]:G,...R.index_var?{[R.index_var]:G}:{}},K=os({if:w.if,condition:w.condition,conditions:w.conditions},P,l,w.id);if(w.if&&O?.isEnabled()){const bt=`${v}-iter-${G}-if`;O.trackIfCondition(bt,w.if,K,w.name)}if(!K)return[];const he=w.id?String(Ia(m(w.id,P))):void 0,Ee=`${v}-iter-${G}`,ke=i?.getRemountKey?i.getRemountKey(he,Ee):Ee,ze=y(w.props,P),Be=ef(ze,w.actions,P,{actionDispatcher:i?.actionDispatcher,componentContext:i?.componentContext});let je=null;return w.text!==void 0?je=m(w.text,P):w.children&&w.children.length>0&&(je=Co(w.children,P,n,ke,i)),O?.isEnabled()&&O.trackRender(w.name),[We.createElement(j,{key:ke,...Ia(Be)},Ia(je))]}):(cr.warn(`renderItemChildren: 컴포넌트를 찾을 수 없습니다: ${w.name}`),[])};return s.flatMap((S,v)=>{const x=Jg(S),w=x.id?String(Ia(m(x.id,f))):void 0,R=r?`${r}-${w||v}`:w||`child-${v}`,L=i?.getRemountKey?i.getRemountKey(w,R):R;if(x.iteration)return C(x,L,f);const O=os({if:x.if,condition:x.condition,conditions:x.conditions},f,l,x.id),j=Kg();if(x.if&&j?.isEnabled()){const he=`${L}-if`;j.trackIfCondition(he,x.if,O,x.name)}if(!O)return[];const F=n[x.name];if(!F)return cr.warn(`renderItemChildren: 컴포넌트를 찾을 수 없습니다: ${x.name}`),[];const G=y(x.props,f),P=ef(G,x.actions,f,{actionDispatcher:i?.actionDispatcher,componentContext:i?.componentContext});let K=null;return x.text!==void 0?K=m(x.text,f):x.children&&x.children.length>0&&(K=Co(x.children,f,n,L,i)),j?.isEnabled()&&j.trackRender(x.name),[We.createElement(F,{key:L,...Ia(P)},Ia(K))]})}function ls(s,e,n,r){let i,l;return n instanceof Tn?(i=n,l=r):(i=Wg,l=n),i.resolveBindings(s,e,l)}function S0(s,e,n,r){const i=n??Wg,l={skipCache:!0,...r};let c;try{c=i.resolveBindings(s.key,e,{skipCache:l.skipCache})?.toString()?.trim()??""}catch(p){cr.warn("resolveClassMap: key 평가 실패:",s.key,p),c=""}let d="";c&&s.variants&&c in s.variants?d=s.variants[c]:s.default&&(d=s.default);const f=[];return s.base?.trim()&&f.push(s.base.trim()),d?.trim()&&f.push(d.trim()),f.join(" ")}function Qg(s,e){return function(){return s.apply(e,arguments)}}const{toString:w0}=Object.prototype,{getPrototypeOf:tf}=Object,{iterator:pc,toStringTag:Zg}=Symbol,gc=(s=>e=>{const n=w0.call(e);return s[n]||(s[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Ar=s=>(s=s.toLowerCase(),e=>gc(e)===s),mc=s=>e=>typeof e===s,{isArray:cs}=Array,us=mc("undefined");function Eo(s){return s!==null&&!us(s)&&s.constructor!==null&&!us(s.constructor)&&Ln(s.constructor.isBuffer)&&s.constructor.isBuffer(s)}const em=Ar("ArrayBuffer");function C0(s){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(s):e=s&&s.buffer&&em(s.buffer),e}const E0=mc("string"),Ln=mc("function"),tm=mc("number"),_o=s=>s!==null&&typeof s=="object",_0=s=>s===!0||s===!1,yc=s=>{if(gc(s)!=="object")return!1;const e=tf(s);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Zg in s)&&!(pc in s)},A0=s=>{if(!_o(s)||Eo(s))return!1;try{return Object.keys(s).length===0&&Object.getPrototypeOf(s)===Object.prototype}catch{return!1}},x0=Ar("Date"),T0=Ar("File"),k0=Ar("Blob"),R0=Ar("FileList"),D0=s=>_o(s)&&Ln(s.pipe),O0=s=>{let e;return s&&(typeof FormData=="function"&&s instanceof FormData||Ln(s.append)&&((e=gc(s))==="formdata"||e==="object"&&Ln(s.toString)&&s.toString()==="[object FormData]"))},L0=Ar("URLSearchParams"),[$0,M0,N0,I0]=["ReadableStream","Request","Response","Headers"].map(Ar),j0=s=>s.trim?s.trim():s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Ao(s,e,{allOwnKeys:n=!1}={}){if(s===null||typeof s>"u")return;let r,i;if(typeof s!="object"&&(s=[s]),cs(s))for(r=0,i=s.length;r0;)if(i=n[r],e===i.toLowerCase())return i;return null}const Ai=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,rm=s=>!us(s)&&s!==Ai;function nf(){const{caseless:s,skipUndefined:e}=rm(this)&&this||{},n={},r=(i,l)=>{const c=s&&nm(n,l)||l;yc(n[c])&&yc(i)?n[c]=nf(n[c],i):yc(i)?n[c]=nf({},i):cs(i)?n[c]=i.slice():(!e||!us(i))&&(n[c]=i)};for(let i=0,l=arguments.length;i(Ao(e,(i,l)=>{n&&Ln(i)?s[l]=Qg(i,n):s[l]=i},{allOwnKeys:r}),s),H0=s=>(s.charCodeAt(0)===65279&&(s=s.slice(1)),s),U0=(s,e,n,r)=>{s.prototype=Object.create(e.prototype,r),s.prototype.constructor=s,Object.defineProperty(s,"super",{value:e.prototype}),n&&Object.assign(s.prototype,n)},P0=(s,e,n,r)=>{let i,l,c;const d={};if(e=e||{},s==null)return e;do{for(i=Object.getOwnPropertyNames(s),l=i.length;l-- >0;)c=i[l],(!r||r(c,s,e))&&!d[c]&&(e[c]=s[c],d[c]=!0);s=n!==!1&&tf(s)}while(s&&(!n||n(s,e))&&s!==Object.prototype);return e},B0=(s,e,n)=>{s=String(s),(n===void 0||n>s.length)&&(n=s.length),n-=e.length;const r=s.indexOf(e,n);return r!==-1&&r===n},q0=s=>{if(!s)return null;if(cs(s))return s;let e=s.length;if(!tm(e))return null;const n=new Array(e);for(;e-- >0;)n[e]=s[e];return n},G0=(s=>e=>s&&e instanceof s)(typeof Uint8Array<"u"&&tf(Uint8Array)),F0=(s,e)=>{const r=(s&&s[pc]).call(s);let i;for(;(i=r.next())&&!i.done;){const l=i.value;e.call(s,l[0],l[1])}},V0=(s,e)=>{let n;const r=[];for(;(n=s.exec(e))!==null;)r.push(n);return r},K0=Ar("HTMLFormElement"),W0=s=>s.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,i){return r.toUpperCase()+i}),am=(({hasOwnProperty:s})=>(e,n)=>s.call(e,n))(Object.prototype),Y0=Ar("RegExp"),im=(s,e)=>{const n=Object.getOwnPropertyDescriptors(s),r={};Ao(n,(i,l)=>{let c;(c=e(i,l,s))!==!1&&(r[l]=c||i)}),Object.defineProperties(s,r)},X0=s=>{im(s,(e,n)=>{if(Ln(s)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=s[n];if(Ln(r)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},J0=(s,e)=>{const n={},r=i=>{i.forEach(l=>{n[l]=!0})};return cs(s)?r(s):r(String(s).split(e)),n},Q0=()=>{},Z0=(s,e)=>s!=null&&Number.isFinite(s=+s)?s:e;function eC(s){return!!(s&&Ln(s.append)&&s[Zg]==="FormData"&&s[pc])}const tC=s=>{const e=new Array(10),n=(r,i)=>{if(_o(r)){if(e.indexOf(r)>=0)return;if(Eo(r))return r;if(!("toJSON"in r)){e[i]=r;const l=cs(r)?[]:{};return Ao(r,(c,d)=>{const f=n(c,i+1);!us(f)&&(l[d]=f)}),e[i]=void 0,l}}return r};return n(s,0)},nC=Ar("AsyncFunction"),rC=s=>s&&(_o(s)||Ln(s))&&Ln(s.then)&&Ln(s.catch),sm=((s,e)=>s?setImmediate:e?((n,r)=>(Ai.addEventListener("message",({source:i,data:l})=>{i===Ai&&l===n&&r.length&&r.shift()()},!1),i=>{r.push(i),Ai.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ln(Ai.postMessage)),aC=typeof queueMicrotask<"u"?queueMicrotask.bind(Ai):typeof process<"u"&&process.nextTick||sm,ee={isArray:cs,isArrayBuffer:em,isBuffer:Eo,isFormData:O0,isArrayBufferView:C0,isString:E0,isNumber:tm,isBoolean:_0,isObject:_o,isPlainObject:yc,isEmptyObject:A0,isReadableStream:$0,isRequest:M0,isResponse:N0,isHeaders:I0,isUndefined:us,isDate:x0,isFile:T0,isBlob:k0,isRegExp:Y0,isFunction:Ln,isStream:D0,isURLSearchParams:L0,isTypedArray:G0,isFileList:R0,forEach:Ao,merge:nf,extend:z0,trim:j0,stripBOM:H0,inherits:U0,toFlatObject:P0,kindOf:gc,kindOfTest:Ar,endsWith:B0,toArray:q0,forEachEntry:F0,matchAll:V0,isHTMLForm:K0,hasOwnProperty:am,hasOwnProp:am,reduceDescriptors:im,freezeMethods:X0,toObjectSet:J0,toCamelCase:W0,noop:Q0,toFiniteNumber:Z0,findKey:nm,global:Ai,isContextDefined:rm,isSpecCompliantForm:eC,toJSONObject:tC,isAsyncFn:nC,isThenable:rC,setImmediate:sm,asap:aC,isIterable:s=>s!=null&&Ln(s[pc])};function Ye(s,e,n,r,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=s,this.name="AxiosError",e&&(this.code=e),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status?i.status:null)}ee.inherits(Ye,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ee.toJSONObject(this.config),code:this.code,status:this.status}}});const om=Ye.prototype,lm={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(s=>{lm[s]={value:s}}),Object.defineProperties(Ye,lm),Object.defineProperty(om,"isAxiosError",{value:!0}),Ye.from=(s,e,n,r,i,l)=>{const c=Object.create(om);ee.toFlatObject(s,c,function(m){return m!==Error.prototype},p=>p!=="isAxiosError");const d=s&&s.message?s.message:"Error",f=e==null&&s?s.code:e;return Ye.call(c,d,f,n,r,i),s&&c.cause==null&&Object.defineProperty(c,"cause",{value:s,configurable:!0}),c.name=s&&s.name||"Error",l&&Object.assign(c,l),c};const iC=null;function rf(s){return ee.isPlainObject(s)||ee.isArray(s)}function cm(s){return ee.endsWith(s,"[]")?s.slice(0,-2):s}function um(s,e,n){return s?s.concat(e).map(function(i,l){return i=cm(i),!n&&l?"["+i+"]":i}).join(n?".":""):e}function sC(s){return ee.isArray(s)&&!s.some(rf)}const oC=ee.toFlatObject(ee,{},null,function(e){return/^is[A-Z]/.test(e)});function bc(s,e,n){if(!ee.isObject(s))throw new TypeError("target must be an object");e=e||new FormData,n=ee.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(x,w){return!ee.isUndefined(w[x])});const r=n.metaTokens,i=n.visitor||m,l=n.dots,c=n.indexes,f=(n.Blob||typeof Blob<"u"&&Blob)&&ee.isSpecCompliantForm(e);if(!ee.isFunction(i))throw new TypeError("visitor must be a function");function p(v){if(v===null)return"";if(ee.isDate(v))return v.toISOString();if(ee.isBoolean(v))return v.toString();if(!f&&ee.isBlob(v))throw new Ye("Blob is not supported. Use a Buffer instead.");return ee.isArrayBuffer(v)||ee.isTypedArray(v)?f&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function m(v,x,w){let R=v;if(v&&!w&&typeof v=="object"){if(ee.endsWith(x,"{}"))x=r?x:x.slice(0,-2),v=JSON.stringify(v);else if(ee.isArray(v)&&sC(v)||(ee.isFileList(v)||ee.endsWith(x,"[]"))&&(R=ee.toArray(v)))return x=cm(x),R.forEach(function(O,j){!(ee.isUndefined(O)||O===null)&&e.append(c===!0?um([x],j,l):c===null?x:x+"[]",p(O))}),!1}return rf(v)?!0:(e.append(um(w,x,l),p(v)),!1)}const y=[],C=Object.assign(oC,{defaultVisitor:m,convertValue:p,isVisitable:rf});function S(v,x){if(!ee.isUndefined(v)){if(y.indexOf(v)!==-1)throw Error("Circular reference detected in "+x.join("."));y.push(v),ee.forEach(v,function(R,L){(!(ee.isUndefined(R)||R===null)&&i.call(e,R,ee.isString(L)?L.trim():L,x,C))===!0&&S(R,x?x.concat(L):[L])}),y.pop()}}if(!ee.isObject(s))throw new TypeError("data must be an object");return S(s),e}function dm(s){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(s).replace(/[!'()~]|%20|%00/g,function(r){return e[r]})}function af(s,e){this._pairs=[],s&&bc(s,this,e)}const fm=af.prototype;fm.append=function(e,n){this._pairs.push([e,n])},fm.toString=function(e){const n=e?function(r){return e.call(this,r,dm)}:dm;return this._pairs.map(function(i){return n(i[0])+"="+n(i[1])},"").join("&")};function lC(s){return encodeURIComponent(s).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function hm(s,e,n){if(!e)return s;const r=n&&n.encode||lC;ee.isFunction(n)&&(n={serialize:n});const i=n&&n.serialize;let l;if(i?l=i(e,n):l=ee.isURLSearchParams(e)?e.toString():new af(e,n).toString(r),l){const c=s.indexOf("#");c!==-1&&(s=s.slice(0,c)),s+=(s.indexOf("?")===-1?"?":"&")+l}return s}class pm{constructor(){this.handlers=[]}use(e,n,r){return this.handlers.push({fulfilled:e,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){ee.forEach(this.handlers,function(r){r!==null&&e(r)})}}const gm={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},cC={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:af,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},sf=typeof window<"u"&&typeof document<"u",of=typeof navigator=="object"&&navigator||void 0,uC=sf&&(!of||["ReactNative","NativeScript","NS"].indexOf(of.product)<0),dC=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",fC=sf&&window.location.href||"http://localhost",Cn={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:sf,hasStandardBrowserEnv:uC,hasStandardBrowserWebWorkerEnv:dC,navigator:of,origin:fC},Symbol.toStringTag,{value:"Module"})),...cC};function hC(s,e){return bc(s,new Cn.classes.URLSearchParams,{visitor:function(n,r,i,l){return Cn.isNode&&ee.isBuffer(n)?(this.append(r,n.toString("base64")),!1):l.defaultVisitor.apply(this,arguments)},...e})}function pC(s){return ee.matchAll(/\w+|\[(\w*)]/g,s).map(e=>e[0]==="[]"?"":e[1]||e[0])}function gC(s){const e={},n=Object.keys(s);let r;const i=n.length;let l;for(r=0;r=n.length;return c=!c&&ee.isArray(i)?i.length:c,f?(ee.hasOwnProp(i,c)?i[c]=[i[c],r]:i[c]=r,!d):((!i[c]||!ee.isObject(i[c]))&&(i[c]=[]),e(n,r,i[c],l)&&ee.isArray(i[c])&&(i[c]=gC(i[c])),!d)}if(ee.isFormData(s)&&ee.isFunction(s.entries)){const n={};return ee.forEachEntry(s,(r,i)=>{e(pC(r),i,n,0)}),n}return null}function mC(s,e,n){if(ee.isString(s))try{return(e||JSON.parse)(s),ee.trim(s)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(s)}const xo={transitional:gm,adapter:["xhr","http","fetch"],transformRequest:[function(e,n){const r=n.getContentType()||"",i=r.indexOf("application/json")>-1,l=ee.isObject(e);if(l&&ee.isHTMLForm(e)&&(e=new FormData(e)),ee.isFormData(e))return i?JSON.stringify(mm(e)):e;if(ee.isArrayBuffer(e)||ee.isBuffer(e)||ee.isStream(e)||ee.isFile(e)||ee.isBlob(e)||ee.isReadableStream(e))return e;if(ee.isArrayBufferView(e))return e.buffer;if(ee.isURLSearchParams(e))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let d;if(l){if(r.indexOf("application/x-www-form-urlencoded")>-1)return hC(e,this.formSerializer).toString();if((d=ee.isFileList(e))||r.indexOf("multipart/form-data")>-1){const f=this.env&&this.env.FormData;return bc(d?{"files[]":e}:e,f&&new f,this.formSerializer)}}return l||i?(n.setContentType("application/json",!1),mC(e)):e}],transformResponse:[function(e){const n=this.transitional||xo.transitional,r=n&&n.forcedJSONParsing,i=this.responseType==="json";if(ee.isResponse(e)||ee.isReadableStream(e))return e;if(e&&ee.isString(e)&&(r&&!this.responseType||i)){const c=!(n&&n.silentJSONParsing)&&i;try{return JSON.parse(e,this.parseReviver)}catch(d){if(c)throw d.name==="SyntaxError"?Ye.from(d,Ye.ERR_BAD_RESPONSE,this,null,this.response):d}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Cn.classes.FormData,Blob:Cn.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ee.forEach(["delete","get","head","post","put","patch"],s=>{xo.headers[s]={}});const yC=ee.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),bC=s=>{const e={};let n,r,i;return s&&s.split(` -`).forEach(function(c){i=c.indexOf(":"),n=c.substring(0,i).trim().toLowerCase(),r=c.substring(i+1).trim(),!(!n||e[n]&&yC[n])&&(n==="set-cookie"?e[n]?e[n].push(r):e[n]=[r]:e[n]=e[n]?e[n]+", "+r:r)}),e},ym=Symbol("internals");function To(s){return s&&String(s).trim().toLowerCase()}function vc(s){return s===!1||s==null?s:ee.isArray(s)?s.map(vc):String(s)}function vC(s){const e=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(s);)e[r[1]]=r[2];return e}const SC=s=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(s.trim());function lf(s,e,n,r,i){if(ee.isFunction(r))return r.call(this,e,n);if(i&&(e=n),!!ee.isString(e)){if(ee.isString(r))return e.indexOf(r)!==-1;if(ee.isRegExp(r))return r.test(e)}}function wC(s){return s.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,n,r)=>n.toUpperCase()+r)}function CC(s,e){const n=ee.toCamelCase(" "+e);["get","set","has"].forEach(r=>{Object.defineProperty(s,r+n,{value:function(i,l,c){return this[r].call(this,e,i,l,c)},configurable:!0})})}let $n=class{constructor(e){e&&this.set(e)}set(e,n,r){const i=this;function l(d,f,p){const m=To(f);if(!m)throw new Error("header name must be a non-empty string");const y=ee.findKey(i,m);(!y||i[y]===void 0||p===!0||p===void 0&&i[y]!==!1)&&(i[y||f]=vc(d))}const c=(d,f)=>ee.forEach(d,(p,m)=>l(p,m,f));if(ee.isPlainObject(e)||e instanceof this.constructor)c(e,n);else if(ee.isString(e)&&(e=e.trim())&&!SC(e))c(bC(e),n);else if(ee.isObject(e)&&ee.isIterable(e)){let d={},f,p;for(const m of e){if(!ee.isArray(m))throw TypeError("Object iterator must return a key-value pair");d[p=m[0]]=(f=d[p])?ee.isArray(f)?[...f,m[1]]:[f,m[1]]:m[1]}c(d,n)}else e!=null&&l(n,e,r);return this}get(e,n){if(e=To(e),e){const r=ee.findKey(this,e);if(r){const i=this[r];if(!n)return i;if(n===!0)return vC(i);if(ee.isFunction(n))return n.call(this,i,r);if(ee.isRegExp(n))return n.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,n){if(e=To(e),e){const r=ee.findKey(this,e);return!!(r&&this[r]!==void 0&&(!n||lf(this,this[r],r,n)))}return!1}delete(e,n){const r=this;let i=!1;function l(c){if(c=To(c),c){const d=ee.findKey(r,c);d&&(!n||lf(r,r[d],d,n))&&(delete r[d],i=!0)}}return ee.isArray(e)?e.forEach(l):l(e),i}clear(e){const n=Object.keys(this);let r=n.length,i=!1;for(;r--;){const l=n[r];(!e||lf(this,this[l],l,e,!0))&&(delete this[l],i=!0)}return i}normalize(e){const n=this,r={};return ee.forEach(this,(i,l)=>{const c=ee.findKey(r,l);if(c){n[c]=vc(i),delete n[l];return}const d=e?wC(l):String(l).trim();d!==l&&delete n[l],n[d]=vc(i),r[d]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const n=Object.create(null);return ee.forEach(this,(r,i)=>{r!=null&&r!==!1&&(n[i]=e&&ee.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,n])=>e+": "+n).join(` -`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...n){const r=new this(e);return n.forEach(i=>r.set(i)),r}static accessor(e){const r=(this[ym]=this[ym]={accessors:{}}).accessors,i=this.prototype;function l(c){const d=To(c);r[d]||(CC(i,c),r[d]=!0)}return ee.isArray(e)?e.forEach(l):l(e),this}};$n.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),ee.reduceDescriptors($n.prototype,({value:s},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>s,set(r){this[n]=r}}}),ee.freezeMethods($n);function cf(s,e){const n=this||xo,r=e||n,i=$n.from(r.headers);let l=r.data;return ee.forEach(s,function(d){l=d.call(n,l,i.normalize(),e?e.status:void 0)}),i.normalize(),l}function bm(s){return!!(s&&s.__CANCEL__)}function ds(s,e,n){Ye.call(this,s??"canceled",Ye.ERR_CANCELED,e,n),this.name="CanceledError"}ee.inherits(ds,Ye,{__CANCEL__:!0});function vm(s,e,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?s(n):e(new Ye("Request failed with status code "+n.status,[Ye.ERR_BAD_REQUEST,Ye.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function EC(s){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(s);return e&&e[1]||""}function _C(s,e){s=s||10;const n=new Array(s),r=new Array(s);let i=0,l=0,c;return e=e!==void 0?e:1e3,function(f){const p=Date.now(),m=r[l];c||(c=p),n[i]=f,r[i]=p;let y=l,C=0;for(;y!==i;)C+=n[y++],y=y%s;if(i=(i+1)%s,i===l&&(l=(l+1)%s),p-c{n=m,i=null,l&&(clearTimeout(l),l=null),s(...p)};return[(...p)=>{const m=Date.now(),y=m-n;y>=r?c(p,m):(i=p,l||(l=setTimeout(()=>{l=null,c(i)},r-y)))},()=>i&&c(i)]}const Sc=(s,e,n=3)=>{let r=0;const i=_C(50,250);return AC(l=>{const c=l.loaded,d=l.lengthComputable?l.total:void 0,f=c-r,p=i(f),m=c<=d;r=c;const y={loaded:c,total:d,progress:d?c/d:void 0,bytes:f,rate:p||void 0,estimated:p&&d&&m?(d-c)/p:void 0,event:l,lengthComputable:d!=null,[e?"download":"upload"]:!0};s(y)},n)},Sm=(s,e)=>{const n=s!=null;return[r=>e[0]({lengthComputable:n,total:s,loaded:r}),e[1]]},wm=s=>(...e)=>ee.asap(()=>s(...e)),xC=Cn.hasStandardBrowserEnv?((s,e)=>n=>(n=new URL(n,Cn.origin),s.protocol===n.protocol&&s.host===n.host&&(e||s.port===n.port)))(new URL(Cn.origin),Cn.navigator&&/(msie|trident)/i.test(Cn.navigator.userAgent)):()=>!0,TC=Cn.hasStandardBrowserEnv?{write(s,e,n,r,i,l){const c=[s+"="+encodeURIComponent(e)];ee.isNumber(n)&&c.push("expires="+new Date(n).toGMTString()),ee.isString(r)&&c.push("path="+r),ee.isString(i)&&c.push("domain="+i),l===!0&&c.push("secure"),document.cookie=c.join("; ")},read(s){const e=document.cookie.match(new RegExp("(^|;\\s*)("+s+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(s){this.write(s,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function kC(s){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(s)}function RC(s,e){return e?s.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):s}function Cm(s,e,n){let r=!kC(e);return s&&(r||n==!1)?RC(s,e):e}const Em=s=>s instanceof $n?{...s}:s;function xi(s,e){e=e||{};const n={};function r(p,m,y,C){return ee.isPlainObject(p)&&ee.isPlainObject(m)?ee.merge.call({caseless:C},p,m):ee.isPlainObject(m)?ee.merge({},m):ee.isArray(m)?m.slice():m}function i(p,m,y,C){if(ee.isUndefined(m)){if(!ee.isUndefined(p))return r(void 0,p,y,C)}else return r(p,m,y,C)}function l(p,m){if(!ee.isUndefined(m))return r(void 0,m)}function c(p,m){if(ee.isUndefined(m)){if(!ee.isUndefined(p))return r(void 0,p)}else return r(void 0,m)}function d(p,m,y){if(y in e)return r(p,m);if(y in s)return r(void 0,p)}const f={url:l,method:l,data:l,baseURL:c,transformRequest:c,transformResponse:c,paramsSerializer:c,timeout:c,timeoutMessage:c,withCredentials:c,withXSRFToken:c,adapter:c,responseType:c,xsrfCookieName:c,xsrfHeaderName:c,onUploadProgress:c,onDownloadProgress:c,decompress:c,maxContentLength:c,maxBodyLength:c,beforeRedirect:c,transport:c,httpAgent:c,httpsAgent:c,cancelToken:c,socketPath:c,responseEncoding:c,validateStatus:d,headers:(p,m,y)=>i(Em(p),Em(m),y,!0)};return ee.forEach(Object.keys({...s,...e}),function(m){const y=f[m]||i,C=y(s[m],e[m],m);ee.isUndefined(C)&&y!==d||(n[m]=C)}),n}const _m=s=>{const e=xi({},s);let{data:n,withXSRFToken:r,xsrfHeaderName:i,xsrfCookieName:l,headers:c,auth:d}=e;if(e.headers=c=$n.from(c),e.url=hm(Cm(e.baseURL,e.url,e.allowAbsoluteUrls),s.params,s.paramsSerializer),d&&c.set("Authorization","Basic "+btoa((d.username||"")+":"+(d.password?unescape(encodeURIComponent(d.password)):""))),ee.isFormData(n)){if(Cn.hasStandardBrowserEnv||Cn.hasStandardBrowserWebWorkerEnv)c.setContentType(void 0);else if(ee.isFunction(n.getHeaders)){const f=n.getHeaders(),p=["content-type","content-length"];Object.entries(f).forEach(([m,y])=>{p.includes(m.toLowerCase())&&c.set(m,y)})}}if(Cn.hasStandardBrowserEnv&&(r&&ee.isFunction(r)&&(r=r(e)),r||r!==!1&&xC(e.url))){const f=i&&l&&TC.read(l);f&&c.set(i,f)}return e},DC=typeof XMLHttpRequest<"u"&&function(s){return new Promise(function(n,r){const i=_m(s);let l=i.data;const c=$n.from(i.headers).normalize();let{responseType:d,onUploadProgress:f,onDownloadProgress:p}=i,m,y,C,S,v;function x(){S&&S(),v&&v(),i.cancelToken&&i.cancelToken.unsubscribe(m),i.signal&&i.signal.removeEventListener("abort",m)}let w=new XMLHttpRequest;w.open(i.method.toUpperCase(),i.url,!0),w.timeout=i.timeout;function R(){if(!w)return;const O=$n.from("getAllResponseHeaders"in w&&w.getAllResponseHeaders()),F={data:!d||d==="text"||d==="json"?w.responseText:w.response,status:w.status,statusText:w.statusText,headers:O,config:s,request:w};vm(function(P){n(P),x()},function(P){r(P),x()},F),w=null}"onloadend"in w?w.onloadend=R:w.onreadystatechange=function(){!w||w.readyState!==4||w.status===0&&!(w.responseURL&&w.responseURL.indexOf("file:")===0)||setTimeout(R)},w.onabort=function(){w&&(r(new Ye("Request aborted",Ye.ECONNABORTED,s,w)),w=null)},w.onerror=function(j){const F=j&&j.message?j.message:"Network Error",G=new Ye(F,Ye.ERR_NETWORK,s,w);G.event=j||null,r(G),w=null},w.ontimeout=function(){let j=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const F=i.transitional||gm;i.timeoutErrorMessage&&(j=i.timeoutErrorMessage),r(new Ye(j,F.clarifyTimeoutError?Ye.ETIMEDOUT:Ye.ECONNABORTED,s,w)),w=null},l===void 0&&c.setContentType(null),"setRequestHeader"in w&&ee.forEach(c.toJSON(),function(j,F){w.setRequestHeader(F,j)}),ee.isUndefined(i.withCredentials)||(w.withCredentials=!!i.withCredentials),d&&d!=="json"&&(w.responseType=i.responseType),p&&([C,v]=Sc(p,!0),w.addEventListener("progress",C)),f&&w.upload&&([y,S]=Sc(f),w.upload.addEventListener("progress",y),w.upload.addEventListener("loadend",S)),(i.cancelToken||i.signal)&&(m=O=>{w&&(r(!O||O.type?new ds(null,s,w):O),w.abort(),w=null)},i.cancelToken&&i.cancelToken.subscribe(m),i.signal&&(i.signal.aborted?m():i.signal.addEventListener("abort",m)));const L=EC(i.url);if(L&&Cn.protocols.indexOf(L)===-1){r(new Ye("Unsupported protocol "+L+":",Ye.ERR_BAD_REQUEST,s));return}w.send(l||null)})},OC=(s,e)=>{const{length:n}=s=s?s.filter(Boolean):[];if(e||n){let r=new AbortController,i;const l=function(p){if(!i){i=!0,d();const m=p instanceof Error?p:this.reason;r.abort(m instanceof Ye?m:new ds(m instanceof Error?m.message:m))}};let c=e&&setTimeout(()=>{c=null,l(new Ye(`timeout ${e} of ms exceeded`,Ye.ETIMEDOUT))},e);const d=()=>{s&&(c&&clearTimeout(c),c=null,s.forEach(p=>{p.unsubscribe?p.unsubscribe(l):p.removeEventListener("abort",l)}),s=null)};s.forEach(p=>p.addEventListener("abort",l));const{signal:f}=r;return f.unsubscribe=()=>ee.asap(d),f}},LC=function*(s,e){let n=s.byteLength;if(n{const i=$C(s,e);let l=0,c,d=f=>{c||(c=!0,r&&r(f))};return new ReadableStream({async pull(f){try{const{done:p,value:m}=await i.next();if(p){d(),f.close();return}let y=m.byteLength;if(n){let C=l+=y;n(C)}f.enqueue(new Uint8Array(m))}catch(p){throw d(p),p}},cancel(f){return d(f),i.return()}},{highWaterMark:2})},xm=64*1024,{isFunction:wc}=ee,NC=(({Request:s,Response:e})=>({Request:s,Response:e}))(ee.global),{ReadableStream:Tm,TextEncoder:km}=ee.global,Rm=(s,...e)=>{try{return!!s(...e)}catch{return!1}},IC=s=>{s=ee.merge.call({skipUndefined:!0},NC,s);const{fetch:e,Request:n,Response:r}=s,i=e?wc(e):typeof fetch=="function",l=wc(n),c=wc(r);if(!i)return!1;const d=i&&wc(Tm),f=i&&(typeof km=="function"?(v=>x=>v.encode(x))(new km):async v=>new Uint8Array(await new n(v).arrayBuffer())),p=l&&d&&Rm(()=>{let v=!1;const x=new n(Cn.origin,{body:new Tm,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!x}),m=c&&d&&Rm(()=>ee.isReadableStream(new r("").body)),y={stream:m&&(v=>v.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!y[v]&&(y[v]=(x,w)=>{let R=x&&x[v];if(R)return R.call(x);throw new Ye(`Response type '${v}' is not supported`,Ye.ERR_NOT_SUPPORT,w)})});const C=async v=>{if(v==null)return 0;if(ee.isBlob(v))return v.size;if(ee.isSpecCompliantForm(v))return(await new n(Cn.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(ee.isArrayBufferView(v)||ee.isArrayBuffer(v))return v.byteLength;if(ee.isURLSearchParams(v)&&(v=v+""),ee.isString(v))return(await f(v)).byteLength},S=async(v,x)=>{const w=ee.toFiniteNumber(v.getContentLength());return w??C(x)};return async v=>{let{url:x,method:w,data:R,signal:L,cancelToken:O,timeout:j,onDownloadProgress:F,onUploadProgress:G,responseType:P,headers:K,withCredentials:he="same-origin",fetchOptions:Ee}=_m(v),ke=e||fetch;P=P?(P+"").toLowerCase():"text";let ze=OC([L,O&&O.toAbortSignal()],j),Be=null;const je=ze&&ze.unsubscribe&&(()=>{ze.unsubscribe()});let bt;try{if(G&&p&&w!=="get"&&w!=="head"&&(bt=await S(K,R))!==0){let z=new n(x,{method:"POST",body:R,duplex:"half"}),T;if(ee.isFormData(R)&&(T=z.headers.get("content-type"))&&K.setContentType(T),z.body){const[pe,fe]=Sm(bt,Sc(wm(G)));R=Am(z.body,xm,pe,fe)}}ee.isString(he)||(he=he?"include":"omit");const X=l&&"credentials"in n.prototype,de={...Ee,signal:ze,method:w.toUpperCase(),headers:K.normalize().toJSON(),body:R,duplex:"half",credentials:X?he:void 0};Be=l&&new n(x,de);let Ce=await(l?ke(Be,Ee):ke(x,de));const Z=m&&(P==="stream"||P==="response");if(m&&(F||Z&&je)){const z={};["status","statusText","headers"].forEach(me=>{z[me]=Ce[me]});const T=ee.toFiniteNumber(Ce.headers.get("content-length")),[pe,fe]=F&&Sm(T,Sc(wm(F),!0))||[];Ce=new r(Am(Ce.body,xm,pe,()=>{fe&&fe(),je&&je()}),z)}P=P||"text";let ge=await y[ee.findKey(y,P)||"text"](Ce,v);return!Z&&je&&je(),await new Promise((z,T)=>{vm(z,T,{data:ge,headers:$n.from(Ce.headers),status:Ce.status,statusText:Ce.statusText,config:v,request:Be})})}catch(X){throw je&&je(),X&&X.name==="TypeError"&&/Load failed|fetch/i.test(X.message)?Object.assign(new Ye("Network Error",Ye.ERR_NETWORK,v,Be),{cause:X.cause||X}):Ye.from(X,X&&X.code,v,Be)}}},jC=new Map,Dm=s=>{let e=s?s.env:{};const{fetch:n,Request:r,Response:i}=e,l=[r,i,n];let c=l.length,d=c,f,p,m=jC;for(;d--;)f=l[d],p=m.get(f),p===void 0&&m.set(f,p=d?new Map:IC(e)),m=p;return p};Dm();const uf={http:iC,xhr:DC,fetch:{get:Dm}};ee.forEach(uf,(s,e)=>{if(s){try{Object.defineProperty(s,"name",{value:e})}catch{}Object.defineProperty(s,"adapterName",{value:e})}});const Om=s=>`- ${s}`,zC=s=>ee.isFunction(s)||s===null||s===!1,Lm={getAdapter:(s,e)=>{s=ee.isArray(s)?s:[s];const{length:n}=s;let r,i;const l={};for(let c=0;c`adapter ${f} `+(p===!1?"is not supported by the environment":"is not available in the build"));let d=n?c.length>1?`since : -`+c.map(Om).join(` -`):" "+Om(c[0]):"as no adapter specified";throw new Ye("There is no suitable adapter to dispatch the request "+d,"ERR_NOT_SUPPORT")}return i},adapters:uf};function df(s){if(s.cancelToken&&s.cancelToken.throwIfRequested(),s.signal&&s.signal.aborted)throw new ds(null,s)}function $m(s){return df(s),s.headers=$n.from(s.headers),s.data=cf.call(s,s.transformRequest),["post","put","patch"].indexOf(s.method)!==-1&&s.headers.setContentType("application/x-www-form-urlencoded",!1),Lm.getAdapter(s.adapter||xo.adapter,s)(s).then(function(r){return df(s),r.data=cf.call(s,s.transformResponse,r),r.headers=$n.from(r.headers),r},function(r){return bm(r)||(df(s),r&&r.response&&(r.response.data=cf.call(s,s.transformResponse,r.response),r.response.headers=$n.from(r.response.headers))),Promise.reject(r)})}const Mm="1.12.2",Cc={};["object","boolean","number","function","string","symbol"].forEach((s,e)=>{Cc[s]=function(r){return typeof r===s||"a"+(e<1?"n ":" ")+s}});const Nm={};Cc.transitional=function(e,n,r){function i(l,c){return"[Axios v"+Mm+"] Transitional option '"+l+"'"+c+(r?". "+r:"")}return(l,c,d)=>{if(e===!1)throw new Ye(i(c," has been removed"+(n?" in "+n:"")),Ye.ERR_DEPRECATED);return n&&!Nm[c]&&(Nm[c]=!0,console.warn(i(c," has been deprecated since v"+n+" and will be removed in the near future"))),e?e(l,c,d):!0}},Cc.spelling=function(e){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};function HC(s,e,n){if(typeof s!="object")throw new Ye("options must be an object",Ye.ERR_BAD_OPTION_VALUE);const r=Object.keys(s);let i=r.length;for(;i-- >0;){const l=r[i],c=e[l];if(c){const d=s[l],f=d===void 0||c(d,l,s);if(f!==!0)throw new Ye("option "+l+" must be "+f,Ye.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Ye("Unknown option "+l,Ye.ERR_BAD_OPTION)}}const Ec={assertOptions:HC,validators:Cc},qr=Ec.validators;let Ti=class{constructor(e){this.defaults=e||{},this.interceptors={request:new pm,response:new pm}}async request(e,n){try{return await this._request(e,n)}catch(r){if(r instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const l=i.stack?i.stack.replace(/^.+\n/,""):"";try{r.stack?l&&!String(r.stack).endsWith(l.replace(/^.+\n.+\n/,""))&&(r.stack+=` -`+l):r.stack=l}catch{}}throw r}}_request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=xi(this.defaults,n);const{transitional:r,paramsSerializer:i,headers:l}=n;r!==void 0&&Ec.assertOptions(r,{silentJSONParsing:qr.transitional(qr.boolean),forcedJSONParsing:qr.transitional(qr.boolean),clarifyTimeoutError:qr.transitional(qr.boolean)},!1),i!=null&&(ee.isFunction(i)?n.paramsSerializer={serialize:i}:Ec.assertOptions(i,{encode:qr.function,serialize:qr.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Ec.assertOptions(n,{baseUrl:qr.spelling("baseURL"),withXsrfToken:qr.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let c=l&&ee.merge(l.common,l[n.method]);l&&ee.forEach(["delete","get","head","post","put","patch","common"],v=>{delete l[v]}),n.headers=$n.concat(c,l);const d=[];let f=!0;this.interceptors.request.forEach(function(x){typeof x.runWhen=="function"&&x.runWhen(n)===!1||(f=f&&x.synchronous,d.unshift(x.fulfilled,x.rejected))});const p=[];this.interceptors.response.forEach(function(x){p.push(x.fulfilled,x.rejected)});let m,y=0,C;if(!f){const v=[$m.bind(this),void 0];for(v.unshift(...d),v.push(...p),C=v.length,m=Promise.resolve(n);y{if(!r._listeners)return;let l=r._listeners.length;for(;l-- >0;)r._listeners[l](i);r._listeners=null}),this.promise.then=i=>{let l;const c=new Promise(d=>{r.subscribe(d),l=d}).then(i);return c.cancel=function(){r.unsubscribe(l)},c},e(function(l,c,d){r.reason||(r.reason=new ds(l,c,d),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const e=new AbortController,n=r=>{e.abort(r)};return this.subscribe(n),e.signal.unsubscribe=()=>this.unsubscribe(n),e.signal}static source(){let e;return{token:new Dw(function(i){e=i}),cancel:e}}};function PC(s){return function(n){return s.apply(null,n)}}function BC(s){return ee.isObject(s)&&s.isAxiosError===!0}const ff={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ff).forEach(([s,e])=>{ff[e]=s});function Im(s){const e=new Ti(s),n=Qg(Ti.prototype.request,e);return ee.extend(n,Ti.prototype,e,{allOwnKeys:!0}),ee.extend(n,e,null,{allOwnKeys:!0}),n.create=function(i){return Im(xi(s,i))},n}const Ft=Im(xo);Ft.Axios=Ti,Ft.CanceledError=ds,Ft.CancelToken=UC,Ft.isCancel=bm,Ft.VERSION=Mm,Ft.toFormData=bc,Ft.AxiosError=Ye,Ft.Cancel=Ft.CanceledError,Ft.all=function(e){return Promise.all(e)},Ft.spread=PC,Ft.isAxiosError=BC,Ft.mergeConfig=xi,Ft.AxiosHeaders=$n,Ft.formToJSON=s=>mm(ee.isHTMLForm(s)?new FormData(s):s),Ft.getAdapter=Lm.getAdapter,Ft.HttpStatusCode=ff,Ft.default=Ft;const{Axios:Ek,AxiosError:_k,CanceledError:Ak,isCancel:xk,CancelToken:Tk,VERSION:kk,all:Rk,Cancel:Dk,isAxiosError:Ok,spread:Lk,toFormData:$k,AxiosHeaders:Mk,HttpStatusCode:Nk,formToJSON:Ik,getAdapter:jk,mergeConfig:zk}=Ft,hf="g7.identity.redirectStash",_c=dt("IdentityGuardInterceptor");class yt{static setLauncher(e){this.launcher=e}static hasLauncher(){return this.launcher!==null}static markDomainNoticeShown(){this.domainNoticeShown=!0}static consumeDomainNoticeShown(){const e=this.domainNoticeShown;return this.domainNoticeShown=!1,e}static resolveDeferred(e){const n=this.deferredResolver;if(!n){_c.warn("IdentityGuardInterceptor.resolveDeferred 호출됐지만 대기 중인 launcher 가 없습니다. 모달이 launcher 외부에서 열렸는지 확인하세요.");return}this.deferredResolver=null,n(e)}static createDeferred(){if(this.deferredResolver){const e=this.deferredResolver;this.deferredResolver=null,e({status:"cancelled"})}return new Promise(e=>{this.deferredResolver=e})}static isIdentityRequired(e,n){return e===428&&typeof n=="object"&&n!==null&&n.error_code==="identity_verification_required"}static async handle(e,n,r){this.domainNoticeShown=!1;const i=this.launcher??GC,c=!!(r&&(r.email||r.phone))?{...e.verification,target:r}:e.verification,d=await i(c);if(d.status!=="verified")return null;const f=c.return_request;if(!f)return null;const p=qC(f.url,d.token);return fetch(p,{method:f.method,headers:n?.headers??{Accept:"application/json","Content-Type":"application/json"},body:n?.body,credentials:n?.credentials??"same-origin"})}static redirectExternally(e){const n=e.redirect_url;if(!n)return _c.error("redirectExternally 호출 시 verification.redirect_url 이 없습니다. payload:",e),Promise.resolve({status:"failed",failureCode:"MISSING_REDIRECT_URL",reason:"verification.redirect_url is required for external_redirect flow"});if(typeof window<"u"){const r={return_url:window.location.href,payload:e,stashed_at:Date.now()};try{window.sessionStorage?.setItem(hf,JSON.stringify(r))}catch(i){_c.warn("sessionStorage 접근 실패 — stash 없이 redirect 합니다.",i)}window.location.href=n}return new Promise(()=>{})}static reset(){if(this.deferredResolver){const e=this.deferredResolver;this.deferredResolver=null;try{e({status:"cancelled"})}catch{}}this.launcher=null,this.domainNoticeShown=!1}}$(yt,"launcher",null),$(yt,"deferredResolver",null),$(yt,"domainNoticeShown",!1);function qC(s,e){if(!e)return s;try{const n=typeof window<"u"?window.location.origin:"http://localhost",r=new URL(s,n);return r.searchParams.set("verification_token",e),/^https?:\/\//i.test(s)?r.toString():`${r.pathname}${r.search}${r.hash}`}catch{const n=s.includes("?")?"&":"?";return`${s}${n}verification_token=${encodeURIComponent(e)}`}}const GC=async s=>{if(typeof window>"u")return{status:"cancelled"};if(s.render_hint==="external_redirect"||s.redirect_url)return yt.redirectExternally(s);const e=window.G7Core;if(!e?.dispatch)return console.error("[IdentityGuardInterceptor] defaultLauncher: G7Core 가 초기화되지 않아 본인인증 흐름을 시작할 수 없습니다."),{status:"failed",failureCode:"G7_NOT_READY"};try{await e.dispatch({handler:"toast",params:{message:"본인 확인이 필요합니다.",variant:"warning"}})}catch{}const n=window.location.href,r={return_url:n,payload:s,stashed_at:Date.now()};try{window.sessionStorage?.setItem(hf,JSON.stringify(r))}catch{}const i=`/identity/challenge?return=${encodeURIComponent(n)}`;try{await e.dispatch({handler:"navigate",params:{path:i}})}catch(l){_c.warn("navigate 실패 — window.location 으로 폴백",l),window.location.href=i}return new Promise(()=>{})},jm=dt("ApiClient");function pf(){return typeof window<"u"&&window.__G7_DEVTOOLS__?window.__G7_DEVTOOLS__:null}class FC{constructor(e={}){$(this,"client");$(this,"config");$(this,"TOKEN_KEY","auth_token");this.config={baseURL:e.baseURL||"/api",timeout:e.timeout||3e4,onTokenExpired:e.onTokenExpired,onUnauthorized:e.onUnauthorized,onError:e.onError},this.client=Ft.create({baseURL:this.config.baseURL,timeout:this.config.timeout,headers:{"Content-Type":"application/json",Accept:"application/json"},paramsSerializer:{serialize:n=>{const r=[];for(const[i,l]of Object.entries(n))if(l!=null)if(Array.isArray(l)){const c=i.endsWith("[]")?i:`${i}[]`;for(const d of l)r.push(`${encodeURIComponent(c)}=${encodeURIComponent(String(d))}`)}else r.push(`${encodeURIComponent(i)}=${encodeURIComponent(String(l))}`);return r.join("&")}}}),this.setupInterceptors()}setToken(e){if(typeof e!="string"||e===""){jm.warn("Ignoring invalid auth token — token must be a non-empty string.");return}typeof window<"u"&&localStorage.setItem(this.TOKEN_KEY,e)}getToken(){return typeof window<"u"?localStorage.getItem(this.TOKEN_KEY):null}removeToken(){typeof window<"u"&&localStorage.removeItem(this.TOKEN_KEY)}setupInterceptors(){this.client.interceptors.request.use(e=>{e.url?.startsWith("/api")&&e.baseURL==="/api"&&(e.baseURL="");const n=this.getToken();if(n&&e.headers&&!this.isCrossOriginRequest(e.url)&&(e.headers.Authorization=`Bearer ${n}`),typeof window<"u"&&e.headers){const i=localStorage.getItem("g7_locale");i&&(e.headers["Accept-Language"]=i)}const r=pf();if(r?.isEnabled()){const i=this.buildFullUrl(e),l=(e.method||"GET").toUpperCase(),c=r.trackRequest(i,l,{requestBody:e.data});e._devToolsRequestId=c}return e},e=>Promise.reject(e)),this.client.interceptors.response.use(e=>{const n=e.config,r=n._devToolsRequestId;if(r){const i=pf();i?.isEnabled()&&i.completeRequest(r,e.status,e.data),n._devToolsRequestId=null}return e},async e=>{const n=e.config,r=n?.url||"",l=["/auth/","/layouts/"].some(c=>r.includes(c));if(e.response?.status===401&&!n?._retry&&!l){if(n._retry=!0,await Yn.getInstance().refreshToken()){const f=this.getToken();return f&&(n.headers.Authorization=`Bearer ${f}`),n._devToolsRequestId=null,this.client(n)}return this.completeDevToolsRequest(n,e),this.removeToken(),this.config.onUnauthorized&&this.config.onUnauthorized(),Promise.reject(e)}if(e.response?.status===401&&l)return this.completeDevToolsRequest(n,e),Promise.reject(e);if(yt.isIdentityRequired(e.response?.status,e.response?.data)){this.completeDevToolsRequest(n,e);const c={},d=n?.headers??{};for(const[C,S]of Object.entries(d))typeof S=="string"&&(c[C]=S);let f;n?.data!==void 0&&n?.data!==null&&(f=typeof n.data=="string"?n.data:JSON.stringify(n.data),c["Content-Type"]=c["Content-Type"]??"application/json");const p=n?.identity_target,m=await yt.handle(e.response.data,{headers:c,body:f,credentials:"same-origin"},p);if(!m)return Promise.reject(e);let y=null;try{y=await m.json()}catch{y=null}return m.ok?{...e.response,status:m.status,data:y}:Promise.reject(Object.assign(new Error("replay failed"),{response:{status:m.status,data:y}}))}return e.response?.status===403?(this.completeDevToolsRequest(n,e),this.callOnError(e),Promise.reject(e)):(this.completeDevToolsRequest(n,e),e.response&&this.callOnError(e),Promise.reject(e))})}async get(e,n){return(await this.client.get(e,n)).data}async post(e,n,r){return(await this.client.post(e,n,r)).data}async put(e,n,r){return(await this.client.put(e,n,r)).data}async patch(e,n,r){return(await this.client.patch(e,n,r)).data}async delete(e,n){return(await this.client.delete(e,n)).data}getInstance(){return this.client}setOnUnauthorized(e){this.config.onUnauthorized=e}setOnError(e){this.config.onError=e}completeDevToolsRequest(e,n){if(!e?._devToolsRequestId)return;const r=pf();if(!r?.isEnabled())return;const i=e._devToolsRequestId;e._devToolsRequestId=null,n.response?r.completeRequest(i,n.response.status,n.response.data):n.request?r.failRequest(i,n.message||"Network error"):r.failRequest(i,n.message||"Request error")}isCrossOriginRequest(e){if(!e||typeof window>"u"||!window.location||!/^(https?:)?\/\//i.test(e))return!1;try{return new URL(e,window.location.href).origin!==window.location.origin}catch{return!1}}buildFullUrl(e){let n=e.url||"";if(e.baseURL&&!n.startsWith("http")&&(n=`${e.baseURL}${n.startsWith("/")?"":"/"}${n}`),e.params&&typeof e.params=="object"){const r=e.params,i=[];for(const[l,c]of Object.entries(r))if(c!=null)if(Array.isArray(c)){const d=l.endsWith("[]")?l:`${l}[]`;for(const f of c)i.push(`${encodeURIComponent(d)}=${encodeURIComponent(String(f))}`)}else i.push(`${encodeURIComponent(l)}=${encodeURIComponent(String(c))}`);i.length>0&&(n+=(n.includes("?")?"&":"?")+i.join("&"))}return n}callOnError(e){if(!this.config.onError)return;const n={status:e.response?.status||0,message:e.response?.data?.message||e.message||"Unknown error",data:e.response?.data,statusText:e.response?.statusText};try{this.config.onError(n)}catch(r){jm.error("Error in onError handler:",r)}}}let gf=null;function Wn(){return gf||(gf=new FC),gf}const ko=dt("AuthManager");function ki(s,e,n,r){try{window.G7Core?.devTools?.trackAuthEvent?.(s,e,n,r)}catch{}}const zm={admin:{type:"admin",loginPath:"/admin/login",defaultPath:"/admin",userEndpoint:"/admin/auth/user",loginEndpoint:"/auth/admin/login",logoutEndpoint:"/admin/auth/logout",refreshEndpoint:"/admin/auth/refresh",twoFactorEndpoint:"/auth/admin/login/two-factor",twoFactorResendEndpoint:"/auth/admin/login/two-factor/resend"},user:{type:"user",loginPath:"/login",defaultPath:"/",userEndpoint:"/auth/user",loginEndpoint:"/auth/login",logoutEndpoint:"/auth/logout",refreshEndpoint:"/auth/refresh",twoFactorEndpoint:"/auth/login/two-factor",twoFactorResendEndpoint:"/auth/login/two-factor/resend"}},Or=class Or{constructor(){$(this,"state");$(this,"config");$(this,"isRefreshing",!1);$(this,"refreshPromise",null);$(this,"eventHandlers",new Map);this.state={isAuthenticated:!1,user:null,type:null},this.config=new Map,this.config.set("admin",zm.admin),this.config.set("user",zm.user)}static getInstance(){return Or.instance||(Or.instance=new Or),Or.instance}on(e,n){this.eventHandlers.has(e)||this.eventHandlers.set(e,[]),this.eventHandlers.get(e).push(n)}emit(e,...n){const r=this.eventHandlers.get(e);r&&r.forEach(i=>i(...n))}isAuthenticated(){return this.state.isAuthenticated}getUser(){return this.state.user}getAuthType(){return this.state.type}async checkAuth(e){const n=Wn();if(!n.getToken())return this.clearState(),!1;const i=this.config.get(e);if(!i)return ko.error(`Unknown auth type: ${e}`),!1;try{const l=await n.get(i.userEndpoint);return l.success&&l.data?(this.state={isAuthenticated:!0,user:l.data,type:e},this.emit("authStateChange",this.state),!0):(this.clearState(),!1)}catch(l){return l.response?.status===401&&await this.refreshToken()?this.checkAuth(e):(this.clearState(),!1)}}async preloadAuth(e){try{return await this.checkAuth(e)}catch(n){return ko.warn(`Preload auth failed for type ${e}:`,n),!1}}async login(e,n,r){const i=Wn(),l=this.config.get(e);if(!l)throw new Error(`Unknown auth type: ${e}`);try{const c=r?.headers?{headers:r.headers}:void 0,d=await i.post(l.loginEndpoint,n,c);if(d.success&&d.data){if(d.data.two_factor_required===!0)return ki("login",!0,void 0,{type:e,two_factor:!0}),{status:"two_factor_required",challenge:{challengeId:String(d.data.challenge_id??""),providerId:String(d.data.provider_id??""),expiresAt:d.data.expires_at??null}};if(d.data.token&&d.data.user)return{status:"authenticated",user:this.establishSession(e,d.data.token,d.data.user)}}throw new Error("Login failed")}catch(c){throw this.clearState(),this.enhanceAuthError(c,e,"Login failed")}}async completeTwoFactor(e,n,r){const i=Wn(),l=this.config.get(e);if(!l)throw new Error(`Unknown auth type: ${e}`);try{const c=r?.headers?{headers:r.headers}:void 0,d=await i.post(l.twoFactorEndpoint,{challenge_id:n.challengeId,code:n.code},c);if(d.success&&d.data?.token&&d.data?.user)return this.establishSession(e,d.data.token,d.data.user);throw new Error("Login failed")}catch(c){throw this.clearState(),this.enhanceAuthError(c,e,"Login failed")}}async resendTwoFactor(e,n,r){const i=Wn(),l=this.config.get(e);if(!l)throw new Error(`Unknown auth type: ${e}`);try{const c=r?.headers?{headers:r.headers}:void 0,d=await i.post(l.twoFactorResendEndpoint,{challenge_id:n.challengeId},c);if(d.success&&d.data?.challenge_id)return{challengeId:String(d.data.challenge_id),providerId:String(d.data.provider_id??""),expiresAt:d.data.expires_at??null};throw new Error("Resend failed")}catch(c){throw this.enhanceAuthError(c,e,"Resend failed")}}establishSession(e,n,r){Wn().setToken(n);const l=r.language,c=localStorage.getItem(Or.LOCALE_STORAGE_KEY),d=l&&l!==c;if(l)try{localStorage.setItem(Or.LOCALE_STORAGE_KEY,l)}catch(f){ko.warn("Failed to save user language to localStorage:",f)}return this.state={isAuthenticated:!0,user:r,type:e},this.emit("login",this.state),this.emit("authStateChange",this.state),ki("login",!0,void 0,{userId:r.uuid,email:r.email,type:e}),d&&window.__templateApp&&window.__templateApp.changeLocale(l),r}enhanceAuthError(e,n,r){const i=e?.response?.data?.message,l=new Error(i||e?.message||r);return l.response=e?.response,l.status=e?.response?.status,l.code=e?.code,ki("login",!1,l.message,{type:n,status:e?.response?.status}),l}async logout(){const e=Wn(),n=this.state.type?this.config.get(this.state.type):null;try{n&&await e.post(n.logoutEndpoint)}catch(r){ko.warn("Logout API call failed:",r)}finally{e.removeToken();const r={...this.state};if(this.clearState(),this.emit("logout",r),this.emit("authStateChange",this.state),ki("logout",!0,void 0,{previousType:r.type}),n&&r.type){const i=window.location.pathname+window.location.search;window.location.href=this.getLoginRedirectUrl(r.type,i)}}}async refreshToken(){if(this.isRefreshing&&this.refreshPromise)return this.refreshPromise;this.isRefreshing=!0,this.refreshPromise=this.doRefreshToken();try{return await this.refreshPromise}finally{this.isRefreshing=!1,this.refreshPromise=null}}async doRefreshToken(){const e=this.state.type;if(!e)return!1;const n=this.config.get(e);if(!n)return!1;const r=Wn();try{const i=await r.post(n.refreshEndpoint);return i.success&&i.data?.token?(r.setToken(i.data.token),this.emit("tokenRefreshed"),ki("token-refresh",!0,void 0,{type:e}),!0):(ki("token-refresh",!1,"No token in response",{type:e}),!1)}catch(i){return ko.error("Token refresh failed:",i),ki("token-refresh",!1,i instanceof Error?i.message:"Unknown error",{type:e}),!1}}getLoginRedirectUrl(e,n,r){const i=this.config.get(e);if(!i)return"/login";const l=encodeURIComponent(n);let c=`${i.loginPath}?redirect=${l}`;return r&&(c+=`&reason=${encodeURIComponent(r)}`),c}updateConfig(e,n){if(n.loginPath!==void 0){const i=n.loginPath;if(!i.startsWith("/")||i.startsWith("//"))throw new Error(`AuthManager.updateConfig: loginPath must be a same-origin path starting with '/' (got: ${i})`)}const r=this.config.get(e);r&&this.config.set(e,{...r,...n})}getRedirectUrl(e){const r=this.config.get(e)?.defaultPath||"/",l=new URLSearchParams(window.location.search).get("redirect");if(l)try{const c=decodeURIComponent(l);if(c.startsWith("/"))return c}catch{}return r}getConfig(e){return this.config.get(e)}clearState(){this.state={isAuthenticated:!1,user:null,type:null}}static resetInstance(){Or.instance=null}};$(Or,"instance"),$(Or,"LOCALE_STORAGE_KEY","g7_locale");let Yn=Or;const Hm={401:{handler:"navigate",params:{path:"{{auth.loginPath}}"}},403:{handler:"toast",params:{type:"error",message:"{{error.message}}"}},404:{handler:"toast",params:{type:"error",message:"{{error.message}}"}},422:{handler:"toast",params:{type:"error",message:"{{error.message}}"}},default:{handler:"toast",params:{type:"error",message:"{{error.message}}"}}},oa={findHandler(s,e){if(s){if(s[e])return s[e];if(s[String(e)])return s[String(e)];if(s.default)return s.default}},normalizeOnError(s){return s?Array.isArray(s)?s:[s]:[]},injectErrorCode(s,e,n){if(s.handler!=="showErrorPage"||s.params?.errorCode!==void 0)return s;const r=typeof e=="string"?parseInt(e,10):e,i=isNaN(r)?n:r;return i===void 0?s:{...s,params:{...s.params,errorCode:i}}}},xr=dt("ErrorHandlingResolver"),Ba=class Ba{constructor(){$(this,"templateErrorHandling",null);$(this,"layoutErrorHandling",null);$(this,"executeAction",null)}static getInstance(){return Ba.instance||(Ba.instance=new Ba),Ba.instance}static resetInstance(){Ba.instance=null}setTemplateConfig(e){this.templateErrorHandling=e,xr.log("Template config set:",e)}setLayoutConfig(e){this.layoutErrorHandling=e,xr.log("Layout config set:",e)}setActionExecutor(e){this.executeAction=e}resolve(e,n={}){const{errorHandling:r,onError:i}=n;xr.log("Resolving error:",e,{hasActionErrorHandling:!!r,hasActionOnError:!!i,hasLayoutConfig:!!this.layoutErrorHandling,hasTemplateConfig:!!this.templateErrorHandling});let l=oa.findHandler(r,e);if(l){const c=this.getMatchedKey(r,e);return{handler:oa.injectErrorCode(l,c,e),level:"action",matchedKey:c}}if(i){const c=oa.normalizeOnError(i);if(c.length>0)return{handler:c.length===1?c[0]:{handler:"sequence",actions:c},level:"action",matchedKey:"onError"}}if(l=oa.findHandler(this.layoutErrorHandling||void 0,e),l){const c=this.getMatchedKey(this.layoutErrorHandling,e);return{handler:oa.injectErrorCode(l,c,e),level:"layout",matchedKey:c}}if(l=oa.findHandler(this.templateErrorHandling||void 0,e),l){const c=this.getMatchedKey(this.templateErrorHandling,e);return{handler:oa.injectErrorCode(l,c,e),level:"template",matchedKey:c}}if(l=oa.findHandler(Hm,e),l){const c=this.getMatchedKey(Hm,e);return{handler:oa.injectErrorCode(l,c,e),level:"system",matchedKey:c}}return{handler:null,level:null,matchedKey:null}}async execute(e,n){if(!this.executeAction){xr.error("Action executor is not set");return}xr.log("Executing handler:",e.handler,{errorContext:n});try{return await this.executeAction(e,{error:n})}catch(r){throw xr.error("Failed to execute handler:",r),r}}async resolveAndExecute(e,n,r={}){const i=this.resolve(e,r);if(xr.log("Resolve result:",{errorCode:e,handler:i.handler?.handler,level:i.level,matchedKey:i.matchedKey}),!i.handler)return xr.warn("No handler found for error:",e),{handled:!1};try{return{handled:!0,result:await this.execute(i.handler,n)}}catch(l){return xr.error("Handler execution failed:",l),{handled:!1}}}getMatchedKey(e,n){return e[n]?n:e[String(n)]?String(n):"default"}clearLayoutConfig(){this.layoutErrorHandling=null,xr.log("Layout config cleared")}clearAllConfig(){this.templateErrorHandling=null,this.layoutErrorHandling=null,xr.log("All config cleared")}getConfigStatus(){return{hasTemplate:this.templateErrorHandling!==null,hasLayout:this.layoutErrorHandling!==null,hasExecutor:this.executeAction!==null}}};$(Ba,"instance",null);let mf=Ba;function Tr(){return mf.getInstance()}function Ro(s,e){const n={...s};for(const r of Object.keys(e))r in n?n[r]!==null&&typeof n[r]=="object"&&!Array.isArray(n[r])&&e[r]!==null&&typeof e[r]=="object"&&!Array.isArray(e[r])&&(n[r]=Ro(n[r],e[r])):n[r]=e[r];return n}var yf={exports:{}},Do={};/** +`+u.stack}}var mt=Object.prototype.hasOwnProperty,Dt=s.unstable_scheduleCallback,zt=s.unstable_cancelCallback,kn=s.unstable_shouldYield,hr=s.unstable_requestPaint,Ot=s.unstable_now,Mi=s.unstable_getCurrentPriorityLevel,ua=s.unstable_ImmediatePriority,bn=s.unstable_UserBlockingPriority,Mn=s.unstable_NormalPriority,it=s.unstable_LowPriority,Un=s.unstable_IdlePriority,vn=s.log,da=s.unstable_setDisableYieldValue,pr=null,un=null;function Rn(t){if(typeof vn=="function"&&da(t),un&&typeof un.setStrictMode=="function")try{un.setStrictMode(pr,t)}catch{}}var dn=Math.clz32?Math.clz32:ce,V=Math.log,ie=Math.LN2;function ce(t){return t>>>=0,t===0?32:31-(V(t)/ie|0)|0}var Z=256,ve=262144,pe=4194304;function Ee(t){var a=t&42;if(a!==0)return a;switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function xe(t,a,o){var u=t.pendingLanes;if(u===0)return 0;var p=0,g=t.suspendedLanes,w=t.pingedLanes;t=t.warmLanes;var R=u&134217727;return R!==0?(u=R&~g,u!==0?p=Ee(u):(w&=R,w!==0?p=Ee(w):o||(o=R&~t,o!==0&&(p=Ee(o))))):(R=u&~g,R!==0?p=Ee(R):w!==0?p=Ee(w):o||(o=u&~t,o!==0&&(p=Ee(o)))),p===0?0:a!==0&&a!==p&&(a&g)===0&&(g=p&-p,o=a&-a,g>=o||g===32&&(o&4194048)!==0)?a:p}function Ke(t,a){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&a)===0}function ke(t,a){switch(t){case 1:case 2:case 4:case 8:case 64:return a+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return a+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Me(){var t=pe;return pe<<=1,(pe&62914560)===0&&(pe=4194304),t}function Re(t){for(var a=[],o=0;31>o;o++)a.push(t);return a}function tt(t,a){t.pendingLanes|=a,a!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function Pe(t,a,o,u,p,g){var w=t.pendingLanes;t.pendingLanes=o,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=o,t.entangledLanes&=o,t.errorRecoveryDisabledLanes&=o,t.shellSuspendCounter=0;var R=t.entanglements,P=t.expirationTimes,X=t.hiddenUpdates;for(o=w&~o;0"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var vh=/[\n"\\]/g;function qn(t){return t.replace(vh,function(a){return"\\"+a.charCodeAt(0).toString(16)+" "})}function Os(t,a,o,u,p,g,w,R){t.name="",w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"?t.type=w:t.removeAttribute("type"),a!=null?w==="number"?(a===0&&t.value===""||t.value!=a)&&(t.value=""+On(a)):t.value!==""+On(a)&&(t.value=""+On(a)):w!=="submit"&&w!=="reset"||t.removeAttribute("value"),a!=null?ha(t,w,On(a)):o!=null?ha(t,w,On(o)):u!=null&&t.removeAttribute("value"),p==null&&g!=null&&(t.defaultChecked=!!g),p!=null&&(t.checked=p&&typeof p!="function"&&typeof p!="symbol"),R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"?t.name=""+On(R):t.removeAttribute("name")}function ji(t,a,o,u,p,g,w,R){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(t.type=g),a!=null||o!=null){if(!(g!=="submit"&&g!=="reset"||a!=null)){al(t);return}o=o!=null?""+On(o):"",a=a!=null?""+On(a):o,R||a===t.value||(t.value=a),t.defaultValue=a}u=u??p,u=typeof u!="function"&&typeof u!="symbol"&&!!u,t.checked=R?t.checked:!!u,t.defaultChecked=!!u,w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"&&(t.name=w),al(t)}function ha(t,a,o){a==="number"&&Fa(t.ownerDocument)===t||t.defaultValue===""+o||(t.defaultValue=""+o)}function Va(t,a,o,u){if(t=t.options,a){a={};for(var p=0;p"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),cl=!1;if(Ir)try{var zi={};Object.defineProperty(zi,"passive",{get:function(){cl=!0}}),window.addEventListener("test",zi,zi),window.removeEventListener("test",zi,zi)}catch{cl=!1}var Jr=null,ul=null,$s=null;function cu(){if($s)return $s;var t,a=ul,o=a.length,u,p="value"in Jr?Jr.value:Jr.textContent,g=p.length;for(t=0;t=ne),We=" ",ft=!1;function vt(t,a){switch(t){case"keyup":return $.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Vt(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Hr=!1;function jh(t,a){switch(t){case"compositionend":return Vt(a);case"keypress":return a.which!==32?null:(ft=!0,We);case"textInput":return t=a.data,t===We&&ft?null:t;default:return null}}function mu(t,a){if(Hr)return t==="compositionend"||!j&&vt(t,a)?(t=cu(),$s=ul=Jr=null,Hr=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1=a)return{node:o,offset:a-t};t=u}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=qb(o)}}function Fb(t,a){return t&&a?t===a?!0:t&&t.nodeType===3?!1:a&&a.nodeType===3?Fb(t,a.parentNode):"contains"in t?t.contains(a):t.compareDocumentPosition?!!(t.compareDocumentPosition(a)&16):!1:!1}function Vb(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var a=Fa(t.document);a instanceof t.HTMLIFrameElement;){try{var o=typeof a.contentWindow.location.href=="string"}catch{o=!1}if(o)t=a.contentWindow;else break;a=Fa(t.document)}return a}function Bh(t){var a=t&&t.nodeName&&t.nodeName.toLowerCase();return a&&(a==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||a==="textarea"||t.contentEditable==="true")}var ek=Ir&&"documentMode"in document&&11>=document.documentMode,js=null,qh=null,Sl=null,Gh=!1;function Kb(t,a,o){var u=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Gh||js==null||js!==Fa(u)||(u=js,"selectionStart"in u&&Bh(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),Sl&&vl(Sl,u)||(Sl=u,u=ld(qh,"onSelect"),0>=w,p-=w,Qr=1<<32-dn(a)+p|o<Ze?(ut=Ne,Ne=null):ut=Ne.sibling;var wt=J(K,Ne,Y[Ze],oe);if(wt===null){Ne===null&&(Ne=ut);break}t&&Ne&&wt.alternate===null&&a(K,Ne),F=g(wt,F,Ze),St===null?Be=wt:St.sibling=wt,St=wt,Ne=ut}if(Ze===Y.length)return o(K,Ne),ht&&ya(K,Ze),Be;if(Ne===null){for(;ZeZe?(ut=Ne,Ne=null):ut=Ne.sibling;var bi=J(K,Ne,wt.value,oe);if(bi===null){Ne===null&&(Ne=ut);break}t&&Ne&&bi.alternate===null&&a(K,Ne),F=g(bi,F,Ze),St===null?Be=bi:St.sibling=bi,St=bi,Ne=ut}if(wt.done)return o(K,Ne),ht&&ya(K,Ze),Be;if(Ne===null){for(;!wt.done;Ze++,wt=Y.next())wt=le(K,wt.value,oe),wt!==null&&(F=g(wt,F,Ze),St===null?Be=wt:St.sibling=wt,St=wt);return ht&&ya(K,Ze),Be}for(Ne=u(Ne);!wt.done;Ze++,wt=Y.next())wt=te(Ne,K,Ze,wt.value,oe),wt!==null&&(t&&wt.alternate!==null&&Ne.delete(wt.key===null?Ze:wt.key),F=g(wt,F,Ze),St===null?Be=wt:St.sibling=wt,St=wt);return t&&Ne.forEach(function(SR){return a(K,SR)}),ht&&ya(K,Ze),Be}function Nt(K,F,Y,oe){if(typeof Y=="object"&&Y!==null&&Y.type===x&&Y.key===null&&(Y=Y.props.children),typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case S:e:{for(var Be=Y.key;F!==null;){if(F.key===Be){if(Be=Y.type,Be===x){if(F.tag===7){o(K,F.sibling),oe=p(F,Y.props.children),oe.return=K,K=oe;break e}}else if(F.elementType===Be||typeof Be=="object"&&Be!==null&&Be.$$typeof===W&&ts(Be)===F.type){o(K,F.sibling),oe=p(F,Y.props),xl(oe,Y),oe.return=K,K=oe;break e}o(K,F);break}else a(K,F);F=F.sibling}Y.type===x?(oe=Xi(Y.props.children,K.mode,oe,Y.key),oe.return=K,K=oe):(oe=Au(Y.type,Y.key,Y.props,null,K.mode,oe),xl(oe,Y),oe.return=K,K=oe)}return w(K);case _:e:{for(Be=Y.key;F!==null;){if(F.key===Be)if(F.tag===4&&F.stateNode.containerInfo===Y.containerInfo&&F.stateNode.implementation===Y.implementation){o(K,F.sibling),oe=p(F,Y.children||[]),oe.return=K,K=oe;break e}else{o(K,F);break}else a(K,F);F=F.sibling}oe=Jh(Y,K.mode,oe),oe.return=K,K=oe}return w(K);case W:return Y=ts(Y),Nt(K,F,Y,oe)}if(Et(Y))return Oe(K,F,Y,oe);if(je(Y)){if(Be=je(Y),typeof Be!="function")throw Error(r(150));return Y=Be.call(Y),Ge(K,F,Y,oe)}if(typeof Y.then=="function")return Nt(K,F,Lu(Y),oe);if(Y.$$typeof===k)return Nt(K,F,ku(K,Y),oe);$u(K,Y)}return typeof Y=="string"&&Y!==""||typeof Y=="number"||typeof Y=="bigint"?(Y=""+Y,F!==null&&F.tag===6?(o(K,F.sibling),oe=p(F,Y),oe.return=K,K=oe):(o(K,F),oe=Xh(Y,K.mode,oe),oe.return=K,K=oe),w(K)):o(K,F)}return function(K,F,Y,oe){try{Al=0;var Be=Nt(K,F,Y,oe);return Ws=null,Be}catch(Ne){if(Ne===Ks||Ne===Du)throw Ne;var St=nr(29,Ne,null,K.mode);return St.lanes=oe,St.return=K,St}finally{}}}var rs=mv(!0),yv=mv(!1),ti=!1;function cp(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function up(t,a){t=t.updateQueue,a.updateQueue===t&&(a.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function ni(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function ri(t,a,o){var u=t.updateQueue;if(u===null)return null;if(u=u.shared,(_t&2)!==0){var p=u.pending;return p===null?a.next=a:(a.next=p.next,p.next=a),u.pending=a,a=_u(t),ev(t,null,o),a}return Eu(t,u,a,o),_u(t)}function Tl(t,a,o){if(a=a.updateQueue,a!==null&&(a=a.shared,(o&4194048)!==0)){var u=a.lanes;u&=t.pendingLanes,o|=u,a.lanes=o,Ce(t,o)}}function dp(t,a){var o=t.updateQueue,u=t.alternate;if(u!==null&&(u=u.updateQueue,o===u)){var p=null,g=null;if(o=o.firstBaseUpdate,o!==null){do{var w={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};g===null?p=g=w:g=g.next=w,o=o.next}while(o!==null);g===null?p=g=a:g=g.next=a}else p=g=a;o={baseState:u.baseState,firstBaseUpdate:p,lastBaseUpdate:g,shared:u.shared,callbacks:u.callbacks},t.updateQueue=o;return}t=o.lastBaseUpdate,t===null?o.firstBaseUpdate=a:t.next=a,o.lastBaseUpdate=a}var fp=!1;function kl(){if(fp){var t=Vs;if(t!==null)throw t}}function Rl(t,a,o,u){fp=!1;var p=t.updateQueue;ti=!1;var g=p.firstBaseUpdate,w=p.lastBaseUpdate,R=p.shared.pending;if(R!==null){p.shared.pending=null;var P=R,X=P.next;P.next=null,w===null?g=X:w.next=X,w=P;var re=t.alternate;re!==null&&(re=re.updateQueue,R=re.lastBaseUpdate,R!==w&&(R===null?re.firstBaseUpdate=X:R.next=X,re.lastBaseUpdate=P))}if(g!==null){var le=p.baseState;w=0,re=X=P=null,R=g;do{var J=R.lane&-536870913,te=J!==R.lane;if(te?(ct&J)===J:(u&J)===J){J!==0&&J===Fs&&(fp=!0),re!==null&&(re=re.next={lane:0,tag:R.tag,payload:R.payload,callback:null,next:null});e:{var Oe=t,Ge=R;J=a;var Nt=o;switch(Ge.tag){case 1:if(Oe=Ge.payload,typeof Oe=="function"){le=Oe.call(Nt,le,J);break e}le=Oe;break e;case 3:Oe.flags=Oe.flags&-65537|128;case 0:if(Oe=Ge.payload,J=typeof Oe=="function"?Oe.call(Nt,le,J):Oe,J==null)break e;le=y({},le,J);break e;case 2:ti=!0}}J=R.callback,J!==null&&(t.flags|=64,te&&(t.flags|=8192),te=p.callbacks,te===null?p.callbacks=[J]:te.push(J))}else te={lane:J,tag:R.tag,payload:R.payload,callback:R.callback,next:null},re===null?(X=re=te,P=le):re=re.next=te,w|=J;if(R=R.next,R===null){if(R=p.shared.pending,R===null)break;te=R,R=te.next,te.next=null,p.lastBaseUpdate=te,p.shared.pending=null}}while(!0);re===null&&(P=le),p.baseState=P,p.firstBaseUpdate=X,p.lastBaseUpdate=re,g===null&&(p.shared.lanes=0),li|=w,t.lanes=w,t.memoizedState=le}}function bv(t,a){if(typeof t!="function")throw Error(r(191,t));t.call(a)}function vv(t,a){var o=t.callbacks;if(o!==null)for(t.callbacks=null,t=0;tg?g:8;var w=Q.T,R={};Q.T=R,Op(t,!1,a,o);try{var P=p(),X=Q.S;if(X!==null&&X(R,P),P!==null&&typeof P=="object"&&typeof P.then=="function"){var re=ck(P,u);Ll(t,a,re,or(t))}else Ll(t,a,u,or(t))}catch(le){Ll(t,a,{then:function(){},status:"rejected",reason:le},or())}finally{ue.p=g,w!==null&&R.types!==null&&(w.types=R.types),Q.T=w}}function gk(){}function Rp(t,a,o,u){if(t.tag!==5)throw Error(r(476));var p=Jv(t).queue;Xv(t,p,a,De,o===null?gk:function(){return Qv(t),o(u)})}function Jv(t){var a=t.memoizedState;if(a!==null)return a;a={memoizedState:De,baseState:De,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:wa,lastRenderedState:De},next:null};var o={};return a.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:wa,lastRenderedState:o},next:null},t.memoizedState=a,t=t.alternate,t!==null&&(t.memoizedState=a),a}function Qv(t){var a=Jv(t);a.next===null&&(a=t.alternate.memoizedState),Ll(t,a.next.queue,{},or())}function Dp(){return Cn(Yl)}function Zv(){return en().memoizedState}function eS(){return en().memoizedState}function mk(t){for(var a=t.return;a!==null;){switch(a.tag){case 24:case 3:var o=or();t=ni(o);var u=ri(a,t,o);u!==null&&(Wn(u,a,o),Tl(u,a,o)),a={cache:ip()},t.payload=a;return}a=a.return}}function yk(t,a,o){var u=or();o={lane:u,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},qu(t)?nS(a,o):(o=Wh(t,a,o,u),o!==null&&(Wn(o,t,u),rS(o,a,u)))}function tS(t,a,o){var u=or();Ll(t,a,o,u)}function Ll(t,a,o,u){var p={lane:u,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(qu(t))nS(a,p);else{var g=t.alternate;if(t.lanes===0&&(g===null||g.lanes===0)&&(g=a.lastRenderedReducer,g!==null))try{var w=a.lastRenderedState,R=g(w,o);if(p.hasEagerState=!0,p.eagerState=R,tr(R,w))return Eu(t,a,p,0),jt===null&&Cu(),!1}catch{}finally{}if(o=Wh(t,a,p,u),o!==null)return Wn(o,t,u),rS(o,a,u),!0}return!1}function Op(t,a,o,u){if(u={lane:2,revertLane:cg(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},qu(t)){if(a)throw Error(r(479))}else a=Wh(t,o,u,2),a!==null&&Wn(a,t,2)}function qu(t){var a=t.alternate;return t===Qe||a!==null&&a===Qe}function nS(t,a){Xs=Iu=!0;var o=t.pending;o===null?a.next=a:(a.next=o.next,o.next=a),t.pending=a}function rS(t,a,o){if((o&4194048)!==0){var u=a.lanes;u&=t.pendingLanes,o|=u,a.lanes=o,Ce(t,o)}}var $l={readContext:Cn,use:zu,useCallback:Xt,useContext:Xt,useEffect:Xt,useImperativeHandle:Xt,useLayoutEffect:Xt,useInsertionEffect:Xt,useMemo:Xt,useReducer:Xt,useRef:Xt,useState:Xt,useDebugValue:Xt,useDeferredValue:Xt,useTransition:Xt,useSyncExternalStore:Xt,useId:Xt,useHostTransitionStatus:Xt,useFormState:Xt,useActionState:Xt,useOptimistic:Xt,useMemoCache:Xt,useCacheRefresh:Xt};$l.useEffectEvent=Xt;var aS={readContext:Cn,use:zu,useCallback:function(t,a){return In().memoizedState=[t,a===void 0?null:a],t},useContext:Cn,useEffect:Uv,useImperativeHandle:function(t,a,o){o=o!=null?o.concat([t]):null,Uu(4194308,4,Fv.bind(null,a,t),o)},useLayoutEffect:function(t,a){return Uu(4194308,4,t,a)},useInsertionEffect:function(t,a){Uu(4,2,t,a)},useMemo:function(t,a){var o=In();a=a===void 0?null:a;var u=t();if(as){Rn(!0);try{t()}finally{Rn(!1)}}return o.memoizedState=[u,a],u},useReducer:function(t,a,o){var u=In();if(o!==void 0){var p=o(a);if(as){Rn(!0);try{o(a)}finally{Rn(!1)}}}else p=a;return u.memoizedState=u.baseState=p,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:p},u.queue=t,t=t.dispatch=yk.bind(null,Qe,t),[u.memoizedState,t]},useRef:function(t){var a=In();return t={current:t},a.memoizedState=t},useState:function(t){t=_p(t);var a=t.queue,o=tS.bind(null,Qe,a);return a.dispatch=o,[t.memoizedState,o]},useDebugValue:Tp,useDeferredValue:function(t,a){var o=In();return kp(o,t,a)},useTransition:function(){var t=_p(!1);return t=Xv.bind(null,Qe,t.queue,!0,!1),In().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,a,o){var u=Qe,p=In();if(ht){if(o===void 0)throw Error(r(407));o=o()}else{if(o=a(),jt===null)throw Error(r(349));(ct&127)!==0||Av(u,a,o)}p.memoizedState=o;var g={value:o,getSnapshot:a};return p.queue=g,Uv(Tv.bind(null,u,g,t),[t]),u.flags|=2048,Qs(9,{destroy:void 0},xv.bind(null,u,g,o,a),null),o},useId:function(){var t=In(),a=jt.identifierPrefix;if(ht){var o=Zr,u=Qr;o=(u&~(1<<32-dn(u)-1)).toString(32)+o,a="_"+a+"R_"+o,o=ju++,0<\/script>",g=g.removeChild(g.firstChild);break;case"select":g=typeof u.is=="string"?w.createElement("select",{is:u.is}):w.createElement("select"),u.multiple?g.multiple=!0:u.size&&(g.size=u.size);break;default:g=typeof u.is=="string"?w.createElement(p,{is:u.is}):w.createElement(p)}}g[Ft]=a,g[Dn]=u;e:for(w=a.child;w!==null;){if(w.tag===5||w.tag===6)g.appendChild(w.stateNode);else if(w.tag!==4&&w.tag!==27&&w.child!==null){w.child.return=w,w=w.child;continue}if(w===a)break e;for(;w.sibling===null;){if(w.return===null||w.return===a)break e;w=w.return}w.sibling.return=w.return,w=w.sibling}a.stateNode=g;e:switch(_n(g,p,u),p){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&Ea(a)}}return Ut(a),Fp(a,a.type,t===null?null:t.memoizedProps,a.pendingProps,o),null;case 6:if(t&&a.stateNode!=null)t.memoizedProps!==u&&Ea(a);else{if(typeof u!="string"&&a.stateNode===null)throw Error(r(166));if(t=se.current,qs(a)){if(t=a.stateNode,o=a.memoizedProps,u=null,p=wn,p!==null)switch(p.tag){case 27:case 5:u=p.memoizedProps}t[Ft]=a,t=!!(t.nodeValue===o||u!==null&&u.suppressHydrationWarning===!0||Ew(t.nodeValue,o)),t||Za(a,!0)}else t=cd(t).createTextNode(u),t[Ft]=a,a.stateNode=t}return Ut(a),null;case 31:if(o=a.memoizedState,t===null||t.memoizedState!==null){if(u=qs(a),o!==null){if(t===null){if(!u)throw Error(r(318));if(t=a.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(r(557));t[Ft]=a}else Ji(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;Ut(a),t=!1}else o=tp(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=o),t=!0;if(!t)return a.flags&256?(ar(a),a):(ar(a),null);if((a.flags&128)!==0)throw Error(r(558))}return Ut(a),null;case 13:if(u=a.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(p=qs(a),u!==null&&u.dehydrated!==null){if(t===null){if(!p)throw Error(r(318));if(p=a.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(r(317));p[Ft]=a}else Ji(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;Ut(a),p=!1}else p=tp(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=p),p=!0;if(!p)return a.flags&256?(ar(a),a):(ar(a),null)}return ar(a),(a.flags&128)!==0?(a.lanes=o,a):(o=u!==null,t=t!==null&&t.memoizedState!==null,o&&(u=a.child,p=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(p=u.alternate.memoizedState.cachePool.pool),g=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(g=u.memoizedState.cachePool.pool),g!==p&&(u.flags|=2048)),o!==t&&o&&(a.child.flags|=8192),Wu(a,a.updateQueue),Ut(a),null);case 4:return Te(),t===null&&hg(a.stateNode.containerInfo),Ut(a),null;case 10:return va(a.type),Ut(a),null;case 19:if(T(Zt),u=a.memoizedState,u===null)return Ut(a),null;if(p=(a.flags&128)!==0,g=u.rendering,g===null)if(p)Nl(u,!1);else{if(Jt!==0||t!==null&&(t.flags&128)!==0)for(t=a.child;t!==null;){if(g=Nu(t),g!==null){for(a.flags|=128,Nl(u,!1),t=g.updateQueue,a.updateQueue=t,Wu(a,t),a.subtreeFlags=0,t=o,o=a.child;o!==null;)tv(o,t),o=o.sibling;return fe(Zt,Zt.current&1|2),ht&&ya(a,u.treeForkCount),a.child}t=t.sibling}u.tail!==null&&Ot()>Zu&&(a.flags|=128,p=!0,Nl(u,!1),a.lanes=4194304)}else{if(!p)if(t=Nu(g),t!==null){if(a.flags|=128,p=!0,t=t.updateQueue,a.updateQueue=t,Wu(a,t),Nl(u,!0),u.tail===null&&u.tailMode==="hidden"&&!g.alternate&&!ht)return Ut(a),null}else 2*Ot()-u.renderingStartTime>Zu&&o!==536870912&&(a.flags|=128,p=!0,Nl(u,!1),a.lanes=4194304);u.isBackwards?(g.sibling=a.child,a.child=g):(t=u.last,t!==null?t.sibling=g:a.child=g,u.last=g)}return u.tail!==null?(t=u.tail,u.rendering=t,u.tail=t.sibling,u.renderingStartTime=Ot(),t.sibling=null,o=Zt.current,fe(Zt,p?o&1|2:o&1),ht&&ya(a,u.treeForkCount),t):(Ut(a),null);case 22:case 23:return ar(a),pp(),u=a.memoizedState!==null,t!==null?t.memoizedState!==null!==u&&(a.flags|=8192):u&&(a.flags|=8192),u?(o&536870912)!==0&&(a.flags&128)===0&&(Ut(a),a.subtreeFlags&6&&(a.flags|=8192)):Ut(a),o=a.updateQueue,o!==null&&Wu(a,o.retryQueue),o=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(o=t.memoizedState.cachePool.pool),u=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(u=a.memoizedState.cachePool.pool),u!==o&&(a.flags|=2048),t!==null&&T(es),null;case 24:return o=null,t!==null&&(o=t.memoizedState.cache),a.memoizedState.cache!==o&&(a.flags|=2048),va(rn),Ut(a),null;case 25:return null;case 30:return null}throw Error(r(156,a.tag))}function Ck(t,a){switch(Zh(a),a.tag){case 1:return t=a.flags,t&65536?(a.flags=t&-65537|128,a):null;case 3:return va(rn),Te(),t=a.flags,(t&65536)!==0&&(t&128)===0?(a.flags=t&-65537|128,a):null;case 26:case 27:case 5:return xt(a),null;case 31:if(a.memoizedState!==null){if(ar(a),a.alternate===null)throw Error(r(340));Ji()}return t=a.flags,t&65536?(a.flags=t&-65537|128,a):null;case 13:if(ar(a),t=a.memoizedState,t!==null&&t.dehydrated!==null){if(a.alternate===null)throw Error(r(340));Ji()}return t=a.flags,t&65536?(a.flags=t&-65537|128,a):null;case 19:return T(Zt),null;case 4:return Te(),null;case 10:return va(a.type),null;case 22:case 23:return ar(a),pp(),t!==null&&T(es),t=a.flags,t&65536?(a.flags=t&-65537|128,a):null;case 24:return va(rn),null;case 25:return null;default:return null}}function kS(t,a){switch(Zh(a),a.tag){case 3:va(rn),Te();break;case 26:case 27:case 5:xt(a);break;case 4:Te();break;case 31:a.memoizedState!==null&&ar(a);break;case 13:ar(a);break;case 19:T(Zt);break;case 10:va(a.type);break;case 22:case 23:ar(a),pp(),t!==null&&T(es);break;case 24:va(rn)}}function Il(t,a){try{var o=a.updateQueue,u=o!==null?o.lastEffect:null;if(u!==null){var p=u.next;o=p;do{if((o.tag&t)===t){u=void 0;var g=o.create,w=o.inst;u=g(),w.destroy=u}o=o.next}while(o!==p)}}catch(R){kt(a,a.return,R)}}function si(t,a,o){try{var u=a.updateQueue,p=u!==null?u.lastEffect:null;if(p!==null){var g=p.next;u=g;do{if((u.tag&t)===t){var w=u.inst,R=w.destroy;if(R!==void 0){w.destroy=void 0,p=a;var P=o,X=R;try{X()}catch(re){kt(p,P,re)}}}u=u.next}while(u!==g)}}catch(re){kt(a,a.return,re)}}function RS(t){var a=t.updateQueue;if(a!==null){var o=t.stateNode;try{vv(a,o)}catch(u){kt(t,t.return,u)}}}function DS(t,a,o){o.props=is(t.type,t.memoizedProps),o.state=t.memoizedState;try{o.componentWillUnmount()}catch(u){kt(t,a,u)}}function jl(t,a){try{var o=t.ref;if(o!==null){switch(t.tag){case 26:case 27:case 5:var u=t.stateNode;break;case 30:u=t.stateNode;break;default:u=t.stateNode}typeof o=="function"?t.refCleanup=o(u):o.current=u}}catch(p){kt(t,a,p)}}function ea(t,a){var o=t.ref,u=t.refCleanup;if(o!==null)if(typeof u=="function")try{u()}catch(p){kt(t,a,p)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(p){kt(t,a,p)}else o.current=null}function OS(t){var a=t.type,o=t.memoizedProps,u=t.stateNode;try{e:switch(a){case"button":case"input":case"select":case"textarea":o.autoFocus&&u.focus();break e;case"img":o.src?u.src=o.src:o.srcSet&&(u.srcset=o.srcSet)}}catch(p){kt(t,t.return,p)}}function Vp(t,a,o){try{var u=t.stateNode;Gk(u,t.type,o,a),u[Dn]=a}catch(p){kt(t,t.return,p)}}function LS(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&hi(t.type)||t.tag===4}function Kp(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||LS(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&hi(t.type)||t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Wp(t,a,o){var u=t.tag;if(u===5||u===6)t=t.stateNode,a?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(t,a):(a=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,a.appendChild(t),o=o._reactRootContainer,o!=null||a.onclick!==null||(a.onclick=Nr));else if(u!==4&&(u===27&&hi(t.type)&&(o=t.stateNode,a=null),t=t.child,t!==null))for(Wp(t,a,o),t=t.sibling;t!==null;)Wp(t,a,o),t=t.sibling}function Yu(t,a,o){var u=t.tag;if(u===5||u===6)t=t.stateNode,a?o.insertBefore(t,a):o.appendChild(t);else if(u!==4&&(u===27&&hi(t.type)&&(o=t.stateNode),t=t.child,t!==null))for(Yu(t,a,o),t=t.sibling;t!==null;)Yu(t,a,o),t=t.sibling}function $S(t){var a=t.stateNode,o=t.memoizedProps;try{for(var u=t.type,p=a.attributes;p.length;)a.removeAttributeNode(p[0]);_n(a,u,o),a[Ft]=t,a[Dn]=o}catch(g){kt(t,t.return,g)}}var _a=!1,on=!1,Yp=!1,MS=typeof WeakSet=="function"?WeakSet:Set,yn=null;function Ek(t,a){if(t=t.containerInfo,mg=md,t=Vb(t),Bh(t)){if("selectionStart"in t)var o={start:t.selectionStart,end:t.selectionEnd};else e:{o=(o=t.ownerDocument)&&o.defaultView||window;var u=o.getSelection&&o.getSelection();if(u&&u.rangeCount!==0){o=u.anchorNode;var p=u.anchorOffset,g=u.focusNode;u=u.focusOffset;try{o.nodeType,g.nodeType}catch{o=null;break e}var w=0,R=-1,P=-1,X=0,re=0,le=t,J=null;t:for(;;){for(var te;le!==o||p!==0&&le.nodeType!==3||(R=w+p),le!==g||u!==0&&le.nodeType!==3||(P=w+u),le.nodeType===3&&(w+=le.nodeValue.length),(te=le.firstChild)!==null;)J=le,le=te;for(;;){if(le===t)break t;if(J===o&&++X===p&&(R=w),J===g&&++re===u&&(P=w),(te=le.nextSibling)!==null)break;le=J,J=le.parentNode}le=te}o=R===-1||P===-1?null:{start:R,end:P}}else o=null}o=o||{start:0,end:0}}else o=null;for(yg={focusedElem:t,selectionRange:o},md=!1,yn=a;yn!==null;)if(a=yn,t=a.child,(a.subtreeFlags&1028)!==0&&t!==null)t.return=a,yn=t;else for(;yn!==null;){switch(a=yn,g=a.alternate,t=a.flags,a.tag){case 0:if((t&4)!==0&&(t=a.updateQueue,t=t!==null?t.events:null,t!==null))for(o=0;o title"))),_n(g,u,o),g[Ft]=t,nn(g),u=g;break e;case"link":var w=Pw("link","href",p).get(u+(o.href||""));if(w){for(var R=0;RNt&&(w=Nt,Nt=Ge,Ge=w);var K=Gb(R,Ge),F=Gb(R,Nt);if(K&&F&&(te.rangeCount!==1||te.anchorNode!==K.node||te.anchorOffset!==K.offset||te.focusNode!==F.node||te.focusOffset!==F.offset)){var Y=le.createRange();Y.setStart(K.node,K.offset),te.removeAllRanges(),Ge>Nt?(te.addRange(Y),te.extend(F.node,F.offset)):(Y.setEnd(F.node,F.offset),te.addRange(Y))}}}}for(le=[],te=R;te=te.parentNode;)te.nodeType===1&&le.push({element:te,left:te.scrollLeft,top:te.scrollTop});for(typeof R.focus=="function"&&R.focus(),R=0;Ro?32:o,Q.T=null,o=ng,ng=null;var g=ui,w=Ra;if(hn=0,ro=ui=null,Ra=0,(_t&6)!==0)throw Error(r(331));var R=_t;if(_t|=4,FS(g.current),BS(g,g.current,w,o),_t=R,ql(0,!1),un&&typeof un.onPostCommitFiberRoot=="function")try{un.onPostCommitFiberRoot(pr,g)}catch{}return!0}finally{ue.p=p,Q.T=u,cw(t,a)}}function dw(t,a,o){a=yr(o,a),a=Np(t.stateNode,a,2),t=ri(t,a,2),t!==null&&(tt(t,2),ta(t))}function kt(t,a,o){if(t.tag===3)dw(t,t,o);else for(;a!==null;){if(a.tag===3){dw(a,t,o);break}else if(a.tag===1){var u=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(ci===null||!ci.has(u))){t=yr(o,t),o=fS(2),u=ri(a,o,2),u!==null&&(hS(o,u,a,t),tt(u,2),ta(u));break}}a=a.return}}function sg(t,a,o){var u=t.pingCache;if(u===null){u=t.pingCache=new xk;var p=new Set;u.set(a,p)}else p=u.get(a),p===void 0&&(p=new Set,u.set(a,p));p.has(o)||(Qp=!0,p.add(o),t=Ok.bind(null,t,a,o),a.then(t,t))}function Ok(t,a,o){var u=t.pingCache;u!==null&&u.delete(a),t.pingedLanes|=t.suspendedLanes&o,t.warmLanes&=~o,jt===t&&(ct&o)===o&&(Jt===4||Jt===3&&(ct&62914560)===ct&&300>Ot()-Qu?(_t&2)===0&&ao(t,0):Zp|=o,no===ct&&(no=0)),ta(t)}function fw(t,a){a===0&&(a=Me()),t=Yi(t,a),t!==null&&(tt(t,a),ta(t))}function Lk(t){var a=t.memoizedState,o=0;a!==null&&(o=a.retryLane),fw(t,o)}function $k(t,a){var o=0;switch(t.tag){case 31:case 13:var u=t.stateNode,p=t.memoizedState;p!==null&&(o=p.retryLane);break;case 19:u=t.stateNode;break;case 22:u=t.stateNode._retryCache;break;default:throw Error(r(314))}u!==null&&u.delete(a),fw(t,o)}function Mk(t,a){return Dt(t,a)}var id=null,so=null,og=!1,sd=!1,lg=!1,fi=0;function ta(t){t!==so&&t.next===null&&(so===null?id=so=t:so=so.next=t),sd=!0,og||(og=!0,Ik())}function ql(t,a){if(!lg&&sd){lg=!0;do for(var o=!1,u=id;u!==null;){if(t!==0){var p=u.pendingLanes;if(p===0)var g=0;else{var w=u.suspendedLanes,R=u.pingedLanes;g=(1<<31-dn(42|t)+1)-1,g&=p&~(w&~R),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(o=!0,mw(u,g))}else g=ct,g=xe(u,u===jt?g:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(g&3)===0||Ke(u,g)||(o=!0,mw(u,g));u=u.next}while(o);lg=!1}}function Nk(){hw()}function hw(){sd=og=!1;var t=0;fi!==0&&Vk()&&(t=fi);for(var a=Ot(),o=null,u=id;u!==null;){var p=u.next,g=pw(u,a);g===0?(u.next=null,o===null?id=p:o.next=p,p===null&&(so=o)):(o=u,(t!==0||(g&3)!==0)&&(sd=!0)),u=p}hn!==0&&hn!==5||ql(t),fi!==0&&(fi=0)}function pw(t,a){for(var o=t.suspendedLanes,u=t.pingedLanes,p=t.expirationTimes,g=t.pendingLanes&-62914561;0R)break;var re=P.transferSize,le=P.initiatorType;re&&_w(le)&&(P=P.responseEnd,w+=re*(P"u"?null:document;function Iw(t,a,o){var u=oo;if(u&&typeof a=="string"&&a){var p=qn(a);p='link[rel="'+t+'"][href="'+p+'"]',typeof o=="string"&&(p+='[crossorigin="'+o+'"]'),Nw.has(p)||(Nw.add(p),t={rel:t,crossOrigin:o,href:a},u.querySelector(p)===null&&(a=u.createElement("link"),_n(a,"link",t),nn(a),u.head.appendChild(a)))}}function tR(t){Da.D(t),Iw("dns-prefetch",t,null)}function nR(t,a){Da.C(t,a),Iw("preconnect",t,a)}function rR(t,a,o){Da.L(t,a,o);var u=oo;if(u&&t&&a){var p='link[rel="preload"][as="'+qn(a)+'"]';a==="image"&&o&&o.imageSrcSet?(p+='[imagesrcset="'+qn(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(p+='[imagesizes="'+qn(o.imageSizes)+'"]')):p+='[href="'+qn(t)+'"]';var g=p;switch(a){case"style":g=lo(t);break;case"script":g=co(t)}Er.has(g)||(t=y({rel:"preload",href:a==="image"&&o&&o.imageSrcSet?void 0:t,as:a},o),Er.set(g,t),u.querySelector(p)!==null||a==="style"&&u.querySelector(Kl(g))||a==="script"&&u.querySelector(Wl(g))||(a=u.createElement("link"),_n(a,"link",t),nn(a),u.head.appendChild(a)))}}function aR(t,a){Da.m(t,a);var o=oo;if(o&&t){var u=a&&typeof a.as=="string"?a.as:"script",p='link[rel="modulepreload"][as="'+qn(u)+'"][href="'+qn(t)+'"]',g=p;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=co(t)}if(!Er.has(g)&&(t=y({rel:"modulepreload",href:t},a),Er.set(g,t),o.querySelector(p)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(Wl(g)))return}u=o.createElement("link"),_n(u,"link",t),nn(u),o.head.appendChild(u)}}}function iR(t,a,o){Da.S(t,a,o);var u=oo;if(u&&t){var p=qa(u).hoistableStyles,g=lo(t);a=a||"default";var w=p.get(g);if(!w){var R={loading:0,preload:null};if(w=u.querySelector(Kl(g)))R.loading=5;else{t=y({rel:"stylesheet",href:t,"data-precedence":a},o),(o=Er.get(g))&&_g(t,o);var P=w=u.createElement("link");nn(P),_n(P,"link",t),P._p=new Promise(function(X,re){P.onload=X,P.onerror=re}),P.addEventListener("load",function(){R.loading|=1}),P.addEventListener("error",function(){R.loading|=2}),R.loading|=4,dd(w,a,u)}w={type:"stylesheet",instance:w,count:1,state:R},p.set(g,w)}}}function sR(t,a){Da.X(t,a);var o=oo;if(o&&t){var u=qa(o).hoistableScripts,p=co(t),g=u.get(p);g||(g=o.querySelector(Wl(p)),g||(t=y({src:t,async:!0},a),(a=Er.get(p))&&Ag(t,a),g=o.createElement("script"),nn(g),_n(g,"link",t),o.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},u.set(p,g))}}function oR(t,a){Da.M(t,a);var o=oo;if(o&&t){var u=qa(o).hoistableScripts,p=co(t),g=u.get(p);g||(g=o.querySelector(Wl(p)),g||(t=y({src:t,async:!0,type:"module"},a),(a=Er.get(p))&&Ag(t,a),g=o.createElement("script"),nn(g),_n(g,"link",t),o.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},u.set(p,g))}}function jw(t,a,o,u){var p=(p=se.current)?ud(p):null;if(!p)throw Error(r(446));switch(t){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(a=lo(o.href),o=qa(p).hoistableStyles,u=o.get(a),u||(u={type:"style",instance:null,count:0,state:null},o.set(a,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){t=lo(o.href);var g=qa(p).hoistableStyles,w=g.get(t);if(w||(p=p.ownerDocument||p,w={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(t,w),(g=p.querySelector(Kl(t)))&&!g._p&&(w.instance=g,w.state.loading=5),Er.has(t)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},Er.set(t,o),g||lR(p,t,o,w.state))),a&&u===null)throw Error(r(528,""));return w}if(a&&u!==null)throw Error(r(529,""));return null;case"script":return a=o.async,o=o.src,typeof o=="string"&&a&&typeof a!="function"&&typeof a!="symbol"?(a=co(o),o=qa(p).hoistableScripts,u=o.get(a),u||(u={type:"script",instance:null,count:0,state:null},o.set(a,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,t))}}function lo(t){return'href="'+qn(t)+'"'}function Kl(t){return'link[rel="stylesheet"]['+t+"]"}function Hw(t){return y({},t,{"data-precedence":t.precedence,precedence:null})}function lR(t,a,o,u){t.querySelector('link[rel="preload"][as="style"]['+a+"]")?u.loading=1:(a=t.createElement("link"),u.preload=a,a.addEventListener("load",function(){return u.loading|=1}),a.addEventListener("error",function(){return u.loading|=2}),_n(a,"link",o),nn(a),t.head.appendChild(a))}function co(t){return'[src="'+qn(t)+'"]'}function Wl(t){return"script[async]"+t}function zw(t,a,o){if(a.count++,a.instance===null)switch(a.type){case"style":var u=t.querySelector('style[data-href~="'+qn(o.href)+'"]');if(u)return a.instance=u,nn(u),u;var p=y({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return u=(t.ownerDocument||t).createElement("style"),nn(u),_n(u,"style",p),dd(u,o.precedence,t),a.instance=u;case"stylesheet":p=lo(o.href);var g=t.querySelector(Kl(p));if(g)return a.state.loading|=4,a.instance=g,nn(g),g;u=Hw(o),(p=Er.get(p))&&_g(u,p),g=(t.ownerDocument||t).createElement("link"),nn(g);var w=g;return w._p=new Promise(function(R,P){w.onload=R,w.onerror=P}),_n(g,"link",u),a.state.loading|=4,dd(g,o.precedence,t),a.instance=g;case"script":return g=co(o.src),(p=t.querySelector(Wl(g)))?(a.instance=p,nn(p),p):(u=o,(p=Er.get(g))&&(u=y({},o),Ag(u,p)),t=t.ownerDocument||t,p=t.createElement("script"),nn(p),_n(p,"link",u),t.head.appendChild(p),a.instance=p);case"void":return null;default:throw Error(r(443,a.type))}else a.type==="stylesheet"&&(a.state.loading&4)===0&&(u=a.instance,a.state.loading|=4,dd(u,o.precedence,t));return a.instance}function dd(t,a,o){for(var u=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),p=u.length?u[u.length-1]:null,g=p,w=0;w title"):null)}function cR(t,a,o){if(o===1||a.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof a.precedence!="string"||typeof a.href!="string"||a.href==="")break;return!0;case"link":if(typeof a.rel!="string"||typeof a.href!="string"||a.href===""||a.onLoad||a.onError)break;switch(a.rel){case"stylesheet":return t=a.disabled,typeof a.precedence=="string"&&t==null;default:return!0}case"script":if(a.async&&typeof a.async!="function"&&typeof a.async!="symbol"&&!a.onLoad&&!a.onError&&a.src&&typeof a.src=="string")return!0}return!1}function Bw(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function uR(t,a,o,u){if(o.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var p=lo(u.href),g=a.querySelector(Kl(p));if(g){a=g._p,a!==null&&typeof a=="object"&&typeof a.then=="function"&&(t.count++,t=hd.bind(t),a.then(t,t)),o.state.loading|=4,o.instance=g,nn(g);return}g=a.ownerDocument||a,u=Hw(u),(p=Er.get(p))&&_g(u,p),g=g.createElement("link"),nn(g);var w=g;w._p=new Promise(function(R,P){w.onload=R,w.onerror=P}),_n(g,"link",u),o.instance=g}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(o,a),(a=o.state.preload)&&(o.state.loading&3)===0&&(t.count++,o=hd.bind(t),a.addEventListener("load",o),a.addEventListener("error",o))}}var xg=0;function dR(t,a){return t.stylesheets&&t.count===0&&gd(t,t.stylesheets),0xg?50:800)+a);return t.unsuspend=o,function(){t.unsuspend=null,clearTimeout(u),clearTimeout(p)}}:null}function hd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)gd(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var pd=null;function gd(t,a){t.stylesheets=null,t.unsuspend!==null&&(t.count++,pd=new Map,a.forEach(fR,t),pd=null,hd.call(t))}function fR(t,a){if(!(a.state.loading&4)){var o=pd.get(t);if(o)var u=o.get(null);else{o=new Map,pd.set(t,o);for(var p=t.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(s)}catch(e){console.error(e)}}return s(),Ad.exports=c0(),Ad.exports}var Rd=u0();const Dd=ra(Rd),ho=[],d0=50;let Od=!1;function Bg(){try{return window.G7Core?.devTools}catch{return}}function ls(s,e,n){const r=Bg();if(Od&&r?.isEnabled?.()){r.trackLog?.(s,e,n);return}Od||(s==="error"||s==="warn")&&ho.length{n.isDebugEnabled()&&console.log(e,...r),ls("log",s,r)},warn:(...r)=>{n.isDebugEnabled()&&console.warn(e,...r),ls("warn",s,r)},error:(...r)=>{n.isDebugEnabled()&&console.error(e,...r),ls("error",s,r)}}}po.getInstance();const qg="extension",cs="extensionless",Gg="file";function f0(){const s=globalThis?.G7Config;if(globalThis?.__g7AssetUrlMode===cs)return cs;const n=s?.assetUrlMode;return n===cs||n===qg?n:s?.settings?.general?.asset_url_mode===cs?cs:qg}function $d(){return f0()===cs}function h0(s,e,n){return Md("templates",s,e,n)}function p0(s,e){const n=e.replace(/^\/+/,"").replace(/\/+$/,""),r=encodeURIComponent(s),i=go(`templates/${s}/assets/${n}`);return i!==null?i:`/api/templates/assets/${r}/${n}`}function g0(s,e,n){return Md("modules",s,e,n)}function m0(s,e,n){return Md("plugins",s,e,n)}function Md(s,e,n,r){const i=n.replace(/^\/+/,""),l=encodeURIComponent(e);if(!$d())return`/api/${s}/assets/${l}/${i}${v0(r)}`;let c=`${Gg}=${encodeURIComponent(i)}`;return r!=null&&r!==""&&(c+=`&v=${r}`),`/api/${s}/assets/${l}?${c}`}function Br(s,e,n,r){const i=s.replace(/\/+$/,""),l=e.replace(/^\.+/,""),c=$d()?i:`${i}.${l}`,d=[];return r&&d.push(r.replace(/^[?&]+/,"")),n!=null&&n!==""&&d.push(`v=${n}`),d.length>0?`${c}?${d.join("&")}`:c}function Fg(){const s=globalThis?.G7Config?.staticBase;return typeof s=="string"&&s!==""?s.replace(/\/+$/,""):null}function y0(){const s=Fg();if(!s)return null;const e=s.match(/\/(\d+)$/);return e?Number(e[1]):null}function go(s,e){const n=Fg();if(!n)return null;const r=s.replace(/^\/+/,"");return e!==void 0&&e>0&&e!==y0()?`${n.replace(/\/\d+$/,"")}/${e}/${r}`:`${n}/${r}`}function Nd(s){if(!s)return null;const e=globalThis?.location?.origin,r=(e&&s.startsWith(e)?s.slice(e.length):s).match(/^\/build\/ext\/(\d+)\/(.+)$/);if(!r)return null;const i=r[1],l=r[2].split("?")[0],c=l.match(/^(templates|modules|plugins)\/([^/]+)\/assets\/(.+)$/);if(c){const[,h,m,y]=c;return`/api/${h}/assets/${m}/${y}?v=${i}`}const d=l.match(/^bundles\/(modules|plugins)\.(js|css)$/);if(d)return`/api/${d[1]}/bundle.${d[2]}?v=${i}`;const f=l.match(/^templates\/([^/]+)\/(routes\.json|components\.json|lang\/([a-zA-Z-]+)\.json)$/);if(f){const[,h,m]=f,y=m.replace(/\.json$/,"");return`/api/templates/${h}/${y}.json?v=${i}`}return null}function Ln(s){if(!s||!$d())return s;const e=globalThis?.location?.origin,n=e&&s.startsWith(e)?s.slice(e.length):s;if(!n.startsWith("/api/"))return s;const[r,i]=b0(n),l=r.match(/^\/api\/(modules|plugins)\/bundle\.(js|css)$/);if(l)return Vg(`/api/${l[1]}/bundle/${l[2]}`,i);const c=r.match(/^\/api\/(templates|modules|plugins)\/assets\/([^/]+)\/(.+)$/);if(c){const[,f,h,m]=c,y=`${Gg}=${encodeURIComponent(decodeURIComponent(m))}`;return`/api/${f}/assets/${h}?${y}${i?`&${i}`:""}`}const d=r.match(/^(\/api\/.+)\.(json|js|css)$/);return d?Vg(d[1],i):s}function b0(s){const e=s.indexOf("?");return e===-1?[s,""]:[s.slice(0,e),s.slice(e+1)]}function Vg(s,e){return e?`${s}?${e}`:s}function v0(s){return s==null||s===""?"":`?v=${s}`}const aa=pt("networkResilience"),Id=2,jd=300,Hd=2e3,S0=15e3;function zd(s){return s?.name==="AbortError"}function Kg(s){if(zd(s))return!1;if(s instanceof TypeError)return!0;const e=s?.code;return e==="ERR_NETWORK"||e==="ECONNABORTED"}let Zl=!1,Wg=!1;function ec(){return Zl}function w0(){typeof window>"u"||Wg||(Wg=!0,window.addEventListener("pagehide",()=>{Zl=!0}),window.addEventListener("pageshow",s=>{s.persisted&&(Zl=!1)}),window.addEventListener("beforeunload",()=>{Zl=!0}))}function Pd(s,e,n){const r=Math.min(e*Math.pow(2,s),n),i=r*.25*(Math.random()*2-1);return Math.max(0,Math.round(r+i))}function Ud(s){return new Promise(e=>setTimeout(e,s))}async function tc(s,e={}){const{retries:n=Id,baseDelayMs:r=jd,maxDelayMs:i=Hd,timeoutMs:l=S0,label:c=s,init:d}=e,f=n+1;let h;for(let m=0;m0?new AbortController:null;try{const _={...d};if(S){const A=d?.signal;A&&(A.aborted?S.abort():A.addEventListener("abort",()=>S.abort(),{once:!0})),_.signal=S.signal,v=setTimeout(()=>{y=!0,S.abort()},l)}return await fetch(s,_)}catch(_){if(h=_,zd(_)&&!y||!(y||Kg(_)))throw _;if(ec())throw aa.warn(`Document unloading, aborting retries: ${c}`),_;if(m===f-1)throw aa.warn(`All ${f} attempts failed: ${c}`,_),_;const D=Pd(m,r,i);aa.warn(`Network failure (attempt ${m+1}/${f}), retrying in ${D}ms: ${c}`),await Ud(D)}finally{v!==void 0&&clearTimeout(v)}}throw h}async function _r(s,e={},n={}){const{retries:r=Id,baseDelayMs:i=jd,maxDelayMs:l=Hd,label:c=s}=n,d=r+1;for(let f=0;f{const i=document.createElement("script");i.src=s,i.async=!1;for(const[l,c]of Object.entries(e))l==="id"?i.id=c:i.setAttribute(l,c);i.onload=()=>n(),i.onerror=()=>r(new Error(`Failed to load script: ${s}`)),document.head.appendChild(i)})}async function ia(s,e={},n={}){const{retries:r=Id,baseDelayMs:i=jd,maxDelayMs:l=Hd,label:c=s}=n,d=r+1;for(let f=0;f{s.onload=()=>e(),s.onerror=()=>n(new Error(`Failed to load stylesheet: ${s.href}`))})}async function nc(s,e,n={}){if(!s)return tc(e,n);try{const r=await fetch(s,n.init);if(r.ok){const i=await r.text();try{return JSON.parse(i),new Response(i,{status:r.status,statusText:r.statusText,headers:r.headers})}catch{return console.warn(`[fetchStaticFirst] Static fast path returned malformed JSON — falling back to API: ${s}`),tc(e,n)}}console.warn(`[fetchStaticFirst] Static fast path miss (${r.status}) — falling back to API: ${s}`)}catch(r){console.warn(`[fetchStaticFirst] Static fast path fetch failed — falling back to API: ${s}`,r)}return tc(e,n)}const qr=pt("ComponentRegistry");class pn extends Error{constructor(e,n,r){super(e),this.code=n,this.details=r,this.name="ComponentRegistryError"}}const er=class er{constructor(){M(this,"registry",{});M(this,"manifest",null);M(this,"cacheVersion",0);M(this,"loadingState","idle");M(this,"error",null);M(this,"templateId",null);M(this,"templateType",null)}static getInstance(){return er.instance||(er.instance=new er),er.instance}static createIsolatedInstance(){return new er}static resetInstance(){er.instance=null}async loadComponents(e,n,r=0){if(this.loadingState==="loading")throw new pn("Components are already being loaded","LOADING_IN_PROGRESS");if(this.loadingState==="loaded"&&this.templateId===e&&this.templateType===n){qr.log("Components already loaded for template:",e,n);return}this.loadingState="loading",this.templateId=e,this.templateType=n,this.cacheVersion=r,this.error=null;try{await this.loadManifest(),await this.loadComponentBundle(),this.loadingState="loaded",qr.log("Successfully loaded components:",Object.keys(this.registry).length)}catch(i){throw this.loadingState="error",this.error=i instanceof Error?i:new Error(String(i)),new pn(`Failed to load components: ${this.error.message}`,"LOAD_FAILED",{originalError:this.error})}}async loadManifest(){try{if(!this.templateId)throw new pn("Template ID not set","TEMPLATE_ID_NOT_SET");const e=`${this.templateId}:${this.templateType}:v${this.cacheVersion||0}`;if(er.manifestCache.has(e)){this.manifest=er.manifestCache.get(e),qr.log("Manifest loaded from cache:",this.manifest.templateId);return}const n=Br(`/api/templates/${this.templateId}/components`,"json",this.cacheVersion>0?this.cacheVersion:null),r=await nc(this.cacheVersion>0?go(`templates/${this.templateId}/components.json`,this.cacheVersion):null,n,{label:"components.json"});if(!r.ok)throw new pn(`Failed to fetch manifest: ${r.status} ${r.statusText}`,"MANIFEST_FETCH_FAILED",{status:r.status,statusText:r.statusText});const i=await r.json();this.validateManifest(i),this.manifest=i,er.manifestCache.set(e,i),qr.log("Manifest loaded and cached:",i.templateId)}catch(e){throw e instanceof pn?e:new pn("Failed to load component manifest","MANIFEST_LOAD_FAILED",{originalError:e})}}validateManifest(e){if(!e.version)throw new pn("Manifest missing required field: version","MANIFEST_INVALID",{field:"version"});if(!e.templateId)throw new pn("Manifest missing required field: templateId","MANIFEST_INVALID",{field:"templateId"});if(!e.components||typeof e.components!="object")throw new pn("Manifest missing required field: components","MANIFEST_INVALID",{field:"components"});const n=["basic","composite","layout"];for(const r of n){if(!Array.isArray(e.components[r]))throw new pn(`Manifest field 'components.${r}' must be an array`,"MANIFEST_INVALID",{field:`components.${r}`,value:e.components[r]});e.components[r].forEach((i,l)=>{if(!i.name||typeof i.name!="string")throw new pn(`Invalid component metadata at ${r}[${l}]: missing or invalid 'name'`,"MANIFEST_INVALID",{type:r,index:l,metadata:i});if(!i.type||typeof i.type!="string")throw new pn(`Invalid component metadata at ${r}[${l}]: missing or invalid 'type'`,"MANIFEST_INVALID",{type:r,index:l,metadata:i})})}qr.log("Manifest validation passed")}async loadComponentBundle(){try{if(!this.templateId)throw new pn("Template ID not set","TEMPLATE_ID_NOT_SET");const e=this.getGlobalVariableName(),n=window[e];if(!n||typeof n!="object")throw new pn(`Component bundle not loaded. Expected global variable: ${e}. Ensure admin.blade.php includes the IIFE bundle script.`,"BUNDLE_NOT_LOADED",{expectedVariable:e});await this.registerComponentsFromManifest(n),qr.log("Component bundle loaded from global variable:",e)}catch(e){throw e instanceof pn?e:new pn("Failed to load component bundle","BUNDLE_LOAD_FAILED",{originalError:e})}}getGlobalVariableName(){if(!this.templateId)throw new pn("Template ID not set","TEMPLATE_ID_NOT_SET");return this.templateId.split(/[-_]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join("")}async registerComponentsFromManifest(e){if(!this.manifest)throw new pn("Manifest not loaded","MANIFEST_NOT_LOADED");const n=["basic","composite","layout"];for(const r of n){const i=this.manifest.components[r]||[];for(const l of i){const c=l.name,d=e[c];if(!d){qr.warn(`Component '${c}' not found in bundle`);continue}this.registerComponent(c,d,l)}}}registerComponent(e,n,r){this.registry[e]&&qr.warn(`Component '${e}' already registered, overwriting`);const i=Xe.memo(n);this.registry[e]={component:i,metadata:r},qr.log(`[ComponentRegistry] Registered component: ${e} (${r.type})`)}getComponent(e){const n=this.registry[e];return n?n.component:null}getMetadata(e){const n=this.registry[e];return n?n.metadata:null}hasComponent(e){return e in this.registry}getComponentsByType(e){return Object.entries(this.registry).filter(([n,r])=>r.metadata.type===e).map(([n,r])=>n)}getAllComponents(){return Object.keys(this.registry)}getComponentMap(){const e={};for(const[n,r]of Object.entries(this.registry))e[n]=r.component;return e}getLoadingState(){return this.loadingState}getError(){return this.error}getTemplateId(){return this.templateId}getManifest(){return this.manifest}clear(){this.registry={},this.manifest=null,this.loadingState="idle",this.error=null,this.templateId=null,this.templateType=null,qr.log("Registry cleared")}};M(er,"instance",null),M(er,"manifestCache",new Map);let Ar=er;const us=pt("PipeRegistry");function Yg(s,e){const n=s.getFullYear(),r=String(s.getMonth()+1).padStart(2,"0"),i=String(s.getDate()).padStart(2,"0"),l=String(s.getHours()).padStart(2,"0"),c=String(s.getMinutes()).padStart(2,"0"),d=String(s.getSeconds()).padStart(2,"0");return e.replace("YYYY",String(n)).replace("YY",String(n).slice(-2)).replace("MM",r).replace("M",String(s.getMonth()+1)).replace("DD",i).replace("D",String(s.getDate())).replace("HH",l).replace("H",String(s.getHours())).replace("mm",c).replace("m",String(s.getMinutes())).replace("ss",d).replace("s",String(s.getSeconds()))}function A0(s,e="ko"){const r=new Date().getTime()-s.getTime(),i=Math.floor(r/1e3),l=Math.floor(i/60),c=Math.floor(l/60),d=Math.floor(c/24),f=Math.floor(d/7),h=Math.floor(d/30),m=Math.floor(d/365);return e==="ko"?i<60?"방금 전":l<60?`${l}분 전`:c<24?`${c}시간 전`:d<7?`${d}일 전`:f<4?`${f}주 전`:h<12?`${h}개월 전`:`${m}년 전`:i<60?"just now":l<60?`${l} minute${l===1?"":"s"} ago`:c<24?`${c} hour${c===1?"":"s"} ago`:d<7?`${d} day${d===1?"":"s"} ago`:f<4?`${f} week${f===1?"":"s"} ago`:h<12?`${h} month${h===1?"":"s"} ago`:`${m} year${m===1?"":"s"} ago`}function Bd(s){if(s==null)return null;if(s instanceof Date)return s;if(typeof s=="number")return new Date(s);if(typeof s=="string"){const e=new Date(s);return isNaN(e.getTime())?null:e}return null}const mo={date:{fn:(s,e="YYYY-MM-DD")=>{const n=Bd(s);return n?Yg(n,e):""},description:"날짜 포맷 (기본: YYYY-MM-DD)"},datetime:{fn:(s,e="YYYY-MM-DD HH:mm")=>{const n=Bd(s);return n?Yg(n,e):""},description:"날짜+시간 포맷 (기본: YYYY-MM-DD HH:mm)"},relativeTime:{fn:(s,e="ko")=>{const n=Bd(s);return n?A0(n,e):""},description:'상대 시간 표시 (예: "3분 전")'},number:{fn:(s,e)=>{const n=Number(s);if(isNaN(n))return String(s??"");const r={};return e!==void 0&&(r.minimumFractionDigits=e,r.maximumFractionDigits=e),n.toLocaleString(void 0,r)},description:"숫자 포맷 (천단위 구분, 선택적 소수점)"},truncate:{fn:(s,e=100,n="...")=>typeof s!="string"?String(s??""):s.length<=e?s:s.slice(0,e)+n,description:'문자열 자르기 (기본: 100자, 접미사: "...")'},uppercase:{fn:s=>typeof s!="string"?String(s??""):s.toUpperCase(),description:"대문자 변환"},lowercase:{fn:s=>typeof s!="string"?String(s??""):s.toLowerCase(),description:"소문자 변환"},stripHtml:{fn:s=>typeof s!="string"?String(s??""):s.replace(/<[^>]*>/g,""),description:"HTML 태그 제거"},default:{fn:(s,e="")=>s==null||s===""?e:s,description:"기본값 설정 (null, undefined, 빈문자열 시)"},fallback:{fn:(s,e)=>s??e,description:"폴백 값 설정 (null, undefined 시만)"},first:{fn:s=>{if(Array.isArray(s))return s[0]},description:"배열의 첫 번째 요소"},last:{fn:s=>{if(Array.isArray(s))return s[s.length-1]},description:"배열의 마지막 요소"},join:{fn:(s,e=", ")=>Array.isArray(s)?s.join(e):"",description:'배열을 문자열로 결합 (기본 구분자: ", ")'},length:{fn:s=>Array.isArray(s)||typeof s=="string"?s.length:0,description:"배열/문자열 길이"},filterBy:{fn:(s,e,n)=>Array.isArray(s)?Array.isArray(e)?s.filter(r=>{const i=n?r?.[n]:r;return e.includes(i)}):s:[],description:"배열 필터링 (allowList에 포함된 항목만 반환)"},keys:{fn:s=>s==null||typeof s!="object"?[]:Object.keys(s),description:"객체의 키 배열"},values:{fn:s=>s==null||typeof s!="object"?[]:Object.values(s),description:"객체의 값 배열"},json:{fn:(s,e)=>{try{return JSON.stringify(s,null,e)}catch{return""}},description:"JSON 문자열로 변환"},localized:{fn:(s,e)=>s==null?"":typeof s=="string"?s:typeof s!="object"?String(s):s[e||"ko"]||s.ko||s.en||Object.values(s)[0]||"",description:"다국어 객체에서 로케일에 맞는 값 추출"}},ds=new Map,Li=class Li{static getInstance(){return Li.instance||(Li.instance=new Li),Li.instance}register(e,n,r){if(mo[e]){us.warn(`[PipeRegistry] 내장 파이프를 덮어쓸 수 없습니다: ${e}`);return}ds.set(e,{fn:n,description:r}),us.log(`[PipeRegistry] 커스텀 파이프 등록됨: ${e}`)}unregister(e){if(mo[e])return us.warn(`[PipeRegistry] 내장 파이프는 해제할 수 없습니다: ${e}`),!1;const n=ds.delete(e);return n&&us.log(`[PipeRegistry] 커스텀 파이프 해제됨: ${e}`),n}get(e){const n=mo[e];return n?n.fn:ds.get(e)?.fn}has(e){return!!mo[e]||ds.has(e)}execute(e,n,r=[]){const i=this.get(e);if(!i)return us.warn(`[PipeRegistry] 알 수 없는 파이프: ${e}`),n;try{return i(n,...r)}catch(l){return us.error(`[PipeRegistry] 파이프 실행 오류 (${e}):`,l),n}}list(){const e=[];for(const[n,r]of Object.entries(mo))e.push({name:n,description:r.description,type:"built-in"});for(const[n,r]of ds.entries())e.push({name:n,description:r.description,type:"custom"});return e.sort((n,r)=>n.name.localeCompare(r.name))}clearCustomPipes(){ds.clear()}};M(Li,"instance",null);let rc=Li;rc.getInstance();function x0(s){const e=s.trim(),n=e.indexOf("(");if(n===-1)return{name:e,args:[]};const r=e.slice(0,n).trim(),i=e.slice(n+1,-1);if(!i.trim())return{name:r,args:[]};const l=[];let c="",d=null,f=0;for(let h=0;h0?i[h-1]:"")==="\\"){c+=m;continue}if((m==='"'||m==="'")&&!d){d=m;continue}if(m===d){d=null;continue}if(d){c+=m;continue}if(m==="("||m==="["||m==="{"){f++,c+=m;continue}if(m===")"||m==="]"||m==="}"){f--,c+=m;continue}if(m===","&&f===0){l.push(Xg(c.trim())),c="";continue}c+=m}return c.trim()&&l.push(Xg(c.trim())),{name:r,args:l}}function Xg(s){if(s==="null")return null;if(s==="undefined")return;if(s==="true")return!0;if(s==="false")return!1;const e=Number(s);return!isNaN(e)&&s!==""?e:s}function T0(s){const e=[];let n="",r=null,i=0;for(let l=0;l0?s[l-1]:"",f=l0?s[r-1]:"",c=r",e),this.cacheVersion=e,this.cache.clear())}getCacheVersion(){return this.cacheVersion}async loadTranslations(e,n,r="/api",i=!1){const l=`${e}:${n}`;if(!i){const c=this.getFromCache(l);if(c)return this.translations.set(l,c),c}try{const c=[];i&&c.push(`_=${Date.now()}`);const d=Br(`${r}/templates/${e}/lang/${n}`,"json",this.cacheVersion>0?this.cacheVersion:null,c.length>0?c.join("&"):void 0),f=!i&&this.cacheVersion>0?go(`templates/${e}/lang/${n}.json`,this.cacheVersion):null,h=f!==null?await nc(f,d,{label:`lang/${n}.json`}):await fetch(d);if(!h.ok)throw new Gd(`Failed to load translations: ${h.statusText}`,void 0,n);const y=await h.json();return this.saveToCache(l,y),this.translations.set(l,y),y}catch(c){throw new Gd(`Failed to fetch translations for ${n}: ${c instanceof Error?c.message:String(c)}`,void 0,n)}}resolveTranslations(e,n,r){let i=e;const l=5;let c=0;for(;c"="+this.translate(m,n,void 0,r)),i===d)break;c++}return i.replace(Pn.TRANSLATION_PATTERN,(d,f,h)=>{const{cleanedParams:m,trailing:y}=this.separateTrailingText(h);return this.translate(f,n,m,r)+y})}translate(e,n,r,i){const l=this.getTranslation(e,n),c=r&&this.cleanParamsStr(r);if(c){const d=this.parseParams(c,i);return this.replaceParams(l,d)}return l}getTranslation(e,n){const{templateId:r,locale:i}=n,l=`${r}:${i}`,c=this.translations.get(l);if(c){const d=this.getNestedValue(c,e);if(d!==null)return d}if(i!==this.options.fallbackLocale){const d=`${r}:${this.options.fallbackLocale}`,f=this.translations.get(d);if(f){const h=this.getNestedValue(f,e);if(h!==null)return h}}return e}getNestedValue(e,n){const r=n.split(".");let i=e;for(const l of r){if(i==null||typeof i!="object")return null;i=i[l]}return typeof i=="string"?i:null}setTranslationValue(e,n,r,i){const l=`${e}:${n}`,c=this.translations.get(l)??{},d=r.split(".");let f=c;for(let h=0;h(l.push(f),`__PLACEHOLDER_${l.length-1}__`)).matchAll(Pn.PARAM_PATTERN);for(const f of d){const[,h,m]=f,y=m.replace(/__PLACEHOLDER_(\d+)__/g,(v,S)=>l[parseInt(S,10)]);r[h.trim()]=this.resolveParamValue(y.trim(),n)}return r}resolveParamValue(e,n){if(e.startsWith("{{")&&e.endsWith("}}")){const r=e.slice(2,-2).trim();if(jn(r)&&n)try{const l=oc.evaluatePipeExpression(r,n);return String(l??"")}catch(l){return qd.error("Pipe expression evaluation failed:",r,l),""}if(/[|&()[\]!?:+\-*/%<>=\s]/.test(r)&&n)try{const l=oc.evaluateExpression(r,n);return String(l??"")}catch(l){return qd.error("Expression evaluation failed:",r,l),""}else{const l=this.getNestedDataValue(n,r);return String(l??"")}}return e}separateTrailingText(e){if(!e)return{cleanedParams:void 0,trailing:""};if(e.trimEnd().endsWith("}}"))return{cleanedParams:e,trailing:""};if(!(e.startsWith("|")?e.slice(1):e).includes("="))return{cleanedParams:void 0,trailing:e};const r=e.match(/(\s+[^\p{L}\w=|&\s][^\p{L}\w=]*\s*)$/u);return r?{cleanedParams:e.slice(0,-r[1].length),trailing:r[1]}:{cleanedParams:e,trailing:""}}cleanParamsStr(e){return this.separateTrailingText(e).cleanedParams||""}getNestedDataValue(e,n){if(!e)return;const r=n.split(".");let i=e;for(const l of r){if(i==null)return;i=i[l]}return i}replaceParams(e,n){let r=e;for(const[i,l]of Object.entries(n)){const c=new RegExp(`\\{\\{${i}\\}\\}`,"g");r=r.replace(c,String(l));const d=new RegExp(`\\{${i}\\}`,"g");r=r.replace(d,String(l))}return r}getFromCache(e){const n=this.cache.get(e);return n?Date.now()-n.timestamp>this.options.cacheTTL?(this.cache.delete(e),null):n.data:null}saveToCache(e,n){this.cache.set(e,{data:n,timestamp:Date.now()})}clearCache(){this.cache.clear(),this.translations.clear()}pruneCache(){const e=Date.now(),n=[];for(const[r,i]of this.cache.entries())e-i.timestamp>this.options.cacheTTL&&n.push(r);for(const r of n)this.cache.delete(r)}getCacheStats(){const e=Date.now();let n=0;for(const r of this.cache.values())e-r.timestamp>this.options.cacheTTL&&n++;return{size:this.cache.size,expired:n}}};M(Pn,"instance",null),M(Pn,"TRANSLATION_PATTERN",/\$t:(?:defer:)?([a-zA-Z0-9._-]+)(\|(?:(?!\$t:).)+)?/g),M(Pn,"NESTED_TRANSLATION_PARAM_PATTERN",/=(\$t:([a-zA-Z0-9._-]+))(?=[|&\s]|$)/g),M(Pn,"PARAM_PATTERN",/([^=|&]+)=([^|&]+)/g);let vi=Pn;const Jg=Object.freeze(Object.defineProperty({__proto__:null,TranslationEngine:vi,TranslationError:Gd},Symbol.toStringTag,{value:"Module"})),Fd=new Map([["true",!0],["false",!1],["null",null],["undefined",void 0]]);function Oa(s){if(typeof s!="string"||!s.startsWith("{{")||!s.endsWith("}}")||s.length<4)return null;const e=s.slice(2,-2);let n=null,r=0;for(let i=0;i0){r--;continue}return null}}return r===0?e.trim():null}function R0(s){const e=[];if(typeof s!="string")return e;for(let n=0;n0){i--;continue}if(s[c+1]==="}"){l=c;break}break}}l!==-1&&(e.push({start:n,end:l+2,expr:s.slice(n+2,l)}),n=l+1)}return e}function yo(s){return/[?:|&!+\-*/<>=()[\]{}]/.test(s)}function Qg(s){const e=typeof s=="string"?s.trim():"";return e===""?"empty":Fd.has(e)?"literal":jn(e)?"pipe":yo(e)?"expression":"path"}function Vd(s,e,n,r){const i=typeof s=="string"?s.trim():"",l=Qg(i),c=r?.skipCache?{skipCache:!0}:void 0;if(l==="empty"){r?.onEmpty?.(s);return}if(l==="literal")return Fd.get(i);try{return l==="pipe"?n.evaluatePipeExpression(i,e,c,r?.trackingInfo):l==="expression"?n.evaluateExpression(i,e,r?.trackingInfo):n.resolve(i,e,c,r?.trackingInfo)}catch(d){if(r?.onError)return r.onError(d,i);throw d}}const lr="raw:";function Zg(s){return s.startsWith(lr)?s.slice(lr.length):s}const bo="﷐",Si="﷑",La="﷒";function vo(s){return bo+s+Si}function ac(s){return s.length>=2&&s.charCodeAt(0)===64976&&s.charCodeAt(s.length-1)===64977}function ic(s){return s.includes(bo)}function Kd(s){return s.slice(1,-1)}function fs(s){if(typeof s=="string")return vo(s);if(Array.isArray(s))return s.map(fs);if(s&&typeof s=="object"){const e={};for(const[n,r]of Object.entries(s))e[n]=fs(r);return e}return s}function $a(s){if(typeof s=="string")return ac(s)?Kd(s):ic(s)||s.includes(Si)?s.split(bo).join("").split(Si).join(""):s;if(Array.isArray(s)){let e=!1;const n=s.map(r=>{const i=$a(r);return i!==r&&(e=!0),i});return e?n:s}if(s&&typeof s=="object"){if(s.$$typeof!==void 0)return s;let e=!1;const n={};for(const[r,i]of Object.entries(s)){const l=$a(i);l!==i&&(e=!0),n[r]=l}return e?n:s}return s}const So=new Set(["constructor","__proto__","prototype","__lookupGetter__","__lookupSetter__","__defineGetter__","__defineSetter__"]),D0=new Set(["Function","eval","globalThis","window","self","document","require","module","process","Reflect","Proxy","WebAssembly","import","constructor"]);function em(s,e){if(s!==null&&(typeof s=="object"||typeof s=="function")&&tm.has(s))throw new Error(`Object.${e} on a built-in global object is not allowed`);return s}const O0=Object.freeze({keys:Object.keys,values:Object.values,entries:Object.entries,assign:(s,...e)=>{const n=em(s,"assign");for(const r of e)if(r!=null)for(const i of Object.keys(r)){if(So.has(i))throw new Error(`Access to "${i}" is forbidden`);tf(n,i,r[i])}return n},freeze:s=>Object.freeze(em(s,"freeze")),fromEntries:Object.fromEntries,create:Object.create,isFrozen:Object.isFrozen}),Wd={Math,JSON,Date,Array,Object:O0,Number,String,Boolean,Set,Map,WeakSet,WeakMap,parseInt,parseFloat,isNaN,isFinite},Yd={Date,Set,Map,WeakSet,WeakMap,Array,Number,String,Boolean,Object},tm=new Set([...Object.values(Wd),...Object.values(Yd)].filter(s=>s!==null&&(typeof s=="object"||typeof s=="function"))),sc=new Set(["function"]),xr=Symbol("short-circuit");class Xd{constructor(e){this.value=e}}class Jd{}class Qd{}function L0(s){return/[A-Za-z_$]/.test(s)}function $0(s){return/[A-Za-z0-9_$]/.test(s)}function wi(s){return s>="0"&&s<="9"}function M0(s,e,n){let r=e+1;for(;r0;){const h=s[n];if(h==="{")f++,n++;else if(h==="}"){if(f--,f===0)break;n++}else h==='"'||h==="'"?n=M0(s,n,h):h==="`"?n=nm(s,n).end:n++}if(f!==0)throw new Error("Unterminated ${...} in template literal");i.push(s.slice(d,n)),n++;continue}l+=c,n++}throw new Error(`Unterminated template literal at position ${e}`)}function N0(s){const e=[];let n=0;const r=s.length,i=l=>n+l=r)throw new Error(`Unterminated string literal at position ${h}`);n++,e.push({type:"str",value:y,pos:h});continue}if(L0(l)){const h=n;for(n++;n"?(e.push({type:"punct",value:"=>",pos:c}),n+=2):i(1)==="="?i(2)==="="?(e.push({type:"punct",value:"===",pos:c}),n+=3):(e.push({type:"punct",value:"==",pos:c}),n+=2):(e.push({type:"punct",value:"=",pos:c}),n+=1);continue}case"!":{i(1)==="="?i(2)==="="?(e.push({type:"punct",value:"!==",pos:c}),n+=3):(e.push({type:"punct",value:"!=",pos:c}),n+=2):(e.push({type:"punct",value:"!",pos:c}),n+=1);continue}case"<":{if(i(1)==="=")e.push({type:"punct",value:"<=",pos:c}),n+=2;else{if(i(1)==="<")throw new Error("Bitwise/shift operators are not allowed");e.push({type:"punct",value:"<",pos:c}),n+=1}continue}case">":{if(i(1)==="=")e.push({type:"punct",value:">=",pos:c}),n+=2;else{if(i(1)===">")throw new Error("Bitwise/shift operators are not allowed");e.push({type:"punct",value:">",pos:c}),n+=1}continue}case"&":{if(i(1)==="&")e.push({type:"punct",value:"&&",pos:c}),n+=2;else throw new Error("Bitwise operators are not allowed");continue}case"|":{if(i(1)==="|")e.push({type:"punct",value:"||",pos:c}),n+=2;else throw new Error("Bitwise operators are not allowed");continue}case"?":{i(1)==="."&&!wi(i(2))?(e.push({type:"punct",value:"?.",pos:c}),n+=2):i(1)==="?"?(e.push({type:"punct",value:"??",pos:c}),n+=2):(e.push({type:"punct",value:"?",pos:c}),n+=1);continue}case"+":{if(i(1)==="+")throw new Error("Increment operator is not allowed");if(i(1)==="=")throw new Error("Assignment operators are not allowed");e.push({type:"punct",value:"+",pos:c}),n+=1;continue}case"-":{if(i(1)==="-")throw new Error("Decrement operator is not allowed");if(i(1)==="=")throw new Error("Assignment operators are not allowed");e.push({type:"punct",value:"-",pos:c}),n+=1;continue}case"*":{if(i(1)==="=")throw new Error("Assignment operators are not allowed");if(i(1)==="*")throw new Error("Exponentiation operator is not supported");e.push({type:"punct",value:"*",pos:c}),n+=1;continue}case"/":{if(i(1)==="=")throw new Error("Assignment operators are not allowed");e.push({type:"punct",value:"/",pos:c}),n+=1;continue}case"%":{if(i(1)==="=")throw new Error("Assignment operators are not allowed");e.push({type:"punct",value:"%",pos:c}),n+=1;continue}case"~":case"^":throw new Error("Bitwise operators are not allowed");case".":case":":case"(":case")":case"[":case"]":case"{":case"}":case",":e.push({type:"punct",value:l,pos:c}),n+=1;continue;case";":e.push({type:"punct",value:";",pos:c}),n+=1;continue;default:throw new Error(`Unexpected character "${l}" at position ${c}`)}}return e}const I0={"??":1,"||":1,"&&":2,"===":3,"!==":3,"==":3,"!=":3,"<":4,">":4,"<=":4,">=":4,"+":5,"-":5,"*":6,"/":6,"%":6},j0=new Set(["??","||","&&"]);class H0{constructor(e){M(this,"tokens");M(this,"pos",0);this.tokens=e}atEnd(){return this.pos>=this.tokens.length}peek(e=0){const n=this.pos+e;return n"}"`);this.pos++}parseExpression(){const e=this.tryParseArrow();return e||this.parseTernary()}tryParseArrow(){const e=this.pos,n=this.peek();if(!n)return null;if(n.type==="ident"&&this.isPunct("=>",1)&&!sc.has(String(n.value))){this.pos+=1,this.pos+=1;const{body:r,isBlock:i}=this.parseArrowBody();return{type:"Arrow",params:[{name:String(n.value),default:null}],body:r,isBlock:i}}if(n.type==="punct"&&n.value==="("){this.pos+=1;const r=this.tryParseParamList();if(r&&this.isPunct(")")&&(this.pos+=1,this.isPunct("=>"))){this.pos+=1;const{body:i,isBlock:l}=this.parseArrowBody();return{type:"Arrow",params:r,body:i,isBlock:l}}return this.pos=e,null}return this.pos=e,null}tryParseParamList(){const e=[];if(this.isPunct(")"))return e;for(;;){const n=this.peek();let r=null,i;if(n&&n.type==="punct"&&n.value==="["){const c=this.tryParseArrayPattern();if(!c)return null;i=c}else if(n&&n.type==="ident"&&!sc.has(String(n.value)))r=String(n.value),this.pos+=1;else return null;let l=null;if(this.isPunct("=")&&(this.pos+=1,l=this.parseExpression()),e.push(i?{name:r,elements:i,default:l}:{name:r,default:l}),this.isPunct(",")){this.pos+=1;continue}break}return e}tryParseArrayPattern(){const e=this.pos;this.pos+=1;const n=[];for(;;){if(this.isPunct("]"))return this.pos+=1,n;if(this.isPunct(",")){n.push(null),this.pos+=1;continue}const r=this.peek();if(!r||r.type!=="ident"||sc.has(String(r.value)))return this.pos=e,null;if(n.push(String(r.value)),this.pos+=1,this.isPunct(",")){this.pos+=1;continue}return this.isPunct("]")?(this.pos+=1,n):(this.pos=e,null)}}parseArrowBody(){return this.isPunct("{")?{body:this.parseBlock(),isBlock:!0}:{body:this.parseExpression(),isBlock:!1}}parseBlock(){this.expectPunct("{");const e=[];for(;!this.isPunct("}");){if(this.atEnd())throw new Error("Unterminated block");e.push(this.parseStatement())}return this.expectPunct("}"),{type:"Block",body:e}}parseStatement(){const e=this.peek();if(!e)throw new Error("Unexpected end of statement");if(e.type==="punct"&&e.value==="{")return this.parseBlock();if(e.type==="punct"&&e.value===";")return this.pos+=1,{type:"Empty"};if(e.type==="ident")switch(String(e.value)){case"const":case"let":return this.parseVarDecl();case"if":return this.parseIf();case"for":return this.parseForOf();case"return":return this.parseReturn();case"try":return this.parseTry();case"break":return this.pos+=1,this.consumeSemicolon(),{type:"Break"};case"continue":return this.pos+=1,this.consumeSemicolon(),{type:"Continue"}}const n=this.parseExpression();return this.consumeSemicolon(),{type:"ExprStmt",expression:n}}consumeSemicolon(){this.isPunct(";")&&(this.pos+=1)}parseVarDecl(){this.pos+=1;const e=[];for(;;){const n=this.peek();if(!n||n.type!=="ident")throw new Error("Expected variable name in declaration");const r=String(n.value);this.pos+=1,this.expectPunct("=");const i=this.parseExpression();if(e.push({name:r,init:i}),this.isPunct(",")){this.pos+=1;continue}break}return this.consumeSemicolon(),{type:"VarDecl",declarations:e}}parseIf(){this.pos+=1,this.expectPunct("(");const e=this.parseExpression();this.expectPunct(")");const n=this.parseStatement();let r=null;const i=this.peek();return i&&i.type==="ident"&&i.value==="else"&&(this.pos+=1,r=this.parseStatement()),{type:"If",test:e,consequent:n,alternate:r}}parseForOf(){this.pos+=1,this.expectPunct("(");const e=this.peek();if(!e||e.type!=="ident"||e.value!=="const"&&e.value!=="let")throw new Error('Only "for (const x of …)" / "for (let x of …)" loops are supported');this.pos+=1;const n=this.peek();if(!n||n.type!=="ident")throw new Error("Expected loop variable name");const r=String(n.value);this.pos+=1;const i=this.peek();if(!i||i.type!=="ident"||i.value!=="of")throw new Error("Only for-of loops are supported (for-in / C-style for are not allowed)");this.pos+=1;const l=this.parseExpression();this.expectPunct(")");const c=this.parseStatement();return{type:"ForOf",name:r,iterable:l,body:c}}parseReturn(){if(this.pos+=1,this.isPunct(";")||this.isPunct("}")||this.atEnd())return this.consumeSemicolon(),{type:"Return",argument:null};const e=this.parseExpression();return this.consumeSemicolon(),{type:"Return",argument:e}}parseTry(){this.pos+=1;const e=this.parseBlock();let n=null,r=null,i=null;const l=this.peek();if(l&&l.type==="ident"&&l.value==="catch"){if(this.pos+=1,this.isPunct("(")){this.pos+=1;const d=this.peek();d&&d.type==="ident"&&(n=String(d.value),this.pos+=1),this.expectPunct(")")}r=this.parseBlock()}const c=this.peek();if(c&&c.type==="ident"&&c.value==="finally"&&(this.pos+=1,i=this.parseBlock()),!r&&!i)throw new Error("Missing catch or finally after try");return{type:"Try",block:e,handlerParam:n,handler:r,finalizer:i}}parseFunctionExpression(){this.pos+=1;let e=null;const n=this.peek();n&&n.type==="ident"&&n.value!==void 0&&!this.isPunct("(")&&(e=String(n.value),this.pos+=1),this.expectPunct("(");const r=this.tryParseParamList();if(!r)throw new Error("Invalid function parameter list");this.expectPunct(")");const i=this.parseBlock();return{type:"Function",name:e,params:r,body:i}}parseTernary(){const e=this.parseBinary(0);if(this.isPunct("?")){this.pos+=1;const n=this.parseExpression();this.expectPunct(":");const r=this.parseExpression();return{type:"Conditional",test:e,consequent:n,alternate:r}}return e}parseBinary(e){let n=this.parseUnary();for(;;){const r=this.peek();if(!r||r.type!=="punct")break;const i=String(r.value),l=I0[i];if(l===void 0||lrm(l));return{type:"Template",quasis:n,expressions:i}}if(e.type==="ident"&&e.value==="new")return this.parseNew();if(e.type==="ident"&&e.value==="function")return this.parseFunctionExpression();if(e.type==="ident"){const n=String(e.value);if(sc.has(n))throw new Error(`Keyword "${n}" is not allowed`);switch(this.pos+=1,n){case"true":return{type:"Literal",value:!0};case"false":return{type:"Literal",value:!1};case"null":return{type:"Literal",value:null};case"undefined":return{type:"Literal",value:void 0};default:return{type:"Identifier",name:n}}}if(e.type==="punct"){if(e.value==="("){this.pos+=1;const n=this.parseExpression();return this.expectPunct(")"),n}if(e.value==="[")return this.parseArrayLiteral();if(e.value==="{")return this.parseObjectLiteral()}throw new Error(`Unexpected token "${e.value}"`)}parseArrayLiteral(){this.expectPunct("[");const e=[];for(;!this.isPunct("]");){if(this.isPunct(",")){this.pos+=1,e.push({type:"Literal",value:void 0});continue}if(this.isPunct("...")?(this.pos+=1,e.push({type:"Spread",argument:this.parseExpression()})):e.push(this.parseExpression()),this.isPunct(",")){this.pos+=1;continue}break}return this.expectPunct("]"),{type:"Array",elements:e}}parseObjectLiteral(){this.expectPunct("{");const e=[];for(;!this.isPunct("}");){if(this.isPunct("..."))this.pos+=1,e.push({kind:"spread",value:this.parseExpression()});else{let n,r=!1;const i=this.peek();if(!i)throw new Error("Unexpected end of expression in object literal");if(i.type==="punct"&&i.value==="[")this.pos+=1,n=this.parseExpression(),this.expectPunct("]"),r=!0;else if(i.type==="str")this.pos+=1,n={type:"Literal",value:i.value};else if(i.type==="num")this.pos+=1,n={type:"Literal",value:String(i.value)};else if(i.type==="ident")this.pos+=1,n={type:"Literal",value:String(i.value)};else throw new Error(`Unexpected token "${i.value}" in object literal`);if(this.isPunct(":")){this.pos+=1;const l=this.parseExpression();e.push({kind:"init",key:n,computed:r,value:l})}else{if(r||n.type!=="Literal"||typeof n.value!="string")throw new Error("Invalid shorthand property in object literal");if(i.type!=="ident")throw new Error("Invalid shorthand property in object literal");e.push({kind:"init",key:n,computed:!1,value:{type:"Identifier",name:n.value}})}}if(this.isPunct(",")){this.pos+=1;continue}break}return this.expectPunct("}"),{type:"Object",properties:e}}}function rm(s){const e=N0(s),n=new H0(e),r=n.parseExpression();if(!n.atEnd()){const i=n.peek();throw i&&i.type==="punct"&&i.value===","?new Error("The comma/sequence operator is not allowed"):new Error(`Unexpected token "${i?i.value:""}" after expression`)}return r}function z0(s,e){let n=e;for(;n;){if(Object.prototype.hasOwnProperty.call(n.vars,s))return n.vars[s];n=n.parent}if(Object.prototype.hasOwnProperty.call(Wd,s))return Wd[s];if(D0.has(s))throw new Error(`Reference to forbidden global "${s}" is not allowed`)}function Zd(s){const e=typeof s=="symbol"?s:String(s);if(typeof e=="string"&&So.has(e))throw new Error(`Access to "${e}" is forbidden`);return e}function ef(s,e){return s.type==="Member"?am(s,e):s.type==="Call"?im(s,e):et(s,e)}function am(s,e){const n=ef(s.object,e);if(n===xr||s.optional&&n==null)return xr;let r;s.computed?r=et(s.property,e):r=s.property.value;const i=Zd(r);if(n!=null)return n[i]}function im(s,e){let n,r;if(s.callee.type==="Member"){const l=s.callee,c=ef(l.object,e);if(c===xr||l.optional&&c==null)return xr;let d;l.computed?d=et(l.property,e):d=l.property.value;const f=Zd(d);c==null?n=void 0:(n=c[f],r=c)}else if(n=ef(s.callee,e),n===xr)return xr;if(s.optional&&n==null)return xr;if(typeof n!="function")throw new Error("Attempted to call a non-function value");const i=sm(s.args,e);return n.apply(r,i)}function sm(s,e){const n=[];for(const r of s)if(r.type==="Spread"){const i=et(r.argument,e);if(i!=null)for(const l of i)n.push(l)}else n.push(et(r,e));return n}function om(s,e,n){for(let r=0;r":return n>r;case"<=":return n<=r;case">=":return n>=r;default:throw new Error(`Unknown binary operator "${s.operator}"`)}}case"Logical":{const n=et(s.left,e);switch(s.operator){case"&&":return n&&et(s.right,e);case"||":return n||et(s.right,e);case"??":return n??et(s.right,e);default:throw new Error(`Unknown logical operator "${s.operator}"`)}}case"Conditional":return et(s.test,e)?et(s.consequent,e):et(s.alternate,e);case"Array":{const n=[];for(const r of s.elements)if(r.type==="Spread"){const i=et(r.argument,e);if(i!=null)for(const l of i)n.push(l)}else n.push(et(r,e));return n}case"Object":{const n={};for(const r of s.properties)if(r.kind==="spread"){const i=et(r.value,e);if(i!=null&&typeof i=="object")for(const l of Object.keys(i))tf(n,l,i[l])}else{let i;r.computed?i=et(r.key,e):i=r.key.value;const l=et(r.value,e);tf(n,String(i),l)}return n}case"Arrow":{const n=e,r=s.params,i=s.body,l=s.isBlock;return function(...d){const f={vars:{},parent:n};return om(r,d,f),l?lm(i,f):et(i,f)}}case"Function":{const n=e,r=s.params,i=s.body,l=s.name,c=function(...f){const h={vars:{},parent:n};return l&&(h.vars[l]=c),om(r,f,h),lm(i,h)};return c}case"Delete":{const n=s.argument,r=et(n.object,e);let i;n.computed?i=et(n.property,e):i=n.property.value;const l=Zd(i);if(r==null||typeof r!="object"&&typeof r!="function")return!0;if(tm.has(r))throw new Error("delete on a built-in global object is not allowed");return delete r[l]}case"Block":{const n={vars:{},parent:e};for(const r of s.body)et(r,n);return}case"VarDecl":{for(const n of s.declarations)e.vars[n.name]=et(n.init,e);return}case"If":{et(s.test,e)?et(s.consequent,e):s.alternate&&et(s.alternate,e);return}case"ForOf":{const n=et(s.iterable,e);if(n!=null)for(const r of n){const i={vars:{},parent:e};i.vars[s.name]=r;try{et(s.body,i)}catch(l){if(l instanceof Qd)continue;if(l instanceof Jd)break;throw l}}return}case"Return":throw new Xd(s.argument?et(s.argument,e):void 0);case"ExprStmt":et(s.expression,e);return;case"Break":throw new Jd;case"Continue":throw new Qd;case"Empty":return;case"Try":{try{try{et(s.block,e)}catch(n){if(n instanceof Xd||n instanceof Jd||n instanceof Qd)throw n;if(s.handler){const r={vars:{},parent:e};s.handlerParam&&(r.vars[s.handlerParam]=n),et(s.handler,r)}else throw n}}finally{s.finalizer&&et(s.finalizer,e)}return}case"New":{const n=Yd[s.ctor];if(typeof n!="function")throw new Error("new on non-whitelisted constructor");const r=sm(s.args,e);return new n(...r)}case"Template":{let n=s.quasis[0]??"";for(let r=0;r0}getFromRenderCycleCache(e){if(this.isRenderCycleCacheActive())return this.renderCycleCache.get(e)}saveToRenderCycleCache(e,n){this.isRenderCycleCacheActive()&&this.renderCycleCache.set(e,n)}resolveBindings(e,n,r,i){const l={...this.defaultOptions,...r},c=wo(),d=n._computed&&!n.$computed?{...n,$computed:n._computed}:n,f=(v,S)=>{const _=S.trim();let x=!1,A=_;if(_.startsWith(lr)&&(x=!0,A=_.slice(lr.length)),jn(A))try{const z=this.evaluatePipeExpression(A,d,l,{...i,method:"resolveBindings",displayExpression:`{{${_}}}`}),W=this.formatValue(z);return x?vo(W):W}catch(z){return Ma.error("Pipe expression evaluation failed:",A,z),v}if(yo(A)){const z=c?.isEnabled()?performance.now():0;try{let W,de=!1;if(l.skipCache)W=this.evaluateExpression(A,d);else{const Se=`expr:${A}`,je=this.getFromRenderCycleCache(Se);je!==void 0?(W=je,de=!0):(W=this.evaluateExpression(A,d),this.saveToRenderCycleCache(Se,W))}if(c?.isEnabled()){const Se=performance.now()-z;c.trackExpressionEval({expression:`{{${_}}}`,result:this.sanitizeResultForTracking(W),resultType:this.getResultType(W),componentId:i?.componentId,componentName:i?.componentName,propName:i?.propName,fromCache:de,duration:Se,method:"resolveBindings",skipCache:l.skipCache})}const _e=this.formatValue(W);return x?vo(_e):_e}catch(W){return Ma.error("Expression evaluation failed:",A,W),v}}if(l.skipCache){const z=c?.isEnabled()?performance.now():0,W=this.resolvePath(A,d,l);if(c?.isEnabled()){const _e=performance.now()-z;c.trackExpressionEval({expression:`{{${_}}}`,result:this.sanitizeResultForTracking(W),resultType:this.getResultType(W),componentId:i?.componentId,componentName:i?.componentName,propName:i?.propName,fromCache:!1,duration:_e,method:"resolveBindings",skipCache:!0})}const de=this.formatValue(W);return x?vo(de):de}const O=A.startsWith("_global")||A.startsWith("_local")||A.startsWith("_isolated")||A.startsWith("$parent"),k=c?.isEnabled()?performance.now():0;let L,B=!1;if(O){const z=this.getFromRenderCycleCache(A);z!==void 0?(L=z,B=!0):(L=this.resolvePath(A,d,l),this.saveToRenderCycleCache(A,L))}else{const z=this.getFromCache(A);z!==void 0?(L=z,B=!0):(L=this.resolvePath(A,d,l),this.saveToCache(A,L))}if(c?.isEnabled()){const z=performance.now()-k;c.trackExpressionEval({expression:`{{${_}}}`,result:this.sanitizeResultForTracking(L),resultType:this.getResultType(L),componentId:i?.componentId,componentName:i?.componentName,propName:i?.propName,fromCache:B,duration:z,method:"resolveBindings",skipCache:l.skipCache})}const q=this.formatValue(L);return x?vo(q):q},h=R0(e);if(h.length===0)return e;let m="",y=0;for(const v of h)m+=e.slice(y,v.start),m+=f(e.slice(v.start,v.end),v.expr),y=v.end;return m+e.slice(y)}evaluatePipeExpression(e,n,r,i){const l={...this.defaultOptions,...r},c=wo(),d=c?.isEnabled()?performance.now():0,f=n._computed&&!n.$computed?{...n,$computed:n._computed}:n,[h,m]=T0(e);let y,v=!1;const S=yo(h),_=h.startsWith("_global")||h.startsWith("_local")||h.startsWith("_isolated")||h.startsWith("$parent");if(l.skipCache)S?y=this.evaluateExpression(h,f):y=this.resolvePath(h,f,l);else if(S){const A=this.getFromRenderCycleCache(`expr:${h}`);A!==void 0?(y=A,v=!0):(y=this.evaluateExpression(h,f),this.saveToRenderCycleCache(`expr:${h}`,y))}else if(_){const A=this.getFromRenderCycleCache(h);A!==void 0?(y=A,v=!0):(y=this.resolvePath(h,f,l),this.saveToRenderCycleCache(h,y))}else{const A=this.getFromCache(h);A!==void 0?(y=A,v=!0):(y=this.resolvePath(h,f,l),this.saveToCache(h,y))}const x=k0(y,m);if(c?.isEnabled()){const A=performance.now()-d;c.trackExpressionEval({expression:i?.displayExpression??`{{${e}}}`,result:this.sanitizeResultForTracking(x),resultType:this.getResultType(x),componentId:i?.componentId,componentName:i?.componentName,propName:i?.propName,fromCache:v,duration:A,method:i?.method??"evaluatePipeExpression",skipCache:l.skipCache})}return x}resolve(e,n,r,i){const l={...this.defaultOptions,...r},c=wo(),d=c?.isEnabled()?performance.now():0;if(l.skipCache){const y=this.resolvePath(e,n,l);return c?.isEnabled()&&c.trackExpressionEval({expression:e,result:this.sanitizeResultForTracking(y),resultType:this.getResultType(y),componentId:i?.componentId,componentName:i?.componentName,propName:i?.propName,fromCache:!1,duration:performance.now()-d,method:"resolve",skipCache:!0}),y}const f=e.startsWith("_global")||e.startsWith("_local")||e.startsWith("_isolated")||e.startsWith("$parent");let h=!1;if(f){const y=this.getFromRenderCycleCache(e);if(y!==void 0)return h=!0,c?.isEnabled()&&c.trackExpressionEval({expression:e,result:this.sanitizeResultForTracking(y),resultType:this.getResultType(y),componentId:i?.componentId,componentName:i?.componentName,propName:i?.propName,fromCache:!0,duration:performance.now()-d,method:"resolve",skipCache:l.skipCache}),y}else{const y=this.getFromCache(e);if(y!==void 0)return h=!0,c?.isEnabled()&&c.trackExpressionEval({expression:e,result:this.sanitizeResultForTracking(y),resultType:this.getResultType(y),componentId:i?.componentId,componentName:i?.componentName,propName:i?.propName,fromCache:!0,duration:performance.now()-d,method:"resolve",skipCache:l.skipCache}),y}const m=this.resolvePath(e,n,l);return f?this.saveToRenderCycleCache(e,m):this.saveToCache(e,m),c?.isEnabled()&&c.trackExpressionEval({expression:e,result:this.sanitizeResultForTracking(m),resultType:this.getResultType(m),componentId:i?.componentId,componentName:i?.componentName,propName:i?.propName,fromCache:h,duration:performance.now()-d,method:"resolve",skipCache:l.skipCache}),m}resolvePath(e,n,r,i=0,l=new WeakSet){if(typeof e!="string"||e.trim()===""){Ma.warn("resolvePath: 빈 경로가 전달되었습니다 — undefined 로 해석합니다.");return}if(r.maxDepth&&i>r.maxDepth){if(r.detectCircular)throw new rf(`Maximum depth exceeded (${r.maxDepth}). Possible circular reference.`,e,n);return r.defaultValue}const c=this.parsePath(e);let d=n;for(let f=0;fca.CACHE_EXPIRY){this.cache.delete(e),r?.isEnabled()&&r.recordCacheMiss();return}return r?.isEnabled()&&r.recordCacheHit(),n.value}saveToCache(e,n){this.cache.set(e,{value:n,timestamp:Date.now()})}isActionDefinition(e){return typeof e.handler!="string"?!1:e.params!==void 0||Array.isArray(e.actions)||typeof e.target=="string"||e.onSuccess!==void 0||e.onError!==void 0}resolveObject(e,n,r){if(this.isSwitchExpression(e)){const d=e;return this.resolveSwitch(d,n,r)}if(this.isActionDefinition(e))return{...e};if("iteration"in e)return{...e};const i={},c=[...["cellChildren","expandChildren","expandContext","render"],...r?.skipBindingKeys||[]];for(const[d,f]of Object.entries(e)){if(c.includes(d)){i[d]=f;continue}try{this.resolveObjectEntry(i,d,f,n,r)}catch(h){Ma.warn(`resolveObject: 값 해석 실패 (key: ${d}):`,h),i[d]=void 0}}return i}resolveObjectEntry(e,n,r,i,l){if(typeof r=="string"){const c=Oa(r);if(c!==null){const d=c.trim();let f=!1,h=d;d.startsWith(lr)&&(f=!0,h=d.slice(lr.length));let m;switch(Qg(h)){case"empty":Ma.warn(`resolveObject: 빈 바인딩 \`{{}}\` (key: ${n}) — undefined 로 해석합니다.`),m=void 0;break;case"literal":m=Fd.get(h);break;case"pipe":m=this.evaluatePipeExpression(h,i,l);break;case"expression":m=this.evaluateExpression(h,i,l);break;default:m=this.resolve(h,i,l)}e[n]=f&&m!=null?fs(m):m}else e[n]=this.resolveBindings(r,i,l)}else Array.isArray(r)?e[n]=r.map(c=>typeof c=="string"?this.resolveBindings(c,i,l):typeof c=="object"&&c!==null?this.resolveObject(c,i,l):c):r&&typeof r=="object"?e[n]=this.resolveObject(r,i,l):e[n]=r}clearCache(){this.cache.clear()}invalidateCacheByKeys(e){for(const n of this.cache.keys())for(const r of e)if(n===r||n.startsWith(`${r}.`)||n.startsWith(`${r}[`)){this.cache.delete(n);break}}pruneCache(){const e=Date.now();for(const[n,r]of this.cache.entries())e-r.timestamp>ca.CACHE_EXPIRY&&this.cache.delete(n)}getCacheStats(){const e=Date.now();let n=0;for(const r of this.cache.values())e-r.timestamp>ca.CACHE_EXPIRY&&n++;return{size:this.cache.size,expired:n}}evaluateExpression(e,n,r){const i=wo(),l=i?.isEnabled()?performance.now():0;i?.isEnabled()&&i.trackBindingEval();try{let c=this.preprocessOptionalChaining(e);c=this.preprocessTranslationTokens(c);const d=this.extractVariablesFromExpression(c),f={...n};for(const A of d)A in f||(f[A]=void 0);n._computed&&!f.$computed&&(f.$computed=n._computed);let h=n.$templateId,m=n.$locale;if(typeof window<"u"&&(!h||!m)){const A=window.__templateApp?.getConfig?.();h??(h=A?.templateId),m??(m=A?.locale)}const y=m||"ko";f.$localized=(A,D)=>{if(A==null&&!D)return"";if(typeof A=="string")return A;if(A&&typeof A=="object"&&A[y])return A[y];if(D&&typeof D=="string"){const O=f.$t?f.$t(D):D;if(O&&O!==D)return O}return A&&typeof A=="object"?A.ko||A.en||Object.values(A)[0]||"":A==null?"":String(A)};const v=typeof window<"u"?window.G7Core:void 0;f.$uuid=()=>v?.uuid?v.uuid():typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,A=>{const D=Math.random()*16|0;return(A==="x"?D:D&3|8).toString(16)});const S={templateId:h||"",locale:y};f.$t=A=>{if(!A||typeof A!="string")return"";try{return vi.getInstance().translate(A,S)}catch(D){return Ma.warn("$t() translation failed for key:",A,D),A}},f.$get=(A,D,O=void 0)=>{if(A==null)return O;const k=Array.isArray(D)?D:[D];if(k.length===0)return A;let L=A;for(const B of k){if(L==null||B==null)return O;L=L[B]}return L??O};const _=!1,x=nf(c,f);if(i?.isEnabled()){const A=performance.now()-l;i.trackExpressionEval({expression:e,result:this.sanitizeResultForTracking(x),resultType:this.getResultType(x),componentId:r?.componentId,componentName:r?.componentName,propName:r?.propName,fromCache:_,duration:A,method:"evaluateExpression",skipCache:r?.skipCache})}return x}catch(c){throw new Error(`Failed to evaluate expression "${e}": ${c instanceof Error?c.message:String(c)}`)}}getResultType(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?"array":typeof e}sanitizeResultForTracking(e){if(e==null||typeof e!="object")return e;try{if(Array.isArray(e))return e.length>10?`[Array(${e.length})]`:e.slice(0,10);const n=Object.keys(e);return n.length>20?`{Object(${n.length} keys)}`:(JSON.stringify(e),e)}catch{return"[Complex Object]"}}preprocessTranslationTokens(e){return e=e.replace(/(['"])(\$t:([a-zA-Z_][a-zA-Z0-9_.\-]*))\1/g,(n,r,i,l)=>`$t('${l}')`),e.replace(/(['"]\s*)?(\$t:[a-zA-Z_][a-zA-Z0-9_.\-]*)(?!\s*['"])/g,(n,r,i)=>r?n:`"${i}"`)}preprocessOptionalChaining(e){const n=[];let r=e.replace(/(['"])(?:(?!\1|\\).|\\.)*\1/g,l=>(n.push(l),`__STRING_LITERAL_${n.length-1}__`));const i=[];return r=r.replace(/\$t:[a-zA-Z_][a-zA-Z0-9_.\-]*(?:\|[^'"\s,)]+)?/g,l=>(i.push(l),`__TRANSLATION_TOKEN_${i.length-1}__`)),r=r.replace(/([a-zA-Z_$][a-zA-Z0-9_$]*)\.(?!\?)/g,"$1?."),r=r.replace(/__TRANSLATION_TOKEN_(\d+)__/g,(l,c)=>i[parseInt(c,10)]),r=r.replace(/__STRING_LITERAL_(\d+)__/g,(l,c)=>n[parseInt(c,10)]),r}extractVariablesFromExpression(e){const n=new Set(["true","false","null","undefined","NaN","Infinity","if","else","for","while","do","switch","case","break","continue","return","function","class","const","let","var","new","delete","typeof","instanceof","this","super","import","export","default","try","catch","finally","throw","Math","Date","JSON","Array","Object","String","Number","Boolean","RegExp","Set","Map","WeakSet","WeakMap","Symbol","Promise","BigInt","Error","parseInt","parseFloat","isNaN","isFinite","encodeURI","decodeURI","encodeURIComponent","decodeURIComponent"]),r=/(^|[^.\w$])([a-zA-Z_$][a-zA-Z0-9_$]*)/g,i=new Set;let l;for(;(l=r.exec(e))!==null;){const c=l[2];n.has(c)||i.add(c)}return Array.from(i)}isSwitchExpression(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&"$switch"in e&&"$cases"in e}resolveSwitch(e,n,r){const i={...r,skipCache:!0};let l;try{l=this.resolveBindings(e.$switch,n,i)?.toString()?.trim()??""}catch(d){Ma.warn("resolveSwitch: $switch 키 평가 실패:",e.$switch,d),l=""}let c;if(l&&e.$cases&&l in e.$cases)c=e.$cases[l];else if("$default"in e)c=e.$default;else return;return typeof c=="string"?c.includes("{{")?this.resolveBindings(c,n,i):c:c!==null&&typeof c=="object"?this.resolveObject(c,n,i):c}};M(ca,"PATH_SEGMENT_PATTERN",/([^.[\]]+)|\[(\d+)\]/g),M(ca,"CACHE_EXPIRY",3e4);let $n=ca;const oc=new $n,lc={mobile:{min:0,max:767},tablet:{min:768,max:1023},desktop:{min:1024,max:1/0},portable:{min:0,max:1023}},cc=new Map;function P0(s,e){let n=null;return((...r)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{s(...r)},e)})}class U0{constructor(){M(this,"subscribers",new Set);M(this,"currentWidth",1024);M(this,"debouncedHandler",null);M(this,"isInitialized",!1);this.initialize()}initialize(){typeof window>"u"||(this.currentWidth=window.innerWidth,this.isInitialized=!0,this.debouncedHandler=P0(()=>{this.currentWidth=window.innerWidth,this.notifySubscribers()},150),window.addEventListener("resize",this.debouncedHandler))}notifySubscribers(){this.subscribers.forEach(e=>{e(this.currentWidth)})}subscribe(e){return this.subscribers.add(e),e(this.currentWidth),()=>{this.subscribers.delete(e)}}getWidth(){return this.currentWidth}parseRange(e){if(cc.has(e))return cc.get(e)??null;let n=null;if(lc[e])n={...lc[e]};else{const r=e.match(/^(-?\d*)-(-?\d*)$/);if(r){const[,i,l]=r,c=i===""?0:parseInt(i,10),d=l===""?1/0:parseInt(l,10);!isNaN(c)&&!isNaN(d)&&c<=d&&(n={min:c,max:d})}}return cc.set(e,n),n}getMatchingKey(e,n){const r=[];for(const i of Object.keys(e)){const l=this.parseRange(i);l&&n>=l.min&&n<=l.max&&r.push({key:i,range:l,isPreset:!!lc[i]})}return r.length===0?null:(r.sort((i,l)=>{if(i.isPreset!==l.isPreset)return i.isPreset?1:-1;const c=i.range.max-i.range.min,d=l.range.max-l.range.min;return c-d}),r[0].key)}matches(e){const n=this.parseRange(e);return n?this.currentWidth>=n.min&&this.currentWidth<=n.max:!1}clearSubscribers(){this.subscribers.clear()}destroy(){this.debouncedHandler&&typeof window<"u"&&window.removeEventListener("resize",this.debouncedHandler),this.clearSubscribers(),cc.clear()}_setWidthForTesting(e){this.currentWidth=e,this.notifySubscribers()}}const Ci=new U0,Co=pt("ConditionEvaluator");function B0(s,e,n,r){return Vd(Zg(s),e,n,{skipCache:!0,onEmpty:()=>{Co.warn(`${r}: 빈 바인딩 \`{{}}\` — undefined 로 해석합니다.`)}})}function cm(s,e,n){if(!s)return!0;try{const r=Oa(s);let i;if(r!==null?i=B0(r,e,n,"evaluateStringCondition"):i=n.resolveBindings(s,e,{skipCache:!0}),typeof i=="string"){const l=i.toLowerCase().trim();if(l==="false"||l==="0"||l===""||l==="null"||l==="undefined")return!1}return!!i}catch(r){return Co.warn(`evaluateStringCondition: 조건 평가 실패: ${s}`,r),!1}}function uc(s,e,n){if(typeof s=="string")return cm(s,e,n);if("and"in s){if(!Array.isArray(s.and)||s.and.length===0)return Co.warn("evaluateConditionExpression: AND 그룹이 비어있습니다"),!0;for(const r of s.and)if(!uc(r,e,n))return!1;return!0}if("or"in s){if(!Array.isArray(s.or)||s.or.length===0)return Co.warn("evaluateConditionExpression: OR 그룹이 비어있습니다"),!1;for(const r of s.or)if(uc(r,e,n))return!0;return!1}return Co.warn("evaluateConditionExpression: 알 수 없는 조건 형식",s),!1}function um(s,e,n){if(!Array.isArray(s)||s.length===0)return{matched:!1,branchIndex:-1};for(let r=0;r{cr.warn(`evaluateIfCondition: 빈 바인딩 \`{{}}\` (컴포넌트: ${r||"unknown"}) — undefined 로 해석합니다.`)}}):l=n.resolveBindings(s,e,{skipCache:!0}),typeof l=="string"){const c=l.toLowerCase().trim();if(c==="false"||c==="0"||c===""||c==="null"||c==="undefined")return!1}return!!l}catch(i){return cr.warn(`evaluateIfCondition: 조건 평가 실패 (컴포넌트: ${r||"unknown"}):`,i),!1}}function hs(s,e,n,r){if(s.if!==void 0)return pm(s.if,e,n,r);if(s.condition!==void 0)return pm(s.condition,e,n,r);if(s.conditions===void 0)return!0;const i=s.conditions;try{return q0(i)?uc(i,e,n):G0(i)?um(i,e,n).matched:(cr.warn(`evaluateRenderCondition: 알 수 없는 conditions 형식 (컴포넌트: ${r||"unknown"})`),!0)}catch(l){return cr.warn(`evaluateRenderCondition: conditions 평가 실패 (컴포넌트: ${r||"unknown"}):`,l),!1}}function gm(s){if(!s.responsive)return s;const e=Ci.getWidth(),n=Ci.getMatchingKey(s.responsive,e);if(!n)return s;const r=s.responsive[n];return{...s,props:{...s.props,...r.props},children:r.children??s.children,text:r.text??s.text,if:r.if??s.if,iteration:r.iteration??s.iteration}}function Eo(s,e,n,r,i){if(!s||s.length===0)return[];const l=i?.bindingEngine??new $n,c=i?.translationEngine??vi.getInstance(),d=i?.translationContext??{templateId:"",locale:"ko"},f=V0(e,i?.componentContext),h=(S,_)=>{if(typeof S=="string")return ac(S)||ic(S)||!/\$t:[a-zA-Z0-9._-]+/.test(S)?S:c.resolveTranslations(S,d,_);if(Array.isArray(S))return S.map(x=>h(x,_));if(S&&typeof S=="object"){const x={};for(const[A,D]of Object.entries(S))x[A]=h(D,_);return x}return S},m=(S,_)=>{if(typeof S=="string"){if(ac(S))return Kd(S);if(ic(S)){const A=[],D=S.replace(new RegExp(`${bo}([^${Si}]*)${Si}`,"g"),(k,L)=>(A.push(L),`${La}${A.length-1}${La}`));let O=D;return/\$t:[a-zA-Z0-9._-]+/.test(D)&&(O=c.resolveTranslations(D,d,_)),O.replace(new RegExp(`${La}(\\d+)${La}`,"g"),(k,L)=>A[parseInt(L)])}if(S.startsWith("$t:defer:")){const A="$t:"+S.slice(9);return c.resolveTranslations(A,d,_)}if(S.startsWith("$t:"))return c.resolveTranslations(S,d,_);if(/\$t:[a-zA-Z0-9._-]+/.test(S)){const A=S.trim();if(!(A.startsWith("{")&&A.endsWith("}")||A.startsWith("[")&&A.endsWith("]"))&&!S.includes("{{"))return c.resolveTranslations(S,d,_)}const x=hm(S);if(x!==null){let A=!1,D=x;x.startsWith(lr)&&(A=!0,D=x.slice(lr.length));let O=!1,k=Vd(D,_,l,{skipCache:!0,onError:L=>{cr.warn("renderItemChildren: 표현식 평가 실패:",L),O=!0},onEmpty:()=>{cr.warn("renderItemChildren: 빈 바인딩 `{{}}` 은 해석하지 않습니다.")}});return O?void 0:(A||(k=h(k,_)),A&&k!=null?fs(k):k)}if(S.includes("{{")){const A=l.resolveBindings(S,_,{skipCache:!0});return typeof A=="string"&&/\$t:[a-zA-Z0-9._-]+/.test(A)?c.resolveTranslations(A,d,_):A}return S}if(Array.isArray(S))return S.map(x=>m(x,_));if(S&&typeof S=="object"){if(l.isSwitchExpression(S))return l.resolveSwitch(S,_,{skipCache:!0});if(l.isActionDefinition(S))return{...S};const x={};for(const[A,D]of Object.entries(S))x[A]=m(D,_);return x}return S},y=(S,_)=>{if(!S)return{};const x={};for(const[A,D]of Object.entries(S))x[A]=m(D,_);return x},v=(S,_,x)=>{const A=gm(S),D=A.iteration;if(!D)return[];const O=af(D.source,x,l);if(!Array.isArray(O))return cr.warn(`renderItemChildren: iteration.source가 배열이 아닙니다: ${D.source}`),[];const k=dm();if(k?.isEnabled()){const B=`${_}-iteration`;k.trackIteration(B,D.source,D.item_var,D.index_var,O.length)}const L=n[A.name];return L?O.flatMap((B,q)=>{const z={...x,[D.item_var]:B,[`${D.item_var}_index`]:q,...D.index_var?{[D.index_var]:q}:{}},W=hs({if:A.if,condition:A.condition,conditions:A.conditions},z,l,A.id);if(A.if&&k?.isEnabled()){const Et=`${_}-iter-${q}-if`;k.trackIfCondition(Et,A.if,W,A.name)}if(!W)return[];const de=A.id?String($a(m(A.id,z))):void 0,_e=`${_}-iter-${q}`,Se=i?.getRemountKey?i.getRemountKey(de,_e):_e,je=y(A.props,z),Fe=sf(je,A.actions,z,{actionDispatcher:i?.actionDispatcher,componentContext:i?.componentContext});let ze=null;return A.text!==void 0?ze=m(A.text,z):A.children&&A.children.length>0&&(ze=Eo(A.children,z,n,Se,i)),k?.isEnabled()&&k.trackRender(A.name),[Xe.createElement(L,{key:Se,...$a(Fe)},$a(ze))]}):(cr.warn(`renderItemChildren: 컴포넌트를 찾을 수 없습니다: ${A.name}`),[])};return s.flatMap((S,_)=>{const x=gm(S),A=x.id?String($a(m(x.id,f))):void 0,D=r?`${r}-${A||_}`:A||`child-${_}`,O=i?.getRemountKey?i.getRemountKey(A,D):D;if(x.iteration)return v(x,O,f);const k=hs({if:x.if,condition:x.condition,conditions:x.conditions},f,l,x.id),L=dm();if(x.if&&L?.isEnabled()){const de=`${O}-if`;L.trackIfCondition(de,x.if,k,x.name)}if(!k)return[];const B=n[x.name];if(!B)return cr.warn(`renderItemChildren: 컴포넌트를 찾을 수 없습니다: ${x.name}`),[];const q=y(x.props,f),z=sf(q,x.actions,f,{actionDispatcher:i?.actionDispatcher,componentContext:i?.componentContext});let W=null;return x.text!==void 0?W=m(x.text,f):x.children&&x.children.length>0&&(W=Eo(x.children,f,n,O,i)),L?.isEnabled()&&L.trackRender(x.name),[Xe.createElement(B,{key:O,...$a(z)},$a(W))]})}function ps(s,e,n,r){let i,l;return n instanceof $n?(i=n,l=r):(i=fm,l=n),i.resolveBindings(s,e,l)}function K0(s,e,n,r){const i=n??fm,l={skipCache:!0,...r};let c;try{c=i.resolveBindings(s.key,e,{skipCache:l.skipCache})?.toString()?.trim()??""}catch(h){cr.warn("resolveClassMap: key 평가 실패:",s.key,h),c=""}let d="";c&&s.variants&&c in s.variants?d=s.variants[c]:s.default&&(d=s.default);const f=[];return s.base?.trim()&&f.push(s.base.trim()),d?.trim()&&f.push(d.trim()),f.join(" ")}function mm(s,e){return function(){return s.apply(e,arguments)}}const{toString:W0}=Object.prototype,{getPrototypeOf:Na}=Object,{iterator:_o,toStringTag:ym}=Symbol,Ao=(({hasOwnProperty:s})=>(e,n)=>s.call(e,n))(Object.prototype),bm=s=>typeof s=="string"&&(s==="__proto__"||s==="constructor"||s==="prototype"),vm=(s,e,n)=>s===Object.prototype||!n&&e===null,Y0=s=>{if(!Object.isExtensible(s))return!1;const e=Object.getOwnPropertyNames(s);return Object.getOwnPropertySymbols&&e.push(...Object.getOwnPropertySymbols(s)),e.every(n=>{if(bm(n))return!1;const r=Object.getOwnPropertyDescriptor(s,n);return!!r&&r.configurable&&r.writable===!0})},xo=(s,e)=>{let n=s;const r=[];for(;n!=null;){if(r.indexOf(n)!==-1)return!1;r.push(n);const i=Na(n);if(vm(n,i,n===s))return!1;if(Ao(n,e))return!0;n=i}return!1},X0=(s,e)=>s!=null&&xo(s,e)?s[e]:void 0,J0=s=>{if(s==null||typeof s!="object"&&typeof s!="function")return s;const e=Na(s);if(e===null&&Y0(s))return s;const n=Object.create(null),r=Object.create(null),i=[];let l=s;for(;l!=null&&i.indexOf(l)===-1;){i.push(l);const c=l===s?e:Na(l);if(vm(l,c,l===s))break;const d=Object.getOwnPropertyNames(l);Object.getOwnPropertySymbols&&d.push(...Object.getOwnPropertySymbols(l));for(const f of d)bm(f)||Ao(r,f)||(n[f]=s[f],r[f]=!0);l=c}return n},of=(s=>e=>{const n=W0.call(e);return s[n]||(s[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),ur=s=>(s=s.toLowerCase(),e=>of(e)===s),dc=s=>e=>typeof e===s,{isArray:Ei}=Array,_i=dc("undefined");function gs(s){return s!==null&&!_i(s)&&s.constructor!==null&&!_i(s.constructor)&&Hn(s.constructor.isBuffer)&&s.constructor.isBuffer(s)}const Sm=ur("ArrayBuffer");function Q0(s){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(s):e=s&&s.buffer&&Sm(s.buffer),e}const Z0=dc("string"),Hn=dc("function"),wm=dc("number"),ms=s=>s!==null&&typeof s=="object",eC=s=>s===!0||s===!1,fc=s=>{if(!ms(s))return!1;const e=Na(s);return(e===null||e===Object.prototype||Na(e)===null)&&!xo(s,ym)&&!xo(s,_o)},tC=s=>{if(!ms(s)||gs(s))return!1;try{return Object.keys(s).length===0&&Object.getPrototypeOf(s)===Object.prototype}catch{return!1}},nC=ur("Date"),rC=ur("File"),aC=s=>!!(s&&typeof s.uri<"u"),iC=s=>s&&typeof s.getParts<"u",sC=ur("Blob"),oC=ur("FileList"),lC=ur("Set"),cC=s=>ms(s)&&Hn(s.pipe);function uC(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Cm=uC(),Em=typeof Cm.FormData<"u"?Cm.FormData:void 0,dC=s=>{if(!s)return!1;if(Em&&s instanceof Em)return!0;const e=Na(s);if(!e||e===Object.prototype||!Hn(s.append))return!1;const n=of(s);return n==="formdata"||n==="object"&&Hn(s.toString)&&s.toString()==="[object FormData]"},fC=ur("URLSearchParams"),[hC,pC,gC,mC]=["ReadableStream","Request","Response","Headers"].map(ur),yC=s=>s.trim?s.trim():s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function To(s,e,{allOwnKeys:n=!1}={}){if(s===null||typeof s>"u")return;let r,i;if(typeof s!="object"&&(s=[s]),Ei(s))for(r=0,i=s.length;r0;)if(i=n[r],e===i.toLowerCase())return i;return null}const Ai=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Am=s=>!_i(s)&&s!==Ai;function lf(...s){const{caseless:e,skipUndefined:n}=Am(this)&&this||{},r={},i=(l,c)=>{if(c==="__proto__"||c==="constructor"||c==="prototype")return;const d=e&&typeof c=="string"&&_m(r,c)||c,f=Ao(r,d)?r[d]:void 0;fc(f)&&fc(l)?r[d]=lf(f,l):fc(l)?r[d]=lf({},l):Ei(l)?r[d]=l.slice():(!n||!_i(l))&&(r[d]=l)};for(let l=0,c=s.length;l(To(e,(i,l)=>{n&&Hn(i)?Object.defineProperty(s,l,{__proto__:null,value:mm(i,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(s,l,{__proto__:null,value:i,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),s),vC=s=>(s.charCodeAt(0)===65279&&(s=s.slice(1)),s),SC=(s,e,n,r)=>{s.prototype=Object.create(e.prototype,r),Object.defineProperty(s.prototype,"constructor",{__proto__:null,value:s,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(s,"super",{__proto__:null,value:e.prototype}),n&&Object.assign(s.prototype,n)},wC=(s,e,n,r)=>{let i,l,c;const d={};if(e=e||{},s==null)return e;do{for(i=Object.getOwnPropertyNames(s),l=i.length;l-- >0;)c=i[l],(!r||r(c,s,e))&&!d[c]&&(e[c]=s[c],d[c]=!0);s=n!==!1&&Na(s)}while(s&&(!n||n(s,e))&&s!==Object.prototype);return e},CC=(s,e,n)=>{s=String(s),(n===void 0||n>s.length)&&(n=s.length),n-=e.length;const r=s.indexOf(e,n);return r!==-1&&r===n},EC=s=>{if(!s)return null;if(Ei(s))return s;let e=s.length;if(!wm(e))return null;const n=new Array(e);for(;e-- >0;)n[e]=s[e];return n},_C=(s=>e=>s&&e instanceof s)(typeof Uint8Array<"u"&&Na(Uint8Array)),AC=(s,e)=>{const r=(s&&s[_o]).call(s);let i;for(;(i=r.next())&&!i.done;){const l=i.value;e.call(s,l[0],l[1])}},xC=(s,e)=>{let n;const r=[];for(;(n=s.exec(e))!==null;)r.push(n);return r},TC=ur("HTMLFormElement"),kC=s=>s.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,i){return r.toUpperCase()+i}),{propertyIsEnumerable:RC}=Object.prototype,DC=ur("RegExp"),xm=(s,e)=>{const n=Object.getOwnPropertyDescriptors(s),r={};To(n,(i,l)=>{let c;(c=e(i,l,s))!==!1&&(r[l]=c||i)}),Object.defineProperties(s,r)},OC=s=>{xm(s,(e,n)=>{if(Hn(s)&&["arguments","caller","callee"].includes(n))return!1;const r=s[n];if(Hn(r)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},LC=(s,e)=>{const n={},r=i=>{i.forEach(l=>{n[l]=!0})};return Ei(s)?r(s):r(String(s).split(e)),n},$C=()=>{},MC=(s,e)=>s!=null&&Number.isFinite(s=+s)?s:e;function NC(s){return!!(s&&Hn(s.append)&&s[ym]==="FormData"&&s[_o])}const IC=s=>{const e=new WeakSet,n=r=>{if(ms(r)){if(e.has(r))return;if(gs(r))return r;if(!("toJSON"in r)){e.add(r);let i;if(lC(r)){i=[];for(const l of r){const c=n(l);!_i(c)&&i.push(c)}}else i=Ei(r)?[]:{},To(r,(l,c)=>{const d=n(l);!_i(d)&&(i[c]=d)});return e.delete(r),i}}return r};return n(s)},jC=ur("AsyncFunction"),HC=s=>s&&(ms(s)||Hn(s))&&Hn(s.then)&&Hn(s.catch),Tm=((s,e)=>s?setImmediate:e?((n,r)=>(Ai.addEventListener("message",({source:i,data:l})=>{i===Ai&&l===n&&r.length&&r.shift()()},!1),i=>{r.push(i),Ai.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Hn(Ai.postMessage)),zC=typeof queueMicrotask<"u"?queueMicrotask.bind(Ai):typeof process<"u"&&process.nextTick||Tm,km=s=>s!=null&&Hn(s[_o]),G={isArray:Ei,isArrayBuffer:Sm,isBuffer:gs,isFormData:dC,isArrayBufferView:Q0,isString:Z0,isNumber:wm,isBoolean:eC,isObject:ms,isPlainObject:fc,isEmptyObject:tC,isReadableStream:hC,isRequest:pC,isResponse:gC,isHeaders:mC,isUndefined:_i,isDate:nC,isFile:rC,isReactNativeBlob:aC,isReactNative:iC,isBlob:sC,isRegExp:DC,isFunction:Hn,isStream:cC,isURLSearchParams:fC,isTypedArray:_C,isFileList:oC,forEach:To,merge:lf,extend:bC,trim:yC,stripBOM:vC,inherits:SC,toFlatObject:wC,kindOf:of,kindOfTest:ur,endsWith:CC,toArray:EC,forEachEntry:AC,matchAll:xC,isHTMLForm:TC,hasOwnProperty:Ao,hasOwnProp:Ao,hasOwnInPrototypeChain:xo,getSafeProp:X0,toSafeFlatObject:J0,reduceDescriptors:xm,freezeMethods:OC,toObjectSet:LC,toCamelCase:kC,noop:$C,toFiniteNumber:MC,findKey:_m,global:Ai,isContextDefined:Am,isSpecCompliantForm:NC,toJSONObject:IC,isAsyncFn:jC,isThenable:HC,setImmediate:Tm,asap:zC,isIterable:km,isSafeIterable:s=>s!=null&&xo(s,_o)&&km(s)},PC=G.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),UC=s=>{const e={};let n,r,i;return s&&s.split(` +`).forEach(function(c){i=c.indexOf(":"),n=c.substring(0,i).trim().toLowerCase(),r=c.substring(i+1).trim();const d=G.hasOwnProp(e,n);!n||d&&G.hasOwnProp(PC,n)||(n==="set-cookie"?d?e[n].push(r):e[n]=[r]:e[n]=d?e[n]+", "+r:r)}),e};function BC(s){let e=0,n=s.length;for(;ee;){const r=s.charCodeAt(n-1);if(r!==9&&r!==32)break;n-=1}return e===0&&n===s.length?s:s.slice(e,n)}const qC=new RegExp("[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+","g"),GC=new RegExp("[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+","g");function cf(s,e){return G.isArray(s)?s.map(n=>cf(n,e)):BC(String(s).replace(e,""))}const FC=s=>cf(s,qC),VC=s=>cf(s,GC);function Rm(s){const e=Object.create(null);return G.forEach(s.toJSON(),(n,r)=>{e[r]=VC(n)}),e}const Dm=Symbol("internals");function ko(s){return s&&String(s).trim().toLowerCase()}function hc(s){return s===!1||s==null?s:G.isArray(s)?s.map(hc):FC(String(s))}function KC(s){const e=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(s);)e[r[1]]=r[2];return e}const WC=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function uf(s){let e=0,n=s.length;for(;ee;){const r=s.charCodeAt(n-1);if(r!==9&&r!==32)break;n-=1}return e===0&&n===s.length?s:s.slice(e,n)}function YC(s){const e=s.length-1;if(e<1||s.charCodeAt(0)!==34||s.charCodeAt(e)!==34)return s;let n="";for(let r=1;r=e))return s;n+=s[r]}return n}function XC(s){const e=Object.create(null),n=String(s);let r=0,i=!1,l=!1;function c(d){const f=uf(n.slice(r,d)),h=f.indexOf("=");if(h<1)return;const m=uf(f.slice(0,h));if(!WC.test(m))return;const y=m.toLowerCase();if(y==="__proto__"||y==="constructor"||y==="prototype")return;const v=uf(f.slice(h+1));e[y]=YC(v)}for(let d=0;d/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(s.trim());function df(s,e,n,r,i){if(G.isFunction(r))return r.call(this,e,n);if(i&&(e=n),!!G.isString(e)){if(G.isString(r))return e.indexOf(r)!==-1;if(G.isRegExp(r))return r.test(e)}}function QC(s){return s.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,n,r)=>n.toUpperCase()+r)}function ZC(s,e){const n=G.toCamelCase(" "+e);["get","set","has"].forEach(r=>{Object.defineProperty(s,r+n,{__proto__:null,value:function(i,l,c){return this[r].call(this,e,i,l,c)},configurable:!0})})}let xn=class{constructor(e){e&&this.set(e)}set(e,n,r){const i=this;function l(d,f,h){const m=ko(f);if(!m)return;const y=G.findKey(i,m);(!y||i[y]===void 0||h===!0||h===void 0&&i[y]!==!1)&&(i[y||f]=hc(d))}const c=(d,f)=>G.forEach(d,(h,m)=>l(h,m,f));if(G.isPlainObject(e)||e instanceof this.constructor)c(e,n);else if(G.isString(e)&&(e=e.trim())&&!JC(e))c(UC(e),n);else if(G.isObject(e)&&G.isSafeIterable(e)){let d=Object.create(null),f,h;for(const m of e){if(!G.isArray(m))throw new TypeError("Object iterator must return a key-value pair");h=m[0],G.hasOwnProp(d,h)?(f=d[h],d[h]=G.isArray(f)?[...f,m[1]]:[f,m[1]]):d[h]=m[1]}c(d,n)}else e!=null&&l(n,e,r);return this}get(e,n){if(e=ko(e),e){const r=G.findKey(this,e);if(r){const i=this[r];if(!n)return i;if(n===!0)return KC(i);if(G.isFunction(n))return n.call(this,i,r);if(G.isRegExp(n))return n.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,n){if(e=ko(e),e){const r=G.findKey(this,e);return!!(r&&this[r]!==void 0&&(!n||df(this,this[r],r,n)))}return!1}delete(e,n){const r=this;let i=!1;function l(c){if(c=ko(c),c){const d=G.findKey(r,c);d&&(!n||df(r,r[d],d,n))&&(delete r[d],i=!0)}}return G.isArray(e)?e.forEach(l):l(e),i}clear(e){const n=Object.keys(this);let r=n.length,i=!1;for(;r--;){const l=n[r];(!e||df(this,this[l],l,e,!0))&&(delete this[l],i=!0)}return i}normalize(e){const n=this,r={};return G.forEach(this,(i,l)=>{const c=G.findKey(r,l);if(c){n[c]=hc(i),delete n[l];return}const d=e?QC(l):String(l).trim();d!==l&&delete n[l],n[d]=hc(i),r[d]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const n=Object.create(null);return G.forEach(this,(r,i)=>{r!=null&&r!==!1&&(n[i]=e&&G.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,n])=>e+": "+n).join(` +`)}getSetCookie(){const e=this.get("set-cookie");return G.isArray(e)?e:e==null||e===!1?[]:[e]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static parseParameters(e){return XC(e)}static concat(e,...n){const r=new this(e);return n.forEach(i=>r.set(i)),r}static accessor(e){const r=(this[Dm]=this[Dm]={accessors:{}}).accessors,i=this.prototype;function l(c){const d=ko(c);r[d]||(ZC(i,c),r[d]=!0)}return G.isArray(e)?e.forEach(l):l(e),this}};xn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),G.reduceDescriptors(xn.prototype,({value:s},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>s,set(r){this[n]=r}}}),G.freezeMethods(xn);const pc="[REDACTED ****]";function eE(s){if(G.hasOwnProp(s,"toJSON"))return!0;let e=Object.getPrototypeOf(s);for(;e&&e!==Object.prototype;){if(G.hasOwnProp(e,"toJSON"))return!0;e=Object.getPrototypeOf(e)}return!1}function tE(s,e){const n=new Set(e.map(l=>String(l).toLowerCase())),r=[],i=l=>{if(l===null||typeof l!="object"||G.isBuffer(l))return l;if(r.indexOf(l)!==-1)return;l instanceof xn&&(l=l.toJSON()),r.push(l);let c;if(G.isArray(l))c=[],l.forEach((d,f)=>{const h=i(d);G.isUndefined(h)||(c[f]=h)});else{if(!G.isPlainObject(l)&&eE(l))return r.pop(),l;c=Object.create(null);for(const[d,f]of Object.entries(l)){const h=n.has(d.toLowerCase())?pc:i(f);G.isUndefined(h)||(c[d]=h)}}return r.pop(),c};return i(s)}function Om(s){try{return String(s)}catch{return""}}function nE(s){return s.errors.map(n=>{try{return n&&n.message?Om(n.message):Om(n)}catch{return""}}).filter(Boolean).join("; ")||s.name||"AggregateError"}let we=class n0 extends Error{static from(e,n,r,i,l,c){let d=e.message;!d&&G.isArray(e.errors)&&e.errors.length&&(d=nE(e));const f=new n0(d,n||e.code,r,i,l);return Object.defineProperty(f,"cause",{__proto__:null,value:e,writable:!0,enumerable:!1,configurable:!0}),f.name=e.name,e.status!=null&&f.status==null&&(f.status=e.status),c&&Object.assign(f,c),f}constructor(e,n,r,i,l){super(e),Object.defineProperty(this,"message",{__proto__:null,value:e,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),r&&(this.config=r),i&&(this.request=i),l&&(this.response=l,this.status=l.status)}toJSON(){const e=this.config,n=e&&G.hasOwnProp(e,"redact")?e.redact:void 0,r=G.isArray(n)&&n.length>0?tE(e,n):G.toJSONObject(e);return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:r,code:this.code,status:this.status}}};we.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",we.ERR_BAD_OPTION="ERR_BAD_OPTION",we.ECONNABORTED="ECONNABORTED",we.ETIMEDOUT="ETIMEDOUT",we.ECONNREFUSED="ECONNREFUSED",we.ERR_NETWORK="ERR_NETWORK",we.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",we.ERR_DEPRECATED="ERR_DEPRECATED",we.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",we.ERR_BAD_REQUEST="ERR_BAD_REQUEST",we.ERR_CANCELED="ERR_CANCELED",we.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",we.ERR_INVALID_URL="ERR_INVALID_URL",we.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const rE=null,Lm=100;function ff(s){return G.isPlainObject(s)||G.isArray(s)}function $m(s){return G.endsWith(s,"[]")?s.slice(0,-2):s}function hf(s,e,n){return s?s.concat(e).map(function(i,l){return i=$m(i),!n&&l?"["+i+"]":i}).join(n?".":""):e}function aE(s){return G.isArray(s)&&!s.some(ff)}const iE=G.toFlatObject(G,{},null,function(e){return/^is[A-Z]/.test(e)});function gc(s,e,n){if(!G.isObject(s))throw new TypeError("target must be an object");e=e||new FormData;const r=(O,k)=>{const L=G.getSafeProp(n,O);return G.isUndefined(L)?k:L},i=r("metaTokens",!0),l=r("visitor")||x,c=r("dots",!1),d=r("indexes",!1),f=r("Blob")||typeof Blob<"u"&&Blob,h=r("maxDepth",Lm),m=f&&G.isSpecCompliantForm(e),y=[];if(!G.isFunction(l))throw new TypeError("visitor must be a function");function v(O){if(O===null)return"";if(G.isDate(O))return O.toISOString();if(G.isBoolean(O))return O.toString();if(!m&&G.isBlob(O))throw new we("Blob is not supported. Use a Buffer instead.");if(G.isArrayBuffer(O)||G.isTypedArray(O)){if(m&&typeof f=="function")return new f([O]);throw new we("Blob is not supported. Use a Buffer instead.",we.ERR_NOT_SUPPORT)}return O}function S(O){if(O>h)throw new we("Object is too deeply nested ("+O+" levels). Max depth: "+h,we.ERR_FORM_DATA_DEPTH_EXCEEDED)}function _(O,k){if(h===1/0)return JSON.stringify(O);const L=[];return JSON.stringify(O,function(q,z){if(!G.isObject(z))return z;for(;L.length&&L[L.length-1]!==this;)L.pop();return L.push(z),S(k+L.length-1),z})}function x(O,k,L){let B=O;if(G.isReactNative(e)&&G.isReactNativeBlob(O))return e.append(hf(L,k,c),v(O)),!1;if(O&&!L&&typeof O=="object"){if(G.endsWith(k,"{}"))k=i?k:k.slice(0,-2),O=_(O,1);else if(G.isArray(O)&&aE(O)||(G.isFileList(O)||G.endsWith(k,"[]"))&&(B=G.toArray(O)))return k=$m(k),B.forEach(function(z,W){!(G.isUndefined(z)||z===null)&&e.append(d===!0?hf([k],W,c):d===null?k:k+"[]",v(z))}),!1}return ff(O)?!0:(e.append(hf(L,k,c),v(O)),!1)}const A=Object.assign(iE,{defaultVisitor:x,convertValue:v,isVisitable:ff});function D(O,k,L=0){if(!G.isUndefined(O)){if(S(L),y.indexOf(O)!==-1)throw new Error("Circular reference detected in "+k.join("."));y.push(O),G.forEach(O,function(q,z){(!(G.isUndefined(q)||q===null)&&l.call(e,q,G.isString(z)?z.trim():z,k,A))===!0&&D(q,k?k.concat(z):[z],L+1)}),y.pop()}}if(!G.isObject(s))throw new TypeError("data must be an object");return D(s),e}function Mm(s){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(s).replace(/[!'()~]|%20/g,function(r){return e[r]})}function pf(s,e){this._pairs=[],s&&gc(s,this,e)}const Nm=pf.prototype;Nm.append=function(e,n){this._pairs.push([e,n])},Nm.toString=function(e){const n=e?r=>e.call(this,r,Mm):Mm;return this._pairs.map(function(i){return n(i[0])+"="+n(i[1])},"").join("&")};function sE(s){return encodeURIComponent(s).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Im(s,e,n){if(!e)return s;s=s||"";const r=G.isFunction(n)?{serialize:n}:n,i=G.getSafeProp(r,"encode")||sE,l=G.getSafeProp(r,"serialize");let c;if(l?c=l(e,r):c=G.isURLSearchParams(e)?e.toString():new pf(e,r).toString(i),c){const d=s.indexOf("#");d!==-1&&(s=s.slice(0,d)),s+=(s.indexOf("?")===-1?"?":"&")+c}return s}const Ro=Symbol("internals");function jm(s){return s?s.length:0}function Hm(s){if(s)for(;s.length&&s[s.length-1]===null;)s.pop()}function Do(s,e){const n=s.handlers,r=jm(n);n!==e.handlersRef?(e.handlersRef=n,e.handlerEntries.clear()):r!==e.handlersLength&&(r?e.handlerEntries.forEach(function(l,c){n[l.index]!==l.handler&&e.handlerEntries.delete(c)}):e.handlerEntries.clear()),e.handlersLength=r}class zm{constructor(){this.handlers=[],this[Ro]={handlersRef:this.handlers,handlersLength:this.handlers.length,handlerEntries:new Map,iterationDepth:0,nextId:0}}use(e,n,r){const i={fulfilled:e,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null},l=this[Ro];this.handlers==null&&(this.handlers=[]),Do(this,l);const c=l.nextId++;return this.handlers.push(i),l.handlerEntries.set(c,{handler:i,index:this.handlers.length-1}),l.handlersLength=this.handlers.length,c}eject(e){const n=this[Ro];Do(this,n);const r=n.handlerEntries.get(e);if(r){if(n.handlerEntries.delete(e),this.handlers[r.index]!==r.handler)return;this.handlers[r.index]=null,n.iterationDepth||(Hm(this.handlers),n.handlersLength=this.handlers.length)}}clear(){this.handlers&&(this.handlers=[],Do(this,this[Ro]))}forEach(e){const n=this[Ro];Do(this,n),n.iterationDepth++;try{G.forEach(this.handlers,function(i){i!==null&&e(i)})}finally{--n.iterationDepth||(Do(this,n),Hm(this.handlers),n.handlersLength=jm(this.handlers))}}}const gf={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0,advertiseZstdAcceptEncoding:!1,validateStatusUndefinedResolves:!0},oE={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:pf,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},mf=typeof window<"u"&&typeof document<"u",yf=typeof navigator=="object"&&navigator||void 0,lE=mf&&(!yf||["ReactNative","NativeScript","NS"].indexOf(yf.product)<0),cE=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",uE=mf&&window.location.href||"http://localhost",gn={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:mf,hasStandardBrowserEnv:lE,hasStandardBrowserWebWorkerEnv:cE,navigator:yf,origin:uE},Symbol.toStringTag,{value:"Module"})),...oE};function dE(s,e){return gc(s,new gn.classes.URLSearchParams,{visitor:function(n,r,i,l){return gn.isNode&&G.isBuffer(n)?(this.append(r,n.toString("base64")),!1):l.defaultVisitor.apply(this,arguments)},...e})}const Pm=Lm;function Um(s){if(s>Pm)throw new we("FormData field is too deeply nested ("+s+" levels). Max depth: "+Pm,we.ERR_FORM_DATA_DEPTH_EXCEEDED)}function fE(s){const e=[],n=/[^.[\]]+|\[([^.[\]]*)]/g;let r;for(;(r=n.exec(s))!==null;)Um(e.length),e.push(r[0]==="[]"?"":r[1]||r[0]);return e}function hE(s){const e={},n=Object.keys(s);let r;const i=n.length;let l;for(r=0;r=n.length;return c=!c&&G.isArray(i)?i.length:c,f?(G.hasOwnProp(i,c)?i[c]=G.isArray(i[c])?i[c].concat(r):[i[c],r]:i[c]=r,!d):((!G.hasOwnProp(i,c)||!G.isObject(i[c]))&&(i[c]=[]),e(n,r,i[c],l)&&G.isArray(i[c])&&(i[c]=hE(i[c])),!d)}if(G.isFormData(s)&&G.isFunction(s.entries)){const n={};return G.forEachEntry(s,(r,i)=>{e(fE(r),i,n,0)}),n}return null}const qm=Object.freeze(["get","delete","head","options","post","put","patch","purge","link","unlink","query"]),ys=(s,e)=>s!=null&&G.hasOwnProp(s,e)?s[e]:void 0;function pE(s,e,n){if(G.isString(s))try{return(e||JSON.parse)(s),G.trim(s)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(s)}const Oo={transitional:gf,adapter:["xhr","http","fetch"],transformRequest:[function(e,n){const r=n.getContentType()||"",i=r.indexOf("application/json")>-1,l=G.isObject(e);if(l&&G.isHTMLForm(e)&&(e=new FormData(e)),G.isFormData(e))return i?JSON.stringify(Bm(e)):e;if(G.isArrayBuffer(e)||G.isBuffer(e)||G.isStream(e)||G.isFile(e)||G.isBlob(e)||G.isReadableStream(e))return e;if(G.isArrayBufferView(e))return e.buffer;if(G.isURLSearchParams(e))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let d;if(l){const f=ys(this,"formSerializer");if(r.indexOf("application/x-www-form-urlencoded")>-1)return dE(e,f).toString();if((d=G.isFileList(e))||r.indexOf("multipart/form-data")>-1){const h=ys(this,"env"),m=h&&h.FormData;return gc(d?{"files[]":e}:e,m&&new m,f)}}return l||i?(n.setContentType("application/json",!1),pE(e)):e}],transformResponse:[function(e){const n=ys(this,"transitional")||Oo.transitional,r=n&&n.forcedJSONParsing,i=ys(this,"responseType"),l=i==="json";if(G.isResponse(e)||G.isReadableStream(e))return e;if(e&&G.isString(e)&&(r&&!i||l)){const d=!(n&&n.silentJSONParsing)&&l;try{return JSON.parse(e,ys(this,"parseReviver"))}catch(f){if(d)throw f.name==="SyntaxError"?we.from(f,we.ERR_BAD_RESPONSE,this,null,ys(this,"response")):f}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:gn.classes.FormData,Blob:gn.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};G.forEach(qm,s=>{Oo.headers[s]={}});function bf(s,e){const n=this||Oo,r=e||n,i=xn.from(r.headers);let l=r.data;return G.forEach(s,function(d){l=d.call(n,l,i.normalize(),e?e.status:void 0)}),i.normalize(),l}function Gm(s){return!!(s&&s.__CANCEL__)}let Lo=class extends we{constructor(e,n,r){super(e??"canceled",we.ERR_CANCELED,n,r),this.name="CanceledError",this.__CANCEL__=!0}};function Fm(s,e,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?s(n):e(new we("Request failed with status code "+n.status,n.status>=400&&n.status<500?we.ERR_BAD_REQUEST:we.ERR_BAD_RESPONSE,n.config,n.request,n))}const gE=/[\t\n\r]/g;function Vm(s){if(typeof s!="string")return s;let e=0;for(;e{n=y,i=null,l&&(clearTimeout(l),l=null),s(...m)};return[(...m)=>{const y=Date.now(),v=y-n;v>=r?c(m,y):(i=m,l||(l=setTimeout(()=>{l=null,c(i)},r-v)))},()=>i&&c(i),(...m)=>c(m)]}const mc=(s,e,n=3)=>{let r=0;const i=mE(50,250);return yE(l=>{if(!l||!G.isNumber(l.loaded))return;const c=l.loaded,d=l.lengthComputable?l.total:void 0,f=Math.max(0,d!=null?Math.min(c,d):c),h=Math.max(0,f-r),m=i(h);r=Math.max(r,f);const y={loaded:f,total:d,progress:d?f/d:void 0,bytes:h,rate:m||void 0,estimated:m&&d?(d-f)/m:void 0,event:l,lengthComputable:d!=null,[e?"download":"upload"]:!0};s(y)},n)},Km=(s,e)=>{const n=s!=null;return[r=>e[0]({lengthComputable:n,total:s,loaded:r}),e[1]]},Wm=(s,e=G.asap)=>(...n)=>e(()=>s(...n)),bE=gn.hasStandardBrowserEnv?((s,e)=>n=>(n=new URL(n,gn.origin),s.protocol===n.protocol&&s.host===n.host&&(e||s.port===n.port)))(new URL(gn.origin),gn.navigator&&/(msie|trident)/i.test(gn.navigator.userAgent)):()=>!0,vE=gn.hasStandardBrowserEnv?{write(s,e,n,r,i,l,c){if(typeof document>"u")return;const d=[`${s}=${encodeURIComponent(e)}`];G.isNumber(n)&&d.push(`expires=${new Date(n).toUTCString()}`),G.isString(r)&&d.push(`path=${r}`),G.isString(i)&&d.push(`domain=${i}`),l===!0&&d.push("secure"),G.isString(c)&&d.push(`SameSite=${c}`),document.cookie=d.join("; ")},read(s){if(typeof document>"u")return null;const e=document.cookie.split(";");for(let n=0;n0&&s.charCodeAt(n-1)===47;)n--;return s.slice(0,n)+"/"+e.replace(/^\/+/,"")}const CE=/^https?:(?!\/\/)/i;function EE(s){return s&&s.replace(/(^|&)([^=&]*=)?[^&]+/g,(e,n,r="")=>`${n}${r}${pc}`)}function _E(s){const e=s.replace(/^(https?:\/{0,2})[^/?#]*@/i,`$1${pc}@`),n=e.indexOf("#"),i=(n===-1?e:e.slice(0,n)).replace(/([?&][^=&#]*=)[^&#]*/g,`$1${pc}`);return n===-1?i:`${i}#${EE(e.slice(n+1))}`}function Ym(s,e){if(typeof s=="string"){const n=Vm(s);if(CE.test(n))throw new we(`Invalid URL ${JSON.stringify(_E(n))}: missing "//" after protocol`,we.ERR_INVALID_URL,e)}}function Xm(s,e,n,r){Ym(e,r);let i=!SE(e);return s&&(i||n===!1)?(Ym(s,r),wE(s,e)):e}const Jm=s=>s instanceof xn?{...s}:s,AE=s=>Object.getOwnPropertySymbols&&Object.getOwnPropertyDescriptor?Object.keys(s).concat(Object.getOwnPropertySymbols(s).filter(e=>Object.getOwnPropertyDescriptor(s,e).enumerable)):Object.keys(s);function xi(s,e){s=s||{},e=e||{};const n=Object.create(null);Object.defineProperty(n,"hasOwnProperty",{__proto__:null,value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function r(m,y,v,S){return G.isPlainObject(m)&&G.isPlainObject(y)?G.merge.call({caseless:S},m,y):G.isPlainObject(y)?G.merge({},y):G.isArray(y)?y.slice():y}function i(m,y,v,S){if(G.isUndefined(y)){if(!G.isUndefined(m))return r(void 0,m,v,S)}else return r(m,y,v,S)}function l(m,y){if(!G.isUndefined(y))return r(void 0,y)}function c(m,y){if(G.isUndefined(y)){if(!G.isUndefined(m))return r(void 0,m)}else return r(void 0,y)}function d(m){const y=G.hasOwnProp(e,"transitional")?e.transitional:void 0;if(!G.isUndefined(y))if(G.isPlainObject(y)){if(G.hasOwnProp(y,m))return y[m]}else return;const v=G.hasOwnProp(s,"transitional")?s.transitional:void 0;if(G.isPlainObject(v)&&G.hasOwnProp(v,m))return v[m]}function f(m,y,v){if(G.hasOwnProp(e,v))return r(m,y);if(G.hasOwnProp(s,v))return r(void 0,m)}const h={url:l,method:l,data:l,baseURL:c,transformRequest:c,transformResponse:c,paramsSerializer:c,timeout:c,timeoutErrorMessage:c,withCredentials:c,withXSRFToken:c,adapter:c,responseType:c,xsrfCookieName:c,xsrfHeaderName:c,onUploadProgress:c,onDownloadProgress:c,decompress:c,maxContentLength:c,maxBodyLength:c,beforeRedirect:c,transport:c,httpAgent:c,httpsAgent:c,cancelToken:c,socketPath:c,allowedSocketPaths:c,responseEncoding:c,validateStatus:f,headers:(m,y,v)=>i(Jm(m),Jm(y),v,!0)};return G.forEach(AE({...s,...e}),function(y){if(y==="__proto__"||y==="constructor"||y==="prototype")return;const v=G.hasOwnProp(h,y)?h[y]:i,S=G.hasOwnProp(s,y)?s[y]:void 0,_=G.hasOwnProp(e,y)?e[y]:void 0,x=v(S,_,y);G.isUndefined(x)&&v!==f||(n[y]=x)}),G.hasOwnProp(e,"validateStatus")&&G.isUndefined(e.validateStatus)&&d("validateStatusUndefinedResolves")===!1&&(G.hasOwnProp(s,"validateStatus")?n.validateStatus=r(void 0,s.validateStatus):delete n.validateStatus),n}const xE=["content-type","content-length"];function TE(s,e,n){if(n!=="content-only"){s.set(e);return}Object.entries(e||{}).forEach(([r,i])=>{xE.includes(r.toLowerCase())&&s.set(r,i)})}const kE=s=>encodeURIComponent(s).replace(/%([0-9A-F]{2})/gi,(e,n)=>String.fromCharCode(parseInt(n,16)));function Qm(s){const e=xi({},s),n=v=>G.hasOwnProp(e,v)?e[v]:void 0,r=n("data");let i=n("withXSRFToken");const l=n("xsrfHeaderName"),c=n("xsrfCookieName");let d=n("headers");const f=n("auth"),h=n("baseURL"),m=n("allowAbsoluteUrls"),y=n("url");if(e.headers=d=xn.from(d),e.url=Im(Xm(h,y,m,e),n("params"),n("paramsSerializer")),f){const v=G.getSafeProp(f,"username")||"",S=G.getSafeProp(f,"password")||"";try{d.set("Authorization","Basic "+btoa(v+":"+(S?kE(S):"")))}catch(_){throw we.from(_,we.ERR_BAD_OPTION_VALUE,s)}}if(G.isFormData(r)){const v=G.getSafeProp(r,"getHeaders");gn.hasStandardBrowserEnv||gn.hasStandardBrowserWebWorkerEnv||G.isReactNative(r)?d.setContentType(void 0):G.isFunction(v)&&TE(d,v.call(r),n("formDataHeaderPolicy"))}if(gn.hasStandardBrowserEnv&&(G.isFunction(i)&&(i=i(e)),i===!0||i==null&&bE(e.url))){const S=l&&c&&vE.read(c);S&&d.set(l,S)}return e}const RE=typeof XMLHttpRequest<"u"&&function(s){return new Promise(function(n,r){const i=Qm(s);let l=i.data;const c=xn.from(i.headers).normalize();let{responseType:d,onUploadProgress:f,onDownloadProgress:h}=i,m,y,v,S,_,x;function A(){S&&S(),_&&_(),i.cancelToken&&i.cancelToken.unsubscribe(m),i.signal&&i.signal.removeEventListener("abort",m)}let D=new XMLHttpRequest;D.open(i.method.toUpperCase(),i.url,!0),D.timeout=i.timeout;function O(L){if(!D)return;if(D.status===0&&(vf(Vm(i.url))||vf(gn.origin))!=="file"&&!(D.responseURL&&D.responseURL.startsWith("file:"))){r(new we("Request aborted",we.ECONNABORTED,s,D)),A(),D=null;return}try{L?x&&x(L):_&&_()}catch(W){setTimeout(()=>{throw W})}if(!D)return;const B=xn.from("getAllResponseHeaders"in D&&D.getAllResponseHeaders()),z={data:!d||d==="text"||d==="json"?D.responseText:D.response,status:D.status,statusText:D.statusText,headers:B,config:s,request:D};Fm(function(de){n(de),A()},function(de){r(de),A()},z),D=null}"onloadend"in D?D.onloadend=O:D.onreadystatechange=function(){!D||D.readyState!==4||D.status===0&&!(D.responseURL&&D.responseURL.startsWith("file:"))||setTimeout(O)},D.onabort=function(){D&&(r(new we("Request aborted",we.ECONNABORTED,s,D)),A(),D=null)},D.onerror=function(B){const q=B&&B.message?B.message:"Network Error",z=new we(q,we.ERR_NETWORK,s,D);z.event=B||null,r(z),A(),D=null},D.ontimeout=function(){let B=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const q=i.transitional||gf;i.timeoutErrorMessage&&(B=i.timeoutErrorMessage),r(new we(B,q.clarifyTimeoutError?we.ETIMEDOUT:we.ECONNABORTED,s,D)),A(),D=null},l===void 0&&c.setContentType(null),"setRequestHeader"in D&&G.forEach(Rm(c),function(B,q){D.setRequestHeader(q,B)}),G.isUndefined(i.withCredentials)||(D.withCredentials=!!i.withCredentials),d&&d!=="json"&&(D.responseType=i.responseType),h&&([v,_,x]=mc(h,!0),D.addEventListener("progress",v)),f&&D.upload&&([y,S]=mc(f),D.upload.addEventListener("progress",y),D.upload.addEventListener("loadend",S)),(i.cancelToken||i.signal)&&(m=L=>{D&&(r(!L||L.type?new Lo(null,s,D):L),D.abort(),A(),D=null)},i.cancelToken&&i.cancelToken.subscribe(m),i.signal&&(i.signal.aborted?m():i.signal.addEventListener("abort",m)));const k=vf(i.url);if(k&&!gn.protocols.includes(k)){r(new we("Unsupported protocol "+k+":",we.ERR_BAD_REQUEST,s)),A();return}D.send(l||null)})},DE=(s,e)=>{if(s=s?s.filter(Boolean):[],!e&&!s.length)return;const n=new AbortController;let r=!1;const i=function(f){if(!r){r=!0,c();const h=f instanceof Error?f:this.reason;n.abort(h instanceof we?h:new Lo(h instanceof Error?h.message:h))}};let l=e&&setTimeout(()=>{l=null,i(new we(`timeout of ${e}ms exceeded`,we.ETIMEDOUT))},e);const c=()=>{s&&(l&&clearTimeout(l),l=null,s.forEach(f=>{f.unsubscribe?f.unsubscribe(i):f.removeEventListener("abort",i)}),s=null)};s.forEach(f=>{if(!r){if(f.aborted){i.call(f);return}f.addEventListener("abort",i,{once:!0})}});const{signal:d}=n;return d.unsubscribe=()=>G.asap(c),d},OE=function*(s,e){let n=s.byteLength;if(n{const i=LE(s,e);let l=0,c,d=f=>{c||(c=!0,r&&r(f))};return new ReadableStream({async pull(f){try{const{done:h,value:m}=await i.next();if(h){d(),f.close();return}let y=m.byteLength;if(n){let v=l+=y;n(v)}f.enqueue(new Uint8Array(m))}catch(h){throw d(h),h}},cancel(f){return d(f),i.return()}},{highWaterMark:2})},ey=s=>s>=48&&s<=57||s>=65&&s<=70||s>=97&&s<=102,ty=(s,e,n)=>e+2s<=57?s-48:(s&223)-55,ME=s=>s>=65&&s<=90||s>=97&&s<=122||s>=48&&s<=57||s===43||s===47||s===45||s===95,NE=s=>s===9||s===10||s===12||s===13||s===32,IE=s=>{const e=Math.floor(s/4),n=s%4;return e*3+(n===2?1:n===3?2:0)},jE=s=>{const e=s.length;let n=0;return e>0&&s.charCodeAt(e-1)===61&&(n++,e>1&&s.charCodeAt(e-2)===61&&n++),Math.floor((e-n)*3/4)},HE=s=>{const e=s.length;let n=0,r=0,i=!1;for(let l=0;l0){i=!0;continue}n++}}return i||r>2||r>0&&(n+r)%4!==0||n%4===1?jE(s):IE(n)},zE=(s,e)=>{if(!s||typeof s!="string"||!s.startsWith("data:"))return 0;const n=s.indexOf(",");if(n<0)return 0;const r=s.slice(5,n),i=s.slice(n+1);if(/;base64/i.test(r))return e(i);let c=0;for(let d=0,f=i.length;d=55296&&h<=56319&&d+1=56320&&m<=57343?(c+=4,d++):c+=3}else c+=3}return c};function PE(s){const e=typeof s=="string"?s.indexOf("#"):-1;return zE(e===-1?s:s.slice(0,e),HE)}const Sf="1.20.0",ry=64*1024,UE={cache:"default",redirect:"follow",referrer:"about:client",referrerPolicy:"",mode:"cors",integrity:"",keepalive:!1,priority:"auto",window:null},{isFunction:yc}=G,BE=s=>encodeURIComponent(s).replace(/%([0-9A-F]{2})/gi,(e,n)=>String.fromCharCode(parseInt(n,16))),ay=s=>{if(!G.isString(s))return s;try{return decodeURIComponent(s)}catch{return s}},iy=(s,...e)=>{try{return!!s(...e)}catch{return!1}},qE=s=>{const e=s.indexOf("://");let n=s;return e!==-1&&(n=n.slice(e+3)),n.includes("@")||n.includes(":")},GE=s=>{const e=G.global!==void 0&&G.global!==null?G.global:globalThis,{ReadableStream:n,TextEncoder:r}=e;s=G.merge.call({skipUndefined:!0},{Request:e.Request,Response:e.Response},s);const{fetch:i,Request:l,Response:c}=s,d=i?yc(i):typeof fetch=="function",f=yc(l),h=yc(c);if(!d)return!1;const m=d&&yc(n),y=d&&(typeof r=="function"?(D=>O=>D.encode(O))(new r):async D=>new Uint8Array(await new l(D).arrayBuffer())),v=f&&m&&iy(()=>{let D=!1;const O=new l(gn.origin,{body:new n,method:"POST",get duplex(){return D=!0,"half"}}),k=O.headers.has("Content-Type");return O.body!=null&&O.body.cancel(),D&&!k}),S=h&&m&&iy(()=>G.isReadableStream(new c("").body)),_={stream:S&&(D=>D.body)};d&&["text","arrayBuffer","blob","formData","stream"].forEach(D=>{!_[D]&&(_[D]=(O,k)=>{let L=O&&O[D];if(L)return L.call(O);throw new we(`Response type '${D}' is not supported`,we.ERR_NOT_SUPPORT,k)})});const x=async D=>{if(D==null)return 0;if(G.isBlob(D))return D.size;if(G.isSpecCompliantForm(D))return(await new l(gn.origin,{method:"POST",body:D}).arrayBuffer()).byteLength;if(G.isArrayBufferView(D)||G.isArrayBuffer(D))return D.byteLength;if(G.isURLSearchParams(D)&&(D=D+""),G.isString(D))return(await y(D)).byteLength},A=async(D,O)=>{const k=G.toFiniteNumber(D.getContentLength());return k??x(O)};return async D=>{let{url:O,method:k,data:L,signal:B,cancelToken:q,timeout:z,onDownloadProgress:W,onUploadProgress:de,responseType:_e,headers:Se,withCredentials:je="same-origin",fetchOptions:Fe,maxContentLength:ze,maxBodyLength:Et,maxRedirects:Q}=Qm(D);const ue=G.isNumber(ze)&&ze>-1,De=G.isNumber(Et)&&Et>-1,ee=ge=>G.hasOwnProp(D,ge)?D[ge]:void 0;let me=i||fetch;_e=_e?(_e+"").toLowerCase():"text";let H=DE([B,q&&q.toAbortSignal()],z),T=null;const fe=H&&H.unsubscribe&&(()=>{H.unsubscribe()});let he,Ae=null;const se=()=>new we("Request body larger than maxBodyLength limit",we.ERR_BAD_REQUEST,D,T);try{let ge;const $e=ee("auth");if($e){const qe=G.getSafeProp($e,"username")||"",mt=G.getSafeProp($e,"password")||"";ge={username:qe,password:mt}}if(qE(O)){const qe=new URL(O,gn.origin);if(!ge&&(qe.username||qe.password)){const mt=ay(qe.username),Dt=ay(qe.password);ge={username:mt,password:Dt}}(qe.username||qe.password)&&(qe.username="",qe.password="",O=qe.href)}if(ge&&(Se.delete("authorization"),Se.set("Authorization","Basic "+btoa(BE((ge.username||"")+":"+(ge.password||""))))),ue&&typeof O=="string"&&O.startsWith("data:")&&PE(O)>ze)throw new we("maxContentLength size of "+ze+" exceeded",we.ERR_BAD_RESPONSE,D,T);if(De&&k!=="get"&&k!=="head"){const qe=await x(L);if(typeof qe=="number"&&isFinite(qe)&&(he=qe,qe>Et))throw se()}const Te=De&&(G.isReadableStream(L)||G.isStream(L)),Ie=(qe,mt,Dt)=>Zm(qe,ry,zt=>{if(De&&zt>Et)throw Ae=se();mt&&mt(zt)},Dt);if(v&&k!=="get"&&k!=="head"&&(de||Te)){if(he=he??await A(Se,L),he!==0||Te){let qe=new l(O,{method:"POST",body:L,duplex:"half"}),mt;if(G.isFormData(L)&&(mt=qe.headers.get("content-type"))&&Se.setContentType(mt),qe.body){const[Dt,zt]=de&&Km(he,mc(Wm(de)))||[];L=Ie(qe.body,Dt,zt)}}}else if(Te&&!f&&m&&k!=="get"&&k!=="head")L=Ie(L);else if(Te&&f&&!v&&k!=="get"&&k!=="head")throw new we("Stream request bodies are not supported by the current fetch implementation",we.ERR_NOT_SUPPORT,D,T);G.isString(je)||(je=je?"include":"omit");const xt=f&&"credentials"in l.prototype;if(G.isFormData(L)){const qe=Se.getContentType();qe&&/^multipart\/form-data/i.test(qe)&&!/boundary=/i.test(qe)&&Se.delete("content-type")}Se.set("User-Agent","axios/"+Sf,!1);const rt=Fe==null?Fe:Object.assign(Object.create(null),Fe);rt&&(delete rt.body,delete rt.headers,delete rt.method,delete rt.signal,delete rt.duplex,delete rt.credentials);const gt=Object.assign(Object.create(null),rt,{signal:H,method:k.toUpperCase(),headers:Rm(Se.normalize()),body:L,duplex:"half",credentials:xt?je:void 0});f&&(G.forEach(UE,(qe,mt)=>{gt[mt]===void 0&&(gt[mt]=qe)}),gt.signal===void 0&&(gt.signal=null),gt.body===void 0&&(gt.body=null)),Q===0&&(gt.redirect="manual",rt&&(rt.redirect="manual")),T=f&&new l(O,gt);let at=await(f?me(T,rt):me(O,gt));const Yt=xn.from(at.headers);if(ue){const qe=G.toFiniteNumber(Yt.getContentLength());if(qe!=null&&qe>ze)throw new we("maxContentLength size of "+ze+" exceeded",we.ERR_BAD_RESPONSE,D,T)}const Ht=S&&(_e==="stream"||_e==="response");if(S&&at.body&&(W||ue||Ht&&fe)){const qe={};["status","statusText","headers"].forEach(Ot=>{qe[Ot]=at[Ot]});const mt=G.toFiniteNumber(Yt.getContentLength()),[Dt,zt]=W&&Km(mt,mc(Wm(W),!0))||[];let kn=0;const hr=Ot=>{if(ue&&(kn=Ot,kn>ze))throw new we("maxContentLength size of "+ze+" exceeded",we.ERR_BAD_RESPONSE,D,T);Dt&&Dt(Ot)};at=new c(Zm(at.body,ry,hr,()=>{zt&&zt(),fe&&fe()}),qe)}_e=_e||"text";let bt=await _[G.findKey(_,_e)||"text"](at,D);if(ue&&!S&&!Ht){let qe;if(bt!=null&&(typeof bt.byteLength=="number"?qe=bt.byteLength:typeof bt.size=="number"?qe=bt.size:typeof bt=="string"&&(qe=typeof r=="function"?new r().encode(bt).byteLength:bt.length)),typeof qe=="number"&&qe>ze)throw new we("maxContentLength size of "+ze+" exceeded",we.ERR_BAD_RESPONSE,D,T)}return!Ht&&fe&&fe(),await new Promise((qe,mt)=>{Fm(qe,mt,{data:bt,headers:xn.from(at.headers),status:at.status,statusText:at.statusText,config:D,request:T})})}catch(ge){if(fe&&fe(),H&&H.aborted&&H.reason instanceof we){const $e=H.reason;throw $e.config=D,T&&($e.request=T),ge!==$e&&Object.defineProperty($e,"cause",{__proto__:null,value:ge,writable:!0,enumerable:!1,configurable:!0}),$e}if(Ae)throw T&&!Ae.request&&(Ae.request=T),Ae;if(ge instanceof we)throw T&&!ge.request&&(ge.request=T),ge;if(ge&&ge.name==="TypeError"&&/Load failed|fetch/i.test(ge.message)){const $e=new we("Network Error",we.ERR_NETWORK,D,T,ge&&ge.response);throw Object.defineProperty($e,"cause",{__proto__:null,value:ge.cause||ge,writable:!0,enumerable:!1,configurable:!0}),$e}throw we.from(ge,ge&&ge.code,D,T,ge&&ge.response)}}},FE=new Map,sy=s=>{let e=s&&s.env||{};const{fetch:n,Request:r,Response:i}=e,l=[r,i,n];let c=l.length,d=c,f,h,m=FE;for(;d--;)f=l[d],h=m.get(f),h===void 0&&m.set(f,h=d?new Map:GE(e)),m=h;return h};sy();const wf={http:rE,xhr:RE,fetch:{get:sy}};G.forEach(wf,(s,e)=>{if(s){try{Object.defineProperty(s,"name",{__proto__:null,value:e})}catch{}Object.defineProperty(s,"adapterName",{__proto__:null,value:e})}});const oy=s=>`- ${s}`,VE=s=>G.isFunction(s)||s===null||s===!1;function KE(s,e){s=G.isArray(s)?s:[s];const{length:n}=s;let r,i;const l={};for(let c=0;c`adapter ${f} `+(h===!1?"is not supported by the environment":"is not available in the build"));let d=n?c.length>1?`since : +`+c.map(oy).join(` +`):" "+oy(c[0]):"as no adapter specified";throw new we("There is no suitable adapter to dispatch the request "+d,we.ERR_NOT_SUPPORT)}return i}const ly={getAdapter:KE,adapters:wf};function Cf(s){if(s.cancelToken&&s.cancelToken.throwIfRequested(),s.signal&&s.signal.aborted)throw new Lo(null,s)}function Ef(s){const e=G.toSafeFlatObject(s);return Cf(e),e.headers=xn.from(G.getSafeProp(e,"headers")),e.data=bf.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),ly.getAdapter(e.adapter||Oo.adapter,e)(e).then(function(i){Cf(e),e.response=i;try{i.data=bf.call(e,e.transformResponse,i)}finally{delete e.response}return i.headers=xn.from(i.headers),i},function(i){if(!Gm(i)&&(Cf(e),i&&i.response)){e.response=i.response;try{i.response.data=bf.call(e,e.transformResponse,i.response)}finally{delete e.response}i.response.headers=xn.from(i.response.headers)}return Promise.reject(i)})}const bc={};["object","boolean","number","function","string","symbol"].forEach((s,e)=>{bc[s]=function(r){return typeof r===s||"a"+(e<1?"n ":" ")+s}});const cy={};bc.transitional=function(e,n,r){function i(l,c){return"[Axios v"+Sf+"] Transitional option '"+l+"'"+c+(r?". "+r:"")}return(l,c,d)=>{if(e===!1)throw new we(i(c," has been removed"+(n?" in "+n:"")),we.ERR_DEPRECATED);return n&&!cy[c]&&(cy[c]=!0,console.warn(i(c," has been deprecated since v"+n+" and will be removed in the near future"))),e?e(l,c,d):!0}},bc.spelling=function(e){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};function WE(s,e,n){if(typeof s!="object"||s===null)throw new we("options must be an object",we.ERR_BAD_OPTION_VALUE);const r=Object.keys(s);let i=r.length;for(;i-- >0;){const l=r[i],c=Object.prototype.hasOwnProperty.call(e,l)?e[l]:void 0;if(c){const d=s[l],f=d===void 0||c(d,l,s);if(f!==!0)throw new we("option "+l+" must be "+f,we.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new we("Unknown option "+l,we.ERR_BAD_OPTION)}}const vc={assertOptions:WE,validators:bc},Tn=vc.validators;let Ti=class{constructor(e){this.defaults=e||{},this.interceptors={request:new zm,response:new zm}}async request(e,n){try{return await this._request(e,n)}catch(r){if(r instanceof Error)try{let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const l=i.stack;let c="";if(typeof l=="string"){const d=l.indexOf(` +`);c=d===-1?"":l.slice(d+1)}if(!r.stack)r.stack=c;else if(c){const d=c.indexOf(` +`),f=d===-1?-1:c.indexOf(` +`,d+1),h=f===-1?"":c.slice(f+1);String(r.stack).endsWith(h)||(r.stack+=` +`+c)}}catch{}throw r}}_request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=xi(this.defaults,n);const{transitional:r,paramsSerializer:i,headers:l}=n;r!==void 0&&vc.assertOptions(r,{silentJSONParsing:Tn.transitional(Tn.boolean),forcedJSONParsing:Tn.transitional(Tn.boolean),clarifyTimeoutError:Tn.transitional(Tn.boolean),legacyInterceptorReqResOrdering:Tn.transitional(Tn.boolean),advertiseZstdAcceptEncoding:Tn.transitional(Tn.boolean),validateStatusUndefinedResolves:Tn.transitional(Tn.boolean)},!1),i!=null&&(G.isFunction(i)?n.paramsSerializer={serialize:i}:vc.assertOptions(i,{encode:Tn.function,serialize:Tn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),vc.assertOptions(n,{baseUrl:Tn.spelling("baseURL"),withXsrfToken:Tn.spelling("withXSRFToken")},!0),n.method=(G.getSafeProp(n,"method")||G.getSafeProp(this.defaults,"method")||"get").toLowerCase();let c=l&&G.merge(l.common,l[n.method]);l&&G.forEach(qm.concat("common"),_=>{delete l[_]}),n.headers=xn.concat(c,l);const d=[];let f=!0;this.interceptors.request.forEach(function(x){if(typeof x.runWhen=="function"&&x.runWhen(n)===!1)return;f=f&&x.synchronous;const A=n.transitional||gf;A&&A.legacyInterceptorReqResOrdering?d.unshift(x.fulfilled,x.rejected):d.push(x.fulfilled,x.rejected)});const h=[];this.interceptors.response.forEach(function(x){h.push(x.fulfilled,x.rejected)});let m,y=0,v;if(!f){const _=[Ef.bind(this),void 0];for(_.unshift(...d),_.push(...h),v=_.length,m=Promise.resolve(n);yEf.call(this,S)))}catch(D){m=Promise.reject(D)}break}}if(!m)try{m=Ef.call(this,S)}catch(_){m=Promise.reject(_)}for(y=0,v=h.length;y{if(!r._listeners)return;let l=r._listeners.length;for(;l-- >0;)r._listeners[l](i);r._listeners=null}),this.promise.then=i=>{let l;const c=new Promise(d=>{r.subscribe(d),l=d}).then(i);return c.cancel=function(){r.unsubscribe(l)},c},e(function(l,c,d){r.reason||(r.reason=new Lo(l,c,d),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const e=new AbortController,n=r=>{e.abort(r)};return this.subscribe(n),e.signal.unsubscribe=()=>this.unsubscribe(n),e.signal}static source(){let e;return{token:new r0(function(i){e=i}),cancel:e}}};function XE(s){return function(n){return s.apply(null,n)}}function JE(s){return G.isObject(s)&&s.isAxiosError===!0}const Sc={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,ContentTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,UnprocessableContent:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerReturnsAnUnknownError:520,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Sc).forEach(([s,e])=>{Sc[e]===void 0&&(Sc[e]=s)});function uy(s){const e=new Ti(s),n=mm(Ti.prototype.request,e);return G.extend(n,Ti.prototype,e,{allOwnKeys:!0}),G.extend(n,e,null,{allOwnKeys:!0}),n.create=function(i){return uy(xi(s,i))},n}const Qt=uy(Oo);Qt.Axios=Ti,Qt.CanceledError=Lo,Qt.CancelToken=YE,Qt.isCancel=Gm,Qt.VERSION=Sf,Qt.toFormData=gc,Qt.AxiosError=we,Qt.Cancel=Qt.CanceledError,Qt.all=function(e){return Promise.all(e)},Qt.spread=XE,Qt.isAxiosError=JE,Qt.mergeConfig=xi,Qt.AxiosHeaders=xn,Qt.formToJSON=s=>Bm(G.isHTMLForm(s)?new FormData(s):s),Qt.getAdapter=ly.getAdapter,Qt.HttpStatusCode=Sc,Qt.default=Qt;const{Axios:RR,AxiosError:DR,CanceledError:OR,isCancel:LR,CancelToken:$R,VERSION:MR,all:NR,Cancel:IR,isAxiosError:jR,spread:HR,toFormData:zR,AxiosHeaders:PR,HttpStatusCode:UR,formToJSON:BR,getAdapter:qR,mergeConfig:GR,create:FR}=Qt,_f="g7.identity.redirectStash",wc=pt("IdentityGuardInterceptor");class At{static setLauncher(e){this.launcher=e}static hasLauncher(){return this.launcher!==null}static markDomainNoticeShown(){this.domainNoticeShown=!0}static consumeDomainNoticeShown(){const e=this.domainNoticeShown;return this.domainNoticeShown=!1,e}static resolveDeferred(e){const n=this.deferredResolver;if(!n){wc.warn("IdentityGuardInterceptor.resolveDeferred 호출됐지만 대기 중인 launcher 가 없습니다. 모달이 launcher 외부에서 열렸는지 확인하세요.");return}this.deferredResolver=null,n(e)}static createDeferred(){if(this.deferredResolver){const e=this.deferredResolver;this.deferredResolver=null,e({status:"cancelled"})}return new Promise(e=>{this.deferredResolver=e})}static isIdentityRequired(e,n){return e===428&&typeof n=="object"&&n!==null&&n.error_code==="identity_verification_required"}static async handle(e,n,r){this.domainNoticeShown=!1;const i=this.launcher??ZE,c=!!(r&&(r.email||r.phone))?{...e.verification,target:r}:e.verification,d=await i(c);if(d.status!=="verified")return null;const f=c.return_request;if(!f)return null;const h=QE(f.url,d.token);return fetch(h,{method:f.method,headers:n?.headers??{Accept:"application/json","Content-Type":"application/json"},body:n?.body,credentials:n?.credentials??"same-origin"})}static redirectExternally(e){const n=e.redirect_url;if(!n)return wc.error("redirectExternally 호출 시 verification.redirect_url 이 없습니다. payload:",e),Promise.resolve({status:"failed",failureCode:"MISSING_REDIRECT_URL",reason:"verification.redirect_url is required for external_redirect flow"});if(typeof window<"u"){const r={return_url:window.location.href,payload:e,stashed_at:Date.now()};try{window.sessionStorage?.setItem(_f,JSON.stringify(r))}catch(i){wc.warn("sessionStorage 접근 실패 — stash 없이 redirect 합니다.",i)}window.location.href=n}return new Promise(()=>{})}static reset(){if(this.deferredResolver){const e=this.deferredResolver;this.deferredResolver=null;try{e({status:"cancelled"})}catch{}}this.launcher=null,this.domainNoticeShown=!1}}M(At,"launcher",null),M(At,"deferredResolver",null),M(At,"domainNoticeShown",!1);function QE(s,e){if(!e)return s;try{const n=typeof window<"u"?window.location.origin:"http://localhost",r=new URL(s,n);return r.searchParams.set("verification_token",e),/^https?:\/\//i.test(s)?r.toString():`${r.pathname}${r.search}${r.hash}`}catch{const n=s.includes("?")?"&":"?";return`${s}${n}verification_token=${encodeURIComponent(e)}`}}const ZE=async s=>{if(typeof window>"u")return{status:"cancelled"};if(s.render_hint==="external_redirect"||s.redirect_url)return At.redirectExternally(s);const e=window.G7Core;if(!e?.dispatch)return console.error("[IdentityGuardInterceptor] defaultLauncher: G7Core 가 초기화되지 않아 본인인증 흐름을 시작할 수 없습니다."),{status:"failed",failureCode:"G7_NOT_READY"};try{await e.dispatch({handler:"toast",params:{message:"본인 확인이 필요합니다.",variant:"warning"}})}catch{}const n=window.location.href,r={return_url:n,payload:s,stashed_at:Date.now()};try{window.sessionStorage?.setItem(_f,JSON.stringify(r))}catch{}const i=`/identity/challenge?return=${encodeURIComponent(n)}`;try{await e.dispatch({handler:"navigate",params:{path:i}})}catch(l){wc.warn("navigate 실패 — window.location 으로 폴백",l),window.location.href=i}return new Promise(()=>{})},dy=pt("ApiClient");function Af(){return typeof window<"u"&&window.__G7_DEVTOOLS__?window.__G7_DEVTOOLS__:null}class e_{constructor(e={}){M(this,"client");M(this,"config");M(this,"TOKEN_KEY","auth_token");this.config={baseURL:e.baseURL||"/api",timeout:e.timeout||3e4,onTokenExpired:e.onTokenExpired,onUnauthorized:e.onUnauthorized,onError:e.onError},this.client=Qt.create({baseURL:this.config.baseURL,timeout:this.config.timeout,headers:{"Content-Type":"application/json",Accept:"application/json"},paramsSerializer:{serialize:n=>{const r=[];for(const[i,l]of Object.entries(n))if(l!=null)if(Array.isArray(l)){const c=i.endsWith("[]")?i:`${i}[]`;for(const d of l)r.push(`${encodeURIComponent(c)}=${encodeURIComponent(String(d))}`)}else r.push(`${encodeURIComponent(i)}=${encodeURIComponent(String(l))}`);return r.join("&")}}}),this.setupInterceptors()}setToken(e){if(typeof e!="string"||e===""){dy.warn("Ignoring invalid auth token — token must be a non-empty string.");return}typeof window<"u"&&localStorage.setItem(this.TOKEN_KEY,e)}getToken(){return typeof window<"u"?localStorage.getItem(this.TOKEN_KEY):null}removeToken(){typeof window<"u"&&localStorage.removeItem(this.TOKEN_KEY)}setupInterceptors(){this.client.interceptors.request.use(e=>{e.url?.startsWith("/api")&&e.baseURL==="/api"&&(e.baseURL="");const n=this.getToken();if(n&&e.headers&&!this.isCrossOriginRequest(e.url)&&(e.headers.Authorization=`Bearer ${n}`),typeof window<"u"&&e.headers){const i=localStorage.getItem("g7_locale");i&&(e.headers["Accept-Language"]=i)}const r=Af();if(r?.isEnabled()){const i=this.buildFullUrl(e),l=(e.method||"GET").toUpperCase(),c=r.trackRequest(i,l,{requestBody:e.data});e._devToolsRequestId=c}return e},e=>Promise.reject(e)),this.client.interceptors.response.use(e=>{const n=e.config,r=n._devToolsRequestId;if(r){const i=Af();i?.isEnabled()&&i.completeRequest(r,e.status,e.data),n._devToolsRequestId=null}return e},async e=>{const n=e.config,r=n?.url||"",l=["/auth/","/layouts/"].some(c=>r.includes(c));if(e.response?.status===401&&!n?._retry&&!l){if(n._retry=!0,await Xn.getInstance().refreshToken()){const f=this.getToken();return f&&(n.headers.Authorization=`Bearer ${f}`),n._devToolsRequestId=null,this.client(n)}return this.completeDevToolsRequest(n,e),this.removeToken(),this.config.onUnauthorized&&this.config.onUnauthorized(),Promise.reject(e)}if(e.response?.status===401&&l)return this.completeDevToolsRequest(n,e),Promise.reject(e);if(At.isIdentityRequired(e.response?.status,e.response?.data)){this.completeDevToolsRequest(n,e);const c={},d=n?.headers??{};for(const[v,S]of Object.entries(d))typeof S=="string"&&(c[v]=S);let f;n?.data!==void 0&&n?.data!==null&&(f=typeof n.data=="string"?n.data:JSON.stringify(n.data),c["Content-Type"]=c["Content-Type"]??"application/json");const h=n?.identity_target,m=await At.handle(e.response.data,{headers:c,body:f,credentials:"same-origin"},h);if(!m)return Promise.reject(e);let y=null;try{y=await m.json()}catch{y=null}return m.ok?{...e.response,status:m.status,data:y}:Promise.reject(Object.assign(new Error("replay failed"),{response:{status:m.status,data:y}}))}return e.response?.status===403?(this.completeDevToolsRequest(n,e),this.callOnError(e),Promise.reject(e)):(this.completeDevToolsRequest(n,e),e.response&&this.callOnError(e),Promise.reject(e))})}async get(e,n){return(await this.client.get(e,n)).data}async post(e,n,r){return(await this.client.post(e,n,r)).data}async put(e,n,r){return(await this.client.put(e,n,r)).data}async patch(e,n,r){return(await this.client.patch(e,n,r)).data}async delete(e,n){return(await this.client.delete(e,n)).data}getInstance(){return this.client}setOnUnauthorized(e){this.config.onUnauthorized=e}setOnError(e){this.config.onError=e}completeDevToolsRequest(e,n){if(!e?._devToolsRequestId)return;const r=Af();if(!r?.isEnabled())return;const i=e._devToolsRequestId;e._devToolsRequestId=null,n.response?r.completeRequest(i,n.response.status,n.response.data):n.request?r.failRequest(i,n.message||"Network error"):r.failRequest(i,n.message||"Request error")}isCrossOriginRequest(e){if(!e||typeof window>"u"||!window.location||!/^(https?:)?\/\//i.test(e))return!1;try{return new URL(e,window.location.href).origin!==window.location.origin}catch{return!1}}buildFullUrl(e){let n=e.url||"";if(e.baseURL&&!n.startsWith("http")&&(n=`${e.baseURL}${n.startsWith("/")?"":"/"}${n}`),e.params&&typeof e.params=="object"){const r=e.params,i=[];for(const[l,c]of Object.entries(r))if(c!=null)if(Array.isArray(c)){const d=l.endsWith("[]")?l:`${l}[]`;for(const f of c)i.push(`${encodeURIComponent(d)}=${encodeURIComponent(String(f))}`)}else i.push(`${encodeURIComponent(l)}=${encodeURIComponent(String(c))}`);i.length>0&&(n+=(n.includes("?")?"&":"?")+i.join("&"))}return n}callOnError(e){if(!this.config.onError)return;const n={status:e.response?.status||0,message:e.response?.data?.message||e.message||"Unknown error",data:e.response?.data,statusText:e.response?.statusText};try{this.config.onError(n)}catch(r){dy.error("Error in onError handler:",r)}}}let xf=null;function Yn(){return xf||(xf=new e_),xf}const $o=pt("AuthManager");function ki(s,e,n,r){try{window.G7Core?.devTools?.trackAuthEvent?.(s,e,n,r)}catch{}}const fy={admin:{type:"admin",loginPath:"/admin/login",defaultPath:"/admin",userEndpoint:"/admin/auth/user",loginEndpoint:"/auth/admin/login",logoutEndpoint:"/admin/auth/logout",refreshEndpoint:"/admin/auth/refresh",twoFactorEndpoint:"/auth/admin/login/two-factor",twoFactorResendEndpoint:"/auth/admin/login/two-factor/resend"},user:{type:"user",loginPath:"/login",defaultPath:"/",userEndpoint:"/auth/user",loginEndpoint:"/auth/login",logoutEndpoint:"/auth/logout",refreshEndpoint:"/auth/refresh",twoFactorEndpoint:"/auth/login/two-factor",twoFactorResendEndpoint:"/auth/login/two-factor/resend"}},Lr=class Lr{constructor(){M(this,"state");M(this,"config");M(this,"isRefreshing",!1);M(this,"refreshPromise",null);M(this,"eventHandlers",new Map);this.state={isAuthenticated:!1,user:null,type:null},this.config=new Map,this.config.set("admin",fy.admin),this.config.set("user",fy.user)}static getInstance(){return Lr.instance||(Lr.instance=new Lr),Lr.instance}on(e,n){this.eventHandlers.has(e)||this.eventHandlers.set(e,[]),this.eventHandlers.get(e).push(n)}emit(e,...n){const r=this.eventHandlers.get(e);r&&r.forEach(i=>i(...n))}isAuthenticated(){return this.state.isAuthenticated}getUser(){return this.state.user}getAuthType(){return this.state.type}async checkAuth(e){const n=Yn();if(!n.getToken())return this.clearState(),!1;const i=this.config.get(e);if(!i)return $o.error(`Unknown auth type: ${e}`),!1;try{const l=await n.get(i.userEndpoint);return l.success&&l.data?(this.state={isAuthenticated:!0,user:l.data,type:e},this.emit("authStateChange",this.state),!0):(this.clearState(),!1)}catch(l){return l.response?.status===401&&await this.refreshToken()?this.checkAuth(e):(this.clearState(),!1)}}async preloadAuth(e){try{return await this.checkAuth(e)}catch(n){return $o.warn(`Preload auth failed for type ${e}:`,n),!1}}async login(e,n,r){const i=Yn(),l=this.config.get(e);if(!l)throw new Error(`Unknown auth type: ${e}`);try{const c=r?.headers?{headers:r.headers}:void 0,d=await i.post(l.loginEndpoint,n,c);if(d.success&&d.data){if(d.data.two_factor_required===!0)return ki("login",!0,void 0,{type:e,two_factor:!0}),{status:"two_factor_required",challenge:{challengeId:String(d.data.challenge_id??""),providerId:String(d.data.provider_id??""),expiresAt:d.data.expires_at??null}};if(d.data.token&&d.data.user)return{status:"authenticated",user:this.establishSession(e,d.data.token,d.data.user)}}throw new Error("Login failed")}catch(c){throw this.clearState(),this.enhanceAuthError(c,e,"Login failed")}}async completeTwoFactor(e,n,r){const i=Yn(),l=this.config.get(e);if(!l)throw new Error(`Unknown auth type: ${e}`);try{const c=r?.headers?{headers:r.headers}:void 0,d=await i.post(l.twoFactorEndpoint,{challenge_id:n.challengeId,code:n.code},c);if(d.success&&d.data?.token&&d.data?.user)return this.establishSession(e,d.data.token,d.data.user);throw new Error("Login failed")}catch(c){throw this.clearState(),this.enhanceAuthError(c,e,"Login failed")}}async resendTwoFactor(e,n,r){const i=Yn(),l=this.config.get(e);if(!l)throw new Error(`Unknown auth type: ${e}`);try{const c=r?.headers?{headers:r.headers}:void 0,d=await i.post(l.twoFactorResendEndpoint,{challenge_id:n.challengeId},c);if(d.success&&d.data?.challenge_id)return{challengeId:String(d.data.challenge_id),providerId:String(d.data.provider_id??""),expiresAt:d.data.expires_at??null};throw new Error("Resend failed")}catch(c){throw this.enhanceAuthError(c,e,"Resend failed")}}establishSession(e,n,r){Yn().setToken(n);const l=r.language,c=localStorage.getItem(Lr.LOCALE_STORAGE_KEY),d=l&&l!==c;if(l)try{localStorage.setItem(Lr.LOCALE_STORAGE_KEY,l)}catch(f){$o.warn("Failed to save user language to localStorage:",f)}return this.state={isAuthenticated:!0,user:r,type:e},this.emit("login",this.state),this.emit("authStateChange",this.state),ki("login",!0,void 0,{userId:r.uuid,email:r.email,type:e}),d&&window.__templateApp&&window.__templateApp.changeLocale(l),r}enhanceAuthError(e,n,r){const i=e?.response?.data?.message,l=new Error(i||e?.message||r);return l.response=e?.response,l.status=e?.response?.status,l.code=e?.code,ki("login",!1,l.message,{type:n,status:e?.response?.status}),l}async logout(){const e=Yn(),n=this.state.type?this.config.get(this.state.type):null;try{n&&await e.post(n.logoutEndpoint)}catch(r){$o.warn("Logout API call failed:",r)}finally{e.removeToken();const r={...this.state};if(this.clearState(),this.emit("logout",r),this.emit("authStateChange",this.state),ki("logout",!0,void 0,{previousType:r.type}),n&&r.type){const i=window.location.pathname+window.location.search;window.location.href=this.getLoginRedirectUrl(r.type,i)}}}async refreshToken(){if(this.isRefreshing&&this.refreshPromise)return this.refreshPromise;this.isRefreshing=!0,this.refreshPromise=this.doRefreshToken();try{return await this.refreshPromise}finally{this.isRefreshing=!1,this.refreshPromise=null}}async doRefreshToken(){const e=this.state.type;if(!e)return!1;const n=this.config.get(e);if(!n)return!1;const r=Yn();try{const i=await r.post(n.refreshEndpoint);return i.success&&i.data?.token?(r.setToken(i.data.token),this.emit("tokenRefreshed"),ki("token-refresh",!0,void 0,{type:e}),!0):(ki("token-refresh",!1,"No token in response",{type:e}),!1)}catch(i){return $o.error("Token refresh failed:",i),ki("token-refresh",!1,i instanceof Error?i.message:"Unknown error",{type:e}),!1}}getLoginRedirectUrl(e,n,r){const i=this.config.get(e);if(!i)return"/login";const l=encodeURIComponent(n);let c=`${i.loginPath}?redirect=${l}`;return r&&(c+=`&reason=${encodeURIComponent(r)}`),c}updateConfig(e,n){if(n.loginPath!==void 0){const i=n.loginPath;if(!i.startsWith("/")||i.startsWith("//"))throw new Error(`AuthManager.updateConfig: loginPath must be a same-origin path starting with '/' (got: ${i})`)}const r=this.config.get(e);r&&this.config.set(e,{...r,...n})}getRedirectUrl(e){const r=this.config.get(e)?.defaultPath||"/",l=new URLSearchParams(window.location.search).get("redirect");if(l)try{const c=decodeURIComponent(l);if(c.startsWith("/"))return c}catch{}return r}getConfig(e){return this.config.get(e)}clearState(){this.state={isAuthenticated:!1,user:null,type:null}}static resetInstance(){Lr.instance=null}};M(Lr,"instance"),M(Lr,"LOCALE_STORAGE_KEY","g7_locale");let Xn=Lr;const hy={401:{handler:"navigate",params:{path:"{{auth.loginPath}}"}},403:{handler:"toast",params:{type:"error",message:"{{error.message}}"}},404:{handler:"toast",params:{type:"error",message:"{{error.message}}"}},422:{handler:"toast",params:{type:"error",message:"{{error.message}}"}},default:{handler:"toast",params:{type:"error",message:"{{error.message}}"}}},sa={findHandler(s,e){if(s){if(s[e])return s[e];if(s[String(e)])return s[String(e)];if(s.default)return s.default}},normalizeOnError(s){return s?Array.isArray(s)?s:[s]:[]},injectErrorCode(s,e,n){if(s.handler!=="showErrorPage"||s.params?.errorCode!==void 0)return s;const r=typeof e=="string"?parseInt(e,10):e,i=isNaN(r)?n:r;return i===void 0?s:{...s,params:{...s.params,errorCode:i}}}},Tr=pt("ErrorHandlingResolver"),Pa=class Pa{constructor(){M(this,"templateErrorHandling",null);M(this,"layoutErrorHandling",null);M(this,"executeAction",null)}static getInstance(){return Pa.instance||(Pa.instance=new Pa),Pa.instance}static resetInstance(){Pa.instance=null}setTemplateConfig(e){this.templateErrorHandling=e,Tr.log("Template config set:",e)}setLayoutConfig(e){this.layoutErrorHandling=e,Tr.log("Layout config set:",e)}setActionExecutor(e){this.executeAction=e}resolve(e,n={}){const{errorHandling:r,onError:i}=n;Tr.log("Resolving error:",e,{hasActionErrorHandling:!!r,hasActionOnError:!!i,hasLayoutConfig:!!this.layoutErrorHandling,hasTemplateConfig:!!this.templateErrorHandling});let l=sa.findHandler(r,e);if(l){const c=this.getMatchedKey(r,e);return{handler:sa.injectErrorCode(l,c,e),level:"action",matchedKey:c}}if(i){const c=sa.normalizeOnError(i);if(c.length>0)return{handler:c.length===1?c[0]:{handler:"sequence",actions:c},level:"action",matchedKey:"onError"}}if(l=sa.findHandler(this.layoutErrorHandling||void 0,e),l){const c=this.getMatchedKey(this.layoutErrorHandling,e);return{handler:sa.injectErrorCode(l,c,e),level:"layout",matchedKey:c}}if(l=sa.findHandler(this.templateErrorHandling||void 0,e),l){const c=this.getMatchedKey(this.templateErrorHandling,e);return{handler:sa.injectErrorCode(l,c,e),level:"template",matchedKey:c}}if(l=sa.findHandler(hy,e),l){const c=this.getMatchedKey(hy,e);return{handler:sa.injectErrorCode(l,c,e),level:"system",matchedKey:c}}return{handler:null,level:null,matchedKey:null}}async execute(e,n){if(!this.executeAction){Tr.error("Action executor is not set");return}Tr.log("Executing handler:",e.handler,{errorContext:n});try{return await this.executeAction(e,{error:n})}catch(r){throw Tr.error("Failed to execute handler:",r),r}}async resolveAndExecute(e,n,r={}){const i=this.resolve(e,r);if(Tr.log("Resolve result:",{errorCode:e,handler:i.handler?.handler,level:i.level,matchedKey:i.matchedKey}),!i.handler)return Tr.warn("No handler found for error:",e),{handled:!1};try{return{handled:!0,result:await this.execute(i.handler,n)}}catch(l){return Tr.error("Handler execution failed:",l),{handled:!1}}}getMatchedKey(e,n){return e[n]?n:e[String(n)]?String(n):"default"}clearLayoutConfig(){this.layoutErrorHandling=null,Tr.log("Layout config cleared")}clearAllConfig(){this.templateErrorHandling=null,this.layoutErrorHandling=null,Tr.log("All config cleared")}getConfigStatus(){return{hasTemplate:this.templateErrorHandling!==null,hasLayout:this.layoutErrorHandling!==null,hasExecutor:this.executeAction!==null}}};M(Pa,"instance",null);let Tf=Pa;function kr(){return Tf.getInstance()}function Mo(s,e){const n={...s};for(const r of Object.keys(e))r in n?n[r]!==null&&typeof n[r]=="object"&&!Array.isArray(n[r])&&e[r]!==null&&typeof e[r]=="object"&&!Array.isArray(e[r])&&(n[r]=Mo(n[r],e[r])):n[r]=e[r];return n}var kf={exports:{}},No={};/** * @license React * react-jsx-runtime.production.js * @@ -54,7 +57,7 @@ Error generating stack: `+u.message+` * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Um;function VC(){if(Um)return Do;Um=1;var s=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,l){var c=null;if(l!==void 0&&(c=""+l),i.key!==void 0&&(c=""+i.key),"key"in i){l={};for(var d in i)d!=="key"&&(l[d]=i[d])}else l=i;return i=l.ref,{$$typeof:s,type:r,key:c,ref:i!==void 0?i:null,props:l}}return Do.Fragment=e,Do.jsx=n,Do.jsxs=n,Do}var Pm;function KC(){return Pm||(Pm=1,yf.exports=VC()),yf.exports}var ft=KC();const WC=ra({__proto__:null,default:aa(ft)},[ft]),bf=dt("ParentContextProvider"),Bm=M.createContext(null);let Ac=null;function vf(){Ac?(bf.log("[triggerModalParentUpdate] 모달 부모 컨텍스트 업데이트 트리거"),Ac()):bf.warn("[triggerModalParentUpdate] Provider가 아직 마운트되지 않음")}const qm=({children:s})=>{const[e,n]=M.useState(0),r=M.useRef(!0),i=M.useCallback(()=>{const c=window.__g7LayoutContextStack||[];return c[c.length-1]?.dataContext},[]);M.useEffect(()=>(r.current=!0,Ac=()=>{r.current&&(n(c=>c+1),bf.log("[ParentContextProvider] 버전 업데이트됨"))},()=>{r.current=!1,Ac=null}),[]);const l={version:e,getParentDataContext:i};return ft.jsx(Bm.Provider,{value:l,children:s})};function YC(){return M.useContext(Bm)}function Gm(s){return s.replace(/[\t\n\r]/g,"").replace(/\\/g,"/").replace(/^([a-z][a-z0-9+.\-]*:)?\/{2,}/i,"$1//")}function Fm(s,e){try{const n=typeof window<"u"&&window.location?.protocol||"https:",r=e||(typeof window<"u"?window.location?.origin:void 0)||"https://localhost",i=s.startsWith("//")?`${n}${s}`:s,l=new URL(i,r);return l.protocol!=="http:"&&l.protocol!=="https:"?null:l.hostname.toLowerCase()}catch{return null}}function fs(){const s=typeof window<"u"?window.G7Config?.trustedScriptHosts:void 0;return Array.isArray(s)?s.map(e=>String(e).toLowerCase()):[]}function Oo(s,e){if(typeof s!="string")return!1;const n=s.trim();if(n==="")return!1;const r=Gm(n),i=r.startsWith("//"),l=/^[a-z][a-z0-9+.-]*:/i.test(r);if(!i&&!l&&r.startsWith("/"))return!0;const c=Fm(r),d=e??fs();return c!==null&&d.map(f=>String(f).toLowerCase()).includes(c)}const N=dt("ActionDispatcher");function XC(s,e,n,r){return n||(Rg(s)||Md(s)?"$t:core.errors.network_request_failed":r||`Failed to execute action: ${e}`)}const Vm=new Set(["navigate","navigateBack","navigateForward","replaceUrl","refresh","logout"]),JC=new Set(["redirect"]);function Xn(){try{return window.G7Core?.devTools}catch{return}}class Tt extends Error{constructor(n,r,i){super(n);$(this,"unknownHandler",!1);this.action=r,this.originalError=i,this.name="ActionError"}}const Km={click:"onClick",change:"onChange",input:"onInput",submit:"onSubmit",focus:"onFocus",blur:"onBlur",keydown:"onKeyDown",keyup:"onKeyUp",keypress:"onKeyPress",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",scroll:"onScroll",dragstart:"onDragStart",drag:"onDrag",dragend:"onDragEnd",dragenter:"onDragEnter",dragover:"onDragOver",dragleave:"onDragLeave",drop:"onDrop"},rn=class rn{constructor(e={},n,r){$(this,"bindingEngine");$(this,"translationEngine");$(this,"translationContext");$(this,"customHandlers",new Map);$(this,"defaultContext");$(this,"globalStateUpdater");$(this,"errorHandlingSetup",!1);$(this,"debounceTimers",new Map);$(this,"pendingDebounceFlushers",new Map);$(this,"debounceAccumulatedValues",new Map);$(this,"globalHeaders",[]);$(this,"namedActions",{});$(this,"previewMode",!1);$(this,"localMirrorDepth",0);$(this,"intervals",new Map);this.bindingEngine=new Tn,this.translationEngine=n,this.translationContext=r,this.defaultContext=e,this.registerDefaultHandlers(),this.setupErrorHandling()}setGlobalHeaders(e){this.globalHeaders=e||[]}setNamedActions(e){this.namedActions=e||{};const n=Xn();n?.isEnabled?.()&&n.setNamedActionDefinitions?.(this.namedActions),N.log("[setNamedActions] registered:",Object.keys(this.namedActions))}getNamedActions(){return this.namedActions}setPreviewMode(e){this.previewMode=e,N.log("Preview mode:",e?"enabled":"disabled")}isPreviewMode(){return this.previewMode}static getPreviewSuppressedHandlers(){return Vm}static getPreviewSuppressedLayoutFeatures(){return JC}resolveActionRef(e){if(!e.actionRef)return e;const n=this.namedActions[e.actionRef];if(!n)return N.warn(`[resolveActionRef] named action not found: "${e.actionRef}"`),e;const r=Xn();r?.isEnabled?.()&&r.trackNamedActionRef?.({actionRefName:e.actionRef,resolvedHandler:n.handler,timestamp:Date.now()});const{actionRef:i,type:l,key:c,event:d,...f}=e,p={...n,...Object.fromEntries(Object.entries(f).filter(([,m])=>m!==void 0)),type:l??n.type};return c!==void 0&&(p.key=c),d!==void 0&&(p.event=d),p}matchesPattern(e,n){if(n==="*")return!0;const r=n.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${r}$`).test(e)}getMatchingGlobalHeaders(e,n){const r={};for(const i of this.globalHeaders)this.matchesPattern(e,i.pattern)&&Object.entries(i.headers).forEach(([l,c])=>{const d=ls(c,n,{skipCache:!0});d!=null&&d!==""&&(r[l]=String(d))});return r}setupErrorHandling(){if(this.errorHandlingSetup)return;Tr().setActionExecutor(async(n,r)=>{const i={type:"click",handler:n.handler,target:n.target,params:n.params,actions:n.actions},l={data:{...this.defaultContext.data,error:r.error}};return await this.dispatchAction(i,l)}),this.errorHandlingSetup=!0}registerDefaultHandlers(){this.registerHandler("refetchDataSource",async(n,r)=>{const i=n.params?.dataSourceId,l=n.params?.sync;if(!i){N.warn("refetchDataSource: dataSourceId is required");return}if(typeof window<"u"&&window.G7Core?.dataSource?.refetch){const c=window.G7Core?.state?.get?.()||{},d={...r.state?._global,...c},f=window.G7Core?.state?.getLocal?.()||{},p=r.data?._local||r.state||{},m={...f,...p},y=r.isolatedContext?.state;N.log("[refetchDataSource] localStateOverride:",m),await window.G7Core.dataSource.refetch(i,{...l?{sync:!0}:{},...d?{globalStateOverride:d}:{},...m?{localStateOverride:m}:{},...y?{isolatedStateOverride:y}:{}})}else N.warn("refetchDataSource: G7Core.dataSource.refetch is not available")}),this.registerHandler("appendDataSource",async(n,r)=>{const{dataSourceId:i,dataPath:l,newData:c}=n.params||{};if(!i){N.warn("appendDataSource: dataSourceId is required");return}if(c===void 0){N.warn("appendDataSource: newData is required");return}if(typeof window<"u"&&window.G7Core?.dataSource?.updateData){if(!Array.isArray(c)){N.warn("appendDataSource: newData must be an array, got:",typeof c,c);return}await window.G7Core.dataSource.updateData(i,l||null,c,"append")}else N.warn("appendDataSource: G7Core.dataSource.updateData is not available")}),this.registerHandler("updateDataSource",async(n,r)=>{const{dataSourceId:i,data:l,merge:c=!1}=n.params||{};if(!i){N.warn("updateDataSource: dataSourceId is required");return}if(l===void 0){N.warn("updateDataSource: data is required");return}typeof window<"u"&&window.G7Core?.dataSource?.set?(N.log(`[updateDataSource] Updating dataSource '${i}' with:`,l),window.G7Core.dataSource.set(i,l,{merge:c})):N.warn("updateDataSource: G7Core.dataSource.set is not available")}),this.registerHandler("scrollIntoView",async(n,r)=>{const{selector:i,behavior:l="smooth",block:c="nearest",inline:d="nearest",waitForElement:f=!1,timeout:p=2e3,delay:m=0,retryCount:y=0,retryInterval:C=50,scrollContainer:S}=n.params||{};if(!i){N.warn("scrollIntoView: selector is required");return}if(typeof window>"u"||typeof document>"u"){N.warn("scrollIntoView: window/document is not available");return}let v=null;if(f){if(v=await new Promise(x=>{const w=document.querySelector(i);if(w){x(w);return}const R=setTimeout(()=>{L.disconnect(),x(null)},p),L=new MutationObserver(()=>{const O=document.querySelector(i);O&&(clearTimeout(R),L.disconnect(),x(O))});L.observe(document.body,{childList:!0,subtree:!0})}),!v){N.warn(`scrollIntoView: element not found for selector "${i}" after ${p}ms timeout`);return}}else{m>0&&await new Promise(w=>setTimeout(w,m)),v=document.querySelector(i);let x=0;for(;!v&&xsetTimeout(w,C)),v=document.querySelector(i),x++;if(!v){N.warn(`scrollIntoView: element not found for selector "${i}" after ${x+1} attempts`);return}}if(S){const x=document.querySelector(S);if(!x){N.warn(`scrollIntoView: container not found for selector "${S}"`);return}const w=v.getBoundingClientRect(),R=x.getBoundingClientRect(),L=w.top-R.top+x.scrollTop,O=L+w.height;let j;switch(c){case"start":j=L;break;case"center":j=L-x.clientHeight/2+w.height/2;break;case"end":j=O-x.clientHeight;break;case"nearest":default:const F=w.topR.bottom;if(F)j=L;else if(G)j=O-x.clientHeight;else return;break}x.scrollTo({top:Math.max(0,j),behavior:l});return}v.scrollIntoView({behavior:l,block:c,inline:d})}),this.registerHandler("reloadExtensions",async(n,r)=>{if(typeof window>"u"){N.warn("reloadExtensions: window is not available");return}const i=window.__templateApp;if(!i){N.warn("reloadExtensions: TemplateApp not initialized");return}if(typeof i.reloadExtensionState=="function")try{await i.reloadExtensionState()}catch(d){throw N.error("reloadExtensions: reloadExtensionState failed",d),d}else N.warn("reloadExtensions: TemplateApp.reloadExtensionState unavailable");const{moduleInfo:l,pluginInfo:c}=n.params||{};if(l)try{await this.executeAction({handler:"reloadModuleHandlers",params:n.params},r)}catch(d){N.error("reloadExtensions: reloadModuleHandlers failed",d)}if(c)try{await this.executeAction({handler:"reloadPluginHandlers",params:n.params},r)}catch(d){N.error("reloadExtensions: reloadPluginHandlers failed",d)}N.log("reloadExtensions: done")}),this.registerHandler("reloadRoutes",async(n,r)=>{if(typeof window>"u"){N.warn("reloadRoutes: window is not available");return}const i=window.__templateApp;if(!i){N.warn("reloadRoutes: TemplateApp not initialized");return}if(typeof i.reloadExtensionState=="function")try{await i.reloadExtensionState(),N.log("reloadRoutes: delegated to reloadExtensionState")}catch(l){throw N.error("reloadRoutes: Failed to reload routes",l),l}else{const l=i.getRouter?.();l&&(await l.loadRoutes(),N.log("reloadRoutes: Routes reloaded (legacy fallback)"))}}),this.registerHandler("refresh",async(n,r)=>{if(typeof window>"u"){N.warn("refresh: window is not available");return}const i=Number(n.params?.delayMs??0);i>0&&await new Promise(l=>setTimeout(l,i)),window.location.reload()}),this.registerHandler("remount",async(n,r)=>{const{componentId:i}=n.params||{};if(!i){N.warn("remount: componentId parameter is required");return}if(!this.globalStateUpdater){N.warn("remount: globalStateUpdater is not set");return}const d=(window.G7Core?.state?.get()||{})._global?._remountKeys||{},f=d[i]||0;this.globalStateUpdater({_remountKeys:{...d,[i]:f+1}}),N.log(`remount: ${i} key incremented to ${f+1}`)}),this.registerHandler("reloadTranslations",async(n,r)=>{if(typeof window>"u"){N.warn("reloadTranslations: window is not available");return}const i=window.__templateApp;if(!i){N.warn("reloadTranslations: TemplateApp not initialized");return}if(typeof i.reloadExtensionState=="function")try{await i.reloadExtensionState(),N.log("reloadTranslations: delegated to reloadExtensionState")}catch(l){throw N.error("reloadTranslations: Failed to reload translations",l),l}}),this.registerHandler("reloadModuleHandlers",async(n,r)=>{if(typeof window>"u"){N.warn("reloadModuleHandlers: window is not available");return}const{moduleInfo:i,action:l}=n.params||{};if(!i){N.warn("reloadModuleHandlers: moduleInfo is required");return}const c=i.data||i;if(!c.identifier){N.warn("reloadModuleHandlers: moduleInfo with identifier is required");return}if(!l||l!=="add"&&l!=="remove"){N.warn('reloadModuleHandlers: action must be "add" or "remove"');return}const d=window.G7Config;if(!d){N.warn("reloadModuleHandlers: G7Config not available");return}const f=c.identifier;try{if(l==="add"){if(c.assets){if(d.moduleAssets=d.moduleAssets||{},d.moduleAssets[f]=c.assets,N.log(`reloadModuleHandlers: Added assets for ${f}`),c.assets.js){const p=c.assets.js,m=`module-${f}`;this.assertAllowedExtensionAssetUrl(p,`module script (${f})`,n),document.getElementById(m)?N.warn(`reloadModuleHandlers: Script ${m} already loaded`):(await Cr(p,{id:m},{label:`module-script:${f}`}),N.log(`reloadModuleHandlers: Script loaded successfully for ${f}`))}if(c.assets.css){const p=c.assets.css,m=`module-css-${f}`;this.assertAllowedExtensionAssetUrl(p,`module stylesheet (${f})`,n),document.getElementById(m)||(await sa(p,{id:m},{label:`module-css:${f}`}),N.log(`reloadModuleHandlers: CSS loaded for ${f}`))}}}else if(l==="remove"){d.moduleAssets&&d.moduleAssets[f]&&(delete d.moduleAssets[f],N.log(`reloadModuleHandlers: Removed assets for ${f}`));const p=`module-${f}`,m=document.getElementById(p);m&&(m.remove(),N.log(`reloadModuleHandlers: Removed script for ${f}`));const y=`module-css-${f}`,C=document.getElementById(y);C&&(C.remove(),N.log(`reloadModuleHandlers: Removed CSS for ${f}`))}}catch(p){throw N.error(`reloadModuleHandlers: Failed to ${l} module assets`,p),p}}),this.registerHandler("reloadPluginHandlers",async(n,r)=>{if(typeof window>"u"){N.warn("reloadPluginHandlers: window is not available");return}const{pluginInfo:i,action:l}=n.params||{};if(!i){N.warn("reloadPluginHandlers: pluginInfo is required");return}const c=i.data||i;if(!c.identifier){N.warn("reloadPluginHandlers: pluginInfo with identifier is required");return}if(!l||l!=="add"&&l!=="remove"){N.warn('reloadPluginHandlers: action must be "add" or "remove"');return}const d=window.G7Config;if(!d){N.warn("reloadPluginHandlers: G7Config not available");return}const f=c.identifier;try{if(l==="add"){if(c.assets){if(d.pluginAssets=d.pluginAssets||{},d.pluginAssets[f]=c.assets,N.log(`reloadPluginHandlers: Added assets for ${f}`),c.assets.js){const p=c.assets.js,m=`plugin-${f}`;this.assertAllowedExtensionAssetUrl(p,`plugin script (${f})`,n),document.getElementById(m)?N.warn(`reloadPluginHandlers: Script ${m} already loaded`):(await Cr(p,{id:m},{label:`plugin-script:${f}`}),N.log(`reloadPluginHandlers: Script loaded successfully for ${f}`))}if(c.assets.css){const p=c.assets.css,m=`plugin-css-${f}`;this.assertAllowedExtensionAssetUrl(p,`plugin stylesheet (${f})`,n),document.getElementById(m)||(await sa(p,{id:m},{label:`plugin-css:${f}`}),N.log(`reloadPluginHandlers: CSS loaded for ${f}`))}}}else if(l==="remove"){d.pluginAssets&&d.pluginAssets[f]&&(delete d.pluginAssets[f],N.log(`reloadPluginHandlers: Removed assets for ${f}`));const p=`plugin-${f}`,m=document.getElementById(p);m&&(m.remove(),N.log(`reloadPluginHandlers: Removed script for ${f}`));const y=`plugin-css-${f}`,C=document.getElementById(y);C&&(C.remove(),N.log(`reloadPluginHandlers: Removed CSS for ${f}`))}}catch(p){throw N.error(`reloadPluginHandlers: Failed to ${l} plugin assets`,p),p}});let e=!1;this.registerHandler("showErrorPage",async(n,r)=>{if(e){N.log("showErrorPage: Already active, skipping duplicate call");return}if(e=!0,typeof window>"u"){e=!1,N.warn("showErrorPage: window is not available");return}const i=window.__templateApp;if(!i){e=!1,N.warn("showErrorPage: TemplateApp not initialized");return}const l=i.getErrorPageHandler?.();if(!l){e=!1,N.warn("showErrorPage: ErrorPageHandler not available");return}const c=n.params?.errorCode||500,d=n.params?.target||"content";let f=n.params?.containerId;f||(f=d==="full"?"app":"main_content"),N.log("showErrorPage:",{errorCode:c,target:d,containerId:f});const p=(m,y=6e4)=>new Promise((C,S)=>{const v=document.getElementById(m);if(v){C(v);return}N.log(`showErrorPage: Waiting for container #${m}...`);let x;const w=new MutationObserver((R,L)=>{const O=document.getElementById(m);O&&(N.log(`showErrorPage: Container #${m} found`),L.disconnect(),clearTimeout(x),C(O))});w.observe(document.body,{childList:!0,subtree:!0}),x=setTimeout(()=>{w.disconnect(),S(new Error(`Container #${m} not found within ${y}ms`))},y)});try{await p(f);const m=Tr(),y=m.layoutErrorHandling;m.clearLayoutConfig();try{await l.renderError(c,f)||N.warn(`showErrorPage: Failed to render error page for code ${c}`)}finally{m.setLayoutConfig(y)}}catch(m){throw N.error("showErrorPage: Error rendering error page:",m),m}finally{e=!1}}),this.registerHandler("emitEvent",async(n,r)=>{const i=n.params?.event,l=n.params?.data;if(!i){N.warn("emitEvent: event parameter is required");return}if(typeof window>"u"){N.warn("emitEvent: window is not available");return}const c=window.G7Core;if(!c?.componentEvent?.emit){N.warn("emitEvent: G7Core.componentEvent is not available");return}try{N.log(`emitEvent: Emitting "${i}"`,l);const d={...l,_context:{data:r.data,state:r.state}},f=await c.componentEvent.emit(i,d);if(!f||f.length===0?N.warn(`emitEvent: No listeners found for "${i}"`):N.log(`emitEvent: Event "${i}" completed with ${f.length} listener(s)`,f),this.globalStateUpdater){const p=(c?.state?.get()||{})._local||{},m={event:i,success:!0,data:f.length===1?f[0]:f,listeners:f.length};this.globalStateUpdater({_local:{...p,_eventResult:m}});const y=r.state&&typeof r.state=="object"&&!Array.isArray(r.state)?r.state:p;window.__g7SequenceLocalSync={...y,_eventResult:m}}}catch(d){if(N.error(`emitEvent: Event "${i}" failed`,d),this.globalStateUpdater){const f=c?.state?.get()||{};this.globalStateUpdater({_local:{...f._local,_eventResult:{event:i,success:!1,error:d instanceof Error?d.message:String(d)}}})}throw d}}),this.registerHandler("updateProductField",async(n,r)=>{const{productId:i,field:l,value:c}=n.params||{};if(!i||!l){N.warn("updateProductField: productId and field are required");return}if(typeof window>"u"){N.warn("updateProductField: window is not available");return}const d=window.G7Core;if(!d?.state?.get||!this.globalStateUpdater){N.warn("updateProductField: G7Core.state or globalStateUpdater is not available");return}try{const f=d.state.get()||{},m=(f.products?.data?.data||[]).map(C=>C.id===i?{...C,[l]:c,_modified:!0}:C),y=new Set(f._local?.modifiedProductIds||[]);y.add(i),this.globalStateUpdater({products:{...f.products,data:{...f.products?.data,data:m}},_local:{...f._local,modifiedProductIds:Array.from(y)}}),N.log(`updateProductField: Updated product ${i}, field: ${l}, value:`,c)}catch(f){throw N.error("updateProductField: Error updating product field",f),f}}),this.registerHandler("updateOptionField",async(n,r)=>{const{productId:i,optionId:l,field:c,value:d}=n.params||{};if(!i||!l||!c){N.warn("updateOptionField: productId, optionId and field are required");return}if(typeof window>"u"){N.warn("updateOptionField: window is not available");return}const f=window.G7Core;if(!f?.state?.get||!this.globalStateUpdater){N.warn("updateOptionField: G7Core.state or globalStateUpdater is not available");return}try{const p=f.state.get()||{},y=(p.products?.data?.data||[]).map(S=>{if(S.id===i&&S.options){const v=S.options.map(x=>x.id===l?{...x,[c]:d,_modified:!0}:x);return{...S,options:v,_modified:!0}}return S}),C=new Set(p._local?.modifiedProductIds||[]);C.add(i),this.globalStateUpdater({products:{...p.products,data:{...p.products?.data,data:y}},_local:{...p._local,modifiedProductIds:Array.from(C)}}),N.log(`updateOptionField: Updated product ${i} option ${l}, field: ${c}, value:`,d)}catch(p){throw N.error("updateOptionField: Error updating option field",p),p}}),this.registerHandler("setLocale",async(n,r)=>{const i=n.target;if(!i||typeof i!="string"){N.warn("setLocale: Invalid locale:",i);return}const l=window.__templateApp;if(l&&typeof l.changeLocale=="function")try{await l.changeLocale(i),N.log("setLocale: Locale changed to",i)}catch(c){N.error("setLocale: Failed to change locale:",c),window.location.reload()}else{N.warn("setLocale: TemplateApp not found, falling back to page reload");try{localStorage.setItem("g7_locale",i)}catch{}window.location.reload()}}),this.registerHandler("suppress",async()=>{N.log("suppress: Error intentionally suppressed")}),this.registerBuiltInHandlerMetadata()}registerBuiltInHandlerMetadata(){const e=Xn();if(!e?.isEnabled())return;const n=[{name:"refetchDataSource",description:"데이터 소스를 다시 fetch합니다"},{name:"appendDataSource",description:"데이터 소스에 새 데이터를 병합합니다 (무한 스크롤용)"},{name:"updateDataSource",description:"API 응답으로 데이터 소스를 직접 업데이트합니다 (refetch 대체)"},{name:"reloadRoutes",description:"라우트를 다시 로드합니다"},{name:"refresh",description:"현재 페이지를 새로고침합니다"},{name:"remount",description:"컴포넌트를 리마운트합니다"},{name:"reloadTranslations",description:"다국어 파일을 다시 로드합니다"},{name:"showErrorPage",description:"에러 페이지를 표시합니다"},{name:"emitEvent",description:"이벤트를 발생시킵니다"},{name:"updateProductField",description:"상품 필드를 인라인 수정합니다"},{name:"updateOptionField",description:"상품 옵션 필드를 인라인 수정합니다"},{name:"setLocale",description:"언어를 변경합니다 (DB 저장 + UI 리렌더링)"}];for(const r of n)e.trackHandlerRegistration(r.name,"built-in",r.description)}createHandler(e,n,r){N.log("createHandler called for:",e.handler,e.type);const i=window.__g7DevTools,l=Date.now(),c=r?.state?{...r.state}:null,d=`handler_${e.handler}_${l}`;return async f=>{if(N.log("Handler invoked for:",e.handler,"event:",f.type),i?.isEnabled?.()&&c){const m=window.G7Core?.state?.getLocal?.()??r?.state??{},y=Date.now()-l;for(const C of Object.keys(c)){const S=c[C],v=m[C];S!==v&&y>100&&(i.trackStaleClosureWarning?.({type:"event-handler-stale",location:`createHandler(${e.handler})`,capturedPath:`_local.${C}`,capturedValue:S,capturedAt:l,currentValue:v,actionId:d,stackTrace:new Error().stack}),N.warn(`[Stale Closure] _local.${C} changed after handler creation:`,`captured="${S}" → current="${v}" (${y}ms ago)`))}}try{f.type!=="change"&&f.preventDefault();let p={};if(f.type==="submit"&&f.target instanceof HTMLFormElement){const C=f.target;new FormData(C).forEach((v,x)=>{p[x]=v})}const m={...this.defaultContext,data:{...n,form:p,_local:r?.state||{},$event:f},event:f,...r&&{state:r.state,setState:r.setState},isolatedContext:r?.isolatedContext};if(e.confirm){let C=this.resolveValue(e.confirm,m.data);if(this.translationEngine&&this.translationContext&&C.startsWith("$t:")&&(C=this.translationEngine.resolveTranslations(C,this.translationContext,m.data)),!confirm(C))return}const y=window.__g7ActionContext;window.__g7ActionContext={...r,data:m.data};try{await this.executeAction(e,m)}finally{window.__g7ActionContext=y}}catch(p){if(N.error("Action execution failed:",p),e.onError){const m=p instanceof Tt&&p.originalError?p.originalError:p,y={...this.defaultContext,data:{...n,error:m,_local:r?.state||{},$event:f},event:f,...r&&{state:r.state,setState:r.setState}},C=Array.isArray(e.onError)?e.onError:[e.onError];for(const S of C)await this.executeAction(S,y)}}}}generateActionId(e,n){const r=e.handler,i=n||"no-target",l=Date.now(),c=Math.random().toString(36).substring(2,9);return`${r}_${i.replace(/[^a-zA-Z0-9]/g,"_")}_${l}_${c}`}async executeAction(e,n){if(e=this.resolveActionRef(e),typeof e.handler=="string"&&e.handler.includes("{{")){const f=this.evaluateExpression(e.handler,n.data);e={...e,handler:f==null?"":String(f)}}const r=Xn(),i=r?.isEnabled()?`action_${Date.now()}_${Math.random().toString(36).substring(2,11)}`:void 0,l=performance.now();let c;if(i&&r&&r.logAction({id:i,type:e.handler,params:this.sanitizeForDevTools(e.params),context:this.sanitizeForDevTools({hasState:!!n.state,hasSetState:!!n.setState,dataKeys:n.data?Object.keys(n.data):[]}),startTime:l,status:"started"}),e.if!==void 0)try{const f=this.resolveValue(e.if,n.data),p=f===!0||f==="true"||f&&f!=="false"&&f!=="0"&&f!==!1;if(N.log("[executeAction] if condition result:",e.handler,p),!p)return i&&r&&r.logAction({id:i,type:e.handler,startTime:l,endTime:performance.now(),duration:performance.now()-l,status:"success",result:{skipped:!0,reason:"if condition false"}}),{success:!0,data:void 0}}catch(f){return N.error("[executeAction] if condition error:",e.handler,f),i&&r&&r.logAction({id:i,type:e.handler,startTime:l,endTime:performance.now(),duration:performance.now()-l,status:"error",error:{name:"ConditionEvaluationError",message:f instanceof Error?f.message:String(f),stack:f instanceof Error?f.stack:void 0}}),{success:!0,data:void 0}}let d;try{const f=this.resolveParams(e.params,n.data);i&&(c=this.sanitizeForDevTools(f));const p=e.target?this.resolveValue(e.target,n.data):void 0;if(e.handler==="apiCall"&&n.setState){d=this.generateActionId(e,p);const y=n.state?.loadingActions||{};n.setState({loadingActions:{...y,[d]:!0}})}if(this.previewMode&&Vm.has(e.handler))return N.warn(`Preview mode: "${e.handler}" suppressed`,p||f),i&&r&&r.logAction({id:i,type:e.handler,startTime:l,endTime:performance.now(),duration:performance.now()-l,status:"skipped",metadata:{reason:"preview_mode_suppressed"}}),{success:!0,data:void 0};let m;switch(e.handler){case"ensureIdentityVerified":m=await this.handleEnsureIdentityVerified(f);break;case"resolveIdentityChallenge":m=this.handleResolveIdentityChallenge(f);break;case"navigate":const y=f.path||p;m=await this.handleNavigate(y,f,n);break;case"navigateBack":m=await this.handleNavigateBack();break;case"navigateForward":m=await this.handleNavigateForward();break;case"openWindow":{const v=f.path||p;m=await this.handleOpenWindow(v,f);break}case"replaceUrl":{const v=f.path||p||window.location.pathname;m=await this.handleReplaceUrl(v,f);break}case"apiCall":if(e.onSuccess&&r?.isEnabled()&&i){const v=window.G7Core,x={};if(v?.state?.get){const w=v.state.get();x._global=w}n.state&&(x._local=n.state),r.registerStateCaptureForHandler?.(i,["_global","_local"],x)}const C=e.auth_mode??(e.auth_required?"required":"none"),S=e.identity_target?this.resolveParams(e.identity_target,n.data):void 0;m=await this.handleApiCall(p,f,n,C,S);break;case"login":m=await this.handleLogin(p,f,n);break;case"loginTwoFactor":m=await this.handleLoginTwoFactor(p,f,n);break;case"loginTwoFactorResend":m=await this.handleLoginTwoFactorResend(p,f,n);break;case"logout":m=await this.handleLogout(p,n);break;case"setState":N.log("[executeAction] setState resolvedParams:",f),m=await this.handleSetState(e.render!==void 0?{...f,__render:e.render}:f,n);break;case"setError":m=await this.handleSetError(p,f,n);break;case"openModal":m=await this.handleOpenModal(p,n);break;case"closeModal":m=await this.handleCloseModal(n);break;case"showAlert":m=await this.handleShowAlert(p,n);break;case"toast":m=await this.handleToast(f,n);break;case"switch":m=await this.handleSwitch(e,n);break;case"conditions":m=await this.handleConditions(e,n);break;case"sequence":m=await this.handleSequence(e,n);break;case"parallel":m=await this.handleParallel(e,n);break;case"startInterval":m=this.handleStartInterval(f,n);break;case"stopInterval":m=this.handleStopInterval(f);break;case"loadScript":m=await this.handleLoadScript(f,e,n);break;case"callExternal":m=await this.handleCallExternal(f,e,n);break;case"callExternalEmbed":m=await this.handleCallExternalEmbed(f,e,n);break;case"saveToLocalStorage":m=await this.handleSaveToLocalStorage(f,n);break;case"loadFromLocalStorage":m=await this.handleLoadFromLocalStorage(f,n);break;default:m=await this.handleCustomAction({...e,target:p,params:f},n);break}if(e.resultTo&&m!==void 0){const{target:y,key:C,merge:S}=e.resultTo,v=this.resolveValue(C,n.data),x=S==="replace"?"replace":S==="shallow"?"shallow":"deep";if(y==="_local"&&n.setState){const w=this.buildNestedUpdate(v,m),R=x!=="deep"?{...w,__mergeMode:x}:w;this.writeLocalState(n,R),N.log(`[resultTo] Saved to _local.${v} (merge=${x}):`,m)}else if(y==="_local"&&this.globalStateUpdater){const L=(window.G7Core?.state?.get()||{})._local||{},O=this.buildNestedUpdate(v,m);let j;x==="replace"?j=O:x==="shallow"?j={...L,...O}:j=this.deepMergeWithState(O,L),this.globalStateUpdater({_local:j}),N.log(`[resultTo] Saved to _local.${v} via globalStateUpdater (merge=${x}):`,m)}else if(y==="_global"&&this.globalStateUpdater){const w=this.buildNestedUpdate(v,m);this.globalStateUpdater(w),N.log(`[resultTo] Saved to _global.${v}:`,m)}else if(y==="_isolated"&&n.isolatedContext){const w=this.buildNestedUpdate(v,m);n.isolatedContext.mergeState(w,x),N.log(`[resultTo] Saved to _isolated.${v} (merge=${x}):`,m)}else N.warn(`[resultTo] Cannot save result: target=${y}, setState=${!!n.setState}, globalStateUpdater=${!!this.globalStateUpdater}, isolatedContext=${!!n.isolatedContext}`)}if(e.onSuccess){if(r?.isEnabled()&&i&&e.handler==="apiCall"){const S=window.G7Core,v={};S?.state?.get&&(v._global=S.state.get()),n.state&&(v._local=n.state),r.detectStaleClosure?.(i,`${e.handler} → onSuccess`,v,"callback-state-capture",i)}const y={...n,data:{...n.data,result:m,response:m}},C=Array.isArray(e.onSuccess)?e.onSuccess:[e.onSuccess];C.length>1?await this.handleSequence({handler:"sequence",type:"click",actions:C},y):C.length===1&&await this.executeAction(C[0],y)}return i&&r&&r.logAction({id:i,type:e.handler,params:this.sanitizeForDevTools(e.params),resolvedParams:c,startTime:l,endTime:performance.now(),duration:performance.now()-l,status:"success",result:this.sanitizeForDevTools(m)}),{success:!0,data:m}}catch(f){const p=f instanceof Tt?f:new Tt(`Failed to execute action: ${e.handler}`,e,f instanceof Error?f:void 0),m=p.originalError?.response||{},y=m.data||{},C=p.originalError?.status||m.status||500;let S=XC(p.originalError??f,e.handler,y.message,p.message);this.translationEngine&&this.translationContext&&S.startsWith("$t:")&&(S=this.translationEngine.resolveTranslations(S,this.translationContext));const v={status:C,message:S,errors:y.errors||m.errors,data:y,statusText:p.originalError?.statusText,error_code:y.error_code??m.error_code};if(p.unknownHandler)throw N.warn(`Unknown action handler "${e.handler}" — skipped (extension not loaded?). Not surfaced to the user.`),p;const w=Tr().resolve(C,{errorHandling:e.errorHandling,onError:e.onError});if(w.handler){if(r?.isEnabled()&&i&&e.handler==="apiCall"){const L=window.G7Core,O={};L?.state?.get&&(O._global=L.state.get()),n.state&&(O._local=n.state),r.detectStaleClosure?.(i,`${e.handler} → onError`,O,"callback-state-capture",i)}const R={...n,data:{...n.data,error:v}};try{const L={type:"click",handler:w.handler.handler,target:w.handler.target,params:w.handler.params,actions:w.handler.actions};return await this.executeAction(L,R),{success:!1,error:p}}catch(L){return N.error("Error executing error handler:",L),{success:!1,error:p}}}throw i&&r&&r.logAction({id:i,type:e.handler,params:this.sanitizeForDevTools(e.params),resolvedParams:c,startTime:l,endTime:performance.now(),duration:performance.now()-l,status:"error",error:{name:p.name,message:p.message,stack:p.stack}}),p}finally{if(e.handler==="apiCall"&&n.setState&&d){const f=n.state?.loadingActions||{},{[d]:p,...m}=f;n.setState({loadingActions:m})}}}async handleNavigate(e,n,r){let i=e;if(n.query||n.mergeQuery===!0)if(n.mergeQuery===!0)i=this.buildMergedQueryPath(e,n.query??{});else{const c=new URLSearchParams;for(const[f,p]of Object.entries(n.query))if(p!=null&&p!=="")if(Array.isArray(p)){const m=f.endsWith("[]")?f:`${f}[]`;for(const y of p)y!=null&&y!==""&&c.append(m,String(y))}else c.set(f,String(p));const d=c.toString();d&&(i=`${e}?${d}`)}if(N.log("handleNavigate:",{target:e,params:n,finalPath:i,replace:n.replace,windowLocationSearch:window.location.search}),n.replace===!0){const c=window.G7Core;if(c?.updateQueryParams){const d=typeof n.transition_overlay_target=="string"?n.transition_overlay_target:void 0;await c.updateQueryParams(i,d?{transitionOverlayTarget:d}:void 0),N.log("handleNavigate: Used updateQueryParams for replace mode",d?{transitionOverlayTarget:d}:void 0),this.applyScrollOption(n.scroll,n.scrollBehavior,"top");return}N.warn("handleNavigate: G7Core.updateQueryParams not available, falling back to React Router")}const l=this.resolveNavigateFallbackAction(i,n);if(l){N.warn(`handleNavigate: No route matched, falling back to "${l.handler}"`),await this.dispatchAction({type:"click",handler:l.handler,params:l.params},r),this.applyScrollOption(n.scroll,n.scrollBehavior,"top");return}if(!r.navigate)throw new Tt("Navigate function is not provided in context");r.navigate(i,{replace:n.replace===!0}),this.applyScrollOption(n.scroll,n.scrollBehavior,"top")}resolveNavigateFallbackAction(e,n){const r=n.fallback;if(r===!1||n.replace===!0)return null;const l=window.__templateApp?.getRouter?.();if(!l||typeof l.match!="function"||typeof l.getRoutes=="function"&&l.getRoutes().length===0)return null;const c=e.split("?")[0];return l.match(c)?null:this.resolveNavigateFallback(r,e,n)}resolveNavigateFallback(e,n,r){return e==null?{handler:"openWindow",params:{path:n,target:"_self"}}:typeof e=="string"?{handler:e,params:{path:n}}:typeof e=="object"&&typeof e.handler=="string"?{handler:e.handler,params:{path:n,...e.params||{}}}:(N.warn("resolveNavigateFallback: unrecognized fallback option, using openWindow",e),{handler:"openWindow",params:{path:n,target:"_blank"}})}applyScrollOption(e,n,r){const i=e===void 0?r:e;if(i==="preserve")return;const l=n==="smooth"?"smooth":"instant",c=y=>{if(typeof y!="object"||y===null)return!1;const C=y;return"container"in C||"to"in C||"block"in C||"offset"in C},d=(y,C,S=0)=>{y===window?window.scrollTo({top:C,left:S,behavior:l}):y.scrollTo({top:C,left:S,behavior:l})},f=(y,C,S,v)=>{if(C===window){y.scrollIntoView({behavior:l,block:S}),v&&window.scrollBy({top:-v,left:0,behavior:l});return}const x=C,w=y.getBoundingClientRect(),R=x.getBoundingClientRect(),L=x.scrollTop+(w.top-R.top);let O;S==="center"?O=L-(x.clientHeight-y.clientHeight)/2:S==="end"?O=L-(x.clientHeight-y.clientHeight):O=L,O-=v,x.scrollTo({top:Math.max(0,O),left:0,behavior:l})},p=()=>{window.scrollTo({top:0,left:0,behavior:l});const y=document.getElementById("app")??document.body;if(!y)return;y.querySelectorAll("*").forEach(S=>{if(S.scrollTop===0&&S.scrollLeft===0)return;const v=window.getComputedStyle(S),x=v.overflowY,w=v.overflowX;(x==="auto"||x==="scroll"||w==="auto"||w==="scroll")&&S.scrollTo({top:0,left:0,behavior:l})})},m=()=>{try{if(c(i)){const y=i,C=y.block??"start",S=typeof y.offset=="number"?y.offset:0;let v=window;if(typeof y.container=="string"&&y.container.length>0){const w=document.querySelector(y.container);if(!w){N.warn(`applyScrollOption: container not found: ${y.container}`);return}v=w}const x=y.to??"top";if(x==="top"){v===window?p():d(v,0);return}if(typeof x=="number"){d(v,x-S);return}if(typeof x=="object"&&x!==null&&("x"in x||"y"in x)){const{x:w=0,y:R=0}=x;d(v,R-S,w);return}if(typeof x=="string"&&(x.startsWith("#")||x.startsWith("."))){const w=document.querySelector(x);w?f(w,v,C,S):N.warn(`applyScrollOption: target element not found: ${x}`);return}N.warn('applyScrollOption: invalid "to" value in extended form',x);return}if(i==="top"){p();return}if(typeof i=="number"){window.scrollTo({top:i,left:0,behavior:l});return}if(typeof i=="object"&&i!==null&&("x"in i||"y"in i)){const{x:y=0,y:C=0}=i;window.scrollTo({top:C,left:y,behavior:l});return}if(typeof i=="string"&&(i.startsWith("#")||i.startsWith("."))){const y=document.querySelector(i);y&&y.scrollIntoView({behavior:l,block:"start"});return}}catch(y){N.warn("applyScrollOption: failed to apply scroll",y)}};typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(m):m()}async handleOpenWindow(e,n){let r=e;if(n.query){const l=new URLSearchParams;for(const[d,f]of Object.entries(n.query))f!=null&&f!==""&&l.set(d,String(f));const c=l.toString();c&&(r=`${e}?${c}`)}const i=n.target==="_self"?"_self":"_blank";N.log("handleOpenWindow:",{target:e,params:n,finalPath:r,windowTarget:i}),i==="_self"?window.location.assign(r):window.open(r,"_blank")}async handleNavigateBack(){N.log("handleNavigateBack"),window.history.back()}async handleNavigateForward(){N.log("handleNavigateForward"),window.history.forward()}async handleReplaceUrl(e,n){let r=e;if(n.query||n.mergeQuery===!0)if(n.mergeQuery===!0)r=this.buildMergedQueryPath(e,n.query??{});else{const i=new URLSearchParams;for(const[c,d]of Object.entries(n.query))if(d!=null&&d!=="")if(Array.isArray(d)){const f=c.endsWith("[]")?c:`${c}[]`;for(const p of d)p!=null&&p!==""&&i.append(f,String(p))}else i.set(c,String(d));const l=i.toString();l&&(r=`${e}?${l}`)}N.log("handleReplaceUrl:",{target:e,params:n,finalPath:r}),window.history.replaceState(null,"",r),this.applyScrollOption(n.scroll,n.scrollBehavior,"preserve")}buildMergedQueryPath(e,n){const r=new URLSearchParams(window.location.search);for(const[c,d]of Object.entries(n))if(d==null||d==="")r.delete(c);else if(Array.isArray(d)){const f=c.endsWith("[]")?c:`${c}[]`;r.delete(c),r.delete(f);for(const p of d)p!=null&&p!==""&&r.append(f,String(p))}else r.set(c,String(d));const i=r.toString(),l=e.split("?")[0];return i?`${l}?${i}`:l}async ensureCsrfToken(){try{await fetch("/sanctum/csrf-cookie",{credentials:"include"})}catch(e){throw new Tt("Failed to fetch CSRF token",void 0,e instanceof Error?e:void 0)}}getCsrfTokenFromCookie(){const r=`; ${document.cookie}`.split("; XSRF-TOKEN=");if(r.length===2){const i=r.pop()?.split(";").shift();return i?decodeURIComponent(i):null}return null}buildQueryString(e){const n=new URLSearchParams;for(const[r,i]of Object.entries(e))if(!(i==null||i===""))if(Array.isArray(i))for(const l of i)l!=null&&l!==""&&n.append(`${r}[]`,String(l));else typeof i=="object"?n.append(r,JSON.stringify(i)):n.append(r,String(i));return n.toString()}async handleEnsureIdentityVerified(e){const n=typeof e.purpose=="string"?e.purpose:"sensitive_action",r=e.target&&typeof e.target=="object"?e.target:void 0;return await yt.handle({success:!1,error_code:"identity_verification_required",message:"",verification:{policy_key:e.policy_key??"",purpose:n,provider_id:e.provider_id??null,render_hint:e.render_hint??null,return_request:null}},void 0,r)!==null}handleResolveIdentityChallenge(e){const n=typeof e.result=="string"?e.result:"cancelled";let r;switch(n){case"verified":{const i=typeof e.token=="string"?e.token:"";if(!i){N.warn("resolveIdentityChallenge: result=verified 인데 token 이 비어있습니다. failed 로 강등합니다."),r={status:"failed",failureCode:"MISSING_TOKEN"};break}r={status:"verified",token:i,providerData:e.providerData&&typeof e.providerData=="object"?e.providerData:void 0};break}case"pending":{const i=typeof e.pollUrl=="string"?e.pollUrl:"",l=typeof e.expiresAt=="string"?e.expiresAt:"";if(!i||!l){N.warn("resolveIdentityChallenge: result=pending 인데 pollUrl/expiresAt 누락 — failed 로 강등합니다."),r={status:"failed",failureCode:"MALFORMED_PENDING"};break}r={status:"pending",pollUrl:i,pollIntervalMs:typeof e.pollIntervalMs=="number"?e.pollIntervalMs:void 0,expiresAt:l};break}case"failed":r={status:"failed",failureCode:typeof e.failureCode=="string"?e.failureCode:"UNKNOWN",reason:typeof e.reason=="string"?e.reason:void 0};break;case"cancelled":default:r={status:"cancelled"};break}return yt.resolveDeferred(r),!0}async handleApiCall(e,n,r,i="none",l){const{method:c="GET",body:d,headers:f,contentType:p}=n;c!=="GET"&&c!=="HEAD"&&await this.ensureCsrfToken();const m=this.getCsrfTokenFromCookie();let y={};if(i==="required"||i==="optional"){const K=Wn().getToken();K&&(y={Authorization:`Bearer ${K}`})}let C=e;const S=n.query||(c==="GET"?d:null);if(S&&typeof S=="object"){const P=this.buildQueryString(S);if(P){const K=e.includes("?")?"&":"?";C=`${e}${K}${P}`}}const v=window.G7Core?.state?.getGlobal?.()||r.state?._global||{},x=window.G7Core?.state?.getLocal?.()||r.state?._local||{},w={_global:v,_local:x},R=this.getMatchingGlobalHeaders(e,w),L={};if(typeof window<"u"){const P=localStorage.getItem("g7_locale");P&&(L["Accept-Language"]=P)}const O=p==="multipart/form-data",j={method:c,headers:{...O?{}:{"Content-Type":"application/json"},Accept:"application/json",...L,...m&&{"X-XSRF-TOKEN":m},...y,...R,...f},credentials:"include"};if(d&&c!=="GET")if(O){const P=new FormData;for(const[K,he]of Object.entries(d))he instanceof File||he instanceof Blob?P.append(K,he):he!=null&&P.append(K,typeof he=="object"?JSON.stringify(he):String(he));j.body=P}else j.body=JSON.stringify(d);const F=Xn();let G=null;F?.isEnabled()&&(G=F.trackRequest(C,c));try{let P=await fetch(C,j),K;try{K=await P.json()}catch{K=null}if(yt.isIdentityRequired(P.status,K)){const he=await yt.handle(K,{body:j.body,headers:j.headers,credentials:j.credentials},l);if(he){P=he;try{K=await P.json()}catch{K=null}}}if(G&&F?.isEnabled()&&(F.completeRequest(G,P.status,K),G=null),!P.ok){const he=K||{},Ee=new Error(he.message||`API call failed: ${P.statusText}`);throw Ee.response=he,Ee.status=P.status,Ee.statusText=P.statusText,new Tt(he.message||`API call failed: ${P.statusText}`,void 0,Ee)}return K}catch(P){throw G&&F?.isEnabled()&&F.failRequest(G,P instanceof Error?P.message:String(P)),P}}async handleLogin(e,n,r){const{body:i}=n;if(!i||!i.email||!i.password)throw new Tt("Login requires email and password in body params");const l=this.resolveAuthType(e),c=l==="admin"?"/api/auth/admin/login":"/api/auth/login",d=Yn.getInstance();try{const f=await d.login(l,{email:i.email,password:i.password},this.buildAuthRequestOptions(c,r));return f.status==="two_factor_required"?{user:null,two_factor_required:!0,challenge_id:f.challenge.challengeId,provider_id:f.challenge.providerId,expires_at:f.challenge.expiresAt}:{user:f.user,two_factor_required:!1}}catch(f){throw this.toLoginActionError(f,"Login failed")}}async handleLoginTwoFactor(e,n,r){const{body:i}=n;if(!i||!i.challenge_id||!i.code)throw new Tt("loginTwoFactor requires challenge_id and code in body params");const l=this.resolveAuthType(e),c=l==="admin"?"/api/auth/admin/login/two-factor":"/api/auth/login/two-factor";try{return{user:await Yn.getInstance().completeTwoFactor(l,{challengeId:String(i.challenge_id),code:String(i.code)},this.buildAuthRequestOptions(c,r))}}catch(d){throw this.toLoginActionError(d,"Login failed")}}async handleLoginTwoFactorResend(e,n,r){const{body:i}=n;if(!i||!i.challenge_id)throw new Tt("loginTwoFactorResend requires challenge_id in body params");const l=this.resolveAuthType(e),c=l==="admin"?"/api/auth/admin/login/two-factor/resend":"/api/auth/login/two-factor/resend";try{const d=await Yn.getInstance().resendTwoFactor(l,{challengeId:String(i.challenge_id)},this.buildAuthRequestOptions(c,r));return{two_factor_required:!0,challenge_id:d.challengeId,provider_id:d.providerId,expires_at:d.expiresAt}}catch(d){throw this.toLoginActionError(d,"Resend failed")}}resolveAuthType(e){return e==="user"?"user":"admin"}buildAuthRequestOptions(e,n){const r=window.G7Core?.state?.getGlobal?.()||n.state?._global||{},i=window.G7Core?.state?.getLocal?.()||n.state?._local||{},l={_global:r,_local:i},c=this.getMatchingGlobalHeaders(e,l);return Object.keys(c).length>0?{headers:c}:void 0}toLoginActionError(e,n){const r=e?.message||n,i=new Error(r);return i.response=e?.response?.data||{},i.status=e?.status||e?.response?.status||500,i.code=e?.code,new Tt(r,void 0,i)}async handleLogout(e,n){await Yn.getInstance().logout()}async handleSetState(e,n){N.log("[handleSetState] START, params:",e);const{target:r="component",scope:i,merge:l,__render:c,...d}=e,f=Xn(),p=window.G7Core;if(typeof r=="string"&&(r.startsWith("$parent.")||r.startsWith("$root.")))return this.handleParentScopeSetState(r,d,l,n);const m=n.state&&Object.keys(n.state).length>0?n.state:p?.state?.get()||{},y=r==="global"?"_global":r.startsWith("_local.")?r:"_local",C=y==="_global"?m._global:y.startsWith("_local.")?this.getNestedProperty(m._local||{},y.slice(7)):m._local,S=f?.isEnabled()?f.startStateChange(y,C,d,{actionId:n.actionId,handlerType:"setState",source:`target=${r}`}):void 0,v=l==="replace"?"replace":l==="shallow"?"shallow":"deep",x=v!=="deep"?{...d,__mergeMode:v,...S?{__setStateId:S}:{}}:{...d,...S?{__setStateId:S}:{}};if(r==="global"){if(!this.globalStateUpdater){N.warn("Global state updater is not set"),S&&f&&f.completeStateChange(S);return}const w=p?.state?.get()||{},{__setStateId:R,__mergeMode:L,...O}=x,j=v==="deep"?this.deepMergeWithState(O,w):O,F={...j,...S?{__setStateId:S}:{},...v!=="deep"?{__mergeMode:v}:{}};return N.log("setState global:",F),this.globalStateUpdater(F,{render:c}),S&&f&&setTimeout(()=>f.completeStateChange(S),0),{__target:"global",...v!=="deep"?{__mergeMode:v}:{},...j}}else if(r==="isolated"){const w=n.isolatedContext;if(w){const{__mergeMode:R,__setStateId:L,...O}=x;return w.mergeState(O,v),N.log("[handleSetState] isolated state updated:",O,"mergeMode:",v),S&&f&&setTimeout(()=>f.completeStateChange(S),0),{__target:"isolated",...O}}else if(N.warn('[handleSetState] isolated target used but no IsolatedStateContext found. Make sure the component has "isolatedState" attribute. Falling back to local state.'),n.setState){const L=window.__g7PendingLocalState||n.state||{},O=v==="deep"?this.deepMergeWithState(x,L):x;return this.writeLocalState(n,O),S&&f&&setTimeout(()=>f.completeStateChange(S),0),O}else throw S&&f&&f.completeStateChange(S),new Tt("isolated target used but no IsolatedStateContext found and no setState function in context")}else if(r==="local"||r==="component"||r==="_local"){if(i==="parent"||i==="root"){const R=window.__g7LayoutContextStack||[];if(R.length>0){const L=i==="parent"?R[R.length-1]:R[0];if(L?.setState){const{__mergeMode:O,__setStateId:j,...F}=x,G=v==="deep"?this.deepMergeWithState(F,L.state||{}):F;return N.log(`[handleSetState] scope=${i}: 타겟 컨텍스트에 상태 업데이트`,G),L.setState(G),S&&f&&setTimeout(()=>f.completeStateChange(S),0),G}}N.warn(`[handleSetState] scope=${i}: 레이아웃 컨텍스트 스택이 비어있습니다. current로 폴백합니다.`)}const w=n.setState&&!n._isDispatchFallbackContext;if(N.log("[handleSetState] isRealComponentContext:",w,"context.setState:",!!n.setState,"_isDispatchFallbackContext:",n._isDispatchFallbackContext),w){N.log("[handleSetState] Using COMPONENT setState path"),N.log("[handleSetState] resolvedPayload:",x),N.log("[handleSetState] context.state:",n.state),N.log("[handleSetState] mergeMode:",v);const L=window.__g7PendingLocalState||n.state||{},O=v==="deep"?this.deepMergeWithState(x,{}):x;N.log("[handleSetState] convertedPayload (변경 필드만, dot notation 변환):",O),n.setState(O);const j=v==="deep"?this.deepMergeWithState(x,L):v==="shallow"?{...n.state||{},...x}:x,{__mergeMode:F,__setStateId:G,...P}=j;window.__g7PendingLocalState=P,N.log("[handleSetState] __g7PendingLocalState updated:",P);const K=(window.__g7LayoutContextStack||[]).length;let he;if(this.globalStateUpdater){const je=K===0?window.__templateApp?.getGlobalState?.()?._local:void 0;if(v!=="replace"&&!!je&&typeof je=="object"&&!Array.isArray(je)){const de=v==="deep"?this.deepMergeWithState(x,je):{...je,...x},{__mergeMode:Ce,__setStateId:Z,...ge}=de;he=ge}else v!=="replace"&&N.log("[handleSetState] canonical _local 미사용 → 전체 스냅샷 폴백",{modalDepth:K,hasTemplateApp:!!window.__templateApp});const X=he?Ro(he,P):P;this.globalStateUpdater({_local:X},{render:!1}),N.log("[handleSetState] _global._local synced (render:false):",X)}const{__mergeMode:Ee,__setStateId:ke,...ze}=x;if(v==="replace")window.__g7ForcedLocalFields=ze;else{const je=window.__g7ForcedLocalFields||{};window.__g7ForcedLocalFields=this.deepMergeWithState(ze,je)}return N.log("[handleSetState] __g7ForcedLocalFields updated:",ze),S&&f&&setTimeout(()=>f.completeStateChange(S),0),{__target:"local",...he?Ro(he,P):j,...v!=="deep"?{__mergeMode:v}:{}}}else if(this.globalStateUpdater){N.log("[handleSetState] Using GLOBAL STATE UPDATER path for _local");const L=window.__g7PendingLocalState||m._local||{};N.log("[handleSetState] currentLocal (with pending):",L);const O=v==="deep"?this.deepMergeWithState(x,L):x;return N.log("[handleSetState] finalLocal (merged):",O),this.globalStateUpdater({_local:O},{render:c}),window.__g7PendingLocalState=O,N.log("[handleSetState] __g7PendingLocalState updated for globalStateUpdater path"),S&&f&&setTimeout(()=>f.completeStateChange(S),0),{__target:"local",...O}}else throw S&&f&&f.completeStateChange(S),new Tt("setState function is not provided in context and globalStateUpdater is not set")}else if(r.startsWith("_local.")){const w=r.slice(7),{__mergeMode:R,__setStateId:L,...O}=x,j=O.value!==void 0?O.value:Object.values(O)[0];if(n.setState){const G=window.__g7PendingLocalState||n.state||{},P=this.createNestedUpdate(w,j,G),K={...G,...P};if(n.setState(P),this.globalStateUpdater&&i!=="parent"&&i!=="root"){const he=window.__templateApp?.getGlobalState?.()?._local,Ee=he&&typeof he=="object"?{...he,...P}:K;this.globalStateUpdater({_local:Ee},{render:!1}),N.log("[handleSetState] _global._local synced for dot notation (render:false):",Ee)}return S&&f&&setTimeout(()=>f.completeStateChange(S),0),K}else throw S&&f&&f.completeStateChange(S),new Tt("setState function is not provided in context")}else{if(!n.setState)throw S&&f&&f.completeStateChange(S),new Tt("setState function is not provided in context");const R=window.__g7PendingLocalState||n.state||{},L=v==="deep"?this.deepMergeWithState(x,R):x;return this.writeLocalState(n,L,void 0,{scope:i}),S&&f&&setTimeout(()=>f.completeStateChange(S),0),L}}async handleParentScopeSetState(e,n,r,i){const l=Xn(),c=window.G7Core,d=r==="replace"?"replace":r==="shallow"?"shallow":"deep",f=e.startsWith("$parent."),p=f?"$parent.":"$root.",m=e.slice(p.length);let y,C;if(m==="_local"||m==="_global")y=m,C=void 0;else if(m.startsWith("_local."))y="_local",C=m.slice(7);else if(m.startsWith("_global."))y="_global",C=m.slice(8);else{N.warn(`[handleParentScopeSetState] 지원하지 않는 타겟 형식: ${e}. _local 또는 _global으로 시작해야 합니다.`);return}const S=window.__g7LayoutContextStack||[];if(S.length===0){N.warn(`[handleParentScopeSetState] 레이아웃 컨텍스트 스택이 비어있습니다. target=${e}`);return}const v=f?S[S.length-1]:S[0];if(!v){N.warn(`[handleParentScopeSetState] 타겟 컨텍스트를 찾을 수 없습니다. target=${e}`);return}const x=y==="_global"?v.state?._global:v.state?._local,w=l?.isEnabled()?l.startStateChange(e,x,n,{actionId:i.actionId,handlerType:"setState",source:`target=${e}`}):void 0,{__mergeMode:R,__setStateId:L,...O}=n;if(y==="_global"){if(!this.globalStateUpdater){N.warn("[handleParentScopeSetState] globalStateUpdater가 설정되지 않았습니다."),w&&l&&l.completeStateChange(w);return}const j=c?.state?.get()||{};if(C){const F=O.value!==void 0?O.value:Object.values(O)[0],G=this.createNestedUpdate(C,F,j),P={...j,...G};N.log(`[handleParentScopeSetState] ${e}: 전역 상태 중첩 경로 업데이트`,P),this.globalStateUpdater(P)}else{const F=d==="deep"?this.deepMergeWithState(O,j):O;N.log(`[handleParentScopeSetState] ${e}: 전역 상태 업데이트 (mergeMode=${d})`,F),this.globalStateUpdater(d!=="deep"?{...F,__mergeMode:d}:F)}return w&&l&&setTimeout(()=>l.completeStateChange(w),0),{__target:e,...O}}else{if(!v.setState){N.warn(`[handleParentScopeSetState] 타겟 컨텍스트에 setState가 없습니다. target=${e}`),w&&l&&l.completeStateChange(w);return}const j=v.state||{};if(C){const F=O.value!==void 0?O.value:Object.values(O)[0],G=this.createNestedUpdate(C,F,j),P={...j,...G};return N.log(`[handleParentScopeSetState] ${e}: 로컬 상태 중첩 경로 업데이트`,G),v.setState(G),v.state=P,v.dataContext&&(v.dataContext._local=P),vf(),w&&l&&setTimeout(()=>l.completeStateChange(w),0),P}else{const F=d!=="deep"?{...O,__mergeMode:d}:O,G=d==="replace"?O:d==="shallow"?{...j,...O}:this.deepMergeWithState(O,j);return N.log(`[handleParentScopeSetState] ${e}: 로컬 상태 업데이트 (mergeMode=${d})`,G),v.setState(F),v.state=G,v.dataContext&&(v.dataContext._local=G),vf(),w&&l&&setTimeout(()=>l.completeStateChange(w),0),G}}}deepMergeWithState(e,n){const r=["errors"];let i=e;if("..."in e){const c=e["..."];if(c&&typeof c=="object"&&!Array.isArray(c)){const{"...":d,...f}=e;i={...c,...f}}else{const{"...":d,...f}=e;i=f}}const l={...n};for(const[c,d]of Object.entries(i)){if(r.includes(c)){l[c]=d;continue}if(c.includes(".")&&c!=="..."){const f=this.createNestedUpdate(c,d,l);this.deepMergeInto(l,f,l);continue}if(d!==null&&typeof d=="object"&&!Array.isArray(d)&&Object.getPrototypeOf(d)!==Object.prototype&&Object.getPrototypeOf(d)!==null){l[c]=d;continue}d!==null&&typeof d=="object"&&!Array.isArray(d)&&n[c]!==null&&typeof n[c]=="object"&&!Array.isArray(n[c])?l[c]=this.deepMergeWithState(d,n[c]):l[c]=d}return l}deepMergeInto(e,n,r){for(const[i,l]of Object.entries(n)){if(l===null){e[i]=l;continue}if(e[i]===null){e[i]=l;continue}typeof l=="object"&&!Array.isArray(l)&&e[i]!==void 0&&e[i]!==null&&typeof e[i]=="object"&&!Array.isArray(e[i])?(e[i]===r[i]&&(e[i]={...e[i]}),this.deepMergeInto(e[i],l,r[i]||{})):typeof l=="object"&&!Array.isArray(l)&&e[i]===void 0&&r[i]!==null&&typeof r[i]=="object"&&!Array.isArray(r[i])?e[i]={...r[i],...l}:e[i]=l}}createNestedUpdate(e,n,r){const i=e.split(".");if(i.length===1)return{[i[0]]:n};const l={};let c=l,d=r;for(let f=0;f{this.globalStateUpdater({_local:S})};m.push({state:y,setState:C,dataContext:{_local:y||n.data?._local,_global:l?n.data?._global:n.data?._global||i?.state?.get?.(),_computed:n.data?._computed}}),window.__g7LayoutContextStack=m,N.log(`[handleOpenModal] 레이아웃 컨텍스트 스택에 push, 스택 크기: ${m.length}, state:`,y,l?"(direct)":"(fallback via G7Core)")}else N.warn(`[handleOpenModal] 컨텍스트 스택에 push 실패 - setState: ${!!n.setState}, state: ${n.state!==void 0}, G7Core: ${!!i?.state?.getLocal}`);const f=[...r,e];this.globalStateUpdater({modalStack:f,activeModal:e});const p=Xn();if(p?.isEnabled()){const m=r.length>0?r[r.length-1]:void 0;p.trackModalOpen?.({modalId:e,modalName:e,scopeType:"isolated",parentModalId:m,initialState:n.state?{...n.state}:{}})}}async handleCloseModal(e){if(!this.globalStateUpdater){N.warn("Global state updater is not set for closeModal");return}const n=e?.data?._global?.modalStack||[],r=n.length>0?n[n.length-1]:null,i=n.slice(0,-1),l=i.length>0?i[i.length-1]:null,c=window.__g7LayoutContextStack||[];if(c.length>0){const d=c[c.length-1];d&&(d.dataContext=void 0),c.pop(),window.__g7LayoutContextStack=c,N.log(`[handleCloseModal] 레이아웃 컨텍스트 스택에서 pop, 스택 크기: ${c.length}`)}if(r){const d=Xn();d?.isEnabled()&&d.trackModalClose?.(r,e?.state)}this.globalStateUpdater({modalStack:i,activeModal:l})}async handleShowAlert(e,n){let r=e;this.translationEngine&&this.translationContext&&e.startsWith("$t:")&&(r=this.translationEngine.resolveTranslations(e,this.translationContext,n.data)),alert(r)}async handleToast(e,n){const{type:r="info",message:i,icon:l,duration:c}=e;if(r==="error"){const f=n.data?.error;if((f?.error_code==="identity_verification_required"||f?.data?.error_code==="identity_verification_required")&&yt.consumeDomainNoticeShown()){N.log("[Toast] IDV 도메인 안내 표출됨 — 중복 가드 토스트 1건 skip");return}}let d=i;if(this.translationEngine&&this.translationContext&&i?.startsWith("$t:")&&(d=this.translationEngine.resolveTranslations(i,this.translationContext,n.data)),this.globalStateUpdater){const p={id:`toast_${Date.now()}_${Math.random().toString(36).substring(2,9)}`,type:r,message:d,...l&&{icon:l},...c&&{duration:c}},S=[...window.G7Core?.state?.get()?.toasts||[],p];this.globalStateUpdater({toasts:S})}else N.log(`[Toast ${r}] ${d}`)}async handleSwitch(e,n){const{cases:r}=e;if(!r){N.warn("switch handler requires cases property");return}const i=this.resolveParams(e.params,n.data);let l;if(i?.value!==void 0?(l=i.value,N.log("switch handler: using params.value as case key:",l)):(l=n.data?.$args?.[0],N.log("switch handler: using $args[0] as case key:",l)),l==null){if(r.default)return N.log("switch handler: case key is undefined, using default case"),await this.executeAction(r.default,n);N.warn("switch handler: case key is not defined and no default case");return}const c=String(l);let d=r[c];if(!d&&r.default&&(N.log(`switch handler: no case found for key "${c}", using default case`),d=r.default),!d){N.warn(`switch handler: no case found for key "${c}" and no default case`);return}return await this.executeAction(d,n)}async handleConditions(e,n){const{conditions:r}=e;if(!r||!Array.isArray(r)){N.warn("conditions handler requires conditions array");return}const i=n.data||{},l=Vg(r,i,this.bindingEngine);if(!l.matched){N.log("conditions handler: no matching branch found");return}const c=r[l.branchIndex];if(N.log(`conditions handler: matched branch ${l.branchIndex}`),!c.then){N.warn('conditions handler: matched branch has no "then" action');return}return Array.isArray(c.then)?await this.handleSequence({...e,actions:c.then},n):await this.executeAction(c.then,n)}handleStartInterval(e,n){const r=typeof e.id=="string"?e.id:"",i=Number(e.intervalMs??1e3),l=Array.isArray(e.actions)?e.actions:[];if(r===""||!l.length||i<=0)return N.warn("startInterval requires non-empty id, positive intervalMs, and actions array"),{success:!1};const c=this.intervals.get(r);c&&(clearInterval(c),this.intervals.delete(r));const d=setInterval(()=>{for(const f of l)this.executeAction(f,n).catch(p=>{N.error(`[startInterval:${r}] tick action failed`,p)})},i);return this.intervals.set(r,d),{success:!0,id:r}}handleStopInterval(e){const n=typeof e.id=="string"?e.id:"";if(n==="")return N.warn("stopInterval requires id parameter"),{success:!1};const r=this.intervals.get(n);return r&&(clearInterval(r),this.intervals.delete(n)),{success:!0,id:n}}stopAllIntervals(){for(const e of this.intervals.values())clearInterval(e);this.intervals.clear()}async handleSequence(e,n){const r=e.actions||e.params?.actions;if(!r||!Array.isArray(r)||r.length===0)return N.warn("sequence handler requires non-empty actions array"),[];const i=Xn(),l=i?.isEnabled()&&i.startSequenceExecution?.({eventType:e.type})||"";window.__g7SequenceLocalSync=void 0;const c=[];let d,f=n.state?{...n.state}:{},p=n.isolatedContext?.state?{...n.isolatedContext.state}:{},m=n.data?._computed||{};const y=window.G7Core,C=()=>({_global:y?.state?.get()||{},_local:{...f},_isolated:Object.keys(p).length>0?{...p}:void 0});for(let S=0;S0){const O={},j={...n.data,_local:f,_computed:O,$computed:O,_isolated:p};for(const[F,G]of Object.entries(L))if(typeof G=="string"){const P=G.trim();if(P.startsWith("{{")&&P.endsWith("}}"))try{const K=P.slice(2,-2).trim();O[F]=On(K)?this.bindingEngine.evaluatePipeExpression(K,j,{skipCache:!0}):this.bindingEngine.evaluateExpression(K,j,{skipCache:!0})}catch{O[F]=m[F]}}m=O,N.log("[handleSequence] _computed recalculated after setState:",m)}}if(v.handler!=="setState"){const L=window.__g7SequenceLocalSync;if(L&&L!==f){f=L,window.__g7SequenceLocalSync=void 0,N.log("[handleSequence] currentState synchronized from __g7SequenceLocalSync after custom handler:",v.handler);const O=n.data?._computedDefinitions;if(O&&Object.keys(O).length>0){const j={},F={...n.data,_local:f,_computed:j,$computed:j,_isolated:p};for(const[G,P]of Object.entries(O))if(typeof P=="string"){const K=P.trim();if(K.startsWith("{{")&&K.endsWith("}}"))try{const he=K.slice(2,-2).trim();j[G]=On(he)?this.bindingEngine.evaluatePipeExpression(he,F,{skipCache:!0}):this.bindingEngine.evaluateExpression(he,F,{skipCache:!0})}catch{j[G]=m[G]}}m=j,N.log("[handleSequence] _computed recalculated after custom handler:",m)}}}l&&i?.isEnabled()&&i.captureSequenceActionAfter?.(l,S,C(),Date.now()-x,R.data)}catch(R){throw l&&i?.isEnabled()&&(i.captureSequenceActionAfter?.(l,S,C(),Date.now()-x,void 0,R),i.endSequenceExecution?.(l,R)),N.error(`sequence handler: action[${S}] failed:`,R),R}}return window.__g7SequenceLocalSync=void 0,l&&i?.isEnabled()&&i.endSequenceExecution?.(l),c}async handleParallel(e,n){const r=e.actions||e.params?.actions;if(!r||!Array.isArray(r)||r.length===0)return N.warn("parallel handler requires non-empty actions array"),[];N.log(`parallel handler: executing ${r.length} actions in parallel`);const i=n.isolatedContext?{...n.isolatedContext,state:{...n.isolatedContext.state}}:null,l=r.map((f,p)=>{const m={...n,isolatedContext:i};return this.executeAction(f,m).catch(y=>{throw N.error(`parallel handler: action[${p}] failed:`,y),y})}),c=await Promise.allSettled(l),d=c.filter(f=>f.status==="rejected").length;return d>0&&N.warn(`parallel handler: ${d}/${r.length} actions failed`),c}assertAllowedExtensionAssetUrl(e,n,r){if(!Oo(e,fs()))throw N.error(`Blocked untrusted ${n} asset url: ${e}`),new Tt(`Blocked untrusted ${n} url (same-origin path or declared trusted host required): ${e}`,r)}async handleLoadScript(e,n,r){const{src:i,id:l,async:c=!0,defer:d=!1}=e;if(!i)throw new Tt('loadScript handler requires "src" parameter',n);if(!Oo(i,fs()))throw N.warn(`loadScript: blocked untrusted script src (same-origin path or declared trusted host required): ${i}`),new Tt(`Blocked untrusted script src (same-origin path or declared trusted host required): ${i}`,n);const f=l||`script_${i.replace(/[^a-zA-Z0-9]/g,"_")}`;if(rn.loadedScripts.has(f))return N.log(`loadScript: script already loaded, skipping: ${f}`),n.onLoad&&await this.executeAction(n.onLoad,r),!0;const p=rn.loadingScripts.get(f);if(p)return N.log(`loadScript: joining in-flight load: ${f}`),await p,n.onLoad&&await this.executeAction(n.onLoad,r),!0;if(document.getElementById(f))return N.log(`loadScript: script element already exists: ${f}`),rn.loadedScripts.add(f),n.onLoad&&await this.executeAction(n.onLoad,r),!0;N.log(`loadScript: loading script: ${i}`);const y=document.createElement("script");if(y.id=f,y.src=i,y.async=c,y.defer=d,y.hasAttribute("data-gdpr-blocked-src"))return N.warn(`loadScript: script blocked by consent manager (not loaded): ${i}`),!1;const C=new Promise((S,v)=>{y.onload=()=>{N.log(`loadScript: script loaded successfully: ${f}`),rn.loadedScripts.add(f),rn.loadingScripts.delete(f),S()},y.onerror=x=>{N.error(`loadScript: failed to load script: ${i}`,x),rn.loadingScripts.delete(f),v(new Tt(`Failed to load script: ${i}`,n))},document.head.appendChild(y)});if(C.catch(()=>{}),rn.loadingScripts.set(f,C),await C,n.onLoad)try{await this.executeAction(n.onLoad,r)}catch(S){N.error("loadScript: onLoad action failed:",S)}return!0}async handleCallExternal(e,n,r){const i=e.constructor,l=e.args||{},c=e.method,d=e.methodArgs||[],f=e.callbackEvent,p=e.embedTarget,m=e.callbackSetState,y=e.callbackAction;if(!i)throw new Tt('callExternal handler requires "constructor" parameter',n);const C=this.getNestedProperty(window,i);if(!C||typeof C!="function")throw new Tt(`Constructor not found or not a function: ${i}. Make sure the script is loaded first using loadScript handler.`,n);this.assertCallableExternalConstructor(C,i,n),N.log(`callExternal: calling constructor ${i}`);const S={...l};for(const[x,w]of Object.entries(l))w===!0&&(S[x]=R=>{if(N.log(`callExternal: callback triggered for ${x}`,R),f&&typeof window<"u"&&window.G7Core?.componentEvent&&window.G7Core.componentEvent.emit(f,R),m&&r.setState){const L=F=>{const G={};for(const[P,K]of Object.entries(F)){if(rn.isPrototypePathSegment(P)){N.warn(`callExternal: skipped prototype-polluting mapping key: ${P}`);continue}typeof K=="string"?G[P]=this.getNestedProperty(R,K):typeof K=="object"&&K!==null&&(G[P]=L(K))}return G},O=L(m);N.log("callExternal: callbackSetState mapping result",O);const j=this.deepMergeWithState(O,r.state||{});N.log("callExternal: merged with existing state",j),this.writeLocalState(r,j)}else f&&r.setState&&this.writeLocalState(r,{[`${f.replace(/:/g,"_")}_result`]:R});if(y){const L={...r,data:{...r.data,$event:R}},O=Array.isArray(y)?y:[y];for(const j of O)try{this.executeAction(j,L)}catch(F){N.error("callExternal: callbackAction failed:",F)}}});const v=new C(S);if(c&&typeof v[c]=="function"){if(N.log(`callExternal: calling method ${c}`),c==="embed"&&p){const x=document.querySelector(p);if(x)return v[c](x,...d);throw new Tt(`Embed target element not found: ${p}`,n)}return v[c](...d)}return v}async handleCallExternalEmbed(e,n,r){const i=e.constructor,l=e.args||{},c=e.callbackSetState,d=e.callbackEvent,f=e.layerClassName,p=e.callbackAction;if(!i)throw new Tt('callExternalEmbed handler requires "constructor" parameter',n);const m=this.getNestedProperty(window,i);if(!m||typeof m!="function")throw new Tt(`Constructor not found or not a function: ${i}. Make sure the script is loaded first.`,n);this.assertCallableExternalConstructor(m,i,n),N.log(`callExternalEmbed: creating layer for ${i}`);const{layer:y,closeLayer:C}=this.createEmbedLayer(f),S={...l};for(const[x,w]of Object.entries(l))w===!0&&(S[x]=R=>{if(N.log(`callExternalEmbed: callback triggered for ${x}`,R),C(),d&&typeof window<"u"&&window.G7Core?.componentEvent&&window.G7Core.componentEvent.emit(d,R),c&&r.setState){const L=F=>{const G={};for(const[P,K]of Object.entries(F)){if(rn.isPrototypePathSegment(P)){N.warn(`callExternal: skipped prototype-polluting mapping key: ${P}`);continue}typeof K=="string"?G[P]=this.getNestedProperty(R,K):typeof K=="object"&&K!==null&&(G[P]=L(K))}return G},O=L(c);N.log("callExternalEmbed: callbackSetState mapping result",O);const j=this.deepMergeWithState(O,r.state||{});N.log("callExternalEmbed: merged with existing state",j),this.writeLocalState(r,j)}if(p){const L={...r,data:{...r.data,$event:R}},O=Array.isArray(p)?p:[p];for(const j of O)try{this.executeAction(j,L)}catch(F){N.error("callExternalEmbed: callbackAction failed:",F)}}});const v=new m(S);if(typeof v.embed=="function")v.embed(y),N.log("callExternalEmbed: embedded in layer");else throw C(),new Tt(`Constructor ${i} does not have embed method`,n);return v}isImeComposing(e){return e?.isComposing===!0||e?.keyCode===229}createEmbedLayer(e){const n=document.createElement("div");n.id="g7-embed-overlay",n.style.cssText=` + */var py;function t_(){if(py)return No;py=1;var s=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,l){var c=null;if(l!==void 0&&(c=""+l),i.key!==void 0&&(c=""+i.key),"key"in i){l={};for(var d in i)d!=="key"&&(l[d]=i[d])}else l=i;return i=l.ref,{$$typeof:s,type:r,key:c,ref:i!==void 0?i:null,props:l}}return No.Fragment=e,No.jsx=n,No.jsxs=n,No}var gy;function n_(){return gy||(gy=1,kf.exports=t_()),kf.exports}var yt=n_();const r_=na({__proto__:null,default:ra(yt)},[yt]),Rf=pt("ParentContextProvider"),my=N.createContext(null);let Cc=null;function Df(){Cc?(Rf.log("[triggerModalParentUpdate] 모달 부모 컨텍스트 업데이트 트리거"),Cc()):Rf.warn("[triggerModalParentUpdate] Provider가 아직 마운트되지 않음")}const yy=({children:s})=>{const[e,n]=N.useState(0),r=N.useRef(!0),i=N.useCallback(()=>{const c=window.__g7LayoutContextStack||[];return c[c.length-1]?.dataContext},[]);N.useEffect(()=>(r.current=!0,Cc=()=>{r.current&&(n(c=>c+1),Rf.log("[ParentContextProvider] 버전 업데이트됨"))},()=>{r.current=!1,Cc=null}),[]);const l={version:e,getParentDataContext:i};return yt.jsx(my.Provider,{value:l,children:s})};function a_(){return N.useContext(my)}function by(s){return s.replace(/[\t\n\r]/g,"").replace(/\\/g,"/").replace(/^([a-z][a-z0-9+.\-]*:)?\/{2,}/i,"$1//")}function vy(s,e){try{const n=typeof window<"u"&&window.location?.protocol||"https:",r=e||(typeof window<"u"?window.location?.origin:void 0)||"https://localhost",i=s.startsWith("//")?`${n}${s}`:s,l=new URL(i,r);return l.protocol!=="http:"&&l.protocol!=="https:"?null:l.hostname.toLowerCase()}catch{return null}}function bs(){const s=typeof window<"u"?window.G7Config?.trustedScriptHosts:void 0;return Array.isArray(s)?s.map(e=>String(e).toLowerCase()):[]}function Io(s,e){if(typeof s!="string")return!1;const n=s.trim();if(n==="")return!1;const r=by(n),i=r.startsWith("//"),l=/^[a-z][a-z0-9+.-]*:/i.test(r);if(!i&&!l&&r.startsWith("/"))return!0;const c=vy(r),d=e??bs();return c!==null&&d.map(f=>String(f).toLowerCase()).includes(c)}const I=pt("ActionDispatcher");function i_(s,e,n,r){return n||(Kg(s)||zd(s)?"$t:core.errors.network_request_failed":r||`Failed to execute action: ${e}`)}const Sy=new Set(["navigate","navigateBack","navigateForward","replaceUrl","refresh","logout"]),s_=new Set(["redirect"]);function Jn(){try{return window.G7Core?.devTools}catch{return}}class It extends Error{constructor(n,r,i){super(n);M(this,"unknownHandler",!1);this.action=r,this.originalError=i,this.name="ActionError"}}const wy={click:"onClick",change:"onChange",input:"onInput",submit:"onSubmit",focus:"onFocus",blur:"onBlur",keydown:"onKeyDown",keyup:"onKeyUp",keypress:"onKeyPress",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",scroll:"onScroll",dragstart:"onDragStart",drag:"onDrag",dragend:"onDragEnd",dragenter:"onDragEnter",dragover:"onDragOver",dragleave:"onDragLeave",drop:"onDrop"},cn=class cn{constructor(e={},n,r){M(this,"bindingEngine");M(this,"translationEngine");M(this,"translationContext");M(this,"customHandlers",new Map);M(this,"defaultContext");M(this,"globalStateUpdater");M(this,"errorHandlingSetup",!1);M(this,"debounceTimers",new Map);M(this,"pendingDebounceFlushers",new Map);M(this,"debounceAccumulatedValues",new Map);M(this,"globalHeaders",[]);M(this,"namedActions",{});M(this,"previewMode",!1);M(this,"localMirrorDepth",0);M(this,"intervals",new Map);this.bindingEngine=new $n,this.translationEngine=n,this.translationContext=r,this.defaultContext=e,this.registerDefaultHandlers(),this.setupErrorHandling()}setGlobalHeaders(e){this.globalHeaders=e||[]}setNamedActions(e){this.namedActions=e||{};const n=Jn();n?.isEnabled?.()&&n.setNamedActionDefinitions?.(this.namedActions),I.log("[setNamedActions] registered:",Object.keys(this.namedActions))}getNamedActions(){return this.namedActions}setPreviewMode(e){this.previewMode=e,I.log("Preview mode:",e?"enabled":"disabled")}isPreviewMode(){return this.previewMode}static getPreviewSuppressedHandlers(){return Sy}static getPreviewSuppressedLayoutFeatures(){return s_}resolveActionRef(e){if(!e.actionRef)return e;const n=this.namedActions[e.actionRef];if(!n)return I.warn(`[resolveActionRef] named action not found: "${e.actionRef}"`),e;const r=Jn();r?.isEnabled?.()&&r.trackNamedActionRef?.({actionRefName:e.actionRef,resolvedHandler:n.handler,timestamp:Date.now()});const{actionRef:i,type:l,key:c,event:d,...f}=e,h={...n,...Object.fromEntries(Object.entries(f).filter(([,m])=>m!==void 0)),type:l??n.type};return c!==void 0&&(h.key=c),d!==void 0&&(h.event=d),h}matchesPattern(e,n){if(n==="*")return!0;const r=n.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${r}$`).test(e)}getMatchingGlobalHeaders(e,n){const r={};for(const i of this.globalHeaders)this.matchesPattern(e,i.pattern)&&Object.entries(i.headers).forEach(([l,c])=>{const d=ps(c,n,{skipCache:!0});d!=null&&d!==""&&(r[l]=String(d))});return r}setupErrorHandling(){if(this.errorHandlingSetup)return;kr().setActionExecutor(async(n,r)=>{const i={type:"click",handler:n.handler,target:n.target,params:n.params,actions:n.actions},l={data:{...this.defaultContext.data,error:r.error}};return await this.dispatchAction(i,l)}),this.errorHandlingSetup=!0}registerDefaultHandlers(){this.registerHandler("refetchDataSource",async(n,r)=>{const i=n.params?.dataSourceId,l=n.params?.sync;if(!i){I.warn("refetchDataSource: dataSourceId is required");return}if(typeof window<"u"&&window.G7Core?.dataSource?.refetch){const c=window.G7Core?.state?.get?.()||{},d={...r.state?._global,...c},f=window.G7Core?.state?.getLocal?.()||{},h=r.data?._local||r.state||{},m={...f,...h},y=r.isolatedContext?.state;I.log("[refetchDataSource] localStateOverride:",m),await window.G7Core.dataSource.refetch(i,{...l?{sync:!0}:{},...d?{globalStateOverride:d}:{},...m?{localStateOverride:m}:{},...y?{isolatedStateOverride:y}:{}})}else I.warn("refetchDataSource: G7Core.dataSource.refetch is not available")}),this.registerHandler("appendDataSource",async(n,r)=>{const{dataSourceId:i,dataPath:l,newData:c}=n.params||{};if(!i){I.warn("appendDataSource: dataSourceId is required");return}if(c===void 0){I.warn("appendDataSource: newData is required");return}if(typeof window<"u"&&window.G7Core?.dataSource?.updateData){if(!Array.isArray(c)){I.warn("appendDataSource: newData must be an array, got:",typeof c,c);return}await window.G7Core.dataSource.updateData(i,l||null,c,"append")}else I.warn("appendDataSource: G7Core.dataSource.updateData is not available")}),this.registerHandler("updateDataSource",async(n,r)=>{const{dataSourceId:i,data:l,merge:c=!1}=n.params||{};if(!i){I.warn("updateDataSource: dataSourceId is required");return}if(l===void 0){I.warn("updateDataSource: data is required");return}typeof window<"u"&&window.G7Core?.dataSource?.set?(I.log(`[updateDataSource] Updating dataSource '${i}' with:`,l),window.G7Core.dataSource.set(i,l,{merge:c})):I.warn("updateDataSource: G7Core.dataSource.set is not available")}),this.registerHandler("scrollIntoView",async(n,r)=>{const{selector:i,behavior:l="smooth",block:c="nearest",inline:d="nearest",waitForElement:f=!1,timeout:h=2e3,delay:m=0,retryCount:y=0,retryInterval:v=50,scrollContainer:S}=n.params||{};if(!i){I.warn("scrollIntoView: selector is required");return}if(typeof window>"u"||typeof document>"u"){I.warn("scrollIntoView: window/document is not available");return}let _=null;if(f){if(_=await new Promise(x=>{const A=document.querySelector(i);if(A){x(A);return}const D=setTimeout(()=>{O.disconnect(),x(null)},h),O=new MutationObserver(()=>{const k=document.querySelector(i);k&&(clearTimeout(D),O.disconnect(),x(k))});O.observe(document.body,{childList:!0,subtree:!0})}),!_){I.warn(`scrollIntoView: element not found for selector "${i}" after ${h}ms timeout`);return}}else{m>0&&await new Promise(A=>setTimeout(A,m)),_=document.querySelector(i);let x=0;for(;!_&&xsetTimeout(A,v)),_=document.querySelector(i),x++;if(!_){I.warn(`scrollIntoView: element not found for selector "${i}" after ${x+1} attempts`);return}}if(S){const x=document.querySelector(S);if(!x){I.warn(`scrollIntoView: container not found for selector "${S}"`);return}const A=_.getBoundingClientRect(),D=x.getBoundingClientRect(),O=A.top-D.top+x.scrollTop,k=O+A.height;let L;switch(c){case"start":L=O;break;case"center":L=O-x.clientHeight/2+A.height/2;break;case"end":L=k-x.clientHeight;break;case"nearest":default:const B=A.topD.bottom;if(B)L=O;else if(q)L=k-x.clientHeight;else return;break}x.scrollTo({top:Math.max(0,L),behavior:l});return}_.scrollIntoView({behavior:l,block:c,inline:d})}),this.registerHandler("reloadExtensions",async(n,r)=>{if(typeof window>"u"){I.warn("reloadExtensions: window is not available");return}const i=window.__templateApp;if(!i){I.warn("reloadExtensions: TemplateApp not initialized");return}if(typeof i.reloadExtensionState=="function")try{await i.reloadExtensionState()}catch(d){throw I.error("reloadExtensions: reloadExtensionState failed",d),d}else I.warn("reloadExtensions: TemplateApp.reloadExtensionState unavailable");const{moduleInfo:l,pluginInfo:c}=n.params||{};if(l)try{await this.executeAction({handler:"reloadModuleHandlers",params:n.params},r)}catch(d){I.error("reloadExtensions: reloadModuleHandlers failed",d)}if(c)try{await this.executeAction({handler:"reloadPluginHandlers",params:n.params},r)}catch(d){I.error("reloadExtensions: reloadPluginHandlers failed",d)}I.log("reloadExtensions: done")}),this.registerHandler("reloadRoutes",async(n,r)=>{if(typeof window>"u"){I.warn("reloadRoutes: window is not available");return}const i=window.__templateApp;if(!i){I.warn("reloadRoutes: TemplateApp not initialized");return}if(typeof i.reloadExtensionState=="function")try{await i.reloadExtensionState(),I.log("reloadRoutes: delegated to reloadExtensionState")}catch(l){throw I.error("reloadRoutes: Failed to reload routes",l),l}else{const l=i.getRouter?.();l&&(await l.loadRoutes(),I.log("reloadRoutes: Routes reloaded (legacy fallback)"))}}),this.registerHandler("refresh",async(n,r)=>{if(typeof window>"u"){I.warn("refresh: window is not available");return}const i=Number(n.params?.delayMs??0);i>0&&await new Promise(l=>setTimeout(l,i)),window.location.reload()}),this.registerHandler("remount",async(n,r)=>{const{componentId:i}=n.params||{};if(!i){I.warn("remount: componentId parameter is required");return}if(!this.globalStateUpdater){I.warn("remount: globalStateUpdater is not set");return}const d=(window.G7Core?.state?.get()||{})._global?._remountKeys||{},f=d[i]||0;this.globalStateUpdater({_remountKeys:{...d,[i]:f+1}}),I.log(`remount: ${i} key incremented to ${f+1}`)}),this.registerHandler("reloadTranslations",async(n,r)=>{if(typeof window>"u"){I.warn("reloadTranslations: window is not available");return}const i=window.__templateApp;if(!i){I.warn("reloadTranslations: TemplateApp not initialized");return}if(typeof i.reloadExtensionState=="function")try{await i.reloadExtensionState(),I.log("reloadTranslations: delegated to reloadExtensionState")}catch(l){throw I.error("reloadTranslations: Failed to reload translations",l),l}}),this.registerHandler("reloadModuleHandlers",async(n,r)=>{if(typeof window>"u"){I.warn("reloadModuleHandlers: window is not available");return}const{moduleInfo:i,action:l}=n.params||{};if(!i){I.warn("reloadModuleHandlers: moduleInfo is required");return}const c=i.data||i;if(!c.identifier){I.warn("reloadModuleHandlers: moduleInfo with identifier is required");return}if(!l||l!=="add"&&l!=="remove"){I.warn('reloadModuleHandlers: action must be "add" or "remove"');return}const d=window.G7Config;if(!d){I.warn("reloadModuleHandlers: G7Config not available");return}const f=c.identifier;try{if(l==="add"){if(c.assets){if(d.moduleAssets=d.moduleAssets||{},d.moduleAssets[f]=c.assets,I.log(`reloadModuleHandlers: Added assets for ${f}`),c.assets.js){const h=c.assets.js,m=`module-${f}`;this.assertAllowedExtensionAssetUrl(h,`module script (${f})`,n),document.getElementById(m)?I.warn(`reloadModuleHandlers: Script ${m} already loaded`):(await _r(h,{id:m},{label:`module-script:${f}`}),I.log(`reloadModuleHandlers: Script loaded successfully for ${f}`))}if(c.assets.css){const h=c.assets.css,m=`module-css-${f}`;this.assertAllowedExtensionAssetUrl(h,`module stylesheet (${f})`,n),document.getElementById(m)||(await ia(h,{id:m},{label:`module-css:${f}`}),I.log(`reloadModuleHandlers: CSS loaded for ${f}`))}}}else if(l==="remove"){d.moduleAssets&&d.moduleAssets[f]&&(delete d.moduleAssets[f],I.log(`reloadModuleHandlers: Removed assets for ${f}`));const h=`module-${f}`,m=document.getElementById(h);m&&(m.remove(),I.log(`reloadModuleHandlers: Removed script for ${f}`));const y=`module-css-${f}`,v=document.getElementById(y);v&&(v.remove(),I.log(`reloadModuleHandlers: Removed CSS for ${f}`))}}catch(h){throw I.error(`reloadModuleHandlers: Failed to ${l} module assets`,h),h}}),this.registerHandler("reloadPluginHandlers",async(n,r)=>{if(typeof window>"u"){I.warn("reloadPluginHandlers: window is not available");return}const{pluginInfo:i,action:l}=n.params||{};if(!i){I.warn("reloadPluginHandlers: pluginInfo is required");return}const c=i.data||i;if(!c.identifier){I.warn("reloadPluginHandlers: pluginInfo with identifier is required");return}if(!l||l!=="add"&&l!=="remove"){I.warn('reloadPluginHandlers: action must be "add" or "remove"');return}const d=window.G7Config;if(!d){I.warn("reloadPluginHandlers: G7Config not available");return}const f=c.identifier;try{if(l==="add"){if(c.assets){if(d.pluginAssets=d.pluginAssets||{},d.pluginAssets[f]=c.assets,I.log(`reloadPluginHandlers: Added assets for ${f}`),c.assets.js){const h=c.assets.js,m=`plugin-${f}`;this.assertAllowedExtensionAssetUrl(h,`plugin script (${f})`,n),document.getElementById(m)?I.warn(`reloadPluginHandlers: Script ${m} already loaded`):(await _r(h,{id:m},{label:`plugin-script:${f}`}),I.log(`reloadPluginHandlers: Script loaded successfully for ${f}`))}if(c.assets.css){const h=c.assets.css,m=`plugin-css-${f}`;this.assertAllowedExtensionAssetUrl(h,`plugin stylesheet (${f})`,n),document.getElementById(m)||(await ia(h,{id:m},{label:`plugin-css:${f}`}),I.log(`reloadPluginHandlers: CSS loaded for ${f}`))}}}else if(l==="remove"){d.pluginAssets&&d.pluginAssets[f]&&(delete d.pluginAssets[f],I.log(`reloadPluginHandlers: Removed assets for ${f}`));const h=`plugin-${f}`,m=document.getElementById(h);m&&(m.remove(),I.log(`reloadPluginHandlers: Removed script for ${f}`));const y=`plugin-css-${f}`,v=document.getElementById(y);v&&(v.remove(),I.log(`reloadPluginHandlers: Removed CSS for ${f}`))}}catch(h){throw I.error(`reloadPluginHandlers: Failed to ${l} plugin assets`,h),h}});let e=!1;this.registerHandler("showErrorPage",async(n,r)=>{if(e){I.log("showErrorPage: Already active, skipping duplicate call");return}if(e=!0,typeof window>"u"){e=!1,I.warn("showErrorPage: window is not available");return}const i=window.__templateApp;if(!i){e=!1,I.warn("showErrorPage: TemplateApp not initialized");return}const l=i.getErrorPageHandler?.();if(!l){e=!1,I.warn("showErrorPage: ErrorPageHandler not available");return}const c=n.params?.errorCode||500,d=n.params?.target||"content";let f=n.params?.containerId;f||(f=d==="full"?"app":"main_content"),I.log("showErrorPage:",{errorCode:c,target:d,containerId:f});const h=(m,y=6e4)=>new Promise((v,S)=>{const _=document.getElementById(m);if(_){v(_);return}I.log(`showErrorPage: Waiting for container #${m}...`);let x;const A=new MutationObserver((D,O)=>{const k=document.getElementById(m);k&&(I.log(`showErrorPage: Container #${m} found`),O.disconnect(),clearTimeout(x),v(k))});A.observe(document.body,{childList:!0,subtree:!0}),x=setTimeout(()=>{A.disconnect(),S(new Error(`Container #${m} not found within ${y}ms`))},y)});try{await h(f);const m=kr(),y=m.layoutErrorHandling;m.clearLayoutConfig();try{await l.renderError(c,f)||I.warn(`showErrorPage: Failed to render error page for code ${c}`)}finally{m.setLayoutConfig(y)}}catch(m){throw I.error("showErrorPage: Error rendering error page:",m),m}finally{e=!1}}),this.registerHandler("emitEvent",async(n,r)=>{const i=n.params?.event,l=n.params?.data;if(!i){I.warn("emitEvent: event parameter is required");return}if(typeof window>"u"){I.warn("emitEvent: window is not available");return}const c=window.G7Core;if(!c?.componentEvent?.emit){I.warn("emitEvent: G7Core.componentEvent is not available");return}try{I.log(`emitEvent: Emitting "${i}"`,l);const d={...l,_context:{data:r.data,state:r.state}},f=await c.componentEvent.emit(i,d);if(!f||f.length===0?I.warn(`emitEvent: No listeners found for "${i}"`):I.log(`emitEvent: Event "${i}" completed with ${f.length} listener(s)`,f),this.globalStateUpdater){const h=(c?.state?.get()||{})._local||{},m={event:i,success:!0,data:f.length===1?f[0]:f,listeners:f.length};this.globalStateUpdater({_local:{...h,_eventResult:m}});const y=r.state&&typeof r.state=="object"&&!Array.isArray(r.state)?r.state:h;window.__g7SequenceLocalSync={...y,_eventResult:m}}}catch(d){if(I.error(`emitEvent: Event "${i}" failed`,d),this.globalStateUpdater){const f=c?.state?.get()||{};this.globalStateUpdater({_local:{...f._local,_eventResult:{event:i,success:!1,error:d instanceof Error?d.message:String(d)}}})}throw d}}),this.registerHandler("updateProductField",async(n,r)=>{const{productId:i,field:l,value:c}=n.params||{};if(!i||!l){I.warn("updateProductField: productId and field are required");return}if(typeof window>"u"){I.warn("updateProductField: window is not available");return}const d=window.G7Core;if(!d?.state?.get||!this.globalStateUpdater){I.warn("updateProductField: G7Core.state or globalStateUpdater is not available");return}try{const f=d.state.get()||{},m=(f.products?.data?.data||[]).map(v=>v.id===i?{...v,[l]:c,_modified:!0}:v),y=new Set(f._local?.modifiedProductIds||[]);y.add(i),this.globalStateUpdater({products:{...f.products,data:{...f.products?.data,data:m}},_local:{...f._local,modifiedProductIds:Array.from(y)}}),I.log(`updateProductField: Updated product ${i}, field: ${l}, value:`,c)}catch(f){throw I.error("updateProductField: Error updating product field",f),f}}),this.registerHandler("updateOptionField",async(n,r)=>{const{productId:i,optionId:l,field:c,value:d}=n.params||{};if(!i||!l||!c){I.warn("updateOptionField: productId, optionId and field are required");return}if(typeof window>"u"){I.warn("updateOptionField: window is not available");return}const f=window.G7Core;if(!f?.state?.get||!this.globalStateUpdater){I.warn("updateOptionField: G7Core.state or globalStateUpdater is not available");return}try{const h=f.state.get()||{},y=(h.products?.data?.data||[]).map(S=>{if(S.id===i&&S.options){const _=S.options.map(x=>x.id===l?{...x,[c]:d,_modified:!0}:x);return{...S,options:_,_modified:!0}}return S}),v=new Set(h._local?.modifiedProductIds||[]);v.add(i),this.globalStateUpdater({products:{...h.products,data:{...h.products?.data,data:y}},_local:{...h._local,modifiedProductIds:Array.from(v)}}),I.log(`updateOptionField: Updated product ${i} option ${l}, field: ${c}, value:`,d)}catch(h){throw I.error("updateOptionField: Error updating option field",h),h}}),this.registerHandler("setLocale",async(n,r)=>{const i=n.target;if(!i||typeof i!="string"){I.warn("setLocale: Invalid locale:",i);return}const l=window.__templateApp;if(l&&typeof l.changeLocale=="function")try{await l.changeLocale(i),I.log("setLocale: Locale changed to",i)}catch(c){I.error("setLocale: Failed to change locale:",c),window.location.reload()}else{I.warn("setLocale: TemplateApp not found, falling back to page reload");try{localStorage.setItem("g7_locale",i)}catch{}window.location.reload()}}),this.registerHandler("suppress",async()=>{I.log("suppress: Error intentionally suppressed")}),this.registerBuiltInHandlerMetadata()}registerBuiltInHandlerMetadata(){const e=Jn();if(!e?.isEnabled())return;const n=[{name:"refetchDataSource",description:"데이터 소스를 다시 fetch합니다"},{name:"appendDataSource",description:"데이터 소스에 새 데이터를 병합합니다 (무한 스크롤용)"},{name:"updateDataSource",description:"API 응답으로 데이터 소스를 직접 업데이트합니다 (refetch 대체)"},{name:"reloadRoutes",description:"라우트를 다시 로드합니다"},{name:"refresh",description:"현재 페이지를 새로고침합니다"},{name:"remount",description:"컴포넌트를 리마운트합니다"},{name:"reloadTranslations",description:"다국어 파일을 다시 로드합니다"},{name:"showErrorPage",description:"에러 페이지를 표시합니다"},{name:"emitEvent",description:"이벤트를 발생시킵니다"},{name:"updateProductField",description:"상품 필드를 인라인 수정합니다"},{name:"updateOptionField",description:"상품 옵션 필드를 인라인 수정합니다"},{name:"setLocale",description:"언어를 변경합니다 (DB 저장 + UI 리렌더링)"}];for(const r of n)e.trackHandlerRegistration(r.name,"built-in",r.description)}createHandler(e,n,r){I.log("createHandler called for:",e.handler,e.type);const i=window.__g7DevTools,l=Date.now(),c=r?.state?{...r.state}:null,d=`handler_${e.handler}_${l}`;return async f=>{if(I.log("Handler invoked for:",e.handler,"event:",f.type),i?.isEnabled?.()&&c){const m=window.G7Core?.state?.getLocal?.()??r?.state??{},y=Date.now()-l;for(const v of Object.keys(c)){const S=c[v],_=m[v];S!==_&&y>100&&(i.trackStaleClosureWarning?.({type:"event-handler-stale",location:`createHandler(${e.handler})`,capturedPath:`_local.${v}`,capturedValue:S,capturedAt:l,currentValue:_,actionId:d,stackTrace:new Error().stack}),I.warn(`[Stale Closure] _local.${v} changed after handler creation:`,`captured="${S}" → current="${_}" (${y}ms ago)`))}}try{f.type!=="change"&&f.preventDefault();let h={};if(f.type==="submit"&&f.target instanceof HTMLFormElement){const v=f.target;new FormData(v).forEach((_,x)=>{h[x]=_})}const m={...this.defaultContext,data:{...n,form:h,_local:r?.state||{},$event:f},event:f,...r&&{state:r.state,setState:r.setState},isolatedContext:r?.isolatedContext};if(e.confirm){let v=this.resolveValue(e.confirm,m.data);if(this.translationEngine&&this.translationContext&&v.startsWith("$t:")&&(v=this.translationEngine.resolveTranslations(v,this.translationContext,m.data)),!confirm(v))return}const y=window.__g7ActionContext;window.__g7ActionContext={...r,data:m.data};try{await this.executeAction(e,m)}finally{window.__g7ActionContext=y}}catch(h){if(I.error("Action execution failed:",h),e.onError){const m=h instanceof It&&h.originalError?h.originalError:h,y={...this.defaultContext,data:{...n,error:m,_local:r?.state||{},$event:f},event:f,...r&&{state:r.state,setState:r.setState}},v=Array.isArray(e.onError)?e.onError:[e.onError];for(const S of v)await this.executeAction(S,y)}}}}generateActionId(e,n){const r=e.handler,i=n||"no-target",l=Date.now(),c=Math.random().toString(36).substring(2,9);return`${r}_${i.replace(/[^a-zA-Z0-9]/g,"_")}_${l}_${c}`}async executeAction(e,n){if(e=this.resolveActionRef(e),typeof e.handler=="string"&&e.handler.includes("{{")){const f=this.evaluateExpression(e.handler,n.data);e={...e,handler:f==null?"":String(f)}}const r=Jn(),i=r?.isEnabled()?`action_${Date.now()}_${Math.random().toString(36).substring(2,11)}`:void 0,l=performance.now();let c;if(i&&r&&r.logAction({id:i,type:e.handler,params:this.sanitizeForDevTools(e.params),context:this.sanitizeForDevTools({hasState:!!n.state,hasSetState:!!n.setState,dataKeys:n.data?Object.keys(n.data):[]}),startTime:l,status:"started"}),e.if!==void 0)try{const f=this.resolveValue(e.if,n.data),h=f===!0||f==="true"||f&&f!=="false"&&f!=="0"&&f!==!1;if(I.log("[executeAction] if condition result:",e.handler,h),!h)return i&&r&&r.logAction({id:i,type:e.handler,startTime:l,endTime:performance.now(),duration:performance.now()-l,status:"success",result:{skipped:!0,reason:"if condition false"}}),{success:!0,data:void 0}}catch(f){return I.error("[executeAction] if condition error:",e.handler,f),i&&r&&r.logAction({id:i,type:e.handler,startTime:l,endTime:performance.now(),duration:performance.now()-l,status:"error",error:{name:"ConditionEvaluationError",message:f instanceof Error?f.message:String(f),stack:f instanceof Error?f.stack:void 0}}),{success:!0,data:void 0}}let d;try{const f=this.resolveParams(e.params,n.data);i&&(c=this.sanitizeForDevTools(f));const h=e.target?this.resolveValue(e.target,n.data):void 0;if(e.handler==="apiCall"&&n.setState){d=this.generateActionId(e,h);const y=n.state?.loadingActions||{};n.setState({loadingActions:{...y,[d]:!0}})}if(this.previewMode&&Sy.has(e.handler))return I.warn(`Preview mode: "${e.handler}" suppressed`,h||f),i&&r&&r.logAction({id:i,type:e.handler,startTime:l,endTime:performance.now(),duration:performance.now()-l,status:"skipped",metadata:{reason:"preview_mode_suppressed"}}),{success:!0,data:void 0};let m;switch(e.handler){case"ensureIdentityVerified":m=await this.handleEnsureIdentityVerified(f);break;case"resolveIdentityChallenge":m=this.handleResolveIdentityChallenge(f);break;case"navigate":const y=f.path||h;m=await this.handleNavigate(y,f,n);break;case"navigateBack":m=await this.handleNavigateBack();break;case"navigateForward":m=await this.handleNavigateForward();break;case"openWindow":{const _=f.path||h;m=await this.handleOpenWindow(_,f);break}case"replaceUrl":{const _=f.path||h||window.location.pathname;m=await this.handleReplaceUrl(_,f);break}case"apiCall":if(e.onSuccess&&r?.isEnabled()&&i){const _=window.G7Core,x={};if(_?.state?.get){const A=_.state.get();x._global=A}n.state&&(x._local=n.state),r.registerStateCaptureForHandler?.(i,["_global","_local"],x)}const v=e.auth_mode??(e.auth_required?"required":"none"),S=e.identity_target?this.resolveParams(e.identity_target,n.data):void 0;m=await this.handleApiCall(h,f,n,v,S);break;case"login":m=await this.handleLogin(h,f,n);break;case"loginTwoFactor":m=await this.handleLoginTwoFactor(h,f,n);break;case"loginTwoFactorResend":m=await this.handleLoginTwoFactorResend(h,f,n);break;case"logout":m=await this.handleLogout(h,n);break;case"setState":I.log("[executeAction] setState resolvedParams:",f),m=await this.handleSetState(e.render!==void 0?{...f,__render:e.render}:f,n);break;case"setError":m=await this.handleSetError(h,f,n);break;case"openModal":m=await this.handleOpenModal(h,n);break;case"closeModal":m=await this.handleCloseModal(n);break;case"showAlert":m=await this.handleShowAlert(h,n);break;case"toast":m=await this.handleToast(f,n);break;case"switch":m=await this.handleSwitch(e,n);break;case"conditions":m=await this.handleConditions(e,n);break;case"sequence":m=await this.handleSequence(e,n);break;case"parallel":m=await this.handleParallel(e,n);break;case"startInterval":m=this.handleStartInterval(f,n);break;case"stopInterval":m=this.handleStopInterval(f);break;case"loadScript":m=await this.handleLoadScript(f,e,n);break;case"callExternal":m=await this.handleCallExternal(f,e,n);break;case"callExternalEmbed":m=await this.handleCallExternalEmbed(f,e,n);break;case"saveToLocalStorage":m=await this.handleSaveToLocalStorage(f,n);break;case"loadFromLocalStorage":m=await this.handleLoadFromLocalStorage(f,n);break;default:m=await this.handleCustomAction({...e,target:h,params:f},n);break}if(e.resultTo&&m!==void 0){const{target:y,key:v,merge:S}=e.resultTo,_=this.resolveValue(v,n.data),x=S==="replace"?"replace":S==="shallow"?"shallow":"deep";if(y==="_local"&&n.setState){const A=this.buildNestedUpdate(_,m),D=x!=="deep"?{...A,__mergeMode:x}:A;this.writeLocalState(n,D),I.log(`[resultTo] Saved to _local.${_} (merge=${x}):`,m)}else if(y==="_local"&&this.globalStateUpdater){const O=(window.G7Core?.state?.get()||{})._local||{},k=this.buildNestedUpdate(_,m);let L;x==="replace"?L=k:x==="shallow"?L={...O,...k}:L=this.deepMergeWithState(k,O),this.globalStateUpdater({_local:L}),I.log(`[resultTo] Saved to _local.${_} via globalStateUpdater (merge=${x}):`,m)}else if(y==="_global"&&this.globalStateUpdater){const A=this.buildNestedUpdate(_,m);this.globalStateUpdater(A),I.log(`[resultTo] Saved to _global.${_}:`,m)}else if(y==="_isolated"&&n.isolatedContext){const A=this.buildNestedUpdate(_,m);n.isolatedContext.mergeState(A,x),I.log(`[resultTo] Saved to _isolated.${_} (merge=${x}):`,m)}else I.warn(`[resultTo] Cannot save result: target=${y}, setState=${!!n.setState}, globalStateUpdater=${!!this.globalStateUpdater}, isolatedContext=${!!n.isolatedContext}`)}if(e.onSuccess){if(r?.isEnabled()&&i&&e.handler==="apiCall"){const S=window.G7Core,_={};S?.state?.get&&(_._global=S.state.get()),n.state&&(_._local=n.state),r.detectStaleClosure?.(i,`${e.handler} → onSuccess`,_,"callback-state-capture",i)}const y={...n,data:{...n.data,result:m,response:m}},v=Array.isArray(e.onSuccess)?e.onSuccess:[e.onSuccess];v.length>1?await this.handleSequence({handler:"sequence",type:"click",actions:v},y):v.length===1&&await this.executeAction(v[0],y)}return i&&r&&r.logAction({id:i,type:e.handler,params:this.sanitizeForDevTools(e.params),resolvedParams:c,startTime:l,endTime:performance.now(),duration:performance.now()-l,status:"success",result:this.sanitizeForDevTools(m)}),{success:!0,data:m}}catch(f){const h=f instanceof It?f:new It(`Failed to execute action: ${e.handler}`,e,f instanceof Error?f:void 0),m=h.originalError?.response||{},y=m.data||{},v=h.originalError?.status||m.status||500;let S=i_(h.originalError??f,e.handler,y.message,h.message);this.translationEngine&&this.translationContext&&S.startsWith("$t:")&&(S=this.translationEngine.resolveTranslations(S,this.translationContext));const _={status:v,message:S,errors:y.errors||m.errors,data:y,statusText:h.originalError?.statusText,error_code:y.error_code??m.error_code};if(h.unknownHandler)throw I.warn(`Unknown action handler "${e.handler}" — skipped (extension not loaded?). Not surfaced to the user.`),h;const A=kr().resolve(v,{errorHandling:e.errorHandling,onError:e.onError});if(A.handler){if(r?.isEnabled()&&i&&e.handler==="apiCall"){const O=window.G7Core,k={};O?.state?.get&&(k._global=O.state.get()),n.state&&(k._local=n.state),r.detectStaleClosure?.(i,`${e.handler} → onError`,k,"callback-state-capture",i)}const D={...n,data:{...n.data,error:_}};try{const O={type:"click",handler:A.handler.handler,target:A.handler.target,params:A.handler.params,actions:A.handler.actions};return await this.executeAction(O,D),{success:!1,error:h}}catch(O){return I.error("Error executing error handler:",O),{success:!1,error:h}}}throw i&&r&&r.logAction({id:i,type:e.handler,params:this.sanitizeForDevTools(e.params),resolvedParams:c,startTime:l,endTime:performance.now(),duration:performance.now()-l,status:"error",error:{name:h.name,message:h.message,stack:h.stack}}),h}finally{if(e.handler==="apiCall"&&n.setState&&d){const f=n.state?.loadingActions||{},{[d]:h,...m}=f;n.setState({loadingActions:m})}}}async handleNavigate(e,n,r){let i=e;if(n.query||n.mergeQuery===!0)if(n.mergeQuery===!0)i=this.buildMergedQueryPath(e,n.query??{});else{const c=new URLSearchParams;for(const[f,h]of Object.entries(n.query))if(h!=null&&h!=="")if(Array.isArray(h)){const m=f.endsWith("[]")?f:`${f}[]`;for(const y of h)y!=null&&y!==""&&c.append(m,String(y))}else c.set(f,String(h));const d=c.toString();d&&(i=`${e}?${d}`)}if(I.log("handleNavigate:",{target:e,params:n,finalPath:i,replace:n.replace,windowLocationSearch:window.location.search}),n.replace===!0){const c=window.G7Core;if(c?.updateQueryParams){const d=typeof n.transition_overlay_target=="string"?n.transition_overlay_target:void 0;await c.updateQueryParams(i,d?{transitionOverlayTarget:d}:void 0),I.log("handleNavigate: Used updateQueryParams for replace mode",d?{transitionOverlayTarget:d}:void 0),this.applyScrollOption(n.scroll,n.scrollBehavior,"top");return}I.warn("handleNavigate: G7Core.updateQueryParams not available, falling back to React Router")}const l=this.resolveNavigateFallbackAction(i,n);if(l){I.warn(`handleNavigate: No route matched, falling back to "${l.handler}"`),await this.dispatchAction({type:"click",handler:l.handler,params:l.params},r),this.applyScrollOption(n.scroll,n.scrollBehavior,"top");return}if(!r.navigate)throw new It("Navigate function is not provided in context");r.navigate(i,{replace:n.replace===!0}),this.applyScrollOption(n.scroll,n.scrollBehavior,"top")}resolveNavigateFallbackAction(e,n){const r=n.fallback;if(r===!1||n.replace===!0)return null;const l=window.__templateApp?.getRouter?.();if(!l||typeof l.match!="function"||typeof l.getRoutes=="function"&&l.getRoutes().length===0)return null;const c=e.split("?")[0];return l.match(c)?null:this.resolveNavigateFallback(r,e,n)}resolveNavigateFallback(e,n,r){return e==null?{handler:"openWindow",params:{path:n,target:"_self"}}:typeof e=="string"?{handler:e,params:{path:n}}:typeof e=="object"&&typeof e.handler=="string"?{handler:e.handler,params:{path:n,...e.params||{}}}:(I.warn("resolveNavigateFallback: unrecognized fallback option, using openWindow",e),{handler:"openWindow",params:{path:n,target:"_blank"}})}applyScrollOption(e,n,r){const i=e===void 0?r:e;if(i==="preserve")return;const l=n==="smooth"?"smooth":"instant",c=y=>{if(typeof y!="object"||y===null)return!1;const v=y;return"container"in v||"to"in v||"block"in v||"offset"in v},d=(y,v,S=0)=>{y===window?window.scrollTo({top:v,left:S,behavior:l}):y.scrollTo({top:v,left:S,behavior:l})},f=(y,v,S,_)=>{if(v===window){y.scrollIntoView({behavior:l,block:S}),_&&window.scrollBy({top:-_,left:0,behavior:l});return}const x=v,A=y.getBoundingClientRect(),D=x.getBoundingClientRect(),O=x.scrollTop+(A.top-D.top);let k;S==="center"?k=O-(x.clientHeight-y.clientHeight)/2:S==="end"?k=O-(x.clientHeight-y.clientHeight):k=O,k-=_,x.scrollTo({top:Math.max(0,k),left:0,behavior:l})},h=()=>{window.scrollTo({top:0,left:0,behavior:l});const y=document.getElementById("app")??document.body;if(!y)return;y.querySelectorAll("*").forEach(S=>{if(S.scrollTop===0&&S.scrollLeft===0)return;const _=window.getComputedStyle(S),x=_.overflowY,A=_.overflowX;(x==="auto"||x==="scroll"||A==="auto"||A==="scroll")&&S.scrollTo({top:0,left:0,behavior:l})})},m=()=>{try{if(c(i)){const y=i,v=y.block??"start",S=typeof y.offset=="number"?y.offset:0;let _=window;if(typeof y.container=="string"&&y.container.length>0){const A=document.querySelector(y.container);if(!A){I.warn(`applyScrollOption: container not found: ${y.container}`);return}_=A}const x=y.to??"top";if(x==="top"){_===window?h():d(_,0);return}if(typeof x=="number"){d(_,x-S);return}if(typeof x=="object"&&x!==null&&("x"in x||"y"in x)){const{x:A=0,y:D=0}=x;d(_,D-S,A);return}if(typeof x=="string"&&(x.startsWith("#")||x.startsWith("."))){const A=document.querySelector(x);A?f(A,_,v,S):I.warn(`applyScrollOption: target element not found: ${x}`);return}I.warn('applyScrollOption: invalid "to" value in extended form',x);return}if(i==="top"){h();return}if(typeof i=="number"){window.scrollTo({top:i,left:0,behavior:l});return}if(typeof i=="object"&&i!==null&&("x"in i||"y"in i)){const{x:y=0,y:v=0}=i;window.scrollTo({top:v,left:y,behavior:l});return}if(typeof i=="string"&&(i.startsWith("#")||i.startsWith("."))){const y=document.querySelector(i);y&&y.scrollIntoView({behavior:l,block:"start"});return}}catch(y){I.warn("applyScrollOption: failed to apply scroll",y)}};typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(m):m()}async handleOpenWindow(e,n){let r=e;if(n.query){const l=new URLSearchParams;for(const[d,f]of Object.entries(n.query))f!=null&&f!==""&&l.set(d,String(f));const c=l.toString();c&&(r=`${e}?${c}`)}const i=n.target==="_self"?"_self":"_blank";I.log("handleOpenWindow:",{target:e,params:n,finalPath:r,windowTarget:i}),i==="_self"?window.location.assign(r):window.open(r,"_blank")}async handleNavigateBack(){I.log("handleNavigateBack"),window.history.back()}async handleNavigateForward(){I.log("handleNavigateForward"),window.history.forward()}async handleReplaceUrl(e,n){let r=e;if(n.query||n.mergeQuery===!0)if(n.mergeQuery===!0)r=this.buildMergedQueryPath(e,n.query??{});else{const i=new URLSearchParams;for(const[c,d]of Object.entries(n.query))if(d!=null&&d!=="")if(Array.isArray(d)){const f=c.endsWith("[]")?c:`${c}[]`;for(const h of d)h!=null&&h!==""&&i.append(f,String(h))}else i.set(c,String(d));const l=i.toString();l&&(r=`${e}?${l}`)}I.log("handleReplaceUrl:",{target:e,params:n,finalPath:r}),window.history.replaceState(null,"",r),this.applyScrollOption(n.scroll,n.scrollBehavior,"preserve")}buildMergedQueryPath(e,n){const r=new URLSearchParams(window.location.search);for(const[c,d]of Object.entries(n))if(d==null||d==="")r.delete(c);else if(Array.isArray(d)){const f=c.endsWith("[]")?c:`${c}[]`;r.delete(c),r.delete(f);for(const h of d)h!=null&&h!==""&&r.append(f,String(h))}else r.set(c,String(d));const i=r.toString(),l=e.split("?")[0];return i?`${l}?${i}`:l}async ensureCsrfToken(){try{await fetch("/sanctum/csrf-cookie",{credentials:"include"})}catch(e){throw new It("Failed to fetch CSRF token",void 0,e instanceof Error?e:void 0)}}getCsrfTokenFromCookie(){const r=`; ${document.cookie}`.split("; XSRF-TOKEN=");if(r.length===2){const i=r.pop()?.split(";").shift();return i?decodeURIComponent(i):null}return null}buildQueryString(e){const n=new URLSearchParams;for(const[r,i]of Object.entries(e))if(!(i==null||i===""))if(Array.isArray(i))for(const l of i)l!=null&&l!==""&&n.append(`${r}[]`,String(l));else typeof i=="object"?n.append(r,JSON.stringify(i)):n.append(r,String(i));return n.toString()}async handleEnsureIdentityVerified(e){const n=typeof e.purpose=="string"?e.purpose:"sensitive_action",r=e.target&&typeof e.target=="object"?e.target:void 0;return await At.handle({success:!1,error_code:"identity_verification_required",message:"",verification:{policy_key:e.policy_key??"",purpose:n,provider_id:e.provider_id??null,render_hint:e.render_hint??null,return_request:null}},void 0,r)!==null}handleResolveIdentityChallenge(e){const n=typeof e.result=="string"?e.result:"cancelled";let r;switch(n){case"verified":{const i=typeof e.token=="string"?e.token:"";if(!i){I.warn("resolveIdentityChallenge: result=verified 인데 token 이 비어있습니다. failed 로 강등합니다."),r={status:"failed",failureCode:"MISSING_TOKEN"};break}r={status:"verified",token:i,providerData:e.providerData&&typeof e.providerData=="object"?e.providerData:void 0};break}case"pending":{const i=typeof e.pollUrl=="string"?e.pollUrl:"",l=typeof e.expiresAt=="string"?e.expiresAt:"";if(!i||!l){I.warn("resolveIdentityChallenge: result=pending 인데 pollUrl/expiresAt 누락 — failed 로 강등합니다."),r={status:"failed",failureCode:"MALFORMED_PENDING"};break}r={status:"pending",pollUrl:i,pollIntervalMs:typeof e.pollIntervalMs=="number"?e.pollIntervalMs:void 0,expiresAt:l};break}case"failed":r={status:"failed",failureCode:typeof e.failureCode=="string"?e.failureCode:"UNKNOWN",reason:typeof e.reason=="string"?e.reason:void 0};break;case"cancelled":default:r={status:"cancelled"};break}return At.resolveDeferred(r),!0}async handleApiCall(e,n,r,i="none",l){const{method:c="GET",body:d,headers:f,contentType:h}=n;c!=="GET"&&c!=="HEAD"&&await this.ensureCsrfToken();const m=this.getCsrfTokenFromCookie();let y={};if(i==="required"||i==="optional"){const W=Yn().getToken();W&&(y={Authorization:`Bearer ${W}`})}let v=e;const S=n.query||(c==="GET"?d:null);if(S&&typeof S=="object"){const z=this.buildQueryString(S);if(z){const W=e.includes("?")?"&":"?";v=`${e}${W}${z}`}}const _=window.G7Core?.state?.getGlobal?.()||r.state?._global||{},x=window.G7Core?.state?.getLocal?.()||r.state?._local||{},A={_global:_,_local:x},D=this.getMatchingGlobalHeaders(e,A),O={};if(typeof window<"u"){const z=localStorage.getItem("g7_locale");z&&(O["Accept-Language"]=z)}const k=h==="multipart/form-data",L={method:c,headers:{...k?{}:{"Content-Type":"application/json"},Accept:"application/json",...O,...m&&{"X-XSRF-TOKEN":m},...y,...D,...f},credentials:"include"};if(d&&c!=="GET")if(k){const z=new FormData;for(const[W,de]of Object.entries(d))de instanceof File||de instanceof Blob?z.append(W,de):de!=null&&z.append(W,typeof de=="object"?JSON.stringify(de):String(de));L.body=z}else L.body=JSON.stringify(d);const B=Jn();let q=null;B?.isEnabled()&&(q=B.trackRequest(v,c));try{let z=await fetch(v,L),W;try{W=await z.json()}catch{W=null}if(At.isIdentityRequired(z.status,W)){const de=await At.handle(W,{body:L.body,headers:L.headers,credentials:L.credentials},l);if(de){z=de;try{W=await z.json()}catch{W=null}}}if(q&&B?.isEnabled()&&(B.completeRequest(q,z.status,W),q=null),!z.ok){const de=W||{},_e=new Error(de.message||`API call failed: ${z.statusText}`);throw _e.response=de,_e.status=z.status,_e.statusText=z.statusText,new It(de.message||`API call failed: ${z.statusText}`,void 0,_e)}return W}catch(z){throw q&&B?.isEnabled()&&B.failRequest(q,z instanceof Error?z.message:String(z)),z}}async handleLogin(e,n,r){const{body:i}=n;if(!i||!i.email||!i.password)throw new It("Login requires email and password in body params");const l=this.resolveAuthType(e),c=l==="admin"?"/api/auth/admin/login":"/api/auth/login",d=Xn.getInstance();try{const f=await d.login(l,{email:i.email,password:i.password},this.buildAuthRequestOptions(c,r));return f.status==="two_factor_required"?{user:null,two_factor_required:!0,challenge_id:f.challenge.challengeId,provider_id:f.challenge.providerId,expires_at:f.challenge.expiresAt}:{user:f.user,two_factor_required:!1}}catch(f){throw this.toLoginActionError(f,"Login failed")}}async handleLoginTwoFactor(e,n,r){const{body:i}=n;if(!i||!i.challenge_id||!i.code)throw new It("loginTwoFactor requires challenge_id and code in body params");const l=this.resolveAuthType(e),c=l==="admin"?"/api/auth/admin/login/two-factor":"/api/auth/login/two-factor";try{return{user:await Xn.getInstance().completeTwoFactor(l,{challengeId:String(i.challenge_id),code:String(i.code)},this.buildAuthRequestOptions(c,r))}}catch(d){throw this.toLoginActionError(d,"Login failed")}}async handleLoginTwoFactorResend(e,n,r){const{body:i}=n;if(!i||!i.challenge_id)throw new It("loginTwoFactorResend requires challenge_id in body params");const l=this.resolveAuthType(e),c=l==="admin"?"/api/auth/admin/login/two-factor/resend":"/api/auth/login/two-factor/resend";try{const d=await Xn.getInstance().resendTwoFactor(l,{challengeId:String(i.challenge_id)},this.buildAuthRequestOptions(c,r));return{two_factor_required:!0,challenge_id:d.challengeId,provider_id:d.providerId,expires_at:d.expiresAt}}catch(d){throw this.toLoginActionError(d,"Resend failed")}}resolveAuthType(e){return e==="user"?"user":"admin"}buildAuthRequestOptions(e,n){const r=window.G7Core?.state?.getGlobal?.()||n.state?._global||{},i=window.G7Core?.state?.getLocal?.()||n.state?._local||{},l={_global:r,_local:i},c=this.getMatchingGlobalHeaders(e,l);return Object.keys(c).length>0?{headers:c}:void 0}toLoginActionError(e,n){const r=e?.message||n,i=new Error(r);return i.response=e?.response?.data||{},i.status=e?.status||e?.response?.status||500,i.code=e?.code,new It(r,void 0,i)}async handleLogout(e,n){await Xn.getInstance().logout()}async handleSetState(e,n){I.log("[handleSetState] START, params:",e);const{target:r="component",scope:i,merge:l,__render:c,...d}=e,f=Jn(),h=window.G7Core;if(typeof r=="string"&&(r.startsWith("$parent.")||r.startsWith("$root.")))return this.handleParentScopeSetState(r,d,l,n);const m=n.state&&Object.keys(n.state).length>0?n.state:h?.state?.get()||{},y=r==="global"?"_global":r.startsWith("_local.")?r:"_local",v=y==="_global"?m._global:y.startsWith("_local.")?this.getNestedProperty(m._local||{},y.slice(7)):m._local,S=f?.isEnabled()?f.startStateChange(y,v,d,{actionId:n.actionId,handlerType:"setState",source:`target=${r}`}):void 0,_=l==="replace"?"replace":l==="shallow"?"shallow":"deep",x=_!=="deep"?{...d,__mergeMode:_,...S?{__setStateId:S}:{}}:{...d,...S?{__setStateId:S}:{}};if(r==="global"){if(!this.globalStateUpdater){I.warn("Global state updater is not set"),S&&f&&f.completeStateChange(S);return}const A=h?.state?.get()||{},{__setStateId:D,__mergeMode:O,...k}=x,L=_==="deep"?this.deepMergeWithState(k,A):k,B={...L,...S?{__setStateId:S}:{},..._!=="deep"?{__mergeMode:_}:{}};return I.log("setState global:",B),this.globalStateUpdater(B,{render:c}),S&&f&&setTimeout(()=>f.completeStateChange(S),0),{__target:"global",..._!=="deep"?{__mergeMode:_}:{},...L}}else if(r==="isolated"){const A=n.isolatedContext;if(A){const{__mergeMode:D,__setStateId:O,...k}=x;return A.mergeState(k,_),I.log("[handleSetState] isolated state updated:",k,"mergeMode:",_),S&&f&&setTimeout(()=>f.completeStateChange(S),0),{__target:"isolated",...k}}else if(I.warn('[handleSetState] isolated target used but no IsolatedStateContext found. Make sure the component has "isolatedState" attribute. Falling back to local state.'),n.setState){const O=window.__g7PendingLocalState||n.state||{},k=_==="deep"?this.deepMergeWithState(x,O):x;return this.writeLocalState(n,k),S&&f&&setTimeout(()=>f.completeStateChange(S),0),k}else throw S&&f&&f.completeStateChange(S),new It("isolated target used but no IsolatedStateContext found and no setState function in context")}else if(r==="local"||r==="component"||r==="_local"){if(i==="parent"||i==="root"){const D=window.__g7LayoutContextStack||[];if(D.length>0){const O=i==="parent"?D[D.length-1]:D[0];if(O?.setState){const{__mergeMode:k,__setStateId:L,...B}=x,q=_==="deep"?this.deepMergeWithState(B,O.state||{}):B;return I.log(`[handleSetState] scope=${i}: 타겟 컨텍스트에 상태 업데이트`,q),O.setState(q),S&&f&&setTimeout(()=>f.completeStateChange(S),0),q}}I.warn(`[handleSetState] scope=${i}: 레이아웃 컨텍스트 스택이 비어있습니다. current로 폴백합니다.`)}const A=n.setState&&!n._isDispatchFallbackContext;if(I.log("[handleSetState] isRealComponentContext:",A,"context.setState:",!!n.setState,"_isDispatchFallbackContext:",n._isDispatchFallbackContext),A){I.log("[handleSetState] Using COMPONENT setState path"),I.log("[handleSetState] resolvedPayload:",x),I.log("[handleSetState] context.state:",n.state),I.log("[handleSetState] mergeMode:",_);const O=window.__g7PendingLocalState||n.state||{},k=_==="deep"?this.deepMergeWithState(x,{}):x;I.log("[handleSetState] convertedPayload (변경 필드만, dot notation 변환):",k),n.setState(k);const L=_==="deep"?this.deepMergeWithState(x,O):_==="shallow"?{...n.state||{},...x}:x,{__mergeMode:B,__setStateId:q,...z}=L;window.__g7PendingLocalState=z,I.log("[handleSetState] __g7PendingLocalState updated:",z);const W=(window.__g7LayoutContextStack||[]).length;let de;if(this.globalStateUpdater){const ze=W===0?window.__templateApp?.getGlobalState?.()?._local:void 0;if(_!=="replace"&&!!ze&&typeof ze=="object"&&!Array.isArray(ze)){const ue=_==="deep"?this.deepMergeWithState(x,ze):{...ze,...x},{__mergeMode:De,__setStateId:ee,...me}=ue;de=me}else _!=="replace"&&I.log("[handleSetState] canonical _local 미사용 → 전체 스냅샷 폴백",{modalDepth:W,hasTemplateApp:!!window.__templateApp});const Q=de?Mo(de,z):z;this.globalStateUpdater({_local:Q},{render:!1}),I.log("[handleSetState] _global._local synced (render:false):",Q)}const{__mergeMode:_e,__setStateId:Se,...je}=x;if(_==="replace")window.__g7ForcedLocalFields=je;else{const ze=window.__g7ForcedLocalFields||{};window.__g7ForcedLocalFields=this.deepMergeWithState(je,ze)}return I.log("[handleSetState] __g7ForcedLocalFields updated:",je),S&&f&&setTimeout(()=>f.completeStateChange(S),0),{__target:"local",...de?Mo(de,z):L,..._!=="deep"?{__mergeMode:_}:{}}}else if(this.globalStateUpdater){I.log("[handleSetState] Using GLOBAL STATE UPDATER path for _local");const O=window.__g7PendingLocalState||m._local||{};I.log("[handleSetState] currentLocal (with pending):",O);const k=_==="deep"?this.deepMergeWithState(x,O):x;return I.log("[handleSetState] finalLocal (merged):",k),this.globalStateUpdater({_local:k},{render:c}),window.__g7PendingLocalState=k,I.log("[handleSetState] __g7PendingLocalState updated for globalStateUpdater path"),S&&f&&setTimeout(()=>f.completeStateChange(S),0),{__target:"local",...k}}else throw S&&f&&f.completeStateChange(S),new It("setState function is not provided in context and globalStateUpdater is not set")}else if(r.startsWith("_local.")){const A=r.slice(7),{__mergeMode:D,__setStateId:O,...k}=x,L=k.value!==void 0?k.value:Object.values(k)[0];if(n.setState){const q=window.__g7PendingLocalState||n.state||{},z=this.createNestedUpdate(A,L,q),W={...q,...z};if(n.setState(z),this.globalStateUpdater&&i!=="parent"&&i!=="root"){const de=window.__templateApp?.getGlobalState?.()?._local,_e=de&&typeof de=="object"?{...de,...z}:W;this.globalStateUpdater({_local:_e},{render:!1}),I.log("[handleSetState] _global._local synced for dot notation (render:false):",_e)}return S&&f&&setTimeout(()=>f.completeStateChange(S),0),W}else throw S&&f&&f.completeStateChange(S),new It("setState function is not provided in context")}else{if(!n.setState)throw S&&f&&f.completeStateChange(S),new It("setState function is not provided in context");const D=window.__g7PendingLocalState||n.state||{},O=_==="deep"?this.deepMergeWithState(x,D):x;return this.writeLocalState(n,O,void 0,{scope:i}),S&&f&&setTimeout(()=>f.completeStateChange(S),0),O}}async handleParentScopeSetState(e,n,r,i){const l=Jn(),c=window.G7Core,d=r==="replace"?"replace":r==="shallow"?"shallow":"deep",f=e.startsWith("$parent."),h=f?"$parent.":"$root.",m=e.slice(h.length);let y,v;if(m==="_local"||m==="_global")y=m,v=void 0;else if(m.startsWith("_local."))y="_local",v=m.slice(7);else if(m.startsWith("_global."))y="_global",v=m.slice(8);else{I.warn(`[handleParentScopeSetState] 지원하지 않는 타겟 형식: ${e}. _local 또는 _global으로 시작해야 합니다.`);return}const S=window.__g7LayoutContextStack||[];if(S.length===0){I.warn(`[handleParentScopeSetState] 레이아웃 컨텍스트 스택이 비어있습니다. target=${e}`);return}const _=f?S[S.length-1]:S[0];if(!_){I.warn(`[handleParentScopeSetState] 타겟 컨텍스트를 찾을 수 없습니다. target=${e}`);return}const x=y==="_global"?_.state?._global:_.state?._local,A=l?.isEnabled()?l.startStateChange(e,x,n,{actionId:i.actionId,handlerType:"setState",source:`target=${e}`}):void 0,{__mergeMode:D,__setStateId:O,...k}=n;if(y==="_global"){if(!this.globalStateUpdater){I.warn("[handleParentScopeSetState] globalStateUpdater가 설정되지 않았습니다."),A&&l&&l.completeStateChange(A);return}const L=c?.state?.get()||{};if(v){const B=k.value!==void 0?k.value:Object.values(k)[0],q=this.createNestedUpdate(v,B,L),z={...L,...q};I.log(`[handleParentScopeSetState] ${e}: 전역 상태 중첩 경로 업데이트`,z),this.globalStateUpdater(z)}else{const B=d==="deep"?this.deepMergeWithState(k,L):k;I.log(`[handleParentScopeSetState] ${e}: 전역 상태 업데이트 (mergeMode=${d})`,B),this.globalStateUpdater(d!=="deep"?{...B,__mergeMode:d}:B)}return A&&l&&setTimeout(()=>l.completeStateChange(A),0),{__target:e,...k}}else{if(!_.setState){I.warn(`[handleParentScopeSetState] 타겟 컨텍스트에 setState가 없습니다. target=${e}`),A&&l&&l.completeStateChange(A);return}const L=_.state||{};if(v){const B=k.value!==void 0?k.value:Object.values(k)[0],q=this.createNestedUpdate(v,B,L),z={...L,...q};return I.log(`[handleParentScopeSetState] ${e}: 로컬 상태 중첩 경로 업데이트`,q),_.setState(q),_.state=z,_.dataContext&&(_.dataContext._local=z),Df(),A&&l&&setTimeout(()=>l.completeStateChange(A),0),z}else{const B=d!=="deep"?{...k,__mergeMode:d}:k,q=d==="replace"?k:d==="shallow"?{...L,...k}:this.deepMergeWithState(k,L);return I.log(`[handleParentScopeSetState] ${e}: 로컬 상태 업데이트 (mergeMode=${d})`,q),_.setState(B),_.state=q,_.dataContext&&(_.dataContext._local=q),Df(),A&&l&&setTimeout(()=>l.completeStateChange(A),0),q}}}deepMergeWithState(e,n){const r=["errors"];let i=e;if("..."in e){const c=e["..."];if(c&&typeof c=="object"&&!Array.isArray(c)){const{"...":d,...f}=e;i={...c,...f}}else{const{"...":d,...f}=e;i=f}}const l={...n};for(const[c,d]of Object.entries(i)){if(r.includes(c)){l[c]=d;continue}if(c.includes(".")&&c!=="..."){const f=this.createNestedUpdate(c,d,l);this.deepMergeInto(l,f,l);continue}if(d!==null&&typeof d=="object"&&!Array.isArray(d)&&Object.getPrototypeOf(d)!==Object.prototype&&Object.getPrototypeOf(d)!==null){l[c]=d;continue}d!==null&&typeof d=="object"&&!Array.isArray(d)&&n[c]!==null&&typeof n[c]=="object"&&!Array.isArray(n[c])?l[c]=this.deepMergeWithState(d,n[c]):l[c]=d}return l}deepMergeInto(e,n,r){for(const[i,l]of Object.entries(n)){if(l===null){e[i]=l;continue}if(e[i]===null){e[i]=l;continue}typeof l=="object"&&!Array.isArray(l)&&e[i]!==void 0&&e[i]!==null&&typeof e[i]=="object"&&!Array.isArray(e[i])?(e[i]===r[i]&&(e[i]={...e[i]}),this.deepMergeInto(e[i],l,r[i]||{})):typeof l=="object"&&!Array.isArray(l)&&e[i]===void 0&&r[i]!==null&&typeof r[i]=="object"&&!Array.isArray(r[i])?e[i]={...r[i],...l}:e[i]=l}}createNestedUpdate(e,n,r){const i=e.split(".");if(i.length===1)return{[i[0]]:n};const l={};let c=l,d=r;for(let f=0;f{this.globalStateUpdater({_local:S})};m.push({state:y,setState:v,dataContext:{_local:y||n.data?._local,_global:l?n.data?._global:n.data?._global||i?.state?.get?.(),_computed:n.data?._computed}}),window.__g7LayoutContextStack=m,I.log(`[handleOpenModal] 레이아웃 컨텍스트 스택에 push, 스택 크기: ${m.length}, state:`,y,l?"(direct)":"(fallback via G7Core)")}else I.warn(`[handleOpenModal] 컨텍스트 스택에 push 실패 - setState: ${!!n.setState}, state: ${n.state!==void 0}, G7Core: ${!!i?.state?.getLocal}`);const f=[...r,e];this.globalStateUpdater({modalStack:f,activeModal:e});const h=Jn();if(h?.isEnabled()){const m=r.length>0?r[r.length-1]:void 0;h.trackModalOpen?.({modalId:e,modalName:e,scopeType:"isolated",parentModalId:m,initialState:n.state?{...n.state}:{}})}}async handleCloseModal(e){if(!this.globalStateUpdater){I.warn("Global state updater is not set for closeModal");return}const n=e?.data?._global?.modalStack||[],r=n.length>0?n[n.length-1]:null,i=n.slice(0,-1),l=i.length>0?i[i.length-1]:null,c=window.__g7LayoutContextStack||[];if(c.length>0){const d=c[c.length-1];d&&(d.dataContext=void 0),c.pop(),window.__g7LayoutContextStack=c,I.log(`[handleCloseModal] 레이아웃 컨텍스트 스택에서 pop, 스택 크기: ${c.length}`)}if(r){const d=Jn();d?.isEnabled()&&d.trackModalClose?.(r,e?.state)}this.globalStateUpdater({modalStack:i,activeModal:l})}async handleShowAlert(e,n){let r=e;this.translationEngine&&this.translationContext&&e.startsWith("$t:")&&(r=this.translationEngine.resolveTranslations(e,this.translationContext,n.data)),alert(r)}async handleToast(e,n){const{type:r="info",message:i,icon:l,duration:c}=e;if(r==="error"){const f=n.data?.error;if((f?.error_code==="identity_verification_required"||f?.data?.error_code==="identity_verification_required")&&At.consumeDomainNoticeShown()){I.log("[Toast] IDV 도메인 안내 표출됨 — 중복 가드 토스트 1건 skip");return}}let d=i;if(this.translationEngine&&this.translationContext&&i?.startsWith("$t:")&&(d=this.translationEngine.resolveTranslations(i,this.translationContext,n.data)),this.globalStateUpdater){const h={id:`toast_${Date.now()}_${Math.random().toString(36).substring(2,9)}`,type:r,message:d,...l&&{icon:l},...c&&{duration:c}},S=[...window.G7Core?.state?.get()?.toasts||[],h];this.globalStateUpdater({toasts:S})}else I.log(`[Toast ${r}] ${d}`)}async handleSwitch(e,n){const{cases:r}=e;if(!r){I.warn("switch handler requires cases property");return}const i=this.resolveParams(e.params,n.data);let l;if(i?.value!==void 0?(l=i.value,I.log("switch handler: using params.value as case key:",l)):(l=n.data?.$args?.[0],I.log("switch handler: using $args[0] as case key:",l)),l==null){if(r.default)return I.log("switch handler: case key is undefined, using default case"),await this.executeAction(r.default,n);I.warn("switch handler: case key is not defined and no default case");return}const c=String(l);let d=r[c];if(!d&&r.default&&(I.log(`switch handler: no case found for key "${c}", using default case`),d=r.default),!d){I.warn(`switch handler: no case found for key "${c}" and no default case`);return}return await this.executeAction(d,n)}async handleConditions(e,n){const{conditions:r}=e;if(!r||!Array.isArray(r)){I.warn("conditions handler requires conditions array");return}const i=n.data||{},l=um(r,i,this.bindingEngine);if(!l.matched){I.log("conditions handler: no matching branch found");return}const c=r[l.branchIndex];if(I.log(`conditions handler: matched branch ${l.branchIndex}`),!c.then){I.warn('conditions handler: matched branch has no "then" action');return}return Array.isArray(c.then)?await this.handleSequence({...e,actions:c.then},n):await this.executeAction(c.then,n)}handleStartInterval(e,n){const r=typeof e.id=="string"?e.id:"",i=Number(e.intervalMs??1e3),l=Array.isArray(e.actions)?e.actions:[];if(r===""||!l.length||i<=0)return I.warn("startInterval requires non-empty id, positive intervalMs, and actions array"),{success:!1};const c=this.intervals.get(r);c&&(clearInterval(c),this.intervals.delete(r));const d=setInterval(()=>{for(const f of l)this.executeAction(f,n).catch(h=>{I.error(`[startInterval:${r}] tick action failed`,h)})},i);return this.intervals.set(r,d),{success:!0,id:r}}handleStopInterval(e){const n=typeof e.id=="string"?e.id:"";if(n==="")return I.warn("stopInterval requires id parameter"),{success:!1};const r=this.intervals.get(n);return r&&(clearInterval(r),this.intervals.delete(n)),{success:!0,id:n}}stopAllIntervals(){for(const e of this.intervals.values())clearInterval(e);this.intervals.clear()}async handleSequence(e,n){const r=e.actions||e.params?.actions;if(!r||!Array.isArray(r)||r.length===0)return I.warn("sequence handler requires non-empty actions array"),[];const i=Jn(),l=i?.isEnabled()&&i.startSequenceExecution?.({eventType:e.type})||"";window.__g7SequenceLocalSync=void 0;const c=[];let d,f=n.state?{...n.state}:{},h=n.isolatedContext?.state?{...n.isolatedContext.state}:{},m=n.data?._computed||{};const y=window.G7Core,v=()=>({_global:y?.state?.get()||{},_local:{...f},_isolated:Object.keys(h).length>0?{...h}:void 0});for(let S=0;S0){const k={},L={...n.data,_local:f,_computed:k,$computed:k,_isolated:h};for(const[B,q]of Object.entries(O))if(typeof q=="string"){const z=q.trim();if(z.startsWith("{{")&&z.endsWith("}}"))try{const W=z.slice(2,-2).trim();k[B]=jn(W)?this.bindingEngine.evaluatePipeExpression(W,L,{skipCache:!0}):this.bindingEngine.evaluateExpression(W,L,{skipCache:!0})}catch{k[B]=m[B]}}m=k,I.log("[handleSequence] _computed recalculated after setState:",m)}}if(_.handler!=="setState"){const O=window.__g7SequenceLocalSync;if(O&&O!==f){f=O,window.__g7SequenceLocalSync=void 0,I.log("[handleSequence] currentState synchronized from __g7SequenceLocalSync after custom handler:",_.handler);const k=n.data?._computedDefinitions;if(k&&Object.keys(k).length>0){const L={},B={...n.data,_local:f,_computed:L,$computed:L,_isolated:h};for(const[q,z]of Object.entries(k))if(typeof z=="string"){const W=z.trim();if(W.startsWith("{{")&&W.endsWith("}}"))try{const de=W.slice(2,-2).trim();L[q]=jn(de)?this.bindingEngine.evaluatePipeExpression(de,B,{skipCache:!0}):this.bindingEngine.evaluateExpression(de,B,{skipCache:!0})}catch{L[q]=m[q]}}m=L,I.log("[handleSequence] _computed recalculated after custom handler:",m)}}}l&&i?.isEnabled()&&i.captureSequenceActionAfter?.(l,S,v(),Date.now()-x,D.data)}catch(D){throw l&&i?.isEnabled()&&(i.captureSequenceActionAfter?.(l,S,v(),Date.now()-x,void 0,D),i.endSequenceExecution?.(l,D)),I.error(`sequence handler: action[${S}] failed:`,D),D}}return window.__g7SequenceLocalSync=void 0,l&&i?.isEnabled()&&i.endSequenceExecution?.(l),c}async handleParallel(e,n){const r=e.actions||e.params?.actions;if(!r||!Array.isArray(r)||r.length===0)return I.warn("parallel handler requires non-empty actions array"),[];I.log(`parallel handler: executing ${r.length} actions in parallel`);const i=n.isolatedContext?{...n.isolatedContext,state:{...n.isolatedContext.state}}:null,l=r.map((f,h)=>{const m={...n,isolatedContext:i};return this.executeAction(f,m).catch(y=>{throw I.error(`parallel handler: action[${h}] failed:`,y),y})}),c=await Promise.allSettled(l),d=c.filter(f=>f.status==="rejected").length;return d>0&&I.warn(`parallel handler: ${d}/${r.length} actions failed`),c}assertAllowedExtensionAssetUrl(e,n,r){if(!Io(e,bs()))throw I.error(`Blocked untrusted ${n} asset url: ${e}`),new It(`Blocked untrusted ${n} url (same-origin path or declared trusted host required): ${e}`,r)}async handleLoadScript(e,n,r){const{src:i,id:l,async:c=!0,defer:d=!1}=e;if(!i)throw new It('loadScript handler requires "src" parameter',n);if(!Io(i,bs()))throw I.warn(`loadScript: blocked untrusted script src (same-origin path or declared trusted host required): ${i}`),new It(`Blocked untrusted script src (same-origin path or declared trusted host required): ${i}`,n);const f=l||`script_${i.replace(/[^a-zA-Z0-9]/g,"_")}`;if(cn.loadedScripts.has(f))return I.log(`loadScript: script already loaded, skipping: ${f}`),n.onLoad&&await this.executeAction(n.onLoad,r),!0;const h=cn.loadingScripts.get(f);if(h)return I.log(`loadScript: joining in-flight load: ${f}`),await h,n.onLoad&&await this.executeAction(n.onLoad,r),!0;if(document.getElementById(f))return I.log(`loadScript: script element already exists: ${f}`),cn.loadedScripts.add(f),n.onLoad&&await this.executeAction(n.onLoad,r),!0;I.log(`loadScript: loading script: ${i}`);const y=document.createElement("script");if(y.id=f,y.src=i,y.async=c,y.defer=d,y.hasAttribute("data-gdpr-blocked-src"))return I.warn(`loadScript: script blocked by consent manager (not loaded): ${i}`),!1;const v=new Promise((S,_)=>{y.onload=()=>{I.log(`loadScript: script loaded successfully: ${f}`),cn.loadedScripts.add(f),cn.loadingScripts.delete(f),S()},y.onerror=x=>{I.error(`loadScript: failed to load script: ${i}`,x),cn.loadingScripts.delete(f),_(new It(`Failed to load script: ${i}`,n))},document.head.appendChild(y)});if(v.catch(()=>{}),cn.loadingScripts.set(f,v),await v,n.onLoad)try{await this.executeAction(n.onLoad,r)}catch(S){I.error("loadScript: onLoad action failed:",S)}return!0}async handleCallExternal(e,n,r){const i=e.constructor,l=e.args||{},c=e.method,d=e.methodArgs||[],f=e.callbackEvent,h=e.embedTarget,m=e.callbackSetState,y=e.callbackAction;if(!i)throw new It('callExternal handler requires "constructor" parameter',n);const v=this.getNestedProperty(window,i);if(!v||typeof v!="function")throw new It(`Constructor not found or not a function: ${i}. Make sure the script is loaded first using loadScript handler.`,n);this.assertCallableExternalConstructor(v,i,n),I.log(`callExternal: calling constructor ${i}`);const S={...l};for(const[x,A]of Object.entries(l))A===!0&&(S[x]=D=>{if(I.log(`callExternal: callback triggered for ${x}`,D),f&&typeof window<"u"&&window.G7Core?.componentEvent&&window.G7Core.componentEvent.emit(f,D),m&&r.setState){const O=B=>{const q={};for(const[z,W]of Object.entries(B)){if(cn.isPrototypePathSegment(z)){I.warn(`callExternal: skipped prototype-polluting mapping key: ${z}`);continue}typeof W=="string"?q[z]=this.getNestedProperty(D,W):typeof W=="object"&&W!==null&&(q[z]=O(W))}return q},k=O(m);I.log("callExternal: callbackSetState mapping result",k);const L=this.deepMergeWithState(k,r.state||{});I.log("callExternal: merged with existing state",L),this.writeLocalState(r,L)}else f&&r.setState&&this.writeLocalState(r,{[`${f.replace(/:/g,"_")}_result`]:D});if(y){const O={...r,data:{...r.data,$event:D}},k=Array.isArray(y)?y:[y];for(const L of k)try{this.executeAction(L,O)}catch(B){I.error("callExternal: callbackAction failed:",B)}}});const _=new v(S);if(c&&typeof _[c]=="function"){if(I.log(`callExternal: calling method ${c}`),c==="embed"&&h){const x=document.querySelector(h);if(x)return _[c](x,...d);throw new It(`Embed target element not found: ${h}`,n)}return _[c](...d)}return _}async handleCallExternalEmbed(e,n,r){const i=e.constructor,l=e.args||{},c=e.callbackSetState,d=e.callbackEvent,f=e.layerClassName,h=e.callbackAction;if(!i)throw new It('callExternalEmbed handler requires "constructor" parameter',n);const m=this.getNestedProperty(window,i);if(!m||typeof m!="function")throw new It(`Constructor not found or not a function: ${i}. Make sure the script is loaded first.`,n);this.assertCallableExternalConstructor(m,i,n),I.log(`callExternalEmbed: creating layer for ${i}`);const{layer:y,closeLayer:v}=this.createEmbedLayer(f),S={...l};for(const[x,A]of Object.entries(l))A===!0&&(S[x]=D=>{if(I.log(`callExternalEmbed: callback triggered for ${x}`,D),v(),d&&typeof window<"u"&&window.G7Core?.componentEvent&&window.G7Core.componentEvent.emit(d,D),c&&r.setState){const O=B=>{const q={};for(const[z,W]of Object.entries(B)){if(cn.isPrototypePathSegment(z)){I.warn(`callExternal: skipped prototype-polluting mapping key: ${z}`);continue}typeof W=="string"?q[z]=this.getNestedProperty(D,W):typeof W=="object"&&W!==null&&(q[z]=O(W))}return q},k=O(c);I.log("callExternalEmbed: callbackSetState mapping result",k);const L=this.deepMergeWithState(k,r.state||{});I.log("callExternalEmbed: merged with existing state",L),this.writeLocalState(r,L)}if(h){const O={...r,data:{...r.data,$event:D}},k=Array.isArray(h)?h:[h];for(const L of k)try{this.executeAction(L,O)}catch(B){I.error("callExternalEmbed: callbackAction failed:",B)}}});const _=new m(S);if(typeof _.embed=="function")_.embed(y),I.log("callExternalEmbed: embedded in layer");else throw v(),new It(`Constructor ${i} does not have embed method`,n);return _}isImeComposing(e){return e?.isComposing===!0||e?.keyCode===229}createEmbedLayer(e){const n=document.createElement("div");n.id="g7-embed-overlay",n.style.cssText=` position: fixed; inset: 0; background-color: rgba(0, 0, 0, 0.5); @@ -87,11 +90,11 @@ Error generating stack: `+u.message+` justify-content: center; color: #666; transition: background-color 0.2s; - `,i.onmouseenter=()=>{i.style.backgroundColor="rgba(0, 0, 0, 0.2)"},i.onmouseleave=()=>{i.style.backgroundColor="rgba(0, 0, 0, 0.1)"};const l=()=>{n.parentNode&&n.parentNode.removeChild(n)};i.onclick=l;const c=d=>{this.isImeComposing(d)||d.key==="Escape"&&(l(),document.removeEventListener("keydown",c))};return document.addEventListener("keydown",c),n.onclick=d=>{d.target===n&&l()},r.appendChild(i),n.appendChild(r),document.body.appendChild(n),{overlay:n,layer:r,closeLayer:l}}static isPrototypePathSegment(e){return rn.PROTOTYPE_PATH_SEGMENTS.includes(e)}getNestedProperty(e,n){return n.split(".").reduce((r,i)=>{if(!rn.isPrototypePathSegment(i))return r&&r[i]!==void 0?r[i]:void 0},e)}assertCallableExternalConstructor(e,n,r){if(typeof window>"u")return;if([window.Function,window.eval,window.setTimeout,window.setInterval].some(l=>l!==void 0&&l===e))throw N.error(`callExternal: blocked arbitrary code execution seam: ${n}`),new Tt(`Blocked constructor (arbitrary code execution): ${n}`,r)}async handleSaveToLocalStorage(e,n){const{key:r,value:i}=e;if(!r)return N.error("saveToLocalStorage: key parameter is required"),!1;try{const l=typeof i=="string"?i:JSON.stringify(i);return localStorage.setItem(r,l),N.log(`saveToLocalStorage: saved ${r}`,i),!0}catch(l){return N.error("saveToLocalStorage: failed to save",{key:r,error:l}),!1}}async handleLoadFromLocalStorage(e,n){const{key:r,target:i,stateKey:l,defaultValue:c}=e;if(!r)return N.error("loadFromLocalStorage: key parameter is required"),c;try{const d=localStorage.getItem(r);if(d===null)return N.log(`loadFromLocalStorage: no value found for ${r}, using default`),l&&n.setState&&this.writeLocalState(n,{[l]:c}),c;let f;try{f=JSON.parse(d)}catch{f=d}return N.log(`loadFromLocalStorage: loaded ${r}`,f),l&&n.setState&&this.writeLocalState(n,{[l]:f}),f}catch(d){return N.error("loadFromLocalStorage: failed to load",{key:r,error:d}),c}}writeLocalState(e,n,r,i){const l=r||e.setState;if(!l)return;if(typeof n=="function"){N.warn("[writeLocalState] 함수형 업데이터는 저장소 B 미러 대상이 아닙니다 (payload 추출 불가). 저장소 A 만 갱신합니다."),l(n);return}if(i?.scope==="parent"||i?.scope==="root"){l(n);return}if(this.localMirrorDepth>0||l?.__g7CanonicalWriter){l(n);return}const c=n&&typeof n=="object"?n:{},d=c.__mergeMode;if(d==="replace"){l(n);return}const{__mergeMode:f,__setStateId:p,...m}=c;if("errors"in m||!rn.isMirrorSafePayload(m)){l(n);return}const y=window;if((y.__g7LayoutContextStack||[]).length>0){l(n);return}const C=y.G7Core?.state?.setLocal;if(!y.__templateApp||typeof C!="function"){l(n);return}const S=this.deepMergeWithState(m,{});this.localMirrorDepth++;try{C(S,{render:!1,merge:d??"deep"}),y.__g7ActionContext?.setState!==l&&l(n),d&&(y.__g7ForcedLocalFields={...y.__g7ForcedLocalFields||{},...S})}finally{this.localMirrorDepth--}}static isMirrorSafePayload(e,n=0){if(e===null||typeof e!="object"||n>=8)return!0;if(Array.isArray(e))return e.every(i=>rn.isMirrorSafePayload(i,n+1));const r=Object.getPrototypeOf(e);return r!==Object.prototype&&r!==null?!1:Object.values(e).every(i=>rn.isMirrorSafePayload(i,n+1))}makeLocalSetStateProxy(e){const n=e.setState;if(!n)return;if(n.__g7CanonicalWriter)return n;const r=i=>{this.writeLocalState(e,i,n)};return r.__g7CanonicalWriter=!0,r}async handleCustomAction(e,n){const r=this.customHandlers.get(e.handler);if(!r){if(this.previewMode){N.warn(`[Preview] Unknown action handler "${e.handler}" — skipped (preview mode)`);return}const c=new Tt(`Unknown action handler: ${e.handler}`,e);throw c.unknownHandler=!0,c}const i=this.makeLocalSetStateProxy(n),l=i&&i!==n.setState?{...n,setState:i}:n;return await r(e,l)}resolveParams(e,n){if(!e)return{};const r={};for(const[i,l]of Object.entries(e))i.includes("{{")&&N.warn(`[resolveParams] setState params의 키에 표현식이 포함되어 있습니다: "${i}". 키는 해석되지 않습니다. 배열 항목 수정은 .map()/.filter() 패턴을 사용하세요.`),typeof l=="string"&&l.includes("{{")?r[i]=this.evaluateExpression(l,n):typeof l=="string"?r[i]=l:Array.isArray(l)?r[i]=l.map(c=>typeof c=="string"&&c.includes("{{")?this.evaluateExpression(c,n):c):typeof l=="object"&&l!==null&&!Array.isArray(l)&&Object.getPrototypeOf(l)!==Object.prototype&&Object.getPrototypeOf(l)!==null?r[i]=l:typeof l=="object"&&l!==null?r[i]=this.resolveParams(l,n):r[i]=l;return r}resolveValue(e,n){return n?this.bindingEngine.resolveBindings(e,n,{skipCache:!0}):e}evaluateExpressions(e,n){let r={};for(const[i,l]of Object.entries(e))if(i==="..."){let c=l;typeof l=="string"&&l.includes("{{")&&(c=this.evaluateExpression(l,n)),c&&typeof c=="object"&&!Array.isArray(c)&&(r={...r,...c})}else typeof l=="string"&&l.includes("{{")?r[i]=this.evaluateExpression(l,n):typeof l=="object"&&l!==null&&!Array.isArray(l)?r[i]=this.evaluateExpressions(l,n):r[i]=l;return r}evaluateExpressionsIfNeeded(e,n){const r={};for(const[i,l]of Object.entries(e))typeof l=="string"&&l.includes("{{")?r[i]=this.evaluateExpression(l,n):r[i]=l;return r}evaluateExpression(e,n){if(!n)return e;const r=Ma(e);if(r===null){let c=n;if(e.includes("_global")){const f=window.G7Core?.state?.get()?._global;f&&(c={...n,_global:f})}if(e.includes("_computed")||e.includes("$computed")){const f=window.__g7ActionContext?.computedRef?.current;f&&Object.keys(f).length>0&&(c={...c,_computed:f,$computed:f})}return this.bindingEngine.resolveBindings(e,c,{skipCache:!0})}let i=r;i=i.replace(/\$args\.(\d+)/g,"$args[$1]");let l=n;if(i.includes("_global")){const d=window.G7Core?.state?.get()?._global;d&&(l={...n,_global:d})}if(i.includes("_computed")||i.includes("$computed")){const d=window.__g7ActionContext?.computedRef?.current;d&&Object.keys(d).length>0&&(l={...l,_computed:d,$computed:d})}i.includes("_global.modules")&&(N.log("[evaluateExpression] expression:",i),N.log("[evaluateExpression] dataContext._global:",l._global),N.log("[evaluateExpression] dataContext._global?.modules:",l._global?.modules));try{const c=On(i)?this.bindingEngine.evaluatePipeExpression(i,l,{skipCache:!0}):this.bindingEngine.evaluateExpression(i,l);return i.includes("_global.modules")&&N.log("[evaluateExpression] result:",c),typeof c=="string"&&c.startsWith("$t:")&&this.translationEngine&&this.translationContext?this.translationEngine.resolveTranslations(c,this.translationContext,n):c}catch(c){return N.error("Expression evaluation failed:",e,c),e}}setDefaultContext(e){this.defaultContext={...this.defaultContext,...e}}setGlobalStateUpdater(e){this.globalStateUpdater=e}getGlobalStateUpdater(){return this.globalStateUpdater}async dispatchAction(e,n){const r={...this.defaultContext,...n,data:{...this.defaultContext.data,...n?.data}};if(e.confirm){let i=this.resolveValue(e.confirm,r.data);if(this.translationEngine&&this.translationContext&&i.startsWith("$t:")&&(i=this.translationEngine.resolveTranslations(i,this.translationContext,r.data)),!confirm(i))return{success:!1}}try{return await this.executeAction(e,r)}catch(i){if(N.error("dispatchAction failed:",i),e.onError){const l=i instanceof Tt&&i.originalError?{message:i.originalError.message,response:i.originalError.response}:{message:i instanceof Error?i.message:String(i)},c={...r,data:{...r.data,error:l}},d=Array.isArray(e.onError)?e.onError:[e.onError];for(const f of d)await this.executeAction(f,c)}return{success:!1,error:i instanceof Error?i:new Error(String(i))}}}registerHandler(e,n,r){this.customHandlers.set(e,n);const i=Xn();i?.isEnabled()&&i.trackHandlerRegistration(e,r?.category??"custom",r?.description,r?.source)}unregisterHandler(e){this.customHandlers.delete(e);const n=Xn();n?.isEnabled()&&n.trackHandlerUnregistration(e)}getRegisteredHandlers(){return Array.from(this.customHandlers.keys())}getHandler(e){return this.customHandlers.get(e)}normalizeDebounceConfig(e){return typeof e=="number"?{delay:e,leading:!1,trailing:!0}:{delay:e.delay,leading:e.leading??!1,trailing:e.trailing??!0}}extractEventData(e){const n=e.target;if(n&&!("tagName"in n)){const l={type:e.type??"custom",target:{value:n.value,name:n.name??""}};return e._changedKeys&&(l._changedKeys=e._changedKeys),l}const i=n?{value:n.value,name:n.name??"",checked:n.checked??!1,type:n.type??"",tagName:n.tagName}:{};if(e.type==="scroll"&&n){const l=n;i.scrollHeight=l.scrollHeight??0,i.scrollTop=l.scrollTop??0,i.clientHeight=l.clientHeight??0,i.scrollLeft=l.scrollLeft??0,i.clientWidth=l.clientWidth??0,i.scrollWidth=l.scrollWidth??0}return{type:e.type,target:n?i:null}}executeDebouncedAction(e,n,r,i,l){const c={...r,$event:n,$args:l},d={type:n.type,target:n.target,preventDefault:()=>{},stopPropagation:()=>{}};this.createHandler(e,c,i)(d)}handleDebouncedAction(e,n,r,i,l,c){const d=this.normalizeDebounceConfig(e.debounce),f=l||`default-${e.handler}-${Date.now()}`,p=this.extractEventData(n),m=p._changedKeys;if(m&&Array.isArray(m)&&p?.target?.value&&typeof p.target.value=="object"&&!Array.isArray(p.target.value)){const v=this.debounceAccumulatedValues.get(f);if(v){const x={...v};for(const w of m)x[w]=p.target.value[w];p.target.value=x}this.debounceAccumulatedValues.set(f,p.target.value)}const y=this.debounceTimers.get(f);y&&(clearTimeout(y),this.debounceTimers.delete(f));const C=Xn();C?.isEnabled()&&C.trackAction({handler:typeof e.handler=="string"?e.handler:String(e.handler),type:e.type,status:"pending",params:e.params,debounce:{delay:d.delay,status:"pending",scheduledAt:Date.now()}});const S=!this.debounceTimers.has(f+"_leading");if(d.leading&&S&&(this.debounceTimers.set(f+"_leading",setTimeout(()=>{},0)),this.executeDebouncedAction(e,p,r,i,c),C?.isEnabled()&&C.trackAction({handler:typeof e.handler=="string"?e.handler:String(e.handler),type:e.type,status:"success",params:e.params,debounce:{delay:d.delay,status:"executed",executedAt:Date.now(),mode:"leading"}})),d.trailing){const v=()=>{this.executeDebouncedAction(e,p,r,i,c),C?.isEnabled()&&C.trackAction({handler:typeof e.handler=="string"?e.handler:String(e.handler),type:e.type,status:"success",params:e.params,debounce:{delay:d.delay,status:"executed",executedAt:Date.now(),mode:"trailing"}})},x=setTimeout(()=>{this.debounceTimers.delete(f),this.debounceTimers.delete(f+"_leading"),this.pendingDebounceFlushers.delete(f),this.debounceAccumulatedValues.delete(f),v()},d.delay);this.debounceTimers.set(f,x),this.pendingDebounceFlushers.set(f,v)}}clearDebounceTimers(e){if(e)for(const[n,r]of this.debounceTimers)n.startsWith(e+"-")&&(clearTimeout(r),this.debounceTimers.delete(n),this.pendingDebounceFlushers.delete(n),this.debounceAccumulatedValues.delete(n));else{for(const n of this.debounceTimers.values())clearTimeout(n);this.debounceTimers.clear(),this.pendingDebounceFlushers.clear(),this.debounceAccumulatedValues.clear()}}debouncedCall(e,n,r){const i=this.debounceTimers.get(e);i&&(clearTimeout(i),this.debounceTimers.delete(e));const l=setTimeout(()=>{this.debounceTimers.delete(e),this.pendingDebounceFlushers.delete(e),r()},n);this.debounceTimers.set(e,l),this.pendingDebounceFlushers.set(e,r)}flushPendingDebounceTimers(){if(this.pendingDebounceFlushers.size===0)return;const e=new Map(this.pendingDebounceFlushers);for(const[n,r]of e){const i=this.debounceTimers.get(n);i&&(clearTimeout(i),this.debounceTimers.delete(n)),this.debounceTimers.delete(n+"_leading"),this.pendingDebounceFlushers.delete(n),r()}this.globalStateUpdater&&this.globalStateUpdater({})}bindActionsToProps(e,n,r){const i={...e};if(e.actions&&Array.isArray(e.actions)){const l=new Map;for(const m of e.actions){const y=this.resolveActionRef(m),C=y.event?this.normalizeEventPropName(y.event):this.getEventHandlerName(y.type);l.has(C)||l.set(C,[]),l.get(C).push(y)}const c=e.name||e.id||"unknown",d=l.has("onDrop"),f=l.has("onDragOver"),p=l.has("onDragEnter");d&&!f&&(i.onDragOver=m=>{m.preventDefault()}),d&&!p&&(i.onDragEnter=m=>{m.preventDefault()});for(const[m,y]of l)i[m]=(...C)=>{for(const S of y){const v=C[0],x=v&&typeof v=="object"&&"preventDefault"in v;if(x&&(m==="onDragOver"||m==="onDrop")&&v.preventDefault(),x&&S.key&&"key"in v){if(this.isImeComposing(v)){N.log("Key filter skipped (IME composing):",S.key);continue}if(v.key!==S.key){N.log("Key filter not matched:",S.key,"actual:",v.key);continue}N.log("Key filter matched:",S.key)}if(S.debounce){const w=`${c}-${S.handler}-${m}`,R=v&&typeof v=="object"&&!("preventDefault"in v)&&"target"in v&&v.target!==null;let L;if(x)L=v;else if(R){const j={type:"custom",target:v.target,preventDefault:()=>{},stopPropagation:()=>{}};v._changedKeys&&(j._changedKeys=v._changedKeys),L=j}else L=new Event("custom");const O=S.event?{...n,$args:C}:n;this.handleDebouncedAction(S,L,O,r,w,C)}else if(this.flushPendingDebounceTimers(),S.event){const w={...n,$args:C},R=this.resolveEventForHandler(v,x);this.createHandler(S,w,r)(R)}else if(x)this.createHandler(S,n,r)(v);else if(v&&typeof v=="object"&&!("preventDefault"in v)&&"target"in v&&v.target!==null){const R={type:"custom",target:v.target,preventDefault:()=>{},stopPropagation:()=>{}};this.createHandler(S,n,r)(R)}}}}return i}getEventHandlerName(e){return Km[e]||`on${e.charAt(0).toUpperCase()}${e.slice(1)}`}normalizeEventPropName(e){return Km[e]??e}resolveEventForHandler(e,n){if(n)return e;if(!(e&&typeof e=="object"&&!("preventDefault"in e)&&"target"in e&&e.target!==null))return new Event("custom");const i={type:"custom",target:e.target,preventDefault:()=>{},stopPropagation:()=>{}};return e._changedKeys&&(i._changedKeys=e._changedKeys),i}sanitizeForDevTools(e,n=5){const r=new WeakSet,i=(l,c)=>{if(l==null||typeof l=="string"||typeof l=="number"||typeof l=="boolean")return l;if(c>n)return"[Max Depth Exceeded]";if(typeof l=="function")return`[Function: ${l.name||"anonymous"}]`;if(l instanceof Element)return`[Element: ${l.tagName}${l.className?"."+l.className.split(" ").join("."):""}]`;if(l instanceof Event)return`[Event: ${l.type}]`;if(Array.isArray(l)){if(r.has(l))return"[Circular Array]";r.add(l);const d=l.slice(0,10).map(f=>i(f,c+1));return l.length>10&&d.push(`... ${l.length-10} more items`),d}if(typeof l=="object"){if(r.has(l))return"[Circular Reference]";r.add(l);const d={},f=Object.keys(l),p=f.slice(0,20);for(const m of p)try{d[m]=i(l[m],c+1)}catch{d[m]="[Error accessing property]"}return f.length>20&&(d["..."]=`${f.length-20} more properties`),d}return String(l)};return i(e,0)}};$(rn,"loadedScripts",new Set),$(rn,"loadingScripts",new Map),$(rn,"PROTOTYPE_PATH_SEGMENTS",["__proto__","prototype","constructor"]);let Lo=rn,xc=null;function Wm(s){return xc||(xc=new Lo(s)),xc}function QC(s){xc=s}const Ym=dt("TransitionManager");class ZC{constructor(){$(this,"isPending",!1);$(this,"subscribers",new Set)}setPending(e){this.isPending!==e&&(Ym.log("setPending:",{from:this.isPending,to:e,stack:new Error().stack}),this.isPending=e,this.notifySubscribers())}getIsPending(){return this.isPending}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}notifySubscribers(){Ym.log("notifySubscribers:",{isPending:this.isPending,subscriberCount:this.subscribers.size}),this.subscribers.forEach(e=>{e(this.isPending)})}clearSubscribers(){this.subscribers.clear()}}const Gr=new ZC,Tc=dt("TransitionContext"),Xm=M.createContext({isTransitioning:!1}),Sf=({children:s})=>{const[e,n]=M.useState(()=>{const i=Gr.getIsPending();return Tc.log("Initial state:",i),i});M.useEffect(()=>{Tc.log("Subscribing to TransitionManager");const i=Gr.subscribe(l=>{Tc.log("Received isPending update:",l),n(l)});return()=>{Tc.log("Unsubscribing from TransitionManager"),i()}},[]);const r=M.useMemo(()=>({isTransitioning:e}),[e]);return ft.jsx(Xm.Provider,{value:r,children:s})},Jm=()=>M.useContext(Xm),kc="__g7LocalInitTracking";function wf(){const s=globalThis;return s[kc]||(s[kc]={hash:"",timestamp:void 0,consumed:void 0}),s[kc]}function eE(){const s=globalThis;s[kc]={hash:"",timestamp:void 0,consumed:void 0}}function tE(s){wf().consumed=s}function nE(s){return wf().consumed===s}function rE(s){return s.globalTrackedKey!==s.trackingKey?"apply":s.instanceHandledKey===s.trackingKey?"skip":"prune"}function aE(s,e){return typeof s=="number"&&typeof e=="number"?Math.max(s,e):e??s}function iE(s,e){if(e===void 0)return s;if(!(s!==null&&typeof s=="object"&&e!==null&&typeof e=="object"&&!nE(s)))return e;const{_forceLocalInit:r,...i}=s,{_forceLocalInit:l,...c}=e,d={...i,...c},f=aE(r,l);return f!==void 0&&(d._forceLocalInit=f),d}function sE(s){return s<768?"mobile":s<1024?"tablet":"desktop"}function Qm(s){const e=sE(s);return{width:s,isMobile:e==="mobile",isTablet:e==="tablet",isDesktop:e==="desktop",matchedPreset:e}}const Cf=M.createContext(Qm(1024)),Rc=({children:s,overrideWidth:e})=>{const[n,r]=M.useState(()=>_i.getWidth());M.useEffect(()=>{const c=_i.subscribe(d=>{r(d)});return()=>{c()}},[]);const i=e??n,l=M.useMemo(()=>Qm(i),[i]);return ft.jsx(Cf.Provider,{value:l,children:s})},Ef=()=>M.useContext(Cf);window.G7Core?.createLogger?.("Core:State");function oE(s,e,n,r){const{syncOnControlledChange:i=!0,isEqual:l}=r??{},c=s!==void 0;M.useRef(c);const[d,f]=M.useState(s!==void 0?s:e),p=d,m=M.useRef(s),y=M.useRef(!1);M.useEffect(()=>{if(y.current){m.current=s;return}i&&c&&s!==m.current&&(l?!l(d,s):d!==s)&&f(s),m.current=s},[s,c,i,l,d]);const C=M.useCallback(S=>{const v=typeof S=="function"?S(p):S;(l?l(p,v):p===v)||(y.current=!0,f(v),n?.(v),requestAnimationFrame(()=>{y.current=!1}))},[p,c,n,l]);return[p,C]}function lE(s,e){return s===e?!0:s.length!==e.length?!1:s.every((n,r)=>n===e[r])}function Zm(s,e){if(s===e)return!0;const n=Object.keys(s),r=Object.keys(e);return n.length!==r.length?!1:n.every(i=>s[i]===e[i])}const ey=M.createContext({}),cE=({children:s,value:e})=>ft.jsx(ey.Provider,{value:e,children:s}),uE=()=>M.useContext(ey),dE=(s,e)=>{if(!s)return;const n=e.split(".");let r=s;for(const i of n){if(r==null)return;r=r[i]}return r},ty=(s,e,n)=>{const r=e.split(".");if(r.length===1)return{...s,[r[0]]:n};const i={...s};let l=i;for(let c=0;c{hs.warn("IsolatedStateContext not available: setState called outside IsolatedStateProvider")},getState:()=>{},mergeState:()=>{hs.warn("IsolatedStateContext not available: mergeState called outside IsolatedStateProvider")},stateRef:{current:{}},scopeId:""},ny=M.createContext(fE);let hE=0;function pE(){return`isolated-${++hE}-${Date.now().toString(36)}`}function ry(s,e){if(e==null)return s;if(typeof e!="object"||Array.isArray(e))return e;const n={...s};for(const r of Object.keys(e)){const i=e[r],l=s?.[r];i!==null&&typeof i=="object"&&!Array.isArray(i)&&l!==null&&typeof l=="object"&&!Array.isArray(l)?n[r]=ry(l,i):n[r]=i}return n}function gE(s,e){return e?e.split(".").reduce((n,r)=>n?.[r],s):s}function mE(s,e,n){const r=e.split("."),i={...s};let l=i;for(let c=0;c{const i=M.useRef(e||pE()).current,[l,c]=M.useState(s),d=M.useRef(l);d.current=l;const f=M.useCallback(S=>gE(d.current,S),[]),p=M.useCallback((S,v)=>{c(x=>{const w=mE(x,S,v);return hs.log(`[${i}] setState: ${S} =`,v),w})},[i]),m=M.useCallback((S,v="deep")=>{c(x=>{let w;return v==="replace"?w=S:v==="shallow"?w={...x,...S}:w=ry(x,S),hs.log(`[${i}] mergeState (${v}):`,S),w})},[i]),y=M.useMemo(()=>({state:l,setState:p,getState:f,mergeState:m,stateRef:d,scopeId:i}),[l,p,f,m,i]),C=M.useMemo(()=>({state:d.current,setState:p,getState:f,mergeState:m}),[p,f,m]);return M.useEffect(()=>{const S=window.G7Core,v=window.__g7IsolatedStates||{};return window.__g7IsolatedStates||(window.__g7IsolatedStates=v),v[i]=C,S&&(S._isolatedStates||(S._isolatedStates={}),S._isolatedStates[i]=l),S?.devTools?.isEnabled?.()&&S.devTools.emit?.("isolated:created",{id:i,state:l}),hs.log(`[${i}] IsolatedStateProvider mounted with initial state:`,l),()=>{delete v[i],S?._isolatedStates&&delete S._isolatedStates[i],S?.devTools?.isEnabled?.()&&S.devTools.emit?.("isolated:destroyed",{id:i}),hs.log(`[${i}] IsolatedStateProvider unmounted`)}},[i,C]),M.useEffect(()=>{const S=window.G7Core,v=window.__g7IsolatedStates;v?.[i]&&(v[i].state=l),S?._isolatedStates&&(S._isolatedStates[i]=l),S?.devTools?.isEnabled?.()&&S.devTools.emit?.("isolated:updated",{id:i,state:l})},[l,i]),ft.jsx(ny.Provider,{value:y,children:n})},bE=()=>{const s=M.useContext(ny);return s.scopeId?s:null};var za=wg();function vE(){for(var s=arguments.length,e=new Array(s),n=0;nr=>{e.forEach(i=>i(r))},e)}const Dc=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ps(s){const e=Object.prototype.toString.call(s);return e==="[object Window]"||e==="[object global]"}function _f(s){return"nodeType"in s}function Mn(s){var e,n;return s?ps(s)?s:_f(s)&&(e=(n=s.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function Af(s){const{Document:e}=Mn(s);return s instanceof e}function $o(s){return ps(s)?!1:s instanceof Mn(s).HTMLElement}function ay(s){return s instanceof Mn(s).SVGElement}function gs(s){return s?ps(s)?s.document:_f(s)?Af(s)?s:$o(s)||ay(s)?s.ownerDocument:document:document:document}const Fr=Dc?M.useLayoutEffect:M.useEffect;function xf(s){const e=M.useRef(s);return Fr(()=>{e.current=s}),M.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i{s.current=setInterval(r,i)},[]),n=M.useCallback(()=>{s.current!==null&&(clearInterval(s.current),s.current=null)},[]);return[e,n]}function Mo(s,e){e===void 0&&(e=[s]);const n=M.useRef(s);return Fr(()=>{n.current!==s&&(n.current=s)},e),n}function No(s,e){const n=M.useRef();return M.useMemo(()=>{const r=s(n.current);return n.current=r,r},[...e])}function Oc(s){const e=xf(s),n=M.useRef(null),r=M.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function Tf(s){const e=M.useRef();return M.useEffect(()=>{e.current=s},[s]),e.current}let kf={};function Io(s,e){return M.useMemo(()=>{if(e)return e;const n=kf[s]==null?0:kf[s]+1;return kf[s]=n,s+"-"+n},[s,e])}function iy(s){return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i{const d=Object.entries(c);for(const[f,p]of d){const m=l[f];m!=null&&(l[f]=m+s*p)}return l},{...e})}}const ms=iy(1),jo=iy(-1);function wE(s){return"clientX"in s&&"clientY"in s}function Rf(s){if(!s)return!1;const{KeyboardEvent:e}=Mn(s.target);return e&&s instanceof e}function CE(s){if(!s)return!1;const{TouchEvent:e}=Mn(s.target);return e&&s instanceof e}function Df(s){if(CE(s)){if(s.touches&&s.touches.length){const{clientX:e,clientY:n}=s.touches[0];return{x:e,y:n}}else if(s.changedTouches&&s.changedTouches.length){const{clientX:e,clientY:n}=s.changedTouches[0];return{x:e,y:n}}}return wE(s)?{x:s.clientX,y:s.clientY}:null}const zo=Object.freeze({Translate:{toString(s){if(!s)return;const{x:e,y:n}=s;return"translate3d("+(e?Math.round(e):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(s){if(!s)return;const{scaleX:e,scaleY:n}=s;return"scaleX("+e+") scaleY("+n+")"}},Transform:{toString(s){if(s)return[zo.Translate.toString(s),zo.Scale.toString(s)].join(" ")}},Transition:{toString(s){let{property:e,duration:n,easing:r}=s;return e+" "+n+"ms "+r}}}),sy="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function EE(s){return s.matches(sy)?s:s.querySelector(sy)}const _E={display:"none"};function AE(s){let{id:e,value:n}=s;return We.createElement("div",{id:e,style:_E},n)}function xE(s){let{id:e,announcement:n,ariaLiveType:r="assertive"}=s;const i={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return We.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function TE(){const[s,e]=M.useState("");return{announce:M.useCallback(r=>{r!=null&&e(r)},[]),announcement:s}}const oy=M.createContext(null);function kE(s){const e=M.useContext(oy);M.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of ");return e(s)},[s,e])}function RE(){const[s]=M.useState(()=>new Set),e=M.useCallback(r=>(s.add(r),()=>s.delete(r)),[s]);return[M.useCallback(r=>{let{type:i,event:l}=r;s.forEach(c=>{var d;return(d=c[i])==null?void 0:d.call(c,l)})},[s]),e]}const DE={draggable:` + `,i.onmouseenter=()=>{i.style.backgroundColor="rgba(0, 0, 0, 0.2)"},i.onmouseleave=()=>{i.style.backgroundColor="rgba(0, 0, 0, 0.1)"};const l=()=>{n.parentNode&&n.parentNode.removeChild(n)};i.onclick=l;const c=d=>{this.isImeComposing(d)||d.key==="Escape"&&(l(),document.removeEventListener("keydown",c))};return document.addEventListener("keydown",c),n.onclick=d=>{d.target===n&&l()},r.appendChild(i),n.appendChild(r),document.body.appendChild(n),{overlay:n,layer:r,closeLayer:l}}static isPrototypePathSegment(e){return cn.PROTOTYPE_PATH_SEGMENTS.includes(e)}getNestedProperty(e,n){return n.split(".").reduce((r,i)=>{if(!cn.isPrototypePathSegment(i))return r&&r[i]!==void 0?r[i]:void 0},e)}assertCallableExternalConstructor(e,n,r){if(typeof window>"u")return;if([window.Function,window.eval,window.setTimeout,window.setInterval].some(l=>l!==void 0&&l===e))throw I.error(`callExternal: blocked arbitrary code execution seam: ${n}`),new It(`Blocked constructor (arbitrary code execution): ${n}`,r)}async handleSaveToLocalStorage(e,n){const{key:r,value:i}=e;if(!r)return I.error("saveToLocalStorage: key parameter is required"),!1;try{const l=typeof i=="string"?i:JSON.stringify(i);return localStorage.setItem(r,l),I.log(`saveToLocalStorage: saved ${r}`,i),!0}catch(l){return I.error("saveToLocalStorage: failed to save",{key:r,error:l}),!1}}async handleLoadFromLocalStorage(e,n){const{key:r,target:i,stateKey:l,defaultValue:c}=e;if(!r)return I.error("loadFromLocalStorage: key parameter is required"),c;try{const d=localStorage.getItem(r);if(d===null)return I.log(`loadFromLocalStorage: no value found for ${r}, using default`),l&&n.setState&&this.writeLocalState(n,{[l]:c}),c;let f;try{f=JSON.parse(d)}catch{f=d}return I.log(`loadFromLocalStorage: loaded ${r}`,f),l&&n.setState&&this.writeLocalState(n,{[l]:f}),f}catch(d){return I.error("loadFromLocalStorage: failed to load",{key:r,error:d}),c}}writeLocalState(e,n,r,i){const l=r||e.setState;if(!l)return;if(typeof n=="function"){I.warn("[writeLocalState] 함수형 업데이터는 저장소 B 미러 대상이 아닙니다 (payload 추출 불가). 저장소 A 만 갱신합니다."),l(n);return}if(i?.scope==="parent"||i?.scope==="root"){l(n);return}if(this.localMirrorDepth>0||l?.__g7CanonicalWriter){l(n);return}const c=n&&typeof n=="object"?n:{},d=c.__mergeMode;if(d==="replace"){l(n);return}const{__mergeMode:f,__setStateId:h,...m}=c;if("errors"in m||!cn.isMirrorSafePayload(m)){l(n);return}const y=window;if((y.__g7LayoutContextStack||[]).length>0){l(n);return}const v=y.G7Core?.state?.setLocal;if(!y.__templateApp||typeof v!="function"){l(n);return}const S=this.deepMergeWithState(m,{});this.localMirrorDepth++;try{v(S,{render:!1,merge:d??"deep"}),y.__g7ActionContext?.setState!==l&&l(n),d&&(y.__g7ForcedLocalFields={...y.__g7ForcedLocalFields||{},...S})}finally{this.localMirrorDepth--}}static isMirrorSafePayload(e,n=0){if(e===null||typeof e!="object"||n>=8)return!0;if(Array.isArray(e))return e.every(i=>cn.isMirrorSafePayload(i,n+1));const r=Object.getPrototypeOf(e);return r!==Object.prototype&&r!==null?!1:Object.values(e).every(i=>cn.isMirrorSafePayload(i,n+1))}makeLocalSetStateProxy(e){const n=e.setState;if(!n)return;if(n.__g7CanonicalWriter)return n;const r=i=>{this.writeLocalState(e,i,n)};return r.__g7CanonicalWriter=!0,r}async handleCustomAction(e,n){const r=this.customHandlers.get(e.handler);if(!r){if(this.previewMode){I.warn(`[Preview] Unknown action handler "${e.handler}" — skipped (preview mode)`);return}const c=new It(`Unknown action handler: ${e.handler}`,e);throw c.unknownHandler=!0,c}const i=this.makeLocalSetStateProxy(n),l=i&&i!==n.setState?{...n,setState:i}:n;return await r(e,l)}resolveParams(e,n){if(!e)return{};const r={};for(const[i,l]of Object.entries(e))i.includes("{{")&&I.warn(`[resolveParams] setState params의 키에 표현식이 포함되어 있습니다: "${i}". 키는 해석되지 않습니다. 배열 항목 수정은 .map()/.filter() 패턴을 사용하세요.`),typeof l=="string"&&l.includes("{{")?r[i]=this.evaluateExpression(l,n):typeof l=="string"?r[i]=l:Array.isArray(l)?r[i]=l.map(c=>typeof c=="string"&&c.includes("{{")?this.evaluateExpression(c,n):c):typeof l=="object"&&l!==null&&!Array.isArray(l)&&Object.getPrototypeOf(l)!==Object.prototype&&Object.getPrototypeOf(l)!==null?r[i]=l:typeof l=="object"&&l!==null?r[i]=this.resolveParams(l,n):r[i]=l;return r}resolveValue(e,n){return n?this.bindingEngine.resolveBindings(e,n,{skipCache:!0}):e}evaluateExpressions(e,n){let r={};for(const[i,l]of Object.entries(e))if(i==="..."){let c=l;typeof l=="string"&&l.includes("{{")&&(c=this.evaluateExpression(l,n)),c&&typeof c=="object"&&!Array.isArray(c)&&(r={...r,...c})}else typeof l=="string"&&l.includes("{{")?r[i]=this.evaluateExpression(l,n):typeof l=="object"&&l!==null&&!Array.isArray(l)?r[i]=this.evaluateExpressions(l,n):r[i]=l;return r}evaluateExpressionsIfNeeded(e,n){const r={};for(const[i,l]of Object.entries(e))typeof l=="string"&&l.includes("{{")?r[i]=this.evaluateExpression(l,n):r[i]=l;return r}evaluateExpression(e,n){if(!n)return e;const r=Oa(e);if(r===null){let c=n;if(e.includes("_global")){const f=window.G7Core?.state?.get()?._global;f&&(c={...n,_global:f})}if(e.includes("_computed")||e.includes("$computed")){const f=window.__g7ActionContext?.computedRef?.current;f&&Object.keys(f).length>0&&(c={...c,_computed:f,$computed:f})}return this.bindingEngine.resolveBindings(e,c,{skipCache:!0})}let i=r;i=i.replace(/\$args\.(\d+)/g,"$args[$1]");let l=n;if(i.includes("_global")){const d=window.G7Core?.state?.get()?._global;d&&(l={...n,_global:d})}if(i.includes("_computed")||i.includes("$computed")){const d=window.__g7ActionContext?.computedRef?.current;d&&Object.keys(d).length>0&&(l={...l,_computed:d,$computed:d})}i.includes("_global.modules")&&(I.log("[evaluateExpression] expression:",i),I.log("[evaluateExpression] dataContext._global:",l._global),I.log("[evaluateExpression] dataContext._global?.modules:",l._global?.modules));try{const c=jn(i)?this.bindingEngine.evaluatePipeExpression(i,l,{skipCache:!0}):this.bindingEngine.evaluateExpression(i,l);return i.includes("_global.modules")&&I.log("[evaluateExpression] result:",c),typeof c=="string"&&c.startsWith("$t:")&&this.translationEngine&&this.translationContext?this.translationEngine.resolveTranslations(c,this.translationContext,n):c}catch(c){return I.error("Expression evaluation failed:",e,c),e}}setDefaultContext(e){this.defaultContext={...this.defaultContext,...e}}setGlobalStateUpdater(e){this.globalStateUpdater=e}getGlobalStateUpdater(){return this.globalStateUpdater}async dispatchAction(e,n){const r={...this.defaultContext,...n,data:{...this.defaultContext.data,...n?.data}};if(e.confirm){let i=this.resolveValue(e.confirm,r.data);if(this.translationEngine&&this.translationContext&&i.startsWith("$t:")&&(i=this.translationEngine.resolveTranslations(i,this.translationContext,r.data)),!confirm(i))return{success:!1}}try{return await this.executeAction(e,r)}catch(i){if(I.error("dispatchAction failed:",i),e.onError){const l=i instanceof It&&i.originalError?{message:i.originalError.message,response:i.originalError.response}:{message:i instanceof Error?i.message:String(i)},c={...r,data:{...r.data,error:l}},d=Array.isArray(e.onError)?e.onError:[e.onError];for(const f of d)await this.executeAction(f,c)}return{success:!1,error:i instanceof Error?i:new Error(String(i))}}}registerHandler(e,n,r){this.customHandlers.set(e,n);const i=Jn();i?.isEnabled()&&i.trackHandlerRegistration(e,r?.category??"custom",r?.description,r?.source)}unregisterHandler(e){this.customHandlers.delete(e);const n=Jn();n?.isEnabled()&&n.trackHandlerUnregistration(e)}getRegisteredHandlers(){return Array.from(this.customHandlers.keys())}getHandler(e){return this.customHandlers.get(e)}normalizeDebounceConfig(e){return typeof e=="number"?{delay:e,leading:!1,trailing:!0}:{delay:e.delay,leading:e.leading??!1,trailing:e.trailing??!0}}extractEventData(e){const n=e.target;if(n&&!("tagName"in n)){const l={type:e.type??"custom",target:{value:n.value,name:n.name??""}};return e._changedKeys&&(l._changedKeys=e._changedKeys),l}const i=n?{value:n.value,name:n.name??"",checked:n.checked??!1,type:n.type??"",tagName:n.tagName}:{};if(e.type==="scroll"&&n){const l=n;i.scrollHeight=l.scrollHeight??0,i.scrollTop=l.scrollTop??0,i.clientHeight=l.clientHeight??0,i.scrollLeft=l.scrollLeft??0,i.clientWidth=l.clientWidth??0,i.scrollWidth=l.scrollWidth??0}return{type:e.type,target:n?i:null}}executeDebouncedAction(e,n,r,i,l){const c={...r,$event:n,$args:l},d={type:n.type,target:n.target,preventDefault:()=>{},stopPropagation:()=>{}};this.createHandler(e,c,i)(d)}handleDebouncedAction(e,n,r,i,l,c){const d=this.normalizeDebounceConfig(e.debounce),f=l||`default-${e.handler}-${Date.now()}`,h=this.extractEventData(n),m=h._changedKeys;if(m&&Array.isArray(m)&&h?.target?.value&&typeof h.target.value=="object"&&!Array.isArray(h.target.value)){const _=this.debounceAccumulatedValues.get(f);if(_){const x={..._};for(const A of m)x[A]=h.target.value[A];h.target.value=x}this.debounceAccumulatedValues.set(f,h.target.value)}const y=this.debounceTimers.get(f);y&&(clearTimeout(y),this.debounceTimers.delete(f));const v=Jn();v?.isEnabled()&&v.trackAction({handler:typeof e.handler=="string"?e.handler:String(e.handler),type:e.type,status:"pending",params:e.params,debounce:{delay:d.delay,status:"pending",scheduledAt:Date.now()}});const S=!this.debounceTimers.has(f+"_leading");if(d.leading&&S&&(this.debounceTimers.set(f+"_leading",setTimeout(()=>{},0)),this.executeDebouncedAction(e,h,r,i,c),v?.isEnabled()&&v.trackAction({handler:typeof e.handler=="string"?e.handler:String(e.handler),type:e.type,status:"success",params:e.params,debounce:{delay:d.delay,status:"executed",executedAt:Date.now(),mode:"leading"}})),d.trailing){const _=()=>{this.executeDebouncedAction(e,h,r,i,c),v?.isEnabled()&&v.trackAction({handler:typeof e.handler=="string"?e.handler:String(e.handler),type:e.type,status:"success",params:e.params,debounce:{delay:d.delay,status:"executed",executedAt:Date.now(),mode:"trailing"}})},x=setTimeout(()=>{this.debounceTimers.delete(f),this.debounceTimers.delete(f+"_leading"),this.pendingDebounceFlushers.delete(f),this.debounceAccumulatedValues.delete(f),_()},d.delay);this.debounceTimers.set(f,x),this.pendingDebounceFlushers.set(f,_)}}clearDebounceTimers(e){if(e)for(const[n,r]of this.debounceTimers)n.startsWith(e+"-")&&(clearTimeout(r),this.debounceTimers.delete(n),this.pendingDebounceFlushers.delete(n),this.debounceAccumulatedValues.delete(n));else{for(const n of this.debounceTimers.values())clearTimeout(n);this.debounceTimers.clear(),this.pendingDebounceFlushers.clear(),this.debounceAccumulatedValues.clear()}}debouncedCall(e,n,r){const i=this.debounceTimers.get(e);i&&(clearTimeout(i),this.debounceTimers.delete(e));const l=setTimeout(()=>{this.debounceTimers.delete(e),this.pendingDebounceFlushers.delete(e),r()},n);this.debounceTimers.set(e,l),this.pendingDebounceFlushers.set(e,r)}flushPendingDebounceTimers(){if(this.pendingDebounceFlushers.size===0)return;const e=new Map(this.pendingDebounceFlushers);for(const[n,r]of e){const i=this.debounceTimers.get(n);i&&(clearTimeout(i),this.debounceTimers.delete(n)),this.debounceTimers.delete(n+"_leading"),this.pendingDebounceFlushers.delete(n),r()}this.globalStateUpdater&&this.globalStateUpdater({})}bindActionsToProps(e,n,r){const i={...e};if(e.actions&&Array.isArray(e.actions)){const l=new Map;for(const m of e.actions){const y=this.resolveActionRef(m),v=y.event?this.normalizeEventPropName(y.event):this.getEventHandlerName(y.type);l.has(v)||l.set(v,[]),l.get(v).push(y)}const c=e.name||e.id||"unknown",d=l.has("onDrop"),f=l.has("onDragOver"),h=l.has("onDragEnter");d&&!f&&(i.onDragOver=m=>{m.preventDefault()}),d&&!h&&(i.onDragEnter=m=>{m.preventDefault()});for(const[m,y]of l)i[m]=(...v)=>{for(const S of y){const _=v[0],x=_&&typeof _=="object"&&"preventDefault"in _;if(x&&(m==="onDragOver"||m==="onDrop")&&_.preventDefault(),x&&S.key&&"key"in _){if(this.isImeComposing(_)){I.log("Key filter skipped (IME composing):",S.key);continue}if(_.key!==S.key){I.log("Key filter not matched:",S.key,"actual:",_.key);continue}I.log("Key filter matched:",S.key)}if(S.debounce){const A=`${c}-${S.handler}-${m}`,D=_&&typeof _=="object"&&!("preventDefault"in _)&&"target"in _&&_.target!==null;let O;if(x)O=_;else if(D){const L={type:"custom",target:_.target,preventDefault:()=>{},stopPropagation:()=>{}};_._changedKeys&&(L._changedKeys=_._changedKeys),O=L}else O=new Event("custom");const k=S.event?{...n,$args:v}:n;this.handleDebouncedAction(S,O,k,r,A,v)}else if(this.flushPendingDebounceTimers(),S.event){const A={...n,$args:v},D=this.resolveEventForHandler(_,x);this.createHandler(S,A,r)(D)}else if(x)this.createHandler(S,n,r)(_);else if(_&&typeof _=="object"&&!("preventDefault"in _)&&"target"in _&&_.target!==null){const D={type:"custom",target:_.target,preventDefault:()=>{},stopPropagation:()=>{}};this.createHandler(S,n,r)(D)}}}}return i}getEventHandlerName(e){return wy[e]||`on${e.charAt(0).toUpperCase()}${e.slice(1)}`}normalizeEventPropName(e){return wy[e]??e}resolveEventForHandler(e,n){if(n)return e;if(!(e&&typeof e=="object"&&!("preventDefault"in e)&&"target"in e&&e.target!==null))return new Event("custom");const i={type:"custom",target:e.target,preventDefault:()=>{},stopPropagation:()=>{}};return e._changedKeys&&(i._changedKeys=e._changedKeys),i}sanitizeForDevTools(e,n=5){const r=new WeakSet,i=(l,c)=>{if(l==null||typeof l=="string"||typeof l=="number"||typeof l=="boolean")return l;if(c>n)return"[Max Depth Exceeded]";if(typeof l=="function")return`[Function: ${l.name||"anonymous"}]`;if(l instanceof Element)return`[Element: ${l.tagName}${l.className?"."+l.className.split(" ").join("."):""}]`;if(l instanceof Event)return`[Event: ${l.type}]`;if(Array.isArray(l)){if(r.has(l))return"[Circular Array]";r.add(l);const d=l.slice(0,10).map(f=>i(f,c+1));return l.length>10&&d.push(`... ${l.length-10} more items`),d}if(typeof l=="object"){if(r.has(l))return"[Circular Reference]";r.add(l);const d={},f=Object.keys(l),h=f.slice(0,20);for(const m of h)try{d[m]=i(l[m],c+1)}catch{d[m]="[Error accessing property]"}return f.length>20&&(d["..."]=`${f.length-20} more properties`),d}return String(l)};return i(e,0)}};M(cn,"loadedScripts",new Set),M(cn,"loadingScripts",new Map),M(cn,"PROTOTYPE_PATH_SEGMENTS",["__proto__","prototype","constructor"]);let jo=cn,Ec=null;function Cy(s){return Ec||(Ec=new jo(s)),Ec}function o_(s){Ec=s}const Ey=pt("TransitionManager");class l_{constructor(){M(this,"isPending",!1);M(this,"subscribers",new Set)}setPending(e){this.isPending!==e&&(Ey.log("setPending:",{from:this.isPending,to:e,stack:new Error().stack}),this.isPending=e,this.notifySubscribers())}getIsPending(){return this.isPending}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}notifySubscribers(){Ey.log("notifySubscribers:",{isPending:this.isPending,subscriberCount:this.subscribers.size}),this.subscribers.forEach(e=>{e(this.isPending)})}clearSubscribers(){this.subscribers.clear()}}const Gr=new l_,_c=pt("TransitionContext"),_y=N.createContext({isTransitioning:!1}),Of=({children:s})=>{const[e,n]=N.useState(()=>{const i=Gr.getIsPending();return _c.log("Initial state:",i),i});N.useEffect(()=>{_c.log("Subscribing to TransitionManager");const i=Gr.subscribe(l=>{_c.log("Received isPending update:",l),n(l)});return()=>{_c.log("Unsubscribing from TransitionManager"),i()}},[]);const r=N.useMemo(()=>({isTransitioning:e}),[e]);return yt.jsx(_y.Provider,{value:r,children:s})},Ay=()=>N.useContext(_y),Ac="__g7LocalInitTracking";function Lf(){const s=globalThis;return s[Ac]||(s[Ac]={hash:"",timestamp:void 0,consumed:void 0}),s[Ac]}function c_(){const s=globalThis;s[Ac]={hash:"",timestamp:void 0,consumed:void 0}}function u_(s){Lf().consumed=s}function d_(s){return Lf().consumed===s}function f_(s){return s.globalTrackedKey!==s.trackingKey?"apply":s.instanceHandledKey===s.trackingKey?"skip":"prune"}function h_(s,e){return typeof s=="number"&&typeof e=="number"?Math.max(s,e):e??s}function p_(s,e){if(e===void 0)return s;if(!(s!==null&&typeof s=="object"&&e!==null&&typeof e=="object"&&!d_(s)))return e;const{_forceLocalInit:r,...i}=s,{_forceLocalInit:l,...c}=e,d={...i,...c},f=h_(r,l);return f!==void 0&&(d._forceLocalInit=f),d}function g_(s){return s<768?"mobile":s<1024?"tablet":"desktop"}function xy(s){const e=g_(s);return{width:s,isMobile:e==="mobile",isTablet:e==="tablet",isDesktop:e==="desktop",matchedPreset:e}}const $f=N.createContext(xy(1024)),xc=({children:s,overrideWidth:e})=>{const[n,r]=N.useState(()=>Ci.getWidth());N.useEffect(()=>{const c=Ci.subscribe(d=>{r(d)});return()=>{c()}},[]);const i=e??n,l=N.useMemo(()=>xy(i),[i]);return yt.jsx($f.Provider,{value:l,children:s})},Mf=()=>N.useContext($f);window.G7Core?.createLogger?.("Core:State");function m_(s,e,n,r){const{syncOnControlledChange:i=!0,isEqual:l}=r??{},c=s!==void 0;N.useRef(c);const[d,f]=N.useState(s!==void 0?s:e),h=d,m=N.useRef(s),y=N.useRef(!1);N.useEffect(()=>{if(y.current){m.current=s;return}i&&c&&s!==m.current&&(l?!l(d,s):d!==s)&&f(s),m.current=s},[s,c,i,l,d]);const v=N.useCallback(S=>{const _=typeof S=="function"?S(h):S;(l?l(h,_):h===_)||(y.current=!0,f(_),n?.(_),requestAnimationFrame(()=>{y.current=!1}))},[h,c,n,l]);return[h,v]}function y_(s,e){return s===e?!0:s.length!==e.length?!1:s.every((n,r)=>n===e[r])}function Ty(s,e){if(s===e)return!0;const n=Object.keys(s),r=Object.keys(e);return n.length!==r.length?!1:n.every(i=>s[i]===e[i])}const ky=N.createContext({}),b_=({children:s,value:e})=>yt.jsx(ky.Provider,{value:e,children:s}),v_=()=>N.useContext(ky),S_=(s,e)=>{if(!s)return;const n=e.split(".");let r=s;for(const i of n){if(r==null)return;r=r[i]}return r},Ry=(s,e,n)=>{const r=e.split(".");if(r.length===1)return{...s,[r[0]]:n};const i={...s};let l=i;for(let c=0;c{vs.warn("IsolatedStateContext not available: setState called outside IsolatedStateProvider")},getState:()=>{},mergeState:()=>{vs.warn("IsolatedStateContext not available: mergeState called outside IsolatedStateProvider")},stateRef:{current:{}},scopeId:""},Dy=N.createContext(w_);let C_=0;function E_(){return`isolated-${++C_}-${Date.now().toString(36)}`}function Oy(s,e){if(e==null)return s;if(typeof e!="object"||Array.isArray(e))return e;const n={...s};for(const r of Object.keys(e)){const i=e[r],l=s?.[r];i!==null&&typeof i=="object"&&!Array.isArray(i)&&l!==null&&typeof l=="object"&&!Array.isArray(l)?n[r]=Oy(l,i):n[r]=i}return n}function __(s,e){return e?e.split(".").reduce((n,r)=>n?.[r],s):s}function A_(s,e,n){const r=e.split("."),i={...s};let l=i;for(let c=0;c{const i=N.useRef(e||E_()).current,[l,c]=N.useState(s),d=N.useRef(l);d.current=l;const f=N.useCallback(S=>__(d.current,S),[]),h=N.useCallback((S,_)=>{c(x=>{const A=A_(x,S,_);return vs.log(`[${i}] setState: ${S} =`,_),A})},[i]),m=N.useCallback((S,_="deep")=>{c(x=>{let A;return _==="replace"?A=S:_==="shallow"?A={...x,...S}:A=Oy(x,S),vs.log(`[${i}] mergeState (${_}):`,S),A})},[i]),y=N.useMemo(()=>({state:l,setState:h,getState:f,mergeState:m,stateRef:d,scopeId:i}),[l,h,f,m,i]),v=N.useMemo(()=>({state:d.current,setState:h,getState:f,mergeState:m}),[h,f,m]);return N.useEffect(()=>{const S=window.G7Core,_=window.__g7IsolatedStates||{};return window.__g7IsolatedStates||(window.__g7IsolatedStates=_),_[i]=v,S&&(S._isolatedStates||(S._isolatedStates={}),S._isolatedStates[i]=l),S?.devTools?.isEnabled?.()&&S.devTools.emit?.("isolated:created",{id:i,state:l}),vs.log(`[${i}] IsolatedStateProvider mounted with initial state:`,l),()=>{delete _[i],S?._isolatedStates&&delete S._isolatedStates[i],S?.devTools?.isEnabled?.()&&S.devTools.emit?.("isolated:destroyed",{id:i}),vs.log(`[${i}] IsolatedStateProvider unmounted`)}},[i,v]),N.useEffect(()=>{const S=window.G7Core,_=window.__g7IsolatedStates;_?.[i]&&(_[i].state=l),S?._isolatedStates&&(S._isolatedStates[i]=l),S?.devTools?.isEnabled?.()&&S.devTools.emit?.("isolated:updated",{id:i,state:l})},[l,i]),yt.jsx(Dy.Provider,{value:y,children:n})},T_=()=>{const s=N.useContext(Dy);return s.scopeId?s:null};var Ia=zg();function k_(){for(var s=arguments.length,e=new Array(s),n=0;nr=>{e.forEach(i=>i(r))},e)}const Tc=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ss(s){const e=Object.prototype.toString.call(s);return e==="[object Window]"||e==="[object global]"}function Nf(s){return"nodeType"in s}function zn(s){var e,n;return s?Ss(s)?s:Nf(s)&&(e=(n=s.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function If(s){const{Document:e}=zn(s);return s instanceof e}function Ho(s){return Ss(s)?!1:s instanceof zn(s).HTMLElement}function Ly(s){return s instanceof zn(s).SVGElement}function ws(s){return s?Ss(s)?s.document:Nf(s)?If(s)?s:Ho(s)||Ly(s)?s.ownerDocument:document:document:document}const Fr=Tc?N.useLayoutEffect:N.useEffect;function jf(s){const e=N.useRef(s);return Fr(()=>{e.current=s}),N.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i{s.current=setInterval(r,i)},[]),n=N.useCallback(()=>{s.current!==null&&(clearInterval(s.current),s.current=null)},[]);return[e,n]}function zo(s,e){e===void 0&&(e=[s]);const n=N.useRef(s);return Fr(()=>{n.current!==s&&(n.current=s)},e),n}function Po(s,e){const n=N.useRef();return N.useMemo(()=>{const r=s(n.current);return n.current=r,r},[...e])}function kc(s){const e=jf(s),n=N.useRef(null),r=N.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function Hf(s){const e=N.useRef();return N.useEffect(()=>{e.current=s},[s]),e.current}let zf={};function Uo(s,e){return N.useMemo(()=>{if(e)return e;const n=zf[s]==null?0:zf[s]+1;return zf[s]=n,s+"-"+n},[s,e])}function $y(s){return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i{const d=Object.entries(c);for(const[f,h]of d){const m=l[f];m!=null&&(l[f]=m+s*h)}return l},{...e})}}const Cs=$y(1),Bo=$y(-1);function D_(s){return"clientX"in s&&"clientY"in s}function Pf(s){if(!s)return!1;const{KeyboardEvent:e}=zn(s.target);return e&&s instanceof e}function O_(s){if(!s)return!1;const{TouchEvent:e}=zn(s.target);return e&&s instanceof e}function Uf(s){if(O_(s)){if(s.touches&&s.touches.length){const{clientX:e,clientY:n}=s.touches[0];return{x:e,y:n}}else if(s.changedTouches&&s.changedTouches.length){const{clientX:e,clientY:n}=s.changedTouches[0];return{x:e,y:n}}}return D_(s)?{x:s.clientX,y:s.clientY}:null}const qo=Object.freeze({Translate:{toString(s){if(!s)return;const{x:e,y:n}=s;return"translate3d("+(e?Math.round(e):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(s){if(!s)return;const{scaleX:e,scaleY:n}=s;return"scaleX("+e+") scaleY("+n+")"}},Transform:{toString(s){if(s)return[qo.Translate.toString(s),qo.Scale.toString(s)].join(" ")}},Transition:{toString(s){let{property:e,duration:n,easing:r}=s;return e+" "+n+"ms "+r}}}),My="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function L_(s){return s.matches(My)?s:s.querySelector(My)}const $_={display:"none"};function M_(s){let{id:e,value:n}=s;return Xe.createElement("div",{id:e,style:$_},n)}function N_(s){let{id:e,announcement:n,ariaLiveType:r="assertive"}=s;const i={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Xe.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function I_(){const[s,e]=N.useState("");return{announce:N.useCallback(r=>{r!=null&&e(r)},[]),announcement:s}}const Ny=N.createContext(null);function j_(s){const e=N.useContext(Ny);N.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of ");return e(s)},[s,e])}function H_(){const[s]=N.useState(()=>new Set),e=N.useCallback(r=>(s.add(r),()=>s.delete(r)),[s]);return[N.useCallback(r=>{let{type:i,event:l}=r;s.forEach(c=>{var d;return(d=c[i])==null?void 0:d.call(c,l)})},[s]),e]}const z_={draggable:` To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel. - `},OE={onDragStart(s){let{active:e}=s;return"Picked up draggable item "+e.id+"."},onDragOver(s){let{active:e,over:n}=s;return n?"Draggable item "+e.id+" was moved over droppable area "+n.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(s){let{active:e,over:n}=s;return n?"Draggable item "+e.id+" was dropped over droppable area "+n.id:"Draggable item "+e.id+" was dropped."},onDragCancel(s){let{active:e}=s;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function LE(s){let{announcements:e=OE,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=DE}=s;const{announce:l,announcement:c}=TE(),d=Io("DndLiveRegion"),[f,p]=M.useState(!1);if(M.useEffect(()=>{p(!0)},[]),kE(M.useMemo(()=>({onDragStart(y){let{active:C}=y;l(e.onDragStart({active:C}))},onDragMove(y){let{active:C,over:S}=y;e.onDragMove&&l(e.onDragMove({active:C,over:S}))},onDragOver(y){let{active:C,over:S}=y;l(e.onDragOver({active:C,over:S}))},onDragEnd(y){let{active:C,over:S}=y;l(e.onDragEnd({active:C,over:S}))},onDragCancel(y){let{active:C,over:S}=y;l(e.onDragCancel({active:C,over:S}))}}),[l,e])),!f)return null;const m=We.createElement(We.Fragment,null,We.createElement(AE,{id:r,value:i.draggable}),We.createElement(xE,{id:d,announcement:c}));return n?za.createPortal(m,n):m}var nn;(function(s){s.DragStart="dragStart",s.DragMove="dragMove",s.DragEnd="dragEnd",s.DragCancel="dragCancel",s.DragOver="dragOver",s.RegisterDroppable="registerDroppable",s.SetDroppableDisabled="setDroppableDisabled",s.UnregisterDroppable="unregisterDroppable"})(nn||(nn={}));function Lc(){}function ly(s,e){return M.useMemo(()=>({sensor:s,options:e??{}}),[s,e])}function $E(){for(var s=arguments.length,e=new Array(s),n=0;n[...e].filter(r=>r!=null),[...e])}const kr=Object.freeze({x:0,y:0});function cy(s,e){return Math.sqrt(Math.pow(s.x-e.x,2)+Math.pow(s.y-e.y,2))}function uy(s,e){let{data:{value:n}}=s,{data:{value:r}}=e;return n-r}function ME(s,e){let{data:{value:n}}=s,{data:{value:r}}=e;return r-n}function dy(s){let{left:e,top:n,height:r,width:i}=s;return[{x:e,y:n},{x:e+i,y:n},{x:e,y:n+r},{x:e+i,y:n+r}]}function fy(s,e){if(!s||s.length===0)return null;const[n]=s;return n[e]}function hy(s,e,n){return e===void 0&&(e=s.left),n===void 0&&(n=s.top),{x:e+s.width*.5,y:n+s.height*.5}}const NE=s=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=s;const i=hy(e,e.left,e.top),l=[];for(const c of r){const{id:d}=c,f=n.get(d);if(f){const p=cy(hy(f),i);l.push({id:d,data:{droppableContainer:c,value:p}})}}return l.sort(uy)},IE=s=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=s;const i=dy(e),l=[];for(const c of r){const{id:d}=c,f=n.get(d);if(f){const p=dy(f),m=i.reduce((C,S,v)=>C+cy(p[v],S),0),y=Number((m/4).toFixed(4));l.push({id:d,data:{droppableContainer:c,value:y}})}}return l.sort(uy)};function jE(s,e){const n=Math.max(e.top,s.top),r=Math.max(e.left,s.left),i=Math.min(e.left+e.width,s.left+s.width),l=Math.min(e.top+e.height,s.top+s.height),c=i-r,d=l-n;if(r{let{collisionRect:e,droppableRects:n,droppableContainers:r}=s;const i=[];for(const l of r){const{id:c}=l,d=n.get(c);if(d){const f=jE(d,e);f>0&&i.push({id:c,data:{droppableContainer:l,value:f}})}}return i.sort(ME)};function HE(s,e,n){return{...s,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function py(s,e){return s&&e?{x:s.left-e.left,y:s.top-e.top}:kr}function UE(s){return function(n){for(var r=arguments.length,i=new Array(r>1?r-1:0),l=1;l({...c,top:c.top+s*d.y,bottom:c.bottom+s*d.y,left:c.left+s*d.x,right:c.right+s*d.x}),{...n})}}const PE=UE(1);function BE(s){if(s.startsWith("matrix3d(")){const e=s.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(s.startsWith("matrix(")){const e=s.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function qE(s,e,n){const r=BE(e);if(!r)return s;const{scaleX:i,scaleY:l,x:c,y:d}=r,f=s.left-c-(1-i)*parseFloat(n),p=s.top-d-(1-l)*parseFloat(n.slice(n.indexOf(" ")+1)),m=i?s.width/i:s.width,y=l?s.height/l:s.height;return{width:m,height:y,top:p,right:f+m,bottom:p+y,left:f}}const GE={ignoreTransform:!1};function ys(s,e){e===void 0&&(e=GE);let n=s.getBoundingClientRect();if(e.ignoreTransform){const{transform:p,transformOrigin:m}=Mn(s).getComputedStyle(s);p&&(n=qE(n,p,m))}const{top:r,left:i,width:l,height:c,bottom:d,right:f}=n;return{top:r,left:i,width:l,height:c,bottom:d,right:f}}function gy(s){return ys(s,{ignoreTransform:!0})}function FE(s){const e=s.innerWidth,n=s.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function VE(s,e){return e===void 0&&(e=Mn(s).getComputedStyle(s)),e.position==="fixed"}function KE(s,e){e===void 0&&(e=Mn(s).getComputedStyle(s));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const l=e[i];return typeof l=="string"?n.test(l):!1})}function $c(s,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(Af(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!$o(i)||ay(i)||n.includes(i))return n;const l=Mn(s).getComputedStyle(i);return i!==s&&KE(i,l)&&n.push(i),VE(i,l)?n:r(i.parentNode)}return s?r(s):n}function my(s){const[e]=$c(s,1);return e??null}function Of(s){return!Dc||!s?null:ps(s)?s:_f(s)?Af(s)||s===gs(s).scrollingElement?window:$o(s)?s:null:null}function yy(s){return ps(s)?s.scrollX:s.scrollLeft}function by(s){return ps(s)?s.scrollY:s.scrollTop}function Lf(s){return{x:yy(s),y:by(s)}}var cn;(function(s){s[s.Forward=1]="Forward",s[s.Backward=-1]="Backward"})(cn||(cn={}));function vy(s){return!Dc||!s?!1:s===document.scrollingElement}function Sy(s){const e={x:0,y:0},n=vy(s)?{height:window.innerHeight,width:window.innerWidth}:{height:s.clientHeight,width:s.clientWidth},r={x:s.scrollWidth-n.width,y:s.scrollHeight-n.height},i=s.scrollTop<=e.y,l=s.scrollLeft<=e.x,c=s.scrollTop>=r.y,d=s.scrollLeft>=r.x;return{isTop:i,isLeft:l,isBottom:c,isRight:d,maxScroll:r,minScroll:e}}const WE={x:.2,y:.2};function YE(s,e,n,r,i){let{top:l,left:c,right:d,bottom:f}=n;r===void 0&&(r=10),i===void 0&&(i=WE);const{isTop:p,isBottom:m,isLeft:y,isRight:C}=Sy(s),S={x:0,y:0},v={x:0,y:0},x={height:e.height*i.y,width:e.width*i.x};return!p&&l<=e.top+x.height?(S.y=cn.Backward,v.y=r*Math.abs((e.top+x.height-l)/x.height)):!m&&f>=e.bottom-x.height&&(S.y=cn.Forward,v.y=r*Math.abs((e.bottom-x.height-f)/x.height)),!C&&d>=e.right-x.width?(S.x=cn.Forward,v.x=r*Math.abs((e.right-x.width-d)/x.width)):!y&&c<=e.left+x.width&&(S.x=cn.Backward,v.x=r*Math.abs((e.left+x.width-c)/x.width)),{direction:S,speed:v}}function XE(s){if(s===document.scrollingElement){const{innerWidth:l,innerHeight:c}=window;return{top:0,left:0,right:l,bottom:c,width:l,height:c}}const{top:e,left:n,right:r,bottom:i}=s.getBoundingClientRect();return{top:e,left:n,right:r,bottom:i,width:s.clientWidth,height:s.clientHeight}}function wy(s){return s.reduce((e,n)=>ms(e,Lf(n)),kr)}function JE(s){return s.reduce((e,n)=>e+yy(n),0)}function QE(s){return s.reduce((e,n)=>e+by(n),0)}function ZE(s,e){if(e===void 0&&(e=ys),!s)return;const{top:n,left:r,bottom:i,right:l}=e(s);my(s)&&(i<=0||l<=0||n>=window.innerHeight||r>=window.innerWidth)&&s.scrollIntoView({block:"center",inline:"center"})}const e_=[["x",["left","right"],JE],["y",["top","bottom"],QE]];class $f{constructor(e,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=$c(n),i=wy(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[l,c,d]of e_)for(const f of c)Object.defineProperty(this,f,{get:()=>{const p=d(r),m=i[l]-p;return this.rect[f]+m},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ho{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=e}add(e,n,r){var i;(i=this.target)==null||i.addEventListener(e,n,r),this.listeners.push([e,n,r])}}function t_(s){const{EventTarget:e}=Mn(s);return s instanceof e?s:gs(s)}function Mf(s,e){const n=Math.abs(s.x),r=Math.abs(s.y);return typeof e=="number"?Math.sqrt(n**2+r**2)>e:"x"in e&&"y"in e?n>e.x&&r>e.y:"x"in e?n>e.x:"y"in e?r>e.y:!1}var ur;(function(s){s.Click="click",s.DragStart="dragstart",s.Keydown="keydown",s.ContextMenu="contextmenu",s.Resize="resize",s.SelectionChange="selectionchange",s.VisibilityChange="visibilitychange"})(ur||(ur={}));function Cy(s){s.preventDefault()}function n_(s){s.stopPropagation()}var lt;(function(s){s.Space="Space",s.Down="ArrowDown",s.Right="ArrowRight",s.Left="ArrowLeft",s.Up="ArrowUp",s.Esc="Escape",s.Enter="Enter",s.Tab="Tab"})(lt||(lt={}));const Ey={start:[lt.Space,lt.Enter],cancel:[lt.Esc],end:[lt.Space,lt.Enter,lt.Tab]},r_=(s,e)=>{let{currentCoordinates:n}=e;switch(s.code){case lt.Right:return{...n,x:n.x+25};case lt.Left:return{...n,x:n.x-25};case lt.Down:return{...n,y:n.y+25};case lt.Up:return{...n,y:n.y-25}}};class Nf{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:n}}=e;this.props=e,this.listeners=new Ho(gs(n)),this.windowListeners=new Ho(Mn(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ur.Resize,this.handleCancel),this.windowListeners.add(ur.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(ur.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&ZE(r),n(kr)}handleKeyDown(e){if(Rf(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:l=Ey,coordinateGetter:c=r_,scrollBehavior:d="smooth"}=i,{code:f}=e;if(l.end.includes(f)){this.handleEnd(e);return}if(l.cancel.includes(f)){this.handleCancel(e);return}const{collisionRect:p}=r.current,m=p?{x:p.left,y:p.top}:kr;this.referenceCoordinates||(this.referenceCoordinates=m);const y=c(e,{active:n,context:r.current,currentCoordinates:m});if(y){const C=jo(y,m),S={x:0,y:0},{scrollableAncestors:v}=r.current;for(const x of v){const w=e.code,{isTop:R,isRight:L,isLeft:O,isBottom:j,maxScroll:F,minScroll:G}=Sy(x),P=XE(x),K={x:Math.min(w===lt.Right?P.right-P.width/2:P.right,Math.max(w===lt.Right?P.left:P.left+P.width/2,y.x)),y:Math.min(w===lt.Down?P.bottom-P.height/2:P.bottom,Math.max(w===lt.Down?P.top:P.top+P.height/2,y.y))},he=w===lt.Right&&!L||w===lt.Left&&!O,Ee=w===lt.Down&&!j||w===lt.Up&&!R;if(he&&K.x!==y.x){const ke=x.scrollLeft+C.x,ze=w===lt.Right&&ke<=F.x||w===lt.Left&&ke>=G.x;if(ze&&!C.y){x.scrollTo({left:ke,behavior:d});return}ze?S.x=x.scrollLeft-ke:S.x=w===lt.Right?x.scrollLeft-F.x:x.scrollLeft-G.x,S.x&&x.scrollBy({left:-S.x,behavior:d});break}else if(Ee&&K.y!==y.y){const ke=x.scrollTop+C.y,ze=w===lt.Down&&ke<=F.y||w===lt.Up&&ke>=G.y;if(ze&&!C.x){x.scrollTo({top:ke,behavior:d});return}ze?S.y=x.scrollTop-ke:S.y=w===lt.Down?x.scrollTop-F.y:x.scrollTop-G.y,S.y&&x.scrollBy({top:-S.y,behavior:d});break}}this.handleMove(e,ms(jo(y,this.referenceCoordinates),S))}}}handleMove(e,n){const{onMove:r}=this.props;e.preventDefault(),r(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Nf.activators=[{eventName:"onKeyDown",handler:(s,e,n)=>{let{keyboardCodes:r=Ey,onActivation:i}=e,{active:l}=n;const{code:c}=s.nativeEvent;if(r.start.includes(c)){const d=l.activatorNode.current;return d&&s.target!==d?!1:(s.preventDefault(),i?.({event:s.nativeEvent}),!0)}return!1}}];function _y(s){return!!(s&&"distance"in s)}function Ay(s){return!!(s&&"delay"in s)}class If{constructor(e,n,r){var i;r===void 0&&(r=t_(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:l}=e,{target:c}=l;this.props=e,this.events=n,this.document=gs(c),this.documentListeners=new Ho(this.document),this.listeners=new Ho(r),this.windowListeners=new Ho(Mn(c)),this.initialCoordinates=(i=Df(l))!=null?i:kr,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(ur.Resize,this.handleCancel),this.windowListeners.add(ur.DragStart,Cy),this.windowListeners.add(ur.VisibilityChange,this.handleCancel),this.windowListeners.add(ur.ContextMenu,Cy),this.documentListeners.add(ur.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Ay(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(_y(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,n){const{active:r,onPending:i}=this.props;i(r,e,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:e}=this,{onStart:n}=this.props;e&&(this.activated=!0,this.documentListeners.add(ur.Click,n_,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ur.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:l}=this,{onMove:c,options:{activationConstraint:d}}=l;if(!i)return;const f=(n=Df(e))!=null?n:kr,p=jo(i,f);if(!r&&d){if(_y(d)){if(d.tolerance!=null&&Mf(p,d.tolerance))return this.handleCancel();if(Mf(p,d.distance))return this.handleStart()}if(Ay(d)&&Mf(p,d.tolerance))return this.handleCancel();this.handlePending(d,p);return}e.cancelable&&e.preventDefault(),c(f)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===lt.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const a_={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class jf extends If{constructor(e){const{event:n}=e,r=gs(n.target);super(e,a_,r)}}jf.activators=[{eventName:"onPointerDown",handler:(s,e)=>{let{nativeEvent:n}=s,{onActivation:r}=e;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const i_={move:{name:"mousemove"},end:{name:"mouseup"}};var zf;(function(s){s[s.RightClick=2]="RightClick"})(zf||(zf={}));class s_ extends If{constructor(e){super(e,i_,gs(e.event.target))}}s_.activators=[{eventName:"onMouseDown",handler:(s,e)=>{let{nativeEvent:n}=s,{onActivation:r}=e;return n.button===zf.RightClick?!1:(r?.({event:n}),!0)}}];const Hf={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class o_ extends If{constructor(e){super(e,Hf)}static setup(){return window.addEventListener(Hf.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Hf.move.name,e)};function e(){}}}o_.activators=[{eventName:"onTouchStart",handler:(s,e)=>{let{nativeEvent:n}=s,{onActivation:r}=e;const{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var Uo;(function(s){s[s.Pointer=0]="Pointer",s[s.DraggableRect=1]="DraggableRect"})(Uo||(Uo={}));var Mc;(function(s){s[s.TreeOrder=0]="TreeOrder",s[s.ReversedTreeOrder=1]="ReversedTreeOrder"})(Mc||(Mc={}));function l_(s){let{acceleration:e,activator:n=Uo.Pointer,canScroll:r,draggingRect:i,enabled:l,interval:c=5,order:d=Mc.TreeOrder,pointerCoordinates:f,scrollableAncestors:p,scrollableAncestorRects:m,delta:y,threshold:C}=s;const S=u_({delta:y,disabled:!l}),[v,x]=SE(),w=M.useRef({x:0,y:0}),R=M.useRef({x:0,y:0}),L=M.useMemo(()=>{switch(n){case Uo.Pointer:return f?{top:f.y,bottom:f.y,left:f.x,right:f.x}:null;case Uo.DraggableRect:return i}},[n,i,f]),O=M.useRef(null),j=M.useCallback(()=>{const G=O.current;if(!G)return;const P=w.current.x*R.current.x,K=w.current.y*R.current.y;G.scrollBy(P,K)},[]),F=M.useMemo(()=>d===Mc.TreeOrder?[...p].reverse():p,[d,p]);M.useEffect(()=>{if(!l||!p.length||!L){x();return}for(const G of F){if(r?.(G)===!1)continue;const P=p.indexOf(G),K=m[P];if(!K)continue;const{direction:he,speed:Ee}=YE(G,K,L,e,C);for(const ke of["x","y"])S[ke][he[ke]]||(Ee[ke]=0,he[ke]=0);if(Ee.x>0||Ee.y>0){x(),O.current=G,v(j,c),w.current=Ee,R.current=he;return}}w.current={x:0,y:0},R.current={x:0,y:0},x()},[e,j,r,x,l,c,JSON.stringify(L),JSON.stringify(S),v,p,F,m,JSON.stringify(C)])}const c_={x:{[cn.Backward]:!1,[cn.Forward]:!1},y:{[cn.Backward]:!1,[cn.Forward]:!1}};function u_(s){let{delta:e,disabled:n}=s;const r=Tf(e);return No(i=>{if(n||!r||!i)return c_;const l={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[cn.Backward]:i.x[cn.Backward]||l.x===-1,[cn.Forward]:i.x[cn.Forward]||l.x===1},y:{[cn.Backward]:i.y[cn.Backward]||l.y===-1,[cn.Forward]:i.y[cn.Forward]||l.y===1}}},[n,e,r])}function d_(s,e){const n=e!=null?s.get(e):void 0,r=n?n.node.current:null;return No(i=>{var l;return e==null?null:(l=r??i)!=null?l:null},[r,e])}function f_(s,e){return M.useMemo(()=>s.reduce((n,r)=>{const{sensor:i}=r,l=i.activators.map(c=>({eventName:c.eventName,handler:e(c.handler,r)}));return[...n,...l]},[]),[s,e])}var Po;(function(s){s[s.Always=0]="Always",s[s.BeforeDragging=1]="BeforeDragging",s[s.WhileDragging=2]="WhileDragging"})(Po||(Po={}));var Uf;(function(s){s.Optimized="optimized"})(Uf||(Uf={}));const xy=new Map;function h_(s,e){let{dragging:n,dependencies:r,config:i}=e;const[l,c]=M.useState(null),{frequency:d,measure:f,strategy:p}=i,m=M.useRef(s),y=w(),C=Mo(y),S=M.useCallback(function(R){R===void 0&&(R=[]),!C.current&&c(L=>L===null?R:L.concat(R.filter(O=>!L.includes(O))))},[C]),v=M.useRef(null),x=No(R=>{if(y&&!n)return xy;if(!R||R===xy||m.current!==s||l!=null){const L=new Map;for(let O of s){if(!O)continue;if(l&&l.length>0&&!l.includes(O.id)&&O.rect.current){L.set(O.id,O.rect.current);continue}const j=O.node.current,F=j?new $f(f(j),j):null;O.rect.current=F,F&&L.set(O.id,F)}return L}return R},[s,l,n,y,f]);return M.useEffect(()=>{m.current=s},[s]),M.useEffect(()=>{y||S()},[n,y]),M.useEffect(()=>{l&&l.length>0&&c(null)},[JSON.stringify(l)]),M.useEffect(()=>{y||typeof d!="number"||v.current!==null||(v.current=setTimeout(()=>{S(),v.current=null},d))},[d,y,S,...r]),{droppableRects:x,measureDroppableContainers:S,measuringScheduled:l!=null};function w(){switch(p){case Po.Always:return!1;case Po.BeforeDragging:return n;default:return!n}}}function Ty(s,e){return No(n=>s?n||(typeof e=="function"?e(s):s):null,[e,s])}function p_(s,e){return Ty(s,e)}function g_(s){let{callback:e,disabled:n}=s;const r=xf(e),i=M.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:l}=window;return new l(r)},[r,n]);return M.useEffect(()=>()=>i?.disconnect(),[i]),i}function Nc(s){let{callback:e,disabled:n}=s;const r=xf(e),i=M.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:l}=window;return new l(r)},[n]);return M.useEffect(()=>()=>i?.disconnect(),[i]),i}function m_(s){return new $f(ys(s),s)}function ky(s,e,n){e===void 0&&(e=m_);const[r,i]=M.useState(null);function l(){i(f=>{if(!s)return null;if(s.isConnected===!1){var p;return(p=f??n)!=null?p:null}const m=e(s);return JSON.stringify(f)===JSON.stringify(m)?f:m})}const c=g_({callback(f){if(s)for(const p of f){const{type:m,target:y}=p;if(m==="childList"&&y instanceof HTMLElement&&y.contains(s)){l();break}}}}),d=Nc({callback:l});return Fr(()=>{l(),s?(d?.observe(s),c?.observe(document.body,{childList:!0,subtree:!0})):(d?.disconnect(),c?.disconnect())},[s]),r}function y_(s){const e=Ty(s);return py(s,e)}const Ry=[];function b_(s){const e=M.useRef(s),n=No(r=>s?r&&r!==Ry&&s&&e.current&&s.parentNode===e.current.parentNode?r:$c(s):Ry,[s]);return M.useEffect(()=>{e.current=s},[s]),n}function v_(s){const[e,n]=M.useState(null),r=M.useRef(s),i=M.useCallback(l=>{const c=Of(l.target);c&&n(d=>d?(d.set(c,Lf(c)),new Map(d)):null)},[]);return M.useEffect(()=>{const l=r.current;if(s!==l){c(l);const d=s.map(f=>{const p=Of(f);return p?(p.addEventListener("scroll",i,{passive:!0}),[p,Lf(p)]):null}).filter(f=>f!=null);n(d.length?new Map(d):null),r.current=s}return()=>{c(s),c(l)};function c(d){d.forEach(f=>{const p=Of(f);p?.removeEventListener("scroll",i)})}},[i,s]),M.useMemo(()=>s.length?e?Array.from(e.values()).reduce((l,c)=>ms(l,c),kr):wy(s):kr,[s,e])}function Dy(s,e){e===void 0&&(e=[]);const n=M.useRef(null);return M.useEffect(()=>{n.current=null},e),M.useEffect(()=>{const r=s!==kr;r&&!n.current&&(n.current=s),!r&&n.current&&(n.current=null)},[s]),n.current?jo(s,n.current):kr}function S_(s){M.useEffect(()=>{if(!Dc)return;const e=s.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of e)n?.()}},s.map(e=>{let{sensor:n}=e;return n}))}function w_(s,e){return M.useMemo(()=>s.reduce((n,r)=>{let{eventName:i,handler:l}=r;return n[i]=c=>{l(c,e)},n},{}),[s,e])}function Oy(s){return M.useMemo(()=>s?FE(s):null,[s])}const Ly=[];function C_(s,e){e===void 0&&(e=ys);const[n]=s,r=Oy(n?Mn(n):null),[i,l]=M.useState(Ly);function c(){l(()=>s.length?s.map(f=>vy(f)?r:new $f(e(f),f)):Ly)}const d=Nc({callback:c});return Fr(()=>{d?.disconnect(),c(),s.forEach(f=>d?.observe(f))},[s]),i}function E_(s){if(!s)return null;if(s.children.length>1)return s;const e=s.children[0];return $o(e)?e:s}function __(s){let{measure:e}=s;const[n,r]=M.useState(null),i=M.useCallback(p=>{for(const{target:m}of p)if($o(m)){r(y=>{const C=e(m);return y?{...y,width:C.width,height:C.height}:C});break}},[e]),l=Nc({callback:i}),c=M.useCallback(p=>{const m=E_(p);l?.disconnect(),m&&l?.observe(m),r(m?e(m):null)},[e,l]),[d,f]=Oc(c);return M.useMemo(()=>({nodeRef:d,rect:n,setRef:f}),[n,d,f])}const A_=[{sensor:jf,options:{}},{sensor:Nf,options:{}}],x_={current:{}},Ic={draggable:{measure:gy},droppable:{measure:gy,strategy:Po.WhileDragging,frequency:Uf.Optimized},dragOverlay:{measure:ys}};class Bo extends Map{get(e){var n;return e!=null&&(n=super.get(e))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:n}=e;return!n})}getNodeFor(e){var n,r;return(n=(r=this.get(e))==null?void 0:r.node.current)!=null?n:void 0}}const T_={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Bo,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Lc},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Ic,measureDroppableContainers:Lc,windowRect:null,measuringScheduled:!1},k_={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Lc,draggableNodes:new Map,over:null,measureDroppableContainers:Lc},jc=M.createContext(k_),$y=M.createContext(T_);function R_(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Bo}}}function D_(s,e){switch(e.type){case nn.DragStart:return{...s,draggable:{...s.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case nn.DragMove:return s.draggable.active==null?s:{...s,draggable:{...s.draggable,translate:{x:e.coordinates.x-s.draggable.initialCoordinates.x,y:e.coordinates.y-s.draggable.initialCoordinates.y}}};case nn.DragEnd:case nn.DragCancel:return{...s,draggable:{...s.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case nn.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new Bo(s.droppable.containers);return i.set(r,n),{...s,droppable:{...s.droppable,containers:i}}}case nn.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=e,l=s.droppable.containers.get(n);if(!l||r!==l.key)return s;const c=new Bo(s.droppable.containers);return c.set(n,{...l,disabled:i}),{...s,droppable:{...s.droppable,containers:c}}}case nn.UnregisterDroppable:{const{id:n,key:r}=e,i=s.droppable.containers.get(n);if(!i||r!==i.key)return s;const l=new Bo(s.droppable.containers);return l.delete(n),{...s,droppable:{...s.droppable,containers:l}}}default:return s}}function O_(s){let{disabled:e}=s;const{active:n,activatorEvent:r,draggableNodes:i}=M.useContext(jc),l=Tf(r),c=Tf(n?.id);return M.useEffect(()=>{if(!e&&!r&&l&&c!=null){if(!Rf(l)||document.activeElement===l.target)return;const d=i.get(c);if(!d)return;const{activatorNode:f,node:p}=d;if(!f.current&&!p.current)return;requestAnimationFrame(()=>{for(const m of[f.current,p.current]){if(!m)continue;const y=EE(m);if(y){y.focus();break}}})}},[r,e,i,c,l]),null}function L_(s,e){let{transform:n,...r}=e;return s!=null&&s.length?s.reduce((i,l)=>l({transform:i,...r}),n):n}function $_(s){return M.useMemo(()=>({draggable:{...Ic.draggable,...s?.draggable},droppable:{...Ic.droppable,...s?.droppable},dragOverlay:{...Ic.dragOverlay,...s?.dragOverlay}}),[s?.draggable,s?.droppable,s?.dragOverlay])}function M_(s){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=s;const l=M.useRef(!1),{x:c,y:d}=typeof i=="boolean"?{x:i,y:i}:i;Fr(()=>{if(!c&&!d||!e){l.current=!1;return}if(l.current||!r)return;const p=e?.node.current;if(!p||p.isConnected===!1)return;const m=n(p),y=py(m,r);if(c||(y.x=0),d||(y.y=0),l.current=!0,Math.abs(y.x)>0||Math.abs(y.y)>0){const C=my(p);C&&C.scrollBy({top:y.y,left:y.x})}},[e,c,d,r,n])}const My=M.createContext({...kr,scaleX:1,scaleY:1});var Ha;(function(s){s[s.Uninitialized=0]="Uninitialized",s[s.Initializing=1]="Initializing",s[s.Initialized=2]="Initialized"})(Ha||(Ha={}));const N_=M.memo(function(e){var n,r,i,l;let{id:c,accessibility:d,autoScroll:f=!0,children:p,sensors:m=A_,collisionDetection:y=zE,measuring:C,modifiers:S,...v}=e;const x=M.useReducer(D_,void 0,R_),[w,R]=x,[L,O]=RE(),[j,F]=M.useState(Ha.Uninitialized),G=j===Ha.Initialized,{draggable:{active:P,nodes:K,translate:he},droppable:{containers:Ee}}=w,ke=P!=null?K.get(P):null,ze=M.useRef({initial:null,translated:null}),Be=M.useMemo(()=>{var ue;return P!=null?{id:P,data:(ue=ke?.data)!=null?ue:x_,rect:ze}:null},[P,ke]),je=M.useRef(null),[bt,X]=M.useState(null),[de,Ce]=M.useState(null),Z=Mo(v,Object.values(v)),ge=Io("DndDescribedBy",c),z=M.useMemo(()=>Ee.getEnabled(),[Ee]),T=$_(C),{droppableRects:pe,measureDroppableContainers:fe,measuringScheduled:me}=h_(z,{dragging:G,dependencies:[he.x,he.y],config:T.droppable}),ae=d_(K,P),Re=M.useMemo(()=>de?Df(de):null,[de]),Pe=ve(),Me=p_(ae,T.draggable.measure);M_({activeNode:P!=null?K.get(P):null,config:Pe.layoutShiftCompensation,initialRect:Me,measure:T.draggable.measure});const Ge=ky(ae,T.draggable.measure,Me),kt=ky(ae?ae.parentElement:null),vt=M.useRef({activatorEvent:null,active:null,activeNode:ae,collisionRect:null,collisions:null,droppableRects:pe,draggableNodes:K,draggingNode:null,draggingNodeRect:null,droppableContainers:Ee,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),hn=Ee.getNodeFor((n=vt.current.over)==null?void 0:n.id),Dt=__({measure:T.dragOverlay.measure}),Xt=(r=Dt.nodeRef.current)!=null?r:ae,un=G?(i=Dt.rect)!=null?i:Ge:null,Ut=!!(Dt.nodeRef.current&&Dt.rect),$r=y_(Ut?null:Ge),En=Oy(Xt?Mn(Xt):null),dn=b_(G?hn??ae:null),pn=C_(dn),fr=L_(S,{transform:{x:he.x-$r.x,y:he.y-$r.y,scaleX:1,scaleY:1},activatorEvent:de,active:Be,activeNodeRect:Ge,containerNodeRect:kt,draggingNodeRect:un,over:vt.current.over,overlayNodeRect:Dt.rect,scrollableAncestors:dn,scrollableAncestorRects:pn,windowRect:En}),er=Re?ms(Re,he):null,Pt=v_(dn),St=Dy(Pt),da=Dy(Pt,[Ge]),In=ms(fr,St),kn=un?PE(un,fr):null,Rn=Be&&kn?y({active:Be,collisionRect:kn,droppableRects:pe,droppableContainers:z,pointerCoordinates:er}):null,jn=fy(Rn,"id"),[gn,fa]=M.useState(null),zn=Ut?fr:ms(fr,da),Vt=HE(zn,(l=gn?.rect)!=null?l:null,Ge),_n=M.useRef(null),an=M.useCallback((ue,we)=>{let{sensor:_e,options:qe}=we;if(je.current==null)return;const xe=K.get(je.current);if(!xe)return;const De=ue.nativeEvent,Ae=new _e({active:je.current,activeNode:xe,event:De,options:qe,context:vt,onAbort(Ne){if(!K.get(Ne))return;const{onDragAbort:Se}=Z.current,$e={id:Ne};Se?.($e),L({type:"onDragAbort",event:$e})},onPending(Ne,He,Se,$e){if(!K.get(Ne))return;const{onDragPending:Ot}=Z.current,Mt={id:Ne,constraint:He,initialCoordinates:Se,offset:$e};Ot?.(Mt),L({type:"onDragPending",event:Mt})},onStart(Ne){const He=je.current;if(He==null)return;const Se=K.get(He);if(!Se)return;const{onDragStart:$e}=Z.current,et={activatorEvent:De,active:{id:He,data:Se.data,rect:ze}};za.unstable_batchedUpdates(()=>{$e?.(et),F(Ha.Initializing),R({type:nn.DragStart,initialCoordinates:Ne,active:He}),L({type:"onDragStart",event:et}),X(_n.current),Ce(De)})},onMove(Ne){R({type:nn.DragMove,coordinates:Ne})},onEnd:tt(nn.DragEnd),onCancel:tt(nn.DragCancel)});_n.current=Ae;function tt(Ne){return async function(){const{active:Se,collisions:$e,over:et,scrollAdjustedTranslate:Ot}=vt.current;let Mt=null;if(Se&&Ot){const{cancelDrop:Hn}=Z.current;Mt={activatorEvent:De,active:Se,collisions:$e,delta:Ot,over:et},Ne===nn.DragEnd&&typeof Hn=="function"&&await Promise.resolve(Hn(Mt))&&(Ne=nn.DragCancel)}je.current=null,za.unstable_batchedUpdates(()=>{R({type:Ne}),F(Ha.Uninitialized),fa(null),X(null),Ce(null),_n.current=null;const Hn=Ne===nn.DragEnd?"onDragEnd":"onDragCancel";if(Mt){const It=Z.current[Hn];It?.(Mt),L({type:Hn,event:Mt})}})}}},[K]),q=M.useCallback((ue,we)=>(_e,qe)=>{const xe=_e.nativeEvent,De=K.get(qe);if(je.current!==null||!De||xe.dndKit||xe.defaultPrevented)return;const Ae={active:De};ue(_e,we.options,Ae)===!0&&(xe.dndKit={capturedBy:we.sensor},je.current=qe,an(_e,we))},[K,an]),oe=f_(m,q);S_(m),Fr(()=>{Ge&&j===Ha.Initializing&&F(Ha.Initialized)},[Ge,j]),M.useEffect(()=>{const{onDragMove:ue}=Z.current,{active:we,activatorEvent:_e,collisions:qe,over:xe}=vt.current;if(!we||!_e)return;const De={active:we,activatorEvent:_e,collisions:qe,delta:{x:In.x,y:In.y},over:xe};za.unstable_batchedUpdates(()=>{ue?.(De),L({type:"onDragMove",event:De})})},[In.x,In.y]),M.useEffect(()=>{const{active:ue,activatorEvent:we,collisions:_e,droppableContainers:qe,scrollAdjustedTranslate:xe}=vt.current;if(!ue||je.current==null||!we||!xe)return;const{onDragOver:De}=Z.current,Ae=qe.get(jn),tt=Ae&&Ae.rect.current?{id:Ae.id,rect:Ae.rect.current,data:Ae.data,disabled:Ae.disabled}:null,Ne={active:ue,activatorEvent:we,collisions:_e,delta:{x:xe.x,y:xe.y},over:tt};za.unstable_batchedUpdates(()=>{fa(tt),De?.(Ne),L({type:"onDragOver",event:Ne})})},[jn]),Fr(()=>{vt.current={activatorEvent:de,active:Be,activeNode:ae,collisionRect:kn,collisions:Rn,droppableRects:pe,draggableNodes:K,draggingNode:Xt,draggingNodeRect:un,droppableContainers:Ee,over:gn,scrollableAncestors:dn,scrollAdjustedTranslate:In},ze.current={initial:un,translated:kn}},[Be,ae,Rn,kn,K,Xt,un,pe,Ee,gn,dn,In]),l_({...Pe,delta:he,draggingRect:kn,pointerCoordinates:er,scrollableAncestors:dn,scrollableAncestorRects:pn});const ce=M.useMemo(()=>({active:Be,activeNode:ae,activeNodeRect:Ge,activatorEvent:de,collisions:Rn,containerNodeRect:kt,dragOverlay:Dt,draggableNodes:K,droppableContainers:Ee,droppableRects:pe,over:gn,measureDroppableContainers:fe,scrollableAncestors:dn,scrollableAncestorRects:pn,measuringConfiguration:T,measuringScheduled:me,windowRect:En}),[Be,ae,Ge,de,Rn,kt,Dt,K,Ee,pe,gn,fe,dn,pn,T,me,En]),J=M.useMemo(()=>({activatorEvent:de,activators:oe,active:Be,activeNodeRect:Ge,ariaDescribedById:{draggable:ge},dispatch:R,draggableNodes:K,over:gn,measureDroppableContainers:fe}),[de,oe,Be,Ge,R,ge,K,gn,fe]);return We.createElement(oy.Provider,{value:O},We.createElement(jc.Provider,{value:J},We.createElement($y.Provider,{value:ce},We.createElement(My.Provider,{value:Vt},p)),We.createElement(O_,{disabled:d?.restoreFocus===!1})),We.createElement(LE,{...d,hiddenTextDescribedById:ge}));function ve(){const ue=bt?.autoScrollEnabled===!1,we=typeof f=="object"?f.enabled===!1:f===!1,_e=G&&!ue&&!we;return typeof f=="object"?{...f,enabled:_e}:{enabled:_e}}}),I_=M.createContext(null),Ny="button",j_="Draggable";function z_(s){let{id:e,data:n,disabled:r=!1,attributes:i}=s;const l=Io(j_),{activators:c,activatorEvent:d,active:f,activeNodeRect:p,ariaDescribedById:m,draggableNodes:y,over:C}=M.useContext(jc),{role:S=Ny,roleDescription:v="draggable",tabIndex:x=0}=i??{},w=f?.id===e,R=M.useContext(w?My:I_),[L,O]=Oc(),[j,F]=Oc(),G=w_(c,e),P=Mo(n);Fr(()=>(y.set(e,{id:e,key:l,node:L,activatorNode:j,data:P}),()=>{const he=y.get(e);he&&he.key===l&&y.delete(e)}),[y,e]);const K=M.useMemo(()=>({role:S,tabIndex:x,"aria-disabled":r,"aria-pressed":w&&S===Ny?!0:void 0,"aria-roledescription":v,"aria-describedby":m.draggable}),[r,S,x,w,v,m.draggable]);return{active:f,activatorEvent:d,activeNodeRect:p,attributes:K,isDragging:w,listeners:r?void 0:G,node:L,over:C,setNodeRef:O,setActivatorNodeRef:F,transform:R}}function H_(){return M.useContext($y)}const U_="Droppable",P_={timeout:25};function B_(s){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=s;const l=Io(U_),{active:c,dispatch:d,over:f,measureDroppableContainers:p}=M.useContext(jc),m=M.useRef({disabled:n}),y=M.useRef(!1),C=M.useRef(null),S=M.useRef(null),{disabled:v,updateMeasurementsFor:x,timeout:w}={...P_,...i},R=Mo(x??r),L=M.useCallback(()=>{if(!y.current){y.current=!0;return}S.current!=null&&clearTimeout(S.current),S.current=setTimeout(()=>{p(Array.isArray(R.current)?R.current:[R.current]),S.current=null},w)},[w]),O=Nc({callback:L,disabled:v||!c}),j=M.useCallback((K,he)=>{O&&(he&&(O.unobserve(he),y.current=!1),K&&O.observe(K))},[O]),[F,G]=Oc(j),P=Mo(e);return M.useEffect(()=>{!O||!F.current||(O.disconnect(),y.current=!1,O.observe(F.current))},[F,O]),M.useEffect(()=>(d({type:nn.RegisterDroppable,element:{id:r,key:l,disabled:n,node:F,rect:C,data:P}}),()=>d({type:nn.UnregisterDroppable,key:l,id:r})),[r]),M.useEffect(()=>{n!==m.current.disabled&&(d({type:nn.SetDroppableDisabled,id:r,key:l,disabled:n}),m.current.disabled=n)},[r,l,n,d]),{active:c,rect:C,isOver:f?.id===r,node:F,over:f,setNodeRef:G}}function Pf(s,e,n){const r=s.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function q_(s,e){return s.reduce((n,r,i)=>{const l=e.get(r);return l&&(n[i]=l),n},Array(s.length))}function zc(s){return s!==null&&s>=0}function G_(s,e){if(s===e)return!0;if(s.length!==e.length)return!1;for(let n=0;n{var e;let{rects:n,activeNodeRect:r,activeIndex:i,overIndex:l,index:c}=s;const d=(e=n[i])!=null?e:r;if(!d)return null;const f=K_(n,c,i);if(c===i){const p=n[l];return p?{x:ii&&c<=l?{x:-d.width-f,y:0,...Hc}:c=l?{x:d.width+f,y:0,...Hc}:{x:0,y:0,...Hc}};function K_(s,e,n){const r=s[e],i=s[e-1],l=s[e+1];return!r||!i&&!l?0:n{let{rects:e,activeIndex:n,overIndex:r,index:i}=s;const l=Pf(e,r,n),c=e[i],d=l[i];return!d||!c?null:{x:d.left-c.left,y:d.top-c.top,scaleX:d.width/c.width,scaleY:d.height/c.height}},Uc={scaleX:1,scaleY:1},W_=s=>{var e;let{activeIndex:n,activeNodeRect:r,index:i,rects:l,overIndex:c}=s;const d=(e=l[n])!=null?e:r;if(!d)return null;if(i===n){const p=l[c];return p?{x:0,y:nn&&i<=c?{x:0,y:-d.height-f,...Uc}:i=c?{x:0,y:d.height+f,...Uc}:{x:0,y:0,...Uc}};function Y_(s,e,n){const r=s[e],i=s[e-1],l=s[e+1];return r?nr.map(G=>typeof G=="object"&&"id"in G?G.id:G),[r]),v=c!=null,x=c?S.indexOf(c.id):-1,w=p?S.indexOf(p.id):-1,R=M.useRef(S),L=!G_(S,R.current),O=w!==-1&&x===-1||L,j=F_(l);Fr(()=>{L&&v&&m(S)},[L,S,v,m]),M.useEffect(()=>{R.current=S},[S]);const F=M.useMemo(()=>({activeIndex:x,containerId:y,disabled:j,disableTransforms:O,items:S,overIndex:w,useDragOverlay:C,sortedRects:q_(S,f),strategy:i}),[x,y,j.draggable,j.droppable,O,S,w,f,C,i]);return We.createElement(jy.Provider,{value:F},e)}const J_=s=>{let{id:e,items:n,activeIndex:r,overIndex:i}=s;return Pf(n,r,i).indexOf(e)},Q_=s=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:l,newIndex:c,previousItems:d,previousContainerId:f,transition:p}=s;return!p||!r||d!==l&&i===c?!1:n?!0:c!==i&&e===f},Z_={duration:200,easing:"ease"},zy="transform",eA=zo.Transition.toString({property:zy,duration:0,easing:"linear"}),tA={roleDescription:"sortable"};function nA(s){let{disabled:e,index:n,node:r,rect:i}=s;const[l,c]=M.useState(null),d=M.useRef(n);return Fr(()=>{if(!e&&n!==d.current&&r.current){const f=i.current;if(f){const p=ys(r.current,{ignoreTransform:!0}),m={x:f.left-p.left,y:f.top-p.top,scaleX:f.width/p.width,scaleY:f.height/p.height};(m.x||m.y)&&c(m)}}n!==d.current&&(d.current=n)},[e,n,r,i]),M.useEffect(()=>{l&&c(null)},[l]),l}function rA(s){let{animateLayoutChanges:e=Q_,attributes:n,disabled:r,data:i,getNewIndex:l=J_,id:c,strategy:d,resizeObserverConfig:f,transition:p=Z_}=s;const{items:m,containerId:y,activeIndex:C,disabled:S,disableTransforms:v,sortedRects:x,overIndex:w,useDragOverlay:R,strategy:L}=M.useContext(jy),O=aA(r,S),j=m.indexOf(c),F=M.useMemo(()=>({sortable:{containerId:y,index:j,items:m},...i}),[y,i,j,m]),G=M.useMemo(()=>m.slice(m.indexOf(c)),[m,c]),{rect:P,node:K,isOver:he,setNodeRef:Ee}=B_({id:c,data:F,disabled:O.droppable,resizeObserverConfig:{updateMeasurementsFor:G,...f}}),{active:ke,activatorEvent:ze,activeNodeRect:Be,attributes:je,setNodeRef:bt,listeners:X,isDragging:de,over:Ce,setActivatorNodeRef:Z,transform:ge}=z_({id:c,data:F,attributes:{...tA,...n},disabled:O.draggable}),z=vE(Ee,bt),T=!!ke,pe=T&&!v&&zc(C)&&zc(w),fe=!R&&de,me=fe&&pe?ge:null,Re=pe?me??(d??L)({rects:x,activeNodeRect:Be,activeIndex:C,overIndex:w,index:j}):null,Pe=zc(C)&&zc(w)?l({id:c,items:m,activeIndex:C,overIndex:w}):j,Me=ke?.id,Ge=M.useRef({activeId:Me,items:m,newIndex:Pe,containerId:y}),kt=m!==Ge.current.items,vt=e({active:ke,containerId:y,isDragging:de,isSorting:T,id:c,index:j,items:m,newIndex:Ge.current.newIndex,previousItems:Ge.current.items,previousContainerId:Ge.current.containerId,transition:p,wasDragging:Ge.current.activeId!=null}),hn=nA({disabled:!vt,index:j,node:K,rect:P});return M.useEffect(()=>{T&&Ge.current.newIndex!==Pe&&(Ge.current.newIndex=Pe),y!==Ge.current.containerId&&(Ge.current.containerId=y),m!==Ge.current.items&&(Ge.current.items=m)},[T,Pe,y,m]),M.useEffect(()=>{if(Me===Ge.current.activeId)return;if(Me!=null&&Ge.current.activeId==null){Ge.current.activeId=Me;return}const Xt=setTimeout(()=>{Ge.current.activeId=Me},50);return()=>clearTimeout(Xt)},[Me]),{active:ke,activeIndex:C,attributes:je,data:F,rect:P,index:j,newIndex:Pe,items:m,isOver:he,isSorting:T,isDragging:de,listeners:X,node:K,overIndex:w,over:Ce,setNodeRef:z,setActivatorNodeRef:Z,setDroppableNodeRef:Ee,setDraggableNodeRef:bt,transform:hn??Re,transition:Dt()};function Dt(){if(hn||kt&&Ge.current.newIndex===j)return eA;if(!(fe&&!Rf(ze)||!p)&&(T||vt))return zo.Transition.toString({...p,property:zy})}}function aA(s,e){var n,r;return typeof s=="boolean"?{draggable:s,droppable:!1}:{draggable:(n=s?.draggable)!=null?n:e.draggable,droppable:(r=s?.droppable)!=null?r:e.droppable}}function Pc(s){if(!s)return!1;const e=s.data.current;return!!(e&&"sortable"in e&&typeof e.sortable=="object"&&"containerId"in e.sortable&&"items"in e.sortable&&"index"in e.sortable)}const iA=[lt.Down,lt.Right,lt.Up,lt.Left],sA=(s,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:l,over:c,scrollableAncestors:d}}=e;if(iA.includes(s.code)){if(s.preventDefault(),!n||!r)return;const f=[];l.getEnabled().forEach(y=>{if(!y||y!=null&&y.disabled)return;const C=i.get(y.id);if(C)switch(s.code){case lt.Down:r.topC.top&&f.push(y);break;case lt.Left:r.left>C.left&&f.push(y);break;case lt.Right:r.left1&&(m=p[1].id),m!=null){const y=l.get(n.id),C=l.get(m),S=C?i.get(C.id):null,v=C?.node.current;if(v&&S&&y&&C){const w=$c(v).some((G,P)=>d[P]!==G),R=Hy(y,C),L=oA(y,C),O=w||!R?{x:0,y:0}:{x:L?r.width-S.width:0,y:L?r.height-S.height:0},j={x:S.left,y:S.top};return O.x&&O.y?j:jo(j,O)}}}};function Hy(s,e){return!Pc(s)||!Pc(e)?!1:s.data.current.sortable.containerId===e.data.current.sortable.containerId}function oA(s,e){return!Pc(s)||!Pc(e)||!Hy(s,e)?!1:s.data.current.sortable.index{const d=M.useId(),f=M.useRef({inProgress:!1,lastSortTime:0,lastActiveId:null}),p=$E(ly(jf,{activationConstraint:{distance:5}}),ly(Nf,{coordinateGetter:sA})),m=M.useCallback(S=>{f.current={inProgress:!0,lastSortTime:Date.now(),lastActiveId:S.active.id},l?.({activeId:S.active.id})},[l]),y=M.useCallback(S=>{const{active:v,over:x}=S,w=Date.now();if(!x||v.id===x.id){f.current.inProgress=!1;return}const{lastSortTime:R,lastActiveId:L,inProgress:O}=f.current;if(L===v.id&&w-R<500&&!O)return;f.current={inProgress:!1,lastSortTime:w,lastActiveId:v.id};const j=s.findIndex(G=>String(G[e])===String(v.id)),F=s.findIndex(G=>String(G[e])===String(x.id));if(j!==-1&&F!==-1&&j!==F){const G=Pf(s,j,F);i?.(G,{oldIndex:j,newIndex:F})}},[s,e,i]),C=s.map(S=>String(S[e]));return ft.jsx(N_,{id:d,sensors:p,collisionDetection:NE,onDragStart:m,onDragEnd:y,children:ft.jsx(X_,{items:C,strategy:lA[n],children:r})},c!==void 0?`${d}-v${c}`:d)},Uy=M.createContext(null),uA=({value:s,children:e})=>ft.jsx(Uy.Provider,{value:s,children:e}),dA=()=>M.useContext(Uy),fA=({id:s,handle:e,as:n="div",children:r})=>{const{attributes:i,listeners:l,setNodeRef:c,transform:d,transition:f,isDragging:p}=rA({id:s}),m={transform:zo.Transform.toString(d),transition:f,opacity:p?.5:1,position:"relative"};return ft.jsx(n,{ref:c,style:m,...i,...e?{}:l,"data-sortable-item":!0,"data-sortable-id":String(s),"data-dragging":p,children:ft.jsx(uA,{value:{listeners:l,handle:e,isDragging:p},children:r})})},at=dt("DynamicRenderer");function la(){try{return window.G7Core?.devTools}catch{return}}function qf(s,e,n,r){if(typeof s=="string"){if(/\$t:[a-zA-Z_][a-zA-Z0-9_.\-]*/.test(s))try{return e.resolveTranslations(s,n,r)}catch{return s}return s}if(Array.isArray(s))return s.map(i=>qf(i,e,n,r));if(s&&typeof s=="object"){const i={};for(const[l,c]of Object.entries(s))i[l]=qf(c,e,n,r);return i}return s}function hA(s){const e=Object.keys(s);return e.length>0&&e.every(n=>/^\d+$/.test(n))}const dr=(s,e)=>{const n=["errors"],r={...s};for(const i of Object.keys(e)){const l=e[i],c=s[i];if(l===null){r[i]=null;continue}if(n.includes(i)){r[i]=l;continue}if(Array.isArray(l)){r[i]=l;continue}if(Array.isArray(c)&&l!==null&&typeof l=="object"&&!Array.isArray(l)&&hA(l)){const d=Object.keys(l).map(p=>parseInt(p,10));if((d.length>0?Math.max(...d):0)>=c.length+d.length+10)r[i]={...l};else{const p=[...c];for(const[m,y]of Object.entries(l)){const C=parseInt(m,10);C>=0&&C=p.length&&(p[C]=y)}r[i]=p}}else l!==null&&typeof l=="object"&&c!==null&&typeof c=="object"&&!Array.isArray(c)?r[i]=dr(c,l):r[i]=l}return r},pA=(s,e,n,r)=>{if(!e||typeof e!="object"||Array.isArray(e))return s;const i=dr(s,e);return ty(i,n,r)},Bc=(s,e)=>{let n=null;const r=()=>(n===null&&(n={...s}),n);for(const i of Object.keys(e)){if(!(i in s))continue;const l=e[i],c=s[i];if(l!==null&&typeof l=="object"&&!Array.isArray(l)&&c!==null&&typeof c=="object"&&!Array.isArray(c)){const d=Bc(c,l);if(d===c)continue;Object.keys(d).length===0?delete r()[i]:r()[i]=d}else delete r()[i]}return n??s},gA=s=>{const e={},n=s.split(";").filter(r=>r.trim());for(const r of n){const i=r.indexOf(":");if(i===-1)continue;const l=r.substring(0,i).trim(),c=r.substring(i+1).trim();if(l&&c){const d=l.replace(/-([a-z])/g,(f,p)=>p.toUpperCase());e[d]=c}}return e};class mA extends M.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,n){at.error(`컴포넌트 렌더링 에러 (ID: ${this.props.componentId}, Name: ${this.props.componentName}):`,e,n)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:ft.jsxs("div",{className:"p-4 my-2 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg text-red-800 dark:text-red-400",children:[ft.jsx("div",{className:"font-semibold mb-1",children:"컴포넌트 로드 실패"}),ft.jsxs("div",{className:"text-xs opacity-80",children:[this.props.componentName&&`[${this.props.componentName}] `,"데이터를 표시할 수 없습니다."]}),this.state.error&&ft.jsxs("details",{className:"mt-2",children:[ft.jsx("summary",{className:"cursor-pointer text-xs opacity-70 hover:opacity-100",children:"상세 정보"}),ft.jsx("div",{className:"mt-1 p-2 bg-red-100 dark:bg-red-900/30 rounded text-xs font-mono whitespace-pre-wrap break-all",children:this.state.error.message})]})]}):this.props.children}}const Vr=M.memo(({componentDef:s,dataContext:e,translationContext:n,registry:r,bindingEngine:i,translationEngine:l,actionDispatcher:c,parentComponentContext:d,parentFormContextProp:f,parentDataContext:p,isRootRenderer:m=!1,isInsideIteration:y=!1,isEditMode:C=!1,onComponentSelect:S,onComponentHover:v,onDragStart:x,onDragEnd:w,componentPath:R,layoutKey:L})=>{const[O,j]=M.useState({loadingActions:{}});M.useLayoutEffect(()=>{d||(i.startRenderCycle(),window.__g7SetLocalOverrideKeys||(window.__g7ForcedLocalFields=void 0),window.__g7PendingLocalState=null)});const F=M.useRef(null);M.useLayoutEffect(()=>{if(!d&&e._localInit&&typeof e._localInit=="object"){const{_forceLocalInit:q,_merge:oe,...ce}=e._localInit,J=`${JSON.stringify(ce)}:${q||"no-force"}`;if(F.current!==J){F.current=J;const ve=oe||"shallow",we=window.G7Core?.state?.get?.()?._local||{},_e=window.__g7PendingLocalState||{},qe={...we,..._e};ve==="replace"?window.__g7PendingLocalState={loadingActions:qe.loadingActions||{},...ce,hasChanges:!1}:ve==="deep"?window.__g7PendingLocalState=dr(qe,{...ce,hasChanges:!1}):window.__g7PendingLocalState={...qe,...ce,hasChanges:!1};const xe=window.__g7SetLocalOverrideKeys;xe&&typeof xe=="object"&&(ve==="replace"?window.__g7SetLocalOverrideKeys={...ce,hasChanges:!1}:window.__g7SetLocalOverrideKeys=dr(xe,{...ce,hasChanges:!1}))}}}),M.useLayoutEffect(()=>{if(!d){const q=window.__g7SetLocalOverrideKeys;if(q){j(ve=>Bc(ve,q));const oe=q,ce=window.__g7ForcedLocalFields,J=window.__g7LastSetLocalSnapshot;queueMicrotask(()=>{window.__g7SetLocalOverrideKeys===oe&&(window.__g7SetLocalOverrideKeys=void 0),window.__g7ForcedLocalFields===ce&&(window.__g7ForcedLocalFields=void 0),window.__g7LastSetLocalSnapshot===J&&(window.__g7LastSetLocalSnapshot=void 0)})}}},[e._local]);const G=M.useRef(L);M.useEffect(()=>{s._fromBase&&L&&G.current!==L&&(G.current=L,j({loadingActions:{}}))},[L,s._fromBase]);const P=M.useRef(""),K=M.useRef(!1),he=M.useRef(null),Ee=M.useRef(null),ke=M.useRef({}),ze=M.useRef({}),Be=M.useRef(p),je=bE(),bt=YC(),X=bt?.getParentDataContext()??p;M.useEffect(()=>{if(e._localInit&&typeof e._localInit=="object"){const{_forceLocalInit:q,...oe}=e._localInit,ce=JSON.stringify(oe),J=q!==void 0,ve=wf(),ue=`${ce}:${q||"no-force"}`,we=rE({globalTrackedKey:ve.hash,instanceHandledKey:Ee.current,trackingKey:ue});if(we==="apply"){Ee.current=ue,ve.hash=ue,ve.timestamp=q,P.current=ce,J&&(K.current=!0);const{_merge:qe,...xe}=oe,De=qe||"shallow";j(Ae=>De==="replace"?{loadingActions:Ae.loadingActions||{},...xe,hasChanges:!1}:De==="deep"?dr(Ae,{...xe,hasChanges:!1}):{...Ae,...xe,hasChanges:!1}),e._globalSetState&&e._globalSetState(Ae=>{const tt=Ae?._local||{};let Ne;return De==="replace"?Ne={...xe,hasChanges:!1}:De==="deep"?Ne=dr(tt,{...xe,hasChanges:!1}):Ne={...tt,...xe,hasChanges:!1},{...Ae,_local:Ne}}),i.invalidateCacheByKeys(["_local"]),at.log("_localInit applied (data changed):",Object.keys(oe))}else if(we==="prune"){Ee.current=ue;const{_merge:qe,...xe}=oe;j(Ae=>Bc(Ae,xe)),Bc(O,xe)!==O&&(i.invalidateCacheByKeys(["_local"]),at.log("_localInit pruned (applied by another renderer):",Object.keys(xe)))}he.current=e._localInit,tE(e._localInit)}},[e._localInit,p,i]);const{isTransitioning:de}=Jm(),Ce=uE(),Z=f??Ce,{width:ge}=Ef(),z=dA(),T=M.useMemo(()=>{let q=s;if(s.type==="iterator"&&s.data){const{data:J,itemName:ve,indexName:ue,...we}=s;q={...we,iteration:{source:J,item_var:ve||"item",index_var:ue}}}if(!q.responsive)return q;const oe=_i.getMatchingKey(q.responsive,ge);if(!oe)return q;const ce=q.responsive[oe];return{...q,props:{...q.props,...ce.props},children:ce.children??q.children,text:ce.text??q.text,if:ce.if??q.if,iteration:ce.iteration??q.iteration,__responsiveChildrenKey:ce.children!==void 0?oe:void 0}},[s,ge]),pe=M.useCallback(q=>{const oe=q?.__setStateId;if(j(ce=>{const J=window.__g7PendingLocalState,ue=window.__g7SetLocalOverrideKeys||J,we=ue?dr(ce,ue):ce;if(typeof q=="function"){const Ae=q(we);return dr(we,Ae)}const{__mergeMode:_e,__setStateId:qe,...xe}=q;let De;if(_e==="replace"?De=xe:_e==="shallow"?De={...we,...xe}:De=dr(we,xe),_e!==void 0){const Ae=window.__g7ForcedLocalFields;Ae&&(window.__g7ForcedLocalFields={...Ae,...xe})}return De}),oe){const ce=la();if(ce?.isEnabled()){const J=T.id||"unknown",ve=T.name||"Unknown";setTimeout(()=>{ce.trackComponentRender?.(J,ve,0,["_local"],[]),ce.completeStateChange?.(oe)},0)}}},[T.id,T.name]),fe=d?.state??O,me=d?.setState??pe,ae=M.useMemo(()=>{const q=e._localInit&&e._localInit!==he.current;let oe;q&&e._local?oe=e._local:oe=e._local?dr(e._local,fe):fe;const ce=window.__g7ForcedLocalFields;ce&&(oe=dr(oe,ce));const J={...e,_local:oe},ve=e._computedDefinitions;if(ve&&Object.keys(ve).length>0){const ue=new Tn,we={...J,...je?{_isolated:je.state}:{}},_e={},qe=la(),xe=qe?.isEnabled()??!1;for(const[De,Ae]of Object.entries(ve)){const tt=xe?Date.now():0,Ne=xe?e._computed?.[De]:void 0;let He;try{if(typeof Ae=="string")if(Ae.startsWith("{{")&&Ae.endsWith("}}")){const Se=Ae.slice(2,-2).trim(),$e=On(Se)?ue.evaluatePipeExpression(Se,we,{skipCache:!0}):ue.evaluateExpression(Se,we,{skipCache:!0});_e[De]=$e}else _e[De]=Ae;else if(Ae&&typeof Ae=="object"&&"$switch"in Ae){const Se=ue.resolveSwitch(Ae,we,{skipCache:!0});_e[De]=Se}}catch(Se){at.warn(`Failed to recalculate computed value: ${De}`,Se),_e[De]=e._computed?.[De],He=Se instanceof Error?Se.message:String(Se)}if(xe&&(He||Ne!==_e[De])){const $e=Date.now()-tt;qe.trackComputedProperty?.(De,typeof Ae=="string"?Ae:JSON.stringify(Ae),[{type:"_local",path:"_local",value:J._local}],_e[De],$e,T.id,He),Ne!==_e[De]&&qe.trackComputedRecalc?.(De,"dependency-change",Ne,_e[De],$e,{type:"_local",path:"_local"},T.id)}}J._computed=_e}if(je&&(J._isolated=je.state),X&&(J.$parent=X),s.extensionPointProps){const ue=i.resolveObject(s.extensionPointProps,J,y?{skipCache:!0}:void 0);J.extensionPointProps=C&&l?qf(ue,l,n,J):ue}return s.extensionPointCallbacks&&(J.extensionPointCallbacks=s.extensionPointCallbacks),C&&(J.$templateId===void 0&&n?.templateId&&(J.$templateId=n.templateId),J.$locale===void 0&&n?.locale&&(J.$locale=n.locale)),J},[e,fe,je?.state,X,bt?.version,s.extensionPointProps,s.extensionPointCallbacks]);ke.current=ae._local,ze.current=ae._computed||{},Be.current=X,M.useEffect(()=>{const q=la();if(!q?.isEnabled())return;const oe=ae._local;oe&&q.updateLocalState(oe);const ce=ae._computed;ce&&q.updateComputedState(ce),X&&q.updateParentContext?.(X);const J=T.id||`comp-${Date.now()}`,ve=T.name||"Unknown",ue={global:Object.keys(e._global||{}),local:Object.keys(oe||{}),context:d?Object.keys(d.state||{}):[]},we={type:d?"componentContext":"dynamicState",hasComponentContext:!!d,parentId:d?"parent":void 0};q.trackComponentStateSource?.(J,ve,ue,we),fe&&Object.keys(fe).length>0&&q.trackDynamicState?.(J,fe);const _e=!!(T.expandChildren||T.props?.expandChildren);q.trackContextFlow?.(J,ve,!!d,_e,!0)},[ae._local,e,T.id,T.name,d,fe,T.expandChildren,T.props?.expandChildren,X]);const Re=M.useMemo(()=>({state:{...ae._local},setState:me,stateRef:ke,computedRef:ze,isolatedContext:je,parentDataContext:ae}),[ae._local,me,O,je,ae]),Pe=M.useMemo(()=>{const q=os({if:T.if,condition:T.condition,conditions:T.conditions},ae,i,T.id);if(T.if||T.condition!==void 0||T.conditions){const ce=la();ce?.isEnabled()&&T.if&&ce.trackIfCondition(T.id||`if-${Date.now()}`,T.if,q)}return q},[T.if,T.conditions,ae,i,T.id]),Me=M.useMemo(()=>{if(!T.slot)return null;const q=T.slot;if(q.startsWith("{{")&&q.endsWith("}}")){const oe=q.slice(2,-2).trim();try{const ce={componentId:T.id,componentName:T.name,propName:"slot"},J=On(oe)?i.evaluatePipeExpression(oe,ae,void 0,ce):i.evaluateExpression(oe,ae,ce);return at.log(`[Slot] 표현식 평가: "${oe}" => "${J}" (컴포넌트: ${T.id})`),typeof J=="string"?J:null}catch(ce){return at.warn(`slot 표현식 평가 실패 (컴포넌트: ${T.id}):`,ce),null}}return at.log(`[Slot] 정적 슬롯 ID: "${q}" (컴포넌트: ${T.id})`),q},[T.slot,T.id,ae,i]),Ge=M.useMemo(()=>!Me||!T.id?"":`${T.id}-${Me}-${JSON.stringify(T.slotOrder??0)}`,[Me,T.id,T.slotOrder]),kt=M.useRef(null);M.useEffect(()=>{const q=window.__slotContextValue,oe=q?.isEnabled??!1;if(T.slot&&at.log(`[Slot Registration] 컴포넌트: ${T.id}, isSlotEnabled: ${oe}, shouldRender: ${Pe}, resolvedSlotId: ${Me}`),!oe||!Pe){T.slot&&at.log(`[Slot Registration] 등록 스킵 - isSlotEnabled: ${oe}, shouldRender: ${Pe}`),kt.current&&T.id&&q&&(q.unregisterFromSlot(kt.current,T.id),kt.current=null);return}if(!Me||!T.id){T.slot&&at.log(`[Slot Registration] 등록 스킵 - resolvedSlotId: ${Me}, id: ${T.id}`),kt.current&&T.id&&q&&(q.unregisterFromSlot(kt.current,T.id),kt.current=null);return}kt.current&&kt.current!==Me&&q.unregisterFromSlot(kt.current,T.id);const ce={...T,slot:void 0,slotOrder:void 0};return q.registerToSlot(Me,T.id,{componentDef:ce,dataContext:e,order:T.slotOrder??0,parentFormContext:f??null,getParentComponentContext:()=>Re,translationContext:n,registrationKey:Ge}),kt.current=Me,()=>{const J=window.__slotContextValue;Me&&T.id&&J&&J.unregisterFromSlot(Me,T.id)}},[Pe,Me,T,e,f,Re,n,Ge]);const vt=M.useCallback(q=>{if(typeof q=="string"){if(oc(q))return Bd(q);if(lc(q)){const oe=[],ce=q.replace(new RegExp(`${yo}([^${Ci}]*)${Ci}`,"g"),(ve,ue)=>(oe.push(ue),`${Na}${oe.length-1}${Na}`));let J=ce;return/\$t:[a-zA-Z0-9._-]+/.test(ce)&&(J=l.resolveTranslations(ce,n,ae)),J.replace(new RegExp(`${Na}(\\d+)${Na}`,"g"),(ve,ue)=>oe[parseInt(ue)])}if(q.startsWith("$t:defer:"))return q;if(/\$t:[a-zA-Z0-9._-]+/.test(q)){const oe=q.trim();return oe.startsWith("{")&&oe.endsWith("}")||oe.startsWith("[")&&oe.endsWith("]")?q:l.resolveTranslations(q,n,ae)}return q}if(Array.isArray(q))return q.map(oe=>vt(oe));if(q&&typeof q=="object"){const oe={};for(const[ce,J]of Object.entries(q))oe[ce]=vt(J);return oe}return q},[l,n,ae]),hn=M.useCallback(q=>mo(q),[]),Dt=M.useCallback(q=>Ma(q),[]),Xt=M.useMemo(()=>{let q={...T.props||{}};const oe=["cellChildren","expandChildren","expandContext","render"],J=r.getMetadata(T.name)?.skipBindingKeys||[],ve=[...new Set([...oe,...J])],ue=y?{skipCache:!0}:void 0,we={...ue??{},skipBindingKeys:ve},_e=Se=>{if(ue)return ue;if(Se.startsWith("_computed")||Se.startsWith("$computed"))return{skipCache:!0}};for(const[Se,$e]of Object.entries(q))if(!ve.includes(Se))if(typeof $e=="string"){const et=Dt($e);if(et!==null){let Ot=!1,Mt=et;et.startsWith(lr)&&(Ot=!0,Mt=et.slice(lr.length));const Hn={componentId:T.id,componentName:T.name,propName:Se};let It;if(On(Mt))try{It=i.evaluatePipeExpression(Mt,ae,_e(Mt),Hn)}catch(jt){at.warn(`파이프 표현식 평가 실패 (컴포넌트: ${T.id}, prop: ${Se}):`,jt),It=void 0}else if(hn(Mt))try{It=i.evaluateExpression(Mt,ae,Hn)}catch(jt){at.warn(`표현식 평가 실패 (컴포넌트: ${T.id}, prop: ${Se}):`,jt),It=void 0}else It=i.resolve(Mt,ae,_e(Mt),Hn);q[Se]=Ot&&It!=null?ss(It):It}else{const Ot={componentId:T.id,componentName:T.name,propName:Se};q[Se]=i.resolveBindings($e,ae,ue,Ot)}}else Array.isArray($e)?q[Se]=$e.map(et=>typeof et=="string"?i.resolveBindings(et,ae,ue):typeof et=="object"&&et!==null?i.resolveObject(et,ae,we):et):$e&&typeof $e=="object"&&(q[Se]=i.resolveObject($e,ae,we));for(const[Se,$e]of Object.entries(q))q[Se]=vt($e);if(typeof q.style=="string"&&(q.style=gA(q.style)),q=ef(q,C?void 0:T.actions,ae,{componentContext:Re,actionDispatcher:c}),T.classMap){const Se=S0(T.classMap,ae,i,{skipCache:!0});if(Se){const $e=q.className||"";q.className=$e?`${$e} ${Se}`:Se}}T.style&&(q.style=T.style),T.actions&&T.actions.length>0&&T.type==="composite"&&Object.assign(q,fe),T.component_layout&&(q.__componentLayoutDefs=T.component_layout);const qe=T.expandChildren||T.props?.expandChildren,xe=T.props?.cellChildren,De=T.children&&T.children.length>0,Ae=T.component_layout,tt=T.slot,Ne=T.props?.modalId,He=T.type==="composite";return(qe||xe||De||Ae||tt||Ne||He)&&(q.__componentContext=Re),q},[T.props,T.actions,T.style,T.classMap,T.id,ae,n,i,l,Re,fe,vt,hn,Dt,y]),un=M.useRef(null),Ut=M.useMemo(()=>un.current&&Zm(un.current,Xt)?un.current:(un.current=Xt,Xt),[Xt]),$r=M.useMemo(()=>{const q=T.id;if(typeof q!="string"||!q.includes("{{"))return q;const oe=i.resolveBindings(q,ae,{skipCache:!0});return typeof oe=="string"?oe:q},[T.id,ae,i]),En=M.useMemo(()=>{const q=T.dataKey,oe=T.trackChanges,ce=T.debounce;if(q){const J=q.startsWith("_global."),ve=J?q.slice(8):q,ue=J?e._global:ae._local;return{dataKey:ve,trackChanges:oe??!1,debounce:ce,setState:J?_e=>{e._globalSetState?e._globalSetState(_e):at.warn("_global.formData 사용 시 _globalSetState가 필요합니다.")}:me,state:ue??{},_isGlobal:J}}if(Z.dataKey)return Z},[T.dataKey,T.trackChanges,T.debounce,T.id,me,ae._local,e._global,e._globalSetState,Z]),dn=M.useRef(new Set);M.useEffect(()=>{dn.current.clear()},[e._global?._remountKeys]);const pn=M.useCallback((q,oe)=>{const ce=e._global?._remountKeys;return q&&ce?.[q]&&!dn.current.has(q)?(dn.current.add(q),`${q}-remount-${ce[q]}`):q||oe},[e._global?._remountKeys]),fr=M.useMemo(()=>{if(T.text!==void 0){if(typeof T.text=="string"){const q=T.text;let oe=q;const ce={componentId:T.id,componentName:T.name,propName:"text",skipCache:!0},J=Dt(q);if(J!==null){let ve=!1,ue=J;if(J.startsWith(lr)&&(ve=!0,ue=J.slice(lr.length)),On(ue))try{oe=i.evaluatePipeExpression(ue,ae,{skipCache:!0},ce)}catch(we){at.warn(`text 파이프 표현식 평가 실패 (컴포넌트: ${T.id}):`,we),oe=""}else if(hn(ue))try{oe=i.evaluateExpression(ue,ae,ce)}catch(we){at.warn(`text 표현식 평가 실패 (컴포넌트: ${T.id}):`,we),oe=""}else oe=i.resolve(ue,ae,{skipCache:!0},ce);ve&&oe!=null&&(oe=ss(oe))}else q.includes("{{")&&(oe=i.resolveBindings(q,ae,{skipCache:!0},ce));return oe=vt(oe),oe??""}return T.text}return!T.children||T.children.length===0?null:T.children.map((q,oe)=>{if(typeof q=="string")return q;const ce=T.__responsiveChildrenKey,J=ce?`responsive.${ce}.children`:"children",ve=R?`${R}.${J}.${oe}`:`${oe}`,ue=q._fromBase?q.id||`child-${oe}`:pn(q.id,`child-${oe}`),we=!q._fromBase&&L?`${ue}_${L}`:ue;return ft.jsx(Vr,{componentDef:q,dataContext:ae,translationContext:n,registry:r,bindingEngine:i,translationEngine:l,actionDispatcher:c,parentComponentContext:Re,parentFormContextProp:En,isInsideIteration:y,isEditMode:C,onComponentSelect:S,onComponentHover:v,componentPath:ve,onDragStart:x,onDragEnd:w,layoutKey:L},we)})},[T.text,T.children,T.id,e,ae,n,r,i,l,c,Re,En,Dt,hn,vt,pn,y,C,S,v,R,x,w,L]),er=M.useMemo(()=>{if(!T.iteration)return null;try{const q=Zd(T.iteration.source,ae,i);if(!Array.isArray(q))return at.warn(`iteration source가 배열이 아닙니다 (컴포넌트: ${T.id}):`,q),null;const oe=la();return oe?.isEnabled()&&oe.trackIteration(T.id||`iteration-${Date.now()}`,T.iteration.source,T.iteration.item_var,T.iteration.index_var,q.length),q.map((ce,J)=>{const ve={...ae,[T.iteration.item_var]:ce,[`${T.iteration.item_var}_index`]:J};T.iteration.index_var&&(ve[T.iteration.index_var]=J);const ue=J===0||J===q.length-1;oe?.isEnabled()&&ue&&oe.trackNestedContext?.({componentId:`${T.id||"unknown"}-iter-${J}`,componentType:"iteration",parentContext:{available:Object.keys(ae),values:{}},ownContext:{added:[T.iteration.item_var,...T.iteration.index_var?[T.iteration.index_var]:[]],values:{[T.iteration.item_var]:ce,...T.iteration.index_var?{[T.iteration.index_var]:J}:{}}},depth:1});const we={...T,iteration:void 0,responsive:void 0},_e=R?`${R}.iteration.${J}`:`iteration.${J}`,qe=`${pn(T.id,"item")}-${J}`;return ft.jsx(Vr,{componentDef:we,dataContext:ve,translationContext:n,registry:r,bindingEngine:i,translationEngine:l,actionDispatcher:c,parentComponentContext:Re,parentFormContextProp:En,isInsideIteration:!0,isEditMode:C,onComponentSelect:S,onComponentHover:v,componentPath:_e,onDragStart:x,onDragEnd:w,layoutKey:L},qe)})}catch(q){return at.error(`iteration 렌더링 실패 (컴포넌트: ${T.id}):`,q),null}},[T.iteration,T.children,T.id,e,ae,n,r,i,l,c,Re,En,pn,C,S,v,R,x,w,L]),[Pt,St]=M.useState(0),da=M.useMemo(()=>{if(!T.sortable||!T.itemTemplate)return null;const{sortable:q,itemTemplate:oe}=T;try{const ce=Zd(q.source,ae,i);if(!Array.isArray(ce))return at.warn(`sortable source가 배열이 아닙니다 (컴포넌트: ${T.id}):`,ce),null;if(ce.length===0)return null;const J=q.itemKey||"id",ve=q.strategy||"verticalList",ue=q.itemVar||"$item",we=q.indexVar||"$index",_e=q.handle,qe=q.wrapperElement,xe=(tt,Ne)=>{const He=T.actions?.filter(Se=>Se.event==="onSortEnd"||Se.type==="onSortEnd");if(St(Se=>Se+1),He&&He.length>0&&c){const Se={...ae,$sortedItems:tt,$sortEvent:Ne};He.forEach($e=>{try{const et=c.createHandler($e,Se,Re),Ot=new Event("sortend");et(Ot)}catch(et){at.error(`onSortEnd action failed: ${$e.handler}`,et)}})}},De=tt=>{const Ne=T.actions?.filter(He=>He.event==="onSortStart"||He.type==="onSortStart");if(Ne&&Ne.length>0&&c){const He={...ae,$activeId:tt.activeId};Ne.forEach(Se=>{try{const $e=c.createHandler(Se,He,Re),et=new Event("sortstart");$e(et)}catch($e){at.error(`onSortStart action failed: ${Se.handler}`,$e)}})}},Ae=ce.map((tt,Ne)=>{const He=String(tt[J]),Se={...ae,[ue]:tt,[we]:Ne},$e=R?`${R}.sortable.${Ne}`:`sortable.${Ne}`,et=`${pn(T.id,"sortable-item")}-v${Pt}-${He}`;return ft.jsx(fA,{id:He,handle:_e,...qe?{as:qe}:{},children:(qe&&oe.children?oe.children:[oe]).map((Ot,Mt)=>ft.jsx(Vr,{componentDef:Ot,dataContext:Se,translationContext:n,registry:r,bindingEngine:i,translationEngine:l,actionDispatcher:c,parentComponentContext:Re,parentFormContextProp:void 0,isInsideIteration:!0,isEditMode:C,onComponentSelect:S,onComponentHover:v,componentPath:$e,onDragStart:x,onDragEnd:w,layoutKey:L},`${et}-child-${Mt}`))},et)});return ft.jsx(cA,{items:ce,itemKey:J,strategy:ve,onSortEnd:xe,onSortStart:De,sortVersion:Pt,children:Ae})}catch(ce){return at.error(`sortable 렌더링 실패 (컴포넌트: ${T.id}):`,ce),null}},[T.sortable,T.itemTemplate,T.actions,T.id,e,ae,n,r,i,l,c,Re,pn,C,S,v,R,x,w,Pt,L]),In=M.useRef(!1);M.useEffect(()=>{if(In.current)return;In.current=!0;const q=la();if(q?.isEnabled()&&q.trackMount(s.id,{name:s.name,type:s.type||"component",props:Ut}),s.lifecycle?.onMount&&s.lifecycle.onMount.length>0)for(const ce of s.lifecycle.onMount)try{const J=c.createHandler(ce,ae,Re),ve=new Event("mount");J(ve),at.log(`Lifecycle onMount executed: ${ce.handler} (Component: ${s.id})`)}catch(J){at.error(`Lifecycle onMount failed: ${ce.handler} (Component: ${s.id})`,J)}const oe=[];if(s.onComponentEvent&&s.onComponentEvent.length>0){const ce=window.G7Core;if(ce?.componentEvent?.on)for(const J of s.onComponentEvent){if(!J.event){at.warn(`onComponentEvent: event name is required (Component: ${s.id})`);continue}const ve=async we=>{try{const _e={...ae,_eventData:we},xe=await c.createHandler({handler:J.handler,params:J.params,onSuccess:J.onSuccess,onError:J.onError},_e,Re)(new CustomEvent(J.event,{detail:we}));return at.log(`onComponentEvent "${J.event}" handled: ${J.handler} (Component: ${s.id})`,{eventData:we,result:xe}),xe}catch(_e){throw at.error(`onComponentEvent "${J.event}" failed: ${J.handler} (Component: ${s.id})`,_e),_e}},ue=ce.componentEvent.on(J.event,ve);oe.push(ue),at.log(`onComponentEvent: Subscribed to "${J.event}" (Component: ${s.id})`)}else at.warn(`onComponentEvent: G7Core.componentEvent is not available (Component: ${s.id})`)}return()=>{const ce=la();ce?.isEnabled()&&ce.trackUnmount(s.id);for(const J of oe)try{J()}catch(ve){at.error(`onComponentEvent: Failed to unsubscribe (Component: ${s.id})`,ve)}if(oe.length>0&&at.log(`onComponentEvent: Unsubscribed ${oe.length} event(s) (Component: ${s.id})`),s.lifecycle?.onUnmount&&s.lifecycle.onUnmount.length>0)for(const J of s.lifecycle.onUnmount)try{const ve=c.createHandler(J,ae,Re),ue=new Event("unmount");ve(ue),at.log(`Lifecycle onUnmount executed: ${J.handler} (Component: ${s.id})`)}catch(ve){at.error(`Lifecycle onUnmount failed: ${J.handler} (Component: ${s.id})`,ve)}}},[]);const kn=M.useMemo(()=>{const q=Ut.dataKey,oe=Ut.trackChanges,ce=Ut.debounce;return q?{dataKey:q,trackChanges:oe??!1,debounce:ce,setState:me,state:fe}:null},[Ut.dataKey,Ut.trackChanges,Ut.debounce,me,fe]);M.useEffect(()=>{const q=T.dataKey||Ut.dataKey;if(!q)return;const oe=la();if(!oe?.isEnabled())return;const ce=[],J=ue=>{if(ue)for(const we of ue){const _e=we?.props?.name;if(_e&&ce.push({name:_e,type:we.name||we.type||"unknown"}),we?.children&&J(we.children),we?.slots)for(const qe of Object.values(we.slots))Array.isArray(qe)&&J(qe)}};if(s.children&&J(s.children),s.slots)for(const ue of Object.values(s.slots))Array.isArray(ue)&&J(ue);const ve=s.id||`form-${q}`;return oe.trackForm(ve,q,ce),()=>{oe.untrackForm(ve)}},[T,Ut.dataKey,s.id,s.children]);const Rn=M.useRef(null),jn=M.useRef(void 0);M.useEffect(()=>{const q=Ut?.name;if(!q||!Z.dataKey||!Z.setState||Ut?.autoBinding===!1)return;const oe=`${Z.dataKey}.${q}`,ce=window.__g7AutoBindingPaths??new Map;return window.__g7AutoBindingPaths=ce,ce.set(oe,(ce.get(oe)??0)+1),()=>{const J=ce.get(oe)??0;J<=1?ce.delete(oe):ce.set(oe,J-1)}},[Ut?.name,Ut?.autoBinding,Z.dataKey,Z.setState]);const gn=M.useMemo(()=>{const{dataKey:q,trackChanges:oe,debounce:ce,...J}=Ut,ve=J.name;if(!ve||!Z.dataKey||!Z.setState)return J;if(J.autoBinding===!1){const{autoBinding:He,...Se}=J;return Se}const ue=`${Z.dataKey}.${ve}`,we=dE(Z.state,ue),_e=we!==void 0?we:J.value,xe=r.getMetadata(s.name)?.bindingType,De=typeof _e=="boolean"&&(xe==="checked"||xe==="checkable"&&["checkbox","radio"].includes(J?.type)),Ae=Z.debounce,tt=He=>{const Se=Z.state||{},$e=ty(Se,ue,He);if(Z.trackChanges&&($e.hasChanges=!0),window.__g7PendingLocalState=pA($e,window.__g7ForcedLocalFields,ue,He),Z.setState($e),Z._isGlobal)return;const et=window.G7Core,Ot={[ue]:He};Z.trackChanges&&(Ot.hasChanges=!0),et?.state?.setLocal?.(Ot,{render:!1})},Ne=(He,Se)=>{Ae&&Ae>0?(Rn.current&&clearTimeout(Rn.current),Rn.current=setTimeout(()=>{tt(He),Rn.current=null,Se&&(Se(),window.__g7PendingLocalState=null)},Ae)):(tt(He),Se&&(Se(),window.__g7PendingLocalState=null))};if(De)return{...J,checked:_e,onChange:Se=>{const $e=Se.target.checked;tt($e),J.onChange&&J.onChange(Se)}};{const He=$e=>{const et=$e?.target?.value!==void 0?$e.target.value:$e;Ae&&Ae>0&&(jn.current=et);const Ot=$e?.target?{target:{value:et,name:$e.target.name,type:$e.target.type,checked:$e.target.checked},currentTarget:$e.currentTarget?{value:et,name:$e.currentTarget.name}:void 0}:$e;Ne(et,()=>{J.onChange&&J.onChange(Ot)})};let Se;return jn.current!==void 0?Rn.current!==null?Se=jn.current:String(_e??"")===String(jn.current)?(jn.current=void 0,Se=_e??""):Se=jn.current:Se=_e??"",{...J,value:Se,onChange:He}}},[Ut,Z,Z.state,Z.debounce]),fa=M.useMemo(()=>{const q=la();if(q?.isEnabled()&&q.trackRender(s.name),!Pe)return T.iteration?er:null;if(T.sortable&&T.itemTemplate)return da;if(T.iteration)return er;if(T.type==="extension_point"){const{layout:xe,columns:De,gap:Ae,className:tt,...Ne}=T.props||{};let He=tt||"";return xe==="grid"&&De?He=`${He} grid grid-cols-${De} gap-${Ae||4}`.trim():xe==="flex"&&(He=`${He} flex flex-col gap-${Ae||4}`.trim()),ft.jsx("div",{id:$r,className:He||void 0,...Ne,children:fr})}const oe=r.getComponent(T.name);if(!oe)return at.error(`컴포넌트를 찾을 수 없습니다: ${T.name} (ID: ${T.id})`,"componentDef:",JSON.stringify(T,null,2)),null;const ce=e._global?._remountKeys,J={...gn,id:gn.id??$r,...ce&&Object.keys(ce).length>0&&{__remountTrigger:JSON.stringify(ce)}};if(z?.listeners&&z.handle&&gn["data-drag-handle"]!==void 0&&(Object.assign(J,z.listeners),J.style={...J.style,cursor:z.isDragging?"grabbing":"grab"}),C){const xe=T.id||`auto_${T.name||T.type||"unknown"}_${Math.random().toString(36).substring(2,8)}`,De=Ne=>{typeof Ne.preventDefault=="function"&&Ne.preventDefault(),S&&(Ne.stopPropagation(),S(xe,Ne))},Ae={"data-editor-id":xe,"data-editor-name":T.name,"data-editor-type":T.type,onClick:De};R&&(Ae["data-editor-path"]=R);const tt=T.__editorSlotName??T.slot;typeof tt=="string"&&(Ae["data-editor-slot"]=tt),v&&(Ae.onMouseMove=Ne=>{Ne.stopPropagation(),v(xe,Ne)},Ae.onMouseLeave=Ne=>{v(null,Ne)}),Object.assign(J,Ae),J.editorAttrs=Ae}const ve=T.type==="basic",ue=T.type==="layout",_e=ve||ue?(()=>{const xe={};for(const[De,Ae]of Object.entries(J))De.startsWith("__")||De==="editorAttrs"&&ve||(xe[De]=Ae);return xe})():J;let qe=ft.jsx(oe,{..._e,children:fr});if(En&&(qe=ft.jsx(cE,{value:En,children:qe})),T.isolatedState){const xe=typeof T.isolatedState=="object"?T.isolatedState:{},De=e?._isolatedInit,Ae=De?{...xe,...De}:xe;qe=ft.jsx(yE,{initialState:Ae,scopeId:T.isolatedScopeId,children:qe})}return qe},[Pe,T.iteration,T.sortable,T.itemTemplate,T.type,T.name,T.id,T.props,T.isolatedState,T.isolatedScopeId,r,gn,fr,er,da,z,kn,C,S,v,x,w,R,e._global?._remountKeys]),zn=M.useMemo(()=>{const q=T.blur_until_loaded;if(!q||e?._global?.__isPreview)return!1;if(typeof q=="string"){const J=Dt(q);if(J!==null)try{const ve={componentId:T.id,componentName:T.name,propName:"blur_until_loaded"};return!!i.evaluateExpression(J,ae,ve)}catch(ve){return at.warn(`blur_until_loaded 표현식 평가 실패 (컴포넌트: ${T.id}):`,ve),!1}return!1}if(typeof q=="object"&&q!==null){if(!q.enabled)return!1;if(q.data_sources)return(Array.isArray(q.data_sources)?q.data_sources:[q.data_sources]).some(we=>e[we]===void 0);if(de)return!0;const J=["route","query","_global","_local","_dataSourceErrors"];return Object.keys(e).filter(ue=>!J.includes(ue)&&!ue.startsWith("_")).some(ue=>e[ue]===void 0)}if(de)return!0;const oe=["route","query","_global","_local","_dataSourceErrors"];return Object.keys(e).filter(J=>!oe.includes(J)&&!J.startsWith("_")).some(J=>e[J]===void 0)},[T.blur_until_loaded,T.id,de,e,ae,i,Dt]);if(zn){const q=T.blur_until_loaded;if(typeof q=="object"&&q?.data_sources){const ce=(Array.isArray(q.data_sources)?q.data_sources:[q.data_sources]).reduce((ve,ue)=>(ve[ue]=e[ue]===void 0?"UNDEFINED":"LOADED",ve),{}),J=Object.keys(e).filter(ve=>!ve.startsWith("_"));at.log(`[BLUR APPLIED] Component: ${T.id}, data_sources status:`,ce,"Available keys:",J)}else at.log(`[BLUR APPLIED] Component: ${T.id}, blur_until_loaded:`,q)}const Vt=M.useMemo(()=>{if(!T.blur_until_loaded)return{wrapperClasses:"",innerClasses:""};const q=Xt?.className||"";if(!q)return{wrapperClasses:"",innerClasses:""};const oe=[/^(sm:|md:|lg:|xl:|2xl:)?(col-span-|row-span-|col-start-|col-end-|row-start-|row-end-)/,/^(sm:|md:|lg:|xl:|2xl:)?(self-|place-self-|order-)/,/^(sm:|md:|lg:|xl:|2xl:)?(flex-shrink|flex-grow|flex-\d|basis-)/],ce=q.split(/\s+/).filter(Boolean),J=[],ve=[];for(const ue of ce)oe.some(_e=>_e.test(ue))?J.push(ue):ve.push(ue);return{wrapperClasses:J.join(" "),innerClasses:ve.join(" ")}},[T.blur_until_loaded,Xt?.className]),_n=window.__slotContextValue;return Me&&_n?.isEnabled?null:ft.jsx(mA,{componentId:s.id,componentName:s.name,children:T.blur_until_loaded?ft.jsx("div",{className:[Vt.wrapperClasses,zn?"opacity-50 blur-sm transition-all duration-300 pointer-events-none":void 0].filter(Boolean).join(" ")||void 0,children:fa}):fa})});Vr.displayName="DynamicRenderer",typeof window<"u"&&(window.__DynamicRenderer=Vr);function yA(s){const e={};try{const r=new URL(s,typeof window<"u"?window.location.origin:"http://localhost").searchParams,i=new Set;for(const l of r.keys()){if(i.has(l))continue;i.add(l);const c=r.getAll(l);c.length>1||l.endsWith("[]")?e[l]=c:e[l]=c[0]}}catch{}return e}function bA(s){try{return new URL(s,typeof window<"u"?window.location.origin:"http://localhost").pathname}catch{return s.split("?")[0]}}const $i=class $i{constructor(){$(this,"config",{enabled:!1,maxHistorySize:100,logLevel:"info",serverEndpoint:"/_boost/g7-debug/dump-state",autoCapture:!0});$(this,"stateHistory",[]);$(this,"snapshotIdCounter",0);$(this,"stateWatchers",new Map);$(this,"currentLocalState",{});$(this,"currentComputedState",{});$(this,"currentParentContext");$(this,"actionHistory",[]);$(this,"actionWatchers",new Set);$(this,"cacheStats",{hits:0,misses:0,entries:0});$(this,"cacheDecisions",[]);$(this,"cacheDecisionIdCounter",0);$(this,"maxCacheDecisions",200);$(this,"currentRenderCycleId",null);$(this,"isInActionExecution",!1);$(this,"isInIteration",!1);$(this,"mountedComponents",new Map);$(this,"eventListeners",new Map);$(this,"mountWatchers",new Set);$(this,"unmountWatchers",new Set);$(this,"renderCounts",new Map);$(this,"bindingEvalCount",0);$(this,"profilingData",[]);$(this,"isProfiling",!1);$(this,"profilingStartTime",0);$(this,"activeRequests",new Map);$(this,"requestHistory",[]);$(this,"pendingDataSources",new Set);$(this,"requestWatchers",new Set);$(this,"wsConnections",new Map);$(this,"wsMessageHistory",[]);$(this,"wsMessageWatchers",new Set);$(this,"ifConditions",new Map);$(this,"iterations",new Map);$(this,"conditionWatchers",new Set);$(this,"forms",new Map);$(this,"formWatchers",new Set);$(this,"expressionHistory",[]);$(this,"expressionWatchers",new Set);$(this,"expressionIdCounter",0);$(this,"dataSources",new Map);$(this,"dataPathTransforms",[]);$(this,"maxDataPathTransforms",100);$(this,"nestedContexts",[]);$(this,"nestedContextIdCounter",0);$(this,"maxNestedContexts",100);$(this,"formBindingIssues",[]);$(this,"formBindingValidations",[]);$(this,"formBindingIssueIdCounter",0);$(this,"maxFormBindingIssues",100);$(this,"computedProperties",new Map);$(this,"computedRecalcLogs",[]);$(this,"computedRecalcIdCounter",0);$(this,"maxComputedRecalcLogs",100);$(this,"handlers",new Map);$(this,"componentEventSubscriptions",new Map);$(this,"componentEventEmitHistory",[]);$(this,"componentEventIdCounter",0);$(this,"maxComponentEventHistory",100);$(this,"stateRenderingLogs",[]);$(this,"currentStateChangeContext",null);$(this,"stateRenderingIdCounter",0);$(this,"componentRenderCounts",new Map);$(this,"stateToComponentMap",new Map);$(this,"maxStateRenderingLogs",100);$(this,"componentStateSources",new Map);$(this,"contextFlowNodes",new Map);$(this,"dynamicStates",new Map);$(this,"styleIssues",[]);$(this,"componentStyles",new Map);$(this,"authEvents",[]);$(this,"authHeaderHistory",[]);$(this,"authEventIdCounter",0);$(this,"maxAuthEventHistory",50);$(this,"logHistory",[]);$(this,"logIdCounter",0);$(this,"maxLogHistory",500);$(this,"currentLayout",null);$(this,"layoutHistory",[]);$(this,"layoutIdCounter",0);$(this,"layoutStats",{totalLoads:0,cacheHits:0,apiLoads:0});$(this,"maxLayoutHistory",50);$(this,"executionDetails",new Map);$(this,"stateChangeHistory",[]);$(this,"dataSourceChangeHistory",[]);$(this,"changeAlerts",[]);$(this,"changeExpectations",new Map);$(this,"executionIdCounter",0);$(this,"stateChangeIdCounter",0);$(this,"alertIdCounter",0);$(this,"maxExecutionDetails",100);$(this,"maxStateChangeHistory",200);$(this,"maxChangeAlerts",100);$(this,"sequenceExecutions",[]);$(this,"sequenceExecutionStack",[]);$(this,"sequenceIdCounter",0);$(this,"maxSequenceExecutions",50);$(this,"staleClosureWarnings",[]);$(this,"staleClosureIdCounter",0);$(this,"maxStaleClosureWarnings",100);$(this,"stateCaptureRegistry",new Map);$(this,"modalStates",new Map);$(this,"modalStateIssues",[]);$(this,"modalStateRelations",[]);$(this,"modalStateChangeLogs",[]);$(this,"modalStateIssueIdCounter",0);$(this,"modalStateChangeLogIdCounter",0);$(this,"maxModalStateIssues",100);$(this,"maxModalStateChangeLogs",200);$(this,"namedActionDefinitions",{});$(this,"namedActionRefLogs",[]);$(this,"namedActionRefIdCounter",0);$(this,"maxNamedActionRefLogs",200);$(this,"debounceActionHistory",[]);$(this,"dataSourceUpdateHistory",[]);$(this,"debounceActionIdCounter",0);$(this,"dataSourceUpdateIdCounter",0)}static getInstance(){return $i.instance||($i.instance=new $i),$i.instance}initialize(){if(this.config.enabled=this.checkDebugMode(),!this.config.enabled){console.log("[G7DevTools] 비활성화됨 (환경설정 > 고급 설정 > 디버그 모드를 켜세요)");return}console.log("[G7DevTools] 활성화됨"),this.setupGlobalErrorHandler()}checkDebugMode(){try{if(window.G7Config?.debug===!0)return!0;const r=window.G7Core?.state?.get?.();return r?.settings?.advanced?.debug_mode===!0||r?._global?.settings?.advanced?.debug_mode===!0}catch{return!1}}isEnabled(){return this.config.enabled}setupGlobalErrorHandler(){window.addEventListener("error",e=>{this.config.enabled&&this.logAction({id:this.generateId(),type:"globalError",startTime:Date.now(),status:"error",error:{name:"Error",message:e.message,stack:e.error?.stack}})}),window.addEventListener("unhandledrejection",e=>{this.config.enabled&&this.logAction({id:this.generateId(),type:"unhandledRejection",startTime:Date.now(),status:"error",error:{name:"UnhandledRejection",message:String(e.reason)}})})}captureStateSnapshot(e){if(!this.config.enabled)return;const n={id:++this.snapshotIdCounter,timestamp:Date.now(),source:e.source,prev:this.sanitizeObject(e.prev),next:this.sanitizeObject(e.next),diff:e.diff};this.stateHistory.push(n),this.stateHistory.length>this.config.maxHistorySize&&this.stateHistory.shift(),this.notifyStateWatchers(n)}getState(){try{const e=window.G7Core,n=e?.state?.get?.()||{},r={};if(e?._isolatedStates&&typeof e._isolatedStates=="object")for(const[i,l]of Object.entries(e._isolatedStates))r[i]=this.sanitizeObject(l);return{_global:n._global||n,_local:this.currentLocalState,_computed:this.currentComputedState,_isolated:Object.keys(r).length>0?r:void 0,$parent:this.currentParentContext}}catch{return{_global:{},_local:this.currentLocalState,_computed:this.currentComputedState}}}updateLocalState(e){this.config.enabled&&(this.currentLocalState=this.sanitizeObject(e))}updateComputedState(e){this.config.enabled&&(this.currentComputedState=this.sanitizeObject(e))}updateParentContext(e){this.config.enabled&&(this.currentParentContext=e?this.sanitizeObject(e):void 0)}getStateHistory(){return[...this.stateHistory]}getDualStorageMismatch(){const e=this.currentLocalState||{};let n={};try{n=(window.G7Core?.state?.get?.()||{})._local||{}}catch{n={}}const r=this.findMismatchedLeafPaths(e,n);return{hasMismatch:r.length>0,mismatchedPaths:r,storageA:e,storageB:n}}findMismatchedLeafPaths(e,n,r=""){const i=[],l=new Set([...Object.keys(e||{}),...Object.keys(n||{})]);for(const c of l){const d=r?`${r}.${c}`:c,f=e?.[c],p=n?.[c],m=f&&typeof f=="object"&&!Array.isArray(f),y=p&&typeof p=="object"&&!Array.isArray(p);if(m&&y)i.push(...this.findMismatchedLeafPaths(f,p,d));else{const C=f===void 0?"__undefined__":JSON.stringify(f),S=p===void 0?"__undefined__":JSON.stringify(p);C!==S&&i.push(d)}}return i}watchState(e,n){return this.stateWatchers.has(e)||this.stateWatchers.set(e,new Set),this.stateWatchers.get(e).add(n),()=>{this.stateWatchers.get(e)?.delete(n)}}notifyStateWatchers(e){if(this.stateWatchers.get("*")?.forEach(n=>{try{n(e.next,e.prev,"*")}catch(r){console.error("[G7DevTools] State watcher error:",r)}}),e.diff)for(const n of e.diff.changed)this.stateWatchers.get(n.path)?.forEach(r=>{try{r(n.newValue,n.oldValue,n.path)}catch(i){console.error("[G7DevTools] State watcher error:",i)}})}diffSnapshots(e,n){const r=this.stateHistory.find(l=>l.id===e),i=this.stateHistory.find(l=>l.id===n);return!r||!i?null:this.calculateDiff(r.next,i.next)}calculateDiff(e,n,r=""){const i={added:[],removed:[],changed:[]},l=new Set(Object.keys(e)),c=new Set(Object.keys(n));for(const d of c){const f=r?`${r}.${d}`:d;l.has(d)?JSON.stringify(e[d])!==JSON.stringify(n[d])&&i.changed.push({path:f,oldValue:e[d],newValue:n[d]}):i.added.push(f)}for(const d of l){const f=r?`${r}.${d}`:d;c.has(d)||i.removed.push(f)}return i}logAction(e){if(!this.config.enabled)return;const n=this.actionHistory.findIndex(r=>r.id===e.id);n>=0?this.actionHistory[n]={...this.actionHistory[n],...e}:(this.actionHistory.push(e),this.actionHistory.length>this.config.maxHistorySize&&this.actionHistory.shift()),this.isProfiling&&this.profilingData.push({type:"action",action:e.type,timestamp:performance.now(),duration:e.duration}),this.notifyActionWatchers(e)}getActionHistory(){return[...this.actionHistory]}watchActions(e){return this.actionWatchers.add(e),()=>{this.actionWatchers.delete(e)}}notifyActionWatchers(e){this.actionWatchers.forEach(n=>{try{n(e)}catch(r){console.error("[G7DevTools] Action watcher error:",r)}})}getActionMetrics(){const e=this.actionHistory.filter(l=>l.status==="success"),n=this.actionHistory.filter(l=>l.status==="error"),r={};for(const l of this.actionHistory)r[l.type]=(r[l.type]||0)+1;const i=e.reduce((l,c)=>l+(c.duration||0),0);return{totalActions:this.actionHistory.length,successCount:e.length,errorCount:n.length,averageDuration:e.length>0?i/e.length:0,actionsByType:r}}recordCacheHit(){this.config.enabled&&this.cacheStats.hits++}recordCacheMiss(){this.config.enabled&&this.cacheStats.misses++}updateCacheEntries(e){this.config.enabled&&(this.cacheStats.entries=e)}getCacheStats(){const e=this.cacheStats.hits+this.cacheStats.misses;return{...this.cacheStats,hitRate:e>0?this.cacheStats.hits/e:0}}resetCacheStats(){this.cacheStats={hits:0,misses:0,entries:0}}trackCacheDecision(e){if(!this.config.enabled)return;const n={id:`cache-${++this.cacheDecisionIdCounter}`,timestamp:Date.now(),expression:e.expression,decision:e.decision,reason:e.reason,context:{isInIteration:this.isInIteration,isInAction:this.isInActionExecution,renderCycleId:this.currentRenderCycleId||void 0,componentId:e.componentId,skipCacheOption:e.skipCacheOption},cachedValue:e.cachedValue!==void 0?this.safeClone(e.cachedValue):void 0,freshValue:e.freshValue!==void 0?this.safeClone(e.freshValue):void 0,valueMatch:e.cachedValue!==void 0&&e.freshValue!==void 0?JSON.stringify(e.cachedValue)===JSON.stringify(e.freshValue):void 0,duration:e.duration};this.cacheDecisions.push(n),this.cacheDecisions.length>this.maxCacheDecisions&&this.cacheDecisions.shift(),e.decision==="cache_hit"?this.cacheStats.hits++:(e.decision==="cache_miss"||e.decision==="skip_cache")&&this.cacheStats.misses++}startRenderCycle(e){return this.currentRenderCycleId=`render-${Date.now()}-${e||"root"}`,this.currentRenderCycleId}endRenderCycle(){this.currentRenderCycleId=null}startActionContext(){this.isInActionExecution=!0}endActionContext(){this.isInActionExecution=!1}startIterationContext(){this.isInIteration=!0}endIterationContext(){this.isInIteration=!1}getCacheDecisionTrackingInfo(){const e=this.getCacheDecisionStats();return{decisions:[...this.cacheDecisions],stats:e,timestamp:Date.now()}}getCacheDecisionStats(){const e=this.cacheDecisions;let n=0,r=0,i=0,l=0;const c={},d={};for(const p of e)p.decision==="cache_hit"?n++:p.decision==="cache_miss"?r++:p.decision==="skip_cache"?i++:p.decision==="invalidate"&&l++,c[p.reason]=(c[p.reason]||0)+1,p.context.componentId&&(d[p.context.componentId]=(d[p.context.componentId]||0)+1);const f=n+r+i;return{totalDecisions:e.length,cacheHits:n,cacheMisses:r,skipCacheCount:i,invalidateCount:l,byReason:c,byComponent:d,avgHitRate:f>0?n/f:0}}getRecentCacheDecisions(e=20,n){let r=[...this.cacheDecisions];return n&&(r=r.filter(i=>i.decision===n)),r.slice(-e)}clearCacheDecisionData(){this.cacheDecisions=[],this.cacheDecisionIdCounter=0}summarizePropsForLifecycle(e){if(!e||typeof e!="object")return e;const n={},r=["children","ref","key"];for(const[i,l]of Object.entries(e))if(!r.includes(i))if(l==null)n[i]=l;else if(Array.isArray(l))n[i]=`[Array(${l.length})]`;else if(typeof l=="object"){const c=Object.keys(l);c.length<=3?n[i]=`{${c.join(", ")}}`:n[i]=`{${c.slice(0,3).join(", ")}, ... +${c.length-3}}`}else typeof l=="string"&&l.length>50?n[i]=l.substring(0,50)+"...":typeof l=="function"?n[i]="[Function]":n[i]=l;return n}trackMount(e,n){if(!this.config.enabled)return;const r=this.summarizePropsForLifecycle(n.props),i={...n,props:r,id:e,mountTime:Date.now()};this.mountedComponents.set(e,i),this.mountWatchers.forEach(l=>{try{l({componentId:e,componentName:n.name,timestamp:i.mountTime})}catch(c){console.error("[G7DevTools] Mount watcher error:",c)}})}trackUnmount(e){if(!this.config.enabled)return;const n=this.mountedComponents.get(e),r=this.eventListeners.get(e)||[];r.length>0&&console.warn(`[G7DevTools] 컴포넌트 ${e} 언마운트 시 ${r.length}개 리스너 미정리`),n&&this.unmountWatchers.forEach(i=>{try{i({componentId:e,componentName:n.name,timestamp:Date.now(),orphanedListeners:r.length})}catch(l){console.error("[G7DevTools] Unmount watcher error:",l)}}),this.mountedComponents.delete(e)}trackListener(e,n,r){if(!this.config.enabled)return;const i=this.eventListeners.get(e)||[];i.push({type:n,target:r,addedAt:Date.now()}),this.eventListeners.set(e,i)}removeListener(e,n){if(!this.config.enabled)return;const r=this.eventListeners.get(e)||[],i=r.findIndex(l=>l.type===n);i>=0&&r.splice(i,1)}getMountedComponents(){return Array.from(this.mountedComponents.values())}getOrphanedListeners(){const e=[];for(const[n,r]of this.eventListeners)this.mountedComponents.has(n)||e.push(...r.map(i=>({...i,componentId:n})));return e}watchMount(e){return this.mountWatchers.add(e),()=>{this.mountWatchers.delete(e)}}watchUnmount(e){return this.unmountWatchers.add(e),()=>{this.unmountWatchers.delete(e)}}trackRender(e){if(!this.config.enabled)return;const n=this.renderCounts.get(e)||0;this.renderCounts.set(e,n+1),this.isProfiling&&this.profilingData.push({type:"render",component:e,timestamp:performance.now()})}trackBindingEval(e){this.config.enabled&&(this.bindingEvalCount++,this.isProfiling&&e&&this.profilingData.push({type:"binding",expression:e,timestamp:performance.now()}))}getRenderCount(){return new Map(this.renderCounts)}getBindingEvalCount(){return this.bindingEvalCount}getMemoryWarnings(){const e=[];try{const i=this.getState(),l=JSON.stringify(i).length;l>1e6&&e.push({type:"large-state",message:`상태 크기가 ${(l/1024/1024).toFixed(2)}MB입니다`,suggestion:"불필요한 데이터 정리 필요",severity:l>5e6?"error":"warning"})}catch{}this.stateHistory.length>this.config.maxHistorySize*.8&&e.push({type:"large-history",message:`상태 이력이 ${this.stateHistory.length}개입니다`,suggestion:"maxHistory 설정 조정 필요",severity:"warning"});const n=this.getOrphanedListeners().length;n>0&&e.push({type:"orphaned-listeners",message:`${n}개의 정리되지 않은 이벤트 리스너`,suggestion:"useEffect cleanup 또는 removeEventListener 확인",severity:n>10?"error":"warning"});const r=Array.from(this.renderCounts.entries()).filter(([,i])=>i>50);return r.length>0&&e.push({type:"excessive-renders",message:`${r.length}개 컴포넌트가 50회 이상 렌더링`,suggestion:"React.memo, useMemo, useCallback 사용 고려",severity:"warning"}),e}startProfiling(){this.config.enabled&&(this.isProfiling=!0,this.profilingData=[],this.profilingStartTime=performance.now(),console.log("[G7DevTools] 프로파일링 시작"))}stopProfiling(){this.isProfiling=!1;const e=performance.now()-this.profilingStartTime,n=this.analyzeProfile(e);return console.log("[G7DevTools] 프로파일링 완료",n),n}analyzeProfile(e){const n=this.profilingData.filter(p=>p.type==="render"),r=this.profilingData.filter(p=>p.type==="binding"),i=this.profilingData.filter(p=>p.type==="action"),l={};for(const p of n)p.component&&(l[p.component]||(l[p.component]={count:0,durations:[]}),l[p.component].count++,p.duration&&l[p.component].durations.push(p.duration));const c=Object.entries(l).map(([p,m])=>({name:p,renderCount:m.count,avgDuration:m.durations.length>0?m.durations.reduce((y,C)=>y+C,0)/m.durations.length:0})).sort((p,m)=>m.renderCount-p.renderCount).slice(0,10),d={};for(const p of r)p.expression&&(d[p.expression]=(d[p.expression]||0)+1);const f=Object.entries(d).sort(([,p],[,m])=>m-p).slice(0,10).map(([p])=>p);return{duration:e,entries:this.profilingData,summary:{totalRenders:n.length,totalBindings:r.length,totalActions:i.length,slowestComponents:c,hotPaths:f}}}resetPerformanceStats(){this.renderCounts.clear(),this.bindingEvalCount=0,this.profilingData=[]}trackRequest(e,n,r){if(!this.config.enabled)return"";const i=this.generateId(),l=bA(e),c=yA(e);return this.activeRequests.set(i,{id:i,url:l,fullUrl:e,queryParams:c,method:n,startTime:Date.now(),status:"pending",requestBody:r?.requestBody?this.sanitizeObject(r.requestBody):void 0,dataSourceId:r?.dataSourceId}),this.isProfiling&&this.profilingData.push({type:"network",timestamp:performance.now()}),i}completeRequest(e,n,r){if(!this.config.enabled)return;const i=this.activeRequests.get(e);if(!i)return;const l={...i,status:n>=200&&n<300?"success":"error",statusCode:n,duration:Date.now()-i.startTime,endTime:Date.now(),response:this.sanitizeObject(r)};this.requestHistory.push(l),this.activeRequests.delete(e),this.requestHistory.length>this.config.maxHistorySize&&this.requestHistory.shift(),this.notifyRequestWatchers(l)}failRequest(e,n){if(!this.config.enabled)return;const r=this.activeRequests.get(e);if(!r)return;const i={...r,status:"error",error:n,duration:Date.now()-r.startTime,endTime:Date.now()};this.requestHistory.push(i),this.activeRequests.delete(e),this.notifyRequestWatchers(i)}trackDataSource(e){this.config.enabled&&this.pendingDataSources.add(e)}completeDataSource(e){this.config.enabled&&this.pendingDataSources.delete(e)}getActiveRequests(){return Array.from(this.activeRequests.values())}getRequestHistory(){return[...this.requestHistory]}getPendingDataSources(){return Array.from(this.pendingDataSources)}watchRequest(e){return this.requestWatchers.add(e),()=>{this.requestWatchers.delete(e)}}notifyRequestWatchers(e){this.requestWatchers.forEach(n=>{try{n(e)}catch(r){console.error("[G7DevTools] Request watcher error:",r)}})}trackWebSocketConnection(e,n,r){this.config.enabled&&this.wsConnections.set(e,{id:e,url:n,state:r,connectedAt:r==="open"?Date.now():void 0})}trackWebSocketMessage(e,n,r,i){if(!this.config.enabled)return;const l={id:this.generateId(),connectionId:e,direction:n,type:r,payload:this.sanitizeObject(i),timestamp:Date.now(),sequence:this.wsMessageHistory.length};this.wsMessageHistory.push(l),this.wsMessageHistory.length>this.config.maxHistorySize&&this.wsMessageHistory.shift(),this.notifyWebSocketWatchers(l)}getWebSocketConnections(){return Array.from(this.wsConnections.values())}getWebSocketMessageHistory(){return[...this.wsMessageHistory]}getWebSocketConnectionState(){const e=Array.from(this.wsConnections.values());return e.some(n=>n.state==="open")?"connected":e.some(n=>n.state==="connecting")?"reconnecting":"disconnected"}watchWebSocketMessage(e){return this.wsMessageWatchers.add(e),()=>{this.wsMessageWatchers.delete(e)}}notifyWebSocketWatchers(e){this.wsMessageWatchers.forEach(n=>{try{n(e)}catch(r){console.error("[G7DevTools] WebSocket watcher error:",r)}})}trackIfCondition(e,n,r){if(!this.config.enabled)return;const i=this.ifConditions.get(e),l=i?.evaluatedValue;this.ifConditions.set(e,{id:e,expression:n,evaluatedValue:r,evaluationCount:(i?.evaluationCount||0)+1,lastEvaluated:Date.now()}),i&&l!==r&&this.notifyConditionWatchers({id:e,expression:n,oldValue:l,newValue:r,timestamp:Date.now()})}trackIteration(e,n){this.config.enabled&&this.iterations.set(e,{id:e,...n,lastRendered:Date.now()})}getIfConditions(){return Array.from(this.ifConditions.values())}getIterations(){return Array.from(this.iterations.values())}getScopeChain(e){const n=[],r=this.getState();return n.push({name:"_global",value:r._global,source:"global"}),n.push({name:"_local",value:r._local,source:"local"}),n.push({name:"_computed",value:r._computed,source:"computed"}),n}watchConditionChange(e){return this.conditionWatchers.add(e),()=>{this.conditionWatchers.delete(e)}}notifyConditionWatchers(e){this.conditionWatchers.forEach(n=>{try{n(e)}catch(r){console.error("[G7DevTools] Condition watcher error:",r)}})}trackForm(e,n,r){this.config.enabled&&this.forms.set(e,{id:e,dataKey:n,inputs:r,trackedAt:Date.now()})}trackFormChange(e,n,r){if(!this.config.enabled)return;const i={formId:e,inputName:n,value:r,timestamp:Date.now()};this.notifyFormWatchers(i)}untrackForm(e){this.forms.delete(e)}getForms(){return Array.from(this.forms.values())}getFormState(e){const n=this.getState();return this.getNestedValue(n,e)||{}}getBindingPath(e,n){return`${e}.${n}`}watchFormChange(e){return this.formWatchers.add(e),()=>{this.formWatchers.delete(e)}}notifyFormWatchers(e){this.formWatchers.forEach(n=>{try{n(e)}catch(r){console.error("[G7DevTools] Form watcher error:",r)}})}trackFormBindingIssue(e,n,r){if(!this.config.enabled)return;const i={id:`form-issue-${++this.formBindingIssueIdCounter}`,timestamp:Date.now(),type:e,severity:n,formId:r.formId,formDataKey:r.formDataKey,inputInfo:r.inputInfo,contextInfo:r.contextInfo,description:r.description,suggestion:r.suggestion,docLink:r.docLink};this.formBindingIssues.push(i),this.formBindingIssues.length>this.maxFormBindingIssues&&this.formBindingIssues.shift()}validateFormBinding(e,n,r,i){const l=r.map(f=>{const p=[];let m=!0;return f.name||(p.push("Input에 name 속성이 없습니다"),m=!1,this.trackFormBindingIssue("missing-input-name","error",{formId:e,formDataKey:n,inputInfo:{name:f.name,type:f.type},description:"Input에 name 속성이 없어 자동 바인딩이 동작하지 않습니다",suggestion:"Input에 name 속성을 추가하세요",docLink:"troubleshooting-components-form.md"})),n||(p.push("Form에 dataKey가 없습니다"),m=!1),{inputName:f.name||"(unnamed)",inputType:f.type,bindingPath:n&&f.name?`${n}.${f.name}`:"-",isValid:m,currentValue:f.value,issues:p}});if(n||this.trackFormBindingIssue("missing-datakey","error",{formId:e,description:"Form에 dataKey가 설정되지 않아 자동 바인딩이 동작하지 않습니다",suggestion:"Form 컴포넌트에 dataKey props를 설정하세요",docLink:"troubleshooting-components-form.md"}),i.isContextBroken){const f=i.breakReason?.includes("sortable")?"sortable-context-break":i.breakReason?.includes("modal")?"modal-context-isolation":"context-not-propagated";this.trackFormBindingIssue(f,"warning",{formId:e,formDataKey:n,contextInfo:{hasParentFormContext:i.hasParentContext,parentFormContextProp:i.parentContextProp,isInsideSortable:i.breakReason?.includes("sortable")||!1,isInsideModal:i.breakReason?.includes("modal")||!1,depth:0},description:i.breakReason||"Form 컨텍스트가 제대로 전파되지 않았습니다",suggestion:"parentFormContextProp={undefined}를 확인하거나 중첩 구조를 검토하세요",docLink:"troubleshooting-components-form.md"})}const c={formId:e,dataKey:n,timestamp:Date.now(),contextPropagation:i,inputBindings:l,isValid:l.every(f=>f.isValid)&&!!n&&!i.isContextBroken,issueCount:l.filter(f=>!f.isValid).length+(n?0:1)+(i.isContextBroken?1:0)},d=this.formBindingValidations.findIndex(f=>f.formId===e);return d>=0?this.formBindingValidations[d]=c:this.formBindingValidations.push(c),c}getFormBindingValidationTrackingInfo(){const e=this.getFormBindingValidationStats();return{issues:[...this.formBindingIssues],validations:[...this.formBindingValidations],stats:e,timestamp:Date.now()}}getFormBindingValidationStats(){const e={"missing-datakey":0,"missing-input-name":0,"context-not-propagated":0,"sortable-context-break":0,"modal-context-isolation":0,"duplicate-input-name":0,"value-type-mismatch":0,"binding-path-invalid":0},n={info:0,warning:0,error:0};for(const i of this.formBindingIssues)e[i.type]++,n[i.severity]++;const r=Object.entries(e).filter(([,i])=>i>0).sort((i,l)=>l[1]-i[1]).slice(0,5).map(([i,l])=>({type:i,count:l,description:this.getIssueTypeDescription(i)}));return{totalFormsValidated:this.formBindingValidations.length,validForms:this.formBindingValidations.filter(i=>i.isValid).length,formsWithIssues:this.formBindingValidations.filter(i=>!i.isValid).length,totalIssues:this.formBindingIssues.length,byIssueType:e,bySeverity:n,topIssues:r}}getIssueTypeDescription(e){return{"missing-datakey":"Form에 dataKey 누락","missing-input-name":"Input에 name 속성 누락","context-not-propagated":"Form 컨텍스트 전파 실패","sortable-context-break":"Sortable 컨테이너에서 컨텍스트 단절","modal-context-isolation":"모달에서 부모 Form 컨텍스트 격리","duplicate-input-name":"동일 Form 내 중복 Input name","value-type-mismatch":"값 타입과 Input 타입 불일치","binding-path-invalid":"바인딩 경로 유효하지 않음"}[e]||e}clearFormBindingIssues(){this.formBindingIssues=[],this.formBindingValidations=[],this.formBindingIssueIdCounter=0}trackComputedProperty(e,n,r,i,l,c,d){if(!this.config.enabled)return;const f=`computed-${e}-${c||"global"}`,p={id:f,name:e,expression:n,componentId:c,dependencies:r,currentValue:this.safeClone(i),lastComputedAt:Date.now(),computationTime:l,error:d};this.computedProperties.set(f,p)}trackComputedRecalc(e,n,r,i,l,c,d){if(!this.config.enabled)return;const f=`computed-${e}-${d||"global"}`,p=JSON.stringify(r)!==JSON.stringify(i),m={id:`recalc-${++this.computedRecalcIdCounter}`,computedId:f,computedName:e,timestamp:Date.now(),trigger:n,triggeredBy:c,previousValue:this.safeClone(r),newValue:this.safeClone(i),valueChanged:p,computationTime:l,cascadeCount:0};this.computedRecalcLogs.push(m),this.computedRecalcLogs.length>this.maxComputedRecalcLogs&&this.computedRecalcLogs.shift();const y=this.computedProperties.get(f);y&&(y.currentValue=this.safeClone(i),y.lastComputedAt=Date.now(),y.computationTime=l)}analyzeComputedDependencyChain(e,n){const r=new Set,i=[];let l=!1,c,d=0;const f=(m,y)=>{if(d=Math.max(d,y),r.has(m))return l=!0,c=[...i,m],{name:m,type:"computed",children:[],depth:y};r.add(m),i.push(m);const C=this.computedProperties.get(`computed-${m}-${n||"global"}`),S=[];if(C)for(const v of C.dependencies)v.type==="computed"?S.push(f(v.path,y+1)):S.push({name:v.path,type:v.type,children:[],depth:y+1});return i.pop(),r.delete(m),{name:m,type:"computed",children:S,depth:y}},p=f(e,0);return{root:e,tree:p,hasCycle:l,cyclePath:c,maxDepth:d}}getComputedDependencyTrackingInfo(){const e=Array.from(this.computedProperties.values()),n=this.getComputedDependencyStats(),r=[];for(const i of e){const l=this.analyzeComputedDependencyChain(i.name,i.componentId);r.push(l)}return{properties:e,recalcLogs:[...this.computedRecalcLogs],dependencyChains:r,stats:n,timestamp:Date.now()}}getComputedDependencyStats(){const e={"state-change":0,"datasource-update":0,"dependency-change":0,manual:0,initial:0},n={},r={};let i=0,l=0;for(const p of this.computedRecalcLogs)e[p.trigger]++,p.valueChanged||l++,n[p.computedName]=(n[p.computedName]||0)+1,r[p.computedName]||(r[p.computedName]=[]),r[p.computedName].push(p.computationTime),i+=p.computationTime;const c=Object.entries(n).sort((p,m)=>m[1]-p[1]).slice(0,5).map(([p,m])=>({name:p,count:m})),d=Object.entries(r).map(([p,m])=>({name:p,avgTime:m.reduce((y,C)=>y+C,0)/m.length})).sort((p,m)=>m.avgTime-p.avgTime).slice(0,5);let f=0;for(const p of this.computedProperties.values())this.analyzeComputedDependencyChain(p.name,p.componentId).hasCycle&&f++;return{totalComputed:this.computedProperties.size,totalRecalculations:this.computedRecalcLogs.length,unnecessaryRecalculations:l,avgComputationTime:this.computedRecalcLogs.length>0?i/this.computedRecalcLogs.length:0,topRecalculated:c,slowestComputed:d,cycleDetectionCount:f,byTrigger:e}}clearComputedTracking(){this.computedProperties.clear(),this.computedRecalcLogs=[],this.computedRecalcIdCounter=0}trackModalOpen(e){if(!this.config.enabled)return;const n={modalId:e.modalId,modalName:e.modalName,openedAt:Date.now(),closedAt:null,scopeType:e.scopeType||"isolated",parentModalId:e.parentModalId,componentId:e.componentId,initialState:e.initialState?{...e.initialState}:{},currentState:e.initialState?{...e.initialState}:{},stateChangeCount:0,isolatedStateKeys:e.isolatedStateKeys||[],sharedStateKeys:e.sharedStateKeys||[]};this.modalStates.set(e.modalId,n),this.validateModalDefinitionExists(e.modalId,e.modalName),e.parentModalId&&(this.modalStateRelations.find(i=>i.parentModalId===e.parentModalId&&i.childModalId===e.modalId)||this.modalStateRelations.push({parentModalId:e.parentModalId,childModalId:e.modalId,sharedKeys:e.sharedStateKeys||[],isolatedKeys:e.isolatedStateKeys||[],relationType:"parent-child"}))}trackModalClose(e,n){if(!this.config.enabled)return;const r=this.modalStates.get(e);r&&(r.closedAt=Date.now(),n&&(r.currentState={...n}),this.detectStateLeakage(r))}validateModalDefinitionExists(e,n){const r=this.currentLayout;if(!r?.layoutJson)return;const i=r.layoutJson.modals;if(!i){this.recordModalStateIssue({type:"missing-definition",modalId:e,modalName:n,severity:"error",description:`모달 "${e}"이(가) modalStack에 추가되었으나, 현재 레이아웃에 modals 섹션이 없습니다. 레이아웃 경로: ${r.layoutPath}`,affectedStateKeys:[],expectedValue:`modals 섹션에 id="${e}" 정의 존재`,actualValue:"modals 섹션 없음"});return}const l=Array.isArray(i)?i:Object.values(i);l.some(d=>d?.id===e||d?.props?.id===e)||this.recordModalStateIssue({type:"missing-definition",modalId:e,modalName:n,severity:"error",description:`모달 "${e}"이(가) modalStack에 추가되었으나, 렌더링된 레이아웃의 modals 섹션에 해당 ID의 정의가 없습니다. partial 로딩 실패, 레이아웃 병합 문제, extends 상속 누락 등을 확인하세요. 레이아웃 경로: ${r.layoutPath}`,affectedStateKeys:[],expectedValue:`modals 배열에 id="${e}" 항목 존재`,actualValue:`modals 배열에 ${l.length}개 모달 정의 (${l.map(d=>d?.id||"unknown").join(", ")})`})}trackModalStateChange(e){if(!this.config.enabled)return;const n=this.modalStates.get(e.modalId);if(!n)return;n.stateChangeCount++,n.currentState[e.stateKey]=e.newValue;const r=this.checkIsolationViolation(n,e.stateKey),i={id:`modal-change-${++this.modalStateChangeLogIdCounter}`,modalId:e.modalId,modalName:n.modalName,timestamp:Date.now(),stateKey:e.stateKey,previousValue:e.previousValue,newValue:e.newValue,changeSource:e.changeSource||"user-action",violatesIsolation:r};this.modalStateChangeLogs.push(i),this.modalStateChangeLogs.length>this.maxModalStateChangeLogs&&this.modalStateChangeLogs.shift(),r&&this.recordModalStateIssue({type:"isolation-violation",modalId:e.modalId,modalName:n.modalName,severity:"warning",description:`모달 '${n.modalName}'에서 격리된 상태 키 '${e.stateKey}'가 변경됨`,affectedStateKeys:[e.stateKey]})}detectStateLeakage(e){if(e.scopeType==="isolated")for(const n of e.isolatedStateKeys){const r=e.initialState[n],i=e.currentState[n];if(r!==i&&e.parentModalId){const l=this.modalStates.get(e.parentModalId);l&&l.currentState.hasOwnProperty(n)&&this.recordModalStateIssue({type:"state-leakage",modalId:e.modalId,modalName:e.modalName,severity:"error",description:`모달 닫힘 후 상태 '${n}'가 부모 모달로 유출될 수 있음`,affectedStateKeys:[n],leakedValue:i,expectedValue:r})}}}checkIsolationViolation(e,n){return e.scopeType==="isolated",!1}recordModalStateIssue(e){const n={id:`modal-issue-${++this.modalStateIssueIdCounter}`,type:e.type,modalId:e.modalId,modalName:e.modalName,timestamp:Date.now(),severity:e.severity,description:e.description,affectedStateKeys:e.affectedStateKeys,leakedValue:e.leakedValue,expectedValue:e.expectedValue,actualValue:e.actualValue,stackInfo:e.stackInfo};this.modalStateIssues.push(n),this.modalStateIssues.length>this.maxModalStateIssues&&this.modalStateIssues.shift()}getModalStateScopeTrackingInfo(){const e=Array.from(this.modalStates.values()),n=this.getModalStateScopeStats();return{modals:e,issues:[...this.modalStateIssues],relations:[...this.modalStateRelations],changeLogs:[...this.modalStateChangeLogs],stats:n,timestamp:Date.now()}}getModalStateScopeStats(){const e=Array.from(this.modalStates.values()),n={warning:0,error:0},r={"state-leakage":0,"isolation-violation":0,"parent-mutation":0,"orphaned-state":0,"scope-mismatch":0,"cleanup-failure":0,"missing-definition":0};for(const l of this.modalStateIssues)n[l.severity]++,r[l.type]++;const i={isolated:0,shared:0,inherited:0};for(const l of e)i[l.scopeType]++;return{totalModals:e.length,openModals:e.filter(l=>l.closedAt===null).length,nestedModals:e.filter(l=>l.parentModalId!==void 0).length,totalIssues:this.modalStateIssues.length,issuesBySeverity:n,issuesByType:r,byScope:i,leakageDetectionCount:r["state-leakage"],cleanupFailureCount:r["cleanup-failure"]}}clearModalStateScopeTracking(){this.modalStates.clear(),this.modalStateIssues=[],this.modalStateRelations=[],this.modalStateChangeLogs=[],this.modalStateIssueIdCounter=0,this.modalStateChangeLogIdCounter=0}setNamedActionDefinitions(e){this.config.enabled&&(this.namedActionDefinitions=e||{})}trackNamedActionRef(e){if(!this.config.enabled)return;const n={...e,id:`named_action_ref_${++this.namedActionRefIdCounter}`};this.namedActionRefLogs.push(n),this.namedActionRefLogs.length>this.maxNamedActionRefLogs&&(this.namedActionRefLogs=this.namedActionRefLogs.slice(-this.maxNamedActionRefLogs))}getNamedActionTrackingInfo(){const e={};for(const r of this.namedActionRefLogs)e[r.actionRefName]=(e[r.actionRefName]||0)+1;const n=Object.keys(this.namedActionDefinitions).filter(r=>!e[r]);return{definitions:this.namedActionDefinitions,refLogs:[...this.namedActionRefLogs],stats:{totalDefinitions:Object.keys(this.namedActionDefinitions).length,totalRefs:this.namedActionRefLogs.length,refCountByName:e,unusedDefinitions:n},timestamp:Date.now()}}clearNamedActionTracking(){this.namedActionDefinitions={},this.namedActionRefLogs=[],this.namedActionRefIdCounter=0}trackExpressionEval(e){if(!this.config.enabled)return;const n={...e,id:`expr-${++this.expressionIdCounter}`,timestamp:Date.now(),warning:this.detectExpressionWarning(e)};this.expressionHistory.push(n),this.expressionHistory.length>500&&this.expressionHistory.shift(),this.isProfiling&&this.profilingData.push({type:"binding",expression:e.expression,timestamp:performance.now(),duration:e.duration}),this.notifyExpressionWatchers(n)}detectExpressionWarning(e){const{expression:n,result:r,resultType:i,method:l,duration:c}=e;if(i==="undefined"&&!n.includes("??")&&!n.includes("||")&&/^[a-zA-Z_$][a-zA-Z0-9_$.]*$/.test(n.replace(/{{|}}/g,"").trim()))return{type:"undefined-result",message:"표현식 결과가 undefined입니다",suggestion:`데이터가 로드되었는지 확인하거나 fallback 값을 추가하세요: ${n} ?? ''`};if(i==="null")return{type:"null-result",message:"표현식 결과가 null입니다",suggestion:`nullish coalescing 연산자를 사용하세요: ${n} ?? ''`};if(l==="resolveBindings"&&i==="string"){const d=String(r);if(d.includes("[object Object]")||/^\[.*\]$/.test(d))return{type:"array-to-string",message:"배열/객체가 문자열로 변환되었습니다",suggestion:"evaluateExpression()을 사용하여 원본 타입을 유지하세요"}}if(l==="resolveBindings"&&i==="string"&&String(r).includes("[object Object]"))return{type:"object-to-string",message:"객체가 [object Object]로 변환되었습니다",suggestion:"evaluateExpression()을 사용하거나 특정 속성에 접근하세요"};if(i==="undefined"&&n.includes(".")&&!n.includes("?.")){const d=n.replace(/{{|}}/g,"").trim().split(".");if(d.length>=2)return{type:"missing-optional-chain",message:"Optional chaining(?.) 누락 가능성",suggestion:`안전한 접근을 위해 ?. 사용을 고려하세요: ${d.join("?.")}`}}if((n.includes("{{item.")||n.includes("{{index}}"))&&Array.from(this.iterations.values()).some(p=>p.itemVar!=="item"))return{type:"wrong-iteration-var",message:"'item'/'index' 대신 iteration에서 정의한 변수명을 사용해야 합니다",suggestion:"iteration의 item_var/index_var에 정의된 변수명을 확인하세요"};if(c&&c>10)return{type:"slow-evaluation",message:`표현식 평가에 ${c.toFixed(2)}ms 소요됨`,suggestion:"복잡한 표현식을 단순화하거나 computed 값으로 분리하세요"}}getExpressions(){return[...this.expressionHistory]}getExpressionWarnings(){return this.expressionHistory.filter(e=>e.warning!=null)}searchExpressions(e){const n=e.toLowerCase();return this.expressionHistory.filter(r=>r.expression.toLowerCase().includes(n)||r.componentName?.toLowerCase().includes(n)||r.propName?.toLowerCase().includes(n))}getExpressionStats(){const e=this.expressionHistory,n=new Set(e.map(f=>f.expression)),r=e.filter(f=>f.warning!=null),i=e.filter(f=>f.fromCache),l=e.filter(f=>f.duration!=null).map(f=>f.duration),c={};for(const f of e)c[f.resultType]=(c[f.resultType]||0)+1;const d={};for(const f of r)f.warning&&(d[f.warning.type]=(d[f.warning.type]||0)+1);return{totalEvaluations:e.length,uniqueExpressions:n.size,warningCount:r.length,cacheHitRate:e.length>0?i.length/e.length:0,averageDuration:l.length>0?l.reduce((f,p)=>f+p,0)/l.length:0,byType:c,byWarning:d}}clearExpressions(){this.expressionHistory=[],this.expressionIdCounter=0}watchExpressions(e){return this.expressionWatchers.add(e),()=>{this.expressionWatchers.delete(e)}}notifyExpressionWatchers(e){this.expressionWatchers.forEach(n=>{try{n(e)}catch(r){console.error("[G7DevTools] Expression watcher error:",r)}})}setLogLevel(e){this.config.logLevel=e}setMaxHistory(e){this.config.maxHistorySize=Math.max(10,Math.min(1e3,e))}setServerEndpoint(e){this.config.serverEndpoint=e}getConfig(){return{...this.config}}generateId(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}sanitizeObject(e,n=new WeakSet){if(e===null||typeof e!="object")return e;if(n.has(e))return"[Circular]";if(n.add(e),Array.isArray(e))return e.map(i=>this.sanitizeObject(i,n));const r={};for(const i of Object.keys(e))try{r[i]=this.sanitizeObject(e[i],n)}catch{r[i]="[Unable to serialize]"}return r}getNestedValue(e,n){if(!n)return e;const r=n.split(".");let i=e;for(const l of r){if(i==null)return;i=i[l]}return i}getLifecycleInfo(){return{mountedComponents:Array.from(this.mountedComponents.values()),orphanedListeners:this.getOrphanedListeners()}}getPerformanceInfo(){return{renderCounts:this.renderCounts,bindingEvalCount:this.bindingEvalCount,memoryWarnings:this.getMemoryWarnings()}}getNetworkInfo(){return{activeRequests:Array.from(this.activeRequests.values()),requestHistory:[...this.requestHistory],pendingDataSources:Array.from(this.pendingDataSources)}}getConditionalInfo(){return{ifConditions:Array.from(this.ifConditions.values()),iterations:Array.from(this.iterations.values())}}getFormInfo(){return Array.from(this.forms.values())}getWebSocketInfo(){return{connections:Array.from(this.wsConnections.values()),messageHistory:[...this.wsMessageHistory],connectionState:this.getWebSocketConnectionState()}}getStateAtTime(e){const n=[...this.stateHistory].reverse().find(r=>r.timestamp<=e);if(n)return{_global:n.next,_local:{}}}reset(){this.stateHistory=[],this.actionHistory=[],this.cacheStats={hits:0,misses:0,entries:0},this.cacheDecisions=[],this.cacheDecisionIdCounter=0,this.currentRenderCycleId=null,this.isInActionExecution=!1,this.isInIteration=!1,this.mountedComponents.clear(),this.eventListeners.clear(),this.renderCounts.clear(),this.bindingEvalCount=0,this.profilingData=[],this.activeRequests.clear(),this.requestHistory=[],this.pendingDataSources.clear(),this.wsConnections.clear(),this.wsMessageHistory=[],this.ifConditions.clear(),this.iterations.clear(),this.forms.clear(),this.expressionHistory=[],this.expressionIdCounter=0,this.dataSources.clear(),this.dataPathTransforms=[],this.nestedContexts=[],this.nestedContextIdCounter=0,this.formBindingIssues=[],this.formBindingValidations=[],this.formBindingIssueIdCounter=0,this.computedProperties.clear(),this.computedRecalcLogs=[],this.computedRecalcIdCounter=0,this.modalStates.clear(),this.modalStateIssues=[],this.modalStateRelations=[],this.modalStateChangeLogs=[],this.modalStateIssueIdCounter=0,this.modalStateChangeLogIdCounter=0,this.logHistory=[],this.logIdCounter=0}getExpressionInfo(){return{expressions:this.getExpressions(),stats:this.getExpressionStats()}}trackLog(e,n,r){if(!this.config.enabled)return;const i=r.map(c=>{if(typeof c=="string")return c;try{return JSON.stringify(c)}catch{return String(c)}}).join(" "),l={id:`log-${++this.logIdCounter}`,level:e,prefix:n,message:i,args:this.sanitizeObject(r),timestamp:Date.now(),stack:e==="error"?new Error().stack:void 0};this.logHistory.push(l),this.logHistory.length>this.maxLogHistory&&this.logHistory.shift()}trackAction(e){if(!this.config.enabled)return;const n={id:`debounce-action-${++this.debounceActionIdCounter}`,...e,timestamp:Date.now()};this.debounceActionHistory.push(n),this.debounceActionHistory.length>100&&this.debounceActionHistory.shift()}trackDataSourceUpdate(e){if(!this.config.enabled)return;const n={id:`ds-update-${++this.dataSourceUpdateIdCounter}`,...e};this.dataSourceUpdateHistory.push(n),this.dataSourceUpdateHistory.length>100&&this.dataSourceUpdateHistory.shift()}getDebounceActionHistory(e){let n=[...this.debounceActionHistory];return e?.handler&&(n=n.filter(r=>r.handler.includes(e.handler))),e?.status&&(n=n.filter(r=>r.status===e.status)),e?.limit&&(n=n.slice(-e.limit)),n}getDataSourceUpdateHistory(e){let n=[...this.dataSourceUpdateHistory];return e?.dataSourceId&&(n=n.filter(r=>r.dataSourceId===e.dataSourceId)),e?.updateType&&(n=n.filter(r=>r.updateType===e.updateType)),e?.limit&&(n=n.slice(-e.limit)),n}getLogs(e){let n=[...this.logHistory];if(e?.level){const r=Array.isArray(e.level)?e.level:[e.level];n=n.filter(i=>r.includes(i.level))}if(e?.prefix){const r=e.prefix.toLowerCase();n=n.filter(i=>i.prefix.toLowerCase().includes(r))}if(e?.search){const r=e.search.toLowerCase();n=n.filter(i=>i.message.toLowerCase().includes(r))}return e?.since&&(n=n.filter(r=>r.timestamp>=e.since)),e?.limit&&(n=n.slice(-e.limit)),n}getLogStats(){const n=Date.now()-6e4,r={log:0,warn:0,error:0,debug:0,info:0},i={};let l=0,c=0;for(const d of this.logHistory)r[d.level]++,i[d.prefix]=(i[d.prefix]||0)+1,d.timestamp>=n&&(d.level==="error"&&l++,d.level==="warn"&&c++);return{totalLogs:this.logHistory.length,byLevel:r,byPrefix:i,recentErrors:l,recentWarnings:c}}clearLogs(){this.logHistory=[],this.logIdCounter=0}getLogInfo(){return{entries:this.getLogs(),stats:this.getLogStats()}}trackDataSourceDefinition(e){this.config.enabled&&this.dataSources.set(e.id,{...e,status:"idle"})}trackDataSourceLoading(e){if(!this.config.enabled)return;const n=this.dataSources.get(e);n&&this.dataSources.set(e,{...n,status:"loading"})}trackDataSourceLoaded(e,n,r){if(!this.config.enabled)return;const i=this.dataSources.get(e);if(!i)return;let l,c,d=r;n&&(Array.isArray(n)?(l=n.length,c=n.length>0&&typeof n[0]=="object"?Object.keys(n[0]):void 0):typeof n=="object"&&(Array.isArray(n.data)?(d=d||"data",l=n.data.length,c=n.data.length>0&&typeof n.data[0]=="object"?Object.keys(n.data[0]):void 0):Array.isArray(n.items)?(d=d||"items",l=n.items.length,c=n.items.length>0&&typeof n.items[0]=="object"?Object.keys(n.items[0]):void 0):c=Object.keys(n))),this.dataSources.set(e,{...i,status:"loaded",dataPath:d,itemCount:l,keys:c,lastLoadedAt:Date.now(),error:void 0})}trackDataSourceError(e,n){if(!this.config.enabled)return;const r=this.dataSources.get(e);r&&this.dataSources.set(e,{...r,status:"error",error:n,lastLoadedAt:Date.now()})}untrackDataSource(e){this.dataSources.delete(e)}getDataSources(){return Array.from(this.dataSources.values())}getDataSource(e){return this.dataSources.get(e)}clearDataSources(){this.dataSources.clear()}trackDataPathTransform(e){if(!this.config.enabled)return;let n=this.dataPathTransforms.find(r=>r.dataSourceId===e.dataSourceId);n||(n={dataSourceId:e.dataSourceId,timestamp:Date.now(),transformSteps:[],warnings:[]},this.dataPathTransforms.push(n),this.dataPathTransforms.length>this.maxDataPathTransforms&&this.dataPathTransforms.shift()),n.transformSteps.push({step:e.step,inputPath:e.inputPath,inputValue:this.safeClone(e.inputValue),outputPath:e.outputPath,outputValue:this.safeClone(e.outputValue),config:e.config}),e.warning&&n.warnings.push(e.warning)}setDataPathFinalBinding(e,n){if(!this.config.enabled)return;const r=this.dataPathTransforms.find(i=>i.dataSourceId===e);r&&(r.finalBinding={expression:n.expression,resolvedPath:n.resolvedPath,value:this.safeClone(n.value)})}getDataPathTransformTrackingInfo(){const e=this.getDataPathTransformStats();return{transforms:[...this.dataPathTransforms],stats:e,timestamp:Date.now()}}getDataPathTransformStats(){const e=this.dataPathTransforms,n={};let r=0;const i={};for(const c of e){n[c.dataSourceId]=(n[c.dataSourceId]||0)+1,r+=c.warnings.length;for(const d of c.warnings)i[d]=(i[d]||0)+1}const l=Object.entries(i).map(([c,d])=>({warning:c,count:d})).sort((c,d)=>d.count-c.count).slice(0,10);return{totalTransforms:e.length,byDataSource:n,warningsCount:r,commonWarnings:l}}getDataPathTransformForDataSource(e){return this.dataPathTransforms.find(n=>n.dataSourceId===e)}clearDataPathTransforms(){this.dataPathTransforms=[]}trackNestedContext(e){if(!this.config.enabled)return"";const n=`nested-${++this.nestedContextIdCounter}`,r=[...new Set([...e.parentContext.available,...e.ownContext.added])],i={...e.parentContext.values,...e.ownContext.values},l={id:n,timestamp:Date.now(),componentId:e.componentId,componentType:e.componentType,parentContext:{available:e.parentContext.available,values:this.safeClone(e.parentContext.values)},ownContext:{added:e.ownContext.added,values:this.safeClone(e.ownContext.values)},mergedContext:{all:r,values:this.safeClone(i)},accessAttempts:[],depth:e.depth,parentId:e.parentId};return this.nestedContexts.push(l),this.nestedContexts.length>this.maxNestedContexts&&this.nestedContexts.shift(),n}trackNestedContextAccess(e,n){if(!this.config.enabled)return;const r=this.nestedContexts.find(i=>i.id===e);r&&r.accessAttempts.push({path:n.path,found:n.found,value:n.found?this.safeClone(n.value):void 0,error:n.error})}getNestedContextTrackingInfo(){const e=this.getNestedContextStats();return{contexts:[...this.nestedContexts],stats:e,timestamp:Date.now()}}getNestedContextStats(){const e=this.nestedContexts,n={expandChildren:0,cellChildren:0,iteration:0,modal:0,slot:0};let r=0,i=0;const l={};for(const d of e){n[d.componentType]++,d.depth>r&&(r=d.depth);for(const f of d.accessAttempts)f.found||(i++,l[f.path]=(l[f.path]||0)+1)}const c=Object.entries(l).map(([d,f])=>({path:d,count:f})).sort((d,f)=>f.count-d.count).slice(0,10);return{totalContexts:e.length,byType:n,maxDepth:r,failedAccessCount:i,commonFailedPaths:c}}getNestedContextForComponent(e){return this.nestedContexts.find(n=>n.componentId===e)}clearNestedContexts(){this.nestedContexts=[],this.nestedContextIdCounter=0}trackHandlerRegistration(e,n="custom",r,i){this.isEnabled&&this.handlers.set(e,{name:e,category:n,description:r,registeredAt:Date.now(),source:i})}trackHandlerUnregistration(e){this.isEnabled&&this.handlers.delete(e)}getHandlers(){return Array.from(this.handlers.values())}getHandler(e){return this.handlers.get(e)}getHandlersByCategory(e){return Array.from(this.handlers.values()).filter(n=>n.category===e)}clearHandlers(){this.handlers.clear()}trackEventSubscribe(e){if(!this.isEnabled)return;const n=this.componentEventSubscriptions.get(e),r=Date.now();n?(n.subscriberCount++,n.lastSubscribedAt=r):this.componentEventSubscriptions.set(e,{eventName:e,subscriberCount:1,firstSubscribedAt:r,lastSubscribedAt:r})}trackEventUnsubscribe(e){if(!this.isEnabled)return;const n=this.componentEventSubscriptions.get(e);n&&(n.subscriberCount--,n.subscriberCount<=0&&this.componentEventSubscriptions.delete(e))}trackEventEmit(e,n,r,i,l){if(!this.isEnabled)return;const c={id:`evt_${++this.componentEventIdCounter}`,eventName:e,data:this.sanitizeForLogging(n),timestamp:Date.now(),listenerCount:r,results:i?this.sanitizeForLogging(i):void 0,hasError:!!l,errorMessage:l?.message};this.componentEventEmitHistory.push(c),this.componentEventEmitHistory.length>this.maxComponentEventHistory&&(this.componentEventEmitHistory=this.componentEventEmitHistory.slice(-this.maxComponentEventHistory))}trackEventOff(e){this.isEnabled&&this.componentEventSubscriptions.delete(e)}trackEventClear(){this.isEnabled&&this.componentEventSubscriptions.clear()}getComponentEventInfo(){const e=Array.from(this.componentEventSubscriptions.values());return{subscriptions:e,emitHistory:[...this.componentEventEmitHistory],totalSubscribers:e.reduce((n,r)=>n+r.subscriberCount,0),totalEmits:this.componentEventEmitHistory.length}}getEventEmitHistory(){return[...this.componentEventEmitHistory]}getEventSubscriptions(){return Array.from(this.componentEventSubscriptions.values())}clearComponentEvents(){this.componentEventSubscriptions.clear(),this.componentEventEmitHistory=[],this.componentEventIdCounter=0}sanitizeForLogging(e){if(e==null||typeof e!="object")return e;try{return JSON.parse(JSON.stringify(e))}catch{return"[Circular or Non-serializable]"}}startStateChange(e,n,r,i){if(!this.config.enabled)return"";const l=`setState_${++this.stateRenderingIdCounter}`;this.currentStateChangeContext={setStateId:l,startTime:performance.now(),changedPath:e,trigger:i||{},renderedComponents:[]};const c={id:`sr_${this.stateRenderingIdCounter}`,setStateId:l,statePath:e,oldValue:this.sanitizeForLogging(n),newValue:this.sanitizeForLogging(r),timestamp:Date.now(),triggeredBy:i||{},renderedComponents:[],totalRenderDuration:0,affectedBindingsCount:0};return this.stateRenderingLogs.push(c),this.stateRenderingLogs.length>this.maxStateRenderingLogs&&this.stateRenderingLogs.shift(),l}trackComponentRender(e,n,r,i=[],l=[],c){if(!this.config.enabled)return;const d=this.componentRenderCounts.get(n)||0;this.componentRenderCounts.set(n,d+1);for(const f of i)this.stateToComponentMap.has(f)||this.stateToComponentMap.set(f,new Set),this.stateToComponentMap.get(f).add(n);if(this.currentStateChangeContext){const f={componentId:e,componentName:n,renderDuration:r,accessedStatePaths:i,evaluatedBindings:l,renderOrder:this.currentStateChangeContext.renderedComponents.length,parentId:c};this.currentStateChangeContext.renderedComponents.push(f)}this.trackRender(n)}completeStateChange(e){if(!this.config.enabled||!this.currentStateChangeContext||this.currentStateChangeContext.setStateId!==e)return;const n=this.currentStateChangeContext,i=performance.now()-n.startTime,l=this.stateRenderingLogs.findIndex(c=>c.setStateId===e);if(l>=0){const c=this.stateRenderingLogs[l];c.renderedComponents=n.renderedComponents,c.totalRenderDuration=i,c.affectedBindingsCount=n.renderedComponents.reduce((d,f)=>d+f.evaluatedBindings.length,0)}this.currentStateChangeContext=null}getCurrentStateChangeContext(){return this.currentStateChangeContext}getStateRenderingLogs(){return[...this.stateRenderingLogs]}getStateRenderingInfo(){const e=this.stateRenderingLogs,n=Object.fromEntries(this.componentRenderCounts),r={};for(const[i,l]of this.stateToComponentMap)r[i]=Array.from(l);return{logs:e,componentRenderCounts:n,stateToComponentMap:r,stats:this.calculateStateRenderingStats()}}calculateStateRenderingStats(){const e=this.stateRenderingLogs;if(e.length===0)return{totalStateChanges:0,totalRenders:0,avgRenderDuration:0,avgComponentsPerChange:0,topRenderedComponents:[],topInfluentialPaths:[]};const n=e.reduce((d,f)=>d+f.renderedComponents.length,0),r=e.reduce((d,f)=>d+f.totalRenderDuration,0)/e.length,i=n/e.length,l=Array.from(this.componentRenderCounts.entries()).sort((d,f)=>f[1]-d[1]).slice(0,5).map(([d,f])=>({name:d,count:f})),c=Array.from(this.stateToComponentMap.entries()).sort((d,f)=>f[1].size-d[1].size).slice(0,5).map(([d,f])=>({path:d,affectedComponents:f.size}));return{totalStateChanges:e.length,totalRenders:n,avgRenderDuration:r,avgComponentsPerChange:i,topRenderedComponents:l,topInfluentialPaths:c}}getComponentsAffectedByState(e){const n=this.stateToComponentMap.get(e);return n?Array.from(n):[]}getComponentRenderHistory(e){return this.stateRenderingLogs.filter(n=>n.renderedComponents.some(r=>r.componentName===e))}clearStateRenderingLogs(){this.stateRenderingLogs=[],this.componentRenderCounts.clear(),this.stateToComponentMap.clear(),this.currentStateChangeContext=null,this.stateRenderingIdCounter=0}trackComponentStateSource(e,n,r,i){this.config.enabled&&this.componentStateSources.set(e,{componentId:e,componentName:n,stateSource:r,stateProvider:i})}trackDynamicState(e,n){this.config.enabled&&this.dynamicStates.set(e,n)}trackContextFlow(e,n,r,i,l,c){if(!this.config.enabled)return;const d={component:n,componentId:e,contextReceived:r,passedToChildren:i,usedInRender:l};if(this.contextFlowNodes.set(e,d),c){const f=this.contextFlowNodes.get(c);f&&(f.children||(f.children=[]),f.children.push(d))}}getStateHierarchyInfo(e=!0){const n=this.buildStateHierarchyLayers(),r=this.detectStateConflicts(n),i=Array.from(this.componentStateSources.values());return{layers:e?n.map(c=>({...c,values:this.summarizeValues(c.values,2)})):n,conflicts:r,componentStateSources:i,timestamp:Date.now()}}summarizeValues(e,n,r=0){if(e==null)return e;if(typeof e!="object")return typeof e=="string"&&e.length>100?e.substring(0,100)+`... (${e.length}자)`:e;if(r>=n){if(Array.isArray(e))return`[Array(${e.length})]`;const c=Object.keys(e);return`{${c.slice(0,5).join(", ")}${c.length>5?`, ... +${c.length-5}`:""}}`}if(Array.isArray(e))return e.length<=3?e.map(c=>this.summarizeValues(c,n,r+1)):{__type:"array",__length:e.length,__preview:e.slice(0,3).map(c=>this.summarizeValues(c,n,r+1))};const i={},l=Object.keys(e);for(const c of l)i[c]=this.summarizeValues(e[c],n,r+1);return i}buildStateHierarchyLayers(){const e=[];try{const r=window.G7Core?.state?.get?.();if(!r)return e;r._local&&e.push({name:"Global _local",type:"global",path:"_local",values:r._local,priority:1}),r._global&&e.push({name:"Global _global",type:"global",path:"_global",values:r._global,priority:1});for(const[l,c]of this.dynamicStates)c&&Object.keys(c).length>0&&e.push({name:`DynamicState (${l})`,type:"dynamicState",componentId:l,values:c,priority:2});const i=this.computeEffectiveState(r._local||{});e.push({name:"Effective _local (merged)",type:"effective",values:i,priority:3})}catch(n){console.warn("[G7DevTools] 상태 계층 빌드 실패:",n)}return e}computeEffectiveState(e){const n={...e};for(const[,r]of this.dynamicStates)r._local&&Object.assign(n,r._local);return n}detectStateConflicts(e){const n=[],r=e.find(l=>l.type==="global"&&l.path==="_local");if(!r)return n;const i=e.filter(l=>l.type==="dynamicState");for(const l of i){const c=l.values._local||l.values;for(const[d,f]of Object.entries(c)){const p=r.values[d];if(JSON.stringify(p)!==JSON.stringify(f)){const m=[],y=[];for(const C of this.componentStateSources.values())C.stateSource.local.some(v=>v===`_local.${d}`||v===d)&&(C.stateProvider.type==="dynamicState"?m.push(C.componentName):C.stateProvider.type==="globalState"&&y.push(C.componentName));n.push({path:`_local.${d}`,globalValue:p,dynamicStateValue:f,effectiveValue:f,usedBy:m,notUsedBy:y,severity:y.length>0?"warning":"info",description:y.length>0?`${y.join(", ")}은(는) globalState._local을 읽어 dynamicState 값을 사용하지 못함`:"dynamicState 값이 globalState와 다르지만 모든 컴포넌트가 dynamicState를 사용"})}}}return n}getContextFlowInfo(){const e=[],n=new Set(this.contextFlowNodes.keys());for(const r of this.contextFlowNodes.values())if(r.children)for(const i of r.children)n.delete(i.componentId);for(const r of n){const i=this.contextFlowNodes.get(r);i&&e.push(i)}return{rootComponent:e.length>0?e[0].component:"Unknown",contextFlow:e,timestamp:Date.now()}}clearStateHierarchyData(){this.componentStateSources.clear(),this.contextFlowNodes.clear(),this.dynamicStates.clear()}trackComponentStyle(e,n,r,i){if(!this.config.enabled)return;const l=this.analyzeTailwindClasses(r),c={componentId:e,componentName:n,classes:r,computedStyles:i,tailwindAnalysis:l};this.componentStyles.set(e,c),this.detectStyleIssues(c)}analyzeTailwindClasses(e){const n=[],r=[],i=[],l=[],c=["sm:","md:","lg:","xl:","2xl:"],d=[/bg-\w+-\d+/,/text-\w+-\d+/,/border-\w+-\d+/];for(const f of e){l.push(f),f.startsWith("dark:")&&n.push(f);for(const p of c)if(f.startsWith(p)){r.push(f);break}for(const p of d)if(p.test(f)){i.push(f);break}}return{usedClasses:l,darkClasses:n,responsiveClasses:r,dynamicClasses:i}}detectStyleIssues(e){const{componentId:n,componentName:r,computedStyles:i,tailwindAnalysis:l}=e;(i.opacity==="0"||i.visibility==="hidden"||i.display==="none"||i.width==="0px"&&i.height==="0px")&&this.addStyleIssue({id:this.generateId(),type:"invisible-element",componentId:n,componentName:r,property:i.opacity==="0"?"opacity":i.visibility==="hidden"?"visibility":i.display==="none"?"display":"width/height",currentValue:i.opacity==="0"?"0":i.visibility==="hidden"?"hidden":i.display==="none"?"none":"0px",severity:"warning",description:"요소가 화면에 보이지 않습니다.",suggestion:"opacity, visibility, display, width/height 값을 확인하세요."});const c=l.usedClasses.filter(f=>f.startsWith("bg-")&&!f.startsWith("dark:")),d=l.darkClasses.filter(f=>f.includes("bg-"));c.length>0&&d.length===0&&this.addStyleIssue({id:this.generateId(),type:"dark-mode-missing",componentId:n,componentName:r,property:"background-color",currentValue:c.join(", "),expectedValue:"dark:bg-* 클래스 필요",severity:"info",description:"다크 모드 배경색 클래스가 누락되었습니다.",suggestion:`${c[0]}에 대응하는 dark: 클래스를 추가하세요.`}),l.dynamicClasses.length>0&&this.addStyleIssue({id:this.generateId(),type:"tailwind-purging",componentId:n,componentName:r,property:"class",currentValue:l.dynamicClasses.join(", "),severity:"info",description:"동적으로 생성된 Tailwind 클래스가 있습니다.",suggestion:"tailwind.config.js의 safelist에 추가하거나 전체 클래스명을 상수로 정의하세요."})}addStyleIssue(e){this.styleIssues.some(r=>r.componentId===e.componentId&&r.type===e.type&&r.property===e.property)||this.styleIssues.push(e)}getStyleValidationInfo(){const e=Array.from(this.componentStyles.values());return{issues:[...this.styleIssues],componentStyles:e,stats:{totalComponents:e.length,invisibleCount:this.styleIssues.filter(n=>n.type==="invisible-element").length,tailwindIssueCount:this.styleIssues.filter(n=>n.type==="tailwind-purging").length,darkModeIssueCount:this.styleIssues.filter(n=>n.type==="dark-mode-missing").length},timestamp:Date.now()}}clearStyleValidationData(){this.styleIssues=[],this.componentStyles.clear()}trackAuthEvent(e,n,r,i){if(!this.config.enabled)return;const l={id:`auth_${++this.authEventIdCounter}`,type:e,timestamp:Date.now(),success:n,error:r,details:i};this.authEvents.push(l),this.authEvents.length>this.maxAuthEventHistory&&(this.authEvents=this.authEvents.slice(-this.maxAuthEventHistory))}trackAuthHeader(e,n,r,i,l){if(!this.config.enabled)return;const c={url:e,hasAuthHeader:n,headerType:r,tokenValid:i??!1,responseStatus:l,timestamp:Date.now()};this.authHeaderHistory.push(c),this.authHeaderHistory.length>this.maxAuthEventHistory&&(this.authHeaderHistory=this.authHeaderHistory.slice(-this.maxAuthEventHistory)),l===401&&this.trackAuthEvent("api-unauthorized",!1,`401 Unauthorized: ${e}`,{url:e})}getAuthState(){try{const e=window.G7Core,n=e?.api;let r=e?.auth;!r&&e?.AuthManager?.getInstance&&(r=e.AuthManager.getInstance());const i=n?.getToken?.()||r?.getAccessToken?.()||localStorage.getItem("auth_token")||localStorage.getItem("access_token"),l=r?.getRefreshToken?.()||localStorage.getItem("refresh_token");let c="unknown",d=r?.getUser?.();if(d&&(c="AuthManager"),!d){const S=e?.state?.get?.();d=S?._global?.user||S?._global?.currentUser||S?.user||S?.currentUser,d&&(c="G7Core.state")}const f=r?.isAuthenticated?.()??!1;let p="memory";localStorage.getItem("auth_token")||localStorage.getItem("access_token")?p="localStorage":(sessionStorage.getItem("auth_token")||sessionStorage.getItem("access_token"))&&(p="sessionStorage");const m=!!i&&(!!d||f);let y;i&&typeof i=="string"&&i.length>20?y=`${i.substring(0,10)}...${i.substring(i.length-6)}`:i&&(y="***");const C=d?{id:d.id,email:d.email,name:d.name,roles:d.roles?.map(S=>typeof S=="string"?{name:S}:{id:S.id,name:S.name,guard_name:S.guard_name}),permissions:d.permissions?.map(S=>typeof S=="string"?{name:S}:{id:S.id,name:S.name,guard_name:S.guard_name}),avatar:d.avatar||d.profile_photo_url||d.profile_image,created_at:d.created_at,updated_at:d.updated_at,last_login_at:d.last_login_at,email_verified_at:d.email_verified_at,...d.phone&&{phone:d.phone},...d.nickname&&{nickname:d.nickname},...d.status&&{status:d.status},...d.locale&&{locale:d.locale}}:void 0;return{isAuthenticated:m,user:C,tokens:{hasAccessToken:!!i,hasRefreshToken:!!l,storage:p,accessTokenPreview:y},lastActivity:Date.now(),source:c}}catch{return{isAuthenticated:!1,tokens:{hasAccessToken:!1,hasRefreshToken:!1,storage:"memory"},source:"unknown"}}}getAuthDebugInfo(){const e=[...this.authEvents];return{state:this.getAuthState(),events:e,headerAnalysis:[...this.authHeaderHistory],stats:{loginAttempts:e.filter(n=>n.type==="login").length,successfulLogins:e.filter(n=>n.type==="login"&&n.success).length,failedLogins:e.filter(n=>n.type==="login"&&!n.success).length,tokenRefreshes:e.filter(n=>n.type==="token-refresh").length,unauthorizedResponses:e.filter(n=>n.type==="api-unauthorized").length},timestamp:Date.now()}}clearAuthData(){this.authEvents=[],this.authHeaderHistory=[],this.authEventIdCounter=0}trackLayoutLoad(e,n,r,i="api"){if(!this.config.enabled)return;const l=Date.now();this.currentLayout={layoutPath:e,templateId:n,layoutJson:this.sanitizeObject(r),loadedAt:l,version:r.version,layoutName:r.layout_name,source:i};const c={id:`layout-${++this.layoutIdCounter}`,layoutPath:e,templateId:n,loadedAt:l,source:i,version:r.version};this.layoutHistory.push(c),this.layoutHistory.length>this.maxLayoutHistory&&this.layoutHistory.shift(),this.layoutStats.totalLoads++,i==="cache"?this.layoutStats.cacheHits++:this.layoutStats.apiLoads++}getCurrentLayout(){return this.currentLayout}getLayoutHistory(){return[...this.layoutHistory]}getLayoutDebugInfo(){return{current:this.currentLayout,history:[...this.layoutHistory],stats:{...this.layoutStats}}}clearLayoutData(){this.currentLayout=null,this.layoutHistory=[],this.layoutIdCounter=0,this.layoutStats={totalLoads:0,cacheHits:0,apiLoads:0}}startHandlerExecution(e){if(!this.config.enabled)return"";const n=`exec_${++this.executionIdCounter}_${Date.now()}`,r={handlerName:e,executionId:n,startTime:Date.now(),stateChanges:[],dataSourceChanges:[],alerts:[]};if(this.executionDetails.set(n,r),this.executionDetails.size>this.maxExecutionDetails){const i=Array.from(this.executionDetails.keys());i.slice(0,i.length-this.maxExecutionDetails).forEach(c=>this.executionDetails.delete(c))}return n}endHandlerExecution(e,n,r,i){if(!this.config.enabled||!e)return;const l=this.executionDetails.get(e);if(!l)return;l.endTime=Date.now(),l.duration=l.endTime-l.startTime,l.exitReason=n,l.exitLocation=r,l.exitDescription=i;const c=this.changeExpectations.get(e);c&&(l.expectedChanges=c,this.checkExpectations(e,l,c),this.changeExpectations.delete(e)),n==="normal"&&l.stateChanges.length===0&&l.dataSourceChanges.length===0&&this.addChangeAlert(e,{type:"no-state-change",severity:"warning",message:`핸들러 "${l.handlerName}"이(가) 상태 변경 없이 완료됨`,description:"핸들러가 성공적으로 완료되었지만 상태나 데이터소스 변경이 없습니다. 의도한 동작인지 확인하세요.",handlerName:l.handlerName,suggestion:'핸들러 내부 조건문을 확인하거나 DevTools의 "변경감지" 탭에서 exitLocation을 확인하세요.',docLink:"troubleshooting-state.md"}),(n==="early-return-condition"||n==="early-return-validation")&&this.addChangeAlert(e,{type:"early-return-detected",severity:"info",message:`핸들러 "${l.handlerName}"이(가) early return으로 종료됨`,description:i||`종료 위치: ${r||"알 수 없음"}`,handlerName:l.handlerName,suggestion:n==="early-return-validation"?"검증 실패로 인한 early return입니다. 입력 데이터를 확인하세요.":"조건부 early return입니다. 조건문의 평가 결과를 확인하세요."})}recordExitReason(e,n,r,i){if(!this.config.enabled||!e)return;const l=this.executionDetails.get(e);l&&(l.exitReason=n,l.exitLocation=r,l.exitDescription=i)}recordStateChange(e,n,r,i,l){if(!this.config.enabled)return;const c={id:`sc_${++this.stateChangeIdCounter}`,path:n,changeType:r,oldValue:this.safeClone(i),newValue:this.safeClone(l),timestamp:Date.now(),comparison:this.compareValues(i,l),executionId:e};if(this.stateChangeHistory.push(c),e){const d=this.executionDetails.get(e);d&&d.stateChanges.push(c)}this.stateChangeHistory.length>this.maxStateChangeHistory&&this.stateChangeHistory.splice(0,this.stateChangeHistory.length-this.maxStateChangeHistory),c.comparison.isDeepEqual&&typeof i=="object"&&i!==null&&this.addChangeAlert(e||"",{type:"object-reference-same",severity:"warning",message:`상태 "${n}"가 변경되었으나 값이 동일함`,description:"객체 참조가 동일하거나 깊은 비교 결과 변경이 없습니다. 변경 감지가 실패할 수 있습니다.",handlerName:e&&this.executionDetails.get(e)?.handlerName||"unknown",statePath:n,suggestion:"불변성을 유지하여 새 객체를 생성하세요. 예: { ...oldObject, newField: value }",docLink:"troubleshooting-state.md#object-mutation"})}recordDataSourceChange(e,n,r,i,l){if(!this.config.enabled)return;const c={dataSourceId:n,changeType:r,timestamp:Date.now(),previousStatus:i,newStatus:l,executionId:e};if(this.dataSourceChangeHistory.push(c),e){const d=this.executionDetails.get(e);d&&d.dataSourceChanges.push(c)}this.dataSourceChangeHistory.length>this.maxStateChangeHistory&&this.dataSourceChangeHistory.splice(0,this.dataSourceChangeHistory.length-this.maxStateChangeHistory)}expectChange(e,n,r){if(!this.config.enabled||!e)return;const i=this.executionDetails.get(e);if(!i)return;const l={expectedStatePaths:n,expectedDataSources:r,setAt:Date.now(),source:i.handlerName};this.changeExpectations.set(e,l)}checkExpectations(e,n,r){const i=new Set(n.stateChanges.map(c=>c.path)),l=new Set(n.dataSourceChanges.map(c=>c.dataSourceId));for(const c of r.expectedStatePaths)i.has(c)||this.addChangeAlert(e,{type:"expected-not-fulfilled",severity:"error",message:`기대한 상태 변경 "${c}"가 발생하지 않음`,description:`핸들러 "${n.handlerName}"이(가) "${c}" 변경을 예고했지만 실제로 변경되지 않았습니다.`,handlerName:n.handlerName,statePath:c,suggestion:"핸들러 내부 로직을 확인하세요. early return이나 조건부 분기로 인해 변경이 생략되었을 수 있습니다.",docLink:"troubleshooting-state.md"});for(const c of r.expectedDataSources)l.has(c)||this.addChangeAlert(e,{type:"expected-not-fulfilled",severity:"error",message:`기대한 데이터소스 갱신 "${c}"가 발생하지 않음`,description:`핸들러 "${n.handlerName}"이(가) "${c}" 갱신을 예고했지만 실제로 갱신되지 않았습니다.`,handlerName:n.handlerName,dataSourceId:c,suggestion:"refetchDataSource 호출이 실행되었는지 확인하세요.",docLink:"data-sources.md"})}addChangeAlert(e,n){const r={...n,id:`alert_${++this.alertIdCounter}`,timestamp:Date.now()};if(this.changeAlerts.push(r),e){const i=this.executionDetails.get(e);i&&i.alerts.push(r)}this.changeAlerts.length>this.maxChangeAlerts&&this.changeAlerts.splice(0,this.changeAlerts.length-this.maxChangeAlerts)}compareValues(e,n){const r=this.getValueType(e),i=this.getValueType(n),l=r!==i;let c=!1,d;return!l&&(r==="object"||r==="array")?(c=this.deepEqual(e,n),!c&&r==="object"&&(d=this.getChangedKeys(e,n))):c=e===n,{typeChanged:l,oldType:r,newType:i,isDeepEqual:c,changedKeys:d}}getValueType(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?"array":typeof e}deepEqual(e,n){if(e===n)return!0;if(typeof e!=typeof n)return!1;if(e===null||n===null||typeof e!="object")return e===n;if(Array.isArray(e)!==Array.isArray(n))return!1;const r=Object.keys(e),i=Object.keys(n);if(r.length!==i.length)return!1;for(const l of r)if(!i.includes(l)||!this.deepEqual(e[l],n[l]))return!1;return!0}getChangedKeys(e,n){const r=[],i=new Set([...Object.keys(e),...Object.keys(n)]);for(const l of i)this.deepEqual(e[l],n[l])||r.push(l);return r}getChangeDetectionInfo(){const e=Array.from(this.executionDetails.values()),n={totalExecutions:e.length,executionsWithStateChange:e.filter(r=>r.stateChanges.length>0).length,executionsWithoutStateChange:e.filter(r=>r.stateChanges.length===0&&r.exitReason==="normal").length,earlyReturnCount:e.filter(r=>r.exitReason==="early-return-condition"||r.exitReason==="early-return-validation").length,alertCount:this.changeAlerts.length,alertsByType:this.getAlertsByType()};return{executionDetails:e,stateChangeHistory:[...this.stateChangeHistory],dataSourceChangeHistory:[...this.dataSourceChangeHistory],alerts:[...this.changeAlerts],stats:n,timestamp:Date.now()}}getAlertsByType(){const e={"no-state-change":0,"no-datasource-change":0,"expected-not-fulfilled":0,"object-reference-same":0,"early-return-detected":0,"async-timing-issue":0};for(const n of this.changeAlerts)e[n.type]++;return e}clearChangeDetectionData(){this.executionDetails.clear(),this.stateChangeHistory=[],this.dataSourceChangeHistory=[],this.changeAlerts=[],this.changeExpectations.clear(),this.executionIdCounter=0,this.stateChangeIdCounter=0,this.alertIdCounter=0}getRecentAlerts(e=10,n){let r=[...this.changeAlerts];return n&&(r=r.filter(i=>i.severity===n)),r.slice(-e)}getHandlerExecutions(e,n=10){return Array.from(this.executionDetails.values()).filter(i=>i.handlerName===e).slice(-n)}findExecutionInStack(e){return this.sequenceExecutionStack.find(n=>n.sequenceId===e)}startSequenceExecution(e){if(!this.config.enabled)return"";const n=`seq_${++this.sequenceIdCounter}_${Date.now()}`,r={sequenceId:n,startTime:Date.now(),totalDuration:0,trigger:e,actions:[],status:"running"};return this.sequenceExecutionStack.push(r),n}captureSequenceActionBefore(e,n,r,i,l){if(!this.config.enabled)return;const c=this.findExecutionInStack(e);if(!c)return;const d={index:n,handler:r,params:this.safeClone(i),stateBeforeAction:{_global:this.safeClone(l._global),_local:this.safeClone(l._local),_isolated:l._isolated?this.safeClone(l._isolated):void 0},stateAfterAction:{_global:{},_local:{}},duration:0,status:"success"};c.actions.push(d)}captureSequenceActionAfter(e,n,r,i,l,c){if(!this.config.enabled)return;const d=this.findExecutionInStack(e);if(!d)return;const f=d.actions.find(m=>m.index===n);if(!f)return;f.stateAfterAction={_global:this.safeClone(r._global),_local:this.safeClone(r._local),_isolated:r._isolated?this.safeClone(r._isolated):void 0},f.duration=i,f.result=this.safeClone(l),f.stateDiff={global:this.computeStateDiff(f.stateBeforeAction._global,f.stateAfterAction._global),local:this.computeStateDiff(f.stateBeforeAction._local,f.stateAfterAction._local)},f.stateBeforeAction._isolated&&f.stateAfterAction._isolated&&(f.stateDiff.isolated=this.computeStateDiff(f.stateBeforeAction._isolated,f.stateAfterAction._isolated));const p=window.__g7PendingLocalState;p&&(f.pendingState=this.safeClone(p)),c&&(f.status="error",f.error={name:c.name,message:c.message,stack:c.stack})}endSequenceExecution(e,n){if(!this.config.enabled)return;const r=this.sequenceExecutionStack.findIndex(l=>l.sequenceId===e);if(r===-1)return;const i=this.sequenceExecutionStack[r];if(i.endTime=Date.now(),i.totalDuration=i.endTime-i.startTime,n){i.status="error",i.error={name:n.name,message:n.message,stack:n.stack};const l=i.actions.find(c=>c.status==="error");l&&(i.failedAtIndex=l.index)}else i.status="success";this.sequenceExecutions.push(i),this.sequenceExecutions.length>this.maxSequenceExecutions&&this.sequenceExecutions.shift(),this.sequenceExecutionStack.splice(r,1)}computeStateDiff(e,n){const r=[],i=[],l=[],c=new Set(Object.keys(e)),d=new Set(Object.keys(n));for(const f of d)c.has(f)||r.push(f);for(const f of c)d.has(f)||i.push(f);for(const f of c)if(d.has(f)){const p=e[f],m=n[f];JSON.stringify(p)!==JSON.stringify(m)&&l.push({path:f,oldValue:p,newValue:m})}return{added:r,removed:i,changed:l}}getSequenceTrackingInfo(){const e=this.getSequenceStats(),n=this.sequenceExecutionStack.length>0?this.sequenceExecutionStack[this.sequenceExecutionStack.length-1]:void 0;return{executions:[...this.sequenceExecutions],currentExecution:n,stats:e}}getSequenceStats(){const e=this.sequenceExecutions,n=e.length,r=e.filter(p=>p.status==="success").length,i=e.filter(p=>p.status==="error").length,l=e.reduce((p,m)=>p+m.actions.length,0),c=n>0?e.reduce((p,m)=>p+m.totalDuration,0)/n:0,d={};for(const p of e)for(const m of p.actions)d[m.handler]=(d[m.handler]||0)+1;const f=Object.entries(d).sort(([,p],[,m])=>m-p).slice(0,5).map(([p,m])=>({handler:p,count:m}));return{totalExecutions:n,successCount:r,errorCount:i,totalActions:l,avgDuration:c,topHandlers:f}}clearSequenceData(){this.sequenceExecutions=[],this.sequenceExecutionStack=[],this.sequenceIdCounter=0}getSequenceExecution(e){const n=this.findExecutionInStack(e);return n||this.sequenceExecutions.find(r=>r.sequenceId===e)}getRecentSequences(e=10){return this.sequenceExecutions.slice(-e)}registerStateCaptureForHandler(e,n,r){if(!this.config.enabled)return;const i=new Map,l=Date.now();for(const c of n)i.set(c,{value:this.safeClone(r[c]),capturedAt:l});this.stateCaptureRegistry.set(e,i)}detectStaleClosure(e,n,r,i,l){if(!this.config.enabled)return[];const c=this.stateCaptureRegistry.get(e);if(!c)return[];const d=Date.now(),f=[];for(const[p,m]of c){const y=this.getValueByPath(r,p),C=d-m.capturedAt;if(!this.isDeepEqual(m.value,y)&&C>0){const S=this.createStaleClosureWarning(i,n,p,m.value,m.capturedAt,y,d,C,l);f.push(S),this.addStaleClosureWarning(S)}}return this.stateCaptureRegistry.delete(e),f}trackStaleClosureWarning(e){if(!this.config.enabled)return;const n=Date.now(),r=this.createStaleClosureWarning(e.type,e.location,e.capturedPath,e.capturedValue,e.capturedAt,e.currentValue,n,n-e.capturedAt,e.actionId,e.stackTrace);this.addStaleClosureWarning(r)}createStaleClosureWarning(e,n,r,i,l,c,d,f,p,m){const y=this.getStaleClosureSeverity(e,f),{description:C,suggestion:S,docLink:v}=this.getStaleClosureMessages(e,r,f);return{id:`stale_${++this.staleClosureIdCounter}_${Date.now()}`,timestamp:Date.now(),type:e,location:n,capturedState:{path:r,capturedValue:this.safeClone(i),capturedAt:l},currentState:{path:r,currentValue:this.safeClone(c),retrievedAt:d},timeDiff:f,severity:y,description:C,suggestion:S,docLink:v,actionId:p,stackTrace:m}}getStaleClosureSeverity(e,n){if(n>5e3)return"error";if(n>1e3)return"warning";switch(e){case"async-state-capture":case"sequence-state-mismatch":return"warning";case"callback-state-capture":case"timeout-state-capture":return"info";case"event-handler-stale":return"warning";default:return"info"}}getStaleClosureMessages(e,n,r){const i=r<1e3?`${r}ms`:`${(r/1e3).toFixed(1)}s`;switch(e){case"async-state-capture":return{description:`await 후 ${i} 경과 시점에 '${n}' 상태가 변경됨. 캡처된 상태 대신 최신 상태를 사용해야 함`,suggestion:"await 이후에는 G7Core.state.get()으로 최신 상태를 다시 조회하거나, useRef + getter 패턴을 사용하세요",docLink:"troubleshooting-state-closure.md"};case"callback-state-capture":return{description:`콜백에서 ${i} 전에 캡처된 '${n}' 상태를 사용 중. 최신 상태와 다름`,suggestion:"콜백에서 상태를 참조할 때는 stateRef.current 패턴 또는 G7Core.state.get()를 사용하세요",docLink:"troubleshooting-state-closure.md"};case"timeout-state-capture":return{description:`setTimeout/setInterval 콜백에서 '${n}' 상태가 ${i} 전 값 사용 중`,suggestion:"타이머 콜백 내에서는 G7Core.state.get()으로 최신 상태를 조회하세요",docLink:"troubleshooting-state-closure.md"};case"sequence-state-mismatch":return{description:`sequence 내 '${n}' 상태가 이전 액션 결과와 불일치. context.state 대신 캡처된 값 사용 의심`,suggestion:"sequence 내에서는 context.state 또는 $prev를 사용하여 최신 상태를 참조하세요",docLink:"troubleshooting-state-setstate.md"};case"event-handler-stale":return{description:`이벤트 핸들러에서 ${i} 전에 바인딩된 '${n}' 상태 사용 중`,suggestion:"이벤트 핸들러에서 상태를 참조할 때는 useRef 패턴 또는 G7Core.state.get()를 사용하세요",docLink:"troubleshooting-state-closure.md"};default:return{description:`'${n}' 상태에서 stale closure 감지됨 (${i} 경과)`,suggestion:"상태 참조 시 최신 값을 사용하는지 확인하세요"}}}addStaleClosureWarning(e){this.staleClosureWarnings.push(e),this.staleClosureWarnings.length>this.maxStaleClosureWarnings&&this.staleClosureWarnings.shift()}getValueByPath(e,n){const r=n.split(".");let i=e;for(const l of r){if(i==null)return;i=i[l]}return i}isDeepEqual(e,n){if(e===n)return!0;if(e===null||n===null)return e===n;if(typeof e!=typeof n)return!1;if(typeof e!="object")return e===n;try{return JSON.stringify(e)===JSON.stringify(n)}catch{return!1}}getStaleClosureTrackingInfo(){const e=this.getStaleClosureStats();return{warnings:[...this.staleClosureWarnings],stats:e,timestamp:Date.now()}}getStaleClosureStats(){const e=this.staleClosureWarnings,n={"async-state-capture":0,"callback-state-capture":0,"timeout-state-capture":0,"sequence-state-mismatch":0,"event-handler-stale":0};for(const f of e)n[f.type]++;const r={info:0,warning:0,error:0};for(const f of e)r[f.severity]++;const i={};for(const f of e)i[f.location]=(i[f.location]||0)+1;const l=Object.entries(i).sort(([,f],[,p])=>p-f).slice(0,5).map(([f,p])=>({location:f,count:p})),c={};for(const f of e)c[f.capturedState.path]=(c[f.capturedState.path]||0)+1;const d=Object.entries(c).sort(([,f],[,p])=>p-f).slice(0,5).map(([f,p])=>({path:f,count:p}));return{totalWarnings:e.length,warningsByType:n,warningsBySeverity:r,topLocations:l,topAffectedPaths:d}}clearStaleClosureData(){this.staleClosureWarnings=[],this.staleClosureIdCounter=0,this.stateCaptureRegistry.clear()}getRecentStaleClosureWarnings(e=10,n){let r=[...this.staleClosureWarnings];return n&&(r=r.filter(i=>i.severity===n)),r.slice(-e)}safeClone(e){if(e==null||typeof e!="object")return e;try{return JSON.parse(JSON.stringify(e))}catch{if(Array.isArray(e))return e.map(r=>{try{return JSON.parse(JSON.stringify(r))}catch{return"[Unserializable]"}});const n={};for(const r of Object.keys(e))try{n[r]=JSON.parse(JSON.stringify(e[r]))}catch{n[r]="[Unserializable]"}return n}}};$($i,"instance");let Ua=$i;const Jn=dt("LayoutLoader");class Rr extends Error{constructor(e,n,r){super(e),this.code=n,this.details=r,this.name="LayoutLoaderError"}}class Gf{constructor(e){$(this,"componentRegistry");$(this,"currentLayout",null);$(this,"layoutCache",new Map);$(this,"cacheVersion",0);this.componentRegistry=e}setCacheVersion(e){this.cacheVersion!==e&&(Jn.log("Cache version updated:",this.cacheVersion,"->",e),this.cacheVersion=e,this.layoutCache.clear())}getCacheVersion(){return this.cacheVersion}async loadLayout(e,n){const r=`${e}:${n}`;if(this.layoutCache.has(r)){Jn.log("Loading layout from cache:",n);const l=await this.layoutCache.get(r),c=JSON.parse(JSON.stringify(l));return this.currentLayout=c,Ua.getInstance().trackLayoutLoad(n,e,c,"cache"),c}const i=this.fetchLayout(e,n);return this.layoutCache.set(r,i),i.catch(()=>{this.layoutCache.get(r)===i&&this.layoutCache.delete(r)}),i}async fetchLayout(e,n,r=!1){try{const i=this.cacheVersion>0?this.cacheVersion:null;let l;if(n.startsWith("__preview__/")){const C=n.replace("__preview__/","");l=Pr(`/api/layouts/preview/${C}`,"json",i)}else l=Pr(`/api/layouts/${e}/${n}`,"json",i);Jn.log("Fetching layout from API:",l);const c=Wn(),d=r?null:c.getToken(),f={Accept:"application/json"};d&&(f.Authorization=`Bearer ${d}`);const p=await ac(l,{init:{headers:f},label:`layout: ${n}`});let m;try{m=await p.json()}catch{m=null}if(!p.ok){if(p.status===401&&!r&&d){Jn.log("Token invalid, removing and retrying without token"),c.removeToken();try{return await this.fetchLayout(e,n,!0)}catch(S){throw S instanceof Rr&&S.details?.status===401?new Rr(S.message,S.code,{...S.details,hadToken:!0}):S}}const C=m?.message||m?.error;throw new Rr(`Failed to fetch layout: ${p.status} ${p.statusText}`,"FETCH_FAILED",{status:p.status,statusText:p.statusText,url:l,apiMessage:C})}const y=m.data||m;return this.validateLayoutData(y),this.currentLayout=y,Ua.getInstance().trackLayoutLoad(n,e,y,"api"),Jn.log("Layout fetched and cached successfully:",y.layout_name),y}catch(i){const l=`${e}:${n}`;throw this.layoutCache.delete(l),i instanceof Rr?i:new Rr("Failed to load layout","LOAD_FAILED",{originalError:i})}}prefetchLayout(e,n){return this.loadLayout(e,n)}validateLayoutData(e){if(!e.version)throw new Rr("Layout data missing required field: version","VALIDATION_FAILED",{field:"version"});if(!e.layout_name)throw new Rr("Layout data missing required field: layout_name","VALIDATION_FAILED",{field:"layout_name"});if(!Array.isArray(e.components))throw new Rr('Layout data field "components" must be an array',"VALIDATION_FAILED",{field:"components",value:e.components});Jn.log("Layout data validation passed")}renderLayout(e,n){try{const r=n||this.currentLayout;if(!r)throw new Rr("No layout data to render","NO_LAYOUT_DATA");Jn.log("Rendering layout:",r.layout_name),e.innerHTML="",this.renderComponents(e,r.components),Jn.log("Layout rendered successfully")}catch(r){Jn.error("Render error:",r),this.renderErrorState(e,r)}}renderComponents(e,n){for(const r of n){const i=this.renderComponent(r);i&&e.appendChild(i)}}renderComponent(e){try{if(!this.componentRegistry.getComponent(e.type))return Jn.warn(`Component not found: ${e.type}`),this.createPlaceholderElement(e.type);const r=document.createElement("div");return r.setAttribute("data-component",e.type),e.props&&Object.entries(e.props).forEach(([i,l])=>{r.setAttribute(`data-prop-${i}`,JSON.stringify(l))}),e.children&&e.children.length>0?this.renderComponents(r,e.children):e.text&&(r.textContent=e.text),r}catch(n){return Jn.error(`Error rendering component ${e.type}:`,n),this.createErrorElement(e.type,n)}}createPlaceholderElement(e){const n=document.createElement("div");return n.className="component-placeholder",n.setAttribute("data-component-type",e),n.innerHTML=` + `},P_={onDragStart(s){let{active:e}=s;return"Picked up draggable item "+e.id+"."},onDragOver(s){let{active:e,over:n}=s;return n?"Draggable item "+e.id+" was moved over droppable area "+n.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(s){let{active:e,over:n}=s;return n?"Draggable item "+e.id+" was dropped over droppable area "+n.id:"Draggable item "+e.id+" was dropped."},onDragCancel(s){let{active:e}=s;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function U_(s){let{announcements:e=P_,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=z_}=s;const{announce:l,announcement:c}=I_(),d=Uo("DndLiveRegion"),[f,h]=N.useState(!1);if(N.useEffect(()=>{h(!0)},[]),j_(N.useMemo(()=>({onDragStart(y){let{active:v}=y;l(e.onDragStart({active:v}))},onDragMove(y){let{active:v,over:S}=y;e.onDragMove&&l(e.onDragMove({active:v,over:S}))},onDragOver(y){let{active:v,over:S}=y;l(e.onDragOver({active:v,over:S}))},onDragEnd(y){let{active:v,over:S}=y;l(e.onDragEnd({active:v,over:S}))},onDragCancel(y){let{active:v,over:S}=y;l(e.onDragCancel({active:v,over:S}))}}),[l,e])),!f)return null;const m=Xe.createElement(Xe.Fragment,null,Xe.createElement(M_,{id:r,value:i.draggable}),Xe.createElement(N_,{id:d,announcement:c}));return n?Ia.createPortal(m,n):m}var ln;(function(s){s.DragStart="dragStart",s.DragMove="dragMove",s.DragEnd="dragEnd",s.DragCancel="dragCancel",s.DragOver="dragOver",s.RegisterDroppable="registerDroppable",s.SetDroppableDisabled="setDroppableDisabled",s.UnregisterDroppable="unregisterDroppable"})(ln||(ln={}));function Rc(){}function Iy(s,e){return N.useMemo(()=>({sensor:s,options:e??{}}),[s,e])}function B_(){for(var s=arguments.length,e=new Array(s),n=0;n[...e].filter(r=>r!=null),[...e])}const Rr=Object.freeze({x:0,y:0});function jy(s,e){return Math.sqrt(Math.pow(s.x-e.x,2)+Math.pow(s.y-e.y,2))}function Hy(s,e){let{data:{value:n}}=s,{data:{value:r}}=e;return n-r}function q_(s,e){let{data:{value:n}}=s,{data:{value:r}}=e;return r-n}function zy(s){let{left:e,top:n,height:r,width:i}=s;return[{x:e,y:n},{x:e+i,y:n},{x:e,y:n+r},{x:e+i,y:n+r}]}function Py(s,e){if(!s||s.length===0)return null;const[n]=s;return n[e]}function Uy(s,e,n){return e===void 0&&(e=s.left),n===void 0&&(n=s.top),{x:e+s.width*.5,y:n+s.height*.5}}const G_=s=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=s;const i=Uy(e,e.left,e.top),l=[];for(const c of r){const{id:d}=c,f=n.get(d);if(f){const h=jy(Uy(f),i);l.push({id:d,data:{droppableContainer:c,value:h}})}}return l.sort(Hy)},F_=s=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=s;const i=zy(e),l=[];for(const c of r){const{id:d}=c,f=n.get(d);if(f){const h=zy(f),m=i.reduce((v,S,_)=>v+jy(h[_],S),0),y=Number((m/4).toFixed(4));l.push({id:d,data:{droppableContainer:c,value:y}})}}return l.sort(Hy)};function V_(s,e){const n=Math.max(e.top,s.top),r=Math.max(e.left,s.left),i=Math.min(e.left+e.width,s.left+s.width),l=Math.min(e.top+e.height,s.top+s.height),c=i-r,d=l-n;if(r{let{collisionRect:e,droppableRects:n,droppableContainers:r}=s;const i=[];for(const l of r){const{id:c}=l,d=n.get(c);if(d){const f=V_(d,e);f>0&&i.push({id:c,data:{droppableContainer:l,value:f}})}}return i.sort(q_)};function W_(s,e,n){return{...s,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function By(s,e){return s&&e?{x:s.left-e.left,y:s.top-e.top}:Rr}function Y_(s){return function(n){for(var r=arguments.length,i=new Array(r>1?r-1:0),l=1;l({...c,top:c.top+s*d.y,bottom:c.bottom+s*d.y,left:c.left+s*d.x,right:c.right+s*d.x}),{...n})}}const X_=Y_(1);function J_(s){if(s.startsWith("matrix3d(")){const e=s.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(s.startsWith("matrix(")){const e=s.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function Q_(s,e,n){const r=J_(e);if(!r)return s;const{scaleX:i,scaleY:l,x:c,y:d}=r,f=s.left-c-(1-i)*parseFloat(n),h=s.top-d-(1-l)*parseFloat(n.slice(n.indexOf(" ")+1)),m=i?s.width/i:s.width,y=l?s.height/l:s.height;return{width:m,height:y,top:h,right:f+m,bottom:h+y,left:f}}const Z_={ignoreTransform:!1};function Es(s,e){e===void 0&&(e=Z_);let n=s.getBoundingClientRect();if(e.ignoreTransform){const{transform:h,transformOrigin:m}=zn(s).getComputedStyle(s);h&&(n=Q_(n,h,m))}const{top:r,left:i,width:l,height:c,bottom:d,right:f}=n;return{top:r,left:i,width:l,height:c,bottom:d,right:f}}function qy(s){return Es(s,{ignoreTransform:!0})}function eA(s){const e=s.innerWidth,n=s.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function tA(s,e){return e===void 0&&(e=zn(s).getComputedStyle(s)),e.position==="fixed"}function nA(s,e){e===void 0&&(e=zn(s).getComputedStyle(s));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const l=e[i];return typeof l=="string"?n.test(l):!1})}function Dc(s,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(If(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Ho(i)||Ly(i)||n.includes(i))return n;const l=zn(s).getComputedStyle(i);return i!==s&&nA(i,l)&&n.push(i),tA(i,l)?n:r(i.parentNode)}return s?r(s):n}function Gy(s){const[e]=Dc(s,1);return e??null}function Bf(s){return!Tc||!s?null:Ss(s)?s:Nf(s)?If(s)||s===ws(s).scrollingElement?window:Ho(s)?s:null:null}function Fy(s){return Ss(s)?s.scrollX:s.scrollLeft}function Vy(s){return Ss(s)?s.scrollY:s.scrollTop}function qf(s){return{x:Fy(s),y:Vy(s)}}var mn;(function(s){s[s.Forward=1]="Forward",s[s.Backward=-1]="Backward"})(mn||(mn={}));function Ky(s){return!Tc||!s?!1:s===document.scrollingElement}function Wy(s){const e={x:0,y:0},n=Ky(s)?{height:window.innerHeight,width:window.innerWidth}:{height:s.clientHeight,width:s.clientWidth},r={x:s.scrollWidth-n.width,y:s.scrollHeight-n.height},i=s.scrollTop<=e.y,l=s.scrollLeft<=e.x,c=s.scrollTop>=r.y,d=s.scrollLeft>=r.x;return{isTop:i,isLeft:l,isBottom:c,isRight:d,maxScroll:r,minScroll:e}}const rA={x:.2,y:.2};function aA(s,e,n,r,i){let{top:l,left:c,right:d,bottom:f}=n;r===void 0&&(r=10),i===void 0&&(i=rA);const{isTop:h,isBottom:m,isLeft:y,isRight:v}=Wy(s),S={x:0,y:0},_={x:0,y:0},x={height:e.height*i.y,width:e.width*i.x};return!h&&l<=e.top+x.height?(S.y=mn.Backward,_.y=r*Math.abs((e.top+x.height-l)/x.height)):!m&&f>=e.bottom-x.height&&(S.y=mn.Forward,_.y=r*Math.abs((e.bottom-x.height-f)/x.height)),!v&&d>=e.right-x.width?(S.x=mn.Forward,_.x=r*Math.abs((e.right-x.width-d)/x.width)):!y&&c<=e.left+x.width&&(S.x=mn.Backward,_.x=r*Math.abs((e.left+x.width-c)/x.width)),{direction:S,speed:_}}function iA(s){if(s===document.scrollingElement){const{innerWidth:l,innerHeight:c}=window;return{top:0,left:0,right:l,bottom:c,width:l,height:c}}const{top:e,left:n,right:r,bottom:i}=s.getBoundingClientRect();return{top:e,left:n,right:r,bottom:i,width:s.clientWidth,height:s.clientHeight}}function Yy(s){return s.reduce((e,n)=>Cs(e,qf(n)),Rr)}function sA(s){return s.reduce((e,n)=>e+Fy(n),0)}function oA(s){return s.reduce((e,n)=>e+Vy(n),0)}function lA(s,e){if(e===void 0&&(e=Es),!s)return;const{top:n,left:r,bottom:i,right:l}=e(s);Gy(s)&&(i<=0||l<=0||n>=window.innerHeight||r>=window.innerWidth)&&s.scrollIntoView({block:"center",inline:"center"})}const cA=[["x",["left","right"],sA],["y",["top","bottom"],oA]];class Gf{constructor(e,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=Dc(n),i=Yy(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[l,c,d]of cA)for(const f of c)Object.defineProperty(this,f,{get:()=>{const h=d(r),m=i[l]-h;return this.rect[f]+m},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Go{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=e}add(e,n,r){var i;(i=this.target)==null||i.addEventListener(e,n,r),this.listeners.push([e,n,r])}}function uA(s){const{EventTarget:e}=zn(s);return s instanceof e?s:ws(s)}function Ff(s,e){const n=Math.abs(s.x),r=Math.abs(s.y);return typeof e=="number"?Math.sqrt(n**2+r**2)>e:"x"in e&&"y"in e?n>e.x&&r>e.y:"x"in e?n>e.x:"y"in e?r>e.y:!1}var dr;(function(s){s.Click="click",s.DragStart="dragstart",s.Keydown="keydown",s.ContextMenu="contextmenu",s.Resize="resize",s.SelectionChange="selectionchange",s.VisibilityChange="visibilitychange"})(dr||(dr={}));function Xy(s){s.preventDefault()}function dA(s){s.stopPropagation()}var dt;(function(s){s.Space="Space",s.Down="ArrowDown",s.Right="ArrowRight",s.Left="ArrowLeft",s.Up="ArrowUp",s.Esc="Escape",s.Enter="Enter",s.Tab="Tab"})(dt||(dt={}));const Jy={start:[dt.Space,dt.Enter],cancel:[dt.Esc],end:[dt.Space,dt.Enter,dt.Tab]},fA=(s,e)=>{let{currentCoordinates:n}=e;switch(s.code){case dt.Right:return{...n,x:n.x+25};case dt.Left:return{...n,x:n.x-25};case dt.Down:return{...n,y:n.y+25};case dt.Up:return{...n,y:n.y-25}}};class Vf{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:n}}=e;this.props=e,this.listeners=new Go(ws(n)),this.windowListeners=new Go(zn(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(dr.Resize,this.handleCancel),this.windowListeners.add(dr.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(dr.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&lA(r),n(Rr)}handleKeyDown(e){if(Pf(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:l=Jy,coordinateGetter:c=fA,scrollBehavior:d="smooth"}=i,{code:f}=e;if(l.end.includes(f)){this.handleEnd(e);return}if(l.cancel.includes(f)){this.handleCancel(e);return}const{collisionRect:h}=r.current,m=h?{x:h.left,y:h.top}:Rr;this.referenceCoordinates||(this.referenceCoordinates=m);const y=c(e,{active:n,context:r.current,currentCoordinates:m});if(y){const v=Bo(y,m),S={x:0,y:0},{scrollableAncestors:_}=r.current;for(const x of _){const A=e.code,{isTop:D,isRight:O,isLeft:k,isBottom:L,maxScroll:B,minScroll:q}=Wy(x),z=iA(x),W={x:Math.min(A===dt.Right?z.right-z.width/2:z.right,Math.max(A===dt.Right?z.left:z.left+z.width/2,y.x)),y:Math.min(A===dt.Down?z.bottom-z.height/2:z.bottom,Math.max(A===dt.Down?z.top:z.top+z.height/2,y.y))},de=A===dt.Right&&!O||A===dt.Left&&!k,_e=A===dt.Down&&!L||A===dt.Up&&!D;if(de&&W.x!==y.x){const Se=x.scrollLeft+v.x,je=A===dt.Right&&Se<=B.x||A===dt.Left&&Se>=q.x;if(je&&!v.y){x.scrollTo({left:Se,behavior:d});return}je?S.x=x.scrollLeft-Se:S.x=A===dt.Right?x.scrollLeft-B.x:x.scrollLeft-q.x,S.x&&x.scrollBy({left:-S.x,behavior:d});break}else if(_e&&W.y!==y.y){const Se=x.scrollTop+v.y,je=A===dt.Down&&Se<=B.y||A===dt.Up&&Se>=q.y;if(je&&!v.x){x.scrollTo({top:Se,behavior:d});return}je?S.y=x.scrollTop-Se:S.y=A===dt.Down?x.scrollTop-B.y:x.scrollTop-q.y,S.y&&x.scrollBy({top:-S.y,behavior:d});break}}this.handleMove(e,Cs(Bo(y,this.referenceCoordinates),S))}}}handleMove(e,n){const{onMove:r}=this.props;e.preventDefault(),r(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Vf.activators=[{eventName:"onKeyDown",handler:(s,e,n)=>{let{keyboardCodes:r=Jy,onActivation:i}=e,{active:l}=n;const{code:c}=s.nativeEvent;if(r.start.includes(c)){const d=l.activatorNode.current;return d&&s.target!==d?!1:(s.preventDefault(),i?.({event:s.nativeEvent}),!0)}return!1}}];function Qy(s){return!!(s&&"distance"in s)}function Zy(s){return!!(s&&"delay"in s)}class Kf{constructor(e,n,r){var i;r===void 0&&(r=uA(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:l}=e,{target:c}=l;this.props=e,this.events=n,this.document=ws(c),this.documentListeners=new Go(this.document),this.listeners=new Go(r),this.windowListeners=new Go(zn(c)),this.initialCoordinates=(i=Uf(l))!=null?i:Rr,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(dr.Resize,this.handleCancel),this.windowListeners.add(dr.DragStart,Xy),this.windowListeners.add(dr.VisibilityChange,this.handleCancel),this.windowListeners.add(dr.ContextMenu,Xy),this.documentListeners.add(dr.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Zy(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(Qy(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,n){const{active:r,onPending:i}=this.props;i(r,e,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:e}=this,{onStart:n}=this.props;e&&(this.activated=!0,this.documentListeners.add(dr.Click,dA,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(dr.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:l}=this,{onMove:c,options:{activationConstraint:d}}=l;if(!i)return;const f=(n=Uf(e))!=null?n:Rr,h=Bo(i,f);if(!r&&d){if(Qy(d)){if(d.tolerance!=null&&Ff(h,d.tolerance))return this.handleCancel();if(Ff(h,d.distance))return this.handleStart()}if(Zy(d)&&Ff(h,d.tolerance))return this.handleCancel();this.handlePending(d,h);return}e.cancelable&&e.preventDefault(),c(f)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===dt.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const hA={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Wf extends Kf{constructor(e){const{event:n}=e,r=ws(n.target);super(e,hA,r)}}Wf.activators=[{eventName:"onPointerDown",handler:(s,e)=>{let{nativeEvent:n}=s,{onActivation:r}=e;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const pA={move:{name:"mousemove"},end:{name:"mouseup"}};var Yf;(function(s){s[s.RightClick=2]="RightClick"})(Yf||(Yf={}));class gA extends Kf{constructor(e){super(e,pA,ws(e.event.target))}}gA.activators=[{eventName:"onMouseDown",handler:(s,e)=>{let{nativeEvent:n}=s,{onActivation:r}=e;return n.button===Yf.RightClick?!1:(r?.({event:n}),!0)}}];const Xf={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class mA extends Kf{constructor(e){super(e,Xf)}static setup(){return window.addEventListener(Xf.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Xf.move.name,e)};function e(){}}}mA.activators=[{eventName:"onTouchStart",handler:(s,e)=>{let{nativeEvent:n}=s,{onActivation:r}=e;const{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var Fo;(function(s){s[s.Pointer=0]="Pointer",s[s.DraggableRect=1]="DraggableRect"})(Fo||(Fo={}));var Oc;(function(s){s[s.TreeOrder=0]="TreeOrder",s[s.ReversedTreeOrder=1]="ReversedTreeOrder"})(Oc||(Oc={}));function yA(s){let{acceleration:e,activator:n=Fo.Pointer,canScroll:r,draggingRect:i,enabled:l,interval:c=5,order:d=Oc.TreeOrder,pointerCoordinates:f,scrollableAncestors:h,scrollableAncestorRects:m,delta:y,threshold:v}=s;const S=vA({delta:y,disabled:!l}),[_,x]=R_(),A=N.useRef({x:0,y:0}),D=N.useRef({x:0,y:0}),O=N.useMemo(()=>{switch(n){case Fo.Pointer:return f?{top:f.y,bottom:f.y,left:f.x,right:f.x}:null;case Fo.DraggableRect:return i}},[n,i,f]),k=N.useRef(null),L=N.useCallback(()=>{const q=k.current;if(!q)return;const z=A.current.x*D.current.x,W=A.current.y*D.current.y;q.scrollBy(z,W)},[]),B=N.useMemo(()=>d===Oc.TreeOrder?[...h].reverse():h,[d,h]);N.useEffect(()=>{if(!l||!h.length||!O){x();return}for(const q of B){if(r?.(q)===!1)continue;const z=h.indexOf(q),W=m[z];if(!W)continue;const{direction:de,speed:_e}=aA(q,W,O,e,v);for(const Se of["x","y"])S[Se][de[Se]]||(_e[Se]=0,de[Se]=0);if(_e.x>0||_e.y>0){x(),k.current=q,_(L,c),A.current=_e,D.current=de;return}}A.current={x:0,y:0},D.current={x:0,y:0},x()},[e,L,r,x,l,c,JSON.stringify(O),JSON.stringify(S),_,h,B,m,JSON.stringify(v)])}const bA={x:{[mn.Backward]:!1,[mn.Forward]:!1},y:{[mn.Backward]:!1,[mn.Forward]:!1}};function vA(s){let{delta:e,disabled:n}=s;const r=Hf(e);return Po(i=>{if(n||!r||!i)return bA;const l={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[mn.Backward]:i.x[mn.Backward]||l.x===-1,[mn.Forward]:i.x[mn.Forward]||l.x===1},y:{[mn.Backward]:i.y[mn.Backward]||l.y===-1,[mn.Forward]:i.y[mn.Forward]||l.y===1}}},[n,e,r])}function SA(s,e){const n=e!=null?s.get(e):void 0,r=n?n.node.current:null;return Po(i=>{var l;return e==null?null:(l=r??i)!=null?l:null},[r,e])}function wA(s,e){return N.useMemo(()=>s.reduce((n,r)=>{const{sensor:i}=r,l=i.activators.map(c=>({eventName:c.eventName,handler:e(c.handler,r)}));return[...n,...l]},[]),[s,e])}var Vo;(function(s){s[s.Always=0]="Always",s[s.BeforeDragging=1]="BeforeDragging",s[s.WhileDragging=2]="WhileDragging"})(Vo||(Vo={}));var Jf;(function(s){s.Optimized="optimized"})(Jf||(Jf={}));const eb=new Map;function CA(s,e){let{dragging:n,dependencies:r,config:i}=e;const[l,c]=N.useState(null),{frequency:d,measure:f,strategy:h}=i,m=N.useRef(s),y=A(),v=zo(y),S=N.useCallback(function(D){D===void 0&&(D=[]),!v.current&&c(O=>O===null?D:O.concat(D.filter(k=>!O.includes(k))))},[v]),_=N.useRef(null),x=Po(D=>{if(y&&!n)return eb;if(!D||D===eb||m.current!==s||l!=null){const O=new Map;for(let k of s){if(!k)continue;if(l&&l.length>0&&!l.includes(k.id)&&k.rect.current){O.set(k.id,k.rect.current);continue}const L=k.node.current,B=L?new Gf(f(L),L):null;k.rect.current=B,B&&O.set(k.id,B)}return O}return D},[s,l,n,y,f]);return N.useEffect(()=>{m.current=s},[s]),N.useEffect(()=>{y||S()},[n,y]),N.useEffect(()=>{l&&l.length>0&&c(null)},[JSON.stringify(l)]),N.useEffect(()=>{y||typeof d!="number"||_.current!==null||(_.current=setTimeout(()=>{S(),_.current=null},d))},[d,y,S,...r]),{droppableRects:x,measureDroppableContainers:S,measuringScheduled:l!=null};function A(){switch(h){case Vo.Always:return!1;case Vo.BeforeDragging:return n;default:return!n}}}function tb(s,e){return Po(n=>s?n||(typeof e=="function"?e(s):s):null,[e,s])}function EA(s,e){return tb(s,e)}function _A(s){let{callback:e,disabled:n}=s;const r=jf(e),i=N.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:l}=window;return new l(r)},[r,n]);return N.useEffect(()=>()=>i?.disconnect(),[i]),i}function Lc(s){let{callback:e,disabled:n}=s;const r=jf(e),i=N.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:l}=window;return new l(r)},[n]);return N.useEffect(()=>()=>i?.disconnect(),[i]),i}function AA(s){return new Gf(Es(s),s)}function nb(s,e,n){e===void 0&&(e=AA);const[r,i]=N.useState(null);function l(){i(f=>{if(!s)return null;if(s.isConnected===!1){var h;return(h=f??n)!=null?h:null}const m=e(s);return JSON.stringify(f)===JSON.stringify(m)?f:m})}const c=_A({callback(f){if(s)for(const h of f){const{type:m,target:y}=h;if(m==="childList"&&y instanceof HTMLElement&&y.contains(s)){l();break}}}}),d=Lc({callback:l});return Fr(()=>{l(),s?(d?.observe(s),c?.observe(document.body,{childList:!0,subtree:!0})):(d?.disconnect(),c?.disconnect())},[s]),r}function xA(s){const e=tb(s);return By(s,e)}const rb=[];function TA(s){const e=N.useRef(s),n=Po(r=>s?r&&r!==rb&&s&&e.current&&s.parentNode===e.current.parentNode?r:Dc(s):rb,[s]);return N.useEffect(()=>{e.current=s},[s]),n}function kA(s){const[e,n]=N.useState(null),r=N.useRef(s),i=N.useCallback(l=>{const c=Bf(l.target);c&&n(d=>d?(d.set(c,qf(c)),new Map(d)):null)},[]);return N.useEffect(()=>{const l=r.current;if(s!==l){c(l);const d=s.map(f=>{const h=Bf(f);return h?(h.addEventListener("scroll",i,{passive:!0}),[h,qf(h)]):null}).filter(f=>f!=null);n(d.length?new Map(d):null),r.current=s}return()=>{c(s),c(l)};function c(d){d.forEach(f=>{const h=Bf(f);h?.removeEventListener("scroll",i)})}},[i,s]),N.useMemo(()=>s.length?e?Array.from(e.values()).reduce((l,c)=>Cs(l,c),Rr):Yy(s):Rr,[s,e])}function ab(s,e){e===void 0&&(e=[]);const n=N.useRef(null);return N.useEffect(()=>{n.current=null},e),N.useEffect(()=>{const r=s!==Rr;r&&!n.current&&(n.current=s),!r&&n.current&&(n.current=null)},[s]),n.current?Bo(s,n.current):Rr}function RA(s){N.useEffect(()=>{if(!Tc)return;const e=s.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of e)n?.()}},s.map(e=>{let{sensor:n}=e;return n}))}function DA(s,e){return N.useMemo(()=>s.reduce((n,r)=>{let{eventName:i,handler:l}=r;return n[i]=c=>{l(c,e)},n},{}),[s,e])}function ib(s){return N.useMemo(()=>s?eA(s):null,[s])}const sb=[];function OA(s,e){e===void 0&&(e=Es);const[n]=s,r=ib(n?zn(n):null),[i,l]=N.useState(sb);function c(){l(()=>s.length?s.map(f=>Ky(f)?r:new Gf(e(f),f)):sb)}const d=Lc({callback:c});return Fr(()=>{d?.disconnect(),c(),s.forEach(f=>d?.observe(f))},[s]),i}function LA(s){if(!s)return null;if(s.children.length>1)return s;const e=s.children[0];return Ho(e)?e:s}function $A(s){let{measure:e}=s;const[n,r]=N.useState(null),i=N.useCallback(h=>{for(const{target:m}of h)if(Ho(m)){r(y=>{const v=e(m);return y?{...y,width:v.width,height:v.height}:v});break}},[e]),l=Lc({callback:i}),c=N.useCallback(h=>{const m=LA(h);l?.disconnect(),m&&l?.observe(m),r(m?e(m):null)},[e,l]),[d,f]=kc(c);return N.useMemo(()=>({nodeRef:d,rect:n,setRef:f}),[n,d,f])}const MA=[{sensor:Wf,options:{}},{sensor:Vf,options:{}}],NA={current:{}},$c={draggable:{measure:qy},droppable:{measure:qy,strategy:Vo.WhileDragging,frequency:Jf.Optimized},dragOverlay:{measure:Es}};class Ko extends Map{get(e){var n;return e!=null&&(n=super.get(e))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:n}=e;return!n})}getNodeFor(e){var n,r;return(n=(r=this.get(e))==null?void 0:r.node.current)!=null?n:void 0}}const IA={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Ko,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Rc},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:$c,measureDroppableContainers:Rc,windowRect:null,measuringScheduled:!1},jA={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Rc,draggableNodes:new Map,over:null,measureDroppableContainers:Rc},Mc=N.createContext(jA),ob=N.createContext(IA);function HA(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Ko}}}function zA(s,e){switch(e.type){case ln.DragStart:return{...s,draggable:{...s.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case ln.DragMove:return s.draggable.active==null?s:{...s,draggable:{...s.draggable,translate:{x:e.coordinates.x-s.draggable.initialCoordinates.x,y:e.coordinates.y-s.draggable.initialCoordinates.y}}};case ln.DragEnd:case ln.DragCancel:return{...s,draggable:{...s.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ln.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new Ko(s.droppable.containers);return i.set(r,n),{...s,droppable:{...s.droppable,containers:i}}}case ln.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=e,l=s.droppable.containers.get(n);if(!l||r!==l.key)return s;const c=new Ko(s.droppable.containers);return c.set(n,{...l,disabled:i}),{...s,droppable:{...s.droppable,containers:c}}}case ln.UnregisterDroppable:{const{id:n,key:r}=e,i=s.droppable.containers.get(n);if(!i||r!==i.key)return s;const l=new Ko(s.droppable.containers);return l.delete(n),{...s,droppable:{...s.droppable,containers:l}}}default:return s}}function PA(s){let{disabled:e}=s;const{active:n,activatorEvent:r,draggableNodes:i}=N.useContext(Mc),l=Hf(r),c=Hf(n?.id);return N.useEffect(()=>{if(!e&&!r&&l&&c!=null){if(!Pf(l)||document.activeElement===l.target)return;const d=i.get(c);if(!d)return;const{activatorNode:f,node:h}=d;if(!f.current&&!h.current)return;requestAnimationFrame(()=>{for(const m of[f.current,h.current]){if(!m)continue;const y=L_(m);if(y){y.focus();break}}})}},[r,e,i,c,l]),null}function UA(s,e){let{transform:n,...r}=e;return s!=null&&s.length?s.reduce((i,l)=>l({transform:i,...r}),n):n}function BA(s){return N.useMemo(()=>({draggable:{...$c.draggable,...s?.draggable},droppable:{...$c.droppable,...s?.droppable},dragOverlay:{...$c.dragOverlay,...s?.dragOverlay}}),[s?.draggable,s?.droppable,s?.dragOverlay])}function qA(s){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=s;const l=N.useRef(!1),{x:c,y:d}=typeof i=="boolean"?{x:i,y:i}:i;Fr(()=>{if(!c&&!d||!e){l.current=!1;return}if(l.current||!r)return;const h=e?.node.current;if(!h||h.isConnected===!1)return;const m=n(h),y=By(m,r);if(c||(y.x=0),d||(y.y=0),l.current=!0,Math.abs(y.x)>0||Math.abs(y.y)>0){const v=Gy(h);v&&v.scrollBy({top:y.y,left:y.x})}},[e,c,d,r,n])}const lb=N.createContext({...Rr,scaleX:1,scaleY:1});var ja;(function(s){s[s.Uninitialized=0]="Uninitialized",s[s.Initializing=1]="Initializing",s[s.Initialized=2]="Initialized"})(ja||(ja={}));const GA=N.memo(function(e){var n,r,i,l;let{id:c,accessibility:d,autoScroll:f=!0,children:h,sensors:m=MA,collisionDetection:y=K_,measuring:v,modifiers:S,..._}=e;const x=N.useReducer(zA,void 0,HA),[A,D]=x,[O,k]=H_(),[L,B]=N.useState(ja.Uninitialized),q=L===ja.Initialized,{draggable:{active:z,nodes:W,translate:de},droppable:{containers:_e}}=A,Se=z!=null?W.get(z):null,je=N.useRef({initial:null,translated:null}),Fe=N.useMemo(()=>{var pe;return z!=null?{id:z,data:(pe=Se?.data)!=null?pe:NA,rect:je}:null},[z,Se]),ze=N.useRef(null),[Et,Q]=N.useState(null),[ue,De]=N.useState(null),ee=zo(_,Object.values(_)),me=Uo("DndDescribedBy",c),H=N.useMemo(()=>_e.getEnabled(),[_e]),T=BA(v),{droppableRects:fe,measureDroppableContainers:he,measuringScheduled:Ae}=CA(H,{dragging:q,dependencies:[de.x,de.y],config:T.droppable}),se=SA(W,z),ge=N.useMemo(()=>ue?Uf(ue):null,[ue]),$e=ve(),Te=EA(se,T.draggable.measure);qA({activeNode:z!=null?W.get(z):null,config:$e.layoutShiftCompensation,initialRect:Te,measure:T.draggable.measure});const Ie=nb(se,T.draggable.measure,Te),xt=nb(se?se.parentElement:null),rt=N.useRef({activatorEvent:null,active:null,activeNode:se,collisionRect:null,collisions:null,droppableRects:fe,draggableNodes:W,draggingNode:null,draggingNodeRect:null,droppableContainers:_e,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),gt=_e.getNodeFor((n=rt.current.over)==null?void 0:n.id),at=$A({measure:T.dragOverlay.measure}),Yt=(r=at.nodeRef.current)!=null?r:se,Ht=q?(i=at.rect)!=null?i:Ie:null,bt=!!(at.nodeRef.current&&at.rect),qe=xA(bt?null:Ie),mt=ib(Yt?zn(Yt):null),Dt=TA(q?gt??se:null),zt=OA(Dt),kn=UA(S,{transform:{x:de.x-qe.x,y:de.y-qe.y,scaleX:1,scaleY:1},activatorEvent:ue,active:Fe,activeNodeRect:Ie,containerNodeRect:xt,draggingNodeRect:Ht,over:rt.current.over,overlayNodeRect:at.rect,scrollableAncestors:Dt,scrollableAncestorRects:zt,windowRect:mt}),hr=ge?Cs(ge,de):null,Ot=kA(Dt),Mi=ab(Ot),ua=ab(Ot,[Ie]),bn=Cs(kn,Mi),Mn=Ht?X_(Ht,kn):null,it=Fe&&Mn?y({active:Fe,collisionRect:Mn,droppableRects:fe,droppableContainers:H,pointerCoordinates:hr}):null,Un=Py(it,"id"),[vn,da]=N.useState(null),pr=bt?kn:Cs(kn,ua),un=W_(pr,(l=vn?.rect)!=null?l:null,Ie),Rn=N.useRef(null),dn=N.useCallback((pe,Ee)=>{let{sensor:xe,options:Ke}=Ee;if(ze.current==null)return;const ke=W.get(ze.current);if(!ke)return;const Me=pe.nativeEvent,Re=new xe({active:ze.current,activeNode:ke,event:Me,options:Ke,context:rt,onAbort(Pe){if(!W.get(Pe))return;const{onDragAbort:Ce}=ee.current,He={id:Pe};Ce?.(He),O({type:"onDragAbort",event:He})},onPending(Pe,Ve,Ce,He){if(!W.get(Pe))return;const{onDragPending:Lt}=ee.current,Bt={id:Pe,constraint:Ve,initialCoordinates:Ce,offset:He};Lt?.(Bt),O({type:"onDragPending",event:Bt})},onStart(Pe){const Ve=ze.current;if(Ve==null)return;const Ce=W.get(Ve);if(!Ce)return;const{onDragStart:He}=ee.current,nt={activatorEvent:Me,active:{id:Ve,data:Ce.data,rect:je}};Ia.unstable_batchedUpdates(()=>{He?.(nt),B(ja.Initializing),D({type:ln.DragStart,initialCoordinates:Pe,active:Ve}),O({type:"onDragStart",event:nt}),Q(Rn.current),De(Me)})},onMove(Pe){D({type:ln.DragMove,coordinates:Pe})},onEnd:tt(ln.DragEnd),onCancel:tt(ln.DragCancel)});Rn.current=Re;function tt(Pe){return async function(){const{active:Ce,collisions:He,over:nt,scrollAdjustedTranslate:Lt}=rt.current;let Bt=null;if(Ce&&Lt){const{cancelDrop:Nn}=ee.current;Bt={activatorEvent:Me,active:Ce,collisions:He,delta:Lt,over:nt},Pe===ln.DragEnd&&typeof Nn=="function"&&await Promise.resolve(Nn(Bt))&&(Pe=ln.DragCancel)}ze.current=null,Ia.unstable_batchedUpdates(()=>{D({type:Pe}),B(ja.Uninitialized),da(null),Q(null),De(null),Rn.current=null;const Nn=Pe===ln.DragEnd?"onDragEnd":"onDragCancel";if(Bt){const Gt=ee.current[Nn];Gt?.(Bt),O({type:Nn,event:Bt})}})}}},[W]),V=N.useCallback((pe,Ee)=>(xe,Ke)=>{const ke=xe.nativeEvent,Me=W.get(Ke);if(ze.current!==null||!Me||ke.dndKit||ke.defaultPrevented)return;const Re={active:Me};pe(xe,Ee.options,Re)===!0&&(ke.dndKit={capturedBy:Ee.sensor},ze.current=Ke,dn(xe,Ee))},[W,dn]),ie=wA(m,V);RA(m),Fr(()=>{Ie&&L===ja.Initializing&&B(ja.Initialized)},[Ie,L]),N.useEffect(()=>{const{onDragMove:pe}=ee.current,{active:Ee,activatorEvent:xe,collisions:Ke,over:ke}=rt.current;if(!Ee||!xe)return;const Me={active:Ee,activatorEvent:xe,collisions:Ke,delta:{x:bn.x,y:bn.y},over:ke};Ia.unstable_batchedUpdates(()=>{pe?.(Me),O({type:"onDragMove",event:Me})})},[bn.x,bn.y]),N.useEffect(()=>{const{active:pe,activatorEvent:Ee,collisions:xe,droppableContainers:Ke,scrollAdjustedTranslate:ke}=rt.current;if(!pe||ze.current==null||!Ee||!ke)return;const{onDragOver:Me}=ee.current,Re=Ke.get(Un),tt=Re&&Re.rect.current?{id:Re.id,rect:Re.rect.current,data:Re.data,disabled:Re.disabled}:null,Pe={active:pe,activatorEvent:Ee,collisions:xe,delta:{x:ke.x,y:ke.y},over:tt};Ia.unstable_batchedUpdates(()=>{da(tt),Me?.(Pe),O({type:"onDragOver",event:Pe})})},[Un]),Fr(()=>{rt.current={activatorEvent:ue,active:Fe,activeNode:se,collisionRect:Mn,collisions:it,droppableRects:fe,draggableNodes:W,draggingNode:Yt,draggingNodeRect:Ht,droppableContainers:_e,over:vn,scrollableAncestors:Dt,scrollAdjustedTranslate:bn},je.current={initial:Ht,translated:Mn}},[Fe,se,it,Mn,W,Yt,Ht,fe,_e,vn,Dt,bn]),yA({...$e,delta:de,draggingRect:Mn,pointerCoordinates:hr,scrollableAncestors:Dt,scrollableAncestorRects:zt});const ce=N.useMemo(()=>({active:Fe,activeNode:se,activeNodeRect:Ie,activatorEvent:ue,collisions:it,containerNodeRect:xt,dragOverlay:at,draggableNodes:W,droppableContainers:_e,droppableRects:fe,over:vn,measureDroppableContainers:he,scrollableAncestors:Dt,scrollableAncestorRects:zt,measuringConfiguration:T,measuringScheduled:Ae,windowRect:mt}),[Fe,se,Ie,ue,it,xt,at,W,_e,fe,vn,he,Dt,zt,T,Ae,mt]),Z=N.useMemo(()=>({activatorEvent:ue,activators:ie,active:Fe,activeNodeRect:Ie,ariaDescribedById:{draggable:me},dispatch:D,draggableNodes:W,over:vn,measureDroppableContainers:he}),[ue,ie,Fe,Ie,D,me,W,vn,he]);return Xe.createElement(Ny.Provider,{value:k},Xe.createElement(Mc.Provider,{value:Z},Xe.createElement(ob.Provider,{value:ce},Xe.createElement(lb.Provider,{value:un},h)),Xe.createElement(PA,{disabled:d?.restoreFocus===!1})),Xe.createElement(U_,{...d,hiddenTextDescribedById:me}));function ve(){const pe=Et?.autoScrollEnabled===!1,Ee=typeof f=="object"?f.enabled===!1:f===!1,xe=q&&!pe&&!Ee;return typeof f=="object"?{...f,enabled:xe}:{enabled:xe}}}),FA=N.createContext(null),cb="button",VA="Draggable";function KA(s){let{id:e,data:n,disabled:r=!1,attributes:i}=s;const l=Uo(VA),{activators:c,activatorEvent:d,active:f,activeNodeRect:h,ariaDescribedById:m,draggableNodes:y,over:v}=N.useContext(Mc),{role:S=cb,roleDescription:_="draggable",tabIndex:x=0}=i??{},A=f?.id===e,D=N.useContext(A?lb:FA),[O,k]=kc(),[L,B]=kc(),q=DA(c,e),z=zo(n);Fr(()=>(y.set(e,{id:e,key:l,node:O,activatorNode:L,data:z}),()=>{const de=y.get(e);de&&de.key===l&&y.delete(e)}),[y,e]);const W=N.useMemo(()=>({role:S,tabIndex:x,"aria-disabled":r,"aria-pressed":A&&S===cb?!0:void 0,"aria-roledescription":_,"aria-describedby":m.draggable}),[r,S,x,A,_,m.draggable]);return{active:f,activatorEvent:d,activeNodeRect:h,attributes:W,isDragging:A,listeners:r?void 0:q,node:O,over:v,setNodeRef:k,setActivatorNodeRef:B,transform:D}}function WA(){return N.useContext(ob)}const YA="Droppable",XA={timeout:25};function JA(s){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=s;const l=Uo(YA),{active:c,dispatch:d,over:f,measureDroppableContainers:h}=N.useContext(Mc),m=N.useRef({disabled:n}),y=N.useRef(!1),v=N.useRef(null),S=N.useRef(null),{disabled:_,updateMeasurementsFor:x,timeout:A}={...XA,...i},D=zo(x??r),O=N.useCallback(()=>{if(!y.current){y.current=!0;return}S.current!=null&&clearTimeout(S.current),S.current=setTimeout(()=>{h(Array.isArray(D.current)?D.current:[D.current]),S.current=null},A)},[A]),k=Lc({callback:O,disabled:_||!c}),L=N.useCallback((W,de)=>{k&&(de&&(k.unobserve(de),y.current=!1),W&&k.observe(W))},[k]),[B,q]=kc(L),z=zo(e);return N.useEffect(()=>{!k||!B.current||(k.disconnect(),y.current=!1,k.observe(B.current))},[B,k]),N.useEffect(()=>(d({type:ln.RegisterDroppable,element:{id:r,key:l,disabled:n,node:B,rect:v,data:z}}),()=>d({type:ln.UnregisterDroppable,key:l,id:r})),[r]),N.useEffect(()=>{n!==m.current.disabled&&(d({type:ln.SetDroppableDisabled,id:r,key:l,disabled:n}),m.current.disabled=n)},[r,l,n,d]),{active:c,rect:v,isOver:f?.id===r,node:B,over:f,setNodeRef:q}}function Qf(s,e,n){const r=s.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function QA(s,e){return s.reduce((n,r,i)=>{const l=e.get(r);return l&&(n[i]=l),n},Array(s.length))}function Nc(s){return s!==null&&s>=0}function ZA(s,e){if(s===e)return!0;if(s.length!==e.length)return!1;for(let n=0;n{var e;let{rects:n,activeNodeRect:r,activeIndex:i,overIndex:l,index:c}=s;const d=(e=n[i])!=null?e:r;if(!d)return null;const f=nx(n,c,i);if(c===i){const h=n[l];return h?{x:ii&&c<=l?{x:-d.width-f,y:0,...Ic}:c=l?{x:d.width+f,y:0,...Ic}:{x:0,y:0,...Ic}};function nx(s,e,n){const r=s[e],i=s[e-1],l=s[e+1];return!r||!i&&!l?0:n{let{rects:e,activeIndex:n,overIndex:r,index:i}=s;const l=Qf(e,r,n),c=e[i],d=l[i];return!d||!c?null:{x:d.left-c.left,y:d.top-c.top,scaleX:d.width/c.width,scaleY:d.height/c.height}},jc={scaleX:1,scaleY:1},rx=s=>{var e;let{activeIndex:n,activeNodeRect:r,index:i,rects:l,overIndex:c}=s;const d=(e=l[n])!=null?e:r;if(!d)return null;if(i===n){const h=l[c];return h?{x:0,y:nn&&i<=c?{x:0,y:-d.height-f,...jc}:i=c?{x:0,y:d.height+f,...jc}:{x:0,y:0,...jc}};function ax(s,e,n){const r=s[e],i=s[e-1],l=s[e+1];return r?nr.map(q=>typeof q=="object"&&"id"in q?q.id:q),[r]),_=c!=null,x=c?S.indexOf(c.id):-1,A=h?S.indexOf(h.id):-1,D=N.useRef(S),O=!ZA(S,D.current),k=A!==-1&&x===-1||O,L=ex(l);Fr(()=>{O&&_&&m(S)},[O,S,_,m]),N.useEffect(()=>{D.current=S},[S]);const B=N.useMemo(()=>({activeIndex:x,containerId:y,disabled:L,disableTransforms:k,items:S,overIndex:A,useDragOverlay:v,sortedRects:QA(S,f),strategy:i}),[x,y,L.draggable,L.droppable,k,S,A,f,v,i]);return Xe.createElement(db.Provider,{value:B},e)}const sx=s=>{let{id:e,items:n,activeIndex:r,overIndex:i}=s;return Qf(n,r,i).indexOf(e)},ox=s=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:l,newIndex:c,previousItems:d,previousContainerId:f,transition:h}=s;return!h||!r||d!==l&&i===c?!1:n?!0:c!==i&&e===f},lx={duration:200,easing:"ease"},fb="transform",cx=qo.Transition.toString({property:fb,duration:0,easing:"linear"}),ux={roleDescription:"sortable"};function dx(s){let{disabled:e,index:n,node:r,rect:i}=s;const[l,c]=N.useState(null),d=N.useRef(n);return Fr(()=>{if(!e&&n!==d.current&&r.current){const f=i.current;if(f){const h=Es(r.current,{ignoreTransform:!0}),m={x:f.left-h.left,y:f.top-h.top,scaleX:f.width/h.width,scaleY:f.height/h.height};(m.x||m.y)&&c(m)}}n!==d.current&&(d.current=n)},[e,n,r,i]),N.useEffect(()=>{l&&c(null)},[l]),l}function fx(s){let{animateLayoutChanges:e=ox,attributes:n,disabled:r,data:i,getNewIndex:l=sx,id:c,strategy:d,resizeObserverConfig:f,transition:h=lx}=s;const{items:m,containerId:y,activeIndex:v,disabled:S,disableTransforms:_,sortedRects:x,overIndex:A,useDragOverlay:D,strategy:O}=N.useContext(db),k=hx(r,S),L=m.indexOf(c),B=N.useMemo(()=>({sortable:{containerId:y,index:L,items:m},...i}),[y,i,L,m]),q=N.useMemo(()=>m.slice(m.indexOf(c)),[m,c]),{rect:z,node:W,isOver:de,setNodeRef:_e}=JA({id:c,data:B,disabled:k.droppable,resizeObserverConfig:{updateMeasurementsFor:q,...f}}),{active:Se,activatorEvent:je,activeNodeRect:Fe,attributes:ze,setNodeRef:Et,listeners:Q,isDragging:ue,over:De,setActivatorNodeRef:ee,transform:me}=KA({id:c,data:B,attributes:{...ux,...n},disabled:k.draggable}),H=k_(_e,Et),T=!!Se,fe=T&&!_&&Nc(v)&&Nc(A),he=!D&&ue,Ae=he&&fe?me:null,ge=fe?Ae??(d??O)({rects:x,activeNodeRect:Fe,activeIndex:v,overIndex:A,index:L}):null,$e=Nc(v)&&Nc(A)?l({id:c,items:m,activeIndex:v,overIndex:A}):L,Te=Se?.id,Ie=N.useRef({activeId:Te,items:m,newIndex:$e,containerId:y}),xt=m!==Ie.current.items,rt=e({active:Se,containerId:y,isDragging:ue,isSorting:T,id:c,index:L,items:m,newIndex:Ie.current.newIndex,previousItems:Ie.current.items,previousContainerId:Ie.current.containerId,transition:h,wasDragging:Ie.current.activeId!=null}),gt=dx({disabled:!rt,index:L,node:W,rect:z});return N.useEffect(()=>{T&&Ie.current.newIndex!==$e&&(Ie.current.newIndex=$e),y!==Ie.current.containerId&&(Ie.current.containerId=y),m!==Ie.current.items&&(Ie.current.items=m)},[T,$e,y,m]),N.useEffect(()=>{if(Te===Ie.current.activeId)return;if(Te!=null&&Ie.current.activeId==null){Ie.current.activeId=Te;return}const Yt=setTimeout(()=>{Ie.current.activeId=Te},50);return()=>clearTimeout(Yt)},[Te]),{active:Se,activeIndex:v,attributes:ze,data:B,rect:z,index:L,newIndex:$e,items:m,isOver:de,isSorting:T,isDragging:ue,listeners:Q,node:W,overIndex:A,over:De,setNodeRef:H,setActivatorNodeRef:ee,setDroppableNodeRef:_e,setDraggableNodeRef:Et,transform:gt??ge,transition:at()};function at(){if(gt||xt&&Ie.current.newIndex===L)return cx;if(!(he&&!Pf(je)||!h)&&(T||rt))return qo.Transition.toString({...h,property:fb})}}function hx(s,e){var n,r;return typeof s=="boolean"?{draggable:s,droppable:!1}:{draggable:(n=s?.draggable)!=null?n:e.draggable,droppable:(r=s?.droppable)!=null?r:e.droppable}}function Hc(s){if(!s)return!1;const e=s.data.current;return!!(e&&"sortable"in e&&typeof e.sortable=="object"&&"containerId"in e.sortable&&"items"in e.sortable&&"index"in e.sortable)}const px=[dt.Down,dt.Right,dt.Up,dt.Left],gx=(s,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:l,over:c,scrollableAncestors:d}}=e;if(px.includes(s.code)){if(s.preventDefault(),!n||!r)return;const f=[];l.getEnabled().forEach(y=>{if(!y||y!=null&&y.disabled)return;const v=i.get(y.id);if(v)switch(s.code){case dt.Down:r.topv.top&&f.push(y);break;case dt.Left:r.left>v.left&&f.push(y);break;case dt.Right:r.left1&&(m=h[1].id),m!=null){const y=l.get(n.id),v=l.get(m),S=v?i.get(v.id):null,_=v?.node.current;if(_&&S&&y&&v){const A=Dc(_).some((q,z)=>d[z]!==q),D=hb(y,v),O=mx(y,v),k=A||!D?{x:0,y:0}:{x:O?r.width-S.width:0,y:O?r.height-S.height:0},L={x:S.left,y:S.top};return k.x&&k.y?L:Bo(L,k)}}}};function hb(s,e){return!Hc(s)||!Hc(e)?!1:s.data.current.sortable.containerId===e.data.current.sortable.containerId}function mx(s,e){return!Hc(s)||!Hc(e)||!hb(s,e)?!1:s.data.current.sortable.index{const d=N.useId(),f=N.useRef({inProgress:!1,lastSortTime:0,lastActiveId:null}),h=B_(Iy(Wf,{activationConstraint:{distance:5}}),Iy(Vf,{coordinateGetter:gx})),m=N.useCallback(S=>{f.current={inProgress:!0,lastSortTime:Date.now(),lastActiveId:S.active.id},l?.({activeId:S.active.id})},[l]),y=N.useCallback(S=>{const{active:_,over:x}=S,A=Date.now();if(!x||_.id===x.id){f.current.inProgress=!1;return}const{lastSortTime:D,lastActiveId:O,inProgress:k}=f.current;if(O===_.id&&A-D<500&&!k)return;f.current={inProgress:!1,lastSortTime:A,lastActiveId:_.id};const L=s.findIndex(q=>String(q[e])===String(_.id)),B=s.findIndex(q=>String(q[e])===String(x.id));if(L!==-1&&B!==-1&&L!==B){const q=Qf(s,L,B);i?.(q,{oldIndex:L,newIndex:B})}},[s,e,i]),v=s.map(S=>String(S[e]));return yt.jsx(GA,{id:d,sensors:h,collisionDetection:G_,onDragStart:m,onDragEnd:y,children:yt.jsx(ix,{items:v,strategy:yx[n],children:r})},c!==void 0?`${d}-v${c}`:d)},pb=N.createContext(null),vx=({value:s,children:e})=>yt.jsx(pb.Provider,{value:s,children:e}),Sx=()=>N.useContext(pb),wx=({id:s,handle:e,as:n="div",children:r})=>{const{attributes:i,listeners:l,setNodeRef:c,transform:d,transition:f,isDragging:h}=fx({id:s}),m={transform:qo.Transform.toString(d),transition:f,opacity:h?.5:1,position:"relative"};return yt.jsx(n,{ref:c,style:m,...i,...e?{}:l,"data-sortable-item":!0,"data-sortable-id":String(s),"data-dragging":h,children:yt.jsx(vx,{value:{listeners:l,handle:e,isDragging:h},children:r})})},lt=pt("DynamicRenderer");function oa(){try{return window.G7Core?.devTools}catch{return}}function eh(s,e,n,r){if(typeof s=="string"){if(/\$t:[a-zA-Z_][a-zA-Z0-9_.\-]*/.test(s))try{return e.resolveTranslations(s,n,r)}catch{return s}return s}if(Array.isArray(s))return s.map(i=>eh(i,e,n,r));if(s&&typeof s=="object"){const i={};for(const[l,c]of Object.entries(s))i[l]=eh(c,e,n,r);return i}return s}function Cx(s){const e=Object.keys(s);return e.length>0&&e.every(n=>/^\d+$/.test(n))}const fr=(s,e)=>{const n=["errors"],r={...s};for(const i of Object.keys(e)){const l=e[i],c=s[i];if(l===null){r[i]=null;continue}if(n.includes(i)){r[i]=l;continue}if(Array.isArray(l)){r[i]=l;continue}if(Array.isArray(c)&&l!==null&&typeof l=="object"&&!Array.isArray(l)&&Cx(l)){const d=Object.keys(l).map(h=>parseInt(h,10));if((d.length>0?Math.max(...d):0)>=c.length+d.length+10)r[i]={...l};else{const h=[...c];for(const[m,y]of Object.entries(l)){const v=parseInt(m,10);v>=0&&v=h.length&&(h[v]=y)}r[i]=h}}else l!==null&&typeof l=="object"&&c!==null&&typeof c=="object"&&!Array.isArray(c)?r[i]=fr(c,l):r[i]=l}return r},Ex=(s,e,n,r)=>{if(!e||typeof e!="object"||Array.isArray(e))return s;const i=fr(s,e);return Ry(i,n,r)},zc=(s,e)=>{let n=null;const r=()=>(n===null&&(n={...s}),n);for(const i of Object.keys(e)){if(!(i in s))continue;const l=e[i],c=s[i];if(l!==null&&typeof l=="object"&&!Array.isArray(l)&&c!==null&&typeof c=="object"&&!Array.isArray(c)){const d=zc(c,l);if(d===c)continue;Object.keys(d).length===0?delete r()[i]:r()[i]=d}else delete r()[i]}return n??s},_x=s=>{const e={},n=s.split(";").filter(r=>r.trim());for(const r of n){const i=r.indexOf(":");if(i===-1)continue;const l=r.substring(0,i).trim(),c=r.substring(i+1).trim();if(l&&c){const d=l.replace(/-([a-z])/g,(f,h)=>h.toUpperCase());e[d]=c}}return e};class Ax extends N.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,n){lt.error(`컴포넌트 렌더링 에러 (ID: ${this.props.componentId}, Name: ${this.props.componentName}):`,e,n)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:yt.jsxs("div",{className:"p-4 my-2 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg text-red-800 dark:text-red-400",children:[yt.jsx("div",{className:"font-semibold mb-1",children:"컴포넌트 로드 실패"}),yt.jsxs("div",{className:"text-xs opacity-80",children:[this.props.componentName&&`[${this.props.componentName}] `,"데이터를 표시할 수 없습니다."]}),this.state.error&&yt.jsxs("details",{className:"mt-2",children:[yt.jsx("summary",{className:"cursor-pointer text-xs opacity-70 hover:opacity-100",children:"상세 정보"}),yt.jsx("div",{className:"mt-1 p-2 bg-red-100 dark:bg-red-900/30 rounded text-xs font-mono whitespace-pre-wrap break-all",children:this.state.error.message})]})]}):this.props.children}}const Vr=N.memo(({componentDef:s,dataContext:e,translationContext:n,registry:r,bindingEngine:i,translationEngine:l,actionDispatcher:c,parentComponentContext:d,parentFormContextProp:f,parentDataContext:h,isRootRenderer:m=!1,isInsideIteration:y=!1,isEditMode:v=!1,onComponentSelect:S,onComponentHover:_,onDragStart:x,onDragEnd:A,componentPath:D,layoutKey:O})=>{const[k,L]=N.useState({loadingActions:{}});N.useLayoutEffect(()=>{d||(i.startRenderCycle(),window.__g7SetLocalOverrideKeys||(window.__g7ForcedLocalFields=void 0),window.__g7PendingLocalState=null)});const B=N.useRef(null);N.useLayoutEffect(()=>{if(!d&&e._localInit&&typeof e._localInit=="object"){const{_forceLocalInit:V,_merge:ie,...ce}=e._localInit,Z=`${JSON.stringify(ce)}:${V||"no-force"}`;if(B.current!==Z){B.current=Z;const ve=ie||"shallow",Ee=window.G7Core?.state?.get?.()?._local||{},xe=window.__g7PendingLocalState||{},Ke={...Ee,...xe};ve==="replace"?window.__g7PendingLocalState={loadingActions:Ke.loadingActions||{},...ce,hasChanges:!1}:ve==="deep"?window.__g7PendingLocalState=fr(Ke,{...ce,hasChanges:!1}):window.__g7PendingLocalState={...Ke,...ce,hasChanges:!1};const ke=window.__g7SetLocalOverrideKeys;ke&&typeof ke=="object"&&(ve==="replace"?window.__g7SetLocalOverrideKeys={...ce,hasChanges:!1}:window.__g7SetLocalOverrideKeys=fr(ke,{...ce,hasChanges:!1}))}}}),N.useLayoutEffect(()=>{if(!d){const V=window.__g7SetLocalOverrideKeys;if(V){L(ve=>zc(ve,V));const ie=V,ce=window.__g7ForcedLocalFields,Z=window.__g7LastSetLocalSnapshot;queueMicrotask(()=>{window.__g7SetLocalOverrideKeys===ie&&(window.__g7SetLocalOverrideKeys=void 0),window.__g7ForcedLocalFields===ce&&(window.__g7ForcedLocalFields=void 0),window.__g7LastSetLocalSnapshot===Z&&(window.__g7LastSetLocalSnapshot=void 0)})}}},[e._local]);const q=N.useRef(O);N.useEffect(()=>{s._fromBase&&O&&q.current!==O&&(q.current=O,L({loadingActions:{}}))},[O,s._fromBase]);const z=N.useRef(""),W=N.useRef(!1),de=N.useRef(null),_e=N.useRef(null),Se=N.useRef({}),je=N.useRef({}),Fe=N.useRef(h),ze=T_(),Et=a_(),Q=Et?.getParentDataContext()??h;N.useEffect(()=>{if(e._localInit&&typeof e._localInit=="object"){const{_forceLocalInit:V,...ie}=e._localInit,ce=JSON.stringify(ie),Z=V!==void 0,ve=Lf(),pe=`${ce}:${V||"no-force"}`,Ee=f_({globalTrackedKey:ve.hash,instanceHandledKey:_e.current,trackingKey:pe});if(Ee==="apply"){_e.current=pe,ve.hash=pe,ve.timestamp=V,z.current=ce,Z&&(W.current=!0);const{_merge:Ke,...ke}=ie,Me=Ke||"shallow";L(Re=>Me==="replace"?{loadingActions:Re.loadingActions||{},...ke,hasChanges:!1}:Me==="deep"?fr(Re,{...ke,hasChanges:!1}):{...Re,...ke,hasChanges:!1}),e._globalSetState&&e._globalSetState(Re=>{const tt=Re?._local||{};let Pe;return Me==="replace"?Pe={...ke,hasChanges:!1}:Me==="deep"?Pe=fr(tt,{...ke,hasChanges:!1}):Pe={...tt,...ke,hasChanges:!1},{...Re,_local:Pe}}),i.invalidateCacheByKeys(["_local"]),lt.log("_localInit applied (data changed):",Object.keys(ie))}else if(Ee==="prune"){_e.current=pe;const{_merge:Ke,...ke}=ie;L(Re=>zc(Re,ke)),zc(k,ke)!==k&&(i.invalidateCacheByKeys(["_local"]),lt.log("_localInit pruned (applied by another renderer):",Object.keys(ke)))}de.current=e._localInit,u_(e._localInit)}},[e._localInit,h,i]);const{isTransitioning:ue}=Ay(),De=v_(),ee=f??De,{width:me}=Mf(),H=Sx(),T=N.useMemo(()=>{let V=s;if(s.type==="iterator"&&s.data){const{data:Z,itemName:ve,indexName:pe,...Ee}=s;V={...Ee,iteration:{source:Z,item_var:ve||"item",index_var:pe}}}if(!V.responsive)return V;const ie=Ci.getMatchingKey(V.responsive,me);if(!ie)return V;const ce=V.responsive[ie];return{...V,props:{...V.props,...ce.props},children:ce.children??V.children,text:ce.text??V.text,if:ce.if??V.if,iteration:ce.iteration??V.iteration,__responsiveChildrenKey:ce.children!==void 0?ie:void 0}},[s,me]),fe=N.useCallback(V=>{const ie=V?.__setStateId;if(L(ce=>{const Z=window.__g7PendingLocalState,pe=window.__g7SetLocalOverrideKeys||Z,Ee=pe?fr(ce,pe):ce;if(typeof V=="function"){const Re=V(Ee);return fr(Ee,Re)}const{__mergeMode:xe,__setStateId:Ke,...ke}=V;let Me;if(xe==="replace"?Me=ke:xe==="shallow"?Me={...Ee,...ke}:Me=fr(Ee,ke),xe!==void 0){const Re=window.__g7ForcedLocalFields;Re&&(window.__g7ForcedLocalFields={...Re,...ke})}return Me}),ie){const ce=oa();if(ce?.isEnabled()){const Z=T.id||"unknown",ve=T.name||"Unknown";setTimeout(()=>{ce.trackComponentRender?.(Z,ve,0,["_local"],[]),ce.completeStateChange?.(ie)},0)}}},[T.id,T.name]),he=d?.state??k,Ae=d?.setState??fe,se=N.useMemo(()=>{const V=e._localInit&&e._localInit!==de.current;let ie;V&&e._local?ie=e._local:ie=e._local?fr(e._local,he):he;const ce=window.__g7ForcedLocalFields;ce&&(ie=fr(ie,ce));const Z={...e,_local:ie},ve=e._computedDefinitions;if(ve&&Object.keys(ve).length>0){const pe=new $n,Ee={...Z,...ze?{_isolated:ze.state}:{}},xe={},Ke=oa(),ke=Ke?.isEnabled()??!1;for(const[Me,Re]of Object.entries(ve)){const tt=ke?Date.now():0,Pe=ke?e._computed?.[Me]:void 0;let Ve;try{if(typeof Re=="string")if(Re.startsWith("{{")&&Re.endsWith("}}")){const Ce=Re.slice(2,-2).trim(),He=jn(Ce)?pe.evaluatePipeExpression(Ce,Ee,{skipCache:!0}):pe.evaluateExpression(Ce,Ee,{skipCache:!0});xe[Me]=He}else xe[Me]=Re;else if(Re&&typeof Re=="object"&&"$switch"in Re){const Ce=pe.resolveSwitch(Re,Ee,{skipCache:!0});xe[Me]=Ce}}catch(Ce){lt.warn(`Failed to recalculate computed value: ${Me}`,Ce),xe[Me]=e._computed?.[Me],Ve=Ce instanceof Error?Ce.message:String(Ce)}if(ke&&(Ve||Pe!==xe[Me])){const He=Date.now()-tt;Ke.trackComputedProperty?.(Me,typeof Re=="string"?Re:JSON.stringify(Re),[{type:"_local",path:"_local",value:Z._local}],xe[Me],He,T.id,Ve),Pe!==xe[Me]&&Ke.trackComputedRecalc?.(Me,"dependency-change",Pe,xe[Me],He,{type:"_local",path:"_local"},T.id)}}Z._computed=xe}if(ze&&(Z._isolated=ze.state),Q&&(Z.$parent=Q),s.extensionPointProps){const pe=i.resolveObject(s.extensionPointProps,Z,y?{skipCache:!0}:void 0);Z.extensionPointProps=v&&l?eh(pe,l,n,Z):pe}return s.extensionPointCallbacks&&(Z.extensionPointCallbacks=s.extensionPointCallbacks),v&&(Z.$templateId===void 0&&n?.templateId&&(Z.$templateId=n.templateId),Z.$locale===void 0&&n?.locale&&(Z.$locale=n.locale)),Z},[e,he,ze?.state,Q,Et?.version,s.extensionPointProps,s.extensionPointCallbacks]);Se.current=se._local,je.current=se._computed||{},Fe.current=Q,N.useEffect(()=>{const V=oa();if(!V?.isEnabled())return;const ie=se._local;ie&&V.updateLocalState(ie);const ce=se._computed;ce&&V.updateComputedState(ce),Q&&V.updateParentContext?.(Q);const Z=T.id||`comp-${Date.now()}`,ve=T.name||"Unknown",pe={global:Object.keys(e._global||{}),local:Object.keys(ie||{}),context:d?Object.keys(d.state||{}):[]},Ee={type:d?"componentContext":"dynamicState",hasComponentContext:!!d,parentId:d?"parent":void 0};V.trackComponentStateSource?.(Z,ve,pe,Ee),he&&Object.keys(he).length>0&&V.trackDynamicState?.(Z,he);const xe=!!(T.expandChildren||T.props?.expandChildren);V.trackContextFlow?.(Z,ve,!!d,xe,!0)},[se._local,e,T.id,T.name,d,he,T.expandChildren,T.props?.expandChildren,Q]);const ge=N.useMemo(()=>({state:{...se._local},setState:Ae,stateRef:Se,computedRef:je,isolatedContext:ze,parentDataContext:se}),[se._local,Ae,k,ze,se]),$e=N.useMemo(()=>{const V=hs({if:T.if,condition:T.condition,conditions:T.conditions},se,i,T.id);if(T.if||T.condition!==void 0||T.conditions){const ce=oa();ce?.isEnabled()&&T.if&&ce.trackIfCondition(T.id||`if-${Date.now()}`,T.if,V)}return V},[T.if,T.conditions,se,i,T.id]),Te=N.useMemo(()=>{if(!T.slot)return null;const V=T.slot;if(V.startsWith("{{")&&V.endsWith("}}")){const ie=V.slice(2,-2).trim();try{const ce={componentId:T.id,componentName:T.name,propName:"slot"},Z=jn(ie)?i.evaluatePipeExpression(ie,se,void 0,ce):i.evaluateExpression(ie,se,ce);return lt.log(`[Slot] 표현식 평가: "${ie}" => "${Z}" (컴포넌트: ${T.id})`),typeof Z=="string"?Z:null}catch(ce){return lt.warn(`slot 표현식 평가 실패 (컴포넌트: ${T.id}):`,ce),null}}return lt.log(`[Slot] 정적 슬롯 ID: "${V}" (컴포넌트: ${T.id})`),V},[T.slot,T.id,se,i]),Ie=N.useMemo(()=>!Te||!T.id?"":`${T.id}-${Te}-${JSON.stringify(T.slotOrder??0)}`,[Te,T.id,T.slotOrder]),xt=N.useRef(null);N.useEffect(()=>{const V=window.__slotContextValue,ie=V?.isEnabled??!1;if(T.slot&<.log(`[Slot Registration] 컴포넌트: ${T.id}, isSlotEnabled: ${ie}, shouldRender: ${$e}, resolvedSlotId: ${Te}`),!ie||!$e){T.slot&<.log(`[Slot Registration] 등록 스킵 - isSlotEnabled: ${ie}, shouldRender: ${$e}`),xt.current&&T.id&&V&&(V.unregisterFromSlot(xt.current,T.id),xt.current=null);return}if(!Te||!T.id){T.slot&<.log(`[Slot Registration] 등록 스킵 - resolvedSlotId: ${Te}, id: ${T.id}`),xt.current&&T.id&&V&&(V.unregisterFromSlot(xt.current,T.id),xt.current=null);return}xt.current&&xt.current!==Te&&V.unregisterFromSlot(xt.current,T.id);const ce={...T,slot:void 0,slotOrder:void 0};return V.registerToSlot(Te,T.id,{componentDef:ce,dataContext:e,order:T.slotOrder??0,parentFormContext:f??null,getParentComponentContext:()=>ge,translationContext:n,registrationKey:Ie}),xt.current=Te,()=>{const Z=window.__slotContextValue;Te&&T.id&&Z&&Z.unregisterFromSlot(Te,T.id)}},[$e,Te,T,e,f,ge,n,Ie]);const rt=N.useCallback(V=>{if(typeof V=="string"){if(ac(V))return Kd(V);if(ic(V)){const ie=[],ce=V.replace(new RegExp(`${bo}([^${Si}]*)${Si}`,"g"),(ve,pe)=>(ie.push(pe),`${La}${ie.length-1}${La}`));let Z=ce;return/\$t:[a-zA-Z0-9._-]+/.test(ce)&&(Z=l.resolveTranslations(ce,n,se)),Z.replace(new RegExp(`${La}(\\d+)${La}`,"g"),(ve,pe)=>ie[parseInt(pe)])}if(V.startsWith("$t:defer:"))return V;if(/\$t:[a-zA-Z0-9._-]+/.test(V)){const ie=V.trim();return ie.startsWith("{")&&ie.endsWith("}")||ie.startsWith("[")&&ie.endsWith("]")?V:l.resolveTranslations(V,n,se)}return V}if(Array.isArray(V))return V.map(ie=>rt(ie));if(V&&typeof V=="object"){const ie={};for(const[ce,Z]of Object.entries(V))ie[ce]=rt(Z);return ie}return V},[l,n,se]),gt=N.useCallback(V=>yo(V),[]),at=N.useCallback(V=>Oa(V),[]),Yt=N.useMemo(()=>{let V={...T.props||{}};const ie=["cellChildren","expandChildren","expandContext","render"],Z=r.getMetadata(T.name)?.skipBindingKeys||[],ve=[...new Set([...ie,...Z])],pe=y?{skipCache:!0}:void 0,Ee={...pe??{},skipBindingKeys:ve},xe=Ce=>{if(pe)return pe;if(Ce.startsWith("_computed")||Ce.startsWith("$computed"))return{skipCache:!0}};for(const[Ce,He]of Object.entries(V))if(!ve.includes(Ce))if(typeof He=="string"){const nt=at(He);if(nt!==null){let Lt=!1,Bt=nt;nt.startsWith(lr)&&(Lt=!0,Bt=nt.slice(lr.length));const Nn={componentId:T.id,componentName:T.name,propName:Ce};let Gt;if(jn(Bt))try{Gt=i.evaluatePipeExpression(Bt,se,xe(Bt),Nn)}catch(Ft){lt.warn(`파이프 표현식 평가 실패 (컴포넌트: ${T.id}, prop: ${Ce}):`,Ft),Gt=void 0}else if(gt(Bt))try{Gt=i.evaluateExpression(Bt,se,Nn)}catch(Ft){lt.warn(`표현식 평가 실패 (컴포넌트: ${T.id}, prop: ${Ce}):`,Ft),Gt=void 0}else Gt=i.resolve(Bt,se,xe(Bt),Nn);V[Ce]=Lt&&Gt!=null?fs(Gt):Gt}else{const Lt={componentId:T.id,componentName:T.name,propName:Ce};V[Ce]=i.resolveBindings(He,se,pe,Lt)}}else Array.isArray(He)?V[Ce]=He.map(nt=>typeof nt=="string"?i.resolveBindings(nt,se,pe):typeof nt=="object"&&nt!==null?i.resolveObject(nt,se,Ee):nt):He&&typeof He=="object"&&(V[Ce]=i.resolveObject(He,se,Ee));for(const[Ce,He]of Object.entries(V))V[Ce]=rt(He);if(typeof V.style=="string"&&(V.style=_x(V.style)),V=sf(V,v?void 0:T.actions,se,{componentContext:ge,actionDispatcher:c}),T.classMap){const Ce=K0(T.classMap,se,i,{skipCache:!0});if(Ce){const He=V.className||"";V.className=He?`${He} ${Ce}`:Ce}}T.style&&(V.style=T.style),T.actions&&T.actions.length>0&&T.type==="composite"&&Object.assign(V,he),T.component_layout&&(V.__componentLayoutDefs=T.component_layout);const Ke=T.expandChildren||T.props?.expandChildren,ke=T.props?.cellChildren,Me=T.children&&T.children.length>0,Re=T.component_layout,tt=T.slot,Pe=T.props?.modalId,Ve=T.type==="composite";return(Ke||ke||Me||Re||tt||Pe||Ve)&&(V.__componentContext=ge),V},[T.props,T.actions,T.style,T.classMap,T.id,se,n,i,l,ge,he,rt,gt,at,y]),Ht=N.useRef(null),bt=N.useMemo(()=>Ht.current&&Ty(Ht.current,Yt)?Ht.current:(Ht.current=Yt,Yt),[Yt]),qe=N.useMemo(()=>{const V=T.id;if(typeof V!="string"||!V.includes("{{"))return V;const ie=i.resolveBindings(V,se,{skipCache:!0});return typeof ie=="string"?ie:V},[T.id,se,i]),mt=N.useMemo(()=>{const V=T.dataKey,ie=T.trackChanges,ce=T.debounce;if(V){const Z=V.startsWith("_global."),ve=Z?V.slice(8):V,pe=Z?e._global:se._local;return{dataKey:ve,trackChanges:ie??!1,debounce:ce,setState:Z?xe=>{e._globalSetState?e._globalSetState(xe):lt.warn("_global.formData 사용 시 _globalSetState가 필요합니다.")}:Ae,state:pe??{},_isGlobal:Z}}if(ee.dataKey)return ee},[T.dataKey,T.trackChanges,T.debounce,T.id,Ae,se._local,e._global,e._globalSetState,ee]),Dt=N.useRef(new Set);N.useEffect(()=>{Dt.current.clear()},[e._global?._remountKeys]);const zt=N.useCallback((V,ie)=>{const ce=e._global?._remountKeys;return V&&ce?.[V]&&!Dt.current.has(V)?(Dt.current.add(V),`${V}-remount-${ce[V]}`):V||ie},[e._global?._remountKeys]),kn=N.useMemo(()=>{if(T.text!==void 0){if(typeof T.text=="string"){const V=T.text;let ie=V;const ce={componentId:T.id,componentName:T.name,propName:"text",skipCache:!0},Z=at(V);if(Z!==null){let ve=!1,pe=Z;if(Z.startsWith(lr)&&(ve=!0,pe=Z.slice(lr.length)),jn(pe))try{ie=i.evaluatePipeExpression(pe,se,{skipCache:!0},ce)}catch(Ee){lt.warn(`text 파이프 표현식 평가 실패 (컴포넌트: ${T.id}):`,Ee),ie=""}else if(gt(pe))try{ie=i.evaluateExpression(pe,se,ce)}catch(Ee){lt.warn(`text 표현식 평가 실패 (컴포넌트: ${T.id}):`,Ee),ie=""}else ie=i.resolve(pe,se,{skipCache:!0},ce);ve&&ie!=null&&(ie=fs(ie))}else V.includes("{{")&&(ie=i.resolveBindings(V,se,{skipCache:!0},ce));return ie=rt(ie),ie??""}return T.text}return!T.children||T.children.length===0?null:T.children.map((V,ie)=>{if(typeof V=="string")return V;const ce=T.__responsiveChildrenKey,Z=ce?`responsive.${ce}.children`:"children",ve=D?`${D}.${Z}.${ie}`:`${ie}`,pe=V._fromBase?V.id||`child-${ie}`:zt(V.id,`child-${ie}`),Ee=!V._fromBase&&O?`${pe}_${O}`:pe;return yt.jsx(Vr,{componentDef:V,dataContext:se,translationContext:n,registry:r,bindingEngine:i,translationEngine:l,actionDispatcher:c,parentComponentContext:ge,parentFormContextProp:mt,isInsideIteration:y,isEditMode:v,onComponentSelect:S,onComponentHover:_,componentPath:ve,onDragStart:x,onDragEnd:A,layoutKey:O},Ee)})},[T.text,T.children,T.id,e,se,n,r,i,l,c,ge,mt,at,gt,rt,zt,y,v,S,_,D,x,A,O]),hr=N.useMemo(()=>{if(!T.iteration)return null;try{const V=af(T.iteration.source,se,i);if(!Array.isArray(V))return lt.warn(`iteration source가 배열이 아닙니다 (컴포넌트: ${T.id}):`,V),null;const ie=oa();return ie?.isEnabled()&&ie.trackIteration(T.id||`iteration-${Date.now()}`,T.iteration.source,T.iteration.item_var,T.iteration.index_var,V.length),V.map((ce,Z)=>{const ve={...se,[T.iteration.item_var]:ce,[`${T.iteration.item_var}_index`]:Z};T.iteration.index_var&&(ve[T.iteration.index_var]=Z);const pe=Z===0||Z===V.length-1;ie?.isEnabled()&&pe&&ie.trackNestedContext?.({componentId:`${T.id||"unknown"}-iter-${Z}`,componentType:"iteration",parentContext:{available:Object.keys(se),values:{}},ownContext:{added:[T.iteration.item_var,...T.iteration.index_var?[T.iteration.index_var]:[]],values:{[T.iteration.item_var]:ce,...T.iteration.index_var?{[T.iteration.index_var]:Z}:{}}},depth:1});const Ee={...T,iteration:void 0,responsive:void 0},xe=D?`${D}.iteration.${Z}`:`iteration.${Z}`,Ke=`${zt(T.id,"item")}-${Z}`;return yt.jsx(Vr,{componentDef:Ee,dataContext:ve,translationContext:n,registry:r,bindingEngine:i,translationEngine:l,actionDispatcher:c,parentComponentContext:ge,parentFormContextProp:mt,isInsideIteration:!0,isEditMode:v,onComponentSelect:S,onComponentHover:_,componentPath:xe,onDragStart:x,onDragEnd:A,layoutKey:O},Ke)})}catch(V){return lt.error(`iteration 렌더링 실패 (컴포넌트: ${T.id}):`,V),null}},[T.iteration,T.children,T.id,e,se,n,r,i,l,c,ge,mt,zt,v,S,_,D,x,A,O]),[Ot,Mi]=N.useState(0),ua=N.useMemo(()=>{if(!T.sortable||!T.itemTemplate)return null;const{sortable:V,itemTemplate:ie}=T;try{const ce=af(V.source,se,i);if(!Array.isArray(ce))return lt.warn(`sortable source가 배열이 아닙니다 (컴포넌트: ${T.id}):`,ce),null;if(ce.length===0)return null;const Z=V.itemKey||"id",ve=V.strategy||"verticalList",pe=V.itemVar||"$item",Ee=V.indexVar||"$index",xe=V.handle,Ke=V.wrapperElement,ke=(tt,Pe)=>{const Ve=T.actions?.filter(Ce=>Ce.event==="onSortEnd"||Ce.type==="onSortEnd");if(Mi(Ce=>Ce+1),Ve&&Ve.length>0&&c){const Ce={...se,$sortedItems:tt,$sortEvent:Pe};Ve.forEach(He=>{try{const nt=c.createHandler(He,Ce,ge),Lt=new Event("sortend");nt(Lt)}catch(nt){lt.error(`onSortEnd action failed: ${He.handler}`,nt)}})}},Me=tt=>{const Pe=T.actions?.filter(Ve=>Ve.event==="onSortStart"||Ve.type==="onSortStart");if(Pe&&Pe.length>0&&c){const Ve={...se,$activeId:tt.activeId};Pe.forEach(Ce=>{try{const He=c.createHandler(Ce,Ve,ge),nt=new Event("sortstart");He(nt)}catch(He){lt.error(`onSortStart action failed: ${Ce.handler}`,He)}})}},Re=ce.map((tt,Pe)=>{const Ve=String(tt[Z]),Ce={...se,[pe]:tt,[Ee]:Pe},He=D?`${D}.sortable.${Pe}`:`sortable.${Pe}`,nt=`${zt(T.id,"sortable-item")}-v${Ot}-${Ve}`;return yt.jsx(wx,{id:Ve,handle:xe,...Ke?{as:Ke}:{},children:(Ke&&ie.children?ie.children:[ie]).map((Lt,Bt)=>yt.jsx(Vr,{componentDef:Lt,dataContext:Ce,translationContext:n,registry:r,bindingEngine:i,translationEngine:l,actionDispatcher:c,parentComponentContext:ge,parentFormContextProp:void 0,isInsideIteration:!0,isEditMode:v,onComponentSelect:S,onComponentHover:_,componentPath:He,onDragStart:x,onDragEnd:A,layoutKey:O},`${nt}-child-${Bt}`))},nt)});return yt.jsx(bx,{items:ce,itemKey:Z,strategy:ve,onSortEnd:ke,onSortStart:Me,sortVersion:Ot,children:Re})}catch(ce){return lt.error(`sortable 렌더링 실패 (컴포넌트: ${T.id}):`,ce),null}},[T.sortable,T.itemTemplate,T.actions,T.id,e,se,n,r,i,l,c,ge,zt,v,S,_,D,x,A,Ot,O]),bn=N.useRef(!1);N.useEffect(()=>{if(bn.current)return;bn.current=!0;const V=oa();if(V?.isEnabled()&&V.trackMount(s.id,{name:s.name,type:s.type||"component",props:bt}),s.lifecycle?.onMount&&s.lifecycle.onMount.length>0)for(const ce of s.lifecycle.onMount)try{const Z=c.createHandler(ce,se,ge),ve=new Event("mount");Z(ve),lt.log(`Lifecycle onMount executed: ${ce.handler} (Component: ${s.id})`)}catch(Z){lt.error(`Lifecycle onMount failed: ${ce.handler} (Component: ${s.id})`,Z)}const ie=[];if(s.onComponentEvent&&s.onComponentEvent.length>0){const ce=window.G7Core;if(ce?.componentEvent?.on)for(const Z of s.onComponentEvent){if(!Z.event){lt.warn(`onComponentEvent: event name is required (Component: ${s.id})`);continue}const ve=async Ee=>{try{const xe={...se,_eventData:Ee},ke=await c.createHandler({handler:Z.handler,params:Z.params,onSuccess:Z.onSuccess,onError:Z.onError},xe,ge)(new CustomEvent(Z.event,{detail:Ee}));return lt.log(`onComponentEvent "${Z.event}" handled: ${Z.handler} (Component: ${s.id})`,{eventData:Ee,result:ke}),ke}catch(xe){throw lt.error(`onComponentEvent "${Z.event}" failed: ${Z.handler} (Component: ${s.id})`,xe),xe}},pe=ce.componentEvent.on(Z.event,ve);ie.push(pe),lt.log(`onComponentEvent: Subscribed to "${Z.event}" (Component: ${s.id})`)}else lt.warn(`onComponentEvent: G7Core.componentEvent is not available (Component: ${s.id})`)}return()=>{const ce=oa();ce?.isEnabled()&&ce.trackUnmount(s.id);for(const Z of ie)try{Z()}catch(ve){lt.error(`onComponentEvent: Failed to unsubscribe (Component: ${s.id})`,ve)}if(ie.length>0&<.log(`onComponentEvent: Unsubscribed ${ie.length} event(s) (Component: ${s.id})`),s.lifecycle?.onUnmount&&s.lifecycle.onUnmount.length>0)for(const Z of s.lifecycle.onUnmount)try{const ve=c.createHandler(Z,se,ge),pe=new Event("unmount");ve(pe),lt.log(`Lifecycle onUnmount executed: ${Z.handler} (Component: ${s.id})`)}catch(ve){lt.error(`Lifecycle onUnmount failed: ${Z.handler} (Component: ${s.id})`,ve)}}},[]);const Mn=N.useMemo(()=>{const V=bt.dataKey,ie=bt.trackChanges,ce=bt.debounce;return V?{dataKey:V,trackChanges:ie??!1,debounce:ce,setState:Ae,state:he}:null},[bt.dataKey,bt.trackChanges,bt.debounce,Ae,he]);N.useEffect(()=>{const V=T.dataKey||bt.dataKey;if(!V)return;const ie=oa();if(!ie?.isEnabled())return;const ce=[],Z=pe=>{if(pe)for(const Ee of pe){const xe=Ee?.props?.name;if(xe&&ce.push({name:xe,type:Ee.name||Ee.type||"unknown"}),Ee?.children&&Z(Ee.children),Ee?.slots)for(const Ke of Object.values(Ee.slots))Array.isArray(Ke)&&Z(Ke)}};if(s.children&&Z(s.children),s.slots)for(const pe of Object.values(s.slots))Array.isArray(pe)&&Z(pe);const ve=s.id||`form-${V}`;return ie.trackForm(ve,V,ce),()=>{ie.untrackForm(ve)}},[T,bt.dataKey,s.id,s.children]);const it=N.useRef(null),Un=N.useRef(void 0);N.useEffect(()=>{const V=bt?.name;if(!V||!ee.dataKey||!ee.setState||bt?.autoBinding===!1)return;const ie=`${ee.dataKey}.${V}`,ce=window.__g7AutoBindingPaths??new Map;return window.__g7AutoBindingPaths=ce,ce.set(ie,(ce.get(ie)??0)+1),()=>{const Z=ce.get(ie)??0;Z<=1?ce.delete(ie):ce.set(ie,Z-1)}},[bt?.name,bt?.autoBinding,ee.dataKey,ee.setState]);const vn=N.useMemo(()=>{const{dataKey:V,trackChanges:ie,debounce:ce,...Z}=bt,ve=Z.name;if(!ve||!ee.dataKey||!ee.setState)return Z;if(Z.autoBinding===!1){const{autoBinding:Ve,...Ce}=Z;return Ce}const pe=`${ee.dataKey}.${ve}`,Ee=S_(ee.state,pe),xe=Ee!==void 0?Ee:Z.value,ke=r.getMetadata(s.name)?.bindingType,Me=typeof xe=="boolean"&&(ke==="checked"||ke==="checkable"&&["checkbox","radio"].includes(Z?.type)),Re=ee.debounce,tt=Ve=>{const Ce=ee.state||{},He=Ry(Ce,pe,Ve);if(ee.trackChanges&&(He.hasChanges=!0),window.__g7PendingLocalState=Ex(He,window.__g7ForcedLocalFields,pe,Ve),ee.setState(He),ee._isGlobal)return;const nt=window.G7Core,Lt={[pe]:Ve};ee.trackChanges&&(Lt.hasChanges=!0),nt?.state?.setLocal?.(Lt,{render:!1})},Pe=(Ve,Ce)=>{Re&&Re>0?(it.current&&clearTimeout(it.current),it.current=setTimeout(()=>{tt(Ve),it.current=null,Ce&&(Ce(),window.__g7PendingLocalState=null)},Re)):(tt(Ve),Ce&&(Ce(),window.__g7PendingLocalState=null))};if(Me)return{...Z,checked:xe,onChange:Ce=>{const He=Ce.target.checked;tt(He),Z.onChange&&Z.onChange(Ce)}};{const Ve=He=>{const nt=He?.target?.value!==void 0?He.target.value:He;Re&&Re>0&&(Un.current=nt);const Lt=He?.target?{target:{value:nt,name:He.target.name,type:He.target.type,checked:He.target.checked},currentTarget:He.currentTarget?{value:nt,name:He.currentTarget.name}:void 0}:He;Pe(nt,()=>{Z.onChange&&Z.onChange(Lt)})};let Ce;return Un.current!==void 0?it.current!==null?Ce=Un.current:String(xe??"")===String(Un.current)?(Un.current=void 0,Ce=xe??""):Ce=Un.current:Ce=xe??"",{...Z,value:Ce,onChange:Ve}}},[bt,ee,ee.state,ee.debounce]),da=N.useMemo(()=>{const V=oa();if(V?.isEnabled()&&V.trackRender(s.name),!$e)return T.iteration?hr:null;if(T.sortable&&T.itemTemplate)return ua;if(T.iteration)return hr;if(T.type==="extension_point"){const{layout:ke,columns:Me,gap:Re,className:tt,...Pe}=T.props||{};let Ve=tt||"";return ke==="grid"&&Me?Ve=`${Ve} grid grid-cols-${Me} gap-${Re||4}`.trim():ke==="flex"&&(Ve=`${Ve} flex flex-col gap-${Re||4}`.trim()),yt.jsx("div",{id:qe,className:Ve||void 0,...Pe,children:kn})}const ie=r.getComponent(T.name);if(!ie)return lt.error(`컴포넌트를 찾을 수 없습니다: ${T.name} (ID: ${T.id})`,"componentDef:",JSON.stringify(T,null,2)),null;const ce=e._global?._remountKeys,Z={...vn,id:vn.id??qe,...ce&&Object.keys(ce).length>0&&{__remountTrigger:JSON.stringify(ce)}};if(H?.listeners&&H.handle&&vn["data-drag-handle"]!==void 0&&(Object.assign(Z,H.listeners),Z.style={...Z.style,cursor:H.isDragging?"grabbing":"grab"}),v){const ke=T.id||`auto_${T.name||T.type||"unknown"}_${Math.random().toString(36).substring(2,8)}`,Me=Pe=>{typeof Pe.preventDefault=="function"&&Pe.preventDefault(),S&&(Pe.stopPropagation(),S(ke,Pe))},Re={"data-editor-id":ke,"data-editor-name":T.name,"data-editor-type":T.type,onClick:Me};D&&(Re["data-editor-path"]=D);const tt=T.__editorSlotName??T.slot;typeof tt=="string"&&(Re["data-editor-slot"]=tt),_&&(Re.onMouseMove=Pe=>{Pe.stopPropagation(),_(ke,Pe)},Re.onMouseLeave=Pe=>{_(null,Pe)}),Object.assign(Z,Re),Z.editorAttrs=Re}const ve=T.type==="basic",pe=T.type==="layout",xe=ve||pe?(()=>{const ke={};for(const[Me,Re]of Object.entries(Z))Me.startsWith("__")||Me==="editorAttrs"&&ve||(ke[Me]=Re);return ke})():Z;let Ke=yt.jsx(ie,{...xe,children:kn});if(mt&&(Ke=yt.jsx(b_,{value:mt,children:Ke})),T.isolatedState){const ke=typeof T.isolatedState=="object"?T.isolatedState:{},Me=e?._isolatedInit,Re=Me?{...ke,...Me}:ke;Ke=yt.jsx(x_,{initialState:Re,scopeId:T.isolatedScopeId,children:Ke})}return Ke},[$e,T.iteration,T.sortable,T.itemTemplate,T.type,T.name,T.id,T.props,T.isolatedState,T.isolatedScopeId,r,vn,kn,hr,ua,H,Mn,v,S,_,x,A,D,e._global?._remountKeys]),pr=N.useMemo(()=>{const V=T.blur_until_loaded;if(!V||e?._global?.__isPreview)return!1;if(typeof V=="string"){const Z=at(V);if(Z!==null)try{const ve={componentId:T.id,componentName:T.name,propName:"blur_until_loaded"};return!!i.evaluateExpression(Z,se,ve)}catch(ve){return lt.warn(`blur_until_loaded 표현식 평가 실패 (컴포넌트: ${T.id}):`,ve),!1}return!1}if(typeof V=="object"&&V!==null){if(!V.enabled)return!1;if(V.data_sources)return(Array.isArray(V.data_sources)?V.data_sources:[V.data_sources]).some(Ee=>e[Ee]===void 0);if(ue)return!0;const Z=["route","query","_global","_local","_dataSourceErrors"];return Object.keys(e).filter(pe=>!Z.includes(pe)&&!pe.startsWith("_")).some(pe=>e[pe]===void 0)}if(ue)return!0;const ie=["route","query","_global","_local","_dataSourceErrors"];return Object.keys(e).filter(Z=>!ie.includes(Z)&&!Z.startsWith("_")).some(Z=>e[Z]===void 0)},[T.blur_until_loaded,T.id,ue,e,se,i,at]);if(pr){const V=T.blur_until_loaded;if(typeof V=="object"&&V?.data_sources){const ce=(Array.isArray(V.data_sources)?V.data_sources:[V.data_sources]).reduce((ve,pe)=>(ve[pe]=e[pe]===void 0?"UNDEFINED":"LOADED",ve),{}),Z=Object.keys(e).filter(ve=>!ve.startsWith("_"));lt.log(`[BLUR APPLIED] Component: ${T.id}, data_sources status:`,ce,"Available keys:",Z)}else lt.log(`[BLUR APPLIED] Component: ${T.id}, blur_until_loaded:`,V)}const un=N.useMemo(()=>{if(!T.blur_until_loaded)return{wrapperClasses:"",innerClasses:""};const V=Yt?.className||"";if(!V)return{wrapperClasses:"",innerClasses:""};const ie=[/^(sm:|md:|lg:|xl:|2xl:)?(col-span-|row-span-|col-start-|col-end-|row-start-|row-end-)/,/^(sm:|md:|lg:|xl:|2xl:)?(self-|place-self-|order-)/,/^(sm:|md:|lg:|xl:|2xl:)?(flex-shrink|flex-grow|flex-\d|basis-)/],ce=V.split(/\s+/).filter(Boolean),Z=[],ve=[];for(const pe of ce)ie.some(xe=>xe.test(pe))?Z.push(pe):ve.push(pe);return{wrapperClasses:Z.join(" "),innerClasses:ve.join(" ")}},[T.blur_until_loaded,Yt?.className]),Rn=window.__slotContextValue;return Te&&Rn?.isEnabled?null:yt.jsx(Ax,{componentId:s.id,componentName:s.name,children:T.blur_until_loaded?yt.jsx("div",{className:[un.wrapperClasses,pr?"opacity-50 blur-sm transition-all duration-300 pointer-events-none":void 0].filter(Boolean).join(" ")||void 0,children:da}):da})});Vr.displayName="DynamicRenderer",typeof window<"u"&&(window.__DynamicRenderer=Vr);function xx(s){const e={};try{const r=new URL(s,typeof window<"u"?window.location.origin:"http://localhost").searchParams,i=new Set;for(const l of r.keys()){if(i.has(l))continue;i.add(l);const c=r.getAll(l);c.length>1||l.endsWith("[]")?e[l]=c:e[l]=c[0]}}catch{}return e}function Tx(s){try{return new URL(s,typeof window<"u"?window.location.origin:"http://localhost").pathname}catch{return s.split("?")[0]}}const $i=class $i{constructor(){M(this,"config",{enabled:!1,maxHistorySize:100,logLevel:"info",serverEndpoint:"/_boost/g7-debug/dump-state",autoCapture:!0});M(this,"stateHistory",[]);M(this,"snapshotIdCounter",0);M(this,"stateWatchers",new Map);M(this,"currentLocalState",{});M(this,"currentComputedState",{});M(this,"currentParentContext");M(this,"actionHistory",[]);M(this,"actionWatchers",new Set);M(this,"cacheStats",{hits:0,misses:0,entries:0});M(this,"cacheDecisions",[]);M(this,"cacheDecisionIdCounter",0);M(this,"maxCacheDecisions",200);M(this,"currentRenderCycleId",null);M(this,"isInActionExecution",!1);M(this,"isInIteration",!1);M(this,"mountedComponents",new Map);M(this,"eventListeners",new Map);M(this,"mountWatchers",new Set);M(this,"unmountWatchers",new Set);M(this,"renderCounts",new Map);M(this,"bindingEvalCount",0);M(this,"profilingData",[]);M(this,"isProfiling",!1);M(this,"profilingStartTime",0);M(this,"activeRequests",new Map);M(this,"requestHistory",[]);M(this,"pendingDataSources",new Set);M(this,"requestWatchers",new Set);M(this,"wsConnections",new Map);M(this,"wsMessageHistory",[]);M(this,"wsMessageWatchers",new Set);M(this,"ifConditions",new Map);M(this,"iterations",new Map);M(this,"conditionWatchers",new Set);M(this,"forms",new Map);M(this,"formWatchers",new Set);M(this,"expressionHistory",[]);M(this,"expressionWatchers",new Set);M(this,"expressionIdCounter",0);M(this,"dataSources",new Map);M(this,"dataPathTransforms",[]);M(this,"maxDataPathTransforms",100);M(this,"nestedContexts",[]);M(this,"nestedContextIdCounter",0);M(this,"maxNestedContexts",100);M(this,"formBindingIssues",[]);M(this,"formBindingValidations",[]);M(this,"formBindingIssueIdCounter",0);M(this,"maxFormBindingIssues",100);M(this,"computedProperties",new Map);M(this,"computedRecalcLogs",[]);M(this,"computedRecalcIdCounter",0);M(this,"maxComputedRecalcLogs",100);M(this,"handlers",new Map);M(this,"componentEventSubscriptions",new Map);M(this,"componentEventEmitHistory",[]);M(this,"componentEventIdCounter",0);M(this,"maxComponentEventHistory",100);M(this,"stateRenderingLogs",[]);M(this,"currentStateChangeContext",null);M(this,"stateRenderingIdCounter",0);M(this,"componentRenderCounts",new Map);M(this,"stateToComponentMap",new Map);M(this,"maxStateRenderingLogs",100);M(this,"componentStateSources",new Map);M(this,"contextFlowNodes",new Map);M(this,"dynamicStates",new Map);M(this,"styleIssues",[]);M(this,"componentStyles",new Map);M(this,"authEvents",[]);M(this,"authHeaderHistory",[]);M(this,"authEventIdCounter",0);M(this,"maxAuthEventHistory",50);M(this,"logHistory",[]);M(this,"logIdCounter",0);M(this,"maxLogHistory",500);M(this,"currentLayout",null);M(this,"layoutHistory",[]);M(this,"layoutIdCounter",0);M(this,"layoutStats",{totalLoads:0,cacheHits:0,apiLoads:0});M(this,"maxLayoutHistory",50);M(this,"executionDetails",new Map);M(this,"stateChangeHistory",[]);M(this,"dataSourceChangeHistory",[]);M(this,"changeAlerts",[]);M(this,"changeExpectations",new Map);M(this,"executionIdCounter",0);M(this,"stateChangeIdCounter",0);M(this,"alertIdCounter",0);M(this,"maxExecutionDetails",100);M(this,"maxStateChangeHistory",200);M(this,"maxChangeAlerts",100);M(this,"sequenceExecutions",[]);M(this,"sequenceExecutionStack",[]);M(this,"sequenceIdCounter",0);M(this,"maxSequenceExecutions",50);M(this,"staleClosureWarnings",[]);M(this,"staleClosureIdCounter",0);M(this,"maxStaleClosureWarnings",100);M(this,"stateCaptureRegistry",new Map);M(this,"modalStates",new Map);M(this,"modalStateIssues",[]);M(this,"modalStateRelations",[]);M(this,"modalStateChangeLogs",[]);M(this,"modalStateIssueIdCounter",0);M(this,"modalStateChangeLogIdCounter",0);M(this,"maxModalStateIssues",100);M(this,"maxModalStateChangeLogs",200);M(this,"namedActionDefinitions",{});M(this,"namedActionRefLogs",[]);M(this,"namedActionRefIdCounter",0);M(this,"maxNamedActionRefLogs",200);M(this,"debounceActionHistory",[]);M(this,"dataSourceUpdateHistory",[]);M(this,"debounceActionIdCounter",0);M(this,"dataSourceUpdateIdCounter",0)}static getInstance(){return $i.instance||($i.instance=new $i),$i.instance}initialize(){if(this.config.enabled=this.checkDebugMode(),!this.config.enabled){console.log("[G7DevTools] 비활성화됨 (환경설정 > 고급 설정 > 디버그 모드를 켜세요)");return}console.log("[G7DevTools] 활성화됨"),this.setupGlobalErrorHandler()}checkDebugMode(){try{if(window.G7Config?.debug===!0)return!0;const r=window.G7Core?.state?.get?.();return r?.settings?.advanced?.debug_mode===!0||r?._global?.settings?.advanced?.debug_mode===!0}catch{return!1}}isEnabled(){return this.config.enabled}setupGlobalErrorHandler(){window.addEventListener("error",e=>{this.config.enabled&&this.logAction({id:this.generateId(),type:"globalError",startTime:Date.now(),status:"error",error:{name:"Error",message:e.message,stack:e.error?.stack}})}),window.addEventListener("unhandledrejection",e=>{this.config.enabled&&this.logAction({id:this.generateId(),type:"unhandledRejection",startTime:Date.now(),status:"error",error:{name:"UnhandledRejection",message:String(e.reason)}})})}captureStateSnapshot(e){if(!this.config.enabled)return;const n={id:++this.snapshotIdCounter,timestamp:Date.now(),source:e.source,prev:this.sanitizeObject(e.prev),next:this.sanitizeObject(e.next),diff:e.diff};this.stateHistory.push(n),this.stateHistory.length>this.config.maxHistorySize&&this.stateHistory.shift(),this.notifyStateWatchers(n)}getState(){try{const e=window.G7Core,n=e?.state?.get?.()||{},r={};if(e?._isolatedStates&&typeof e._isolatedStates=="object")for(const[i,l]of Object.entries(e._isolatedStates))r[i]=this.sanitizeObject(l);return{_global:n._global||n,_local:this.currentLocalState,_computed:this.currentComputedState,_isolated:Object.keys(r).length>0?r:void 0,$parent:this.currentParentContext}}catch{return{_global:{},_local:this.currentLocalState,_computed:this.currentComputedState}}}updateLocalState(e){this.config.enabled&&(this.currentLocalState=this.sanitizeObject(e))}updateComputedState(e){this.config.enabled&&(this.currentComputedState=this.sanitizeObject(e))}updateParentContext(e){this.config.enabled&&(this.currentParentContext=e?this.sanitizeObject(e):void 0)}getStateHistory(){return[...this.stateHistory]}getDualStorageMismatch(){const e=this.currentLocalState||{};let n={};try{n=(window.G7Core?.state?.get?.()||{})._local||{}}catch{n={}}const r=this.findMismatchedLeafPaths(e,n);return{hasMismatch:r.length>0,mismatchedPaths:r,storageA:e,storageB:n}}findMismatchedLeafPaths(e,n,r=""){const i=[],l=new Set([...Object.keys(e||{}),...Object.keys(n||{})]);for(const c of l){const d=r?`${r}.${c}`:c,f=e?.[c],h=n?.[c],m=f&&typeof f=="object"&&!Array.isArray(f),y=h&&typeof h=="object"&&!Array.isArray(h);if(m&&y)i.push(...this.findMismatchedLeafPaths(f,h,d));else{const v=f===void 0?"__undefined__":JSON.stringify(f),S=h===void 0?"__undefined__":JSON.stringify(h);v!==S&&i.push(d)}}return i}watchState(e,n){return this.stateWatchers.has(e)||this.stateWatchers.set(e,new Set),this.stateWatchers.get(e).add(n),()=>{this.stateWatchers.get(e)?.delete(n)}}notifyStateWatchers(e){if(this.stateWatchers.get("*")?.forEach(n=>{try{n(e.next,e.prev,"*")}catch(r){console.error("[G7DevTools] State watcher error:",r)}}),e.diff)for(const n of e.diff.changed)this.stateWatchers.get(n.path)?.forEach(r=>{try{r(n.newValue,n.oldValue,n.path)}catch(i){console.error("[G7DevTools] State watcher error:",i)}})}diffSnapshots(e,n){const r=this.stateHistory.find(l=>l.id===e),i=this.stateHistory.find(l=>l.id===n);return!r||!i?null:this.calculateDiff(r.next,i.next)}calculateDiff(e,n,r=""){const i={added:[],removed:[],changed:[]},l=new Set(Object.keys(e)),c=new Set(Object.keys(n));for(const d of c){const f=r?`${r}.${d}`:d;l.has(d)?JSON.stringify(e[d])!==JSON.stringify(n[d])&&i.changed.push({path:f,oldValue:e[d],newValue:n[d]}):i.added.push(f)}for(const d of l){const f=r?`${r}.${d}`:d;c.has(d)||i.removed.push(f)}return i}logAction(e){if(!this.config.enabled)return;const n=this.actionHistory.findIndex(r=>r.id===e.id);n>=0?this.actionHistory[n]={...this.actionHistory[n],...e}:(this.actionHistory.push(e),this.actionHistory.length>this.config.maxHistorySize&&this.actionHistory.shift()),this.isProfiling&&this.profilingData.push({type:"action",action:e.type,timestamp:performance.now(),duration:e.duration}),this.notifyActionWatchers(e)}getActionHistory(){return[...this.actionHistory]}watchActions(e){return this.actionWatchers.add(e),()=>{this.actionWatchers.delete(e)}}notifyActionWatchers(e){this.actionWatchers.forEach(n=>{try{n(e)}catch(r){console.error("[G7DevTools] Action watcher error:",r)}})}getActionMetrics(){const e=this.actionHistory.filter(l=>l.status==="success"),n=this.actionHistory.filter(l=>l.status==="error"),r={};for(const l of this.actionHistory)r[l.type]=(r[l.type]||0)+1;const i=e.reduce((l,c)=>l+(c.duration||0),0);return{totalActions:this.actionHistory.length,successCount:e.length,errorCount:n.length,averageDuration:e.length>0?i/e.length:0,actionsByType:r}}recordCacheHit(){this.config.enabled&&this.cacheStats.hits++}recordCacheMiss(){this.config.enabled&&this.cacheStats.misses++}updateCacheEntries(e){this.config.enabled&&(this.cacheStats.entries=e)}getCacheStats(){const e=this.cacheStats.hits+this.cacheStats.misses;return{...this.cacheStats,hitRate:e>0?this.cacheStats.hits/e:0}}resetCacheStats(){this.cacheStats={hits:0,misses:0,entries:0}}trackCacheDecision(e){if(!this.config.enabled)return;const n={id:`cache-${++this.cacheDecisionIdCounter}`,timestamp:Date.now(),expression:e.expression,decision:e.decision,reason:e.reason,context:{isInIteration:this.isInIteration,isInAction:this.isInActionExecution,renderCycleId:this.currentRenderCycleId||void 0,componentId:e.componentId,skipCacheOption:e.skipCacheOption},cachedValue:e.cachedValue!==void 0?this.safeClone(e.cachedValue):void 0,freshValue:e.freshValue!==void 0?this.safeClone(e.freshValue):void 0,valueMatch:e.cachedValue!==void 0&&e.freshValue!==void 0?JSON.stringify(e.cachedValue)===JSON.stringify(e.freshValue):void 0,duration:e.duration};this.cacheDecisions.push(n),this.cacheDecisions.length>this.maxCacheDecisions&&this.cacheDecisions.shift(),e.decision==="cache_hit"?this.cacheStats.hits++:(e.decision==="cache_miss"||e.decision==="skip_cache")&&this.cacheStats.misses++}startRenderCycle(e){return this.currentRenderCycleId=`render-${Date.now()}-${e||"root"}`,this.currentRenderCycleId}endRenderCycle(){this.currentRenderCycleId=null}startActionContext(){this.isInActionExecution=!0}endActionContext(){this.isInActionExecution=!1}startIterationContext(){this.isInIteration=!0}endIterationContext(){this.isInIteration=!1}getCacheDecisionTrackingInfo(){const e=this.getCacheDecisionStats();return{decisions:[...this.cacheDecisions],stats:e,timestamp:Date.now()}}getCacheDecisionStats(){const e=this.cacheDecisions;let n=0,r=0,i=0,l=0;const c={},d={};for(const h of e)h.decision==="cache_hit"?n++:h.decision==="cache_miss"?r++:h.decision==="skip_cache"?i++:h.decision==="invalidate"&&l++,c[h.reason]=(c[h.reason]||0)+1,h.context.componentId&&(d[h.context.componentId]=(d[h.context.componentId]||0)+1);const f=n+r+i;return{totalDecisions:e.length,cacheHits:n,cacheMisses:r,skipCacheCount:i,invalidateCount:l,byReason:c,byComponent:d,avgHitRate:f>0?n/f:0}}getRecentCacheDecisions(e=20,n){let r=[...this.cacheDecisions];return n&&(r=r.filter(i=>i.decision===n)),r.slice(-e)}clearCacheDecisionData(){this.cacheDecisions=[],this.cacheDecisionIdCounter=0}summarizePropsForLifecycle(e){if(!e||typeof e!="object")return e;const n={},r=["children","ref","key"];for(const[i,l]of Object.entries(e))if(!r.includes(i))if(l==null)n[i]=l;else if(Array.isArray(l))n[i]=`[Array(${l.length})]`;else if(typeof l=="object"){const c=Object.keys(l);c.length<=3?n[i]=`{${c.join(", ")}}`:n[i]=`{${c.slice(0,3).join(", ")}, ... +${c.length-3}}`}else typeof l=="string"&&l.length>50?n[i]=l.substring(0,50)+"...":typeof l=="function"?n[i]="[Function]":n[i]=l;return n}trackMount(e,n){if(!this.config.enabled)return;const r=this.summarizePropsForLifecycle(n.props),i={...n,props:r,id:e,mountTime:Date.now()};this.mountedComponents.set(e,i),this.mountWatchers.forEach(l=>{try{l({componentId:e,componentName:n.name,timestamp:i.mountTime})}catch(c){console.error("[G7DevTools] Mount watcher error:",c)}})}trackUnmount(e){if(!this.config.enabled)return;const n=this.mountedComponents.get(e),r=this.eventListeners.get(e)||[];r.length>0&&console.warn(`[G7DevTools] 컴포넌트 ${e} 언마운트 시 ${r.length}개 리스너 미정리`),n&&this.unmountWatchers.forEach(i=>{try{i({componentId:e,componentName:n.name,timestamp:Date.now(),orphanedListeners:r.length})}catch(l){console.error("[G7DevTools] Unmount watcher error:",l)}}),this.mountedComponents.delete(e)}trackListener(e,n,r){if(!this.config.enabled)return;const i=this.eventListeners.get(e)||[];i.push({type:n,target:r,addedAt:Date.now()}),this.eventListeners.set(e,i)}removeListener(e,n){if(!this.config.enabled)return;const r=this.eventListeners.get(e)||[],i=r.findIndex(l=>l.type===n);i>=0&&r.splice(i,1)}getMountedComponents(){return Array.from(this.mountedComponents.values())}getOrphanedListeners(){const e=[];for(const[n,r]of this.eventListeners)this.mountedComponents.has(n)||e.push(...r.map(i=>({...i,componentId:n})));return e}watchMount(e){return this.mountWatchers.add(e),()=>{this.mountWatchers.delete(e)}}watchUnmount(e){return this.unmountWatchers.add(e),()=>{this.unmountWatchers.delete(e)}}trackRender(e){if(!this.config.enabled)return;const n=this.renderCounts.get(e)||0;this.renderCounts.set(e,n+1),this.isProfiling&&this.profilingData.push({type:"render",component:e,timestamp:performance.now()})}trackBindingEval(e){this.config.enabled&&(this.bindingEvalCount++,this.isProfiling&&e&&this.profilingData.push({type:"binding",expression:e,timestamp:performance.now()}))}getRenderCount(){return new Map(this.renderCounts)}getBindingEvalCount(){return this.bindingEvalCount}getMemoryWarnings(){const e=[];try{const i=this.getState(),l=JSON.stringify(i).length;l>1e6&&e.push({type:"large-state",message:`상태 크기가 ${(l/1024/1024).toFixed(2)}MB입니다`,suggestion:"불필요한 데이터 정리 필요",severity:l>5e6?"error":"warning"})}catch{}this.stateHistory.length>this.config.maxHistorySize*.8&&e.push({type:"large-history",message:`상태 이력이 ${this.stateHistory.length}개입니다`,suggestion:"maxHistory 설정 조정 필요",severity:"warning"});const n=this.getOrphanedListeners().length;n>0&&e.push({type:"orphaned-listeners",message:`${n}개의 정리되지 않은 이벤트 리스너`,suggestion:"useEffect cleanup 또는 removeEventListener 확인",severity:n>10?"error":"warning"});const r=Array.from(this.renderCounts.entries()).filter(([,i])=>i>50);return r.length>0&&e.push({type:"excessive-renders",message:`${r.length}개 컴포넌트가 50회 이상 렌더링`,suggestion:"React.memo, useMemo, useCallback 사용 고려",severity:"warning"}),e}startProfiling(){this.config.enabled&&(this.isProfiling=!0,this.profilingData=[],this.profilingStartTime=performance.now(),console.log("[G7DevTools] 프로파일링 시작"))}stopProfiling(){this.isProfiling=!1;const e=performance.now()-this.profilingStartTime,n=this.analyzeProfile(e);return console.log("[G7DevTools] 프로파일링 완료",n),n}analyzeProfile(e){const n=this.profilingData.filter(h=>h.type==="render"),r=this.profilingData.filter(h=>h.type==="binding"),i=this.profilingData.filter(h=>h.type==="action"),l={};for(const h of n)h.component&&(l[h.component]||(l[h.component]={count:0,durations:[]}),l[h.component].count++,h.duration&&l[h.component].durations.push(h.duration));const c=Object.entries(l).map(([h,m])=>({name:h,renderCount:m.count,avgDuration:m.durations.length>0?m.durations.reduce((y,v)=>y+v,0)/m.durations.length:0})).sort((h,m)=>m.renderCount-h.renderCount).slice(0,10),d={};for(const h of r)h.expression&&(d[h.expression]=(d[h.expression]||0)+1);const f=Object.entries(d).sort(([,h],[,m])=>m-h).slice(0,10).map(([h])=>h);return{duration:e,entries:this.profilingData,summary:{totalRenders:n.length,totalBindings:r.length,totalActions:i.length,slowestComponents:c,hotPaths:f}}}resetPerformanceStats(){this.renderCounts.clear(),this.bindingEvalCount=0,this.profilingData=[]}trackRequest(e,n,r){if(!this.config.enabled)return"";const i=this.generateId(),l=Tx(e),c=xx(e);return this.activeRequests.set(i,{id:i,url:l,fullUrl:e,queryParams:c,method:n,startTime:Date.now(),status:"pending",requestBody:r?.requestBody?this.sanitizeObject(r.requestBody):void 0,dataSourceId:r?.dataSourceId}),this.isProfiling&&this.profilingData.push({type:"network",timestamp:performance.now()}),i}completeRequest(e,n,r){if(!this.config.enabled)return;const i=this.activeRequests.get(e);if(!i)return;const l={...i,status:n>=200&&n<300?"success":"error",statusCode:n,duration:Date.now()-i.startTime,endTime:Date.now(),response:this.sanitizeObject(r)};this.requestHistory.push(l),this.activeRequests.delete(e),this.requestHistory.length>this.config.maxHistorySize&&this.requestHistory.shift(),this.notifyRequestWatchers(l)}failRequest(e,n){if(!this.config.enabled)return;const r=this.activeRequests.get(e);if(!r)return;const i={...r,status:"error",error:n,duration:Date.now()-r.startTime,endTime:Date.now()};this.requestHistory.push(i),this.activeRequests.delete(e),this.notifyRequestWatchers(i)}trackDataSource(e){this.config.enabled&&this.pendingDataSources.add(e)}completeDataSource(e){this.config.enabled&&this.pendingDataSources.delete(e)}getActiveRequests(){return Array.from(this.activeRequests.values())}getRequestHistory(){return[...this.requestHistory]}getPendingDataSources(){return Array.from(this.pendingDataSources)}watchRequest(e){return this.requestWatchers.add(e),()=>{this.requestWatchers.delete(e)}}notifyRequestWatchers(e){this.requestWatchers.forEach(n=>{try{n(e)}catch(r){console.error("[G7DevTools] Request watcher error:",r)}})}trackWebSocketConnection(e,n,r){this.config.enabled&&this.wsConnections.set(e,{id:e,url:n,state:r,connectedAt:r==="open"?Date.now():void 0})}trackWebSocketMessage(e,n,r,i){if(!this.config.enabled)return;const l={id:this.generateId(),connectionId:e,direction:n,type:r,payload:this.sanitizeObject(i),timestamp:Date.now(),sequence:this.wsMessageHistory.length};this.wsMessageHistory.push(l),this.wsMessageHistory.length>this.config.maxHistorySize&&this.wsMessageHistory.shift(),this.notifyWebSocketWatchers(l)}getWebSocketConnections(){return Array.from(this.wsConnections.values())}getWebSocketMessageHistory(){return[...this.wsMessageHistory]}getWebSocketConnectionState(){const e=Array.from(this.wsConnections.values());return e.some(n=>n.state==="open")?"connected":e.some(n=>n.state==="connecting")?"reconnecting":"disconnected"}watchWebSocketMessage(e){return this.wsMessageWatchers.add(e),()=>{this.wsMessageWatchers.delete(e)}}notifyWebSocketWatchers(e){this.wsMessageWatchers.forEach(n=>{try{n(e)}catch(r){console.error("[G7DevTools] WebSocket watcher error:",r)}})}trackIfCondition(e,n,r){if(!this.config.enabled)return;const i=this.ifConditions.get(e),l=i?.evaluatedValue;this.ifConditions.set(e,{id:e,expression:n,evaluatedValue:r,evaluationCount:(i?.evaluationCount||0)+1,lastEvaluated:Date.now()}),i&&l!==r&&this.notifyConditionWatchers({id:e,expression:n,oldValue:l,newValue:r,timestamp:Date.now()})}trackIteration(e,n){this.config.enabled&&this.iterations.set(e,{id:e,...n,lastRendered:Date.now()})}getIfConditions(){return Array.from(this.ifConditions.values())}getIterations(){return Array.from(this.iterations.values())}getScopeChain(e){const n=[],r=this.getState();return n.push({name:"_global",value:r._global,source:"global"}),n.push({name:"_local",value:r._local,source:"local"}),n.push({name:"_computed",value:r._computed,source:"computed"}),n}watchConditionChange(e){return this.conditionWatchers.add(e),()=>{this.conditionWatchers.delete(e)}}notifyConditionWatchers(e){this.conditionWatchers.forEach(n=>{try{n(e)}catch(r){console.error("[G7DevTools] Condition watcher error:",r)}})}trackForm(e,n,r){this.config.enabled&&this.forms.set(e,{id:e,dataKey:n,inputs:r,trackedAt:Date.now()})}trackFormChange(e,n,r){if(!this.config.enabled)return;const i={formId:e,inputName:n,value:r,timestamp:Date.now()};this.notifyFormWatchers(i)}untrackForm(e){this.forms.delete(e)}getForms(){return Array.from(this.forms.values())}getFormState(e){const n=this.getState();return this.getNestedValue(n,e)||{}}getBindingPath(e,n){return`${e}.${n}`}watchFormChange(e){return this.formWatchers.add(e),()=>{this.formWatchers.delete(e)}}notifyFormWatchers(e){this.formWatchers.forEach(n=>{try{n(e)}catch(r){console.error("[G7DevTools] Form watcher error:",r)}})}trackFormBindingIssue(e,n,r){if(!this.config.enabled)return;const i={id:`form-issue-${++this.formBindingIssueIdCounter}`,timestamp:Date.now(),type:e,severity:n,formId:r.formId,formDataKey:r.formDataKey,inputInfo:r.inputInfo,contextInfo:r.contextInfo,description:r.description,suggestion:r.suggestion,docLink:r.docLink};this.formBindingIssues.push(i),this.formBindingIssues.length>this.maxFormBindingIssues&&this.formBindingIssues.shift()}validateFormBinding(e,n,r,i){const l=r.map(f=>{const h=[];let m=!0;return f.name||(h.push("Input에 name 속성이 없습니다"),m=!1,this.trackFormBindingIssue("missing-input-name","error",{formId:e,formDataKey:n,inputInfo:{name:f.name,type:f.type},description:"Input에 name 속성이 없어 자동 바인딩이 동작하지 않습니다",suggestion:"Input에 name 속성을 추가하세요",docLink:"troubleshooting-components-form.md"})),n||(h.push("Form에 dataKey가 없습니다"),m=!1),{inputName:f.name||"(unnamed)",inputType:f.type,bindingPath:n&&f.name?`${n}.${f.name}`:"-",isValid:m,currentValue:f.value,issues:h}});if(n||this.trackFormBindingIssue("missing-datakey","error",{formId:e,description:"Form에 dataKey가 설정되지 않아 자동 바인딩이 동작하지 않습니다",suggestion:"Form 컴포넌트에 dataKey props를 설정하세요",docLink:"troubleshooting-components-form.md"}),i.isContextBroken){const f=i.breakReason?.includes("sortable")?"sortable-context-break":i.breakReason?.includes("modal")?"modal-context-isolation":"context-not-propagated";this.trackFormBindingIssue(f,"warning",{formId:e,formDataKey:n,contextInfo:{hasParentFormContext:i.hasParentContext,parentFormContextProp:i.parentContextProp,isInsideSortable:i.breakReason?.includes("sortable")||!1,isInsideModal:i.breakReason?.includes("modal")||!1,depth:0},description:i.breakReason||"Form 컨텍스트가 제대로 전파되지 않았습니다",suggestion:"parentFormContextProp={undefined}를 확인하거나 중첩 구조를 검토하세요",docLink:"troubleshooting-components-form.md"})}const c={formId:e,dataKey:n,timestamp:Date.now(),contextPropagation:i,inputBindings:l,isValid:l.every(f=>f.isValid)&&!!n&&!i.isContextBroken,issueCount:l.filter(f=>!f.isValid).length+(n?0:1)+(i.isContextBroken?1:0)},d=this.formBindingValidations.findIndex(f=>f.formId===e);return d>=0?this.formBindingValidations[d]=c:this.formBindingValidations.push(c),c}getFormBindingValidationTrackingInfo(){const e=this.getFormBindingValidationStats();return{issues:[...this.formBindingIssues],validations:[...this.formBindingValidations],stats:e,timestamp:Date.now()}}getFormBindingValidationStats(){const e={"missing-datakey":0,"missing-input-name":0,"context-not-propagated":0,"sortable-context-break":0,"modal-context-isolation":0,"duplicate-input-name":0,"value-type-mismatch":0,"binding-path-invalid":0},n={info:0,warning:0,error:0};for(const i of this.formBindingIssues)e[i.type]++,n[i.severity]++;const r=Object.entries(e).filter(([,i])=>i>0).sort((i,l)=>l[1]-i[1]).slice(0,5).map(([i,l])=>({type:i,count:l,description:this.getIssueTypeDescription(i)}));return{totalFormsValidated:this.formBindingValidations.length,validForms:this.formBindingValidations.filter(i=>i.isValid).length,formsWithIssues:this.formBindingValidations.filter(i=>!i.isValid).length,totalIssues:this.formBindingIssues.length,byIssueType:e,bySeverity:n,topIssues:r}}getIssueTypeDescription(e){return{"missing-datakey":"Form에 dataKey 누락","missing-input-name":"Input에 name 속성 누락","context-not-propagated":"Form 컨텍스트 전파 실패","sortable-context-break":"Sortable 컨테이너에서 컨텍스트 단절","modal-context-isolation":"모달에서 부모 Form 컨텍스트 격리","duplicate-input-name":"동일 Form 내 중복 Input name","value-type-mismatch":"값 타입과 Input 타입 불일치","binding-path-invalid":"바인딩 경로 유효하지 않음"}[e]||e}clearFormBindingIssues(){this.formBindingIssues=[],this.formBindingValidations=[],this.formBindingIssueIdCounter=0}trackComputedProperty(e,n,r,i,l,c,d){if(!this.config.enabled)return;const f=`computed-${e}-${c||"global"}`,h={id:f,name:e,expression:n,componentId:c,dependencies:r,currentValue:this.safeClone(i),lastComputedAt:Date.now(),computationTime:l,error:d};this.computedProperties.set(f,h)}trackComputedRecalc(e,n,r,i,l,c,d){if(!this.config.enabled)return;const f=`computed-${e}-${d||"global"}`,h=JSON.stringify(r)!==JSON.stringify(i),m={id:`recalc-${++this.computedRecalcIdCounter}`,computedId:f,computedName:e,timestamp:Date.now(),trigger:n,triggeredBy:c,previousValue:this.safeClone(r),newValue:this.safeClone(i),valueChanged:h,computationTime:l,cascadeCount:0};this.computedRecalcLogs.push(m),this.computedRecalcLogs.length>this.maxComputedRecalcLogs&&this.computedRecalcLogs.shift();const y=this.computedProperties.get(f);y&&(y.currentValue=this.safeClone(i),y.lastComputedAt=Date.now(),y.computationTime=l)}analyzeComputedDependencyChain(e,n){const r=new Set,i=[];let l=!1,c,d=0;const f=(m,y)=>{if(d=Math.max(d,y),r.has(m))return l=!0,c=[...i,m],{name:m,type:"computed",children:[],depth:y};r.add(m),i.push(m);const v=this.computedProperties.get(`computed-${m}-${n||"global"}`),S=[];if(v)for(const _ of v.dependencies)_.type==="computed"?S.push(f(_.path,y+1)):S.push({name:_.path,type:_.type,children:[],depth:y+1});return i.pop(),r.delete(m),{name:m,type:"computed",children:S,depth:y}},h=f(e,0);return{root:e,tree:h,hasCycle:l,cyclePath:c,maxDepth:d}}getComputedDependencyTrackingInfo(){const e=Array.from(this.computedProperties.values()),n=this.getComputedDependencyStats(),r=[];for(const i of e){const l=this.analyzeComputedDependencyChain(i.name,i.componentId);r.push(l)}return{properties:e,recalcLogs:[...this.computedRecalcLogs],dependencyChains:r,stats:n,timestamp:Date.now()}}getComputedDependencyStats(){const e={"state-change":0,"datasource-update":0,"dependency-change":0,manual:0,initial:0},n={},r={};let i=0,l=0;for(const h of this.computedRecalcLogs)e[h.trigger]++,h.valueChanged||l++,n[h.computedName]=(n[h.computedName]||0)+1,r[h.computedName]||(r[h.computedName]=[]),r[h.computedName].push(h.computationTime),i+=h.computationTime;const c=Object.entries(n).sort((h,m)=>m[1]-h[1]).slice(0,5).map(([h,m])=>({name:h,count:m})),d=Object.entries(r).map(([h,m])=>({name:h,avgTime:m.reduce((y,v)=>y+v,0)/m.length})).sort((h,m)=>m.avgTime-h.avgTime).slice(0,5);let f=0;for(const h of this.computedProperties.values())this.analyzeComputedDependencyChain(h.name,h.componentId).hasCycle&&f++;return{totalComputed:this.computedProperties.size,totalRecalculations:this.computedRecalcLogs.length,unnecessaryRecalculations:l,avgComputationTime:this.computedRecalcLogs.length>0?i/this.computedRecalcLogs.length:0,topRecalculated:c,slowestComputed:d,cycleDetectionCount:f,byTrigger:e}}clearComputedTracking(){this.computedProperties.clear(),this.computedRecalcLogs=[],this.computedRecalcIdCounter=0}trackModalOpen(e){if(!this.config.enabled)return;const n={modalId:e.modalId,modalName:e.modalName,openedAt:Date.now(),closedAt:null,scopeType:e.scopeType||"isolated",parentModalId:e.parentModalId,componentId:e.componentId,initialState:e.initialState?{...e.initialState}:{},currentState:e.initialState?{...e.initialState}:{},stateChangeCount:0,isolatedStateKeys:e.isolatedStateKeys||[],sharedStateKeys:e.sharedStateKeys||[]};this.modalStates.set(e.modalId,n),this.validateModalDefinitionExists(e.modalId,e.modalName),e.parentModalId&&(this.modalStateRelations.find(i=>i.parentModalId===e.parentModalId&&i.childModalId===e.modalId)||this.modalStateRelations.push({parentModalId:e.parentModalId,childModalId:e.modalId,sharedKeys:e.sharedStateKeys||[],isolatedKeys:e.isolatedStateKeys||[],relationType:"parent-child"}))}trackModalClose(e,n){if(!this.config.enabled)return;const r=this.modalStates.get(e);r&&(r.closedAt=Date.now(),n&&(r.currentState={...n}),this.detectStateLeakage(r))}validateModalDefinitionExists(e,n){const r=this.currentLayout;if(!r?.layoutJson)return;const i=r.layoutJson.modals;if(!i){this.recordModalStateIssue({type:"missing-definition",modalId:e,modalName:n,severity:"error",description:`모달 "${e}"이(가) modalStack에 추가되었으나, 현재 레이아웃에 modals 섹션이 없습니다. 레이아웃 경로: ${r.layoutPath}`,affectedStateKeys:[],expectedValue:`modals 섹션에 id="${e}" 정의 존재`,actualValue:"modals 섹션 없음"});return}const l=Array.isArray(i)?i:Object.values(i);l.some(d=>d?.id===e||d?.props?.id===e)||this.recordModalStateIssue({type:"missing-definition",modalId:e,modalName:n,severity:"error",description:`모달 "${e}"이(가) modalStack에 추가되었으나, 렌더링된 레이아웃의 modals 섹션에 해당 ID의 정의가 없습니다. partial 로딩 실패, 레이아웃 병합 문제, extends 상속 누락 등을 확인하세요. 레이아웃 경로: ${r.layoutPath}`,affectedStateKeys:[],expectedValue:`modals 배열에 id="${e}" 항목 존재`,actualValue:`modals 배열에 ${l.length}개 모달 정의 (${l.map(d=>d?.id||"unknown").join(", ")})`})}trackModalStateChange(e){if(!this.config.enabled)return;const n=this.modalStates.get(e.modalId);if(!n)return;n.stateChangeCount++,n.currentState[e.stateKey]=e.newValue;const r=this.checkIsolationViolation(n,e.stateKey),i={id:`modal-change-${++this.modalStateChangeLogIdCounter}`,modalId:e.modalId,modalName:n.modalName,timestamp:Date.now(),stateKey:e.stateKey,previousValue:e.previousValue,newValue:e.newValue,changeSource:e.changeSource||"user-action",violatesIsolation:r};this.modalStateChangeLogs.push(i),this.modalStateChangeLogs.length>this.maxModalStateChangeLogs&&this.modalStateChangeLogs.shift(),r&&this.recordModalStateIssue({type:"isolation-violation",modalId:e.modalId,modalName:n.modalName,severity:"warning",description:`모달 '${n.modalName}'에서 격리된 상태 키 '${e.stateKey}'가 변경됨`,affectedStateKeys:[e.stateKey]})}detectStateLeakage(e){if(e.scopeType==="isolated")for(const n of e.isolatedStateKeys){const r=e.initialState[n],i=e.currentState[n];if(r!==i&&e.parentModalId){const l=this.modalStates.get(e.parentModalId);l&&l.currentState.hasOwnProperty(n)&&this.recordModalStateIssue({type:"state-leakage",modalId:e.modalId,modalName:e.modalName,severity:"error",description:`모달 닫힘 후 상태 '${n}'가 부모 모달로 유출될 수 있음`,affectedStateKeys:[n],leakedValue:i,expectedValue:r})}}}checkIsolationViolation(e,n){return e.scopeType==="isolated",!1}recordModalStateIssue(e){const n={id:`modal-issue-${++this.modalStateIssueIdCounter}`,type:e.type,modalId:e.modalId,modalName:e.modalName,timestamp:Date.now(),severity:e.severity,description:e.description,affectedStateKeys:e.affectedStateKeys,leakedValue:e.leakedValue,expectedValue:e.expectedValue,actualValue:e.actualValue,stackInfo:e.stackInfo};this.modalStateIssues.push(n),this.modalStateIssues.length>this.maxModalStateIssues&&this.modalStateIssues.shift()}getModalStateScopeTrackingInfo(){const e=Array.from(this.modalStates.values()),n=this.getModalStateScopeStats();return{modals:e,issues:[...this.modalStateIssues],relations:[...this.modalStateRelations],changeLogs:[...this.modalStateChangeLogs],stats:n,timestamp:Date.now()}}getModalStateScopeStats(){const e=Array.from(this.modalStates.values()),n={warning:0,error:0},r={"state-leakage":0,"isolation-violation":0,"parent-mutation":0,"orphaned-state":0,"scope-mismatch":0,"cleanup-failure":0,"missing-definition":0};for(const l of this.modalStateIssues)n[l.severity]++,r[l.type]++;const i={isolated:0,shared:0,inherited:0};for(const l of e)i[l.scopeType]++;return{totalModals:e.length,openModals:e.filter(l=>l.closedAt===null).length,nestedModals:e.filter(l=>l.parentModalId!==void 0).length,totalIssues:this.modalStateIssues.length,issuesBySeverity:n,issuesByType:r,byScope:i,leakageDetectionCount:r["state-leakage"],cleanupFailureCount:r["cleanup-failure"]}}clearModalStateScopeTracking(){this.modalStates.clear(),this.modalStateIssues=[],this.modalStateRelations=[],this.modalStateChangeLogs=[],this.modalStateIssueIdCounter=0,this.modalStateChangeLogIdCounter=0}setNamedActionDefinitions(e){this.config.enabled&&(this.namedActionDefinitions=e||{})}trackNamedActionRef(e){if(!this.config.enabled)return;const n={...e,id:`named_action_ref_${++this.namedActionRefIdCounter}`};this.namedActionRefLogs.push(n),this.namedActionRefLogs.length>this.maxNamedActionRefLogs&&(this.namedActionRefLogs=this.namedActionRefLogs.slice(-this.maxNamedActionRefLogs))}getNamedActionTrackingInfo(){const e={};for(const r of this.namedActionRefLogs)e[r.actionRefName]=(e[r.actionRefName]||0)+1;const n=Object.keys(this.namedActionDefinitions).filter(r=>!e[r]);return{definitions:this.namedActionDefinitions,refLogs:[...this.namedActionRefLogs],stats:{totalDefinitions:Object.keys(this.namedActionDefinitions).length,totalRefs:this.namedActionRefLogs.length,refCountByName:e,unusedDefinitions:n},timestamp:Date.now()}}clearNamedActionTracking(){this.namedActionDefinitions={},this.namedActionRefLogs=[],this.namedActionRefIdCounter=0}trackExpressionEval(e){if(!this.config.enabled)return;const n={...e,id:`expr-${++this.expressionIdCounter}`,timestamp:Date.now(),warning:this.detectExpressionWarning(e)};this.expressionHistory.push(n),this.expressionHistory.length>500&&this.expressionHistory.shift(),this.isProfiling&&this.profilingData.push({type:"binding",expression:e.expression,timestamp:performance.now(),duration:e.duration}),this.notifyExpressionWatchers(n)}detectExpressionWarning(e){const{expression:n,result:r,resultType:i,method:l,duration:c}=e;if(i==="undefined"&&!n.includes("??")&&!n.includes("||")&&/^[a-zA-Z_$][a-zA-Z0-9_$.]*$/.test(n.replace(/{{|}}/g,"").trim()))return{type:"undefined-result",message:"표현식 결과가 undefined입니다",suggestion:`데이터가 로드되었는지 확인하거나 fallback 값을 추가하세요: ${n} ?? ''`};if(i==="null")return{type:"null-result",message:"표현식 결과가 null입니다",suggestion:`nullish coalescing 연산자를 사용하세요: ${n} ?? ''`};if(l==="resolveBindings"&&i==="string"){const d=String(r);if(d.includes("[object Object]")||/^\[.*\]$/.test(d))return{type:"array-to-string",message:"배열/객체가 문자열로 변환되었습니다",suggestion:"evaluateExpression()을 사용하여 원본 타입을 유지하세요"}}if(l==="resolveBindings"&&i==="string"&&String(r).includes("[object Object]"))return{type:"object-to-string",message:"객체가 [object Object]로 변환되었습니다",suggestion:"evaluateExpression()을 사용하거나 특정 속성에 접근하세요"};if(i==="undefined"&&n.includes(".")&&!n.includes("?.")){const d=n.replace(/{{|}}/g,"").trim().split(".");if(d.length>=2)return{type:"missing-optional-chain",message:"Optional chaining(?.) 누락 가능성",suggestion:`안전한 접근을 위해 ?. 사용을 고려하세요: ${d.join("?.")}`}}if((n.includes("{{item.")||n.includes("{{index}}"))&&Array.from(this.iterations.values()).some(h=>h.itemVar!=="item"))return{type:"wrong-iteration-var",message:"'item'/'index' 대신 iteration에서 정의한 변수명을 사용해야 합니다",suggestion:"iteration의 item_var/index_var에 정의된 변수명을 확인하세요"};if(c&&c>10)return{type:"slow-evaluation",message:`표현식 평가에 ${c.toFixed(2)}ms 소요됨`,suggestion:"복잡한 표현식을 단순화하거나 computed 값으로 분리하세요"}}getExpressions(){return[...this.expressionHistory]}getExpressionWarnings(){return this.expressionHistory.filter(e=>e.warning!=null)}searchExpressions(e){const n=e.toLowerCase();return this.expressionHistory.filter(r=>r.expression.toLowerCase().includes(n)||r.componentName?.toLowerCase().includes(n)||r.propName?.toLowerCase().includes(n))}getExpressionStats(){const e=this.expressionHistory,n=new Set(e.map(f=>f.expression)),r=e.filter(f=>f.warning!=null),i=e.filter(f=>f.fromCache),l=e.filter(f=>f.duration!=null).map(f=>f.duration),c={};for(const f of e)c[f.resultType]=(c[f.resultType]||0)+1;const d={};for(const f of r)f.warning&&(d[f.warning.type]=(d[f.warning.type]||0)+1);return{totalEvaluations:e.length,uniqueExpressions:n.size,warningCount:r.length,cacheHitRate:e.length>0?i.length/e.length:0,averageDuration:l.length>0?l.reduce((f,h)=>f+h,0)/l.length:0,byType:c,byWarning:d}}clearExpressions(){this.expressionHistory=[],this.expressionIdCounter=0}watchExpressions(e){return this.expressionWatchers.add(e),()=>{this.expressionWatchers.delete(e)}}notifyExpressionWatchers(e){this.expressionWatchers.forEach(n=>{try{n(e)}catch(r){console.error("[G7DevTools] Expression watcher error:",r)}})}setLogLevel(e){this.config.logLevel=e}setMaxHistory(e){this.config.maxHistorySize=Math.max(10,Math.min(1e3,e))}setServerEndpoint(e){this.config.serverEndpoint=e}getConfig(){return{...this.config}}generateId(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}sanitizeObject(e,n=new WeakSet){if(e===null||typeof e!="object")return e;if(n.has(e))return"[Circular]";if(n.add(e),Array.isArray(e))return e.map(i=>this.sanitizeObject(i,n));const r={};for(const i of Object.keys(e))try{r[i]=this.sanitizeObject(e[i],n)}catch{r[i]="[Unable to serialize]"}return r}getNestedValue(e,n){if(!n)return e;const r=n.split(".");let i=e;for(const l of r){if(i==null)return;i=i[l]}return i}getLifecycleInfo(){return{mountedComponents:Array.from(this.mountedComponents.values()),orphanedListeners:this.getOrphanedListeners()}}getPerformanceInfo(){return{renderCounts:this.renderCounts,bindingEvalCount:this.bindingEvalCount,memoryWarnings:this.getMemoryWarnings()}}getNetworkInfo(){return{activeRequests:Array.from(this.activeRequests.values()),requestHistory:[...this.requestHistory],pendingDataSources:Array.from(this.pendingDataSources)}}getConditionalInfo(){return{ifConditions:Array.from(this.ifConditions.values()),iterations:Array.from(this.iterations.values())}}getFormInfo(){return Array.from(this.forms.values())}getWebSocketInfo(){return{connections:Array.from(this.wsConnections.values()),messageHistory:[...this.wsMessageHistory],connectionState:this.getWebSocketConnectionState()}}getStateAtTime(e){const n=[...this.stateHistory].reverse().find(r=>r.timestamp<=e);if(n)return{_global:n.next,_local:{}}}reset(){this.stateHistory=[],this.actionHistory=[],this.cacheStats={hits:0,misses:0,entries:0},this.cacheDecisions=[],this.cacheDecisionIdCounter=0,this.currentRenderCycleId=null,this.isInActionExecution=!1,this.isInIteration=!1,this.mountedComponents.clear(),this.eventListeners.clear(),this.renderCounts.clear(),this.bindingEvalCount=0,this.profilingData=[],this.activeRequests.clear(),this.requestHistory=[],this.pendingDataSources.clear(),this.wsConnections.clear(),this.wsMessageHistory=[],this.ifConditions.clear(),this.iterations.clear(),this.forms.clear(),this.expressionHistory=[],this.expressionIdCounter=0,this.dataSources.clear(),this.dataPathTransforms=[],this.nestedContexts=[],this.nestedContextIdCounter=0,this.formBindingIssues=[],this.formBindingValidations=[],this.formBindingIssueIdCounter=0,this.computedProperties.clear(),this.computedRecalcLogs=[],this.computedRecalcIdCounter=0,this.modalStates.clear(),this.modalStateIssues=[],this.modalStateRelations=[],this.modalStateChangeLogs=[],this.modalStateIssueIdCounter=0,this.modalStateChangeLogIdCounter=0,this.logHistory=[],this.logIdCounter=0}getExpressionInfo(){return{expressions:this.getExpressions(),stats:this.getExpressionStats()}}trackLog(e,n,r){if(!this.config.enabled)return;const i=r.map(c=>{if(typeof c=="string")return c;try{return JSON.stringify(c)}catch{return String(c)}}).join(" "),l={id:`log-${++this.logIdCounter}`,level:e,prefix:n,message:i,args:this.sanitizeObject(r),timestamp:Date.now(),stack:e==="error"?new Error().stack:void 0};this.logHistory.push(l),this.logHistory.length>this.maxLogHistory&&this.logHistory.shift()}trackAction(e){if(!this.config.enabled)return;const n={id:`debounce-action-${++this.debounceActionIdCounter}`,...e,timestamp:Date.now()};this.debounceActionHistory.push(n),this.debounceActionHistory.length>100&&this.debounceActionHistory.shift()}trackDataSourceUpdate(e){if(!this.config.enabled)return;const n={id:`ds-update-${++this.dataSourceUpdateIdCounter}`,...e};this.dataSourceUpdateHistory.push(n),this.dataSourceUpdateHistory.length>100&&this.dataSourceUpdateHistory.shift()}getDebounceActionHistory(e){let n=[...this.debounceActionHistory];return e?.handler&&(n=n.filter(r=>r.handler.includes(e.handler))),e?.status&&(n=n.filter(r=>r.status===e.status)),e?.limit&&(n=n.slice(-e.limit)),n}getDataSourceUpdateHistory(e){let n=[...this.dataSourceUpdateHistory];return e?.dataSourceId&&(n=n.filter(r=>r.dataSourceId===e.dataSourceId)),e?.updateType&&(n=n.filter(r=>r.updateType===e.updateType)),e?.limit&&(n=n.slice(-e.limit)),n}getLogs(e){let n=[...this.logHistory];if(e?.level){const r=Array.isArray(e.level)?e.level:[e.level];n=n.filter(i=>r.includes(i.level))}if(e?.prefix){const r=e.prefix.toLowerCase();n=n.filter(i=>i.prefix.toLowerCase().includes(r))}if(e?.search){const r=e.search.toLowerCase();n=n.filter(i=>i.message.toLowerCase().includes(r))}return e?.since&&(n=n.filter(r=>r.timestamp>=e.since)),e?.limit&&(n=n.slice(-e.limit)),n}getLogStats(){const n=Date.now()-6e4,r={log:0,warn:0,error:0,debug:0,info:0},i={};let l=0,c=0;for(const d of this.logHistory)r[d.level]++,i[d.prefix]=(i[d.prefix]||0)+1,d.timestamp>=n&&(d.level==="error"&&l++,d.level==="warn"&&c++);return{totalLogs:this.logHistory.length,byLevel:r,byPrefix:i,recentErrors:l,recentWarnings:c}}clearLogs(){this.logHistory=[],this.logIdCounter=0}getLogInfo(){return{entries:this.getLogs(),stats:this.getLogStats()}}trackDataSourceDefinition(e){this.config.enabled&&this.dataSources.set(e.id,{...e,status:"idle"})}trackDataSourceLoading(e){if(!this.config.enabled)return;const n=this.dataSources.get(e);n&&this.dataSources.set(e,{...n,status:"loading"})}trackDataSourceLoaded(e,n,r){if(!this.config.enabled)return;const i=this.dataSources.get(e);if(!i)return;let l,c,d=r;n&&(Array.isArray(n)?(l=n.length,c=n.length>0&&typeof n[0]=="object"?Object.keys(n[0]):void 0):typeof n=="object"&&(Array.isArray(n.data)?(d=d||"data",l=n.data.length,c=n.data.length>0&&typeof n.data[0]=="object"?Object.keys(n.data[0]):void 0):Array.isArray(n.items)?(d=d||"items",l=n.items.length,c=n.items.length>0&&typeof n.items[0]=="object"?Object.keys(n.items[0]):void 0):c=Object.keys(n))),this.dataSources.set(e,{...i,status:"loaded",dataPath:d,itemCount:l,keys:c,lastLoadedAt:Date.now(),error:void 0})}trackDataSourceError(e,n){if(!this.config.enabled)return;const r=this.dataSources.get(e);r&&this.dataSources.set(e,{...r,status:"error",error:n,lastLoadedAt:Date.now()})}untrackDataSource(e){this.dataSources.delete(e)}getDataSources(){return Array.from(this.dataSources.values())}getDataSource(e){return this.dataSources.get(e)}clearDataSources(){this.dataSources.clear()}trackDataPathTransform(e){if(!this.config.enabled)return;let n=this.dataPathTransforms.find(r=>r.dataSourceId===e.dataSourceId);n||(n={dataSourceId:e.dataSourceId,timestamp:Date.now(),transformSteps:[],warnings:[]},this.dataPathTransforms.push(n),this.dataPathTransforms.length>this.maxDataPathTransforms&&this.dataPathTransforms.shift()),n.transformSteps.push({step:e.step,inputPath:e.inputPath,inputValue:this.safeClone(e.inputValue),outputPath:e.outputPath,outputValue:this.safeClone(e.outputValue),config:e.config}),e.warning&&n.warnings.push(e.warning)}setDataPathFinalBinding(e,n){if(!this.config.enabled)return;const r=this.dataPathTransforms.find(i=>i.dataSourceId===e);r&&(r.finalBinding={expression:n.expression,resolvedPath:n.resolvedPath,value:this.safeClone(n.value)})}getDataPathTransformTrackingInfo(){const e=this.getDataPathTransformStats();return{transforms:[...this.dataPathTransforms],stats:e,timestamp:Date.now()}}getDataPathTransformStats(){const e=this.dataPathTransforms,n={};let r=0;const i={};for(const c of e){n[c.dataSourceId]=(n[c.dataSourceId]||0)+1,r+=c.warnings.length;for(const d of c.warnings)i[d]=(i[d]||0)+1}const l=Object.entries(i).map(([c,d])=>({warning:c,count:d})).sort((c,d)=>d.count-c.count).slice(0,10);return{totalTransforms:e.length,byDataSource:n,warningsCount:r,commonWarnings:l}}getDataPathTransformForDataSource(e){return this.dataPathTransforms.find(n=>n.dataSourceId===e)}clearDataPathTransforms(){this.dataPathTransforms=[]}trackNestedContext(e){if(!this.config.enabled)return"";const n=`nested-${++this.nestedContextIdCounter}`,r=[...new Set([...e.parentContext.available,...e.ownContext.added])],i={...e.parentContext.values,...e.ownContext.values},l={id:n,timestamp:Date.now(),componentId:e.componentId,componentType:e.componentType,parentContext:{available:e.parentContext.available,values:this.safeClone(e.parentContext.values)},ownContext:{added:e.ownContext.added,values:this.safeClone(e.ownContext.values)},mergedContext:{all:r,values:this.safeClone(i)},accessAttempts:[],depth:e.depth,parentId:e.parentId};return this.nestedContexts.push(l),this.nestedContexts.length>this.maxNestedContexts&&this.nestedContexts.shift(),n}trackNestedContextAccess(e,n){if(!this.config.enabled)return;const r=this.nestedContexts.find(i=>i.id===e);r&&r.accessAttempts.push({path:n.path,found:n.found,value:n.found?this.safeClone(n.value):void 0,error:n.error})}getNestedContextTrackingInfo(){const e=this.getNestedContextStats();return{contexts:[...this.nestedContexts],stats:e,timestamp:Date.now()}}getNestedContextStats(){const e=this.nestedContexts,n={expandChildren:0,cellChildren:0,iteration:0,modal:0,slot:0};let r=0,i=0;const l={};for(const d of e){n[d.componentType]++,d.depth>r&&(r=d.depth);for(const f of d.accessAttempts)f.found||(i++,l[f.path]=(l[f.path]||0)+1)}const c=Object.entries(l).map(([d,f])=>({path:d,count:f})).sort((d,f)=>f.count-d.count).slice(0,10);return{totalContexts:e.length,byType:n,maxDepth:r,failedAccessCount:i,commonFailedPaths:c}}getNestedContextForComponent(e){return this.nestedContexts.find(n=>n.componentId===e)}clearNestedContexts(){this.nestedContexts=[],this.nestedContextIdCounter=0}trackHandlerRegistration(e,n="custom",r,i){this.isEnabled&&this.handlers.set(e,{name:e,category:n,description:r,registeredAt:Date.now(),source:i})}trackHandlerUnregistration(e){this.isEnabled&&this.handlers.delete(e)}getHandlers(){return Array.from(this.handlers.values())}getHandler(e){return this.handlers.get(e)}getHandlersByCategory(e){return Array.from(this.handlers.values()).filter(n=>n.category===e)}clearHandlers(){this.handlers.clear()}trackEventSubscribe(e){if(!this.isEnabled)return;const n=this.componentEventSubscriptions.get(e),r=Date.now();n?(n.subscriberCount++,n.lastSubscribedAt=r):this.componentEventSubscriptions.set(e,{eventName:e,subscriberCount:1,firstSubscribedAt:r,lastSubscribedAt:r})}trackEventUnsubscribe(e){if(!this.isEnabled)return;const n=this.componentEventSubscriptions.get(e);n&&(n.subscriberCount--,n.subscriberCount<=0&&this.componentEventSubscriptions.delete(e))}trackEventEmit(e,n,r,i,l){if(!this.isEnabled)return;const c={id:`evt_${++this.componentEventIdCounter}`,eventName:e,data:this.sanitizeForLogging(n),timestamp:Date.now(),listenerCount:r,results:i?this.sanitizeForLogging(i):void 0,hasError:!!l,errorMessage:l?.message};this.componentEventEmitHistory.push(c),this.componentEventEmitHistory.length>this.maxComponentEventHistory&&(this.componentEventEmitHistory=this.componentEventEmitHistory.slice(-this.maxComponentEventHistory))}trackEventOff(e){this.isEnabled&&this.componentEventSubscriptions.delete(e)}trackEventClear(){this.isEnabled&&this.componentEventSubscriptions.clear()}getComponentEventInfo(){const e=Array.from(this.componentEventSubscriptions.values());return{subscriptions:e,emitHistory:[...this.componentEventEmitHistory],totalSubscribers:e.reduce((n,r)=>n+r.subscriberCount,0),totalEmits:this.componentEventEmitHistory.length}}getEventEmitHistory(){return[...this.componentEventEmitHistory]}getEventSubscriptions(){return Array.from(this.componentEventSubscriptions.values())}clearComponentEvents(){this.componentEventSubscriptions.clear(),this.componentEventEmitHistory=[],this.componentEventIdCounter=0}sanitizeForLogging(e){if(e==null||typeof e!="object")return e;try{return JSON.parse(JSON.stringify(e))}catch{return"[Circular or Non-serializable]"}}startStateChange(e,n,r,i){if(!this.config.enabled)return"";const l=`setState_${++this.stateRenderingIdCounter}`;this.currentStateChangeContext={setStateId:l,startTime:performance.now(),changedPath:e,trigger:i||{},renderedComponents:[]};const c={id:`sr_${this.stateRenderingIdCounter}`,setStateId:l,statePath:e,oldValue:this.sanitizeForLogging(n),newValue:this.sanitizeForLogging(r),timestamp:Date.now(),triggeredBy:i||{},renderedComponents:[],totalRenderDuration:0,affectedBindingsCount:0};return this.stateRenderingLogs.push(c),this.stateRenderingLogs.length>this.maxStateRenderingLogs&&this.stateRenderingLogs.shift(),l}trackComponentRender(e,n,r,i=[],l=[],c){if(!this.config.enabled)return;const d=this.componentRenderCounts.get(n)||0;this.componentRenderCounts.set(n,d+1);for(const f of i)this.stateToComponentMap.has(f)||this.stateToComponentMap.set(f,new Set),this.stateToComponentMap.get(f).add(n);if(this.currentStateChangeContext){const f={componentId:e,componentName:n,renderDuration:r,accessedStatePaths:i,evaluatedBindings:l,renderOrder:this.currentStateChangeContext.renderedComponents.length,parentId:c};this.currentStateChangeContext.renderedComponents.push(f)}this.trackRender(n)}completeStateChange(e){if(!this.config.enabled||!this.currentStateChangeContext||this.currentStateChangeContext.setStateId!==e)return;const n=this.currentStateChangeContext,i=performance.now()-n.startTime,l=this.stateRenderingLogs.findIndex(c=>c.setStateId===e);if(l>=0){const c=this.stateRenderingLogs[l];c.renderedComponents=n.renderedComponents,c.totalRenderDuration=i,c.affectedBindingsCount=n.renderedComponents.reduce((d,f)=>d+f.evaluatedBindings.length,0)}this.currentStateChangeContext=null}getCurrentStateChangeContext(){return this.currentStateChangeContext}getStateRenderingLogs(){return[...this.stateRenderingLogs]}getStateRenderingInfo(){const e=this.stateRenderingLogs,n=Object.fromEntries(this.componentRenderCounts),r={};for(const[i,l]of this.stateToComponentMap)r[i]=Array.from(l);return{logs:e,componentRenderCounts:n,stateToComponentMap:r,stats:this.calculateStateRenderingStats()}}calculateStateRenderingStats(){const e=this.stateRenderingLogs;if(e.length===0)return{totalStateChanges:0,totalRenders:0,avgRenderDuration:0,avgComponentsPerChange:0,topRenderedComponents:[],topInfluentialPaths:[]};const n=e.reduce((d,f)=>d+f.renderedComponents.length,0),r=e.reduce((d,f)=>d+f.totalRenderDuration,0)/e.length,i=n/e.length,l=Array.from(this.componentRenderCounts.entries()).sort((d,f)=>f[1]-d[1]).slice(0,5).map(([d,f])=>({name:d,count:f})),c=Array.from(this.stateToComponentMap.entries()).sort((d,f)=>f[1].size-d[1].size).slice(0,5).map(([d,f])=>({path:d,affectedComponents:f.size}));return{totalStateChanges:e.length,totalRenders:n,avgRenderDuration:r,avgComponentsPerChange:i,topRenderedComponents:l,topInfluentialPaths:c}}getComponentsAffectedByState(e){const n=this.stateToComponentMap.get(e);return n?Array.from(n):[]}getComponentRenderHistory(e){return this.stateRenderingLogs.filter(n=>n.renderedComponents.some(r=>r.componentName===e))}clearStateRenderingLogs(){this.stateRenderingLogs=[],this.componentRenderCounts.clear(),this.stateToComponentMap.clear(),this.currentStateChangeContext=null,this.stateRenderingIdCounter=0}trackComponentStateSource(e,n,r,i){this.config.enabled&&this.componentStateSources.set(e,{componentId:e,componentName:n,stateSource:r,stateProvider:i})}trackDynamicState(e,n){this.config.enabled&&this.dynamicStates.set(e,n)}trackContextFlow(e,n,r,i,l,c){if(!this.config.enabled)return;const d={component:n,componentId:e,contextReceived:r,passedToChildren:i,usedInRender:l};if(this.contextFlowNodes.set(e,d),c){const f=this.contextFlowNodes.get(c);f&&(f.children||(f.children=[]),f.children.push(d))}}getStateHierarchyInfo(e=!0){const n=this.buildStateHierarchyLayers(),r=this.detectStateConflicts(n),i=Array.from(this.componentStateSources.values());return{layers:e?n.map(c=>({...c,values:this.summarizeValues(c.values,2)})):n,conflicts:r,componentStateSources:i,timestamp:Date.now()}}summarizeValues(e,n,r=0){if(e==null)return e;if(typeof e!="object")return typeof e=="string"&&e.length>100?e.substring(0,100)+`... (${e.length}자)`:e;if(r>=n){if(Array.isArray(e))return`[Array(${e.length})]`;const c=Object.keys(e);return`{${c.slice(0,5).join(", ")}${c.length>5?`, ... +${c.length-5}`:""}}`}if(Array.isArray(e))return e.length<=3?e.map(c=>this.summarizeValues(c,n,r+1)):{__type:"array",__length:e.length,__preview:e.slice(0,3).map(c=>this.summarizeValues(c,n,r+1))};const i={},l=Object.keys(e);for(const c of l)i[c]=this.summarizeValues(e[c],n,r+1);return i}buildStateHierarchyLayers(){const e=[];try{const r=window.G7Core?.state?.get?.();if(!r)return e;r._local&&e.push({name:"Global _local",type:"global",path:"_local",values:r._local,priority:1}),r._global&&e.push({name:"Global _global",type:"global",path:"_global",values:r._global,priority:1});for(const[l,c]of this.dynamicStates)c&&Object.keys(c).length>0&&e.push({name:`DynamicState (${l})`,type:"dynamicState",componentId:l,values:c,priority:2});const i=this.computeEffectiveState(r._local||{});e.push({name:"Effective _local (merged)",type:"effective",values:i,priority:3})}catch(n){console.warn("[G7DevTools] 상태 계층 빌드 실패:",n)}return e}computeEffectiveState(e){const n={...e};for(const[,r]of this.dynamicStates)r._local&&Object.assign(n,r._local);return n}detectStateConflicts(e){const n=[],r=e.find(l=>l.type==="global"&&l.path==="_local");if(!r)return n;const i=e.filter(l=>l.type==="dynamicState");for(const l of i){const c=l.values._local||l.values;for(const[d,f]of Object.entries(c)){const h=r.values[d];if(JSON.stringify(h)!==JSON.stringify(f)){const m=[],y=[];for(const v of this.componentStateSources.values())v.stateSource.local.some(_=>_===`_local.${d}`||_===d)&&(v.stateProvider.type==="dynamicState"?m.push(v.componentName):v.stateProvider.type==="globalState"&&y.push(v.componentName));n.push({path:`_local.${d}`,globalValue:h,dynamicStateValue:f,effectiveValue:f,usedBy:m,notUsedBy:y,severity:y.length>0?"warning":"info",description:y.length>0?`${y.join(", ")}은(는) globalState._local을 읽어 dynamicState 값을 사용하지 못함`:"dynamicState 값이 globalState와 다르지만 모든 컴포넌트가 dynamicState를 사용"})}}}return n}getContextFlowInfo(){const e=[],n=new Set(this.contextFlowNodes.keys());for(const r of this.contextFlowNodes.values())if(r.children)for(const i of r.children)n.delete(i.componentId);for(const r of n){const i=this.contextFlowNodes.get(r);i&&e.push(i)}return{rootComponent:e.length>0?e[0].component:"Unknown",contextFlow:e,timestamp:Date.now()}}clearStateHierarchyData(){this.componentStateSources.clear(),this.contextFlowNodes.clear(),this.dynamicStates.clear()}trackComponentStyle(e,n,r,i){if(!this.config.enabled)return;const l=this.analyzeTailwindClasses(r),c={componentId:e,componentName:n,classes:r,computedStyles:i,tailwindAnalysis:l};this.componentStyles.set(e,c),this.detectStyleIssues(c)}analyzeTailwindClasses(e){const n=[],r=[],i=[],l=[],c=["sm:","md:","lg:","xl:","2xl:"],d=[/bg-\w+-\d+/,/text-\w+-\d+/,/border-\w+-\d+/];for(const f of e){l.push(f),f.startsWith("dark:")&&n.push(f);for(const h of c)if(f.startsWith(h)){r.push(f);break}for(const h of d)if(h.test(f)){i.push(f);break}}return{usedClasses:l,darkClasses:n,responsiveClasses:r,dynamicClasses:i}}detectStyleIssues(e){const{componentId:n,componentName:r,computedStyles:i,tailwindAnalysis:l}=e;(i.opacity==="0"||i.visibility==="hidden"||i.display==="none"||i.width==="0px"&&i.height==="0px")&&this.addStyleIssue({id:this.generateId(),type:"invisible-element",componentId:n,componentName:r,property:i.opacity==="0"?"opacity":i.visibility==="hidden"?"visibility":i.display==="none"?"display":"width/height",currentValue:i.opacity==="0"?"0":i.visibility==="hidden"?"hidden":i.display==="none"?"none":"0px",severity:"warning",description:"요소가 화면에 보이지 않습니다.",suggestion:"opacity, visibility, display, width/height 값을 확인하세요."});const c=l.usedClasses.filter(f=>f.startsWith("bg-")&&!f.startsWith("dark:")),d=l.darkClasses.filter(f=>f.includes("bg-"));c.length>0&&d.length===0&&this.addStyleIssue({id:this.generateId(),type:"dark-mode-missing",componentId:n,componentName:r,property:"background-color",currentValue:c.join(", "),expectedValue:"dark:bg-* 클래스 필요",severity:"info",description:"다크 모드 배경색 클래스가 누락되었습니다.",suggestion:`${c[0]}에 대응하는 dark: 클래스를 추가하세요.`}),l.dynamicClasses.length>0&&this.addStyleIssue({id:this.generateId(),type:"tailwind-purging",componentId:n,componentName:r,property:"class",currentValue:l.dynamicClasses.join(", "),severity:"info",description:"동적으로 생성된 Tailwind 클래스가 있습니다.",suggestion:"tailwind.config.js의 safelist에 추가하거나 전체 클래스명을 상수로 정의하세요."})}addStyleIssue(e){this.styleIssues.some(r=>r.componentId===e.componentId&&r.type===e.type&&r.property===e.property)||this.styleIssues.push(e)}getStyleValidationInfo(){const e=Array.from(this.componentStyles.values());return{issues:[...this.styleIssues],componentStyles:e,stats:{totalComponents:e.length,invisibleCount:this.styleIssues.filter(n=>n.type==="invisible-element").length,tailwindIssueCount:this.styleIssues.filter(n=>n.type==="tailwind-purging").length,darkModeIssueCount:this.styleIssues.filter(n=>n.type==="dark-mode-missing").length},timestamp:Date.now()}}clearStyleValidationData(){this.styleIssues=[],this.componentStyles.clear()}trackAuthEvent(e,n,r,i){if(!this.config.enabled)return;const l={id:`auth_${++this.authEventIdCounter}`,type:e,timestamp:Date.now(),success:n,error:r,details:i};this.authEvents.push(l),this.authEvents.length>this.maxAuthEventHistory&&(this.authEvents=this.authEvents.slice(-this.maxAuthEventHistory))}trackAuthHeader(e,n,r,i,l){if(!this.config.enabled)return;const c={url:e,hasAuthHeader:n,headerType:r,tokenValid:i??!1,responseStatus:l,timestamp:Date.now()};this.authHeaderHistory.push(c),this.authHeaderHistory.length>this.maxAuthEventHistory&&(this.authHeaderHistory=this.authHeaderHistory.slice(-this.maxAuthEventHistory)),l===401&&this.trackAuthEvent("api-unauthorized",!1,`401 Unauthorized: ${e}`,{url:e})}getAuthState(){try{const e=window.G7Core,n=e?.api;let r=e?.auth;!r&&e?.AuthManager?.getInstance&&(r=e.AuthManager.getInstance());const i=n?.getToken?.()||r?.getAccessToken?.()||localStorage.getItem("auth_token")||localStorage.getItem("access_token"),l=r?.getRefreshToken?.()||localStorage.getItem("refresh_token");let c="unknown",d=r?.getUser?.();if(d&&(c="AuthManager"),!d){const S=e?.state?.get?.();d=S?._global?.user||S?._global?.currentUser||S?.user||S?.currentUser,d&&(c="G7Core.state")}const f=r?.isAuthenticated?.()??!1;let h="memory";localStorage.getItem("auth_token")||localStorage.getItem("access_token")?h="localStorage":(sessionStorage.getItem("auth_token")||sessionStorage.getItem("access_token"))&&(h="sessionStorage");const m=!!i&&(!!d||f);let y;i&&typeof i=="string"&&i.length>20?y=`${i.substring(0,10)}...${i.substring(i.length-6)}`:i&&(y="***");const v=d?{id:d.id,email:d.email,name:d.name,roles:d.roles?.map(S=>typeof S=="string"?{name:S}:{id:S.id,name:S.name,guard_name:S.guard_name}),permissions:d.permissions?.map(S=>typeof S=="string"?{name:S}:{id:S.id,name:S.name,guard_name:S.guard_name}),avatar:d.avatar||d.profile_photo_url||d.profile_image,created_at:d.created_at,updated_at:d.updated_at,last_login_at:d.last_login_at,email_verified_at:d.email_verified_at,...d.phone&&{phone:d.phone},...d.nickname&&{nickname:d.nickname},...d.status&&{status:d.status},...d.locale&&{locale:d.locale}}:void 0;return{isAuthenticated:m,user:v,tokens:{hasAccessToken:!!i,hasRefreshToken:!!l,storage:h,accessTokenPreview:y},lastActivity:Date.now(),source:c}}catch{return{isAuthenticated:!1,tokens:{hasAccessToken:!1,hasRefreshToken:!1,storage:"memory"},source:"unknown"}}}getAuthDebugInfo(){const e=[...this.authEvents];return{state:this.getAuthState(),events:e,headerAnalysis:[...this.authHeaderHistory],stats:{loginAttempts:e.filter(n=>n.type==="login").length,successfulLogins:e.filter(n=>n.type==="login"&&n.success).length,failedLogins:e.filter(n=>n.type==="login"&&!n.success).length,tokenRefreshes:e.filter(n=>n.type==="token-refresh").length,unauthorizedResponses:e.filter(n=>n.type==="api-unauthorized").length},timestamp:Date.now()}}clearAuthData(){this.authEvents=[],this.authHeaderHistory=[],this.authEventIdCounter=0}trackLayoutLoad(e,n,r,i="api"){if(!this.config.enabled)return;const l=Date.now();this.currentLayout={layoutPath:e,templateId:n,layoutJson:this.sanitizeObject(r),loadedAt:l,version:r.version,layoutName:r.layout_name,source:i};const c={id:`layout-${++this.layoutIdCounter}`,layoutPath:e,templateId:n,loadedAt:l,source:i,version:r.version};this.layoutHistory.push(c),this.layoutHistory.length>this.maxLayoutHistory&&this.layoutHistory.shift(),this.layoutStats.totalLoads++,i==="cache"?this.layoutStats.cacheHits++:this.layoutStats.apiLoads++}getCurrentLayout(){return this.currentLayout}getLayoutHistory(){return[...this.layoutHistory]}getLayoutDebugInfo(){return{current:this.currentLayout,history:[...this.layoutHistory],stats:{...this.layoutStats}}}clearLayoutData(){this.currentLayout=null,this.layoutHistory=[],this.layoutIdCounter=0,this.layoutStats={totalLoads:0,cacheHits:0,apiLoads:0}}startHandlerExecution(e){if(!this.config.enabled)return"";const n=`exec_${++this.executionIdCounter}_${Date.now()}`,r={handlerName:e,executionId:n,startTime:Date.now(),stateChanges:[],dataSourceChanges:[],alerts:[]};if(this.executionDetails.set(n,r),this.executionDetails.size>this.maxExecutionDetails){const i=Array.from(this.executionDetails.keys());i.slice(0,i.length-this.maxExecutionDetails).forEach(c=>this.executionDetails.delete(c))}return n}endHandlerExecution(e,n,r,i){if(!this.config.enabled||!e)return;const l=this.executionDetails.get(e);if(!l)return;l.endTime=Date.now(),l.duration=l.endTime-l.startTime,l.exitReason=n,l.exitLocation=r,l.exitDescription=i;const c=this.changeExpectations.get(e);c&&(l.expectedChanges=c,this.checkExpectations(e,l,c),this.changeExpectations.delete(e)),n==="normal"&&l.stateChanges.length===0&&l.dataSourceChanges.length===0&&this.addChangeAlert(e,{type:"no-state-change",severity:"warning",message:`핸들러 "${l.handlerName}"이(가) 상태 변경 없이 완료됨`,description:"핸들러가 성공적으로 완료되었지만 상태나 데이터소스 변경이 없습니다. 의도한 동작인지 확인하세요.",handlerName:l.handlerName,suggestion:'핸들러 내부 조건문을 확인하거나 DevTools의 "변경감지" 탭에서 exitLocation을 확인하세요.',docLink:"troubleshooting-state.md"}),(n==="early-return-condition"||n==="early-return-validation")&&this.addChangeAlert(e,{type:"early-return-detected",severity:"info",message:`핸들러 "${l.handlerName}"이(가) early return으로 종료됨`,description:i||`종료 위치: ${r||"알 수 없음"}`,handlerName:l.handlerName,suggestion:n==="early-return-validation"?"검증 실패로 인한 early return입니다. 입력 데이터를 확인하세요.":"조건부 early return입니다. 조건문의 평가 결과를 확인하세요."})}recordExitReason(e,n,r,i){if(!this.config.enabled||!e)return;const l=this.executionDetails.get(e);l&&(l.exitReason=n,l.exitLocation=r,l.exitDescription=i)}recordStateChange(e,n,r,i,l){if(!this.config.enabled)return;const c={id:`sc_${++this.stateChangeIdCounter}`,path:n,changeType:r,oldValue:this.safeClone(i),newValue:this.safeClone(l),timestamp:Date.now(),comparison:this.compareValues(i,l),executionId:e};if(this.stateChangeHistory.push(c),e){const d=this.executionDetails.get(e);d&&d.stateChanges.push(c)}this.stateChangeHistory.length>this.maxStateChangeHistory&&this.stateChangeHistory.splice(0,this.stateChangeHistory.length-this.maxStateChangeHistory),c.comparison.isDeepEqual&&typeof i=="object"&&i!==null&&this.addChangeAlert(e||"",{type:"object-reference-same",severity:"warning",message:`상태 "${n}"가 변경되었으나 값이 동일함`,description:"객체 참조가 동일하거나 깊은 비교 결과 변경이 없습니다. 변경 감지가 실패할 수 있습니다.",handlerName:e&&this.executionDetails.get(e)?.handlerName||"unknown",statePath:n,suggestion:"불변성을 유지하여 새 객체를 생성하세요. 예: { ...oldObject, newField: value }",docLink:"troubleshooting-state.md#object-mutation"})}recordDataSourceChange(e,n,r,i,l){if(!this.config.enabled)return;const c={dataSourceId:n,changeType:r,timestamp:Date.now(),previousStatus:i,newStatus:l,executionId:e};if(this.dataSourceChangeHistory.push(c),e){const d=this.executionDetails.get(e);d&&d.dataSourceChanges.push(c)}this.dataSourceChangeHistory.length>this.maxStateChangeHistory&&this.dataSourceChangeHistory.splice(0,this.dataSourceChangeHistory.length-this.maxStateChangeHistory)}expectChange(e,n,r){if(!this.config.enabled||!e)return;const i=this.executionDetails.get(e);if(!i)return;const l={expectedStatePaths:n,expectedDataSources:r,setAt:Date.now(),source:i.handlerName};this.changeExpectations.set(e,l)}checkExpectations(e,n,r){const i=new Set(n.stateChanges.map(c=>c.path)),l=new Set(n.dataSourceChanges.map(c=>c.dataSourceId));for(const c of r.expectedStatePaths)i.has(c)||this.addChangeAlert(e,{type:"expected-not-fulfilled",severity:"error",message:`기대한 상태 변경 "${c}"가 발생하지 않음`,description:`핸들러 "${n.handlerName}"이(가) "${c}" 변경을 예고했지만 실제로 변경되지 않았습니다.`,handlerName:n.handlerName,statePath:c,suggestion:"핸들러 내부 로직을 확인하세요. early return이나 조건부 분기로 인해 변경이 생략되었을 수 있습니다.",docLink:"troubleshooting-state.md"});for(const c of r.expectedDataSources)l.has(c)||this.addChangeAlert(e,{type:"expected-not-fulfilled",severity:"error",message:`기대한 데이터소스 갱신 "${c}"가 발생하지 않음`,description:`핸들러 "${n.handlerName}"이(가) "${c}" 갱신을 예고했지만 실제로 갱신되지 않았습니다.`,handlerName:n.handlerName,dataSourceId:c,suggestion:"refetchDataSource 호출이 실행되었는지 확인하세요.",docLink:"data-sources.md"})}addChangeAlert(e,n){const r={...n,id:`alert_${++this.alertIdCounter}`,timestamp:Date.now()};if(this.changeAlerts.push(r),e){const i=this.executionDetails.get(e);i&&i.alerts.push(r)}this.changeAlerts.length>this.maxChangeAlerts&&this.changeAlerts.splice(0,this.changeAlerts.length-this.maxChangeAlerts)}compareValues(e,n){const r=this.getValueType(e),i=this.getValueType(n),l=r!==i;let c=!1,d;return!l&&(r==="object"||r==="array")?(c=this.deepEqual(e,n),!c&&r==="object"&&(d=this.getChangedKeys(e,n))):c=e===n,{typeChanged:l,oldType:r,newType:i,isDeepEqual:c,changedKeys:d}}getValueType(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?"array":typeof e}deepEqual(e,n){if(e===n)return!0;if(typeof e!=typeof n)return!1;if(e===null||n===null||typeof e!="object")return e===n;if(Array.isArray(e)!==Array.isArray(n))return!1;const r=Object.keys(e),i=Object.keys(n);if(r.length!==i.length)return!1;for(const l of r)if(!i.includes(l)||!this.deepEqual(e[l],n[l]))return!1;return!0}getChangedKeys(e,n){const r=[],i=new Set([...Object.keys(e),...Object.keys(n)]);for(const l of i)this.deepEqual(e[l],n[l])||r.push(l);return r}getChangeDetectionInfo(){const e=Array.from(this.executionDetails.values()),n={totalExecutions:e.length,executionsWithStateChange:e.filter(r=>r.stateChanges.length>0).length,executionsWithoutStateChange:e.filter(r=>r.stateChanges.length===0&&r.exitReason==="normal").length,earlyReturnCount:e.filter(r=>r.exitReason==="early-return-condition"||r.exitReason==="early-return-validation").length,alertCount:this.changeAlerts.length,alertsByType:this.getAlertsByType()};return{executionDetails:e,stateChangeHistory:[...this.stateChangeHistory],dataSourceChangeHistory:[...this.dataSourceChangeHistory],alerts:[...this.changeAlerts],stats:n,timestamp:Date.now()}}getAlertsByType(){const e={"no-state-change":0,"no-datasource-change":0,"expected-not-fulfilled":0,"object-reference-same":0,"early-return-detected":0,"async-timing-issue":0};for(const n of this.changeAlerts)e[n.type]++;return e}clearChangeDetectionData(){this.executionDetails.clear(),this.stateChangeHistory=[],this.dataSourceChangeHistory=[],this.changeAlerts=[],this.changeExpectations.clear(),this.executionIdCounter=0,this.stateChangeIdCounter=0,this.alertIdCounter=0}getRecentAlerts(e=10,n){let r=[...this.changeAlerts];return n&&(r=r.filter(i=>i.severity===n)),r.slice(-e)}getHandlerExecutions(e,n=10){return Array.from(this.executionDetails.values()).filter(i=>i.handlerName===e).slice(-n)}findExecutionInStack(e){return this.sequenceExecutionStack.find(n=>n.sequenceId===e)}startSequenceExecution(e){if(!this.config.enabled)return"";const n=`seq_${++this.sequenceIdCounter}_${Date.now()}`,r={sequenceId:n,startTime:Date.now(),totalDuration:0,trigger:e,actions:[],status:"running"};return this.sequenceExecutionStack.push(r),n}captureSequenceActionBefore(e,n,r,i,l){if(!this.config.enabled)return;const c=this.findExecutionInStack(e);if(!c)return;const d={index:n,handler:r,params:this.safeClone(i),stateBeforeAction:{_global:this.safeClone(l._global),_local:this.safeClone(l._local),_isolated:l._isolated?this.safeClone(l._isolated):void 0},stateAfterAction:{_global:{},_local:{}},duration:0,status:"success"};c.actions.push(d)}captureSequenceActionAfter(e,n,r,i,l,c){if(!this.config.enabled)return;const d=this.findExecutionInStack(e);if(!d)return;const f=d.actions.find(m=>m.index===n);if(!f)return;f.stateAfterAction={_global:this.safeClone(r._global),_local:this.safeClone(r._local),_isolated:r._isolated?this.safeClone(r._isolated):void 0},f.duration=i,f.result=this.safeClone(l),f.stateDiff={global:this.computeStateDiff(f.stateBeforeAction._global,f.stateAfterAction._global),local:this.computeStateDiff(f.stateBeforeAction._local,f.stateAfterAction._local)},f.stateBeforeAction._isolated&&f.stateAfterAction._isolated&&(f.stateDiff.isolated=this.computeStateDiff(f.stateBeforeAction._isolated,f.stateAfterAction._isolated));const h=window.__g7PendingLocalState;h&&(f.pendingState=this.safeClone(h)),c&&(f.status="error",f.error={name:c.name,message:c.message,stack:c.stack})}endSequenceExecution(e,n){if(!this.config.enabled)return;const r=this.sequenceExecutionStack.findIndex(l=>l.sequenceId===e);if(r===-1)return;const i=this.sequenceExecutionStack[r];if(i.endTime=Date.now(),i.totalDuration=i.endTime-i.startTime,n){i.status="error",i.error={name:n.name,message:n.message,stack:n.stack};const l=i.actions.find(c=>c.status==="error");l&&(i.failedAtIndex=l.index)}else i.status="success";this.sequenceExecutions.push(i),this.sequenceExecutions.length>this.maxSequenceExecutions&&this.sequenceExecutions.shift(),this.sequenceExecutionStack.splice(r,1)}computeStateDiff(e,n){const r=[],i=[],l=[],c=new Set(Object.keys(e)),d=new Set(Object.keys(n));for(const f of d)c.has(f)||r.push(f);for(const f of c)d.has(f)||i.push(f);for(const f of c)if(d.has(f)){const h=e[f],m=n[f];JSON.stringify(h)!==JSON.stringify(m)&&l.push({path:f,oldValue:h,newValue:m})}return{added:r,removed:i,changed:l}}getSequenceTrackingInfo(){const e=this.getSequenceStats(),n=this.sequenceExecutionStack.length>0?this.sequenceExecutionStack[this.sequenceExecutionStack.length-1]:void 0;return{executions:[...this.sequenceExecutions],currentExecution:n,stats:e}}getSequenceStats(){const e=this.sequenceExecutions,n=e.length,r=e.filter(h=>h.status==="success").length,i=e.filter(h=>h.status==="error").length,l=e.reduce((h,m)=>h+m.actions.length,0),c=n>0?e.reduce((h,m)=>h+m.totalDuration,0)/n:0,d={};for(const h of e)for(const m of h.actions)d[m.handler]=(d[m.handler]||0)+1;const f=Object.entries(d).sort(([,h],[,m])=>m-h).slice(0,5).map(([h,m])=>({handler:h,count:m}));return{totalExecutions:n,successCount:r,errorCount:i,totalActions:l,avgDuration:c,topHandlers:f}}clearSequenceData(){this.sequenceExecutions=[],this.sequenceExecutionStack=[],this.sequenceIdCounter=0}getSequenceExecution(e){const n=this.findExecutionInStack(e);return n||this.sequenceExecutions.find(r=>r.sequenceId===e)}getRecentSequences(e=10){return this.sequenceExecutions.slice(-e)}registerStateCaptureForHandler(e,n,r){if(!this.config.enabled)return;const i=new Map,l=Date.now();for(const c of n)i.set(c,{value:this.safeClone(r[c]),capturedAt:l});this.stateCaptureRegistry.set(e,i)}detectStaleClosure(e,n,r,i,l){if(!this.config.enabled)return[];const c=this.stateCaptureRegistry.get(e);if(!c)return[];const d=Date.now(),f=[];for(const[h,m]of c){const y=this.getValueByPath(r,h),v=d-m.capturedAt;if(!this.isDeepEqual(m.value,y)&&v>0){const S=this.createStaleClosureWarning(i,n,h,m.value,m.capturedAt,y,d,v,l);f.push(S),this.addStaleClosureWarning(S)}}return this.stateCaptureRegistry.delete(e),f}trackStaleClosureWarning(e){if(!this.config.enabled)return;const n=Date.now(),r=this.createStaleClosureWarning(e.type,e.location,e.capturedPath,e.capturedValue,e.capturedAt,e.currentValue,n,n-e.capturedAt,e.actionId,e.stackTrace);this.addStaleClosureWarning(r)}createStaleClosureWarning(e,n,r,i,l,c,d,f,h,m){const y=this.getStaleClosureSeverity(e,f),{description:v,suggestion:S,docLink:_}=this.getStaleClosureMessages(e,r,f);return{id:`stale_${++this.staleClosureIdCounter}_${Date.now()}`,timestamp:Date.now(),type:e,location:n,capturedState:{path:r,capturedValue:this.safeClone(i),capturedAt:l},currentState:{path:r,currentValue:this.safeClone(c),retrievedAt:d},timeDiff:f,severity:y,description:v,suggestion:S,docLink:_,actionId:h,stackTrace:m}}getStaleClosureSeverity(e,n){if(n>5e3)return"error";if(n>1e3)return"warning";switch(e){case"async-state-capture":case"sequence-state-mismatch":return"warning";case"callback-state-capture":case"timeout-state-capture":return"info";case"event-handler-stale":return"warning";default:return"info"}}getStaleClosureMessages(e,n,r){const i=r<1e3?`${r}ms`:`${(r/1e3).toFixed(1)}s`;switch(e){case"async-state-capture":return{description:`await 후 ${i} 경과 시점에 '${n}' 상태가 변경됨. 캡처된 상태 대신 최신 상태를 사용해야 함`,suggestion:"await 이후에는 G7Core.state.get()으로 최신 상태를 다시 조회하거나, useRef + getter 패턴을 사용하세요",docLink:"troubleshooting-state-closure.md"};case"callback-state-capture":return{description:`콜백에서 ${i} 전에 캡처된 '${n}' 상태를 사용 중. 최신 상태와 다름`,suggestion:"콜백에서 상태를 참조할 때는 stateRef.current 패턴 또는 G7Core.state.get()를 사용하세요",docLink:"troubleshooting-state-closure.md"};case"timeout-state-capture":return{description:`setTimeout/setInterval 콜백에서 '${n}' 상태가 ${i} 전 값 사용 중`,suggestion:"타이머 콜백 내에서는 G7Core.state.get()으로 최신 상태를 조회하세요",docLink:"troubleshooting-state-closure.md"};case"sequence-state-mismatch":return{description:`sequence 내 '${n}' 상태가 이전 액션 결과와 불일치. context.state 대신 캡처된 값 사용 의심`,suggestion:"sequence 내에서는 context.state 또는 $prev를 사용하여 최신 상태를 참조하세요",docLink:"troubleshooting-state-setstate.md"};case"event-handler-stale":return{description:`이벤트 핸들러에서 ${i} 전에 바인딩된 '${n}' 상태 사용 중`,suggestion:"이벤트 핸들러에서 상태를 참조할 때는 useRef 패턴 또는 G7Core.state.get()를 사용하세요",docLink:"troubleshooting-state-closure.md"};default:return{description:`'${n}' 상태에서 stale closure 감지됨 (${i} 경과)`,suggestion:"상태 참조 시 최신 값을 사용하는지 확인하세요"}}}addStaleClosureWarning(e){this.staleClosureWarnings.push(e),this.staleClosureWarnings.length>this.maxStaleClosureWarnings&&this.staleClosureWarnings.shift()}getValueByPath(e,n){const r=n.split(".");let i=e;for(const l of r){if(i==null)return;i=i[l]}return i}isDeepEqual(e,n){if(e===n)return!0;if(e===null||n===null)return e===n;if(typeof e!=typeof n)return!1;if(typeof e!="object")return e===n;try{return JSON.stringify(e)===JSON.stringify(n)}catch{return!1}}getStaleClosureTrackingInfo(){const e=this.getStaleClosureStats();return{warnings:[...this.staleClosureWarnings],stats:e,timestamp:Date.now()}}getStaleClosureStats(){const e=this.staleClosureWarnings,n={"async-state-capture":0,"callback-state-capture":0,"timeout-state-capture":0,"sequence-state-mismatch":0,"event-handler-stale":0};for(const f of e)n[f.type]++;const r={info:0,warning:0,error:0};for(const f of e)r[f.severity]++;const i={};for(const f of e)i[f.location]=(i[f.location]||0)+1;const l=Object.entries(i).sort(([,f],[,h])=>h-f).slice(0,5).map(([f,h])=>({location:f,count:h})),c={};for(const f of e)c[f.capturedState.path]=(c[f.capturedState.path]||0)+1;const d=Object.entries(c).sort(([,f],[,h])=>h-f).slice(0,5).map(([f,h])=>({path:f,count:h}));return{totalWarnings:e.length,warningsByType:n,warningsBySeverity:r,topLocations:l,topAffectedPaths:d}}clearStaleClosureData(){this.staleClosureWarnings=[],this.staleClosureIdCounter=0,this.stateCaptureRegistry.clear()}getRecentStaleClosureWarnings(e=10,n){let r=[...this.staleClosureWarnings];return n&&(r=r.filter(i=>i.severity===n)),r.slice(-e)}safeClone(e){if(e==null||typeof e!="object")return e;try{return JSON.parse(JSON.stringify(e))}catch{if(Array.isArray(e))return e.map(r=>{try{return JSON.parse(JSON.stringify(r))}catch{return"[Unserializable]"}});const n={};for(const r of Object.keys(e))try{n[r]=JSON.parse(JSON.stringify(e[r]))}catch{n[r]="[Unserializable]"}return n}}};M($i,"instance");let Ha=$i;const Qn=pt("LayoutLoader");class Dr extends Error{constructor(e,n,r){super(e),this.code=n,this.details=r,this.name="LayoutLoaderError"}}class th{constructor(e){M(this,"componentRegistry");M(this,"currentLayout",null);M(this,"layoutCache",new Map);M(this,"cacheVersion",0);this.componentRegistry=e}setCacheVersion(e){this.cacheVersion!==e&&(Qn.log("Cache version updated:",this.cacheVersion,"->",e),this.cacheVersion=e,this.layoutCache.clear())}getCacheVersion(){return this.cacheVersion}async loadLayout(e,n){const r=`${e}:${n}`;if(this.layoutCache.has(r)){Qn.log("Loading layout from cache:",n);const l=await this.layoutCache.get(r),c=JSON.parse(JSON.stringify(l));return this.currentLayout=c,Ha.getInstance().trackLayoutLoad(n,e,c,"cache"),c}const i=this.fetchLayout(e,n);return this.layoutCache.set(r,i),i.catch(()=>{this.layoutCache.get(r)===i&&this.layoutCache.delete(r)}),i}async fetchLayout(e,n,r=!1){try{const i=this.cacheVersion>0?this.cacheVersion:null;let l;if(n.startsWith("__preview__/")){const v=n.replace("__preview__/","");l=Br(`/api/layouts/preview/${v}`,"json",i)}else l=Br(`/api/layouts/${e}/${n}`,"json",i);Qn.log("Fetching layout from API:",l);const c=Yn(),d=r?null:c.getToken(),f={Accept:"application/json"};d&&(f.Authorization=`Bearer ${d}`);const h=await tc(l,{init:{headers:f},label:`layout: ${n}`});let m;try{m=await h.json()}catch{m=null}if(!h.ok){if(h.status===401&&!r&&d){Qn.log("Token invalid, removing and retrying without token"),c.removeToken();try{return await this.fetchLayout(e,n,!0)}catch(S){throw S instanceof Dr&&S.details?.status===401?new Dr(S.message,S.code,{...S.details,hadToken:!0}):S}}const v=m?.message||m?.error;throw new Dr(`Failed to fetch layout: ${h.status} ${h.statusText}`,"FETCH_FAILED",{status:h.status,statusText:h.statusText,url:l,apiMessage:v})}const y=m.data||m;return this.validateLayoutData(y),this.currentLayout=y,Ha.getInstance().trackLayoutLoad(n,e,y,"api"),Qn.log("Layout fetched and cached successfully:",y.layout_name),y}catch(i){const l=`${e}:${n}`;throw this.layoutCache.delete(l),i instanceof Dr?i:new Dr("Failed to load layout","LOAD_FAILED",{originalError:i})}}prefetchLayout(e,n){return this.loadLayout(e,n)}validateLayoutData(e){if(!e.version)throw new Dr("Layout data missing required field: version","VALIDATION_FAILED",{field:"version"});if(!e.layout_name)throw new Dr("Layout data missing required field: layout_name","VALIDATION_FAILED",{field:"layout_name"});if(!Array.isArray(e.components))throw new Dr('Layout data field "components" must be an array',"VALIDATION_FAILED",{field:"components",value:e.components});Qn.log("Layout data validation passed")}renderLayout(e,n){try{const r=n||this.currentLayout;if(!r)throw new Dr("No layout data to render","NO_LAYOUT_DATA");Qn.log("Rendering layout:",r.layout_name),e.innerHTML="",this.renderComponents(e,r.components),Qn.log("Layout rendered successfully")}catch(r){Qn.error("Render error:",r),this.renderErrorState(e,r)}}renderComponents(e,n){for(const r of n){const i=this.renderComponent(r);i&&e.appendChild(i)}}renderComponent(e){try{if(!this.componentRegistry.getComponent(e.type))return Qn.warn(`Component not found: ${e.type}`),this.createPlaceholderElement(e.type);const r=document.createElement("div");return r.setAttribute("data-component",e.type),e.props&&Object.entries(e.props).forEach(([i,l])=>{r.setAttribute(`data-prop-${i}`,JSON.stringify(l))}),e.children&&e.children.length>0?this.renderComponents(r,e.children):e.text&&(r.textContent=e.text),r}catch(n){return Qn.error(`Error rendering component ${e.type}:`,n),this.createErrorElement(e.type,n)}}createPlaceholderElement(e){const n=document.createElement("div");return n.className="component-placeholder",n.setAttribute("data-component-type",e),n.innerHTML=`

Component not found: ${e}

@@ -100,7 +103,7 @@ Error generating stack: `+u.message+`

Component Error: ${e}

${n?.message||"Unknown error"}

- `,r}renderErrorState(e,n){const r=n instanceof Error?n.message:String(n),i=n instanceof Rr?n.code:"UNKNOWN_ERROR";e.innerHTML=` + `,r}renderErrorState(e,n){const r=n instanceof Error?n.message:String(n),i=n instanceof Dr?n.code:"UNKNOWN_ERROR";e.innerHTML=`
페이지 새로고침
- `,Jn.error("Error state rendered:",i,r)}getCurrentLayout(){return this.currentLayout}clear(){this.currentLayout=null,this.layoutCache.clear(),Jn.log("Layout data and cache cleared")}}const vA=dt("TranslationContext"),Ff=M.createContext(null),qc=({children:s,translationEngine:e,translationContext:n})=>{const r=M.useMemo(()=>(l,c)=>{if(c){const d="|"+Object.entries(c).map(([f,p])=>`${f}=${p}`).join("|");return e.translate(l,n,d)}return e.translate(l,n)},[e,n]),i=M.useMemo(()=>({translationEngine:e,translationContext:n,t:r}),[e,n,r]);return ft.jsx(Ff.Provider,{value:i,children:s})},Py=()=>{const s=M.useContext(Ff);return s||(vA.warn("TranslationProvider 외부에서 호출되었습니다. 키를 그대로 반환합니다."),{t:e=>e,translationEngine:null,translationContext:null})},Pa=dt("SlotContext"),SA={registerToSlot:()=>{Pa.warn("SlotContext not available: registerToSlot called outside SlotProvider")},unregisterFromSlot:()=>{Pa.warn("SlotContext not available: unregisterFromSlot called outside SlotProvider")},getSlotComponents:()=>[],subscribeToSlot:()=>()=>{},clearAllSlots:()=>{},isEnabled:!1},wA=M.createContext(SA),Vf=({children:s})=>{const e=M.useRef(new Map),n=M.useRef(new Map),r=M.useCallback(m=>{const y=n.current.get(m);y&&y.forEach(C=>{try{C()}catch(S){Pa.error(`Slot subscriber error (slotId: ${m}):`,S)}})},[]),i=M.useCallback((m,y,C)=>{if(!m||!y){Pa.warn("registerToSlot: slotId and componentId are required");return}e.current.has(m)||e.current.set(m,new Map);const S=e.current.get(m),v=S.get(y);v&&v.registrationKey===C.registrationKey||(S.set(y,C),Pa.log(`Component registered to slot: ${y} -> ${m} (order: ${C.order})`),r(m))},[r]),l=M.useCallback((m,y)=>{const C=e.current.get(m);C&&C.has(y)&&(C.delete(y),Pa.log(`Component unregistered from slot: ${y} <- ${m}`),C.size===0&&e.current.delete(m),r(m))},[r]),c=M.useCallback(m=>{const y=e.current.get(m);return y?Array.from(y.values()).sort((C,S)=>C.order-S.order):[]},[]),d=M.useCallback((m,y)=>{n.current.has(m)||n.current.set(m,new Set);const C=n.current.get(m);return C.add(y),()=>{C.delete(y),C.size===0&&n.current.delete(m)}},[]),f=M.useCallback(()=>{e.current.forEach((m,y)=>{r(y)}),e.current.clear(),n.current.clear(),Pa.log("All slots cleared")},[r]),p=M.useMemo(()=>({registerToSlot:i,unregisterFromSlot:l,getSlotComponents:c,subscribeToSlot:d,clearAllSlots:f,isEnabled:!0}),[i,l,c,d,f]);return M.useLayoutEffect(()=>{typeof window<"u"&&(window.__slotContextValue=p,Pa.log("SlotContext exposed to window.__slotContextValue"))},[p]),ft.jsx(wA.Provider,{value:p,children:s})};class Kf{constructor(){this.notificationCreatedEvent=".Illuminate\\Notifications\\Events\\BroadcastNotificationCreated"}listenForWhisper(e,n){return this.listen(".client-"+e,n)}notification(e){return this.listen(this.notificationCreatedEvent,e)}stopListeningForNotification(e){return this.stopListening(this.notificationCreatedEvent,e)}stopListeningForWhisper(e,n){return this.stopListening(".client-"+e,n)}}class By{constructor(e){this.namespace=e}format(e){return[".","\\"].includes(e.charAt(0))?e.substring(1):(this.namespace&&(e=this.namespace+"."+e),e.replace(/\./g,"\\"))}setNamespace(e){this.namespace=e}}function CA(s){try{new s}catch(e){if(e instanceof Error&&e.message.includes("is not a constructor"))return!1}return!0}class Wf extends Kf{constructor(e,n,r){super(),this.name=n,this.pusher=e,this.options=r,this.eventFormatter=new By(this.options.namespace),this.subscribe()}subscribe(){this.subscription=this.pusher.subscribe(this.name)}unsubscribe(){this.pusher.unsubscribe(this.name)}listen(e,n){return this.on(this.eventFormatter.format(e),n),this}listenToAll(e){return this.subscription.bind_global((n,r)=>{if(n.startsWith("pusher:"))return;let i=String(this.options.namespace??"").replace(/\./g,"\\"),l=n.startsWith(i)?n.substring(i.length+1):"."+n;e(l,r)}),this}stopListening(e,n){return n?this.subscription.unbind(this.eventFormatter.format(e),n):this.subscription.unbind(this.eventFormatter.format(e)),this}stopListeningToAll(e){return e?this.subscription.unbind_global(e):this.subscription.unbind_global(),this}subscribed(e){return this.on("pusher:subscription_succeeded",()=>{e()}),this}error(e){return this.on("pusher:subscription_error",n=>{e(n)}),this}on(e,n){return this.subscription.bind(e,n),this}}class qy extends Wf{whisper(e,n){return this.pusher.channels.channels[this.name].trigger(`client-${e}`,n),this}}class EA extends Wf{whisper(e,n){return this.pusher.channels.channels[this.name].trigger(`client-${e}`,n),this}}class _A extends qy{here(e){return this.on("pusher:subscription_succeeded",n=>{e(Object.keys(n.members).map(r=>n.members[r]))}),this}joining(e){return this.on("pusher:member_added",n=>{e(n.info)}),this}whisper(e,n){return this.pusher.channels.channels[this.name].trigger(`client-${e}`,n),this}leaving(e){return this.on("pusher:member_removed",n=>{e(n.info)}),this}}class Gy extends Kf{constructor(e,n,r){super(),this.events={},this.listeners={},this.name=n,this.socket=e,this.options=r,this.eventFormatter=new By(this.options.namespace),this.subscribe()}subscribe(){this.socket.emit("subscribe",{channel:this.name,auth:this.options.auth||{}})}unsubscribe(){this.unbind(),this.socket.emit("unsubscribe",{channel:this.name,auth:this.options.auth||{}})}listen(e,n){return this.on(this.eventFormatter.format(e),n),this}stopListening(e,n){return this.unbindEvent(this.eventFormatter.format(e),n),this}subscribed(e){return this.on("connect",n=>{e(n)}),this}error(e){return this}on(e,n){return this.listeners[e]=this.listeners[e]||[],this.events[e]||(this.events[e]=(r,i)=>{this.name===r&&this.listeners[e]&&this.listeners[e].forEach(l=>l(i))},this.socket.on(e,this.events[e])),this.listeners[e].push(n),this}unbind(){Object.keys(this.events).forEach(e=>{this.unbindEvent(e)})}unbindEvent(e,n){this.listeners[e]=this.listeners[e]||[],n&&(this.listeners[e]=this.listeners[e].filter(r=>r!==n)),(!n||this.listeners[e].length===0)&&(this.events[e]&&(this.socket.removeListener(e,this.events[e]),delete this.events[e]),delete this.listeners[e])}}class Fy extends Gy{whisper(e,n){return this.socket.emit("client event",{channel:this.name,event:`client-${e}`,data:n}),this}}class AA extends Fy{here(e){return this.on("presence:subscribed",n=>{e(n.map(r=>r.user_info))}),this}joining(e){return this.on("presence:joining",n=>e(n.user_info)),this}whisper(e,n){return this.socket.emit("client event",{channel:this.name,event:`client-${e}`,data:n}),this}leaving(e){return this.on("presence:leaving",n=>e(n.user_info)),this}}class Gc extends Kf{subscribe(){}unsubscribe(){}listen(e,n){return this}listenToAll(e){return this}stopListening(e,n){return this}subscribed(e){return this}error(e){return this}on(e,n){return this}}class Vy extends Gc{whisper(e,n){return this}}class xA extends Gc{whisper(e,n){return this}}class TA extends Vy{here(e){return this}joining(e){return this}whisper(e,n){return this}leaving(e){return this}}const Ky=class Ow{constructor(e){this.setOptions(e),this.connect()}setOptions(e){this.options={...Ow._defaultOptions,...e,broadcaster:e.broadcaster};let n=this.csrfToken();n&&(this.options.auth.headers["X-CSRF-TOKEN"]=n,this.options.userAuthentication.headers["X-CSRF-TOKEN"]=n),n=this.options.bearerToken,n&&(this.options.auth.headers.Authorization="Bearer "+n,this.options.userAuthentication.headers.Authorization="Bearer "+n)}csrfToken(){var e,n;return typeof window<"u"&&(e=window.Laravel)!=null&&e.csrfToken?window.Laravel.csrfToken:this.options.csrfToken?this.options.csrfToken:typeof document<"u"&&typeof document.querySelector=="function"?((n=document.querySelector('meta[name="csrf-token"]'))==null?void 0:n.getAttribute("content"))??null:null}};Ky._defaultOptions={auth:{headers:{}},authEndpoint:"/broadcasting/auth",userAuthentication:{endpoint:"/broadcasting/user-auth",headers:{}},csrfToken:null,bearerToken:null,host:null,key:null,namespace:"App.Events"};let Yf=Ky;class Fc extends Yf{constructor(){super(...arguments),this.channels={}}connect(){if(typeof this.options.client<"u")this.pusher=this.options.client;else if(this.options.Pusher)this.pusher=new this.options.Pusher(this.options.key,this.options);else if(typeof window<"u"&&typeof window.Pusher<"u")this.pusher=new window.Pusher(this.options.key,this.options);else throw new Error("Pusher client not found. Should be globally available or passed via options.client")}signin(){this.pusher.signin()}listen(e,n,r){return this.channel(e).listen(n,r)}channel(e){return this.channels[e]||(this.channels[e]=new Wf(this.pusher,e,this.options)),this.channels[e]}privateChannel(e){return this.channels["private-"+e]||(this.channels["private-"+e]=new qy(this.pusher,"private-"+e,this.options)),this.channels["private-"+e]}encryptedPrivateChannel(e){return this.channels["private-encrypted-"+e]||(this.channels["private-encrypted-"+e]=new EA(this.pusher,"private-encrypted-"+e,this.options)),this.channels["private-encrypted-"+e]}presenceChannel(e){return this.channels["presence-"+e]||(this.channels["presence-"+e]=new _A(this.pusher,"presence-"+e,this.options)),this.channels["presence-"+e]}leave(e){[e,"private-"+e,"private-encrypted-"+e,"presence-"+e].forEach(n=>{this.leaveChannel(n)})}leaveChannel(e){this.channels[e]&&(this.channels[e].unsubscribe(),delete this.channels[e])}socketId(){return this.pusher.connection.socket_id}disconnect(){this.pusher.disconnect()}}class kA extends Yf{constructor(){super(...arguments),this.channels={}}connect(){let e=this.getSocketIO();this.socket=e(this.options.host??void 0,this.options),this.socket.io.on("reconnect",()=>{Object.values(this.channels).forEach(n=>{n.subscribe()})})}getSocketIO(){if(typeof this.options.client<"u")return this.options.client;if(typeof window<"u"&&typeof window.io<"u")return window.io;throw new Error("Socket.io client not found. Should be globally available or passed via options.client")}listen(e,n,r){return this.channel(e).listen(n,r)}channel(e){return this.channels[e]||(this.channels[e]=new Gy(this.socket,e,this.options)),this.channels[e]}privateChannel(e){return this.channels["private-"+e]||(this.channels["private-"+e]=new Fy(this.socket,"private-"+e,this.options)),this.channels["private-"+e]}presenceChannel(e){return this.channels["presence-"+e]||(this.channels["presence-"+e]=new AA(this.socket,"presence-"+e,this.options)),this.channels["presence-"+e]}leave(e){[e,"private-"+e,"presence-"+e].forEach(n=>{this.leaveChannel(n)})}leaveChannel(e){this.channels[e]&&(this.channels[e].unsubscribe(),delete this.channels[e])}socketId(){return this.socket.id}disconnect(){this.socket.disconnect()}}class Wy extends Yf{constructor(){super(...arguments),this.channels={}}connect(){}listen(e,n,r){return new Gc}channel(e){return new Gc}privateChannel(e){return new Vy}encryptedPrivateChannel(e){return new xA}presenceChannel(e){return new TA}leave(e){}leaveChannel(e){}socketId(){return"fake-socket-id"}disconnect(){}}class RA{constructor(e){this.options=e,this.connect(),this.options.withoutInterceptors||this.registerInterceptors()}channel(e){return this.connector.channel(e)}connect(){if(this.options.broadcaster==="reverb")this.connector=new Fc({...this.options,cluster:""});else if(this.options.broadcaster==="pusher")this.connector=new Fc(this.options);else if(this.options.broadcaster==="ably")this.connector=new Fc({...this.options,cluster:"",broadcaster:"pusher"});else if(this.options.broadcaster==="socket.io")this.connector=new kA(this.options);else if(this.options.broadcaster==="null")this.connector=new Wy(this.options);else if(typeof this.options.broadcaster=="function"&&CA(this.options.broadcaster))this.connector=new this.options.broadcaster(this.options);else throw new Error(`Broadcaster ${typeof this.options.broadcaster} ${String(this.options.broadcaster)} is not supported.`)}disconnect(){this.connector.disconnect()}join(e){return this.connector.presenceChannel(e)}leave(e){this.connector.leave(e)}leaveChannel(e){this.connector.leaveChannel(e)}leaveAllChannels(){for(const e in this.connector.channels)this.leaveChannel(e)}listen(e,n,r){return this.connector.listen(e,n,r)}private(e){return this.connector.privateChannel(e)}encryptedPrivate(e){if(this.connectorSupportsEncryptedPrivateChannels(this.connector))return this.connector.encryptedPrivateChannel(e);throw new Error(`Broadcaster ${typeof this.options.broadcaster} ${String(this.options.broadcaster)} does not support encrypted private channels.`)}connectorSupportsEncryptedPrivateChannels(e){return e instanceof Fc||e instanceof Wy}socketId(){return this.connector.socketId()}registerInterceptors(){typeof Vue<"u"&&Vue!=null&&Vue.http&&this.registerVueRequestInterceptor(),typeof axios=="function"&&this.registerAxiosRequestInterceptor(),typeof jQuery=="function"&&this.registerjQueryAjaxSetup(),typeof Turbo=="object"&&this.registerTurboRequestInterceptor()}registerVueRequestInterceptor(){Vue.http.interceptors.push((e,n)=>{this.socketId()&&e.headers.set("X-Socket-ID",this.socketId()),n()})}registerAxiosRequestInterceptor(){axios.interceptors.request.use(e=>(this.socketId()&&(e.headers["X-Socket-Id"]=this.socketId()),e))}registerjQueryAjaxSetup(){typeof jQuery.ajax<"u"&&jQuery.ajaxPrefilter((e,n,r)=>{this.socketId()&&r.setRequestHeader("X-Socket-Id",this.socketId())})}registerTurboRequestInterceptor(){document.addEventListener("turbo:before-fetch-request",e=>{e.detail.fetchOptions.headers["X-Socket-Id"]=this.socketId()})}}var Xf={exports:{}};/*! - * Pusher JavaScript Library v8.4.0 + `,Qn.error("Error state rendered:",i,r)}getCurrentLayout(){return this.currentLayout}clear(){this.currentLayout=null,this.layoutCache.clear(),Qn.log("Layout data and cache cleared")}}const kx=pt("TranslationContext"),nh=N.createContext(null),Pc=({children:s,translationEngine:e,translationContext:n})=>{const r=N.useMemo(()=>(l,c)=>{if(c){const d="|"+Object.entries(c).map(([f,h])=>`${f}=${h}`).join("|");return e.translate(l,n,d)}return e.translate(l,n)},[e,n]),i=N.useMemo(()=>({translationEngine:e,translationContext:n,t:r}),[e,n,r]);return yt.jsx(nh.Provider,{value:i,children:s})},gb=()=>{const s=N.useContext(nh);return s||(kx.warn("TranslationProvider 외부에서 호출되었습니다. 키를 그대로 반환합니다."),{t:e=>e,translationEngine:null,translationContext:null})},za=pt("SlotContext"),Rx={registerToSlot:()=>{za.warn("SlotContext not available: registerToSlot called outside SlotProvider")},unregisterFromSlot:()=>{za.warn("SlotContext not available: unregisterFromSlot called outside SlotProvider")},getSlotComponents:()=>[],subscribeToSlot:()=>()=>{},clearAllSlots:()=>{},isEnabled:!1},Dx=N.createContext(Rx),rh=({children:s})=>{const e=N.useRef(new Map),n=N.useRef(new Map),r=N.useCallback(m=>{const y=n.current.get(m);y&&y.forEach(v=>{try{v()}catch(S){za.error(`Slot subscriber error (slotId: ${m}):`,S)}})},[]),i=N.useCallback((m,y,v)=>{if(!m||!y){za.warn("registerToSlot: slotId and componentId are required");return}e.current.has(m)||e.current.set(m,new Map);const S=e.current.get(m),_=S.get(y);_&&_.registrationKey===v.registrationKey||(S.set(y,v),za.log(`Component registered to slot: ${y} -> ${m} (order: ${v.order})`),r(m))},[r]),l=N.useCallback((m,y)=>{const v=e.current.get(m);v&&v.has(y)&&(v.delete(y),za.log(`Component unregistered from slot: ${y} <- ${m}`),v.size===0&&e.current.delete(m),r(m))},[r]),c=N.useCallback(m=>{const y=e.current.get(m);return y?Array.from(y.values()).sort((v,S)=>v.order-S.order):[]},[]),d=N.useCallback((m,y)=>{n.current.has(m)||n.current.set(m,new Set);const v=n.current.get(m);return v.add(y),()=>{v.delete(y),v.size===0&&n.current.delete(m)}},[]),f=N.useCallback(()=>{e.current.forEach((m,y)=>{r(y)}),e.current.clear(),n.current.clear(),za.log("All slots cleared")},[r]),h=N.useMemo(()=>({registerToSlot:i,unregisterFromSlot:l,getSlotComponents:c,subscribeToSlot:d,clearAllSlots:f,isEnabled:!0}),[i,l,c,d,f]);return N.useLayoutEffect(()=>{typeof window<"u"&&(window.__slotContextValue=h,za.log("SlotContext exposed to window.__slotContextValue"))},[h]),yt.jsx(Dx.Provider,{value:h,children:s})};class ah{constructor(){this.notificationCreatedEvent=".Illuminate\\Notifications\\Events\\BroadcastNotificationCreated"}listenForWhisper(e,n){return this.listen(".client-"+e,n)}notification(e){return this.listen(this.notificationCreatedEvent,e)}stopListeningForNotification(e){return this.stopListening(this.notificationCreatedEvent,e)}stopListeningForWhisper(e,n){return this.stopListening(".client-"+e,n)}}class mb{constructor(e){this.namespace=e}format(e){return[".","\\"].includes(e.charAt(0))?e.substring(1):(this.namespace&&(e=this.namespace+"."+e),e.replace(/\./g,"\\"))}setNamespace(e){this.namespace=e}}function Ox(s){try{return Reflect.construct(String,[],s),!0}catch{return!1}}class ih extends ah{constructor(e,n,r){super(),this.name=n,this.pusher=e,this.options=r,this.eventFormatter=new mb(this.options.namespace),this.subscribe()}subscribe(){this.subscription=this.pusher.subscribe(this.name)}unsubscribe(){this.pusher.unsubscribe(this.name)}listen(e,n){return this.on(this.eventFormatter.format(e),n),this}listenToAll(e){return this.subscription.bind_global((n,r)=>{if(n.startsWith("pusher:"))return;let i=String(this.options.namespace??"").replace(/\./g,"\\"),l=n.startsWith(i)?n.substring(i.length+1):"."+n;e(l,r)}),this}stopListening(e,n){return n?this.subscription.unbind(this.eventFormatter.format(e),n):this.subscription.unbind(this.eventFormatter.format(e)),this}stopListeningToAll(e){return e?this.subscription.unbind_global(e):this.subscription.unbind_global(),this}subscribed(e){return this.on("pusher:subscription_succeeded",()=>{e()}),this}error(e){return this.on("pusher:subscription_error",n=>{e(n)}),this}on(e,n){return this.subscription.bind(e,n),this}}class yb extends ih{whisper(e,n){return this.pusher.channels.channels[this.name].trigger(`client-${e}`,n),this}}class Lx extends ih{whisper(e,n){return this.pusher.channels.channels[this.name].trigger(`client-${e}`,n),this}}class $x extends yb{here(e){return this.on("pusher:subscription_succeeded",n=>{e(Object.keys(n.members).map(r=>n.members[r]))}),this}joining(e){return this.on("pusher:member_added",n=>{e(n.info)}),this}whisper(e,n){return this.pusher.channels.channels[this.name].trigger(`client-${e}`,n),this}leaving(e){return this.on("pusher:member_removed",n=>{e(n.info)}),this}}class bb extends ah{constructor(e,n,r){super(),this.events={},this.listeners={},this.name=n,this.socket=e,this.options=r,this.eventFormatter=new mb(this.options.namespace),this.subscribe()}subscribe(){this.socket.emit("subscribe",{channel:this.name,auth:this.options.auth||{}})}unsubscribe(){this.unbind(),this.socket.emit("unsubscribe",{channel:this.name,auth:this.options.auth||{}})}listen(e,n){return this.on(this.eventFormatter.format(e),n),this}stopListening(e,n){return this.unbindEvent(this.eventFormatter.format(e),n),this}subscribed(e){return this.on("connect",n=>{e(n)}),this}error(e){return this}on(e,n){return this.listeners[e]=this.listeners[e]||[],this.events[e]||(this.events[e]=(r,i)=>{this.name===r&&this.listeners[e]&&this.listeners[e].forEach(l=>l(i))},this.socket.on(e,this.events[e])),this.listeners[e].push(n),this}unbind(){Object.keys(this.events).forEach(e=>{this.unbindEvent(e)})}unbindEvent(e,n){this.listeners[e]=this.listeners[e]||[],n&&(this.listeners[e]=this.listeners[e].filter(r=>r!==n)),(!n||this.listeners[e].length===0)&&(this.events[e]&&(this.socket.removeListener(e,this.events[e]),delete this.events[e]),delete this.listeners[e])}}class vb extends bb{whisper(e,n){return this.socket.emit("client event",{channel:this.name,event:`client-${e}`,data:n}),this}}class Mx extends vb{here(e){return this.on("presence:subscribed",n=>{e(n.map(r=>r.user_info))}),this}joining(e){return this.on("presence:joining",n=>e(n.user_info)),this}whisper(e,n){return this.socket.emit("client event",{channel:this.name,event:`client-${e}`,data:n}),this}leaving(e){return this.on("presence:leaving",n=>e(n.user_info)),this}}class Uc extends ah{subscribe(){}unsubscribe(){}listen(e,n){return this}listenToAll(e){return this}stopListening(e,n){return this}subscribed(e){return this}error(e){return this}on(e,n){return this}}class Sb extends Uc{whisper(e,n){return this}}class Nx extends Uc{whisper(e,n){return this}}class Ix extends Sb{here(e){return this}joining(e){return this}whisper(e,n){return this}leaving(e){return this}}const wb=class a0{constructor(e){this.setOptions(e),this.connect()}setOptions(e){this.options={...a0._defaultOptions,...e,broadcaster:e.broadcaster};let n=this.csrfToken();n&&(this.options.auth.headers["X-CSRF-TOKEN"]=n,this.options.userAuthentication.headers["X-CSRF-TOKEN"]=n),n=this.options.bearerToken,n&&(this.options.auth.headers.Authorization="Bearer "+n,this.options.userAuthentication.headers.Authorization="Bearer "+n)}csrfToken(){var e,n;return typeof window<"u"&&(e=window.Laravel)!=null&&e.csrfToken?window.Laravel.csrfToken:this.options.csrfToken?this.options.csrfToken:typeof document<"u"&&typeof document.querySelector=="function"?((n=document.querySelector('meta[name="csrf-token"]'))==null?void 0:n.getAttribute("content"))??null:null}};wb._defaultOptions={auth:{headers:{}},authEndpoint:"/broadcasting/auth",userAuthentication:{endpoint:"/broadcasting/user-auth",headers:{}},csrfToken:null,bearerToken:null,host:null,key:null,namespace:"App.Events"};let sh=wb;class Bc extends sh{constructor(){super(...arguments),this.channels={}}connect(){if(typeof this.options.client<"u")this.pusher=this.options.client;else if(this.options.Pusher)this.pusher=new this.options.Pusher(this.options.key,this.options);else if(typeof window<"u"&&typeof window.Pusher<"u")this.pusher=new window.Pusher(this.options.key,this.options);else throw new Error("Pusher client not found. Should be globally available or passed via options.client")}signin(){this.pusher.signin()}listen(e,n,r){return this.channel(e).listen(n,r)}channel(e){return this.channels[e]||(this.channels[e]=new ih(this.pusher,e,this.options)),this.channels[e]}privateChannel(e){return this.channels["private-"+e]||(this.channels["private-"+e]=new yb(this.pusher,"private-"+e,this.options)),this.channels["private-"+e]}encryptedPrivateChannel(e){return this.channels["private-encrypted-"+e]||(this.channels["private-encrypted-"+e]=new Lx(this.pusher,"private-encrypted-"+e,this.options)),this.channels["private-encrypted-"+e]}presenceChannel(e){return this.channels["presence-"+e]||(this.channels["presence-"+e]=new $x(this.pusher,"presence-"+e,this.options)),this.channels["presence-"+e]}leave(e){[e,"private-"+e,"private-encrypted-"+e,"presence-"+e].forEach(n=>{this.leaveChannel(n)})}leaveChannel(e){this.channels[e]&&(this.channels[e].unsubscribe(),delete this.channels[e])}socketId(){return this.pusher.connection.socket_id}connectionStatus(){const e=this.pusher.connection.state;switch(e){case"connected":case"connecting":return e;case"failed":case"unavailable":return"failed";default:return"disconnected"}}onConnectionChange(e){const n=()=>{e(this.connectionStatus())},r=["state_change","connected","disconnected"];return r.forEach(i=>{this.pusher.connection.bind(i,n)}),()=>{r.forEach(i=>{this.pusher.connection.unbind(i,n)})}}disconnect(){this.pusher.disconnect()}}class jx extends sh{constructor(){super(...arguments),this.channels={}}connect(){let e=this.getSocketIO();this.socket=e(this.options.host??void 0,this.options),this.socket.io.on("reconnect",()=>{Object.values(this.channels).forEach(n=>{n.subscribe()})})}getSocketIO(){if(typeof this.options.client<"u")return this.options.client;if(typeof window<"u"&&typeof window.io<"u")return window.io;throw new Error("Socket.io client not found. Should be globally available or passed via options.client")}listen(e,n,r){return this.channel(e).listen(n,r)}channel(e){return this.channels[e]||(this.channels[e]=new bb(this.socket,e,this.options)),this.channels[e]}privateChannel(e){return this.channels["private-"+e]||(this.channels["private-"+e]=new vb(this.socket,"private-"+e,this.options)),this.channels["private-"+e]}presenceChannel(e){return this.channels["presence-"+e]||(this.channels["presence-"+e]=new Mx(this.socket,"presence-"+e,this.options)),this.channels["presence-"+e]}leave(e){[e,"private-"+e,"presence-"+e].forEach(n=>{this.leaveChannel(n)})}leaveChannel(e){this.channels[e]&&(this.channels[e].unsubscribe(),delete this.channels[e])}socketId(){return this.socket.id}connectionStatus(){return this.socket.connected?"connected":this.socket.io._reconnecting?"reconnecting":this.socket.id!==void 0?"disconnected":"connecting"}onConnectionChange(e){const n=()=>{e(this.connectionStatus())},r=["connect","disconnect","connect_error","reconnect_attempt","reconnect","reconnect_error","reconnect_failed"];return r.forEach(i=>{this.socket.on(i,n)}),()=>{r.forEach(i=>{this.socket.off(i,n)})}}disconnect(){this.socket.disconnect()}}class Cb extends sh{constructor(){super(...arguments),this.channels={}}connect(){}listen(e,n,r){return new Uc}channel(e){return new Uc}privateChannel(e){return new Sb}encryptedPrivateChannel(e){return new Nx}presenceChannel(e){return new Ix}leave(e){}leaveChannel(e){}socketId(){return"fake-socket-id"}connectionStatus(){return"connected"}onConnectionChange(e){return()=>{}}disconnect(){}}class Hx{constructor(e){this.options=e,this.connect(),this.options.withoutInterceptors||this.registerInterceptors()}channel(e){return this.connector.channel(e)}connect(){if(this.options.broadcaster==="reverb")this.connector=new Bc({...this.options,cluster:""});else if(this.options.broadcaster==="pusher")this.connector=new Bc(this.options);else if(this.options.broadcaster==="ably")this.connector=new Bc({...this.options,cluster:"",broadcaster:"pusher"});else if(this.options.broadcaster==="socket.io")this.connector=new jx(this.options);else if(this.options.broadcaster==="null")this.connector=new Cb(this.options);else if(typeof this.options.broadcaster=="function"&&Ox(this.options.broadcaster))this.connector=new this.options.broadcaster(this.options);else throw new Error(`Broadcaster ${typeof this.options.broadcaster} ${String(this.options.broadcaster)} is not supported.`)}disconnect(){this.connector.disconnect()}join(e){return this.connector.presenceChannel(e)}leave(e){this.connector.leave(e)}leaveChannel(e){this.connector.leaveChannel(e)}leaveAllChannels(){for(const e in this.connector.channels)this.leaveChannel(e)}listen(e,n,r){return this.connector.listen(e,n,r)}private(e){return this.connector.privateChannel(e)}encryptedPrivate(e){if(this.connectorSupportsEncryptedPrivateChannels(this.connector))return this.connector.encryptedPrivateChannel(e);throw new Error(`Broadcaster ${typeof this.options.broadcaster} ${String(this.options.broadcaster)} does not support encrypted private channels.`)}connectorSupportsEncryptedPrivateChannels(e){return e instanceof Bc||e instanceof Cb}socketId(){return this.connector.socketId()}connectionStatus(){return this.connector.connectionStatus()}registerInterceptors(){typeof Vue<"u"&&Vue!=null&&Vue.http&&this.registerVueRequestInterceptor(),typeof axios=="function"&&this.registerAxiosRequestInterceptor(),typeof jQuery=="function"&&this.registerjQueryAjaxSetup(),typeof Turbo=="object"&&this.registerTurboRequestInterceptor()}registerVueRequestInterceptor(){Vue.http.interceptors.push((e,n)=>{this.socketId()&&e.headers.set("X-Socket-ID",this.socketId()),n()})}registerAxiosRequestInterceptor(){axios.interceptors.request.use(e=>(this.socketId()&&(e.headers["X-Socket-Id"]=this.socketId()),e))}registerjQueryAjaxSetup(){typeof jQuery.ajax<"u"&&jQuery.ajaxPrefilter((e,n,r)=>{this.socketId()&&r.setRequestHeader("X-Socket-Id",this.socketId())})}registerTurboRequestInterceptor(){document.addEventListener("turbo:before-fetch-request",e=>{e.detail.fetchOptions.headers["X-Socket-Id"]=this.socketId()})}}var oh={exports:{}};/*! + * Pusher JavaScript Library v8.5.0 * https://pusher.com/ * * Copyright 2020, Pusher * Released under the MIT licence. - */var Yy;function DA(){return Yy||(Yy=1,(function(s,e){(function(r,i){s.exports=i()})(window,function(){return(function(n){var r={};function i(l){if(r[l])return r[l].exports;var c=r[l]={i:l,l:!1,exports:{}};return n[l].call(c.exports,c,c.exports,i),c.l=!0,c.exports}return i.m=n,i.c=r,i.d=function(l,c,d){i.o(l,c)||Object.defineProperty(l,c,{enumerable:!0,get:d})},i.r=function(l){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(l,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(l,"__esModule",{value:!0})},i.t=function(l,c){if(c&1&&(l=i(l)),c&8||c&4&&typeof l=="object"&&l&&l.__esModule)return l;var d=Object.create(null);if(i.r(d),Object.defineProperty(d,"default",{enumerable:!0,value:l}),c&2&&typeof l!="string")for(var f in l)i.d(d,f,function(p){return l[p]}.bind(null,f));return d},i.n=function(l){var c=l&&l.__esModule?function(){return l.default}:function(){return l};return i.d(c,"a",c),c},i.o=function(l,c){return Object.prototype.hasOwnProperty.call(l,c)},i.p="",i(i.s=2)})([(function(n,r,i){var l=this&&this.__extends||(function(){var x=function(w,R){return x=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(L,O){L.__proto__=O}||function(L,O){for(var j in O)O.hasOwnProperty(j)&&(L[j]=O[j])},x(w,R)};return function(w,R){x(w,R);function L(){this.constructor=w}w.prototype=R===null?Object.create(R):(L.prototype=R.prototype,new L)}})();Object.defineProperty(r,"__esModule",{value:!0});var c=256,d=(function(){function x(w){w===void 0&&(w="="),this._paddingCharacter=w}return x.prototype.encodedLength=function(w){return this._paddingCharacter?(w+2)/3*4|0:(w*8+5)/6|0},x.prototype.encode=function(w){for(var R="",L=0;L>>18&63),R+=this._encodeByte(O>>>12&63),R+=this._encodeByte(O>>>6&63),R+=this._encodeByte(O>>>0&63)}var j=w.length-L;if(j>0){var O=w[L]<<16|(j===2?w[L+1]<<8:0);R+=this._encodeByte(O>>>18&63),R+=this._encodeByte(O>>>12&63),j===2?R+=this._encodeByte(O>>>6&63):R+=this._paddingCharacter||"",R+=this._paddingCharacter||""}return R},x.prototype.maxDecodedLength=function(w){return this._paddingCharacter?w/4*3|0:(w*6+7)/8|0},x.prototype.decodedLength=function(w){return this.maxDecodedLength(w.length-this._getPaddingLength(w))},x.prototype.decode=function(w){if(w.length===0)return new Uint8Array(0);for(var R=this._getPaddingLength(w),L=w.length-R,O=new Uint8Array(this.maxDecodedLength(L)),j=0,F=0,G=0,P=0,K=0,he=0,Ee=0;F>>4,O[j++]=K<<4|he>>>2,O[j++]=he<<6|Ee,G|=P&c,G|=K&c,G|=he&c,G|=Ee&c;if(F>>4,G|=P&c,G|=K&c),F>>2,G|=he&c),F>>8&6,R+=51-w>>>8&-75,R+=61-w>>>8&-15,R+=62-w>>>8&3,String.fromCharCode(R)},x.prototype._decodeChar=function(w){var R=c;return R+=(42-w&w-44)>>>8&-c+w-43+62,R+=(46-w&w-48)>>>8&-c+w-47+63,R+=(47-w&w-58)>>>8&-c+w-48+52,R+=(64-w&w-91)>>>8&-c+w-65+0,R+=(96-w&w-123)>>>8&-c+w-97+26,R},x.prototype._getPaddingLength=function(w){var R=0;if(this._paddingCharacter){for(var L=w.length-1;L>=0&&w[L]===this._paddingCharacter;L--)R++;if(w.length<4||R>2)throw new Error("Base64Coder: incorrect padding")}return R},x})();r.Coder=d;var f=new d;function p(x){return f.encode(x)}r.encode=p;function m(x){return f.decode(x)}r.decode=m;var y=(function(x){l(w,x);function w(){return x!==null&&x.apply(this,arguments)||this}return w.prototype._encodeByte=function(R){var L=R;return L+=65,L+=25-R>>>8&6,L+=51-R>>>8&-75,L+=61-R>>>8&-13,L+=62-R>>>8&49,String.fromCharCode(L)},w.prototype._decodeChar=function(R){var L=c;return L+=(44-R&R-46)>>>8&-c+R-45+62,L+=(94-R&R-96)>>>8&-c+R-95+63,L+=(47-R&R-58)>>>8&-c+R-48+52,L+=(64-R&R-91)>>>8&-c+R-65+0,L+=(96-R&R-123)>>>8&-c+R-97+26,L},w})(d);r.URLSafeCoder=y;var C=new y;function S(x){return C.encode(x)}r.encodeURLSafe=S;function v(x){return C.decode(x)}r.decodeURLSafe=v,r.encodedLength=function(x){return f.encodedLength(x)},r.maxDecodedLength=function(x){return f.maxDecodedLength(x)},r.decodedLength=function(x){return f.decodedLength(x)}}),(function(n,r,i){Object.defineProperty(r,"__esModule",{value:!0});var l="utf8: invalid string",c="utf8: invalid source encoding";function d(m){for(var y=new Uint8Array(f(m)),C=0,S=0;S>6,y[C++]=128|v&63):v<55296?(y[C++]=224|v>>12,y[C++]=128|v>>6&63,y[C++]=128|v&63):(S++,v=(v&1023)<<10,v|=m.charCodeAt(S)&1023,v+=65536,y[C++]=240|v>>18,y[C++]=128|v>>12&63,y[C++]=128|v>>6&63,y[C++]=128|v&63)}return y}r.encode=d;function f(m){for(var y=0,C=0;C=m.length-1)throw new Error(l);C++,y+=4}else throw new Error(l)}return y}r.encodedLength=f;function p(m){for(var y=[],C=0;C=m.length)throw new Error(c);var x=m[++C];if((x&192)!==128)throw new Error(c);S=(S&31)<<6|x&63,v=128}else if(S<240){if(C>=m.length-1)throw new Error(c);var x=m[++C],w=m[++C];if((x&192)!==128||(w&192)!==128)throw new Error(c);S=(S&15)<<12|(x&63)<<6|w&63,v=2048}else if(S<248){if(C>=m.length-2)throw new Error(c);var x=m[++C],w=m[++C],R=m[++C];if((x&192)!==128||(w&192)!==128||(R&192)!==128)throw new Error(c);S=(S&15)<<18|(x&63)<<12|(w&63)<<6|R&63,v=65536}else throw new Error(c);if(S=55296&&S<=57343)throw new Error(c);if(S>=65536){if(S>1114111)throw new Error(c);S-=65536,y.push(String.fromCharCode(55296|S>>10)),S=56320|S&1023}}y.push(String.fromCharCode(S))}return y.join("")}r.decode=p}),(function(n,r,i){n.exports=i(3).default}),(function(n,r,i){i.r(r);class l{constructor(b,_){this.lastId=0,this.prefix=b,this.name=_}create(b){this.lastId++;var _=this.lastId,D=this.prefix+_,I=this.name+"["+_+"]",ie=!1,ye=function(){ie||(b.apply(null,arguments),ie=!0)};return this[_]=ye,{number:_,id:D,name:I,callback:ye}}remove(b){delete this[b.number]}}var c=new l("_pusher_script_","Pusher.ScriptReceivers"),d={VERSION:"8.4.0",PROTOCOL:7,wsPort:80,wssPort:443,wsPath:"",httpHost:"sockjs.pusher.com",httpPort:80,httpsPort:443,httpPath:"/pusher",stats_host:"stats.pusher.com",authEndpoint:"/pusher/auth",authTransport:"ajax",activityTimeout:12e4,pongTimeout:3e4,unavailableTimeout:1e4,userAuthentication:{endpoint:"/pusher/user-auth",transport:"ajax"},channelAuthorization:{endpoint:"/pusher/auth",transport:"ajax"},cdn_http:"http://js.pusher.com",cdn_https:"https://js.pusher.com",dependency_suffix:""},f=d;class p{constructor(b){this.options=b,this.receivers=b.receivers||c,this.loading={}}load(b,_,D){var I=this;if(I.loading[b]&&I.loading[b].length>0)I.loading[b].push(D);else{I.loading[b]=[D];var ie=Fe.createScriptRequest(I.getPath(b,_)),ye=I.receivers.create(function(Oe){if(I.receivers.remove(ye),I.loading[b]){var Ve=I.loading[b];delete I.loading[b];for(var it=function(Bt){Bt||ie.cleanup()},ct=0;ct>>6)+ze(128|b&63):ze(224|b>>>12&15)+ze(128|b>>>6&63)+ze(128|b&63)},bt=function(A){return A.replace(/[^\x00-\x7F]/g,je)},X=function(A){var b=[0,2,1][A.length%3],_=A.charCodeAt(0)<<16|(A.length>1?A.charCodeAt(1):0)<<8|(A.length>2?A.charCodeAt(2):0),D=[Be.charAt(_>>>18),Be.charAt(_>>>12&63),b>=2?"=":Be.charAt(_>>>6&63),b>=1?"=":Be.charAt(_&63)];return D.join("")},de=window.btoa||function(A){return A.replace(/[\s\S]{1,3}/g,X)};class Ce{constructor(b,_,D,I){this.clear=_,this.timer=b(()=>{this.timer&&(this.timer=I(this.timer))},D)}isRunning(){return this.timer!==null}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}}var Z=Ce;function ge(A){window.clearTimeout(A)}function z(A){window.clearInterval(A)}class T extends Z{constructor(b,_){super(setTimeout,ge,b,function(D){return _(),null})}}class pe extends Z{constructor(b,_){super(setInterval,z,b,function(D){return _(),D})}}var fe={now(){return Date.now?Date.now():new Date().valueOf()},defer(A){return new T(0,A)},method(A,...b){var _=Array.prototype.slice.call(arguments,1);return function(D){return D[A].apply(D,_.concat(arguments))}}},me=fe;function ae(A,...b){for(var _=0;_{window.console&&window.console.log&&window.console.log(b)}}debug(...b){this.log(this.globalLog,b)}warn(...b){this.log(this.globalLogWarn,b)}error(...b){this.log(this.globalLogError,b)}globalLogWarn(b){window.console&&window.console.warn?window.console.warn(b):this.globalLog(b)}globalLogError(b){window.console&&window.console.error?window.console.error(b):this.globalLogWarn(b)}log(b,..._){var D=Re.apply(this,arguments);hl.log?hl.log(D):hl.logToConsole&&b.bind(this)(D)}}var St=new Pt,da=function(A,b,_,D,I){(_.headers!==void 0||_.headersProvider!=null)&&St.warn(`To send headers with the ${D.toString()} request, you must use AJAX, rather than JSONP.`);var ie=A.nextAuthCallbackID.toString();A.nextAuthCallbackID++;var ye=A.getDocument(),Oe=ye.createElement("script");A.auth_callbacks[ie]=function(ct){I(null,ct)};var Ve="Pusher.auth_callbacks['"+ie+"']";Oe.src=_.endpoint+"?callback="+encodeURIComponent(Ve)+"&"+b;var it=ye.getElementsByTagName("head")[0]||ye.documentElement;it.insertBefore(Oe,it.firstChild)},In=da;class kn{constructor(b){this.src=b}send(b){var _=this,D="Error loading "+_.src;_.script=document.createElement("script"),_.script.id=b.id,_.script.src=_.src,_.script.type="text/javascript",_.script.charset="UTF-8",_.script.addEventListener?(_.script.onerror=function(){b.callback(D)},_.script.onload=function(){b.callback(null)}):_.script.onreadystatechange=function(){(_.script.readyState==="loaded"||_.script.readyState==="complete")&&b.callback(null)},_.script.async===void 0&&document.attachEvent&&/opera/i.test(navigator.userAgent)?(_.errorScript=document.createElement("script"),_.errorScript.id=b.id+"_error",_.errorScript.text=b.name+"('"+D+"');",_.script.async=_.errorScript.async=!1):_.script.async=!0;var I=document.getElementsByTagName("head")[0];I.insertBefore(_.script,I.firstChild),_.errorScript&&I.insertBefore(_.errorScript,_.script.nextSibling)}cleanup(){this.script&&(this.script.onload=this.script.onerror=null,this.script.onreadystatechange=null),this.script&&this.script.parentNode&&this.script.parentNode.removeChild(this.script),this.errorScript&&this.errorScript.parentNode&&this.errorScript.parentNode.removeChild(this.errorScript),this.script=null,this.errorScript=null}}class Rn{constructor(b,_){this.url=b,this.data=_}send(b){if(!this.request){var _=pn(this.data),D=this.url+"/"+b.number+"?"+_;this.request=Fe.createScriptRequest(D),this.request.send(b)}}cleanup(){this.request&&this.request.cleanup()}}var jn=function(A,b){return function(_,D){var I="http"+(b?"s":"")+"://",ie=I+(A.host||A.options.host)+A.options.path,ye=Fe.createJSONPRequest(ie,_),Oe=Fe.ScriptReceivers.create(function(Ve,it){c.remove(Oe),ye.cleanup(),it&&it.host&&(A.host=it.host),D&&D(Ve,it)});ye.send(Oe)}},gn={name:"jsonp",getAgent:jn},fa=gn;function zn(A,b,_){var D=A+(b.useTLS?"s":""),I=b.useTLS?b.hostTLS:b.hostNonTLS;return D+"://"+I+_}function Vt(A,b){var _="/app/"+A,D="?protocol="+f.PROTOCOL+"&client=js&version="+f.VERSION+(b?"&"+b:"");return _+D}var _n={getInitial:function(A,b){var _=(b.httpPath||"")+Vt(A,"flash=false");return zn("ws",b,_)}},an={getInitial:function(A,b){var _=(b.httpPath||"/pusher")+Vt(A);return zn("http",b,_)}},q={getInitial:function(A,b){return zn("http",b,b.httpPath||"/pusher")},getPath:function(A,b){return Vt(A)}};class oe{constructor(){this._callbacks={}}get(b){return this._callbacks[ce(b)]}add(b,_,D){var I=ce(b);this._callbacks[I]=this._callbacks[I]||[],this._callbacks[I].push({fn:_,context:D})}remove(b,_,D){if(!b&&!_&&!D){this._callbacks={};return}var I=b?[ce(b)]:Ge(this._callbacks);_||D?this.removeCallback(I,_,D):this.removeAllCallbacks(I)}removeCallback(b,_,D){vt(b,function(I){this._callbacks[I]=Xt(this._callbacks[I]||[],function(ie){return _&&_!==ie.fn||D&&D!==ie.context}),this._callbacks[I].length===0&&delete this._callbacks[I]},this)}removeAllCallbacks(b){vt(b,function(_){delete this._callbacks[_]},this)}}function ce(A){return"_"+A}class J{constructor(b){this.callbacks=new oe,this.global_callbacks=[],this.failThrough=b}bind(b,_,D){return this.callbacks.add(b,_,D),this}bind_global(b){return this.global_callbacks.push(b),this}unbind(b,_,D){return this.callbacks.remove(b,_,D),this}unbind_global(b){return b?(this.global_callbacks=Xt(this.global_callbacks||[],_=>_!==b),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(b,_,D){for(var I=0;I0)for(var I=0;I{this.onError(_),this.changeState("closed")}),!1}return this.bindListeners(),St.debug("Connecting",{transport:this.name,url:b}),this.changeState("connecting"),!0}close(){return this.socket?(this.socket.close(),!0):!1}send(b){return this.state==="open"?(me.defer(()=>{this.socket&&this.socket.send(b)}),!0):!1}ping(){this.state==="open"&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(b){this.emit("error",{type:"WebSocketError",error:b}),this.timeline.error(this.buildTimelineMessage({error:b.toString()}))}onClose(b){b?this.changeState("closed",{code:b.code,reason:b.reason,wasClean:b.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(b){this.emit("message",b)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=b=>{this.onError(b)},this.socket.onclose=b=>{this.onClose(b)},this.socket.onmessage=b=>{this.onMessage(b)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(b,_){this.state=b,this.timeline.info(this.buildTimelineMessage({state:b,params:_})),this.emit(b,_)}buildTimelineMessage(b){return ae({cid:this.id},b)}}class ue{constructor(b){this.hooks=b}isSupported(b){return this.hooks.isSupported(b)}createConnection(b,_,D,I){return new ve(this.hooks,b,_,D,I)}}var we=new ue({urls:_n,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return!!Fe.getWebSocketAPI()},isSupported:function(){return!!Fe.getWebSocketAPI()},getSocket:function(A){return Fe.createWebSocket(A)}}),_e={urls:an,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},qe=ae({getSocket:function(A){return Fe.HTTPFactory.createStreamingSocket(A)}},_e),xe=ae({getSocket:function(A){return Fe.HTTPFactory.createPollingSocket(A)}},_e),De={isSupported:function(){return Fe.isXHRSupported()}},Ae=new ue(ae({},qe,De)),tt=new ue(ae({},xe,De)),Ne={ws:we,xhr_streaming:Ae,xhr_polling:tt},He=Ne,Se=new ue({file:"sockjs",urls:q,handlesActivityChecks:!0,supportsPing:!1,isSupported:function(){return!0},isInitialized:function(){return window.SockJS!==void 0},getSocket:function(A,b){return new window.SockJS(A,null,{js_path:y.getPath("sockjs",{useTLS:b.useTLS}),ignore_null_origin:b.ignoreNullOrigin})},beforeOpen:function(A,b){A.send(JSON.stringify({path:b}))}}),$e={isSupported:function(A){var b=Fe.isXDRSupported(A.useTLS);return b}},et=new ue(ae({},qe,$e)),Ot=new ue(ae({},xe,$e));He.xdr_streaming=et,He.xdr_polling=Ot,He.sockjs=Se;var Mt=He;class Hn extends J{constructor(){super();var b=this;window.addEventListener!==void 0&&(window.addEventListener("online",function(){b.emit("online")},!1),window.addEventListener("offline",function(){b.emit("offline")},!1))}isOnline(){return window.navigator.onLine===void 0?!0:window.navigator.onLine}}var It=new Hn;class jt{constructor(b,_,D){this.manager=b,this.transport=_,this.minPingDelay=D.minPingDelay,this.maxPingDelay=D.maxPingDelay,this.pingDelay=void 0}createConnection(b,_,D,I){I=ae({},I,{activityTimeout:this.pingDelay});var ie=this.transport.createConnection(b,_,D,I),ye=null,Oe=function(){ie.unbind("open",Oe),ie.bind("closed",Ve),ye=me.now()},Ve=it=>{if(ie.unbind("closed",Ve),it.code===1002||it.code===1003)this.manager.reportDeath();else if(!it.wasClean&&ye){var ct=me.now()-ye;ct<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(ct/2,this.minPingDelay))}};return ie.bind("open",Oe),ie}isSupported(b){return this.manager.isAlive()&&this.transport.isSupported(b)}}const mn={decodeMessage:function(A){try{var b=JSON.parse(A.data),_=b.data;if(typeof _=="string")try{_=JSON.parse(b.data)}catch{}var D={event:b.event,channel:b.channel,data:_};return b.user_id&&(D.user_id=b.user_id),D}catch(I){throw{type:"MessageParseError",error:I,data:A.data}}},encodeMessage:function(A){return JSON.stringify(A)},processHandshake:function(A){var b=mn.decodeMessage(A);if(b.event==="pusher:connection_established"){if(!b.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:b.data.socket_id,activityTimeout:b.data.activity_timeout*1e3}}else{if(b.event==="pusher:error")return{action:this.getCloseAction(b.data),error:this.getCloseError(b.data)};throw"Invalid handshake"}},getCloseAction:function(A){return A.code<4e3?A.code>=1002&&A.code<=1004?"backoff":null:A.code===4e3?"tls_only":A.code<4100?"refused":A.code<4200?"backoff":A.code<4300?"retry":"refused"},getCloseError:function(A){return A.code!==1e3&&A.code!==1001?{type:"PusherError",data:{code:A.code,message:A.reason||A.message}}:null}};var Un=mn;class Jo extends J{constructor(b,_){super(),this.id=b,this.transport=_,this.activityTimeout=_.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(b){return this.transport.send(b)}send_event(b,_,D){var I={event:b,data:_};return D&&(I.channel=D),St.debug("Event sent",I),this.send(Un.encodeMessage(I))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var b={message:D=>{var I;try{I=Un.decodeMessage(D)}catch(ie){this.emit("error",{type:"MessageParseError",error:ie,data:D.data})}if(I!==void 0){switch(St.debug("Event recd",I),I.event){case"pusher:error":this.emit("error",{type:"PusherError",data:I.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong");break}this.emit("message",I)}},activity:()=>{this.emit("activity")},error:D=>{this.emit("error",D)},closed:D=>{_(),D&&D.code&&this.handleCloseEvent(D),this.transport=null,this.emit("closed")}},_=()=>{Me(b,(D,I)=>{this.transport.unbind(I,D)})};Me(b,(D,I)=>{this.transport.bind(I,D)})}handleCloseEvent(b){var _=Un.getCloseAction(b),D=Un.getCloseError(b);D&&this.emit("error",D),_&&this.emit(_,{action:_,error:D})}}class rh{constructor(b,_){this.transport=b,this.callback=_,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=b=>{this.unbindListeners();var _;try{_=Un.processHandshake(b)}catch(D){this.finish("error",{error:D}),this.transport.close();return}_.action==="connected"?this.finish("connected",{connection:new Jo(_.id,this.transport),activityTimeout:_.activityTimeout}):(this.finish(_.action,{error:_.error}),this.transport.close())},this.onClosed=b=>{this.unbindListeners();var _=Un.getCloseAction(b)||"backoff",D=Un.getCloseError(b);this.finish(_,{error:D})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(b,_){this.callback(ae({transport:this.transport,action:b},_))}}class ah{constructor(b,_){this.timeline=b,this.options=_||{}}send(b,_){this.timeline.isEmpty()||this.timeline.send(Fe.TimelineTransport.getAgent(this,b),_)}}class As extends J{constructor(b,_){super(function(D,I){St.debug("No callbacks on "+b+" for "+D)}),this.name=b,this.pusher=_,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(b,_){return _(null,{auth:""})}trigger(b,_){if(b.indexOf("client-")!==0)throw new w("Event '"+b+"' does not start with 'client-'");if(!this.subscribed){var D=v.buildLogSuffix("triggeringClientEvents");St.warn(`Client event triggered before channel 'subscription_succeeded' event . ${D}`)}return this.pusher.send_event(b,_,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(b){var _=b.event,D=b.data;if(_==="pusher_internal:subscription_succeeded")this.handleSubscriptionSucceededEvent(b);else if(_==="pusher_internal:subscription_count")this.handleSubscriptionCountEvent(b);else if(_.indexOf("pusher_internal:")!==0){var I={};this.emit(_,D,I)}}handleSubscriptionSucceededEvent(b){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",b.data)}handleSubscriptionCountEvent(b){b.data.subscription_count&&(this.subscriptionCount=b.data.subscription_count),this.emit("pusher:subscription_count",b.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(b,_)=>{b?(this.subscriptionPending=!1,St.error(b.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:b.message},b instanceof K?{status:b.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:_.auth,channel_data:_.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class ha extends As{authorize(b,_){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:b},_)}}class Qo{constructor(){this.reset()}get(b){return Object.prototype.hasOwnProperty.call(this.members,b)?{id:b,info:this.members[b]}:null}each(b){Me(this.members,(_,D)=>{b(this.get(D))})}setMyID(b){this.myID=b}onSubscription(b){this.members=b.presence.hash,this.count=b.presence.count,this.me=this.get(this.myID)}addMember(b){return this.get(b.user_id)===null&&this.count++,this.members[b.user_id]=b.user_info,this.get(b.user_id)}removeMember(b){var _=this.get(b.user_id);return _&&(delete this.members[b.user_id],this.count--),_}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var qa=function(A,b,_,D){function I(ie){return ie instanceof _?ie:new _(function(ye){ye(ie)})}return new(_||(_=Promise))(function(ie,ye){function Oe(ct){try{it(D.next(ct))}catch(Bt){ye(Bt)}}function Ve(ct){try{it(D.throw(ct))}catch(Bt){ye(Bt)}}function it(ct){ct.done?ie(ct.value):I(ct.value).then(Oe,Ve)}it((D=D.apply(A,b||[])).next())})};class Ga extends ha{constructor(b,_){super(b,_),this.members=new Qo}authorize(b,_){super.authorize(b,(D,I)=>qa(this,void 0,void 0,function*(){if(!D)if(I=I,I.channel_data!=null){var ie=JSON.parse(I.channel_data);this.members.setMyID(ie.user_id)}else if(yield this.pusher.user.signinDonePromise,this.pusher.user.user_data!=null)this.members.setMyID(this.pusher.user.user_data.id);else{let ye=v.buildLogSuffix("authorizationEndpoint");St.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${ye}, or the user should be signed in.`),_("Invalid auth response");return}_(D,I)}))}handleEvent(b){var _=b.event;if(_.indexOf("pusher_internal:")===0)this.handleInternalEvent(b);else{var D=b.data,I={};b.user_id&&(I.user_id=b.user_id),this.emit(_,D,I)}}handleInternalEvent(b){var _=b.event,D=b.data;switch(_){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(b);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(b);break;case"pusher_internal:member_added":var I=this.members.addMember(D);this.emit("pusher:member_added",I);break;case"pusher_internal:member_removed":var ie=this.members.removeMember(D);ie&&this.emit("pusher:member_removed",ie);break}}handleSubscriptionSucceededEvent(b){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(b.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var Mi=i(1),Yr=i(0);class Jt extends ha{constructor(b,_,D){super(b,_),this.key=null,this.nacl=D}authorize(b,_){super.authorize(b,(D,I)=>{if(D){_(D,I);return}let ie=I.shared_secret;if(!ie){_(new Error(`No shared_secret key in auth payload for encrypted channel: ${this.name}`),null);return}this.key=Object(Yr.decode)(ie),delete I.shared_secret,_(null,I)})}trigger(b,_){throw new F("Client events are not currently supported for encrypted channels")}handleEvent(b){var _=b.event,D=b.data;if(_.indexOf("pusher_internal:")===0||_.indexOf("pusher:")===0){super.handleEvent(b);return}this.handleEncryptedEvent(_,D)}handleEncryptedEvent(b,_){if(!this.key){St.debug("Received encrypted event before key has been retrieved from the authEndpoint");return}if(!_.ciphertext||!_.nonce){St.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+_);return}let D=Object(Yr.decode)(_.ciphertext);if(D.length{if(ye){St.error(`Failed to make a request to the authEndpoint: ${Oe}. Unable to fetch new key, so dropping encrypted event`);return}if(ie=this.nacl.secretbox.open(D,I,this.key),ie===null){St.error("Failed to decrypt event with new key. Dropping encrypted event");return}this.emit(b,this.getDataToEmit(ie))});return}this.emit(b,this.getDataToEmit(ie))}getDataToEmit(b){let _=Object(Mi.decode)(b);try{return JSON.parse(_)}catch{return _}}}class eu extends J{constructor(b,_){super(),this.state="initialized",this.connection=null,this.key=b,this.options=_,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var D=Fe.getNetwork();D.bind("online",()=>{this.timeline.info({netinfo:"online"}),(this.state==="connecting"||this.state==="unavailable")&&this.retryIn(0)}),D.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}connect(){if(!(this.connection||this.runner)){if(!this.strategy.isSupported()){this.updateState("failed");return}this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()}}send(b){return this.connection?this.connection.send(b):!1}send_event(b,_,D){return this.connection?this.connection.send_event(b,_,D):!1}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var b=(_,D)=>{_?this.runner=this.strategy.connect(0,b):D.action==="error"?(this.emit("error",{type:"HandshakeError",error:D.error}),this.timeline.error({handshakeError:D.error})):(this.abortConnecting(),this.handshakeCallbacks[D.action](D))};this.runner=this.strategy.connect(0,b)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){if(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection){var b=this.abandonConnection();b.close()}}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(b){this.timeline.info({action:"retry",delay:b}),b>0&&this.emit("connecting_in",Math.round(b/1e3)),this.retryTimer=new T(b||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new T(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new T(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new T(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(b){return ae({},b,{message:_=>{this.resetActivityCheck(),this.emit("message",_)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:_=>{this.emit("error",_)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(b){return ae({},b,{connected:_=>{this.activityTimeout=Math.min(this.options.activityTimeout,_.activityTimeout,_.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(_.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let b=_=>D=>{D.error&&this.emit("error",{type:"WebSocketError",error:D.error}),_(D)};return{tls_only:b(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:b(()=>{this.disconnect()}),backoff:b(()=>{this.retryIn(1e3)}),retry:b(()=>{this.retryIn(0)})}}setConnection(b){this.connection=b;for(var _ in this.connectionCallbacks)this.connection.bind(_,this.connectionCallbacks[_]);this.resetActivityCheck()}abandonConnection(){if(this.connection){this.stopActivityCheck();for(var b in this.connectionCallbacks)this.connection.unbind(b,this.connectionCallbacks[b]);var _=this.connection;return this.connection=null,_}}updateState(b,_){var D=this.state;if(this.state=b,D!==b){var I=b;I==="connected"&&(I+=" with new socket ID "+_.socket_id),St.debug("State changed",D+" -> "+I),this.timeline.info({state:b,params:_}),this.emit("state_change",{previous:D,current:b}),this.emit(b,_)}}shouldRetry(){return this.state==="connecting"||this.state==="connected"}}class tu{constructor(){this.channels={}}add(b,_){return this.channels[b]||(this.channels[b]=pa(b,_)),this.channels[b]}all(){return kt(this.channels)}find(b){return this.channels[b]}remove(b){var _=this.channels[b];return delete this.channels[b],_}disconnect(){Me(this.channels,function(b){b.disconnect()})}}function pa(A,b){if(A.indexOf("private-encrypted-")===0){if(b.config.nacl)return Mr.createEncryptedChannel(A,b,b.config.nacl);let _="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",D=v.buildLogSuffix("encryptedChannelSupport");throw new F(`${_}. ${D}`)}else{if(A.indexOf("private-")===0)return Mr.createPrivateChannel(A,b);if(A.indexOf("presence-")===0)return Mr.createPresenceChannel(A,b);if(A.indexOf("#")===0)throw new R('Cannot create a channel with name "'+A+'".');return Mr.createChannel(A,b)}}var Fa={createChannels(){return new tu},createConnectionManager(A,b){return new eu(A,b)},createChannel(A,b){return new As(A,b)},createPrivateChannel(A,b){return new ha(A,b)},createPresenceChannel(A,b){return new Ga(A,b)},createEncryptedChannel(A,b,_){return new Jt(A,b,_)},createTimelineSender(A,b){return new ah(A,b)},createHandshake(A,b){return new rh(A,b)},createAssistantToTheTransportManager(A,b,_){return new jt(A,b,_)}},Mr=Fa;class Zo{constructor(b){this.options=b||{},this.livesLeft=this.options.lives||1/0}getAssistant(b){return Mr.createAssistantToTheTransportManager(this,b,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class Xr{constructor(b,_){this.strategies=b,this.loop=!!_.loop,this.failFast=!!_.failFast,this.timeout=_.timeout,this.timeoutLimit=_.timeoutLimit}isSupported(){return $r(this.strategies,me.method("isSupported"))}connect(b,_){var D=this.strategies,I=0,ie=this.timeout,ye=null,Oe=(Ve,it)=>{it?_(null,it):(I=I+1,this.loop&&(I=I%D.length),I0&&(ie=new T(D.timeout,function(){ye.abort(),I(!0)})),ye=b.connect(_,function(Oe,Ve){Oe&&ie&&ie.isRunning()&&!D.failFast||(ie&&ie.ensureAborted(),I(Oe,Ve))}),{abort:function(){ie&&ie.ensureAborted(),ye.abort()},forceMinPriority:function(Oe){ye.forceMinPriority(Oe)}}}}class el{constructor(b){this.strategies=b}isSupported(){return $r(this.strategies,me.method("isSupported"))}connect(b,_){return xs(this.strategies,b,function(D,I){return function(ie,ye){if(I[D].error=ie,ie){Ts(I)&&_(!0);return}vt(I,function(Oe){Oe.forceMinPriority(ye.transport.priority)}),_(null,ye)}})}}function xs(A,b,_){var D=hn(A,function(I,ie,ye,Oe){return I.connect(b,_(ie,Oe))});return{abort:function(){vt(D,Nr)},forceMinPriority:function(I){vt(D,function(ie){ie.forceMinPriority(I)})}}}function Ts(A){return En(A,function(b){return!!b.error})}function Nr(A){!A.error&&!A.aborted&&(A.abort(),A.aborted=!0)}class Pn{constructor(b,_,D){this.strategy=b,this.transports=_,this.ttl=D.ttl||1800*1e3,this.usingTLS=D.useTLS,this.timeline=D.timeline}isSupported(){return this.strategy.isSupported()}connect(b,_){var D=this.usingTLS,I=ih(D),ie=I&&I.cacheSkipCount?I.cacheSkipCount:0,ye=[this.strategy];if(I&&I.timestamp+this.ttl>=me.now()){var Oe=this.transports[I.transport];Oe&&(["ws","wss"].includes(I.transport)||ie>3?(this.timeline.info({cached:!0,transport:I.transport,latency:I.latency}),ye.push(new Xr([Oe],{timeout:I.latency*2+1e3,failFast:!0}))):ie++)}var Ve=me.now(),it=ye.pop().connect(b,function ct(Bt,Hi){Bt?(nl(D),ye.length>0?(Ve=me.now(),it=ye.pop().connect(b,ct)):_(Bt)):(tl(D,Hi.transport.name,me.now()-Ve,ie),_(null,Hi))});return{abort:function(){it.abort()},forceMinPriority:function(ct){b=ct,it&&it.forceMinPriority(ct)}}}}function ks(A){return"pusherTransport"+(A?"TLS":"NonTLS")}function ih(A){var b=Fe.getLocalStorage();if(b)try{var _=b[ks(A)];if(_)return JSON.parse(_)}catch{nl(A)}return null}function tl(A,b,_,D){var I=Fe.getLocalStorage();if(I)try{I[ks(A)]=er({timestamp:me.now(),transport:b,latency:_,cacheSkipCount:D})}catch{}}function nl(A){var b=Fe.getLocalStorage();if(b)try{delete b[ks(A)]}catch{}}class ga{constructor(b,{delay:_}){this.strategy=b,this.options={delay:_}}isSupported(){return this.strategy.isSupported()}connect(b,_){var D=this.strategy,I,ie=new T(this.options.delay,function(){I=D.connect(b,_)});return{abort:function(){ie.ensureAborted(),I&&I.abort()},forceMinPriority:function(ye){b=ye,I&&I.forceMinPriority(ye)}}}}class Ni{constructor(b,_,D){this.test=b,this.trueBranch=_,this.falseBranch=D}isSupported(){var b=this.test()?this.trueBranch:this.falseBranch;return b.isSupported()}connect(b,_){var D=this.test()?this.trueBranch:this.falseBranch;return D.connect(b,_)}}class Bn{constructor(b){this.strategy=b}isSupported(){return this.strategy.isSupported()}connect(b,_){var D=this.strategy.connect(b,function(I,ie){ie&&D.abort(),_(I,ie)});return D}}function ma(A){return function(){return A.isSupported()}}var nu=function(A,b,_){var D={};function I(Ui,pu,gu,vl,Sl){var wl=_(A,Ui,pu,gu,vl,Sl);return D[Ui]=wl,wl}var ie=Object.assign({},b,{hostNonTLS:A.wsHost+":"+A.wsPort,hostTLS:A.wsHost+":"+A.wssPort,httpPath:A.wsPath}),ye=Object.assign({},ie,{useTLS:!0}),Oe=Object.assign({},b,{hostNonTLS:A.httpHost+":"+A.httpPort,hostTLS:A.httpHost+":"+A.httpsPort,httpPath:A.httpPath}),Ve={loop:!0,timeout:15e3,timeoutLimit:6e4},it=new Zo({minPingDelay:1e4,maxPingDelay:A.activityTimeout}),ct=new Zo({lives:2,minPingDelay:1e4,maxPingDelay:A.activityTimeout}),Bt=I("ws","ws",3,ie,it),Hi=I("wss","ws",3,ye,it),du=I("sockjs","sockjs",1,Oe),pl=I("xhr_streaming","xhr_streaming",1,Oe,ct),fu=I("xdr_streaming","xdr_streaming",1,Oe,ct),gl=I("xhr_polling","xhr_polling",1,Oe),Ja=I("xdr_polling","xdr_polling",1,Oe),hu=new Xr([Bt],Ve),Ch=new Xr([Hi],Ve),Eh=new Xr([du],Ve),ml=new Xr([new Ni(ma(pl),pl,fu)],Ve),yl=new Xr([new Ni(ma(gl),gl,Ja)],Ve),Qa=new Xr([new Ni(ma(ml),new el([ml,new ga(yl,{delay:4e3})]),yl)],Ve),ba=new Ni(ma(Qa),Qa,Eh),bl;return b.useTLS?bl=new el([hu,new ga(ba,{delay:2e3})]):bl=new el([hu,new ga(Ch,{delay:2e3}),new ga(ba,{delay:5e3})]),new Pn(new Bn(new Ni(ma(Bt),bl,ba)),D,{ttl:18e5,timeline:b.timeline,useTLS:b.useTLS})},rl=nu,Va=(function(){var A=this;A.timeline.info(A.buildTimelineMessage({transport:A.name+(A.options.useTLS?"s":"")})),A.hooks.isInitialized()?A.changeState("initialized"):A.hooks.file?(A.changeState("initializing"),y.load(A.hooks.file,{useTLS:A.options.useTLS},function(b,_){A.hooks.isInitialized()?(A.changeState("initialized"),_(!0)):(b&&A.onError(b),A.onClose(),_(!1))})):A.onClose()}),ru={getRequest:function(A){var b=new window.XDomainRequest;return b.ontimeout=function(){A.emit("error",new L),A.close()},b.onerror=function(_){A.emit("error",_),A.close()},b.onprogress=function(){b.responseText&&b.responseText.length>0&&A.onChunk(200,b.responseText)},b.onload=function(){b.responseText&&b.responseText.length>0&&A.onChunk(200,b.responseText),A.emit("finished",200),A.close()},b},abortRequest:function(A){A.ontimeout=A.onerror=A.onprogress=A.onload=null,A.abort()}},au=ru;const Ka=256*1024;class sh extends J{constructor(b,_,D){super(),this.hooks=b,this.method=_,this.url=D}start(b){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},Fe.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(b)}close(){this.unloader&&(Fe.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(b,_){for(;;){var D=this.advanceBuffer(_);if(D)this.emit("chunk",{status:b,data:D});else break}this.isBufferTooLong(_)&&this.emit("buffer_too_long")}advanceBuffer(b){var _=b.slice(this.position),D=_.indexOf(` -`);return D!==-1?(this.position+=D+1,_.slice(0,D)):null}isBufferTooLong(b){return this.position===b.length&&b.length>Ka}}var Rs;(function(A){A[A.CONNECTING=0]="CONNECTING",A[A.OPEN=1]="OPEN",A[A.CLOSED=3]="CLOSED"})(Rs||(Rs={}));var Jr=Rs,al=1;class oh{constructor(b,_){this.hooks=b,this.session=Os(1e3)+"/"+Wa(8),this.location=lh(_),this.readyState=Jr.CONNECTING,this.openStream()}send(b){return this.sendRaw(JSON.stringify([b]))}ping(){this.hooks.sendHeartbeat(this)}close(b,_){this.onClose(b,_,!0)}sendRaw(b){if(this.readyState===Jr.OPEN)try{return Fe.createSocketRequest("POST",hr(Ds(this.location,this.session))).start(b),!0}catch{return!1}else return!1}reconnect(){this.closeStream(),this.openStream()}onClose(b,_,D){this.closeStream(),this.readyState=Jr.CLOSED,this.onclose&&this.onclose({code:b,reason:_,wasClean:D})}onChunk(b){if(b.status===200){this.readyState===Jr.OPEN&&this.onActivity();var _,D=b.data.slice(0,1);switch(D){case"o":_=JSON.parse(b.data.slice(1)||"{}"),this.onOpen(_);break;case"a":_=JSON.parse(b.data.slice(1)||"[]");for(var I=0;I<_.length;I++)this.onEvent(_[I]);break;case"m":_=JSON.parse(b.data.slice(1)||"null"),this.onEvent(_);break;case"h":this.hooks.onHeartbeat(this);break;case"c":_=JSON.parse(b.data.slice(1)||"[]"),this.onClose(_[0],_[1],!0);break}}}onOpen(b){this.readyState===Jr.CONNECTING?(b&&b.hostname&&(this.location.base=il(this.location.base,b.hostname)),this.readyState=Jr.OPEN,this.onopen&&this.onopen()):this.onClose(1006,"Server lost session",!0)}onEvent(b){this.readyState===Jr.OPEN&&this.onmessage&&this.onmessage({data:b})}onActivity(){this.onactivity&&this.onactivity()}onError(b){this.onerror&&this.onerror(b)}openStream(){this.stream=Fe.createSocketRequest("POST",hr(this.hooks.getReceiveURL(this.location,this.session))),this.stream.bind("chunk",b=>{this.onChunk(b)}),this.stream.bind("finished",b=>{this.hooks.onFinished(this,b)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(b){me.defer(()=>{this.onError(b),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}}function lh(A){var b=/([^\?]*)\/*(\??.*)/.exec(A);return{base:b[1],queryString:b[2]}}function Ds(A,b){return A.base+"/"+b+"/xhr_send"}function hr(A){var b=A.indexOf("?")===-1?"?":"&";return A+b+"t="+ +new Date+"&n="+al++}function il(A,b){var _=/(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(A);return _[1]+b+_[3]}function Os(A){return Fe.randomInt(A)}function Wa(A){for(var b=[],_=0;_0&&A.onChunk(_.status,_.responseText);break;case 4:_.responseText&&_.responseText.length>0&&A.onChunk(_.status,_.responseText),A.emit("finished",_.status),A.close();break}},_},abortRequest:function(A){A.onreadystatechange=null,A.abort()}},ol=Ir,ji={createStreamingSocket(A){return this.createSocket(sl,A)},createPollingSocket(A){return this.createSocket(Ii,A)},createSocket(A,b){return new Ya(A,b)},createXHR(A,b){return this.createRequest(ol,A,b)},createRequest(A,b,_){return new sh(A,b,_)}},jr=ji;jr.createXDR=function(A,b){return this.createRequest(au,A,b)};var ll=jr,Ls={nextAuthCallbackID:1,auth_callbacks:{},ScriptReceivers:c,DependenciesReceivers:m,getDefaultStrategy:rl,Transports:Mt,transportConnectionInitializer:Va,HTTPFactory:ll,TimelineTransport:fa,getXHRAPI(){return window.XMLHttpRequest},getWebSocketAPI(){return window.WebSocket||window.MozWebSocket},setup(A){window.Pusher=A;var b=()=>{this.onDocumentBody(A.ready)};window.JSON?b():y.load("json2",{},b)},getDocument(){return document},getProtocol(){return this.getDocument().location.protocol},getAuthorizers(){return{ajax:Ee,jsonp:In}},onDocumentBody(A){document.body?A():setTimeout(()=>{this.onDocumentBody(A)},0)},createJSONPRequest(A,b){return new Rn(A,b)},createScriptRequest(A){return new kn(A)},getLocalStorage(){try{return window.localStorage}catch{return}},createXHR(){return this.getXHRAPI()?this.createXMLHttpRequest():this.createMicrosoftXHR()},createXMLHttpRequest(){var A=this.getXHRAPI();return new A},createMicrosoftXHR(){return new ActiveXObject("Microsoft.XMLHTTP")},getNetwork(){return It},createWebSocket(A){var b=this.getWebSocketAPI();return new b(A)},createSocketRequest(A,b){if(this.isXHRSupported())return this.HTTPFactory.createXHR(A,b);if(this.isXDRSupported(b.indexOf("https:")===0))return this.HTTPFactory.createXDR(A,b);throw"Cross-origin HTTP requests are not supported"},isXHRSupported(){var A=this.getXHRAPI();return!!A&&new A().withCredentials!==void 0},isXDRSupported(A){var b=A?"https:":"http:",_=this.getProtocol();return!!window.XDomainRequest&&_===b},addUnloadListener(A){window.addEventListener!==void 0?window.addEventListener("unload",A,!1):window.attachEvent!==void 0&&window.attachEvent("onunload",A)},removeUnloadListener(A){window.addEventListener!==void 0?window.removeEventListener("unload",A,!1):window.detachEvent!==void 0&&window.detachEvent("onunload",A)},randomInt(A){return Math.floor(function(){return(window.crypto||window.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)}()*A)}},Fe=Ls,Xa;(function(A){A[A.ERROR=3]="ERROR",A[A.INFO=6]="INFO",A[A.DEBUG=7]="DEBUG"})(Xa||(Xa={}));var ya=Xa;class ou{constructor(b,_,D){this.key=b,this.session=_,this.events=[],this.options=D||{},this.sent=0,this.uniqueID=0}log(b,_){b<=this.options.level&&(this.events.push(ae({},_,{timestamp:me.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(b){this.log(ya.ERROR,b)}info(b){this.log(ya.INFO,b)}debug(b){this.log(ya.DEBUG,b)}isEmpty(){return this.events.length===0}send(b,_){var D=ae({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],b(D,(I,ie)=>{I||this.sent++,_&&_(I,ie)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class An{constructor(b,_,D,I){this.name=b,this.priority=_,this.transport=D,this.options=I||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(b,_){if(this.isSupported()){if(this.priority{D||(ct(),ie?ie.close():I.close())},forceMinPriority:Bt=>{D||this.priority{var _="socket_id="+encodeURIComponent(A.socketId);for(var D in b.params)_+="&"+encodeURIComponent(D)+"="+encodeURIComponent(b.params[D]);if(b.paramsProvider!=null){let I=b.paramsProvider();for(var D in I)_+="&"+encodeURIComponent(D)+"="+encodeURIComponent(I[D])}return _};var Ns=A=>{if(typeof Fe.getAuthorizers()[A.transport]>"u")throw`'${A.transport}' is not a recognized auth transport`;return(b,_)=>{const D=ul(b,A);Fe.getAuthorizers()[A.transport](Fe,D,A,x.UserAuthentication,_)}};const lu=(A,b)=>{var _="socket_id="+encodeURIComponent(A.socketId);_+="&channel_name="+encodeURIComponent(A.channelName);for(var D in b.params)_+="&"+encodeURIComponent(D)+"="+encodeURIComponent(b.params[D]);if(b.paramsProvider!=null){let I=b.paramsProvider();for(var D in I)_+="&"+encodeURIComponent(D)+"="+encodeURIComponent(I[D])}return _};var uh=A=>{if(typeof Fe.getAuthorizers()[A.transport]>"u")throw`'${A.transport}' is not a recognized auth transport`;return(b,_)=>{const D=lu(b,A);Fe.getAuthorizers()[A.transport](Fe,D,A,x.ChannelAuthorization,_)}};const dh=(A,b,_)=>{const D={authTransport:b.transport,authEndpoint:b.endpoint,auth:{params:b.params,headers:b.headers}};return(I,ie)=>{const ye=A.channel(I.channelName);_(ye,D).authorize(I.socketId,ie)}};function dl(A,b){let _={activityTimeout:A.activityTimeout||f.activityTimeout,cluster:A.cluster,httpPath:A.httpPath||f.httpPath,httpPort:A.httpPort||f.httpPort,httpsPort:A.httpsPort||f.httpsPort,pongTimeout:A.pongTimeout||f.pongTimeout,statsHost:A.statsHost||f.stats_host,unavailableTimeout:A.unavailableTimeout||f.unavailableTimeout,wsPath:A.wsPath||f.wsPath,wsPort:A.wsPort||f.wsPort,wssPort:A.wssPort||f.wssPort,enableStats:mh(A),httpHost:fh(A),useTLS:gh(A),wsHost:hh(A),userAuthenticator:cu(A),channelAuthorizer:bh(A,b)};return"disabledTransports"in A&&(_.disabledTransports=A.disabledTransports),"enabledTransports"in A&&(_.enabledTransports=A.enabledTransports),"ignoreNullOrigin"in A&&(_.ignoreNullOrigin=A.ignoreNullOrigin),"timelineParams"in A&&(_.timelineParams=A.timelineParams),"nacl"in A&&(_.nacl=A.nacl),_}function fh(A){return A.httpHost?A.httpHost:A.cluster?`sockjs-${A.cluster}.pusher.com`:f.httpHost}function hh(A){return A.wsHost?A.wsHost:ph(A.cluster)}function ph(A){return`ws-${A}.pusher.com`}function gh(A){return Fe.getProtocol()==="https:"?!0:A.forceTLS!==!1}function mh(A){return"enableStats"in A?A.enableStats:"disableStats"in A?!A.disableStats:!1}function cu(A){const b=Object.assign(Object.assign({},f.userAuthentication),A.userAuthentication);return"customHandler"in b&&b.customHandler!=null?b.customHandler:Ns(b)}function yh(A,b){let _;return"channelAuthorization"in A?_=Object.assign(Object.assign({},f.channelAuthorization),A.channelAuthorization):(_={transport:A.authTransport||f.authTransport,endpoint:A.authEndpoint||f.authEndpoint},"auth"in A&&("params"in A.auth&&(_.params=A.auth.params),"headers"in A.auth&&(_.headers=A.auth.headers)),"authorizer"in A&&(_.customHandler=dh(b,_,A.authorizer))),_}function bh(A,b){const _=yh(A,b);return"customHandler"in _&&_.customHandler!=null?_.customHandler:uh(_)}class vh extends J{constructor(b){super(function(_,D){St.debug(`No callbacks on watchlist events for ${_}`)}),this.pusher=b,this.bindWatchlistInternalEvent()}handleEvent(b){b.data.events.forEach(_=>{this.emit(_.name,_)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",b=>{var _=b.event;_==="pusher_internal:watchlist_events"&&this.handleEvent(b)})}}function Sh(){let A,b;return{promise:new Promise((D,I)=>{A=D,b=I}),resolve:A,reject:b}}var fl=Sh;class wh extends J{constructor(b){super(function(_,D){St.debug("No callbacks on user for "+_)}),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(_,D)=>{if(_){St.warn(`Error during signin: ${_}`),this._cleanup();return}this.pusher.send_event("pusher:signin",{auth:D.auth,user_data:D.user_data})},this.pusher=b,this.pusher.connection.bind("state_change",({previous:_,current:D})=>{_!=="connected"&&D==="connected"&&this._signin(),_==="connected"&&D!=="connected"&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new vh(b),this.pusher.connection.bind("message",_=>{var D=_.event;D==="pusher:signin_success"&&this._onSigninSuccess(_.data),this.serverToUserChannel&&this.serverToUserChannel.name===_.channel&&this.serverToUserChannel.handleEvent(_)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),this.pusher.connection.state==="connected"&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(b){try{this.user_data=JSON.parse(b.user_data)}catch{St.error(`Failed parsing user data after signin: ${b.user_data}`),this._cleanup();return}if(typeof this.user_data.id!="string"||this.user_data.id===""){St.error(`user_data doesn't contain an id. user_data: ${this.user_data}`),this._cleanup();return}this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){const b=_=>{_.subscriptionPending&&_.subscriptionCancelled?_.reinstateSubscription():!_.subscriptionPending&&this.pusher.connection.state==="connected"&&_.subscribe()};this.serverToUserChannel=new As(`#server-to-user-${this.user_data.id}`,this.pusher),this.serverToUserChannel.bind_global((_,D)=>{_.indexOf("pusher_internal:")===0||_.indexOf("pusher:")===0||this.emit(_,D)}),b(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested||this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:b,resolve:_}=fl();b.done=!1;const D=()=>{b.done=!0};b.then(D).catch(D),this.signinDonePromise=b,this._signinDoneResolve=_}}class sn{static ready(){sn.isReady=!0;for(var b=0,_=sn.instances.length;b<_;b++)sn.instances[b].connect()}static getClientFeatures(){return Ge(un({ws:Fe.Transports.ws},function(b){return b.isSupported({})}))}constructor(b,_){uu(b),cl(_),this.key=b,this.config=dl(_,this),this.channels=Mr.createChannels(),this.global_emitter=new J,this.sessionID=Fe.randomInt(1e9),this.timeline=new ou(this.key,this.sessionID,{cluster:this.config.cluster,features:sn.getClientFeatures(),params:this.config.timelineParams||{},limit:50,level:ya.INFO,version:f.VERSION}),this.config.enableStats&&(this.timelineSender=Mr.createTimelineSender(this.timeline,{host:this.config.statsHost,path:"/timeline/v2/"+Fe.TimelineTransport.name}));var D=I=>Fe.getDefaultStrategy(this.config,I,zi);this.connection=Mr.createConnectionManager(this.key,{getStrategy:D,timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:!!this.config.useTLS}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",I=>{var ie=I.event,ye=ie.indexOf("pusher_internal:")===0;if(I.channel){var Oe=this.channel(I.channel);Oe&&Oe.handleEvent(I)}ye||this.global_emitter.emit(I.event,I.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",I=>{St.warn(I)}),sn.instances.push(this),this.timeline.info({instances:sn.instances.length}),this.user=new wh(this),sn.isReady&&this.connect()}channel(b){return this.channels.find(b)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var b=this.connection.isUsingTLS(),_=this.timelineSender;this.timelineSenderTimer=new pe(6e4,function(){_.send(b)})}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(b,_,D){return this.global_emitter.bind(b,_,D),this}unbind(b,_,D){return this.global_emitter.unbind(b,_,D),this}bind_global(b){return this.global_emitter.bind_global(b),this}unbind_global(b){return this.global_emitter.unbind_global(b),this}unbind_all(b){return this.global_emitter.unbind_all(),this}subscribeAll(){var b;for(b in this.channels.channels)this.channels.channels.hasOwnProperty(b)&&this.subscribe(b)}subscribe(b){var _=this.channels.add(b,this);return _.subscriptionPending&&_.subscriptionCancelled?_.reinstateSubscription():!_.subscriptionPending&&this.connection.state==="connected"&&_.subscribe(),_}unsubscribe(b){var _=this.channels.find(b);_&&_.subscriptionPending?_.cancelSubscription():(_=this.channels.remove(b),_&&_.subscribed&&_.unsubscribe())}send_event(b,_,D){return this.connection.send_event(b,_,D)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}sn.instances=[],sn.isReady=!1,sn.logToConsole=!1,sn.Runtime=Fe,sn.ScriptReceivers=Fe.ScriptReceivers,sn.DependenciesReceivers=Fe.DependenciesReceivers,sn.auth_callbacks=Fe.auth_callbacks;var hl=r.default=sn;function uu(A){if(A==null)throw"You must pass your app key when you instantiate Pusher."}Fe.setup(sn)})])})})(Xf)),Xf.exports}var OA=DA();const Xy=aa(OA),zt=dt("WebSocketManager");class LA{constructor(){$(this,"echo",null);$(this,"subscriptions",new Map);$(this,"initialized",!1);$(this,"config",null)}configure(e){if(this.initialized){zt.warn("[WebSocketManager] 이미 초기화되어 설정을 변경할 수 없습니다.");return}this.config=e,zt.log("[WebSocketManager] 설정 완료:",{appKey:e.appKey?"***":"(없음)",host:e.host,port:e.port,scheme:e.scheme})}initialize(){if(this.initialized)return;if(!this.config||!this.config.appKey){zt.warn("[WebSocketManager] WebSocket 설정이 없습니다. initTemplateApp에서 websocket 옵션을 전달해주세요.");return}const{appKey:e,host:n="localhost",port:r=80,scheme:i="https",authEndpoint:l="/api/broadcasting/auth"}=this.config,c=Number(r)||80,d=i==="https";zt.log("[WebSocketManager] 연결 설정:",{host:n,port:c,scheme:i,useTLS:d,authEndpoint:l}),window.Pusher=Xy;const f=localStorage.getItem("auth_token"),p={wsHost:n,wsPort:c,wssPort:c,forceTLS:d,disableStats:!0,enabledTransports:["ws","wss"],cluster:"mt1",authEndpoint:l,auth:{headers:{Authorization:f?`Bearer ${f}`:"",Accept:"application/json"}}};zt.log("[WebSocketManager] Pusher 옵션:",p);const m=new Xy(e,p);m.connection.bind("connecting",()=>{zt.log("[WebSocketManager] 연결 시도 중...")}),m.connection.bind("connected",()=>{zt.log("[WebSocketManager] 연결 성공! Socket ID:",m.connection.socket_id)}),m.connection.bind("failed",()=>{zt.error("[WebSocketManager] 연결 실패 - WebSocket을 사용할 수 없습니다.")}),m.connection.bind("error",y=>{zt.error("[WebSocketManager] 연결 오류:",y)}),m.connection.bind("state_change",y=>{zt.log(`[WebSocketManager] 상태 변경: ${y.previous} → ${y.current}`)}),m.connection.bind("unavailable",()=>{zt.error("[WebSocketManager] WebSocket 사용 불가 - 연결할 수 없습니다.")}),m.connection.bind("disconnected",()=>{zt.warn("[WebSocketManager] 연결이 끊어졌습니다.")}),zt.log("[WebSocketManager] 초기 연결 상태:",m.connection.state),this.echo=new RA({broadcaster:"reverb",client:m}),zt.log("[WebSocketManager] 연결 시작 시도..."),m.connect(),window.Echo=this.echo,this.initialized=!0,zt.log("[WebSocketManager] Echo 초기화 완료")}subscribe(e,n,r,i={}){if(this.initialize(),!this.echo)return zt.warn("[WebSocketManager] Echo가 초기화되지 않았습니다."),"";const{channelType:l="private"}=i,c=`${e}:${n}`;if(this.subscriptions.has(c))return zt.log(`[WebSocketManager] 이미 구독 중: ${c}`),c;let d;switch(l){case"public":d=this.echo.channel(e);break;case"presence":d=this.echo.join(e);break;default:d=this.echo.private(e)}return d.listen(`.${n}`,r),this.subscriptions.set(c,d),zt.log(`[WebSocketManager] 구독 완료: ${c} (${l})`),c}unsubscribe(e){const n=this.subscriptions.get(e);if(!n)return;const r=e.lastIndexOf(":"),i=r>=0?e.substring(r+1):"";if(i)try{n.stopListening(`.${i}`)}catch(l){zt.warn(`[WebSocketManager] stopListening 실패: ${e}`,l)}this.subscriptions.delete(e),zt.log(`[WebSocketManager] 구독 해제: ${e}`)}leaveChannel(e){if(!this.echo)return;this.echo.leave(e);const n=[];this.subscriptions.forEach((r,i)=>{i.startsWith(`${e}:`)&&n.push(i)}),n.forEach(r=>this.subscriptions.delete(r)),zt.log(`[WebSocketManager] 채널 구독 해제: ${e}`)}disconnect(){this.echo&&(this.echo.disconnect(),this.subscriptions.clear(),this.initialized=!1,zt.log("[WebSocketManager] 연결 종료"))}getEcho(){return this.echo}isInitialized(){return this.initialized}isConfigured(){return this.config!==null&&!!this.config.appKey}getSubscriptionCount(){return this.subscriptions.size}}const Vc=new LA,gt=dt("DataSourceManager"),Jy=new Tn;function Kc(s,e){const n=Ma(s);if(n!==null)try{return On(n)?Jy.evaluatePipeExpression(n,e,{skipCache:!0}):Jy.evaluateExpression(n,e)}catch(r){return gt.error("Failed to evaluate param expression:",n,r),s}return ls(s,e,{skipCache:!0})}function Qy(s){const e={};for(const n of s.keys()){if(n in e)continue;const r=s.getAll(n);r.length>1?e[n]=r:r.length===1&&(n.endsWith("[]")?e[n]=r:e[n]=r[0])}return e}function $A(){try{return window.G7Core?.devTools}catch{return}}const Zc=class Zc{constructor(e={}){$(this,"options");$(this,"dataCache",new Map);$(this,"bindingEngine");$(this,"globalHeaders",[]);this.options=e,this.bindingEngine=new Tn}setGlobalHeaders(e){this.globalHeaders=e||[]}matchesPattern(e,n){if(n==="*")return!0;const r=n.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${r}$`).test(e)}toFormData(e){const n=new FormData;for(const[r,i]of Object.entries(e))i instanceof File||i instanceof Blob?n.append(r,i):i!=null&&n.append(r,typeof i=="object"?JSON.stringify(i):String(i));return n}getMatchingGlobalHeaders(e,n){const r={};for(const i of this.globalHeaders)this.matchesPattern(e,i.pattern)&&Object.entries(i.headers).forEach(([l,c])=>{const d=Kc(c,n);d!=null&&d!==""&&(r[l]=String(d))});return r}filterByCondition(e,n={}){const r=new Set,i=[];for(const l of e){if(r.has(l.id))continue;if(!l.if&&!l.conditions){r.add(l.id),i.push(l);continue}os({if:l.if,conditions:l.conditions},n,this.bindingEngine,`data_source:${l.id}`)&&(r.add(l.id),i.push(l))}return i}checkErrorCondition(e,n){if(!e.errorCondition?.if||e.errorCondition?.errorCode===void 0)return null;try{const r={response:n};if(os({if:e.errorCondition.if},r,this.bindingEngine,`errorCondition:${e.id}`))return gt.log(`errorCondition matched for ${e.id}, triggering error ${e.errorCondition.errorCode}`),e.errorCondition.errorCode}catch(r){gt.error(`Failed to evaluate errorCondition for ${e.id}:`,r)}return null}async fetchDataSources(e,n={},r=new URLSearchParams,i,l){const c={},d=!!this.options.sampleProvider,f=e.filter(p=>(d||p.auto_fetch!==!1)&&p.type!=="websocket");return await Promise.all(f.map(async p=>{try{const m=await this.fetchDataSource(p,n,r,i,l);c[p.id]=m,this.dataCache.set(p.id,{data:m,timestamp:Date.now()});const y=this.checkErrorCondition(p,m);if(y!==null){const C={status:y,message:`Error condition matched for ${p.id}`,data:m},S=Tr(),v=S.resolve(y,{errorHandling:p.errorHandling,onError:p.onError});if(v.handler)try{await S.execute(v.handler,C)}catch(x){gt.error(`Error executing errorCondition handler for ${p.id}:`,x)}p.fallback!==void 0&&(c[p.id]=p.fallback,this.dataCache.set(p.id,{data:p.fallback,timestamp:Date.now()}),gt.log(`Using fallback data for ${p.id} (errorCondition)`));return}if(p.onSuccess)try{const C={data:m,sourceId:p.id};await this.executeOnSuccessHandler(p.onSuccess,C)}catch(C){gt.error(`Error executing onSuccess handler for ${p.id}:`,C)}}catch(m){gt.error(`Failed to fetch data source: ${p.id}`,m);const y=m?.response?.status||m?.status||500,C=m?.response?.data,S=C?.message||m.message||"Unknown error",v={status:y,message:S,errors:C?.errors,data:C,statusText:m?.response?.statusText},x=Tr(),w=x.resolve(y,{errorHandling:p.errorHandling,onError:p.onError});if(w.handler)try{await x.execute(w.handler,v)}catch(R){gt.error(`Error executing error handler for ${p.id}:`,R)}p.fallback!==void 0&&(c[p.id]=p.fallback,this.dataCache.set(p.id,{data:p.fallback,timestamp:Date.now()}),gt.log(`Using fallback data for ${p.id}`)),this.options.onError&&this.options.onError(m,p)}})),c}async fetchDataSourcesWithResults(e,n={},r=new URLSearchParams,i,l,c){if(e.some(m=>m.type==="websocket")){const m=e.filter(y=>y.type==="websocket").map(y=>y.id).join(", ");gt.warn(`fetchDataSourcesWithResults received WebSocket sources (caller should filter them out before calling): ${m}. WebSocket sources are event listeners, not data providers — they should not be passed to fetch.`)}const f=c?.ignoreAutoFetch?e.filter(m=>m.type!=="websocket"):e.filter(m=>m.auto_fetch!==!1&&m.type!=="websocket");return await Promise.all(f.map(async m=>{try{const y=await this.fetchDataSource(m,n,r,i,l);this.dataCache.set(m.id,{data:y,timestamp:Date.now()});const C=this.checkErrorCondition(m,y);if(C!==null){const S={status:C,message:`Error condition matched for ${m.id}`,data:y},v=Tr(),x=v.resolve(C,{errorHandling:m.errorHandling,onError:m.onError});let w=!1;if(x.handler)if(m.loading_strategy==="blocking")v.execute(x.handler,S).catch(R=>{gt.error(`Error executing errorCondition handler for ${m.id}:`,R)}),w=!0;else try{await v.execute(x.handler,S),w=!0}catch(R){gt.error(`Error executing errorCondition handler for ${m.id}:`,R)}return m.fallback!==void 0?(this.dataCache.set(m.id,{data:m.fallback,timestamp:Date.now()}),gt.log(`Using fallback data for ${m.id} (errorCondition)`),{id:m.id,state:"success",data:m.fallback}):{id:m.id,state:"error",error:new Error(`Error condition matched: ${C}`),errorCode:C,errorHandled:w}}if(m.onSuccess)try{const S={data:y,sourceId:m.id};await this.executeOnSuccessHandler(m.onSuccess,S)}catch(S){gt.error(`Error executing onSuccess handler for ${m.id}:`,S)}return{id:m.id,state:"success",data:y}}catch(y){gt.error(`Failed to fetch data source: ${m.id}`,y);const C=y?.response?.status||y?.status||500,S=y?.response?.data,v=S?.message||y.message||"Unknown error",x={status:C,message:v,errors:S?.errors,data:S,statusText:y?.response?.statusText},w=Tr(),R=w.resolve(C,{errorHandling:m.errorHandling,onError:m.onError});let L=!1;if(R.handler)if(m.loading_strategy==="blocking")w.execute(R.handler,x).catch(O=>{gt.error(`Error executing error handler for ${m.id}:`,O)}),L=!0;else try{await w.execute(R.handler,x),L=!0}catch(O){gt.error(`Error executing error handler for ${m.id}:`,O)}return m.fallback!==void 0?(this.dataCache.set(m.id,{data:m.fallback,timestamp:Date.now()}),gt.log(`Using fallback data for ${m.id}`),{id:m.id,state:"success",data:m.fallback}):(this.options.onError&&this.options.onError(y,m),{id:m.id,state:"error",error:y,errorCode:C,errorHandled:L})}}))}fetchDataSourcesInBackground(e,n={},r=new URLSearchParams,i){e.filter(c=>c.auto_fetch!==!1&&c.loading_strategy==="background"&&c.type!=="websocket").forEach(c=>{this.fetchDataSource(c,n,r).then(async d=>{this.dataCache.set(c.id,{data:d,timestamp:Date.now()});const f=this.checkErrorCondition(c,d);if(f!==null){const p={status:f,message:`Error condition matched for ${c.id}`,data:d},m=Tr(),y=m.resolve(f,{errorHandling:c.errorHandling,onError:c.onError});if(y.handler)try{await m.execute(y.handler,p)}catch(C){gt.error(`Error executing errorCondition handler for ${c.id}:`,C)}c.fallback!==void 0&&(this.dataCache.set(c.id,{data:c.fallback,timestamp:Date.now()}),gt.log(`Using fallback data for ${c.id} (errorCondition)`),i&&i(c.id,c.fallback));return}if(c.onSuccess)try{const p={data:d,sourceId:c.id};await this.executeOnSuccessHandler(c.onSuccess,p)}catch(p){gt.error(`Error executing onSuccess handler for ${c.id}:`,p)}i&&i(c.id,d)}).catch(async d=>{gt.error(`Background fetch failed: ${c.id}`,d);const f=d?.response?.status||d?.status||500,p=d?.response?.data,m=p?.message||d.message||"Unknown error",y={status:f,message:m,errors:p?.errors,data:p,statusText:d?.response?.statusText},C=Tr(),S=C.resolve(f,{errorHandling:c.errorHandling,onError:c.onError});if(S.handler)try{await C.execute(S.handler,y)}catch(v){gt.error(`Error executing error handler for ${c.id}:`,v)}if(c.fallback!==void 0){this.dataCache.set(c.id,{data:c.fallback,timestamp:Date.now()}),gt.log(`Using fallback data for ${c.id}`),i&&i(c.id,c.fallback);return}this.options.onError&&this.options.onError(d,c)})})}async fetchDataSource(e,n,r,i,l){switch(e.type){case"api":return this.fetchApiDataSource(e,n,r,i,l);case"static":return e.data;case"route_params":return n;case"query_params":return Qy(r);default:throw new Error(`Unknown data source type: ${e.type}`)}}async fetchApiDataSource(e,n,r,i,l){if(this.options.sampleProvider?.has(e.id))return await Promise.resolve(this.options.sampleProvider.resolve(e));if(!e.endpoint)throw new Error(`API data source ${e.id} has no endpoint`);const c={route:n,query:Qy(r)};i&&(c._global=i),l&&(c._local=l);let d=ls(e.endpoint,c,{skipCache:!0});const f=e.method||"GET",m=(e.contentType?typeof e.contentType=="string"&&e.contentType.includes("{{")?ls(e.contentType,c,{skipCache:!0}):e.contentType:"application/json")==="multipart/form-data";let y=m?{...e.params||{}}:JSON.parse(JSON.stringify(e.params||{}));Object.entries(y).forEach(([v,x])=>{typeof x=="string"&&(y[v]=Kc(x,c))}),Object.keys(y).forEach(v=>{y[v]===""&&delete y[v]});const C=$A();let S=null;if(C?.isEnabled()){C.trackDataSourceDefinition({id:e.id,type:e.type,endpoint:d,method:f,autoFetch:e.auto_fetch,initLocal:e.initLocal,initGlobal:e.initGlobal});let v=d;if(f==="GET"&&Object.keys(y).length>0){const x=new URLSearchParams;Object.entries(y).forEach(([R,L])=>{Array.isArray(L)?L.forEach(O=>x.append(R,String(O))):L!=null&&x.append(R,String(L))});const w=x.toString();v=w?`${d}?${w}`:d}S=C.trackRequest(v,f,{requestBody:f!=="GET"?y:void 0,dataSourceId:e.id}),C.trackDataSourceLoading(e.id)}try{let v;const x=e.auth_mode??(e.auth_required===!0?"required":"none"),w=Yn.getInstance().isAuthenticated();if(x==="required"&&!w){gt.log(`[DataSourceManager] Skipping ${e.id}: auth_mode is 'required' but no token available`),C?.isEnabled()&&(C.trackDataSourceError(e.id,"Skipped: auth_mode required but not authenticated"),S&&C.failRequest(S,"Skipped: not authenticated"));const L=new Error("Auth required but not authenticated");throw L.response={status:401,statusText:"Unauthorized",data:null},L.status=401,L._authSkipped=!0,L}const R=x==="required"||x==="optional"&&w;if(R){const L=Wn(),O=d.startsWith("/api/")?d.substring(4):d.startsWith("/api")?d.substring(4)||"/":d;this.options.onError&>.log(`[DataSourceManager] Normalized endpoint: ${d} -> ${O}`);const j=this.getMatchingGlobalHeaders(d,c),F={};e.headers&&Object.entries(e.headers).forEach(([he,Ee])=>{const ke=Kc(Ee,c);ke!=null&&ke!==""&&(F[he]=String(ke))});const G={...j,...F},P=Object.keys(G).length>0,K=m?this.toFormData(y):y;switch(f){case"GET":v=await L.get(O,{params:y,...P&&{headers:G}});break;case"POST":P?v=await L.post(O,K,{headers:G}):v=await L.post(O,K);break;case"PUT":P?v=await L.put(O,K,{headers:G}):v=await L.put(O,K);break;case"PATCH":P?v=await L.patch(O,K,{headers:G}):v=await L.patch(O,K);break;case"DELETE":v=await L.delete(O,{params:y,...P&&{headers:G}});break;default:throw new Error(`Unsupported HTTP method: ${f}`)}}else{let L=d;if(f==="GET"){const K=new URLSearchParams(y).toString();L=K?`${d}?${K}`:d}const O={...m?{}:{"Content-Type":"application/json"},Accept:"application/json"};if(typeof window<"u"){const K=localStorage.getItem("g7_locale");K&&(O["Accept-Language"]=K)}const j=this.getMatchingGlobalHeaders(d,c);Object.assign(O,j),e.headers&&Object.entries(e.headers).forEach(([K,he])=>{const Ee=Kc(he,c);Ee!=null&&Ee!==""&&(O[K]=String(Ee))});let F;f!=="GET"&&(m?(F=this.toFormData(y),delete O["Content-Type"]):F=JSON.stringify(y));const G=await fetch(L,{method:f,headers:O,body:F});let P;try{P=await G.json()}catch{P=null}if(S&&C?.isEnabled()&&(C.completeRequest(S,G.status,P),S=null),!G.ok){C?.isEnabled()&&C.trackDataSourceError(e.id,`HTTP ${G.status}: ${G.statusText}`);const K=new Error(`HTTP error! status: ${G.status}`);throw K.response={status:G.status,statusText:G.statusText,data:P},K.status=G.status,K}v=P,C?.isEnabled()&&C.trackDataSourceLoaded(e.id,v)}return R&&S&&C?.isEnabled()&&(C.completeRequest(S,200,v),C.trackDataSourceLoaded(e.id,v)),v}catch(v){if(S&&C?.isEnabled()){const x=v;x?.response?C.completeRequest(S,x.response.status,x.response.data):C.failRequest(S,v instanceof Error?v.message:String(v)),C.trackDataSourceError(e.id,v instanceof Error?v.message:String(v))}throw v}}getCachedData(e){const n=this.dataCache.get(e);if(!n)return;if(Date.now()-n.timestamp>Zc.DATA_CACHE_TTL){this.dataCache.delete(e);return}return n.data}clearCache(){this.dataCache.clear()}subscribeWebSockets(e,n,r={}){const i=[],l=e.filter(c=>c.type==="websocket");return l.length===0||l.forEach(c=>{if(!c.channel||!c.event){gt.warn(`WebSocket source ${c.id} missing channel or event`);return}let d,f;try{d=ls(c.channel,r,{skipCache:!0}),f=ls(c.event,r,{skipCache:!0})}catch(y){gt.error(`Failed to resolve WebSocket channel/event for source ${c.id}:`,y);return}const p=y=>!!(!y||y.trim()===""||y.includes("{{")||y.endsWith(".")||y.endsWith(":")||y.startsWith(".")||y.startsWith(":")||y.includes("..")||y.includes("::"));if(p(d)||p(f)){gt.warn(`WebSocket source ${c.id} has invalid channel/event after expression resolution, skipping. Original channel="${c.channel}", resolved="${d}". Original event="${c.event}", resolved="${f}". Available context keys: [${Object.keys(r).join(", ")}]`);return}const m=Vc.subscribe(d,f,y=>{const C=c.target_source||c.id;this.dataCache.set(C,{data:y,timestamp:Date.now()}),n(C,y)},{channelType:c.channel_type||"private"});m&&i.push(m)}),i}unsubscribeWebSockets(e){e.length!==0&&e.forEach(n=>{Vc.unsubscribe(n)})}async executeOnSuccessHandler(e,n){const r=this.options.actionDispatcher??Wm();if(!r){gt.warn("ActionDispatcher not available, skipping onSuccess handler");return}const i=Array.isArray(e)?e:[e];for(const l of i)try{await r.dispatchAction({type:"click",...l},{data:{response:n}})}catch(c){throw gt.error("Failed to execute onSuccess handler:",c),c}}};$(Zc,"DATA_CACHE_TTL",3e5);let Dr=Zc;const MA=new Dr,Ri=dt("ModalDataSourceWrapper");function NA(s,e){if(!s||!e)return s;const r=e.replace(/\?\./g,".").split(/\.(?![^\[]*\])/).flatMap(l=>{const c=l.match(/^([^\[]*)((?:\[\d+\])*)$/);if(c){const[,d,f]=c,p=[];d&&p.push(d);const m=f.match(/\[\d+\]/g);return m&&p.push(...m),p}return[l]}).filter(l=>l!=="");let i=s;for(const l of r){if(i==null)return;if(l.startsWith("[")&&l.endsWith("]")){const c=parseInt(l.slice(1,-1),10);i=i[c]}else i=i[l]}return i}const Zy=({isOpen:s,modalId:e,dataSources:n,dataContext:r,globalStateUpdater:i,bindingEngine:l,debug:c=!1,children:d})=>{const[f,p]=M.useState(!1),[m,y]=M.useState(!1),C=M.useRef(!1),S=M.useRef(null);S.current||(S.current=new Dr);const v=M.useCallback(async()=>{if(!(!n||n.length===0)&&S.current){p(!0);try{const x=r.route||{},w=new URLSearchParams(window.location.search),R=n.map(O=>{let j={...O};if(O.endpoint&&l){const F=l.resolveBindings(O.endpoint,r,{skipCache:!0});j.endpoint=F}if(O.params&&l){const F={};Object.entries(O.params).forEach(([G,P])=>{typeof P=="string"?F[G]=l.resolveBindings(P,r,{skipCache:!0}):F[G]=P}),j.params=F}return j});c&&Ri.log(`[ModalDataSourceWrapper] Modal "${e}" fetching data sources:`,R.map(O=>({id:O.id,endpoint:O.endpoint})));const L=await S.current.fetchDataSourcesWithResults(R,x,w);i&&L.forEach(O=>{if(O.state==="success"&&O.data!==void 0){const j=R.find(F=>F.id===O.id);if(j?.initGlobal){const F=O.data?.data??O.data,G=Array.isArray(j.initGlobal)?j.initGlobal:[j.initGlobal];for(const P of G)if(typeof P=="string")i({[P]:F}),c&&Ri.log(`[ModalDataSourceWrapper] Modal "${e}" initGlobal: ${O.id}.data -> _global.${P}`);else if(typeof P=="object"&&P.key){const{key:K,path:he}=P,Ee=he?NA(F,he):F;i({[K]:Ee}),c&&Ri.log(`Modal "${e}" initGlobal: ${O.id}.data${he?"."+he:""} -> _global.${K}`)}}}else O.state==="error"&&Ri.error(`Modal "${e}" data source error:`,O.id,O.error)}),c&&Ri.log(`Modal "${e}" data sources fetched successfully`)}catch(x){Ri.error(`Modal "${e}" data source fetch error:`,x)}finally{p(!1),y(!0)}}},[n,r,i,l,e,c]);return M.useEffect(()=>{if(!n||n.length===0)return;const x=window.__templateApp;return x?.registerModalDataSources&&x.registerModalDataSources(e,n),()=>{x?.unregisterModalDataSources&&x.unregisterModalDataSources(e)}},[e,n]),M.useEffect(()=>{!s&&C.current&&(y(!1),c&&Ri.log(`[ModalDataSourceWrapper] Modal "${e}" closed, reset fetch state`)),s&&!C.current&&n&&n.length>0&&!m&&v(),C.current=s},[s,n,m,v,e,c]),ft.jsx(ft.Fragment,{children:d})};class Wc extends Error{constructor(n,r,i={}){super(r);$(this,"code");$(this,"userMessageKey");$(this,"showStack");$(this,"icon");$(this,"recoverable");this.name="TemplateEngineError",this.code=n,this.userMessageKey=r,this.showStack=i.showStack??!0,this.icon=i.icon??"fa-circle-exclamation",this.recoverable=i.recoverable??!0,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}getUserMessage(n,r){if(!r||!n)return this.userMessageKey;try{return r.translate(this.userMessageKey,n)}catch{return this.userMessageKey}}}class IA extends Wc{constructor(){super("TEMPLATE_NOT_FOUND","$t:core.errors.template_not_found",{showStack:!1,icon:"fa-paint-brush",recoverable:!1}),this.name="TemplateNotFoundError"}}function eb(s){if(s instanceof Wc)return s;if(s instanceof Error){const e=new Wc("TEMPLATE_INIT_ERROR",s.message||"$t:core.errors.template_init_error",{showStack:!0,icon:"fa-circle-exclamation",recoverable:!0});return e.stack=s.stack,e}return new Wc("TEMPLATE_INIT_ERROR","$t:core.errors.template_init_error",{showStack:!1,icon:"fa-circle-exclamation",recoverable:!0})}const jA=dt("ErrorDisplay");class Jf{static render(e,n){const r=document.getElementById(e);if(!r){jA.error(`Container #${e} not found`);return}const i=n.debug&&n.showStack&&n.stackTrace,l=window.matchMedia("(prefers-color-scheme: dark)").matches,c={container:` + */var Eb;function zx(){return Eb||(Eb=1,(function(s,e){(function(r,i){s.exports=i()})(self,()=>(()=>{var n={594(c,d){var f=this&&this.__extends||(function(){var O=function(k,L){return O=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(B,q){B.__proto__=q}||function(B,q){for(var z in q)q.hasOwnProperty(z)&&(B[z]=q[z])},O(k,L)};return function(k,L){O(k,L);function B(){this.constructor=k}k.prototype=L===null?Object.create(L):(B.prototype=L.prototype,new B)}})();Object.defineProperty(d,"__esModule",{value:!0});var h=256,m=(function(){function O(k){k===void 0&&(k="="),this._paddingCharacter=k}return O.prototype.encodedLength=function(k){return this._paddingCharacter?(k+2)/3*4|0:(k*8+5)/6|0},O.prototype.encode=function(k){for(var L="",B=0;B>>18&63),L+=this._encodeByte(q>>>12&63),L+=this._encodeByte(q>>>6&63),L+=this._encodeByte(q>>>0&63)}var z=k.length-B;if(z>0){var q=k[B]<<16|(z===2?k[B+1]<<8:0);L+=this._encodeByte(q>>>18&63),L+=this._encodeByte(q>>>12&63),z===2?L+=this._encodeByte(q>>>6&63):L+=this._paddingCharacter||"",L+=this._paddingCharacter||""}return L},O.prototype.maxDecodedLength=function(k){return this._paddingCharacter?k/4*3|0:(k*6+7)/8|0},O.prototype.decodedLength=function(k){return this.maxDecodedLength(k.length-this._getPaddingLength(k))},O.prototype.decode=function(k){if(k.length===0)return new Uint8Array(0);for(var L=this._getPaddingLength(k),B=k.length-L,q=new Uint8Array(this.maxDecodedLength(B)),z=0,W=0,de=0,_e=0,Se=0,je=0,Fe=0;W>>4,q[z++]=Se<<4|je>>>2,q[z++]=je<<6|Fe,de|=_e&h,de|=Se&h,de|=je&h,de|=Fe&h;if(W>>4,de|=_e&h,de|=Se&h),W>>2,de|=je&h),W>>8&6,L+=51-k>>>8&-75,L+=61-k>>>8&-15,L+=62-k>>>8&3,String.fromCharCode(L)},O.prototype._decodeChar=function(k){var L=h;return L+=(42-k&k-44)>>>8&-h+k-43+62,L+=(46-k&k-48)>>>8&-h+k-47+63,L+=(47-k&k-58)>>>8&-h+k-48+52,L+=(64-k&k-91)>>>8&-h+k-65+0,L+=(96-k&k-123)>>>8&-h+k-97+26,L},O.prototype._getPaddingLength=function(k){var L=0;if(this._paddingCharacter){for(var B=k.length-1;B>=0&&k[B]===this._paddingCharacter;B--)L++;if(k.length<4||L>2)throw new Error("Base64Coder: incorrect padding")}return L},O})();d.Coder=m;var y=new m;function v(O){return y.encode(O)}d.encode=v;function S(O){return y.decode(O)}d.decode=S;var _=(function(O){f(k,O);function k(){return O!==null&&O.apply(this,arguments)||this}return k.prototype._encodeByte=function(L){var B=L;return B+=65,B+=25-L>>>8&6,B+=51-L>>>8&-75,B+=61-L>>>8&-13,B+=62-L>>>8&49,String.fromCharCode(B)},k.prototype._decodeChar=function(L){var B=h;return B+=(44-L&L-46)>>>8&-h+L-45+62,B+=(94-L&L-96)>>>8&-h+L-95+63,B+=(47-L&L-58)>>>8&-h+L-48+52,B+=(64-L&L-91)>>>8&-h+L-65+0,B+=(96-L&L-123)>>>8&-h+L-97+26,B},k})(m);d.URLSafeCoder=_;var x=new _;function A(O){return x.encode(O)}d.encodeURLSafe=A;function D(O){return x.decode(O)}d.decodeURLSafe=D,d.encodedLength=function(O){return y.encodedLength(O)},d.maxDecodedLength=function(O){return y.maxDecodedLength(O)},d.decodedLength=function(O){return y.decodedLength(O)}},978(c,d){var f="utf8: invalid source encoding";function h(m){for(var y=[],v=0;v=m.length)throw new Error(f);var x=m[++v];if((x&192)!==128)throw new Error(f);S=(S&31)<<6|x&63,_=128}else if(S<240){if(v>=m.length-1)throw new Error(f);var x=m[++v],A=m[++v];if((x&192)!==128||(A&192)!==128)throw new Error(f);S=(S&15)<<12|(x&63)<<6|A&63,_=2048}else if(S<248){if(v>=m.length-2)throw new Error(f);var x=m[++v],A=m[++v],D=m[++v];if((x&192)!==128||(A&192)!==128||(D&192)!==128)throw new Error(f);S=(S&15)<<18|(x&63)<<12|(A&63)<<6|D&63,_=65536}else throw new Error(f);if(S<_||S>=55296&&S<=57343)throw new Error(f);if(S>=65536){if(S>1114111)throw new Error(f);S-=65536,y.push(String.fromCharCode(55296|S>>10)),S=56320|S&1023}}y.push(String.fromCharCode(S))}return y.join("")}d.D4=h},721(c,d,f){c.exports=f(207).default},207(c,d,f){f.d(d,{default:()=>Is});class h{constructor(b,C){this.lastId=0,this.prefix=b,this.name=C}create(b){this.lastId++;var C=this.lastId,$=this.prefix+C,j=this.name+"["+C+"]",ne=!1,ye=function(){ne||(b.apply(null,arguments),ne=!0)};return this[C]=ye,{number:C,id:$,name:j,callback:ye}}remove(b){delete this[b.number]}}var m=new h("_pusher_script_","Pusher.ScriptReceivers"),y={VERSION:"8.5.0",PROTOCOL:7,wsPort:80,wssPort:443,wsPath:"",httpHost:"sockjs.pusher.com",httpPort:80,httpsPort:443,httpPath:"/pusher",stats_host:"stats.pusher.com",authEndpoint:"/pusher/auth",authTransport:"ajax",activityTimeout:12e4,pongTimeout:3e4,unavailableTimeout:1e4,userAuthentication:{endpoint:"/pusher/user-auth",transport:"ajax"},channelAuthorization:{endpoint:"/pusher/auth",transport:"ajax"},cdn_http:"http://js.pusher.com",cdn_https:"https://js.pusher.com",dependency_suffix:""};const v=y;class S{constructor(b){this.options=b,this.receivers=b.receivers||m,this.loading={}}load(b,C,$){var j=this;if(j.loading[b]&&j.loading[b].length>0)j.loading[b].push($);else{j.loading[b]=[$];var ne=Ue.createScriptRequest(j.getPath(b,C)),ye=j.receivers.create(function(Le){if(j.receivers.remove(ye),j.loading[b]){var We=j.loading[b];delete j.loading[b];for(var ft=function(Vt){Vt||ne.cleanup()},vt=0;vt>>6)+Q(128|b&63):Q(224|b>>>12&15)+Q(128|b>>>6&63)+Q(128|b&63)},ee=function(E){return E.replace(/[^\x00-\x7F]/g,De)},me=function(E){var b=[0,2,1][E.length%3],C=E.charCodeAt(0)<<16|(E.length>1?E.charCodeAt(1):0)<<8|(E.length>2?E.charCodeAt(2):0),$=[ue.charAt(C>>>18),ue.charAt(C>>>12&63),b>=2?"=":ue.charAt(C>>>6&63),b>=1?"=":ue.charAt(C&63)];return $.join("")},H=window.btoa||function(E){return E.replace(/[\s\S]{1,3}/g,me)};class T{constructor(b,C,$,j){this.clear=C,this.timer=b(()=>{this.timer&&(this.timer=j(this.timer))},$)}isRunning(){return this.timer!==null}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}}const fe=T;function he(E){window.clearTimeout(E)}function Ae(E){window.clearInterval(E)}class se extends fe{constructor(b,C){super(setTimeout,he,b,function($){return C(),null})}}class ge extends fe{constructor(b,C){super(setInterval,Ae,b,function($){return C(),$})}}var $e={now(){return Date.now?Date.now():new Date().valueOf()},defer(E){return new se(0,E)},method(E,...b){var C=Array.prototype.slice.call(arguments,1);return function($){return $[E].apply($,C.concat(arguments))}}};const Te=$e;function Ie(E,...b){for(var C=0;C{window.console&&window.console.log&&window.console.log(b)}}debug(...b){this.log(this.globalLog,b)}warn(...b){this.log(this.globalLogWarn,b)}error(...b){this.log(this.globalLogError,b)}globalLogWarn(b){window.console&&window.console.warn?window.console.warn(b):this.globalLog(b)}globalLogError(b){window.console&&window.console.error?window.console.error(b):this.globalLogWarn(b)}log(b,...C){var $=xt.apply(this,arguments);Is.log?Is.log($):Is.logToConsole&&b.bind(this)($)}}const it=new Mn;var Un=function(E,b,C,$,j){(C.headers!==void 0||C.headersProvider!=null)&&it.warn(`To send headers with the ${$.toString()} request, you must use AJAX, rather than JSONP.`);var ne=E.nextAuthCallbackID.toString();E.nextAuthCallbackID++;var ye=E.getDocument(),Le=ye.createElement("script");E.auth_callbacks[ne]=function(vt){j(null,vt)};var We="Pusher.auth_callbacks['"+ne+"']";Le.src=C.endpoint+"?callback="+encodeURIComponent(We)+"&"+b;var ft=ye.getElementsByTagName("head")[0]||ye.documentElement;ft.insertBefore(Le,ft.firstChild)};const vn=Un;class da{constructor(b){this.src=b}send(b){var C=this,$="Error loading "+C.src;C.script=document.createElement("script"),C.script.id=b.id,C.script.src=C.src,C.script.type="text/javascript",C.script.charset="UTF-8",C.script.addEventListener?(C.script.onerror=function(){b.callback($)},C.script.onload=function(){b.callback(null)}):C.script.onreadystatechange=function(){(C.script.readyState==="loaded"||C.script.readyState==="complete")&&b.callback(null)},C.script.async===void 0&&document.attachEvent&&/opera/i.test(navigator.userAgent)?(C.errorScript=document.createElement("script"),C.errorScript.id=b.id+"_error",C.errorScript.text=b.name+"('"+$+"');",C.script.async=C.errorScript.async=!1):C.script.async=!0;var j=document.getElementsByTagName("head")[0];j.insertBefore(C.script,j.firstChild),C.errorScript&&j.insertBefore(C.errorScript,C.script.nextSibling)}cleanup(){this.script&&(this.script.onload=this.script.onerror=null,this.script.onreadystatechange=null),this.script&&this.script.parentNode&&this.script.parentNode.removeChild(this.script),this.errorScript&&this.errorScript.parentNode&&this.errorScript.parentNode.removeChild(this.errorScript),this.script=null,this.errorScript=null}}class pr{constructor(b,C){this.url=b,this.data=C}send(b){if(!this.request){var C=Mi(this.data),$=this.url+"/"+b.number+"?"+C;this.request=Ue.createScriptRequest($),this.request.send(b)}}cleanup(){this.request&&this.request.cleanup()}}var un=function(E,b){return function(C,$){var j="http"+(b?"s":"")+"://",ne=j+(E.host||E.options.host)+E.options.path,ye=Ue.createJSONPRequest(ne,C),Le=Ue.ScriptReceivers.create(function(We,ft){m.remove(Le),ye.cleanup(),ft&&ft.host&&(E.host=ft.host),$&&$(We,ft)});ye.send(Le)}},Rn={name:"jsonp",getAgent:un};const dn=Rn;function V(E,b,C){var $=E+(b.useTLS?"s":""),j=b.useTLS?b.hostTLS:b.hostNonTLS;return $+"://"+j+C}function ie(E,b){var C="/app/"+E,$="?protocol="+v.PROTOCOL+"&client=js&version="+v.VERSION+(b?"&"+b:"");return C+$}var ce={getInitial:function(E,b){var C=(b.httpPath||"")+ie(E,"flash=false");return V("ws",b,C)}},Z={getInitial:function(E,b){var C=(b.httpPath||"/pusher")+ie(E);return V("http",b,C)}},ve={getInitial:function(E,b){return V("http",b,b.httpPath||"/pusher")},getPath:function(E,b){return ie(E)}};class pe{constructor(){this._callbacks={}}get(b){return this._callbacks[Ee(b)]}add(b,C,$){var j=Ee(b);this._callbacks[j]=this._callbacks[j]||[],this._callbacks[j].push({fn:C,context:$})}remove(b,C,$){if(!b&&!C&&!$){this._callbacks={};return}var j=b?[Ee(b)]:at(this._callbacks);C||$?this.removeCallback(j,C,$):this.removeAllCallbacks(j)}removeCallback(b,C,$){Ht(b,function(j){this._callbacks[j]=mt(this._callbacks[j]||[],function(ne){return C&&C!==ne.fn||$&&$!==ne.context}),this._callbacks[j].length===0&&delete this._callbacks[j]},this)}removeAllCallbacks(b){Ht(b,function(C){delete this._callbacks[C]},this)}}function Ee(E){return"_"+E}class xe{constructor(b){this.callbacks=new pe,this.global_callbacks=[],this.failThrough=b}bind(b,C,$){return this.callbacks.add(b,C,$),this}bind_global(b){return this.global_callbacks.push(b),this}unbind(b,C,$){return this.callbacks.remove(b,C,$),this}unbind_global(b){return b?(this.global_callbacks=mt(this.global_callbacks||[],C=>C!==b),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(b,C,$){for(var j=0;j0)for(var j=0;j{this.onError(C),this.changeState("closed")}),!1}return this.bindListeners(),it.debug("Connecting",{transport:this.name,url:b}),this.changeState("connecting"),!0}close(){return this.socket?(this.socket.close(),!0):!1}send(b){return this.state==="open"?(Te.defer(()=>{this.socket&&this.socket.send(b)}),!0):!1}ping(){this.state==="open"&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(b){this.emit("error",{type:"WebSocketError",error:b}),this.timeline.error(this.buildTimelineMessage({error:b.toString()}))}onClose(b){b?this.changeState("closed",{code:b.code,reason:b.reason,wasClean:b.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(b){this.emit("message",b)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=b=>{this.onError(b)},this.socket.onclose=b=>{this.onClose(b)},this.socket.onmessage=b=>{this.onMessage(b)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(b,C){this.state=b,this.timeline.info(this.buildTimelineMessage({state:b,params:C})),this.emit(b,C)}buildTimelineMessage(b){return Ie({cid:this.id},b)}}class ke{constructor(b){this.hooks=b}isSupported(b){return this.hooks.isSupported(b)}createConnection(b,C,$,j){return new Ke(this.hooks,b,C,$,j)}}var Me=new ke({urls:ce,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return!!Ue.getWebSocketAPI()},isSupported:function(){return!!Ue.getWebSocketAPI()},getSocket:function(E){return Ue.createWebSocket(E)}}),Re={urls:Z,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},tt=Ie({getSocket:function(E){return Ue.HTTPFactory.createStreamingSocket(E)}},Re),Pe=Ie({getSocket:function(E){return Ue.HTTPFactory.createPollingSocket(E)}},Re),Ve={isSupported:function(){return Ue.isXHRSupported()}},Ce=new ke(Ie({},tt,Ve)),He=new ke(Ie({},Pe,Ve)),nt={ws:Me,xhr_streaming:Ce,xhr_polling:He};const Lt=nt;var Bt=new ke({file:"sockjs",urls:ve,handlesActivityChecks:!0,supportsPing:!1,isSupported:function(){return!0},isInitialized:function(){return window.SockJS!==void 0},getSocket:function(E,b){return new window.SockJS(E,null,{js_path:x.getPath("sockjs",{useTLS:b.useTLS}),ignore_null_origin:b.ignoreNullOrigin})},beforeOpen:function(E,b){E.send(JSON.stringify({path:b}))}}),Nn={isSupported:function(E){var b=Ue.isXDRSupported(E.useTLS);return b}},Gt=new ke(Ie({},tt,Nn)),Ft=new ke(Ie({},Pe,Nn));Lt.xdr_streaming=Gt,Lt.xdr_polling=Ft,Lt.sockjs=Bt;const Dn=Lt;class Ua extends xe{constructor(){super();var b=this;window.addEventListener!==void 0&&(window.addEventListener("online",function(){b.emit("online")},!1),window.addEventListener("offline",function(){b.emit("offline")},!1))}isOnline(){return window.navigator.onLine===void 0?!0:window.navigator.onLine}}var nl=new Ua;class gh{constructor(b,C,$){this.manager=b,this.transport=C,this.minPingDelay=$.minPingDelay,this.maxPingDelay=$.maxPingDelay,this.pingDelay=void 0}createConnection(b,C,$,j){j=Ie({},j,{activityTimeout:this.pingDelay});var ne=this.transport.createConnection(b,C,$,j),ye=null,Le=function(){ne.unbind("open",Le),ne.bind("closed",We),ye=Te.now()},We=ft=>{if(ne.unbind("closed",We),ft.code===1002||ft.code===1003)this.manager.reportDeath();else if(!ft.wasClean&&ye){var vt=Te.now()-ye;vt<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(vt/2,this.minPingDelay))}};return ne.bind("open",Le),ne}isSupported(b){return this.manager.isAlive()&&this.transport.isSupported(b)}}const Jc={decodeMessage:function(E){try{var b=JSON.parse(E.data),C=b.data;if(typeof C=="string")try{C=JSON.parse(b.data)}catch{}var $={event:b.event,channel:b.channel,data:C};return b.user_id&&($.user_id=b.user_id),$}catch(j){throw{type:"MessageParseError",error:j,data:E.data}}},encodeMessage:function(E){return JSON.stringify(E)},processHandshake:function(E){var b=Jc.decodeMessage(E);if(b.event==="pusher:connection_established"){if(!b.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:b.data.socket_id,activityTimeout:b.data.activity_timeout*1e3}}else{if(b.event==="pusher:error")return{action:this.getCloseAction(b.data),error:this.getCloseError(b.data)};throw"Invalid handshake"}},getCloseAction:function(E){return E.code<4e3?E.code>=1002&&E.code<=1004?"backoff":null:E.code===4e3?"tls_only":E.code<4100?"refused":E.code<4200?"backoff":E.code<4300?"retry":"refused"},getCloseError:function(E){return E.code!==1e3&&E.code!==1001?{type:"PusherError",data:{code:E.code,message:E.reason||E.message}}:null}},Yr=Jc;class Ni extends xe{constructor(b,C){super(),this.id=b,this.transport=C,this.activityTimeout=C.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(b){return this.transport.send(b)}send_event(b,C,$){var j={event:b,data:C};return $&&(j.channel=$),it.debug("Event sent",j),this.send(Yr.encodeMessage(j))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var b={message:$=>{var j;try{j=Yr.decodeMessage($)}catch(ne){this.emit("error",{type:"MessageParseError",error:ne,data:$.data})}if(j!==void 0){switch(it.debug("Event recd",j),j.event){case"pusher:error":this.emit("error",{type:"PusherError",data:j.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong");break}this.emit("message",j)}},activity:()=>{this.emit("activity")},error:$=>{this.emit("error",$)},closed:$=>{C(),$&&$.code&&this.handleCloseEvent($),this.transport=null,this.emit("closed")}},C=()=>{gt(b,($,j)=>{this.transport.unbind(j,$)})};gt(b,($,j)=>{this.transport.bind(j,$)})}handleCloseEvent(b){var C=Yr.getCloseAction(b),$=Yr.getCloseError(b);$&&this.emit("error",$),C&&this.emit(C,{action:C,error:$})}}class rl{constructor(b,C){this.transport=b,this.callback=C,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=b=>{this.unbindListeners();var C;try{C=Yr.processHandshake(b)}catch($){this.finish("error",{error:$}),this.transport.close();return}C.action==="connected"?this.finish("connected",{connection:new Ni(C.id,this.transport),activityTimeout:C.activityTimeout}):(this.finish(C.action,{error:C.error}),this.transport.close())},this.onClosed=b=>{this.unbindListeners();var C=Yr.getCloseAction(b)||"backoff",$=Yr.getCloseError(b);this.finish(C,{error:$})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(b,C){this.callback(Ie({transport:this.transport,action:b},C))}}class Ba{constructor(b,C){this.timeline=b,this.options=C||{}}send(b,C){this.timeline.isEmpty()||this.timeline.send(Ue.TimelineTransport.getAgent(this,b),C)}}class Xr extends xe{constructor(b,C){super(function($,j){it.debug("No callbacks on "+b+" for "+$)}),this.name=b,this.pusher=C,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(b,C){return C(null,{auth:""})}trigger(b,C){if(b.indexOf("client-")!==0)throw new L("Event '"+b+"' does not start with 'client-'");if(!this.subscribed){var $=O.buildLogSuffix("triggeringClientEvents");it.warn(`Client event triggered before channel 'subscription_succeeded' event . ${$}`)}return this.pusher.send_event(b,C,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(b){var C=b.event,$=b.data;if(C==="pusher_internal:subscription_succeeded")this.handleSubscriptionSucceededEvent(b);else if(C==="pusher_internal:subscription_count")this.handleSubscriptionCountEvent(b);else if(C.indexOf("pusher_internal:")!==0){var j={};this.emit(C,$,j)}}handleSubscriptionSucceededEvent(b){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",b.data)}handleSubscriptionCountEvent(b){b.data.subscription_count&&(this.subscriptionCount=b.data.subscription_count),this.emit("pusher:subscription_count",b.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(b,C)=>{b?(this.subscriptionPending=!1,it.error(b.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:b.message},b instanceof je?{status:b.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:C.auth,channel_data:C.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class fa extends Xr{authorize(b,C){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:b},C)}}class qa{constructor(){this.reset()}get(b){return Object.prototype.hasOwnProperty.call(this.members,b)?{id:b,info:this.members[b]}:null}each(b){gt(this.members,(C,$)=>{b(this.get($))})}setMyID(b){this.myID=b}onSubscription(b){this.members=b.presence.hash,this.count=b.presence.count,this.me=this.get(this.myID)}addMember(b){return this.get(b.user_id)===null&&this.count++,this.members[b.user_id]=b.user_info,this.get(b.user_id)}removeMember(b){var C=this.get(b.user_id);return C&&(delete this.members[b.user_id],this.count--),C}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var nn=function(E,b,C,$){function j(ne){return ne instanceof C?ne:new C(function(ye){ye(ne)})}return new(C||(C=Promise))(function(ne,ye){function Le(vt){try{ft($.next(vt))}catch(Vt){ye(Vt)}}function We(vt){try{ft($.throw(vt))}catch(Vt){ye(Vt)}}function ft(vt){vt.done?ne(vt.value):j(vt.value).then(Le,We)}ft(($=$.apply(E,b||[])).next())})};class Qc extends fa{constructor(b,C){super(b,C),this.members=new qa}authorize(b,C){super.authorize(b,($,j)=>nn(this,void 0,void 0,function*(){if(!$)if(j=j,j.channel_data!=null){var ne=JSON.parse(j.channel_data);this.members.setMyID(ne.user_id)}else if(yield this.pusher.user.signinDonePromise,this.pusher.user.user_data!=null)this.members.setMyID(this.pusher.user.user_data.id);else{let ye=O.buildLogSuffix("authorizationEndpoint");it.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${ye}, or the user should be signed in.`),C("Invalid auth response");return}C($,j)}))}handleEvent(b){var C=b.event;if(C.indexOf("pusher_internal:")===0)this.handleInternalEvent(b);else{var $=b.data,j={};b.user_id&&(j.user_id=b.user_id),this.emit(C,$,j)}}handleInternalEvent(b){var C=b.event,$=b.data;switch(C){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(b);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(b);break;case"pusher_internal:member_added":var j=this.members.addMember($);this.emit("pusher:member_added",j);break;case"pusher_internal:member_removed":var ne=this.members.removeMember($);ne&&this.emit("pusher:member_removed",ne);break}}handleSubscriptionSucceededEvent(b){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(b.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var Zc=f(978),Mr=f(594);class Ga extends fa{constructor(b,C,$){super(b,C),this.key=null,this.nacl=$}authorize(b,C){super.authorize(b,($,j)=>{if($){C($,j);return}let ne=j.shared_secret;if(!ne){C(new Error(`No shared_secret key in auth payload for encrypted channel: ${this.name}`),null);return}this.key=(0,Mr.decode)(ne),delete j.shared_secret,C(null,j)})}trigger(b,C){throw new de("Client events are not currently supported for encrypted channels")}handleEvent(b){var C=b.event,$=b.data;if(C.indexOf("pusher_internal:")===0||C.indexOf("pusher:")===0){super.handleEvent(b);return}this.handleEncryptedEvent(C,$)}handleEncryptedEvent(b,C){if(!this.key){it.debug("Received encrypted event before key has been retrieved from the authEndpoint");return}if(!C.ciphertext||!C.nonce){it.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+C);return}let $=(0,Mr.decode)(C.ciphertext);if($.length{if(ye){it.error(`Failed to make a request to the authEndpoint: ${Le}. Unable to fetch new key, so dropping encrypted event`);return}if(ne=this.nacl.secretbox.open($,j,this.key),ne===null){it.error("Failed to decrypt event with new key. Dropping encrypted event");return}this.emit(b,this.getDataToEmit(ne))});return}this.emit(b,this.getDataToEmit(ne))}getDataToEmit(b){let C=(0,Zc.D4)(b);try{return JSON.parse(C)}catch{return C}}}class mh extends xe{constructor(b,C){super(),this.state="initialized",this.connection=null,this.key=b,this.options=C,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var $=Ue.getNetwork();$.bind("online",()=>{this.timeline.info({netinfo:"online"}),(this.state==="connecting"||this.state==="unavailable")&&this.retryIn(0)}),$.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(b){this.key=b,this.updateStrategy(),this.retryIn(0)}connect(){if(!(this.connection||this.runner)){if(!this.strategy.isSupported()){this.updateState("failed");return}this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()}}send(b){return this.connection?this.connection.send(b):!1}send_event(b,C,$){return this.connection?this.connection.send_event(b,C,$):!1}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var b=(C,$)=>{C?this.runner=this.strategy.connect(0,b):$.action==="error"?(this.emit("error",{type:"HandshakeError",error:$.error}),this.timeline.error({handshakeError:$.error})):(this.abortConnecting(),this.handshakeCallbacks[$.action]($))};this.runner=this.strategy.connect(0,b)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){if(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection){var b=this.abandonConnection();b.close()}}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(b){this.timeline.info({action:"retry",delay:b}),b>0&&this.emit("connecting_in",Math.round(b/1e3)),this.retryTimer=new se(b||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new se(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new se(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new se(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(b){return Ie({},b,{message:C=>{this.resetActivityCheck(),this.emit("message",C)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:C=>{this.emit("error",C)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(b){return Ie({},b,{connected:C=>{this.activityTimeout=Math.min(this.options.activityTimeout,C.activityTimeout,C.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(C.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let b=C=>$=>{$.error&&this.emit("error",{type:"WebSocketError",error:$.error}),C($)};return{tls_only:b(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:b(()=>{this.disconnect()}),backoff:b(()=>{this.retryIn(1e3)}),retry:b(()=>{this.retryIn(0)})}}setConnection(b){this.connection=b;for(var C in this.connectionCallbacks)this.connection.bind(C,this.connectionCallbacks[C]);this.resetActivityCheck()}abandonConnection(){if(this.connection){this.stopActivityCheck();for(var b in this.connectionCallbacks)this.connection.unbind(b,this.connectionCallbacks[b]);var C=this.connection;return this.connection=null,C}}updateState(b,C){var $=this.state;if(this.state=b,$!==b){var j=b;j==="connected"&&(j+=" with new socket ID "+C.socket_id),it.debug("State changed",$+" -> "+j),this.timeline.info({state:b,params:C}),this.emit("state_change",{previous:$,current:b}),this.emit(b,C)}}shouldRetry(){return this.state==="connecting"||this.state==="connected"}}class eu{constructor(){this.channels={}}add(b,C){return this.channels[b]||(this.channels[b]=tu(b,C)),this.channels[b]}all(){return Yt(this.channels)}find(b){return this.channels[b]}remove(b){var C=this.channels[b];return delete this.channels[b],C}disconnect(){gt(this.channels,function(b){b.disconnect()})}}function tu(E,b){if(E.indexOf("private-encrypted-")===0){if(b.config.nacl)return Bn.createEncryptedChannel(E,b,b.config.nacl);let C="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",$=O.buildLogSuffix("encryptedChannelSupport");throw new de(`${C}. ${$}`)}else{if(E.indexOf("private-")===0)return Bn.createPrivateChannel(E,b);if(E.indexOf("presence-")===0)return Bn.createPresenceChannel(E,b);if(E.indexOf("#")===0)throw new B('Cannot create a channel with name "'+E+'".');return Bn.createChannel(E,b)}}var yh={createChannels(){return new eu},createConnectionManager(E,b){return new mh(E,b)},createChannel(E,b){return new Xr(E,b)},createPrivateChannel(E,b){return new fa(E,b)},createPresenceChannel(E,b){return new Qc(E,b)},createEncryptedChannel(E,b,C){return new Ga(E,b,C)},createTimelineSender(E,b){return new Ba(E,b)},createHandshake(E,b){return new rl(E,b)},createAssistantToTheTransportManager(E,b,C){return new gh(E,b,C)}};const Bn=yh;class Ii{constructor(b){this.options=b||{},this.livesLeft=this.options.lives||1/0}getAssistant(b){return Bn.createAssistantToTheTransportManager(this,b,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class Sn{constructor(b,C){this.strategies=b,this.loop=!!C.loop,this.failFast=!!C.failFast,this.timeout=C.timeout,this.timeoutLimit=C.timeoutLimit}isSupported(){return kn(this.strategies,Te.method("isSupported"))}connect(b,C){var $=this.strategies,j=0,ne=this.timeout,ye=null,Le=(We,ft)=>{ft?C(null,ft):(j=j+1,this.loop&&(j=j%$.length),j<$.length?(ne&&(ne=ne*2,this.timeoutLimit&&(ne=Math.min(ne,this.timeoutLimit))),ye=this.tryStrategy($[j],b,{timeout:ne,failFast:this.failFast},Le)):C(!0))};return ye=this.tryStrategy($[j],b,{timeout:ne,failFast:this.failFast},Le),{abort:function(){ye.abort()},forceMinPriority:function(We){b=We,ye&&ye.forceMinPriority(We)}}}tryStrategy(b,C,$,j){var ne=null,ye=null;return $.timeout>0&&(ne=new se($.timeout,function(){ye.abort(),j(!0)})),ye=b.connect(C,function(Le,We){Le&&ne&&ne.isRunning()&&!$.failFast||(ne&&ne.ensureAborted(),j(Le,We))}),{abort:function(){ne&&ne.ensureAborted(),ye.abort()},forceMinPriority:function(Le){ye.forceMinPriority(Le)}}}}class On{constructor(b){this.strategies=b}isSupported(){return kn(this.strategies,Te.method("isSupported"))}connect(b,C){return nu(this.strategies,b,function($,j){return function(ne,ye){if(j[$].error=ne,ne){bh(j)&&C(!0);return}Ht(j,function(Le){Le.forceMinPriority(ye.transport.priority)}),C(null,ye)}})}}function nu(E,b,C){var $=bt(E,function(j,ne,ye,Le){return j.connect(b,C(ne,Le))});return{abort:function(){Ht($,al)},forceMinPriority:function(j){Ht($,function(ne){ne.forceMinPriority(j)})}}}function bh(E){return hr(E,function(b){return!!b.error})}function al(E){!E.error&&!E.aborted&&(E.abort(),E.aborted=!0)}class ru{constructor(b,C,$){this.strategy=b,this.transports=C,this.ttl=$.ttl||18e5,this.usingTLS=$.useTLS,this.timeline=$.timeline}isSupported(){return this.strategy.isSupported()}connect(b,C){var $=this.usingTLS,j=vh($),ne=j&&j.cacheSkipCount?j.cacheSkipCount:0,ye=[this.strategy];if(j&&j.timestamp+this.ttl>=Te.now()){var Le=this.transports[j.transport];Le&&(["ws","wss"].includes(j.transport)||ne>3?(this.timeline.info({cached:!0,transport:j.transport,latency:j.latency}),ye.push(new Sn([Le],{timeout:j.latency*2+1e3,failFast:!0}))):ne++)}var We=Te.now(),ft=ye.pop().connect(b,function vt(Vt,Hr){Vt?(Os($),ye.length>0?(We=Te.now(),ft=ye.pop().connect(b,vt)):C(Vt)):(qn($,Hr.transport.name,Te.now()-We,ne),C(null,Hr))});return{abort:function(){ft.abort()},forceMinPriority:function(vt){b=vt,ft&&ft.forceMinPriority(vt)}}}}function Fa(E){return"pusherTransport"+(E?"TLS":"NonTLS")}function vh(E){var b=Ue.getLocalStorage();if(b)try{var C=b[Fa(E)];if(C)return JSON.parse(C)}catch{Os(E)}return null}function qn(E,b,C,$){var j=Ue.getLocalStorage();if(j)try{j[Fa(E)]=bn({timestamp:Te.now(),transport:b,latency:C,cacheSkipCount:$})}catch{}}function Os(E){var b=Ue.getLocalStorage();if(b)try{delete b[Fa(E)]}catch{}}class ji{constructor(b,{delay:C}){this.strategy=b,this.options={delay:C}}isSupported(){return this.strategy.isSupported()}connect(b,C){var $=this.strategy,j,ne=new se(this.options.delay,function(){j=$.connect(b,C)});return{abort:function(){ne.ensureAborted(),j&&j.abort()},forceMinPriority:function(ye){b=ye,j&&j.forceMinPriority(ye)}}}}class ha{constructor(b,C,$){this.test=b,this.trueBranch=C,this.falseBranch=$}isSupported(){var b=this.test()?this.trueBranch:this.falseBranch;return b.isSupported()}connect(b,C){var $=this.test()?this.trueBranch:this.falseBranch;return $.connect(b,C)}}class Va{constructor(b){this.strategy=b}isSupported(){return this.strategy.isSupported()}connect(b,C){var $=this.strategy.connect(b,function(j,ne){ne&&$.abort(),C(j,ne)});return $}}function Ka(E){return function(){return E.isSupported()}}var au=function(E,b,C){var $={};function j(bl,bu,vu,Ph,Uh){var Su=C(E,bl,bu,vu,Ph,Uh);return $[bl]=Su,Su}var ne=Object.assign({},b,{hostNonTLS:E.wsHost+":"+E.wsPort,hostTLS:E.wsHost+":"+E.wssPort,httpPath:E.wsPath}),ye=Object.assign({},ne,{useTLS:!0}),Le=Object.assign({},b,{hostNonTLS:E.httpHost+":"+E.httpPort,hostTLS:E.httpHost+":"+E.httpsPort,httpPath:E.httpPath}),We={loop:!0,timeout:15e3,timeoutLimit:6e4},ft=new Ii({minPingDelay:1e4,maxPingDelay:E.activityTimeout}),vt=new Ii({lives:2,minPingDelay:1e4,maxPingDelay:E.activityTimeout}),Vt=j("ws","ws",3,ne,ft),Hr=j("wss","ws",3,ye,ft),jh=j("sockjs","sockjs",1,Le),mu=j("xhr_streaming","xhr_streaming",1,Le,vt),Hh=j("xdr_streaming","xdr_streaming",1,Le,vt),gl=j("xhr_polling","xhr_polling",1,Le),yu=j("xdr_polling","xdr_polling",1,Le),Xa=new Sn([Vt],We),qi=new Sn([Hr],We),zh=new Sn([jh],We),Gi=new Sn([new ha(Ka(mu),mu,Hh)],We),ml=new Sn([new ha(Ka(gl),gl,yu)],We),yl=new Sn([new ha(Ka(Gi),new On([Gi,new ji(ml,{delay:4e3})]),ml)],We),Fi=new ha(Ka(yl),yl,zh),Vi;return b.useTLS?Vi=new On([Xa,new ji(Fi,{delay:2e3})]):Vi=new On([Xa,new ji(qi,{delay:2e3}),new ji(Fi,{delay:5e3})]),new ru(new Va(new ha(Ka(Vt),Vi,Fi)),$,{ttl:18e5,timeline:b.timeline,useTLS:b.useTLS})};const Wa=au;function Sh(){var E=this;E.timeline.info(E.buildTimelineMessage({transport:E.name+(E.options.useTLS?"s":"")})),E.hooks.isInitialized()?E.changeState("initialized"):E.hooks.file?(E.changeState("initializing"),x.load(E.hooks.file,{useTLS:E.options.useTLS},function(b,C){E.hooks.isInitialized()?(E.changeState("initialized"),C(!0)):(b&&E.onError(b),E.onClose(),C(!1))})):E.onClose()}var iu={getRequest:function(E){var b=new window.XDomainRequest;return b.ontimeout=function(){E.emit("error",new q),E.close()},b.onerror=function(C){E.emit("error",C),E.close()},b.onprogress=function(){b.responseText&&b.responseText.length>0&&E.onChunk(200,b.responseText)},b.onload=function(){b.responseText&&b.responseText.length>0&&E.onChunk(200,b.responseText),E.emit("finished",200),E.close()},b},abortRequest:function(E){E.ontimeout=E.onerror=E.onprogress=E.onload=null,E.abort()}};const su=iu,il=256*1024;class wh extends xe{constructor(b,C,$){super(),this.hooks=b,this.method=C,this.url=$}start(b){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},Ue.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(b)}close(){this.unloader&&(Ue.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(b,C){for(;;){var $=this.advanceBuffer(C);if($)this.emit("chunk",{status:b,data:$});else break}this.isBufferTooLong(C)&&this.emit("buffer_too_long")}advanceBuffer(b){var C=b.slice(this.position),$=C.indexOf(` +`);return $!==-1?(this.position+=$+1,C.slice(0,$)):null}isBufferTooLong(b){return this.position===b.length&&b.length>il}}var sl;(function(E){E[E.CONNECTING=0]="CONNECTING",E[E.OPEN=1]="OPEN",E[E.CLOSED=3]="CLOSED"})(sl||(sl={}));const gr=sl;var Nr=1;class ol{constructor(b,C){this.hooks=b,this.session=Ls(1e3)+"/"+lu(8),this.location=ll(C),this.readyState=gr.CONNECTING,this.openStream()}send(b){return this.sendRaw(JSON.stringify([b]))}ping(){this.hooks.sendHeartbeat(this)}close(b,C){this.onClose(b,C,!0)}sendRaw(b){if(this.readyState===gr.OPEN)try{return Ue.createSocketRequest("POST",pa(Ya(this.location,this.session))).start(b),!0}catch{return!1}else return!1}reconnect(){this.closeStream(),this.openStream()}onClose(b,C,$){this.closeStream(),this.readyState=gr.CLOSED,this.onclose&&this.onclose({code:b,reason:C,wasClean:$})}onChunk(b){if(b.status===200){this.readyState===gr.OPEN&&this.onActivity();var C,$=b.data.slice(0,1);switch($){case"o":C=JSON.parse(b.data.slice(1)||"{}"),this.onOpen(C);break;case"a":C=JSON.parse(b.data.slice(1)||"[]");for(var j=0;j{this.onChunk(b)}),this.stream.bind("finished",b=>{this.hooks.onFinished(this,b)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(b){Te.defer(()=>{this.onError(b),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}}function ll(E){var b=/([^\?]*)\/*(\??.*)/.exec(E);return{base:b[1],queryString:b[2]}}function Ya(E,b){return E.base+"/"+b+"/xhr_send"}function pa(E){var b=E.indexOf("?")===-1?"?":"&";return E+b+"t="+ +new Date+"&n="+Nr++}function ou(E,b){var C=/(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(E);return C[1]+b+C[3]}function Ls(E){return Ue.randomInt(E)}function lu(E){for(var b=[],C=0;C0&&E.onChunk(C.status,C.responseText);break;case 4:C.responseText&&C.responseText.length>0&&E.onChunk(C.status,C.responseText),E.emit("finished",C.status),E.close();break}},C},abortRequest:function(E){E.onreadystatechange=null,E.abort()}};const $s=ul;var cu={createStreamingSocket(E){return this.createSocket(cl,E)},createPollingSocket(E){return this.createSocket(Jr,E)},createSocket(E,b){return new Hi(E,b)},createXHR(E,b){return this.createRequest($s,E,b)},createRequest(E,b,C){return new wh(E,b,C)}};const Pi=cu;Pi.createXDR=function(E,b){return this.createRequest(su,E,b)};var uu={nextAuthCallbackID:1,auth_callbacks:{},ScriptReceivers:m,DependenciesReceivers:_,getDefaultStrategy:Wa,Transports:Dn,transportConnectionInitializer:Sh,HTTPFactory:Pi,TimelineTransport:dn,getXHRAPI(){return window.XMLHttpRequest},getWebSocketAPI(){return window.WebSocket||window.MozWebSocket},setup(E){window.Pusher=E;var b=()=>{this.onDocumentBody(E.ready)};window.JSON?b():x.load("json2",{},b)},getDocument(){return document},getProtocol(){return this.getDocument().location.protocol},getAuthorizers(){return{ajax:ze,jsonp:vn}},onDocumentBody(E){document.body?E():setTimeout(()=>{this.onDocumentBody(E)},0)},createJSONPRequest(E,b){return new pr(E,b)},createScriptRequest(E){return new da(E)},getLocalStorage(){try{return window.localStorage}catch{return}},createXHR(){return this.getXHRAPI()?this.createXMLHttpRequest():this.createMicrosoftXHR()},createXMLHttpRequest(){var E=this.getXHRAPI();return new E},createMicrosoftXHR(){return new ActiveXObject("Microsoft.XMLHTTP")},getNetwork(){return nl},createWebSocket(E){var b=this.getWebSocketAPI();return new b(E)},createSocketRequest(E,b){if(this.isXHRSupported())return this.HTTPFactory.createXHR(E,b);if(this.isXDRSupported(b.indexOf("https:")===0))return this.HTTPFactory.createXDR(E,b);throw"Cross-origin HTTP requests are not supported"},isXHRSupported(){var E=this.getXHRAPI();return!!E&&new E().withCredentials!==void 0},isXDRSupported(E){var b=E?"https:":"http:",C=this.getProtocol();return!!window.XDomainRequest&&C===b},addUnloadListener(E){window.addEventListener!==void 0?window.addEventListener("unload",E,!1):window.attachEvent!==void 0&&window.attachEvent("onunload",E)},removeUnloadListener(E){window.addEventListener!==void 0?window.removeEventListener("unload",E,!1):window.detachEvent!==void 0&&window.detachEvent("onunload",E)},randomInt(E){return Math.floor(function(){return(window.crypto||window.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)}()*E)}};const Ue=uu;var jr;(function(E){E[E.ERROR=3]="ERROR",E[E.INFO=6]="INFO",E[E.DEBUG=7]="DEBUG"})(jr||(jr={}));const ga=jr;class Ui{constructor(b,C,$){this.key=b,this.session=C,this.events=[],this.options=$||{},this.sent=0,this.uniqueID=0}log(b,C){b<=this.options.level&&(this.events.push(Ie({},C,{timestamp:Te.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(b){this.log(ga.ERROR,b)}info(b){this.log(ga.INFO,b)}debug(b){this.log(ga.DEBUG,b)}isEmpty(){return this.events.length===0}send(b,C){var $=Ie({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],b($,(j,ne)=>{j||this.sent++,C&&C(j,ne)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class Ch{constructor(b,C,$,j){this.name=b,this.priority=C,this.transport=$,this.options=j||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(b,C){if(this.isSupported()){if(this.priority{$||(vt(),ne?ne.close():j.close())},forceMinPriority:Vt=>{$||this.priority{var C="socket_id="+encodeURIComponent(E.socketId);for(var $ in b.params)C+="&"+encodeURIComponent($)+"="+encodeURIComponent(b.params[$]);if(b.paramsProvider!=null){let j=b.paramsProvider();for(var $ in j)C+="&"+encodeURIComponent($)+"="+encodeURIComponent(j[$])}return C},_h=E=>{if(typeof Ue.getAuthorizers()[E.transport]>"u")throw`'${E.transport}' is not a recognized auth transport`;return(b,C)=>{const $=Eh(b,E);Ue.getAuthorizers()[E.transport](Ue,$,E,k.UserAuthentication,C)}},hl=(E,b)=>{var C="socket_id="+encodeURIComponent(E.socketId);C+="&channel_name="+encodeURIComponent(E.channelName);for(var $ in b.params)C+="&"+encodeURIComponent($)+"="+encodeURIComponent(b.params[$]);if(b.paramsProvider!=null){let j=b.paramsProvider();for(var $ in j)C+="&"+encodeURIComponent($)+"="+encodeURIComponent(j[$])}return C},Ah=E=>{if(typeof Ue.getAuthorizers()[E.transport]>"u")throw`'${E.transport}' is not a recognized auth transport`;return(b,C)=>{const $=hl(b,E);Ue.getAuthorizers()[E.transport](Ue,$,E,k.ChannelAuthorization,C)}},xh=(E,b,C)=>{const $={authTransport:b.transport,authEndpoint:b.endpoint,auth:{params:b.params,headers:b.headers}};return(j,ne)=>{const ye=E.channel(j.channelName);C(ye,$).authorize(j.socketId,ne)}};function fu(E,b){let C={activityTimeout:E.activityTimeout||v.activityTimeout,cluster:E.cluster,httpPath:E.httpPath||v.httpPath,httpPort:E.httpPort||v.httpPort,httpsPort:E.httpsPort||v.httpsPort,pongTimeout:E.pongTimeout||v.pongTimeout,statsHost:E.statsHost||v.stats_host,unavailableTimeout:E.unavailableTimeout||v.unavailableTimeout,wsPath:E.wsPath||v.wsPath,wsPort:E.wsPort||v.wsPort,wssPort:E.wssPort||v.wssPort,enableStats:Dh(E),httpHost:Th(E),useTLS:Rh(E),wsHost:hu(E),userAuthenticator:pl(E),channelAuthorizer:Lh(E,b)};return"disabledTransports"in E&&(C.disabledTransports=E.disabledTransports),"enabledTransports"in E&&(C.enabledTransports=E.enabledTransports),"ignoreNullOrigin"in E&&(C.ignoreNullOrigin=E.ignoreNullOrigin),"timelineParams"in E&&(C.timelineParams=E.timelineParams),"nacl"in E&&(C.nacl=E.nacl),C}function Th(E){return E.httpHost?E.httpHost:E.cluster?`sockjs-${E.cluster}.pusher.com`:v.httpHost}function hu(E){return E.wsHost?E.wsHost:kh(E.cluster)}function kh(E){return`ws-${E}.pusher.com`}function Rh(E){return Ue.getProtocol()==="https:"?!0:E.forceTLS!==!1}function Dh(E){return"enableStats"in E?E.enableStats:"disableStats"in E?!E.disableStats:!1}const pu=E=>"customHandler"in E&&E.customHandler!=null;function pl(E){const b=Object.assign(Object.assign({},v.userAuthentication),E.userAuthentication);return pu(b)?b.customHandler:_h(b)}function Oh(E,b){let C;if("channelAuthorization"in E)C=Object.assign(Object.assign({},v.channelAuthorization),E.channelAuthorization);else if(C={transport:E.authTransport||v.authTransport,endpoint:E.authEndpoint||v.authEndpoint},"auth"in E&&("params"in E.auth&&(C.params=E.auth.params),"headers"in E.auth&&(C.headers=E.auth.headers)),"authorizer"in E)return{customHandler:xh(b,C,E.authorizer)};return C}function Lh(E,b){const C=Oh(E,b);return pu(C)?C.customHandler:Ah(C)}class $h extends xe{constructor(b){super(function(C,$){it.debug(`No callbacks on watchlist events for ${C}`)}),this.pusher=b,this.bindWatchlistInternalEvent()}handleEvent(b){b.data.events.forEach(C=>{this.emit(C.name,C)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",b=>{var C=b.event;C==="pusher_internal:watchlist_events"&&this.handleEvent(b)})}}function gu(){let E,b;return{promise:new Promise(($,j)=>{E=$,b=j}),resolve:E,reject:b}}const Mh=gu;class Nh extends xe{constructor(b){super(function(C,$){it.debug("No callbacks on user for "+C)}),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(C,$)=>{if(C){it.warn(`Error during signin: ${C}`),this._cleanup();return}this.pusher.send_event("pusher:signin",{auth:$.auth,user_data:$.user_data})},this.pusher=b,this.pusher.connection.bind("state_change",({previous:C,current:$})=>{C!=="connected"&&$==="connected"&&this._signin(),C==="connected"&&$!=="connected"&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new $h(b),this.pusher.connection.bind("message",C=>{var $=C.event;$==="pusher:signin_success"&&this._onSigninSuccess(C.data),this.serverToUserChannel&&this.serverToUserChannel.name===C.channel&&this.serverToUserChannel.handleEvent(C)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),this.pusher.connection.state==="connected"&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(b){try{this.user_data=JSON.parse(b.user_data)}catch{it.error(`Failed parsing user data after signin: ${b.user_data}`),this._cleanup();return}if(typeof this.user_data.id!="string"||this.user_data.id===""){it.error(`user_data doesn't contain an id. user_data: ${this.user_data}`),this._cleanup();return}this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){const b=C=>{C.subscriptionPending&&C.subscriptionCancelled?C.reinstateSubscription():!C.subscriptionPending&&this.pusher.connection.state==="connected"&&C.subscribe()};this.serverToUserChannel=new Xr(`#server-to-user-${this.user_data.id}`,this.pusher),this.serverToUserChannel.bind_global((C,$)=>{C.indexOf("pusher_internal:")===0||C.indexOf("pusher:")===0||this.emit(C,$)}),b(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested||this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:b,resolve:C}=Mh();b.done=!1;const $=()=>{b.done=!0};b.then($).catch($),this.signinDonePromise=b,this._signinDoneResolve=C}}class fn{static ready(){fn.isReady=!0;for(var b=0,C=fn.instances.length;bUe.getDefaultStrategy(this.config,j,Bi);this.connection=Bn.createConnectionManager(this.key,{getStrategy:$,timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:!!this.config.useTLS}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",j=>{var ne=j.event,ye=ne.indexOf("pusher_internal:")===0;if(j.channel){var Le=this.channel(j.channel);Le&&Le.handleEvent(j)}ye||this.global_emitter.emit(j.event,j.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",j=>{it.warn(j)}),fn.instances.push(this),this.timeline.info({instances:fn.instances.length}),this.user=new Nh(this),fn.isReady&&this.connect()}switchCluster(b){const{appKey:C,cluster:$}=b;this.key=C,this.options=Object.assign(Object.assign({},this.options),{cluster:$}),this.config=fu(this.options,this),this.connection.switchCluster(this.key)}channel(b){return this.channels.find(b)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var b=this.connection.isUsingTLS(),C=this.timelineSender;this.timelineSenderTimer=new ge(6e4,function(){C.send(b)})}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(b,C,$){return this.global_emitter.bind(b,C,$),this}unbind(b,C,$){return this.global_emitter.unbind(b,C,$),this}bind_global(b){return this.global_emitter.bind_global(b),this}unbind_global(b){return this.global_emitter.unbind_global(b),this}unbind_all(b){return this.global_emitter.unbind_all(),this}subscribeAll(){var b;for(b in this.channels.channels)this.channels.channels.hasOwnProperty(b)&&this.subscribe(b)}subscribe(b){var C=this.channels.add(b,this);return C.subscriptionPending&&C.subscriptionCancelled?C.reinstateSubscription():!C.subscriptionPending&&this.connection.state==="connected"&&C.subscribe(),C}unsubscribe(b){var C=this.channels.find(b);C&&C.subscriptionPending?C.cancelSubscription():(C=this.channels.remove(b),C&&C.subscribed&&C.unsubscribe())}send_event(b,C,$){return this.connection.send_event(b,C,$)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}fn.instances=[],fn.isReady=!1,fn.logToConsole=!1,fn.Runtime=Ue,fn.ScriptReceivers=Ue.ScriptReceivers,fn.DependenciesReceivers=Ue.DependenciesReceivers,fn.auth_callbacks=Ue.auth_callbacks;const Is=fn;function Ih(E){if(E==null)throw"You must pass your app key when you instantiate Pusher."}Ue.setup(fn)}},r={};function i(c){var d=r[c];if(d!==void 0)return d.exports;var f=r[c]={exports:{}};return n[c].call(f.exports,f,f.exports,i),f.exports}i.d=(c,d)=>{for(var f in d)i.o(d,f)&&!i.o(c,f)&&Object.defineProperty(c,f,{enumerable:!0,get:d[f]})},i.o=(c,d)=>Object.prototype.hasOwnProperty.call(c,d);var l=i(721);return l})())})(oh)),oh.exports}var Px=zx();const _b=ra(Px),Kt=pt("WebSocketManager");class Ux{constructor(){M(this,"echo",null);M(this,"subscriptions",new Map);M(this,"initialized",!1);M(this,"config",null)}configure(e){if(this.initialized){Kt.warn("[WebSocketManager] 이미 초기화되어 설정을 변경할 수 없습니다.");return}this.config=e,Kt.log("[WebSocketManager] 설정 완료:",{appKey:e.appKey?"***":"(없음)",host:e.host,port:e.port,scheme:e.scheme})}initialize(){if(this.initialized)return;if(!this.config||!this.config.appKey){Kt.warn("[WebSocketManager] WebSocket 설정이 없습니다. initTemplateApp에서 websocket 옵션을 전달해주세요.");return}const{appKey:e,host:n="localhost",port:r=80,scheme:i="https",authEndpoint:l="/api/broadcasting/auth"}=this.config,c=Number(r)||80,d=i==="https";Kt.log("[WebSocketManager] 연결 설정:",{host:n,port:c,scheme:i,useTLS:d,authEndpoint:l}),window.Pusher=_b;const f=localStorage.getItem("auth_token"),h={wsHost:n,wsPort:c,wssPort:c,forceTLS:d,disableStats:!0,enabledTransports:["ws","wss"],cluster:"mt1",authEndpoint:l,auth:{headers:{Authorization:f?`Bearer ${f}`:"",Accept:"application/json"}}};Kt.log("[WebSocketManager] Pusher 옵션:",h);const m=new _b(e,h);m.connection.bind("connecting",()=>{Kt.log("[WebSocketManager] 연결 시도 중...")}),m.connection.bind("connected",()=>{Kt.log("[WebSocketManager] 연결 성공! Socket ID:",m.connection.socket_id)}),m.connection.bind("failed",()=>{Kt.error("[WebSocketManager] 연결 실패 - WebSocket을 사용할 수 없습니다.")}),m.connection.bind("error",y=>{Kt.error("[WebSocketManager] 연결 오류:",y)}),m.connection.bind("state_change",y=>{Kt.log(`[WebSocketManager] 상태 변경: ${y.previous} → ${y.current}`)}),m.connection.bind("unavailable",()=>{Kt.error("[WebSocketManager] WebSocket 사용 불가 - 연결할 수 없습니다.")}),m.connection.bind("disconnected",()=>{Kt.warn("[WebSocketManager] 연결이 끊어졌습니다.")}),Kt.log("[WebSocketManager] 초기 연결 상태:",m.connection.state),this.echo=new Hx({broadcaster:"reverb",client:m}),Kt.log("[WebSocketManager] 연결 시작 시도..."),m.connect(),window.Echo=this.echo,this.initialized=!0,Kt.log("[WebSocketManager] Echo 초기화 완료")}subscribe(e,n,r,i={}){if(this.initialize(),!this.echo)return Kt.warn("[WebSocketManager] Echo가 초기화되지 않았습니다."),"";const{channelType:l="private"}=i,c=`${e}:${n}`;if(this.subscriptions.has(c))return Kt.log(`[WebSocketManager] 이미 구독 중: ${c}`),c;let d;switch(l){case"public":d=this.echo.channel(e);break;case"presence":d=this.echo.join(e);break;default:d=this.echo.private(e)}return d.listen(`.${n}`,r),this.subscriptions.set(c,d),Kt.log(`[WebSocketManager] 구독 완료: ${c} (${l})`),c}unsubscribe(e){const n=this.subscriptions.get(e);if(!n)return;const r=e.lastIndexOf(":"),i=r>=0?e.substring(r+1):"";if(i)try{n.stopListening(`.${i}`)}catch(l){Kt.warn(`[WebSocketManager] stopListening 실패: ${e}`,l)}this.subscriptions.delete(e),Kt.log(`[WebSocketManager] 구독 해제: ${e}`)}leaveChannel(e){if(!this.echo)return;this.echo.leave(e);const n=[];this.subscriptions.forEach((r,i)=>{i.startsWith(`${e}:`)&&n.push(i)}),n.forEach(r=>this.subscriptions.delete(r)),Kt.log(`[WebSocketManager] 채널 구독 해제: ${e}`)}disconnect(){this.echo&&(this.echo.disconnect(),this.subscriptions.clear(),this.initialized=!1,Kt.log("[WebSocketManager] 연결 종료"))}getEcho(){return this.echo}isInitialized(){return this.initialized}isConfigured(){return this.config!==null&&!!this.config.appKey}getSubscriptionCount(){return this.subscriptions.size}}const qc=new Ux,Ct=pt("DataSourceManager"),Ab=new $n;function Gc(s,e){const n=Oa(s);if(n!==null)try{return jn(n)?Ab.evaluatePipeExpression(n,e,{skipCache:!0}):Ab.evaluateExpression(n,e)}catch(r){return Ct.error("Failed to evaluate param expression:",n,r),s}return ps(s,e,{skipCache:!0})}function xb(s){const e={};for(const n of s.keys()){if(n in e)continue;const r=s.getAll(n);r.length>1?e[n]=r:r.length===1&&(n.endsWith("[]")?e[n]=r:e[n]=r[0])}return e}function Bx(){try{return window.G7Core?.devTools}catch{return}}const Xc=class Xc{constructor(e={}){M(this,"options");M(this,"dataCache",new Map);M(this,"bindingEngine");M(this,"globalHeaders",[]);this.options=e,this.bindingEngine=new $n}setGlobalHeaders(e){this.globalHeaders=e||[]}matchesPattern(e,n){if(n==="*")return!0;const r=n.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${r}$`).test(e)}toFormData(e){const n=new FormData;for(const[r,i]of Object.entries(e))i instanceof File||i instanceof Blob?n.append(r,i):i!=null&&n.append(r,typeof i=="object"?JSON.stringify(i):String(i));return n}getMatchingGlobalHeaders(e,n){const r={};for(const i of this.globalHeaders)this.matchesPattern(e,i.pattern)&&Object.entries(i.headers).forEach(([l,c])=>{const d=Gc(c,n);d!=null&&d!==""&&(r[l]=String(d))});return r}filterByCondition(e,n={}){const r=new Set,i=[];for(const l of e){if(r.has(l.id))continue;if(!l.if&&!l.conditions){r.add(l.id),i.push(l);continue}hs({if:l.if,conditions:l.conditions},n,this.bindingEngine,`data_source:${l.id}`)&&(r.add(l.id),i.push(l))}return i}checkErrorCondition(e,n){if(!e.errorCondition?.if||e.errorCondition?.errorCode===void 0)return null;try{const r={response:n};if(hs({if:e.errorCondition.if},r,this.bindingEngine,`errorCondition:${e.id}`))return Ct.log(`errorCondition matched for ${e.id}, triggering error ${e.errorCondition.errorCode}`),e.errorCondition.errorCode}catch(r){Ct.error(`Failed to evaluate errorCondition for ${e.id}:`,r)}return null}async fetchDataSources(e,n={},r=new URLSearchParams,i,l){const c={},d=!!this.options.sampleProvider,f=e.filter(h=>(d||h.auto_fetch!==!1)&&h.type!=="websocket");return await Promise.all(f.map(async h=>{try{const m=await this.fetchDataSource(h,n,r,i,l);c[h.id]=m,this.dataCache.set(h.id,{data:m,timestamp:Date.now()});const y=this.checkErrorCondition(h,m);if(y!==null){const v={status:y,message:`Error condition matched for ${h.id}`,data:m},S=kr(),_=S.resolve(y,{errorHandling:h.errorHandling,onError:h.onError});if(_.handler)try{await S.execute(_.handler,v)}catch(x){Ct.error(`Error executing errorCondition handler for ${h.id}:`,x)}h.fallback!==void 0&&(c[h.id]=h.fallback,this.dataCache.set(h.id,{data:h.fallback,timestamp:Date.now()}),Ct.log(`Using fallback data for ${h.id} (errorCondition)`));return}if(h.onSuccess)try{const v={data:m,sourceId:h.id};await this.executeOnSuccessHandler(h.onSuccess,v)}catch(v){Ct.error(`Error executing onSuccess handler for ${h.id}:`,v)}}catch(m){Ct.error(`Failed to fetch data source: ${h.id}`,m);const y=m?.response?.status||m?.status||500,v=m?.response?.data,S=v?.message||m.message||"Unknown error",_={status:y,message:S,errors:v?.errors,data:v,statusText:m?.response?.statusText},x=kr(),A=x.resolve(y,{errorHandling:h.errorHandling,onError:h.onError});if(A.handler)try{await x.execute(A.handler,_)}catch(D){Ct.error(`Error executing error handler for ${h.id}:`,D)}h.fallback!==void 0&&(c[h.id]=h.fallback,this.dataCache.set(h.id,{data:h.fallback,timestamp:Date.now()}),Ct.log(`Using fallback data for ${h.id}`)),this.options.onError&&this.options.onError(m,h)}})),c}async fetchDataSourcesWithResults(e,n={},r=new URLSearchParams,i,l,c){if(e.some(m=>m.type==="websocket")){const m=e.filter(y=>y.type==="websocket").map(y=>y.id).join(", ");Ct.warn(`fetchDataSourcesWithResults received WebSocket sources (caller should filter them out before calling): ${m}. WebSocket sources are event listeners, not data providers — they should not be passed to fetch.`)}const f=c?.ignoreAutoFetch?e.filter(m=>m.type!=="websocket"):e.filter(m=>m.auto_fetch!==!1&&m.type!=="websocket");return await Promise.all(f.map(async m=>{try{const y=await this.fetchDataSource(m,n,r,i,l);this.dataCache.set(m.id,{data:y,timestamp:Date.now()});const v=this.checkErrorCondition(m,y);if(v!==null){const S={status:v,message:`Error condition matched for ${m.id}`,data:y},_=kr(),x=_.resolve(v,{errorHandling:m.errorHandling,onError:m.onError});let A=!1;if(x.handler)if(m.loading_strategy==="blocking")_.execute(x.handler,S).catch(D=>{Ct.error(`Error executing errorCondition handler for ${m.id}:`,D)}),A=!0;else try{await _.execute(x.handler,S),A=!0}catch(D){Ct.error(`Error executing errorCondition handler for ${m.id}:`,D)}return m.fallback!==void 0?(this.dataCache.set(m.id,{data:m.fallback,timestamp:Date.now()}),Ct.log(`Using fallback data for ${m.id} (errorCondition)`),{id:m.id,state:"success",data:m.fallback}):{id:m.id,state:"error",error:new Error(`Error condition matched: ${v}`),errorCode:v,errorHandled:A}}if(m.onSuccess)try{const S={data:y,sourceId:m.id};await this.executeOnSuccessHandler(m.onSuccess,S)}catch(S){Ct.error(`Error executing onSuccess handler for ${m.id}:`,S)}return{id:m.id,state:"success",data:y}}catch(y){Ct.error(`Failed to fetch data source: ${m.id}`,y);const v=y?.response?.status||y?.status||500,S=y?.response?.data,_=S?.message||y.message||"Unknown error",x={status:v,message:_,errors:S?.errors,data:S,statusText:y?.response?.statusText},A=kr(),D=A.resolve(v,{errorHandling:m.errorHandling,onError:m.onError});let O=!1;if(D.handler)if(m.loading_strategy==="blocking")A.execute(D.handler,x).catch(k=>{Ct.error(`Error executing error handler for ${m.id}:`,k)}),O=!0;else try{await A.execute(D.handler,x),O=!0}catch(k){Ct.error(`Error executing error handler for ${m.id}:`,k)}return m.fallback!==void 0?(this.dataCache.set(m.id,{data:m.fallback,timestamp:Date.now()}),Ct.log(`Using fallback data for ${m.id}`),{id:m.id,state:"success",data:m.fallback}):(this.options.onError&&this.options.onError(y,m),{id:m.id,state:"error",error:y,errorCode:v,errorHandled:O})}}))}fetchDataSourcesInBackground(e,n={},r=new URLSearchParams,i){e.filter(c=>c.auto_fetch!==!1&&c.loading_strategy==="background"&&c.type!=="websocket").forEach(c=>{this.fetchDataSource(c,n,r).then(async d=>{this.dataCache.set(c.id,{data:d,timestamp:Date.now()});const f=this.checkErrorCondition(c,d);if(f!==null){const h={status:f,message:`Error condition matched for ${c.id}`,data:d},m=kr(),y=m.resolve(f,{errorHandling:c.errorHandling,onError:c.onError});if(y.handler)try{await m.execute(y.handler,h)}catch(v){Ct.error(`Error executing errorCondition handler for ${c.id}:`,v)}c.fallback!==void 0&&(this.dataCache.set(c.id,{data:c.fallback,timestamp:Date.now()}),Ct.log(`Using fallback data for ${c.id} (errorCondition)`),i&&i(c.id,c.fallback));return}if(c.onSuccess)try{const h={data:d,sourceId:c.id};await this.executeOnSuccessHandler(c.onSuccess,h)}catch(h){Ct.error(`Error executing onSuccess handler for ${c.id}:`,h)}i&&i(c.id,d)}).catch(async d=>{Ct.error(`Background fetch failed: ${c.id}`,d);const f=d?.response?.status||d?.status||500,h=d?.response?.data,m=h?.message||d.message||"Unknown error",y={status:f,message:m,errors:h?.errors,data:h,statusText:d?.response?.statusText},v=kr(),S=v.resolve(f,{errorHandling:c.errorHandling,onError:c.onError});if(S.handler)try{await v.execute(S.handler,y)}catch(_){Ct.error(`Error executing error handler for ${c.id}:`,_)}if(c.fallback!==void 0){this.dataCache.set(c.id,{data:c.fallback,timestamp:Date.now()}),Ct.log(`Using fallback data for ${c.id}`),i&&i(c.id,c.fallback);return}this.options.onError&&this.options.onError(d,c)})})}async fetchDataSource(e,n,r,i,l){switch(e.type){case"api":return this.fetchApiDataSource(e,n,r,i,l);case"static":return e.data;case"route_params":return n;case"query_params":return xb(r);default:throw new Error(`Unknown data source type: ${e.type}`)}}async fetchApiDataSource(e,n,r,i,l){if(this.options.sampleProvider?.has(e.id))return await Promise.resolve(this.options.sampleProvider.resolve(e));if(!e.endpoint)throw new Error(`API data source ${e.id} has no endpoint`);const c={route:n,query:xb(r)};i&&(c._global=i),l&&(c._local=l);let d=ps(e.endpoint,c,{skipCache:!0});const f=e.method||"GET",m=(e.contentType?typeof e.contentType=="string"&&e.contentType.includes("{{")?ps(e.contentType,c,{skipCache:!0}):e.contentType:"application/json")==="multipart/form-data";let y=m?{...e.params||{}}:JSON.parse(JSON.stringify(e.params||{}));Object.entries(y).forEach(([_,x])=>{typeof x=="string"&&(y[_]=Gc(x,c))}),Object.keys(y).forEach(_=>{y[_]===""&&delete y[_]});const v=Bx();let S=null;if(v?.isEnabled()){v.trackDataSourceDefinition({id:e.id,type:e.type,endpoint:d,method:f,autoFetch:e.auto_fetch,initLocal:e.initLocal,initGlobal:e.initGlobal});let _=d;if(f==="GET"&&Object.keys(y).length>0){const x=new URLSearchParams;Object.entries(y).forEach(([D,O])=>{Array.isArray(O)?O.forEach(k=>x.append(D,String(k))):O!=null&&x.append(D,String(O))});const A=x.toString();_=A?`${d}?${A}`:d}S=v.trackRequest(_,f,{requestBody:f!=="GET"?y:void 0,dataSourceId:e.id}),v.trackDataSourceLoading(e.id)}try{let _;const x=e.auth_mode??(e.auth_required===!0?"required":"none"),A=Xn.getInstance().isAuthenticated();if(x==="required"&&!A){Ct.log(`[DataSourceManager] Skipping ${e.id}: auth_mode is 'required' but no token available`),v?.isEnabled()&&(v.trackDataSourceError(e.id,"Skipped: auth_mode required but not authenticated"),S&&v.failRequest(S,"Skipped: not authenticated"));const O=new Error("Auth required but not authenticated");throw O.response={status:401,statusText:"Unauthorized",data:null},O.status=401,O._authSkipped=!0,O}const D=x==="required"||x==="optional"&&A;if(D){const O=Yn(),k=d.startsWith("/api/")?d.substring(4):d.startsWith("/api")?d.substring(4)||"/":d;this.options.onError&&Ct.log(`[DataSourceManager] Normalized endpoint: ${d} -> ${k}`);const L=this.getMatchingGlobalHeaders(d,c),B={};e.headers&&Object.entries(e.headers).forEach(([de,_e])=>{const Se=Gc(_e,c);Se!=null&&Se!==""&&(B[de]=String(Se))});const q={...L,...B},z=Object.keys(q).length>0,W=m?this.toFormData(y):y;switch(f){case"GET":_=await O.get(k,{params:y,...z&&{headers:q}});break;case"POST":z?_=await O.post(k,W,{headers:q}):_=await O.post(k,W);break;case"PUT":z?_=await O.put(k,W,{headers:q}):_=await O.put(k,W);break;case"PATCH":z?_=await O.patch(k,W,{headers:q}):_=await O.patch(k,W);break;case"DELETE":_=await O.delete(k,{params:y,...z&&{headers:q}});break;default:throw new Error(`Unsupported HTTP method: ${f}`)}}else{let O=d;if(f==="GET"){const W=new URLSearchParams(y).toString();O=W?`${d}?${W}`:d}const k={...m?{}:{"Content-Type":"application/json"},Accept:"application/json"};if(typeof window<"u"){const W=localStorage.getItem("g7_locale");W&&(k["Accept-Language"]=W)}const L=this.getMatchingGlobalHeaders(d,c);Object.assign(k,L),e.headers&&Object.entries(e.headers).forEach(([W,de])=>{const _e=Gc(de,c);_e!=null&&_e!==""&&(k[W]=String(_e))});let B;f!=="GET"&&(m?(B=this.toFormData(y),delete k["Content-Type"]):B=JSON.stringify(y));const q=await fetch(O,{method:f,headers:k,body:B});let z;try{z=await q.json()}catch{z=null}if(S&&v?.isEnabled()&&(v.completeRequest(S,q.status,z),S=null),!q.ok){v?.isEnabled()&&v.trackDataSourceError(e.id,`HTTP ${q.status}: ${q.statusText}`);const W=new Error(`HTTP error! status: ${q.status}`);throw W.response={status:q.status,statusText:q.statusText,data:z},W.status=q.status,W}_=z,v?.isEnabled()&&v.trackDataSourceLoaded(e.id,_)}return D&&S&&v?.isEnabled()&&(v.completeRequest(S,200,_),v.trackDataSourceLoaded(e.id,_)),_}catch(_){if(S&&v?.isEnabled()){const x=_;x?.response?v.completeRequest(S,x.response.status,x.response.data):v.failRequest(S,_ instanceof Error?_.message:String(_)),v.trackDataSourceError(e.id,_ instanceof Error?_.message:String(_))}throw _}}getCachedData(e){const n=this.dataCache.get(e);if(!n)return;if(Date.now()-n.timestamp>Xc.DATA_CACHE_TTL){this.dataCache.delete(e);return}return n.data}clearCache(){this.dataCache.clear()}subscribeWebSockets(e,n,r={}){const i=[],l=e.filter(c=>c.type==="websocket");return l.length===0||l.forEach(c=>{if(!c.channel||!c.event){Ct.warn(`WebSocket source ${c.id} missing channel or event`);return}let d,f;try{d=ps(c.channel,r,{skipCache:!0}),f=ps(c.event,r,{skipCache:!0})}catch(y){Ct.error(`Failed to resolve WebSocket channel/event for source ${c.id}:`,y);return}const h=y=>!!(!y||y.trim()===""||y.includes("{{")||y.endsWith(".")||y.endsWith(":")||y.startsWith(".")||y.startsWith(":")||y.includes("..")||y.includes("::"));if(h(d)||h(f)){Ct.warn(`WebSocket source ${c.id} has invalid channel/event after expression resolution, skipping. Original channel="${c.channel}", resolved="${d}". Original event="${c.event}", resolved="${f}". Available context keys: [${Object.keys(r).join(", ")}]`);return}const m=qc.subscribe(d,f,y=>{const v=c.target_source||c.id;this.dataCache.set(v,{data:y,timestamp:Date.now()}),n(v,y)},{channelType:c.channel_type||"private"});m&&i.push(m)}),i}unsubscribeWebSockets(e){e.length!==0&&e.forEach(n=>{qc.unsubscribe(n)})}async executeOnSuccessHandler(e,n){const r=this.options.actionDispatcher??Cy();if(!r){Ct.warn("ActionDispatcher not available, skipping onSuccess handler");return}const i=Array.isArray(e)?e:[e];for(const l of i)try{await r.dispatchAction({type:"click",...l},{data:{response:n}})}catch(c){throw Ct.error("Failed to execute onSuccess handler:",c),c}}};M(Xc,"DATA_CACHE_TTL",3e5);let Or=Xc;const qx=new Or,Ri=pt("ModalDataSourceWrapper");function Gx(s,e){if(!s||!e)return s;const r=e.replace(/\?\./g,".").split(/\.(?![^\[]*\])/).flatMap(l=>{const c=l.match(/^([^\[]*)((?:\[\d+\])*)$/);if(c){const[,d,f]=c,h=[];d&&h.push(d);const m=f.match(/\[\d+\]/g);return m&&h.push(...m),h}return[l]}).filter(l=>l!=="");let i=s;for(const l of r){if(i==null)return;if(l.startsWith("[")&&l.endsWith("]")){const c=parseInt(l.slice(1,-1),10);i=i[c]}else i=i[l]}return i}const Tb=({isOpen:s,modalId:e,dataSources:n,dataContext:r,globalStateUpdater:i,bindingEngine:l,debug:c=!1,children:d})=>{const[f,h]=N.useState(!1),[m,y]=N.useState(!1),v=N.useRef(!1),S=N.useRef(null);S.current||(S.current=new Or);const _=N.useCallback(async()=>{if(!(!n||n.length===0)&&S.current){h(!0);try{const x=r.route||{},A=new URLSearchParams(window.location.search),D=n.map(k=>{let L={...k};if(k.endpoint&&l){const B=l.resolveBindings(k.endpoint,r,{skipCache:!0});L.endpoint=B}if(k.params&&l){const B={};Object.entries(k.params).forEach(([q,z])=>{typeof z=="string"?B[q]=l.resolveBindings(z,r,{skipCache:!0}):B[q]=z}),L.params=B}return L});c&&Ri.log(`[ModalDataSourceWrapper] Modal "${e}" fetching data sources:`,D.map(k=>({id:k.id,endpoint:k.endpoint})));const O=await S.current.fetchDataSourcesWithResults(D,x,A);i&&O.forEach(k=>{if(k.state==="success"&&k.data!==void 0){const L=D.find(B=>B.id===k.id);if(L?.initGlobal){const B=k.data?.data??k.data,q=Array.isArray(L.initGlobal)?L.initGlobal:[L.initGlobal];for(const z of q)if(typeof z=="string")i({[z]:B}),c&&Ri.log(`[ModalDataSourceWrapper] Modal "${e}" initGlobal: ${k.id}.data -> _global.${z}`);else if(typeof z=="object"&&z.key){const{key:W,path:de}=z,_e=de?Gx(B,de):B;i({[W]:_e}),c&&Ri.log(`Modal "${e}" initGlobal: ${k.id}.data${de?"."+de:""} -> _global.${W}`)}}}else k.state==="error"&&Ri.error(`Modal "${e}" data source error:`,k.id,k.error)}),c&&Ri.log(`Modal "${e}" data sources fetched successfully`)}catch(x){Ri.error(`Modal "${e}" data source fetch error:`,x)}finally{h(!1),y(!0)}}},[n,r,i,l,e,c]);return N.useEffect(()=>{if(!n||n.length===0)return;const x=window.__templateApp;return x?.registerModalDataSources&&x.registerModalDataSources(e,n),()=>{x?.unregisterModalDataSources&&x.unregisterModalDataSources(e)}},[e,n]),N.useEffect(()=>{!s&&v.current&&(y(!1),c&&Ri.log(`[ModalDataSourceWrapper] Modal "${e}" closed, reset fetch state`)),s&&!v.current&&n&&n.length>0&&!m&&_(),v.current=s},[s,n,m,_,e,c]),yt.jsx(yt.Fragment,{children:d})};class Fc extends Error{constructor(n,r,i={}){super(r);M(this,"code");M(this,"userMessageKey");M(this,"showStack");M(this,"icon");M(this,"recoverable");this.name="TemplateEngineError",this.code=n,this.userMessageKey=r,this.showStack=i.showStack??!0,this.icon=i.icon??"fa-circle-exclamation",this.recoverable=i.recoverable??!0,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}getUserMessage(n,r){if(!r||!n)return this.userMessageKey;try{return r.translate(this.userMessageKey,n)}catch{return this.userMessageKey}}}class Fx extends Fc{constructor(){super("TEMPLATE_NOT_FOUND","$t:core.errors.template_not_found",{showStack:!1,icon:"fa-paint-brush",recoverable:!1}),this.name="TemplateNotFoundError"}}function kb(s){if(s instanceof Fc)return s;if(s instanceof Error){const e=new Fc("TEMPLATE_INIT_ERROR",s.message||"$t:core.errors.template_init_error",{showStack:!0,icon:"fa-circle-exclamation",recoverable:!0});return e.stack=s.stack,e}return new Fc("TEMPLATE_INIT_ERROR","$t:core.errors.template_init_error",{showStack:!1,icon:"fa-circle-exclamation",recoverable:!0})}const Vx=pt("ErrorDisplay");class lh{static render(e,n){const r=document.getElementById(e);if(!r){Vx.error(`Container #${e} not found`);return}const i=n.debug&&n.showStack&&n.stackTrace,l=window.matchMedia("(prefers-color-scheme: dark)").matches,c={container:` display: flex; align-items: center; justify-content: center; @@ -270,4 +273,4 @@ Error generating stack: `+u.message+` `:""} - `}static renderFromError(e,n,r,i=!1,l,c,d){let f,p;if(n.userMessageKey.startsWith("$t:"))if(c&&l)try{f=c.translate(n.userMessageKey,l)}catch{f=n.userMessageKey.replace("$t:","")}else f=n.userMessageKey.replace("$t:","");else f=n.userMessageKey;if(d){const m=d;m.details?.apiMessage?p=m.details.apiMessage:m.response?.data?.message&&(p=m.response.data.message)}this.render(e,{title:r,message:f,detailMessage:p,icon:n.icon,showStack:n.showStack,stackTrace:n.stack,showReloadButton:n.recoverable,debug:i})}static escapeHtml(e){if(!e)return"";const n=document.createElement("div");return n.textContent=e,n.innerHTML}}const bs=dt("Router");class zA{constructor(e){$(this,"routes",[]);$(this,"templateIdentifier");$(this,"eventHandlers",new Map);$(this,"pendingNavigation",null);$(this,"isNavigating",!1);$(this,"handlePopState",()=>{this.navigateToCurrentPath()});this.templateIdentifier=e,this.initPopstateListener()}initPopstateListener(){window.addEventListener("popstate",this.handlePopState)}on(e,n){this.eventHandlers.has(e)||this.eventHandlers.set(e,[]),this.eventHandlers.get(e).push(n)}async emit(e,...n){const r=this.eventHandlers.get(e);r&&await Promise.all(r.map(i=>i(...n)))}async loadRoutes(e){try{const n=e!==void 0&&e>0?e:null,r=await fetch(Pr(`/api/templates/${this.templateIdentifier}/routes`,"json",n));if(!r.ok)throw new Error(`Failed to load routes: ${r.statusText}`);const i=await r.json();if(!i.success)throw new Error("Failed to load routes from API");if(i.data&&Array.isArray(i.data.routes))this.routes=i.data.routes,bs.log(`Loaded ${this.routes.length} routes${e?` (v=${e})`:""}`);else throw new Error("Invalid routes data format")}catch(n){throw bs.error("Error loading routes:",n),n}}setRoutes(e){this.routes=e,bs.log(`Set ${this.routes.length} routes`)}match(e){const n=this.normalizePathname(e);for(const r of this.routes){const i=this.matchPattern(r.path,n);if(i!==null)return{route:r,params:i}}return null}normalizePathname(e){return e.length>1&&e.endsWith("/")?e.replace(/\/+$/,"")||"/":e}matchPattern(e,n){const r=[];let i=e.replace(/:([^/]+)/g,(f,p)=>(r.push(p),"([^/]+)"));i.startsWith("*/")&&(i="(?:/[^/]+)?"+i.slice(1)),i=i.replace(/\//g,"\\/");const l=new RegExp(`^${i}$`),c=n.match(l);if(!c)return null;const d={};return r.forEach((f,p)=>{d[f]=c[p+1]}),d}getRoutes(){return[...this.routes]}getAuthType(e,n){return e.auth_type?e.auth_type:n.startsWith("/admin")?"admin":"user"}async navigateToCurrentPath(){const e=window.location.pathname,n=window.location.search,r=this.match(e);if(!r){bs.warn(`No route matched for path: ${e}`),this.emit("routeNotFound",e);return}if(r.route.redirect){bs.log(`Redirecting from ${e} to ${r.route.redirect}`),this.navigate(r.route.redirect);return}if(r.route.auth_required){const c=this.getAuthType(r.route,e),d=Yn.getInstance();let f=d.isAuthenticated()&&d.getAuthType()===c;if(f||(f=await d.checkAuth(c)),!f){const p=d.getLoginRedirectUrl(c,e+n);bs.log(`Not authenticated, redirecting to: ${p}`),window.location.href=p;return}}const i=new URLSearchParams(n),l={};for(const c of i.keys()){if(c in l)continue;const d=i.getAll(c);d.length>1?l[c]=d:d.length===1&&(c.endsWith("[]")?l[c]=d:l[c]=d[0])}await this.emit("routeChange",{path:e,layout:r.route.layout,endpoint:r.route.endpoint,params:{...r.route.params||{},...r.params},query:l,auth_required:r.route.auth_required,auth_type:r.route.auth_type,meta:r.route.meta})}navigate(e){if(this.isNavigating){this.pendingNavigation=e;return}this.executeNavigation(e)}async executeNavigation(e){this.isNavigating=!0,this.pendingNavigation=null;try{window.history.pushState({},"",e),await this.navigateToCurrentPath()}finally{if(this.isNavigating=!1,this.pendingNavigation){const n=this.pendingNavigation;this.executeNavigation(n)}}}}const HA=/^\/admin\/layout-editor\/([^/?#]+)\/?$/;function tb(s){const e=HA.exec(s);return e?{templateIdentifier:e[1]}:null}const Ht=dt("ErrorPageHandler");class UA{constructor(e){$(this,"templateId");$(this,"layoutLoader");$(this,"locale");$(this,"debug");$(this,"renderFunction");$(this,"dataSourceManager");$(this,"globalState");$(this,"errorConfig",null);$(this,"configLoaded",!1);this.templateId=e.templateId,this.layoutLoader=e.layoutLoader,this.locale=e.locale,this.debug=e.debug,this.renderFunction=e.renderFunction,this.dataSourceManager=e.dataSourceManager,this.globalState=e.globalState||{}}async loadConfig(){if(this.configLoaded)return this.errorConfig;try{const e=await fetch(Pr(`/api/templates/${this.templateId}/config`,"json"));if(!e.ok)return this.debug&&Ht.warn("Failed to load template config:",e.statusText),this.configLoaded=!0,null;const n=await e.json();if(!n.success||!n.data)return this.debug&&Ht.warn("Invalid template config response"),this.configLoaded=!0,null;const r=n.data;return!r.error_config||!r.error_config.layouts?(this.debug&&Ht.warn("No error_config found in template.json"),this.configLoaded=!0,null):(this.errorConfig=r.error_config,this.configLoaded=!0,this.debug&&Ht.log("Error config loaded:",this.errorConfig),this.errorConfig)}catch(e){return Ht.error("Failed to load error config:",e),this.configLoaded=!0,null}}async renderError(e,n="app"){try{const r=await this.loadConfig();if(!r)return this.debug&&Ht.warn("No error config available, cannot render error page"),!1;const i=r.layouts[e]||r.layouts[String(e)];if(!i)return this.debug&&Ht.warn(`No layout defined for error code: ${e}`),!1;this.debug&&Ht.log(`Loading error layout: ${i} for code: ${e}`);const l=await this.layoutLoader.loadLayout(this.templateId,i);if(!l)return this.debug&&Ht.error(`Failed to load error layout: ${i}`),!1;this.debug&&Ht.log("Error layout loaded:",l);let c={};const d=l.data_sources||[];if(d.length>0){this.debug&&Ht.log("Fetching data sources:",d.map(S=>S.id));const m=d.filter(S=>S.loading_strategy==="blocking"),y=d.filter(S=>!S.loading_strategy||S.loading_strategy==="progressive"),C=[...m,...y];if(C.length>0)try{c=await this.dataSourceManager.fetchDataSources(C,{},new URLSearchParams),this.debug&&Ht.log("Data sources fetched:",Object.keys(c))}catch(S){Ht.error("Failed to fetch data sources:",S)}}const f={};d.length>0&&(this.processInitOptions(d,c,f),this.debug&&Ht.log("initOptions processed:",{globalKeys:Object.keys(this.globalState),localKeys:Object.keys(f)}));const p={...c,errorCode:e,_global:{...this.globalState},_local:{...f}};return await this.renderFunction({containerId:n,layoutJson:l,dataContext:p,translationContext:{templateId:this.templateId,locale:this.locale}}),this.debug&&Ht.log(`Error page ${e} rendered successfully`),!0}catch(r){return Ht.error(`Failed to render error page ${e}:`,r),!1}}processInitOptions(e,n,r){for(const i of e){const l=n[i.id];if(!l)continue;const c=l?.data??l;if(i.initLocal){if(typeof i.initLocal=="string")r[i.initLocal]=c,Ht.log(`initLocal: ${i.id}.data -> _local.${i.initLocal}`);else if(typeof i.initLocal=="object"&&"key"in i.initLocal){const{key:d,path:f}=i.initLocal;r[d]=f?this.getValueByPath(c,f):c,Ht.log(`initLocal: ${i.id}.data${f?"."+f:""} -> _local.${d}`)}}if(i.initGlobal){const d=Array.isArray(i.initGlobal)?i.initGlobal:[i.initGlobal];for(const f of d)if(typeof f=="string")this.globalState[f]=c,Ht.log(`initGlobal: ${i.id}.data -> _global.${f}`);else if(typeof f=="object"&&f!==null&&"key"in f){const{key:p,path:m}=f;this.globalState[p]=m?this.getValueByPath(c,m):c,Ht.log(`initGlobal: ${i.id}.data${m?"."+m:""} -> _global.${p}`)}}}}getValueByPath(e,n){return n.split(".").reduce((r,i)=>r?.[i],e)}updateGlobalState(e){this.globalState={...this.globalState,...e}}updateLocale(e){this.locale=e,this.debug&&Ht.log("Locale updated:",e)}isConfigLoaded(){return this.configLoaded}async hasErrorLayout(e){const n=await this.loadConfig();return n?!!(n.layouts[e]||n.layouts[String(e)]):!1}clearConfigCache(){this.errorConfig=null,this.configLoaded=!1,this.debug&&Ht.log("Config cache cleared")}}const Yc=dt("AssetFailureNotice"),nb="g7-asset-failure-notice",PA="g7-system-banners",Kr=new Map;let vs=!1,Xc=!1,qo=null;function Di(s,e,n){try{const r=window?.G7Core?.t;if(typeof r=="function"){const i=r(s,n);if(typeof i=="string"&&i!==s&&!i.startsWith("core.assets."))return i}}catch{}return BA(e,n)}function BA(s,e){return e?Object.entries(e).reduce((n,[r,i])=>n.split("{"+r+"}").join(String(i)),s):s}function Ss(s){!s||!s.id||(Kr.set(s.id,s),Xc=!1,Yc.warn(`Asset failure notified: ${s.id} (${s.label})`),ws())}function rb(s){Kr.delete(s)&&(Yc.log(`Asset failure cleared: ${s}`),ws())}function ab(){Kr.size!==0&&(Kr.clear(),ws())}function qA(){return Array.from(Kr.values())}function ib(s,e,n){return Di(s,e,n)}async function sb(){if(vs)return;vs=!0,Xc=!1,ws();const s=Array.from(Kr.values()).filter(n=>typeof n.retry=="function");let e=!1;for(const n of s)try{await n.retry(),Kr.delete(n.id)}catch(r){e=!0,Yc.warn(`Asset retry failed: ${n.id}`,r)}vs=!1,Xc=e,ws()}function GA(){try{return document.documentElement.classList.contains("dark")}catch{return!1}}function ws(){if(typeof document>"u"||!document.body)return;const s=document.getElementById(nb);if(Kr.size===0){s?.remove(),JA();return}const e=s??FA();VA(e),e.replaceChildren(KA()),XA()}function FA(){const s=document.createElement("div");return s.id=nb,s.setAttribute("role","alert"),s.setAttribute("aria-live","polite"),document.body.appendChild(s),s}function VA(s){const n=document.getElementById(PA)?.offsetHeight??0;s.style.cssText=["position:fixed",`top:${n}px`,"left:0","right:0","z-index:9998","display:flex","justify-content:center","pointer-events:none"].join(";")}function KA(){const s=GA(),e=Array.from(Kr.values()),n=typeof window<"u"&&window.innerWidth<768,r=document.createElement("div");return r.style.cssText=["pointer-events:auto","box-sizing:border-box","width:100%","max-width:960px","margin:8px","padding:12px 16px","border-radius:8px",`border:1px solid ${s?"#78350f":"#fcd34d"}`,`background:${s?"#451a03":"#fffbeb"}`,`color:${s?"#fef3c7":"#78350f"}`,"box-shadow:0 4px 12px rgba(0,0,0,0.12)","font-size:14px","line-height:1.5","display:flex",n?"flex-direction:column":"flex-direction:row",n?"align-items:stretch":"align-items:center","gap:12px"].join(";"),r.style.background=s?"#451a03":"#fffbeb",r.style.color=s?"#fef3c7":"#78350f",r.style.borderColor=s?"#78350f":"#fcd34d",r.appendChild(WA(e,n)),r.appendChild(YA(e,n,s)),r}function WA(s,e){const n=document.createElement("div");n.style.cssText=["flex:1 1 auto","min-width:0","display:flex","gap:8px"].join(";");const r=document.createElement("span");r.setAttribute("aria-hidden","true"),r.textContent="⚠",r.style.cssText="flex:0 0 auto;font-size:16px;line-height:1.4",n.appendChild(r);const i=document.createElement("div");if(i.style.cssText="flex:1 1 auto;min-width:0",s.length===1){const l=s[0],c=document.createElement("div");c.setAttribute("data-asset-failure-id",l.id),c.textContent=l.message??Di("core.assets.load_failed","{label}을(를) 불러오지 못했습니다.",{label:l.label}),i.appendChild(c)}else{const l=document.createElement("div");l.style.cssText="font-weight:600",l.textContent=Di("core.assets.load_failed_multiple","{count}개 항목을 불러오지 못했습니다.",{count:s.length}),i.appendChild(l);const c=document.createElement("div");c.style.cssText="margin-top:2px;opacity:0.9;word-break:break-word",c.textContent=s.map(d=>d.label).join(", "),i.appendChild(c)}if(Xc){const l=document.createElement("div");l.style.cssText="margin-top:4px;font-weight:600",l.textContent=Di("core.assets.retry_failed","다시 시도했지만 실패했습니다. 잠시 후 다시 시도해 주세요."),i.appendChild(l)}return n.appendChild(i),e&&(n.style.alignItems="flex-start"),n}function YA(s,e,n){const r=document.createElement("div");if(r.style.cssText=["flex:0 0 auto","display:flex","gap:8px",e?"width:100%":"","align-items:center"].filter(Boolean).join(";"),s.some(c=>typeof c.retry=="function")){const c=document.createElement("button");c.type="button",c.dataset.action="retry",c.disabled=vs,c.textContent=vs?Di("core.assets.retrying","다시 시도 중..."):Di("core.assets.retry","다시 시도"),c.style.cssText=[e?"flex:1 1 auto":"","padding:6px 14px","border-radius:6px","font-size:14px","font-weight:600","cursor:pointer",`border:1px solid ${n?"#b45309":"#d97706"}`,`background:${n?"#b45309":"#f59e0b"}`,`color:${n?"#fffbeb":"#451a03"}`,vs?"opacity:0.6":""].filter(Boolean).join(";"),c.addEventListener("click",()=>{sb()}),r.appendChild(c)}const l=document.createElement("button");return l.type="button",l.dataset.action="close",l.setAttribute("aria-label",Di("core.assets.close","닫기")),l.textContent="✕",l.style.cssText=["padding:6px 10px","border-radius:6px","font-size:14px","cursor:pointer","border:1px solid transparent","background:transparent",`color:${n?"#fef3c7":"#78350f"}`].join(";"),l.addEventListener("click",()=>{ab()}),r.appendChild(l),r}function XA(){qo||typeof MutationObserver>"u"||(qo=new MutationObserver(()=>{Kr.size>0&&ws()}),qo.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}function JA(){qo?.disconnect(),qo=null}function QA(){const s=window,e=r=>({id:String(r?.id??""),label:String(r?.label??r?.url??"asset"),retry:typeof r?.retry=="function"?r.retry:void 0}),n=Array.isArray(s.__g7ExternalAssetFailures)?s.__g7ExternalAssetFailures:[];n.forEach(r=>{r?.id&&Ss(e(r))}),s.__g7ExternalAssetSink=r=>{r?.id&&Ss(e(r))},Yc.log(`템플릿 externals 실패 대기열 ${n.length}건 반영`)}const Et=dt("ModuleAssetLoader");function ZA(s){return s==="plugin"?ib("core.assets.plugin_styles","플러그인 스타일"):ib("core.assets.module_styles","모듈 스타일")}class ex{constructor(){$(this,"loadedAssets",new Map);$(this,"loadingPromises",new Map);$(this,"failedJsAssets",new Set);$(this,"failedCssAssets",new Set)}getFailedCssAssets(){return[...this.failedCssAssets]}hasFailedJsAssets(){return this.failedJsAssets.size>0}getFailedJsAssets(){return[...this.failedJsAssets]}async loadActiveExtensionAssets(e){if(!e||e.length===0){Et.log("No module assets to load");return}const n=[...e].sort((d,f)=>d.priority-f.priority);Et.log("Loading module assets:",n.map(d=>d.identifier));const r=n.filter(d=>d.css).map(d=>this.loadCSS(d.identifier,d.css)),i=n.filter(d=>d.js).map(d=>this.loadJS(d.identifier,d.js)),l=await Promise.allSettled([...r,...i]),c=l.filter(d=>d.status==="rejected");if(c.length>0){Et.warn(`Some module assets failed to load (${c.length}/${l.length}); continuing with the rest`,this.getFailedJsAssets());return}Et.log("All module assets loaded successfully")}async loadBundle(e,n,r){const i=[];if(r&&i.push(this.loadBundleCss(e,r)),n&&i.push(this.loadBundleJs(e,n)),i.length===0){Et.log(`No bundle assets to load for: ${e}`);return}await Promise.all(i)}async loadCustomAssets(){const e=tx();if(e.length!==0)for(const n of e){const r=`g7-custom-${n.type}-${nx(n.id)}`;if(document.getElementById(r))continue;const i=`${n.type==="style"?"custom CSS":"custom JS"}: ${n.id}`,l=(d,f)=>n.type==="style"?sa(xn(d),{id:r},{label:i,retries:f}):Cr(xn(d),{id:r},{label:i,retries:f}),c=Dd(n.url);try{if(c!==null)try{await l(n.url,0)}catch{Et.warn(`Custom asset static miss, falling back to API: ${n.id} (${n.url} -> ${c})`),await l(c)}else await l(n.url);Et.log(`Custom asset loaded: ${n.id}`)}catch(d){Et.warn(`Failed to load custom asset: ${n.id} (${n.url})`,d),Ss({id:`custom-asset:${n.id}`,label:n.id.split(":").pop()??n.id,retry:async()=>{document.getElementById(r)?.remove(),await l(c??n.url)}})}}}async loadBundleCss(e,n){const r=`ext-bundle-css-${e}`;if(document.getElementById(r)){Et.log(`Bundle CSS already loaded: ${e}`);return}const i=Dd(n);try{if(i!==null)try{await sa(n,{id:r},{label:`bundle CSS: ${e}`,retries:0})}catch{Et.warn(`Bundle CSS static miss, falling back to API: ${e} (${n} -> ${i})`),await sa(xn(i),{id:r},{label:`bundle CSS: ${e}`})}else await sa(n,{id:r},{label:`bundle CSS: ${e}`});Et.log(`Bundle CSS loaded: ${e}`);const l=document.getElementById(r);l&&this.registerLoadedAsset(`bundle-${e}`,{type:"css",element:l})}catch(l){this.surfaceCssFailure(`bundle-${e}`,ZA(e),i!==null?xn(i):n,l)}}async loadBundleJs(e,n){const r=`ext-bundle-js-${e}`;if(document.getElementById(r)){Et.log(`Bundle JS already loaded: ${e}`);return}const i=this.loadingPromises.get(r);if(i)return Et.log(`Bundle JS already loading: ${e}`),i;const l=Dd(n),d=(l!==null?Cr(n,{id:r},{label:`bundle JS: ${e}`,retries:0}).catch(()=>(Et.warn(`Bundle JS static miss, falling back to API: ${e} (${n} -> ${l})`),Cr(xn(l),{id:r},{label:`bundle JS: ${e}`}))):Cr(n,{id:r},{label:`bundle JS: ${e}`})).then(()=>{Et.log(`Bundle JS loaded: ${e}`);const f=document.getElementById(r);f&&this.registerLoadedAsset(`bundle-${e}`,{type:"js",element:f}),this.loadingPromises.delete(r)}).catch(f=>{throw Et.warn(`Failed to load bundle JS: ${e} (${n})`,f),this.failedJsAssets.add(e),this.loadingPromises.delete(r),f});return this.loadingPromises.set(r,d),d}async loadCSS(e,n){const r=`module-css-${e}`;if(document.getElementById(r)){Et.log(`CSS already loaded: ${e}`);return}const i=this.loadingPromises.get(r);if(i)return Et.log(`CSS already loading: ${e}`),i;const l=sa(n,{id:r},{label:`CSS: ${e}`}).then(()=>{Et.log(`CSS loaded: ${e}`);const c=document.getElementById(r);c&&this.registerLoadedAsset(e,{type:"css",element:c}),this.loadingPromises.delete(r)}).catch(c=>{this.loadingPromises.delete(r),this.surfaceCssFailure(e,e,n,c)});return this.loadingPromises.set(r,l),l}surfaceCssFailure(e,n,r,i){Et.warn(`Failed to load CSS after retries: ${e} (${r})`,i),this.failedCssAssets.add(e),Ss({id:`ext-css:${e}`,label:n,retry:async()=>{document.getElementById(`module-css-${e}`)?.remove(),document.getElementById(`ext-bundle-css-${e.replace(/^bundle-/,"")}`)?.remove(),await sa(r,{},{label:`CSS retry: ${e}`}),this.failedCssAssets.delete(e)}})}async loadJS(e,n){const r=`module-js-${e}`;if(document.getElementById(r)){Et.log(`JS already loaded: ${e}`);return}const i=this.loadingPromises.get(e);if(i)return Et.log(`JS already loading: ${e}`),i;const l=Cr(n,{id:r},{label:`JS: ${e}`}).then(()=>{Et.log(`JS loaded: ${e}`);const c=document.getElementById(r);c&&this.registerLoadedAsset(e,{type:"js",element:c}),this.loadingPromises.delete(e)}).catch(c=>{throw Et.warn(`Failed to load JS: ${e} (${n})`,c),this.failedJsAssets.add(e),this.loadingPromises.delete(e),c});return this.loadingPromises.set(e,l),l}registerLoadedAsset(e,n){const r=this.loadedAssets.get(e)||[];r.push(n),this.loadedAssets.set(e,r)}unloadExtensionAsset(e){const n=this.loadedAssets.get(e);if(!n||n.length===0){Et.log(`No assets to unload for: ${e}`);return}n.forEach(r=>{r.element.parentNode&&(r.element.parentNode.removeChild(r.element),Et.log(`${r.type.toUpperCase()} unloaded: ${e}`))}),this.loadedAssets.delete(e),Et.log(`All assets unloaded for: ${e}`)}unloadAllAssets(){Array.from(this.loadedAssets.keys()).forEach(n=>{this.unloadExtensionAsset(n)}),Et.log("All module assets unloaded")}isLoaded(e){return this.loadedAssets.has(e)}getLoadedModules(){return Array.from(this.loadedAssets.keys())}}let Qf=null;function tx(){const s=window?.G7Config?.customAssets;return Array.isArray(s)?s.filter(e=>e&&typeof e.id=="string"&&typeof e.url=="string"&&(e.type==="style"||e.type==="script")):[]}function nx(s){return s.replace(/[^A-Za-z0-9_-]/g,"-")}function Zf(){return Qf||(Qf=new ex),Qf}function rx(){if(typeof window>"u")return[];const s=window.G7Config;if(!s?.moduleAssets)return[];const e=[];for(const[n,r]of Object.entries(s.moduleAssets)){const i=r;e.push({identifier:n,js:i.js?xn(i.js):i.js,css:i.css?xn(i.css):i.css,priority:i.priority,external:i.external})}return e}function ax(){if(typeof window>"u")return null;const s=window.G7Config;if(!s?.bundleUrls)return null;const e=s.bundleUrls;return{moduleJs:e.moduleJs?xn(e.moduleJs):e.moduleJs,moduleCss:e.moduleCss?xn(e.moduleCss):e.moduleCss,pluginJs:e.pluginJs?xn(e.pluginJs):e.pluginJs,pluginCss:e.pluginCss?xn(e.pluginCss):e.pluginCss}}function ix(){if(typeof window>"u")return[];const s=window.G7Config;if(!s?.pluginAssets)return[];const e=[];for(const[n,r]of Object.entries(s.pluginAssets)){const i=r;e.push({identifier:n,js:i.js?xn(i.js):i.js,css:i.css?xn(i.css):i.css,priority:i.priority,external:i.external})}return e}const eh=dt("SystemBannerManager");class Jc{static show(e){this.banners.set(e.id,e),this.render(),eh.log(`Banner shown: ${e.id}`)}static hide(e){this.banners.delete(e)&&(this.render(),eh.log(`Banner hidden: ${e}`))}static hideAll(){this.banners.clear(),this.render(),eh.log("All banners hidden")}static detectLocale(){try{const n=window.G7Core;if(n?.locale?.current)return n.locale.current()}catch{}return(navigator.language||"ko").split("-")[0]}static resolveMessage(e,n){return typeof e=="string"?e:e[n]||e.en||e.ko||Object.values(e)[0]||""}static render(){if(typeof document>"u")return;let e=document.getElementById(this.containerId);if(this.banners.size===0){e&&(e.remove(),this.adjustAppPadding(0));return}e||(e=document.createElement("div"),e.id=this.containerId,e.style.cssText="position:fixed;top:0;left:0;right:0;z-index:99999;",document.body.prepend(e));const n=Array.from(this.banners.values()).sort((i,l)=>(i.order??0)-(l.order??0)),r=this.detectLocale();e.innerHTML=n.map(i=>{const l=this.resolveMessage(i.message,r),c=i.background||"#f59e0b",d=i.color||"white";return`
${l}
`}).join(""),requestAnimationFrame(()=>{e&&this.adjustAppPadding(e.offsetHeight)})}static adjustAppPadding(e){const n=document.getElementById("app");n&&(n.style.paddingTop=e>0?`${e}px`:"")}}$(Jc,"banners",new Map),$(Jc,"containerId","g7-system-banners");const U=dt("TemplateApp");function ob(s){const e={};for(const n of s.keys()){if(n in e)continue;const r=s.getAll(n);r.length>1?e[n]=r:r.length===1&&(n.endsWith("[]")?e[n]=r:e[n]=r[0])}return e}const Lr=class Lr{constructor(e){$(this,"router",null);$(this,"layoutLoader",null);$(this,"errorPageHandler",null);$(this,"config");$(this,"globalState");$(this,"globalStateListeners",new Set);$(this,"currentRouteChangeId",0);$(this,"failedLayoutScripts",new Set);$(this,"currentDataSources",[]);$(this,"currentRawDataSources",[]);$(this,"currentRouteParams",{});$(this,"currentQueryParams",new URLSearchParams);$(this,"currentFetchedData",{});$(this,"currentLayoutName","");$(this,"templateErrorHandling",null);$(this,"currentWebSocketSubscriptions",[]);$(this,"extensionCacheVersion",0);$(this,"currentGlobalHeaders",[]);$(this,"transitionOverlayEl",null);$(this,"skeletonOverlayRoot",null);$(this,"skeletonOverlayContainer",null);$(this,"_spinnerState",null);$(this,"modalDataSources",new Map);this.globalState={sidebarOpen:!1},this.loadG7Config(),this.migrateLocaleStorage();const n=this.loadLocaleFromStorage(),r=n||e.locale||"ko";this.config={...e,locale:r},!n&&e.locale&&this.saveLocaleToStorage(e.locale)}loadG7Config(){if(typeof window<"u"&&window.G7Config){const e=window.G7Config;e.settings&&(this.globalState.settings=e.settings,U.log("Loaded settings from G7Config:",Object.keys(e.settings)),e.settings.upload&&(this.globalState.uploadSettings=e.settings.upload)),e.plugins&&(this.globalState.plugins=e.plugins,U.log("Loaded plugin settings from G7Config:",Object.keys(e.plugins))),e.modules&&(this.globalState.modules=e.modules,U.log("Loaded module settings from G7Config:",Object.keys(e.modules))),e.appConfig&&(this.globalState.appConfig=e.appConfig,U.log("Loaded appConfig from G7Config:",Object.keys(e.appConfig)))}}resolveRouteExpressions(e){const n=new Tn,r={_global:this.globalState};return e.map(i=>{const l={...i};if(l.path&&l.path.includes("{{")){const c=l.path;l.path=n.resolveBindings(l.path,r),l.path=l.path.replace(/\/\/+/g,"/")||"/",l.path.includes("{{")&&(U.warn("Route expression resolution failed, using fallback:",c),l.path=c.replace(/\{\{[^}]+\}\}/g,"").replace(/\/\/+/g,"/")||"/")}if(l.redirect&&l.redirect.includes("{{")){const c=l.redirect;l.redirect=n.resolveBindings(l.redirect,r),l.redirect=l.redirect.replace(/\/\/+/g,"/")||"/",l.redirect.includes("{{")&&(U.warn("Route redirect expression resolution failed:",c),l.redirect=c.replace(/\{\{[^}]+\}\}/g,"").replace(/\/\/+/g,"/")||"/")}return l})}migrateLocaleStorage(){const e=["locale","g7_template_locale"];for(const n of e)try{const r=localStorage.getItem(n);r&&r!==localStorage.getItem(Lr.LOCALE_STORAGE_KEY)&&(localStorage.setItem(Lr.LOCALE_STORAGE_KEY,r),U.log(`Migrated locale from '${n}' to '${Lr.LOCALE_STORAGE_KEY}'`)),localStorage.removeItem(n)}catch(r){U.warn(`Failed to migrate locale key '${n}':`,r)}}async init(){try{ho.getInstance().setDebug(this.config.debug),U.log("Initializing with config:",this.config),Ww();const e=Er.getInstance(),n=Yn.getInstance(),r=typeof window<"u"&&Number(window.G7Config?.cache_version)||0,i=r>0?r:this.loadCacheVersionFromStorage()||0,[l,c,d,f,p]=await Promise.all([Yo({templateId:this.config.templateId,templateType:this.config.templateType,locale:this.config.locale,debug:this.config.debug,cacheVersion:i}),e.loadComponents(this.config.templateId,this.config.templateType,i),ic(i>0?po(`templates/${this.config.templateId}/routes.json`,i):null,Pr(`/api/templates/${this.config.templateId}/routes`,"json",i>0?i:null),{label:"routes.json"}).then(w=>{if(!w.ok)throw new Error(`Failed to load routes: ${w.statusText}`);return w.json()}).then(w=>{if(!w.success)throw new Error("Failed to load routes from API");return w.data}).catch(w=>{throw U.error("Error loading routes:",w),w}),n.preloadAuth(this.config.templateType==="admin"?"admin":"user"),fetch(Pr(`/api/templates/${this.config.templateId}/config`,"json")).then(w=>w.ok?w.json():null).then(w=>!w?.success||!w?.data?null:w.data).catch(w=>(U.warn("Error loading template config:",w),null))]);if(U.log("Template Engine initialized"),U.log("ComponentRegistry loaded"),U.log("Routes data loaded"),U.log("User info preloaded"),U.log("Template config loaded:",p),p?.cache_version!==void 0){const w=i>0?i:null;if(this.extensionCacheVersion=p.cache_version,this.saveCacheVersionToStorage(this.extensionCacheVersion),U.log("Extension cache version:",this.extensionCacheVersion),w!==null&&w!==this.extensionCacheVersion){U.log("Cache version changed, reloading routes...");const R=await ic(po(`templates/${this.config.templateId}/routes.json`,this.extensionCacheVersion),Pr(`/api/templates/${this.config.templateId}/routes`,"json",this.extensionCacheVersion),{label:"routes.json (reload)"}).then(L=>{if(!L.ok)throw new Error(`Failed to reload routes: ${L.statusText}`);return L.json()}).then(L=>{if(!L.success)throw new Error("Failed to reload routes from API");return L.data});Array.isArray(R.routes)&&(R.routes=this.resolveRouteExpressions(R.routes),Object.assign(d,R),U.log("Routes reloaded with new cache version"));try{const{TranslationEngine:L}=await Promise.resolve().then(()=>$g),O=L.getInstance();O.setCacheVersion(this.extensionCacheVersion);const j=this.config.locale||"ko",F="en";await O.loadTranslations(this.config.templateId,j,"/api",!0),j!==F&&await O.loadTranslations(this.config.templateId,F,"/api",!0),U.log("Translations reloaded with new cache version")}catch(L){U.error("Failed to reload translations:",L)}}}p?.errorHandling&&(this.templateErrorHandling=p.errorHandling,Tr().setTemplateConfig(this.templateErrorHandling),U.log("Template errorHandling registered:",this.templateErrorHandling)),n.on("logout",()=>{U.log("User logged out")}),n.on("authStateChange",w=>{U.log("Auth state changed:",w)}),U.log("AuthManager event handlers registered");const m=Wn(),y=this.config.templateType==="admin"?"admin":"user",C=n.getConfig(y);m.setOnUnauthorized(()=>{U.log("Unauthorized - redirecting to login page"),m.removeToken();const w=window.location.pathname+window.location.search,R=n.getLoginRedirectUrl(y,w,"session_expired");window.location.href=R}),U.log("ApiClient onUnauthorized callback registered"),this.layoutLoader=new Gf(e),this.extensionCacheVersion>0&&this.layoutLoader.setCacheVersion(this.extensionCacheVersion),U.log("LayoutLoader initialized:",this.layoutLoader);const S=new Dr({onUnauthorized:()=>{U.warn("Unauthorized request in error page")}});if(this.errorPageHandler=new UA({templateId:this.config.templateId,layoutLoader:this.layoutLoader,locale:this.config.locale,debug:this.config.debug,renderFunction:Es,dataSourceManager:S,globalState:this.globalState}),U.log("ErrorPageHandler initialized with DataSourceManager"),await this.handleServerError()){U.log("Server error handled, skipping normal initialization");return}if(this.router=new zA(this.config.templateId),Array.isArray(d.routes)){const w=this.resolveRouteExpressions(d.routes);this.router.setRoutes(w)}else throw new Error("Invalid routes data format");U.log("Router initialized:",this.router),U.log("Routes set:",this.router.getRoutes());const{getActionDispatcher:v}=await Promise.resolve().then(()=>Wr),x=v();if(x&&(x.setDefaultContext({navigate:w=>this.router?.navigate(w)}),x.setGlobalStateUpdater((w,R)=>this.setGlobalState(w,R)),U.log("Navigate function and setGlobalState injected to ActionDispatcher")),await this.loadExtensionAssets(),this.reinitializeTemplateHandlers(),this.router.on("routeChange",w=>this.handleRouteChange(w)),this.router.on("routeNotFound",w=>this.handleRouteNotFound(w)),typeof window<"u"&&tb(window.location.pathname)){U.log("Layout editor mode detected — skipping router match"),await Es({containerId:"app",layoutJson:{components:[]},dataContext:{},translationContext:{templateId:this.config.templateId,locale:this.config.locale}}),U.log("Template App initialized in layout editor mode");return}this.router.navigateToCurrentPath(),U.log("Template App initialized successfully")}catch(e){U.error("Initialization failed:",e),this.showInitError(e)}}async loadExtensionAssets(){try{const e=Zf(),n=ax();if(!n){await this.loadExtensionAssetsIndividually(),await e.loadCustomAssets();return}await e.loadBundle("module",n.moduleJs,n.moduleCss),await e.loadBundle("plugin",n.pluginJs,n.pluginCss),await e.loadCustomAssets(),U.log("Extension bundle assets loaded successfully")}catch(e){U.warn("Failed to load extension assets:",e)}}async loadExtensionAssetsIndividually(){const e=Zf(),n=rx();n.length>0&&(U.log("Loading module assets (individual fallback):",n.map(i=>i.identifier)),await e.loadActiveExtensionAssets(n));const r=ix();r.length>0&&(U.log("Loading plugin assets (individual fallback):",r.map(i=>i.identifier)),await e.loadActiveExtensionAssets(r))}async handleRouteChange(e){const n=++this.currentRouteChangeId;window.__g7ForcedLocalFields=void 0,window.__g7ActionContext=void 0,window.__g7PendingLocalState=void 0,window.__g7LastSetLocalSnapshot=void 0,window.__g7SetLocalOverrideKeys=void 0,window.__g7SequenceLocalSync=void 0,window.__g7AutoBindingPaths=new Map;try{if(U.log("Route changed:",e,"requestId:",n),!this.layoutLoader)throw new Error("LayoutLoader is not initialized");if(!e.layout)throw new Error("Route layout is not defined");let r=e.layout;const i=r==="__preview__";i&&e.params?.token&&(r=`__preview__/${e.params.token}`);const l=await this.layoutLoader.loadLayout(this.config.templateId,r);if(n!==this.currentRouteChangeId){U.log("Route change cancelled (newer request exists):",n);return}U.log("Layout loaded:",l);const c=Tr();l.errorHandling?(c.setLayoutConfig(l.errorHandling),U.log("Layout errorHandling registered:",l.errorHandling)):c.clearLayoutConfig();const d=l.data_sources||[],f=e.query||{},p=new URLSearchParams;for(const[Z,ge]of Object.entries(f))if(Array.isArray(ge))for(const z of ge)p.append(Z,z);else p.set(Z,ge);const m={route:e.params||{},query:f,_global:this.globalState};l.scripts&&Array.isArray(l.scripts)&&await this.loadLayoutScripts(l.scripts,m);const{DataSourceManager:y,getActionDispatcher:C}=await Promise.resolve().then(()=>Wr),S=new y;if(i){const Z=C();Z&&Z.setPreviewMode(!0),this.setGlobalState({__isPreview:!0}),Jc.show({id:"preview-mode",message:{ko:"⚠ 미리보기 모드 — 페이지 이동이 비활성화됩니다",en:"⚠ Preview Mode — Navigation is disabled"},background:"linear-gradient(90deg, #f59e0b, #d97706)",color:"white"}),U.log("Preview mode activated")}else{const Z=C();Z?.isPreviewMode()&&(Z.setPreviewMode(!1),Jc.hide("preview-mode"))}if(this.currentGlobalHeaders=l.globalHeaders||[],this.currentGlobalHeaders.length>0){S.setGlobalHeaders(this.currentGlobalHeaders);const Z=C();Z&&Z.setGlobalHeaders(this.currentGlobalHeaders),U.log("globalHeaders set:",this.currentGlobalHeaders.map(ge=>ge.pattern))}if(l.named_actions&&Object.keys(l.named_actions).length>0){const Z=C();Z&&Z.setNamedActions(l.named_actions)}const v=S.filterByCondition(d,m);d.length!==v.length&&U.log("Data sources filtered by condition:",{before:d.map(Z=>Z.id),after:v.map(Z=>Z.id)});const x=v.filter(Z=>Z.loading_strategy==="blocking"),w=v.filter(Z=>(Z.loading_strategy||"progressive")!=="blocking"&&Z.type!=="websocket"),R=Array.isArray(l.transition_overlay?.wait_for)?l.transition_overlay.wait_for:[],L=R.length>0&&v.some(Z=>R.includes(Z.id)&&Z.type!=="websocket"&&(Z.loading_strategy||"progressive")!=="background");if((x.length>0||L)&&l.transition_overlay){const Z=typeof l.transition_overlay=="boolean"?{enabled:l.transition_overlay,style:"opaque"}:l.transition_overlay;Z.enabled&&Z.style==="skeleton"&&Z.skeleton?.component&&Z.target?this.renderSkeletonOverlay(Z.target,Z.skeleton,l,Z.fallback_target):Z.enabled&&Z.style==="spinner"&&Z.target&&this.renderSpinnerOverlay(Z.target,Z.spinner,Z.fallback_target)}let O={},j={},F={},G={};this.currentWebSocketSubscriptions.length>0&&(U.log("Unsubscribing previous WebSocket subscriptions:",this.currentWebSocketSubscriptions),S.unsubscribeWebSockets(this.currentWebSocketSubscriptions),this.currentWebSocketSubscriptions=[]),this.currentDataSources=v,this.currentRawDataSources=d,this.currentRouteParams=e.params||{},this.currentQueryParams=p,U.log(`handleRouteChange #${n} - queryObject:`,f),U.log(`handleRouteChange #${n} - queryParams:`,p.toString()),x.length>0&&(U.log("Fetching blocking data sources:",x.map(ge=>ge.id)),(await S.fetchDataSourcesWithResults(x,e.params||{},p)).forEach(ge=>{if(ge.state==="success"&&ge.data!==void 0)O[ge.id]=ge.data;else if(ge.state==="error"&&ge.error){const z=ge.error,T=z.response?.data?.message;j[ge.id]={message:T||ge.error.message,status:z.response?.status||z.status}}}),this.processInitOptions(x,O,F,G),this.currentFetchedData={...O},U.log("Blocking data loaded:",Object.keys(O)),Object.keys(j).length>0&&U.log("Data source errors:",j),Object.keys(F).length>0&&U.log("Local state init (blocking):",Object.keys(F)),Object.keys(G).length>0&&U.log("Isolated state init (blocking):",Object.keys(G)));const P=w.length>0;if(P&&(Gr.setPending(!0),U.log("Transition started before rendering")),n!==this.currentRouteChangeId){U.log("Route change cancelled after blocking data (newer request exists):",n);return}const{getState:K}=await Promise.resolve().then(()=>Wr),he=K().currentDataContext||{},Ee=w.map(Z=>Z.id),ke={};if(P){Ee.forEach(ge=>{he[ge]!==void 0?ke[ge]=he[ge]:ke[ge]=void 0});const Z=Object.keys(ke).filter(ge=>ke[ge]!==void 0);Z.length>0&&U.log("Preserving previous progressive data:",Z),U.log("Progressive data sources initialized:",Ee)}const ze=l.defines||{},Be={...ke,...e.params,...O,route:{...e.params||{},path:e.path},query:f,_global:{...this.globalState},_globalSetState:Z=>this.setGlobalState(Z),_dataSourceErrors:Object.keys(j).length>0?j:void 0,_localInit:Object.keys(F).length>0?F:void 0,_isolatedInit:Object.keys(G).length>0?G:void 0,_defines:Object.keys(ze).length>0?ze:void 0};if(l.computed&&Object.keys(l.computed).length>0){const Z=this.calculateComputed(l.computed,Be);Object.keys(Z).length>0&&(Be._computed=Z,this.globalState._computed=Z,U.log("Computed values calculated:",Object.keys(Z))),Be._computedDefinitions=l.computed}const je=l.layout_name||e.layout;this.currentLayoutName!==""&&this.currentLayoutName!==je&&(U.log("_local reset due to layout change:",{from:this.currentLayoutName,to:je}),this.globalState._local={},eE()),this.currentLayoutName=je;const X=l.initLocal||l.state;if(X&&Object.keys(X).length>0){this.globalState._local||(this.globalState._local={});for(const[Z,ge]of Object.entries(X))this.globalState._local[Z]===void 0&&(this.globalState._local[Z]=JSON.parse(JSON.stringify(ge)));Be._local={...this.globalState._local},U.log("initLocal applied to _local:",Object.keys(X))}if(l.initGlobal&&Object.keys(l.initGlobal).length>0){for(const[Z,ge]of Object.entries(l.initGlobal))this.globalState[Z]===void 0&&(this.globalState[Z]=JSON.parse(JSON.stringify(ge)));U.log("initGlobal applied to _global:",Object.keys(l.initGlobal))}if(l.initIsolated&&Object.keys(l.initIsolated).length>0){for(const[Z,ge]of Object.entries(l.initIsolated))G[Z]===void 0&&(G[Z]=JSON.parse(JSON.stringify(ge)));U.log("initIsolated applied:",Object.keys(l.initIsolated))}Be._global={...this.globalState,layoutWarnings:l.warnings||[]};const de=l.initActions||l.init_actions;if(de&&de.length>0){await this.executeInitActions(de,Be),U.log("initActions executed before render");const Z=this.globalState;if(Z._local){if(Object.keys(F).length>0){for(const[ge,z]of Object.entries(F))Z._local[ge]!==void 0?Z._local[ge]=this.deepMerge(Z._local[ge],z):Z._local[ge]=z;U.log("localInit merged into _local after initActions:",Object.keys(F))}Be._local=Z._local,U.log("_local merged into dataContext:",Z._local)}if(Be._global={...this.globalState,layoutWarnings:l.warnings||[]},U.log("_global merged into dataContext after initActions"),l.computed&&Object.keys(l.computed).length>0){const ge=this.calculateComputed(l.computed,Be);Object.keys(ge).length>0&&(Be._computed=ge,this.globalState._computed=ge,U.log("Computed values recalculated after init_actions:",Object.keys(ge)))}if(Object.keys(this.currentFetchedData).length>0){for(const[ge,z]of Object.entries(this.currentFetchedData))Be[ge]=z;U.log("Fetched data sources merged into dataContext after initActions:",Object.keys(this.currentFetchedData))}}if(l.transition_overlay&&!this.skeletonOverlayContainer&&this.showTransitionOverlay(l.transition_overlay,l),await Es({containerId:"app",layoutJson:l,dataContext:Be,translationContext:{templateId:this.config.templateId,locale:this.config.locale}}),U.log("Initial render complete with blocking data"),this.reattachSpinnerOverlay(),w.length>0){if(n!==this.currentRouteChangeId){U.log("Route change cancelled before progressive fetch (newer request exists):",n),Gr.setPending(!1),this.hideTransitionOverlay();return}U.log("Fetching progressive/background data sources:",w.map(z=>z.id));const{updateTemplateData:Z,getState:ge}=await Promise.resolve().then(()=>Wr);try{const z=w.map(async T=>{try{const fe=(await S.fetchDataSourcesWithResults([T],e.params||{},p,this.globalState))[0];if(!fe){U.log(`Data source ${T.id} skipped (no fetch result)`);return}if(n!==this.currentRouteChangeId){U.log(`Data source ${T.id} fetch cancelled (newer request exists)`);return}if(fe.state==="success"&&fe.data!==void 0){U.log(`Progressive data source loaded: ${T.id}`),this.currentFetchedData[T.id]=fe.data;const me={};this.processInitOptions([T],{[T.id]:fe.data},me);const ae=ge();if(ae.bindingEngine){const Pe=[T.id];T.initGlobal&&Pe.push("_global"),T.initLocal&&Pe.push("_local"),ae.bindingEngine.invalidateCacheByKeys(Pe)}const Re={[T.id]:fe.data};Object.keys(me).length>0&&(Re._localInit=me,Object.assign(F,me)),T.initGlobal&&(Re._global={...this.globalState}),Z(Re)}else if(fe.state==="error"&&fe.error){const me=fe.error,ae=me.response?.data?.message;j[T.id]={message:ae||fe.error.message,status:me.response?.status||me.status},U.log(`Progressive data source error: ${T.id}`,j[T.id]),Z({[T.id]:null,_dataSourceErrors:{...j}})}}catch(pe){U.error(`Failed to fetch data source: ${T.id}`,pe)}});if(await Promise.all(z),n!==this.currentRouteChangeId){U.log("Route change cancelled after progressive fetch (newer request exists):",n);return}U.log("All progressive data sources loaded")}finally{Gr.setPending(!1),this.hideTransitionOverlay()}}else this.hideTransitionOverlay();const Ce=v.filter(Z=>Z.type==="websocket");if(Ce.length>0){U.log("Subscribing WebSocket data sources:",Ce.map(T=>T.id));const{updateTemplateData:Z,getState:ge}=await Promise.resolve().then(()=>Wr),z={...this.currentFetchedData,...e.params,route:{...e.params||{},path:e.path},query:f,_global:{...this.globalState}};U.log("WebSocket binding context keys:",Object.keys(z)),this.currentWebSocketSubscriptions=S.subscribeWebSockets(v,(T,pe)=>{U.log(`WebSocket data received for: ${T}`,pe),this.currentFetchedData[T]=pe;const fe=v.find(Pe=>Pe.id===T),me=ge();if(me.bindingEngine){const Pe=[T];fe?.initGlobal&&Pe.push("_global"),fe?.initLocal&&Pe.push("_local"),me.bindingEngine.invalidateCacheByKeys(Pe)}Z({[T]:pe});const Re=v.find(Pe=>Pe.type==="websocket"&&(Pe.target_source||Pe.id)===T)?.onReceive;Array.isArray(Re)&&Re.length>0&&window.G7Core?.dispatch&&(async()=>{for(const Me of Re)try{const Ge=this.getActionDispatcher?.();Ge&&await Ge.dispatchAction(Me,{navigate:this.getRouter?.()?(kt,vt)=>this.getRouter().navigate(kt,vt):void 0,setState:kt=>this.setGlobalState(kt),state:this.globalState,data:{...this.globalState,$args:[pe],$event:pe},_isDispatchFallbackContext:!0})}catch(Ge){U.error(`WebSocket onReceive action failed for ${T}:`,Ge)}})()},z),U.log("WebSocket subscriptions established:",this.currentWebSocketSubscriptions)}U.log("Layout rendered successfully")}catch(r){U.error("Route change handling failed:",r),this.hideTransitionOverlay(),this.showRouteError(r)}}processInitOptions(e,n,r,i){e.some(c=>c.refetchOnMount===!0&&c.initLocal)&&(r._forceLocalInit=Date.now(),U.log("refetchOnMount detected, forcing local state init")),e.forEach(c=>{const d=n[c.id];if(!d)return;const f=d.data??d;if(c.initLocal){if(typeof c.initLocal=="string"){let p=f;if(c.initLocalDefaults&&typeof c.initLocalDefaults=="object"){const y=this.evaluateDefaults(c.initLocalDefaults,n);p={...y,...f},U.log(`initLocalDefaults applied for ${c.initLocal}:`,Object.keys(y))}const m=this.globalState._local?.[c.initLocal];m!==void 0&&typeof m=="object"&&typeof p=="object"?(r[c.initLocal]=this.deepMerge(m,p),U.log(`initLocal (merged): ${c.id}.data -> _local.${c.initLocal}`)):(r[c.initLocal]=p,U.log(`initLocal: ${c.id}.data -> _local.${c.initLocal}`))}else if(typeof c.initLocal=="object"&&c.initLocal.key){const{key:p,path:m}=c.initLocal;let y=m?this.extractValueByPathOrExpression(f,m,c.id):f;if(c.initLocalDefaults&&typeof c.initLocalDefaults=="object"){const S=this.evaluateDefaults(c.initLocalDefaults,n);y={...S,...y},U.log(`initLocalDefaults applied for ${p}:`,Object.keys(S))}const C=this.globalState._local?.[p];C!==void 0&&typeof C=="object"&&typeof y=="object"?(r[p]=this.deepMerge(C,y),U.log(`initLocal (merged): ${c.id}.data${m?"."+m:""} -> _local.${p}`)):(r[p]=y,U.log(`initLocal: ${c.id}.data${m?"."+m:""} -> _local.${p}`))}else if(typeof c.initLocal=="object"){const p=c.initLocal._merge||"deep",m=this.flattenNestedObjectToMappings(c.initLocal);for(const{targetPath:y,sourcePath:C}of m){const S=this.extractValueByPathOrExpression(f,C,c.id);if(y.includes(".")){const v=y.split(".")[0];r[v]===void 0&&this.globalState._local?.[v]!==void 0&&(r[v]=JSON.parse(JSON.stringify(this.globalState._local[v]))),this.setValueAtPath(r,y,S,p),U.log(`initLocal map (${p}): ${c.id} ${C} -> _local.${y}`)}else{const v=this.globalState._local?.[y];p==="replace"?(r[y]=S,U.log(`initLocal map (replace): ${c.id} ${C} -> _local.${y}`)):p==="shallow"?v!==void 0&&typeof v=="object"&&typeof S=="object"?(r[y]={...v,...S},U.log(`initLocal map (shallow): ${c.id} ${C} -> _local.${y}`)):(r[y]=S,U.log(`initLocal map: ${c.id} ${C} -> _local.${y}`)):v!==void 0&&typeof v=="object"&&typeof S=="object"?(r[y]=this.deepMerge(v,S),U.log(`initLocal map (deep): ${c.id} ${C} -> _local.${y}`)):(r[y]=S,U.log(`initLocal map: ${c.id} ${C} -> _local.${y}`))}}}}if(c.initGlobal)if(typeof c.initGlobal=="object"&&!Array.isArray(c.initGlobal)&&!("key"in c.initGlobal))for(const[m,y]of Object.entries(c.initGlobal)){if(typeof y!="string"){U.warn(`initGlobal map value must be string, got ${typeof y} for key ${m}`);continue}const C=this.extractValueByPathOrExpression(f,y,c.id),S=this.globalState[m];S!==void 0&&typeof S=="object"&&typeof C=="object"?(this.globalState[m]=this.deepMerge(S,C),U.log(`initGlobal map (merged): ${c.id} ${y} -> _global.${m}`)):(this.globalState[m]=C,U.log(`initGlobal map: ${c.id} ${y} -> _global.${m}`))}else{const m=Array.isArray(c.initGlobal)?c.initGlobal:[c.initGlobal];for(const y of m)if(typeof y=="string"){const C=this.globalState[y];C!==void 0&&typeof C=="object"&&typeof f=="object"?(this.globalState[y]=this.deepMerge(C,f),U.log(`initGlobal (merged): ${c.id}.data -> _global.${y}`)):(this.globalState[y]=f,U.log(`initGlobal: ${c.id}.data -> _global.${y}`))}else if(typeof y=="object"&&y.key){const{key:C,path:S}=y,v=S?this.extractValueByPathOrExpression(f,S,c.id):f,x=this.globalState[C];x!==void 0&&typeof x=="object"&&typeof v=="object"?(this.globalState[C]=this.deepMerge(x,v),U.log(`initGlobal (merged): ${c.id}.data${S?"."+S:""} -> _global.${C}`)):(this.globalState[C]=v,U.log(`initGlobal: ${c.id}.data${S?"."+S:""} -> _global.${C}`))}}if(i&&c.initIsolated){if(typeof c.initIsolated=="string"){const p=i[c.initIsolated];p!==void 0&&typeof p=="object"&&typeof f=="object"?(i[c.initIsolated]=this.deepMerge(p,f),U.log(`initIsolated (merged): ${c.id}.data -> _isolated.${c.initIsolated}`)):(i[c.initIsolated]=f,U.log(`initIsolated: ${c.id}.data -> _isolated.${c.initIsolated}`))}else if(typeof c.initIsolated=="object"&&c.initIsolated.key){const{key:p,path:m}=c.initIsolated,y=m?this.extractValueByPathOrExpression(f,m,c.id):f,C=i[p];C!==void 0&&typeof C=="object"&&typeof y=="object"?(i[p]=this.deepMerge(C,y),U.log(`initIsolated (merged): ${c.id}.data${m?"."+m:""} -> _isolated.${p}`)):(i[p]=y,U.log(`initIsolated: ${c.id}.data${m?"."+m:""} -> _isolated.${p}`))}else if(typeof c.initIsolated=="object")for(const[p,m]of Object.entries(c.initIsolated)){if(typeof m!="string"){U.warn(`initIsolated map value must be string, got ${typeof m} for key ${p}`);continue}const y=this.extractValueByPathOrExpression(f,m,c.id),C=i[p];C!==void 0&&typeof C=="object"&&typeof y=="object"?(i[p]=this.deepMerge(C,y),U.log(`initIsolated map (merged): ${c.id} ${m} -> _isolated.${p}`)):(i[p]=y,U.log(`initIsolated map: ${c.id} ${m} -> _isolated.${p}`))}}})}evaluateDefaults(e,n){const r={};for(const[i,l]of Object.entries(e))if(typeof l=="string"&&l.startsWith("{{")&&l.endsWith("}}")){const c=l.slice(2,-2).trim();r[i]=this.evaluateExpression(c,n)}else r[i]=l;return r}evaluateExpression(e,n){try{const r=e.split("??").map(i=>i.trim());for(const i of r){if(/^['"].*['"]$/.test(i))return i.slice(1,-1);if(i==="true")return!0;if(i==="false")return!1;if(/^-?\d+(\.\d+)?$/.test(i))return Number(i);const l=this.getNestedValue(n,i);if(l!=null)return l}return}catch(r){U.warn(`Expression evaluation failed: ${e}`,r);return}}getNestedValue(e,n){const r=n.replace(/\?\./g,".");let i=e;const l=r.split(/\.(?![^\[]*\])/).flatMap(c=>{const d=c.match(/^([^\[]*)((?:\[\d+\])*)$/);if(d){const[,f,p]=d,m=[];f&&m.push(f);const y=p.match(/\[\d+\]/g);return y&&m.push(...y),m}return[c]}).filter(c=>c!=="");for(const c of l){if(i==null)return;if(c.startsWith("[")&&c.endsWith("]")){const d=parseInt(c.slice(1,-1),10);i=i[d]}else i=i[c]}return i}extractValueByPathOrExpression(e,n,r){const i=Ma(n);if(i!==null){const l=new Tn,c={data:e,_global:this.globalState,_local:this.globalState._local||{}};try{const d=On(i)?l.evaluatePipeExpression(i,c,{skipCache:!0}):l.evaluateExpression(i,c);return U.log(`initLocal/initGlobal expression evaluated: ${n} -> `,d),d}catch(d){U.warn(`initLocal/initGlobal expression evaluation failed for ${r}:`,n,d);return}}return this.getNestedValue(e,n)}async loadLayoutScripts(e,n){const r=[];for(const i of e){if((i.if!==void 0||i.conditions!==void 0)&&!os({if:i.if,conditions:i.conditions},n,this.bindingEngine,`script:${i.id}`)){U.log(`Script skipped (condition not met): ${i.id}`);continue}if(document.getElementById(i.id)){U.log(`Script already loaded: ${i.id}`);continue}if(!this.isAllowedScriptSrc(i.src)){U.warn(`Blocked untrusted external script src (same-origin path or declared trusted host required): ${i.id} (${i.src})`);continue}r.push(this.loadLayoutScript(i))}r.length>0&&(await Promise.all(r),U.log(`All scripts loaded: ${e.filter(i=>!document.getElementById(i.id)||r.length>0).map(i=>i.id).join(", ")}`))}async loadLayoutScript(e){const n=e.src.startsWith("/")?xn(e.src):e.src;try{await Cr(n,{id:e.id},{label:`layout-script:${e.id}`}),this.failedLayoutScripts.delete(e.id),rb(`layout-script:${e.id}`),U.log(`Script loaded successfully: ${e.id}`)}catch(r){this.failedLayoutScripts.add(e.id),U.warn(`Failed to load script after retries: ${e.id} (${n})`,r),Ss({id:`layout-script:${e.id}`,label:e.id,retry:async()=>{document.getElementById(e.id)?.remove(),await Cr(n,{id:e.id},{label:`layout-script:${e.id}`}),this.failedLayoutScripts.delete(e.id)}})}}getFailedLayoutScripts(){return Array.from(this.failedLayoutScripts)}isAllowedScriptSrc(e){return Oo(e)}static normalizeScriptSrcForOriginCheck(e){return Gm(e)}extractScriptHost(e){return Fm(e)}getTrustedScriptHosts(){return fs()}evaluateScriptCondition(e,n){try{if(e.startsWith("{{")&&e.endsWith("}}")){const r=e.slice(2,-2).trim();return!!Jd(r,n)}return!!e}catch(r){return U.warn(`Failed to evaluate script condition: ${e}`,r),!1}}showInitError(e){if(rc()){U.warn("Init failed while document is unloading — skipping error screen",e);return}const n=eb(e);Jf.renderFromError("app",n,"초기화 실패",this.config.debug,{templateId:this.config.templateId,locale:this.config.locale},void 0,e)}showTransitionOverlay(e,n){const r=typeof e=="boolean"?{enabled:e,style:"opaque",target:void 0,skeleton:void 0,spinner:void 0}:{enabled:e.enabled,style:e.style||"opaque",target:e.target,skeleton:e.skeleton,spinner:e.spinner,fallback_target:e.fallback_target};if(!r.enabled)return;if(this.hideTransitionOverlay(),r.style==="skeleton"&&r.skeleton?.component&&r.target&&n){this.renderSkeletonOverlay(r.target,r.skeleton,n,r.fallback_target);return}if(r.style==="spinner"&&r.target){this.renderSpinnerOverlay(r.target,r.spinner,r.fallback_target);return}const i=document.documentElement.classList.contains("dark");let l,c="";switch(r.style){case"blur":l=i?"rgba(17,24,39,0.3)":"rgba(255,255,255,0.3)",c="backdrop-filter:blur(4px);-webkit-backdrop-filter:blur(4px);";break;case"fade":l=i?"rgba(17,24,39,0.8)":"rgba(255,255,255,0.8)";break;case"skeleton":l=i?"rgb(17,24,39)":"rgb(249,250,251)";break;case"opaque":default:l=i?"rgb(17,24,39)":"rgb(249,250,251)";break}if(r.target){const d=`#${CSS.escape(r.target)}`,f=document.createElement("style");f.id="g7-transition-overlay",f.textContent=`${d}{position:relative;z-index:0;}${d}::after{content:'';position:absolute;inset:0;background:${l};${c}z-index:2147483647;pointer-events:none;}`,document.head.appendChild(f),this.transitionOverlayEl=f}else{const d=document.createElement("div");d.id="g7-transition-overlay",d.setAttribute("aria-hidden","true"),d.style.position="fixed",d.style.inset="0",d.style.zIndex="9999",d.style.pointerEvents="none",d.style.background=l;for(const f of c.split(";")){const p=f.indexOf(":");p!==-1&&d.style.setProperty(f.slice(0,p).trim(),f.slice(p+1).trim())}document.body.appendChild(d),this.transitionOverlayEl=d}}hideTransitionOverlay(){this.transitionOverlayEl&&(this.transitionOverlayEl.remove(),this.transitionOverlayEl=null),this.hideSkeletonOverlay()}renderSkeletonOverlay(e,n,r,i){const c=Er.getInstance().getComponent(n.component);if(!c){U.log(`Skeleton component "${n.component}" not found in registry, falling back to opaque overlay`),this.showTransitionOverlay({enabled:!0,style:"opaque",target:e});return}let d=document.getElementById(e),f="target";if(!d&&i&&(d=document.getElementById(i),f="fallback"),d||(d=document.getElementById("app"),f="fullpage"),!d){U.log(`Skeleton overlay: no target found (target="#${e}", fallback="${i||"none"}"), falling back to opaque overlay`),this.showTransitionOverlay({enabled:!0,style:"opaque",target:e});return}this.hideSkeletonOverlay();const m=document.documentElement.classList.contains("dark")?"rgb(17,24,39)":"rgb(249,250,251)",y=f==="fullpage"?"app":f==="fallback"?i:e,C=`#${CSS.escape(y)}`,S=document.createElement("style");S.id="g7-skeleton-overlay-style",S.textContent=`${C}{position:relative;z-index:0;}${C}::after{content:'';position:absolute;inset:0;background:${m};z-index:2147483646;pointer-events:none;}`,document.head.appendChild(S),this.transitionOverlayEl=S;const v=document.createElement("div");if(v.id="g7-skeleton-overlay",v.setAttribute("role","status"),v.setAttribute("aria-busy","true"),v.setAttribute("aria-label","Loading..."),f==="fullpage")v.style.cssText=["position:fixed","inset:0","z-index:20","overflow:hidden","pointer-events:none",`background:${m}`].join(";")+";";else{const O=d.getBoundingClientRect(),j=window.scrollX||document.documentElement.scrollLeft,F=window.scrollY||document.documentElement.scrollTop;v.style.cssText=["position:absolute",`top:${O.top+F}px`,`left:${O.left+j}px`,`width:${O.width}px`,`height:${O.height}px`,"z-index:20","overflow:hidden","pointer-events:none",`background:${m}`].join(";")+";"}document.body.appendChild(v),this.skeletonOverlayContainer=v;const x=r.components||[];let w;if(f==="fullpage")w=x;else{const O=f==="fallback"?i:e;w=this.findComponentChildrenById(x,O)}const R=_d.createRoot(v);this.skeletonOverlayRoot=R,za.flushSync(()=>{R.render(We.createElement(c,{components:w,options:{animation:n.animation||"pulse",iteration_count:n.iteration_count||5}}))});const L=f==="fullpage"?"fullpage (#app)":f==="fallback"?`fallback (#${i})`:`target (#${e})`;U.log(`Skeleton overlay rendered [${L}] with "${n.component}" (${w.length} components)`)}findComponentChildrenById(e,n){const r=i=>{for(const l of i){if(l.id===n)return l.children||[];if(l.children&&Array.isArray(l.children)){const c=r(l.children);if(c!==null)return c}}return null};return r(e)||e}renderSpinnerOverlay(e,n,r){let i=document.getElementById(e),l="target";if(!i&&r&&(i=document.getElementById(r),l="fallback"),i||(i=document.getElementById("app"),l="fullpage"),!i){U.log(`Spinner overlay: no target found (target="#${e}", fallback="${r||"none"}"), falling back to opaque overlay`),this.showTransitionOverlay({enabled:!0,style:"opaque",target:e});return}this.hideSkeletonOverlay();const c=l==="fullpage"?"app":l==="fallback"?r:e,d=`#${CSS.escape(c)}`,f=document.createElement("style");f.id="g7-skeleton-overlay-style",f.textContent=[`${d}{position:relative;}`,"@keyframes g7-spin{to{transform:rotate(360deg)}}"].join(""),document.head.appendChild(f),this.transitionOverlayEl=f;const p=n?.text||window.G7Core?.t?.("nav.loading")||"";this._spinnerState={target:e,fallbackTarget:r,spinnerConfig:n,resolvedText:p},this._mountSpinnerInTarget(i);const m=l==="fullpage"?"fullpage (#app)":l==="fallback"?`fallback (#${r})`:`target (#${e})`,y=n?.component||"default spinner";U.log(`Spinner overlay rendered [${m}] with "${y}"`)}_mountSpinnerInTarget(e){if(!this._spinnerState)return;const{spinnerConfig:n,resolvedText:r}=this._spinnerState;if(this.skeletonOverlayRoot){try{this.skeletonOverlayRoot.unmount()}catch{}this.skeletonOverlayRoot=null}if(this.skeletonOverlayContainer){try{this.skeletonOverlayContainer.remove()}catch{}this.skeletonOverlayContainer=null}const i=document.createElement("div");if(i.id="g7-skeleton-overlay",i.setAttribute("role","status"),i.setAttribute("aria-busy","true"),e.appendChild(i),this.skeletonOverlayContainer=i,n?.component){const c=Er.getInstance().getComponent(n.component);if(c){const d=_d.createRoot(i);this.skeletonOverlayRoot=d,za.flushSync(()=>{d.render(We.createElement(c,{options:{text:r}}))});return}U.log(`Spinner component "${n.component}" not found in registry, using default spinner`)}i.innerHTML='
'}reattachSpinnerOverlay(){if(!this._spinnerState)return;const{target:e,fallbackTarget:n}=this._spinnerState;let r=document.getElementById(e);!r&&n&&(r=document.getElementById(n)),r||(r=document.getElementById("app")),r&&(this._mountSpinnerInTarget(r),U.log("Spinner overlay reattached to new DOM target"))}hideSkeletonOverlay(){if(this.skeletonOverlayRoot){try{this.skeletonOverlayRoot.unmount()}catch{}this.skeletonOverlayRoot=null}if(this.skeletonOverlayContainer){try{this.skeletonOverlayContainer.parentNode&&this.skeletonOverlayContainer.remove()}catch{}this.skeletonOverlayContainer=null}const e=document.getElementById("g7-skeleton-overlay-style");e&&e.remove(),this._spinnerState=null}showRouteError(e){if(e instanceof Rr&&e.details?.status===401){const r=this.config.templateId||"",i=window.location.pathname,l=r.includes("admin")||i.startsWith("/admin")?"admin":"user",c=i+window.location.search,d=!!Wn().getToken()||e.details?.hadToken===!0,f=Yn.getInstance().getLoginRedirectUrl(l,c,d?"session_expired":void 0);window.location.href=f;return}const n=eb(e);Jf.renderFromError("app",n,"페이지 로딩 실패",this.config.debug,{templateId:this.config.templateId,locale:this.config.locale},void 0,e)}async handleServerError(){const e=window.G7Error;if(!e)return!1;U.warn("Server error detected:",e);try{return this.errorPageHandler&&(e.data&&(this.globalState.errorData=e.data),this.errorPageHandler.updateGlobalState(this.globalState),this.errorPageHandler.updateLocale(this.config.locale),await this.errorPageHandler.renderError(e.code,"app"))?(U.log(`${e.code} error page rendered successfully`),!0):(U.log(`Falling back to ErrorDisplay for ${e.code}`),this.showInitError(new Error(`Service unavailable (${e.code})`)),!0)}catch(n){return U.error(`Failed to render ${e.code} page:`,n),this.showInitError(new Error(`Service unavailable (${e.code})`)),!0}}async handleRouteNotFound(e){U.warn("Route not found:",e);try{if(this.errorPageHandler&&(this.errorPageHandler.updateGlobalState(this.globalState),this.errorPageHandler.updateLocale(this.config.locale),await this.errorPageHandler.renderError(404,"app"))){U.log("404 error page rendered successfully");return}U.log("Falling back to ErrorDisplay for 404"),this.showRouteError(new Error(`Page not found: ${e}`))}catch(n){U.error("Failed to render 404 page:",n),this.showRouteError(new Error(`Page not found: ${e}`))}}getRouter(){return this.router}getConfig(){return this.config}getLayoutLoader(){return this.layoutLoader}async reloadExtensionState(){U.log("reloadExtensionState: start");let e;try{const n=await fetch(Pr(`/api/templates/${this.config.templateId}/config`,"json",null,`_=${Date.now()}`));if(n.ok){const r=await n.json();r?.success&&r?.data?.cache_version!==void 0&&(e=r.data.cache_version)}}catch(n){U.warn("reloadExtensionState: failed to fetch config.json",n)}e!==void 0&&e!==this.extensionCacheVersion&&(U.log(`reloadExtensionState: cache version ${this.extensionCacheVersion} -> ${e}`),this.extensionCacheVersion=e,this.saveCacheVersionToStorage(e));try{this.router&&(await this.router.loadRoutes(this.extensionCacheVersion),U.log("reloadExtensionState: routes reloaded"))}catch(n){U.error("reloadExtensionState: routes reload failed",n)}try{this.layoutLoader&&(this.extensionCacheVersion>0&&this.layoutLoader.setCacheVersion(this.extensionCacheVersion),this.layoutLoader.clear(),U.log("reloadExtensionState: layout cache cleared"))}catch(n){U.error("reloadExtensionState: layout cache clear failed",n)}try{const{TranslationEngine:n}=await Promise.resolve().then(()=>$g),r=n.getInstance();this.extensionCacheVersion>0&&r.setCacheVersion(this.extensionCacheVersion);const i=this.config.locale||"ko",l="en";await r.loadTranslations(this.config.templateId,i,"/api",!0),i!==l&&await r.loadTranslations(this.config.templateId,l,"/api",!0),U.log("reloadExtensionState: translations reloaded")}catch(n){U.error("reloadExtensionState: translations reload failed",n)}try{const n=await fetch(`/api/locales/active?_=${Date.now()}`);if(n.ok){const i=(await n.json())?.data?.locales;if(Array.isArray(i)&&i.length>0){const l=this.globalState.appConfig??{};this.setGlobalState({appConfig:{...l,supportedLocales:i}}),U.log("reloadExtensionState: supportedLocales refreshed",i)}}}catch(n){U.warn("reloadExtensionState: supportedLocales refresh failed",n)}U.log("reloadExtensionState: done")}getActionDispatcher(){return ca().actionDispatcher}async changeLocale(e){try{if(U.log("Changing locale to:",e),this.config.locale===e){U.log("Locale is already",e);return}this.config.locale=e,this.saveLocaleToStorage(e),await this.saveLocaleToDatabase(e),this.layoutLoader&&(this.layoutLoader.clear(),U.log("Layout cache cleared")),this.errorPageHandler&&(this.errorPageHandler.updateLocale(e),U.log("ErrorPageHandler locale updated")),Qc(),await Yo({templateId:this.config.templateId,templateType:this.config.templateType,locale:e,debug:this.config.debug,cacheVersion:this.extensionCacheVersion}),U.log("Template Engine re-initialized with new locale");const{getActionDispatcher:n}=await Promise.resolve().then(()=>Wr),r=n();r&&(r.setDefaultContext({navigate:i=>this.router?.navigate(i)}),r.setGlobalStateUpdater((i,l)=>this.setGlobalState(i,l)),U.log("Navigate function and setGlobalState re-injected to ActionDispatcher")),this.reinitializeModuleHandlers(),U.log("Module handlers re-initialized"),this.reinitializeTemplateHandlers(),U.log("Template handlers re-initialized"),this.reinitializePluginHandlers(),U.log("Plugin handlers re-initialized"),this.router&&this.router.navigateToCurrentPath(),U.log("Locale changed successfully to",e)}catch(n){throw U.error("Failed to change locale:",n),n}}loadLocaleFromStorage(){try{return localStorage.getItem(Lr.LOCALE_STORAGE_KEY)}catch(e){return U.warn("Failed to load locale from storage:",e),null}}saveLocaleToStorage(e){try{localStorage.setItem(Lr.LOCALE_STORAGE_KEY,e)}catch(n){U.warn("Failed to save locale to storage:",n)}}async saveLocaleToDatabase(e){const n=localStorage.getItem("auth_token");if(!n){U.log("No auth token, skipping DB locale save");return}let r,i;if(this.config.localeApi)r=this.config.localeApi.endpoint,i=this.config.localeApi.method;else{const l=this.config.templateType==="admin";r=l?"/api/admin/users/me/language":"/api/user/profile/update-language",i=l?"PATCH":"POST"}try{const l=this.getXsrfToken(),c=await fetch(r,{method:i,headers:{"Content-Type":"application/json",Accept:"application/json",...l&&{"X-XSRF-TOKEN":l},Authorization:`Bearer ${n}`},credentials:"include",body:JSON.stringify({language:e})});c.ok?U.log("Locale saved to DB:",e):U.warn("Failed to save locale to DB (UI will still change):",c.statusText)}catch(l){U.warn("Failed to call locale API (UI will still change):",l)}}getXsrfToken(){if(typeof document>"u")return null;const n=`; ${document.cookie}`.split("; XSRF-TOKEN=");return n.length===2?decodeURIComponent(n.pop()?.split(";").shift()||""):null}loadCacheVersionFromStorage(){try{const e=localStorage.getItem(Lr.CACHE_VERSION_STORAGE_KEY);return e?parseInt(e,10):null}catch(e){return U.warn("Failed to load cache version from storage:",e),null}}saveCacheVersionToStorage(e){try{localStorage.setItem(Lr.CACHE_VERSION_STORAGE_KEY,String(e))}catch(n){U.warn("Failed to save cache version to storage:",n)}}reinitializeModuleHandlers(){if(typeof window>"u")return;const e="__",n=window;Object.keys(n).forEach(r=>{if(r.startsWith(e)&&typeof n[r]?.initModule=="function")try{n[r].initModule(),U.log(`Module handler re-initialized: ${r}`)}catch(i){U.warn(`Failed to re-initialize module handlers for ${r}:`,i)}})}reinitializeTemplateHandlers(){if(typeof window>"u")return;const e=window.G7TemplateHandlers;if(!e){U.warn("Template handlers not found on window.G7TemplateHandlers");return}const n=this.getActionDispatcher();if(!n){U.warn("ActionDispatcher not available for template handler registration");return}Object.entries(e).forEach(([r,i])=>{n.registerHandler(r,i)}),U.log(`${Object.keys(e).length} template handler(s) re-registered:`,Object.keys(e))}reinitializePluginHandlers(){if(typeof window>"u")return;const e="__",n=window;Object.keys(n).forEach(r=>{if(r.startsWith(e)&&typeof n[r]?.initPlugin=="function")try{n[r].initPlugin(),U.log(`Plugin handler re-initialized: ${r}`)}catch(i){U.warn(`Failed to re-initialize plugin handlers for ${r}:`,i)}})}getLocale(){return this.config.locale}getErrorPageHandler(){return this.errorPageHandler}getGlobalState(){return{...this.globalState}}setGlobalState(e,n){const r={...this.globalState};typeof e=="function"?this.globalState=e(this.globalState):this.globalState={...this.globalState,...e},U.log("Global state updated:",this.globalState),window.G7Core?.devTools?.captureStateSnapshot?.({source:"setGlobalState",prev:r,next:this.globalState}),this.globalStateListeners.forEach(l=>{l(this.globalState)}),n?.render!==!1&&Promise.resolve().then(()=>Wr).then(({updateTemplateData:l,getState:c})=>{const d=c();d.reactRoot&&d.currentLayoutJson&&l({_global:{...this.globalState},_local:this.globalState._local||{}})})}onGlobalStateChange(e){this.globalStateListeners.add(e)}offGlobalStateChange(e){this.globalStateListeners.delete(e)}async refetchDataSource(e,n){let r=this.currentDataSources.find(i=>i.id===e);if(!r)for(const[,i]of this.modalDataSources){const l=i.find(c=>c.id===e);if(l){r=l;break}}if(!r){U.warn(`Data source not found: ${e}`);return}U.log(`Refetching data source: ${e}`,n?.sync?"(sync mode)":"",n?.globalStateOverride?"(with global override)":"",n?.localStateOverride?"(with local override)":""),Gr.setPending(!0);try{const i=new Dr;this.currentGlobalHeaders.length>0&&i.setGlobalHeaders(this.currentGlobalHeaders);const l=ca(),c=l.currentDataContext?._global||{},d=n?.globalStateOverride?{...c,...n.globalStateOverride}:c,f=l.currentDataContext?._local||{},p=n?.localStateOverride?{...f,...n.localStateOverride}:f,y=(await i.fetchDataSourcesWithResults([r],this.currentRouteParams,this.currentQueryParams,d,p,{ignoreAutoFetch:!0}))[0];if(y.state==="success"&&y.data!==void 0){this.currentFetchedData[e]=y.data;const C={};this.processInitOptions([r],{[e]:y.data},C);const S=ca();if(S.bindingEngine){const x=[e];r.initGlobal&&x.push("_global"),r.initLocal&&x.push("_local"),S.bindingEngine.invalidateCacheByKeys(x)}const v={[e]:y.data};return Object.keys(C).length>0&&(v._localInit=C),r.initGlobal&&(v._global={...this.globalState}),_s(v,n?.sync?{sync:!0}:void 0),U.log(`Data source refetched successfully: ${e}`),y.data}else if(y.state==="error"){U.error(`Failed to refetch data source: ${e}`,y.error);return}}catch(i){U.error(`Error refetching data source: ${e}`,i);return}finally{Gr.setPending(!1)}}registerModalDataSources(e,n){this.modalDataSources.set(e,n),U.log(`Modal data sources registered: ${e} (${n.length} sources)`)}unregisterModalDataSources(e){this.modalDataSources.delete(e),U.log(`Modal data sources unregistered: ${e}`)}getDataSource(e){return this.currentFetchedData[e]}setDataSource(e,n,r){if(!e){U.warn("setDataSource: dataSourceId is required");return}const{merge:i=!1,sync:l=!1}=r||{};i&&this.currentFetchedData[e]?this.currentFetchedData[e]={...this.currentFetchedData[e],...n}:this.currentFetchedData[e]=n,Promise.resolve().then(()=>Wr).then(({updateTemplateData:c})=>{c({[e]:this.currentFetchedData[e]},l?{sync:!0}:void 0)}),U.log(`setDataSource: Updated ${e}`,i?"(merged)":"(replaced)")}updateDataSourceItem(e,n,r,i,l){const{idField:c="id",merge:d=!0,skipRender:f=!1}=l||{},p=this.currentFetchedData[e];if(!p)return U.warn(`updateDataSourceItem: DataSource '${e}' not found`),!1;const m=this.parseItemPath(n);let y=p;for(const v of m)if(y=y?.[v],y===void 0)return U.warn(`updateDataSourceItem: Path '${n}' not found in dataSource`),!1;if(!Array.isArray(y))return U.warn(`updateDataSourceItem: Target at '${n}' is not an array`),!1;const C=y.findIndex(v=>String(v[c])===String(r));if(C===-1)return U.warn(`updateDataSourceItem: Item with ${c}='${r}' not found`),!1;d?y[C]=this.deepMerge(y[C],i):y[C]={...y[C],...i};const S=window.G7Core?.devTools;return S?.isEnabled?.()&&S.trackDataSourceUpdate?.({dataSourceId:e,updateType:"partial",itemPath:n,itemId:r,updates:i,timestamp:Date.now()}),f||Promise.resolve().then(()=>Wr).then(({updateTemplateData:v})=>{v({[e]:this.currentFetchedData[e]},{sync:!1})}),U.log(`updateDataSourceItem: Updated ${e}.${n}[${c}=${r}]`),!0}parseItemPath(e){const n=[],r=/([^\.\[\]]+)|\[(\d+)\]/g;let i;for(;(i=r.exec(e))!==null;)i[1]!==void 0?n.push(i[1]):i[2]!==void 0&&n.push(parseInt(i[2],10));return n}deepMerge(e,n){if(n==null)return e;if(typeof n!="object"||Array.isArray(n))return n;const r={...e};for(const i of Object.keys(n))typeof n[i]=="object"&&n[i]!==null&&!Array.isArray(n[i])?r[i]=this.deepMerge(r[i]||{},n[i]):r[i]=n[i];return r}setValueAtPath(e,n,r,i="deep"){const l=n.split(".");let c=e;for(let p=0;p0?l.filterByCondition(this.currentRawDataSources,d):this.currentDataSources;this.currentDataSources=f;const p=f.filter(x=>x.auto_fetch!==!1&&x.type!=="websocket");if(p.length===0){U.log("No auto_fetch data sources to refetch");return}U.log(`Refetching ${p.length} auto_fetch data sources`),Gr.setPending(!0);const m=ca().currentLayoutJson,y=m?.transition_overlay,C=Array.isArray(y?.wait_for)?y.wait_for:[],S=p.some(x=>(x.loading_strategy||"progressive")==="blocking"),v=C.length>0&&p.some(x=>C.includes(x.id)&&x.type!=="websocket"&&(x.loading_strategy||"progressive")!=="background");if((S||v)&&y&&typeof y=="object"){const x=n?.transitionOverlayTarget||y.target;y.enabled&&y.style==="skeleton"&&y.skeleton?.component&&x?this.renderSkeletonOverlay(x,y.skeleton,m,y.fallback_target):y.enabled&&y.style==="spinner"&&x&&this.renderSpinnerOverlay(x,y.spinner,y.fallback_target)}try{const x=new Dr;this.currentGlobalHeaders.length>0&&x.setGlobalHeaders(this.currentGlobalHeaders);const w=ca(),R=w.currentDataContext?._global||{},L=await x.fetchDataSourcesWithResults(p,this.currentRouteParams,this.currentQueryParams,R,void 0,{ignoreAutoFetch:!1}),O={},j={},F=new Map(p.map(G=>[G.id,G]));for(const G of L){const P=F.get(G.id);if(!P){U.warn(`Refetch result id not found in autoFetchDataSources: ${G.id}`);continue}const K=G.id;G.state==="success"&&G.data!==void 0?(this.currentFetchedData[K]=G.data,O[K]=G.data,this.processInitOptions([P],{[K]:G.data},j),U.log(`Data source refetched: ${K}`)):G.state==="error"&&U.error(`Failed to refetch data source: ${K}`,G.error)}if(w.bindingEngine){const G=Object.keys(O);G.push("query"),w.bindingEngine.invalidateCacheByKeys(G)}if(Object.keys(j).length>0&&(O._localInit=j),Object.keys(O).length>0){if(O.query=ob(this.currentQueryParams),w.currentLayoutJson?.computed&&Object.keys(w.currentLayoutJson.computed).length>0){const G={...w.currentDataContext,...O,query:O.query},P=this.calculateComputed(w.currentLayoutJson.computed,G);Object.keys(P).length>0&&(O._computed=P,this.globalState._computed=P,U.log("Computed values recalculated in updateQueryParams:",Object.keys(P)))}_s(O,{sync:!0}),U.log("Template data updated with new query params")}}catch(x){U.error("Error in updateQueryParams:",x)}finally{Gr.setPending(!1),this.hideTransitionOverlay()}}calculateComputed(e,n){const r={},i=new Tn;for(const[l,c]of Object.entries(e))try{let d;if(this.isComputedSwitchDefinition(c))d=i.resolveSwitch(c,n,{skipCache:!0});else if(typeof c=="string")if(c.startsWith("{{")&&c.endsWith("}}")){const f=c.slice(2,-2).trim();d=this.evaluateComputedExpression(f,n)}else d=c;r[l]=d,U.log(`Computed ${l}:`,d)}catch(d){U.warn(`Failed to calculate computed value: ${l}`,d),r[l]=void 0}return r}isComputedSwitchDefinition(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&"$switch"in e&&"$cases"in e}evaluateComputedExpression(e,n){try{return Jd(e,n)}catch(r){U.warn(`Expression evaluation failed: ${e}`,r);return}}async executeInitActions(e,n={}){const{getActionDispatcher:r}=await Promise.resolve().then(()=>Wr),i=r();if(!i){U.warn("ActionDispatcher not available for init_actions");return}U.log("Executing init_actions:",e.map(d=>d.handler)),U.log("Init actions dataContext:",n),U.log("Init actions dataContext._global:",n._global);const l=e.map(d=>d.handler).filter(d=>d.includes("."));l.length>0&&await this.waitForHandlers(i,l);let c={...n};for(const d of e)try{const f={type:"click",handler:d.handler,target:d.target,params:d.params,resultTo:d.resultTo,onSuccess:d.onSuccess,onError:d.onError,if:d.if,conditions:d.conditions,auth_mode:d.auth_mode,auth_required:d.auth_required},p=i.createHandler(f,c),m=new Event("init");await p(m),U.log(`Init action executed: ${d.handler}`);const y=this.globalState;c={...c,_global:{...y},_local:y._local||c._local||{}},U.log(`Data context refreshed after ${d.handler}:`,{cartKey:c._global?.cartKey})}catch(f){U.error(`Failed to execute init action: ${d.handler}`,f)}}async waitForHandlers(e,n,r=5e3){const i=Date.now(),l=50,c=()=>n.every(f=>e.customHandlers?.has(f));if(c()){U.log("All module handlers already registered");return}const d=Zf().getFailedJsAssets();if(d.length>0){const f=d.some(y=>y==="module"||y==="plugin"),p=n.filter(y=>!e.customHandlers?.has(y)),m=p.length>0&&p.every(y=>d.some(C=>y.startsWith(`${C}.`)));if(f||m){U.warn("Extension asset load failed — not waiting for handlers that will never register:",{pending:p,failedAssets:d});return}}return U.log("Waiting for module handlers:",n),new Promise(f=>{const p=()=>{if(c()){U.log("All module handlers now registered"),f();return}if(Date.now()-i>=r){const m=n.filter(y=>!e.customHandlers?.has(y));U.warn("Timeout waiting for handlers:",m),f();return}setTimeout(p,l)};p()})}};$(Lr,"LOCALE_STORAGE_KEY","g7_locale"),$(Lr,"CACHE_VERSION_STORAGE_KEY","g7_cache_version");let Go=Lr;function th(s){const e=new Go(s);return s.websocket&&(Vc.configure(s.websocket),U.log("WebSocket 설정 완료")),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{e.init(),window.__templateApp=e}):(e.init(),window.__templateApp=e),e}typeof window<"u"&&(window.G7Core=window.G7Core||{},window.G7Core.initTemplateApp=th,window.G7Core.dataSource={refetch:async(s,e)=>{const n=window.__templateApp;if(!n){U.warn("TemplateApp not initialized (G7Core.dataSource.refetch)");return}return n.refetchDataSource(s,e)},get:s=>{const e=window.__templateApp;if(!e){U.warn("TemplateApp not initialized (G7Core.dataSource.get)");return}return e.getDataSource(s)}});function sx(s={}){const{checked:e,value:n,name:r,type:i="checkbox"}=s,c=n!==void 0?n:i==="checkbox"||i==="radio"?e??!1:String(e??""),d={checked:e??!1,value:c,name:r??"",type:i};return{target:d,currentTarget:d,preventDefault:()=>{},stopPropagation:()=>{},nativeEvent:new Event("change"),bubbles:!0,cancelable:!0,defaultPrevented:!1,eventPhase:Event.AT_TARGET,isTrusted:!1,timeStamp:Date.now(),type:"change",isDefaultPrevented:()=>!1,isPropagationStopped:()=>!1,persist:()=>{}}}function ox(s={}){const{button:e=0,clientX:n=0,clientY:r=0}=s;return{button:e,clientX:n,clientY:r,preventDefault:()=>{},stopPropagation:()=>{},nativeEvent:new MouseEvent("click"),bubbles:!0,cancelable:!0,defaultPrevented:!1,eventPhase:Event.AT_TARGET,isTrusted:!1,timeStamp:Date.now(),type:"click",isDefaultPrevented:()=>!1,isPropagationStopped:()=>!1,persist:()=>{},target:document.createElement("div"),currentTarget:document.createElement("div")}}function lx(){return{preventDefault:()=>{},stopPropagation:()=>{},nativeEvent:new Event("submit"),bubbles:!0,cancelable:!0,defaultPrevented:!1,eventPhase:Event.AT_TARGET,isTrusted:!1,timeStamp:Date.now(),type:"submit",isDefaultPrevented:()=>!1,isPropagationStopped:()=>!1,persist:()=>{},target:document.createElement("form"),currentTarget:document.createElement("form")}}function cx(s,e="keydown"){return{key:s,code:s.length===1?`Key${s.toUpperCase()}`:s,preventDefault:()=>{},stopPropagation:()=>{},nativeEvent:new KeyboardEvent(e,{key:s}),bubbles:!0,cancelable:!0,defaultPrevented:!1,eventPhase:Event.AT_TARGET,isTrusted:!1,timeStamp:Date.now(),type:e,isDefaultPrevented:()=>!1,isPropagationStopped:()=>!1,persist:()=>{},target:document.createElement("div"),currentTarget:document.createElement("div"),altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1,repeat:!1}}const ux={justify:/^justify-(start|end|center|between|around|evenly)$/,items:/^items-(start|end|center|baseline|stretch)$/,content:/^content-(start|end|center|between|around|evenly|stretch)$/,self:/^self-(auto|start|end|center|stretch|baseline)$/,flex:/^flex-(row|row-reverse|col|col-reverse|wrap|wrap-reverse|nowrap|1|auto|initial|none)$/,grow:/^(grow|grow-0)$/,shrink:/^(shrink|shrink-0)$/,basis:/^basis-/,order:/^(order-|-)order-/,gap:/^gap(-x|-y)?-/,gridCols:/^grid-cols-/,gridRows:/^grid-rows-/,colSpan:/^col-(span-|start-|end-)/,rowSpan:/^row-(span-|start-|end-)/,display:/^(block|inline-block|inline|flex|inline-flex|table|inline-table|table-caption|table-cell|table-column|table-column-group|table-footer-group|table-header-group|table-row-group|table-row|flow-root|grid|inline-grid|contents|list-item|hidden)$/,position:/^(static|fixed|absolute|relative|sticky)$/,inset:/^(inset|top|right|bottom|left)-/,zIndex:/^z-/,width:/^w-/,minWidth:/^min-w-/,maxWidth:/^max-w-/,height:/^h-/,minHeight:/^min-h-/,maxHeight:/^max-h-/,padding:/^p[xytblr]?-/,margin:/^-?m[xytblr]?-/,space:/^space-(x|y)-/,fontSize:/^text-(xs|sm|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl)$/,fontWeight:/^font-(thin|extralight|light|normal|medium|semibold|bold|extrabold|black)$/,fontStyle:/^(italic|not-italic)$/,fontFamily:/^font-(sans|serif|mono)/,textAlign:/^text-(left|center|right|justify|start|end)$/,textColor:/^text-(inherit|current|transparent|black|white|slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-/,textDecoration:/^(underline|overline|line-through|no-underline)$/,textTransform:/^(uppercase|lowercase|capitalize|normal-case)$/,lineHeight:/^leading-/,letterSpacing:/^tracking-/,textOverflow:/^(truncate|text-ellipsis|text-clip)$/,whitespace:/^whitespace-/,wordBreak:/^break-/,bgColor:/^bg-(inherit|current|transparent|black|white|slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-/,bgGradient:/^bg-gradient-/,bgSize:/^bg-(auto|cover|contain)$/,bgPosition:/^bg-(bottom|center|left|left-bottom|left-top|right|right-bottom|right-top|top)$/,bgRepeat:/^bg-(repeat|no-repeat|repeat-x|repeat-y|repeat-round|repeat-space)$/,bgAttachment:/^bg-(fixed|local|scroll)$/,bgClip:/^bg-clip-/,bgOrigin:/^bg-origin-/,borderWidth:/^border(-[xytblr])?(-0|-2|-4|-8)?$/,borderColor:/^border-(inherit|current|transparent|black|white|slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-/,borderStyle:/^border-(solid|dashed|dotted|double|hidden|none)$/,borderRadius:/^rounded(-[tblrse]{1,2})?(-none|-sm|-md|-lg|-xl|-2xl|-3xl|-full)?$/,ringWidth:/^ring(-0|-1|-2|-4|-8|-inset)?$/,ringColor:/^ring-(inherit|current|transparent|black|white|slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-/,ringOffset:/^ring-offset-/,shadow:/^shadow(-sm|-md|-lg|-xl|-2xl|-inner|-none)?$/,opacity:/^opacity-/,mixBlend:/^mix-blend-/,bgBlend:/^bg-blend-/,blur:/^blur(-none|-sm|-md|-lg|-xl|-2xl|-3xl)?$/,brightness:/^brightness-/,contrast:/^contrast-/,grayscale:/^grayscale(-0)?$/,hueRotate:/^-?hue-rotate-/,invert:/^invert(-0)?$/,saturate:/^saturate-/,sepia:/^sepia(-0)?$/,backdropBlur:/^backdrop-blur-/,backdropBrightness:/^backdrop-brightness-/,backdropContrast:/^backdrop-contrast-/,backdropGrayscale:/^backdrop-grayscale-/,backdropHueRotate:/^backdrop-hue-rotate-/,backdropInvert:/^backdrop-invert-/,backdropOpacity:/^backdrop-opacity-/,backdropSaturate:/^backdrop-saturate-/,backdropSepia:/^backdrop-sepia-/,scale:/^scale(-x|-y)?-/,rotate:/^-?rotate-/,translate:/^-?translate-[xy]-/,skew:/^-?skew-[xy]-/,transformOrigin:/^origin-/,transition:/^transition(-none|-all|-colors|-opacity|-shadow|-transform)?$/,duration:/^duration-/,ease:/^ease-(linear|in|out|in-out)$/,delay:/^delay-/,animate:/^animate-/,cursor:/^cursor-/,userSelect:/^select-/,pointerEvents:/^pointer-events-/,resize:/^resize(-none|-x|-y)?$/,scrollBehavior:/^scroll-(auto|smooth)$/,touchAction:/^touch-/,overflow:/^overflow(-x|-y)?-(auto|hidden|clip|visible|scroll)$/,overscroll:/^overscroll(-x|-y)?-(auto|contain|none)$/,visibility:/^(visible|invisible|collapse)$/,aspectRatio:/^aspect-/,columns:/^columns-/,breakAfter:/^break-after-/,breakBefore:/^break-before-/,breakInside:/^break-inside-/,boxDecorationBreak:/^box-decoration-/,boxSizing:/^box-(border|content)$/,float:/^float-(right|left|none)$/,clear:/^clear-(left|right|both|none)$/,isolation:/^(isolate|isolation-auto)$/,objectFit:/^object-(contain|cover|fill|none|scale-down)$/,objectPosition:/^object-/};function lb(s){const e=s.replace(/^(dark:|hover:|focus:|active:|disabled:|group-hover:|sm:|md:|lg:|xl:|2xl:)+/,"");for(const[n,r]of Object.entries(ux))if(r.test(e))return n;return null}function cb(s){const e=s.match(/^((dark:|hover:|focus:|active:|disabled:|group-hover:|sm:|md:|lg:|xl:|2xl:)+)/);return e?e[1]:""}function dx(s,e){if(!e||e.trim()==="")return s;if(!s||s.trim()==="")return e;const n=s.split(/\s+/).filter(Boolean),r=e.split(/\s+/).filter(Boolean),i=new Map;for(const c of r){const d=lb(c);if(d){const f=cb(c),p=`${d}:${f}`;i.set(p,c)}}return[...n.filter(c=>{const d=lb(c);if(!d)return!0;const f=cb(c),p=`${d}:${f}`;return!i.has(p)}),...r].join(" ")}function fx(s){return Object.entries(s).filter(([,e])=>e).map(([e])=>e).join(" ")}function hx(...s){return s.filter(e=>typeof e=="string"&&e.length>0).join(" ")}const be=dt("G7CoreGlobals");function px(){window.React=We,window.ReactDOM={...Ad,createPortal:za.createPortal,unstable_batchedUpdates:s=>s()},window.ReactJSXRuntime=WC,be.log("전역 객체 window.React, window.ReactDOM, window.ReactJSXRuntime에 노출됨")}function gx(s){const e=new Map,n=Ua.getInstance();s.componentEvent={on:(r,i)=>(e.has(r)||e.set(r,new Set),e.get(r).add(i),n.trackEventSubscribe(r),()=>{e.get(r)?.delete(i),n.trackEventUnsubscribe(r)}),emit:async(r,i)=>{const l=e.get(r),c=l?.size??0;if(!l||l.size===0)return n.trackEventEmit(r,i,0),[];let d,f=[];try{f=await Promise.all(Array.from(l).map(async p=>{try{return await p(i)}catch(m){throw be.error(`componentEvent: Error in listener for "${r}":`,m),m}}))}catch(p){d=p instanceof Error?p:new Error(String(p))}if(n.trackEventEmit(r,i,c,f,d),d)throw d;return f},off:r=>{e.delete(r),n.trackEventOff(r)},clear:()=>{e.clear(),n.trackEventClear()}},be.log("전역 객체 window.G7Core.componentEvent에 노출됨")}function mx(s){s.__runtime||(s.__runtime={DynamicRenderer:Vr,ComponentRegistry:Er,TranslationEngine:wi,DataSourceManager:Dr,dataSourceManager:MA,DataBindingEngine:Tn,dataBindingEngine:uc,ActionDispatcher:Lo,TranslationReactContext:Ff,TranslationProvider:qc,useTranslation:Py,ResponsiveContext:Cf,ResponsiveProvider:Rc,useResponsive:Ef,responsiveManager:_i,BREAKPOINT_PRESETS:dc,AuthManager:Yn,createLogger:dt,G7DevToolsCore:Ua},be.log("전역 객체 window.G7Core.__runtime(코어 런타임 표면)에 노출됨"))}function yx(s){if(s.layoutEditor&&s.layoutEditor.__isStub!==!0||s.layoutEditor&&s.layoutEditor.__isStub===!0)return;const e=[],n=[];s.layoutEditor={__isStub:!0,__queue:e,__readyCallbacks:n,registerWidget:(r,i)=>e.push(["widget",r,i]),registerNodeEditor:(r,i)=>e.push(["nodeEditor",r,i]),registerCanvasOverlay:(r,i)=>e.push(["canvasOverlay",r,i]),onReady:r=>{typeof r=="function"&&n.push(r)}},be.log("전역 객체 window.G7Core.layoutEditor 예약 접수함(stub) 노출됨")}function bx(s){s.asset={template:(e,n,r)=>Uw(e,n,r),templateDir:(e,n)=>Pw(e,n),module:(e,n,r)=>Bw(e,n,r),plugin:(e,n,r)=>qw(e,n,r),convertToCurrentMode:e=>xn(e),loadScript:(e,n,r)=>Oo(e,fs())?Cr(e,n,r):Promise.reject(new Error(`Blocked untrusted script src (same-origin path or declared trusted host required): ${e}`)),isAllowedScriptSrc:e=>Oo(e,fs()),loadStylesheet:(e,n,r)=>sa(e,n,r)},s.assets={notifyFailure:Ss,clearFailure:rb,clearAll:ab,getFailures:qA,retryAll:sb},QA(),be.log("전역 객체 window.G7Core.asset / window.G7Core.assets 노출됨")}function vx(s,e){s.useTranslation=Py,s.t=(n,r)=>{const i=e.getState();if(!i.translationEngine||!i.translationContext)return n;if(r){const l="|"+Object.entries(r).map(([c,d])=>`${c}=${d}`).join("|");return i.translationEngine.translate(n,i.translationContext,l)}return i.translationEngine.translate(n,i.translationContext)},be.log("전역 객체 window.G7Core.useTranslation에 노출됨")}function Sx(s,e){s.createChangeEvent=sx,s.createClickEvent=ox,s.createSubmitEvent=lx,s.createKeyboardEvent=cx,s.uuid=()=>typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{const r=Math.random()*16|0;return(n==="x"?r:r&3|8).toString(16)}),s.createLogger=dt,be.log("전역 객체 window.G7Core.createLogger에 노출됨"),s.renderItemChildren=(n,r,i,l,c)=>{const d=e.getState(),m={_global:window.__templateApp?.getGlobalState?.()||{},_local:r._local||{},_computed:r._computed||{},...r},y=new Set,C=(v,x)=>{const w=m._global?._remountKeys;return v&&w?.[v]&&!y.has(v)?(y.add(v),`${v}-remount-${w[v]}`):v||x},S={translationContext:d.translationContext,translationEngine:d.translationEngine,bindingEngine:d.bindingEngine,actionDispatcher:d.actionDispatcher,getRemountKey:C,...c};return Co(n,m,i,l,S)},s.evaluateCondition=(n,r)=>{if(!n)return!0;const i=e.getState(),c=window.__templateApp?.getGlobalState?.()||{},d={_global:c,_local:c._local||{},_computed:c._computed||{},...r||{}},f=i.bindingEngine??uc;return Fg(n,d,f)},s.getComponentMap=()=>Er.getInstance().getComponentMap(),s.renderComponentLayout=(n,r,i)=>{if(!n||!Array.isArray(n)||n.length===0)return null;const l=Er.getInstance().getComponentMap(),c=e.getState(),f=window.__templateApp?.getGlobalState?.()||{},p={_global:f._global||{},_local:f._local||{},_computed:f._computed||{},...r},m=new Set,y=(C,S)=>{const v=p._global?._remountKeys;return C&&v?.[C]&&!m.has(C)?(m.add(C),`${C}-remount-${v[C]}`):C||S};return Co(n,p,l,i,{translationContext:c.translationContext,translationEngine:c.translationEngine,bindingEngine:c.bindingEngine,actionDispatcher:c.actionDispatcher,getRemountKey:y})},s.renderExpandContent=n=>{const{children:r,row:i,expandContext:l,componentContext:c,keyPrefix:d}=n;if(!r||!Array.isArray(r)||r.length===0)return null;const f=n.componentMap||Er.getInstance().getComponentMap(),p=e.getState(),m=s.state?.get?.()||{},y=c?.stateRef?.current??c?.state??{},C={...m._local||{},...y},S=c?.computedRef?.current??m._computed??{},v=p.bindingEngine??s.getDataBindingEngine?.(),x={...m,_local:C,_computed:S,row:i,item:i,$item:i};let w={};if(l&&typeof l=="object"&&v)try{for(const[j,F]of Object.entries(l))if(typeof F=="string"){const G=Ma(F);if(G!==null)try{w[j]=On(G)?v.evaluatePipeExpression(G,x,{skipCache:!0}):v.evaluateExpression(G,x,{skipCache:!0})}catch{w[j]=void 0}else w[j]=v.resolveBindings(F,x,{skipCache:!0})}else w[j]=F}catch(j){be.warn("renderExpandContent: expandContext 평가 오류:",j)}const R={row:i,item:i,$item:i,_local:C,_global:m._global||{},_computed:m._computed||{},...w},L=new Set,O=(j,F)=>{const G=R._global?._remountKeys;return j&&G?.[j]&&!L.has(j)?(L.add(j),`${j}-remount-${G[j]}`):j||F};return Co(r,R,f,d,{translationContext:p.translationContext,translationEngine:p.translationEngine??void 0,bindingEngine:p.bindingEngine??void 0,actionDispatcher:p.actionDispatcher,componentContext:c,getRemountKey:O})},s.$get=function(r,i,l=void 0){if(r==null)return l;const c=Array.isArray(i)?i:[i];if(c.length===0)return r;let d=r;for(const f of c){if(d==null||f==null)return l;d=d[f]}return d??l},be.log("전역 객체 window.G7Core.renderItemChildren에 노출됨"),be.log("전역 객체 window.G7Core.renderComponentLayout에 노출됨"),be.log("전역 객체 window.G7Core.renderExpandContent에 노출됨"),be.log("전역 객체 window.G7Core.$get에 노출됨")}function wx(s){s.dispatch=async(e,n)=>{const r=window.__templateApp;if(!r)return be.warn("G7Core.dispatch: TemplateApp이 초기화되지 않았습니다."),{success:!1,error:new Error("TemplateApp이 초기화되지 않았습니다.")};const i=r.getActionDispatcher?.();if(!i)return be.warn("G7Core.dispatch: ActionDispatcher를 찾을 수 없습니다."),{success:!1,error:new Error("ActionDispatcher를 찾을 수 없습니다.")};const l=r.getRouter?.(),c=r.getGlobalState?.(),d=r.setGlobalState?.bind(r),p=n?.componentContext||window.__g7ActionContext,m=window.__g7PendingLocalState;let y=p?.state??c;m&&p&&(y=m,be.log("[dispatch] Using __g7PendingLocalState for context.state:",m));let C=p?.data??c;m&&p?.data?._local&&(C={...p.data,_local:m},be.log("[dispatch] Updated context.data._local with pendingLocalState"));const S={navigate:l?(v,x)=>l.navigate(v,x):void 0,setState:p?.setState??d,state:y,data:C,_isDispatchFallbackContext:!p?.setState};if(e.debounce){const v=e.debounceKey||`dispatch-${e.handler}`,x=typeof e.debounce=="number"?e.debounce:e.debounce.delay;return i.debouncedCall(v,x,()=>{const{debounce:w,debounceKey:R,...L}=e;i.dispatchAction(L,S)}),{success:!0,debounced:!0}}try{return await i.dispatchAction(e,S)}catch(v){return be.error("G7Core.dispatch: 액션 실행 오류:",v),{success:!1,error:v instanceof Error?v:new Error(String(v))}}},be.log("전역 객체 window.G7Core.dispatch에 노출됨")}function Fo(s){const e={};for(const[n,r]of Object.entries(s))if(n.includes(".")){const i=n.split(".");let l=e;for(let c=0;c0&&e.every(n=>/^\d+$/.test(n))}function Qn(s,e){if(Array.isArray(s)&&!Array.isArray(e)&&Cx(e)){const r=Object.keys(e).map(l=>parseInt(l,10));if(!((r.length>0?Math.max(...r):0)>=s.length+r.length+10)){const l=[...s];for(const[c,d]of Object.entries(e)){const f=parseInt(c,10);f>=0&&f=l.length&&(l[f]=d)}return l}}const n={...s};for(const[r,i]of Object.entries(e))i!==null&&typeof i=="object"&&!Array.isArray(i)?n[r]!==null&&typeof n[r]=="object"?n[r]=Qn(n[r],i):n[r]={...i}:n[r]=i;return n}function Ex(s){s.state={get:()=>window.__templateApp?.getGlobalState?.()||{},set:(e,n)=>{const r=window.__templateApp;if(r?.setGlobalState&&r?.getGlobalState){const i=n?.merge||"deep",l=Fo(e);let c;if(i==="replace")c=l;else if(i==="shallow")c={...r.getGlobalState(),...l};else{const d=r.getGlobalState();c=Qn(d,l)}r.setGlobalState(c,{render:n?.render})}else be.warn("G7Core.state.set: TemplateApp이 초기화되지 않았습니다.")},setLocal:(e,n)=>{const r=window.__templateApp;if(n?.render===!1&&!n?.selfManaged){const w=window.__g7AutoBindingPaths;w&&w.size>0&&ub(Fo(e)).some(L=>w.has(L))&&(be.log("[setLocal] render:false + 자동바인딩 경로 겹침 감지 → render:true 자동 승격 (engine-v1.43.0)"),n={...n,render:!0})}if(n?.debounce){const w=r?.getActionDispatcher?.();if(w){const R=n.debounceKey||`setLocal-${Object.keys(e).join(",")}`,{debounce:L,debounceKey:O,...j}=n;w.debouncedCall(R,n.debounce,()=>{s.state.setLocal(e,j)});return}}const i=n?.scope??"current",l=n?.merge||"deep",c=window.__g7ActionContext,d=Fo(e);if(i==="parent"||i==="root"){const w=window.__g7LayoutContextStack||[];if(w.length>0){const R=i==="parent"?w[w.length-1]:w[0];if(R?.setState){R.setState(L=>l==="replace"?d:l==="shallow"?{...L||{},...d}:Qn(L||{},d)),be.log(`[setLocal] scope=${i}: 타겟 컨텍스트에 상태 업데이트 (mergeMode=${l})`,d);return}}be.warn(`[setLocal] scope=${i}: 레이아웃 컨텍스트 스택이 비어있습니다. current로 폴백합니다.`)}const f=window.__g7PendingLocalState,p=r?.getGlobalState?.()?._local||{},C=!((window.__g7LayoutContextStack||[]).length>0)&&c?.state?c.state:void 0,S=C?Ro(p,C):p,v=f||S;let x;if(l==="replace"?x=d:l==="shallow"?x={...v,...d}:x=Qn(v,d),r?.setGlobalState&&(r.setGlobalState({_local:x},{render:n?.render}),be.log(`[setLocal] globalLocal updated via setGlobalState (mergeMode=${l}, render=${n?.render??!0}):`,d)),window.__g7PendingLocalState=x,be.log("[setLocal] __g7PendingLocalState updated:",x),window.__g7SequenceLocalSync=x,window.__g7LastSetLocalSnapshot=x,l==="replace")window.__g7ForcedLocalFields=d;else{const w=window.__g7ForcedLocalFields||{};window.__g7ForcedLocalFields=Qn(w,d)}if(be.log("[setLocal] __g7ForcedLocalFields updated:",d),l==="replace")window.__g7SetLocalOverrideKeys=d;else{const w=window.__g7SetLocalOverrideKeys||{};window.__g7SetLocalOverrideKeys=Qn(w,d)}be.log("[setLocal] __g7SetLocalOverrideKeys updated:",d),c?.setState&&c.setState(w=>l==="replace"?d:l==="shallow"?{...w||{},...d}:Qn(w||{},d)),r?.setGlobalState||be.warn("G7Core.state.setLocal: TemplateApp이 없습니다.")},getLocal:()=>{const r=(window.__templateApp?.getGlobalState?.()||{})._local||{},i=window.__g7PendingLocalState;if(i)return Qn(r,i);const l=window.__g7LastSetLocalSnapshot;return l&&l!==r?Qn(r,l):r},update:e=>{const n=window.__templateApp;if(n?.getGlobalState&&n?.setGlobalState){const r=n.getGlobalState(),i=e(r);n.setGlobalState(i)}else be.warn("G7Core.state.update: TemplateApp이 초기화되지 않았습니다.")},subscribe:e=>{const n=window.__templateApp;return n?.onGlobalStateChange?n.onGlobalStateChange(e):(be.warn("G7Core.state.subscribe: TemplateApp이 초기화되지 않았습니다."),()=>{})},getDataSource:e=>window.__templateApp?.getDataSource?.(e),getIsolated:e=>e?window.__g7IsolatedStates?.[e]?.state??null:window.__g7ActionContext?.isolatedContext?.state??null,setIsolated:(e,n,r)=>{let i,l,c;typeof e=="string"?(i=e,l=n||{},c=r):(l=e,c=n&&typeof n=="object"&&"merge"in n?n:r);const d=c?.merge||"deep",f=Fo(l);if(i){const y=window.__g7IsolatedStates?.[i];y?.mergeState?y.mergeState(f,d):be.warn(`G7Core.state.setIsolated: scopeId '${i}'를 찾을 수 없습니다.`);return}const p=window.__g7ActionContext;p?.isolatedContext?.mergeState?p.isolatedContext.mergeState(f,d):be.warn("G7Core.state.setIsolated: 액션 컨텍스트에 isolatedContext가 없습니다.")},getParent:()=>{const e=window.__g7LayoutContextStack||[];if(e.length===0)return be.log("[getParent] 레이아웃 컨텍스트 스택이 비어있습니다."),null;const n=e[e.length-1];if(!n)return null;const r=n.dataContext||{};return{_local:n.state||r._local||{},_global:r._global||s.state.get()||{},setState:n.setState}},setParentLocal:(e,n,r)=>{const i=window.__g7LayoutContextStack||[];if(i.length===0){be.warn("[setParentLocal] 레이아웃 컨텍스트 스택이 비어있습니다.");return}const l=i[i.length-1];if(!l?.setState){be.warn("[setParentLocal] 부모 컨텍스트에 setState가 없습니다.");return}let c,d;typeof e=="string"?(c={[e]:n},d=r):(c=e,d=n&&typeof n=="object"&&"merge"in n?n:r);const f=d?.merge||"deep",p=Fo(c),m=l.state?._local!==void 0,y=m?l.state._local:l.state||{};let C;f==="replace"?C=p:f==="shallow"?C={...y,...p}:C=Qn(y,p),window.__g7PendingLocalState=C;const S=window.__templateApp;if(S?.setGlobalState){const v=S.getGlobalState?.()?._local,w=f!=="replace"&&!!v&&typeof v=="object"&&!Array.isArray(v)?f==="shallow"?{...v,...p}:Qn(v,p):void 0;S.setGlobalState({_local:w?Ro(w,C):C})}if(l.setState(C),m?l.state._local=C:l.state=C,l.dataContext&&(l.dataContext._local=C),f==="replace")window.__g7ForcedLocalFields=p;else{const v=window.__g7ForcedLocalFields||{};window.__g7ForcedLocalFields=Qn(v,p)}vf()},setParentGlobal:(e,n)=>{let r;typeof e=="string"?r={[e]:n}:r=e,s.state.set(r),be.log("[setParentGlobal] 전역 상태 업데이트:",r)}},window.__g7IsolatedStates||(window.__g7IsolatedStates={}),s.state.getGlobal=s.state.get,s.state.setGlobal=s.state.set,be.log("전역 객체 window.G7Core.state에 노출됨")}function _x(s){s.dataSource={get:e=>window.__templateApp?.getDataSource?.(e),set:(e,n,r)=>{const i=window.__templateApp;i?.setDataSource?i.setDataSource(e,n,r):be.warn("G7Core.dataSource.set: TemplateApp이 초기화되지 않았습니다.")},refetch:async(e,n)=>{const r=window.__templateApp;if(r?.refetchDataSource)return r.refetchDataSource(e,n);be.warn("G7Core.dataSource.refetch: TemplateApp이 초기화되지 않았습니다.")},updateItem:(e,n,r,i,l)=>{const c=window.__templateApp;return c?.updateDataSourceItem?c.updateDataSourceItem(e,n,r,i,l):(be.warn("G7Core.dataSource.updateItem: TemplateApp이 초기화되지 않았습니다."),!1)},updateData:(e,n,r,i="append")=>{const l=window.__templateApp;if(!l?.getDataSource||!l?.setDataSource)return be.warn("G7Core.dataSource.updateData: TemplateApp이 초기화되지 않았습니다."),!1;const c=l.getDataSource(e);if(!c)return be.warn(`G7Core.dataSource.updateData: 데이터 소스 '${e}'를 찾을 수 없습니다.`),!1;let d,f=c,p=null;if(n){const y=n.split(".");p=y.pop();for(const C of y)if(f&&typeof f=="object"&&C in f)f=f[C];else return be.warn(`G7Core.dataSource.updateData: 경로 '${n}'를 찾을 수 없습니다.`),!1;d=f[p]}else d=c;if(!Array.isArray(d))return be.warn("G7Core.dataSource.updateData: 대상 경로의 데이터가 배열이 아닙니다."),!1;if(!Array.isArray(r))return be.warn("G7Core.dataSource.updateData: newData가 배열이 아닙니다."),!1;const m=i==="prepend"?[...r,...d]:[...d,...r];return n&&p?(f[p]=m,l.setDataSource(e,c,{merge:!1})):l.setDataSource(e,m,{merge:!1}),be.log(`G7Core.dataSource.updateData: '${e}'에 ${r.length}개 항목 ${i==="prepend"?"앞에":"뒤에"} 추가됨`),!0}},be.log("전역 객체 window.G7Core.dataSource에 노출됨")}function Ax(s,e){s.locale={current:()=>window.__templateApp?.getLocale?.()||"ko",supported:()=>{const r=window.__templateApp?.globalState?.appConfig?.supportedLocales;return Array.isArray(r)&&r.length>0?r:e.getState().templateMetadata?.locales||["ko","en"]},change:async n=>{const r=window.__templateApp;r?.changeLocale?await r.changeLocale(n):be.warn("G7Core.locale.change: TemplateApp이 초기화되지 않았습니다.")}},be.log("전역 객체 window.G7Core.locale에 노출됨")}function xx(s){s.toast={show:(e,n)=>{s.dispatch({handler:"toast",params:{message:e,type:n?.type||"info",...n?.duration&&{duration:n.duration}}})},success:(e,n)=>{s.toast.show(e,{type:"success",duration:n})},error:(e,n)=>{s.toast.show(e,{type:"error",duration:n})},warning:(e,n)=>{s.toast.show(e,{type:"warning",duration:n})},info:(e,n)=>{s.toast.show(e,{type:"info",duration:n})}},be.log("전역 객체 window.G7Core.toast에 노출됨")}function Tx(s){s.modal={open:e=>{s.dispatch({handler:"openModal",target:e})},close:e=>{s.dispatch({handler:"closeModal",...e&&{target:e}})},closeAll:()=>{s.dispatch({handler:"closeAllModals"})},isOpen:e=>{const n=s.state.get();return n._global?.activeModal===e||n._global?.modalStack?.includes(e)||!1},getStack:()=>s.state.get()._global?.modalStack||[]},be.log("전역 객체 window.G7Core.modal에 노출됨")}function kx(s){s.style={mergeClasses:dx,conditionalClass:fx,joinClasses:hx},be.log("전역 객체 window.G7Core.style에 노출됨")}function Rx(s,e){const{webSocketManager:n}=e;s.websocket={manager:n,subscribe:(r,i,l,c)=>n.subscribe(r,i,l,c),unsubscribe:r=>n.unsubscribe(r),leaveChannel:r=>n.leaveChannel(r),disconnect:()=>n.disconnect(),isInitialized:()=>n.isInitialized(),getSubscriptionCount:()=>n.getSubscriptionCount()},be.log("전역 객체 window.G7Core.websocket에 노출됨")}function Dx(s,e){const{transitionManager:n}=e;s.navigation={isPending:()=>n?.getIsPending?.()||!1,onComplete:r=>{if(!n)return r(),()=>{};let i=n.getIsPending();const l=n.subscribe(c=>{c?i=!0:i&&(r(),l())});return l}},be.log("전역 객체 window.G7Core.navigation에 노출됨")}function Ox(s){s.plugin={getSettings:e=>window.G7Config?.plugins?.[e],get:(e,n,r)=>window.G7Config?.plugins?.[e]?.[n]??r,getAll:()=>window.G7Config?.plugins??{}},be.log("전역 객체 window.G7Core.plugin에 노출됨")}function Lx(s){s.module={getSettings:e=>window.G7Config?.modules?.[e],get:(e,n,r)=>window.G7Config?.modules?.[e]?.[n]??r,getAll:()=>window.G7Config?.modules??{}},be.log("전역 객체 window.G7Core.module에 노출됨")}function $x(s,e){const{transitionManager:n,responsiveManager:r}=e;s.AuthManager=Yn,s.api=Wn(),s.TransitionManager=n,s.useTransitionState=Jm,s.ResponsiveManager=r,s.useResponsive=Ef,s.useControllableState=oE,s.shallowArrayEqual=lE,s.shallowObjectEqual=Zm,s.updateQueryParams=async(i,l)=>{const c=window.__templateApp;if(c?.updateQueryParams)return c.updateQueryParams(i,l);be.warn("G7Core.updateQueryParams: TemplateApp이 초기화되지 않았습니다.")},be.log("전역 객체 window.G7Core.AuthManager에 노출됨"),be.log("전역 객체 window.G7Core.api에 노출됨"),be.log("전역 객체 window.G7Core.ResponsiveManager에 노출됨"),be.log("전역 객체 window.G7Core.useResponsive에 노출됨"),be.log("전역 객체 window.G7Core.useControllableState에 노출됨"),be.log("전역 객체 window.G7Core.updateQueryParams에 노출됨")}function Mx(s,e){s.getSlotContext=()=>window.__slotContextValue??null,s.getDynamicRenderer=()=>window.__DynamicRenderer??null,s.getComponentRegistry=()=>e.getComponentRegistry?.()??Er.getInstance(),s.getDataBindingEngine=()=>e.getDataBindingEngine?.()??e.getState().bindingEngine,s.getTranslationEngine=()=>e.getTranslationEngine?.()??e.getState().translationEngine,s.getActionDispatcher=()=>e.getActionDispatcher?.()??e.getState().actionDispatcher,be.log("전역 객체 window.G7Core 슬롯 API에 노출됨 (getSlotContext, getDynamicRenderer 등)")}function Nx(s){s.identity={setLauncher:yt.setLauncher.bind(yt),handle:yt.handle.bind(yt),isIdentityRequired:yt.isIdentityRequired.bind(yt),hasLauncher:yt.hasLauncher.bind(yt),markDomainNoticeShown:yt.markDomainNoticeShown.bind(yt),redirectExternally:yt.redirectExternally.bind(yt),createDeferred:yt.createDeferred.bind(yt),resolveDeferred:yt.resolveDeferred.bind(yt),reset:yt.reset.bind(yt),redirectStashKey:hf},be.log("전역 객체 window.G7Core 본인인증(IDV) API에 노출됨 (identity)")}function Ix(s){if(typeof window>"u")return;px(),window.G7Core||(window.G7Core={});const e=window.G7Core;mx(e),gx(e),yx(e),$x(e,s),bx(e),vx(e,s),Sx(e,s),wx(e),Ex(e),_x(e),Ax(e,s),xx(e),Tx(e),kx(e),Rx(e,s),Dx(e,s),Ox(e),Lx(e),Mx(e,s),Nx(e),be.log("G7Core 전역 객체 초기화 완료")}function jx(){const s=window.G7Core;if(!s){be.warn("G7Core가 초기화되지 않았습니다.");return}const e=()=>Ua.getInstance(),n={isEnabled:()=>{try{return e().isEnabled()}catch{return!1}},trackRender:r=>{try{e().isEnabled()&&e().trackRender(r)}catch{}},trackIteration:(r,i,l,c,d)=>{try{e().isEnabled()&&e().trackIteration(r,{source:i,itemVar:l,indexVar:c,sourceLength:d})}catch{}},trackIfCondition:(r,i,l,c)=>{try{e().isEnabled()&&e().trackIfCondition(r,i,l)}catch{}},trackMount:(r,i)=>{try{e().isEnabled()&&e().trackMount(r,{...i,id:r})}catch{}},trackUnmount:r=>{try{e().isEnabled()&&e().trackUnmount(r)}catch{}},trackExpressionEval:r=>{try{e().isEnabled()&&e().trackExpressionEval(r)}catch{}},trackBindingEval:r=>{try{e().isEnabled()&&e().trackBindingEval(r)}catch{}},recordCacheHit:()=>{try{e().isEnabled()&&e().recordCacheHit()}catch{}},recordCacheMiss:()=>{try{e().isEnabled()&&e().recordCacheMiss()}catch{}},trackHandlerRegistration:(r,i,l,c)=>{try{e().isEnabled()&&e().trackHandlerRegistration(r,i,l,c)}catch{}},trackHandlerUnregistration:r=>{try{e().isEnabled()&&e().trackHandlerUnregistration(r)}catch{}},logAction:r=>{try{e().isEnabled()&&e().logAction(r)}catch{}},trackRequest:(r,i)=>{try{return e().isEnabled()?e().trackRequest(r,i):""}catch{return""}},completeRequest:(r,i,l)=>{try{e().isEnabled()&&e().completeRequest(r,i,l)}catch{}},failRequest:(r,i)=>{try{e().isEnabled()&&e().failRequest(r,i)}catch{}},trackDataSourceDefinition:r=>{try{e().isEnabled()&&e().trackDataSourceDefinition(r)}catch{}},trackDataSourceLoading:r=>{try{e().isEnabled()&&e().trackDataSourceLoading(r)}catch{}},trackDataSourceLoaded:(r,i,l)=>{try{e().isEnabled()&&e().trackDataSourceLoaded(r,i,l)}catch{}},trackDataSourceError:(r,i)=>{try{e().isEnabled()&&e().trackDataSourceError(r,i)}catch{}},trackForm:(r,i,l)=>{try{e().isEnabled()&&e().trackForm(r,i,l)}catch{}},untrackForm:r=>{try{e().isEnabled()&&e().untrackForm(r)}catch{}},startStateChange:(r,i,l,c)=>{try{return e().isEnabled()?e().startStateChange(r,i,l,c):""}catch{return""}},completeStateChange:r=>{try{e().isEnabled()&&e().completeStateChange(r)}catch{}},trackComponentRender:(r,i,l,c,d,f)=>{try{e().isEnabled()&&e().trackComponentRender(r,i,l,c,d,f)}catch{}},updateLocalState:r=>{try{e().isEnabled()&&e().updateLocalState(r)}catch{}},updateComputedState:r=>{try{e().isEnabled()&&e().updateComputedState(r)}catch{}},updateParentContext:r=>{try{e().isEnabled()&&e().updateParentContext(r)}catch{}},trackComponentStateSource:(r,i,l,c)=>{try{e().isEnabled()&&e().trackComponentStateSource(r,i,l,c)}catch{}},trackDynamicState:(r,i)=>{try{e().isEnabled()&&e().trackDynamicState(r,i)}catch{}},trackContextFlow:(r,i,l,c,d,f)=>{try{e().isEnabled()&&e().trackContextFlow(r,i,l,c,d,f)}catch{}},trackComponentStyle:(r,i,l,c)=>{try{e().isEnabled()&&e().trackComponentStyle(r,i,l,c)}catch{}},trackAuthEvent:(r,i,l,c)=>{try{e().isEnabled()&&e().trackAuthEvent(r,i,l,c)}catch{}},trackAuthHeader:(r,i,l,c,d)=>{try{e().isEnabled()&&e().trackAuthHeader(r,i,l,c,d)}catch{}},trackLog:(r,i,l)=>{try{e().isEnabled()&&e().trackLog(r,i,l)}catch{}},trackAction:r=>{try{e().isEnabled()&&e().trackAction?.(r)}catch{}},trackDataSourceUpdate:r=>{try{e().isEnabled()&&e().trackDataSourceUpdate?.(r)}catch{}},startSequenceExecution:r=>{try{return e().isEnabled()?e().startSequenceExecution(r):""}catch{return""}},captureSequenceActionBefore:(r,i,l,c,d)=>{try{e().isEnabled()&&e().captureSequenceActionBefore(r,i,l,c,d)}catch{}},captureSequenceActionAfter:(r,i,l,c,d,f)=>{try{e().isEnabled()&&e().captureSequenceActionAfter(r,i,l,c,d,f)}catch{}},endSequenceExecution:(r,i)=>{try{e().isEnabled()&&e().endSequenceExecution(r,i)}catch{}},registerStateCaptureForHandler:(r,i,l)=>{try{e().isEnabled()&&e().registerStateCaptureForHandler(r,i,l)}catch{}},detectStaleClosure:(r,i,l,c,d)=>{try{return e().isEnabled()?e().detectStaleClosure(r,i,l,c,d):[]}catch{return[]}},trackStaleClosureWarning:r=>{try{e().isEnabled()&&e().trackStaleClosureWarning(r)}catch{}},trackModalOpen:r=>{try{e().isEnabled()&&e().trackModalOpen(r)}catch{}},trackModalClose:(r,i)=>{try{e().isEnabled()&&e().trackModalClose(r,i)}catch{}},trackModalStateChange:r=>{try{e().isEnabled()&&e().trackModalStateChange(r)}catch{}},trackNestedContext:r=>{try{return e().isEnabled()?e().trackNestedContext(r):""}catch{return""}},trackNestedContextAccess:(r,i)=>{try{e().isEnabled()&&e().trackNestedContextAccess(r,i)}catch{}},trackComputedProperty:(r,i,l,c,d,f,p)=>{try{e().isEnabled()&&e().trackComputedProperty(r,i,l,c,d,f,p)}catch{}},trackComputedRecalc:(r,i,l,c,d,f,p)=>{try{e().isEnabled()&&e().trackComputedRecalc(r,i,l,c,d,f,p)}catch{}},setNamedActionDefinitions:r=>{try{e().isEnabled()&&e().setNamedActionDefinitions(r)}catch{}},trackNamedActionRef:r=>{try{e().isEnabled()&&e().trackNamedActionRef(r)}catch{}}};s.devTools=n,be.log("G7Core.devTools 인터페이스 초기화 완료")}let Vo=null;function zx(){const s=window.G7Core;return s?.__devtools?Promise.resolve(s.__devtools):Vo||(Vo=new Promise((e,n)=>{const r=window.G7Config?.coreDevToolsAsset||"/build/core/devtools.min.js",i="g7-devtools-bundle",l=()=>{const f=window.G7Core?.__devtools;f?e(f):n(new Error("DevTools 번들 로드됨 — 그러나 __devtools 미노출"))};window.G7Core=window.G7Core||{},window.G7Core.__onDevToolsReady=l;const c=document.getElementById(i);if(c){c.addEventListener("load",l,{once:!0}),c.addEventListener("error",()=>n(new Error(`DevTools 번들 로드 실패: ${r}`)),{once:!0});return}const d=document.createElement("script");d.id=i,d.src=r,d.async=!1,d.addEventListener("load",l,{once:!0}),d.addEventListener("error",()=>{Vo=null,n(new Error(`DevTools 번들 로드 실패: ${r}`))},{once:!0}),document.head.appendChild(d)}),Vo)}function Hx(){const s=window.G7Core;if(!s){be.warn("G7Core가 초기화되지 않았습니다.");return}const e=Ua.getInstance();if(e.initialize(),!e.isEnabled()){window.G7DevTools={isEnabled:()=>!1,enable:()=>{be.log("환경설정 > 고급 설정 > 디버그 모드를 켜세요")}},Td(),be.log("G7DevTools 비활성화됨 (디버그 모드 꺼짐)");return}Ux(s,e)}async function Ux(s,e){let n;try{n=await zx()}catch(p){be.warn("DevTools 번들 로드 실패 — 최소 API 로 폴백:",p),window.G7DevTools={isEnabled:()=>!1,enable:()=>{}},Td();return}const{DiagnosticEngine:r,getServerConnector:i,getStyleTracker:l}=n;jx(),Td();try{l().enable(),be.log("StyleTracker 활성화됨")}catch(p){be.warn("StyleTracker 활성화 실패:",p)}const c=new r,d=i(),f={isEnabled:()=>e.isEnabled(),state:{get:()=>e.getState(),getHistory:()=>e.getStateHistory(),watch:(p,m)=>e.watchState(p,m)},actions:{getHistory:()=>e.getActionHistory(),watch:p=>e.watchActions(p),getMetrics:()=>e.getActionMetrics()},binding:{evaluate:p=>{const m=s.getDataBindingEngine?.();if(!m){be.warn("DataBindingEngine이 없습니다.");return}return m.evaluateExpression(p,e.getState())},getCacheStats:()=>e.getCacheStats(),clearStats:()=>{e.resetCacheStats(),be.log("캐시 통계 초기화됨")}},diagnose:{analyze:p=>c.analyze(p),suggestFix:p=>c.suggestFix(p),getCommonIssues:()=>c.getCommonIssues(),getRulesByCategory:p=>c.getRulesByCategory(p)},server:{dumpState:p=>d.dumpState(p),sendLog:p=>d.sendLog(p),sendError:(p,m)=>d.sendError(p,m),isConnected:()=>d.isConnected(),testConnection:()=>d.testConnection()},config:{isDebugMode:()=>e.isEnabled(),setLogLevel:p=>e.setLogLevel(p),setMaxHistory:p=>e.setMaxHistory(p)},lifecycle:{getMountedComponents:()=>e.getLifecycleInfo().mountedComponents,getOrphanedListeners:()=>e.getLifecycleInfo().orphanedListeners},performance:{getRenderCount:()=>e.getPerformanceInfo().renderCounts,getBindingEvalCount:()=>e.getPerformanceInfo().bindingEvalCount,getMemoryWarnings:()=>e.getPerformanceInfo().memoryWarnings,startProfiling:()=>e.startProfiling(),stopProfiling:()=>e.stopProfiling()},network:{getActiveRequests:()=>e.getNetworkInfo().activeRequests,getRequestHistory:()=>e.getNetworkInfo().requestHistory,getPendingDataSources:()=>e.getNetworkInfo().pendingDataSources},conditional:{getIfConditions:()=>e.getConditionalInfo().ifConditions,getIterations:()=>e.getConditionalInfo().iterations},form:{getForms:()=>e.getFormInfo()},websocket:{getInfo:()=>e.getWebSocketInfo()}};window.G7DevTools=f,s.devtools=f,be.log("G7DevTools 전역 객체 초기화 완료 (window.G7DevTools)"),Px(n.DevToolsPanel)}function Px(s){if(document.getElementById("g7-devtools-root")){be.log("DevToolsPanel 이미 렌더링됨");return}const e=document.createElement("div");e.id="g7-devtools-root",document.body.appendChild(e);try{Ad.createRoot(e).render(We.createElement(s)),be.log("DevToolsPanel UI 렌더링 완료")}catch(n){be.error("DevToolsPanel UI 렌더링 실패:",n)}}const Je=dt("TemplateEngine"),re={templateId:null,locale:"ko",isInitialized:!1,reactRoot:null,containerId:null,currentLayoutJson:null,currentDataContext:{},translationContext:{templateId:"",locale:"ko"},registry:null,bindingEngine:null,translationEngine:null,actionDispatcher:null,templateMetadata:null};let Ko=!1;const Wo=[];async function Bx(s){try{Je.log("템플릿 메타데이터 로드 중...",s);const e=s.split("-").map(r=>r.split("_").map(i=>i.charAt(0).toUpperCase()+i.slice(1)).join("")).join(""),n=window[e];return n?.templateMetadata?(Je.log("템플릿 메타데이터 로드 완료 (전역 변수)",n.templateMetadata),n.templateMetadata):(Je.warn(`템플릿 번들에 메타데이터가 없습니다. 전역 변수: ${e}`),{identifier:s,locales:["ko","en"],name:{ko:s,en:s},description:{ko:"",en:""},version:"1.0.0",type:"admin"})}catch(e){return Je.error("템플릿 메타데이터 로드 실패",e),{identifier:s,locales:["ko","en"],name:{ko:s,en:s},description:{ko:"",en:""},version:"1.0.0",type:"admin"}}}function db(){const e=(typeof window<"u"?window.__templateApp:void 0)?.globalState?.appConfig?.supportedLocales,n=re.templateMetadata?.locales;return{$locale:re.locale,$locales:Array.isArray(e)&&e.length>0?e:n||["ko","en"],$templateLocales:n||["ko","en"],$templateId:re.templateId}}async function Yo(s){try{if(Je.log("템플릿 엔진 초기화 시작",s),re.isInitialized)throw new Error("템플릿 엔진이 이미 초기화되었습니다. destroyTemplate()을 먼저 호출하세요.");if(!s.templateId)throw new IA;Ko=s.debug??!1,typeof window<"u"&&(window.G7Config||(window.G7Config={}),window.G7Config.debug=Ko),Hx(),re.templateId=s.templateId,re.locale=s.locale||"ko",Je.log("엔진 인스턴스 생성 중..."),re.registry=Er.getInstance(),re.bindingEngine=new Tn,re.translationEngine=wi.getInstance(),s.cacheVersion!==void 0&&s.cacheVersion>0&&re.translationEngine.setCacheVersion(s.cacheVersion),re.translationContext={templateId:s.templateId,locale:re.locale},re.actionDispatcher=new Lo({},re.translationEngine,re.translationContext),QC(re.actionDispatcher),Je.log("다국어 파일 로드 중...",s.templateId,re.locale);const e="en",n=[re.translationEngine.loadTranslations(s.templateId,re.locale).then(()=>{Je.log(`다국어 파일 로드 완료: ${re.locale}`)}).catch(r=>{Je.warn(`다국어 파일 로드 실패 (${re.locale}):`,r instanceof Error?r.message:r)})];re.locale!==e&&n.push(re.translationEngine.loadTranslations(s.templateId,e).then(()=>{Je.log(`폴백 다국어 파일 로드 완료: ${e}`)}).catch(r=>{Je.warn(`폴백 다국어 파일 로드 실패 (${e}):`,r instanceof Error?r.message:r)})),await Promise.allSettled(n),Je.log("템플릿 메타데이터 로드 중...",s.templateId),re.templateMetadata=await Bx(s.templateId),re.isInitialized=!0,Je.log("템플릿 엔진 초기화 완료 (ComponentRegistry는 별도 로드)")}catch(e){throw Je.error("템플릿 엔진 초기화 실패",e),re.isInitialized=!1,re.registry=null,re.bindingEngine=null,re.translationEngine=null,re.actionDispatcher=null,e}}let Cs=null;const fb="g7-layout-editor-bundle";function nh(){const s=window.G7Core;return s?.__LayoutEditorChrome?Promise.resolve(s.__LayoutEditorChrome):Cs||(Cs=(async()=>{const e=window.G7Config?.coreEditorAsset||"/build/core/layout-editor.min.js";document.getElementById(fb)?.remove(),window.G7Core=window.G7Core||{},window.G7Core.__onChromeReady=()=>{};try{await Cr(e,{id:fb},{label:"layout-editor bundle"})}catch(r){throw Cs=null,Je.error(`편집기 번들 로드 실패 (${e})`,r),new Error("편집기를 불러오지 못했습니다. 네트워크 상태를 확인한 뒤 다시 시도해 주세요.")}const n=window.G7Core?.__LayoutEditorChrome;if(!n)throw Cs=null,Je.error(`편집기 번들 로드됨 — 그러나 __LayoutEditorChrome 미노출 (${e})`),new Error("편집기를 불러왔으나 초기화하지 못했습니다. 페이지를 새로고침해 주세요.");return n})(),Cs)}async function Es(s){try{if(Je.log("템플릿 렌더링 시작",s),!re.isInitialized)throw new Error("템플릿 엔진이 초기화되지 않았습니다. initTemplateEngine()을 먼저 호출하세요.");if(!s.containerId)throw new Error("containerId는 필수입니다.");if(!s.layoutJson)throw new Error("layoutJson은 필수입니다.");const e=document.getElementById(s.containerId);if(!e)throw new Error(`컨테이너를 찾을 수 없습니다: #${s.containerId}`);const n=db();if(re.containerId=s.containerId,re.currentLayoutJson=s.layoutJson,re.currentDataContext={...n,...s.dataContext||{}},re.translationContext=s.translationContext||{templateId:re.templateId||"",locale:re.locale},re.reactRoot||(Je.log("React Root 생성"),re.reactRoot=Ad.createRoot(e)),typeof window<"u"){const l=tb(window.location.pathname);if(l){Je.log("레이아웃 편집기 모드 진입",l);let c;try{c=await nh()}catch(f){Je.error("레이아웃 편집기 번들 로드 실패",f),Jf.render(s.containerId,{title:"레이아웃 편집기 로드 실패",message:f instanceof Error?f.message:"편집기 번들을 불러오지 못했습니다.",icon:"fas fa-triangle-exclamation",showStack:!1,showReloadButton:!0,debug:Ko});return}const d=We.createElement(c,{templateIdentifier:l.templateIdentifier,initialLocale:re.locale});re.reactRoot.render(We.createElement(qc,{translationEngine:re.translationEngine,translationContext:re.translationContext,children:We.createElement(Sf,{children:We.createElement(Rc,{children:We.createElement(Vf,{children:d})})})}));return}}const r=s.layoutJson.components||[];if(r.length===0){Je.warn("렌더링할 컴포넌트가 없습니다.");return}const i=s.layoutJson.modals||[];if(Je.log("modals 배열:",i),Je.log("modals 개수:",i.length),Je.log("DynamicRenderer로 렌더링 시작"),re.reactRoot.render(We.createElement(qc,{translationEngine:re.translationEngine,translationContext:re.translationContext},We.createElement(Sf,null,We.createElement(Rc,null,We.createElement(Vf,null,[...r.map((l,c)=>{const d=re.currentLayoutJson?.layout_name||"";return We.createElement(Vr,{key:d&&!l._fromBase?`${l.id}_${d}`:l.id,componentDef:l,dataContext:re.currentDataContext,translationContext:re.translationContext,registry:re.registry,bindingEngine:re.bindingEngine,translationEngine:re.translationEngine,actionDispatcher:re.actionDispatcher,isRootRenderer:c===0,layoutKey:d})}),We.createElement(qm,{key:"__modal_parent_context_provider"},i.map(l=>{const c=re.currentDataContext._global?.modalStack||[],f=c.includes(l.id)||re.currentDataContext._global?.activeModal===l.id,p=c.indexOf(l.id),m=p>=0?50+p:50,y=window.__g7LayoutContextStack||[],S=y[y.length-1]?.dataContext,v=We.createElement(Vr,{key:`modal_${l.id}_renderer`,componentDef:{...l,props:{...l.props,isOpen:f,style:{...l.props?.style,zIndex:m},onClose:re.actionDispatcher?.createHandler({type:"click",handler:"closeModal"},re.currentDataContext)}},dataContext:re.currentDataContext,translationContext:re.translationContext,registry:re.registry,bindingEngine:re.bindingEngine,translationEngine:re.translationEngine,actionDispatcher:re.actionDispatcher,parentDataContext:S});return l.data_sources&&l.data_sources.length>0?We.createElement(Zy,{key:`modal_${l.id}`,isOpen:f,modalId:l.id,dataSources:l.data_sources,dataContext:re.currentDataContext,globalStateUpdater:re.actionDispatcher?.getGlobalStateUpdater(),bindingEngine:re.bindingEngine,debug:Ko,children:v}):v}))]))))),Je.log("템플릿 렌더링 완료"),Wo.length>0){Je.log(`대기 중인 데이터 업데이트 ${Wo.length}건 적용`);const l=[...Wo];Wo.length=0;for(const{data:c,options:d}of l)_s(c,d)}}catch(e){throw Je.error("템플릿 렌더링 실패",e),e}}function _s(s,e){try{if(Je.log("템플릿 데이터 업데이트 시작",Object.keys(s)),!re.isInitialized)throw new Error("템플릿 엔진이 초기화되지 않았습니다.");if(!re.reactRoot||!re.currentLayoutJson){Je.log("React 미준비 - 데이터 업데이트 큐잉:",Object.keys(s)),Wo.push({data:s,options:e});return}const n=db(),r={...re.currentDataContext._global||{},...s._global||{}},i=iE(re.currentDataContext._localInit,s._localInit);re.currentDataContext={...n,...re.currentDataContext,...s,_global:r,_localInit:i},r._local!==void 0&&(re.currentDataContext._local=r._local),r._computed!==void 0&&(re.currentDataContext._computed=r._computed);const l=re.currentLayoutJson.components||[],c=re.currentLayoutJson.modals||[];Je.log("updateTemplateData - modals 배열:",c),Je.log("updateTemplateData - modals 개수:",c.length),Je.log("updateTemplateData - activeModal:",re.currentDataContext._global?.activeModal);const d=()=>{re.reactRoot.render(We.createElement(qc,{translationEngine:re.translationEngine,translationContext:re.translationContext},We.createElement(Sf,null,We.createElement(Rc,null,We.createElement(Vf,null,[...l.map((f,p)=>{const m=re.currentLayoutJson?.layout_name||"";return We.createElement(Vr,{key:m&&!f._fromBase?`${f.id}_${m}`:f.id,componentDef:f,dataContext:re.currentDataContext,translationContext:re.translationContext,registry:re.registry,bindingEngine:re.bindingEngine,translationEngine:re.translationEngine,actionDispatcher:re.actionDispatcher,isRootRenderer:p===0,layoutKey:m})}),We.createElement(qm,{key:"__modal_parent_context_provider_update"},c.map(f=>{const p=re.currentDataContext._global?.modalStack||[],y=p.includes(f.id)||re.currentDataContext._global?.activeModal===f.id,C=p.indexOf(f.id),S=C>=0?50+C:50,v=window.__g7LayoutContextStack||[],w=v[v.length-1]?.dataContext,R=We.createElement(Vr,{key:`modal_${f.id}_renderer`,componentDef:{...f,props:{...f.props,isOpen:y,style:{...f.props?.style,zIndex:S},onClose:re.actionDispatcher?.createHandler({type:"click",handler:"closeModal"},re.currentDataContext)}},dataContext:re.currentDataContext,translationContext:re.translationContext,registry:re.registry,bindingEngine:re.bindingEngine,translationEngine:re.translationEngine,actionDispatcher:re.actionDispatcher,parentDataContext:w});return f.data_sources&&f.data_sources.length>0?We.createElement(Zy,{key:`modal_${f.id}`,isOpen:y,modalId:f.id,dataSources:f.data_sources,dataContext:re.currentDataContext,globalStateUpdater:re.actionDispatcher?.getGlobalStateUpdater(),bindingEngine:re.bindingEngine,debug:Ko,children:R}):R}))])))))};e?.sync?(Je.log("재렌더링 시작 (sync mode - 즉시 렌더링)"),d()):(Je.log("재렌더링 시작 (with startTransition)"),M.startTransition(()=>{d()})),Je.log("템플릿 데이터 업데이트 완료")}catch(n){throw Je.error("템플릿 데이터 업데이트 실패",n),n}}function Qc(){try{Je.log("템플릿 정리 시작"),re.reactRoot&&(Je.log("React Root 언마운트"),re.reactRoot.unmount(),re.reactRoot=null),re.templateId=null,re.locale="ko",re.isInitialized=!1,re.containerId=null,re.currentLayoutJson=null,re.currentDataContext={},re.translationContext={templateId:"",locale:"ko"},re.registry=null,re.bindingEngine=null,re.translationEngine=null,re.actionDispatcher=null,re.templateMetadata=null,Je.log("템플릿 정리 완료")}catch(s){throw Je.error("템플릿 정리 실패",s),s}}function ca(){return Object.freeze({...re})}function hb(){return re.actionDispatcher}const Xo={initTemplateEngine:Yo,renderTemplate:Es,updateTemplateData:_s,destroyTemplate:Qc,getState:ca};typeof window<"u"&&(window.G7Core||(window.G7Core={}),window.G7Core.TemplateEngine=Xo,Ix({getState:()=>({translationEngine:re.translationEngine,translationContext:re.translationContext,bindingEngine:re.bindingEngine,actionDispatcher:re.actionDispatcher,templateMetadata:re.templateMetadata}),transitionManager:Gr,responsiveManager:_i,webSocketManager:Vc}),Je.log("전역 객체 window.G7Core.TemplateEngine에 노출됨"));const Wr=Object.freeze(Object.defineProperty({__proto__:null,DataSourceManager:Dr,LayoutLoader:Gf,TemplateApp:Go,TemplateEngine:Xo,default:Xo,destroyTemplate:Qc,getActionDispatcher:hb,getState:ca,initTemplateApp:th,initTemplateEngine:Yo,loadLayoutEditorBundle:nh,renderTemplate:Es,updateTemplateData:_s},Symbol.toStringTag,{value:"Module"}));Yt.DataSourceManager=Dr,Yt.LayoutLoader=Gf,Yt.TemplateApp=Go,Yt.TemplateEngine=Xo,Yt.default=Xo,Yt.destroyTemplate=Qc,Yt.getActionDispatcher=hb,Yt.getState=ca,Yt.initTemplateApp=th,Yt.initTemplateEngine=Yo,Yt.loadLayoutEditorBundle=nh,Yt.renderTemplate=Es,Yt.updateTemplateData=_s,Object.defineProperties(Yt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})})(this.G7Core=this.G7Core||{}); + `}static renderFromError(e,n,r,i=!1,l,c,d){let f,h;if(n.userMessageKey.startsWith("$t:"))if(c&&l)try{f=c.translate(n.userMessageKey,l)}catch{f=n.userMessageKey.replace("$t:","")}else f=n.userMessageKey.replace("$t:","");else f=n.userMessageKey;if(d){const m=d;m.details?.apiMessage?h=m.details.apiMessage:m.response?.data?.message&&(h=m.response.data.message)}this.render(e,{title:r,message:f,detailMessage:h,icon:n.icon,showStack:n.showStack,stackTrace:n.stack,showReloadButton:n.recoverable,debug:i})}static escapeHtml(e){if(!e)return"";const n=document.createElement("div");return n.textContent=e,n.innerHTML}}const _s=pt("Router");class Kx{constructor(e){M(this,"routes",[]);M(this,"templateIdentifier");M(this,"eventHandlers",new Map);M(this,"pendingNavigation",null);M(this,"isNavigating",!1);M(this,"handlePopState",()=>{this.navigateToCurrentPath()});this.templateIdentifier=e,this.initPopstateListener()}initPopstateListener(){window.addEventListener("popstate",this.handlePopState)}on(e,n){this.eventHandlers.has(e)||this.eventHandlers.set(e,[]),this.eventHandlers.get(e).push(n)}async emit(e,...n){const r=this.eventHandlers.get(e);r&&await Promise.all(r.map(i=>i(...n)))}async loadRoutes(e){try{const n=e!==void 0&&e>0?e:null,r=await fetch(Br(`/api/templates/${this.templateIdentifier}/routes`,"json",n));if(!r.ok)throw new Error(`Failed to load routes: ${r.statusText}`);const i=await r.json();if(!i.success)throw new Error("Failed to load routes from API");if(i.data&&Array.isArray(i.data.routes))this.routes=i.data.routes,_s.log(`Loaded ${this.routes.length} routes${e?` (v=${e})`:""}`);else throw new Error("Invalid routes data format")}catch(n){throw _s.error("Error loading routes:",n),n}}setRoutes(e){this.routes=e,_s.log(`Set ${this.routes.length} routes`)}match(e){const n=this.normalizePathname(e);for(const r of this.routes){const i=this.matchPattern(r.path,n);if(i!==null)return{route:r,params:i}}return null}normalizePathname(e){return e.length>1&&e.endsWith("/")?e.replace(/\/+$/,"")||"/":e}matchPattern(e,n){const r=[];let i=e.replace(/:([^/]+)/g,(f,h)=>(r.push(h),"([^/]+)"));i.startsWith("*/")&&(i="(?:/[^/]+)?"+i.slice(1)),i=i.replace(/\//g,"\\/");const l=new RegExp(`^${i}$`),c=n.match(l);if(!c)return null;const d={};return r.forEach((f,h)=>{d[f]=c[h+1]}),d}getRoutes(){return[...this.routes]}getAuthType(e,n){return e.auth_type?e.auth_type:n.startsWith("/admin")?"admin":"user"}async navigateToCurrentPath(){const e=window.location.pathname,n=window.location.search,r=this.match(e);if(!r){_s.warn(`No route matched for path: ${e}`),this.emit("routeNotFound",e);return}if(r.route.redirect){_s.log(`Redirecting from ${e} to ${r.route.redirect}`),this.navigate(r.route.redirect);return}if(r.route.auth_required){const c=this.getAuthType(r.route,e),d=Xn.getInstance();let f=d.isAuthenticated()&&d.getAuthType()===c;if(f||(f=await d.checkAuth(c)),!f){const h=d.getLoginRedirectUrl(c,e+n);_s.log(`Not authenticated, redirecting to: ${h}`),window.location.href=h;return}}const i=new URLSearchParams(n),l={};for(const c of i.keys()){if(c in l)continue;const d=i.getAll(c);d.length>1?l[c]=d:d.length===1&&(c.endsWith("[]")?l[c]=d:l[c]=d[0])}await this.emit("routeChange",{path:e,layout:r.route.layout,endpoint:r.route.endpoint,params:{...r.route.params||{},...r.params},query:l,auth_required:r.route.auth_required,auth_type:r.route.auth_type,meta:r.route.meta})}navigate(e){if(this.isNavigating){this.pendingNavigation=e;return}this.executeNavigation(e)}async executeNavigation(e){this.isNavigating=!0,this.pendingNavigation=null;try{window.history.pushState({},"",e),await this.navigateToCurrentPath()}finally{if(this.isNavigating=!1,this.pendingNavigation){const n=this.pendingNavigation;this.executeNavigation(n)}}}}const Wx=/^\/admin\/layout-editor\/([^/?#]+)\/?$/;function ch(s){const e=Wx.exec(s);return e?{templateIdentifier:e[1]}:null}const Wt=pt("ErrorPageHandler");class Yx{constructor(e){M(this,"templateId");M(this,"layoutLoader");M(this,"locale");M(this,"debug");M(this,"renderFunction");M(this,"dataSourceManager");M(this,"globalState");M(this,"errorConfig",null);M(this,"configLoaded",!1);this.templateId=e.templateId,this.layoutLoader=e.layoutLoader,this.locale=e.locale,this.debug=e.debug,this.renderFunction=e.renderFunction,this.dataSourceManager=e.dataSourceManager,this.globalState=e.globalState||{}}async loadConfig(){if(this.configLoaded)return this.errorConfig;try{const e=await fetch(Br(`/api/templates/${this.templateId}/config`,"json"));if(!e.ok)return this.debug&&Wt.warn("Failed to load template config:",e.statusText),this.configLoaded=!0,null;const n=await e.json();if(!n.success||!n.data)return this.debug&&Wt.warn("Invalid template config response"),this.configLoaded=!0,null;const r=n.data;return!r.error_config||!r.error_config.layouts?(this.debug&&Wt.warn("No error_config found in template.json"),this.configLoaded=!0,null):(this.errorConfig=r.error_config,this.configLoaded=!0,this.debug&&Wt.log("Error config loaded:",this.errorConfig),this.errorConfig)}catch(e){return Wt.error("Failed to load error config:",e),this.configLoaded=!0,null}}async renderError(e,n="app"){try{const r=await this.loadConfig();if(!r)return this.debug&&Wt.warn("No error config available, cannot render error page"),!1;const i=r.layouts[e]||r.layouts[String(e)];if(!i)return this.debug&&Wt.warn(`No layout defined for error code: ${e}`),!1;this.debug&&Wt.log(`Loading error layout: ${i} for code: ${e}`);const l=await this.layoutLoader.loadLayout(this.templateId,i);if(!l)return this.debug&&Wt.error(`Failed to load error layout: ${i}`),!1;this.debug&&Wt.log("Error layout loaded:",l);let c={};const d=l.data_sources||[];if(d.length>0){this.debug&&Wt.log("Fetching data sources:",d.map(S=>S.id));const m=d.filter(S=>S.loading_strategy==="blocking"),y=d.filter(S=>!S.loading_strategy||S.loading_strategy==="progressive"),v=[...m,...y];if(v.length>0)try{c=await this.dataSourceManager.fetchDataSources(v,{},new URLSearchParams),this.debug&&Wt.log("Data sources fetched:",Object.keys(c))}catch(S){Wt.error("Failed to fetch data sources:",S)}}const f={};d.length>0&&(this.processInitOptions(d,c,f),this.debug&&Wt.log("initOptions processed:",{globalKeys:Object.keys(this.globalState),localKeys:Object.keys(f)}));const h={...c,errorCode:e,_global:{...this.globalState},_local:{...f}};return await this.renderFunction({containerId:n,layoutJson:l,dataContext:h,translationContext:{templateId:this.templateId,locale:this.locale}}),this.debug&&Wt.log(`Error page ${e} rendered successfully`),!0}catch(r){return Wt.error(`Failed to render error page ${e}:`,r),!1}}processInitOptions(e,n,r){for(const i of e){const l=n[i.id];if(!l)continue;const c=l?.data??l;if(i.initLocal){if(typeof i.initLocal=="string")r[i.initLocal]=c,Wt.log(`initLocal: ${i.id}.data -> _local.${i.initLocal}`);else if(typeof i.initLocal=="object"&&"key"in i.initLocal){const{key:d,path:f}=i.initLocal;r[d]=f?this.getValueByPath(c,f):c,Wt.log(`initLocal: ${i.id}.data${f?"."+f:""} -> _local.${d}`)}}if(i.initGlobal){const d=Array.isArray(i.initGlobal)?i.initGlobal:[i.initGlobal];for(const f of d)if(typeof f=="string")this.globalState[f]=c,Wt.log(`initGlobal: ${i.id}.data -> _global.${f}`);else if(typeof f=="object"&&f!==null&&"key"in f){const{key:h,path:m}=f;this.globalState[h]=m?this.getValueByPath(c,m):c,Wt.log(`initGlobal: ${i.id}.data${m?"."+m:""} -> _global.${h}`)}}}}getValueByPath(e,n){return n.split(".").reduce((r,i)=>r?.[i],e)}updateGlobalState(e){this.globalState={...this.globalState,...e}}updateLocale(e){this.locale=e,this.debug&&Wt.log("Locale updated:",e)}isConfigLoaded(){return this.configLoaded}async hasErrorLayout(e){const n=await this.loadConfig();return n?!!(n.layouts[e]||n.layouts[String(e)]):!1}clearConfigCache(){this.errorConfig=null,this.configLoaded=!1,this.debug&&Wt.log("Config cache cleared")}}const Vc=pt("AssetFailureNotice"),Rb="g7-asset-failure-notice",Xx="g7-system-banners",Kr=new Map;let As=!1,Kc=!1,Wo=null;function Di(s,e,n){try{const r=window?.G7Core?.t;if(typeof r=="function"){const i=r(s,n);if(typeof i=="string"&&i!==s&&!i.startsWith("core.assets."))return i}}catch{}return Jx(e,n)}function Jx(s,e){return e?Object.entries(e).reduce((n,[r,i])=>n.split("{"+r+"}").join(String(i)),s):s}function xs(s){!s||!s.id||(Kr.set(s.id,s),Kc=!1,Vc.warn(`Asset failure notified: ${s.id} (${s.label})`),Ts())}function Db(s){Kr.delete(s)&&(Vc.log(`Asset failure cleared: ${s}`),Ts())}function Ob(){Kr.size!==0&&(Kr.clear(),Ts())}function Qx(){return Array.from(Kr.values())}function Lb(s,e,n){return Di(s,e,n)}async function $b(){if(As)return;As=!0,Kc=!1,Ts();const s=Array.from(Kr.values()).filter(n=>typeof n.retry=="function");let e=!1;for(const n of s)try{await n.retry(),Kr.delete(n.id)}catch(r){e=!0,Vc.warn(`Asset retry failed: ${n.id}`,r)}As=!1,Kc=e,Ts()}function Zx(){try{return document.documentElement.classList.contains("dark")}catch{return!1}}function Ts(){if(typeof document>"u"||!document.body)return;const s=document.getElementById(Rb);if(Kr.size===0){s?.remove(),sT();return}const e=s??eT();tT(e),e.replaceChildren(nT()),iT()}function eT(){const s=document.createElement("div");return s.id=Rb,s.setAttribute("role","alert"),s.setAttribute("aria-live","polite"),document.body.appendChild(s),s}function tT(s){const n=document.getElementById(Xx)?.offsetHeight??0;s.style.cssText=["position:fixed",`top:${n}px`,"left:0","right:0","z-index:9998","display:flex","justify-content:center","pointer-events:none"].join(";")}function nT(){const s=Zx(),e=Array.from(Kr.values()),n=typeof window<"u"&&window.innerWidth<768,r=document.createElement("div");return r.style.cssText=["pointer-events:auto","box-sizing:border-box","width:100%","max-width:960px","margin:8px","padding:12px 16px","border-radius:8px",`border:1px solid ${s?"#78350f":"#fcd34d"}`,`background:${s?"#451a03":"#fffbeb"}`,`color:${s?"#fef3c7":"#78350f"}`,"box-shadow:0 4px 12px rgba(0,0,0,0.12)","font-size:14px","line-height:1.5","display:flex",n?"flex-direction:column":"flex-direction:row",n?"align-items:stretch":"align-items:center","gap:12px"].join(";"),r.style.background=s?"#451a03":"#fffbeb",r.style.color=s?"#fef3c7":"#78350f",r.style.borderColor=s?"#78350f":"#fcd34d",r.appendChild(rT(e,n)),r.appendChild(aT(e,n,s)),r}function rT(s,e){const n=document.createElement("div");n.style.cssText=["flex:1 1 auto","min-width:0","display:flex","gap:8px"].join(";");const r=document.createElement("span");r.setAttribute("aria-hidden","true"),r.textContent="⚠",r.style.cssText="flex:0 0 auto;font-size:16px;line-height:1.4",n.appendChild(r);const i=document.createElement("div");if(i.style.cssText="flex:1 1 auto;min-width:0",s.length===1){const l=s[0],c=document.createElement("div");c.setAttribute("data-asset-failure-id",l.id),c.textContent=l.message??Di("core.assets.load_failed","{label}을(를) 불러오지 못했습니다.",{label:l.label}),i.appendChild(c)}else{const l=document.createElement("div");l.style.cssText="font-weight:600",l.textContent=Di("core.assets.load_failed_multiple","{count}개 항목을 불러오지 못했습니다.",{count:s.length}),i.appendChild(l);const c=document.createElement("div");c.style.cssText="margin-top:2px;opacity:0.9;word-break:break-word",c.textContent=s.map(d=>d.label).join(", "),i.appendChild(c)}if(Kc){const l=document.createElement("div");l.style.cssText="margin-top:4px;font-weight:600",l.textContent=Di("core.assets.retry_failed","다시 시도했지만 실패했습니다. 잠시 후 다시 시도해 주세요."),i.appendChild(l)}return n.appendChild(i),e&&(n.style.alignItems="flex-start"),n}function aT(s,e,n){const r=document.createElement("div");if(r.style.cssText=["flex:0 0 auto","display:flex","gap:8px",e?"width:100%":"","align-items:center"].filter(Boolean).join(";"),s.some(c=>typeof c.retry=="function")){const c=document.createElement("button");c.type="button",c.dataset.action="retry",c.disabled=As,c.textContent=As?Di("core.assets.retrying","다시 시도 중..."):Di("core.assets.retry","다시 시도"),c.style.cssText=[e?"flex:1 1 auto":"","padding:6px 14px","border-radius:6px","font-size:14px","font-weight:600","cursor:pointer",`border:1px solid ${n?"#b45309":"#d97706"}`,`background:${n?"#b45309":"#f59e0b"}`,`color:${n?"#fffbeb":"#451a03"}`,As?"opacity:0.6":""].filter(Boolean).join(";"),c.addEventListener("click",()=>{$b()}),r.appendChild(c)}const l=document.createElement("button");return l.type="button",l.dataset.action="close",l.setAttribute("aria-label",Di("core.assets.close","닫기")),l.textContent="✕",l.style.cssText=["padding:6px 10px","border-radius:6px","font-size:14px","cursor:pointer","border:1px solid transparent","background:transparent",`color:${n?"#fef3c7":"#78350f"}`].join(";"),l.addEventListener("click",()=>{Ob()}),r.appendChild(l),r}function iT(){Wo||typeof MutationObserver>"u"||(Wo=new MutationObserver(()=>{Kr.size>0&&Ts()}),Wo.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}function sT(){Wo?.disconnect(),Wo=null}function oT(){const s=window,e=r=>({id:String(r?.id??""),label:String(r?.label??r?.url??"asset"),retry:typeof r?.retry=="function"?r.retry:void 0}),n=Array.isArray(s.__g7ExternalAssetFailures)?s.__g7ExternalAssetFailures:[];n.forEach(r=>{r?.id&&xs(e(r))}),s.__g7ExternalAssetSink=r=>{r?.id&&xs(e(r))},Vc.log(`템플릿 externals 실패 대기열 ${n.length}건 반영`)}const Rt=pt("ModuleAssetLoader");function lT(s){return s==="plugin"?Lb("core.assets.plugin_styles","플러그인 스타일"):Lb("core.assets.module_styles","모듈 스타일")}class cT{constructor(){M(this,"loadedAssets",new Map);M(this,"loadingPromises",new Map);M(this,"failedJsAssets",new Set);M(this,"failedCssAssets",new Set)}getFailedCssAssets(){return[...this.failedCssAssets]}hasFailedJsAssets(){return this.failedJsAssets.size>0}getFailedJsAssets(){return[...this.failedJsAssets]}async loadActiveExtensionAssets(e){if(!e||e.length===0){Rt.log("No module assets to load");return}const n=[...e].sort((d,f)=>d.priority-f.priority);Rt.log("Loading module assets:",n.map(d=>d.identifier));const r=n.filter(d=>d.css).map(d=>this.loadCSS(d.identifier,d.css)),i=n.filter(d=>d.js).map(d=>this.loadJS(d.identifier,d.js)),l=await Promise.allSettled([...r,...i]),c=l.filter(d=>d.status==="rejected");if(c.length>0){Rt.warn(`Some module assets failed to load (${c.length}/${l.length}); continuing with the rest`,this.getFailedJsAssets());return}Rt.log("All module assets loaded successfully")}async loadBundle(e,n,r){const i=[];if(r&&i.push(this.loadBundleCss(e,r)),n&&i.push(this.loadBundleJs(e,n)),i.length===0){Rt.log(`No bundle assets to load for: ${e}`);return}await Promise.all(i)}async loadCustomAssets(){const e=uT();if(e.length!==0)for(const n of e){const r=`g7-custom-${n.type}-${dT(n.id)}`;if(document.getElementById(r))continue;const i=`${n.type==="style"?"custom CSS":"custom JS"}: ${n.id}`,l=(d,f)=>n.type==="style"?ia(Ln(d),{id:r},{label:i,retries:f}):_r(Ln(d),{id:r},{label:i,retries:f}),c=Nd(n.url);try{if(c!==null)try{await l(n.url,0)}catch{Rt.warn(`Custom asset static miss, falling back to API: ${n.id} (${n.url} -> ${c})`),await l(c)}else await l(n.url);Rt.log(`Custom asset loaded: ${n.id}`)}catch(d){Rt.warn(`Failed to load custom asset: ${n.id} (${n.url})`,d),xs({id:`custom-asset:${n.id}`,label:n.id.split(":").pop()??n.id,retry:async()=>{document.getElementById(r)?.remove(),await l(c??n.url)}})}}}async loadBundleCss(e,n){const r=`ext-bundle-css-${e}`;if(document.getElementById(r)){Rt.log(`Bundle CSS already loaded: ${e}`);return}const i=Nd(n);try{if(i!==null)try{await ia(n,{id:r},{label:`bundle CSS: ${e}`,retries:0})}catch{Rt.warn(`Bundle CSS static miss, falling back to API: ${e} (${n} -> ${i})`),await ia(Ln(i),{id:r},{label:`bundle CSS: ${e}`})}else await ia(n,{id:r},{label:`bundle CSS: ${e}`});Rt.log(`Bundle CSS loaded: ${e}`);const l=document.getElementById(r);l&&this.registerLoadedAsset(`bundle-${e}`,{type:"css",element:l})}catch(l){this.surfaceCssFailure(`bundle-${e}`,lT(e),i!==null?Ln(i):n,l)}}async loadBundleJs(e,n){const r=`ext-bundle-js-${e}`;if(document.getElementById(r)){Rt.log(`Bundle JS already loaded: ${e}`);return}const i=this.loadingPromises.get(r);if(i)return Rt.log(`Bundle JS already loading: ${e}`),i;const l=Nd(n),d=(l!==null?_r(n,{id:r},{label:`bundle JS: ${e}`,retries:0}).catch(()=>(Rt.warn(`Bundle JS static miss, falling back to API: ${e} (${n} -> ${l})`),_r(Ln(l),{id:r},{label:`bundle JS: ${e}`}))):_r(n,{id:r},{label:`bundle JS: ${e}`})).then(()=>{Rt.log(`Bundle JS loaded: ${e}`);const f=document.getElementById(r);f&&this.registerLoadedAsset(`bundle-${e}`,{type:"js",element:f}),this.loadingPromises.delete(r)}).catch(f=>{throw Rt.warn(`Failed to load bundle JS: ${e} (${n})`,f),this.failedJsAssets.add(e),this.loadingPromises.delete(r),f});return this.loadingPromises.set(r,d),d}async loadCSS(e,n){const r=`module-css-${e}`;if(document.getElementById(r)){Rt.log(`CSS already loaded: ${e}`);return}const i=this.loadingPromises.get(r);if(i)return Rt.log(`CSS already loading: ${e}`),i;const l=ia(n,{id:r},{label:`CSS: ${e}`}).then(()=>{Rt.log(`CSS loaded: ${e}`);const c=document.getElementById(r);c&&this.registerLoadedAsset(e,{type:"css",element:c}),this.loadingPromises.delete(r)}).catch(c=>{this.loadingPromises.delete(r),this.surfaceCssFailure(e,e,n,c)});return this.loadingPromises.set(r,l),l}surfaceCssFailure(e,n,r,i){Rt.warn(`Failed to load CSS after retries: ${e} (${r})`,i),this.failedCssAssets.add(e),xs({id:`ext-css:${e}`,label:n,retry:async()=>{document.getElementById(`module-css-${e}`)?.remove(),document.getElementById(`ext-bundle-css-${e.replace(/^bundle-/,"")}`)?.remove(),await ia(r,{},{label:`CSS retry: ${e}`}),this.failedCssAssets.delete(e)}})}async loadJS(e,n){const r=`module-js-${e}`;if(document.getElementById(r)){Rt.log(`JS already loaded: ${e}`);return}const i=this.loadingPromises.get(e);if(i)return Rt.log(`JS already loading: ${e}`),i;const l=_r(n,{id:r},{label:`JS: ${e}`}).then(()=>{Rt.log(`JS loaded: ${e}`);const c=document.getElementById(r);c&&this.registerLoadedAsset(e,{type:"js",element:c}),this.loadingPromises.delete(e)}).catch(c=>{throw Rt.warn(`Failed to load JS: ${e} (${n})`,c),this.failedJsAssets.add(e),this.loadingPromises.delete(e),c});return this.loadingPromises.set(e,l),l}registerLoadedAsset(e,n){const r=this.loadedAssets.get(e)||[];r.push(n),this.loadedAssets.set(e,r)}unloadExtensionAsset(e){const n=this.loadedAssets.get(e);if(!n||n.length===0){Rt.log(`No assets to unload for: ${e}`);return}n.forEach(r=>{r.element.parentNode&&(r.element.parentNode.removeChild(r.element),Rt.log(`${r.type.toUpperCase()} unloaded: ${e}`))}),this.loadedAssets.delete(e),Rt.log(`All assets unloaded for: ${e}`)}unloadAllAssets(){Array.from(this.loadedAssets.keys()).forEach(n=>{this.unloadExtensionAsset(n)}),Rt.log("All module assets unloaded")}isLoaded(e){return this.loadedAssets.has(e)}getLoadedModules(){return Array.from(this.loadedAssets.keys())}}let uh=null;function uT(){const s=window?.G7Config?.customAssets;return Array.isArray(s)?s.filter(e=>e&&typeof e.id=="string"&&typeof e.url=="string"&&(e.type==="style"||e.type==="script")):[]}function dT(s){return s.replace(/[^A-Za-z0-9_-]/g,"-")}function dh(){return uh||(uh=new cT),uh}function fT(){if(typeof window>"u")return[];const s=window.G7Config;if(!s?.moduleAssets)return[];const e=[];for(const[n,r]of Object.entries(s.moduleAssets)){const i=r;e.push({identifier:n,js:i.js?Ln(i.js):i.js,css:i.css?Ln(i.css):i.css,priority:i.priority,external:i.external})}return e}function hT(){if(typeof window>"u")return null;const s=window.G7Config;if(!s?.bundleUrls)return null;const e=s.bundleUrls;return{moduleJs:e.moduleJs?Ln(e.moduleJs):e.moduleJs,moduleCss:e.moduleCss?Ln(e.moduleCss):e.moduleCss,pluginJs:e.pluginJs?Ln(e.pluginJs):e.pluginJs,pluginCss:e.pluginCss?Ln(e.pluginCss):e.pluginCss}}function pT(){if(typeof window>"u")return[];const s=window.G7Config;if(!s?.pluginAssets)return[];const e=[];for(const[n,r]of Object.entries(s.pluginAssets)){const i=r;e.push({identifier:n,js:i.js?Ln(i.js):i.js,css:i.css?Ln(i.css):i.css,priority:i.priority,external:i.external})}return e}const fh=pt("SystemBannerManager");class Wc{static show(e){this.banners.set(e.id,e),this.render(),fh.log(`Banner shown: ${e.id}`)}static hide(e){this.banners.delete(e)&&(this.render(),fh.log(`Banner hidden: ${e}`))}static hideAll(){this.banners.clear(),this.render(),fh.log("All banners hidden")}static detectLocale(){try{const n=window.G7Core;if(n?.locale?.current)return n.locale.current()}catch{}return(navigator.language||"ko").split("-")[0]}static resolveMessage(e,n){return typeof e=="string"?e:e[n]||e.en||e.ko||Object.values(e)[0]||""}static render(){if(typeof document>"u")return;let e=document.getElementById(this.containerId);if(this.banners.size===0){e&&(e.remove(),this.adjustAppPadding(0));return}e||(e=document.createElement("div"),e.id=this.containerId,e.style.cssText="position:fixed;top:0;left:0;right:0;z-index:99999;",document.body.prepend(e));const n=Array.from(this.banners.values()).sort((i,l)=>(i.order??0)-(l.order??0)),r=this.detectLocale();e.innerHTML=n.map(i=>{const l=this.resolveMessage(i.message,r),c=i.background||"#f59e0b",d=i.color||"white";return`
${l}
`}).join(""),requestAnimationFrame(()=>{e&&this.adjustAppPadding(e.offsetHeight)})}static adjustAppPadding(e){const n=document.getElementById("app");n&&(n.style.paddingTop=e>0?`${e}px`:"")}}M(Wc,"banners",new Map),M(Wc,"containerId","g7-system-banners");const U=pt("TemplateApp");function Mb(s){const e={};for(const n of s.keys()){if(n in e)continue;const r=s.getAll(n);r.length>1?e[n]=r:r.length===1&&(n.endsWith("[]")?e[n]=r:e[n]=r[0])}return e}const $r=class $r{constructor(e){M(this,"router",null);M(this,"layoutLoader",null);M(this,"errorPageHandler",null);M(this,"config");M(this,"globalState");M(this,"globalStateListeners",new Set);M(this,"currentRouteChangeId",0);M(this,"failedLayoutScripts",new Set);M(this,"currentDataSources",[]);M(this,"currentRawDataSources",[]);M(this,"currentRouteParams",{});M(this,"currentQueryParams",new URLSearchParams);M(this,"currentFetchedData",{});M(this,"currentLayoutName","");M(this,"templateErrorHandling",null);M(this,"currentWebSocketSubscriptions",[]);M(this,"extensionCacheVersion",0);M(this,"currentGlobalHeaders",[]);M(this,"transitionOverlayEl",null);M(this,"skeletonOverlayRoot",null);M(this,"skeletonOverlayContainer",null);M(this,"_spinnerState",null);M(this,"modalDataSources",new Map);this.globalState={sidebarOpen:!1},this.loadG7Config(),this.migrateLocaleStorage();const n=this.loadLocaleFromStorage(),r=n||e.locale||"ko";this.config={...e,locale:r},!n&&e.locale&&this.saveLocaleToStorage(e.locale)}loadG7Config(){if(typeof window<"u"&&window.G7Config){const e=window.G7Config;e.settings&&(this.globalState.settings=e.settings,U.log("Loaded settings from G7Config:",Object.keys(e.settings)),e.settings.upload&&(this.globalState.uploadSettings=e.settings.upload)),e.plugins&&(this.globalState.plugins=e.plugins,U.log("Loaded plugin settings from G7Config:",Object.keys(e.plugins))),e.modules&&(this.globalState.modules=e.modules,U.log("Loaded module settings from G7Config:",Object.keys(e.modules))),e.appConfig&&(this.globalState.appConfig=e.appConfig,U.log("Loaded appConfig from G7Config:",Object.keys(e.appConfig)))}}resolveRouteExpressions(e){const n=new $n,r={_global:this.globalState};return e.map(i=>{const l={...i};if(l.path&&l.path.includes("{{")){const c=l.path;l.path=n.resolveBindings(l.path,r),l.path=l.path.replace(/\/\/+/g,"/")||"/",l.path.includes("{{")&&(U.warn("Route expression resolution failed, using fallback:",c),l.path=c.replace(/\{\{[^}]+\}\}/g,"").replace(/\/\/+/g,"/")||"/")}if(l.redirect&&l.redirect.includes("{{")){const c=l.redirect;l.redirect=n.resolveBindings(l.redirect,r),l.redirect=l.redirect.replace(/\/\/+/g,"/")||"/",l.redirect.includes("{{")&&(U.warn("Route redirect expression resolution failed:",c),l.redirect=c.replace(/\{\{[^}]+\}\}/g,"").replace(/\/\/+/g,"/")||"/")}return l})}migrateLocaleStorage(){const e=["locale","g7_template_locale"];for(const n of e)try{const r=localStorage.getItem(n);r&&r!==localStorage.getItem($r.LOCALE_STORAGE_KEY)&&(localStorage.setItem($r.LOCALE_STORAGE_KEY,r),U.log(`Migrated locale from '${n}' to '${$r.LOCALE_STORAGE_KEY}'`)),localStorage.removeItem(n)}catch(r){U.warn(`Failed to migrate locale key '${n}':`,r)}}async init(){try{po.getInstance().setDebug(this.config.debug),U.log("Initializing with config:",this.config),w0();const e=Ar.getInstance(),n=Xn.getInstance(),r=typeof window<"u"&&Number(window.G7Config?.cache_version)||0,i=r>0?r:this.loadCacheVersionFromStorage()||0,[l,c,d,f,h]=await Promise.all([el({templateId:this.config.templateId,templateType:this.config.templateType,locale:this.config.locale,debug:this.config.debug,cacheVersion:i}),e.loadComponents(this.config.templateId,this.config.templateType,i),nc(i>0?go(`templates/${this.config.templateId}/routes.json`,i):null,Br(`/api/templates/${this.config.templateId}/routes`,"json",i>0?i:null),{label:"routes.json"}).then(A=>{if(!A.ok)throw new Error(`Failed to load routes: ${A.statusText}`);return A.json()}).then(A=>{if(!A.success)throw new Error("Failed to load routes from API");return A.data}).catch(A=>{throw U.error("Error loading routes:",A),A}),n.preloadAuth(this.config.templateType==="admin"?"admin":"user"),fetch(Br(`/api/templates/${this.config.templateId}/config`,"json")).then(A=>A.ok?A.json():null).then(A=>!A?.success||!A?.data?null:A.data).catch(A=>(U.warn("Error loading template config:",A),null))]);if(U.log("Template Engine initialized"),U.log("ComponentRegistry loaded"),U.log("Routes data loaded"),U.log("User info preloaded"),U.log("Template config loaded:",h),h?.cache_version!==void 0){const A=i>0?i:null;if(this.extensionCacheVersion=h.cache_version,this.saveCacheVersionToStorage(this.extensionCacheVersion),U.log("Extension cache version:",this.extensionCacheVersion),A!==null&&A!==this.extensionCacheVersion){U.log("Cache version changed, reloading routes...");const D=await nc(go(`templates/${this.config.templateId}/routes.json`,this.extensionCacheVersion),Br(`/api/templates/${this.config.templateId}/routes`,"json",this.extensionCacheVersion),{label:"routes.json (reload)"}).then(O=>{if(!O.ok)throw new Error(`Failed to reload routes: ${O.statusText}`);return O.json()}).then(O=>{if(!O.success)throw new Error("Failed to reload routes from API");return O.data});Array.isArray(D.routes)&&(D.routes=this.resolveRouteExpressions(D.routes),Object.assign(d,D),U.log("Routes reloaded with new cache version"));try{const{TranslationEngine:O}=await Promise.resolve().then(()=>Jg),k=O.getInstance();k.setCacheVersion(this.extensionCacheVersion);const L=this.config.locale||"ko",B="en";await k.loadTranslations(this.config.templateId,L,"/api",!0),L!==B&&await k.loadTranslations(this.config.templateId,B,"/api",!0),U.log("Translations reloaded with new cache version")}catch(O){U.error("Failed to reload translations:",O)}}}h?.errorHandling&&(this.templateErrorHandling=h.errorHandling,kr().setTemplateConfig(this.templateErrorHandling),U.log("Template errorHandling registered:",this.templateErrorHandling)),n.on("logout",()=>{U.log("User logged out")}),n.on("authStateChange",A=>{U.log("Auth state changed:",A)}),U.log("AuthManager event handlers registered");const m=Yn(),y=this.config.templateType==="admin"?"admin":"user",v=n.getConfig(y);m.setOnUnauthorized(()=>{U.log("Unauthorized - redirecting to login page"),m.removeToken();const A=window.location.pathname+window.location.search,D=n.getLoginRedirectUrl(y,A,"session_expired");window.location.href=D}),U.log("ApiClient onUnauthorized callback registered"),this.layoutLoader=new th(e),this.extensionCacheVersion>0&&this.layoutLoader.setCacheVersion(this.extensionCacheVersion),U.log("LayoutLoader initialized:",this.layoutLoader);const S=new Or({onUnauthorized:()=>{U.warn("Unauthorized request in error page")}});if(this.errorPageHandler=new Yx({templateId:this.config.templateId,layoutLoader:this.layoutLoader,locale:this.config.locale,debug:this.config.debug,renderFunction:Rs,dataSourceManager:S,globalState:this.globalState}),U.log("ErrorPageHandler initialized with DataSourceManager"),await this.handleServerError()){U.log("Server error handled, skipping normal initialization");return}if(this.router=new Kx(this.config.templateId),Array.isArray(d.routes)){const A=this.resolveRouteExpressions(d.routes);this.router.setRoutes(A)}else throw new Error("Invalid routes data format");U.log("Router initialized:",this.router),U.log("Routes set:",this.router.getRoutes());const{getActionDispatcher:_}=await Promise.resolve().then(()=>Wr),x=_();if(x&&(x.setDefaultContext({navigate:A=>this.router?.navigate(A)}),x.setGlobalStateUpdater((A,D)=>this.setGlobalState(A,D)),U.log("Navigate function and setGlobalState injected to ActionDispatcher")),await this.loadExtensionAssets(),this.reinitializeTemplateHandlers(),this.router.on("routeChange",A=>this.handleRouteChange(A)),this.router.on("routeNotFound",A=>this.handleRouteNotFound(A)),typeof window<"u"&&ch(window.location.pathname)){U.log("Layout editor mode detected — skipping router match"),await Rs({containerId:"app",layoutJson:{components:[]},dataContext:{},translationContext:{templateId:this.config.templateId,locale:this.config.locale}}),U.log("Template App initialized in layout editor mode");return}this.router.navigateToCurrentPath(),U.log("Template App initialized successfully")}catch(e){U.error("Initialization failed:",e),this.showInitError(e)}}async loadExtensionAssets(){try{const e=dh(),n=hT();if(!n){await this.loadExtensionAssetsIndividually(),await e.loadCustomAssets();return}await e.loadBundle("module",n.moduleJs,n.moduleCss),await e.loadBundle("plugin",n.pluginJs,n.pluginCss),await e.loadCustomAssets(),U.log("Extension bundle assets loaded successfully")}catch(e){U.warn("Failed to load extension assets:",e)}}async loadExtensionAssetsIndividually(){const e=dh(),n=fT();n.length>0&&(U.log("Loading module assets (individual fallback):",n.map(i=>i.identifier)),await e.loadActiveExtensionAssets(n));const r=pT();r.length>0&&(U.log("Loading plugin assets (individual fallback):",r.map(i=>i.identifier)),await e.loadActiveExtensionAssets(r))}async handleRouteChange(e){const n=++this.currentRouteChangeId;window.__g7ForcedLocalFields=void 0,window.__g7ActionContext=void 0,window.__g7PendingLocalState=void 0,window.__g7LastSetLocalSnapshot=void 0,window.__g7SetLocalOverrideKeys=void 0,window.__g7SequenceLocalSync=void 0,window.__g7AutoBindingPaths=new Map;try{if(U.log("Route changed:",e,"requestId:",n),!this.layoutLoader)throw new Error("LayoutLoader is not initialized");if(!e.layout)throw new Error("Route layout is not defined");let r=e.layout;const i=r==="__preview__";i&&e.params?.token&&(r=`__preview__/${e.params.token}`);const l=await this.layoutLoader.loadLayout(this.config.templateId,r);if(n!==this.currentRouteChangeId){U.log("Route change cancelled (newer request exists):",n);return}U.log("Layout loaded:",l);const c=kr();l.errorHandling?(c.setLayoutConfig(l.errorHandling),U.log("Layout errorHandling registered:",l.errorHandling)):c.clearLayoutConfig();const d=l.data_sources||[],f=e.query||{},h=new URLSearchParams;for(const[ee,me]of Object.entries(f))if(Array.isArray(me))for(const H of me)h.append(ee,H);else h.set(ee,me);const m={route:e.params||{},query:f,_global:this.globalState};l.scripts&&Array.isArray(l.scripts)&&await this.loadLayoutScripts(l.scripts,m);const{DataSourceManager:y,getActionDispatcher:v}=await Promise.resolve().then(()=>Wr),S=new y;if(i){const ee=v();ee&&ee.setPreviewMode(!0),this.setGlobalState({__isPreview:!0}),Wc.show({id:"preview-mode",message:{ko:"⚠ 미리보기 모드 — 페이지 이동이 비활성화됩니다",en:"⚠ Preview Mode — Navigation is disabled"},background:"linear-gradient(90deg, #f59e0b, #d97706)",color:"white"}),U.log("Preview mode activated")}else{const ee=v();ee?.isPreviewMode()&&(ee.setPreviewMode(!1),Wc.hide("preview-mode"))}if(this.currentGlobalHeaders=l.globalHeaders||[],this.currentGlobalHeaders.length>0){S.setGlobalHeaders(this.currentGlobalHeaders);const ee=v();ee&&ee.setGlobalHeaders(this.currentGlobalHeaders),U.log("globalHeaders set:",this.currentGlobalHeaders.map(me=>me.pattern))}if(l.named_actions&&Object.keys(l.named_actions).length>0){const ee=v();ee&&ee.setNamedActions(l.named_actions)}const _=S.filterByCondition(d,m);d.length!==_.length&&U.log("Data sources filtered by condition:",{before:d.map(ee=>ee.id),after:_.map(ee=>ee.id)});const x=_.filter(ee=>ee.loading_strategy==="blocking"),A=_.filter(ee=>(ee.loading_strategy||"progressive")!=="blocking"&&ee.type!=="websocket"),D=Array.isArray(l.transition_overlay?.wait_for)?l.transition_overlay.wait_for:[],O=D.length>0&&_.some(ee=>D.includes(ee.id)&&ee.type!=="websocket"&&(ee.loading_strategy||"progressive")!=="background");if((x.length>0||O)&&l.transition_overlay){const ee=typeof l.transition_overlay=="boolean"?{enabled:l.transition_overlay,style:"opaque"}:l.transition_overlay;ee.enabled&&ee.style==="skeleton"&&ee.skeleton?.component&&ee.target?this.renderSkeletonOverlay(ee.target,ee.skeleton,l,ee.fallback_target):ee.enabled&&ee.style==="spinner"&&ee.target&&this.renderSpinnerOverlay(ee.target,ee.spinner,ee.fallback_target)}let k={},L={},B={},q={};this.currentWebSocketSubscriptions.length>0&&(U.log("Unsubscribing previous WebSocket subscriptions:",this.currentWebSocketSubscriptions),S.unsubscribeWebSockets(this.currentWebSocketSubscriptions),this.currentWebSocketSubscriptions=[]),this.currentDataSources=_,this.currentRawDataSources=d,this.currentRouteParams=e.params||{},this.currentQueryParams=h,U.log(`handleRouteChange #${n} - queryObject:`,f),U.log(`handleRouteChange #${n} - queryParams:`,h.toString()),x.length>0&&(U.log("Fetching blocking data sources:",x.map(me=>me.id)),(await S.fetchDataSourcesWithResults(x,e.params||{},h)).forEach(me=>{if(me.state==="success"&&me.data!==void 0)k[me.id]=me.data;else if(me.state==="error"&&me.error){const H=me.error,T=H.response?.data?.message;L[me.id]={message:T||me.error.message,status:H.response?.status||H.status}}}),this.processInitOptions(x,k,B,q),this.currentFetchedData={...k},U.log("Blocking data loaded:",Object.keys(k)),Object.keys(L).length>0&&U.log("Data source errors:",L),Object.keys(B).length>0&&U.log("Local state init (blocking):",Object.keys(B)),Object.keys(q).length>0&&U.log("Isolated state init (blocking):",Object.keys(q)));const z=A.length>0;if(z&&(Gr.setPending(!0),U.log("Transition started before rendering")),n!==this.currentRouteChangeId){U.log("Route change cancelled after blocking data (newer request exists):",n);return}const{getState:W}=await Promise.resolve().then(()=>Wr),de=W().currentDataContext||{},_e=A.map(ee=>ee.id),Se={};if(z){_e.forEach(me=>{de[me]!==void 0?Se[me]=de[me]:Se[me]=void 0});const ee=Object.keys(Se).filter(me=>Se[me]!==void 0);ee.length>0&&U.log("Preserving previous progressive data:",ee),U.log("Progressive data sources initialized:",_e)}const je=l.defines||{},Fe={...Se,...e.params,...k,route:{...e.params||{},path:e.path},query:f,_global:{...this.globalState},_globalSetState:ee=>this.setGlobalState(ee),_dataSourceErrors:Object.keys(L).length>0?L:void 0,_localInit:Object.keys(B).length>0?B:void 0,_isolatedInit:Object.keys(q).length>0?q:void 0,_defines:Object.keys(je).length>0?je:void 0};if(l.computed&&Object.keys(l.computed).length>0){const ee=this.calculateComputed(l.computed,Fe);Object.keys(ee).length>0&&(Fe._computed=ee,this.globalState._computed=ee,U.log("Computed values calculated:",Object.keys(ee))),Fe._computedDefinitions=l.computed}const ze=l.layout_name||e.layout;this.currentLayoutName!==""&&this.currentLayoutName!==ze&&(U.log("_local reset due to layout change:",{from:this.currentLayoutName,to:ze}),this.globalState._local={},c_()),this.currentLayoutName=ze;const Q=l.initLocal||l.state;if(Q&&Object.keys(Q).length>0){this.globalState._local||(this.globalState._local={});for(const[ee,me]of Object.entries(Q))this.globalState._local[ee]===void 0&&(this.globalState._local[ee]=JSON.parse(JSON.stringify(me)));Fe._local={...this.globalState._local},U.log("initLocal applied to _local:",Object.keys(Q))}if(l.initGlobal&&Object.keys(l.initGlobal).length>0){for(const[ee,me]of Object.entries(l.initGlobal))this.globalState[ee]===void 0&&(this.globalState[ee]=JSON.parse(JSON.stringify(me)));U.log("initGlobal applied to _global:",Object.keys(l.initGlobal))}if(l.initIsolated&&Object.keys(l.initIsolated).length>0){for(const[ee,me]of Object.entries(l.initIsolated))q[ee]===void 0&&(q[ee]=JSON.parse(JSON.stringify(me)));U.log("initIsolated applied:",Object.keys(l.initIsolated))}Fe._global={...this.globalState,layoutWarnings:l.warnings||[]};const ue=l.initActions||l.init_actions;if(ue&&ue.length>0){await this.executeInitActions(ue,Fe),U.log("initActions executed before render");const ee=this.globalState;if(ee._local){if(Object.keys(B).length>0){for(const[me,H]of Object.entries(B))ee._local[me]!==void 0?ee._local[me]=this.deepMerge(ee._local[me],H):ee._local[me]=H;U.log("localInit merged into _local after initActions:",Object.keys(B))}Fe._local=ee._local,U.log("_local merged into dataContext:",ee._local)}if(Fe._global={...this.globalState,layoutWarnings:l.warnings||[]},U.log("_global merged into dataContext after initActions"),l.computed&&Object.keys(l.computed).length>0){const me=this.calculateComputed(l.computed,Fe);Object.keys(me).length>0&&(Fe._computed=me,this.globalState._computed=me,U.log("Computed values recalculated after init_actions:",Object.keys(me)))}if(Object.keys(this.currentFetchedData).length>0){for(const[me,H]of Object.entries(this.currentFetchedData))Fe[me]=H;U.log("Fetched data sources merged into dataContext after initActions:",Object.keys(this.currentFetchedData))}}if(l.transition_overlay&&!this.skeletonOverlayContainer&&this.showTransitionOverlay(l.transition_overlay,l),await Rs({containerId:"app",layoutJson:l,dataContext:Fe,translationContext:{templateId:this.config.templateId,locale:this.config.locale}}),U.log("Initial render complete with blocking data"),this.reattachSpinnerOverlay(),A.length>0){if(n!==this.currentRouteChangeId){U.log("Route change cancelled before progressive fetch (newer request exists):",n),Gr.setPending(!1),this.hideTransitionOverlay();return}U.log("Fetching progressive/background data sources:",A.map(H=>H.id));const{updateTemplateData:ee,getState:me}=await Promise.resolve().then(()=>Wr);try{const H=A.map(async T=>{try{const he=(await S.fetchDataSourcesWithResults([T],e.params||{},h,this.globalState))[0];if(!he){U.log(`Data source ${T.id} skipped (no fetch result)`);return}if(n!==this.currentRouteChangeId){U.log(`Data source ${T.id} fetch cancelled (newer request exists)`);return}if(he.state==="success"&&he.data!==void 0){U.log(`Progressive data source loaded: ${T.id}`),this.currentFetchedData[T.id]=he.data;const Ae={};this.processInitOptions([T],{[T.id]:he.data},Ae);const se=me();if(se.bindingEngine){const $e=[T.id];T.initGlobal&&$e.push("_global"),T.initLocal&&$e.push("_local"),se.bindingEngine.invalidateCacheByKeys($e)}const ge={[T.id]:he.data};Object.keys(Ae).length>0&&(ge._localInit=Ae,Object.assign(B,Ae)),T.initGlobal&&(ge._global={...this.globalState}),ee(ge)}else if(he.state==="error"&&he.error){const Ae=he.error,se=Ae.response?.data?.message;L[T.id]={message:se||he.error.message,status:Ae.response?.status||Ae.status},U.log(`Progressive data source error: ${T.id}`,L[T.id]),ee({[T.id]:null,_dataSourceErrors:{...L}})}}catch(fe){U.error(`Failed to fetch data source: ${T.id}`,fe)}});if(await Promise.all(H),n!==this.currentRouteChangeId){U.log("Route change cancelled after progressive fetch (newer request exists):",n);return}U.log("All progressive data sources loaded")}finally{Gr.setPending(!1),this.hideTransitionOverlay()}}else this.hideTransitionOverlay();const De=_.filter(ee=>ee.type==="websocket");if(De.length>0){U.log("Subscribing WebSocket data sources:",De.map(T=>T.id));const{updateTemplateData:ee,getState:me}=await Promise.resolve().then(()=>Wr),H={...this.currentFetchedData,...e.params,route:{...e.params||{},path:e.path},query:f,_global:{...this.globalState}};U.log("WebSocket binding context keys:",Object.keys(H)),this.currentWebSocketSubscriptions=S.subscribeWebSockets(_,(T,fe)=>{U.log(`WebSocket data received for: ${T}`,fe),this.currentFetchedData[T]=fe;const he=_.find($e=>$e.id===T),Ae=me();if(Ae.bindingEngine){const $e=[T];he?.initGlobal&&$e.push("_global"),he?.initLocal&&$e.push("_local"),Ae.bindingEngine.invalidateCacheByKeys($e)}ee({[T]:fe});const ge=_.find($e=>$e.type==="websocket"&&($e.target_source||$e.id)===T)?.onReceive;Array.isArray(ge)&&ge.length>0&&window.G7Core?.dispatch&&(async()=>{for(const Te of ge)try{const Ie=this.getActionDispatcher?.();Ie&&await Ie.dispatchAction(Te,{navigate:this.getRouter?.()?(xt,rt)=>this.getRouter().navigate(xt,rt):void 0,setState:xt=>this.setGlobalState(xt),state:this.globalState,data:{...this.globalState,$args:[fe],$event:fe},_isDispatchFallbackContext:!0})}catch(Ie){U.error(`WebSocket onReceive action failed for ${T}:`,Ie)}})()},H),U.log("WebSocket subscriptions established:",this.currentWebSocketSubscriptions)}U.log("Layout rendered successfully")}catch(r){U.error("Route change handling failed:",r),this.hideTransitionOverlay(),this.showRouteError(r)}}processInitOptions(e,n,r,i){e.some(c=>c.refetchOnMount===!0&&c.initLocal)&&(r._forceLocalInit=Date.now(),U.log("refetchOnMount detected, forcing local state init")),e.forEach(c=>{const d=n[c.id];if(!d)return;const f=d.data??d;if(c.initLocal){if(typeof c.initLocal=="string"){let h=f;if(c.initLocalDefaults&&typeof c.initLocalDefaults=="object"){const y=this.evaluateDefaults(c.initLocalDefaults,n);h={...y,...f},U.log(`initLocalDefaults applied for ${c.initLocal}:`,Object.keys(y))}const m=this.globalState._local?.[c.initLocal];m!==void 0&&typeof m=="object"&&typeof h=="object"?(r[c.initLocal]=this.deepMerge(m,h),U.log(`initLocal (merged): ${c.id}.data -> _local.${c.initLocal}`)):(r[c.initLocal]=h,U.log(`initLocal: ${c.id}.data -> _local.${c.initLocal}`))}else if(typeof c.initLocal=="object"&&c.initLocal.key){const{key:h,path:m}=c.initLocal;let y=m?this.extractValueByPathOrExpression(f,m,c.id):f;if(c.initLocalDefaults&&typeof c.initLocalDefaults=="object"){const S=this.evaluateDefaults(c.initLocalDefaults,n);y={...S,...y},U.log(`initLocalDefaults applied for ${h}:`,Object.keys(S))}const v=this.globalState._local?.[h];v!==void 0&&typeof v=="object"&&typeof y=="object"?(r[h]=this.deepMerge(v,y),U.log(`initLocal (merged): ${c.id}.data${m?"."+m:""} -> _local.${h}`)):(r[h]=y,U.log(`initLocal: ${c.id}.data${m?"."+m:""} -> _local.${h}`))}else if(typeof c.initLocal=="object"){const h=c.initLocal._merge||"deep",m=this.flattenNestedObjectToMappings(c.initLocal);for(const{targetPath:y,sourcePath:v}of m){const S=this.extractValueByPathOrExpression(f,v,c.id);if(y.includes(".")){const _=y.split(".")[0];r[_]===void 0&&this.globalState._local?.[_]!==void 0&&(r[_]=JSON.parse(JSON.stringify(this.globalState._local[_]))),this.setValueAtPath(r,y,S,h),U.log(`initLocal map (${h}): ${c.id} ${v} -> _local.${y}`)}else{const _=this.globalState._local?.[y];h==="replace"?(r[y]=S,U.log(`initLocal map (replace): ${c.id} ${v} -> _local.${y}`)):h==="shallow"?_!==void 0&&typeof _=="object"&&typeof S=="object"?(r[y]={..._,...S},U.log(`initLocal map (shallow): ${c.id} ${v} -> _local.${y}`)):(r[y]=S,U.log(`initLocal map: ${c.id} ${v} -> _local.${y}`)):_!==void 0&&typeof _=="object"&&typeof S=="object"?(r[y]=this.deepMerge(_,S),U.log(`initLocal map (deep): ${c.id} ${v} -> _local.${y}`)):(r[y]=S,U.log(`initLocal map: ${c.id} ${v} -> _local.${y}`))}}}}if(c.initGlobal)if(typeof c.initGlobal=="object"&&!Array.isArray(c.initGlobal)&&!("key"in c.initGlobal))for(const[m,y]of Object.entries(c.initGlobal)){if(typeof y!="string"){U.warn(`initGlobal map value must be string, got ${typeof y} for key ${m}`);continue}const v=this.extractValueByPathOrExpression(f,y,c.id),S=this.globalState[m];S!==void 0&&typeof S=="object"&&typeof v=="object"?(this.globalState[m]=this.deepMerge(S,v),U.log(`initGlobal map (merged): ${c.id} ${y} -> _global.${m}`)):(this.globalState[m]=v,U.log(`initGlobal map: ${c.id} ${y} -> _global.${m}`))}else{const m=Array.isArray(c.initGlobal)?c.initGlobal:[c.initGlobal];for(const y of m)if(typeof y=="string"){const v=this.globalState[y];v!==void 0&&typeof v=="object"&&typeof f=="object"?(this.globalState[y]=this.deepMerge(v,f),U.log(`initGlobal (merged): ${c.id}.data -> _global.${y}`)):(this.globalState[y]=f,U.log(`initGlobal: ${c.id}.data -> _global.${y}`))}else if(typeof y=="object"&&y.key){const{key:v,path:S}=y,_=S?this.extractValueByPathOrExpression(f,S,c.id):f,x=this.globalState[v];x!==void 0&&typeof x=="object"&&typeof _=="object"?(this.globalState[v]=this.deepMerge(x,_),U.log(`initGlobal (merged): ${c.id}.data${S?"."+S:""} -> _global.${v}`)):(this.globalState[v]=_,U.log(`initGlobal: ${c.id}.data${S?"."+S:""} -> _global.${v}`))}}if(i&&c.initIsolated){if(typeof c.initIsolated=="string"){const h=i[c.initIsolated];h!==void 0&&typeof h=="object"&&typeof f=="object"?(i[c.initIsolated]=this.deepMerge(h,f),U.log(`initIsolated (merged): ${c.id}.data -> _isolated.${c.initIsolated}`)):(i[c.initIsolated]=f,U.log(`initIsolated: ${c.id}.data -> _isolated.${c.initIsolated}`))}else if(typeof c.initIsolated=="object"&&c.initIsolated.key){const{key:h,path:m}=c.initIsolated,y=m?this.extractValueByPathOrExpression(f,m,c.id):f,v=i[h];v!==void 0&&typeof v=="object"&&typeof y=="object"?(i[h]=this.deepMerge(v,y),U.log(`initIsolated (merged): ${c.id}.data${m?"."+m:""} -> _isolated.${h}`)):(i[h]=y,U.log(`initIsolated: ${c.id}.data${m?"."+m:""} -> _isolated.${h}`))}else if(typeof c.initIsolated=="object")for(const[h,m]of Object.entries(c.initIsolated)){if(typeof m!="string"){U.warn(`initIsolated map value must be string, got ${typeof m} for key ${h}`);continue}const y=this.extractValueByPathOrExpression(f,m,c.id),v=i[h];v!==void 0&&typeof v=="object"&&typeof y=="object"?(i[h]=this.deepMerge(v,y),U.log(`initIsolated map (merged): ${c.id} ${m} -> _isolated.${h}`)):(i[h]=y,U.log(`initIsolated map: ${c.id} ${m} -> _isolated.${h}`))}}})}evaluateDefaults(e,n){const r={};for(const[i,l]of Object.entries(e))if(typeof l=="string"&&l.startsWith("{{")&&l.endsWith("}}")){const c=l.slice(2,-2).trim();r[i]=this.evaluateExpression(c,n)}else r[i]=l;return r}evaluateExpression(e,n){try{const r=e.split("??").map(i=>i.trim());for(const i of r){if(/^['"].*['"]$/.test(i))return i.slice(1,-1);if(i==="true")return!0;if(i==="false")return!1;if(/^-?\d+(\.\d+)?$/.test(i))return Number(i);const l=this.getNestedValue(n,i);if(l!=null)return l}return}catch(r){U.warn(`Expression evaluation failed: ${e}`,r);return}}getNestedValue(e,n){const r=n.replace(/\?\./g,".");let i=e;const l=r.split(/\.(?![^\[]*\])/).flatMap(c=>{const d=c.match(/^([^\[]*)((?:\[\d+\])*)$/);if(d){const[,f,h]=d,m=[];f&&m.push(f);const y=h.match(/\[\d+\]/g);return y&&m.push(...y),m}return[c]}).filter(c=>c!=="");for(const c of l){if(i==null)return;if(c.startsWith("[")&&c.endsWith("]")){const d=parseInt(c.slice(1,-1),10);i=i[d]}else i=i[c]}return i}extractValueByPathOrExpression(e,n,r){const i=Oa(n);if(i!==null){const l=new $n,c={data:e,_global:this.globalState,_local:this.globalState._local||{}};try{const d=jn(i)?l.evaluatePipeExpression(i,c,{skipCache:!0}):l.evaluateExpression(i,c);return U.log(`initLocal/initGlobal expression evaluated: ${n} -> `,d),d}catch(d){U.warn(`initLocal/initGlobal expression evaluation failed for ${r}:`,n,d);return}}return this.getNestedValue(e,n)}async loadLayoutScripts(e,n){const r=[];for(const i of e){if((i.if!==void 0||i.conditions!==void 0)&&!hs({if:i.if,conditions:i.conditions},n,this.bindingEngine,`script:${i.id}`)){U.log(`Script skipped (condition not met): ${i.id}`);continue}if(document.getElementById(i.id)){U.log(`Script already loaded: ${i.id}`);continue}if(!this.isAllowedScriptSrc(i.src)){U.warn(`Blocked untrusted external script src (same-origin path or declared trusted host required): ${i.id} (${i.src})`);continue}r.push(this.loadLayoutScript(i))}r.length>0&&(await Promise.all(r),U.log(`All scripts loaded: ${e.filter(i=>!document.getElementById(i.id)||r.length>0).map(i=>i.id).join(", ")}`))}async loadLayoutScript(e){const n=e.src.startsWith("/")?Ln(e.src):e.src;try{await _r(n,{id:e.id},{label:`layout-script:${e.id}`}),this.failedLayoutScripts.delete(e.id),Db(`layout-script:${e.id}`),U.log(`Script loaded successfully: ${e.id}`)}catch(r){this.failedLayoutScripts.add(e.id),U.warn(`Failed to load script after retries: ${e.id} (${n})`,r),xs({id:`layout-script:${e.id}`,label:e.id,retry:async()=>{document.getElementById(e.id)?.remove(),await _r(n,{id:e.id},{label:`layout-script:${e.id}`}),this.failedLayoutScripts.delete(e.id)}})}}getFailedLayoutScripts(){return Array.from(this.failedLayoutScripts)}isAllowedScriptSrc(e){return Io(e)}static normalizeScriptSrcForOriginCheck(e){return by(e)}extractScriptHost(e){return vy(e)}getTrustedScriptHosts(){return bs()}evaluateScriptCondition(e,n){try{if(e.startsWith("{{")&&e.endsWith("}}")){const r=e.slice(2,-2).trim();return!!nf(r,n)}return!!e}catch(r){return U.warn(`Failed to evaluate script condition: ${e}`,r),!1}}showInitError(e){if(ec()){U.warn("Init failed while document is unloading — skipping error screen",e);return}const n=kb(e);lh.renderFromError("app",n,"초기화 실패",this.config.debug,{templateId:this.config.templateId,locale:this.config.locale},void 0,e)}showTransitionOverlay(e,n){const r=typeof e=="boolean"?{enabled:e,style:"opaque",target:void 0,skeleton:void 0,spinner:void 0}:{enabled:e.enabled,style:e.style||"opaque",target:e.target,skeleton:e.skeleton,spinner:e.spinner,fallback_target:e.fallback_target};if(!r.enabled)return;if(this.hideTransitionOverlay(),r.style==="skeleton"&&r.skeleton?.component&&r.target&&n){this.renderSkeletonOverlay(r.target,r.skeleton,n,r.fallback_target);return}if(r.style==="spinner"&&r.target){this.renderSpinnerOverlay(r.target,r.spinner,r.fallback_target);return}const i=document.documentElement.classList.contains("dark");let l,c="";switch(r.style){case"blur":l=i?"rgba(17,24,39,0.3)":"rgba(255,255,255,0.3)",c="backdrop-filter:blur(4px);-webkit-backdrop-filter:blur(4px);";break;case"fade":l=i?"rgba(17,24,39,0.8)":"rgba(255,255,255,0.8)";break;case"skeleton":l=i?"rgb(17,24,39)":"rgb(249,250,251)";break;case"opaque":default:l=i?"rgb(17,24,39)":"rgb(249,250,251)";break}if(r.target){const d=`#${CSS.escape(r.target)}`,f=document.createElement("style");f.id="g7-transition-overlay",f.textContent=`${d}{position:relative;z-index:0;}${d}::after{content:'';position:absolute;inset:0;background:${l};${c}z-index:2147483647;pointer-events:none;}`,document.head.appendChild(f),this.transitionOverlayEl=f}else{const d=document.createElement("div");d.id="g7-transition-overlay",d.setAttribute("aria-hidden","true"),d.style.position="fixed",d.style.inset="0",d.style.zIndex="9999",d.style.pointerEvents="none",d.style.background=l;for(const f of c.split(";")){const h=f.indexOf(":");h!==-1&&d.style.setProperty(f.slice(0,h).trim(),f.slice(h+1).trim())}document.body.appendChild(d),this.transitionOverlayEl=d}}hideTransitionOverlay(){this.transitionOverlayEl&&(this.transitionOverlayEl.remove(),this.transitionOverlayEl=null),this.hideSkeletonOverlay()}renderSkeletonOverlay(e,n,r,i){const c=Ar.getInstance().getComponent(n.component);if(!c){U.log(`Skeleton component "${n.component}" not found in registry, falling back to opaque overlay`),this.showTransitionOverlay({enabled:!0,style:"opaque",target:e});return}let d=document.getElementById(e),f="target";if(!d&&i&&(d=document.getElementById(i),f="fallback"),d||(d=document.getElementById("app"),f="fullpage"),!d){U.log(`Skeleton overlay: no target found (target="#${e}", fallback="${i||"none"}"), falling back to opaque overlay`),this.showTransitionOverlay({enabled:!0,style:"opaque",target:e});return}this.hideSkeletonOverlay();const m=document.documentElement.classList.contains("dark")?"rgb(17,24,39)":"rgb(249,250,251)",y=f==="fullpage"?"app":f==="fallback"?i:e,v=`#${CSS.escape(y)}`,S=document.createElement("style");S.id="g7-skeleton-overlay-style",S.textContent=`${v}{position:relative;z-index:0;}${v}::after{content:'';position:absolute;inset:0;background:${m};z-index:2147483646;pointer-events:none;}`,document.head.appendChild(S),this.transitionOverlayEl=S;const _=document.createElement("div");if(_.id="g7-skeleton-overlay",_.setAttribute("role","status"),_.setAttribute("aria-busy","true"),_.setAttribute("aria-label","Loading..."),f==="fullpage")_.style.cssText=["position:fixed","inset:0","z-index:20","overflow:hidden","pointer-events:none",`background:${m}`].join(";")+";";else{const k=d.getBoundingClientRect(),L=window.scrollX||document.documentElement.scrollLeft,B=window.scrollY||document.documentElement.scrollTop;_.style.cssText=["position:absolute",`top:${k.top+B}px`,`left:${k.left+L}px`,`width:${k.width}px`,`height:${k.height}px`,"z-index:20","overflow:hidden","pointer-events:none",`background:${m}`].join(";")+";"}document.body.appendChild(_),this.skeletonOverlayContainer=_;const x=r.components||[];let A;if(f==="fullpage")A=x;else{const k=f==="fallback"?i:e;A=this.findComponentChildrenById(x,k)}const D=Rd.createRoot(_);this.skeletonOverlayRoot=D,Ia.flushSync(()=>{D.render(Xe.createElement(c,{components:A,options:{animation:n.animation||"pulse",iteration_count:n.iteration_count||5}}))});const O=f==="fullpage"?"fullpage (#app)":f==="fallback"?`fallback (#${i})`:`target (#${e})`;U.log(`Skeleton overlay rendered [${O}] with "${n.component}" (${A.length} components)`)}findComponentChildrenById(e,n){const r=i=>{for(const l of i){if(l.id===n)return l.children||[];if(l.children&&Array.isArray(l.children)){const c=r(l.children);if(c!==null)return c}}return null};return r(e)||e}renderSpinnerOverlay(e,n,r){let i=document.getElementById(e),l="target";if(!i&&r&&(i=document.getElementById(r),l="fallback"),i||(i=document.getElementById("app"),l="fullpage"),!i){U.log(`Spinner overlay: no target found (target="#${e}", fallback="${r||"none"}"), falling back to opaque overlay`),this.showTransitionOverlay({enabled:!0,style:"opaque",target:e});return}this.hideSkeletonOverlay();const c=l==="fullpage"?"app":l==="fallback"?r:e,d=`#${CSS.escape(c)}`,f=document.createElement("style");f.id="g7-skeleton-overlay-style",f.textContent=[`${d}{position:relative;}`,"@keyframes g7-spin{to{transform:rotate(360deg)}}"].join(""),document.head.appendChild(f),this.transitionOverlayEl=f;const h=n?.text||window.G7Core?.t?.("nav.loading")||"";this._spinnerState={target:e,fallbackTarget:r,spinnerConfig:n,resolvedText:h},this._mountSpinnerInTarget(i);const m=l==="fullpage"?"fullpage (#app)":l==="fallback"?`fallback (#${r})`:`target (#${e})`,y=n?.component||"default spinner";U.log(`Spinner overlay rendered [${m}] with "${y}"`)}_mountSpinnerInTarget(e){if(!this._spinnerState)return;const{spinnerConfig:n,resolvedText:r}=this._spinnerState;if(this.skeletonOverlayRoot){try{this.skeletonOverlayRoot.unmount()}catch{}this.skeletonOverlayRoot=null}if(this.skeletonOverlayContainer){try{this.skeletonOverlayContainer.remove()}catch{}this.skeletonOverlayContainer=null}const i=document.createElement("div");if(i.id="g7-skeleton-overlay",i.setAttribute("role","status"),i.setAttribute("aria-busy","true"),e.appendChild(i),this.skeletonOverlayContainer=i,n?.component){const c=Ar.getInstance().getComponent(n.component);if(c){const d=Rd.createRoot(i);this.skeletonOverlayRoot=d,Ia.flushSync(()=>{d.render(Xe.createElement(c,{options:{text:r}}))});return}U.log(`Spinner component "${n.component}" not found in registry, using default spinner`)}i.innerHTML='
'}reattachSpinnerOverlay(){if(!this._spinnerState)return;const{target:e,fallbackTarget:n}=this._spinnerState;let r=document.getElementById(e);!r&&n&&(r=document.getElementById(n)),r||(r=document.getElementById("app")),r&&(this._mountSpinnerInTarget(r),U.log("Spinner overlay reattached to new DOM target"))}hideSkeletonOverlay(){if(this.skeletonOverlayRoot){try{this.skeletonOverlayRoot.unmount()}catch{}this.skeletonOverlayRoot=null}if(this.skeletonOverlayContainer){try{this.skeletonOverlayContainer.parentNode&&this.skeletonOverlayContainer.remove()}catch{}this.skeletonOverlayContainer=null}const e=document.getElementById("g7-skeleton-overlay-style");e&&e.remove(),this._spinnerState=null}showRouteError(e){if(e instanceof Dr&&e.details?.status===401){const r=this.config.templateId||"",i=window.location.pathname,l=r.includes("admin")||i.startsWith("/admin")?"admin":"user",c=i+window.location.search,d=!!Yn().getToken()||e.details?.hadToken===!0,f=Xn.getInstance().getLoginRedirectUrl(l,c,d?"session_expired":void 0);window.location.href=f;return}const n=kb(e);lh.renderFromError("app",n,"페이지 로딩 실패",this.config.debug,{templateId:this.config.templateId,locale:this.config.locale},void 0,e)}async handleServerError(){const e=window.G7Error;if(!e)return!1;U.warn("Server error detected:",e);try{return this.errorPageHandler&&(e.data&&(this.globalState.errorData=e.data),this.errorPageHandler.updateGlobalState(this.globalState),this.errorPageHandler.updateLocale(this.config.locale),await this.errorPageHandler.renderError(e.code,"app"))?(U.log(`${e.code} error page rendered successfully`),!0):(U.log(`Falling back to ErrorDisplay for ${e.code}`),this.showInitError(new Error(`Service unavailable (${e.code})`)),!0)}catch(n){return U.error(`Failed to render ${e.code} page:`,n),this.showInitError(new Error(`Service unavailable (${e.code})`)),!0}}async handleRouteNotFound(e){U.warn("Route not found:",e);try{if(this.errorPageHandler&&(this.errorPageHandler.updateGlobalState(this.globalState),this.errorPageHandler.updateLocale(this.config.locale),await this.errorPageHandler.renderError(404,"app"))){U.log("404 error page rendered successfully");return}U.log("Falling back to ErrorDisplay for 404"),this.showRouteError(new Error(`Page not found: ${e}`))}catch(n){U.error("Failed to render 404 page:",n),this.showRouteError(new Error(`Page not found: ${e}`))}}getRouter(){return this.router}getConfig(){return this.config}getLayoutLoader(){return this.layoutLoader}async reloadExtensionState(){U.log("reloadExtensionState: start");let e;try{const n=await fetch(Br(`/api/templates/${this.config.templateId}/config`,"json",null,`_=${Date.now()}`));if(n.ok){const r=await n.json();r?.success&&r?.data?.cache_version!==void 0&&(e=r.data.cache_version)}}catch(n){U.warn("reloadExtensionState: failed to fetch config.json",n)}e!==void 0&&e!==this.extensionCacheVersion&&(U.log(`reloadExtensionState: cache version ${this.extensionCacheVersion} -> ${e}`),this.extensionCacheVersion=e,this.saveCacheVersionToStorage(e));try{this.router&&(await this.router.loadRoutes(this.extensionCacheVersion),U.log("reloadExtensionState: routes reloaded"))}catch(n){U.error("reloadExtensionState: routes reload failed",n)}try{this.layoutLoader&&(this.extensionCacheVersion>0&&this.layoutLoader.setCacheVersion(this.extensionCacheVersion),this.layoutLoader.clear(),U.log("reloadExtensionState: layout cache cleared"))}catch(n){U.error("reloadExtensionState: layout cache clear failed",n)}try{const{TranslationEngine:n}=await Promise.resolve().then(()=>Jg),r=n.getInstance();this.extensionCacheVersion>0&&r.setCacheVersion(this.extensionCacheVersion);const i=this.config.locale||"ko",l="en";await r.loadTranslations(this.config.templateId,i,"/api",!0),i!==l&&await r.loadTranslations(this.config.templateId,l,"/api",!0),U.log("reloadExtensionState: translations reloaded")}catch(n){U.error("reloadExtensionState: translations reload failed",n)}try{const n=await fetch(`/api/locales/active?_=${Date.now()}`);if(n.ok){const i=(await n.json())?.data?.locales;if(Array.isArray(i)&&i.length>0){const l=this.globalState.appConfig??{};this.setGlobalState({appConfig:{...l,supportedLocales:i}}),U.log("reloadExtensionState: supportedLocales refreshed",i)}}}catch(n){U.warn("reloadExtensionState: supportedLocales refresh failed",n)}U.log("reloadExtensionState: done")}getActionDispatcher(){return la().actionDispatcher}async changeLocale(e){try{if(U.log("Changing locale to:",e),this.config.locale===e){U.log("Locale is already",e);return}this.config.locale=e,this.saveLocaleToStorage(e),await this.saveLocaleToDatabase(e),this.layoutLoader&&(this.layoutLoader.clear(),U.log("Layout cache cleared")),this.errorPageHandler&&(this.errorPageHandler.updateLocale(e),U.log("ErrorPageHandler locale updated")),Yc(),await el({templateId:this.config.templateId,templateType:this.config.templateType,locale:e,debug:this.config.debug,cacheVersion:this.extensionCacheVersion}),U.log("Template Engine re-initialized with new locale");const{getActionDispatcher:n}=await Promise.resolve().then(()=>Wr),r=n();r&&(r.setDefaultContext({navigate:i=>this.router?.navigate(i)}),r.setGlobalStateUpdater((i,l)=>this.setGlobalState(i,l)),U.log("Navigate function and setGlobalState re-injected to ActionDispatcher")),this.reinitializeModuleHandlers(),U.log("Module handlers re-initialized"),this.reinitializeTemplateHandlers(),U.log("Template handlers re-initialized"),this.reinitializePluginHandlers(),U.log("Plugin handlers re-initialized"),this.router&&this.router.navigateToCurrentPath(),U.log("Locale changed successfully to",e)}catch(n){throw U.error("Failed to change locale:",n),n}}loadLocaleFromStorage(){try{return localStorage.getItem($r.LOCALE_STORAGE_KEY)}catch(e){return U.warn("Failed to load locale from storage:",e),null}}saveLocaleToStorage(e){try{localStorage.setItem($r.LOCALE_STORAGE_KEY,e)}catch(n){U.warn("Failed to save locale to storage:",n)}}async saveLocaleToDatabase(e){const n=localStorage.getItem("auth_token");if(!n){U.log("No auth token, skipping DB locale save");return}let r,i;if(this.config.localeApi)r=this.config.localeApi.endpoint,i=this.config.localeApi.method;else{const l=this.config.templateType==="admin";r=l?"/api/admin/users/me/language":"/api/user/profile/update-language",i=l?"PATCH":"POST"}try{const l=this.getXsrfToken(),c=await fetch(r,{method:i,headers:{"Content-Type":"application/json",Accept:"application/json",...l&&{"X-XSRF-TOKEN":l},Authorization:`Bearer ${n}`},credentials:"include",body:JSON.stringify({language:e})});c.ok?U.log("Locale saved to DB:",e):U.warn("Failed to save locale to DB (UI will still change):",c.statusText)}catch(l){U.warn("Failed to call locale API (UI will still change):",l)}}getXsrfToken(){if(typeof document>"u")return null;const n=`; ${document.cookie}`.split("; XSRF-TOKEN=");return n.length===2?decodeURIComponent(n.pop()?.split(";").shift()||""):null}loadCacheVersionFromStorage(){try{const e=localStorage.getItem($r.CACHE_VERSION_STORAGE_KEY);return e?parseInt(e,10):null}catch(e){return U.warn("Failed to load cache version from storage:",e),null}}saveCacheVersionToStorage(e){try{localStorage.setItem($r.CACHE_VERSION_STORAGE_KEY,String(e))}catch(n){U.warn("Failed to save cache version to storage:",n)}}reinitializeModuleHandlers(){if(typeof window>"u")return;const e="__",n=window;Object.keys(n).forEach(r=>{if(r.startsWith(e)&&typeof n[r]?.initModule=="function")try{n[r].initModule(),U.log(`Module handler re-initialized: ${r}`)}catch(i){U.warn(`Failed to re-initialize module handlers for ${r}:`,i)}})}reinitializeTemplateHandlers(){if(typeof window>"u")return;const e=window.G7TemplateHandlers;if(!e){U.warn("Template handlers not found on window.G7TemplateHandlers");return}const n=this.getActionDispatcher();if(!n){U.warn("ActionDispatcher not available for template handler registration");return}Object.entries(e).forEach(([r,i])=>{n.registerHandler(r,i)}),U.log(`${Object.keys(e).length} template handler(s) re-registered:`,Object.keys(e))}reinitializePluginHandlers(){if(typeof window>"u")return;const e="__",n=window;Object.keys(n).forEach(r=>{if(r.startsWith(e)&&typeof n[r]?.initPlugin=="function")try{n[r].initPlugin(),U.log(`Plugin handler re-initialized: ${r}`)}catch(i){U.warn(`Failed to re-initialize plugin handlers for ${r}:`,i)}})}getLocale(){return this.config.locale}getErrorPageHandler(){return this.errorPageHandler}getGlobalState(){return{...this.globalState}}setGlobalState(e,n){const r={...this.globalState};typeof e=="function"?this.globalState=e(this.globalState):this.globalState={...this.globalState,...e},U.log("Global state updated:",this.globalState),window.G7Core?.devTools?.captureStateSnapshot?.({source:"setGlobalState",prev:r,next:this.globalState}),this.globalStateListeners.forEach(l=>{l(this.globalState)}),n?.render!==!1&&Promise.resolve().then(()=>Wr).then(({updateTemplateData:l,getState:c})=>{const d=c();d.reactRoot&&d.currentLayoutJson&&l({_global:{...this.globalState},_local:this.globalState._local||{}})})}onGlobalStateChange(e){this.globalStateListeners.add(e)}offGlobalStateChange(e){this.globalStateListeners.delete(e)}async refetchDataSource(e,n){let r=this.currentDataSources.find(i=>i.id===e);if(!r)for(const[,i]of this.modalDataSources){const l=i.find(c=>c.id===e);if(l){r=l;break}}if(!r){U.warn(`Data source not found: ${e}`);return}U.log(`Refetching data source: ${e}`,n?.sync?"(sync mode)":"",n?.globalStateOverride?"(with global override)":"",n?.localStateOverride?"(with local override)":""),Gr.setPending(!0);try{const i=new Or;this.currentGlobalHeaders.length>0&&i.setGlobalHeaders(this.currentGlobalHeaders);const l=la(),c=l.currentDataContext?._global||{},d=n?.globalStateOverride?{...c,...n.globalStateOverride}:c,f=l.currentDataContext?._local||{},h=n?.localStateOverride?{...f,...n.localStateOverride}:f,y=(await i.fetchDataSourcesWithResults([r],this.currentRouteParams,this.currentQueryParams,d,h,{ignoreAutoFetch:!0}))[0];if(y.state==="success"&&y.data!==void 0){this.currentFetchedData[e]=y.data;const v={};this.processInitOptions([r],{[e]:y.data},v);const S=la();if(S.bindingEngine){const x=[e];r.initGlobal&&x.push("_global"),r.initLocal&&x.push("_local"),S.bindingEngine.invalidateCacheByKeys(x)}const _={[e]:y.data};return Object.keys(v).length>0&&(_._localInit=v),r.initGlobal&&(_._global={...this.globalState}),Ds(_,n?.sync?{sync:!0}:void 0),U.log(`Data source refetched successfully: ${e}`),y.data}else if(y.state==="error"){U.error(`Failed to refetch data source: ${e}`,y.error);return}}catch(i){U.error(`Error refetching data source: ${e}`,i);return}finally{Gr.setPending(!1)}}registerModalDataSources(e,n){this.modalDataSources.set(e,n),U.log(`Modal data sources registered: ${e} (${n.length} sources)`)}unregisterModalDataSources(e){this.modalDataSources.delete(e),U.log(`Modal data sources unregistered: ${e}`)}getDataSource(e){return this.currentFetchedData[e]}setDataSource(e,n,r){if(!e){U.warn("setDataSource: dataSourceId is required");return}const{merge:i=!1,sync:l=!1}=r||{};i&&this.currentFetchedData[e]?this.currentFetchedData[e]={...this.currentFetchedData[e],...n}:this.currentFetchedData[e]=n,Promise.resolve().then(()=>Wr).then(({updateTemplateData:c})=>{c({[e]:this.currentFetchedData[e]},l?{sync:!0}:void 0)}),U.log(`setDataSource: Updated ${e}`,i?"(merged)":"(replaced)")}updateDataSourceItem(e,n,r,i,l){const{idField:c="id",merge:d=!0,skipRender:f=!1}=l||{},h=this.currentFetchedData[e];if(!h)return U.warn(`updateDataSourceItem: DataSource '${e}' not found`),!1;const m=this.parseItemPath(n);let y=h;for(const _ of m)if(y=y?.[_],y===void 0)return U.warn(`updateDataSourceItem: Path '${n}' not found in dataSource`),!1;if(!Array.isArray(y))return U.warn(`updateDataSourceItem: Target at '${n}' is not an array`),!1;const v=y.findIndex(_=>String(_[c])===String(r));if(v===-1)return U.warn(`updateDataSourceItem: Item with ${c}='${r}' not found`),!1;d?y[v]=this.deepMerge(y[v],i):y[v]={...y[v],...i};const S=window.G7Core?.devTools;return S?.isEnabled?.()&&S.trackDataSourceUpdate?.({dataSourceId:e,updateType:"partial",itemPath:n,itemId:r,updates:i,timestamp:Date.now()}),f||Promise.resolve().then(()=>Wr).then(({updateTemplateData:_})=>{_({[e]:this.currentFetchedData[e]},{sync:!1})}),U.log(`updateDataSourceItem: Updated ${e}.${n}[${c}=${r}]`),!0}parseItemPath(e){const n=[],r=/([^\.\[\]]+)|\[(\d+)\]/g;let i;for(;(i=r.exec(e))!==null;)i[1]!==void 0?n.push(i[1]):i[2]!==void 0&&n.push(parseInt(i[2],10));return n}deepMerge(e,n){if(n==null)return e;if(typeof n!="object"||Array.isArray(n))return n;const r={...e};for(const i of Object.keys(n))typeof n[i]=="object"&&n[i]!==null&&!Array.isArray(n[i])?r[i]=this.deepMerge(r[i]||{},n[i]):r[i]=n[i];return r}setValueAtPath(e,n,r,i="deep"){const l=n.split(".");let c=e;for(let h=0;h0?l.filterByCondition(this.currentRawDataSources,d):this.currentDataSources;this.currentDataSources=f;const h=f.filter(x=>x.auto_fetch!==!1&&x.type!=="websocket");if(h.length===0){U.log("No auto_fetch data sources to refetch");return}U.log(`Refetching ${h.length} auto_fetch data sources`),Gr.setPending(!0);const m=la().currentLayoutJson,y=m?.transition_overlay,v=Array.isArray(y?.wait_for)?y.wait_for:[],S=h.some(x=>(x.loading_strategy||"progressive")==="blocking"),_=v.length>0&&h.some(x=>v.includes(x.id)&&x.type!=="websocket"&&(x.loading_strategy||"progressive")!=="background");if((S||_)&&y&&typeof y=="object"){const x=n?.transitionOverlayTarget||y.target;y.enabled&&y.style==="skeleton"&&y.skeleton?.component&&x?this.renderSkeletonOverlay(x,y.skeleton,m,y.fallback_target):y.enabled&&y.style==="spinner"&&x&&this.renderSpinnerOverlay(x,y.spinner,y.fallback_target)}try{const x=new Or;this.currentGlobalHeaders.length>0&&x.setGlobalHeaders(this.currentGlobalHeaders);const A=la(),D=A.currentDataContext?._global||{},O=await x.fetchDataSourcesWithResults(h,this.currentRouteParams,this.currentQueryParams,D,void 0,{ignoreAutoFetch:!1}),k={},L={},B=new Map(h.map(q=>[q.id,q]));for(const q of O){const z=B.get(q.id);if(!z){U.warn(`Refetch result id not found in autoFetchDataSources: ${q.id}`);continue}const W=q.id;q.state==="success"&&q.data!==void 0?(this.currentFetchedData[W]=q.data,k[W]=q.data,this.processInitOptions([z],{[W]:q.data},L),U.log(`Data source refetched: ${W}`)):q.state==="error"&&U.error(`Failed to refetch data source: ${W}`,q.error)}if(A.bindingEngine){const q=Object.keys(k);q.push("query"),A.bindingEngine.invalidateCacheByKeys(q)}if(Object.keys(L).length>0&&(k._localInit=L),Object.keys(k).length>0){if(k.query=Mb(this.currentQueryParams),A.currentLayoutJson?.computed&&Object.keys(A.currentLayoutJson.computed).length>0){const q={...A.currentDataContext,...k,query:k.query},z=this.calculateComputed(A.currentLayoutJson.computed,q);Object.keys(z).length>0&&(k._computed=z,this.globalState._computed=z,U.log("Computed values recalculated in updateQueryParams:",Object.keys(z)))}Ds(k,{sync:!0}),U.log("Template data updated with new query params")}}catch(x){U.error("Error in updateQueryParams:",x)}finally{Gr.setPending(!1),this.hideTransitionOverlay()}}calculateComputed(e,n){const r={},i=new $n;for(const[l,c]of Object.entries(e))try{let d;if(this.isComputedSwitchDefinition(c))d=i.resolveSwitch(c,n,{skipCache:!0});else if(typeof c=="string")if(c.startsWith("{{")&&c.endsWith("}}")){const f=c.slice(2,-2).trim();d=this.evaluateComputedExpression(f,n)}else d=c;r[l]=d,U.log(`Computed ${l}:`,d)}catch(d){U.warn(`Failed to calculate computed value: ${l}`,d),r[l]=void 0}return r}isComputedSwitchDefinition(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&"$switch"in e&&"$cases"in e}evaluateComputedExpression(e,n){try{return nf(e,n)}catch(r){U.warn(`Expression evaluation failed: ${e}`,r);return}}async executeInitActions(e,n={}){const{getActionDispatcher:r}=await Promise.resolve().then(()=>Wr),i=r();if(!i){U.warn("ActionDispatcher not available for init_actions");return}U.log("Executing init_actions:",e.map(d=>d.handler)),U.log("Init actions dataContext:",n),U.log("Init actions dataContext._global:",n._global);const l=e.map(d=>d.handler).filter(d=>d.includes("."));l.length>0&&await this.waitForHandlers(i,l);let c={...n};for(const d of e)try{const f={type:"click",handler:d.handler,target:d.target,params:d.params,resultTo:d.resultTo,onSuccess:d.onSuccess,onError:d.onError,if:d.if,conditions:d.conditions,auth_mode:d.auth_mode,auth_required:d.auth_required},h=i.createHandler(f,c),m=new Event("init");await h(m),U.log(`Init action executed: ${d.handler}`);const y=this.globalState;c={...c,_global:{...y},_local:y._local||c._local||{}},U.log(`Data context refreshed after ${d.handler}:`,{cartKey:c._global?.cartKey})}catch(f){U.error(`Failed to execute init action: ${d.handler}`,f)}}async waitForHandlers(e,n,r=5e3){const i=Date.now(),l=50,c=()=>n.every(f=>e.customHandlers?.has(f));if(c()){U.log("All module handlers already registered");return}const d=dh().getFailedJsAssets();if(d.length>0){const f=d.some(y=>y==="module"||y==="plugin"),h=n.filter(y=>!e.customHandlers?.has(y)),m=h.length>0&&h.every(y=>d.some(v=>y.startsWith(`${v}.`)));if(f||m){U.warn("Extension asset load failed — not waiting for handlers that will never register:",{pending:h,failedAssets:d});return}}return U.log("Waiting for module handlers:",n),new Promise(f=>{const h=()=>{if(c()){U.log("All module handlers now registered"),f();return}if(Date.now()-i>=r){const m=n.filter(y=>!e.customHandlers?.has(y));U.warn("Timeout waiting for handlers:",m),f();return}setTimeout(h,l)};h()})}};M($r,"LOCALE_STORAGE_KEY","g7_locale"),M($r,"CACHE_VERSION_STORAGE_KEY","g7_cache_version");let Yo=$r;function hh(s){const e=new Yo(s);return s.websocket&&(qc.configure(s.websocket),U.log("WebSocket 설정 완료")),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{e.init(),window.__templateApp=e}):(e.init(),window.__templateApp=e),e}typeof window<"u"&&(window.G7Core=window.G7Core||{},window.G7Core.initTemplateApp=hh,window.G7Core.dataSource={refetch:async(s,e)=>{const n=window.__templateApp;if(!n){U.warn("TemplateApp not initialized (G7Core.dataSource.refetch)");return}return n.refetchDataSource(s,e)},get:s=>{const e=window.__templateApp;if(!e){U.warn("TemplateApp not initialized (G7Core.dataSource.get)");return}return e.getDataSource(s)}});function gT(s={}){const{checked:e,value:n,name:r,type:i="checkbox"}=s,c=n!==void 0?n:i==="checkbox"||i==="radio"?e??!1:String(e??""),d={checked:e??!1,value:c,name:r??"",type:i};return{target:d,currentTarget:d,preventDefault:()=>{},stopPropagation:()=>{},nativeEvent:new Event("change"),bubbles:!0,cancelable:!0,defaultPrevented:!1,eventPhase:Event.AT_TARGET,isTrusted:!1,timeStamp:Date.now(),type:"change",isDefaultPrevented:()=>!1,isPropagationStopped:()=>!1,persist:()=>{}}}function mT(s={}){const{button:e=0,clientX:n=0,clientY:r=0}=s;return{button:e,clientX:n,clientY:r,preventDefault:()=>{},stopPropagation:()=>{},nativeEvent:new MouseEvent("click"),bubbles:!0,cancelable:!0,defaultPrevented:!1,eventPhase:Event.AT_TARGET,isTrusted:!1,timeStamp:Date.now(),type:"click",isDefaultPrevented:()=>!1,isPropagationStopped:()=>!1,persist:()=>{},target:document.createElement("div"),currentTarget:document.createElement("div")}}function yT(){return{preventDefault:()=>{},stopPropagation:()=>{},nativeEvent:new Event("submit"),bubbles:!0,cancelable:!0,defaultPrevented:!1,eventPhase:Event.AT_TARGET,isTrusted:!1,timeStamp:Date.now(),type:"submit",isDefaultPrevented:()=>!1,isPropagationStopped:()=>!1,persist:()=>{},target:document.createElement("form"),currentTarget:document.createElement("form")}}function bT(s,e="keydown"){return{key:s,code:s.length===1?`Key${s.toUpperCase()}`:s,preventDefault:()=>{},stopPropagation:()=>{},nativeEvent:new KeyboardEvent(e,{key:s}),bubbles:!0,cancelable:!0,defaultPrevented:!1,eventPhase:Event.AT_TARGET,isTrusted:!1,timeStamp:Date.now(),type:e,isDefaultPrevented:()=>!1,isPropagationStopped:()=>!1,persist:()=>{},target:document.createElement("div"),currentTarget:document.createElement("div"),altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1,repeat:!1}}const vT={justify:/^justify-(start|end|center|between|around|evenly)$/,items:/^items-(start|end|center|baseline|stretch)$/,content:/^content-(start|end|center|between|around|evenly|stretch)$/,self:/^self-(auto|start|end|center|stretch|baseline)$/,flex:/^flex-(row|row-reverse|col|col-reverse|wrap|wrap-reverse|nowrap|1|auto|initial|none)$/,grow:/^(grow|grow-0)$/,shrink:/^(shrink|shrink-0)$/,basis:/^basis-/,order:/^(order-|-)order-/,gap:/^gap(-x|-y)?-/,gridCols:/^grid-cols-/,gridRows:/^grid-rows-/,colSpan:/^col-(span-|start-|end-)/,rowSpan:/^row-(span-|start-|end-)/,display:/^(block|inline-block|inline|flex|inline-flex|table|inline-table|table-caption|table-cell|table-column|table-column-group|table-footer-group|table-header-group|table-row-group|table-row|flow-root|grid|inline-grid|contents|list-item|hidden)$/,position:/^(static|fixed|absolute|relative|sticky)$/,inset:/^(inset|top|right|bottom|left)-/,zIndex:/^z-/,width:/^w-/,minWidth:/^min-w-/,maxWidth:/^max-w-/,height:/^h-/,minHeight:/^min-h-/,maxHeight:/^max-h-/,padding:/^p[xytblr]?-/,margin:/^-?m[xytblr]?-/,space:/^space-(x|y)-/,fontSize:/^text-(xs|sm|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl)$/,fontWeight:/^font-(thin|extralight|light|normal|medium|semibold|bold|extrabold|black)$/,fontStyle:/^(italic|not-italic)$/,fontFamily:/^font-(sans|serif|mono)/,textAlign:/^text-(left|center|right|justify|start|end)$/,textColor:/^text-(inherit|current|transparent|black|white|slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-/,textDecoration:/^(underline|overline|line-through|no-underline)$/,textTransform:/^(uppercase|lowercase|capitalize|normal-case)$/,lineHeight:/^leading-/,letterSpacing:/^tracking-/,textOverflow:/^(truncate|text-ellipsis|text-clip)$/,whitespace:/^whitespace-/,wordBreak:/^break-/,bgColor:/^bg-(inherit|current|transparent|black|white|slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-/,bgGradient:/^bg-gradient-/,bgSize:/^bg-(auto|cover|contain)$/,bgPosition:/^bg-(bottom|center|left|left-bottom|left-top|right|right-bottom|right-top|top)$/,bgRepeat:/^bg-(repeat|no-repeat|repeat-x|repeat-y|repeat-round|repeat-space)$/,bgAttachment:/^bg-(fixed|local|scroll)$/,bgClip:/^bg-clip-/,bgOrigin:/^bg-origin-/,borderWidth:/^border(-[xytblr])?(-0|-2|-4|-8)?$/,borderColor:/^border-(inherit|current|transparent|black|white|slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-/,borderStyle:/^border-(solid|dashed|dotted|double|hidden|none)$/,borderRadius:/^rounded(-[tblrse]{1,2})?(-none|-sm|-md|-lg|-xl|-2xl|-3xl|-full)?$/,ringWidth:/^ring(-0|-1|-2|-4|-8|-inset)?$/,ringColor:/^ring-(inherit|current|transparent|black|white|slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-/,ringOffset:/^ring-offset-/,shadow:/^shadow(-sm|-md|-lg|-xl|-2xl|-inner|-none)?$/,opacity:/^opacity-/,mixBlend:/^mix-blend-/,bgBlend:/^bg-blend-/,blur:/^blur(-none|-sm|-md|-lg|-xl|-2xl|-3xl)?$/,brightness:/^brightness-/,contrast:/^contrast-/,grayscale:/^grayscale(-0)?$/,hueRotate:/^-?hue-rotate-/,invert:/^invert(-0)?$/,saturate:/^saturate-/,sepia:/^sepia(-0)?$/,backdropBlur:/^backdrop-blur-/,backdropBrightness:/^backdrop-brightness-/,backdropContrast:/^backdrop-contrast-/,backdropGrayscale:/^backdrop-grayscale-/,backdropHueRotate:/^backdrop-hue-rotate-/,backdropInvert:/^backdrop-invert-/,backdropOpacity:/^backdrop-opacity-/,backdropSaturate:/^backdrop-saturate-/,backdropSepia:/^backdrop-sepia-/,scale:/^scale(-x|-y)?-/,rotate:/^-?rotate-/,translate:/^-?translate-[xy]-/,skew:/^-?skew-[xy]-/,transformOrigin:/^origin-/,transition:/^transition(-none|-all|-colors|-opacity|-shadow|-transform)?$/,duration:/^duration-/,ease:/^ease-(linear|in|out|in-out)$/,delay:/^delay-/,animate:/^animate-/,cursor:/^cursor-/,userSelect:/^select-/,pointerEvents:/^pointer-events-/,resize:/^resize(-none|-x|-y)?$/,scrollBehavior:/^scroll-(auto|smooth)$/,touchAction:/^touch-/,overflow:/^overflow(-x|-y)?-(auto|hidden|clip|visible|scroll)$/,overscroll:/^overscroll(-x|-y)?-(auto|contain|none)$/,visibility:/^(visible|invisible|collapse)$/,aspectRatio:/^aspect-/,columns:/^columns-/,breakAfter:/^break-after-/,breakBefore:/^break-before-/,breakInside:/^break-inside-/,boxDecorationBreak:/^box-decoration-/,boxSizing:/^box-(border|content)$/,float:/^float-(right|left|none)$/,clear:/^clear-(left|right|both|none)$/,isolation:/^(isolate|isolation-auto)$/,objectFit:/^object-(contain|cover|fill|none|scale-down)$/,objectPosition:/^object-/};function Nb(s){const e=s.replace(/^(dark:|hover:|focus:|active:|disabled:|group-hover:|sm:|md:|lg:|xl:|2xl:)+/,"");for(const[n,r]of Object.entries(vT))if(r.test(e))return n;return null}function Ib(s){const e=s.match(/^((dark:|hover:|focus:|active:|disabled:|group-hover:|sm:|md:|lg:|xl:|2xl:)+)/);return e?e[1]:""}function ST(s,e){if(!e||e.trim()==="")return s;if(!s||s.trim()==="")return e;const n=s.split(/\s+/).filter(Boolean),r=e.split(/\s+/).filter(Boolean),i=new Map;for(const c of r){const d=Nb(c);if(d){const f=Ib(c),h=`${d}:${f}`;i.set(h,c)}}return[...n.filter(c=>{const d=Nb(c);if(!d)return!0;const f=Ib(c),h=`${d}:${f}`;return!i.has(h)}),...r].join(" ")}function wT(s){return Object.entries(s).filter(([,e])=>e).map(([e])=>e).join(" ")}function CT(...s){return s.filter(e=>typeof e=="string"&&e.length>0).join(" ")}const be=pt("G7CoreGlobals");function ET(){window.React=Xe,window.ReactDOM={...Dd,createPortal:Ia.createPortal,unstable_batchedUpdates:s=>s()},window.ReactJSXRuntime=r_,be.log("전역 객체 window.React, window.ReactDOM, window.ReactJSXRuntime에 노출됨")}function _T(s){const e=new Map,n=Ha.getInstance();s.componentEvent={on:(r,i)=>(e.has(r)||e.set(r,new Set),e.get(r).add(i),n.trackEventSubscribe(r),()=>{e.get(r)?.delete(i),n.trackEventUnsubscribe(r)}),emit:async(r,i)=>{const l=e.get(r),c=l?.size??0;if(!l||l.size===0)return n.trackEventEmit(r,i,0),[];let d,f=[];try{f=await Promise.all(Array.from(l).map(async h=>{try{return await h(i)}catch(m){throw be.error(`componentEvent: Error in listener for "${r}":`,m),m}}))}catch(h){d=h instanceof Error?h:new Error(String(h))}if(n.trackEventEmit(r,i,c,f,d),d)throw d;return f},off:r=>{e.delete(r),n.trackEventOff(r)},clear:()=>{e.clear(),n.trackEventClear()}},be.log("전역 객체 window.G7Core.componentEvent에 노출됨")}function AT(s){s.__runtime||(s.__runtime={DynamicRenderer:Vr,ComponentRegistry:Ar,TranslationEngine:vi,DataSourceManager:Or,dataSourceManager:qx,DataBindingEngine:$n,dataBindingEngine:oc,ActionDispatcher:jo,TranslationReactContext:nh,TranslationProvider:Pc,useTranslation:gb,ResponsiveContext:$f,ResponsiveProvider:xc,useResponsive:Mf,responsiveManager:Ci,BREAKPOINT_PRESETS:lc,AuthManager:Xn,createLogger:pt,G7DevToolsCore:Ha},be.log("전역 객체 window.G7Core.__runtime(코어 런타임 표면)에 노출됨"))}function xT(s){if(s.layoutEditor&&s.layoutEditor.__isStub!==!0||s.layoutEditor&&s.layoutEditor.__isStub===!0)return;const e=[],n=[];s.layoutEditor={__isStub:!0,__queue:e,__readyCallbacks:n,registerWidget:(r,i)=>e.push(["widget",r,i]),registerNodeEditor:(r,i)=>e.push(["nodeEditor",r,i]),registerCanvasOverlay:(r,i)=>e.push(["canvasOverlay",r,i]),onReady:r=>{typeof r=="function"&&n.push(r)}},be.log("전역 객체 window.G7Core.layoutEditor 예약 접수함(stub) 노출됨")}function TT(s){s.asset={template:(e,n,r)=>h0(e,n,r),templateDir:(e,n)=>p0(e,n),module:(e,n,r)=>g0(e,n,r),plugin:(e,n,r)=>m0(e,n,r),convertToCurrentMode:e=>Ln(e),loadScript:(e,n,r)=>Io(e,bs())?_r(e,n,r):Promise.reject(new Error(`Blocked untrusted script src (same-origin path or declared trusted host required): ${e}`)),isAllowedScriptSrc:e=>Io(e,bs()),loadStylesheet:(e,n,r)=>ia(e,n,r)},s.assets={notifyFailure:xs,clearFailure:Db,clearAll:Ob,getFailures:Qx,retryAll:$b},oT(),be.log("전역 객체 window.G7Core.asset / window.G7Core.assets 노출됨")}function kT(s,e){s.useTranslation=gb,s.t=(n,r)=>{const i=e.getState();if(!i.translationEngine||!i.translationContext)return n;if(r){const l="|"+Object.entries(r).map(([c,d])=>`${c}=${d}`).join("|");return i.translationEngine.translate(n,i.translationContext,l)}return i.translationEngine.translate(n,i.translationContext)},be.log("전역 객체 window.G7Core.useTranslation에 노출됨")}function RT(s,e){s.createChangeEvent=gT,s.createClickEvent=mT,s.createSubmitEvent=yT,s.createKeyboardEvent=bT,s.uuid=()=>typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{const r=Math.random()*16|0;return(n==="x"?r:r&3|8).toString(16)}),s.createLogger=pt,be.log("전역 객체 window.G7Core.createLogger에 노출됨"),s.renderItemChildren=(n,r,i,l,c)=>{const d=e.getState(),m={_global:window.__templateApp?.getGlobalState?.()||{},_local:r._local||{},_computed:r._computed||{},...r},y=new Set,v=(_,x)=>{const A=m._global?._remountKeys;return _&&A?.[_]&&!y.has(_)?(y.add(_),`${_}-remount-${A[_]}`):_||x},S={translationContext:d.translationContext,translationEngine:d.translationEngine,bindingEngine:d.bindingEngine,actionDispatcher:d.actionDispatcher,getRemountKey:v,...c};return Eo(n,m,i,l,S)},s.evaluateCondition=(n,r)=>{if(!n)return!0;const i=e.getState(),c=window.__templateApp?.getGlobalState?.()||{},d={_global:c,_local:c._local||{},_computed:c._computed||{},...r||{}},f=i.bindingEngine??oc;return cm(n,d,f)},s.getComponentMap=()=>Ar.getInstance().getComponentMap(),s.renderComponentLayout=(n,r,i)=>{if(!n||!Array.isArray(n)||n.length===0)return null;const l=Ar.getInstance().getComponentMap(),c=e.getState(),f=window.__templateApp?.getGlobalState?.()||{},h={_global:f._global||{},_local:f._local||{},_computed:f._computed||{},...r},m=new Set,y=(v,S)=>{const _=h._global?._remountKeys;return v&&_?.[v]&&!m.has(v)?(m.add(v),`${v}-remount-${_[v]}`):v||S};return Eo(n,h,l,i,{translationContext:c.translationContext,translationEngine:c.translationEngine,bindingEngine:c.bindingEngine,actionDispatcher:c.actionDispatcher,getRemountKey:y})},s.renderExpandContent=n=>{const{children:r,row:i,expandContext:l,componentContext:c,keyPrefix:d}=n;if(!r||!Array.isArray(r)||r.length===0)return null;const f=n.componentMap||Ar.getInstance().getComponentMap(),h=e.getState(),m=s.state?.get?.()||{},y=c?.stateRef?.current??c?.state??{},v={...m._local||{},...y},S=c?.computedRef?.current??m._computed??{},_=h.bindingEngine??s.getDataBindingEngine?.(),x={...m,_local:v,_computed:S,row:i,item:i,$item:i};let A={};if(l&&typeof l=="object"&&_)try{for(const[L,B]of Object.entries(l))if(typeof B=="string"){const q=Oa(B);if(q!==null)try{A[L]=jn(q)?_.evaluatePipeExpression(q,x,{skipCache:!0}):_.evaluateExpression(q,x,{skipCache:!0})}catch{A[L]=void 0}else A[L]=_.resolveBindings(B,x,{skipCache:!0})}else A[L]=B}catch(L){be.warn("renderExpandContent: expandContext 평가 오류:",L)}const D={row:i,item:i,$item:i,_local:v,_global:m._global||{},_computed:m._computed||{},...A},O=new Set,k=(L,B)=>{const q=D._global?._remountKeys;return L&&q?.[L]&&!O.has(L)?(O.add(L),`${L}-remount-${q[L]}`):L||B};return Eo(r,D,f,d,{translationContext:h.translationContext,translationEngine:h.translationEngine??void 0,bindingEngine:h.bindingEngine??void 0,actionDispatcher:h.actionDispatcher,componentContext:c,getRemountKey:k})},s.$get=function(r,i,l=void 0){if(r==null)return l;const c=Array.isArray(i)?i:[i];if(c.length===0)return r;let d=r;for(const f of c){if(d==null||f==null)return l;d=d[f]}return d??l},be.log("전역 객체 window.G7Core.renderItemChildren에 노출됨"),be.log("전역 객체 window.G7Core.renderComponentLayout에 노출됨"),be.log("전역 객체 window.G7Core.renderExpandContent에 노출됨"),be.log("전역 객체 window.G7Core.$get에 노출됨")}function DT(s){s.dispatch=async(e,n)=>{const r=window.__templateApp;if(!r)return be.warn("G7Core.dispatch: TemplateApp이 초기화되지 않았습니다."),{success:!1,error:new Error("TemplateApp이 초기화되지 않았습니다.")};const i=r.getActionDispatcher?.();if(!i)return be.warn("G7Core.dispatch: ActionDispatcher를 찾을 수 없습니다."),{success:!1,error:new Error("ActionDispatcher를 찾을 수 없습니다.")};const l=r.getRouter?.(),c=r.getGlobalState?.(),d=r.setGlobalState?.bind(r),h=n?.componentContext||window.__g7ActionContext,m=window.__g7PendingLocalState;let y=h?.state??c;m&&h&&(y=m,be.log("[dispatch] Using __g7PendingLocalState for context.state:",m));let v=h?.data??c;m&&h?.data?._local&&(v={...h.data,_local:m},be.log("[dispatch] Updated context.data._local with pendingLocalState"));const S={navigate:l?(_,x)=>l.navigate(_,x):void 0,setState:h?.setState??d,state:y,data:v,_isDispatchFallbackContext:!h?.setState};if(e.debounce){const _=e.debounceKey||`dispatch-${e.handler}`,x=typeof e.debounce=="number"?e.debounce:e.debounce.delay;return i.debouncedCall(_,x,()=>{const{debounce:A,debounceKey:D,...O}=e;i.dispatchAction(O,S)}),{success:!0,debounced:!0}}try{return await i.dispatchAction(e,S)}catch(_){return be.error("G7Core.dispatch: 액션 실행 오류:",_),{success:!1,error:_ instanceof Error?_:new Error(String(_))}}},be.log("전역 객체 window.G7Core.dispatch에 노출됨")}function Xo(s){const e={};for(const[n,r]of Object.entries(s))if(n.includes(".")){const i=n.split(".");let l=e;for(let c=0;c0&&e.every(n=>/^\d+$/.test(n))}function Zn(s,e){if(Array.isArray(s)&&!Array.isArray(e)&&OT(e)){const r=Object.keys(e).map(l=>parseInt(l,10));if(!((r.length>0?Math.max(...r):0)>=s.length+r.length+10)){const l=[...s];for(const[c,d]of Object.entries(e)){const f=parseInt(c,10);f>=0&&f=l.length&&(l[f]=d)}return l}}const n={...s};for(const[r,i]of Object.entries(e))i!==null&&typeof i=="object"&&!Array.isArray(i)?n[r]!==null&&typeof n[r]=="object"?n[r]=Zn(n[r],i):n[r]={...i}:n[r]=i;return n}function LT(s){s.state={get:()=>window.__templateApp?.getGlobalState?.()||{},set:(e,n)=>{const r=window.__templateApp;if(r?.setGlobalState&&r?.getGlobalState){const i=n?.merge||"deep",l=Xo(e);let c;if(i==="replace")c=l;else if(i==="shallow")c={...r.getGlobalState(),...l};else{const d=r.getGlobalState();c=Zn(d,l)}r.setGlobalState(c,{render:n?.render})}else be.warn("G7Core.state.set: TemplateApp이 초기화되지 않았습니다.")},setLocal:(e,n)=>{const r=window.__templateApp;if(n?.render===!1&&!n?.selfManaged){const A=window.__g7AutoBindingPaths;A&&A.size>0&&jb(Xo(e)).some(O=>A.has(O))&&(be.log("[setLocal] render:false + 자동바인딩 경로 겹침 감지 → render:true 자동 승격 (engine-v1.43.0)"),n={...n,render:!0})}if(n?.debounce){const A=r?.getActionDispatcher?.();if(A){const D=n.debounceKey||`setLocal-${Object.keys(e).join(",")}`,{debounce:O,debounceKey:k,...L}=n;A.debouncedCall(D,n.debounce,()=>{s.state.setLocal(e,L)});return}}const i=n?.scope??"current",l=n?.merge||"deep",c=window.__g7ActionContext,d=Xo(e);if(i==="parent"||i==="root"){const A=window.__g7LayoutContextStack||[];if(A.length>0){const D=i==="parent"?A[A.length-1]:A[0];if(D?.setState){D.setState(O=>l==="replace"?d:l==="shallow"?{...O||{},...d}:Zn(O||{},d)),be.log(`[setLocal] scope=${i}: 타겟 컨텍스트에 상태 업데이트 (mergeMode=${l})`,d);return}}be.warn(`[setLocal] scope=${i}: 레이아웃 컨텍스트 스택이 비어있습니다. current로 폴백합니다.`)}const f=window.__g7PendingLocalState,h=r?.getGlobalState?.()?._local||{},v=!((window.__g7LayoutContextStack||[]).length>0)&&c?.state?c.state:void 0,S=v?Mo(h,v):h,_=f||S;let x;if(l==="replace"?x=d:l==="shallow"?x={..._,...d}:x=Zn(_,d),r?.setGlobalState&&(r.setGlobalState({_local:x},{render:n?.render}),be.log(`[setLocal] globalLocal updated via setGlobalState (mergeMode=${l}, render=${n?.render??!0}):`,d)),window.__g7PendingLocalState=x,be.log("[setLocal] __g7PendingLocalState updated:",x),window.__g7SequenceLocalSync=x,window.__g7LastSetLocalSnapshot=x,l==="replace")window.__g7ForcedLocalFields=d;else{const A=window.__g7ForcedLocalFields||{};window.__g7ForcedLocalFields=Zn(A,d)}if(be.log("[setLocal] __g7ForcedLocalFields updated:",d),l==="replace")window.__g7SetLocalOverrideKeys=d;else{const A=window.__g7SetLocalOverrideKeys||{};window.__g7SetLocalOverrideKeys=Zn(A,d)}be.log("[setLocal] __g7SetLocalOverrideKeys updated:",d),c?.setState&&c.setState(A=>l==="replace"?d:l==="shallow"?{...A||{},...d}:Zn(A||{},d)),r?.setGlobalState||be.warn("G7Core.state.setLocal: TemplateApp이 없습니다.")},getLocal:()=>{const r=(window.__templateApp?.getGlobalState?.()||{})._local||{},i=window.__g7PendingLocalState;if(i)return Zn(r,i);const l=window.__g7LastSetLocalSnapshot;return l&&l!==r?Zn(r,l):r},update:e=>{const n=window.__templateApp;if(n?.getGlobalState&&n?.setGlobalState){const r=n.getGlobalState(),i=e(r);n.setGlobalState(i)}else be.warn("G7Core.state.update: TemplateApp이 초기화되지 않았습니다.")},subscribe:e=>{const n=window.__templateApp;return n?.onGlobalStateChange?n.onGlobalStateChange(e):(be.warn("G7Core.state.subscribe: TemplateApp이 초기화되지 않았습니다."),()=>{})},getDataSource:e=>window.__templateApp?.getDataSource?.(e),getIsolated:e=>e?window.__g7IsolatedStates?.[e]?.state??null:window.__g7ActionContext?.isolatedContext?.state??null,setIsolated:(e,n,r)=>{let i,l,c;typeof e=="string"?(i=e,l=n||{},c=r):(l=e,c=n&&typeof n=="object"&&"merge"in n?n:r);const d=c?.merge||"deep",f=Xo(l);if(i){const y=window.__g7IsolatedStates?.[i];y?.mergeState?y.mergeState(f,d):be.warn(`G7Core.state.setIsolated: scopeId '${i}'를 찾을 수 없습니다.`);return}const h=window.__g7ActionContext;h?.isolatedContext?.mergeState?h.isolatedContext.mergeState(f,d):be.warn("G7Core.state.setIsolated: 액션 컨텍스트에 isolatedContext가 없습니다.")},getParent:()=>{const e=window.__g7LayoutContextStack||[];if(e.length===0)return be.log("[getParent] 레이아웃 컨텍스트 스택이 비어있습니다."),null;const n=e[e.length-1];if(!n)return null;const r=n.dataContext||{};return{_local:n.state||r._local||{},_global:r._global||s.state.get()||{},setState:n.setState}},setParentLocal:(e,n,r)=>{const i=window.__g7LayoutContextStack||[];if(i.length===0){be.warn("[setParentLocal] 레이아웃 컨텍스트 스택이 비어있습니다.");return}const l=i[i.length-1];if(!l?.setState){be.warn("[setParentLocal] 부모 컨텍스트에 setState가 없습니다.");return}let c,d;typeof e=="string"?(c={[e]:n},d=r):(c=e,d=n&&typeof n=="object"&&"merge"in n?n:r);const f=d?.merge||"deep",h=Xo(c),m=l.state?._local!==void 0,y=m?l.state._local:l.state||{};let v;f==="replace"?v=h:f==="shallow"?v={...y,...h}:v=Zn(y,h),window.__g7PendingLocalState=v;const S=window.__templateApp;if(S?.setGlobalState){const _=S.getGlobalState?.()?._local,A=f!=="replace"&&!!_&&typeof _=="object"&&!Array.isArray(_)?f==="shallow"?{..._,...h}:Zn(_,h):void 0;S.setGlobalState({_local:A?Mo(A,v):v})}if(l.setState(v),m?l.state._local=v:l.state=v,l.dataContext&&(l.dataContext._local=v),f==="replace")window.__g7ForcedLocalFields=h;else{const _=window.__g7ForcedLocalFields||{};window.__g7ForcedLocalFields=Zn(_,h)}Df()},setParentGlobal:(e,n)=>{let r;typeof e=="string"?r={[e]:n}:r=e,s.state.set(r),be.log("[setParentGlobal] 전역 상태 업데이트:",r)}},window.__g7IsolatedStates||(window.__g7IsolatedStates={}),s.state.getGlobal=s.state.get,s.state.setGlobal=s.state.set,be.log("전역 객체 window.G7Core.state에 노출됨")}function $T(s){s.dataSource={get:e=>window.__templateApp?.getDataSource?.(e),set:(e,n,r)=>{const i=window.__templateApp;i?.setDataSource?i.setDataSource(e,n,r):be.warn("G7Core.dataSource.set: TemplateApp이 초기화되지 않았습니다.")},refetch:async(e,n)=>{const r=window.__templateApp;if(r?.refetchDataSource)return r.refetchDataSource(e,n);be.warn("G7Core.dataSource.refetch: TemplateApp이 초기화되지 않았습니다.")},updateItem:(e,n,r,i,l)=>{const c=window.__templateApp;return c?.updateDataSourceItem?c.updateDataSourceItem(e,n,r,i,l):(be.warn("G7Core.dataSource.updateItem: TemplateApp이 초기화되지 않았습니다."),!1)},updateData:(e,n,r,i="append")=>{const l=window.__templateApp;if(!l?.getDataSource||!l?.setDataSource)return be.warn("G7Core.dataSource.updateData: TemplateApp이 초기화되지 않았습니다."),!1;const c=l.getDataSource(e);if(!c)return be.warn(`G7Core.dataSource.updateData: 데이터 소스 '${e}'를 찾을 수 없습니다.`),!1;let d,f=c,h=null;if(n){const y=n.split(".");h=y.pop();for(const v of y)if(f&&typeof f=="object"&&v in f)f=f[v];else return be.warn(`G7Core.dataSource.updateData: 경로 '${n}'를 찾을 수 없습니다.`),!1;d=f[h]}else d=c;if(!Array.isArray(d))return be.warn("G7Core.dataSource.updateData: 대상 경로의 데이터가 배열이 아닙니다."),!1;if(!Array.isArray(r))return be.warn("G7Core.dataSource.updateData: newData가 배열이 아닙니다."),!1;const m=i==="prepend"?[...r,...d]:[...d,...r];return n&&h?(f[h]=m,l.setDataSource(e,c,{merge:!1})):l.setDataSource(e,m,{merge:!1}),be.log(`G7Core.dataSource.updateData: '${e}'에 ${r.length}개 항목 ${i==="prepend"?"앞에":"뒤에"} 추가됨`),!0}},be.log("전역 객체 window.G7Core.dataSource에 노출됨")}function MT(s,e){s.locale={current:()=>window.__templateApp?.getLocale?.()||"ko",supported:()=>{const r=window.__templateApp?.globalState?.appConfig?.supportedLocales;return Array.isArray(r)&&r.length>0?r:e.getState().templateMetadata?.locales||["ko","en"]},change:async n=>{const r=window.__templateApp;r?.changeLocale?await r.changeLocale(n):be.warn("G7Core.locale.change: TemplateApp이 초기화되지 않았습니다.")}},be.log("전역 객체 window.G7Core.locale에 노출됨")}function NT(s){s.toast={show:(e,n)=>{s.dispatch({handler:"toast",params:{message:e,type:n?.type||"info",...n?.duration&&{duration:n.duration}}})},success:(e,n)=>{s.toast.show(e,{type:"success",duration:n})},error:(e,n)=>{s.toast.show(e,{type:"error",duration:n})},warning:(e,n)=>{s.toast.show(e,{type:"warning",duration:n})},info:(e,n)=>{s.toast.show(e,{type:"info",duration:n})}},be.log("전역 객체 window.G7Core.toast에 노출됨")}function IT(s){s.modal={open:e=>{s.dispatch({handler:"openModal",target:e})},close:e=>{s.dispatch({handler:"closeModal",...e&&{target:e}})},closeAll:()=>{s.dispatch({handler:"closeAllModals"})},isOpen:e=>{const n=s.state.get();return n._global?.activeModal===e||n._global?.modalStack?.includes(e)||!1},getStack:()=>s.state.get()._global?.modalStack||[]},be.log("전역 객체 window.G7Core.modal에 노출됨")}function jT(s){s.style={mergeClasses:ST,conditionalClass:wT,joinClasses:CT},be.log("전역 객체 window.G7Core.style에 노출됨")}function HT(s,e){const{webSocketManager:n}=e;s.websocket={manager:n,subscribe:(r,i,l,c)=>n.subscribe(r,i,l,c),unsubscribe:r=>n.unsubscribe(r),leaveChannel:r=>n.leaveChannel(r),disconnect:()=>n.disconnect(),isInitialized:()=>n.isInitialized(),getSubscriptionCount:()=>n.getSubscriptionCount()},be.log("전역 객체 window.G7Core.websocket에 노출됨")}function zT(s,e){const{transitionManager:n}=e;s.navigation={isPending:()=>n?.getIsPending?.()||!1,onComplete:r=>{if(!n)return r(),()=>{};let i=n.getIsPending();const l=n.subscribe(c=>{c?i=!0:i&&(r(),l())});return l}},be.log("전역 객체 window.G7Core.navigation에 노출됨")}function PT(s){s.plugin={getSettings:e=>window.G7Config?.plugins?.[e],get:(e,n,r)=>window.G7Config?.plugins?.[e]?.[n]??r,getAll:()=>window.G7Config?.plugins??{}},be.log("전역 객체 window.G7Core.plugin에 노출됨")}function UT(s){s.module={getSettings:e=>window.G7Config?.modules?.[e],get:(e,n,r)=>window.G7Config?.modules?.[e]?.[n]??r,getAll:()=>window.G7Config?.modules??{}},be.log("전역 객체 window.G7Core.module에 노출됨")}function BT(s,e){const{transitionManager:n,responsiveManager:r}=e;s.AuthManager=Xn,s.api=Yn(),s.TransitionManager=n,s.useTransitionState=Ay,s.ResponsiveManager=r,s.useResponsive=Mf,s.useControllableState=m_,s.shallowArrayEqual=y_,s.shallowObjectEqual=Ty,s.updateQueryParams=async(i,l)=>{const c=window.__templateApp;if(c?.updateQueryParams)return c.updateQueryParams(i,l);be.warn("G7Core.updateQueryParams: TemplateApp이 초기화되지 않았습니다.")},be.log("전역 객체 window.G7Core.AuthManager에 노출됨"),be.log("전역 객체 window.G7Core.api에 노출됨"),be.log("전역 객체 window.G7Core.ResponsiveManager에 노출됨"),be.log("전역 객체 window.G7Core.useResponsive에 노출됨"),be.log("전역 객체 window.G7Core.useControllableState에 노출됨"),be.log("전역 객체 window.G7Core.updateQueryParams에 노출됨")}function qT(s,e){s.getSlotContext=()=>window.__slotContextValue??null,s.getDynamicRenderer=()=>window.__DynamicRenderer??null,s.getComponentRegistry=()=>e.getComponentRegistry?.()??Ar.getInstance(),s.getDataBindingEngine=()=>e.getDataBindingEngine?.()??e.getState().bindingEngine,s.getTranslationEngine=()=>e.getTranslationEngine?.()??e.getState().translationEngine,s.getActionDispatcher=()=>e.getActionDispatcher?.()??e.getState().actionDispatcher,be.log("전역 객체 window.G7Core 슬롯 API에 노출됨 (getSlotContext, getDynamicRenderer 등)")}function GT(s){s.identity={setLauncher:At.setLauncher.bind(At),handle:At.handle.bind(At),isIdentityRequired:At.isIdentityRequired.bind(At),hasLauncher:At.hasLauncher.bind(At),markDomainNoticeShown:At.markDomainNoticeShown.bind(At),redirectExternally:At.redirectExternally.bind(At),createDeferred:At.createDeferred.bind(At),resolveDeferred:At.resolveDeferred.bind(At),reset:At.reset.bind(At),redirectStashKey:_f},be.log("전역 객체 window.G7Core 본인인증(IDV) API에 노출됨 (identity)")}function FT(s){if(typeof window>"u")return;ET(),window.G7Core||(window.G7Core={});const e=window.G7Core;AT(e),_T(e),xT(e),BT(e,s),TT(e),kT(e,s),RT(e,s),DT(e),LT(e),$T(e),MT(e,s),NT(e),IT(e),jT(e),HT(e,s),zT(e,s),PT(e),UT(e),qT(e,s),GT(e),be.log("G7Core 전역 객체 초기화 완료")}function VT(){const s=window.G7Core;if(!s){be.warn("G7Core가 초기화되지 않았습니다.");return}const e=()=>Ha.getInstance(),n={isEnabled:()=>{try{return e().isEnabled()}catch{return!1}},trackRender:r=>{try{e().isEnabled()&&e().trackRender(r)}catch{}},trackIteration:(r,i,l,c,d)=>{try{e().isEnabled()&&e().trackIteration(r,{source:i,itemVar:l,indexVar:c,sourceLength:d})}catch{}},trackIfCondition:(r,i,l,c)=>{try{e().isEnabled()&&e().trackIfCondition(r,i,l)}catch{}},trackMount:(r,i)=>{try{e().isEnabled()&&e().trackMount(r,{...i,id:r})}catch{}},trackUnmount:r=>{try{e().isEnabled()&&e().trackUnmount(r)}catch{}},trackExpressionEval:r=>{try{e().isEnabled()&&e().trackExpressionEval(r)}catch{}},trackBindingEval:r=>{try{e().isEnabled()&&e().trackBindingEval(r)}catch{}},recordCacheHit:()=>{try{e().isEnabled()&&e().recordCacheHit()}catch{}},recordCacheMiss:()=>{try{e().isEnabled()&&e().recordCacheMiss()}catch{}},trackHandlerRegistration:(r,i,l,c)=>{try{e().isEnabled()&&e().trackHandlerRegistration(r,i,l,c)}catch{}},trackHandlerUnregistration:r=>{try{e().isEnabled()&&e().trackHandlerUnregistration(r)}catch{}},logAction:r=>{try{e().isEnabled()&&e().logAction(r)}catch{}},trackRequest:(r,i)=>{try{return e().isEnabled()?e().trackRequest(r,i):""}catch{return""}},completeRequest:(r,i,l)=>{try{e().isEnabled()&&e().completeRequest(r,i,l)}catch{}},failRequest:(r,i)=>{try{e().isEnabled()&&e().failRequest(r,i)}catch{}},trackDataSourceDefinition:r=>{try{e().isEnabled()&&e().trackDataSourceDefinition(r)}catch{}},trackDataSourceLoading:r=>{try{e().isEnabled()&&e().trackDataSourceLoading(r)}catch{}},trackDataSourceLoaded:(r,i,l)=>{try{e().isEnabled()&&e().trackDataSourceLoaded(r,i,l)}catch{}},trackDataSourceError:(r,i)=>{try{e().isEnabled()&&e().trackDataSourceError(r,i)}catch{}},trackForm:(r,i,l)=>{try{e().isEnabled()&&e().trackForm(r,i,l)}catch{}},untrackForm:r=>{try{e().isEnabled()&&e().untrackForm(r)}catch{}},startStateChange:(r,i,l,c)=>{try{return e().isEnabled()?e().startStateChange(r,i,l,c):""}catch{return""}},completeStateChange:r=>{try{e().isEnabled()&&e().completeStateChange(r)}catch{}},trackComponentRender:(r,i,l,c,d,f)=>{try{e().isEnabled()&&e().trackComponentRender(r,i,l,c,d,f)}catch{}},updateLocalState:r=>{try{e().isEnabled()&&e().updateLocalState(r)}catch{}},updateComputedState:r=>{try{e().isEnabled()&&e().updateComputedState(r)}catch{}},updateParentContext:r=>{try{e().isEnabled()&&e().updateParentContext(r)}catch{}},trackComponentStateSource:(r,i,l,c)=>{try{e().isEnabled()&&e().trackComponentStateSource(r,i,l,c)}catch{}},trackDynamicState:(r,i)=>{try{e().isEnabled()&&e().trackDynamicState(r,i)}catch{}},trackContextFlow:(r,i,l,c,d,f)=>{try{e().isEnabled()&&e().trackContextFlow(r,i,l,c,d,f)}catch{}},trackComponentStyle:(r,i,l,c)=>{try{e().isEnabled()&&e().trackComponentStyle(r,i,l,c)}catch{}},trackAuthEvent:(r,i,l,c)=>{try{e().isEnabled()&&e().trackAuthEvent(r,i,l,c)}catch{}},trackAuthHeader:(r,i,l,c,d)=>{try{e().isEnabled()&&e().trackAuthHeader(r,i,l,c,d)}catch{}},trackLog:(r,i,l)=>{try{e().isEnabled()&&e().trackLog(r,i,l)}catch{}},trackAction:r=>{try{e().isEnabled()&&e().trackAction?.(r)}catch{}},trackDataSourceUpdate:r=>{try{e().isEnabled()&&e().trackDataSourceUpdate?.(r)}catch{}},startSequenceExecution:r=>{try{return e().isEnabled()?e().startSequenceExecution(r):""}catch{return""}},captureSequenceActionBefore:(r,i,l,c,d)=>{try{e().isEnabled()&&e().captureSequenceActionBefore(r,i,l,c,d)}catch{}},captureSequenceActionAfter:(r,i,l,c,d,f)=>{try{e().isEnabled()&&e().captureSequenceActionAfter(r,i,l,c,d,f)}catch{}},endSequenceExecution:(r,i)=>{try{e().isEnabled()&&e().endSequenceExecution(r,i)}catch{}},registerStateCaptureForHandler:(r,i,l)=>{try{e().isEnabled()&&e().registerStateCaptureForHandler(r,i,l)}catch{}},detectStaleClosure:(r,i,l,c,d)=>{try{return e().isEnabled()?e().detectStaleClosure(r,i,l,c,d):[]}catch{return[]}},trackStaleClosureWarning:r=>{try{e().isEnabled()&&e().trackStaleClosureWarning(r)}catch{}},trackModalOpen:r=>{try{e().isEnabled()&&e().trackModalOpen(r)}catch{}},trackModalClose:(r,i)=>{try{e().isEnabled()&&e().trackModalClose(r,i)}catch{}},trackModalStateChange:r=>{try{e().isEnabled()&&e().trackModalStateChange(r)}catch{}},trackNestedContext:r=>{try{return e().isEnabled()?e().trackNestedContext(r):""}catch{return""}},trackNestedContextAccess:(r,i)=>{try{e().isEnabled()&&e().trackNestedContextAccess(r,i)}catch{}},trackComputedProperty:(r,i,l,c,d,f,h)=>{try{e().isEnabled()&&e().trackComputedProperty(r,i,l,c,d,f,h)}catch{}},trackComputedRecalc:(r,i,l,c,d,f,h)=>{try{e().isEnabled()&&e().trackComputedRecalc(r,i,l,c,d,f,h)}catch{}},setNamedActionDefinitions:r=>{try{e().isEnabled()&&e().setNamedActionDefinitions(r)}catch{}},trackNamedActionRef:r=>{try{e().isEnabled()&&e().trackNamedActionRef(r)}catch{}}};s.devTools=n,be.log("G7Core.devTools 인터페이스 초기화 완료")}let Jo=null;function KT(){const s=window.G7Core;return s?.__devtools?Promise.resolve(s.__devtools):Jo||(Jo=new Promise((e,n)=>{const r=window.G7Config?.coreDevToolsAsset||"/build/core/devtools.min.js",i="g7-devtools-bundle",l=()=>{const f=window.G7Core?.__devtools;f?e(f):n(new Error("DevTools 번들 로드됨 — 그러나 __devtools 미노출"))};window.G7Core=window.G7Core||{},window.G7Core.__onDevToolsReady=l;const c=document.getElementById(i);if(c){c.addEventListener("load",l,{once:!0}),c.addEventListener("error",()=>n(new Error(`DevTools 번들 로드 실패: ${r}`)),{once:!0});return}const d=document.createElement("script");d.id=i,d.src=r,d.async=!1,d.addEventListener("load",l,{once:!0}),d.addEventListener("error",()=>{Jo=null,n(new Error(`DevTools 번들 로드 실패: ${r}`))},{once:!0}),document.head.appendChild(d)}),Jo)}function WT(){const s=window.G7Core;if(!s){be.warn("G7Core가 초기화되지 않았습니다.");return}const e=Ha.getInstance();if(e.initialize(),!e.isEnabled()){window.G7DevTools={isEnabled:()=>!1,enable:()=>{be.log("환경설정 > 고급 설정 > 디버그 모드를 켜세요")}},Ld(),be.log("G7DevTools 비활성화됨 (디버그 모드 꺼짐)");return}YT(s,e)}async function YT(s,e){let n;try{n=await KT()}catch(h){be.warn("DevTools 번들 로드 실패 — 최소 API 로 폴백:",h),window.G7DevTools={isEnabled:()=>!1,enable:()=>{}},Ld();return}const{DiagnosticEngine:r,getServerConnector:i,getStyleTracker:l}=n;VT(),Ld();try{l().enable(),be.log("StyleTracker 활성화됨")}catch(h){be.warn("StyleTracker 활성화 실패:",h)}const c=new r,d=i(),f={isEnabled:()=>e.isEnabled(),state:{get:()=>e.getState(),getHistory:()=>e.getStateHistory(),watch:(h,m)=>e.watchState(h,m)},actions:{getHistory:()=>e.getActionHistory(),watch:h=>e.watchActions(h),getMetrics:()=>e.getActionMetrics()},binding:{evaluate:h=>{const m=s.getDataBindingEngine?.();if(!m){be.warn("DataBindingEngine이 없습니다.");return}return m.evaluateExpression(h,e.getState())},getCacheStats:()=>e.getCacheStats(),clearStats:()=>{e.resetCacheStats(),be.log("캐시 통계 초기화됨")}},diagnose:{analyze:h=>c.analyze(h),suggestFix:h=>c.suggestFix(h),getCommonIssues:()=>c.getCommonIssues(),getRulesByCategory:h=>c.getRulesByCategory(h)},server:{dumpState:h=>d.dumpState(h),sendLog:h=>d.sendLog(h),sendError:(h,m)=>d.sendError(h,m),isConnected:()=>d.isConnected(),testConnection:()=>d.testConnection()},config:{isDebugMode:()=>e.isEnabled(),setLogLevel:h=>e.setLogLevel(h),setMaxHistory:h=>e.setMaxHistory(h)},lifecycle:{getMountedComponents:()=>e.getLifecycleInfo().mountedComponents,getOrphanedListeners:()=>e.getLifecycleInfo().orphanedListeners},performance:{getRenderCount:()=>e.getPerformanceInfo().renderCounts,getBindingEvalCount:()=>e.getPerformanceInfo().bindingEvalCount,getMemoryWarnings:()=>e.getPerformanceInfo().memoryWarnings,startProfiling:()=>e.startProfiling(),stopProfiling:()=>e.stopProfiling()},network:{getActiveRequests:()=>e.getNetworkInfo().activeRequests,getRequestHistory:()=>e.getNetworkInfo().requestHistory,getPendingDataSources:()=>e.getNetworkInfo().pendingDataSources},conditional:{getIfConditions:()=>e.getConditionalInfo().ifConditions,getIterations:()=>e.getConditionalInfo().iterations},form:{getForms:()=>e.getFormInfo()},websocket:{getInfo:()=>e.getWebSocketInfo()}};window.G7DevTools=f,s.devtools=f,be.log("G7DevTools 전역 객체 초기화 완료 (window.G7DevTools)"),XT(n.DevToolsPanel)}function XT(s){if(document.getElementById("g7-devtools-root")){be.log("DevToolsPanel 이미 렌더링됨");return}const e=document.createElement("div");e.id="g7-devtools-root",document.body.appendChild(e);try{Dd.createRoot(e).render(Xe.createElement(s)),be.log("DevToolsPanel UI 렌더링 완료")}catch(n){be.error("DevToolsPanel UI 렌더링 실패:",n)}}const Je=pt("TemplateEngine"),ae={templateId:null,locale:"ko",isInitialized:!1,reactRoot:null,containerId:null,currentLayoutJson:null,currentDataContext:{},translationContext:{templateId:"",locale:"ko"},registry:null,bindingEngine:null,translationEngine:null,actionDispatcher:null,templateMetadata:null};let Qo=!1;const Zo=[];async function JT(s){try{Je.log("템플릿 메타데이터 로드 중...",s);const e=s.split("-").map(r=>r.split("_").map(i=>i.charAt(0).toUpperCase()+i.slice(1)).join("")).join(""),n=window[e];return n?.templateMetadata?(Je.log("템플릿 메타데이터 로드 완료 (전역 변수)",n.templateMetadata),n.templateMetadata):(Je.warn(`템플릿 번들에 메타데이터가 없습니다. 전역 변수: ${e}`),{identifier:s,locales:["ko","en"],name:{ko:s,en:s},description:{ko:"",en:""},version:"1.0.0",type:"admin"})}catch(e){return Je.error("템플릿 메타데이터 로드 실패",e),{identifier:s,locales:["ko","en"],name:{ko:s,en:s},description:{ko:"",en:""},version:"1.0.0",type:"admin"}}}function Hb(){const e=(typeof window<"u"?window.__templateApp:void 0)?.globalState?.appConfig?.supportedLocales,n=ae.templateMetadata?.locales;return{$locale:ae.locale,$locales:Array.isArray(e)&&e.length>0?e:n||["ko","en"],$templateLocales:n||["ko","en"],$templateId:ae.templateId}}async function el(s){try{if(Je.log("템플릿 엔진 초기화 시작",s),ae.isInitialized)throw new Error("템플릿 엔진이 이미 초기화되었습니다. destroyTemplate()을 먼저 호출하세요.");if(!s.templateId)throw new Fx;Qo=s.debug??!1,typeof window<"u"&&(window.G7Config||(window.G7Config={}),window.G7Config.debug=Qo),WT(),ae.templateId=s.templateId,ae.locale=s.locale||"ko",Je.log("엔진 인스턴스 생성 중..."),ae.registry=Ar.getInstance(),ae.bindingEngine=new $n,ae.translationEngine=vi.getInstance(),s.cacheVersion!==void 0&&s.cacheVersion>0&&ae.translationEngine.setCacheVersion(s.cacheVersion),ae.translationContext={templateId:s.templateId,locale:ae.locale},ae.actionDispatcher=new jo({},ae.translationEngine,ae.translationContext),o_(ae.actionDispatcher),Je.log("다국어 파일 로드 중...",s.templateId,ae.locale);const e="en",n=[ae.translationEngine.loadTranslations(s.templateId,ae.locale).then(()=>{Je.log(`다국어 파일 로드 완료: ${ae.locale}`)}).catch(r=>{Je.warn(`다국어 파일 로드 실패 (${ae.locale}):`,r instanceof Error?r.message:r)})];ae.locale!==e&&n.push(ae.translationEngine.loadTranslations(s.templateId,e).then(()=>{Je.log(`폴백 다국어 파일 로드 완료: ${e}`)}).catch(r=>{Je.warn(`폴백 다국어 파일 로드 실패 (${e}):`,r instanceof Error?r.message:r)})),await Promise.allSettled(n),Je.log("템플릿 메타데이터 로드 중...",s.templateId),ae.templateMetadata=await JT(s.templateId),ae.isInitialized=!0,Je.log("템플릿 엔진 초기화 완료 (ComponentRegistry는 별도 로드)")}catch(e){throw Je.error("템플릿 엔진 초기화 실패",e),ae.isInitialized=!1,ae.registry=null,ae.bindingEngine=null,ae.translationEngine=null,ae.actionDispatcher=null,e}}let ks=null;const zb="g7-layout-editor-bundle";function ph(){const s=window.G7Core;return s?.__LayoutEditorChrome?Promise.resolve(s.__LayoutEditorChrome):ks||(ks=(async()=>{const e=window.G7Config?.coreEditorAsset||"/build/core/layout-editor.min.js";document.getElementById(zb)?.remove(),window.G7Core=window.G7Core||{},window.G7Core.__onChromeReady=()=>{};try{await _r(e,{id:zb},{label:"layout-editor bundle"})}catch(r){throw ks=null,Je.error(`편집기 번들 로드 실패 (${e})`,r),new Error("편집기를 불러오지 못했습니다. 네트워크 상태를 확인한 뒤 다시 시도해 주세요.")}const n=window.G7Core?.__LayoutEditorChrome;if(!n)throw ks=null,Je.error(`편집기 번들 로드됨 — 그러나 __LayoutEditorChrome 미노출 (${e})`),new Error("편집기를 불러왔으나 초기화하지 못했습니다. 페이지를 새로고침해 주세요.");return n})(),ks)}async function Rs(s){try{if(Je.log("템플릿 렌더링 시작",s),!ae.isInitialized)throw new Error("템플릿 엔진이 초기화되지 않았습니다. initTemplateEngine()을 먼저 호출하세요.");if(!s.containerId)throw new Error("containerId는 필수입니다.");if(!s.layoutJson)throw new Error("layoutJson은 필수입니다.");const e=document.getElementById(s.containerId);if(!e)throw new Error(`컨테이너를 찾을 수 없습니다: #${s.containerId}`);const n=Hb();if(ae.containerId=s.containerId,ae.currentLayoutJson=s.layoutJson,ae.currentDataContext={...n,...s.dataContext||{}},ae.translationContext=s.translationContext||{templateId:ae.templateId||"",locale:ae.locale},ae.reactRoot||(Je.log("React Root 생성"),ae.reactRoot=Dd.createRoot(e)),typeof window<"u"){const l=ch(window.location.pathname);if(l){Je.log("레이아웃 편집기 모드 진입",l);let c;try{c=await ph()}catch(f){Je.error("레이아웃 편집기 번들 로드 실패",f),lh.render(s.containerId,{title:"레이아웃 편집기 로드 실패",message:f instanceof Error?f.message:"편집기 번들을 불러오지 못했습니다.",icon:"fas fa-triangle-exclamation",showStack:!1,showReloadButton:!0,debug:Qo});return}const d=Xe.createElement(c,{templateIdentifier:l.templateIdentifier,initialLocale:ae.locale});ae.reactRoot.render(Xe.createElement(Pc,{translationEngine:ae.translationEngine,translationContext:ae.translationContext,children:Xe.createElement(Of,{children:Xe.createElement(xc,{children:Xe.createElement(rh,{children:d})})})}));return}}const r=s.layoutJson.components||[];if(r.length===0){Je.warn("렌더링할 컴포넌트가 없습니다.");return}const i=s.layoutJson.modals||[];if(Je.log("modals 배열:",i),Je.log("modals 개수:",i.length),Je.log("DynamicRenderer로 렌더링 시작"),ae.reactRoot.render(Xe.createElement(Pc,{translationEngine:ae.translationEngine,translationContext:ae.translationContext},Xe.createElement(Of,null,Xe.createElement(xc,null,Xe.createElement(rh,null,[...r.map((l,c)=>{const d=ae.currentLayoutJson?.layout_name||"";return Xe.createElement(Vr,{key:d&&!l._fromBase?`${l.id}_${d}`:l.id,componentDef:l,dataContext:ae.currentDataContext,translationContext:ae.translationContext,registry:ae.registry,bindingEngine:ae.bindingEngine,translationEngine:ae.translationEngine,actionDispatcher:ae.actionDispatcher,isRootRenderer:c===0,layoutKey:d})}),Xe.createElement(yy,{key:"__modal_parent_context_provider"},i.map(l=>{const c=ae.currentDataContext._global?.modalStack||[],f=c.includes(l.id)||ae.currentDataContext._global?.activeModal===l.id,h=c.indexOf(l.id),m=h>=0?50+h:50,y=window.__g7LayoutContextStack||[],S=y[y.length-1]?.dataContext,_=Xe.createElement(Vr,{key:`modal_${l.id}_renderer`,componentDef:{...l,props:{...l.props,isOpen:f,style:{...l.props?.style,zIndex:m},onClose:ae.actionDispatcher?.createHandler({type:"click",handler:"closeModal"},ae.currentDataContext)}},dataContext:ae.currentDataContext,translationContext:ae.translationContext,registry:ae.registry,bindingEngine:ae.bindingEngine,translationEngine:ae.translationEngine,actionDispatcher:ae.actionDispatcher,parentDataContext:S});return l.data_sources&&l.data_sources.length>0?Xe.createElement(Tb,{key:`modal_${l.id}`,isOpen:f,modalId:l.id,dataSources:l.data_sources,dataContext:ae.currentDataContext,globalStateUpdater:ae.actionDispatcher?.getGlobalStateUpdater(),bindingEngine:ae.bindingEngine,debug:Qo,children:_}):_}))]))))),Je.log("템플릿 렌더링 완료"),Zo.length>0){Je.log(`대기 중인 데이터 업데이트 ${Zo.length}건 적용`);const l=[...Zo];Zo.length=0;for(const{data:c,options:d}of l)Ds(c,d)}}catch(e){throw Je.error("템플릿 렌더링 실패",e),e}}function Ds(s,e){try{if(Je.log("템플릿 데이터 업데이트 시작",Object.keys(s)),!ae.isInitialized)throw new Error("템플릿 엔진이 초기화되지 않았습니다.");if(!ae.reactRoot||!ae.currentLayoutJson){Je.log("React 미준비 - 데이터 업데이트 큐잉:",Object.keys(s)),Zo.push({data:s,options:e});return}const n=Hb(),r={...ae.currentDataContext._global||{},...s._global||{}},i=p_(ae.currentDataContext._localInit,s._localInit);if(ae.currentDataContext={...n,...ae.currentDataContext,...s,_global:r,_localInit:i},r._local!==void 0&&(ae.currentDataContext._local=r._local),r._computed!==void 0&&(ae.currentDataContext._computed=r._computed),typeof window<"u"&&ch(window.location.pathname)){Je.log("레이아웃 편집기 모드 — 재렌더 건너뜀 (편집기 트리 보존)");return}const l=ae.currentLayoutJson.components||[],c=ae.currentLayoutJson.modals||[];Je.log("updateTemplateData - modals 배열:",c),Je.log("updateTemplateData - modals 개수:",c.length),Je.log("updateTemplateData - activeModal:",ae.currentDataContext._global?.activeModal);const d=()=>{ae.reactRoot.render(Xe.createElement(Pc,{translationEngine:ae.translationEngine,translationContext:ae.translationContext},Xe.createElement(Of,null,Xe.createElement(xc,null,Xe.createElement(rh,null,[...l.map((f,h)=>{const m=ae.currentLayoutJson?.layout_name||"";return Xe.createElement(Vr,{key:m&&!f._fromBase?`${f.id}_${m}`:f.id,componentDef:f,dataContext:ae.currentDataContext,translationContext:ae.translationContext,registry:ae.registry,bindingEngine:ae.bindingEngine,translationEngine:ae.translationEngine,actionDispatcher:ae.actionDispatcher,isRootRenderer:h===0,layoutKey:m})}),Xe.createElement(yy,{key:"__modal_parent_context_provider_update"},c.map(f=>{const h=ae.currentDataContext._global?.modalStack||[],y=h.includes(f.id)||ae.currentDataContext._global?.activeModal===f.id,v=h.indexOf(f.id),S=v>=0?50+v:50,_=window.__g7LayoutContextStack||[],A=_[_.length-1]?.dataContext,D=Xe.createElement(Vr,{key:`modal_${f.id}_renderer`,componentDef:{...f,props:{...f.props,isOpen:y,style:{...f.props?.style,zIndex:S},onClose:ae.actionDispatcher?.createHandler({type:"click",handler:"closeModal"},ae.currentDataContext)}},dataContext:ae.currentDataContext,translationContext:ae.translationContext,registry:ae.registry,bindingEngine:ae.bindingEngine,translationEngine:ae.translationEngine,actionDispatcher:ae.actionDispatcher,parentDataContext:A});return f.data_sources&&f.data_sources.length>0?Xe.createElement(Tb,{key:`modal_${f.id}`,isOpen:y,modalId:f.id,dataSources:f.data_sources,dataContext:ae.currentDataContext,globalStateUpdater:ae.actionDispatcher?.getGlobalStateUpdater(),bindingEngine:ae.bindingEngine,debug:Qo,children:D}):D}))])))))};e?.sync?(Je.log("재렌더링 시작 (sync mode - 즉시 렌더링)"),d()):(Je.log("재렌더링 시작 (with startTransition)"),N.startTransition(()=>{d()})),Je.log("템플릿 데이터 업데이트 완료")}catch(n){throw Je.error("템플릿 데이터 업데이트 실패",n),n}}function Yc(){try{Je.log("템플릿 정리 시작"),ae.reactRoot&&(Je.log("React Root 언마운트"),ae.reactRoot.unmount(),ae.reactRoot=null),ae.templateId=null,ae.locale="ko",ae.isInitialized=!1,ae.containerId=null,ae.currentLayoutJson=null,ae.currentDataContext={},ae.translationContext={templateId:"",locale:"ko"},ae.registry=null,ae.bindingEngine=null,ae.translationEngine=null,ae.actionDispatcher=null,ae.templateMetadata=null,Je.log("템플릿 정리 완료")}catch(s){throw Je.error("템플릿 정리 실패",s),s}}function la(){return Object.freeze({...ae})}function Pb(){return ae.actionDispatcher}const tl={initTemplateEngine:el,renderTemplate:Rs,updateTemplateData:Ds,destroyTemplate:Yc,getState:la};typeof window<"u"&&(window.G7Core||(window.G7Core={}),window.G7Core.TemplateEngine=tl,FT({getState:()=>({translationEngine:ae.translationEngine,translationContext:ae.translationContext,bindingEngine:ae.bindingEngine,actionDispatcher:ae.actionDispatcher,templateMetadata:ae.templateMetadata}),transitionManager:Gr,responsiveManager:Ci,webSocketManager:qc}),Je.log("전역 객체 window.G7Core.TemplateEngine에 노출됨"));const Wr=Object.freeze(Object.defineProperty({__proto__:null,DataSourceManager:Or,LayoutLoader:th,TemplateApp:Yo,TemplateEngine:tl,default:tl,destroyTemplate:Yc,getActionDispatcher:Pb,getState:la,initTemplateApp:hh,initTemplateEngine:el,loadLayoutEditorBundle:ph,renderTemplate:Rs,updateTemplateData:Ds},Symbol.toStringTag,{value:"Module"}));tn.DataSourceManager=Or,tn.LayoutLoader=th,tn.TemplateApp=Yo,tn.TemplateEngine=tl,tn.default=tl,tn.destroyTemplate=Yc,tn.getActionDispatcher=Pb,tn.getState=la,tn.initTemplateApp=hh,tn.initTemplateEngine=el,tn.loadLayoutEditorBundle=ph,tn.renderTemplate=Rs,tn.updateTemplateData=Ds,Object.defineProperties(tn,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})})(this.G7Core=this.G7Core||{}); diff --git a/resources/js/core/__tests__/template-engine.layoutEditorRerender.test.tsx b/resources/js/core/__tests__/template-engine.layoutEditorRerender.test.tsx new file mode 100644 index 00000000..982cb486 --- /dev/null +++ b/resources/js/core/__tests__/template-engine.layoutEditorRerender.test.tsx @@ -0,0 +1,190 @@ +/** + * template-engine.ts — 레이아웃 편집기 모드 재렌더 보호 회귀 테스트 + * + * 결함: 편집기 모드에서 `TemplateApp.init` 은 `renderTemplate({ layoutJson: { components: [] } })` + * 로 부르고, `renderTemplate` 의 편집기 분기가 그 빈 배열 대신 `LayoutEditorChrome` 을 렌더한다. + * 그런데 `updateTemplateData` 에는 그 분기가 없어 `state.currentLayoutJson.components`(= 빈 배열) + * 로 **같은 reactRoot 에 두 번째 render** 를 걸었고, React 가 그 커밋에서 편집기 트리를 통째로 + * 제거해 화면이 백지가 됐다. + * + * 예외도 콘솔 오류도 남지 않는다 — 편집기가 잠깐 보였다가 사라지는 것이 유일한 증상이며, + * `renderTemplate` 의 편집기 분기가 비동기(`loadLayoutEditorBundle`)라 부팅 중 `setGlobalState` + * 가 그 커밋 뒤에 도착할 때만 발현하는 **경합**이라 간헐적으로 보인다. + * + * 브라우저 실측(2026-09-08): `app-children-up 1` (668ms) → `APP-EMPTIED removed=1` (704ms), + * 제거 스택은 `init` → startTransition → React commit. `destroyTemplate` 은 호출되지 않았다. + */ + +import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'; +import { act } from '@testing-library/react'; +import React from 'react'; +import { + initTemplateEngine, + renderTemplate, + updateTemplateData, + destroyTemplate, +} from '../template-engine'; + +const flushReactScheduler = async (): Promise => { + await act(async () => { + await new Promise((resolve) => setTimeout(resolve, 0)); + }); +}; + +vi.mock('../template-engine/ComponentRegistry', () => { + const mockInstance = { + loadComponents: vi.fn().mockResolvedValue(undefined), + getComponent: vi.fn().mockReturnValue(() => null), + hasComponent: vi.fn().mockReturnValue(true), + getInstance: vi.fn(), + }; + mockInstance.getInstance.mockReturnValue(mockInstance); + return { ComponentRegistry: { getInstance: vi.fn(() => mockInstance) } }; +}); + +vi.mock('../template-engine/DataBindingEngine', () => { + const DataBindingEngine = vi.fn(function (this: any) { + this.bind = vi.fn(); + this.unbind = vi.fn(); + this.invalidateCacheByKeys = vi.fn(); + }); + return { DataBindingEngine, dataBindingEngine: new (DataBindingEngine as any)() }; +}); + +vi.mock('../template-engine/TranslationEngine', () => { + const mockInstance = { + translate: vi.fn((key: string) => key), + setLocale: vi.fn(), + loadTranslations: vi.fn().mockResolvedValue({}), + resolveTranslations: vi.fn((text: string) => text), + clearCache: vi.fn(), + }; + return { + TranslationEngine: { getInstance: vi.fn(() => mockInstance), resetInstance: vi.fn() }, + TranslationContext: {} as any, + }; +}); + +vi.mock('../template-engine/ActionDispatcher', () => ({ + ActionDispatcher: vi.fn(function (this: any) { + this.dispatch = vi.fn(); + this.register = vi.fn(); + this.createHandler = vi.fn(() => vi.fn()); + }), + setActionDispatcherInstance: vi.fn(), + getActionDispatcher: vi.fn(() => ({ dispatch: vi.fn(), register: vi.fn() })), +})); + +vi.mock('../template-engine/DynamicRenderer', () => ({ default: vi.fn(() => null) })); + +vi.mock('../template-engine/ResponsiveManager', () => ({ + responsiveManager: { + getWidth: vi.fn(() => 1024), + subscribe: vi.fn(() => () => {}), + getMatchingKey: vi.fn(() => null), + parseRange: vi.fn(() => null), + }, + BREAKPOINT_PRESETS: {}, +})); + +vi.mock('../template-engine/ResponsiveContext', () => ({ + ResponsiveContext: {}, + ResponsiveProvider: ({ children }: { children: React.ReactNode }) => children, + useResponsive: vi.fn(() => ({ + width: 1024, + isMobile: false, + isTablet: false, + isDesktop: true, + matchedPreset: 'desktop', + })), +})); + +const EDITOR_PATH = '/admin/layout-editor/sirsoft-basic'; + +/** 편집기 lazy 번들 stub — `loadLayoutEditorBundle` 이 즉시 반환하는 경로를 탄다. */ +function EditorChromeStub(): React.ReactElement { + return React.createElement('div', { 'data-testid': 'editor-chrome' }, 'EDITOR'); +} + +describe('[case:state-advanced-editor-blank] template-engine — 레이아웃 편집기 모드 재렌더 보호', () => { + let container: HTMLDivElement; + + beforeEach(async () => { + destroyTemplate(); + vi.clearAllMocks(); + + container = document.createElement('div'); + container.id = 'app'; + document.body.appendChild(container); + + // `loadLayoutEditorBundle` 은 `G7Core.__LayoutEditorChrome` 이 있으면 즉시 resolve 한다. + (window as any).G7Core = { ...(window as any).G7Core, __LayoutEditorChrome: EditorChromeStub }; + + window.history.replaceState({}, '', EDITOR_PATH); + + await initTemplateEngine({ templateId: 'sirsoft-admin_basic', locale: 'ko' }); + }); + + afterEach(async () => { + destroyTemplate(); + await flushReactScheduler(); + container.remove(); + delete (window as any).G7Core.__LayoutEditorChrome; + window.history.replaceState({}, '', '/'); + }); + + it('편집기 렌더 후 updateTemplateData 가 들어와도 편집기 트리가 지워지지 않는다', async () => { + // TemplateApp.init 이 편집기 모드에서 넘기는 것과 동일한 빈 레이아웃 + await act(async () => { + await renderTemplate({ + containerId: 'app', + layoutJson: { components: [] } as any, + dataContext: {}, + translationContext: { templateId: 'sirsoft-admin_basic', locale: 'ko' }, + }); + }); + await flushReactScheduler(); + + expect( + container.querySelector('[data-testid="editor-chrome"]'), + '편집기 분기가 LayoutEditorChrome 을 렌더해야 한다(사전 조건)', + ).not.toBeNull(); + + // 부팅 중 setGlobalState → updateTemplateData 가 도착하는 상황 + await act(async () => { + updateTemplateData({ _global: { sidebarOpen: false } }); + }); + await flushReactScheduler(); + + expect( + container.querySelector('[data-testid="editor-chrome"]'), + 'updateTemplateData 재렌더가 편집기 트리를 제거하면 안 된다(백지 회귀)', + ).not.toBeNull(); + expect(container.childElementCount, '#app 이 비어서는 안 된다').toBeGreaterThan(0); + }); + + it('편집기 모드가 아니면 updateTemplateData 재렌더가 종전대로 동작한다 (회귀 가드)', async () => { + window.history.replaceState({}, '', '/admin/dashboard'); + + await act(async () => { + await renderTemplate({ + containerId: 'app', + layoutJson: { components: [{ type: 'basic', name: 'Div' }] } as any, + dataContext: {}, + translationContext: { templateId: 'sirsoft-admin_basic', locale: 'ko' }, + }); + }); + await flushReactScheduler(); + + // DynamicRenderer 가 null 을 반환하는 mock 이라 DOM 노드는 없지만, + // 편집기 stub 이 렌더되지 않았다는 것이 이 케이스의 핵심이다. + expect(container.querySelector('[data-testid="editor-chrome"]')).toBeNull(); + + await act(async () => { + updateTemplateData({ _global: { x: 1 } }); + }); + await flushReactScheduler(); + + expect(container.querySelector('[data-testid="editor-chrome"]')).toBeNull(); + }); +}); diff --git a/resources/js/core/template-engine.ts b/resources/js/core/template-engine.ts index eda5b9ec..29f84b3a 100644 --- a/resources/js/core/template-engine.ts +++ b/resources/js/core/template-engine.ts @@ -777,6 +777,23 @@ function updateTemplateData(data: Record, options?: UpdateOptions): state.currentDataContext._computed = mergedGlobalState._computed; } + // 레이아웃 편집기 모드 — 재렌더 금지 (renderTemplate 의 편집기 분기와 대칭). + // + // 편집기 모드에서 `TemplateApp.init` 은 `renderTemplate({ layoutJson: { components: [] } })` + // 으로 부르고, renderTemplate 의 편집기 분기가 그 빈 배열 대신 LayoutEditorChrome 을 + // 같은 reactRoot 에 렌더한다. 그래서 `state.currentLayoutJson.components` 는 **빈 배열**이다. + // 여기서 그대로 재렌더하면 같은 루트에 빈 트리를 커밋해 편집기를 통째로 제거한다 — 화면이 + // 백지가 되고 예외도 콘솔 오류도 남지 않는다. + // + // renderTemplate 의 편집기 분기는 비동기(`loadLayoutEditorBundle`)라, 부팅 중 도착한 + // setGlobalState 한 번이 그 커밋 뒤에 실행되면 발현하는 **경합**이다(간헐 재현). + // 데이터 병합은 위에서 이미 끝났으므로 여기서는 렌더만 건너뛴다 — 편집기 트리는 + // 자기 상태를 스스로 관리하고 currentLayoutJson 에 의존하지 않는다. + if (typeof window !== 'undefined' && checkLayoutEditorMode(window.location.pathname)) { + logger.log('레이아웃 편집기 모드 — 재렌더 건너뜀 (편집기 트리 보존)'); + return; + } + const components = state.currentLayoutJson.components || []; const modals = state.currentLayoutJson.modals || []; logger.log('updateTemplateData - modals 배열:', modals); diff --git a/resources/js/core/template-engine/CHANGELOG.md b/resources/js/core/template-engine/CHANGELOG.md index 8cedf9ac..07edeb16 100644 --- a/resources/js/core/template-engine/CHANGELOG.md +++ b/resources/js/core/template-engine/CHANGELOG.md @@ -5,6 +5,43 @@ > > 형식: [Keep a Changelog](https://keepachangelog.com/ko/1.1.0/) +## [engine-v1.66.0] - 2026-09-08 + +### Added + +#### `number` 위젯 — 숫자 prop 편집 +- `number` 위젯을 코어 레지스트리에 등록 — 종전 미등록이라 `widget:"number"` 컨트롤이 속성 모달에서 「지원하지 않는 컨트롤」로 폴백해 편집 자체가 불가했다 (registerCoreWidgets.ts) +- `NumberWidget` 신설 — blur/Enter 커밋, `0` 은 유효값이라 삭제되지 않고, 비숫자는 미방출(저장본 무손실), 바인딩 문자열은 읽기전용 디그레이드 (StyleControlWidgets.tsx) +- `EditorControlSpec` 에 `min`/`max`/`step` 명시 선언 (specTypes.ts) + +#### `nodeKey` apply 프리미티브 — 노드 최상위 구조키 패치 +- `applyRecipe`/`reverseResolve` 에 `nodeKey` 분기 구현 — `coreProps` 가 선언만 하고 엔진 switch 에 case 가 없어 무음 no-op 이던 것을 실동작으로 (recipeEngine.ts) +- 예약 노드키(`children`/`props`/`type` 등) 가드 — 템플릿이 그 키를 선언해도 노드가 파괴되지 않는다 (recipeEngine.ts) +- 전용 UI 소유 키(`isolatedState`/`isolatedScopeId`)를 `resolveCorePropKeys` 렌더 목록에서 제외 — 같은 노드 키를 두 UI 가 쓰는 이중 경로 차단 (coreProps.ts) + +### Fixed + +#### `image` 위젯 값이 `[object Object]` 로 기록되던 문제 +- 단일 값 슬롯(`propValue`/`cssVar`/단일 `styleProp`)에 이미지 값 객체가 통째로 기록되던 문제 — 공용 헬퍼 `scalarizeImageValue` 로 url 만 축약한다. 게이트는 위젯 이름이며 값 형태 sniffing 이 아니다(`{position:'left'}` 같은 정당한 객체 prop 오인 삭제 방지) (recipeEngine.ts) +- 축약 저장된 문자열을 위젯이 읽지 못하던 문제 — `propValue` 역해석이 `{url}` 로 되감는다. 표현식 문자열도 감싸 빈 피커로 보이지 않게 한다 (recipeEngine.ts) +- 단일 값 슬롯 컨트롤에서 표시모드(채움/맞춤/타일) 버튼이 저장되지 않는데도 눌리던 문제 — 컨테이너째 미렌더하고 미리보기는 `contain` 으로 고정한다(저장되지 않는 값을 흉내내는 거짓 미리보기 제거) (ImagePickerControl.tsx) +- 데이터 연결 값이 빈 피커로 보여 업로드 1클릭에 표현식이 소실되던 문제 — 원문 배지 표시 + 파괴적 조작 잠금 + 「직접 지정으로 바꾸기」 해제 경로 (ImagePickerControl.tsx) + +#### 레이아웃 편집기가 열린 직후 백지가 되던 문제 +- 편집기 모드에서 `updateTemplateData` 가 빈 레이아웃(`components: []`)으로 재렌더해 같은 reactRoot 에 빈 트리를 커밋, `LayoutEditorChrome` 을 통째로 제거하던 문제 — 편집기 모드면 데이터 병합 후 렌더만 건너뛴다. `renderTemplate` 의 편집기 분기가 비동기라 부팅 중 `setGlobalState` 가 그 커밋 뒤에 도착할 때만 발현하는 경합이었다 (template-engine.ts) + +#### 데이터 연결 값이 조작 한 번에 소실되던 문제 +- prop 자리에 저장된 `{{...}}`·설정 참조를 위젯이 해석하지 못해 빈 컨트롤로 보이고, 조작 시 그 연결이 사라지던 문제 — `ControlRenderer` 단일 게이트에서 원문 배지로 디그레이드하고 「직접 지정으로 바꾸기」로만 연다. 위젯마다 구현하지 않으므로 신규 위젯에도 자동 적용된다 (ControlRenderer.tsx, boundValueGuard.tsx) +- 「직접 지정으로 바꾸기」가 편도라 원문을 되찾을 수 없던 문제 — 「되돌리기」 추가(해제 직후엔 취소, 값을 넣은 뒤엔 원문 복구) +- `image` 위젯에서 업로드·제거·썸네일만 잠기고 「이미지 관리」 진입이 열려 있어, 그 창의 「배경」 버튼이 같은 값을 덮어쓰던 문제 — 진입 자체를 함께 잠근다 (ImagePickerControl.tsx) +- `number` 위젯의 자체 바인딩 분기가 공용 해제 경로를 막던 문제 — 위젯 자체 분기를 제거하고 공용 게이트로 일원화 (StyleControlWidgets.tsx) + +#### 공통·확장 레이아웃 노드를 편집해도 저장되지 않던 문제 +- 라우트 편집 모드에서 상속(base)·주입(extension) 노드 중 바인딩을 가진 것이 `data_bound`(편집 허용)로 분류되던 문제 — 출처 잠금이 항상 우선하도록 판정 순서를 통일했다. 저장 시 마스킹이 그 노드를 통째로 폐기하므로 편집분이 오류도 경고도 없이 사라졌다 (useElementSelection.ts) +- 잠긴 노드의 드래그·인라인 편집·복제·`Delete` 키·잘라내기가 무방비이던 문제 — 단일 판정 헬퍼 `isEditableLockKind` 로 전 표면 게이트 (EditorCanvasOverlay.tsx, useCanvasDnd.ts, DndCanvasLayer.tsx) +- 거부된 드래그가 `activeDragPath` 를 남겨 「옮길 수 있다」는 거짓 어포던스를 주던 문제 (useCanvasDnd.ts) +- 조상 산출 구현이 두 벌로 갈라져 잠금 판정 입력이 어긋날 수 있던 문제 — `collectAncestors` 로 승격 (layoutTreeUtils.ts) + ## [engine-v1.65.0] - 2026-09-07 ### Added diff --git a/resources/js/core/template-engine/layout-editor/__tests__/components/ControlRenderer.boundValueGuard.test.tsx b/resources/js/core/template-engine/layout-editor/__tests__/components/ControlRenderer.boundValueGuard.test.tsx new file mode 100644 index 00000000..37b2304e --- /dev/null +++ b/resources/js/core/template-engine/layout-editor/__tests__/components/ControlRenderer.boundValueGuard.test.tsx @@ -0,0 +1,145 @@ +/** + * ControlRenderer.boundValueGuard.test.tsx — 데이터 연결 값 보호 **공용 게이트** + * + * 저장값이 `{{...}}`(또는 설정 참조)이면 위젯은 그 문자열을 해석하지 못해 **빈 컨트롤**로 + * 보이고, 운영자가 조작하는 순간 환경설정과의 연결이 소리 없이 끊긴다. 원문이 화면 어디에도 + * 남지 않아 되돌릴 수단조차 없다. + * + * 이 보호를 위젯마다 넣으면 한 곳이 빠져도 오류가 나지 않고 그 한 곳이 우회로가 된다 + * (공개 #135 후속 실측: 「이미지 관리」 진입 하나만 열려 있었다). 그래서 `ControlRenderer` + * 한 곳에서 걸고, 본 테스트가 **위젯 종류와 무관하게** 걸리는 것을 잠근다 — 새 위젯을 + * 등록해도 자동 적용된다는 계약이다. + * + * @effects bound_value_protection_is_a_single_shared_gate_for_every_widget, restore_affordance_recovers_the_original_binding_after_replacement, bound_value_shows_expression_badge_and_locks_destructive_controls, replace_affordance_reopens_editing_without_emitting_a_change + * @since engine-v1.66.0 + */ + +import React from 'react'; +import { describe, it, expect, vi, afterEach, beforeAll } from 'vitest'; +import { render, screen, fireEvent, cleanup } from '@testing-library/react'; +import { ControlRenderer } from '../../components/property-controls/ControlRenderer'; +import { registerCoreWidgets } from '../../spec/registerCoreWidgets'; +import { LayoutEditorProvider } from '../../LayoutEditorContext'; +import { EditorModalProvider } from '../../EditorModalContext'; +import type { EditorControlSpec } from '../../spec/specTypes'; +import type { EditorNode } from '../../utils/layoutTreeUtils'; + +// 레지스트리 디스패치를 타는 테스트라 코어 위젯이 등록돼 있어야 한다 +// (미등록이면 ControlRenderer 가 "지원하지 않는 위젯" 폴백을 그린다). +beforeAll(() => registerCoreWidgets()); + +const t = (key: string): string => key; +const EXPR = '{{_global.settings?.general?.site_logo_url}}'; + +/** 스칼라를 prop 자리에 기록하는 평범한 컨트롤 — image 가 아니다 */ +const numberCtrl: EditorControlSpec = { + widget: 'number', + apply: { type: 'propValue', propKey: 'maxVisibleBoards' }, +} as never; + +const selectCtrl: EditorControlSpec = { + widget: 'select', + options: [{ value: 'sm', label: 'S' }, { value: 'lg', label: 'L' }], + apply: { type: 'propValue', propKey: 'size' }, +} as never; + +afterEach(() => cleanup()); + +describe('ControlRenderer — 데이터 연결 값 보호 공용 게이트', () => { + it('number 위젯도 바인딩 값이면 원문 배지로 디그레이드된다 (image 전용이 아니다)', () => { + const node: EditorNode = { type: 'basic', name: 'Header', props: { maxVisibleBoards: EXPR } }; + render(); + + expect(screen.getByTestId('g7le-control-hdrMax-expression').textContent).toBe(EXPR); + // 위젯 자체는 렌더되지 않는다 — 해석 못 하는 값을 흉내내면 거짓 컨트롤이다. + expect(screen.queryByTestId('g7le-number-input')).toBeNull(); + }); + + it('select 위젯도 동일하게 걸린다 (닫힌 집합이라 표현식을 표시할 수 없다)', () => { + const node: EditorNode = { type: 'basic', name: 'Div', props: { size: EXPR } }; + render(); + + expect(screen.getByTestId('g7le-control-sz-expression').textContent).toBe(EXPR); + }); + + it('「직접 지정으로 바꾸기」 → 위젯이 열리고, 그 클릭만으로는 값을 바꾸지 않는다', () => { + const onPatch = vi.fn(); + const node: EditorNode = { type: 'basic', name: 'Header', props: { maxVisibleBoards: EXPR } }; + render(); + + fireEvent.click(screen.getByTestId('g7le-control-hdrMax-expression-replace')); + + expect(screen.queryByTestId('g7le-control-hdrMax-expression')).toBeNull(); + expect(screen.getByTestId('g7le-widget-number')).toBeInTheDocument(); + expect(onPatch).not.toHaveBeenCalled(); + }); + + it('해제 뒤 「되돌리기」가 노출되고, 원문을 다시 기록한다 (편도 금지)', () => { + const patches: EditorNode[] = []; + + // 실제 편집기처럼 패치가 노드로 되돌아오는 controlled 하네스 — + // 고정 prop 으로는 "값을 바꾼 뒤" 상태를 재현할 수 없다. + function Harness(): React.ReactElement { + const [node, setNode] = React.useState({ + type: 'basic', + name: 'Header', + props: { maxVisibleBoards: EXPR }, + }); + return ( + { + patches.push(n); + setNode(n); + }} + /> + ); + } + + render(); + + fireEvent.click(screen.getByTestId('g7le-control-hdrMax-expression-replace')); + + const input = screen.getByTestId('g7le-number-input'); + fireEvent.change(input, { target: { value: '7' } }); + fireEvent.blur(input, { target: { value: '7' } }); + expect(patches[patches.length - 1].props?.maxVisibleBoards).toBe(7); + + // 원문이 화면에서 사라진 뒤에도 되돌릴 수 있어야 한다. + fireEvent.click(screen.getByTestId('g7le-control-hdrMax-expression-restore')); + expect(patches[patches.length - 1].props?.maxVisibleBoards).toBe(EXPR); + // 보호 상태로 복귀 + expect(screen.getByTestId('g7le-control-hdrMax-expression').textContent).toBe(EXPR); + }); + + it('바인딩이 아닌 평범한 값은 종전대로 위젯이 렌더된다 (회귀 가드)', () => { + const node: EditorNode = { type: 'basic', name: 'Header', props: { maxVisibleBoards: 5 } }; + render(); + + expect(screen.queryByTestId('g7le-control-hdrMax-expression')).toBeNull(); + expect((screen.getByTestId('g7le-number-input') as HTMLInputElement).value).toBe('5'); + }); + + it('자체 처리 위젯(image)은 공용 게이트를 타지 않는다 — 위젯 자신의 배지를 쓴다', () => { + const imageCtrl: EditorControlSpec = { + widget: 'image', + apply: { type: 'propValue', propKey: 'logo' }, + } as never; + const node: EditorNode = { type: 'composite', name: 'Header', props: { logo: EXPR } }; + // ImagePickerControl 은 편집기 컨텍스트(첨부 목록·모달)를 요구한다. + render( + + + + + , + ); + + // 공용 게이트의 testid 가 아니라 위젯 자신의 testid 로 뜬다. + expect(screen.queryByTestId('g7le-control-hdrLogo-expression')).toBeNull(); + expect(screen.getByTestId('g7le-image-expression').textContent).toBe(EXPR); + }); +}); diff --git a/resources/js/core/template-engine/layout-editor/__tests__/components/DndCanvasLayer.test.tsx b/resources/js/core/template-engine/layout-editor/__tests__/components/DndCanvasLayer.test.tsx index 6e64b4cc..5b8df75a 100644 --- a/resources/js/core/template-engine/layout-editor/__tests__/components/DndCanvasLayer.test.tsx +++ b/resources/js/core/template-engine/layout-editor/__tests__/components/DndCanvasLayer.test.tsx @@ -433,3 +433,146 @@ describe('DndCanvasLayer — 드래그 핸들 렌더 가드', () => { expect(container.firstChild).toBeNull(); }); }); + +// ============================================================================ +// 상속·주입 노드 드래그 핸들 미렌더 (A3) +// +// 이 노드들은 종전에 `data_bound` 로 분류돼 핸들이 렌더됐고, 옮겨도 저장 시 폐기됐다. +// 핸들 자체를 만들지 않아 "옮길 수 있다" 는 어포던스를 주지 않는다. +// ============================================================================ +describe('DndCanvasLayer — 상속·주입 노드 드래그 핸들 차단 (A3)', () => { + /** 펼침 인스턴스 2개를 owner 아래에 깔아 가상 묶음 합성 조건을 만든다. */ + function appendIterationInstances(frame: HTMLElement, ownerPath: string): void { + const owner = frame.querySelector(`[data-editor-path="${ownerPath}"]`)!; + for (const [i, top] of [0, 50].entries()) { + const inst = document.createElement('div'); + const p = `${ownerPath}.iteration.${i}`; + inst.dataset.editorPath = p; + inst.setAttribute('data-editor-path', p); + vi.spyOn(inst, 'getBoundingClientRect').mockReturnValue( + domRect({ left: 0, top, width: 400, height: 50 }), + ); + owner.appendChild(inst); + } + } + + function renderLayer(components: EditorNode[]) { + const frame = buildFrame([ + { path: '0', rect: { left: 0, top: 0, width: 400, height: 100 } }, + { path: '1', rect: { left: 0, top: 100, width: 400, height: 100 } }, + ]); + render( + , + ); + } + + it('N13 base 출처 + 바인딩 노드 → 핸들 미렌더 (route 소유 형제는 렌더)', () => { + renderLayer([ + { name: 'Div', id: 'a', __source: { kind: 'base' }, text: '{{site.title}}' }, + { name: 'Div', id: 'b', __source: { kind: 'route' }, text: '{{user.name}}' }, + ]); + expect(screen.queryByTestId('g7le-dnd-handle-0')).not.toBeInTheDocument(); + // 회귀 가드 — route 소유 data_bound 는 그대로 핸들이 있다. + expect(screen.queryByTestId('g7le-dnd-handle-1')).toBeInTheDocument(); + }); + + it('N14 base 출처 iteration 노드 → 가상 묶음 핸들도 미렌더', () => { + renderLayer([ + { + name: 'Div', + id: 'list', + __source: { kind: 'base' }, + iteration: { source: '{{posts.data}}' }, + }, + { name: 'Div', id: 'b', __source: { kind: 'route' } }, + ]); + expect(screen.queryByTestId('g7le-dnd-handle-0')).not.toBeInTheDocument(); + expect(screen.queryByTestId('g7le-dnd-handle-1')).toBeInTheDocument(); + }); + + /** + * N14b — 가상 묶음 합성 루프(`DndCanvasLayer` 의 iterationGroups 순회)를 **실제로 진입**시켜 + * 원본 노드의 출처 잠금이 그 루프에서도 걸리는지 잰다. + * + * N14 는 펼침 인스턴스(`0.iteration.N`) DOM 을 만들지 않아 묶음 합성 루프에 애초에 + * 들어가지 않았다 — 그래서 그 안의 잠금 게이트를 지워도 초록이었다(라운드3 probe 실측). + * 여기서는 인스턴스를 실제로 깔아 묶음이 합성되는 조건을 만든 뒤 부재를 단언한다. + */ + it('N14b base 출처 iteration 노드 → 펼침 인스턴스가 있어도 가상 묶음 핸들 미합성', () => { + const frame = buildFrame([{ path: '0', rect: { left: 0, top: 0, width: 400, height: 100 } }]); + appendIterationInstances(frame, '0'); + render( + , + ); + expect(screen.queryByTestId('g7le-dnd-handle-0')).not.toBeInTheDocument(); + }); + + /** + * N14c — N14b 의 「부재」가 공허하지 않음을 증명하는 반증 가드. + * 같은 픽스처에서 출처만 route 로 바꾸면 묶음 핸들이 실제로 합성된다. + */ + it('N14c 회귀 가드 — route 출처 iteration 노드는 가상 묶음 핸들이 합성된다', () => { + const frame = buildFrame([{ path: '0', rect: { left: 0, top: 0, width: 400, height: 100 } }]); + appendIterationInstances(frame, '0'); + render( + , + ); + const groupHandle = screen.queryByTestId('g7le-dnd-handle-0'); + expect(groupHandle).toBeInTheDocument(); + expect(groupHandle?.getAttribute('data-dnd-iteration-group')).toBe('true'); + }); + + it('N15 extension 출처 + 바인딩 노드 → 핸들 미렌더', () => { + renderLayer([ + { + name: 'Div', + id: 'a', + __source: { kind: 'extension', extensionId: 35 }, + text: '{{content}}', + }, + { name: 'Div', id: 'b', __source: { kind: 'route' } }, + ]); + expect(screen.queryByTestId('g7le-dnd-handle-0')).not.toBeInTheDocument(); + expect(screen.queryByTestId('g7le-dnd-handle-1')).toBeInTheDocument(); + }); +}); diff --git a/resources/js/core/template-engine/layout-editor/__tests__/components/EditorCanvasOverlay.entryPointGuard.test.tsx b/resources/js/core/template-engine/layout-editor/__tests__/components/EditorCanvasOverlay.entryPointGuard.test.tsx new file mode 100644 index 00000000..2ec8b957 --- /dev/null +++ b/resources/js/core/template-engine/layout-editor/__tests__/components/EditorCanvasOverlay.entryPointGuard.test.tsx @@ -0,0 +1,203 @@ +/** + * EditorCanvasOverlay.entryPointGuard.test.tsx — 구조 편집 콜백의 선두 가드 (A3) + * + * `handleDuplicate` 는 `ElementOverlay` 의 ⓘ 컨텍스트 메뉴에서만 호출되고, 그 ⓘ 는 + * 같은 잠금 판정으로 이미 가려진다(`ElementOverlay` 가 `isContextMenuAllowed` 로 게이트). + * 그래서 ⓘ 를 통과하는 테스트만으로는 **콜백 자신의 선두 가드가 지워져도 초록**이다 + * (라운드3 probe 로 전 스위트 3,587 green 실측). + * + * 그러나 이 저장소는 같은 자리에서 이미 반대 입장을 취하고 있다 — + * `handleEditProps` 는 "ElementOverlay 가 ⓘ 를 미표시하지만, 외부 호출자(Chrome stub) 등 + * 다른 경로로도 들어올 수 있으므로 여기서도 방어한다" 는 주석과 함께 자체 가드를 둔다. + * 이 파일은 그 계약을 `handleDuplicate` 에도 적용해 **호출자를 신뢰하지 않는다**를 잠근다: + * 오버레이를 스텁으로 바꿔 잠금 여부와 무관하게 콜백을 넘겨받아 직접 호출한다. + * + * @since engine-v1.66.0 + */ + +import React from 'react'; +import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; +import { render, act, cleanup, fireEvent, waitFor } from '@testing-library/react'; +import type { UseLayoutDocumentResult, LoadedLayoutDocument } from '../../hooks/useLayoutDocument'; +import type { EditorNode } from '../../utils/layoutTreeUtils'; + +// ⓘ 게이트를 우회하는 스텁 — lockKind 와 무관하게 onDuplicate 트리거를 항상 렌더한다. +// 「다른 경로로 들어온 호출자」를 그대로 흉내낸다. +vi.mock('../../components/ElementOverlay', () => ({ + ElementOverlay: ({ + onDuplicate, + lockKind, + }: { + onDuplicate: () => void; + lockKind: string; + }): React.ReactElement => ( + + ), +})); + +import { EditorCanvasOverlay } from '../../components/EditorCanvasOverlay'; +import { LayoutEditorProvider, useLayoutEditor } from '../../LayoutEditorContext'; +import { LayoutDocumentProvider } from '../../LayoutDocumentContext'; +import { EditorModalProvider } from '../../EditorModalContext'; +import { TranslationProvider } from '../../../TranslationContext'; +import { TranslationEngine } from '../../../TranslationEngine'; + +interface Rect { + left: number; + top: number; + width: number; + height: number; +} +function domRect(r: Rect): DOMRect { + return { + ...r, + right: r.left + r.width, + bottom: r.top + r.height, + x: r.left, + y: r.top, + toJSON: () => ({}), + } as DOMRect; +} + +function buildFrame(children: Array<{ path: string; rect: Rect }>): HTMLElement { + const wrapper = document.createElement('div'); + const frame = document.createElement('div'); + vi.spyOn(frame, 'getBoundingClientRect').mockReturnValue( + domRect({ left: 0, top: 0, width: 400, height: 400 }), + ); + for (const c of children) { + const el = document.createElement('div'); + el.dataset.editorPath = c.path; + el.dataset.editorId = `id-${c.path}`; + el.setAttribute('data-editor-path', c.path); + vi.spyOn(el, 'getBoundingClientRect').mockReturnValue(domRect(c.rect)); + frame.appendChild(el); + } + wrapper.appendChild(frame); + document.body.appendChild(wrapper); + return frame; +} + +function buildDocCtx(initialComponents: EditorNode[]): { + ctx: UseLayoutDocumentResult; + patchSpy: ReturnType; +} { + let document_: LoadedLayoutDocument = { + layoutName: 'home', + raw: { components: initialComponents }, + lockVersion: 1, + }; + const patchSpy = vi.fn(); + const ctx: UseLayoutDocumentResult = { + document: document_, + isLoading: false, + error: null, + isDirty: false, + saveSuccessCounter: 0, + reload: async () => {}, + patchLayout: (patcher) => { + patchSpy(patcher); + const current = (document_.raw.components as EditorNode[]) ?? []; + const next = patcher(current); + document_ = { ...document_, raw: { ...document_.raw, components: next } }; + (ctx as any).document = document_; + }, + setLayoutComponents: (next) => { + document_ = { ...document_, raw: { ...document_.raw, components: next } }; + (ctx as any).document = document_; + }, + save: async () => ({ kind: 'success', newLockVersion: 2 }), + }; + return { ctx, patchSpy }; +} + +function RouteSeeder({ children }: { children: React.ReactNode }): React.ReactElement { + const { dispatch } = useLayoutEditor(); + React.useEffect(() => { + dispatch({ type: 'SELECT_ROUTE', route: { path: '/', layoutName: 'home' } }); + }, [dispatch]); + return <>{children}; +} + +const BASE_TEXT: EditorNode = { + name: 'Span', + id: 'base-span', + __source: { kind: 'base', layout: '_user_base' }, + text: '공통 문구', +}; +const ROUTE_TEXT: EditorNode = { name: 'Span', id: 'route-span', __source: { kind: 'route' }, text: '라우트 문구' }; + +function mount(components: EditorNode[]) { + const frame = buildFrame([ + { path: '0', rect: { left: 0, top: 0, width: 400, height: 100 } }, + { path: '1', rect: { left: 0, top: 100, width: 400, height: 100 } }, + ]); + const { ctx, patchSpy } = buildDocCtx(components); + const engine = new TranslationEngine(); + + render( + + + + + + + + + + + , + ); + + const selectNode = (path: string): void => { + const el = frame.querySelector(`[data-editor-path="${path}"]`) as HTMLElement; + act(() => { + fireEvent.click(el); + }); + }; + return { selectNode, patchSpy }; +} + +afterEach(() => { + cleanup(); + vi.restoreAllMocks(); + document.body.innerHTML = ''; +}); +beforeEach(() => { + delete (window as any).__g7LayoutEditorHistory; +}); + +describe('EditorCanvasOverlay — 구조 편집 콜백의 선두 가드 (호출자 비신뢰)', () => { + it('N24f base 출처 노드 — ⓘ 를 우회해 onDuplicate 를 직접 호출해도 patchLayout 미호출', async () => { + const { selectNode, patchSpy } = mount([BASE_TEXT, ROUTE_TEXT]); + await waitFor(() => expect((window as any).__g7LayoutEditorHistory).toBeTruthy()); + selectNode('0'); + + const btn = document.querySelector('[data-testid="stub-duplicate"]') as HTMLElement; + expect(btn, '스텁 오버레이가 잠금 여부와 무관하게 트리거를 내야 한다').not.toBeNull(); + expect(btn.getAttribute('data-lock-kind')).toBe('base'); + act(() => { + fireEvent.click(btn); + }); + expect(patchSpy).not.toHaveBeenCalled(); + }); + + it('N24g 회귀 가드 — route 출처 노드는 같은 경로로 실제 복제된다', async () => { + // N24f 의 「부재」가 공허하지 않음을 증명한다 — 이 하네스에서 복제는 도달 가능하다. + const { selectNode, patchSpy } = mount([BASE_TEXT, ROUTE_TEXT]); + await waitFor(() => expect((window as any).__g7LayoutEditorHistory).toBeTruthy()); + selectNode('1'); + + const btn = document.querySelector('[data-testid="stub-duplicate"]') as HTMLElement; + expect(btn.getAttribute('data-lock-kind')).toBe('none'); + act(() => { + fireEvent.click(btn); + }); + expect(patchSpy).toHaveBeenCalled(); + }); +}); diff --git a/resources/js/core/template-engine/layout-editor/__tests__/components/EditorCanvasOverlay.sourceLockGuard.test.tsx b/resources/js/core/template-engine/layout-editor/__tests__/components/EditorCanvasOverlay.sourceLockGuard.test.tsx new file mode 100644 index 00000000..610cbc25 --- /dev/null +++ b/resources/js/core/template-engine/layout-editor/__tests__/components/EditorCanvasOverlay.sourceLockGuard.test.tsx @@ -0,0 +1,290 @@ +/** + * EditorCanvasOverlay.sourceLockGuard.test.tsx — 상속·주입 노드 편집 진입 차단 (A3) + * + * `route` 편집 모드에서 상속(base)·주입(extension) 출처 노드는 저장 시 + * `stripInheritedNode` 가 통째로 폐기하므로 편집분이 오류도 경고도 없이 사라진다. + * (저장은 200 으로 성공하고 `history.clear()` 로 undo 도 불가능하다.) + * + * 종전에는 잠금 판정이 ⓘ 컨텍스트 메뉴와 DnD 핸들에만 걸려 있었고, 아래 4개 진입점은 + * 무방비였다 — 더블클릭 인라인 편집 / 복제 / 키보드 `Delete` / 잘라내기. + * 이 파일은 그 4개 표면 각각의 차단과, 라우트 소유 노드의 정상 동작(회귀 가드)을 잠근다. + * + * @since engine-v1.66.0 + */ + +import React from 'react'; +import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; +import { render, act, cleanup, fireEvent, waitFor } from '@testing-library/react'; +import { EditorCanvasOverlay } from '../../components/EditorCanvasOverlay'; +import { LayoutEditorProvider, useLayoutEditor } from '../../LayoutEditorContext'; +import { LayoutDocumentProvider } from '../../LayoutDocumentContext'; +import { EditorModalProvider } from '../../EditorModalContext'; +import { TranslationProvider } from '../../../TranslationContext'; +import { TranslationEngine } from '../../../TranslationEngine'; +import type { UseLayoutDocumentResult, LoadedLayoutDocument } from '../../hooks/useLayoutDocument'; +import type { EditorNode } from '../../utils/layoutTreeUtils'; +import { readClipboard, clearClipboard } from '../../utils/editorClipboard'; + +interface Rect { + left: number; + top: number; + width: number; + height: number; +} +function domRect(r: Rect): DOMRect { + return { + ...r, + right: r.left + r.width, + bottom: r.top + r.height, + x: r.left, + y: r.top, + toJSON: () => ({}), + } as DOMRect; +} + +/** 미리보기 프레임 + 편집 노드 DOM 모킹 (wrapper 로 감싼다 — 리스너 등록 대상) */ +function buildFrame(children: Array<{ path: string; rect: Rect }>): HTMLElement { + const wrapper = document.createElement('div'); + const frame = document.createElement('div'); + vi.spyOn(frame, 'getBoundingClientRect').mockReturnValue( + domRect({ left: 0, top: 0, width: 400, height: 400 }), + ); + for (const c of children) { + const el = document.createElement('div'); + el.dataset.editorPath = c.path; + el.dataset.editorId = `id-${c.path}`; + el.setAttribute('data-editor-path', c.path); + vi.spyOn(el, 'getBoundingClientRect').mockReturnValue(domRect(c.rect)); + frame.appendChild(el); + } + wrapper.appendChild(frame); + document.body.appendChild(wrapper); + return frame; +} + +function buildDocCtx(initialComponents: EditorNode[]): { + ctx: UseLayoutDocumentResult; + patchSpy: ReturnType; +} { + let document_: LoadedLayoutDocument = { + layoutName: 'home', + raw: { components: initialComponents }, + lockVersion: 1, + }; + const patchSpy = vi.fn(); + const ctx: UseLayoutDocumentResult = { + document: document_, + isLoading: false, + error: null, + isDirty: false, + saveSuccessCounter: 0, + reload: async () => {}, + patchLayout: (patcher) => { + patchSpy(patcher); + const current = (document_.raw.components as EditorNode[]) ?? []; + const next = patcher(current); + document_ = { ...document_, raw: { ...document_.raw, components: next } }; + (ctx as any).document = document_; + }, + setLayoutComponents: (next) => { + document_ = { ...document_, raw: { ...document_.raw, components: next } }; + (ctx as any).document = document_; + }, + save: async () => ({ kind: 'success', newLockVersion: 2 }), + }; + return { ctx, patchSpy }; +} + +function RouteSeeder({ children }: { children: React.ReactNode }): React.ReactElement { + const { dispatch } = useLayoutEditor(); + React.useEffect(() => { + dispatch({ type: 'SELECT_ROUTE', route: { path: '/', layoutName: 'home' } }); + }, [dispatch]); + return <>{children}; +} + +function mount(components: EditorNode[]) { + const frame = buildFrame([ + { path: '0', rect: { left: 0, top: 0, width: 400, height: 100 } }, + { path: '1', rect: { left: 0, top: 100, width: 400, height: 100 } }, + ]); + const { ctx, patchSpy } = buildDocCtx(components); + const engine = new TranslationEngine(); + const manifest = { components: {} } as any; + + render( + + + + + + + + + + + , + ); + + const nodeEl = (path: string): HTMLElement => + frame.querySelector(`[data-editor-path="${path}"]`) as HTMLElement; + + /** 캔버스 노드 클릭 → 선택 (frame 부모 wrapper 의 capture 리스너가 잡는다) */ + const selectNode = (path: string): void => { + act(() => { + fireEvent.click(nodeEl(path), { clientX: 10, clientY: 10 }); + }); + }; + + return { frame, nodeEl, selectNode, patchSpy }; +} + +/** 상속(base) 출처 + 평문 텍스트 — 더블클릭 인라인 편집의 대상이 되는 형태 */ +const BASE_TEXT: EditorNode = { + name: 'Span', + type: 'basic', + __source: { kind: 'base', layout: '_user_base' }, + text: '푸터 문구', +}; +/** 라우트 소유 + 평문 텍스트 — 회귀 가드용 대조군 */ +const ROUTE_TEXT: EditorNode = { + name: 'Span', + type: 'basic', + __source: { kind: 'route' }, + text: '본문 문구', +}; + +afterEach(() => { + cleanup(); + vi.restoreAllMocks(); + document.body.innerHTML = ''; +}); +beforeEach(() => { + delete (window as any).__g7LayoutEditorHistory; + // 클립보드는 sessionStorage 라 케이스 간 누수된다 — N24d 의 「부재」 단언이 공허해진다. + clearClipboard(); +}); + +describe('EditorCanvasOverlay — 상속·주입 노드 인라인 편집 차단 (A3)', () => { + it('N21 base 출처 평문 노드 더블클릭 → 인라인 편집기 미마운트', async () => { + const { nodeEl } = mount([BASE_TEXT, ROUTE_TEXT]); + await waitFor(() => expect((window as any).__g7LayoutEditorHistory).toBeTruthy()); + act(() => { + fireEvent.doubleClick(nodeEl('0'), { clientX: 10, clientY: 10 }); + }); + expect(document.querySelector('[data-testid="g7le-inline-text-editor"]')).toBeNull(); + }); + + it('N22 회귀 가드 — route 출처 평문 노드 더블클릭은 그대로 진입한다', async () => { + const { nodeEl } = mount([BASE_TEXT, ROUTE_TEXT]); + await waitFor(() => expect((window as any).__g7LayoutEditorHistory).toBeTruthy()); + act(() => { + fireEvent.doubleClick(nodeEl('1'), { clientX: 10, clientY: 150 }); + }); + expect(document.querySelector('[data-testid="g7le-inline-text-editor"]')).not.toBeNull(); + }); +}); + +describe('EditorCanvasOverlay — 상속·주입 노드 구조 편집 차단 (A3)', () => { + it('N23 base 출처 노드 선택 + 키보드 Delete → patchLayout 미호출', async () => { + const { selectNode, patchSpy } = mount([BASE_TEXT, ROUTE_TEXT]); + await waitFor(() => expect((window as any).__g7LayoutEditorHistory).toBeTruthy()); + selectNode('0'); + act(() => { + fireEvent.keyDown(window, { key: 'Delete' }); + }); + expect(patchSpy).not.toHaveBeenCalled(); + }); + + it('N24 base 출처 노드 잘라내기(Ctrl+X) → patchLayout 미호출', async () => { + const { selectNode, patchSpy } = mount([BASE_TEXT, ROUTE_TEXT]); + await waitFor(() => expect((window as any).__g7LayoutEditorHistory).toBeTruthy()); + selectNode('0'); + act(() => { + fireEvent.keyDown(window, { key: 'x', ctrlKey: true }); + }); + expect(patchSpy).not.toHaveBeenCalled(); + }); + + /** + * N24d — `handleCut` 의 **선두 가드 고유 목적**을 잰다. + * + * N24 는 `patchLayout` 미호출만 단언하는데, 그것은 `handleCut` 이 호출하는 + * `handleDelete` 의 가드(G7)만으로도 성립한다 — 그래서 `handleCut` 자신의 가드를 지워도 + * 초록이었다(라운드3 probe 실측). 계획서 §7.4 가 이 가드를 따로 둔 이유는 + * 「복사는 됐는데 원본이 남는」 어긋난 상태 방지, 즉 **클립보드에 기록되지 않는 것**이다. + */ + it('N24d base 출처 노드 잘라내기 → 클립보드에도 기록되지 않는다', async () => { + const { selectNode } = mount([BASE_TEXT, ROUTE_TEXT]); + await waitFor(() => expect((window as any).__g7LayoutEditorHistory).toBeTruthy()); + selectNode('0'); + act(() => { + fireEvent.keyDown(window, { key: 'x', ctrlKey: true }); + }); + expect(readClipboard()).toBeNull(); + }); + + /** + * N24e — N24d 의 「부재」가 공허하지 않음을 증명하는 반증 가드. + * 같은 하네스에서 route 출처 노드는 실제로 클립보드에 실린다. + */ + it('N24e 회귀 가드 — route 출처 노드 잘라내기는 클립보드에 실린다', async () => { + const { selectNode } = mount([BASE_TEXT, ROUTE_TEXT]); + await waitFor(() => expect((window as any).__g7LayoutEditorHistory).toBeTruthy()); + selectNode('1'); + act(() => { + fireEvent.keyDown(window, { key: 'x', ctrlKey: true }); + }); + expect(readClipboard()).not.toBeNull(); + }); + + it('N24b base 출처 노드는 복제 진입 경로 자체가 없다 (ⓘ 미렌더)', async () => { + const { selectNode, patchSpy } = mount([BASE_TEXT, ROUTE_TEXT]); + await waitFor(() => expect((window as any).__g7LayoutEditorHistory).toBeTruthy()); + selectNode('0'); + + // ⓘ 가 없으면 「복제」 메뉴 항목에 도달할 방법이 없다 — 복제의 유일한 호출부다. + expect(document.querySelector('[data-testid="g7le-overlay-info-button"]')).toBeNull(); + expect(document.querySelector('[data-testid="g7le-context-menu-duplicate"]')).toBeNull(); + expect(patchSpy).not.toHaveBeenCalled(); + }); + + it('N24c 회귀 가드 — route 출처 노드는 ⓘ→복제로 실제 복제된다', async () => { + // 이 케이스가 없으면 N24b 의 「부재」 단언이 공허해진다 — + // 복제 경로가 이 하네스에서 애초에 도달 가능함을 여기서 증명한다. + const { selectNode, patchSpy } = mount([BASE_TEXT, ROUTE_TEXT]); + await waitFor(() => expect((window as any).__g7LayoutEditorHistory).toBeTruthy()); + selectNode('1'); + + const info = document.querySelector('[data-testid="g7le-overlay-info-button"]') as HTMLElement; + expect(info).not.toBeNull(); + act(() => { + fireEvent.click(info); + }); + + const dup = document.querySelector('[data-testid="g7le-context-menu-duplicate"]') as HTMLElement; + expect(dup).not.toBeNull(); + act(() => { + fireEvent.click(dup); + }); + expect(patchSpy).toHaveBeenCalled(); + }); + + it('N25 회귀 가드 — route 출처 노드는 Delete 로 정상 삭제된다', async () => { + const { selectNode, patchSpy } = mount([BASE_TEXT, ROUTE_TEXT]); + await waitFor(() => expect((window as any).__g7LayoutEditorHistory).toBeTruthy()); + selectNode('1'); + act(() => { + fireEvent.keyDown(window, { key: 'Delete' }); + }); + expect(patchSpy).toHaveBeenCalled(); + }); +}); diff --git a/resources/js/core/template-engine/layout-editor/__tests__/components/PropertyEditorModal.propsTab.test.tsx b/resources/js/core/template-engine/layout-editor/__tests__/components/PropertyEditorModal.propsTab.test.tsx index a3fe0fa9..5c64dcfc 100644 --- a/resources/js/core/template-engine/layout-editor/__tests__/components/PropertyEditorModal.propsTab.test.tsx +++ b/resources/js/core/template-engine/layout-editor/__tests__/components/PropertyEditorModal.propsTab.test.tsx @@ -10,7 +10,7 @@ import React from 'react'; import { describe, it, expect, vi, beforeAll, beforeEach } from 'vitest'; -import { render, screen } from '@testing-library/react'; +import { render, screen, fireEvent } from '@testing-library/react'; import { PropertyEditorModal } from '../../components/PropertyEditorModal'; import { registerCoreWidgets } from '../../spec/registerCoreWidgets'; import { @@ -196,3 +196,42 @@ describe('PropertyEditorModal — 데이터 연결(dataProps) 영역', () => { expect(screen.queryByTestId('g7le-iteration-binding-section')).toBeNull(); }); }); + +// ============================================================================ +// 코어 dataKey 컨트롤 — nodeKey apply 통합 (A2) +// +// 엔진 switch 에 `nodeKey` case 가 없던 동안 이 컨트롤은 값을 넣어도 아무 일도 +// 일어나지 않는 무음 no-op 이었다. 통합 축으로 "패치가 노드 최상위에 간다" 를 잠근다. +// ============================================================================ +describe('PropertyEditorModal — 코어 dataKey(nodeKey apply) 통합', () => { + const dataKeySpec: EditorSpec = { + controls: {}, + componentCapabilities: { + // 폼 컨테이너 opt-in — coreProps 에 dataKey 를 명시해야 노출된다. + Form: { coreProps: ['id', 'dataKey'] }, + }, + }; + + it('5-15 dataKey 입력 → onPatchNode 인자의 node.dataKey 설정, props.dataKey 부재', () => { + const onPatchNode = vi.fn(); + render( + , + ); + const input = screen.getByTestId('g7le-widget-core-datakey'); + fireEvent.change(input, { target: { value: 'orderer' } }); + fireEvent.blur(input, { target: { value: 'orderer' } }); + + expect(onPatchNode).toHaveBeenCalled(); + const patched = onPatchNode.mock.calls.at(-1)![0] as EditorNode & Record; + expect(patched.dataKey).toBe('orderer'); + expect(patched.props?.dataKey).toBeUndefined(); + }); +}); diff --git a/resources/js/core/template-engine/layout-editor/__tests__/components/property-controls.test.tsx b/resources/js/core/template-engine/layout-editor/__tests__/components/property-controls.test.tsx index b913aa82..7c794a60 100644 --- a/resources/js/core/template-engine/layout-editor/__tests__/components/property-controls.test.tsx +++ b/resources/js/core/template-engine/layout-editor/__tests__/components/property-controls.test.tsx @@ -24,6 +24,7 @@ import { TagInputControl } from '../../components/property-controls/TagInputCont import { CompositeSettingsForm } from '../../components/property-controls/CompositeSettingsForm'; import { AdvancedPropsForm } from '../../components/property-controls/AdvancedPropsForm'; import { ControlRenderer } from '../../components/property-controls/ControlRenderer'; +import { NumberWidget } from '../../components/property-controls/StyleControlWidgets'; import { registerWidget, clearWidgetRegistry } from '../../spec/widgetRegistry'; import { registerCoreWidgets, resetCoreWidgetRegistration } from '../../spec/registerCoreWidgets'; import { LayoutEditorProvider } from '../../LayoutEditorContext'; @@ -253,6 +254,187 @@ describe('ImagePickerControl', () => { }); }); +// ============================================================================ +// ImagePickerControl — 단일 값 슬롯 / 데이터 연결 보호 (공개 #135) +// +// `propValue`·`cssVar`·단일 `styleProp` 은 값 슬롯이 하나뿐이라 size/repeat/position +// 을 저장할 자리가 없다. 그런 컨트롤에서 표시모드 버튼은 눌러도 저장되지 않는 죽은 +// 컨트롤이므로 **컨테이너째 미렌더**한다(disabled 는 "URL 을 넣으면 살아난다"는 거짓 +// 정보를 준다). 판정은 블랙리스트라 `apply` 미선언 컨트롤은 현행대로 모드 버튼을 유지한다. +// ============================================================================ +describe('ImagePickerControl — 단일 값 슬롯 / 데이터 연결 보호 (공개 #135)', () => { + /** 실물 `hdrLogo` — sirsoft-basic 헤더 「로고 이미지」 */ + const logoCtrl: EditorControlSpec = { + widget: 'image', + apply: { type: 'propValue', propKey: 'logo' }, + }; + /** 실물 `backgroundImage` — 배경 4속성 묶음 */ + const bundleCtrl: EditorControlSpec = { + widget: 'image', + apply: { + type: 'styleProp', + props: ['backgroundImage', 'backgroundSize', 'backgroundRepeat', 'backgroundPosition'], + }, + }; + + function renderWith(control: EditorControlSpec, value: unknown, onChange = vi.fn()) { + render( + + + + + , + ); + return onChange; + } + + beforeEach(() => { + vi.stubGlobal( + 'fetch', + vi.fn().mockResolvedValue({ ok: true, json: async () => ({ success: true, data: [] }) }), + ); + }); + afterEach(() => vi.restoreAllMocks()); + + /** @effects single_value_slot_control_hides_display_mode_buttons_entirely */ + it('3-1 단일 슬롯(propValue) — 표시모드 컨테이너와 3버튼이 모두 미렌더', () => { + renderWith(logoCtrl, { url: '/a.png' }); + expect(screen.queryByTestId('g7le-image-modes')).toBeNull(); + expect(screen.queryByTestId('g7le-image-mode-fill')).toBeNull(); + expect(screen.queryByTestId('g7le-image-mode-fit')).toBeNull(); + expect(screen.queryByTestId('g7le-image-mode-tile')).toBeNull(); + }); + + /** @effects single_value_slot_control_emits_url_only_object_without_size_repeat_position */ + it('3-2 단일 슬롯 — URL blur 시 onChange 인자가 정확히 { url } (다른 키 없음)', () => { + const onChange = renderWith(logoCtrl, undefined); + const url = screen.getByTestId('g7le-image-url'); + fireEvent.change(url, { target: { value: '/b.png' } }); + fireEvent.blur(url, { target: { value: '/b.png' } }); + expect(onChange).toHaveBeenCalledWith({ url: '/b.png' }); + }); + + /** @effects single_value_slot_preview_is_pinned_to_contain_not_a_false_preview */ + it('3-3 단일 슬롯 — 미리보기는 contain 고정 (저장되지 않는 size 를 흉내내지 않는다)', () => { + renderWith(logoCtrl, { url: '/a.png', size: 'cover' }); + const preview = screen.getByTestId('g7le-image-preview') as HTMLElement; + expect(preview.style.backgroundSize).toBe('contain'); + }); + + /** @effects bundle_control_keeps_display_mode_buttons_and_active_state */ + it('3-4 bundle 컨트롤 — 모드 버튼 존재 + 현행 활성 표시 보존', () => { + renderWith(bundleCtrl, { url: '/a.png', size: 'cover', repeat: 'no-repeat' }); + expect(screen.getByTestId('g7le-image-modes')).toBeTruthy(); + expect(screen.getByTestId('g7le-image-mode-fill').getAttribute('data-active')).toBe('true'); + }); + + /** @effects apply_undeclared_control_keeps_display_mode_buttons_blacklist_not_whitelist */ + it('3-5 apply 미선언 컨트롤 — 판정 보류라 모드 버튼 유지 (기존 계약 보존)', () => { + renderWith({ widget: 'image' }, { url: '/a.png' }); + expect(screen.getByTestId('g7le-image-modes')).toBeTruthy(); + }); + + it('3-6 옵션-only apply 도 합집합으로 판정한다 (control.apply 부재에 속지 않음)', () => { + const optionOnly = { + widget: 'image', + options: [{ value: 'a', apply: { type: 'propValue', propKey: 'logo' } }], + } as unknown as EditorControlSpec; + renderWith(optionOnly, { url: '/a.png' }); + expect(screen.queryByTestId('g7le-image-modes')).toBeNull(); + }); + + /** @effects bound_value_shows_expression_badge_and_locks_destructive_controls */ + it('3-7 데이터 연결 값 — 미리보기 대신 원문 배지, 업로드·제거 비활성', () => { + renderWith(logoCtrl, { url: '{{_global.settings?.general?.site_logo_url}}' }); + expect(screen.queryByTestId('g7le-image-preview')).toBeNull(); + const badge = screen.getByTestId('g7le-image-expression'); + expect(badge.textContent).toBe('{{_global.settings?.general?.site_logo_url}}'); + expect((screen.getByTestId('g7le-image-file') as HTMLInputElement).disabled).toBe(true); + expect((screen.getByTestId('g7le-image-clear') as HTMLButtonElement).disabled).toBe(true); + // 원문은 입력칸에도 남아 있고 편집만 막힌다 — 사라지지 않는다. + expect((screen.getByTestId('g7le-image-url') as HTMLInputElement).readOnly).toBe(true); + }); + + /** @effects replace_affordance_reopens_editing_without_emitting_a_change */ + it('3-8 「직접 지정으로 바꾸기」 → 편집 개방, 그 클릭만으로는 값을 바꾸지 않는다', () => { + const onChange = renderWith(logoCtrl, { + url: '{{_global.settings?.general?.site_logo_url}}', + }); + fireEvent.click(screen.getByTestId('g7le-image-expression-replace')); + expect((screen.getByTestId('g7le-image-file') as HTMLInputElement).disabled).toBe(false); + expect((screen.getByTestId('g7le-image-url') as HTMLInputElement).readOnly).toBe(false); + expect(screen.queryByTestId('g7le-image-expression')).toBeNull(); + expect(onChange).not.toHaveBeenCalled(); + }); + + /** @effects bound_value_shows_expression_badge_and_locks_destructive_controls */ + it('3-9 데이터 연결 값 — 「이미지 관리」 진입도 잠근다 (창 안의 「배경」이 우회로다)', () => { + renderWith(logoCtrl, { url: '{{_global.settings?.general?.site_logo_url}}' }); + // 관리 모달은 onSelect 를 받아 각 카드에 「배경」 버튼을 띄우고, 그 클릭이 같은 + // setUrl 을 호출한다 — 인라인 썸네일 「사용」과 동일 동작의 다른 렌더 위치다. + // 하나만 잠그면 나머지 하나가 조용한 우회로가 된다. + expect((screen.getByTestId('g7le-image-manage') as HTMLButtonElement).disabled).toBe(true); + }); + + /** @effects replace_affordance_reopens_editing_without_emitting_a_change */ + it('3-10 「직접 지정으로 바꾸기」 후 되돌리기 — 아직 안 바꿨으면 값 변경 없이 배지로 복귀', () => { + const expr = '{{_global.settings?.general?.site_logo_url}}'; + const onChange = renderWith(logoCtrl, { url: expr }); + + fireEvent.click(screen.getByTestId('g7le-image-expression-replace')); + expect(screen.queryByTestId('g7le-image-expression')).toBeNull(); + + fireEvent.click(screen.getByTestId('g7le-image-expression-restore')); + // 배지 복귀 + 잠금 재적용 + expect(screen.getByTestId('g7le-image-expression').textContent).toBe(expr); + expect((screen.getByTestId('g7le-image-manage') as HTMLButtonElement).disabled).toBe(true); + // 바꾼 것이 없으므로 불필요한 history push 를 만들지 않는다 + expect(onChange).not.toHaveBeenCalled(); + }); + + /** @effects replace_affordance_reopens_editing_without_emitting_a_change */ + it('3-11 URL 을 넣은 뒤에도 되돌리기로 원래 연결값을 복구한다', () => { + const expr = '{{_global.settings?.general?.site_logo_url}}'; + const seen: unknown[] = []; + + // 실제 편집기처럼 값이 되돌아오는 controlled 하네스 — + // 고정 prop 으로는 "값을 바꾼 뒤" 상태를 재현할 수 없다. + function Harness(): React.ReactElement { + const [v, setV] = React.useState({ url: expr }); + return ( + { + seen.push(next); + setV(next); + }} + t={t} + /> + ); + } + + render( + + + + + , + ); + + fireEvent.click(screen.getByTestId('g7le-image-expression-replace')); + const url = screen.getByTestId('g7le-image-url'); + fireEvent.change(url, { target: { value: '/uploaded.png' } }); + fireEvent.blur(url, { target: { value: '/uploaded.png' } }); + expect(seen[seen.length - 1]).toEqual({ url: '/uploaded.png' }); + + // 원문이 화면에서 사라진 뒤에도 되돌릴 수 있어야 한다 — 없으면 편도가 된다. + fireEvent.click(screen.getByTestId('g7le-image-expression-restore')); + expect(seen[seen.length - 1]).toEqual({ url: expr }); + expect(screen.getByTestId('g7le-image-expression').textContent).toBe(expr); + }); +}); + // ============================================================================ // TagInputControl // ============================================================================ @@ -739,3 +921,96 @@ describe('SpacingWidget (여백 방향+크기)', () => { expect((screen.getByTestId('g7le-spacing-all-enabled') as HTMLInputElement).checked).toBe(false); }); }); + +// ============================================================================ +// NumberWidget — 숫자 prop 편집 (A1) +// +// 이 위젯이 없어 `widget:"number"` 컨트롤은 「지원하지 않는 컨트롤」로 폴백했다. +// 출력 타입이 `number` 여야 컴포넌트 prop 계약(`maxVisibleBoards?: number`)을 만족한다. +// ============================================================================ +describe('NumberWidget', () => { + const ctrl: EditorControlSpec = { widget: 'number' }; + + it('4-6 숫자 입력 후 blur → onChange(숫자) — 문자열이 아니다', () => { + const onChange = vi.fn(); + render(); + const input = screen.getByTestId('g7le-number-input'); + fireEvent.change(input, { target: { value: '7' } }); + fireEvent.blur(input, { target: { value: '7' } }); + expect(onChange).toHaveBeenCalledWith(7); + expect(typeof onChange.mock.calls.at(-1)![0]).toBe('number'); + }); + + it('4-7 빈 입력 → onChange(undefined) (prop 삭제)', () => { + const onChange = vi.fn(); + render(); + const input = screen.getByTestId('g7le-number-input'); + fireEvent.change(input, { target: { value: '' } }); + fireEvent.blur(input, { target: { value: '' } }); + expect(onChange).toHaveBeenCalledWith(undefined); + }); + + it('4-8 비숫자 입력 → onChange 미호출 (저장본 무손실 보존)', () => { + const onChange = vi.fn(); + render(); + const input = screen.getByTestId('g7le-number-input'); + fireEvent.blur(input, { target: { value: 'abc' } }); + expect(onChange).not.toHaveBeenCalled(); + }); + + it('4-9 0 은 유효값이라 삭제가 아니라 0 으로 방출된다', () => { + const onChange = vi.fn(); + render(); + fireEvent.blur(screen.getByTestId('g7le-number-input'), { target: { value: '0' } }); + expect(onChange).toHaveBeenCalledWith(0); + }); + + it('4-10 Enter 키도 blur 와 같이 커밋한다', () => { + const onChange = vi.fn(); + render(); + const input = screen.getByTestId('g7le-number-input'); + fireEvent.change(input, { target: { value: '3' } }); + fireEvent.keyDown(input, { key: 'Enter' }); + expect(onChange).toHaveBeenCalledWith(3); + }); + + it('4-11 min/max/step 을 HTML 속성으로 전달한다 (클램프하지 않는다)', () => { + const bounded: EditorControlSpec = { widget: 'number', min: 1, max: 10, step: 1 }; + const onChange = vi.fn(); + render(); + const input = screen.getByTestId('g7le-number-input') as HTMLInputElement; + expect(input.getAttribute('min')).toBe('1'); + expect(input.getAttribute('max')).toBe('10'); + expect(input.getAttribute('step')).toBe('1'); + // 범위 밖 값도 사용자가 넣은 그대로 방출된다 — 조용한 변조 금지. + fireEvent.blur(input, { target: { value: '99' } }); + expect(onChange).toHaveBeenCalledWith(99); + }); + + // 계약 이전(engine-v1.66.0): 바인딩 값 보호는 **위젯이 아니라** `ControlRenderer` 의 + // 공용 게이트(`boundValueGuard`)가 담당한다. 종전에는 이 위젯이 자체 읽기전용 배지를 + // 가졌는데, 그 방식이면 위젯마다 복붙이 필요하고 한 곳이 빠져도 오류가 나지 않는다 — + // 실제로 image 위젯에서 「이미지 관리」 진입 하나만 잠기지 않은 채 남아 있었다. + // 게다가 위젯 자체 분기는 공용 게이트의 「직접 지정으로 바꾸기」 해제 경로까지 막았다. + // 공용 게이트의 동작은 ControlRenderer.boundValueGuard.test.tsx 가 잠근다. + it('4-12 위젯 자체는 바인딩 값을 특별 취급하지 않는다 (보호는 공용 게이트 소관)', () => { + const onChange = vi.fn(); + render(); + // 위젯 전용 배지는 더 이상 존재하지 않는다 + expect(screen.queryByTestId('g7le-number-binding')).toBeNull(); + // 해제된 뒤에는 정상 입력칸이어야 한다 — 여기서 막으면 해제가 무의미해진다 + expect(screen.getByTestId('g7le-number-input')).toBeInTheDocument(); + // 렌더만으로는 값을 건드리지 않는다 + expect(onChange).not.toHaveBeenCalled(); + }); + + it('4-13 외부 value 변경 시 입력칸 draft 를 동기화한다', () => { + const onChange = vi.fn(); + const { rerender } = render( + , + ); + expect((screen.getByTestId('g7le-number-input') as HTMLInputElement).value).toBe('5'); + rerender(); + expect((screen.getByTestId('g7le-number-input') as HTMLInputElement).value).toBe('9'); + }); +}); diff --git a/resources/js/core/template-engine/layout-editor/__tests__/hooks/useCanvasDnd.test.ts b/resources/js/core/template-engine/layout-editor/__tests__/hooks/useCanvasDnd.test.ts index ff2c8d60..f377ab71 100644 --- a/resources/js/core/template-engine/layout-editor/__tests__/hooks/useCanvasDnd.test.ts +++ b/resources/js/core/template-engine/layout-editor/__tests__/hooks/useCanvasDnd.test.ts @@ -802,8 +802,8 @@ describe('useCanvasDnd — 모달 편집 편집루트 confine', () => { }) ); // 딤 호스트 자식(Span, path 0.children.0) 드래그 시작 시도 — 편집 루트(모달[1]) 밖. - // onDragStart 는 activeDragPath 를 항상 설정하나(기존 설계 — 시각 표시), 편집 루트 밖이면 - // decision='denied_data_bound' 로 적재되고, onDragMove 가 드롭존을 계산하지 않으며, + // 편집 루트 밖이면 decision='denied_data_bound' 로 적재되고, 거부된 드래그는 + // activeDragPath 를 남기지 않으며, onDragMove 가 드롭존을 계산하지 않고 // onDragEnd 의 commit confine 가 차단한다(실제 이동 불가). act(() => result.current.onDragStart(startEvent('0.children.0'))); const denied = trackSpy.mock.calls.find( @@ -824,3 +824,113 @@ describe('useCanvasDnd — 모달 편집 편집루트 confine', () => { expect(result.current.activeDropZone, '편집 루트 밖 드래그는 드롭존이 없어야 한다').toBeNull(); }); }); + +// ============================================================================ +// 상속·주입 노드 드래그 차단 — 시작 / 이동 / commit 3층 (A3) +// +// 종전에는 route 모드에서 이 노드들이 `data_bound` 로 분류돼 드래그가 열렸고, 옮겨도 +// 저장 시 `stripInheritedNode` 가 통째로 폐기했다. onDragEnd 에는 잠금 재검사가 아예 +// 없어 `zone === null` 에 기댄 간접 방어뿐이었다. +// ============================================================================ +describe('useCanvasDnd — 상속·주입 노드 드래그 차단 (A3)', () => { + afterEach(() => { + vi.restoreAllMocks(); + document.body.innerHTML = ''; + }); + + function scene(components: EditorNode[]) { + const patchSpy = vi.fn(); + const pushSpy = vi.fn(); + const frame = buildFrame([ + { path: '0', rect: { left: 0, top: 0, width: 400, height: 100 } }, + { path: '1', rect: { left: 0, top: 100, width: 400, height: 100 } }, + ]); + const { result } = renderHook(() => + useCanvasDnd({ + frameEl: frame, + nesting: NESTING, + editMode: 'route', + components, + patchLayout: patchSpy, + pushHistory: pushSpy, + }), + ); + return { result, patchSpy, pushSpy }; + } + + const BASE_BOUND: EditorNode = { + name: 'Div', + id: 'a', + __source: { kind: 'base' }, + text: '{{site.title}}', + }; + const EXT_BOUND: EditorNode = { + name: 'Div', + id: 'a', + __source: { kind: 'extension', extensionId: 35 }, + text: '{{content}}', + }; + const ROUTE_BOUND: EditorNode = { + name: 'Div', + id: 'b', + __source: { kind: 'route' }, + props: { src: '{{product.image}}' }, + }; + + it('N16 base 출처 → onDragStart 가 denied_base_locked + activeDragPath 미보관', () => { + const trackSpy = vi.spyOn(trackers, 'trackEditorDnd'); + const { result } = scene([BASE_BOUND, ROUTE_BOUND]); + act(() => result.current.onDragStart(startEvent('0'))); + const denied = trackSpy.mock.calls.find((c) => c[0].result === 'denied'); + expect(denied?.[0].decision).toBe('denied_base_locked'); + // 거부된 드래그가 activeDragPath 를 남기면 DragOverlay 가 따라다녀 거짓 어포던스가 된다. + expect(result.current.activeDragPath).toBeNull(); + }); + + it('N17 extension 출처 → denied_extension_locked', () => { + const trackSpy = vi.spyOn(trackers, 'trackEditorDnd'); + const { result } = scene([EXT_BOUND, ROUTE_BOUND]); + act(() => result.current.onDragStart(startEvent('0'))); + const denied = trackSpy.mock.calls.find((c) => c[0].result === 'denied'); + expect(denied?.[0].decision).toBe('denied_extension_locked'); + expect(result.current.activeDragPath).toBeNull(); + }); + + it('N18 onDragMove — 잠긴 노드는 드롭존을 계산하지 않는다', () => { + const { result } = scene([BASE_BOUND, ROUTE_BOUND]); + act(() => result.current.onDragStart(startEvent('0'))); + act(() => + result.current.onDragMove({ + active: { id: '0' }, + over: { id: slot('', 1) }, + activatorEvent: { clientX: 0, clientY: 0 } as PointerEvent, + delta: { x: 0, y: 0 }, + } as any), + ); + expect(result.current.activeDropZone).toBeNull(); + }); + + it('N19 onDragEnd 최종 가드 — 유효 zone 을 강제 주입해도 commit 되지 않는다', () => { + const trackSpy = vi.spyOn(trackers, 'trackEditorDnd'); + const { result, patchSpy, pushSpy } = scene([BASE_BOUND, ROUTE_BOUND]); + act(() => result.current.onDragStart(startEvent('0'))); + // stale 슬롯/직접 호출 등으로 유효 zone 이 들어와도 commit 직전 가드가 막아야 한다. + act(() => result.current.onDragEnd(endEvent('0', slot('', 2)))); + expect(patchSpy).not.toHaveBeenCalled(); + expect(pushSpy).not.toHaveBeenCalled(); + const denied = trackSpy.mock.calls.find( + (c) => c[0].result === 'denied' && c[0].decision === 'denied_base_locked', + ); + expect(denied).toBeTruthy(); + }); + + it('N20 회귀 가드 — route 출처 data_bound 노드는 드래그·이동 모두 허용', () => { + const trackSpy = vi.spyOn(trackers, 'trackEditorDnd'); + const { result, patchSpy } = scene([ROUTE_BOUND, { name: 'Div', id: 'c' }]); + act(() => result.current.onDragStart(startEvent('0'))); + expect(trackSpy.mock.calls.find((c) => c[0].result === 'denied')).toBeUndefined(); + expect(result.current.activeDragPath).toBe('0'); + act(() => result.current.onDragEnd(endEvent('0', slot('', 2)))); + expect(patchSpy).toHaveBeenCalled(); + }); +}); diff --git a/resources/js/core/template-engine/layout-editor/__tests__/hooks/useElementSelection.normalize.test.tsx b/resources/js/core/template-engine/layout-editor/__tests__/hooks/useElementSelection.normalize.test.tsx index b7867be6..c0e8113a 100644 --- a/resources/js/core/template-engine/layout-editor/__tests__/hooks/useElementSelection.normalize.test.tsx +++ b/resources/js/core/template-engine/layout-editor/__tests__/hooks/useElementSelection.normalize.test.tsx @@ -433,3 +433,63 @@ describe('useElementSelection — 식별 라벨 (base 파일명 / 데이터소 expect(result.current.selectedDataSourceId).toBe('_local'); }); }); + +// ============================================================================ +// route 모드 상속·주입 노드 선택 → 진입 어포던스 배선 (A3) +// +// 종전에는 이 노드들이 `data_bound` 로 분류돼 「데이터 영역」 라벨만 뜨고 편집이 열렸다. +// 이제 출처 잠금으로 분류되어 「🔒 공통 레이아웃 편집」/「🔒 확장 편집」 어포던스가 뜬다. +// 어포던스 노출의 핵심 게이트는 `selectedBaseLayout` 이므로 그것까지 함께 단언한다. +// ============================================================================ +describe('useElementSelection — 상속·주입 노드 진입 어포던스 (A3)', () => { + const affordanceTree: EditorNode = { + children: [ + // base 출처 + props 바인딩 — 종전 data_bound, 이제 base + { + name: 'Header', + __source: { kind: 'base', layout: '_user_base' }, + props: { logo: '{{_global.settings?.general?.site_logo_url}}' }, + }, + // extension 출처 + 텍스트 바인딩 — 종전 data_bound, 이제 extension + { + name: 'Span', + __source: { kind: 'extension', extensionId: 35 }, + text: '{{content}}', + }, + ], + }; + + it('N10 base 출처 + 바인딩 선택 → lockKind=base AND selectedBaseLayout=_user_base', () => { + const { result } = renderHook(() => + useElementSelection({ rootNode: affordanceTree, editMode: 'route' }), + ); + act(() => { + result.current.handleSelect('', selectByPath('0')); + }); + expect(result.current.selectedLockKind).toBe('base'); + // 이 값이 「🔒 공통 레이아웃 편집」 버튼 노출의 게이트다. + expect(result.current.selectedBaseLayout).toBe('_user_base'); + }); + + it('N11 같은 노드 → 데이터 영역 라벨·반복 진입은 사라진다 (잠금이 이겼으므로)', () => { + const { result } = renderHook(() => + useElementSelection({ rootNode: affordanceTree, editMode: 'route' }), + ); + act(() => { + result.current.handleSelect('', selectByPath('0')); + }); + expect(result.current.selectedDataSourceId).toBeNull(); + expect(result.current.selectedIsIteration).toBe(false); + }); + + it('N12 extension 출처 + 바인딩 선택 → lockKind=extension + 확장 PK 로 진입 가능', () => { + const { result } = renderHook(() => + useElementSelection({ rootNode: affordanceTree, editMode: 'route' }), + ); + act(() => { + result.current.handleSelect('', selectByPath('1')); + }); + expect(result.current.selectedLockKind).toBe('extension'); + expect(result.current.selectedNode?.__source?.extensionId).toBe(35); + }); +}); diff --git a/resources/js/core/template-engine/layout-editor/__tests__/hooks/useElementSelection.test.ts b/resources/js/core/template-engine/layout-editor/__tests__/hooks/useElementSelection.test.ts index d5f8f031..76b389de 100644 --- a/resources/js/core/template-engine/layout-editor/__tests__/hooks/useElementSelection.test.ts +++ b/resources/js/core/template-engine/layout-editor/__tests__/hooks/useElementSelection.test.ts @@ -14,6 +14,9 @@ import { isContextMenuAllowed, sliceDomPathToDepth, resolveSourceExtensionId, + isEditableLockKind, + resolveDndDenial, + type SelectionLockKind, } from '../../hooks/useElementSelection'; import type { EditorNode } from '../../utils/layoutTreeUtils'; @@ -198,16 +201,32 @@ describe('classifyLockKind', () => { expect(classifyLockKind(node, 'base')).toBe('extension'); }); - // route 모드는 종전 동작(data_bound 우선)을 그대로 보존해야 한다. - it('route 모드 + 확장 출처 data_bound 노드 → data_bound (종전 동작 보존, 회귀 방지)', () => { - // 확장 주입 영역 안의 바인딩 노드. route 모드에서는 data_bound 로 분류돼 "데이터 영역" 표식 - // 을 유지하고, 잠긴 확장 루트는 별도로 extension 어포던스를 띄운다(별도 노드). + // 계약 변경(의도적): 종전에는 route 모드에서 data_bound 를 먼저 판정해 이 노드가 + // `data_bound`(= 편집 허용)로 분류됐다. 그런데 저장 시 `stripInheritedNode` 가 확장 출처 + // 노드를 통째로 폐기하므로 편집분이 오류도 경고도 없이 사라졌다(저장은 200 성공, history + // clear 로 undo 불가). 종전 기대값이 고정하던 것은 "route 는 한 줄도 바꾸지 않는다" 는 + // 보수성 선언이었고, 그 보수성이 곧 결함이었다. + it('route 모드 + 확장 출처 data_bound 노드 → extension (편집 차단 + 확장 편집 유도)', () => { const node: EditorNode = { name: 'Span', __source: { kind: 'extension', extensionId: 35 }, text: '{{content}}', }; + expect(classifyLockKind(node, 'route')).toBe('extension'); + expect(isContextMenuAllowed(classifyLockKind(node, 'route'))).toBe(false); + }); + + // ⚠ 위 변경이 좁힌 것은 "어느 노드가 data_bound 로 분류되는가" 뿐이다. + // `data_bound ⇒ 선택·드래그·구조 편집 허용` 계약은 그대로다 — 아래가 그 반증 가드이며, + // 반대 방향으로 되돌리는 변경은 여기서 막힌다. + it('route 모드 + route 출처 data_bound 노드 → data_bound (편집 허용 계약 보존)', () => { + const node: EditorNode = { + name: 'Img', + __source: { kind: 'route' }, + props: { src: '{{product.image}}' }, + }; expect(classifyLockKind(node, 'route')).toBe('data_bound'); + expect(isContextMenuAllowed(classifyLockKind(node, 'route'))).toBe(true); }); it('route 모드 + 확장 출처 (바인딩 없음) 노드 → extension 잠금(확장 편집 어포던스)', () => { @@ -282,3 +301,136 @@ describe('resolveSourceExtensionId', () => { expect(resolveSourceExtensionId(null)).toBeNull(); }); }); + +// ============================================================================ +// route 모드 출처 잠금 우선 — 상속·주입 노드 편집 소실 차단 (A3) +// +// 종전에는 route 모드만 `data_bound` 를 먼저 판정해, 상속(base)·주입(extension) 노드 중 +// props 값 하나라도 `{{ }}` 인 것이 "편집 가능" 으로 분류됐다. 그런데 저장 시 +// `stripInheritedNode` 가 그 노드를 통째로 폐기하므로 편집분이 오류도 경고도 없이 +// 사라졌다(저장은 200 성공 + history clear 로 undo 불가). +// +// N5~N9 는 `data_bound ⇒ 선택·드래그·구조 편집 허용` 계약의 **반증 가드**다 — +// 되돌리는 변경은 여기서 막힌다. +// ============================================================================ +describe('classifyLockKind — route 모드 출처 잠금 우선 (A3)', () => { + const menu = (kind: SelectionLockKind) => isContextMenuAllowed(kind); + const drag = (kind: SelectionLockKind) => resolveDndDenial(kind) === null; + + it('N1 base 출처 + 텍스트 바인딩 → base (ⓘ·드래그 차단)', () => { + const node: EditorNode = { + name: 'H1', + __source: { kind: 'base', layout: '_user_base' }, + text: '{{site.title}}', + }; + const kind = classifyLockKind(node, 'route'); + expect(kind).toBe('base'); + expect(menu(kind)).toBe(false); + expect(drag(kind)).toBe(false); + }); + + it('N2 base 출처 + props 바인딩 → base', () => { + const node: EditorNode = { + name: 'Div', + __source: { kind: 'base' }, + props: { className: '{{theme}}' }, + }; + const kind = classifyLockKind(node, 'route'); + expect(kind).toBe('base'); + expect(menu(kind)).toBe(false); + expect(drag(kind)).toBe(false); + }); + + it('N3 base 출처 + iteration → base (반복 항목 편집 진입도 함께 닫힌다)', () => { + const node: EditorNode = { + name: 'List', + __source: { kind: 'base' }, + iteration: { source: '{{recent.data}}' }, + }; + const kind = classifyLockKind(node, 'route'); + expect(kind).toBe('base'); + expect(menu(kind)).toBe(false); + expect(drag(kind)).toBe(false); + }); + + it('N4 extension 출처 + 바인딩 → extension', () => { + const node: EditorNode = { + name: 'Span', + __source: { kind: 'extension', extensionId: 35 }, + text: '{{content}}', + }; + const kind = classifyLockKind(node, 'route'); + expect(kind).toBe('extension'); + expect(menu(kind)).toBe(false); + expect(drag(kind)).toBe(false); + }); + + it('N5 회귀 가드 — route 출처 + props 바인딩은 data_bound (편집 허용)', () => { + const node: EditorNode = { + name: 'Img', + __source: { kind: 'route' }, + props: { src: '{{product.image}}' }, + }; + const kind = classifyLockKind(node, 'route'); + expect(kind).toBe('data_bound'); + expect(menu(kind)).toBe(true); + expect(drag(kind)).toBe(true); + }); + + it('N6 회귀 가드 — route 출처 + iteration 도 data_bound (편집 허용)', () => { + const node: EditorNode = { + name: 'Div', + __source: { kind: 'route' }, + iteration: { source: '{{posts.data}}' }, + }; + const kind = classifyLockKind(node, 'route'); + expect(kind).toBe('data_bound'); + expect(menu(kind)).toBe(true); + expect(drag(kind)).toBe(true); + }); + + it('N7 회귀 가드 — 조상이 route 출처 iteration 이면 data_bound', () => { + const node: EditorNode = { name: 'Span' }; + const ancestors: EditorNode[] = [ + { name: 'List', __source: { kind: 'route' }, iteration: { source: '{{posts.data}}' } }, + ]; + const kind = classifyLockKind(node, 'route', undefined, ancestors); + expect(kind).toBe('data_bound'); + expect(menu(kind)).toBe(true); + }); + + it('N8 회귀 가드 — __source 미부여(신규 삽입) + 바인딩은 data_bound', () => { + const node: EditorNode = { name: 'Span', text: '{{x}}' }; + const kind = classifyLockKind(node, 'route'); + expect(kind).toBe('data_bound'); + expect(menu(kind)).toBe(true); + }); + + it('N9 회귀 가드 — 조상만 base 이고 자신은 미태깅이면 none (조상은 보지 않는다)', () => { + const node: EditorNode = { name: 'Span' }; + const ancestors: EditorNode[] = [{ name: 'Div', __source: { kind: 'base' } }]; + const kind = classifyLockKind(node, 'route', undefined, ancestors); + expect(kind).toBe('none'); + expect(menu(kind)).toBe(true); + expect(drag(kind)).toBe(true); + }); + + it('isEditableLockKind / resolveDndDenial 이 같은 판정을 공유한다 (조건 복사 금지)', () => { + const kinds: SelectionLockKind[] = [ + 'none', + 'data_bound', + 'base', + 'partial', + 'extension', + 'extension_point', + ]; + for (const k of kinds) { + expect(resolveDndDenial(k) === null).toBe(isEditableLockKind(k)); + expect(isContextMenuAllowed(k)).toBe(isEditableLockKind(k)); + } + expect(resolveDndDenial('base')).toBe('denied_base_locked'); + expect(resolveDndDenial('partial')).toBe('denied_base_locked'); + expect(resolveDndDenial('extension')).toBe('denied_extension_locked'); + expect(resolveDndDenial('extension_point')).toBe('denied_extension_locked'); + }); +}); diff --git a/resources/js/core/template-engine/layout-editor/__tests__/spec/coreProps.dataKey.test.ts b/resources/js/core/template-engine/layout-editor/__tests__/spec/coreProps.dataKey.test.ts index 8d72620b..4bf558ba 100644 --- a/resources/js/core/template-engine/layout-editor/__tests__/spec/coreProps.dataKey.test.ts +++ b/resources/js/core/template-engine/layout-editor/__tests__/spec/coreProps.dataKey.test.ts @@ -47,4 +47,21 @@ describe('coreProps — dataKey', () => { expect(CORE_PROP_CONTROLS.dataKey.label).toContain('layout_editor.core_props.dataKey'); expect(CORE_PROP_CONTROLS.dataKey.placeholder).toContain('layout_editor.core_props.dataKey'); }); + + // nodeKey apply 구현으로 격리 2키가 ControlRenderer 경유로도 렌더 가능해졌다. + // 그러면 「격리 영역」 전용 UI 와 같은 노드 키를 두 경로가 쓰게 되고, 그 순간 값 타입이 + // 갈린다 — IsolatedScopeControl 은 ON 시 `{}`(빈 객체), toggle 위젯은 `true`. + it('5-12 전용 UI 소유 키(isolatedState)는 렌더 목록에서 제외한다 (이중 경로 차단)', () => { + expect(resolveCorePropKeys(['id', 'isolatedState'])).toEqual(['id']); + expect(resolveCorePropKeys(['id', 'isolatedScopeId'])).toEqual(['id']); + expect(resolveCorePropKeys(['isolatedState', 'isolatedScopeId'])).toEqual([]); + }); + + it('5-13 제외는 격리 2키에만 — id·dataKey 는 회귀 없음', () => { + expect(resolveCorePropKeys(['id', 'dataKey'])).toEqual(['id', 'dataKey']); + expect(resolveCorePropKeys(undefined)).toEqual(['id']); + // SSoT 선언 자체는 남는다 — 전용 UI 가 이 정의를 읽는다. + expect(CORE_PROP_CONTROLS.isolatedState).toBeTruthy(); + expect(CORE_PROP_CONTROLS.isolatedScopeId).toBeTruthy(); + }); }); diff --git a/resources/js/core/template-engine/layout-editor/__tests__/spec/recipeEngine.test.ts b/resources/js/core/template-engine/layout-editor/__tests__/spec/recipeEngine.test.ts index 6f996324..ebbe4724 100644 --- a/resources/js/core/template-engine/layout-editor/__tests__/spec/recipeEngine.test.ts +++ b/resources/js/core/template-engine/layout-editor/__tests__/spec/recipeEngine.test.ts @@ -1,3 +1,7 @@ +// @scenario apply_type=cssVar, consumer=none, storage_scope=template_layouts, stored_shape=object, widget_output=image_object +// @scenario apply_type=propValue, consumer=none, storage_scope=template_layouts, stored_shape=string, widget_output=scalar_string +// @scenario apply_type=propValue, consumer=none, storage_scope=template_layouts, stored_shape=string, widget_output=image_object_empty_url +// @scenario apply_type=classToken, consumer=none, storage_scope=template_layouts, stored_shape=absent, widget_output=undefined_cleared /** * recipeEngine.test.ts — 컨트롤 레시피 ↔ 노드 패치 변환 * @@ -528,3 +532,335 @@ describe('propValue 임의 prop 편집 (icon-picker / options-list / text)', () expect(out).toBe(node); }); }); + +// ============================================================================ +// image 위젯 × 단일 값 슬롯 — 값 축약 / 역조립 (공개 #135) +// +// `image` 위젯은 배경 이미지용으로 설계되어 `{url,size,repeat,position}` **객체**를 +// 내보낸다. 그 값을 노드에 기록하는 apply 4종 중 `styleProp` 의 다중 props(배경 묶음) +// 만 객체를 4속성으로 분해했고, `propValue`·`cssVar`·단일 `styleProp` 은 객체를 그대로 +// 기록했다 → 소비 컴포넌트가 `` 로 받아 `[object Object]` 가 URL 이 됐다. +// +// 게이트는 **위젯 이름**(`widget === 'image'`)이며 값 형태 sniffing 이 아니다 — +// `isImageValueObject` 는 4키 중 하나만 있어도 참이라, 값만 보면 `{position:'left'}` +// 같은 정당한 객체 prop 을 이미지로 오인해 삭제한다(1-6/1-7 이 그 가드다). +// ============================================================================ +describe('image 위젯 × 단일 값 슬롯 (공개 #135)', () => { + /** 실물 `hdrLogo` — sirsoft-basic 헤더 「로고 이미지」 */ + const logoCtrl: EditorControlSpec = { + widget: 'image', + apply: { type: 'propValue', propKey: 'logo' }, + }; + const bgBundle: EditorControlSpec = { + widget: 'image', + group: 'bg-image', + apply: { + type: 'styleProp', + props: ['backgroundImage', 'backgroundSize', 'backgroundRepeat', 'backgroundPosition'], + }, + }; + + /** @effects image_object_narrows_to_url_string_in_propvalue_slot */ + it('1-1 값 객체를 url 문자열로 축약해 props 에 기록한다', () => { + const next = applyRecipe({ name: 'Header' }, logoCtrl, { + url: '/a.png', + size: 'cover', + repeat: 'no-repeat', + position: 'center', + }); + expect(next.props?.logo).toBe('/a.png'); + expect(typeof next.props?.logo).toBe('string'); + }); + + /** @effects legacy_css_url_wrapping_is_stripped_for_component_prop_sink */ + it('1-2 레거시 url(...) 래핑을 벗긴다 (컴포넌트 prop 은 CSS 문맥이 아니다)', () => { + const next = applyRecipe({ name: 'Header' }, logoCtrl, { url: 'url(/a.png)' }); + expect(next.props?.logo).toBe('/a.png'); + }); + + /** @effects image_object_without_url_or_with_empty_url_deletes_the_prop */ + it('1-3 url 없이 모드만 담긴 값은 prop 을 삭제한다 (기존 빈값 술어에 위임)', () => { + const seeded: EditorNode = { name: 'Header', props: { logo: '/old.png' } }; + expect(applyRecipe(seeded, logoCtrl, { size: 'contain' }).props?.logo).toBeUndefined(); + }); + + it('1-4 빈 url 은 prop 을 삭제한다', () => { + expect(applyRecipe({ name: 'Header' }, logoCtrl, { url: '' }).props?.logo).toBeUndefined(); + }); + + it('1-5 undefined(기본으로 되돌리기) 는 prop 을 삭제한다', () => { + const seeded: EditorNode = { name: 'Header', props: { logo: '/old.png' } }; + expect(applyRecipe(seeded, logoCtrl, undefined).props?.logo).toBeUndefined(); + }); + + /** @effects non_image_widget_object_and_array_props_are_preserved_intact */ + it('1-6 오탐 가드 — 비-image 위젯의 객체 prop 은 통째로 보존한다', () => { + // `{position:'left'}` 는 isImageValueObject 를 통과한다(4키 중 하나 보유). + // 값 sniffing 으로 게이트했다면 여기서 정당한 prop 이 삭제됐을 것이다. + const tooltipCtrl: EditorControlSpec = { + widget: 'select', + apply: { type: 'propValue', propKey: 'tooltip' }, + }; + const next = applyRecipe({ name: 'Button' }, tooltipCtrl, { position: 'left' }); + expect(next.props?.tooltip).toEqual({ position: 'left' }); + }); + + it('1-7 오탐 가드 — options-list 배열은 그대로 보존한다', () => { + const optionsCtrl: EditorControlSpec = { + widget: 'options-list', + apply: { type: 'propValue', propKey: 'options' }, + }; + const next = applyRecipe({ name: 'Select' }, optionsCtrl, [{ value: 'a' }]); + expect(next.props?.options).toEqual([{ value: 'a' }]); + }); + + /** @effects image_object_narrows_to_wrapped_css_url_in_cssvar_and_single_styleprop */ + it('1-8 cssVar 슬롯은 CSS 문맥이므로 url(...) 로 감싼다', () => { + const heroVar: EditorControlSpec = { + widget: 'image', + apply: { type: 'cssVar', varName: '--hero' }, + }; + const next = applyRecipe({ name: 'Div' }, heroVar, { url: '/a.png', size: 'cover' }); + expect((next.props?.style as Record)['--hero']).toBe('url(/a.png)'); + }); + + it('1-9 단일 styleProp 슬롯도 CSS 문맥이므로 url(...) 로 감싼다', () => { + const singleBg: EditorControlSpec = { + widget: 'image', + apply: { type: 'styleProp', prop: 'backgroundImage' }, + }; + const next = applyRecipe({ name: 'Div' }, singleBg, { url: '/a.png', size: 'cover' }); + expect((next.props?.style as Record).backgroundImage).toBe('url(/a.png)'); + }); + + /** @effects styleprop_bundle_four_property_decomposition_is_unchanged */ + it('1-10 bundle(다중 props) 경로는 무회귀 — 4속성 분해가 그대로', () => { + const value = { url: '/a.png', size: 'cover', repeat: 'no-repeat', position: 'center' }; + const style = applyRecipe({ name: 'Div' }, bgBundle, value).props?.style as Record< + string, + unknown + >; + expect(style).toEqual({ + backgroundImage: 'url(/a.png)', + backgroundSize: 'cover', + backgroundRepeat: 'no-repeat', + backgroundPosition: 'center', + }); + }); + + /** @effects apply_fixed_value_wins_over_control_value_then_gets_narrowed */ + it('1-11 apply.value 고정값이 값보다 우선하고, 그 뒤에 축약이 적용된다', () => { + const fixed: EditorControlSpec = { + widget: 'image', + apply: { type: 'propValue', propKey: 'logo', value: '/fixed.png' }, + }; + expect(applyRecipe({ name: 'Header' }, fixed, { url: '/x.png' }).props?.logo).toBe( + '/fixed.png', + ); + }); + + /** @effects stored_string_is_rewrapped_as_url_object_for_the_widget */ + it('2-1 저장된 문자열을 위젯이 이해하는 객체로 되감는다', () => { + const node: EditorNode = { name: 'Header', props: { logo: '/a.png' } }; + expect(reverseResolve(node, logoCtrl)).toEqual({ value: { url: '/a.png' }, matched: true }); + }); + + it('2-2 값이 없으면 미매칭', () => { + expect(reverseResolve({ name: 'Header', props: {} }, logoCtrl)).toEqual({ + value: undefined, + matched: false, + }); + }); + + /** @effects binding_expression_is_rewrapped_so_one_click_upload_cannot_silently_lose_it */ + it('2-3 표현식 문자열도 감싼다 — 빈 피커로 보여 1클릭에 소실되지 않도록', () => { + const expr = '{{_global.settings?.general?.site_logo_url}}'; + const node: EditorNode = { name: 'Header', props: { logo: expr } }; + expect(reverseResolve(node, logoCtrl)).toEqual({ value: { url: expr }, matched: true }); + }); + + it('2-4 레거시 url(...) 저장값은 언래핑해 되감는다', () => { + const node: EditorNode = { name: 'Header', props: { logo: 'url(/a.png)' } }; + expect(reverseResolve(node, logoCtrl)).toEqual({ value: { url: '/a.png' }, matched: true }); + }); + + /** @effects legacy_object_stored_value_is_returned_losslessly */ + it('2-5 레거시 객체 저장값은 무손실로 그대로 돌려준다', () => { + const legacy = { url: '/a.png', size: 'cover' }; + const node: EditorNode = { name: 'Header', props: { logo: legacy } }; + expect(reverseResolve(node, logoCtrl)).toEqual({ value: legacy, matched: true }); + }); + + /** @effects non_image_widget_values_are_not_rewrapped */ + it('2-6 비-image 위젯은 감싸지 않는다 (문자열 그대로)', () => { + const widthProp: EditorControlSpec = { + widget: 'select', + apply: { type: 'propValue', propKey: 'size' }, + }; + const node: EditorNode = { name: 'Button', props: { size: 'sm' } }; + expect(reverseResolve(node, widthProp)).toEqual({ value: 'sm', matched: true }); + }); + + /** @effects node_axis_roundtrip_is_a_fixed_point_after_first_pass */ + it('2-7 노드 축 고정점 — apply → reverse → apply 2회차가 1회차와 동일', () => { + const first = applyRecipe({ name: 'Header' }, logoCtrl, { + url: '/a.png', + size: 'cover', + repeat: 'no-repeat', + position: 'center', + }); + const back = reverseResolve(first, logoCtrl); + const second = applyRecipe(first, logoCtrl, back.value); + expect(second).toEqual(first); + }); + + /** @effects dark_scope_stays_readonly_for_inline_apply */ + it('2-8 다크 scope 는 인라인이라 읽기 전용', () => { + const node: EditorNode = { name: 'Header', props: { logo: '/a.png' } }; + expect(reverseResolve(node, logoCtrl, { colorScheme: 'dark', breakpoint: 'base' })).toEqual({ + value: undefined, + matched: false, + darkReadonly: true, + }); + }); +}); + +// ============================================================================ +// number 위젯 값 — propValue 숫자 기록 (A1) +// +// `applyPropValue` 는 값을 가공하지 않으므로 위젯이 `number` 를 내보내야 한다. +// `0` 은 유효값이며 빈값 술어(`''|null|undefined`)에 걸리지 않는다. +// ============================================================================ +describe('number 위젯 값 — propValue 숫자 기록', () => { + const maxBoards: EditorControlSpec = { + widget: 'number', + apply: { type: 'propValue', propKey: 'maxVisibleBoards' }, + }; + + it('4-1 숫자를 그대로 props 에 기록한다 (문자열로 변질되지 않음)', () => { + const next = applyRecipe({ name: 'Header' }, maxBoards, 5); + expect(next.props?.maxVisibleBoards).toBe(5); + expect(typeof next.props?.maxVisibleBoards).toBe('number'); + }); + + it('4-2 0 은 유효값이라 삭제되지 않는다', () => { + const next = applyRecipe({ name: 'Header' }, maxBoards, 0); + expect(next.props?.maxVisibleBoards).toBe(0); + }); + + it('4-3 빈 문자열·undefined 는 prop 을 삭제한다', () => { + const seeded: EditorNode = { name: 'Header', props: { maxVisibleBoards: 5 } }; + expect(applyRecipe(seeded, maxBoards, '').props?.maxVisibleBoards).toBeUndefined(); + expect(applyRecipe(seeded, maxBoards, undefined).props?.maxVisibleBoards).toBeUndefined(); + }); + + it('4-4 라운드트립 — 숫자 그대로 역해석', () => { + const applied = applyRecipe({ name: 'Header' }, maxBoards, 7); + expect(reverseResolve(applied, maxBoards)).toEqual({ value: 7, matched: true }); + // 0 도 역해석된다(undefined 와 구분). + const zero = applyRecipe({ name: 'Header' }, maxBoards, 0); + expect(reverseResolve(zero, maxBoards)).toEqual({ value: 0, matched: true }); + }); +}); + +// ============================================================================ +// nodeKey apply — 노드 최상위 구조키 패치 (A2) +// +// `coreProps.ts` 가 `{type:'nodeKey', nodeKey:'dataKey'}` 를 선언했는데 엔진 switch 에 +// case 가 없어 **무음 no-op** 이었다 — 값을 넣어도 아무 일도 일어나지 않고 역해석도 +// 항상 undefined 였다. props 로 흘리면 `props.dataKey` 가 돼 런타임이 영영 읽지 않는다. +// ============================================================================ +describe('nodeKey apply — 노드 최상위 구조키 (A2)', () => { + const dataKeyCtrl: EditorControlSpec = { + widget: 'core-datakey', + apply: { type: 'nodeKey', nodeKey: 'dataKey' } as unknown as string, + }; + + it('5-1 노드 최상위에 기록하고 props 를 오염시키지 않는다', () => { + const next = applyRecipe({ name: 'Form' }, dataKeyCtrl, 'orderer') as EditorNode & + Record; + expect(next.dataKey).toBe('orderer'); + expect(next.props?.dataKey).toBeUndefined(); + }); + + it('5-2 빈 문자열은 키를 삭제한다', () => { + const seeded = { name: 'Form', dataKey: 'orderer' } as EditorNode; + const next = applyRecipe(seeded, dataKeyCtrl, '') as EditorNode & Record; + expect('dataKey' in next).toBe(false); + }); + + it('5-3 undefined 도 키를 삭제한다', () => { + const seeded = { name: 'Form', dataKey: 'orderer' } as EditorNode; + const next = applyRecipe(seeded, dataKeyCtrl, undefined) as EditorNode & + Record; + expect('dataKey' in next).toBe(false); + }); + + it('5-4 역해석 — 노드 최상위에서 읽는다', () => { + const node = { name: 'Form', dataKey: 'orderer' } as EditorNode; + expect(reverseResolve(node, dataKeyCtrl)).toEqual({ value: 'orderer', matched: true }); + }); + + it('5-5 역해석 — 값이 없으면 미매칭', () => { + expect(reverseResolve({ name: 'Form' }, dataKeyCtrl)).toEqual({ + value: undefined, + matched: false, + }); + }); + + it('5-6 예약키 가드 — nodeKey:"children" 은 no-op (노드 파괴 차단)', () => { + const evil: EditorControlSpec = { + widget: 'text', + apply: { type: 'nodeKey', nodeKey: 'children' } as unknown as string, + }; + const node: EditorNode = { name: 'Div', children: [{ name: 'Span' }] }; + const out = applyRecipe(node, evil, 'boom'); + expect(out).toBe(node); // 참조 동일 — 사본조차 만들지 않는다 + expect(node.children).toEqual([{ name: 'Span' }]); + expect(reverseResolve(node, evil)).toEqual({ value: undefined, matched: false }); + }); + + it('5-7 디바이스 scope 도 최상위에 쓴다 (responsive 브랜치는 런타임이 안 읽는다)', () => { + const next = applyRecipe({ name: 'Form' }, dataKeyCtrl, 'orderer', { + colorScheme: 'light', + breakpoint: 'mobile', + }) as EditorNode & Record; + expect(next.dataKey).toBe('orderer'); + expect(next.responsive).toBeUndefined(); + }); + + it('5-8 디바이스 scope 역해석도 최상위에서 — placeholder 흐림을 만들지 않는다', () => { + const node = { name: 'Form', dataKey: 'orderer' } as EditorNode; + expect( + reverseResolve(node, dataKeyCtrl, { colorScheme: 'light', breakpoint: 'mobile' }), + ).toEqual({ value: 'orderer', matched: true }); + }); + + it('5-9 다크 scope 는 no-op (인라인 무손실 보존)', () => { + const node = { name: 'Form', dataKey: 'orderer' } as EditorNode; + expect(applyRecipe(node, dataKeyCtrl, 'other', { colorScheme: 'dark', breakpoint: 'base' })).toBe( + node, + ); + }); + + it('5-10 입력 노드는 변경되지 않는다 (불변)', () => { + const node = { name: 'Form' } as EditorNode; + const snapshot = JSON.stringify(node); + applyRecipe(node, dataKeyCtrl, 'orderer'); + expect(JSON.stringify(node)).toBe(snapshot); + }); + + it('5-11 비-문자열/빈 nodeKey 는 no-op', () => { + const bad: EditorControlSpec = { + widget: 'text', + apply: { type: 'nodeKey', nodeKey: 42 } as unknown as string, + }; + const node: EditorNode = { name: 'Form' }; + expect(applyRecipe(node, bad, 'x')).toBe(node); + const empty: EditorControlSpec = { + widget: 'text', + apply: { type: 'nodeKey', nodeKey: '' } as unknown as string, + }; + expect(applyRecipe(node, empty, 'x')).toBe(node); + }); +}); diff --git a/resources/js/core/template-engine/layout-editor/__tests__/spec/widgetRegistry.test.ts b/resources/js/core/template-engine/layout-editor/__tests__/spec/widgetRegistry.test.ts index 75fbcd83..5a8de6b4 100644 --- a/resources/js/core/template-engine/layout-editor/__tests__/spec/widgetRegistry.test.ts +++ b/resources/js/core/template-engine/layout-editor/__tests__/spec/widgetRegistry.test.ts @@ -60,6 +60,14 @@ describe('registerCoreWidgets — Phase 4 위젯 7종', () => { expect(isCoreWidgetsRegistered()).toBe(true); }); + it('4-5 number 위젯을 등록한다 (미등록 시 「지원하지 않는 컨트롤」 폴백)', () => { + // `widget:"number"` 컨트롤(예 Header 「탭 표시 게시판 수」)이 속성 모달에서 편집 + // 불가였던 원인. 레지스트리 등록만이 그 폴백을 없앤다. + registerCoreWidgets(); + expect(getWidget('number')).toBeTruthy(); + expect(getRegisteredWidgetNames()).toContain('number'); + }); + it('component-target-picker 위젯을 등록한다', () => { // 캔버스 컴포넌트 영역 picker. [로딩 화면] target/fallback·navigate transition_overlay_target· // 향후 요소 ID param 공용. editor-spec param widget 타입으로 어느 폼에서나 선언 가능. diff --git a/resources/js/core/template-engine/layout-editor/components/DndCanvasLayer.tsx b/resources/js/core/template-engine/layout-editor/components/DndCanvasLayer.tsx index d54e0912..3627e44d 100644 --- a/resources/js/core/template-engine/layout-editor/components/DndCanvasLayer.tsx +++ b/resources/js/core/template-engine/layout-editor/components/DndCanvasLayer.tsx @@ -37,8 +37,12 @@ import { type OverlayBox, } from '../utils/overlayGeometry'; import { isDraggableNode } from '../dnd/nestingRules'; -import { findNodeByPath, isInsideIterationInstance, serializeEditorPath, isResponsiveSegment, type EditorNode, type ComponentPath } from '../utils/layoutTreeUtils'; -import { classifyLockKind, parseEditorPath } from '../hooks/useElementSelection'; +import { collectAncestors, findNodeByPath, isInsideIterationInstance, serializeEditorPath, type EditorNode } from '../utils/layoutTreeUtils'; +import { + classifyLockKind, + isEditableLockKind, + parseEditorPath, +} from '../hooks/useElementSelection'; import { useCanvasDnd, type UseCanvasDndParams } from '../hooks/useCanvasDnd'; import { buildDropSlots, type DropSlot } from '../dnd/dropSlots'; import { dndHandleZIndex, DND_DROP_SLOT, DND_DRAG_OVERLAY } from '../utils/overlayZIndex'; @@ -311,7 +315,7 @@ export function DndCanvasLayer(props: DndCanvasLayerProps): React.ReactElement | // 제외 조건에서 data_bound 를 빼야 한다 — 종전에는 `classifyLockKind !== 'none'` // 으로 data_bound 까지 핸들을 막아, 데이터 바인딩 composite(상품 이미지 갤러리 등)가 // 선택·이동 불가였고 클릭이 조상 핸들에 가로채였다. - const ancestors = ancestorsOf(root, indexes); + const ancestors = collectAncestors(root, indexes); // 반복(iteration) 인스턴스 **내부** 노드는 핸들 제외 — 펼침 인스턴스를 개별로 // 선택/드래그하면 안 된다. 묶음 단위 편집은 아래 가상 묶음으로. // 예외: 반복 항목 편집 모드의 편집 대상 iteration 인스턴스 내부는 개별 핸들 허용. @@ -323,11 +327,7 @@ export function DndCanvasLayer(props: DndCanvasLayerProps): React.ReactElement | } const lockKind = classifyLockKind(node, editMode, currentExtensionId, ancestors); // 편집 대상 iteration 인스턴스 내부는 그 모드의 편집 대상이므로 잠금/데이터바운드 무관 허용. - if ( - lockKind !== 'none' && - lockKind !== 'data_bound' && - !isInsideEditableIteration(path, editableRootSourcePath) - ) { + if (!isEditableLockKind(lockKind) && !isInsideEditableIteration(path, editableRootSourcePath)) { return; } const box = measureOverlay(el, frameEl); @@ -353,9 +353,9 @@ export function DndCanvasLayer(props: DndCanvasLayerProps): React.ReactElement | if (!name) continue; // 원본 노드 자체의 잠금만 검사(base/partial/extension). 원본은 iteration 정의 // 노드라 data_bound 지만 대로 묶음 선택/이동은 허용. - const ancestors = ancestorsOf(root, indexes); + const ancestors = collectAncestors(root, indexes); const lockKind = classifyLockKind(ownerNode, editMode, currentExtensionId, ancestors); - if (lockKind !== 'none' && lockKind !== 'data_bound') continue; + if (!isEditableLockKind(lockKind)) continue; const box = unionBoxes(boxes); if (!box) continue; // 인스턴스를 frame 가시 영역으로 이미 걸렀으나, union 결과도 frame 과 겹치는지 @@ -782,23 +782,3 @@ function DraggableHandle(props: { ); } -/** path 조상 노드 배열(루트→부모, 자기 제외) — classifyLockKind ancestors 입력 */ -function ancestorsOf(root: EditorNode, path: ComponentPath): EditorNode[] { - const out: EditorNode[] = []; - let current: EditorNode = root; - let childArray: EditorNode[] = Array.isArray(root.children) ? (root.children as EditorNode[]) : []; - for (let i = 0; i < path.length - 1; i++) { - const seg = path[i]!; - if (isResponsiveSegment(seg)) { - const branch = current.responsive?.[seg.responsive]; - childArray = branch && Array.isArray(branch.children) ? (branch.children as EditorNode[]) : []; - continue; - } - const next = childArray[seg] ?? null; - if (!next) break; - out.push(next); - current = next; - childArray = Array.isArray(next.children) ? (next.children as EditorNode[]) : []; - } - return out; -} diff --git a/resources/js/core/template-engine/layout-editor/components/EditorCanvasOverlay.tsx b/resources/js/core/template-engine/layout-editor/components/EditorCanvasOverlay.tsx index 7f2764a9..a16c4c2c 100644 --- a/resources/js/core/template-engine/layout-editor/components/EditorCanvasOverlay.tsx +++ b/resources/js/core/template-engine/layout-editor/components/EditorCanvasOverlay.tsx @@ -18,12 +18,13 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { useLayoutEditor } from '../LayoutEditorContext'; -import type { RouteTreeNode } from '../LayoutEditorContext'; import { useLayoutDocumentContext } from '../LayoutDocumentContext'; import { useElementSelection, parseEditorPath, isContextMenuAllowed, + isEditableLockKind, + classifyLockKind, } from '../hooks/useElementSelection'; import { useInsertionPoints, type InsertionPoint } from '../hooks/useInsertionPoints'; import { useEditorHistory } from '../hooks/useEditorHistory'; @@ -35,6 +36,7 @@ import { type OverlayBox, } from '../utils/overlayGeometry'; import { + collectAncestors, duplicateNode as duplicateNodeUtil, insertNode, removeNode, @@ -299,6 +301,16 @@ export function EditorCanvasOverlay(props: EditorCanvasOverlayProps): React.Reac if (!pathIdx) return; const root: EditorNode = { children: liveDataRef.current.components }; const node = findNodeByPath(root, pathIdx); + // 출처 잠금 가드 — 상속(base)·주입(extension) 노드는 인라인 편집해도 저장 시 + // `stripInheritedNode` 가 통째로 폐기해 편집분이 조용히 사라진다. 진입 자체를 막고 + // 「🔒 공통 레이아웃 편집」/「🔒 확장 편집」 어포던스로 유도한다. + const lockKind = classifyLockKind( + node, + state.editMode, + currentExtensionId, + collectAncestors(root, pathIdx), + ); + if (!isEditableLockKind(lockKind)) return; const cls = inlineEdit.classify(node); if (!cls.editable) { trackEditorI18n({ @@ -341,7 +353,7 @@ export function EditorCanvasOverlay(props: EditorCanvasOverlayProps): React.Reac timestamp: Date.now(), }); }, - [frameEl, inlineEdit], + [frameEl, inlineEdit, state.editMode, currentExtensionId], ); // 코어 placeholder 오버레이는 회수됨. 신규 노드 시각화는 템플릿의 @@ -999,6 +1011,8 @@ export function EditorCanvasOverlay(props: EditorCanvasOverlayProps): React.Reac // 컨텍스트 메뉴 — 복사 / 삭제 const handleDuplicate = useCallback((): void => { if (!docCtx || !selection.selectedNode || !selectedPathIndexes) return; + // 출처 잠금 가드 — 사본도 `__source` 를 물고 가 저장 시 폐기된다(무반영 복제). + if (!isEditableLockKind(selection.selectedLockKind)) return; const dup = duplicateNodeUtil(selection.selectedNode); let nextComponentsCaptured: EditorNode[] = []; docCtx.patchLayout((current) => { @@ -1011,10 +1025,13 @@ export function EditorCanvasOverlay(props: EditorCanvasOverlayProps): React.Reac return nextComponents; }); history.push({ actionKind: 'insert', label: 'duplicate', snapshot: nextComponentsCaptured }); - }, [docCtx, selection.selectedNode, selectedPathIndexes, history]); + }, [docCtx, selection.selectedNode, selection.selectedLockKind, selectedPathIndexes, history]); const handleDelete = useCallback((): void => { if (!docCtx || !selectedPathIndexes) return; + // 출처 잠금 가드 — 키보드 `Delete` 는 ⓘ 메뉴를 거치지 않아 무방비였다. 상속·주입 노드는 + // 지워도 저장에 반영되지 않으므로(마스킹이 어차피 되살린다) 조작 자체를 막는다. + if (!isEditableLockKind(selection.selectedLockKind)) return; let nextComponentsCaptured: EditorNode[] = []; docCtx.patchLayout((current) => { const root: EditorNode = { children: current }; @@ -1151,9 +1168,12 @@ export function EditorCanvasOverlay(props: EditorCanvasOverlayProps): React.Reac // 잘라내기: 복사 후 선택 노드 삭제. const handleCut = useCallback((): void => { if (!selection.selectedNode) return; + // 출처 잠금 가드 — 잘라내기는 삭제를 동반하므로 같은 기준으로 막는다. `handleDelete` + // 안의 가드에만 기대면 "복사는 됐는데 원본이 남는" 어긋난 상태가 된다. + if (!isEditableLockKind(selection.selectedLockKind)) return; writeClipboard(selection.selectedNode); handleDelete(); - }, [selection.selectedNode, handleDelete]); + }, [selection.selectedNode, selection.selectedLockKind, handleDelete]); // 붙여넣기: 버퍼 노드를 선택 노드의 **다음 형제**로 삽입(선택 없으면 루트 끝). 다른 // 레이아웃으로 이동해도 sessionStorage 라 동작. duplicateNodeUtil 로 새 id 부여(중복 id 회피). diff --git a/resources/js/core/template-engine/layout-editor/components/property-controls/ControlRenderer.tsx b/resources/js/core/template-engine/layout-editor/components/property-controls/ControlRenderer.tsx index 0f45a99d..97421de1 100644 --- a/resources/js/core/template-engine/layout-editor/components/property-controls/ControlRenderer.tsx +++ b/resources/js/core/template-engine/layout-editor/components/property-controls/ControlRenderer.tsx @@ -22,6 +22,7 @@ import { applyRecipe, reverseResolve } from '../../spec/recipeEngine'; import { BASE_SCOPE, isDarkEditable, type StyleScope } from '../../spec/styleScope'; import { I18nTextField } from './I18nTextField'; import { DataChipValueInput } from '../page-settings/DataChipValueInput'; +import { useBoundValueGuard, BoundValueNotice, BoundValueRestore } from './boundValueGuard'; export interface ControlRendererProps { /** 컨트롤 키 (`textAlign` 등) — 라벨 fallback 에 사용 */ @@ -60,6 +61,19 @@ function resolveLabel(controlKey: string, control: EditorControlSpec, t: Control return controlKey; } +/** + * 자체 바인딩 처리를 가진 위젯 — `ControlRenderer` 의 공용 게이트를 타지 않는다. + * + * 새 위젯을 여기에 넣기 전에 **그 위젯이 실제로 원문 표시·해제·복구 셋을 모두 제공하는지** + * 확인한다. 그렇지 않은데 등재하면 공용 보호가 그 위젯에서만 사라진다. + */ +const SELF_GUARDED_WIDGETS: ReadonlySet = new Set([ + 'image', // ImagePickerControl — 배지 + 업로드/제거/갤러리/관리 잠금 + 되돌리기 + 'core-id', // CoreIdControl — chipEditing 디그레이드(선례) + 'i18n-text', // I18nTextField — 표현식 칩 분해가 설계된 처리 + 'text', // DataChipValueInput — 동일 +]); + export function ControlRenderer({ controlKey, control, @@ -122,6 +136,29 @@ export function ControlRenderer({ [node, control, onPatch, scope, darkReadonly], ); + /** + * 데이터 연결 값 보호 — **모든 위젯 공용 단일 게이트**. + * + * 저장값이 `{{...}}`·설정 참조이면 위젯은 그것을 해석하지 못해 빈 컨트롤로 보이고, + * 운영자가 조작하는 순간 **환경설정과의 연결**이 소리 없이 끊긴다. 원문은 화면 + * 어디에도 남지 않아 되돌릴 수단조차 없다. + * + * 이 판정을 위젯마다 넣으면 한 곳이 빠져도 오류가 나지 않고 그 한 곳이 우회로가 + * 된다(공개 #135 후속 실측에서 실제로 「이미지 관리」 진입 하나만 열려 있었다). + * 그래서 위젯이 아니라 **여기 한 곳**에서 건다 — 새 위젯을 등록해도 자동 적용된다. + */ + const boundGuard = useBoundValueGuard(resolution.value, handleChange); + + /** + * 자체 처리 위젯은 이 게이트를 타지 않는다. + * + * - `image` — 배지·잠금·복구를 위젯 안에서 더 세밀하게 제공한다(갤러리·업로드까지 잠금) + * - `core-id` — `chipEditing` 으로 같은 형태의 디그레이드를 이미 갖는다 + * - `i18n-text`/`text`(propValue) — 위 분기에서 표현식을 **칩으로 분해해 보여 주는** 것이 + * 설계된 처리다. 여기서 가리면 그 기능이 통째로 사라진다. + */ + const guardApplies = !SELF_GUARDED_WIDGETS.has(control.widget ?? ''); + return (
@@ -169,8 +206,26 @@ export function ControlRenderer({ > {t('layout_editor.property_modal.dark_code_only')} + ) : guardApplies && boundGuard.bound ? ( + // 데이터 연결 값 — 위젯은 이 문자열을 해석하지 못해 빈 컨트롤로 보이고, + // 조작하는 순간 연결이 소리 없이 끊긴다. 원문을 보여 주고 해제 경로로만 연다. + ) : Widget ? ( - + <> + + {guardApplies && boundGuard.replacing && boundGuard.original !== null && ( + + )} + ) : ( {t('layout_editor.property_modal.unsupported_widget')} diff --git a/resources/js/core/template-engine/layout-editor/components/property-controls/ImagePickerControl.tsx b/resources/js/core/template-engine/layout-editor/components/property-controls/ImagePickerControl.tsx index d8ac35f6..8c589c61 100644 --- a/resources/js/core/template-engine/layout-editor/components/property-controls/ImagePickerControl.tsx +++ b/resources/js/core/template-engine/layout-editor/components/property-controls/ImagePickerControl.tsx @@ -22,6 +22,8 @@ import React, { useCallback, useEffect, useRef, useState } from 'react'; import type { WidgetProps } from '../../spec/widgetRegistry'; +import type { EditorControlSpec } from '../../spec/specTypes'; +import { useBoundValueGuard, BoundValueNotice, BoundValueRestore } from './boundValueGuard'; import { useLayoutEditor } from '../../LayoutEditorContext'; import { listLayoutAttachments, @@ -55,8 +57,54 @@ function modeOf(v: ImageValue): string { return m?.value ?? 'fill'; } -export function ImagePickerControl({ value, onChange, t }: WidgetProps): React.ReactElement { +/** + * 이 컨트롤의 `apply` 가 **값 슬롯을 하나만** 가지는가. + * + * 그렇다면 `size`/`repeat`/`position` 을 저장할 곳이 없으므로 표시모드(채움/맞춤/타일) + * 버튼은 죽은 컨트롤이다 — 눌러도 저장되지 않는데 눌리는 표면이 남으면 "고칠 수 있는 + * 것처럼 보이지만 저장되지 않는" 상태가 된다. + * + * 판정 대상은 **control-level apply + 모든 option-level apply 의 합집합**이다. + * `control.apply` 만 보면 옵션-only 컨트롤에서 `undefined` → 보류 → 표시로 조용히 + * 잘못된 결론에 도달한다. + * + * **화이트리스트가 아니라 블랙리스트다** — `apply` 미선언(합집합이 공집합)이면 판정을 + * 보류하고 `false`(현행대로 표시)를 돌려준다. 화이트리스트("bundle 일 때만 표시")로 + * 짜면 apply 없이 렌더되는 기존 계약이 깨진다. + */ +function hasSingleValueSlot(control: EditorControlSpec | undefined): boolean { + if (!control) return false; + const applies: Array<{ type?: unknown; props?: unknown }> = []; + const own = control.apply as unknown; + if (own && typeof own === 'object') applies.push(own as { type?: unknown; props?: unknown }); + for (const opt of (control.options ?? []) as Array<{ apply?: unknown }>) { + if (opt && typeof opt === 'object' && opt.apply && typeof opt.apply === 'object') { + applies.push(opt.apply as { type?: unknown; props?: unknown }); + } + } + if (applies.length === 0) return false; // 판정 보류 — 현행 동작 보존 + return applies.every( + (a) => + a.type === 'propValue' || + a.type === 'cssVar' || + (a.type === 'styleProp' && !Array.isArray(a.props)), + ); +} + +export function ImagePickerControl({ control, value, onChange, t }: WidgetProps): React.ReactElement { const current = readValue(value); + /** 단일 값 슬롯 — size/repeat/position 을 저장할 자리가 없다 */ + const singleSlot = hasSingleValueSlot(control); + /** + * 데이터 연결 값 보호 — 판정·배지·해제·복구를 공용 프리미티브에 위임한다. + * 위젯마다 복붙하면 한 곳이 빠져도 오류가 나지 않고 그 한 곳이 우회로가 된다. + */ + const guard = useBoundValueGuard( + value, + (original) => onChange({ url: original }), + (v) => readValue(v).url, + ); + const bound = guard.bound; const { state } = useLayoutEditor(); const modal = useEditorModal(); const [uploading, setUploading] = useState(false); @@ -91,6 +139,12 @@ export function ImagePickerControl({ value, onChange, t }: WidgetProps): React.R onChange(undefined); return; } + // 단일 값 슬롯 — size/repeat/position 은 저장될 자리가 없다. 만들지 않으면 + // 엔진 축약(scalarizeImageValue)이 버릴 것도 없어 라운드트립이 애초에 대칭이 된다. + if (singleSlot) { + onChange({ url }); + return; + } const mode = DISPLAY_MODES.find((d) => d.value === modeOf(current)) ?? DISPLAY_MODES[0]; onChange({ url, @@ -155,21 +209,34 @@ export function ImagePickerControl({ value, onChange, t }: WidgetProps): React.R return (
- {current.url && ( -
+ ) : ( + current.url && ( +
)의 클래스가 정하므로 편집기가 흉내낼 수 없다. + backgroundSize: singleSlot ? 'contain' : current.size ?? 'cover', + backgroundRepeat: singleSlot ? 'no-repeat' : current.repeat ?? 'no-repeat', + backgroundPosition: singleSlot ? 'center' : current.position ?? 'center', + }} + /> + ) )}
-
@@ -191,33 +264,50 @@ export function ImagePickerControl({ value, onChange, t }: WidgetProps): React.R data-testid="g7le-image-url" placeholder="https://… / URL" value={urlDraft} + // 데이터 연결 값은 원문을 보이되 편집을 막는다 — 지워지지 않고 남는다. + readOnly={bound} onChange={(e) => setUrlDraft(e.target.value)} - onBlur={(e) => setUrl(e.target.value.trim() || undefined)} + onBlur={(e) => { + if (bound) return; + setUrl(e.target.value.trim() || undefined); + }} style={urlInput} /> -
- {DISPLAY_MODES.map((m) => { - const active = modeOf(current) === m.value; - return ( - - ); - })} -
+ {/* 보호를 해제한 동안의 편도 방지 — 아직 안 바꿨으면 취소로, 이미 값을 넣었으면 + 원래 연결값 복구로 동작한다. 이 경로가 없으면 실수로 한 번 누른 운영자가 + 원문을 되찾을 방법이 없다. */} + {guard.replacing && guard.original !== null && ( + + )} + + {/* 단일 값 슬롯이면 표시모드는 저장될 자리가 없다 — 컨테이너째 미렌더. + `disabled` 로 두면 "URL 을 넣으면 살아나겠지"라는 거짓 정보를 준다 + (기존 `disabled={!current.url}` 은 일시적 비활성이라 의미가 다르다). */} + {!singleSlot && ( +
+ {DISPLAY_MODES.map((m) => { + const active = modeOf(current) === m.value; + return ( + + ); + })} +
+ )} {/* 인라인 미니 갤러리 — 현재 레이아웃 첨부 썸네일 가로 스트립 + 관리 링크 */}
@@ -225,11 +315,15 @@ export function ImagePickerControl({ value, onChange, t }: WidgetProps): React.R {t('layout_editor.attachment_manager.recent')} + {/* 관리 모달은 각 카드에 「배경」 버튼을 띄우고 그 클릭이 같은 setUrl 을 부른다 — + 인라인 썸네일 「사용」과 동일 동작의 다른 렌더 위치다. 하나만 잠그면 + 나머지 하나가 조용한 우회로가 되므로 진입 자체를 함께 잠근다. */} @@ -241,8 +335,13 @@ export function ImagePickerControl({ value, onChange, t }: WidgetProps): React.R +
+
+ ); +} + /** * Spacing — 여백(안쪽/바깥쪽)의 **측별 독립 크기** 편집 (§항목B 재설계). * diff --git a/resources/js/core/template-engine/layout-editor/components/property-controls/boundValueGuard.tsx b/resources/js/core/template-engine/layout-editor/components/property-controls/boundValueGuard.tsx new file mode 100644 index 00000000..63b406d2 --- /dev/null +++ b/resources/js/core/template-engine/layout-editor/components/property-controls/boundValueGuard.tsx @@ -0,0 +1,193 @@ +/** + * boundValueGuard.tsx — 데이터 연결 값(바인딩 표현식) 보호 공용 프리미티브 + * + * 레이아웃의 prop 자리에는 `{{_global.settings?.general?.site_logo_url}}` 같은 **표현식 + * 문자열**이 저장돼 있을 수 있다. 그 값을 편집기 위젯이 그대로 읽으면 위젯은 그것을 + * 해석하지 못해 **빈 컨트롤**로 보이고, 운영자가 무심코 조작하는 순간 그 연결이 + * 소리 없이 사라진다 — 값 하나가 아니라 **환경설정과의 연결**이 끊기고, 원문이 화면 + * 어디에도 남지 않아 되돌릴 수단조차 없다. + * + * 그래서 바인딩 값은 ① 원문을 배지로 보여 주고 ② 파괴적 조작을 잠그고 + * ③ 「직접 지정으로 바꾸기」로만 명시적으로 열고 ④ 「되돌리기」로 원래 연결을 복구한다. + * + * **이 판정과 UI 를 위젯마다 복붙하지 않는다.** 복붙하면 한 곳이 빠져도 오류가 나지 + * 않고, 그 한 곳이 조용한 우회로가 된다(공개 #135 후속 실측에서 실제로 「이미지 관리」 + * 진입 하나만 열려 있었다). 새 위젯을 만들 때도 본 훅만 쓴다. + * + * 선례: `CoreIdControl`(chipEditing) · `I18nTextField`(settingsEditing) 이 같은 형태의 + * 디그레이드를 이미 갖고 있다. 본 모듈은 그 패턴을 위젯 공용으로 승격한 것이다. + * + * @since engine-v1.66.0 + */ + +import React, { useCallback, useState } from 'react'; +import { hasInlineBinding, hasSettingsRef } from '../../spec/inlineBindingUtils'; + +/** 다국어 해석 함수 — `WidgetProps.t` 와 동일 시그니처 */ +export type TranslateFn = (key: string, params?: Record) => string; + +/** + * 값이 데이터 연결(바인딩/설정 참조) 문자열인지 판정한다. + * + * 인라인 바인딩(`{{...}}`)과 설정 참조를 모두 본다 — 둘 다 위젯이 해석하지 못하고 + * 덮어쓰면 소실되는 형태다. + * + * @param value 판정할 값 (문자열이 아니면 false) + * @return 데이터 연결 문자열이면 true + */ +export function isBoundValue(value: unknown): value is string { + return typeof value === 'string' && (hasInlineBinding(value) || hasSettingsRef(value)); +} + +/** `useBoundValueGuard` 반환 계약 */ +export interface BoundValueGuard { + /** 지금 보호 상태인가 — true 면 파괴적 조작을 잠그고 배지를 렌더한다 */ + readonly bound: boolean; + /** 보호를 해제하고 편집 중인가 (「직접 지정으로 바꾸기」 이후) */ + readonly replacing: boolean; + /** 보호 해제 시점에 붙잡아 둔 원문 — 「되돌리기」의 복구 대상 */ + readonly original: string | null; + /** 「직접 지정으로 바꾸기」 — 원문을 붙잡고 편집을 연다 */ + readonly beginReplace: () => void; + /** 「되돌리기」 — 원문을 복구하고 보호 상태로 되돌린다 */ + readonly restore: () => void; +} + +/** + * 바인딩 값 보호 상태를 관리한다. + * + * 위젯의 값이 객체인 경우(예 `image` 는 `{url,…}`)를 위해 문자열 추출자를 받는다. + * + * @param rawValue 현재 값 (위젯이 받은 원본) + * @param onRestore 원문 복구를 위해 호출할 쓰기 함수. 값이 이미 원문과 같으면 호출하지 + * 않는다 — 바꾼 것이 없는데 history push 를 만들지 않기 위함이다. + * @param extract 값에서 판정 대상 문자열을 뽑는다 (기본: 값 자신) + * @return 보호 상태와 조작 + */ +export function useBoundValueGuard( + rawValue: unknown, + onRestore: (original: string) => void, + extract: (value: unknown) => unknown = (v) => v, +): BoundValueGuard { + const [replacing, setReplacing] = useState(false); + const [original, setOriginal] = useState(null); + + const current = extract(rawValue); + const bound = isBoundValue(current) && !replacing; + + const beginReplace = useCallback(() => { + // 해제 시점의 원문을 붙잡는다 — 이후 값이 바뀌어도 복구 대상은 이것이다. + setOriginal(isBoundValue(current) ? current : null); + setReplacing(true); + }, [current]); + + const restore = useCallback(() => { + if (original !== null && current !== original) onRestore(original); + setReplacing(false); + setOriginal(null); + }, [original, current, onRestore]); + + return { bound, replacing, original, beginReplace, restore }; +} + +const noticeWrap: React.CSSProperties = { + display: 'flex', + flexDirection: 'column', + gap: 4, + padding: '8px 10px', + border: '1px dashed #cbd5e1', + borderRadius: 6, + background: '#f8fafc', +}; + +const noticeCode: React.CSSProperties = { + fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace', + fontSize: 11, + color: '#0f172a', + wordBreak: 'break-all', +}; + +const noticeLink: React.CSSProperties = { + alignSelf: 'flex-start', + background: 'none', + border: 'none', + padding: 0, + fontSize: 11, + color: '#2563eb', + cursor: 'pointer', + textDecoration: 'underline', +}; + +/** + * 보호 상태에서 원문과 해제 경로를 보여 주는 공용 배지. + * + * 미리보기·입력칸을 대신해 렌더한다 — 위젯이 해석하지 못하는 값을 흉내 내면 거짓 + * 미리보기가 되기 때문이다. + * + * @param expression 표시할 원문 + * @param t 다국어 해석 함수 + * @param onReplace 「직접 지정으로 바꾸기」 클릭 핸들러 + * @param testIdPrefix testid 접두사 (위젯별 구분 — 예 `g7le-image`) + */ +export function BoundValueNotice({ + expression, + t, + onReplace, + testIdPrefix, +}: { + expression: string; + t: TranslateFn; + onReplace: () => void; + testIdPrefix: string; +}): React.ReactElement { + return ( +
+ + {expression} + + + {t('layout_editor.control.bound_value.notice')} + + +
+ ); +} + +/** + * 보호를 해제한 동안 노출하는 「되돌리기」 어포던스. + * + * 해제 직후(아직 안 바꿈)에는 취소로, URL 등을 이미 넣은 뒤에는 원래 연결값 복구로 + * 동작한다 — 둘 다 같은 버튼이다. 이 경로가 없으면 「직접 지정으로 바꾸기」가 편도가 + * 되어, 실수로 한 번 누른 운영자가 원문을 되찾을 방법이 없다. + * + * @param t 다국어 해석 함수 + * @param onRestore 「되돌리기」 클릭 핸들러 + * @param testIdPrefix testid 접두사 + */ +export function BoundValueRestore({ + t, + onRestore, + testIdPrefix, +}: { + t: TranslateFn; + onRestore: () => void; + testIdPrefix: string; +}): React.ReactElement { + return ( + + ); +} diff --git a/resources/js/core/template-engine/layout-editor/hooks/useCanvasDnd.ts b/resources/js/core/template-engine/layout-editor/hooks/useCanvasDnd.ts index e73ef104..8bba30cb 100644 --- a/resources/js/core/template-engine/layout-editor/hooks/useCanvasDnd.ts +++ b/resources/js/core/template-engine/layout-editor/hooks/useCanvasDnd.ts @@ -37,6 +37,7 @@ export interface DropZone { index: number; } import { + collectAncestors, findNodeByPath, isInsideIterationInstance, moveNode, @@ -47,7 +48,12 @@ import { type EditorNode, type ComponentPath, } from '../utils/layoutTreeUtils'; -import { classifyLockKind, parseEditorPath } from './useElementSelection'; +import { + classifyLockKind, + isEditableLockKind, + parseEditorPath, + resolveDndDenial, +} from './useElementSelection'; import { trackEditorDnd, type EditorDndDecision } from '../devtools/editorTrackers'; import type { NestingSpec } from '../spec/specTypes'; @@ -301,13 +307,15 @@ export function useCanvasDnd(params: UseCanvasDndParams): UseCanvasDndReturn { // 단, 편집 대상 iteration/모달(원본 노드 및 그 자손)은 그 모드의 편집 대상이므로 // data_bound 잠금을 무시하고 컨테이너로 허용한다. if (!isInsideEditableRootContainer) { - const ancestors = ancestorsOf(rootOf(live.components), path); + const ancestors = collectAncestors(rootOf(live.components), path); const lockKind = classifyLockKind( containerNode, live.editMode, live.currentExtensionId, ancestors ); + // 여기는 의도적으로 `data_bound` 도 거부한다 — 데이터가 결정하는 컨테이너 안에 + // 정적 노드를 넣으면 반복/바인딩 결과와 어긋난다(`isEditableLockKind` 보다 엄격). if (lockKind !== 'none') return false; } @@ -497,7 +505,7 @@ export function useCanvasDnd(params: UseCanvasDndParams): UseCanvasDndReturn { if (!name || !isDraggableNode(name, live.nesting)) { decision = 'denied_no_draggable'; } else if (node) { - const ancestors = ancestorsOf(rootOf(live.components), indexes); + const ancestors = collectAncestors(rootOf(live.components), indexes); const lockKind = classifyLockKind(node, live.editMode, live.currentExtensionId, ancestors); // 편집 루트 confine(modal/iteration_item) — 편집 대상 루트 서브트리 **밖** 노드의 드래그 // 시작을 거부한다. 선택 자체가 편집 루트로 제한되나(useElementSelection), @@ -520,9 +528,18 @@ export function useCanvasDnd(params: UseCanvasDndParams): UseCanvasDndReturn { } // 자신 바인딩 data_bound(상품 이미지 갤러리 등)는 명세상 선택·드래그·구조 // 편집 허용 — 위치 이동은 정당한 구조 편집이므로 막지 않는다. - else if (lockKind === 'base' || lockKind === 'partial') decision = 'denied_base_locked'; - else if (lockKind === 'extension' || lockKind === 'extension_point') - decision = 'denied_extension_locked'; + // 그 외 잠금 종류의 거부 사유는 `resolveDndDenial` 단일 지점이 정한다(조건 복사 금지). + else { + const denial = resolveDndDenial(lockKind); + if (denial) decision = denial; + } + } + + // 거부된 드래그는 `activeDragPath` 도 남기지 않는다 — 남으면 DragOverlay 가 잡힌 + // 노드를 따라다녀 "옮길 수 있다" 는 거짓 어포던스를 준다(종전 결함). + // `activeDragName` 은 지우지 않는다 — onDragEnd 가 그것으로 취소 사유를 적재한다. + if (decision !== 'allowed') { + setActiveDragPath(null); } trackEditorDnd({ @@ -558,7 +575,7 @@ export function useCanvasDnd(params: UseCanvasDndParams): UseCanvasDndReturn { setActiveDropZone(null); return; } - const ancestors = ancestorsOf(rootOf(live.components), indexes); + const ancestors = collectAncestors(rootOf(live.components), indexes); // 편집 루트 confine(modal/iteration_item) — 편집 대상 루트 밖 노드는 드롭존 미계산. if ( live.editableRootSourcePath && @@ -574,7 +591,7 @@ export function useCanvasDnd(params: UseCanvasDndParams): UseCanvasDndReturn { const insideEditableIter = isInsideEditableIteration(draggedPath, live.editableRootSourcePath); if ( (isInsideIterationInstance(ancestors) && !insideEditableIter) || - (moveLockKind !== 'none' && moveLockKind !== 'data_bound' && !insideEditableIter) + (!isEditableLockKind(moveLockKind) && !insideEditableIter) ) { setActiveDropZone(null); return; @@ -670,6 +687,35 @@ export function useCanvasDnd(params: UseCanvasDndParams): UseCanvasDndReturn { return; } + // 드래그 노드 출처 잠금 — commit 직전 최종 가드. + // + // 종전에는 `zone === null` 에 기댄 간접 방어뿐이라, stale 슬롯이나 유효 zone 이 들어오면 + // 상속·주입 노드가 그대로 이동 commit 됐다(그리고 저장 시 통째로 폐기됐다). + const draggedNodeAtEnd = findNodeByPath(rootOf(live.components), fromPath); + const endDenial = draggedNodeAtEnd + ? resolveDndDenial( + classifyLockKind( + draggedNodeAtEnd, + live.editMode, + live.currentExtensionId, + collectAncestors(rootOf(live.components), fromPath), + ), + ) + : null; + if (endDenial) { + trackEditorDnd({ + source: 'drag', + draggedComponentName: draggedName, + targetContainerName, + targetContainerPath: zone.containerPath || null, + decision: endDenial, + result: 'denied', + timestamp: Date.now(), + }); + finishDrag(); + return; + } + // no-op 가드 — 같은 위치면 변형/이력 생략. // // zone.index 는 **원본 트리 인덱스**. @@ -758,28 +804,6 @@ export function useCanvasDnd(params: UseCanvasDndParams): UseCanvasDndReturn { }; } -/** path 의 조상 노드 배열(루트→부모, 자기 자신 제외) — classifyLockKind 의 ancestors 입력 */ -function ancestorsOf(root: EditorNode, path: ComponentPath): EditorNode[] { - const out: EditorNode[] = []; - let current: EditorNode = root; - let childArray: EditorNode[] = Array.isArray(root.children) ? (root.children as EditorNode[]) : []; - // 마지막 세그먼트(자기 자신)는 제외. responsive 세그먼트는 노드를 내리지 않고 - // childArray 만 분기로 전환 — 조상 목록에 추가하지 않는다. - for (let i = 0; i < path.length - 1; i++) { - const seg = path[i]!; - if (isResponsiveSegment(seg)) { - const branch = current.responsive?.[seg.responsive]; - childArray = branch && Array.isArray(branch.children) ? (branch.children as EditorNode[]) : []; - continue; - } - const next = childArray[seg] ?? null; - if (!next) break; - out.push(next); - current = next; - childArray = Array.isArray(next.children) ? (next.children as EditorNode[]) : []; - } - return out; -} function pathsEqual(a: ComponentPath, b: ComponentPath): boolean { if (a.length !== b.length) return false; diff --git a/resources/js/core/template-engine/layout-editor/hooks/useElementSelection.ts b/resources/js/core/template-engine/layout-editor/hooks/useElementSelection.ts index 9cbab340..0ff8d95d 100644 --- a/resources/js/core/template-engine/layout-editor/hooks/useElementSelection.ts +++ b/resources/js/core/template-engine/layout-editor/hooks/useElementSelection.ts @@ -398,34 +398,63 @@ export function classifyLockKind( return 'extension_point'; } - // 별도 편집 모드(extension/base/modal/iteration)에서만 **출처 잠금을 data_bound 보다 우선** - // 적용한다. 그 모드들에서는 호스트 본체 노드가 폼 입력 - // 등으로 data_bound 인 경우가 많은데, data_bound 를 먼저 판정하면 잠겨야 할 호스트 노드가 - // "텍스트만 잠금(선택/스타일 허용)"으로 새어 편집된다. 그래서 잠긴 노드는 출처로 분류한다. + // **출처 잠금이 data_bound 보다 항상 우선**한다 (편집 모드 무관). // - // route 모드는 **종전 동작을 그대로 보존**한다 — data_bound 를 먼저 판정해, - // 확장 주입 영역의 data_bound 노드가 "데이터 영역" 표식을 유지하고, 잠긴 확장/ base 노드는 - // 아래 출처 분류로 "확장 편집"/"공통 레이아웃 편집" 어포던스를 띄운다. route 동작을 한 줄도 - // 바꾸지 않아 기존 확장 주입 영역 표식/진입이 그대로 복원된다. - if (editMode !== 'route' && isNodeLocked(node, editMode, currentExtensionId)) { + // 종전에는 route 모드만 예외로 두어 data_bound 를 먼저 판정했다. 그 결과 상속(base)· + // 주입(extension) 노드 중 props 값 하나라도 `{{ }}` 인 것은 `data_bound` 로 분류됐고, + // `data_bound` 는 편집 허용이라 속성 모달·드래그·인라인 편집이 모두 열렸다. 그런데 저장 + // 시 `stripInheritedNode` 가 그 노드를 통째로 폐기하므로 **편집분이 오류도 경고도 없이 + // 사라진다**(저장은 200 으로 성공하고 history 는 clear 돼 undo 도 불가). 그 "종전 동작 + // 보존" 은 계약이 아니라 보수성 선언이었고, 그 보수성이 곧 결함이었다. + // + // `data_bound` 의 **의미는 그대로 두고**(= 편집 가능, 텍스트만 잠금) 어느 노드가 + // data_bound 로 분류되는가만 좁힌다. `isNodeLocked('route')` 는 `__source.kind` 하나만 + // 보고 조상은 보지 않으므로, 라우트 소유 노드는 계속 편집 가능하다(회귀 없음). + if (isNodeLocked(node, editMode, currentExtensionId)) { const src = node.__source?.kind; if (src === 'base') return 'base'; if (src === 'partial') return 'partial'; if (src === 'extension') return 'extension'; - // 출처 메타가 없는데 잠금(별도 모드 한정) — 보수적으로 base 취급(선택 차단). + // 출처 메타가 없는데 잠금 — 보수적으로 base 취급(선택 차단). return 'base'; } - // ── 종전 분류 순서 (route 모드 + 별도 모드의 미잠금 노드) ── + // ── 미잠금(라우트 소유·신규 삽입) 노드 ── if (isDataBoundNode(node, ancestors)) return 'data_bound'; - if (!isNodeLocked(node, editMode, currentExtensionId)) return 'none'; - const src = node.__source?.kind; - if (src === 'base') return 'base'; - if (src === 'partial') return 'partial'; - if (src === 'extension') return 'extension'; return 'none'; } +/** + * 이 노드가 현재 편집 중인 레이아웃의 **소유 노드**인가 — 즉 저장 마스킹 + * (`stripInheritedFromLayoutContent`)을 통과해 영속되는가. + * + * `false` 인 노드(base/partial/extension/extension_point)는 편집해도 저장 시 폐기되므로 + * 속성·구조·드래그·인라인 편집을 **모두 같은 기준으로** 차단하고 진입 어포던스 + * (「🔒 공통 레이아웃 편집」 / 「🔒 확장 편집」)로 유도한다. + * + * 새 편집 진입점을 만들 때 반드시 본 함수를 게이트로 쓸 것 — 조건을 복사하면 + * 한 곳만 빠져도 같은 소실 결함이 재발한다(이번 결함의 원인이 정확히 그것이다). + */ +export function isEditableLockKind(lockKind: SelectionLockKind): boolean { + return lockKind === 'none' || lockKind === 'data_bound'; +} + +/** + * 잠금 종류 → DnD 거부 사유(devtools `EditorDndDecision`). `null` = 허용. + * + * `isEditableLockKind` 와 같은 판정을 쓰되 거부 사유 문자열까지 단일 지점에서 정한다. + * 사유 어휘는 기존 `EditorDndDecision` 그대로다(신설 없음) — base/partial 은 + * `denied_base_locked`, extension/extension_point 는 `denied_extension_locked`. + */ +export function resolveDndDenial( + lockKind: SelectionLockKind, +): 'denied_base_locked' | 'denied_extension_locked' | null { + if (isEditableLockKind(lockKind)) return null; + return lockKind === 'extension' || lockKind === 'extension_point' + ? 'denied_extension_locked' + : 'denied_base_locked'; +} + /** * 노드의 확장 출처 PK 를 해석한다 (devtools editor-selection __sourceExtensionId). * @@ -536,7 +565,8 @@ function normalizeDomPathToExtensionEntry( * @returns ⓘ 메뉴를 띄워도 되면 true */ export function isContextMenuAllowed(lockKind: SelectionLockKind): boolean { - return lockKind === 'none' || lockKind === 'data_bound'; + // 판정은 `isEditableLockKind` 단일 지점 — 조건을 복사하면 한 곳만 빠져도 결함이 남는다. + return isEditableLockKind(lockKind); } /** @@ -580,8 +610,8 @@ export function useElementSelection(params: UseElementSelectionParams): UseEleme if (!node) return true; const ancestors = resolveAncestors(rootNode, path, pathParser); const kind = classifyLockKind(node, editMode, currentExtensionId, ancestors); - // none = 편집 가능, data_bound = 편집 중 대상의 데이터 영역(선택 허용). 그 외는 잠금 → 차단. - return kind === 'none' || kind === 'data_bound'; + // 판정은 `isEditableLockKind` 단일 지점 — 조건을 복사하면 한 곳만 빠져도 결함이 남는다. + return isEditableLockKind(kind); }, [rootNode, pathParser, editMode, currentExtensionId, editableRootPath] ); diff --git a/resources/js/core/template-engine/layout-editor/spec/coreProps.ts b/resources/js/core/template-engine/layout-editor/spec/coreProps.ts index f4e38648..cb3b5f1d 100644 --- a/resources/js/core/template-engine/layout-editor/spec/coreProps.ts +++ b/resources/js/core/template-engine/layout-editor/spec/coreProps.ts @@ -98,7 +98,23 @@ export const DEFAULT_CORE_PROP_KEYS: CorePropKey[] = ['id']; export function resolveCorePropKeys(coreProps: unknown): CorePropKey[] { if (coreProps === false) return []; if (Array.isArray(coreProps)) { - return coreProps.filter((k): k is CorePropKey => k in CORE_PROP_CONTROLS); + return coreProps.filter( + (k): k is CorePropKey => k in CORE_PROP_CONTROLS && !DEDICATED_UI_KEYS.has(k as CorePropKey), + ); } - return [...DEFAULT_CORE_PROP_KEYS]; + return DEFAULT_CORE_PROP_KEYS.filter((k) => !DEDICATED_UI_KEYS.has(k)); } + +/** + * 전용 UI(`IsolatedScopeControl`)가 SSoT 인 코어 속성 키 — `ControlRenderer` 경유 렌더 금지. + * + * 이 두 키는 「격리 영역」 그룹이 직접 렌더한다. 어떤 템플릿이든 capability 에 + * `coreProps:["id","isolatedState"]` 한 줄을 쓰면 **같은 키를 두 UI 가 쓰는 이중 경로**가 + * 생기고, 그 순간 값 타입이 갈린다 — `IsolatedScopeControl` 은 ON 시 `isolatedState = {}` + * (빈 객체)를 쓰는데 `toggle` 위젯은 `true` 를 낸다. 렌더 목록 층에서만 제외하고 + * `CORE_PROP_CONTROLS` 의 정의 자체는 남긴다(SSoT 선언 유지). + */ +const DEDICATED_UI_KEYS: ReadonlySet = new Set([ + 'isolatedState', + 'isolatedScopeId', +]); diff --git a/resources/js/core/template-engine/layout-editor/spec/recipeEngine.ts b/resources/js/core/template-engine/layout-editor/spec/recipeEngine.ts index 710ec59f..04e88e03 100644 --- a/resources/js/core/template-engine/layout-editor/spec/recipeEngine.ts +++ b/resources/js/core/template-engine/layout-editor/spec/recipeEngine.ts @@ -35,7 +35,7 @@ import { } from './styleScope'; /** apply 프리미티브 종류 */ -export type RecipeApplyType = 'classToken' | 'styleProp' | 'propValue' | 'cssVar'; +export type RecipeApplyType = 'classToken' | 'styleProp' | 'propValue' | 'cssVar' | 'nodeKey'; /** * 컨트롤/옵션의 `apply` 선언. 컨트롤 자체에 직접 두거나(`color`/`image`/`width` @@ -65,6 +65,13 @@ export interface RecipeApply { propKey?: string; /** cssVar — CSS 변수명 (`--brand-color` 등) */ varName?: string; + /** + * nodeKey — 노드 **최상위** 키 이름(`dataKey`/`isolatedState` 등). + * + * `props` 가 아니라 노드 자신에 쓰는 구조키다. `propValue` 로 흘리면 + * `props.dataKey` 가 되어 런타임 엔진이 영영 읽지 않는다. + */ + nodeKey?: string; } /** @@ -110,6 +117,16 @@ interface NormalizedControl { * 이전 방향 토큰 제거). buildGroupTokenMatcher 의 빈 prefix 전체 매칭은 배제한다. */ groupPrefixes?: string[]; + /** + * 이 컨트롤이 쓰는 위젯 이름(`image`/`text`/`select` …). + * + * 엔진은 원칙적으로 위젯을 모르지만, **값 형태가 스칼라가 아닌 위젯**은 단일 값 + * 슬롯(`propValue`/`cssVar`/단일 `styleProp`)에 그대로 기록하면 `[object Object]` + * 가 저장된다. 그 축약·역조립의 게이트로 쓰기 위해 위젯 이름을 보존한다. + * **값 형태 sniffing 으로 대신할 수 없다** — `isImageValueObject` 는 4키 중 하나만 + * 있어도 참이라 `{position:'left'}` 같은 정당한 객체 prop 을 이미지로 오인한다. + */ + widget?: string; } /** EditorControlSpec → 정규화 (작성자 자유 필드 보존하되 엔진이 쓰는 키만 추출) */ @@ -117,6 +134,7 @@ function normalize(control: EditorControlSpec): NormalizedControl { const gp = (control as { groupPrefixes?: unknown }).groupPrefixes; return { group: typeof control.group === 'string' ? control.group : undefined, + widget: typeof control.widget === 'string' ? control.widget : undefined, apply: (control.apply && typeof control.apply === 'object' ? (control.apply as unknown as RecipeApply) : undefined) as RecipeApply | undefined, @@ -298,6 +316,34 @@ function isImageBundleProps(props: string[]): boolean { return props.includes('backgroundImage'); } +/** + * `image` 위젯 값 객체(`{ url, size, repeat, position }`)를 **단일 값 슬롯** + * (`propValue` / `cssVar` / 단일 `styleProp`)에 쓸 스칼라로 축약한다. + * + * 단일 슬롯은 값을 하나만 담을 수 있으므로 `url` 만 살아남는다(size/repeat/position 은 + * 저장할 자리가 없다 — `ImagePickerControl` 이 단일 슬롯 컨트롤에서는 애초에 그 3필드를 + * 만들지 않는다). + * + * **호출 게이트는 `widget === 'image'` 이며 값 형태 sniffing 이 아니다.** + * `isImageValueObject` 는 4키 중 **하나만** 있어도 참이므로, 값만 보고 게이트하면 + * `props.tooltip = { position: 'left' }` 같은 정당한 객체 prop 을 이미지로 오인해 + * 삭제한다. 그래서 이 함수 안의 `isImageValueObject` 는 2중 가드일 뿐이고, 1차 + * 게이트는 호출부의 위젯 판정이다. + * + * @param value 컨트롤이 만든 값 + * @param cssContext CSS 값 문맥(styleProp/cssVar)이면 true — `url(...)` 로 다시 감싼다 + * @return 이미지 값 객체가 아니면 value 그대로, 맞으면 축약된 스칼라 + */ +function scalarizeImageValue(value: unknown, cssContext: boolean): unknown { + if (!isImageValueObject(value)) return value; + const raw = (value as Record).url; + // url 부재/빈 문자열/비-문자열 → '' 로 축약해 호출부의 **기존 빈값 삭제 술어**에 위임한다 + // (새 술어를 신설하지 않는다). "url 없이 모드만" 은 위젯이 표현할 수 없는 상태다. + if (typeof raw !== 'string' || raw.trim() === '') return ''; + const bare = unwrapCssUrl(raw); + return cssContext ? wrapCssUrl(bare) : bare; +} + /** * 레거시 손상값 정화 — 과거(수정 이전) 저장본은 각 background 속성에 image 값 객체가 * 통째로 들어가 있을 수 있다(`backgroundPosition: { url, size, ... }`). 그런 객체/배열은 @@ -342,11 +388,67 @@ function readImageObject(style: Record): Record = new Set([ + 'type', + 'name', + 'props', + 'children', + 'text', + 'if', + 'iteration', + 'responsive', + '__source', + '__injectedProps', +]); + +/** + * nodeKey 적용 — 노드 **최상위**(`node[key]`)에 값을 쓴다(불변, 새 사본 반환). + * + * `props`/`style` 컨테이너를 다루지 않으므로 `withScopedProps` 를 경유하지 **않는다** — + * 그 함수는 mutator 에 `(props, style)` 만 넘기고 `{...node, props}` 로 재조립하므로 + * 노드 최상위 임의 키를 만질 방법이 없고, 빈 props 프루닝 로직도 nodeKey 에는 개념이 + * 없다. `setScopedIf`(styleScope) 가 `node.if` 라는 최상위 키를 별도 함수로 다루는 + * 선례를 그대로 따른다. + * + * **디바이스(breakpoint) 축은 무시한다** — 런타임 `DynamicRenderer` 의 responsive 병합은 + * `props`/`children`/`text`/`if`/`iteration` 5키만 본다. `responsive.mobile.dataKey` 는 + * 런타임이 영원히 읽지 않는 죽은 데이터이므로 항상 최상위에 쓴다. bp≠base 에서 no-op 으로 + * 만드는 대안은 "모바일 탭에서 입력했는데 아무 일도 안 일어남" 이라는 또 다른 무음 결함이다. + * + * @param node 대상 노드 (변경되지 않음) + * @param apply nodeKey apply 선언 + * @param value 쓸 값. 빈값(undefined|null|'')이면 키 삭제 + * @return 패치된 노드 사본. 예약키/비-문자열 nodeKey 는 no-op(원본 반환) + */ +function applyNodeKey(node: EditorNode, apply: RecipeApply, value: unknown): EditorNode { + const key = apply.nodeKey; + if (typeof key !== 'string' || key === '' || RESERVED_NODE_KEYS.has(key)) return node; + const next = { ...node } as EditorNode & Record; + if (value === undefined || value === null || value === '') { + delete next[key]; + } else { + next[key] = value; + } + return next; +} + +/** + * styleProp 적용 — 단일/다중 CSS 속성 설정 (value=null/undefined 면 제거) + * + * @param imageWidget 컨트롤 위젯이 `image` 인지 — 단일 `apply.prop` 경로에서 값 객체를 + * 축약할지 결정한다. 다중 `apply.props`(배경 묶음) 경로는 무영향. + */ function applyStyleProp( style: Record, apply: RecipeApply, value: unknown, + imageWidget = false, ): void { const setOne = (prop: string, v: unknown): void => { if (v === undefined || v === null || v === '') { @@ -387,14 +489,27 @@ function applyStyleProp( } if (typeof apply.prop === 'string') { - setOne(apply.prop, apply.value !== undefined ? apply.value : value); + // 단일 값 슬롯 — 고정값(apply.value) 선택 **이후**에 축약한다. 정규화 지점이 한 곳으로 + // 수렴하고, 작성자가 `apply.value: {url:…}` 를 실수로 선언해도 같은 규칙으로 구제된다. + const raw = apply.value !== undefined ? apply.value : value; + setOne(apply.prop, imageWidget ? scalarizeImageValue(raw, true) : raw); } } -/** cssVar 적용 — props.style 에 `--var: value` 설정 */ -function applyCssVar(style: Record, apply: RecipeApply, value: unknown): void { +/** + * cssVar 적용 — props.style 에 `--var: value` 설정 + * + * @param imageWidget 컨트롤 위젯이 `image` 인지 — 값 객체를 CSS `url(...)` 스칼라로 축약 + */ +function applyCssVar( + style: Record, + apply: RecipeApply, + value: unknown, + imageWidget = false, +): void { if (typeof apply.varName !== 'string') return; - const v = apply.value !== undefined ? apply.value : value; + const raw = apply.value !== undefined ? apply.value : value; + const v = imageWidget ? scalarizeImageValue(raw, true) : raw; if (v === undefined || v === null || v === '') { delete style[apply.varName]; } else { @@ -402,14 +517,22 @@ function applyCssVar(style: Record, apply: RecipeApply, value: } } -/** propValue 적용 — props[key] 설정 */ +/** + * propValue 적용 — props[key] 설정 + * + * @param imageWidget 컨트롤 위젯이 `image` 인지 — 값 객체를 **맨 url 문자열**로 축약한다. + * 이 값은 `` 같은 컴포넌트 prop 으로 흐르므로 `url(...)` + * 래핑을 반드시 벗긴다(CSS 문맥이 아니다). + */ function applyPropValue( props: Record, apply: RecipeApply, value: unknown, + imageWidget = false, ): void { if (typeof apply.propKey !== 'string') return; - const v = apply.value !== undefined ? apply.value : value; + const raw = apply.value !== undefined ? apply.value : value; + const v = imageWidget ? scalarizeImageValue(raw, false) : raw; if (v === undefined || v === null || v === '') { delete props[apply.propKey]; } else { @@ -490,6 +613,12 @@ export function applyRecipe( return node; } + // nodeKey — 노드 최상위 구조키. props/style 컨테이너를 다루지 않으므로 withScopedProps + // 앞에서 처리한다(scope 컨테이너 개념이 없다). 다크는 위 short-circuit 으로 도달 불가. + if (effectiveApply?.type === 'nodeKey') { + return applyNodeKey(node, effectiveApply, clearGroup ? undefined : value); + } + // B안 className 시드. // // DynamicRenderer 의 responsive 머지는 props 얕은 머지(`{...base.props, ...override.props}`) @@ -536,19 +665,22 @@ export function applyRecipe( } } } else if (apply) { + // 비-스칼라 값을 내보내는 위젯 — 단일 값 슬롯에 그대로 쓰면 `[object Object]` 가 + // 저장된다(공개 #135). 게이트는 위젯 이름이며 값 형태 sniffing 이 아니다. + const imageWidget = normalized.widget === 'image'; switch (apply.type) { case 'classToken': applyClassToken(props, normalized, apply, value, dark); break; case 'styleProp': // 다크는 위 short-circuit 으로 도달 불가 (인라인 no-op) - applyStyleProp(style, apply, value); + applyStyleProp(style, apply, value, imageWidget); break; case 'cssVar': - applyCssVar(style, apply, value); + applyCssVar(style, apply, value, imageWidget); break; case 'propValue': - applyPropValue(props, apply, value); + applyPropValue(props, apply, value, imageWidget); break; } } @@ -720,9 +852,19 @@ function resolveFromContainer( case 'propValue': { if (!apply.propKey) return { value: undefined, matched: false }; const v = props[apply.propKey]; - return v === undefined - ? { value: undefined, matched: false } - : { value: v, matched: true }; + if (v === undefined) return { value: undefined, matched: false }; + // image 위젯은 객체(`{url,…}`)를 이해한다 — 축약 저장된 문자열을 그 형태로 되감아야 + // 위젯이 현재 값을 읽을 수 있다(쓰기 4.1 과 대칭). `apply.type` 만으로는 판정 불가하고 + // (propValue 는 text/toggle/icon-picker 가 대부분 쓴다), 값이 평범한 문자열이라 형태 + // sniffing 도 불가하다 — **widget 이 유일한 신호다.** + // + // 표현식 문자열(`{{…}}`)도 감싼다. 감싸지 않으면 위젯이 빈 피커로 보이고 운영자가 + // 업로드 1클릭에 그 표현식을 소리 없이 잃는다. 깨진 미리보기 억제와 실수 덮어쓰기 + // 방지는 미리보기·업로드 UI 를 소유한 위젯이 맡는다(ImagePickerControl). + if (normalized.widget === 'image' && typeof v === 'string') { + return { value: { url: unwrapCssUrl(v) }, matched: true }; + } + return { value: v, matched: true }; } case 'classToken': { const tokens = scopedClassTokens(props.className, dark); @@ -790,6 +932,18 @@ export function reverseResolve( return { value: undefined, matched: false, darkReadonly: true }; } + // nodeKey — 노드 최상위에서 읽는다(쓰기와 대칭). scope 컨테이너 개념이 없으므로 + // scopedValue/baseFallback 을 부여하지 않는다 — 디바이스 탭에서 placeholder 흐림이 + // 생기면 "그 디바이스에만 값이 없다" 는 거짓 정보가 된다. + if (normalized.apply?.type === 'nodeKey') { + const key = normalized.apply.nodeKey; + if (typeof key !== 'string' || key === '' || RESERVED_NODE_KEYS.has(key)) { + return { value: undefined, matched: false }; + } + const v = (node as EditorNode & Record)[key]; + return v === undefined ? { value: undefined, matched: false } : { value: v, matched: true }; + } + // scope 컨테이너에서 역해석 const scopedProps = getScopedProps(node, scope); const scopedStyle = styleOf(scopedProps); diff --git a/resources/js/core/template-engine/layout-editor/spec/registerCoreWidgets.ts b/resources/js/core/template-engine/layout-editor/spec/registerCoreWidgets.ts index 54b72c3c..fb6a9b06 100644 --- a/resources/js/core/template-engine/layout-editor/spec/registerCoreWidgets.ts +++ b/resources/js/core/template-engine/layout-editor/spec/registerCoreWidgets.ts @@ -16,6 +16,7 @@ import { SelectWidget, ToggleWidget, DimensionWidget, + NumberWidget, SpacingWidget, } from '../components/property-controls/StyleControlWidgets'; import { ColorPickerControl } from '../components/property-controls/ColorPickerControl'; @@ -46,6 +47,10 @@ export function registerCoreWidgets(): void { registerWidget('slider', SliderWidget); registerWidget('select', SelectWidget); registerWidget('dimension', DimensionWidget); + // 숫자 prop(propValue) 편집 위젯. 종전 미등록이라 `widget:"number"` 컨트롤 + // (예 Header 「탭 표시 게시판 수」)이 속성 모달에서 "지원하지 않는 컨트롤" 로 폴백돼 + // 편집 자체가 불가했다. `number` 타입을 직접 내보내 컴포넌트 prop 계약을 만족시킨다. + registerWidget('number', NumberWidget); registerWidget('spacing', SpacingWidget); registerWidget('toggle', ToggleWidget); registerWidget('color', ColorPickerControl); diff --git a/resources/js/core/template-engine/layout-editor/spec/specTypes.ts b/resources/js/core/template-engine/layout-editor/spec/specTypes.ts index 728de8c1..f41bafea 100644 --- a/resources/js/core/template-engine/layout-editor/spec/specTypes.ts +++ b/resources/js/core/template-engine/layout-editor/spec/specTypes.ts @@ -328,6 +328,20 @@ export interface EditorControlSpec { iconColumns?: number; /** 검색 입력 placeholder — `$t:...` 키 */ iconSearchPlaceholder?: string; + /** + * `number` 위젯이 입력칸에 그대로 실어 보내는 HTML 입력 제약 선언. + * + * 그 입력칸은 `type="text"`(비숫자 입력을 원문 그대로 쥐고 있어야 미방출 정책이 + * 성립한다) 이므로 **브라우저 검증도 스피너도 동작하지 않는다** — 이 세 필드는 값을 + * 제한하는 장치가 아니라 작성자 의도의 선언이다. + * + * 위젯은 이 값으로 **클램프하지 않는다** — 사용자가 넣은 값은 보존한다(조용한 데이터 + * 변조 금지). 아래 세 필드는 index signature 가 이미 허용하므로 하위호환 100% 이고, + * 명시 선언은 발견성만 개선한다. + */ + min?: number; + max?: number; + step?: number; /** 작성자 자유 필드 — 코어는 widget/apply 외 필드를 그대로 보존만 한다 */ [key: string]: unknown; } diff --git a/resources/js/core/template-engine/layout-editor/utils/layoutTreeUtils.ts b/resources/js/core/template-engine/layout-editor/utils/layoutTreeUtils.ts index fb295ce5..6df2c71e 100644 --- a/resources/js/core/template-engine/layout-editor/utils/layoutTreeUtils.ts +++ b/resources/js/core/template-engine/layout-editor/utils/layoutTreeUtils.ts @@ -450,6 +450,39 @@ function asResponsiveChildren(node: EditorNode, key: string): EditorNode[] { return branch && Array.isArray(branch.children) ? (branch.children as EditorNode[]) : []; } +/** + * path 의 조상 노드 배열 (루트의 **자식**부터 부모까지, 자기 자신·루트 제외). + * + * `classifyLockKind` 의 `ancestors` 입력 SSoT. responsive 세그먼트는 노드를 내리지 않고 + * childArray 만 분기로 전환하므로 조상 목록에 추가하지 않는다. + * + * 종전에는 `useCanvasDnd` · `DndCanvasLayer` 가 바이트 동일 사본을 각자 들고 있었다 — + * 잠금 판정의 입력이 갈리면 "핸들은 있는데 드래그는 거부" 같은 어긋남이 조용히 생긴다. + * (`useElementSelection.resolveAncestors` 는 **루트를 포함**하는 다른 계약이라 별개다.) + * + * @param root 루트 노드 + * @param path 대상 노드의 인덱스 경로 + * @returns 조상 노드 배열 (루트 자식 → 부모 순) + */ +export function collectAncestors(root: EditorNode, path: ComponentPath): EditorNode[] { + const out: EditorNode[] = []; + let current: EditorNode = root; + let childArray: EditorNode[] = asChildrenArray(root); + for (let i = 0; i < path.length - 1; i++) { + const seg = path[i]!; + if (isResponsiveSegment(seg)) { + childArray = asResponsiveChildren(current, seg.responsive); + continue; + } + const next = childArray[seg] ?? null; + if (!next) break; + out.push(next); + current = next; + childArray = asChildrenArray(next); + } + return out; +} + /** * 경로로 노드 조회. 경로가 유효하지 않으면 null. * diff --git a/templates/_bundled/sirsoft-basic/AGENTS.md b/templates/_bundled/sirsoft-basic/AGENTS.md index 73fefa37..d3edf4f2 100644 --- a/templates/_bundled/sirsoft-basic/AGENTS.md +++ b/templates/_bundled/sirsoft-basic/AGENTS.md @@ -160,7 +160,7 @@ API 까지만 소유하고, 그 API 를 소비해 실제로 그리는 것은 이 | 종류 | 개수 | 위치 | |---|---|---| | PHPUnit | 0개 | — | -| Vitest | 147개 | `vitest.config.ts` | +| Vitest | 148개 | `vitest.config.ts` | | Playwright | 8개 | `tests/Playwright` | | 시나리오 매니페스트 | 4개 | `tests/scenarios` | diff --git a/templates/_bundled/sirsoft-basic/CHANGELOG.md b/templates/_bundled/sirsoft-basic/CHANGELOG.md index 1edd2705..87fa4642 100644 --- a/templates/_bundled/sirsoft-basic/CHANGELOG.md +++ b/templates/_bundled/sirsoft-basic/CHANGELOG.md @@ -17,6 +17,7 @@ ### Fixed - 로그인 시도 초과로 계정이 잠겼을 때 해제 시각이 화면에 표시되지 않던 문제를 수정했습니다. 언제 다시 시도할 수 있는지 알 수 없어 계속 눌러 보게 되었습니다. +- 화면 편집기로 지정한 로고가 깨져 보이던 문제를 수정했습니다. 이미지 주소 자리에 알 수 없는 값이 저장된 사이트에서도 이제 그림이 정상 표시되며, 주소를 해석할 수 없으면 이미지 대신 사이트 이름이 표시됩니다. (#135 @lyg-kaban 님께서 제보해주셨습니다.) ## [1.1.3] - 2026-09-06 diff --git a/templates/_bundled/sirsoft-basic/dist/js/components.iife.js b/templates/_bundled/sirsoft-basic/dist/js/components.iife.js index 4665837f..7c5f9dfd 100644 --- a/templates/_bundled/sirsoft-basic/dist/js/components.iife.js +++ b/templates/_bundled/sirsoft-basic/dist/js/components.iife.js @@ -1,4 +1,4 @@ -var SirsoftBasic=(function(ee,d,C,tr){"use strict";function bd(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const A=bd(C),yd=()=>window.G7Core,R=C.forwardRef(({children:e,variant:t="primary",size:r="md",className:n="",...o},a)=>{const s="inline-flex items-center justify-center",l=yd()?.style?.mergeClasses?.(s,n)??`${s} ${n}`;return d.jsx("button",{ref:a,className:l,...o,children:e})});R.displayName="Button";const j=C.forwardRef(({children:e,className:t="",...r},n)=>d.jsx("div",{ref:n,className:t,...r,children:e})),te=({children:e,className:t="",...r})=>d.jsx("span",{className:t,...r,children:e}),En=({children:e,className:t="",...r})=>d.jsx("svg",{className:t,...r,children:e}),At=C.forwardRef(({label:e,error:t,className:r="",onChange:n,onKeyPress:o,value:a,defaultValue:s,type:l="text",checked:f,defaultChecked:h,...c},i)=>{const u=l==="radio"||l==="checkbox",g=C.useRef(!1),p=C.useRef(null);C.useImperativeHandle(i,()=>p.current);const[m,x]=C.useState(a??s??"");C.useEffect(()=>{!u&&!g.current&&a!==void 0&&x(a)},[a,u]);const k=C.useCallback(()=>{g.current=!0},[]),M=C.useCallback(y=>{if(g.current=!1,n){const E=y.target.value;x(E);const O=new Event("change",{bubbles:!0});Object.defineProperty(O,"target",{writable:!1,value:{value:E}}),Object.defineProperty(O,"currentTarget",{writable:!1,value:{value:E}}),n(O)}},[n]),v=C.useCallback(y=>{const E=y.target.value;x(E),!g.current&&n&&n(y)},[n]),T=C.useCallback(y=>{g.current||o&&o(y)},[o]),{loadingactions:I,formdata:S,...N}=c;if(u)return d.jsx("input",{ref:p,type:l,className:r,onChange:n,checked:f,defaultChecked:h,value:a,...N});const w=a!==void 0?{value:m}:{defaultValue:s};return d.jsx("input",{ref:p,type:l,className:r,onChange:v,onKeyPress:T,onCompositionStart:k,onCompositionEnd:M,...w,...N})});At.displayName="Input";const ds=C.forwardRef(({accept:e,maxSize:t,onChange:r,onError:n,buttonText:o="Browse",placeholder:a="No file selected",className:s="",disabled:l,...f},h)=>{const c=C.useRef(null),i=h||c,[u,g]=C.useState(""),p={},m={};Object.entries(f).forEach(([v,T])=>{v.startsWith("data-editor-")||v==="id"||v==="onMouseMove"||v==="onMouseLeave"?p[v]=T:m[v]=T});const x=C.useCallback(()=>{!l&&i.current&&i.current.click()},[l,i]),k=C.useCallback(v=>{const T=v.target.files?.[0]||null;if(!T){g(""),r?.(null);return}if(t&&T.size>t*1024*1024){const I=`File size exceeds ${t}MB limit`;n?.(I),i.current&&(i.current.value=""),g("");return}g(T.name),r?.(T)},[t,r,n,i]),M=C.useCallback(v=>{v.stopPropagation(),i.current&&(i.current.value=""),g(""),r?.(null)},[r,i]);return d.jsxs(j,{className:`flex items-center gap-2 ${s}`,...p,children:[d.jsx(At,{ref:i,type:"file",accept:e,onChange:k,disabled:l,className:"hidden",...m}),d.jsx(R,{type:"button",onClick:x,disabled:l,className:"px-4 py-2 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-md text-sm font-medium text-gray-700 dark:text-gray-200 hover:bg-gray-200 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed",children:o}),d.jsx(te,{className:"flex-1 text-sm text-gray-600 dark:text-gray-400 truncate",children:u||a}),u&&!l&&d.jsx(R,{type:"button",onClick:M,className:"p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200","aria-label":"Clear file",children:d.jsx(En,{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})});ds.displayName="FileInput";var nt=(e=>(e.User="fa-user",e.Users="fa-users",e.UserCircle="fa-user-circle",e.UserPlus="fa-user-plus",e.UserMinus="fa-user-minus",e.UserShield="fa-user-shield",e.Search="fa-search",e.Edit="fa-edit",e.Pencil="fa-pencil-alt",e.Trash="fa-trash",e.Save="fa-save",e.Plus="fa-plus",e.Minus="fa-minus",e.Check="fa-check",e.Times="fa-times",e.Download="fa-download",e.Upload="fa-upload",e.Copy="fa-copy",e.ExternalLink="fa-external-link-alt",e.Home="fa-home",e.ChevronLeft="fa-chevron-left",e.ChevronRight="fa-chevron-right",e.ChevronUp="fa-chevron-up",e.ChevronDown="fa-chevron-down",e.AngleLeft="fa-angle-left",e.AngleRight="fa-angle-right",e.AngleUp="fa-angle-up",e.AngleDown="fa-angle-down",e.ArrowUp="fa-arrow-up",e.ArrowDown="fa-arrow-down",e.ArrowLeft="fa-arrow-left",e.ArrowRight="fa-arrow-right",e.Bars="fa-bars",e.EllipsisVertical="fa-ellipsis-v",e.EllipsisHorizontal="fa-ellipsis-h",e.CheckCircle="fa-check-circle",e.TimesCircle="fa-times-circle",e.ExclamationCircle="fa-exclamation-circle",e.ExclamationTriangle="fa-exclamation-triangle",e.InfoCircle="fa-info-circle",e.QuestionCircle="fa-question-circle",e.XCircle="fa-times-circle",e.ShoppingCart="fa-shopping-cart",e.ShoppingBag="fa-shopping-bag",e.CreditCard="fa-credit-card",e.Tag="fa-tag",e.Tags="fa-tags",e.File="fa-file",e.FileAlt="fa-file-alt",e.Folder="fa-folder",e.FolderOpen="fa-folder-open",e.Envelope="fa-envelope",e.Phone="fa-phone",e.Comment="fa-comment",e.Comments="fa-comments",e.Cog="fa-cog",e.Cogs="fa-cogs",e.Settings="fa-cog",e.Wrench="fa-wrench",e.Sliders="fa-sliders-h",e.Image="fa-image",e.Images="fa-images",e.Video="fa-video",e.Camera="fa-camera",e.Heart="fa-heart",e.Star="fa-star",e.ThumbsUp="fa-thumbs-up",e.ThumbsDown="fa-thumbs-down",e.Share="fa-share",e.Clock="fa-clock",e.Calendar="fa-calendar",e.CalendarAlt="fa-calendar-alt",e.Lock="fa-lock",e.Unlock="fa-unlock",e.Eye="fa-eye",e.EyeSlash="fa-eye-slash",e.Bell="fa-bell",e.Flag="fa-flag",e.Map="fa-map",e.MapMarker="fa-map-marker-alt",e.Globe="fa-globe",e.Link="fa-link",e.Unlink="fa-unlink",e.Sun="fa-sun",e.Moon="fa-moon",e.ChartBar="fa-chart-bar",e.ChartLine="fa-chart-line",e.ChartPie="fa-chart-pie",e.ChartArea="fa-chart-area",e.Spinner="fa-spinner",e.CircleNotch="fa-circle-notch",e.CheckBadge="fa-badge-check",e.BellSlash="fa-bell-slash",e.BookOpen="fa-book-open",e.Building="fa-building",e.FileCircleCheck="fa-file-circle-check",e.WandMagicSparkles="fa-wand-magic-sparkles",e.UserXmark="fa-user-xmark",e.Cube="fa-cube",e.Cubes="fa-cubes",e.Plug="fa-plug",e.PuzzlePiece="fa-puzzle-piece",e.Fire="fa-fire",e.CommentDots="fa-comment-dots",e.DollarSign="fa-dollar-sign",e.Bars2="fa-bars",e.X="fa-times",e.List="fa-list",e.ThLarge="fa-th-large",e.Inbox="fa-inbox",e.Box="fa-box",e.PaperPlane="fa-paper-plane",e.FileText="fa-file-alt",e.Paperclip="fa-paperclip",e.Truck="fa-truck",e.Sync="fa-sync",e.RotateLeft="fa-rotate-left",e.MapPin="fa-map-marker-alt",e.HelpCircle="fa-question-circle",e))(nt||{});const vd={user:"fa-user",users:"fa-users","user-circle":"fa-user-circle","user-plus":"fa-user-plus","user-minus":"fa-user-minus","user-shield":"fa-user-shield",search:"fa-search",edit:"fa-edit",pencil:"fa-pencil-alt",trash:"fa-trash",save:"fa-save",plus:"fa-plus",minus:"fa-minus",check:"fa-check",times:"fa-times",download:"fa-download",upload:"fa-upload",copy:"fa-copy","external-link":"fa-external-link-alt",home:"fa-home","chevron-left":"fa-chevron-left","chevron-right":"fa-chevron-right","chevron-up":"fa-chevron-up","chevron-down":"fa-chevron-down","angle-left":"fa-angle-left","angle-right":"fa-angle-right","angle-up":"fa-angle-up","angle-down":"fa-angle-down","arrow-up":"fa-arrow-up","arrow-down":"fa-arrow-down","arrow-left":"fa-arrow-left","arrow-right":"fa-arrow-right",bars:"fa-bars","ellipsis-vertical":"fa-ellipsis-v","ellipsis-v":"fa-ellipsis-v","ellipsis-horizontal":"fa-ellipsis-h","ellipsis-h":"fa-ellipsis-h","check-circle":"fa-check-circle","times-circle":"fa-times-circle","x-circle":"fa-times-circle","exclamation-circle":"fa-exclamation-circle","exclamation-triangle":"fa-exclamation-triangle","info-circle":"fa-info-circle","question-circle":"fa-question-circle","shopping-cart":"fa-shopping-cart","shopping-bag":"fa-shopping-bag","credit-card":"fa-credit-card",tag:"fa-tag",tags:"fa-tags",file:"fa-file","file-alt":"fa-file-alt",folder:"fa-folder","folder-open":"fa-folder-open",envelope:"fa-envelope",phone:"fa-phone",comment:"fa-comment",comments:"fa-comments",cog:"fa-cog",cogs:"fa-cogs",settings:"fa-cog",wrench:"fa-wrench",sliders:"fa-sliders-h",image:"fa-image",images:"fa-images",video:"fa-video",camera:"fa-camera",heart:"fa-heart",star:"fa-star","thumbs-up":"fa-thumbs-up","thumbs-down":"fa-thumbs-down",share:"fa-share",clock:"fa-clock",calendar:"fa-calendar","calendar-alt":"fa-calendar-alt",lock:"fa-lock",unlock:"fa-unlock",eye:"fa-eye","eye-slash":"fa-eye-slash",bell:"fa-bell",flag:"fa-flag",map:"fa-map","map-marker":"fa-map-marker-alt",globe:"fa-globe",link:"fa-link",unlink:"fa-unlink",sun:"fa-sun",moon:"fa-moon","chart-bar":"fa-chart-bar","chart-line":"fa-chart-line","chart-pie":"fa-chart-pie","chart-area":"fa-chart-area",spinner:"fa-spinner","circle-notch":"fa-circle-notch","check-badge":"fa-badge-check","badge-check":"fa-badge-check",cube:"fa-cube",cubes:"fa-cubes",plug:"fa-plug","puzzle-piece":"fa-puzzle-piece",flame:"fa-fire",fire:"fa-fire","message-square":"fa-comment-dots","dollar-sign":"fa-dollar-sign",menu:"fa-bars",x:"fa-times",list:"fa-list","layout-grid":"fa-th-large","th-large":"fa-th-large",grid:"fa-th-large",inbox:"fa-inbox",package:"fa-box",box:"fa-box",send:"fa-paper-plane","paper-plane":"fa-paper-plane","file-text":"fa-file-alt",paperclip:"fa-paperclip",truck:"fa-truck","refresh-cw":"fa-sync",sync:"fa-sync","undo-2":"fa-rotate-left","rotate-left":"fa-rotate-left","map-pin":"fa-map-marker-alt","help-circle":"fa-question-circle","alert-triangle":"fa-exclamation-triangle","bell-off":"fa-bell-slash","book-open":"fa-book-open",building:"fa-building","edit-2":"fa-edit","edit-3":"fa-edit","file-check":"fa-file-circle-check",mail:"fa-envelope",sparkles:"fa-wand-magic-sparkles","trash-2":"fa-trash","user-x":"fa-user-xmark"},fe=({name:e,iconStyle:t="solid",size:r,color:n,spin:o=!1,pulse:a=!1,fixedWidth:s=!1,ariaLabel:l,className:f="",style:h,...c})=>{const i={solid:"fas",regular:"far",light:"fal",duotone:"fad",brands:"fab"},u=typeof e=="string"?e:String(e),g=vd[u],p=g?String(g).replace(/^fa-/,""):u.replace(/^fa-/,""),m=[i[t],`fa-${p}`,r&&`fa-${r}`,o&&"fa-spin",a&&"fa-pulse",s&&"fa-fw",n,f].filter(Boolean).join(" "),x=l||p.replace(/-/g," ");return d.jsx("i",{className:m,style:h,"aria-label":x,role:"img",...c})},Tr=(e,t)=>window.G7Core?.t?.(e,t)??e,ko={minLength:{key:"minLength",labelKey:"auth.password_input.rules.minLength",defaultParam:6,validate:(e,t=6)=>e.length>=t},maxLength:{key:"maxLength",labelKey:"auth.password_input.rules.maxLength",defaultParam:20,validate:(e,t=20)=>e.length<=t},hasUppercase:{key:"hasUppercase",labelKey:"auth.password_input.rules.hasUppercase",validate:e=>/[A-Z]/.test(e)},hasLowercase:{key:"hasLowercase",labelKey:"auth.password_input.rules.hasLowercase",validate:e=>/[a-z]/.test(e)},hasNumber:{key:"hasNumber",labelKey:"auth.password_input.rules.hasNumber",validate:e=>/[0-9]/.test(e)},hasSpecial:{key:"hasSpecial",labelKey:"auth.password_input.rules.hasSpecial",validate:e=>/[!@#$%^&*(),.?":{}|<>]/.test(e)},noSpaces:{key:"noSpaces",labelKey:"auth.password_input.rules.noSpaces",validate:e=>!/\s/.test(e)},minTypes:{key:"minTypes",labelKey:"auth.password_input.rules.minTypes",defaultParam:3,validate:(e,t=3)=>{let r=0;return/[A-Z]/.test(e)&&r++,/[a-z]/.test(e)&&r++,/[0-9]/.test(e)&&r++,/[!@#$%^&*(),.?":{}|<>]/.test(e)&&r++,r>=t}}},us=[ko.minLength];function wd(e){const[t,r]=e.split(":"),n=ko[t];if(!n)return null;const o=r?parseInt(r,10):n.defaultParam;return{rule:n,param:isNaN(o)?n.defaultParam:o}}const fs=C.forwardRef(({label:e,error:t,showToggle:r=!0,showValidation:n=!1,isConfirmField:o=!1,confirmTarget:a,onMatchChange:s,onValidityChange:l,rules:f,enableRules:h,showRules:c,wrapperClassName:i="",validationClassName:u="",className:g="",onChange:p,value:m,defaultValue:x,disabled:k,...M},v)=>{const T=C.useRef(null);C.useImperativeHandle(v,()=>T.current);const[I,S]=C.useState(!1),[N,w]=C.useState(!1),[y,E]=C.useState(m??x??"");C.useEffect(()=>{m!==void 0&&E(m)},[m]);const O=C.useMemo(()=>f&&f.length>0?f.map(H=>({rule:H,param:H.defaultParam})):h&&h.length>0?h.map(H=>wd(H)).filter(H=>H!==null):us.map(H=>({rule:H,param:H.defaultParam})),[f,h]),$=C.useMemo(()=>!c||c.length===0?O:O.filter(H=>c.includes(H.rule.key)),[O,c]),P=C.useMemo(()=>!n||o?{}:$.reduce((H,{rule:W,param:Q})=>(H[W.key]=W.validate(y,Q),H),{}),[y,$,n,o]),L=C.useMemo(()=>!o||a===void 0?!0:y===a&&y.length>0,[o,y,a]),U=C.useMemo(()=>n?Object.values(P).every(H=>H):!0,[P,n]);C.useEffect(()=>{if(l&&n&&!o){const H=Object.entries(P).filter(([,W])=>!W).map(([W])=>W);l(U,H)}},[U,P,l,n,o]),C.useEffect(()=>{s&&o&&s(L)},[L,s,o]);const _=C.useCallback(()=>{S(H=>!H)},[]),b=C.useCallback(H=>{const W=H.target.value;E(W),p&&p(H)},[p]),z=C.useCallback(H=>{w(H.getModifierState("CapsLock"))},[]),{loadingactions:F,formdata:G,...X}=M,B={},Y={};for(const[H,W]of Object.entries(X))H.startsWith("data-editor-")||H==="onMouseMove"||H==="onMouseLeave"?B[H]=W:Y[H]=W;return d.jsxs("div",{className:`relative ${i}`,...B,children:[d.jsxs("div",{className:"relative",children:[d.jsx("input",{ref:T,type:I?"text":"password",className:`${g} ${r?"pr-10":""}`,value:m!==void 0?m:void 0,defaultValue:m===void 0?x:void 0,onChange:b,onKeyDown:z,onKeyUp:z,disabled:k,...Y}),r&&d.jsx("button",{type:"button",onClick:_,disabled:k,className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 disabled:opacity-50 disabled:cursor-not-allowed dark:disabled:opacity-50","aria-label":Tr(I?"auth.password_input.hide":"auth.password_input.show"),children:d.jsx(fe,{name:I?"eye-slash":"eye",className:"w-5 h-5"})})]}),N&&!I&&d.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-sm text-yellow-600 dark:text-yellow-400",children:[d.jsx(fe,{name:"triangle-exclamation",className:"w-4 h-4"}),d.jsx("span",{children:Tr("auth.password_input.caps_lock_on")})]}),o&&a!==void 0&&y.length>0&&d.jsxs("div",{className:`mt-2 flex items-center gap-1.5 text-sm ${L?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:[d.jsx(fe,{name:L?"check-circle":"xmark-circle",className:"w-4 h-4"}),d.jsx("span",{children:Tr(L?"auth.password_input.match":"auth.password_input.mismatch")})]}),n&&!o&&y.length>0&&d.jsx("div",{className:`mt-2 space-y-1 ${u}`,children:$.map(({rule:H,param:W})=>{const Q=P[H.key],be=W!==void 0?{count:W}:void 0;return d.jsxs("div",{className:`flex items-center gap-1.5 text-sm ${Q?"text-green-600 dark:text-green-400":"text-gray-500 dark:text-gray-400"}`,children:[d.jsx(fe,{name:Q?"check-circle":"circle",className:"w-4 h-4"}),d.jsx("span",{children:Tr(H.labelKey,be)})]},H.key)})}),t&&d.jsx("p",{className:"mt-1 text-sm text-red-600 dark:text-red-400",children:t})]})});fs.displayName="PasswordInput";const Co=({label:e,error:t,className:r="",onChange:n,value:o,defaultValue:a,...s})=>{const l=C.useRef(!1),f=C.useRef(null),[h,c]=C.useState(o??a??"");C.useEffect(()=>{!l.current&&o!==void 0&&c(o)},[o]);const i=C.useCallback(()=>{l.current=!0},[]),u=C.useCallback(M=>{if(l.current=!1,n){const v=M.target.value;c(v);const T=new Event("change",{bubbles:!0});Object.defineProperty(T,"target",{writable:!1,value:{value:v}}),Object.defineProperty(T,"currentTarget",{writable:!1,value:{value:v}}),n(T)}},[n]),g=C.useCallback(M=>{const v=M.target.value;c(v),!l.current&&n&&n(M)},[n]),{loadingactions:p,formdata:m,...x}=s,k=o!==void 0?{value:h}:{defaultValue:a};return d.jsx("textarea",{ref:f,className:r,onChange:g,onCompositionStart:i,onCompositionEnd:u,...k,...x})},Ar=({children:e,className:t="",...r})=>d.jsx("label",{className:t,...r,children:e}),Gt=({children:e,className:t="",...r})=>d.jsx("p",{className:t,...r,children:e}),jt=({className:e="",alt:t="",...r})=>d.jsx("img",{className:e,alt:t,...r}),xd=({children:e,className:t="",...r})=>d.jsx("h1",{className:t,...r,children:e}),gs=({children:e,className:t="",...r})=>d.jsx("h2",{className:t,...r,children:e}),Tn=({children:e,className:t="",...r})=>d.jsx("h3",{className:t,...r,children:e}),hs=({children:e,className:t="",...r})=>d.jsx("h4",{className:t,...r,children:e}),_o=({children:e,className:t="",...r})=>d.jsx("ul",{className:t,...r,children:e}),kd=({children:e,className:t="",...r})=>d.jsx("ol",{className:t,...r,children:e}),er=({children:e,className:t="",...r})=>d.jsx("li",{className:t,...r,children:e}),So=({children:e,className:t="",...r})=>d.jsx("a",{className:t,...r,children:e}),Eo=({children:e,className:t="",...r})=>d.jsx("form",{className:t,...r,children:e}),Cd=window.G7Core?.createLogger?.("Comp:Select")??{log:(...e)=>console.log("[Comp:Select]",...e),warn:(...e)=>console.warn("[Comp:Select]",...e),error:(...e)=>console.error("[Comp:Select]",...e)};function _d(e){const t=window.G7Core?.state?.get?.("_global.appConfig.localeNames")?.[e];return t||{ko:"한국어",en:"English",ja:"日本語",zh:"中文",es:"Español",fr:"Français",de:"Deutsch"}[e]||e}const ps=({children:e,label:t,error:r,options:n,className:o="",value:a,onChange:s,disabled:l,searchable:f=!1,searchPlaceholder:h,editorAttrs:c,...i})=>{const[u,g]=C.useState(!1),[p,m]=C.useState(""),[x,k]=C.useState(null),M=C.useRef(null),v=C.useRef(null),T=C.useRef(null),I=C.useRef(null),S=C.useMemo(()=>n?Array.isArray(n)?n.length===0?[]:typeof n[0]=="string"?n.map(_=>({value:_,label:_d(_)})):n:(Cd.warn("options prop is not an array:",n),null):null,[n]),N=C.useMemo(()=>S&&S.find(b=>String(b.value)===String(a))?.label||"",[S,a]),w=C.useMemo(()=>{if(!S)return null;if(!f||p.trim()==="")return S;const _=p.trim().toLowerCase();return S.filter(b=>b.label.toLowerCase().includes(_)||String(b.value).toLowerCase().includes(_))},[S,f,p]);C.useEffect(()=>{if(u&&f){m("");const _=setTimeout(()=>T.current?.focus(),0);return()=>clearTimeout(_)}u||m("")},[u,f]);const y=C.useCallback(()=>{if(!v.current)return;const _=v.current.getBoundingClientRect(),b=window.innerHeight-_.bottom,F=b<280&&_.top>b;k(F?{bottom:window.innerHeight-_.top+4,left:_.left,width:_.width}:{top:_.bottom+4,left:_.left,width:_.width})},[]);C.useEffect(()=>{if(!u){k(null);return}return y(),window.addEventListener("scroll",y,!0),window.addEventListener("resize",y),()=>{window.removeEventListener("scroll",y,!0),window.removeEventListener("resize",y)}},[u,y]),C.useEffect(()=>{const _=b=>{const z=b.target;M.current&&!M.current.contains(z)&&(!I.current||!I.current.contains(z))&&g(!1)};return u&&document.addEventListener("mousedown",_),()=>{document.removeEventListener("mousedown",_)}},[u]),C.useEffect(()=>{const _=b=>{b.key==="Escape"&&u&&(g(!1),v.current?.focus())};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[u]);const E=()=>{l||g(!u)},O=_=>{s&&s({target:{value:_},preventDefault:()=>{},stopPropagation:()=>{},type:"change"}),g(!1),v.current?.focus()};if(!S)return d.jsx("select",{className:o,value:a,onChange:s,disabled:l,...c,...i,children:e});const $=o&&o.includes("bg-"),P=o&&/text-(gray|red|blue|green|yellow|white|black|indigo|purple|pink|orange|amber|emerald|teal|cyan|slate)-\d+|text-white|text-black/.test(o),L=$?`${o}${P?"":" text-gray-700 dark:text-gray-200"}`:`w-full px-4 py-2.5 bg-gray-100 dark:bg-gray-700 border-0 rounded-xl text-gray-700 dark:text-gray-200 font-medium focus:ring-2 focus:ring-blue-500 focus:outline-none ${o}`,U={...c,...i};return d.jsxs(j,{ref:M,className:"relative",...U,children:[d.jsxs(R,{ref:v,type:"button",onClick:E,disabled:l,className:`${L} flex items-center justify-between gap-2 text-left cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed`,"aria-haspopup":"listbox","aria-expanded":u,children:[d.jsx(te,{className:"truncate",children:N||" "}),d.jsx(En,{className:`w-4 h-4 flex-shrink-0 transition-transform duration-200 ${u?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),u&&x&&tr.createPortal(d.jsxs(j,{ref:I,className:"fixed z-[9999] bg-white dark:bg-gray-800 rounded-2xl shadow-lg border border-gray-200 dark:border-gray-600 overflow-hidden",style:{top:x.top,bottom:x.bottom,left:x.left,width:x.width},role:"listbox",children:[f&&d.jsx(j,{className:"p-2 border-b border-gray-200 dark:border-gray-600",children:d.jsx(At,{ref:T,type:"text",value:p,onChange:_=>m(_.target.value),placeholder:h??"Search...",className:"w-full px-3 py-2 bg-gray-100 dark:bg-gray-700 border-0 rounded-lg text-sm text-gray-700 dark:text-gray-200 placeholder-gray-400 dark:placeholder-gray-500 focus:ring-2 focus:ring-blue-500 focus:outline-none",role:"searchbox","aria-label":h??"Search"})}),d.jsxs(j,{className:"py-2 max-h-60 overflow-auto",children:[w&&w.length===0&&d.jsx(j,{className:"px-4 py-3 text-sm text-gray-500 dark:text-gray-400 text-center",children:p?"No results":""}),(w??[]).map(_=>{const b=String(_.value)===String(a);return d.jsxs(R,{type:"button",onClick:()=>!_.disabled&&O(_.value),disabled:_.disabled,className:`w-full px-4 py-3 text-left flex items-center justify-between hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors ${b?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-200"} ${_.disabled?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,role:"option","aria-selected":b,children:[d.jsx(te,{children:_.label}),b&&d.jsx(En,{className:"w-5 h-5 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},_.value)})]})]}),document.body)]})},Sd=({children:e,className:t="",...r})=>d.jsx("option",{className:t,...r,children:e}),Ed=({children:e,className:t="",...r})=>d.jsx("optgroup",{className:t,...r,children:e}),ms=C.forwardRef(({label:e,className:t="",...r},n)=>d.jsx("input",{ref:n,type:"checkbox",className:t,...r}));ms.displayName="Checkbox";const Td=({children:e,className:t="",...r})=>d.jsx("table",{className:t,...r,children:e}),Ad=({children:e,className:t="",...r})=>d.jsx("thead",{className:t,...r,children:e}),Nd=({children:e,className:t="",...r})=>d.jsx("tbody",{className:t,...r,children:e}),Od=({children:e,className:t="",...r})=>d.jsx("tr",{className:t,...r,children:e}),Md=({children:e,className:t="",...r})=>d.jsx("th",{className:t,...r,children:e}),Id=({children:e,className:t="",...r})=>d.jsx("td",{className:t,...r,children:e}),Zr=C.forwardRef(({children:e,className:t="",...r},n)=>d.jsx("nav",{ref:n,className:t,...r,children:e}));Zr.displayName="Nav";const bs=({children:e,className:t="",...r})=>d.jsx("section",{className:t,...r,children:e}),Dd=({children:e,className:t="",...r})=>d.jsx("code",{className:t,...r,children:e}),To=C.forwardRef(({className:e="",...t},r)=>d.jsx("hr",{ref:r,className:e,...t})),Pd=C.forwardRef(({children:e,className:t="",...r},n)=>d.jsx("header",{ref:n,className:t,...r,children:e})),ys=e=>e==="auto"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e,Ao=e=>{const t=ys(e);document.documentElement.setAttribute("data-theme",t),t==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")},Ld=()=>{const e=localStorage.getItem("g7_color_scheme");return e&&["auto","light","dark"].includes(e)?e:"auto"},An=({onThemeChange:e,className:t="",autoText:r="System",lightText:n="Light",darkText:o="Dark",id:a,editorAttrs:s})=>{const l=Ld(),[f,h]=C.useState(l),[c,i]=C.useState(!1),u=C.useRef(null);C.useEffect(()=>{Ao(f)},[]),C.useEffect(()=>{if(f!=="auto")return;const m=window.matchMedia("(prefers-color-scheme: dark)"),x=()=>{Ao("auto")};return m.addEventListener("change",x),()=>m.removeEventListener("change",x)},[f]),C.useEffect(()=>{const m=x=>{u.current&&!u.current.contains(x.target)&&i(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[]);const g=m=>{h(m),localStorage.setItem("g7_color_scheme",m),Ao(m),i(!1),e?.(m)},p=()=>ys(f)==="dark"?nt.Moon:nt.Sun;return d.jsxs(j,{ref:u,className:`relative ${t}`,id:a,...s,children:[d.jsx(R,{onClick:()=>i(!c),className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors text-gray-600 dark:text-gray-400","aria-label":"Toggle theme",children:d.jsx(fe,{name:p(),className:"w-5 h-5"})}),c&&d.jsx(j,{className:"absolute right-0 mt-2 w-48 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-50",children:d.jsxs(j,{className:"py-2",children:[d.jsxs(R,{onClick:()=>g("auto"),className:` +var SirsoftBasic=(function(ee,d,C,tr){"use strict";function bd(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const A=bd(C),yd=()=>window.G7Core,R=C.forwardRef(({children:e,variant:t="primary",size:r="md",className:n="",...o},a)=>{const s="inline-flex items-center justify-center",l=yd()?.style?.mergeClasses?.(s,n)??`${s} ${n}`;return d.jsx("button",{ref:a,className:l,...o,children:e})});R.displayName="Button";const j=C.forwardRef(({children:e,className:t="",...r},n)=>d.jsx("div",{ref:n,className:t,...r,children:e})),te=({children:e,className:t="",...r})=>d.jsx("span",{className:t,...r,children:e}),En=({children:e,className:t="",...r})=>d.jsx("svg",{className:t,...r,children:e}),At=C.forwardRef(({label:e,error:t,className:r="",onChange:n,onKeyPress:o,value:a,defaultValue:s,type:l="text",checked:f,defaultChecked:h,...c},i)=>{const u=l==="radio"||l==="checkbox",g=C.useRef(!1),p=C.useRef(null);C.useImperativeHandle(i,()=>p.current);const[m,x]=C.useState(a??s??"");C.useEffect(()=>{!u&&!g.current&&a!==void 0&&x(a)},[a,u]);const k=C.useCallback(()=>{g.current=!0},[]),M=C.useCallback(y=>{if(g.current=!1,n){const E=y.target.value;x(E);const O=new Event("change",{bubbles:!0});Object.defineProperty(O,"target",{writable:!1,value:{value:E}}),Object.defineProperty(O,"currentTarget",{writable:!1,value:{value:E}}),n(O)}},[n]),v=C.useCallback(y=>{const E=y.target.value;x(E),!g.current&&n&&n(y)},[n]),T=C.useCallback(y=>{g.current||o&&o(y)},[o]),{loadingactions:I,formdata:S,...N}=c;if(u)return d.jsx("input",{ref:p,type:l,className:r,onChange:n,checked:f,defaultChecked:h,value:a,...N});const w=a!==void 0?{value:m}:{defaultValue:s};return d.jsx("input",{ref:p,type:l,className:r,onChange:v,onKeyPress:T,onCompositionStart:k,onCompositionEnd:M,...w,...N})});At.displayName="Input";const ds=C.forwardRef(({accept:e,maxSize:t,onChange:r,onError:n,buttonText:o="Browse",placeholder:a="No file selected",className:s="",disabled:l,...f},h)=>{const c=C.useRef(null),i=h||c,[u,g]=C.useState(""),p={},m={};Object.entries(f).forEach(([v,T])=>{v.startsWith("data-editor-")||v==="id"||v==="onMouseMove"||v==="onMouseLeave"?p[v]=T:m[v]=T});const x=C.useCallback(()=>{!l&&i.current&&i.current.click()},[l,i]),k=C.useCallback(v=>{const T=v.target.files?.[0]||null;if(!T){g(""),r?.(null);return}if(t&&T.size>t*1024*1024){const I=`File size exceeds ${t}MB limit`;n?.(I),i.current&&(i.current.value=""),g("");return}g(T.name),r?.(T)},[t,r,n,i]),M=C.useCallback(v=>{v.stopPropagation(),i.current&&(i.current.value=""),g(""),r?.(null)},[r,i]);return d.jsxs(j,{className:`flex items-center gap-2 ${s}`,...p,children:[d.jsx(At,{ref:i,type:"file",accept:e,onChange:k,disabled:l,className:"hidden",...m}),d.jsx(R,{type:"button",onClick:x,disabled:l,className:"px-4 py-2 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-md text-sm font-medium text-gray-700 dark:text-gray-200 hover:bg-gray-200 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed",children:o}),d.jsx(te,{className:"flex-1 text-sm text-gray-600 dark:text-gray-400 truncate",children:u||a}),u&&!l&&d.jsx(R,{type:"button",onClick:M,className:"p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200","aria-label":"Clear file",children:d.jsx(En,{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})});ds.displayName="FileInput";var nt=(e=>(e.User="fa-user",e.Users="fa-users",e.UserCircle="fa-user-circle",e.UserPlus="fa-user-plus",e.UserMinus="fa-user-minus",e.UserShield="fa-user-shield",e.Search="fa-search",e.Edit="fa-edit",e.Pencil="fa-pencil-alt",e.Trash="fa-trash",e.Save="fa-save",e.Plus="fa-plus",e.Minus="fa-minus",e.Check="fa-check",e.Times="fa-times",e.Download="fa-download",e.Upload="fa-upload",e.Copy="fa-copy",e.ExternalLink="fa-external-link-alt",e.Home="fa-home",e.ChevronLeft="fa-chevron-left",e.ChevronRight="fa-chevron-right",e.ChevronUp="fa-chevron-up",e.ChevronDown="fa-chevron-down",e.AngleLeft="fa-angle-left",e.AngleRight="fa-angle-right",e.AngleUp="fa-angle-up",e.AngleDown="fa-angle-down",e.ArrowUp="fa-arrow-up",e.ArrowDown="fa-arrow-down",e.ArrowLeft="fa-arrow-left",e.ArrowRight="fa-arrow-right",e.Bars="fa-bars",e.EllipsisVertical="fa-ellipsis-v",e.EllipsisHorizontal="fa-ellipsis-h",e.CheckCircle="fa-check-circle",e.TimesCircle="fa-times-circle",e.ExclamationCircle="fa-exclamation-circle",e.ExclamationTriangle="fa-exclamation-triangle",e.InfoCircle="fa-info-circle",e.QuestionCircle="fa-question-circle",e.XCircle="fa-times-circle",e.ShoppingCart="fa-shopping-cart",e.ShoppingBag="fa-shopping-bag",e.CreditCard="fa-credit-card",e.Tag="fa-tag",e.Tags="fa-tags",e.File="fa-file",e.FileAlt="fa-file-alt",e.Folder="fa-folder",e.FolderOpen="fa-folder-open",e.Envelope="fa-envelope",e.Phone="fa-phone",e.Comment="fa-comment",e.Comments="fa-comments",e.Cog="fa-cog",e.Cogs="fa-cogs",e.Settings="fa-cog",e.Wrench="fa-wrench",e.Sliders="fa-sliders-h",e.Image="fa-image",e.Images="fa-images",e.Video="fa-video",e.Camera="fa-camera",e.Heart="fa-heart",e.Star="fa-star",e.ThumbsUp="fa-thumbs-up",e.ThumbsDown="fa-thumbs-down",e.Share="fa-share",e.Clock="fa-clock",e.Calendar="fa-calendar",e.CalendarAlt="fa-calendar-alt",e.Lock="fa-lock",e.Unlock="fa-unlock",e.Eye="fa-eye",e.EyeSlash="fa-eye-slash",e.Bell="fa-bell",e.Flag="fa-flag",e.Map="fa-map",e.MapMarker="fa-map-marker-alt",e.Globe="fa-globe",e.Link="fa-link",e.Unlink="fa-unlink",e.Sun="fa-sun",e.Moon="fa-moon",e.ChartBar="fa-chart-bar",e.ChartLine="fa-chart-line",e.ChartPie="fa-chart-pie",e.ChartArea="fa-chart-area",e.Spinner="fa-spinner",e.CircleNotch="fa-circle-notch",e.CheckBadge="fa-badge-check",e.BellSlash="fa-bell-slash",e.BookOpen="fa-book-open",e.Building="fa-building",e.FileCircleCheck="fa-file-circle-check",e.WandMagicSparkles="fa-wand-magic-sparkles",e.UserXmark="fa-user-xmark",e.Cube="fa-cube",e.Cubes="fa-cubes",e.Plug="fa-plug",e.PuzzlePiece="fa-puzzle-piece",e.Fire="fa-fire",e.CommentDots="fa-comment-dots",e.DollarSign="fa-dollar-sign",e.Bars2="fa-bars",e.X="fa-times",e.List="fa-list",e.ThLarge="fa-th-large",e.Inbox="fa-inbox",e.Box="fa-box",e.PaperPlane="fa-paper-plane",e.FileText="fa-file-alt",e.Paperclip="fa-paperclip",e.Truck="fa-truck",e.Sync="fa-sync",e.RotateLeft="fa-rotate-left",e.MapPin="fa-map-marker-alt",e.HelpCircle="fa-question-circle",e))(nt||{});const vd={user:"fa-user",users:"fa-users","user-circle":"fa-user-circle","user-plus":"fa-user-plus","user-minus":"fa-user-minus","user-shield":"fa-user-shield",search:"fa-search",edit:"fa-edit",pencil:"fa-pencil-alt",trash:"fa-trash",save:"fa-save",plus:"fa-plus",minus:"fa-minus",check:"fa-check",times:"fa-times",download:"fa-download",upload:"fa-upload",copy:"fa-copy","external-link":"fa-external-link-alt",home:"fa-home","chevron-left":"fa-chevron-left","chevron-right":"fa-chevron-right","chevron-up":"fa-chevron-up","chevron-down":"fa-chevron-down","angle-left":"fa-angle-left","angle-right":"fa-angle-right","angle-up":"fa-angle-up","angle-down":"fa-angle-down","arrow-up":"fa-arrow-up","arrow-down":"fa-arrow-down","arrow-left":"fa-arrow-left","arrow-right":"fa-arrow-right",bars:"fa-bars","ellipsis-vertical":"fa-ellipsis-v","ellipsis-v":"fa-ellipsis-v","ellipsis-horizontal":"fa-ellipsis-h","ellipsis-h":"fa-ellipsis-h","check-circle":"fa-check-circle","times-circle":"fa-times-circle","x-circle":"fa-times-circle","exclamation-circle":"fa-exclamation-circle","exclamation-triangle":"fa-exclamation-triangle","info-circle":"fa-info-circle","question-circle":"fa-question-circle","shopping-cart":"fa-shopping-cart","shopping-bag":"fa-shopping-bag","credit-card":"fa-credit-card",tag:"fa-tag",tags:"fa-tags",file:"fa-file","file-alt":"fa-file-alt",folder:"fa-folder","folder-open":"fa-folder-open",envelope:"fa-envelope",phone:"fa-phone",comment:"fa-comment",comments:"fa-comments",cog:"fa-cog",cogs:"fa-cogs",settings:"fa-cog",wrench:"fa-wrench",sliders:"fa-sliders-h",image:"fa-image",images:"fa-images",video:"fa-video",camera:"fa-camera",heart:"fa-heart",star:"fa-star","thumbs-up":"fa-thumbs-up","thumbs-down":"fa-thumbs-down",share:"fa-share",clock:"fa-clock",calendar:"fa-calendar","calendar-alt":"fa-calendar-alt",lock:"fa-lock",unlock:"fa-unlock",eye:"fa-eye","eye-slash":"fa-eye-slash",bell:"fa-bell",flag:"fa-flag",map:"fa-map","map-marker":"fa-map-marker-alt",globe:"fa-globe",link:"fa-link",unlink:"fa-unlink",sun:"fa-sun",moon:"fa-moon","chart-bar":"fa-chart-bar","chart-line":"fa-chart-line","chart-pie":"fa-chart-pie","chart-area":"fa-chart-area",spinner:"fa-spinner","circle-notch":"fa-circle-notch","check-badge":"fa-badge-check","badge-check":"fa-badge-check",cube:"fa-cube",cubes:"fa-cubes",plug:"fa-plug","puzzle-piece":"fa-puzzle-piece",flame:"fa-fire",fire:"fa-fire","message-square":"fa-comment-dots","dollar-sign":"fa-dollar-sign",menu:"fa-bars",x:"fa-times",list:"fa-list","layout-grid":"fa-th-large","th-large":"fa-th-large",grid:"fa-th-large",inbox:"fa-inbox",package:"fa-box",box:"fa-box",send:"fa-paper-plane","paper-plane":"fa-paper-plane","file-text":"fa-file-alt",paperclip:"fa-paperclip",truck:"fa-truck","refresh-cw":"fa-sync",sync:"fa-sync","undo-2":"fa-rotate-left","rotate-left":"fa-rotate-left","map-pin":"fa-map-marker-alt","help-circle":"fa-question-circle","alert-triangle":"fa-exclamation-triangle","bell-off":"fa-bell-slash","book-open":"fa-book-open",building:"fa-building","edit-2":"fa-edit","edit-3":"fa-edit","file-check":"fa-file-circle-check",mail:"fa-envelope",sparkles:"fa-wand-magic-sparkles","trash-2":"fa-trash","user-x":"fa-user-xmark"},fe=({name:e,iconStyle:t="solid",size:r,color:n,spin:o=!1,pulse:a=!1,fixedWidth:s=!1,ariaLabel:l,className:f="",style:h,...c})=>{const i={solid:"fas",regular:"far",light:"fal",duotone:"fad",brands:"fab"},u=typeof e=="string"?e:String(e),g=vd[u],p=g?String(g).replace(/^fa-/,""):u.replace(/^fa-/,""),m=[i[t],`fa-${p}`,r&&`fa-${r}`,o&&"fa-spin",a&&"fa-pulse",s&&"fa-fw",n,f].filter(Boolean).join(" "),x=l||p.replace(/-/g," ");return d.jsx("i",{className:m,style:h,"aria-label":x,role:"img",...c})},Tr=(e,t)=>window.G7Core?.t?.(e,t)??e,ko={minLength:{key:"minLength",labelKey:"auth.password_input.rules.minLength",defaultParam:6,validate:(e,t=6)=>e.length>=t},maxLength:{key:"maxLength",labelKey:"auth.password_input.rules.maxLength",defaultParam:20,validate:(e,t=20)=>e.length<=t},hasUppercase:{key:"hasUppercase",labelKey:"auth.password_input.rules.hasUppercase",validate:e=>/[A-Z]/.test(e)},hasLowercase:{key:"hasLowercase",labelKey:"auth.password_input.rules.hasLowercase",validate:e=>/[a-z]/.test(e)},hasNumber:{key:"hasNumber",labelKey:"auth.password_input.rules.hasNumber",validate:e=>/[0-9]/.test(e)},hasSpecial:{key:"hasSpecial",labelKey:"auth.password_input.rules.hasSpecial",validate:e=>/[!@#$%^&*(),.?":{}|<>]/.test(e)},noSpaces:{key:"noSpaces",labelKey:"auth.password_input.rules.noSpaces",validate:e=>!/\s/.test(e)},minTypes:{key:"minTypes",labelKey:"auth.password_input.rules.minTypes",defaultParam:3,validate:(e,t=3)=>{let r=0;return/[A-Z]/.test(e)&&r++,/[a-z]/.test(e)&&r++,/[0-9]/.test(e)&&r++,/[!@#$%^&*(),.?":{}|<>]/.test(e)&&r++,r>=t}}},us=[ko.minLength];function wd(e){const[t,r]=e.split(":"),n=ko[t];if(!n)return null;const o=r?parseInt(r,10):n.defaultParam;return{rule:n,param:isNaN(o)?n.defaultParam:o}}const fs=C.forwardRef(({label:e,error:t,showToggle:r=!0,showValidation:n=!1,isConfirmField:o=!1,confirmTarget:a,onMatchChange:s,onValidityChange:l,rules:f,enableRules:h,showRules:c,wrapperClassName:i="",validationClassName:u="",className:g="",onChange:p,value:m,defaultValue:x,disabled:k,...M},v)=>{const T=C.useRef(null);C.useImperativeHandle(v,()=>T.current);const[I,S]=C.useState(!1),[N,w]=C.useState(!1),[y,E]=C.useState(m??x??"");C.useEffect(()=>{m!==void 0&&E(m)},[m]);const O=C.useMemo(()=>f&&f.length>0?f.map(H=>({rule:H,param:H.defaultParam})):h&&h.length>0?h.map(H=>wd(H)).filter(H=>H!==null):us.map(H=>({rule:H,param:H.defaultParam})),[f,h]),$=C.useMemo(()=>!c||c.length===0?O:O.filter(H=>c.includes(H.rule.key)),[O,c]),P=C.useMemo(()=>!n||o?{}:$.reduce((H,{rule:W,param:Q})=>(H[W.key]=W.validate(y,Q),H),{}),[y,$,n,o]),L=C.useMemo(()=>!o||a===void 0?!0:y===a&&y.length>0,[o,y,a]),U=C.useMemo(()=>n?Object.values(P).every(H=>H):!0,[P,n]);C.useEffect(()=>{if(l&&n&&!o){const H=Object.entries(P).filter(([,W])=>!W).map(([W])=>W);l(U,H)}},[U,P,l,n,o]),C.useEffect(()=>{s&&o&&s(L)},[L,s,o]);const _=C.useCallback(()=>{S(H=>!H)},[]),b=C.useCallback(H=>{const W=H.target.value;E(W),p&&p(H)},[p]),z=C.useCallback(H=>{w(H.getModifierState("CapsLock"))},[]),{loadingactions:F,formdata:G,...X}=M,B={},Y={};for(const[H,W]of Object.entries(X))H.startsWith("data-editor-")||H==="onMouseMove"||H==="onMouseLeave"?B[H]=W:Y[H]=W;return d.jsxs("div",{className:`relative ${i}`,...B,children:[d.jsxs("div",{className:"relative",children:[d.jsx("input",{ref:T,type:I?"text":"password",className:`${g} ${r?"pr-10":""}`,value:m!==void 0?m:void 0,defaultValue:m===void 0?x:void 0,onChange:b,onKeyDown:z,onKeyUp:z,disabled:k,...Y}),r&&d.jsx("button",{type:"button",onClick:_,disabled:k,className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 disabled:opacity-50 disabled:cursor-not-allowed dark:disabled:opacity-50","aria-label":Tr(I?"auth.password_input.hide":"auth.password_input.show"),children:d.jsx(fe,{name:I?"eye-slash":"eye",className:"w-5 h-5"})})]}),N&&!I&&d.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-sm text-yellow-600 dark:text-yellow-400",children:[d.jsx(fe,{name:"triangle-exclamation",className:"w-4 h-4"}),d.jsx("span",{children:Tr("auth.password_input.caps_lock_on")})]}),o&&a!==void 0&&y.length>0&&d.jsxs("div",{className:`mt-2 flex items-center gap-1.5 text-sm ${L?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:[d.jsx(fe,{name:L?"check-circle":"xmark-circle",className:"w-4 h-4"}),d.jsx("span",{children:Tr(L?"auth.password_input.match":"auth.password_input.mismatch")})]}),n&&!o&&y.length>0&&d.jsx("div",{className:`mt-2 space-y-1 ${u}`,children:$.map(({rule:H,param:W})=>{const Q=P[H.key],be=W!==void 0?{count:W}:void 0;return d.jsxs("div",{className:`flex items-center gap-1.5 text-sm ${Q?"text-green-600 dark:text-green-400":"text-gray-500 dark:text-gray-400"}`,children:[d.jsx(fe,{name:Q?"check-circle":"circle",className:"w-4 h-4"}),d.jsx("span",{children:Tr(H.labelKey,be)})]},H.key)})}),t&&d.jsx("p",{className:"mt-1 text-sm text-red-600 dark:text-red-400",children:t})]})});fs.displayName="PasswordInput";const Co=({label:e,error:t,className:r="",onChange:n,value:o,defaultValue:a,...s})=>{const l=C.useRef(!1),f=C.useRef(null),[h,c]=C.useState(o??a??"");C.useEffect(()=>{!l.current&&o!==void 0&&c(o)},[o]);const i=C.useCallback(()=>{l.current=!0},[]),u=C.useCallback(M=>{if(l.current=!1,n){const v=M.target.value;c(v);const T=new Event("change",{bubbles:!0});Object.defineProperty(T,"target",{writable:!1,value:{value:v}}),Object.defineProperty(T,"currentTarget",{writable:!1,value:{value:v}}),n(T)}},[n]),g=C.useCallback(M=>{const v=M.target.value;c(v),!l.current&&n&&n(M)},[n]),{loadingactions:p,formdata:m,...x}=s,k=o!==void 0?{value:h}:{defaultValue:a};return d.jsx("textarea",{ref:f,className:r,onChange:g,onCompositionStart:i,onCompositionEnd:u,...k,...x})},Ar=({children:e,className:t="",...r})=>d.jsx("label",{className:t,...r,children:e}),Gt=({children:e,className:t="",...r})=>d.jsx("p",{className:t,...r,children:e}),xd=["url","size","repeat","position"];function kd(e){if(typeof e=="string")return e===""?void 0:e;if(!e||typeof e!="object"||Array.isArray(e)||!Object.keys(e).every(n=>xd.includes(n)))return;const r=e.url;return typeof r=="string"&&r!==""?r:void 0}const jt=({className:e="",alt:t="",src:r,...n})=>d.jsx("img",{className:e,alt:t,src:kd(r),...n}),Cd=({children:e,className:t="",...r})=>d.jsx("h1",{className:t,...r,children:e}),gs=({children:e,className:t="",...r})=>d.jsx("h2",{className:t,...r,children:e}),Tn=({children:e,className:t="",...r})=>d.jsx("h3",{className:t,...r,children:e}),hs=({children:e,className:t="",...r})=>d.jsx("h4",{className:t,...r,children:e}),_o=({children:e,className:t="",...r})=>d.jsx("ul",{className:t,...r,children:e}),_d=({children:e,className:t="",...r})=>d.jsx("ol",{className:t,...r,children:e}),er=({children:e,className:t="",...r})=>d.jsx("li",{className:t,...r,children:e}),So=({children:e,className:t="",...r})=>d.jsx("a",{className:t,...r,children:e}),Eo=({children:e,className:t="",...r})=>d.jsx("form",{className:t,...r,children:e}),Sd=window.G7Core?.createLogger?.("Comp:Select")??{log:(...e)=>console.log("[Comp:Select]",...e),warn:(...e)=>console.warn("[Comp:Select]",...e),error:(...e)=>console.error("[Comp:Select]",...e)};function Ed(e){const t=window.G7Core?.state?.get?.("_global.appConfig.localeNames")?.[e];return t||{ko:"한국어",en:"English",ja:"日本語",zh:"中文",es:"Español",fr:"Français",de:"Deutsch"}[e]||e}const ps=({children:e,label:t,error:r,options:n,className:o="",value:a,onChange:s,disabled:l,searchable:f=!1,searchPlaceholder:h,editorAttrs:c,...i})=>{const[u,g]=C.useState(!1),[p,m]=C.useState(""),[x,k]=C.useState(null),M=C.useRef(null),v=C.useRef(null),T=C.useRef(null),I=C.useRef(null),S=C.useMemo(()=>n?Array.isArray(n)?n.length===0?[]:typeof n[0]=="string"?n.map(_=>({value:_,label:Ed(_)})):n:(Sd.warn("options prop is not an array:",n),null):null,[n]),N=C.useMemo(()=>S&&S.find(b=>String(b.value)===String(a))?.label||"",[S,a]),w=C.useMemo(()=>{if(!S)return null;if(!f||p.trim()==="")return S;const _=p.trim().toLowerCase();return S.filter(b=>b.label.toLowerCase().includes(_)||String(b.value).toLowerCase().includes(_))},[S,f,p]);C.useEffect(()=>{if(u&&f){m("");const _=setTimeout(()=>T.current?.focus(),0);return()=>clearTimeout(_)}u||m("")},[u,f]);const y=C.useCallback(()=>{if(!v.current)return;const _=v.current.getBoundingClientRect(),b=window.innerHeight-_.bottom,F=b<280&&_.top>b;k(F?{bottom:window.innerHeight-_.top+4,left:_.left,width:_.width}:{top:_.bottom+4,left:_.left,width:_.width})},[]);C.useEffect(()=>{if(!u){k(null);return}return y(),window.addEventListener("scroll",y,!0),window.addEventListener("resize",y),()=>{window.removeEventListener("scroll",y,!0),window.removeEventListener("resize",y)}},[u,y]),C.useEffect(()=>{const _=b=>{const z=b.target;M.current&&!M.current.contains(z)&&(!I.current||!I.current.contains(z))&&g(!1)};return u&&document.addEventListener("mousedown",_),()=>{document.removeEventListener("mousedown",_)}},[u]),C.useEffect(()=>{const _=b=>{b.key==="Escape"&&u&&(g(!1),v.current?.focus())};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[u]);const E=()=>{l||g(!u)},O=_=>{s&&s({target:{value:_},preventDefault:()=>{},stopPropagation:()=>{},type:"change"}),g(!1),v.current?.focus()};if(!S)return d.jsx("select",{className:o,value:a,onChange:s,disabled:l,...c,...i,children:e});const $=o&&o.includes("bg-"),P=o&&/text-(gray|red|blue|green|yellow|white|black|indigo|purple|pink|orange|amber|emerald|teal|cyan|slate)-\d+|text-white|text-black/.test(o),L=$?`${o}${P?"":" text-gray-700 dark:text-gray-200"}`:`w-full px-4 py-2.5 bg-gray-100 dark:bg-gray-700 border-0 rounded-xl text-gray-700 dark:text-gray-200 font-medium focus:ring-2 focus:ring-blue-500 focus:outline-none ${o}`,U={...c,...i};return d.jsxs(j,{ref:M,className:"relative",...U,children:[d.jsxs(R,{ref:v,type:"button",onClick:E,disabled:l,className:`${L} flex items-center justify-between gap-2 text-left cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed`,"aria-haspopup":"listbox","aria-expanded":u,children:[d.jsx(te,{className:"truncate",children:N||" "}),d.jsx(En,{className:`w-4 h-4 flex-shrink-0 transition-transform duration-200 ${u?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),u&&x&&tr.createPortal(d.jsxs(j,{ref:I,className:"fixed z-[9999] bg-white dark:bg-gray-800 rounded-2xl shadow-lg border border-gray-200 dark:border-gray-600 overflow-hidden",style:{top:x.top,bottom:x.bottom,left:x.left,width:x.width},role:"listbox",children:[f&&d.jsx(j,{className:"p-2 border-b border-gray-200 dark:border-gray-600",children:d.jsx(At,{ref:T,type:"text",value:p,onChange:_=>m(_.target.value),placeholder:h??"Search...",className:"w-full px-3 py-2 bg-gray-100 dark:bg-gray-700 border-0 rounded-lg text-sm text-gray-700 dark:text-gray-200 placeholder-gray-400 dark:placeholder-gray-500 focus:ring-2 focus:ring-blue-500 focus:outline-none",role:"searchbox","aria-label":h??"Search"})}),d.jsxs(j,{className:"py-2 max-h-60 overflow-auto",children:[w&&w.length===0&&d.jsx(j,{className:"px-4 py-3 text-sm text-gray-500 dark:text-gray-400 text-center",children:p?"No results":""}),(w??[]).map(_=>{const b=String(_.value)===String(a);return d.jsxs(R,{type:"button",onClick:()=>!_.disabled&&O(_.value),disabled:_.disabled,className:`w-full px-4 py-3 text-left flex items-center justify-between hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors ${b?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-200"} ${_.disabled?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,role:"option","aria-selected":b,children:[d.jsx(te,{children:_.label}),b&&d.jsx(En,{className:"w-5 h-5 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},_.value)})]})]}),document.body)]})},Td=({children:e,className:t="",...r})=>d.jsx("option",{className:t,...r,children:e}),Ad=({children:e,className:t="",...r})=>d.jsx("optgroup",{className:t,...r,children:e}),ms=C.forwardRef(({label:e,className:t="",...r},n)=>d.jsx("input",{ref:n,type:"checkbox",className:t,...r}));ms.displayName="Checkbox";const Nd=({children:e,className:t="",...r})=>d.jsx("table",{className:t,...r,children:e}),Od=({children:e,className:t="",...r})=>d.jsx("thead",{className:t,...r,children:e}),Md=({children:e,className:t="",...r})=>d.jsx("tbody",{className:t,...r,children:e}),Id=({children:e,className:t="",...r})=>d.jsx("tr",{className:t,...r,children:e}),Dd=({children:e,className:t="",...r})=>d.jsx("th",{className:t,...r,children:e}),Pd=({children:e,className:t="",...r})=>d.jsx("td",{className:t,...r,children:e}),Zr=C.forwardRef(({children:e,className:t="",...r},n)=>d.jsx("nav",{ref:n,className:t,...r,children:e}));Zr.displayName="Nav";const bs=({children:e,className:t="",...r})=>d.jsx("section",{className:t,...r,children:e}),Ld=({children:e,className:t="",...r})=>d.jsx("code",{className:t,...r,children:e}),To=C.forwardRef(({className:e="",...t},r)=>d.jsx("hr",{ref:r,className:e,...t})),$d=C.forwardRef(({children:e,className:t="",...r},n)=>d.jsx("header",{ref:n,className:t,...r,children:e})),ys=e=>e==="auto"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e,Ao=e=>{const t=ys(e);document.documentElement.setAttribute("data-theme",t),t==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")},Fd=()=>{const e=localStorage.getItem("g7_color_scheme");return e&&["auto","light","dark"].includes(e)?e:"auto"},An=({onThemeChange:e,className:t="",autoText:r="System",lightText:n="Light",darkText:o="Dark",id:a,editorAttrs:s})=>{const l=Fd(),[f,h]=C.useState(l),[c,i]=C.useState(!1),u=C.useRef(null);C.useEffect(()=>{Ao(f)},[]),C.useEffect(()=>{if(f!=="auto")return;const m=window.matchMedia("(prefers-color-scheme: dark)"),x=()=>{Ao("auto")};return m.addEventListener("change",x),()=>m.removeEventListener("change",x)},[f]),C.useEffect(()=>{const m=x=>{u.current&&!u.current.contains(x.target)&&i(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[]);const g=m=>{h(m),localStorage.setItem("g7_color_scheme",m),Ao(m),i(!1),e?.(m)},p=()=>ys(f)==="dark"?nt.Moon:nt.Sun;return d.jsxs(j,{ref:u,className:`relative ${t}`,id:a,...s,children:[d.jsx(R,{onClick:()=>i(!c),className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors text-gray-600 dark:text-gray-400","aria-label":"Toggle theme",children:d.jsx(fe,{name:p(),className:"w-5 h-5"})}),c&&d.jsx(j,{className:"absolute right-0 mt-2 w-48 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-50",children:d.jsxs(j,{className:"py-2",children:[d.jsxs(R,{onClick:()=>g("auto"),className:` w-full px-4 py-2 text-left hover:bg-gray-50 dark:hover:bg-gray-700 flex items-center gap-3 transition-colors ${f==="auto"?"bg-gray-50 dark:bg-gray-700":""} `,children:[d.jsx(fe,{name:nt.Settings,className:"w-5 h-5 text-gray-600 dark:text-gray-400"}),d.jsx(te,{className:"flex-1 text-left text-gray-900 dark:text-white",children:r}),f==="auto"&&d.jsx(fe,{name:nt.Check,className:"w-4 h-4 text-blue-600 dark:text-blue-400 ml-auto"})]}),d.jsxs(R,{onClick:()=>g("light"),className:` @@ -7,13 +7,13 @@ var SirsoftBasic=(function(ee,d,C,tr){"use strict";function bd(e){const t=Object `,children:[d.jsx(fe,{name:nt.Sun,className:"w-5 h-5 text-gray-600 dark:text-gray-400"}),d.jsx(te,{className:"flex-1 text-left text-gray-900 dark:text-white",children:n}),f==="light"&&d.jsx(fe,{name:nt.Check,className:"w-4 h-4 text-blue-600 dark:text-blue-400 ml-auto"})]}),d.jsxs(R,{onClick:()=>g("dark"),className:` w-full px-4 py-2 text-left hover:bg-gray-50 dark:hover:bg-gray-700 flex items-center gap-3 transition-colors ${f==="dark"?"bg-gray-50 dark:bg-gray-700":""} - `,children:[d.jsx(fe,{name:nt.Moon,className:"w-5 h-5 text-gray-600 dark:text-gray-400"}),d.jsx(te,{className:"flex-1 text-left text-gray-900 dark:text-white",children:o}),f==="dark"&&d.jsx(fe,{name:nt.Check,className:"w-4 h-4 text-blue-600 dark:text-blue-400 ml-auto"})]})]})})]})},$d=Object.freeze(Object.defineProperty({__proto__:null,ThemeToggle:An,default:An},Symbol.toStringTag,{value:"Module"})),vs={xs:"w-6 h-6 text-xs",sm:"w-8 h-8 text-sm",md:"w-10 h-10 text-base",lg:"w-12 h-12 text-lg",xl:"w-16 h-16 text-xl","2xl":"w-24 h-24 text-2xl","3xl":"w-32 h-32 text-3xl","4xl":"w-40 h-40 text-4xl","5xl":"w-48 h-48 text-5xl"},Fd="rounded-full overflow-hidden flex-shrink-0 border border-gray-200 dark:border-gray-700",Ud="grayscale opacity-50",No={normal:"bg-gradient-to-br from-blue-500 to-purple-600",withdrawn:"bg-gray-300 dark:bg-gray-600",guest:"bg-gray-200 dark:bg-gray-700"},Qr=({author:e,name:t,avatar:r,size:n="md",className:o="",text:a,isWithdrawn:s=!1,isGuest:l=!1,id:f,editorAttrs:h})=>{const c=r??e?.avatar,i=a??t??e?.name??"?",u=s||e?.status==="withdrawn",g=l||e?.is_guest||!1,p=C.useMemo(()=>[vs[n]||vs.md,Fd,u?Ud:"",o].filter(Boolean).join(" "),[n,u,o]),m=g?No.guest:u?No.withdrawn:No.normal,x=()=>g?d.jsx(j,{className:`w-full h-full flex items-center justify-center ${m}`,children:d.jsx(fe,{name:"user",className:"text-gray-400 dark:text-gray-500"})}):u?d.jsx(j,{className:`w-full h-full flex items-center justify-center ${m}`,children:d.jsx(fe,{name:"user",className:"text-gray-500 dark:text-gray-400"})}):d.jsx(j,{className:`w-full h-full flex items-center justify-center text-white font-semibold ${m}`,children:i.charAt(0).toUpperCase()});return d.jsx(j,{className:p,id:f,...h,children:c&&!g&&!u?d.jsx(jt,{src:c,alt:i,className:"w-full h-full object-cover"}):x()})},zd=Object.freeze(Object.defineProperty({__proto__:null,Avatar:Qr},Symbol.toStringTag,{value:"Module"})),Hd=window.G7Core?.createLogger?.("Comp:SlotContainer")??{log:(...e)=>console.log("[Comp:SlotContainer]",...e),warn:(...e)=>console.warn("[Comp:SlotContainer]",...e),error:(...e)=>console.error("[Comp:SlotContainer]",...e)};function ws(e,t){return t&&e&&typeof e.id=="string"&&e.id.length>0?{...e,id:`${e.id}__${t}`}:e}const Nn=({slotId:e,className:t="",emptyContent:r,style:n,id:o,children:a})=>{const[s,l]=C.useState([]),[,f]=C.useState({}),h=C.useCallback(()=>{const p=window.__slotContextValue;if(p)return p;const m=window.G7Core;return m&&m.getSlotContext?.()||null},[]),c=C.useCallback(()=>{const p=h();p&&p.isEnabled&&l(p.getSlotComponents(e))},[e,h]);C.useEffect(()=>{const p=h();return!p||!p.isEnabled?void 0:(c(),p.subscribeToSlot(e,()=>{c(),f({})}))},[e,h,c]);const i=C.useCallback(()=>{const p=window.G7Core;return p?p.getDynamicRenderer?.():null},[]);if(s.length===0)return r?d.jsx(j,{className:t,style:n,id:o,children:r}):a?d.jsx(j,{className:t,style:n,id:o,children:a}):null;const u=i(),g=window.G7Core;return!u||!g?(Hd.error("G7Core or DynamicRenderer not available"),null):d.jsxs(j,{className:t,style:n,id:o,children:[s.map(p=>{const{componentDef:m,dataContext:x,parentFormContext:k,getParentComponentContext:M,translationContext:v}=p,T=ws(m,o);return d.jsx(u,{componentDef:T,dataContext:x,translationContext:v,registry:g.getComponentRegistry(),bindingEngine:g.getDataBindingEngine(),translationEngine:g.getTranslationEngine(),actionDispatcher:g.getActionDispatcher(),parentComponentContext:M?.(),parentFormContextProp:k,isRootRenderer:!1},T.id||`slot-${e}-${p.order}`)}),a]})},Gd=Object.freeze(Object.defineProperty({__proto__:null,SlotContainer:Nn,default:Nn,scopeSlotChildDef:ws},Symbol.toStringTag,{value:"Module"})),On=({notifications:e=[],unreadCount:t=0,hasMore:r=!1,loading:n=!1,titleText:o="알림",emptyText:a="알림이 없습니다.",markAllReadText:s="모두 읽음",deleteAllText:l="모두 삭제",unreadOnlyText:f="안 읽은 알림만",unreadOnly:h=!1,onNotificationClick:c,onClose:i,onLoadMore:u,onMarkAllRead:g,onDeleteAll:p,onDelete:m,onUnreadOnlyToggle:x,dropdownAlign:k="right",className:M="",id:v,editorAttrs:T})=>{const[I,S]=C.useState(!1),N=C.useRef(null),w=C.useRef(null),y=C.useRef(null),E=C.useRef(null),O=C.useRef(new Set),$=C.useRef(u),P=C.useRef(r),L=C.useRef(n),U=C.useRef(e.length),_=C.useRef(-1);C.useEffect(()=>{$.current=u,P.current=r,L.current=n,U.current=e.length}),C.useEffect(()=>{if(!E.current||!y.current||!I)return;_.current=-1;const G=new IntersectionObserver(([X])=>{X.isIntersecting&&(L.current||!P.current||_.current!==U.current&&(_.current=U.current,$.current?.()))},{root:y.current,threshold:.1});return G.observe(E.current),()=>G.disconnect()},[I]),C.useEffect(()=>{if(!y.current||!I)return;const G=new IntersectionObserver(B=>{B.forEach(Y=>{const H=Y.target.getAttribute("data-notification-id"),W=Y.target.getAttribute("data-unread")==="true";H&&W&&Y.isIntersecting&&O.current.add(H)})},{root:y.current,threshold:.5});return y.current.querySelectorAll("[data-notification-id]").forEach(B=>G.observe(B)),()=>G.disconnect()},[I,e]);const b=t>0?t:e.filter(G=>!G.read).length,z=C.useCallback(()=>{if(I){if(b>0){const G=Array.from(O.current).filter(X=>{const B=e.find(Y=>String(Y.id)===String(X));return B&&!B.read});G.length>0&&i?.(G)}O.current.clear(),S(!1)}},[I,i,b,e]);C.useEffect(()=>{if(!I)return;const G=X=>{N.current&&!N.current.contains(X.target)&&z()};return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[I,z]);const F=C.useCallback(()=>{I?z():S(!0)},[I,z]);return C.useLayoutEffect(()=>{const G=w.current;if(!I||!G)return;G.style.transform="";const X=G.getBoundingClientRect(),B=typeof window<"u"?window.innerWidth:0;if(X.width===0&&X.height===0)return;const Y=8;let H=0;X.right>B-Y?H=-(X.right-(B-Y)):X.left0&&d.jsx(te,{className:"absolute -top-1 -right-1 w-5 h-5 flex items-center justify-center text-xs font-bold text-white bg-red-500 dark:bg-red-600 rounded-full",children:b>99?"99+":b})]}),I&&d.jsxs(j,{ref:w,className:`absolute ${k==="left"?"left-0":"right-0"} mt-2 w-80 max-w-[calc(100vw-1rem)] bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-50`,children:[d.jsxs(j,{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700 flex items-center justify-between gap-2",children:[d.jsxs(j,{className:"flex items-center gap-3 min-w-0",children:[d.jsx(te,{className:"font-semibold text-gray-900 dark:text-white",children:o}),x&&d.jsxs(j,{className:"flex items-center gap-1.5 cursor-pointer select-none",onClick:()=>x(!h),children:[d.jsx(At,{type:"checkbox",checked:h,onChange:G=>{G.stopPropagation(),x(G.target.checked)},onClick:G=>G.stopPropagation(),className:"w-3.5 h-3.5 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-400 focus:ring-blue-500 dark:focus:ring-blue-400 cursor-pointer"}),d.jsx(te,{className:"text-xs text-gray-600 dark:text-gray-400",children:f})]})]}),d.jsxs(j,{className:"flex items-center gap-3 flex-shrink-0",children:[g&&b>0&&d.jsx(R,{onClick:()=>{g(),O.current.clear()},className:"text-xs text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300 hover:underline cursor-pointer",children:s}),p&&e.length>0&&d.jsx(R,{onClick:()=>{p()},className:"text-xs text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300 hover:underline cursor-pointer",children:l})]})]}),d.jsx(j,{ref:y,className:"max-h-96 overflow-y-auto",children:e.length===0&&!n?d.jsx(j,{className:"px-4 py-8 text-center text-gray-500 dark:text-gray-400",children:d.jsx(te,{children:a})}):d.jsxs(d.Fragment,{children:[e.map(G=>{const X=!G.read;return d.jsxs(j,{"data-notification-id":G.id,"data-unread":X?"true":"false",onClick:()=>{G.onClick?.(),c?.(G),S(!1)},className:`group flex items-start gap-3 px-4 py-3 text-left border-b border-gray-100 dark:border-gray-700 transition-colors cursor-pointer ${X?"bg-blue-50/70 dark:bg-blue-900/20 hover:bg-blue-50 dark:hover:bg-blue-900/30":"bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700/50 opacity-70"}`,children:[G.iconName&&d.jsx(fe,{name:G.iconName,className:`w-5 h-5 mt-0.5 flex-shrink-0 ${X?"text-blue-600 dark:text-blue-400":"text-gray-400 dark:text-gray-500"}`}),d.jsxs(j,{className:"flex-1 min-w-0",children:[d.jsx(j,{className:`text-sm truncate ${X?"font-semibold text-gray-900 dark:text-white":"font-normal text-gray-600 dark:text-gray-400"}`,children:G.title}),d.jsx(j,{className:`text-sm mt-1 line-clamp-2 ${X?"text-gray-700 dark:text-gray-300":"text-gray-500 dark:text-gray-500"}`,children:G.message}),d.jsx(j,{className:"text-gray-400 dark:text-gray-500 text-xs mt-1 font-mono",children:G.time})]}),d.jsxs(j,{className:"flex flex-col items-center gap-2 flex-shrink-0",children:[X&&d.jsx(te,{className:"w-2 h-2 bg-blue-500 dark:bg-blue-400 rounded-full mt-1.5"}),m&&d.jsx(R,{onClick:B=>{B.stopPropagation(),m(G)},className:"p-1 text-gray-400 dark:text-gray-500 hover:text-red-600 dark:hover:text-red-400 rounded hover:bg-red-50 dark:hover:bg-red-900/20 cursor-pointer opacity-0 group-hover:opacity-100 transition-opacity","aria-label":"Delete notification",children:d.jsx(fe,{name:nt.Trash,className:"w-4 h-4"})})]})]},G.id)}),r&&d.jsx(j,{ref:E,className:"px-4 py-3 text-center",children:n?d.jsx(te,{className:"text-sm text-gray-400 dark:text-gray-500",children:"..."}):d.jsx(te,{className:"text-sm text-gray-400 dark:text-gray-500"})}),n&&!r&&e.length>0&&d.jsx(j,{className:"px-4 py-2 text-center",children:d.jsx(te,{className:"text-sm text-gray-400 dark:text-gray-500",children:"..."})})]})})]})]})},jd=Object.freeze(Object.defineProperty({__proto__:null,NotificationCenter:On,default:On},Symbol.toStringTag,{value:"Module"})),Qe=(e,t)=>window.G7Core?.t?.(e,t)??e,vt=e=>{window.G7Core?.dispatch?.({handler:"navigate",params:{path:e}})},xs=({logo:e,siteName:t="그누보드7",user:r,cartCount:n=0,notificationCount:o=0,boards:a=[],maxVisibleBoards:s=5,onMobileMenuOpen:l,availableLocales:f=[],currentLocale:h="ko",shopBase:c="/shop",className:i="",editorAttrs:u,notifications:g=[],notificationHasMore:p=!1,notificationLoading:m=!1,notificationUnreadOnly:x=!1,notificationTitleText:k,notificationEmptyText:M,notificationMarkAllReadText:v,notificationDeleteAllText:T,notificationUnreadOnlyText:I,onNotificationClose:S,onNotificationClick:N,onNotificationLoadMore:w,onNotificationMarkAllRead:y,onNotificationDeleteAll:E,onNotificationDelete:O,onNotificationUnreadOnlyToggle:$})=>{const[P,L]=C.useState(""),[U,_]=C.useState(!1),[b,z]=C.useState(!1),[F,G]=C.useState(!1),[X,B]=C.useState({top:0,left:0}),[Y,H]=C.useState(window.location.pathname),W=C.useRef(null),Q=C.useRef(null),be=C.useRef(null),pe=window.G7Core?.useResponsive,ne=pe?.(),Ae=ne?ne.width<768:typeof window<"u"&&window.innerWidth<768;C.useEffect(()=>{const K=()=>H(window.location.pathname);window.addEventListener("popstate",K);const oe=history.pushState;return history.pushState=function(...ae){oe.apply(this,ae),H(window.location.pathname)},()=>{window.removeEventListener("popstate",K),history.pushState=oe}},[]);const ve=(K,oe=!1)=>oe?Y===K:Y===K||Y.startsWith(K+"/"),We=()=>{const K=c==="/"?"":c;return Y.startsWith(`${K}/products`)||Y.startsWith(`${K}/cart`)||Y.startsWith(`${K}/checkout`)||Y.startsWith(`${K}/category`)},me=K=>{const oe="px-3 py-2 text-sm font-medium whitespace-nowrap cursor-pointer rounded-lg transition-colors";return K?`${oe} bg-gray-900 text-white dark:bg-white dark:text-gray-900`:`${oe} text-gray-700 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-800`};C.useEffect(()=>{const K=oe=>{W.current&&!W.current.contains(oe.target)&&_(!1),Q.current&&!Q.current.contains(oe.target)&&z(!1),be.current&&!be.current.contains(oe.target)&&G(!1)};return document.addEventListener("mousedown",K),()=>document.removeEventListener("mousedown",K)},[]);const Te=a.slice(0,s),ge=a.slice(s),Oe=K=>{K.preventDefault(),P.trim()&&vt(`/search?q=${encodeURIComponent(P)}`)},we=async()=>{window.G7Core?.dispatch?.({handler:"logout"})},$e=K=>{window.G7Core?.dispatch?.({handler:"setLocale",target:K}),G(!1)},ze=K=>window.G7Core?.state?.get?.("_global.appConfig.localeNames")?.[K]??(K==="ko"?"한국어":K==="en"?"English":K==="ja"?"日本語":K==="zh"?"中文":K==="es"?"Español":K==="fr"?"Français":K==="de"?"Deutsch":K.toUpperCase());return d.jsxs(Pd,{...u??{},className:`sticky top-0 z-50 bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-800 ${i}`,children:[d.jsx(j,{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:d.jsxs(j,{className:"flex items-center justify-between h-16",children:[d.jsx(R,{onClick:()=>vt("/"),className:"flex items-center gap-2 flex-shrink-0 cursor-pointer",children:e?d.jsx(jt,{src:e,alt:t,className:"h-8"}):d.jsx(te,{className:"text-xl font-bold text-gray-900 dark:text-white",children:t})}),!Ae&&d.jsx(Eo,{onSubmit:Oe,className:"flex flex-1 max-w-lg mx-8",children:d.jsxs(j,{className:"relative w-full",children:[d.jsx(At,{type:"text",value:P,onChange:K=>L(K.target.value),placeholder:Qe("common.search_placeholder"),className:"w-full px-4 py-2 pl-10 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}),d.jsx(fe,{name:"search",className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-gray-500"})]})}),d.jsxs(j,{className:"flex items-center gap-2",children:[d.jsx(An,{autoText:Qe("common.theme.auto"),lightText:Qe("common.theme.light"),darkText:Qe("common.theme.dark")}),r?.uuid&&d.jsx(On,{notifications:g,unreadCount:o,hasMore:p,loading:m,unreadOnly:x,titleText:k??Qe("mypage.notifications.title"),emptyText:M??Qe("mypage.notifications.empty"),markAllReadText:v??Qe("mypage.notifications.mark_all_read"),deleteAllText:T??Qe("mypage.notifications.delete_all"),unreadOnlyText:I??Qe("mypage.notifications.unread_only"),onClose:S,onNotificationClick:N,onLoadMore:w,onMarkAllRead:y,onDeleteAll:E,onDelete:O,onUnreadOnlyToggle:$,dropdownAlign:"right"}),d.jsxs(R,{onClick:()=>vt(`${c}/cart`),className:"relative p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white cursor-pointer",children:[d.jsx(fe,{name:"shopping-cart",className:"w-5 h-5"}),n>0&&d.jsx(te,{className:"absolute -top-1 -right-1 w-5 h-5 flex items-center justify-center text-xs bg-blue-500 text-white rounded-full",children:n>99?"99+":n})]}),f&&f.length>1&&d.jsxs(j,{ref:be,className:"relative",children:[d.jsxs(R,{onClick:()=>G(!F),className:"flex items-center gap-1.5 px-2.5 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg cursor-pointer transition-colors","aria-haspopup":"listbox","aria-expanded":F,"aria-label":Qe("common.language"),children:[d.jsx(fe,{name:"globe",className:"w-4 h-4"}),d.jsx(te,{className:"font-medium uppercase",children:h}),d.jsx(fe,{name:"chevron-down",className:"w-3 h-3"})]}),F&&d.jsx(j,{role:"listbox",className:"absolute right-0 mt-2 w-44 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1 z-50 overflow-hidden",children:f.map(K=>{const oe=K===h;return d.jsxs(R,{role:"option","aria-selected":oe,onClick:()=>$e(K),className:`w-full px-4 py-2.5 text-left text-sm flex items-center gap-3 cursor-pointer transition-colors ${oe?"bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:[d.jsx(fe,{name:"globe",className:"w-4 h-4"}),d.jsx(te,{className:"flex-1 font-medium",children:ze(K)}),oe&&d.jsx(fe,{name:"check",className:"w-4 h-4"})]},K)})})]}),d.jsx(Nn,{slotId:"header_currency",id:"header_currency_slot_desktop",className:"flex items-center"}),r?.uuid?d.jsxs(j,{ref:W,className:"relative",children:[d.jsxs(R,{onClick:()=>_(!U),className:"flex items-center gap-2 p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white",children:[d.jsx(Qr,{avatar:r.avatar,name:r.name,size:"sm"}),d.jsx(te,{className:"hidden sm:inline text-sm font-medium",children:r.name}),d.jsx(fe,{name:"chevron-down",className:"w-4 h-4"})]}),U&&d.jsxs(j,{className:"absolute right-0 mt-2 w-56 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1 z-50",children:[d.jsx(j,{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700",children:d.jsxs(j,{className:"flex items-center gap-3",children:[d.jsx(Qr,{avatar:r.avatar,name:r.name,size:"md"}),d.jsxs(j,{children:[d.jsx(j,{className:"text-sm font-medium text-gray-900 dark:text-white",children:r.name}),d.jsx(j,{className:"text-xs text-gray-500 dark:text-gray-400",children:Qe("common.member")})]})]})}),d.jsxs(j,{className:"py-1",children:[r.is_admin&&d.jsxs(d.Fragment,{children:[d.jsxs(So,{href:"/admin",className:"block w-full text-left px-4 py-2 text-sm text-blue-600 dark:text-blue-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer font-medium",children:[d.jsx(fe,{name:"settings",className:"inline w-4 h-4 mr-2"}),Qe("common.admin_menu")]}),d.jsx(To,{className:"my-1 border-gray-200 dark:border-gray-700"})]}),d.jsxs(R,{onClick:()=>{vt("/mypage"),_(!1)},className:"block w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[d.jsx(fe,{name:"user",className:"inline w-4 h-4 mr-2"}),Qe("common.mypage")]}),d.jsxs(R,{onClick:()=>{vt("/mypage/orders"),_(!1)},className:"block w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[d.jsx(fe,{name:"shopping-bag",className:"inline w-4 h-4 mr-2"}),Qe("mypage.tabs.orders")]}),d.jsxs(R,{onClick:()=>{vt("/mypage/wishlist"),_(!1)},className:"block w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[d.jsx(fe,{name:"heart",className:"inline w-4 h-4 mr-2"}),Qe("mypage.tabs.wishlist")]})]}),d.jsx(To,{className:"my-1 border-gray-200 dark:border-gray-700"}),d.jsxs(R,{onClick:we,className:"block w-full text-left px-4 py-2 text-sm text-red-600 dark:text-red-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[d.jsx(fe,{name:"log-out",className:"inline w-4 h-4 mr-2"}),Qe("auth.logout")]})]})]}):d.jsxs(j,{className:"flex items-center gap-1.5",children:[d.jsx(R,{onClick:()=>vt("/login?redirect=/mypage/orders"),className:"px-2.5 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white cursor-pointer",children:Qe("shop.guest_order_form.nav_link")}),d.jsx(R,{onClick:()=>vt("/login"),className:"px-2.5 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white cursor-pointer",children:Qe("auth.login")}),d.jsx(R,{onClick:()=>vt("/register"),className:"ml-1 px-3 py-2 text-sm font-medium text-white bg-emerald-500 rounded-lg hover:bg-emerald-600 cursor-pointer",children:Qe("auth.register_link")})]}),Ae&&d.jsx(R,{onClick:l,className:"p-2 text-gray-600 dark:text-gray-400",children:d.jsx(fe,{name:"menu",className:"w-6 h-6"})})]})]})}),!Ae&&d.jsx(Zr,{className:"border-t border-gray-200 dark:border-gray-800",children:d.jsx(j,{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:d.jsxs(j,{className:"flex items-center gap-1 h-12 overflow-x-auto",children:[d.jsx(R,{onClick:()=>vt("/"),className:me(ve("/",!0)),"data-testid":"nav-home",children:Qe("nav.home")}),d.jsxs(R,{onClick:()=>vt("/boards/popular"),className:`flex items-center gap-1 ${me(ve("/boards/popular"))}`,"data-testid":"nav-popular",children:[d.jsx(te,{className:"text-orange-500",children:"🔥"}),Qe("nav.popular")]}),d.jsxs(R,{onClick:()=>vt(`${c==="/"?"":c}/products`),className:`flex items-center gap-1 ${me(We())}`,"data-testid":"nav-shop",children:[d.jsx(te,{children:"🛒"}),Qe("nav.shop")]}),Te.map(K=>d.jsxs(R,{onClick:()=>vt(`/board/${K.slug}`),className:me(ve(`/board/${K.slug}`)),children:[K.icon&&d.jsx(te,{className:"mr-1",children:K.icon}),K.name]},K.id)),ge.length>0&&d.jsxs(j,{ref:Q,className:"relative",children:[d.jsxs(R,{onClick:()=>{if(!b&&Q.current){const K=Q.current.getBoundingClientRect();B({top:K.bottom+4,left:K.left})}z(!b)},className:"flex items-center gap-1 px-3 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white",children:[Qe("nav.more"),d.jsx(fe,{name:"chevron-down",className:"w-4 h-4"})]}),b&&d.jsx(j,{className:"fixed w-48 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1 z-50",style:{top:`${X.top}px`,left:`${X.left}px`},children:ge.map(K=>{const oe=ve(`/board/${K.slug}`);return d.jsxs(R,{onClick:()=>{vt(`/board/${K.slug}`),z(!1)},className:`block w-full text-left px-4 py-2 text-sm cursor-pointer ${oe?"bg-gray-900 text-white dark:bg-white dark:text-gray-900":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:[K.icon&&d.jsx(te,{className:"mr-1",children:K.icon}),K.name]},K.id)})})]})]})})})]})},Bd=Object.freeze(Object.defineProperty({__proto__:null,default:xs},Symbol.toStringTag,{value:"Module"})),Wd=C.forwardRef(({children:e,className:t="",...r},n)=>d.jsx("footer",{ref:n,className:t,...r,children:e})),Nt=(e,t)=>window.G7Core?.t?.(e,t)??e,Vd=768,ks=1024,Kd=e=>{window.G7Core?.dispatch?.({handler:"navigate",params:{path:e}})},Cs=({siteName:e="그누보드7",siteDescription:t,copyrightText:r,socialLinks:n={},linkGroups:o,className:a="",editorAttrs:s})=>{const l=new Date().getFullYear(),h=window.G7Core?.useResponsive,i=h?.()?.width??(typeof window<"u"?window.innerWidth:ks),u=i=ks,p=u?1:g?5:2,m=[{title:Nt("footer.community"),links:[{label:Nt("nav.home"),href:"/"},{label:Nt("nav.popular"),href:"/boards/popular"},{label:Nt("footer.all_boards"),href:"/boards"}]},{title:Nt("footer.info"),links:[{label:Nt("footer.about"),href:"/page/about"},{label:Nt("footer.faq"),href:"/page/faq"},{label:Nt("footer.contact"),href:"/page/contact"}]},{title:Nt("footer.policy"),links:[{label:Nt("footer.terms"),href:"/page/terms"},{label:Nt("footer.privacy"),href:"/page/privacy"},{label:Nt("footer.refund"),href:"/page/refund"}]}],x=o||m,k={github:"github",twitter:"twitter",discord:"discord",facebook:"facebook",instagram:"instagram"};return d.jsx(Wd,{...s??{},className:`bg-gray-50 dark:bg-gray-900 border-t border-gray-200 dark:border-gray-800 ${a}`,children:d.jsxs(j,{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12",children:[d.jsxs(j,{className:"grid gap-8",style:{gridTemplateColumns:`repeat(${p}, minmax(0, 1fr))`},children:[d.jsxs(j,{style:g?{gridColumn:"span 2 / span 2"}:void 0,children:[d.jsx(Tn,{className:"text-lg font-bold text-gray-900 dark:text-white",children:e}),t&&d.jsx(Gt,{className:"mt-2 text-sm text-gray-600 dark:text-gray-400",children:t}),d.jsx(j,{className:"mt-4 flex items-center gap-4",children:Object.entries(n).map(([M,v])=>v?d.jsx(So,{href:v,target:"_blank",rel:"noopener noreferrer",className:"text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200","aria-label":M,children:d.jsx(fe,{name:k[M],className:"w-5 h-5"})},M):null)})]}),x.map((M,v)=>d.jsxs(j,{children:[d.jsx(hs,{className:"text-sm font-semibold text-gray-900 dark:text-white uppercase tracking-wider",children:M.title}),d.jsx(_o,{className:"mt-4 space-y-2",children:M.links.map((T,I)=>d.jsx(er,{children:d.jsx(R,{onClick:()=>Kd(T.href),className:"text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white cursor-pointer",children:T.label})},I))})]},v))]}),d.jsxs(j,{className:"mt-8 pt-8 border-t border-gray-200 dark:border-gray-800 flex justify-between items-center gap-4",style:{flexDirection:u?"column":"row"},children:[d.jsx(Gt,{className:"text-sm text-gray-500 dark:text-gray-400",children:r||`© ${l} ${e}. All rights reserved.`}),d.jsx(Gt,{className:"text-sm text-gray-500 dark:text-gray-400",children:Nt("footer.powered_by")})]})]})})},Yd=Object.freeze(Object.defineProperty({__proto__:null,default:Cs},Symbol.toStringTag,{value:"Module"})),Bt=(e,t)=>window.G7Core?.t?.(e,t)??e,Lt=e=>{window.G7Core?.dispatch?.({handler:"navigate",params:{path:e}})},_s=({isOpen:e,onClose:t,logo:r,siteName:n="그누보드7",user:o,boards:a=[],cartCount:s=0})=>{const l=C.useRef(null),h=window.G7Core?.useResponsive,c=h?.(),i=c?c.width<1024:typeof window<"u"&&window.innerWidth<1024;C.useEffect(()=>{const g=p=>{p.key==="Escape"&&t()};return e&&(document.addEventListener("keydown",g),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",g),document.body.style.overflow=""}},[e,t]);const u=g=>{g.target===g.currentTarget&&t()};return!e||!i?null:d.jsxs(j,{className:"fixed inset-0 z-50",onClick:u,children:[d.jsx(j,{className:"fixed inset-0 bg-black/50 transition-opacity"}),d.jsxs(j,{ref:l,className:`fixed inset-y-0 left-0 w-80 max-w-[85vw] bg-white dark:bg-gray-900 shadow-xl transform transition-transform duration-300 ${e?"translate-x-0":"-translate-x-full"}`,children:[d.jsxs(j,{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-800",children:[d.jsx(R,{onClick:()=>{t(),Lt("/")},className:"flex items-center gap-2 cursor-pointer",children:r?d.jsx(jt,{src:r,alt:n,className:"h-8"}):d.jsx(te,{className:"text-xl font-bold text-gray-900 dark:text-white",children:n})}),d.jsx(R,{onClick:t,className:"p-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200","aria-label":"메뉴 닫기",children:d.jsx(fe,{name:"x",className:"w-6 h-6"})})]}),o?d.jsx(j,{className:"p-4 border-b border-gray-200 dark:border-gray-800",children:d.jsxs(j,{className:"flex items-center gap-3",children:[o.avatar?d.jsx(jt,{src:o.avatar,alt:o.name,className:"w-12 h-12 rounded-full"}):d.jsx(j,{className:"w-12 h-12 rounded-full bg-blue-500 flex items-center justify-center text-white text-lg font-medium",children:(o.name||"U").charAt(0).toUpperCase()}),d.jsxs(j,{children:[d.jsx(Gt,{className:"font-medium text-gray-900 dark:text-white",children:o.name}),d.jsx(R,{onClick:()=>{t(),Lt("/mypage")},className:"text-sm text-blue-600 dark:text-blue-400 hover:underline cursor-pointer",children:Bt("common.mypage")})]})]})}):d.jsx(j,{className:"p-4 border-b border-gray-200 dark:border-gray-800",children:d.jsxs(j,{className:"flex gap-2",children:[d.jsx(R,{onClick:()=>{t(),Lt("/login")},className:"flex-1 py-2 text-center text-sm font-medium text-white bg-gray-900 dark:bg-white dark:text-gray-900 rounded-lg cursor-pointer",children:Bt("auth.login")}),d.jsx(R,{onClick:()=>{t(),Lt("/register")},className:"flex-1 py-2 text-center text-sm font-medium text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 rounded-lg cursor-pointer",children:Bt("auth.register")})]})}),d.jsx(Zr,{className:"p-4 overflow-y-auto max-h-[calc(100vh-200px)]",children:d.jsxs(_o,{className:"space-y-1",children:[d.jsx(er,{children:d.jsxs(R,{onClick:()=>{t(),Lt("/")},className:"flex items-center gap-3 px-3 py-2 w-full text-left text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg cursor-pointer",children:[d.jsx(fe,{name:"home",className:"w-5 h-5"}),Bt("nav.home")]})}),d.jsx(er,{children:d.jsxs(R,{onClick:()=>{t(),Lt("/popular")},className:"flex items-center gap-3 px-3 py-2 w-full text-left text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg cursor-pointer",children:[d.jsx(te,{className:"text-orange-500",children:"🔥"}),Bt("nav.popular")]})}),d.jsx(er,{children:d.jsxs(R,{onClick:()=>{t(),Lt("/shop")},className:"flex items-center gap-3 px-3 py-2 w-full text-left text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg cursor-pointer",children:[d.jsx(te,{children:"🛒"}),Bt("nav.shop")]})}),d.jsx(er,{children:d.jsxs(R,{onClick:()=>{t(),Lt("/cart")},className:"flex items-center gap-3 px-3 py-2 w-full text-left text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg cursor-pointer",children:[d.jsx(fe,{name:"shopping-cart",className:"w-5 h-5"}),Bt("nav.cart"),s>0&&d.jsx(te,{className:"ml-auto px-2 py-0.5 text-xs bg-blue-500 text-white rounded-full",children:s})]})}),d.jsx(er,{className:"my-4 border-t border-gray-200 dark:border-gray-800"}),d.jsx(er,{className:"px-3 py-2 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:Bt("nav.boards")}),a.map(g=>d.jsx(er,{children:d.jsxs(R,{onClick:()=>{t(),Lt(`/board/${g.slug}`)},className:"flex items-center gap-3 px-3 py-2 w-full text-left text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg cursor-pointer",children:[g.icon&&d.jsx(te,{children:g.icon}),g.name]})},g.id))]})}),d.jsx(j,{className:"absolute bottom-0 left-0 right-0 p-4 border-t border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900",children:d.jsxs(j,{className:"flex items-center justify-between text-sm text-gray-500 dark:text-gray-400",children:[d.jsx(R,{onClick:()=>{t(),Lt("/about")},className:"hover:text-gray-700 dark:hover:text-gray-200 cursor-pointer",children:Bt("footer.about")}),d.jsx(R,{onClick:()=>{t(),Lt("/terms")},className:"hover:text-gray-700 dark:hover:text-gray-200 cursor-pointer",children:Bt("footer.terms")}),d.jsx(R,{onClick:()=>{t(),Lt("/privacy")},className:"hover:text-gray-700 dark:hover:text-gray-200 cursor-pointer",children:Bt("footer.privacy")})]})})]})]})},Xd=Object.freeze(Object.defineProperty({__proto__:null,default:_s},Symbol.toStringTag,{value:"Module"}));function Ss(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r2?n-2:0),a=2;a1?r-1:0),o=1;o"u"?null:tt(BigInt.prototype.toString),Ds=typeof Symbol>"u"?null:tt(Symbol.prototype.toString),wt=tt(Object.prototype.hasOwnProperty),tn=tt(Object.prototype.toString),gt=tt(RegExp.prototype.test),ur=iu(TypeError);function tt(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o2&&arguments[2]!==void 0?arguments[2]:Rr;if(Ts&&Ts(e,null),!Or(t))return e;let n=t.length;for(;n--;){let o=t[n];if(typeof o=="string"){const a=r(o);a!==o&&(eu(t)||(t[n]=a),o=a)}e[o]=!0}return e}function cu(e){for(let t=0;t/g),mu=lt(/\${[\w\W]*/g),bu=lt(/^data-[\-\w.\u00B7-\uFFFF]+$/),yu=lt(/^aria-[\-\w]+$/),Us=lt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),vu=lt(/^(?:\w+script|data):/i),wu=lt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),xu=lt(/^html$/i),ku=lt(/^[a-z][.\w]*(-[.\w]+)+$/i),zs=lt(/<[/\w!]/g),Hs=lt(/<[/\w]/g),Cu=lt(/<\/no(script|embed|frames)/i),_u=lt(/\/>/i),Mt={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Gs=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],Su=ot(Ge({},Gs)),Eu=(function(){const e={};return dr(Gs,t=>{e[t]=lt(new RegExp("])","i"))}),ot(e)})(),Tu=function(){return typeof window>"u"?null:window},Au=function(t,r){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let n=null;const o="data-tt-policy-suffix";r&&r.hasAttribute(o)&&(n=r.getAttribute(o));const a="dompurify"+(n?"#"+n:"");try{return t.createPolicy(a,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},js=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},rr=function(t,r,n,o){return wt(t,r)&&Or(t[r])?Ge(o.base?Ot(o.base):{},t[r],o.transform):n},Fo=function(t,r,n){const o=wt(t,r)?t[r]:void 0;return o&&typeof o=="object"?Ot(o):n()};function Bs(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Tu();const t=J=>Bs(J);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==Mt.document||!e.Element)return t.isSupported=!1,t;let r=e.document;const n=r,o=n.currentScript;e.DocumentFragment;const a=e.HTMLTemplateElement,s=e.Node,l=e.Element,f=e.NodeFilter,h=e.NamedNodeMap;h===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const c=e.DOMParser,i=e.trustedTypes,u=l.prototype,g=Wt(u,"cloneNode"),p=Wt(u,"remove"),m=Wt(u,"nextSibling"),x=Wt(u,"childNodes"),k=Wt(u,"parentNode"),M=Wt(u,"shadowRoot"),v=Wt(u,"attributes"),T=s&&s.prototype?Wt(s.prototype,"nodeType"):null,I=s&&s.prototype?Wt(s.prototype,"nodeName"):null,S=s&&s.prototype?Wt(s.prototype,"ownerDocument"):null,N=function(D){return T?T(D):D.nodeType},w=function(D){return I?I(D):D.nodeName};if(typeof a=="function"){const J=r.createElement("template");J.content&&J.content.ownerDocument&&(r=J.content.ownerDocument)}let y,E="",O,$=!1,P=0;const L=function(){if(P>0)throw ur('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},U=function(D){L(),P++;try{return y.createHTML(D)}finally{P--}},_=function(D){L(),P++;try{return y.createScriptURL(D)}finally{P--}},b=function(){return $||(O=Au(i,o),$=!0),O},z=r,F=z.implementation,G=z.createNodeIterator,X=z.createDocumentFragment,B=z.getElementsByTagName,Y=n.importNode;let H=js();t.isSupported=typeof Es=="function"&&typeof k=="function"&&F&&F.createHTMLDocument!==void 0;const W=hu,Q=pu,be=mu,se=bu,pe=yu,ne=vu,Ae=wu,ve=ku;let We=Us,me=null;const Te=Ge({},[...Ps,...Do,...Po,...Lo,...Ls]);let ge=null;const Oe=Ge({},[...$s,...$o,...Fs,...Mn]);let we=Object.seal(Nr(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),$e=null,ze=null;const K=Object.seal(Nr(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let oe=!0,ae=!0,ce=!1,ke=!0,Ee=!1,Be=!0,Me=!1,Ke=!1,Pe=null,q=null,le=!1,de=!1,ue=!1,ie=!1,Fe=!0,Ce=!1;const Ie="user-content-";let Ne=!0,He=!1,je={},_e=null;const xe=Ge({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let De=null;const Ye=Ge({},["audio","video","img","source","image","track"]);let rt=null;const qe=Ge({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Je="http://www.w3.org/1998/Math/MathML",Zt="http://www.w3.org/2000/svg",Ve="http://www.w3.org/1999/xhtml";let bt=Ve,St=!1,Pt=null;const _r=Ge({},[Je,Zt,Ve],Io),lr=ot(["mi","mo","mn","ms","mtext"]);let Ht=Ge({},lr);const ir=ot(["annotation-xml"]);let Sr=Ge({},ir);const Vm=Ge({},["title","style","font","a","script"]);let _n=null;const Km=["application/xhtml+xml","text/html"],Ym="text/html";let et=null,Xr=null;const Xm=r.createElement("form"),od=function(D){return D instanceof RegExp||D instanceof Function},ss=function(){let D=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Xr&&Xr===D)return;(!D||typeof D!="object")&&(D={}),D=Ot(D),_n=Km.indexOf(D.PARSER_MEDIA_TYPE)===-1?Ym:D.PARSER_MEDIA_TYPE,et=_n==="application/xhtml+xml"?Io:Rr,me=rr(D,"ALLOWED_TAGS",Te,{transform:et}),ge=rr(D,"ALLOWED_ATTR",Oe,{transform:et}),Pt=rr(D,"ALLOWED_NAMESPACES",_r,{transform:Io}),rt=rr(D,"ADD_URI_SAFE_ATTR",qe,{transform:et,base:qe}),De=rr(D,"ADD_DATA_URI_TAGS",Ye,{transform:et,base:Ye}),_e=rr(D,"FORBID_CONTENTS",xe,{transform:et}),$e=rr(D,"FORBID_TAGS",Ot({}),{transform:et}),ze=rr(D,"FORBID_ATTR",Ot({}),{transform:et}),je=wt(D,"USE_PROFILES")?D.USE_PROFILES&&typeof D.USE_PROFILES=="object"?Ot(D.USE_PROFILES):D.USE_PROFILES:!1,oe=D.ALLOW_ARIA_ATTR!==!1,ae=D.ALLOW_DATA_ATTR!==!1,ce=D.ALLOW_UNKNOWN_PROTOCOLS||!1,ke=D.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ee=D.SAFE_FOR_TEMPLATES||!1,Be=D.SAFE_FOR_XML!==!1,Me=D.WHOLE_DOCUMENT||!1,de=D.RETURN_DOM||!1,ue=D.RETURN_DOM_FRAGMENT||!1,ie=D.RETURN_TRUSTED_TYPE||!1,le=D.FORCE_BODY||!1,Fe=D.SANITIZE_DOM!==!1,Ce=D.SANITIZE_NAMED_PROPS||!1,Ne=D.KEEP_CONTENT!==!1,He=D.IN_PLACE||!1,We=uu(D.ALLOWED_URI_REGEXP)?D.ALLOWED_URI_REGEXP:Us,bt=typeof D.NAMESPACE=="string"?D.NAMESPACE:Ve,Ht=Fo(D,"MATHML_TEXT_INTEGRATION_POINTS",()=>Ge({},lr)),Sr=Fo(D,"HTML_INTEGRATION_POINTS",()=>Ge({},ir));const V=Fo(D,"CUSTOM_ELEMENT_HANDLING",()=>Nr(null));if(we=Nr(null),wt(V,"tagNameCheck")&&od(V.tagNameCheck)&&(we.tagNameCheck=V.tagNameCheck),wt(V,"attributeNameCheck")&&od(V.attributeNameCheck)&&(we.attributeNameCheck=V.attributeNameCheck),wt(V,"allowCustomizedBuiltInElements")&&typeof V.allowCustomizedBuiltInElements=="boolean"&&(we.allowCustomizedBuiltInElements=V.allowCustomizedBuiltInElements),lt(we),Ee&&(ae=!1),ue&&(de=!0),je&&(me=Ge({},Ls),ge=Nr(null),je.html===!0&&(Ge(me,Ps),Ge(ge,$s)),je.svg===!0&&(Ge(me,Do),Ge(ge,$o),Ge(ge,Mn)),je.svgFilters===!0&&(Ge(me,Po),Ge(ge,$o),Ge(ge,Mn)),je.mathMl===!0&&(Ge(me,Lo),Ge(ge,Fs),Ge(ge,Mn))),K.tagCheck=null,K.attributeCheck=null,wt(D,"ADD_TAGS")&&(typeof D.ADD_TAGS=="function"?K.tagCheck=D.ADD_TAGS:Or(D.ADD_TAGS)&&(me===Te&&(me=Ot(me)),Ge(me,D.ADD_TAGS,et))),wt(D,"ADD_ATTR")&&(typeof D.ADD_ATTR=="function"?K.attributeCheck=D.ADD_ATTR:Or(D.ADD_ATTR)&&(ge===Oe&&(ge=Ot(ge)),Ge(ge,D.ADD_ATTR,et))),wt(D,"ADD_FORBID_CONTENTS")&&Or(D.ADD_FORBID_CONTENTS)&&(_e===xe&&(_e=Ot(_e)),Ge(_e,D.ADD_FORBID_CONTENTS,et)),Ne&&(me["#text"]=!0),Me&&Ge(me,["html","head","body"]),me.table&&(Ge(me,["tbody"]),delete $e.tbody),D.TRUSTED_TYPES_POLICY){if(typeof D.TRUSTED_TYPES_POLICY.createHTML!="function")throw ur('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof D.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ur('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const Z=y;y=D.TRUSTED_TYPES_POLICY;try{E=U("")}catch(re){throw y=Z,re}}else D.TRUSTED_TYPES_POLICY===null?(y=void 0,E=""):(y===void 0&&(y=b()),y&&typeof E=="string"&&(E=U("")));ot&&ot(D),Xr=D},ad=Ge({},[...Do,...Po,...fu]),sd=Ge({},[...Lo,...gu]),qm=function(D,V,Z){return V.namespaceURI===Ve?D==="svg":V.namespaceURI===Je?D==="svg"&&(Z==="annotation-xml"||Ht[Z]):!!ad[D]},Zm=function(D,V,Z){return V.namespaceURI===Ve?D==="math":V.namespaceURI===Zt?D==="math"&&Sr[Z]:!!sd[D]},Qm=function(D,V,Z){return V.namespaceURI===Zt&&!Sr[Z]||V.namespaceURI===Je&&!Ht[Z]?!1:!sd[D]&&(Vm[D]||!ad[D])},Jm=function(D){let V=k(D);(!V||!V.tagName)&&(V={namespaceURI:bt,tagName:"template"});const Z=Rr(D.tagName),re=Rr(V.tagName);return Pt[D.namespaceURI]?D.namespaceURI===Zt?qm(Z,V,re):D.namespaceURI===Je?Zm(Z,V,re):D.namespaceURI===Ve?Qm(Z,V,re):!!(_n==="application/xhtml+xml"&&Pt[D.namespaceURI]):!1},cr=function(D){Jr(t.removed,{element:D});try{k(D).removeChild(D)}catch{if(p(D),!k(D))throw ur("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},ld=function(D,V,Z){try{D.removeAttributeNode(V)}catch{try{D.removeAttribute(Z)}catch{}}},mo=function(D){bo(D);const V=x(D);if(V){const re=[];dr(V,he=>{Jr(re,he)}),dr(re,he=>{try{p(he)}catch{}})}const Z=v(D);if(Z)for(let re=Z.length-1;re>=0;--re){const he=Z[re],Se=he&&he.name;typeof Se=="string"&&ld(D,he,Se)}},Er=function(D,V,Z){if(!Z)try{Z=V.getAttributeNode(D)}catch{Z=null}Jr(t.removed,{attribute:Z||null,from:V});try{Z?V.removeAttributeNode(Z):V.removeAttribute(D)}catch{try{V.removeAttribute(D)}catch{}}if(D==="is")if(de||ue)try{cr(V)}catch{}else try{V.setAttribute(D,"")}catch{}},Rm=function(D){const V=v(D);if(V)for(let Z=V.length-1;Z>=0;--Z){const re=V[Z],he=re&&re.name;typeof he!="string"||ge[et(he)]||ld(D,re,he)}},bo=function(D){const V=[D];for(;V.length>0;){const Z=V.pop();N(Z)===Mt.element&&Rm(Z);const he=x(Z);if(he)for(let Se=he.length-1;Se>=0;--Se)V.push(he[Se])}},id=function(D,V){return Be?D==="patchsrc"?!0:D==="for"&&V!=="label"&&V!=="output":!1},eb=function(D){if(!Be)return;const V=[D];for(;V.length>0;){const Z=V.pop(),re=N(Z);if(re===Mt.processingInstruction||re===Mt.comment&>(Hs,Z.data)){try{p(Z)}catch{}continue}if(re===Mt.element){const Se=Z,Ze=et(w(Z));try{Se.hasAttribute&&Se.hasAttribute("patchsrc")&&Se.removeAttribute("patchsrc"),Se.hasAttribute&&Se.hasAttribute("for")&&id("for",Ze)&&Se.removeAttribute("for")}catch{}}const he=x(Z);if(he)for(let Se=he.length-1;Se>=0;--Se)V.push(he[Se])}},cd=function(D){let V=null,Z=null;if(le)D=""+D;else{const Se=Os(D,/^[\r\n\t ]+/);Z=Se&&Se[0]}_n==="application/xhtml+xml"&&bt===Ve&&(D=''+D+"");const re=y?U(D):D;if(bt===Ve)try{V=new c().parseFromString(re,_n)}catch{}if(!V||!V.documentElement){V=F.createDocument(bt,"template",null);try{V.documentElement.innerHTML=St?E:re}catch{}}const he=V.body||V.documentElement;return D&&Z&&he.insertBefore(r.createTextNode(Z),he.childNodes[0]||null),bt===Ve?B.call(V,Me?"html":"body")[0]:Me?V.documentElement:he},dd=function(D){const V=S?S(D):D.ownerDocument;return G.call(V||D,D,f.SHOW_ELEMENT|f.SHOW_COMMENT|f.SHOW_TEXT|f.SHOW_PROCESSING_INSTRUCTION|f.SHOW_CDATA_SECTION,null)},yo=function(D){return D=en(D,W," "),D=en(D,Q," "),D=en(D,be," "),D},ls=function(D){var V;D.normalize();const Z=S?S(D):D.ownerDocument,re=G.call(Z||D,D,f.SHOW_TEXT|f.SHOW_COMMENT|f.SHOW_CDATA_SECTION|f.SHOW_PROCESSING_INSTRUCTION,null);let he=re.nextNode();for(;he;)he.data=yo(he.data),he=re.nextNode();const Se=(V=D.querySelectorAll)===null||V===void 0?void 0:V.call(D,"template");Se&&dr(Se,Ze=>{qr(Ze.content)&&ls(Ze.content)})},vo=function(D){const V=I?I(D):null;return typeof V!="string"||et(V)!=="form"?!1:typeof D.nodeName!="string"||typeof D.textContent!="string"||typeof D.removeChild!="function"||D.attributes!==v(D)||typeof D.removeAttribute!="function"||typeof D.setAttribute!="function"||typeof D.namespaceURI!="string"||typeof D.insertBefore!="function"||typeof D.hasChildNodes!="function"||D.nodeType!==T(D)||D.childNodes!==x(D)},qr=function(D){if(!T||typeof D!="object"||D===null)return!1;try{return T(D)===Mt.documentFragment}catch{return!1}},Sn=function(D){if(!T||typeof D!="object"||D===null)return!1;try{return typeof T(D)=="number"}catch{return!1}};function Rt(J,D,V){J.length!==0&&dr(J,Z=>{Z.call(t,D,V,Xr)})}const tb=function(D,V){return!!(Be&&D.hasChildNodes()&&!Sn(D.firstElementChild)&>(zs,D.textContent)&>(zs,D.innerHTML)||Be&&D.namespaceURI===Ve&&Su[V]&&(Sn(D.firstElementChild)||typeof D.textContent=="string"&>(Eu[V],D.textContent))||D.nodeType===Mt.processingInstruction||Be&&D.nodeType===Mt.comment&>(Hs,D.data))},wo=function(D,V){if(D instanceof RegExp)return gt(D,V);if(D instanceof Function){for(var Z=arguments.length,re=new Array(Z>2?Z-2:0),he=2;he=0;--Ze){const Re=D===Z?g(he[Ze],!0):he[Ze];re.insertBefore(Re,m(D))}}}return cr(D),!0},ud=function(D,V,Z,re){return D.length===0?V:V===Z||V===re?Ot(V):V},fd=function(D,V){return D===V||k(D)!==null?!1:(He&&bo(D),!0)},gd=function(D,V){if(Rt(H.beforeSanitizeElements,D,null),fd(D,V))return!0;if(vo(D))return cr(D),!0;const Z=et(w(D));if(me=ud(H.uponSanitizeElement,me,Te,Pe),Rt(H.uponSanitizeElement,D,{tagName:Z,allowedTags:me}),fd(D,V))return!0;if(tb(D,Z))return cr(D),!0;if($e[Z]||!(K.tagCheck instanceof Function&&K.tagCheck(Z))&&!me[Z]){const he=rb(D,Z,V);return he===!1&&Rt(H.afterSanitizeElements,D,null),he}if(N(D)===Mt.element&&!Jm(D)||(Z==="noscript"||Z==="noembed"||Z==="noframes")&>(Cu,D.innerHTML))return cr(D),!0;if(Ee&&D.nodeType===Mt.text){const he=yo(D.textContent);D.textContent!==he&&(Jr(t.removed,{element:D.cloneNode()}),D.textContent=he)}return Rt(H.afterSanitizeElements,D,null),!1},hd=function(D,V,Z){if(ze[V]||id(V,D)||Fe&&(V==="id"||V==="name")&&(Z in r||Z in Xm))return!1;const re=ge[V]||K.attributeCheck instanceof Function&&K.attributeCheck(V,D);return ae&>(se,V)||oe&>(pe,V)?!0:re?rt[V]||gt(We,en(Z,Ae,""))||(V==="src"||V==="xlink:href"||V==="href")&&D!=="script"&&Ms(Z,"data:")===0&&De[D]||ce&&!gt(ne,en(Z,Ae,""))?!0:!Z:pd(D)&&wo(we.tagNameCheck,D)&&wo(we.attributeNameCheck,V,D)||V==="is"&&we.allowCustomizedBuiltInElements&&wo(we.tagNameCheck,Z)},nb=Ge({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),pd=function(D){return!nb[Rr(D)]&>(ve,D)},ob=function(D,V,Z,re){if(y&&typeof i=="object"&&typeof i.getAttributeType=="function"&&!Z)switch(i.getAttributeType(D,V)){case"TrustedHTML":return U(re);case"TrustedScriptURL":return _(re)}return re},ab=function(D,V,Z,re){try{Z?D.setAttributeNS(Z,V,re):D.setAttribute(V,re),vo(D)?cr(D):Ns(t.removed)}catch{Er(V,D)}},md=function(D){Rt(H.beforeSanitizeAttributes,D,null);const V=D.attributes;if(!V||vo(D))return;ge=ud(H.uponSanitizeAttribute,ge,Oe,q);const Z={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ge,forceKeepAttr:void 0};let re=V.length;const he=et(D.nodeName);for(;re--;){const Se=V[re],Ze=Se.name,Re=Se.namespaceURI,Et=Se.value,Tt=et(Ze),cs=Et;let yt=Ze==="value"?cs:au(cs);if(Z.attrName=Tt,Z.attrValue=yt,Z.keepAttr=!0,Z.forceKeepAttr=void 0,Rt(H.uponSanitizeAttribute,D,Z),yt=Z.attrValue,Ce&&(Tt==="id"||Tt==="name")&&Ms(yt,Ie)!==0&&(Er(Ze,D,Se),yt=Ie+yt),Be&>(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,yt)){Er(Ze,D,Se);continue}if(Tt==="attributename"&&Os(yt,"href")){Er(Ze,D,Se);continue}if(!Z.forceKeepAttr){if(!Z.keepAttr){Er(Ze,D,Se);continue}if(!ke&>(_u,yt)){Er(Ze,D,Se);continue}if(Ee&&(yt=yo(yt)),!hd(he,Tt,yt)){Er(Ze,D,Se);continue}yt=ob(he,Tt,Re,yt),yt!==cs&&ab(D,Ze,Re,yt)}}Rt(H.afterSanitizeAttributes,D,null)},xo=function(D){let V=null;const Z=dd(D);for(Rt(H.beforeSanitizeShadowDOM,D,null);V=Z.nextNode();)if(Rt(H.uponSanitizeShadowNode,V,null),gd(V,D),md(V),qr(V.content)&&xo(V.content),N(V)===Mt.element){const re=M(V);qr(re)&&(is(re),xo(re))}Rt(H.afterSanitizeShadowDOM,D,null)},is=function(D){const V=[{node:D,shadow:null}];for(;V.length>0;){const Z=V.pop();if(Z.shadow){xo(Z.shadow);continue}const re=Z.node,Se=N(re)===Mt.element,Ze=x(re);if(Ze)for(let Re=Ze.length-1;Re>=0;--Re)V.push({node:Ze[Re],shadow:null});if(Se){const Re=I?I(re):null;if(typeof Re=="string"&&et(Re)==="template"){const Et=re.content;qr(Et)&&V.push({node:Et,shadow:null})}}if(Se){const Re=M(re);qr(Re)&&V.push({node:null,shadow:Re},{node:Re,shadow:null})}}};return t.sanitize=function(J){let D=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},V=null,Z=null,re=null,he=null;if(St=!J,St&&(J=""),typeof J!="string"&&!Sn(J)&&(J=du(J),typeof J!="string"))throw ur("dirty is not a string, aborting");if(!t.isSupported)return J;Ke?(me=Pe,ge=q):ss(D),(H.uponSanitizeElement.length>0||H.uponSanitizeAttribute.length>0)&&(me=Ot(me)),H.uponSanitizeAttribute.length>0&&(ge=Ot(ge)),t.removed=[];const Se=He&&typeof J!="string"&&Sn(J);if(Se){eb(J);const Et=w(J);if(typeof Et=="string"){const Tt=et(Et);if(!me[Tt]||$e[Tt])throw mo(J),ur("root node is forbidden and cannot be sanitized in-place")}if(vo(J))throw mo(J),ur("root node is clobbered and cannot be sanitized in-place");try{is(J)}catch(Tt){throw mo(J),Tt}}else if(Sn(J))V=cd(""),Z=V.ownerDocument.importNode(J,!0),Z.nodeType===Mt.element&&Z.nodeName==="BODY"||Z.nodeName==="HTML"?V=Z:V.appendChild(Z),is(Z);else{if(!de&&!Ee&&!Me&&J.indexOf("<")===-1)return y&&ie?U(J):J;if(V=cd(J),!V)return de?null:ie?E:""}V&&le&&cr(V.firstChild);const Ze=Se?J:V;try{const Et=dd(Ze);for(;re=Et.nextNode();)gd(re,Ze),md(re),qr(re.content)&&xo(re.content)}catch(Et){throw Se&&(mo(J),dr(t.removed,Tt=>{Tt.element&&bo(Tt.element)})),Et}if(Se)return dr(t.removed,Et=>{Et.element&&bo(Et.element)}),Ee&&ls(J),J;if(de){if(Ee&&ls(V),ue)for(he=X.call(V.ownerDocument);V.firstChild;)he.appendChild(V.firstChild);else he=V;return(ge.shadowroot||ge.shadowrootmode)&&(he=Y.call(n,he,!0)),he}let Re=Me?V.outerHTML:V.innerHTML;return Me&&me["!doctype"]&&V.ownerDocument&&V.ownerDocument.doctype&&V.ownerDocument.doctype.name&>(xu,V.ownerDocument.doctype.name)&&(Re=" -`+Re),Ee&&(Re=yo(Re)),y&&ie?U(Re):Re},t.setConfig=function(){let J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ss(J),Ke=!0,Pe=me,q=ge},t.clearConfig=function(){Xr=null,Ke=!1,Pe=null,q=null,y=O,E=""},t.isValidAttribute=function(J,D,V){Xr||ss({});const Z=et(J),re=et(D);return hd(Z,re,V)},t.addHook=function(J,D){typeof D=="function"&&wt(H,J)&&Jr(H[J],D)},t.removeHook=function(J,D){if(wt(H,J)){if(D!==void 0){const V=nu(H[J],D);return V===-1?void 0:ou(H[J],V,1)[0]}return Ns(H[J])}},t.removeHooks=function(J){wt(H,J)&&(H[J]=[])},t.removeAllHooks=function(){H=js()},t}var Uo=Bs();const Nu=()=>{const e=()=>{const n=window.G7Core?.state?.get?.();return n&&(n.preferredCurrency||n.defaultCurrency)||""},[t,r]=C.useState(e);return C.useEffect(()=>{const n=window.G7Core?.state?.subscribe;if(r(e()),typeof n!="function")return;const o=n(a=>{r(a&&(a.preferredCurrency||a.defaultCurrency)||"")});return typeof o=="function"?o:void 0},[]),t},Ou=(e,t=!1)=>{window.G7Core?.dispatch?.({handler:"navigate",params:t?{path:e,mergeQuery:!0,query:{}}:{path:e}})},Mu=e=>{const t=Math.round(e*2)/2;return[1,2,3,4,5].map(r=>t>=r?"full":t>=r-.5?"half":"empty")},Ws=({product:e,onClick:t,shopBase:r="/shop",preserveListQuery:n=!1,className:o="",id:a,editorAttrs:s})=>{const l=Nu(),f=v=>{const T=`multi_currency_${v}`,I=e[T];if(I&&I[l])return I[l].formatted;const S=`${v}_formatted`;return e[S]},h=e.name_localized??(typeof e.name=="string"?e.name:"")??"",c=f("selling_price"),i=f("list_price"),u=e.discount_rate&&e.discount_rate>0,g=e.sales_status&&e.sales_status!=="on_sale",p=e.labels??[],m=v=>Uo.sanitize(v,{ALLOWED_TAGS:["mark"],ALLOWED_ATTR:[]}),x=e.name_highlighted,k=e.description_highlighted??e.short_description,M=()=>{if(t)t(e.id);else{const v=r==="/"?"":r,T=e.product_code??e.id;Ou(`${v}/products/${T}`,n)}};return d.jsxs(R,{onClick:M,className:`block w-full text-left group bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden hover:shadow-lg transition-shadow cursor-pointer ${o}`,id:a,...s,children:[d.jsxs(j,{className:"relative aspect-square overflow-hidden bg-gray-100 dark:bg-gray-700",children:[d.jsx(jt,{src:e.thumbnail_url,alt:h,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-200",loading:"lazy"}),g&&d.jsx(j,{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:d.jsx(te,{className:`text-lg font-bold ${e.sales_status==="sold_out"?"text-red-300":e.sales_status==="suspended"?"text-amber-300":"text-blue-300"}`,style:{textShadow:"0 1px 4px rgba(0,0,0,0.6)"},children:e.sales_status_label??e.sales_status})}),u&&e.sales_status!=="sold_out"&&e.sales_status!=="suspended"&&d.jsxs(te,{className:"absolute top-2 left-2 px-2 py-1 bg-red-500 text-white text-xs font-bold rounded",children:[e.discount_rate,"%"]}),p.length>0&&d.jsx(j,{className:"absolute bottom-2 right-2 flex gap-1 flex-wrap justify-end",children:p.map((v,T)=>d.jsx(te,{className:"text-xs text-white font-medium px-1.5 py-0.5 rounded",style:{backgroundColor:v.color||"#6b7280"},children:v.name},T))})]}),d.jsxs(j,{className:"p-4",children:[d.jsxs(j,{className:"flex items-center gap-1.5 flex-wrap",children:[e.primary_category&&d.jsx(te,{className:"inline-block text-xs font-medium text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30 px-2 py-0.5 rounded",children:e.primary_category}),e.brand_name&&d.jsx(te,{className:"text-xs text-gray-500 dark:text-gray-400",children:e.brand_name})]}),x?d.jsx(j,{className:"mt-1 font-medium text-gray-900 dark:text-white line-clamp-1 [&_mark]:bg-yellow-200 [&_mark]:dark:bg-yellow-500/40 [&_mark]:px-0.5 [&_mark]:rounded",dangerouslySetInnerHTML:{__html:m(x)}}):d.jsx(Tn,{className:"mt-1 font-medium text-gray-900 dark:text-white line-clamp-1",children:h}),k&&d.jsx(j,{className:"mt-1 text-sm text-gray-600 dark:text-gray-400 line-clamp-2 [&_mark]:bg-yellow-200 [&_mark]:dark:bg-yellow-500/40 [&_mark]:px-0.5 [&_mark]:rounded",dangerouslySetInnerHTML:{__html:m(k)}}),d.jsxs(j,{className:"mt-1.5 flex items-center gap-1",children:[Mu(e.rating_avg??0).map((v,T)=>d.jsxs(te,{className:`text-xs ${v==="empty"?"text-gray-300 dark:text-gray-600":"text-yellow-400"}`,children:[v==="full"&&d.jsx("i",{className:"fa-solid fa-star"}),v==="half"&&d.jsx("i",{className:"fa-solid fa-star-half-stroke"}),v==="empty"&&d.jsx("i",{className:"fa-regular fa-star"})]},T)),d.jsx(te,{className:"text-xs text-gray-600 dark:text-gray-400 ml-0.5",children:(e.rating_avg??0).toFixed(1)}),d.jsxs(te,{className:"text-xs text-gray-400 dark:text-gray-500",children:["(",e.review_count??0,")"]})]}),d.jsxs(j,{className:"mt-2 flex items-baseline gap-2",children:[d.jsx(te,{className:"font-bold text-gray-900 dark:text-white",children:c}),i&&u&&d.jsx(te,{className:"text-sm text-gray-500 dark:text-gray-400 line-through",children:i})]})]})]})},Iu=Object.freeze(Object.defineProperty({__proto__:null,default:Ws},Symbol.toStringTag,{value:"Module"})),Du={ALLOWED_TAGS:["svg","g","defs","title","desc","rect","circle","ellipse","line","polyline","polygon","path","text","tspan","linearGradient","radialGradient","stop","clipPath"],ALLOWED_ATTR:["xmlns","width","height","viewBox","role","aria-label","aria-hidden","fill","fill-opacity","fill-rule","stroke","stroke-width","stroke-linecap","stroke-linejoin","opacity","transform","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","d","points","width","height","text-anchor","dominant-baseline","font-family","font-size","font-weight","offset","stop-color","stop-opacity","gradientUnits","id","clip-path"],FORBID_TAGS:["script","foreignObject","image","use","a","style"],FORBID_ATTR:["onload","onerror","onclick","onmouseover","onfocus","onblur","href","xlink:href"]},zo=({brandMark:e,size:t=32,className:r="",id:n,editorAttrs:o})=>{const a=e?.svg,s=e?.text,l=C.useMemo(()=>!a||a.trim()===""?"":Uo.sanitize(a,Du),[a]),f={width:`${t}px`,height:`${t}px`,flex:`0 0 ${t}px`};if(l)return d.jsx(j,{id:n,"aria-hidden":"true",className:`inline-flex items-center justify-center ${r}`.trim(),style:f,dangerouslySetInnerHTML:{__html:l},...o});if(s&&s.trim()!==""){const h=e?.class??"bg-gray-500 text-white";return d.jsx(te,{id:n,"aria-hidden":"true",className:`inline-flex items-center justify-center rounded-lg text-xs font-bold ${h} ${r}`.trim(),style:f,...o,children:s})}return null},Pu=Object.freeze(Object.defineProperty({__proto__:null,BrandMark:zo,default:zo},Symbol.toStringTag,{value:"Module"})),Vs="carousel",rn="controller",Lu="navigation",$u="no-scroll",Ho="portal",Fu="root",Ks="toolbar",Uu="counter",nn="fullscreen",Ys="slideshow",on="thumbnails",Xs="zoom",Mr="loading",Go="playing",an="error",sn="complete",zu="placeholder",ln=e=>`active-slide-${e}`,Hu=ln(Mr),Gu=ln(Go),ju=ln(an),Bu=ln(sn),qs="fullsize",Ir="flex_center",Wu="no_scroll",Zs="no_scroll_padding",jo="slide",Qs="slide_wrapper",Vu="slide_wrapper_interactive",nr="prev",or="next",Bo="swipe",Dr="close",Js="onPointerDown",Rs="onPointerMove",el="onPointerUp",tl="onPointerLeave",rl="onPointerCancel",Wo="onKeyDown",Ku="onKeyUp",Vo="onWheel",Yu="Escape",Xu="ArrowLeft",qu="ArrowRight",Zu="button",In="icon",nl="contain",ol="cover",al="Unknown action type",sl="yarl__";function ht(...e){return[...e].filter(Boolean).join(" ")}function ye(e){return`${sl}${e}`}function Xe(e){return`--${sl}${e}`}function fr(e,t){return`${e}${t?`_${t}`:""}`}function gr(e){return t=>fr(e,t)}function hr(e,t){var r;return(r=e?.[t])!==null&&r!==void 0?r:t}function ll(e,t,r){return hr(e,"{index} of {total}").replace(/\{index}/g,`${qo(r,t.length)+1}`).replace(/\{total}/g,`${t.length}`)}function Pr(...e){return()=>{e.forEach(t=>{t()})}}function $t(e,t,r){return()=>{const n=A.useContext(r);if(!n)throw new Error(`${e} must be used within a ${t}.Provider`);return n}}function Ko(){return typeof window<"u"}function Yo(e,t=0){const r=10**t;return Math.round((e+Number.EPSILON)*r)/r}function pr(e){return e.type===void 0||e.type==="image"}function Xo(e,t){return e.imageFit===ol||e.imageFit!==nl&&t===ol}function Dn(e){return typeof e=="string"?Number.parseInt(e,10):e}function Pn(e){if(typeof e=="number")return{pixel:e};if(typeof e=="string"){const t=Dn(e);return e.endsWith("%")?{percent:t}:{pixel:t}}return{pixel:0}}function Qu(e,t){const r=Pn(t),n=r.percent!==void 0?e.width/100*r.percent:r.pixel;return{width:Math.max(e.width-2*n,0),height:Math.max(e.height-2*n,0)}}function Ju(){return(Ko()?window?.devicePixelRatio:void 0)||1}function qo(e,t){return t>0?(e%t+t)%t:0}function Zo(e){return e.length>0}function Qo(e,t){return e[qo(t,e.length)]}function Jo(e,t){return Zo(e)?Qo(e,t):void 0}function il(e){return pr(e)?e.src:void 0}function Ln(e,t,r){if(!r)return e;const{buttons:n,...o}=e,a=n.findIndex(l=>l===t),s=A.isValidElement(r)?A.cloneElement(r,{key:t},null):r;if(a>=0){const l=[...n];return l.splice(a,1,s),{buttons:l,...o}}return{buttons:[s,...n],...o}}function cl(e,t,r=0){return Math.min(e.preload,Math.max(e.finite?t.length-1:Math.floor(t.length/2),r))}const Ru=Number(A.version.split(".")[0])>=19;function ef(e){return{inert:Ru?e:e?"":void 0}}function tf(e){e.scrollTop}const Ro={open:!1,close:()=>{},index:0,slides:[],render:{},plugins:[],toolbar:{buttons:[Dr]},labels:{},animation:{fade:250,swipe:500,easing:{fade:"ease",swipe:"ease-out",navigation:"ease-in-out"}},carousel:{finite:!1,preload:2,padding:"16px",spacing:"30%",imageFit:nl,imageProps:{}},controller:{ref:null,focus:!0,aria:!1,touchAction:"none",closeOnPullUp:!1,closeOnPullDown:!1,closeOnBackdropClick:!1,preventDefaultWheelX:!0,preventDefaultWheelY:!1,disableSwipeNavigation:!1},portal:{},noScroll:{disabled:!1},on:{},styles:{},className:""};function Ft(e,t){return{name:e,component:t}}function it(e,t){return{module:e,children:t}}function dl(e,t,r){return e.module.name===t?r(e):e.children?[it(e.module,e.children.flatMap(n=>{var o;return(o=dl(n,t,r))!==null&&o!==void 0?o:[]}))]:[e]}function Lr(e,t,r){return e.flatMap(n=>{var o;return(o=dl(n,t,r))!==null&&o!==void 0?o:[]})}function rf(e,t=[],r=[]){let n=e;const o=g=>{const p=[...n];for(;p.length>0;){const m=p.pop();if(m?.module.name===g)return!0;m?.children&&p.push(...m.children)}return!1},a=(g,p)=>{if(g===""){n=[it(p,n)];return}n=Lr(n,g,m=>[it(p,[m])])},s=(g,p)=>{n=Lr(n,g,m=>[it(m.module,[it(p,m.children)])])},l=(g,p,m)=>{n=Lr(n,g,x=>{var k;return[it(x.module,[...m?[it(p)]:[],...(k=x.children)!==null&&k!==void 0?k:[],...m?[]:[it(p)]])]})},f=(g,p,m)=>{n=Lr(n,g,x=>[...m?[it(p)]:[],x,...m?[]:[it(p)]])},h=g=>{s(rn,g)},c=(g,p)=>{n=Lr(n,g,m=>[it(p,m.children)])},i=g=>{n=Lr(n,g,p=>p.children)},u=g=>{r.push(g)};return t.forEach(g=>{g({contains:o,addParent:a,append:s,addChild:l,addSibling:f,addModule:h,replace:c,remove:i,augment:u})}),{config:n,augmentation:g=>r.reduce((p,m)=>m(p),g)}}const ul=A.createContext(null),ea=$t("useA11yContext","A11yContext",ul);function nf({children:e}){const[t,r]=A.useState(!1),[n,o]=A.useState(!1),a=A.useMemo(()=>({focusWithin:t,trackFocusWithin:(l,f)=>{const h=c=>i=>{var u;i.currentTarget.contains(i.relatedTarget)||r(c),(u=c?l:f)===null||u===void 0||u(i)};return{onFocus:h(!0),onBlur:h(!1)}},autoPlaying:n,setAutoPlaying:o}),[t,n]);return A.createElement(ul.Provider,{value:a},e)}const fl=A.createContext(null),$r=$t("useDocument","DocumentContext",fl);function of({nodeRef:e,children:t}){const r=A.useMemo(()=>{const n=a=>{var s;return((s=a||e.current)===null||s===void 0?void 0:s.ownerDocument)||document};return{getOwnerDocument:n,getOwnerWindow:a=>{var s;return((s=n(a))===null||s===void 0?void 0:s.defaultView)||window}}},[e]);return A.createElement(fl.Provider,{value:r},t)}const gl=A.createContext(null),Fr=$t("useEvents","EventsContext",gl);function af({children:e}){const[t]=A.useState({});A.useEffect(()=>()=>{Object.keys(t).forEach(n=>delete t[n])},[t]);const r=A.useMemo(()=>{const n=(s,l)=>{var f;(f=t[s])===null||f===void 0||f.splice(0,t[s].length,...t[s].filter(h=>h!==l))};return{publish:(...[s,l])=>{var f;(f=t[s])===null||f===void 0||f.forEach(h=>h(l))},subscribe:(s,l)=>(t[s]||(t[s]=[]),t[s].push(l),()=>n(s,l)),unsubscribe:n}},[t]);return A.createElement(gl.Provider,{value:r},e)}const hl=A.createContext(null),ct=$t("useLightboxProps","LightboxPropsContext",hl);function pl({children:e,...t}){return A.createElement(hl.Provider,{value:t},e)}const ml=A.createContext(null),Ut=$t("useLightboxState","LightboxStateContext",ml),bl=A.createContext(null),sf=$t("useLightboxDispatch","LightboxDispatchContext",bl);function lf(e,t){switch(t.type){case"swipe":{const{slides:r}=e,n=t?.increment||0,o=e.globalIndex+n,a=qo(o,r.length),s=Jo(r,a),l=n||t.duration!==void 0?{increment:n,duration:t.duration,easing:t.easing}:void 0;return{slides:r,currentIndex:a,globalIndex:o,currentSlide:s,animation:l}}case"update":return t.slides!==e.slides||t.index!==e.currentIndex?{slides:t.slides,currentIndex:t.index,globalIndex:t.index,currentSlide:Jo(t.slides,t.index)}:e;default:throw new Error(al)}}function cf({slides:e,index:t,children:r}){const[n,o]=A.useReducer(lf,{slides:e,currentIndex:t,globalIndex:t,currentSlide:Jo(e,t)});A.useEffect(()=>{o({type:"update",slides:e,index:t})},[e,t]);const a=A.useMemo(()=>({...n,state:n,dispatch:o}),[n,o]);return A.createElement(bl.Provider,{value:o},A.createElement(ml.Provider,{value:a},r))}const yl=A.createContext(null),cn=$t("useTimeouts","TimeoutsContext",yl);function df({children:e}){const[t]=A.useState([]);A.useEffect(()=>()=>{t.forEach(n=>window.clearTimeout(n)),t.splice(0,t.length)},[t]);const r=A.useMemo(()=>{const n=s=>{t.splice(0,t.length,...t.filter(l=>l!==s))};return{setTimeout:(s,l)=>{const f=window.setTimeout(()=>{n(f),s()},l);return t.push(f),f},clearTimeout:s=>{s!==void 0&&(n(s),window.clearTimeout(s))}}},[t]);return A.createElement(yl.Provider,{value:r},e)}const Ur=A.forwardRef(function({label:t,className:r,icon:n,renderIcon:o,onClick:a,style:s,...l},f){const{styles:h,labels:c}=ct(),i=hr(c,t);return A.createElement("button",{ref:f,type:"button",title:i,"aria-label":i,className:ht(ye(Zu),r),onClick:a,style:{...s,...h.button},...l},o?o():A.createElement(n,{className:ye(In),style:h.icon}))});function vl(e,t){const r=n=>A.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":"true",focusable:"false",...n},t);return r.displayName=e,r}function xt(e,t){return vl(e,A.createElement("g",{fill:"currentColor"},A.createElement("path",{d:"M0 0h24v24H0z",fill:"none"}),t))}function uf(e,t){return vl(e,A.createElement(A.Fragment,null,A.createElement("defs",null,A.createElement("mask",{id:"strike"},A.createElement("path",{d:"M0 0h24v24H0z",fill:"white"}),A.createElement("path",{d:"M0 0L24 24",stroke:"black",strokeWidth:4}))),A.createElement("path",{d:"M0.70707 2.121320L21.878680 23.292883",stroke:"currentColor",strokeWidth:2}),A.createElement("g",{fill:"currentColor",mask:"url(#strike)"},A.createElement("path",{d:"M0 0h24v24H0z",fill:"none"}),t)))}const ff=xt("Close",A.createElement("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})),gf=xt("Previous",A.createElement("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})),hf=xt("Next",A.createElement("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})),pf=xt("Loading",A.createElement(A.Fragment,null,Array.from({length:8}).map((e,t,r)=>A.createElement("line",{key:t,x1:"12",y1:"6.5",x2:"12",y2:"1.8",strokeLinecap:"round",strokeWidth:"2.6",stroke:"currentColor",strokeOpacity:1/r.length*(t+1),transform:`rotate(${360/r.length*t}, 12, 12)`})))),mf=xt("Error",A.createElement("path",{d:"M21.9,21.9l-8.49-8.49l0,0L3.59,3.59l0,0L2.1,2.1L0.69,3.51L3,5.83V19c0,1.1,0.9,2,2,2h13.17l2.31,2.31L21.9,21.9z M5,18 l3.5-4.5l2.5,3.01L12.17,15l3,3H5z M21,18.17L5.83,3H19c1.1,0,2,0.9,2,2V18.17z"})),Vt=Ko()?A.useLayoutEffect:A.useEffect;function ta(){const[e,t]=A.useState(!1);return A.useEffect(()=>{var r,n;const o=(r=window.matchMedia)===null||r===void 0?void 0:r.call(window,"(prefers-reduced-motion: reduce)");t(o?.matches);const a=s=>t(s.matches);return(n=o?.addEventListener)===null||n===void 0||n.call(o,"change",a),()=>{var s;return(s=o?.removeEventListener)===null||s===void 0?void 0:s.call(o,"change",a)}},[]),e}function bf(e){let t=0,r=0,n=0;const a=window.getComputedStyle(e).transform.match(/matrix.*\((.+)\)/);if(a){const s=a[1].split(",").map(Dn);s.length===6?(t=s[4],r=s[5]):s.length===16&&(t=s[12],r=s[13],n=s[14])}return{x:t,y:r,z:n}}function ra(e,t){const r=A.useRef(void 0),n=A.useRef(void 0),o=ta();return Vt(()=>{var a,s,l;if(e.current&&r.current!==void 0&&!o){const{keyframes:f,duration:h,easing:c,onfinish:i}=t(r.current,e.current.getBoundingClientRect(),bf(e.current))||{};if(f&&h){(a=n.current)===null||a===void 0||a.cancel(),n.current=void 0;try{n.current=(l=(s=e.current).animate)===null||l===void 0?void 0:l.call(s,f,{duration:h,easing:c})}catch(u){console.error(u)}n.current&&(n.current.onfinish=()=>{n.current=void 0,i?.()})}}r.current=void 0}),{prepareAnimation:a=>{r.current=a},isAnimationPlaying:()=>{var a;return((a=n.current)===null||a===void 0?void 0:a.playState)==="running"}}}function wl(){const e=A.useRef(null),t=A.useRef(void 0),[r,n]=A.useState();return{setContainerRef:A.useCallback(a=>{e.current=a,t.current&&(t.current.disconnect(),t.current=void 0);const s=()=>{if(a){const l=window.getComputedStyle(a),f=h=>parseFloat(h)||0;n({width:Math.round(a.clientWidth-f(l.paddingLeft)-f(l.paddingRight)),height:Math.round(a.clientHeight-f(l.paddingTop)-f(l.paddingBottom))})}else n(void 0)};s(),a&&typeof ResizeObserver<"u"&&(t.current=new ResizeObserver(s),t.current.observe(a))},[]),containerRef:e,containerRect:r}}function $n(){const e=A.useRef(void 0),{setTimeout:t,clearTimeout:r}=cn();return A.useCallback((n,o)=>{r(e.current),e.current=t(n,o>0?o:0)},[t,r])}function Le(e){const t=A.useRef(e);return Vt(()=>{t.current=e}),A.useCallback((...r)=>{var n;return(n=t.current)===null||n===void 0?void 0:n.call(t,...r)},[])}function xl(e,t){typeof e=="function"?e(t):e&&(e.current=t)}function na(e,t){return A.useMemo(()=>e==null&&t==null?null:r=>{xl(e,r),xl(t,r)},[e,t])}function kl(e,t=!1){const r=A.useRef(!1);Vt(()=>{t&&r.current&&(r.current=!1,e())},[t,e]);const n=A.useCallback(()=>{r.current=!0},[]),o=A.useCallback(()=>{r.current=!1},[]);return{onFocus:n,onBlur:o}}function Fn(){const[e,t]=A.useState(!1);return Vt(()=>{t(window.getComputedStyle(window.document.documentElement).direction==="rtl")},[]),e}function Cl(){const[e]=A.useState({}),t=A.useCallback((o,a)=>{var s;(s=e[o])===null||s===void 0||s.forEach(l=>{a.isPropagationStopped()||l(a)})},[e]),r=A.useMemo(()=>({onPointerDown:o=>t(Js,o),onPointerMove:o=>t(Rs,o),onPointerUp:o=>t(el,o),onPointerLeave:o=>t(tl,o),onPointerCancel:o=>t(rl,o),onKeyDown:o=>t(Wo,o),onKeyUp:o=>t(Ku,o),onWheel:o=>t(Vo,o)}),[t]),n=A.useCallback((o,a)=>(e[o]||(e[o]=[]),e[o].unshift(a),()=>{const s=e[o];s&&s.splice(0,s.length,...s.filter(l=>l!==a))}),[e]);return{registerSensors:r,subscribeSensors:n}}function _l(e,t){const r=A.useRef(0),n=$n(),o=Le((...a)=>{r.current=Date.now(),e(a)});return A.useCallback((...a)=>{n(()=>{o(a)},t-(Date.now()-r.current))},[t,o,n])}const oa=gr("slide"),aa=gr("slide_image");function mr({slide:e,offset:t,render:r,rect:n,imageFit:o,imageProps:a,onClick:s,onLoad:l,onError:f,style:h}){var c,i,u,g,p,m,x,k;const[M,v]=A.useState(Mr),{publish:T}=Fr(),{setTimeout:I}=cn(),S=A.useRef(null);A.useEffect(()=>{t===0&&T(ln(M))},[t,M,T]);const N=Le(B=>{("decode"in B?B.decode():Promise.resolve()).catch(()=>{}).then(()=>{B.parentNode&&(v(sn),I(()=>{l?.(B)},0))})}),w=A.useCallback(B=>{S.current=B,B?.complete&&N(B)},[N]),y=A.useCallback(B=>{N(B.currentTarget)},[N]),E=Le(()=>{v(an),f?.()}),O=Xo(e,o),$=(B,Y)=>Number.isFinite(B)?B:Y,P=$(Math.max(...((i=(c=e.srcSet)===null||c===void 0?void 0:c.map(B=>B.width))!==null&&i!==void 0?i:[]).concat(e.width?[e.width]:[]).filter(Boolean)),((u=S.current)===null||u===void 0?void 0:u.naturalWidth)||0),L=$(Math.max(...((p=(g=e.srcSet)===null||g===void 0?void 0:g.map(B=>B.height))!==null&&p!==void 0?p:[]).concat(e.height?[e.height]:[]).filter(Boolean)),((m=S.current)===null||m===void 0?void 0:m.naturalHeight)||0),U=P&&L?{maxWidth:`min(${P}px, 100%)`,maxHeight:`min(${L}px, 100%)`}:{maxWidth:"100%",maxHeight:"100%"},_=(x=e.srcSet)===null||x===void 0?void 0:x.sort((B,Y)=>B.width-Y.width).map(B=>`${B.src} ${B.width}w`).join(", "),b=()=>n&&!O&&e.width&&e.height?n.height/e.height*e.width:Number.MAX_VALUE,z=_&&n&&Ko()?`${Math.round(Math.min(b(),n.width))}px`:void 0,{style:F,className:G,...X}=a||{};return A.createElement(A.Fragment,null,A.createElement("img",{ref:w,onLoad:y,onError:E,onClick:s,draggable:!1,className:ht(ye(aa()),O&&ye(aa("cover")),M!==sn&&ye(aa("loading")),G),style:{...U,...h,...F},...X,alt:(k=e.alt)!==null&&k!==void 0?k:"",sizes:z,srcSet:_,src:e.src}),M!==sn&&A.createElement("div",{className:ye(oa(zu))},M===Mr&&(r?.iconLoading?r.iconLoading():A.createElement(pf,{className:ht(ye(In),ye(oa(Mr)))})),M===an&&(r?.iconError?r.iconError():A.createElement(mf,{className:ht(ye(In),ye(oa(an)))}))))}const yf=A.forwardRef(function({className:t,children:r,onFocus:n,onBlur:o,...a},s){const l=A.useRef(null),{trackFocusWithin:f}=ea();return A.createElement(of,{nodeRef:l},A.createElement("div",{ref:na(s,l),className:ht(ye("root"),t),...f(n,o),...a},r))});var pt;(function(e){e[e.NONE=0]="NONE",e[e.SWIPE=1]="SWIPE",e[e.PULL=2]="PULL",e[e.ANIMATION=3]="ANIMATION"})(pt||(pt={}));function Sl(e,t,r,n,o){A.useEffect(()=>o?()=>{}:Pr(e(Js,t),e(Rs,r),e(el,n),e(tl,n),e(rl,n)),[e,t,r,n,o])}var Kt;(function(e){e[e.NONE=0]="NONE",e[e.SWIPE=1]="SWIPE",e[e.PULL=2]="PULL"})(Kt||(Kt={}));const sa=30;function vf({disableSwipeNavigation:e,closeOnBackdropClick:t},r,n,o,a,s,l,f,h,c,i,u,g,p,m,x){const k=A.useRef(0),M=A.useRef([]),v=A.useRef(void 0),T=A.useRef(0),I=A.useRef(Kt.NONE),S=A.useCallback(P=>{v.current===P.pointerId&&(v.current=void 0,I.current=Kt.NONE);const L=M.current;L.splice(0,L.length,...L.filter(U=>U.pointerId!==P.pointerId))},[]),N=A.useCallback(P=>{S(P),P.persist(),M.current.push(P)},[S]),w=A.useCallback(P=>M.current.find(({pointerId:L})=>P.pointerId===L),[]),y=Le(P=>{N(P)}),E=(P,L)=>i&&P>L||c&&P<-L,O=Le(P=>{const L=w(P);if(L)if(v.current===P.pointerId){const U=Date.now()-T.current,_=k.current;I.current===Kt.SWIPE?Math.abs(_)>.3*o||Math.abs(_)>5&&U{const L=w(P);if(L){const U=v.current===P.pointerId;if(P.buttons===0){U&&k.current!==0?O(P):S(L);return}const _=P.clientX-L.clientX,b=P.clientY-L.clientY;if(v.current===void 0){const z=F=>{N(P),v.current=P.pointerId,T.current=Date.now(),I.current=F};Math.abs(_)>Math.abs(b)&&Math.abs(_)>sa&&n(_)?e||(z(Kt.SWIPE),s()):Math.abs(b)>Math.abs(_)&&E(b,sa)&&(z(Kt.PULL),u())}else U&&(I.current===Kt.SWIPE?(k.current=_,l(_)):I.current===Kt.PULL&&(k.current=b,g(b)))}});Sl(r,y,$,O)}function wf({preventDefaultWheelX:e,preventDefaultWheelY:t}){const r=A.useRef(null),n=Le(o=>{const a=Math.abs(o.deltaX)>Math.abs(o.deltaY);(a&&e||!a&&t||o.ctrlKey)&&o.preventDefault()});return A.useCallback(o=>{var a;o?o.addEventListener("wheel",n,{passive:!1}):(a=r.current)===null||a===void 0||a.removeEventListener("wheel",n),r.current=o},[n])}function xf(e,t,r,n,o,a,s,l,f){const h=A.useRef(0),c=A.useRef(0),i=A.useRef(void 0),u=A.useRef(void 0),g=A.useRef(0),p=A.useRef(void 0),m=A.useRef(0),{setTimeout:x,clearTimeout:k}=cn(),M=A.useCallback(()=>{i.current&&(k(i.current),i.current=void 0)},[k]),v=A.useCallback(()=>{u.current&&(k(u.current),u.current=void 0)},[k]),T=Le(()=>{e!==pt.SWIPE&&(h.current=0,m.current=0,M(),v())});A.useEffect(T,[e,T]);const I=Le(N=>{u.current=void 0,h.current===N&&f(h.current)}),S=Le(N=>{if(N.ctrlKey||Math.abs(N.deltaY)>Math.abs(N.deltaX))return;const w=y=>{g.current=y,k(p.current),p.current=y>0?x(()=>{g.current=0,p.current=void 0},300):void 0};if(e===pt.NONE){if(Math.abs(N.deltaX)<=1.2*Math.abs(g.current)){w(N.deltaX);return}if(!r(-N.deltaX))return;if(c.current+=N.deltaX,M(),Math.abs(c.current)>30)c.current=0,w(0),m.current=Date.now(),a();else{const y=c.current;i.current=x(()=>{i.current=void 0,y===c.current&&(c.current=0)},o)}}else if(e===pt.SWIPE){let y=h.current-N.deltaX;if(y=Math.min(Math.abs(y),n)*Math.sign(y),h.current=y,s(y),v(),Math.abs(y)>.2*n){w(N.deltaX),l(y,Date.now()-m.current);return}u.current=x(()=>I(y),2*o)}else w(N.deltaX)});A.useEffect(()=>t(Vo,S),[t,S])}const El=gr("container"),Tl=A.createContext(null),Yt=$t("useController","ControllerContext",Tl);function kf({children:e,...t}){var r;const{carousel:n,animation:o,controller:a,on:s,styles:l,render:f}=t,{closeOnPullUp:h,closeOnPullDown:c,preventDefaultWheelX:i,preventDefaultWheelY:u}=a,[g,p]=A.useState(),m=Ut(),x=sf(),[k,M]=A.useState(pt.NONE),v=A.useRef(0),T=A.useRef(0),I=A.useRef(1),{registerSensors:S,subscribeSensors:N}=Cl(),{subscribe:w,publish:y}=Fr(),E=$n(),O=$n(),$=$n(),{containerRef:P,setContainerRef:L,containerRect:U}=wl(),_=na(wf({preventDefaultWheelX:i,preventDefaultWheelY:u}),L),b=A.useRef(null),z=na(b,void 0),{getOwnerDocument:F}=$r(),G=Fn(),X=K=>(G?-1:1)*(typeof K=="number"?K:1),B=Le(()=>{var K;return(K=P.current)===null||K===void 0?void 0:K.focus()}),Y=Le(()=>t),H=Le(()=>m),W=A.useCallback(K=>y(nr,K),[y]),Q=A.useCallback(K=>y(or,K),[y]),be=A.useCallback(()=>y(Dr),[y]),se=K=>!(n.finite&&(X(K)>0&&m.currentIndex===0||X(K)<0&&m.currentIndex===m.slides.length-1)),pe=K=>{var oe;v.current=K,(oe=P.current)===null||oe===void 0||oe.style.setProperty(Xe("swipe_offset"),`${Math.round(K)}px`)},ne=K=>{var oe,ae;T.current=K,I.current=(()=>{const Ee=c&&K>0?K:h&&K<0?-K:0;return Math.min(Math.max(Yo(1-Ee/60*(1-.5),2),.5),1)})(),(oe=P.current)===null||oe===void 0||oe.style.setProperty(Xe("pull_offset"),`${Math.round(K)}px`),(ae=P.current)===null||ae===void 0||ae.style.setProperty(Xe("pull_opacity"),`${I.current}`)},{prepareAnimation:Ae}=ra(b,(K,oe,ae)=>{if(b.current&&U)return{keyframes:[{transform:`translate(0, ${K.rect.y-oe.y+ae.y}px)`,opacity:K.opacity},{transform:"translate(0, 0)",opacity:1}],duration:K.duration,easing:o.easing.fade}}),ve=(K,oe)=>{if(h||c){ne(K);let ae=0;b.current&&(ae=o.fade*(oe?2:1),Ae({rect:b.current.getBoundingClientRect(),opacity:I.current,duration:ae})),$(()=>{ne(0),M(pt.NONE)},ae),M(pt.ANIMATION),oe||be()}},{prepareAnimation:We,isAnimationPlaying:me}=ra(b,(K,oe,ae)=>{var ce;if(b.current&&U&&(!((ce=m.animation)===null||ce===void 0)&&ce.duration)){const ke=Pn(n.spacing),Ee=(ke.percent?ke.percent*U.width/100:ke.pixel)||0;return{keyframes:[{transform:`translate(${X(m.globalIndex-K.index)*(U.width+Ee)+K.rect.x-oe.x+ae.x}px, 0)`},{transform:"translate(0, 0)"}],duration:m.animation.duration,easing:m.animation.easing}}}),Te=Le(K=>{var oe,ae;const ce=K.offset||0,ke=ce?o.swipe:(oe=o.navigation)!==null&&oe!==void 0?oe:o.swipe,Ee=!ce&&!me()?o.easing.navigation:o.easing.swipe;let{direction:Be}=K;const Me=(ae=K.count)!==null&&ae!==void 0?ae:1;let Ke=pt.ANIMATION,Pe=ke*Me;if(!Be){const le=U?.width,de=K.duration||0,ue=le?ke/le*Math.abs(ce):ke;Me!==0?(de0?nr:or):Pe=ke/2}let q=0;Be===nr?se(X(1))?q=-Me:(Ke=pt.NONE,Pe=ke):Be===or&&(se(X(-1))?q=Me:(Ke=pt.NONE,Pe=ke)),Pe=Math.round(Pe),O(()=>{pe(0),M(pt.NONE)},Pe),b.current&&We({rect:b.current.getBoundingClientRect(),index:m.globalIndex}),M(Ke),y(Bo,{type:"swipe",increment:q,duration:Pe,easing:Ee})});A.useEffect(()=>{var K,oe;!((K=m.animation)===null||K===void 0)&&K.increment&&(!((oe=m.animation)===null||oe===void 0)&&oe.duration)&&E(()=>x({type:"swipe",increment:0}),m.animation.duration)},[m.animation,x,E]);const ge=[N,se,U?.width||0,o.swipe,()=>M(pt.SWIPE),K=>pe(K),(K,oe)=>Te({offset:K,duration:oe,count:1}),K=>Te({offset:K,count:0})],Oe=[()=>{c&&M(pt.PULL)},K=>ne(K),K=>ve(K),K=>ve(K,!0)];vf(a,...ge,h,c,...Oe,be),xf(k,...ge);const we=Le(()=>{a.focus&&F().querySelector(`.${ye(Ho)} .${ye(El())}`)&&B()});A.useEffect(we,[we]);const $e=Le(()=>{var K;(K=s.view)===null||K===void 0||K.call(s,{index:m.currentIndex})});A.useEffect($e,[m.globalIndex,$e]),A.useEffect(()=>Pr(w(nr,K=>Te({direction:nr,...K})),w(or,K=>Te({direction:or,...K})),w(Bo,K=>x(K))),[w,Te,x]);const ze=A.useMemo(()=>({prev:W,next:Q,close:be,focus:B,slideRect:U?Qu(U,n.padding):{width:0,height:0},containerRect:U||{width:0,height:0},subscribeSensors:N,containerRef:P,setCarouselRef:z,toolbarWidth:g,setToolbarWidth:p}),[W,Q,be,B,N,U,P,z,g,p,n.padding]);return A.useImperativeHandle(a.ref,()=>({prev:W,next:Q,close:be,focus:B,getLightboxProps:Y,getLightboxState:H}),[W,Q,be,B,Y,H]),A.createElement("div",{ref:_,className:ht(ye(El()),ye(Ir)),style:{...k===pt.SWIPE?{[Xe("swipe_offset")]:`${Math.round(v.current)}px`}:null,...k===pt.PULL?{[Xe("pull_offset")]:`${Math.round(T.current)}px`,[Xe("pull_opacity")]:`${I.current}`}:null,...a.touchAction!=="none"?{[Xe("controller_touch_action")]:a.touchAction}:null,...l.container},tabIndex:-1,...S},U&&A.createElement(Tl.Provider,{value:ze},e,(r=f.controls)===null||r===void 0?void 0:r.call(f)))}const Cf=Ft(rn,kf);function br(e){return fr(Vs,e)}function Al(e){return fr(jo,e)}function _f({slide:e,offset:t}){const r=A.useRef(null),{currentIndex:n,slides:o}=Ut(),{slideRect:a,focus:s}=Yt(),{render:l,carousel:{imageFit:f,imageProps:h},on:{click:c},styles:{slide:i},labels:u}=ct(),{getOwnerDocument:g}=$r(),p=t!==0;A.useEffect(()=>{var x;p&&(!((x=r.current)===null||x===void 0)&&x.contains(g().activeElement))&&s()},[p,s,g]);const m=()=>{var x,k,M,v;let T=(x=l.slide)===null||x===void 0?void 0:x.call(l,{slide:e,offset:t,rect:a});return!T&&pr(e)&&(T=A.createElement(mr,{slide:e,offset:t,render:l,rect:a,imageFit:f,imageProps:h,onClick:p?void 0:()=>c?.({index:n})})),T?A.createElement(A.Fragment,null,(k=l.slideHeader)===null||k===void 0?void 0:k.call(l,{slide:e}),((M=l.slideContainer)!==null&&M!==void 0?M:(({children:I})=>I))({slide:e,children:T}),(v=l.slideFooter)===null||v===void 0?void 0:v.call(l,{slide:e})):null};return A.createElement("div",{ref:r,className:ht(ye(Al()),!p&&ye(Al("current")),ye(Ir)),...ef(p),style:i,role:"group","aria-roledescription":hr(u,"Slide"),"aria-label":ll(u,o,n+t)},m())}function Sf(){const e=ct().styles.slide;return A.createElement("div",{className:ye(jo),style:e})}function Ef({carousel:e,labels:t}){const{slides:r,currentIndex:n,globalIndex:o}=Ut(),{setCarouselRef:a}=Yt(),{autoPlaying:s,focusWithin:l}=ea(),f=Pn(e.spacing),h=Pn(e.padding),c=cl(e,r,1),i=[];if(Zo(r))for(let u=n-c;u<=n+c;u+=1){const g=Qo(r,u),p=o-n+u,m=e.finite&&(u<0||u>r.length-1);i.push(m?{key:p}:{key:[`${p}`,il(g)].filter(Boolean).join("|"),offset:u-n,slide:g})}return A.createElement("div",{ref:a,className:ht(ye(br()),i.length>0&&ye(br("with_slides"))),style:{[`${Xe(br("slides_count"))}`]:i.length,[`${Xe(br("spacing_px"))}`]:f.pixel||0,[`${Xe(br("spacing_percent"))}`]:f.percent||0,[`${Xe(br("padding_px"))}`]:h.pixel||0,[`${Xe(br("padding_percent"))}`]:h.percent||0},role:"region","aria-live":s&&!l?"off":"polite","aria-roledescription":hr(t,"Carousel"),"aria-label":hr(t,"Photo gallery")},i.map(({key:u,slide:g,offset:p})=>g?A.createElement(_f,{key:u,slide:g,offset:p}):A.createElement(Sf,{key:u})))}const Tf=Ft(Vs,Ef);function Nl(){const{carousel:e}=ct(),{slides:t,currentIndex:r}=Ut(),n=t.length===0||e.finite&&r===0,o=t.length===0||e.finite&&r===t.length-1;return{prevDisabled:n,nextDisabled:o}}function Ol(e){var t;const r=Fn(),{publish:n}=Fr(),{animation:o}=ct(),{prevDisabled:a,nextDisabled:s}=Nl(),l=((t=o.navigation)!==null&&t!==void 0?t:o.swipe)/2,f=_l(()=>n(nr),l),h=_l(()=>n(or),l),c=Le(i=>{switch(i.key){case Yu:n(Dr);break;case Xu:(r?s:a)||(r?h:f)();break;case qu:(r?a:s)||(r?f:h)();break}});A.useEffect(()=>e(Wo,c),[e,c])}function Ml({label:e,icon:t,renderIcon:r,action:n,onClick:o,disabled:a,style:s}){return A.createElement(Ur,{label:e,icon:t,renderIcon:r,className:ye(`navigation_${n}`),disabled:a,onClick:o,style:s,...kl(Yt().focus,a)})}function Af({render:{buttonPrev:e,buttonNext:t,iconPrev:r,iconNext:n},styles:o}){const{prev:a,next:s,subscribeSensors:l}=Yt(),{prevDisabled:f,nextDisabled:h}=Nl();return Ol(l),A.createElement(A.Fragment,null,e?e():A.createElement(Ml,{label:"Previous",action:nr,icon:gf,renderIcon:r,style:o.navigationPrev,disabled:f,onClick:a}),t?t():A.createElement(Ml,{label:"Next",action:or,icon:hf,renderIcon:n,style:o.navigationNext,disabled:h,onClick:s}))}const Nf=Ft(Lu,Af),Il=ye(Wu),Of=ye(Zs);function Mf(e){return"style"in e}function Dl(e,t,r){const n=window.getComputedStyle(e),o=r?"padding-left":"padding-right",a=r?n.paddingLeft:n.paddingRight,s=e.style.getPropertyValue(o);return e.style.setProperty(o,`${(Dn(a)||0)+t}px`),()=>{s?e.style.setProperty(o,s):e.style.removeProperty(o)}}function If({noScroll:{disabled:e},children:t}){const r=Fn(),{getOwnerDocument:n,getOwnerWindow:o}=$r();return A.useEffect(()=>{if(e)return()=>{};const a=[],s=o(),{body:l,documentElement:f}=n(),h=Math.round(s.innerWidth-f.clientWidth);if(h>0){a.push(Dl(l,h,r));const c=l.getElementsByTagName("*");for(let i=0;i{l.classList.remove(Il),a.forEach(c=>c())}},[r,e,n,o]),A.createElement(A.Fragment,null,t)}const Df=Ft($u,If);function Pl(e){return fr(Ho,e)}function Ll(e,t,r){const n=e.getAttribute(t);return e.setAttribute(t,r),()=>{n?e.setAttribute(t,n):e.removeAttribute(t)}}function Pf({children:e,animation:t,styles:r,className:n,on:o,portal:a,close:s,labels:l}){const[f,h]=A.useState(!1),[c,i]=A.useState(!1),u=A.useRef([]),g=A.useRef(null),{setTimeout:p}=cn(),{subscribe:m}=Fr(),k=ta()?0:t.fade;A.useEffect(()=>(h(!0),()=>{h(!1),i(!1)}),[]);const M=Le(()=>{u.current.forEach(S=>S()),u.current=[]}),v=Le(()=>{var S;i(!1),M(),(S=o.exiting)===null||S===void 0||S.call(o),p(()=>{var N;(N=o.exited)===null||N===void 0||N.call(o),s()},k)});A.useEffect(()=>m(Dr,v),[m,v]);const T=Le(S=>{var N,w,y;tf(S),i(!0),(N=o.entering)===null||N===void 0||N.call(o);const E=(y=(w=S.parentNode)===null||w===void 0?void 0:w.children)!==null&&y!==void 0?y:[];for(let O=0;O{var O,$;($=(O=g.current)===null||O===void 0?void 0:O.focus)===null||$===void 0||$.call(O)}),p(()=>{var O;(O=o.entered)===null||O===void 0||O.call(o)},k)}),I=A.useCallback(S=>{S?T(S):M()},[T,M]);return f?tr.createPortal(A.createElement(yf,{ref:I,className:ht(n,ye(Pl()),ye(Zs),c&&ye(Pl("open"))),"aria-modal":!0,role:"dialog","aria-label":hr(l,"Lightbox"),style:{...t.fade!==Ro.animation.fade?{[Xe("fade_animation_duration")]:`${k}ms`}:null,...t.easing.fade!==Ro.animation.easing.fade?{[Xe("fade_animation_timing_function")]:t.easing.fade}:null,...r.root},onFocus:S=>{g.current||(g.current=S.relatedTarget)}},e),a.root||document.body):null}const Lf=Ft(Ho,Pf);function $f({children:e}){return A.createElement(A.Fragment,null,e)}const Ff=Ft(Fu,$f);function Uf(e){return fr(Ks,e)}function zf({toolbar:{buttons:e},render:{buttonClose:t,iconClose:r},styles:n}){const{close:o,setToolbarWidth:a}=Yt(),{setContainerRef:s,containerRect:l}=wl();Vt(()=>{a(l?.width)},[a,l?.width]);const f=()=>t?t():A.createElement(Ur,{key:Dr,label:"Close",icon:ff,renderIcon:r,onClick:o});return A.createElement("div",{ref:s,style:n.toolbar,className:ye(Uf())},e?.map(h=>h===Dr?f():h))}const Hf=Ft(Ks,zf);function $l(e,t){var r;return A.createElement(e.module.component,{key:e.module.name,...t},(r=e.children)===null||r===void 0?void 0:r.map(n=>$l(n,t)))}function Gf(e,t={}){const{easing:r,...n}=e,{easing:o,...a}=t;return{easing:{...r,...o},...n,...a}}function jf({carousel:e,animation:t,render:r,toolbar:n,controller:o,noScroll:a,on:s,plugins:l,slides:f,index:h,...c}){const{animation:i,carousel:u,render:g,toolbar:p,controller:m,noScroll:x,on:k,slides:M,index:v,plugins:T,...I}=Ro,{config:S,augmentation:N}=rf([it(Lf,[it(Df,[it(Cf,[it(Tf),it(Hf),it(Nf)])])])],l||T),w=N({animation:Gf(i,t),carousel:{...u,...e},render:{...g,...r},toolbar:{...p,...n},controller:{...m,...o},noScroll:{...x,...a},on:{...k,...s},...I,...c});return w.open?A.createElement(pl,{...w},A.createElement(cf,{slides:f||M,index:Dn(h||v)},A.createElement(df,null,A.createElement(af,null,A.createElement(nf,null,$l(it(Ff,S),w)))))):null}const Bf={minZoom:1,maxZoomPixelRatio:1,zoomInMultiplier:2,doubleTapDelay:300,doubleClickDelay:500,doubleClickMaxStops:2,keyboardMoveDistance:50,wheelZoomDistanceFactor:100,pinchZoomDistanceFactor:100,pinchZoomV4:!1,scrollToZoom:!1};function Wf(e){return Math.min(Math.max(e,Number.EPSILON),1)}function Fl(e){const{minZoom:t,...r}={...Bf,...e};return{minZoom:Wf(t),...r}}function Vf(e,t,r,n){const o=A.useRef(void 0),a=A.useRef(void 0),{zoom:s}=ct().animation,l=ta(),f=Le(()=>{var h,c,i;if((h=o.current)===null||h===void 0||h.cancel(),o.current=void 0,a.current&&n?.current){try{o.current=(i=(c=n.current).animate)===null||i===void 0?void 0:i.call(c,[{transform:a.current},{transform:`scale(${e}) translateX(${t}px) translateY(${r}px)`}],{duration:l?0:s??500,easing:o.current?"ease-out":"ease-in-out"})}catch(u){console.error(u)}a.current=void 0,o.current&&(o.current.onfinish=()=>{o.current=void 0})}});return Vt(f,[e,t,r,f]),A.useCallback(()=>{a.current=n?.current?window.getComputedStyle(n.current).transform:void 0},[n])}function Kf(e,t){const{on:r}=ct(),n=Le(()=>{var o;t||(o=r.zoom)===null||o===void 0||o.call(r,{zoom:e})});A.useEffect(n,[e,n])}function Un(){const{zoom:e}=ct();return Fl(e)}function Yf(e,t){var r,n;let o={width:0,height:0},a={width:0,height:0};const{currentSlide:s}=Ut(),{imageFit:l}=ct().carousel,{maxZoomPixelRatio:f}=Un();if(e&&s){const c={...s,...t};if(pr(c)){const i=Xo(c,l),u=Math.max(...(((r=c.srcSet)===null||r===void 0?void 0:r.map(p=>p.width))||[]).concat(c.width?[c.width]:[])),g=Math.max(...(((n=c.srcSet)===null||n===void 0?void 0:n.map(p=>p.height))||[]).concat(c.height?[c.height]:[]));u>0&&g>0&&e.width>0&&e.height>0&&(a=i?{width:Math.round(Math.min(u,e.width/e.height*g)),height:Math.round(Math.min(g,e.height/e.width*u))}:{width:u,height:g},a={width:a.width*f,height:a.height*f},o=i?{width:Math.min(e.width,a.width,u),height:Math.min(e.height,a.height,g)}:{width:Math.round(Math.min(e.width,e.height/g*u,u)),height:Math.round(Math.min(e.height,e.width/u*g,g))})}}const h=o.width?Math.max(Yo(a.width/o.width,5),1):1;return{imageRect:o,maxZoom:h}}function Ul(e,t){return Math.hypot(e.clientX-t.clientX,e.clientY-t.clientY)}function zl(e,t,r=100,n=2){return e*Math.min(1+Math.abs(t/r),n)**Math.sign(t)}function Xf(e,t,r,n,o,a,s,l,f){const h=A.useRef([]),c=A.useRef(0),i=A.useRef(void 0),{globalIndex:u}=Ut(),{getOwnerWindow:g}=$r(),{containerRef:p,subscribeSensors:m}=Yt(),{keyboardMoveDistance:x,zoomInMultiplier:k,wheelZoomDistanceFactor:M,scrollToZoom:v,doubleTapDelay:T,doubleClickDelay:I,doubleClickMaxStops:S,pinchZoomDistanceFactor:N,pinchZoomV4:w}=Un(),y=A.useCallback(z=>{if(p.current){const{pageX:F,pageY:G}=z,{scrollX:X,scrollY:B}=g(),{left:Y,top:H,width:W,height:Q}=p.current.getBoundingClientRect();return[F-Y-X-W/2,G-H-B-Q/2]}return[]},[p,g]),E=Le(z=>{const{key:F,metaKey:G,ctrlKey:X}=z,B=G||X,Y=()=>{z.preventDefault(),z.stopPropagation()};if(e>1){const H=(W,Q)=>{Y(),l(W,Q)};F==="ArrowDown"?H(0,x):F==="ArrowUp"?H(0,-x):F==="ArrowLeft"?H(-x,0):F==="ArrowRight"&&H(x,0)}F==="+"||B&&F==="="?(Y(),o()):F==="-"||B&&F==="_"?(Y(),a()):B&&F==="0"&&(Y(),s(1))}),O=Le(z=>{if((z.ctrlKey||v)&&Math.abs(z.deltaY)>Math.abs(z.deltaX)){z.stopPropagation(),s(zl(e,-z.deltaY,M),!0,...y(z));return}e>1&&(z.stopPropagation(),v||l(z.deltaX,z.deltaY))}),$=A.useCallback(z=>{const F=h.current;F.splice(0,F.length,...F.filter(G=>G.pointerId!==z.pointerId))},[]),P=A.useCallback(z=>{$(z),z.persist(),h.current.push(z)},[$]),L=Le(z=>{var F;const G=h.current;if(z.pointerType==="mouse"&&z.buttons>1||!(!((F=f?.current)===null||F===void 0)&&F.contains(z.target)))return;e>1&&z.stopPropagation();const{timeStamp:X}=z;if(G.length===0&&X-c.current<(z.pointerType==="touch"?T:I)){c.current=0;const B=e>=1?e!==r?e*Math.max(r**(1/S),k):1:e!==t?e/Math.max(t**(-1/S),k):1;s(B,!1,...y(z))}else c.current=X;if(P(z),G.length===2){const B=Ul(G[0],G[1]);i.current={previousDistance:B,initialDistance:Math.max(B,1),initialZoom:e}}}),U=Le(z=>{const F=h.current,G=F.find(X=>X.pointerId===z.pointerId);if(F.length===2&&i.current){z.stopPropagation(),P(z);const X=Ul(F[0],F[1]),B=w?i.current.initialZoom/i.current.initialDistance*X:zl(e,X-i.current.previousDistance,N);s(B,!0,...F.map(Y=>y(Y)).reduce((Y,H)=>H.map((W,Q)=>Y[Q]+W/2))),i.current.previousDistance=X;return}e>1&&(z.stopPropagation(),G&&(F.length===1&&l((G.clientX-z.clientX)/e,(G.clientY-z.clientY)/e),P(z)))}),_=A.useCallback(z=>{const F=h.current;F.length===2&&F.find(G=>G.pointerId===z.pointerId)&&(i.current=void 0),$(z)},[$]),b=A.useCallback(()=>{const z=h.current;z.splice(0,z.length),c.current=0,i.current=void 0},[]);Sl(m,L,U,_,n),A.useEffect(b,[u,b]),A.useEffect(()=>n?()=>{}:Pr(b,m(Wo,E),m(Vo,O)),[n,m,b,E,O])}function qf(e,t,r){const[n,o]=A.useState(1),[a,s]=A.useState(0),[l,f]=A.useState(0),h=Vf(n,a,l,r),{currentSlide:c,globalIndex:i}=Ut(),{containerRect:u,slideRect:g}=Yt(),{minZoom:p,zoomInMultiplier:m}=Un(),x=c&&pr(c)?c.src:void 0,k=!x||!r?.current;Vt(()=>{o(1),s(0),f(0)},[i,x]);const M=A.useCallback((N,w,y)=>{const E=y||n,O=a-(N||0),$=l-(w||0),P=(e.width*E-g.width)/2/E,L=(e.height*E-g.height)/2/E;s(Math.min(Math.abs(O),Math.max(P,0))*Math.sign(O)),f(Math.min(Math.abs($),Math.max(L,0))*Math.sign($))},[n,a,l,g,e.width,e.height]),v=A.useCallback((N,w,y,E)=>{const O=Yo(N+.01p?N:p:t,5);w||h(),M(y?y*(1/n-1/O):0,E?E*(1/n-1/O):0,O),o(O)},[n,p,t,M,h]),T=Le(()=>{n>1&&(n>t&&v(t,!0),M())});Vt(T,[u.width,u.height,T]);const I=A.useCallback(()=>{const N=n*m;v(n<1&&N>1?1:N)},[n,m,v]),S=A.useCallback(()=>{const N=n/m;v(n>1&&N<1?1:N)},[n,m,v]);return{zoom:n,offsetX:a,offsetY:l,disabled:k,changeOffsets:M,changeZoom:v,zoomIn:I,zoomOut:S}}const Hl=A.createContext(null),la=$t("useZoom","ZoomControllerContext",Hl);function Zf({children:e}){const[t,r]=A.useState(),{slideRect:n}=Yt(),{ref:o,minZoom:a}=Un(),{imageRect:s,maxZoom:l}=Yf(n,t?.imageDimensions),{zoom:f,offsetX:h,offsetY:c,disabled:i,changeZoom:u,changeOffsets:g,zoomIn:p,zoomOut:m}=qf(s,l,t?.zoomWrapperRef);Kf(f,i),Xf(f,a,l,i,p,m,u,g,t?.zoomWrapperRef);const x=A.useMemo(()=>({zoom:f,minZoom:a,maxZoom:l,offsetX:h,offsetY:c,disabled:i,zoomIn:p,zoomOut:m,changeZoom:u}),[f,a,l,h,c,i,p,m,u]);A.useImperativeHandle(o,()=>x,[x]);const k=A.useMemo(()=>({...x,setZoomWrapper:r}),[x,r]);return A.createElement(Hl.Provider,{value:k},e)}const Qf=xt("ZoomIn",A.createElement(A.Fragment,null,A.createElement("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"}),A.createElement("path",{d:"M12 10h-2v2H9v-2H7V9h2V7h1v2h2v1z"}))),Jf=xt("ZoomOut",A.createElement("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zM7 9h5v1H7z"})),Gl=A.forwardRef(function({zoomIn:t,onLoseFocus:r},n){const o=A.useRef(!1),a=A.useRef(!1),{zoom:s,minZoom:l,maxZoom:f,zoomIn:h,zoomOut:c,disabled:i}=la(),{render:u}=ct(),g=i||(t?s>=f:s<=l);return A.useEffect(()=>{g&&o.current&&a.current&&r(),g||(o.current=!0)},[g,r]),A.createElement(Ur,{ref:n,disabled:g,label:t?"Zoom in":"Zoom out",icon:t?Qf:Jf,renderIcon:t?u.iconZoomIn:u.iconZoomOut,onClick:t?h:c,onFocus:()=>{a.current=!0},onBlur:()=>{a.current=!1}})});function Rf(){const e=A.useRef(null),t=A.useRef(null),{focus:r}=Yt(),n=A.useCallback(s=>{var l,f;!((l=s.current)===null||l===void 0)&&l.disabled?r():(f=s.current)===null||f===void 0||f.focus()},[r]),o=A.useCallback(()=>n(e),[n]),a=A.useCallback(()=>n(t),[n]);return A.createElement(A.Fragment,null,A.createElement(Gl,{zoomIn:!0,ref:e,onLoseFocus:a}),A.createElement(Gl,{ref:t,onLoseFocus:o}))}function eg(){const{render:e}=ct(),t=la();return e.buttonZoom?A.createElement(A.Fragment,null,e.buttonZoom(t)):A.createElement(Rf,null)}function tg(e){var t;return(((t=e.srcSet)===null||t===void 0?void 0:t.length)||0)>0}function rg({current:e,preload:t},{type:r,source:n}){switch(r){case"fetch":return e?{current:e,preload:n}:{current:n};case"done":return n===t?{current:n}:{current:e,preload:t};default:throw new Error(al)}}function ng(e){var t,r;const[{current:n,preload:o},a]=A.useReducer(rg,{}),{slide:s,rect:l,imageFit:f,render:h,interactive:c}=e,i=s.srcSet.sort((I,S)=>I.width-S.width),u=(t=s.width)!==null&&t!==void 0?t:i[i.length-1].width,g=(r=s.height)!==null&&r!==void 0?r:i[i.length-1].height,p=Xo(s,f),m=Math.max(...i.map(I=>I.width)),x=Math.min((p?Math.max:Math.min)(l.width,u*(l.height/g)),m),k=Ju(),M=Le(()=>{var I;const S=(I=i.find(N=>N.width>=x*k))!==null&&I!==void 0?I:i[i.length-1];(!n||i.findIndex(N=>N.src===n)N===S))&&a({type:"fetch",source:S.src})});Vt(M,[l.width,l.height,k,M]);const v=Le(I=>a({type:"done",source:I})),T={WebkitTransform:c?"initial":"translateZ(0)"};return p||Object.assign(T,l.width/l.heightv(o),render:{...h,iconLoading:()=>null,iconError:()=>null}}),n&&A.createElement(mr,{key:"current",...e,slide:{...s,src:n,srcSet:void 0},style:T}))}function og({render:e,slide:t,offset:r,rect:n}){var o;const[a,s]=A.useState(),l=A.useRef(null),{zoom:f,maxZoom:h,offsetX:c,offsetY:i,setZoomWrapper:u}=la(),g=f>1,{carousel:p,on:m}=ct(),{currentIndex:x}=Ut();Vt(()=>r===0?(u({zoomWrapperRef:l,imageDimensions:a}),()=>u(void 0)):()=>{},[r,a,u]);let k=(o=e.slide)===null||o===void 0?void 0:o.call(e,{slide:t,offset:r,rect:n,zoom:f,maxZoom:h});if(!k&&pr(t)){const M={slide:t,offset:r,rect:n,render:e,imageFit:p.imageFit,imageProps:p.imageProps,onClick:r===0?()=>{var v;return(v=m.click)===null||v===void 0?void 0:v.call(m,{index:x})}:void 0};k=tg(t)?A.createElement(ng,{...M,slide:t,interactive:g,rect:r===0?{width:n.width*f,height:n.height*f}:n}):A.createElement(mr,{onLoad:v=>s({width:v.naturalWidth,height:v.naturalHeight}),...M})}return k?A.createElement("div",{ref:l,className:ht(ye(qs),ye(Ir),ye(Qs),g&&ye(Vu)),style:r===0?{transform:`scale(${f}) translateX(${c}px) translateY(${i}px)`}:void 0},k):null}const ag=({augment:e,addModule:t})=>{e(({zoom:r,toolbar:n,render:o,controller:a,...s})=>{const l=Fl(r);return{zoom:l,toolbar:Ln(n,Xs,A.createElement(eg,null)),render:{...o,slide:f=>{var h;return pr(f.slide)?A.createElement(og,{render:o,...f}):(h=o.slide)===null||h===void 0?void 0:h.call(o,f)}},controller:{...a,preventDefaultWheelY:l.scrollToZoom},...s}}),t(Ft(Xs,Zf))},sg={separator:"/",container:{}},jl=e=>({...sg,...e});function lg({counter:e}){const{slides:t,currentIndex:r}=Ut(),{separator:n,container:{className:o,...a},className:s,...l}=jl(e);return t.length===0?null:A.createElement("div",{className:ht(ye("counter"),o||s),...l,...a,"aria-hidden":!0},r+1," ",n," ",t.length)}function ig({augment:e,addChild:t}){e(({counter:r,...n})=>({counter:jl(r),...n})),t(rn,Ft(Uu,lg))}const cg={autoplay:!1,delay:3e3,ref:null},Bl=e=>({...cg,...e}),Wl=A.createContext(null),dg=$t("useSlideshow","SlideshowContext",Wl);function ug({slideshow:e,carousel:{finite:t},on:r,children:n}){const{autoplay:o,delay:a,ref:s}=Bl(e),l=A.useRef(o),[f,h]=A.useState(o),c=A.useRef(void 0),i=A.useRef(void 0),{slides:u,currentIndex:g}=Ut(),{setTimeout:p,clearTimeout:m}=cn(),{subscribe:x}=Fr(),{next:k}=Yt(),{setAutoPlaying:M}=ea();A.useEffect(()=>M(f),[f,M]);const v=u.length===0||t&&g===u.length-1,T=A.useCallback(()=>{!f&&!v&&h(!0)},[f,v]),I=A.useCallback(()=>{f&&h(!1)},[f]),S=A.useCallback(()=>{m(c.current),c.current=void 0},[m]),N=Le(()=>{S(),!(!f||v||i.current===Mr||i.current===Go)&&(c.current=p(()=>{f&&(i.current=void 0,k())},a))});A.useEffect(N,[g,f,N]),A.useEffect(()=>{f&&v&&h(!1)},[g,f,v]);const w=Le(()=>{var O;return(O=r.slideshowStart)===null||O===void 0?void 0:O.call(r)}),y=Le(()=>{var O;return(O=r.slideshowStop)===null||O===void 0?void 0:O.call(r)});A.useEffect(()=>{f?w():l.current&&y(),l.current=f},[f,w,y]),A.useEffect(()=>Pr(S,x(Hu,()=>{i.current=Mr,S()}),x(Gu,()=>{i.current=Go,S()}),x(ju,()=>{i.current=an,N()}),x(Bu,()=>{i.current=sn,N()})),[x,S,N]);const E=A.useMemo(()=>({playing:f,disabled:v,play:T,pause:I}),[f,v,T,I]);return A.useImperativeHandle(s,()=>E,[E]),A.createElement(Wl.Provider,{value:E},n)}const fg=xt("Play",A.createElement("path",{d:"M8 5v14l11-7z"})),gg=xt("Pause",A.createElement("path",{d:"M6 19h4V5H6v14zm8-14v14h4V5h-4z"}));function hg(){const{playing:e,disabled:t,play:r,pause:n}=dg(),{render:o}=ct(),a=kl(Yt().focus,t);return o.buttonSlideshow?A.createElement(A.Fragment,null,o.buttonSlideshow({playing:e,disabled:t,play:r,pause:n})):A.createElement(Ur,{label:e?"Pause":"Play",icon:e?gg:fg,renderIcon:e?o.iconSlideshowPause:o.iconSlideshowPlay,onClick:e?n:r,disabled:t,...a})}function pg({augment:e,addModule:t}){e(({slideshow:r,toolbar:n,...o})=>({toolbar:Ln(n,Ys,A.createElement(hg,null)),slideshow:Bl(r),...o})),t(Ft(Ys,ug))}const mg={auto:!1,ref:null},Vl=e=>({...mg,...e}),Kl=A.createContext(null),bg=$t("useFullscreen","FullscreenContext",Kl);function yg({fullscreen:e,on:t,children:r}){const{auto:n,ref:o}=Vl(e),a=A.useRef(null),[s,l]=A.useState(),[f,h]=A.useState(!1),c=A.useRef(!1),{getOwnerDocument:i}=$r();Vt(()=>{var v,T,I,S;const N=i();l(!((S=(I=(T=(v=N.fullscreenEnabled)!==null&&v!==void 0?v:N.webkitFullscreenEnabled)!==null&&T!==void 0?T:N.mozFullScreenEnabled)!==null&&I!==void 0?I:N.msFullscreenEnabled)!==null&&S!==void 0&&S))},[i]);const u=A.useCallback(()=>{var v;const T=i(),I=T.fullscreenElement||T.webkitFullscreenElement||T.mozFullScreenElement||T.msFullscreenElement;return((v=I?.shadowRoot)===null||v===void 0?void 0:v.fullscreenElement)||I},[i]),g=A.useCallback(()=>{const v=a.current;try{v.requestFullscreen?v.requestFullscreen().catch(()=>{}):v.webkitRequestFullscreen?v.webkitRequestFullscreen():v.mozRequestFullScreen?v.mozRequestFullScreen():v.msRequestFullscreen&&v.msRequestFullscreen()}catch{}},[]),p=A.useCallback(()=>{if(!u())return;const v=i();try{v.exitFullscreen?v.exitFullscreen().catch(()=>{}):v.webkitExitFullscreen?v.webkitExitFullscreen():v.mozCancelFullScreen?v.mozCancelFullScreen():v.msExitFullscreen&&v.msExitFullscreen()}catch{}},[u,i]);A.useEffect(()=>{const v=i(),T=()=>{h(u()===a.current)};return Pr(...["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"].map(I=>(v.addEventListener(I,T),()=>v.removeEventListener(I,T))))},[u,i]);const m=Le(()=>{var v;return(v=t.enterFullscreen)===null||v===void 0?void 0:v.call(t)}),x=Le(()=>{var v;return(v=t.exitFullscreen)===null||v===void 0?void 0:v.call(t)});A.useEffect(()=>{f&&(c.current=!0),c.current&&(f?m:x)()},[f,m,x]);const k=Le(()=>{var v;return(v=n?g:null)===null||v===void 0||v(),p});A.useEffect(k,[k]);const M=A.useMemo(()=>({fullscreen:f,disabled:s,enter:g,exit:p}),[f,s,g,p]);return A.useImperativeHandle(o,()=>M,[M]),A.createElement("div",{ref:a,className:ht(ye(nn),ye(qs))},A.createElement(Kl.Provider,{value:M},r))}const vg=xt("EnterFullscreen",A.createElement("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"})),wg=xt("ExitFullscreen",A.createElement("path",{d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"}));function xg(){var e;const{fullscreen:t,disabled:r,enter:n,exit:o}=bg(),{render:a}=ct();return r?null:a.buttonFullscreen?A.createElement(A.Fragment,null,(e=a.buttonFullscreen)===null||e===void 0?void 0:e.call(a,{fullscreen:t,disabled:r,enter:n,exit:o})):A.createElement(Ur,{disabled:r,label:t?"Exit Fullscreen":"Enter Fullscreen",icon:t?wg:vg,renderIcon:t?a.iconExitFullscreen:a.iconEnterFullscreen,onClick:t?o:n})}function kg({augment:e,contains:t,addParent:r}){e(({fullscreen:n,toolbar:o,...a})=>({toolbar:Ln(o,nn,A.createElement(xg,null)),fullscreen:Vl(n),...a})),r(t(on)?on:rn,Ft(nn,yg))}const yr={ref:null,position:"bottom",width:120,height:80,border:1,borderRadius:4,padding:4,gap:16,imageFit:"contain",vignette:!0,hidden:!1,showToggle:!1},ia=e=>({...yr,...e});function Yl(){const{thumbnails:e}=ct();return ia(e)}const vr=e=>fr(on,e),dt=e=>vr(fr("thumbnail",e)),Cg=xt("VideoThumbnail",A.createElement("path",{d:"M10 16.5l6-4.5-6-4.5v9zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"})),_g=xt("UnknownThumbnail",A.createElement("path",{d:"M23 18V6c0-1.1-.9-2-2-2H3c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2zM8.5 12.5l2.5 3.01L14.5 11l4.5 6H5l3.5-4.5z"}));function Sg({slide:e,render:t,rect:r,imageFit:n}){var o;const a=(o=t.thumbnail)===null||o===void 0?void 0:o.call(t,{slide:e,render:t,rect:r,imageFit:n});if(a)return a;const s={render:t,rect:r,imageFit:n};if(e.thumbnail)return A.createElement(mr,{slide:{src:e.thumbnail},...s});if(pr(e))return A.createElement(mr,{slide:e,...s});const l=ye(dt(In));return e.type==="video"?A.createElement(A.Fragment,null,e.poster&&A.createElement(mr,{slide:{src:e.poster},...s}),A.createElement(Cg,{className:l})):A.createElement(_g,{className:l})}const Eg=gr("active"),ca=gr("fadein"),da=gr("fadeout"),Tg=gr("placeholder"),Xl="delay",ql="duration";function Ag({slide:e,index:t,onClick:r,fadeIn:n,fadeOut:o,placeholder:a,onLoseFocus:s}){const l=A.useRef(null),{render:f,styles:h,labels:c}=ct(),{slides:i,globalIndex:u}=Ut(),{getOwnerDocument:g}=$r(),{width:p,height:m,imageFit:x}=Yl(),k={width:p,height:m},M=t===u,v=Le(s);return A.useEffect(()=>{o&&g().activeElement===l.current&&v()},[o,v,g]),A.createElement("button",{ref:l,type:"button",className:ht(ye(Ir),ye(dt()),M&&ye(dt(Eg())),n&&ye(dt(ca())),o&&ye(dt(da())),a&&ye(dt(Tg()))),style:{...n?{[Xe(dt(ca(ql)))]:`${n.duration}ms`,[Xe(dt(ca(Xl)))]:`${n.delay}ms`}:null,...o?{[Xe(dt(da(ql)))]:`${o.duration}ms`,[Xe(dt(da(Xl)))]:`${o.delay}ms`}:null,...h.thumbnail},onClick:r,"aria-current":M?!0:void 0,"aria-label":ll(c,i,t)},e&&Sg({slide:e,render:f,rect:k,imageFit:x}))}function Zl(e){return["top","bottom"].includes(e)}function Ql(e,t){return t+2*(e.border+e.padding)+e.gap}function Ng(e){const{thumbnail:t,poster:r}=e||{thumbnail:"placeholder"};return typeof t=="string"&&t||typeof r=="string"&&r||e&&il(e)||void 0}function Jl({visible:e,containerRef:t}){const r=A.useRef(null),n=Fn(),{publish:o,subscribe:a}=Fr(),{carousel:s,styles:l,labels:f}=ct(),{slides:h,globalIndex:c,animation:i}=Ut(),{registerSensors:u,subscribeSensors:g}=Cl();Ol(g);const p=Yl(),{position:m,width:x,height:k,border:M,borderStyle:v,borderColor:T,borderRadius:I,padding:S,gap:N,vignette:w}=p,y=i?.duration!==void 0&&i?.increment||0,E=i?.duration||0,{prepareAnimation:O}=ra(r,_=>({keyframes:Zl(m)?[{transform:`translateX(${(n?-1:1)*Ql(p,x)*y+_}px)`},{transform:"translateX(0)"}]:[{transform:`translateY(${Ql(p,k)*y+_}px)`},{transform:"translateY(0)"}],duration:E,easing:i?.easing})),$=Le(()=>{let _=0;if(t.current&&r.current){const b=t.current.getBoundingClientRect(),z=r.current.getBoundingClientRect();_=Zl(m)?z.left-b.left-(b.width-z.width)/2:z.top-b.top-(b.height-z.height)/2}O(_)});A.useEffect(()=>Pr(a(Bo,$)),[a,$]);const P=cl(s,h),L=[];if(Zo(h))for(let _=c-P-Math.abs(y);_<=c+P+Math.abs(y);_+=1){const z=s.finite&&(_<0||_>h.length-1)||y<0&&_0&&_>c+P?null:Qo(h,_),F=[`${_}`,Ng(z)].filter(Boolean).join("|");L.push({key:F,index:_,slide:z})}const U=_=>()=>{_>c?o(or,{count:_-c}):_{const F=E/Math.abs(y||1),G=y>0&&b>c+P-y&&b<=c+P||y<0&&b=c-P?{duration:F,delay:((y>0?b-(c+P-y):c-P-y-b)-1)*F}:void 0,X=y>0&&bc+P?{duration:F,delay:(y>0?y-(c-P-b):-y-(b-(c+P)))*F}:void 0;return A.createElement(Ag,{key:_,index:b,slide:z,fadeIn:G,fadeOut:X,placeholder:!z,onClick:U(b),onLoseFocus:()=>{var B;return(B=r.current)===null||B===void 0?void 0:B.focus()}})})),w&&A.createElement("div",{className:ye(vr("vignette"))}))}const Rl=A.createContext(null),Og=$t("useThumbnails","ThumbnailsContext",Rl);function Mg({children:e,...t}){const{ref:r,position:n,hidden:o}=ia(t.thumbnails),[a,s]=A.useState(!o),l=A.useRef(null),f=A.useMemo(()=>({visible:a,show:()=>s(!0),hide:()=>s(!1)}),[a]);return A.useImperativeHandle(r,()=>f,[f]),A.createElement(pl,{...t},A.createElement(Rl.Provider,{value:f},A.createElement("div",{ref:l,className:ht(ye(vr()),ye(vr(`${n}`)))},["start","top"].includes(n)&&A.createElement(Jl,{containerRef:l,visible:a}),A.createElement("div",{className:ye(vr("wrapper"))},e),["end","bottom"].includes(n)&&A.createElement(Jl,{containerRef:l,visible:a}))))}const ei=()=>A.createElement(A.Fragment,null,A.createElement("path",{strokeWidth:2,stroke:"currentColor",strokeLinejoin:"round",fill:"none",d:"M3 5l18 0l0 14l-18 0l0-14z"}),A.createElement("path",{d:"M5 14h4v3h-4zM10 14h4v3h-4zM15 14h4v3h-4z"})),Ig=xt("ThumbnailsVisible",ei()),Dg=uf("ThumbnailsHidden",ei());function Pg(){const{visible:e,show:t,hide:r}=Og(),{render:n}=ct();return n.buttonThumbnails?A.createElement(A.Fragment,null,n.buttonThumbnails({visible:e,show:t,hide:r})):A.createElement(Ur,{label:e?"Hide thumbnails":"Show thumbnails",icon:e?Ig:Dg,renderIcon:e?n.iconThumbnailsVisible:n.iconThumbnailsHidden,onClick:e?r:t})}function Lg({augment:e,contains:t,append:r,addParent:n}){e(({thumbnails:a,toolbar:s,...l})=>{const f=ia(a);return{toolbar:Ln(s,on,f.showToggle?A.createElement(Pg,null):null),thumbnails:f,...l}});const o=Ft(on,Mg);t(nn)?r(nn,o):n(rn,o)}const $g="X-Board-Secret-View-Token";function zn(){const e=window.G7Core?.state?.get?.("_global")?.secretViewToken;return typeof e=="string"&&e!==""?{[$g]:e}:{}}const It=({className:e="",children:t,style:r,...n})=>d.jsx("i",{className:e,style:r,...n,children:t}),ua=e=>{if(!e||typeof window>"u"||!window.location||!/^(https?:)?\/\//i.test(e))return!1;try{return new URL(e,window.location.href).origin!==window.location.origin}catch{return!1}},fa=window.G7Core,Hn=(e,t)=>fa?.t?.(e,t)??e,Fg=async(e,t)=>{try{const r=await fa.api.get(e,{responseType:"blob",headers:zn()});if(r){const n=URL.createObjectURL(r),o=document.createElement("a");o.href=n,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}}catch(r){console.error("Failed to download file:",r),fa?.toast?.error?.(Hn("common.download_failed"))}},Ug=(e,t)=>{const r=document.createElement("a");r.href=e,r.download=t,r.target="_blank",document.body.appendChild(r),r.click(),document.body.removeChild(r)},ti=async e=>{const t=e.downloadUrl||e.src,r=e.filename||e.title||"image";e.downloadRequiresAuth&&!ua(t)?await Fg(t,r):Ug(t,r)},zg=({image:e,index:t,onDownload:r})=>{const[n,o]=C.useState(!1),a=async s=>{if(s.stopPropagation(),r){r(e,t);return}o(!0);try{await ti(e)}finally{o(!1)}};return d.jsx(R,{type:"button",onClick:a,disabled:n,className:"yarl__button flex items-center justify-center","aria-label":Hn("common.download"),title:Hn("common.download"),children:n?d.jsx(It,{className:"fa-solid fa-spinner fa-spin text-white"}):d.jsx(It,{className:"fa-solid fa-download text-white"})})},zr=({images:e,isOpen:t,onClose:r,startIndex:n=0,enableZoom:o=!0,enableSlideshow:a=!1,enableFullscreen:s=!0,showCounter:l=!0,showDownload:f=!0,showThumbnails:h=!0,onDownload:c,editorAttrs:i,id:u})=>{const[g,p]=C.useState(n),m=C.useRef(n),x=e.map(v=>({src:v.src,title:v.title,description:v.description})),k=[];o&&k.push(ag),a&&k.push(pg),s&&k.push(kg),l&&k.push(ig),h&&k.push(Lg);const M=e[g];if(C.useEffect(()=>{m.current=g},[g]),i){const v=(e??[]).slice(0,4);return d.jsx(j,{id:u,className:"grid grid-cols-2 gap-2 p-3 rounded-lg border border-dashed border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800",...i,children:v.length>0?v.map((T,I)=>d.jsx(jt,{src:T.thumbnail||T.src,alt:T.title||"",className:"w-full aspect-square object-cover rounded bg-gray-200 dark:bg-gray-700"},I)):d.jsxs(j,{className:"col-span-2 flex items-center justify-center py-6 text-sm text-gray-400 dark:text-gray-500",children:[d.jsx(It,{className:"fa-regular fa-images mr-2"}),Hn("editor.component.image_gallery")]})})}return d.jsx(jf,{open:t,close:r,slides:x,index:g,plugins:k,on:{view:({index:v})=>{v!==m.current&&p(v)}},zoom:{maxZoomPixelRatio:3,zoomInMultiplier:2,doubleTapDelay:300,doubleClickDelay:300,doubleClickMaxStops:2,keyboardMoveDistance:50,wheelZoomDistanceFactor:100,pinchZoomDistanceFactor:100,scrollToZoom:!0},carousel:{finite:!0,preload:2,padding:"16px",spacing:"30%"},animation:{fade:250,swipe:500,easing:{fade:"ease",swipe:"ease-out",navigation:"ease-in-out"}},controller:{closeOnBackdropClick:!0,closeOnPullDown:!0,closeOnPullUp:!0},thumbnails:{position:"bottom",width:120,height:80,border:2,borderRadius:4,padding:4,gap:16,showToggle:!1,vignette:!0},toolbar:{buttons:[f&&M&&d.jsx(zg,{image:M,index:g,onDownload:c},"download"),"close"].filter(Boolean)},styles:{container:{backgroundColor:"rgba(0, 0, 0, 0.9)"}}})},ri=()=>{const[e,t]=C.useState(!1),[r,n]=C.useState([]),[o,a]=C.useState(0),s=C.useCallback((f,h=0)=>{n(f),a(h),t(!0)},[]),l=C.useCallback(()=>{t(!1)},[]);return{isOpen:e,openGallery:s,closeGallery:l,galleryProps:{images:r,isOpen:e,onClose:l,startIndex:o}}};zr.displayName="ImageGallery";const ni=Object.freeze(Object.defineProperty({__proto__:null,ImageGallery:zr,default:zr,executeImageDownload:ti,useImageGallery:ri},Symbol.toStringTag,{value:"Module"})),Hg=window.G7Core,ga=(e,t)=>Hg?.t?.(e,t)??e,Gn=e=>e.url??e.download_url,jn=({images:e=[],className:t="",id:r,editorAttrs:n})=>{const[o,a]=C.useState(0),{openGallery:s,galleryProps:l}=ri(),f=C.useMemo(()=>e.map(c=>({src:Gn(c),title:c.alt_text_current??"",thumbnail:Gn(c),downloadUrl:c.download_url,filename:c.alt_text_current??`image-${c.id}`})),[e]);if(!e||e.length===0)return d.jsx(j,{className:`flex items-center justify-center bg-gray-100 dark:bg-gray-700 rounded-lg aspect-square ${t}`,id:r,...n,children:d.jsxs(j,{className:"text-center text-gray-400 dark:text-gray-500",children:[d.jsx(fe,{name:"image",size:"3x",className:"mb-3 opacity-50"}),d.jsx(j,{className:"text-sm",children:ga("shop.no_image")})]})});const h=e[o]??e[0];return d.jsxs(j,{id:r,className:t,...n,children:[d.jsx(j,{className:"relative overflow-hidden rounded-lg bg-gray-100 dark:bg-gray-700 aspect-square mb-3",children:d.jsx(R,{type:"button",className:"w-full h-full cursor-zoom-in block",onClick:()=>s(f,o),"aria-label":ga("shop.view_image"),children:d.jsx(jt,{src:Gn(h),alt:h.alt_text_current??"",className:"w-full h-full object-contain"})})}),e.length>1&&d.jsx(j,{className:"flex gap-2 overflow-x-auto pb-1",children:e.map((c,i)=>d.jsx(R,{type:"button",className:`flex-shrink-0 w-16 h-16 rounded-md overflow-hidden border-2 transition-colors cursor-pointer ${i===o?"border-gray-900 dark:border-white":"border-gray-200 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-400"}`,onClick:()=>a(i),"aria-label":c.alt_text_current??`${ga("shop.image")} ${i+1}`,children:d.jsx(jt,{src:Gn(c),alt:c.alt_text_current??"",className:"w-full h-full object-cover"})},c.id))}),d.jsx(zr,{...l})]})};jn.displayName="ProductImageViewer";const Gg=Object.freeze(Object.defineProperty({__proto__:null,ProductImageViewer:jn,default:jn},Symbol.toStringTag,{value:"Module"})),oi=({value:e,min:t=1,max:r=999,onChange:n,size:o="md",disabled:a=!1,className:s="",id:l,editorAttrs:f})=>{const c={sm:{container:"h-8",button:"w-8 h-8 text-sm",input:"w-10 text-sm"},md:{container:"h-10",button:"w-10 h-10",input:"w-14"},lg:{container:"h-12",button:"w-12 h-12 text-lg",input:"w-16 text-lg"}}[o],i=()=>{e>t&&!a&&n(e-1)},u=()=>{e{const M=parseInt(k.target.value,10);if(!isNaN(M)){const v=Math.max(t,Math.min(r,M));n(v)}},p=k=>{const M=parseInt(k.target.value,10);isNaN(M)||Mr&&n(r)},m=a||e<=t,x=a||e>=r;return d.jsxs(j,{className:`inline-flex items-center border border-gray-300 dark:border-gray-600 rounded-lg ${c.container} ${s}`,id:l,...f,children:[d.jsx(R,{type:"button",onClick:i,disabled:m,className:`${c.button} flex items-center justify-center text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed rounded-l-lg transition-colors`,"aria-label":"수량 감소",children:d.jsx(fe,{name:"minus",className:"w-4 h-4"})}),d.jsx(At,{type:"number",value:e,onChange:g,onBlur:p,min:t,max:r,disabled:a,className:`${c.input} text-center border-x border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`,"aria-label":"수량"}),d.jsx(R,{type:"button",onClick:u,disabled:x,className:`${c.button} flex items-center justify-center text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed rounded-r-lg transition-colors`,"aria-label":"수량 증가",children:d.jsx(fe,{name:"plus",className:"w-4 h-4"})})]})},jg=Object.freeze(Object.defineProperty({__proto__:null,default:oi},Symbol.toStringTag,{value:"Module"})),Bg=window.G7Core?.createLogger?.("Comp:PostReactions")??{log:(...e)=>console.log("[Comp:PostReactions]",...e),warn:(...e)=>console.warn("[Comp:PostReactions]",...e),error:(...e)=>console.error("[Comp:PostReactions]",...e)},ai=(e,t)=>window.G7Core?.t?.(e,t)??e,Wg=[{type:"like",emoji:"👍",labelKey:"board.reactions.like",activeColor:"bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400"},{type:"funny",emoji:"😂",labelKey:"board.reactions.funny",activeColor:"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-600 dark:text-yellow-400"},{type:"agree",emoji:"👌",labelKey:"board.reactions.agree",activeColor:"bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400"},{type:"thanks",emoji:"🙏",labelKey:"board.reactions.thanks",activeColor:"bg-purple-100 dark:bg-purple-900/30 text-purple-600 dark:text-purple-400"},{type:"wow",emoji:"😮",labelKey:"board.reactions.wow",activeColor:"bg-orange-100 dark:bg-orange-900/30 text-orange-600 dark:text-orange-400"}],si=({reactions:e,userReaction:t,postId:r,onReact:n,size:o="md",className:a="",id:s,editorAttrs:l})=>{const f={sm:"px-2 py-1 text-xs gap-1",md:"px-3 py-1.5 text-sm gap-1.5",lg:"px-4 py-2 text-base gap-2"},h={sm:"text-sm",md:"text-base",lg:"text-lg"},c=u=>e.find(p=>p.type===u)?.count??0,i=async u=>{if(n){n(u);return}try{if(!(await fetch(`/api/posts/${r}/reactions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:u}),credentials:"include"})).ok)throw new Error("리액션 처리 실패");window.location.reload()}catch(g){Bg.error("리액션 오류:",g)}};return d.jsx(j,{className:`flex flex-wrap gap-2 ${a}`,id:s,...l,children:Wg.map(u=>{const g=c(u.type),p=t===u.type;return d.jsxs(R,{onClick:()=>i(u.type),className:` + `,children:[d.jsx(fe,{name:nt.Moon,className:"w-5 h-5 text-gray-600 dark:text-gray-400"}),d.jsx(te,{className:"flex-1 text-left text-gray-900 dark:text-white",children:o}),f==="dark"&&d.jsx(fe,{name:nt.Check,className:"w-4 h-4 text-blue-600 dark:text-blue-400 ml-auto"})]})]})})]})},Ud=Object.freeze(Object.defineProperty({__proto__:null,ThemeToggle:An,default:An},Symbol.toStringTag,{value:"Module"})),vs={xs:"w-6 h-6 text-xs",sm:"w-8 h-8 text-sm",md:"w-10 h-10 text-base",lg:"w-12 h-12 text-lg",xl:"w-16 h-16 text-xl","2xl":"w-24 h-24 text-2xl","3xl":"w-32 h-32 text-3xl","4xl":"w-40 h-40 text-4xl","5xl":"w-48 h-48 text-5xl"},zd="rounded-full overflow-hidden flex-shrink-0 border border-gray-200 dark:border-gray-700",Hd="grayscale opacity-50",No={normal:"bg-gradient-to-br from-blue-500 to-purple-600",withdrawn:"bg-gray-300 dark:bg-gray-600",guest:"bg-gray-200 dark:bg-gray-700"},Qr=({author:e,name:t,avatar:r,size:n="md",className:o="",text:a,isWithdrawn:s=!1,isGuest:l=!1,id:f,editorAttrs:h})=>{const c=r??e?.avatar,i=a??t??e?.name??"?",u=s||e?.status==="withdrawn",g=l||e?.is_guest||!1,p=C.useMemo(()=>[vs[n]||vs.md,zd,u?Hd:"",o].filter(Boolean).join(" "),[n,u,o]),m=g?No.guest:u?No.withdrawn:No.normal,x=()=>g?d.jsx(j,{className:`w-full h-full flex items-center justify-center ${m}`,children:d.jsx(fe,{name:"user",className:"text-gray-400 dark:text-gray-500"})}):u?d.jsx(j,{className:`w-full h-full flex items-center justify-center ${m}`,children:d.jsx(fe,{name:"user",className:"text-gray-500 dark:text-gray-400"})}):d.jsx(j,{className:`w-full h-full flex items-center justify-center text-white font-semibold ${m}`,children:i.charAt(0).toUpperCase()});return d.jsx(j,{className:p,id:f,...h,children:c&&!g&&!u?d.jsx(jt,{src:c,alt:i,className:"w-full h-full object-cover"}):x()})},Gd=Object.freeze(Object.defineProperty({__proto__:null,Avatar:Qr},Symbol.toStringTag,{value:"Module"})),jd=window.G7Core?.createLogger?.("Comp:SlotContainer")??{log:(...e)=>console.log("[Comp:SlotContainer]",...e),warn:(...e)=>console.warn("[Comp:SlotContainer]",...e),error:(...e)=>console.error("[Comp:SlotContainer]",...e)};function ws(e,t){return t&&e&&typeof e.id=="string"&&e.id.length>0?{...e,id:`${e.id}__${t}`}:e}const Nn=({slotId:e,className:t="",emptyContent:r,style:n,id:o,children:a})=>{const[s,l]=C.useState([]),[,f]=C.useState({}),h=C.useCallback(()=>{const p=window.__slotContextValue;if(p)return p;const m=window.G7Core;return m&&m.getSlotContext?.()||null},[]),c=C.useCallback(()=>{const p=h();p&&p.isEnabled&&l(p.getSlotComponents(e))},[e,h]);C.useEffect(()=>{const p=h();return!p||!p.isEnabled?void 0:(c(),p.subscribeToSlot(e,()=>{c(),f({})}))},[e,h,c]);const i=C.useCallback(()=>{const p=window.G7Core;return p?p.getDynamicRenderer?.():null},[]);if(s.length===0)return r?d.jsx(j,{className:t,style:n,id:o,children:r}):a?d.jsx(j,{className:t,style:n,id:o,children:a}):null;const u=i(),g=window.G7Core;return!u||!g?(jd.error("G7Core or DynamicRenderer not available"),null):d.jsxs(j,{className:t,style:n,id:o,children:[s.map(p=>{const{componentDef:m,dataContext:x,parentFormContext:k,getParentComponentContext:M,translationContext:v}=p,T=ws(m,o);return d.jsx(u,{componentDef:T,dataContext:x,translationContext:v,registry:g.getComponentRegistry(),bindingEngine:g.getDataBindingEngine(),translationEngine:g.getTranslationEngine(),actionDispatcher:g.getActionDispatcher(),parentComponentContext:M?.(),parentFormContextProp:k,isRootRenderer:!1},T.id||`slot-${e}-${p.order}`)}),a]})},Bd=Object.freeze(Object.defineProperty({__proto__:null,SlotContainer:Nn,default:Nn,scopeSlotChildDef:ws},Symbol.toStringTag,{value:"Module"})),On=({notifications:e=[],unreadCount:t=0,hasMore:r=!1,loading:n=!1,titleText:o="알림",emptyText:a="알림이 없습니다.",markAllReadText:s="모두 읽음",deleteAllText:l="모두 삭제",unreadOnlyText:f="안 읽은 알림만",unreadOnly:h=!1,onNotificationClick:c,onClose:i,onLoadMore:u,onMarkAllRead:g,onDeleteAll:p,onDelete:m,onUnreadOnlyToggle:x,dropdownAlign:k="right",className:M="",id:v,editorAttrs:T})=>{const[I,S]=C.useState(!1),N=C.useRef(null),w=C.useRef(null),y=C.useRef(null),E=C.useRef(null),O=C.useRef(new Set),$=C.useRef(u),P=C.useRef(r),L=C.useRef(n),U=C.useRef(e.length),_=C.useRef(-1);C.useEffect(()=>{$.current=u,P.current=r,L.current=n,U.current=e.length}),C.useEffect(()=>{if(!E.current||!y.current||!I)return;_.current=-1;const G=new IntersectionObserver(([X])=>{X.isIntersecting&&(L.current||!P.current||_.current!==U.current&&(_.current=U.current,$.current?.()))},{root:y.current,threshold:.1});return G.observe(E.current),()=>G.disconnect()},[I]),C.useEffect(()=>{if(!y.current||!I)return;const G=new IntersectionObserver(B=>{B.forEach(Y=>{const H=Y.target.getAttribute("data-notification-id"),W=Y.target.getAttribute("data-unread")==="true";H&&W&&Y.isIntersecting&&O.current.add(H)})},{root:y.current,threshold:.5});return y.current.querySelectorAll("[data-notification-id]").forEach(B=>G.observe(B)),()=>G.disconnect()},[I,e]);const b=t>0?t:e.filter(G=>!G.read).length,z=C.useCallback(()=>{if(I){if(b>0){const G=Array.from(O.current).filter(X=>{const B=e.find(Y=>String(Y.id)===String(X));return B&&!B.read});G.length>0&&i?.(G)}O.current.clear(),S(!1)}},[I,i,b,e]);C.useEffect(()=>{if(!I)return;const G=X=>{N.current&&!N.current.contains(X.target)&&z()};return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[I,z]);const F=C.useCallback(()=>{I?z():S(!0)},[I,z]);return C.useLayoutEffect(()=>{const G=w.current;if(!I||!G)return;G.style.transform="";const X=G.getBoundingClientRect(),B=typeof window<"u"?window.innerWidth:0;if(X.width===0&&X.height===0)return;const Y=8;let H=0;X.right>B-Y?H=-(X.right-(B-Y)):X.left0&&d.jsx(te,{className:"absolute -top-1 -right-1 w-5 h-5 flex items-center justify-center text-xs font-bold text-white bg-red-500 dark:bg-red-600 rounded-full",children:b>99?"99+":b})]}),I&&d.jsxs(j,{ref:w,className:`absolute ${k==="left"?"left-0":"right-0"} mt-2 w-80 max-w-[calc(100vw-1rem)] bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-50`,children:[d.jsxs(j,{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700 flex items-center justify-between gap-2",children:[d.jsxs(j,{className:"flex items-center gap-3 min-w-0",children:[d.jsx(te,{className:"font-semibold text-gray-900 dark:text-white",children:o}),x&&d.jsxs(j,{className:"flex items-center gap-1.5 cursor-pointer select-none",onClick:()=>x(!h),children:[d.jsx(At,{type:"checkbox",checked:h,onChange:G=>{G.stopPropagation(),x(G.target.checked)},onClick:G=>G.stopPropagation(),className:"w-3.5 h-3.5 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-400 focus:ring-blue-500 dark:focus:ring-blue-400 cursor-pointer"}),d.jsx(te,{className:"text-xs text-gray-600 dark:text-gray-400",children:f})]})]}),d.jsxs(j,{className:"flex items-center gap-3 flex-shrink-0",children:[g&&b>0&&d.jsx(R,{onClick:()=>{g(),O.current.clear()},className:"text-xs text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300 hover:underline cursor-pointer",children:s}),p&&e.length>0&&d.jsx(R,{onClick:()=>{p()},className:"text-xs text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300 hover:underline cursor-pointer",children:l})]})]}),d.jsx(j,{ref:y,className:"max-h-96 overflow-y-auto",children:e.length===0&&!n?d.jsx(j,{className:"px-4 py-8 text-center text-gray-500 dark:text-gray-400",children:d.jsx(te,{children:a})}):d.jsxs(d.Fragment,{children:[e.map(G=>{const X=!G.read;return d.jsxs(j,{"data-notification-id":G.id,"data-unread":X?"true":"false",onClick:()=>{G.onClick?.(),c?.(G),S(!1)},className:`group flex items-start gap-3 px-4 py-3 text-left border-b border-gray-100 dark:border-gray-700 transition-colors cursor-pointer ${X?"bg-blue-50/70 dark:bg-blue-900/20 hover:bg-blue-50 dark:hover:bg-blue-900/30":"bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700/50 opacity-70"}`,children:[G.iconName&&d.jsx(fe,{name:G.iconName,className:`w-5 h-5 mt-0.5 flex-shrink-0 ${X?"text-blue-600 dark:text-blue-400":"text-gray-400 dark:text-gray-500"}`}),d.jsxs(j,{className:"flex-1 min-w-0",children:[d.jsx(j,{className:`text-sm truncate ${X?"font-semibold text-gray-900 dark:text-white":"font-normal text-gray-600 dark:text-gray-400"}`,children:G.title}),d.jsx(j,{className:`text-sm mt-1 line-clamp-2 ${X?"text-gray-700 dark:text-gray-300":"text-gray-500 dark:text-gray-500"}`,children:G.message}),d.jsx(j,{className:"text-gray-400 dark:text-gray-500 text-xs mt-1 font-mono",children:G.time})]}),d.jsxs(j,{className:"flex flex-col items-center gap-2 flex-shrink-0",children:[X&&d.jsx(te,{className:"w-2 h-2 bg-blue-500 dark:bg-blue-400 rounded-full mt-1.5"}),m&&d.jsx(R,{onClick:B=>{B.stopPropagation(),m(G)},className:"p-1 text-gray-400 dark:text-gray-500 hover:text-red-600 dark:hover:text-red-400 rounded hover:bg-red-50 dark:hover:bg-red-900/20 cursor-pointer opacity-0 group-hover:opacity-100 transition-opacity","aria-label":"Delete notification",children:d.jsx(fe,{name:nt.Trash,className:"w-4 h-4"})})]})]},G.id)}),r&&d.jsx(j,{ref:E,className:"px-4 py-3 text-center",children:n?d.jsx(te,{className:"text-sm text-gray-400 dark:text-gray-500",children:"..."}):d.jsx(te,{className:"text-sm text-gray-400 dark:text-gray-500"})}),n&&!r&&e.length>0&&d.jsx(j,{className:"px-4 py-2 text-center",children:d.jsx(te,{className:"text-sm text-gray-400 dark:text-gray-500",children:"..."})})]})})]})]})},Wd=Object.freeze(Object.defineProperty({__proto__:null,NotificationCenter:On,default:On},Symbol.toStringTag,{value:"Module"})),Qe=(e,t)=>window.G7Core?.t?.(e,t)??e,vt=e=>{window.G7Core?.dispatch?.({handler:"navigate",params:{path:e}})},xs=({logo:e,siteName:t="그누보드7",user:r,cartCount:n=0,notificationCount:o=0,boards:a=[],maxVisibleBoards:s=5,onMobileMenuOpen:l,availableLocales:f=[],currentLocale:h="ko",shopBase:c="/shop",className:i="",editorAttrs:u,notifications:g=[],notificationHasMore:p=!1,notificationLoading:m=!1,notificationUnreadOnly:x=!1,notificationTitleText:k,notificationEmptyText:M,notificationMarkAllReadText:v,notificationDeleteAllText:T,notificationUnreadOnlyText:I,onNotificationClose:S,onNotificationClick:N,onNotificationLoadMore:w,onNotificationMarkAllRead:y,onNotificationDeleteAll:E,onNotificationDelete:O,onNotificationUnreadOnlyToggle:$})=>{const[P,L]=C.useState(""),[U,_]=C.useState(!1),[b,z]=C.useState(!1),[F,G]=C.useState(!1),[X,B]=C.useState({top:0,left:0}),[Y,H]=C.useState(window.location.pathname),W=C.useRef(null),Q=C.useRef(null),be=C.useRef(null),pe=window.G7Core?.useResponsive,ne=pe?.(),Ae=ne?ne.width<768:typeof window<"u"&&window.innerWidth<768;C.useEffect(()=>{const K=()=>H(window.location.pathname);window.addEventListener("popstate",K);const oe=history.pushState;return history.pushState=function(...ae){oe.apply(this,ae),H(window.location.pathname)},()=>{window.removeEventListener("popstate",K),history.pushState=oe}},[]);const ve=(K,oe=!1)=>oe?Y===K:Y===K||Y.startsWith(K+"/"),We=()=>{const K=c==="/"?"":c;return Y.startsWith(`${K}/products`)||Y.startsWith(`${K}/cart`)||Y.startsWith(`${K}/checkout`)||Y.startsWith(`${K}/category`)},me=K=>{const oe="px-3 py-2 text-sm font-medium whitespace-nowrap cursor-pointer rounded-lg transition-colors";return K?`${oe} bg-gray-900 text-white dark:bg-white dark:text-gray-900`:`${oe} text-gray-700 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-800`};C.useEffect(()=>{const K=oe=>{W.current&&!W.current.contains(oe.target)&&_(!1),Q.current&&!Q.current.contains(oe.target)&&z(!1),be.current&&!be.current.contains(oe.target)&&G(!1)};return document.addEventListener("mousedown",K),()=>document.removeEventListener("mousedown",K)},[]);const Te=a.slice(0,s),ge=a.slice(s),Oe=K=>{K.preventDefault(),P.trim()&&vt(`/search?q=${encodeURIComponent(P)}`)},we=async()=>{window.G7Core?.dispatch?.({handler:"logout"})},$e=K=>{window.G7Core?.dispatch?.({handler:"setLocale",target:K}),G(!1)},ze=K=>window.G7Core?.state?.get?.("_global.appConfig.localeNames")?.[K]??(K==="ko"?"한국어":K==="en"?"English":K==="ja"?"日本語":K==="zh"?"中文":K==="es"?"Español":K==="fr"?"Français":K==="de"?"Deutsch":K.toUpperCase());return d.jsxs($d,{...u??{},className:`sticky top-0 z-50 bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-800 ${i}`,children:[d.jsx(j,{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:d.jsxs(j,{className:"flex items-center justify-between h-16",children:[d.jsx(R,{onClick:()=>vt("/"),className:"flex items-center gap-2 flex-shrink-0 cursor-pointer",children:e?d.jsx(jt,{src:e,alt:t,className:"h-8"}):d.jsx(te,{className:"text-xl font-bold text-gray-900 dark:text-white",children:t})}),!Ae&&d.jsx(Eo,{onSubmit:Oe,className:"flex flex-1 max-w-lg mx-8",children:d.jsxs(j,{className:"relative w-full",children:[d.jsx(At,{type:"text",value:P,onChange:K=>L(K.target.value),placeholder:Qe("common.search_placeholder"),className:"w-full px-4 py-2 pl-10 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}),d.jsx(fe,{name:"search",className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-gray-500"})]})}),d.jsxs(j,{className:"flex items-center gap-2",children:[d.jsx(An,{autoText:Qe("common.theme.auto"),lightText:Qe("common.theme.light"),darkText:Qe("common.theme.dark")}),r?.uuid&&d.jsx(On,{notifications:g,unreadCount:o,hasMore:p,loading:m,unreadOnly:x,titleText:k??Qe("mypage.notifications.title"),emptyText:M??Qe("mypage.notifications.empty"),markAllReadText:v??Qe("mypage.notifications.mark_all_read"),deleteAllText:T??Qe("mypage.notifications.delete_all"),unreadOnlyText:I??Qe("mypage.notifications.unread_only"),onClose:S,onNotificationClick:N,onLoadMore:w,onMarkAllRead:y,onDeleteAll:E,onDelete:O,onUnreadOnlyToggle:$,dropdownAlign:"right"}),d.jsxs(R,{onClick:()=>vt(`${c}/cart`),className:"relative p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white cursor-pointer",children:[d.jsx(fe,{name:"shopping-cart",className:"w-5 h-5"}),n>0&&d.jsx(te,{className:"absolute -top-1 -right-1 w-5 h-5 flex items-center justify-center text-xs bg-blue-500 text-white rounded-full",children:n>99?"99+":n})]}),f&&f.length>1&&d.jsxs(j,{ref:be,className:"relative",children:[d.jsxs(R,{onClick:()=>G(!F),className:"flex items-center gap-1.5 px-2.5 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg cursor-pointer transition-colors","aria-haspopup":"listbox","aria-expanded":F,"aria-label":Qe("common.language"),children:[d.jsx(fe,{name:"globe",className:"w-4 h-4"}),d.jsx(te,{className:"font-medium uppercase",children:h}),d.jsx(fe,{name:"chevron-down",className:"w-3 h-3"})]}),F&&d.jsx(j,{role:"listbox",className:"absolute right-0 mt-2 w-44 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1 z-50 overflow-hidden",children:f.map(K=>{const oe=K===h;return d.jsxs(R,{role:"option","aria-selected":oe,onClick:()=>$e(K),className:`w-full px-4 py-2.5 text-left text-sm flex items-center gap-3 cursor-pointer transition-colors ${oe?"bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:[d.jsx(fe,{name:"globe",className:"w-4 h-4"}),d.jsx(te,{className:"flex-1 font-medium",children:ze(K)}),oe&&d.jsx(fe,{name:"check",className:"w-4 h-4"})]},K)})})]}),d.jsx(Nn,{slotId:"header_currency",id:"header_currency_slot_desktop",className:"flex items-center"}),r?.uuid?d.jsxs(j,{ref:W,className:"relative",children:[d.jsxs(R,{onClick:()=>_(!U),className:"flex items-center gap-2 p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white",children:[d.jsx(Qr,{avatar:r.avatar,name:r.name,size:"sm"}),d.jsx(te,{className:"hidden sm:inline text-sm font-medium",children:r.name}),d.jsx(fe,{name:"chevron-down",className:"w-4 h-4"})]}),U&&d.jsxs(j,{className:"absolute right-0 mt-2 w-56 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1 z-50",children:[d.jsx(j,{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700",children:d.jsxs(j,{className:"flex items-center gap-3",children:[d.jsx(Qr,{avatar:r.avatar,name:r.name,size:"md"}),d.jsxs(j,{children:[d.jsx(j,{className:"text-sm font-medium text-gray-900 dark:text-white",children:r.name}),d.jsx(j,{className:"text-xs text-gray-500 dark:text-gray-400",children:Qe("common.member")})]})]})}),d.jsxs(j,{className:"py-1",children:[r.is_admin&&d.jsxs(d.Fragment,{children:[d.jsxs(So,{href:"/admin",className:"block w-full text-left px-4 py-2 text-sm text-blue-600 dark:text-blue-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer font-medium",children:[d.jsx(fe,{name:"settings",className:"inline w-4 h-4 mr-2"}),Qe("common.admin_menu")]}),d.jsx(To,{className:"my-1 border-gray-200 dark:border-gray-700"})]}),d.jsxs(R,{onClick:()=>{vt("/mypage"),_(!1)},className:"block w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[d.jsx(fe,{name:"user",className:"inline w-4 h-4 mr-2"}),Qe("common.mypage")]}),d.jsxs(R,{onClick:()=>{vt("/mypage/orders"),_(!1)},className:"block w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[d.jsx(fe,{name:"shopping-bag",className:"inline w-4 h-4 mr-2"}),Qe("mypage.tabs.orders")]}),d.jsxs(R,{onClick:()=>{vt("/mypage/wishlist"),_(!1)},className:"block w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[d.jsx(fe,{name:"heart",className:"inline w-4 h-4 mr-2"}),Qe("mypage.tabs.wishlist")]})]}),d.jsx(To,{className:"my-1 border-gray-200 dark:border-gray-700"}),d.jsxs(R,{onClick:we,className:"block w-full text-left px-4 py-2 text-sm text-red-600 dark:text-red-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[d.jsx(fe,{name:"log-out",className:"inline w-4 h-4 mr-2"}),Qe("auth.logout")]})]})]}):d.jsxs(j,{className:"flex items-center gap-1.5",children:[d.jsx(R,{onClick:()=>vt("/login?redirect=/mypage/orders"),className:"px-2.5 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white cursor-pointer",children:Qe("shop.guest_order_form.nav_link")}),d.jsx(R,{onClick:()=>vt("/login"),className:"px-2.5 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white cursor-pointer",children:Qe("auth.login")}),d.jsx(R,{onClick:()=>vt("/register"),className:"ml-1 px-3 py-2 text-sm font-medium text-white bg-emerald-500 rounded-lg hover:bg-emerald-600 cursor-pointer",children:Qe("auth.register_link")})]}),Ae&&d.jsx(R,{onClick:l,className:"p-2 text-gray-600 dark:text-gray-400",children:d.jsx(fe,{name:"menu",className:"w-6 h-6"})})]})]})}),!Ae&&d.jsx(Zr,{className:"border-t border-gray-200 dark:border-gray-800",children:d.jsx(j,{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:d.jsxs(j,{className:"flex items-center gap-1 h-12 overflow-x-auto",children:[d.jsx(R,{onClick:()=>vt("/"),className:me(ve("/",!0)),"data-testid":"nav-home",children:Qe("nav.home")}),d.jsxs(R,{onClick:()=>vt("/boards/popular"),className:`flex items-center gap-1 ${me(ve("/boards/popular"))}`,"data-testid":"nav-popular",children:[d.jsx(te,{className:"text-orange-500",children:"🔥"}),Qe("nav.popular")]}),d.jsxs(R,{onClick:()=>vt(`${c==="/"?"":c}/products`),className:`flex items-center gap-1 ${me(We())}`,"data-testid":"nav-shop",children:[d.jsx(te,{children:"🛒"}),Qe("nav.shop")]}),Te.map(K=>d.jsxs(R,{onClick:()=>vt(`/board/${K.slug}`),className:me(ve(`/board/${K.slug}`)),children:[K.icon&&d.jsx(te,{className:"mr-1",children:K.icon}),K.name]},K.id)),ge.length>0&&d.jsxs(j,{ref:Q,className:"relative",children:[d.jsxs(R,{onClick:()=>{if(!b&&Q.current){const K=Q.current.getBoundingClientRect();B({top:K.bottom+4,left:K.left})}z(!b)},className:"flex items-center gap-1 px-3 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white",children:[Qe("nav.more"),d.jsx(fe,{name:"chevron-down",className:"w-4 h-4"})]}),b&&d.jsx(j,{className:"fixed w-48 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1 z-50",style:{top:`${X.top}px`,left:`${X.left}px`},children:ge.map(K=>{const oe=ve(`/board/${K.slug}`);return d.jsxs(R,{onClick:()=>{vt(`/board/${K.slug}`),z(!1)},className:`block w-full text-left px-4 py-2 text-sm cursor-pointer ${oe?"bg-gray-900 text-white dark:bg-white dark:text-gray-900":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:[K.icon&&d.jsx(te,{className:"mr-1",children:K.icon}),K.name]},K.id)})})]})]})})})]})},Vd=Object.freeze(Object.defineProperty({__proto__:null,default:xs},Symbol.toStringTag,{value:"Module"})),Kd=C.forwardRef(({children:e,className:t="",...r},n)=>d.jsx("footer",{ref:n,className:t,...r,children:e})),Nt=(e,t)=>window.G7Core?.t?.(e,t)??e,Yd=768,ks=1024,Xd=e=>{window.G7Core?.dispatch?.({handler:"navigate",params:{path:e}})},Cs=({siteName:e="그누보드7",siteDescription:t,copyrightText:r,socialLinks:n={},linkGroups:o,className:a="",editorAttrs:s})=>{const l=new Date().getFullYear(),h=window.G7Core?.useResponsive,i=h?.()?.width??(typeof window<"u"?window.innerWidth:ks),u=i=ks,p=u?1:g?5:2,m=[{title:Nt("footer.community"),links:[{label:Nt("nav.home"),href:"/"},{label:Nt("nav.popular"),href:"/boards/popular"},{label:Nt("footer.all_boards"),href:"/boards"}]},{title:Nt("footer.info"),links:[{label:Nt("footer.about"),href:"/page/about"},{label:Nt("footer.faq"),href:"/page/faq"},{label:Nt("footer.contact"),href:"/page/contact"}]},{title:Nt("footer.policy"),links:[{label:Nt("footer.terms"),href:"/page/terms"},{label:Nt("footer.privacy"),href:"/page/privacy"},{label:Nt("footer.refund"),href:"/page/refund"}]}],x=o||m,k={github:"github",twitter:"twitter",discord:"discord",facebook:"facebook",instagram:"instagram"};return d.jsx(Kd,{...s??{},className:`bg-gray-50 dark:bg-gray-900 border-t border-gray-200 dark:border-gray-800 ${a}`,children:d.jsxs(j,{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12",children:[d.jsxs(j,{className:"grid gap-8",style:{gridTemplateColumns:`repeat(${p}, minmax(0, 1fr))`},children:[d.jsxs(j,{style:g?{gridColumn:"span 2 / span 2"}:void 0,children:[d.jsx(Tn,{className:"text-lg font-bold text-gray-900 dark:text-white",children:e}),t&&d.jsx(Gt,{className:"mt-2 text-sm text-gray-600 dark:text-gray-400",children:t}),d.jsx(j,{className:"mt-4 flex items-center gap-4",children:Object.entries(n).map(([M,v])=>v?d.jsx(So,{href:v,target:"_blank",rel:"noopener noreferrer",className:"text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200","aria-label":M,children:d.jsx(fe,{name:k[M],className:"w-5 h-5"})},M):null)})]}),x.map((M,v)=>d.jsxs(j,{children:[d.jsx(hs,{className:"text-sm font-semibold text-gray-900 dark:text-white uppercase tracking-wider",children:M.title}),d.jsx(_o,{className:"mt-4 space-y-2",children:M.links.map((T,I)=>d.jsx(er,{children:d.jsx(R,{onClick:()=>Xd(T.href),className:"text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white cursor-pointer",children:T.label})},I))})]},v))]}),d.jsxs(j,{className:"mt-8 pt-8 border-t border-gray-200 dark:border-gray-800 flex justify-between items-center gap-4",style:{flexDirection:u?"column":"row"},children:[d.jsx(Gt,{className:"text-sm text-gray-500 dark:text-gray-400",children:r||`© ${l} ${e}. All rights reserved.`}),d.jsx(Gt,{className:"text-sm text-gray-500 dark:text-gray-400",children:Nt("footer.powered_by")})]})]})})},qd=Object.freeze(Object.defineProperty({__proto__:null,default:Cs},Symbol.toStringTag,{value:"Module"})),Bt=(e,t)=>window.G7Core?.t?.(e,t)??e,Lt=e=>{window.G7Core?.dispatch?.({handler:"navigate",params:{path:e}})},_s=({isOpen:e,onClose:t,logo:r,siteName:n="그누보드7",user:o,boards:a=[],cartCount:s=0})=>{const l=C.useRef(null),h=window.G7Core?.useResponsive,c=h?.(),i=c?c.width<1024:typeof window<"u"&&window.innerWidth<1024;C.useEffect(()=>{const g=p=>{p.key==="Escape"&&t()};return e&&(document.addEventListener("keydown",g),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",g),document.body.style.overflow=""}},[e,t]);const u=g=>{g.target===g.currentTarget&&t()};return!e||!i?null:d.jsxs(j,{className:"fixed inset-0 z-50",onClick:u,children:[d.jsx(j,{className:"fixed inset-0 bg-black/50 transition-opacity"}),d.jsxs(j,{ref:l,className:`fixed inset-y-0 left-0 w-80 max-w-[85vw] bg-white dark:bg-gray-900 shadow-xl transform transition-transform duration-300 ${e?"translate-x-0":"-translate-x-full"}`,children:[d.jsxs(j,{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-800",children:[d.jsx(R,{onClick:()=>{t(),Lt("/")},className:"flex items-center gap-2 cursor-pointer",children:r?d.jsx(jt,{src:r,alt:n,className:"h-8"}):d.jsx(te,{className:"text-xl font-bold text-gray-900 dark:text-white",children:n})}),d.jsx(R,{onClick:t,className:"p-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200","aria-label":"메뉴 닫기",children:d.jsx(fe,{name:"x",className:"w-6 h-6"})})]}),o?d.jsx(j,{className:"p-4 border-b border-gray-200 dark:border-gray-800",children:d.jsxs(j,{className:"flex items-center gap-3",children:[o.avatar?d.jsx(jt,{src:o.avatar,alt:o.name,className:"w-12 h-12 rounded-full"}):d.jsx(j,{className:"w-12 h-12 rounded-full bg-blue-500 flex items-center justify-center text-white text-lg font-medium",children:(o.name||"U").charAt(0).toUpperCase()}),d.jsxs(j,{children:[d.jsx(Gt,{className:"font-medium text-gray-900 dark:text-white",children:o.name}),d.jsx(R,{onClick:()=>{t(),Lt("/mypage")},className:"text-sm text-blue-600 dark:text-blue-400 hover:underline cursor-pointer",children:Bt("common.mypage")})]})]})}):d.jsx(j,{className:"p-4 border-b border-gray-200 dark:border-gray-800",children:d.jsxs(j,{className:"flex gap-2",children:[d.jsx(R,{onClick:()=>{t(),Lt("/login")},className:"flex-1 py-2 text-center text-sm font-medium text-white bg-gray-900 dark:bg-white dark:text-gray-900 rounded-lg cursor-pointer",children:Bt("auth.login")}),d.jsx(R,{onClick:()=>{t(),Lt("/register")},className:"flex-1 py-2 text-center text-sm font-medium text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 rounded-lg cursor-pointer",children:Bt("auth.register")})]})}),d.jsx(Zr,{className:"p-4 overflow-y-auto max-h-[calc(100vh-200px)]",children:d.jsxs(_o,{className:"space-y-1",children:[d.jsx(er,{children:d.jsxs(R,{onClick:()=>{t(),Lt("/")},className:"flex items-center gap-3 px-3 py-2 w-full text-left text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg cursor-pointer",children:[d.jsx(fe,{name:"home",className:"w-5 h-5"}),Bt("nav.home")]})}),d.jsx(er,{children:d.jsxs(R,{onClick:()=>{t(),Lt("/popular")},className:"flex items-center gap-3 px-3 py-2 w-full text-left text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg cursor-pointer",children:[d.jsx(te,{className:"text-orange-500",children:"🔥"}),Bt("nav.popular")]})}),d.jsx(er,{children:d.jsxs(R,{onClick:()=>{t(),Lt("/shop")},className:"flex items-center gap-3 px-3 py-2 w-full text-left text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg cursor-pointer",children:[d.jsx(te,{children:"🛒"}),Bt("nav.shop")]})}),d.jsx(er,{children:d.jsxs(R,{onClick:()=>{t(),Lt("/cart")},className:"flex items-center gap-3 px-3 py-2 w-full text-left text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg cursor-pointer",children:[d.jsx(fe,{name:"shopping-cart",className:"w-5 h-5"}),Bt("nav.cart"),s>0&&d.jsx(te,{className:"ml-auto px-2 py-0.5 text-xs bg-blue-500 text-white rounded-full",children:s})]})}),d.jsx(er,{className:"my-4 border-t border-gray-200 dark:border-gray-800"}),d.jsx(er,{className:"px-3 py-2 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:Bt("nav.boards")}),a.map(g=>d.jsx(er,{children:d.jsxs(R,{onClick:()=>{t(),Lt(`/board/${g.slug}`)},className:"flex items-center gap-3 px-3 py-2 w-full text-left text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg cursor-pointer",children:[g.icon&&d.jsx(te,{children:g.icon}),g.name]})},g.id))]})}),d.jsx(j,{className:"absolute bottom-0 left-0 right-0 p-4 border-t border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900",children:d.jsxs(j,{className:"flex items-center justify-between text-sm text-gray-500 dark:text-gray-400",children:[d.jsx(R,{onClick:()=>{t(),Lt("/about")},className:"hover:text-gray-700 dark:hover:text-gray-200 cursor-pointer",children:Bt("footer.about")}),d.jsx(R,{onClick:()=>{t(),Lt("/terms")},className:"hover:text-gray-700 dark:hover:text-gray-200 cursor-pointer",children:Bt("footer.terms")}),d.jsx(R,{onClick:()=>{t(),Lt("/privacy")},className:"hover:text-gray-700 dark:hover:text-gray-200 cursor-pointer",children:Bt("footer.privacy")})]})})]})]})},Zd=Object.freeze(Object.defineProperty({__proto__:null,default:_s},Symbol.toStringTag,{value:"Module"}));function Ss(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r2?n-2:0),a=2;a1?r-1:0),o=1;o"u"?null:tt(BigInt.prototype.toString),Ds=typeof Symbol>"u"?null:tt(Symbol.prototype.toString),wt=tt(Object.prototype.hasOwnProperty),tn=tt(Object.prototype.toString),gt=tt(RegExp.prototype.test),ur=du(TypeError);function tt(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o2&&arguments[2]!==void 0?arguments[2]:Rr;if(Ts&&Ts(e,null),!Or(t))return e;let n=t.length;for(;n--;){let o=t[n];if(typeof o=="string"){const a=r(o);a!==o&&(ru(t)||(t[n]=a),o=a)}e[o]=!0}return e}function uu(e){for(let t=0;t/g),yu=lt(/\${[\w\W]*/g),vu=lt(/^data-[\-\w.\u00B7-\uFFFF]+$/),wu=lt(/^aria-[\-\w]+$/),Us=lt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),xu=lt(/^(?:\w+script|data):/i),ku=lt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Cu=lt(/^html$/i),_u=lt(/^[a-z][.\w]*(-[.\w]+)+$/i),zs=lt(/<[/\w!]/g),Hs=lt(/<[/\w]/g),Su=lt(/<\/no(script|embed|frames)/i),Eu=lt(/\/>/i),Mt={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Gs=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],Tu=ot(Ge({},Gs)),Au=(function(){const e={};return dr(Gs,t=>{e[t]=lt(new RegExp("])","i"))}),ot(e)})(),Nu=function(){return typeof window>"u"?null:window},Ou=function(t,r){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let n=null;const o="data-tt-policy-suffix";r&&r.hasAttribute(o)&&(n=r.getAttribute(o));const a="dompurify"+(n?"#"+n:"");try{return t.createPolicy(a,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},js=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},rr=function(t,r,n,o){return wt(t,r)&&Or(t[r])?Ge(o.base?Ot(o.base):{},t[r],o.transform):n},Fo=function(t,r,n){const o=wt(t,r)?t[r]:void 0;return o&&typeof o=="object"?Ot(o):n()};function Bs(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Nu();const t=J=>Bs(J);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==Mt.document||!e.Element)return t.isSupported=!1,t;let r=e.document;const n=r,o=n.currentScript;e.DocumentFragment;const a=e.HTMLTemplateElement,s=e.Node,l=e.Element,f=e.NodeFilter,h=e.NamedNodeMap;h===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const c=e.DOMParser,i=e.trustedTypes,u=l.prototype,g=Wt(u,"cloneNode"),p=Wt(u,"remove"),m=Wt(u,"nextSibling"),x=Wt(u,"childNodes"),k=Wt(u,"parentNode"),M=Wt(u,"shadowRoot"),v=Wt(u,"attributes"),T=s&&s.prototype?Wt(s.prototype,"nodeType"):null,I=s&&s.prototype?Wt(s.prototype,"nodeName"):null,S=s&&s.prototype?Wt(s.prototype,"ownerDocument"):null,N=function(D){return T?T(D):D.nodeType},w=function(D){return I?I(D):D.nodeName};if(typeof a=="function"){const J=r.createElement("template");J.content&&J.content.ownerDocument&&(r=J.content.ownerDocument)}let y,E="",O,$=!1,P=0;const L=function(){if(P>0)throw ur('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},U=function(D){L(),P++;try{return y.createHTML(D)}finally{P--}},_=function(D){L(),P++;try{return y.createScriptURL(D)}finally{P--}},b=function(){return $||(O=Ou(i,o),$=!0),O},z=r,F=z.implementation,G=z.createNodeIterator,X=z.createDocumentFragment,B=z.getElementsByTagName,Y=n.importNode;let H=js();t.isSupported=typeof Es=="function"&&typeof k=="function"&&F&&F.createHTMLDocument!==void 0;const W=mu,Q=bu,be=yu,se=vu,pe=wu,ne=xu,Ae=ku,ve=_u;let We=Us,me=null;const Te=Ge({},[...Ps,...Do,...Po,...Lo,...Ls]);let ge=null;const Oe=Ge({},[...$s,...$o,...Fs,...Mn]);let we=Object.seal(Nr(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),$e=null,ze=null;const K=Object.seal(Nr(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let oe=!0,ae=!0,ce=!1,ke=!0,Ee=!1,Be=!0,Me=!1,Ke=!1,Pe=null,q=null,le=!1,de=!1,ue=!1,ie=!1,Fe=!0,Ce=!1;const Ie="user-content-";let Ne=!0,He=!1,je={},_e=null;const xe=Ge({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let De=null;const Ye=Ge({},["audio","video","img","source","image","track"]);let rt=null;const qe=Ge({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Je="http://www.w3.org/1998/Math/MathML",Zt="http://www.w3.org/2000/svg",Ve="http://www.w3.org/1999/xhtml";let bt=Ve,St=!1,Pt=null;const _r=Ge({},[Je,Zt,Ve],Io),lr=ot(["mi","mo","mn","ms","mtext"]);let Ht=Ge({},lr);const ir=ot(["annotation-xml"]);let Sr=Ge({},ir);const Ym=Ge({},["title","style","font","a","script"]);let _n=null;const Xm=["application/xhtml+xml","text/html"],qm="text/html";let et=null,Xr=null;const Zm=r.createElement("form"),od=function(D){return D instanceof RegExp||D instanceof Function},ss=function(){let D=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Xr&&Xr===D)return;(!D||typeof D!="object")&&(D={}),D=Ot(D),_n=Xm.indexOf(D.PARSER_MEDIA_TYPE)===-1?qm:D.PARSER_MEDIA_TYPE,et=_n==="application/xhtml+xml"?Io:Rr,me=rr(D,"ALLOWED_TAGS",Te,{transform:et}),ge=rr(D,"ALLOWED_ATTR",Oe,{transform:et}),Pt=rr(D,"ALLOWED_NAMESPACES",_r,{transform:Io}),rt=rr(D,"ADD_URI_SAFE_ATTR",qe,{transform:et,base:qe}),De=rr(D,"ADD_DATA_URI_TAGS",Ye,{transform:et,base:Ye}),_e=rr(D,"FORBID_CONTENTS",xe,{transform:et}),$e=rr(D,"FORBID_TAGS",Ot({}),{transform:et}),ze=rr(D,"FORBID_ATTR",Ot({}),{transform:et}),je=wt(D,"USE_PROFILES")?D.USE_PROFILES&&typeof D.USE_PROFILES=="object"?Ot(D.USE_PROFILES):D.USE_PROFILES:!1,oe=D.ALLOW_ARIA_ATTR!==!1,ae=D.ALLOW_DATA_ATTR!==!1,ce=D.ALLOW_UNKNOWN_PROTOCOLS||!1,ke=D.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ee=D.SAFE_FOR_TEMPLATES||!1,Be=D.SAFE_FOR_XML!==!1,Me=D.WHOLE_DOCUMENT||!1,de=D.RETURN_DOM||!1,ue=D.RETURN_DOM_FRAGMENT||!1,ie=D.RETURN_TRUSTED_TYPE||!1,le=D.FORCE_BODY||!1,Fe=D.SANITIZE_DOM!==!1,Ce=D.SANITIZE_NAMED_PROPS||!1,Ne=D.KEEP_CONTENT!==!1,He=D.IN_PLACE||!1,We=gu(D.ALLOWED_URI_REGEXP)?D.ALLOWED_URI_REGEXP:Us,bt=typeof D.NAMESPACE=="string"?D.NAMESPACE:Ve,Ht=Fo(D,"MATHML_TEXT_INTEGRATION_POINTS",()=>Ge({},lr)),Sr=Fo(D,"HTML_INTEGRATION_POINTS",()=>Ge({},ir));const V=Fo(D,"CUSTOM_ELEMENT_HANDLING",()=>Nr(null));if(we=Nr(null),wt(V,"tagNameCheck")&&od(V.tagNameCheck)&&(we.tagNameCheck=V.tagNameCheck),wt(V,"attributeNameCheck")&&od(V.attributeNameCheck)&&(we.attributeNameCheck=V.attributeNameCheck),wt(V,"allowCustomizedBuiltInElements")&&typeof V.allowCustomizedBuiltInElements=="boolean"&&(we.allowCustomizedBuiltInElements=V.allowCustomizedBuiltInElements),lt(we),Ee&&(ae=!1),ue&&(de=!0),je&&(me=Ge({},Ls),ge=Nr(null),je.html===!0&&(Ge(me,Ps),Ge(ge,$s)),je.svg===!0&&(Ge(me,Do),Ge(ge,$o),Ge(ge,Mn)),je.svgFilters===!0&&(Ge(me,Po),Ge(ge,$o),Ge(ge,Mn)),je.mathMl===!0&&(Ge(me,Lo),Ge(ge,Fs),Ge(ge,Mn))),K.tagCheck=null,K.attributeCheck=null,wt(D,"ADD_TAGS")&&(typeof D.ADD_TAGS=="function"?K.tagCheck=D.ADD_TAGS:Or(D.ADD_TAGS)&&(me===Te&&(me=Ot(me)),Ge(me,D.ADD_TAGS,et))),wt(D,"ADD_ATTR")&&(typeof D.ADD_ATTR=="function"?K.attributeCheck=D.ADD_ATTR:Or(D.ADD_ATTR)&&(ge===Oe&&(ge=Ot(ge)),Ge(ge,D.ADD_ATTR,et))),wt(D,"ADD_FORBID_CONTENTS")&&Or(D.ADD_FORBID_CONTENTS)&&(_e===xe&&(_e=Ot(_e)),Ge(_e,D.ADD_FORBID_CONTENTS,et)),Ne&&(me["#text"]=!0),Me&&Ge(me,["html","head","body"]),me.table&&(Ge(me,["tbody"]),delete $e.tbody),D.TRUSTED_TYPES_POLICY){if(typeof D.TRUSTED_TYPES_POLICY.createHTML!="function")throw ur('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof D.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ur('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const Z=y;y=D.TRUSTED_TYPES_POLICY;try{E=U("")}catch(re){throw y=Z,re}}else D.TRUSTED_TYPES_POLICY===null?(y=void 0,E=""):(y===void 0&&(y=b()),y&&typeof E=="string"&&(E=U("")));ot&&ot(D),Xr=D},ad=Ge({},[...Do,...Po,...hu]),sd=Ge({},[...Lo,...pu]),Qm=function(D,V,Z){return V.namespaceURI===Ve?D==="svg":V.namespaceURI===Je?D==="svg"&&(Z==="annotation-xml"||Ht[Z]):!!ad[D]},Jm=function(D,V,Z){return V.namespaceURI===Ve?D==="math":V.namespaceURI===Zt?D==="math"&&Sr[Z]:!!sd[D]},Rm=function(D,V,Z){return V.namespaceURI===Zt&&!Sr[Z]||V.namespaceURI===Je&&!Ht[Z]?!1:!sd[D]&&(Ym[D]||!ad[D])},eb=function(D){let V=k(D);(!V||!V.tagName)&&(V={namespaceURI:bt,tagName:"template"});const Z=Rr(D.tagName),re=Rr(V.tagName);return Pt[D.namespaceURI]?D.namespaceURI===Zt?Qm(Z,V,re):D.namespaceURI===Je?Jm(Z,V,re):D.namespaceURI===Ve?Rm(Z,V,re):!!(_n==="application/xhtml+xml"&&Pt[D.namespaceURI]):!1},cr=function(D){Jr(t.removed,{element:D});try{k(D).removeChild(D)}catch{if(p(D),!k(D))throw ur("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},ld=function(D,V,Z){try{D.removeAttributeNode(V)}catch{try{D.removeAttribute(Z)}catch{}}},mo=function(D){bo(D);const V=x(D);if(V){const re=[];dr(V,he=>{Jr(re,he)}),dr(re,he=>{try{p(he)}catch{}})}const Z=v(D);if(Z)for(let re=Z.length-1;re>=0;--re){const he=Z[re],Se=he&&he.name;typeof Se=="string"&&ld(D,he,Se)}},Er=function(D,V,Z){if(!Z)try{Z=V.getAttributeNode(D)}catch{Z=null}Jr(t.removed,{attribute:Z||null,from:V});try{Z?V.removeAttributeNode(Z):V.removeAttribute(D)}catch{try{V.removeAttribute(D)}catch{}}if(D==="is")if(de||ue)try{cr(V)}catch{}else try{V.setAttribute(D,"")}catch{}},tb=function(D){const V=v(D);if(V)for(let Z=V.length-1;Z>=0;--Z){const re=V[Z],he=re&&re.name;typeof he!="string"||ge[et(he)]||ld(D,re,he)}},bo=function(D){const V=[D];for(;V.length>0;){const Z=V.pop();N(Z)===Mt.element&&tb(Z);const he=x(Z);if(he)for(let Se=he.length-1;Se>=0;--Se)V.push(he[Se])}},id=function(D,V){return Be?D==="patchsrc"?!0:D==="for"&&V!=="label"&&V!=="output":!1},rb=function(D){if(!Be)return;const V=[D];for(;V.length>0;){const Z=V.pop(),re=N(Z);if(re===Mt.processingInstruction||re===Mt.comment&>(Hs,Z.data)){try{p(Z)}catch{}continue}if(re===Mt.element){const Se=Z,Ze=et(w(Z));try{Se.hasAttribute&&Se.hasAttribute("patchsrc")&&Se.removeAttribute("patchsrc"),Se.hasAttribute&&Se.hasAttribute("for")&&id("for",Ze)&&Se.removeAttribute("for")}catch{}}const he=x(Z);if(he)for(let Se=he.length-1;Se>=0;--Se)V.push(he[Se])}},cd=function(D){let V=null,Z=null;if(le)D=""+D;else{const Se=Os(D,/^[\r\n\t ]+/);Z=Se&&Se[0]}_n==="application/xhtml+xml"&&bt===Ve&&(D=''+D+"");const re=y?U(D):D;if(bt===Ve)try{V=new c().parseFromString(re,_n)}catch{}if(!V||!V.documentElement){V=F.createDocument(bt,"template",null);try{V.documentElement.innerHTML=St?E:re}catch{}}const he=V.body||V.documentElement;return D&&Z&&he.insertBefore(r.createTextNode(Z),he.childNodes[0]||null),bt===Ve?B.call(V,Me?"html":"body")[0]:Me?V.documentElement:he},dd=function(D){const V=S?S(D):D.ownerDocument;return G.call(V||D,D,f.SHOW_ELEMENT|f.SHOW_COMMENT|f.SHOW_TEXT|f.SHOW_PROCESSING_INSTRUCTION|f.SHOW_CDATA_SECTION,null)},yo=function(D){return D=en(D,W," "),D=en(D,Q," "),D=en(D,be," "),D},ls=function(D){var V;D.normalize();const Z=S?S(D):D.ownerDocument,re=G.call(Z||D,D,f.SHOW_TEXT|f.SHOW_COMMENT|f.SHOW_CDATA_SECTION|f.SHOW_PROCESSING_INSTRUCTION,null);let he=re.nextNode();for(;he;)he.data=yo(he.data),he=re.nextNode();const Se=(V=D.querySelectorAll)===null||V===void 0?void 0:V.call(D,"template");Se&&dr(Se,Ze=>{qr(Ze.content)&&ls(Ze.content)})},vo=function(D){const V=I?I(D):null;return typeof V!="string"||et(V)!=="form"?!1:typeof D.nodeName!="string"||typeof D.textContent!="string"||typeof D.removeChild!="function"||D.attributes!==v(D)||typeof D.removeAttribute!="function"||typeof D.setAttribute!="function"||typeof D.namespaceURI!="string"||typeof D.insertBefore!="function"||typeof D.hasChildNodes!="function"||D.nodeType!==T(D)||D.childNodes!==x(D)},qr=function(D){if(!T||typeof D!="object"||D===null)return!1;try{return T(D)===Mt.documentFragment}catch{return!1}},Sn=function(D){if(!T||typeof D!="object"||D===null)return!1;try{return typeof T(D)=="number"}catch{return!1}};function Rt(J,D,V){J.length!==0&&dr(J,Z=>{Z.call(t,D,V,Xr)})}const nb=function(D,V){return!!(Be&&D.hasChildNodes()&&!Sn(D.firstElementChild)&>(zs,D.textContent)&>(zs,D.innerHTML)||Be&&D.namespaceURI===Ve&&Tu[V]&&(Sn(D.firstElementChild)||typeof D.textContent=="string"&>(Au[V],D.textContent))||D.nodeType===Mt.processingInstruction||Be&&D.nodeType===Mt.comment&>(Hs,D.data))},wo=function(D,V){if(D instanceof RegExp)return gt(D,V);if(D instanceof Function){for(var Z=arguments.length,re=new Array(Z>2?Z-2:0),he=2;he=0;--Ze){const Re=D===Z?g(he[Ze],!0):he[Ze];re.insertBefore(Re,m(D))}}}return cr(D),!0},ud=function(D,V,Z,re){return D.length===0?V:V===Z||V===re?Ot(V):V},fd=function(D,V){return D===V||k(D)!==null?!1:(He&&bo(D),!0)},gd=function(D,V){if(Rt(H.beforeSanitizeElements,D,null),fd(D,V))return!0;if(vo(D))return cr(D),!0;const Z=et(w(D));if(me=ud(H.uponSanitizeElement,me,Te,Pe),Rt(H.uponSanitizeElement,D,{tagName:Z,allowedTags:me}),fd(D,V))return!0;if(nb(D,Z))return cr(D),!0;if($e[Z]||!(K.tagCheck instanceof Function&&K.tagCheck(Z))&&!me[Z]){const he=ob(D,Z,V);return he===!1&&Rt(H.afterSanitizeElements,D,null),he}if(N(D)===Mt.element&&!eb(D)||(Z==="noscript"||Z==="noembed"||Z==="noframes")&>(Su,D.innerHTML))return cr(D),!0;if(Ee&&D.nodeType===Mt.text){const he=yo(D.textContent);D.textContent!==he&&(Jr(t.removed,{element:D.cloneNode()}),D.textContent=he)}return Rt(H.afterSanitizeElements,D,null),!1},hd=function(D,V,Z){if(ze[V]||id(V,D)||Fe&&(V==="id"||V==="name")&&(Z in r||Z in Zm))return!1;const re=ge[V]||K.attributeCheck instanceof Function&&K.attributeCheck(V,D);return ae&>(se,V)||oe&>(pe,V)?!0:re?rt[V]||gt(We,en(Z,Ae,""))||(V==="src"||V==="xlink:href"||V==="href")&&D!=="script"&&Ms(Z,"data:")===0&&De[D]||ce&&!gt(ne,en(Z,Ae,""))?!0:!Z:pd(D)&&wo(we.tagNameCheck,D)&&wo(we.attributeNameCheck,V,D)||V==="is"&&we.allowCustomizedBuiltInElements&&wo(we.tagNameCheck,Z)},ab=Ge({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),pd=function(D){return!ab[Rr(D)]&>(ve,D)},sb=function(D,V,Z,re){if(y&&typeof i=="object"&&typeof i.getAttributeType=="function"&&!Z)switch(i.getAttributeType(D,V)){case"TrustedHTML":return U(re);case"TrustedScriptURL":return _(re)}return re},lb=function(D,V,Z,re){try{Z?D.setAttributeNS(Z,V,re):D.setAttribute(V,re),vo(D)?cr(D):Ns(t.removed)}catch{Er(V,D)}},md=function(D){Rt(H.beforeSanitizeAttributes,D,null);const V=D.attributes;if(!V||vo(D))return;ge=ud(H.uponSanitizeAttribute,ge,Oe,q);const Z={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ge,forceKeepAttr:void 0};let re=V.length;const he=et(D.nodeName);for(;re--;){const Se=V[re],Ze=Se.name,Re=Se.namespaceURI,Et=Se.value,Tt=et(Ze),cs=Et;let yt=Ze==="value"?cs:lu(cs);if(Z.attrName=Tt,Z.attrValue=yt,Z.keepAttr=!0,Z.forceKeepAttr=void 0,Rt(H.uponSanitizeAttribute,D,Z),yt=Z.attrValue,Ce&&(Tt==="id"||Tt==="name")&&Ms(yt,Ie)!==0&&(Er(Ze,D,Se),yt=Ie+yt),Be&>(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,yt)){Er(Ze,D,Se);continue}if(Tt==="attributename"&&Os(yt,"href")){Er(Ze,D,Se);continue}if(!Z.forceKeepAttr){if(!Z.keepAttr){Er(Ze,D,Se);continue}if(!ke&>(Eu,yt)){Er(Ze,D,Se);continue}if(Ee&&(yt=yo(yt)),!hd(he,Tt,yt)){Er(Ze,D,Se);continue}yt=sb(he,Tt,Re,yt),yt!==cs&&lb(D,Ze,Re,yt)}}Rt(H.afterSanitizeAttributes,D,null)},xo=function(D){let V=null;const Z=dd(D);for(Rt(H.beforeSanitizeShadowDOM,D,null);V=Z.nextNode();)if(Rt(H.uponSanitizeShadowNode,V,null),gd(V,D),md(V),qr(V.content)&&xo(V.content),N(V)===Mt.element){const re=M(V);qr(re)&&(is(re),xo(re))}Rt(H.afterSanitizeShadowDOM,D,null)},is=function(D){const V=[{node:D,shadow:null}];for(;V.length>0;){const Z=V.pop();if(Z.shadow){xo(Z.shadow);continue}const re=Z.node,Se=N(re)===Mt.element,Ze=x(re);if(Ze)for(let Re=Ze.length-1;Re>=0;--Re)V.push({node:Ze[Re],shadow:null});if(Se){const Re=I?I(re):null;if(typeof Re=="string"&&et(Re)==="template"){const Et=re.content;qr(Et)&&V.push({node:Et,shadow:null})}}if(Se){const Re=M(re);qr(Re)&&V.push({node:null,shadow:Re},{node:Re,shadow:null})}}};return t.sanitize=function(J){let D=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},V=null,Z=null,re=null,he=null;if(St=!J,St&&(J=""),typeof J!="string"&&!Sn(J)&&(J=fu(J),typeof J!="string"))throw ur("dirty is not a string, aborting");if(!t.isSupported)return J;Ke?(me=Pe,ge=q):ss(D),(H.uponSanitizeElement.length>0||H.uponSanitizeAttribute.length>0)&&(me=Ot(me)),H.uponSanitizeAttribute.length>0&&(ge=Ot(ge)),t.removed=[];const Se=He&&typeof J!="string"&&Sn(J);if(Se){rb(J);const Et=w(J);if(typeof Et=="string"){const Tt=et(Et);if(!me[Tt]||$e[Tt])throw mo(J),ur("root node is forbidden and cannot be sanitized in-place")}if(vo(J))throw mo(J),ur("root node is clobbered and cannot be sanitized in-place");try{is(J)}catch(Tt){throw mo(J),Tt}}else if(Sn(J))V=cd(""),Z=V.ownerDocument.importNode(J,!0),Z.nodeType===Mt.element&&Z.nodeName==="BODY"||Z.nodeName==="HTML"?V=Z:V.appendChild(Z),is(Z);else{if(!de&&!Ee&&!Me&&J.indexOf("<")===-1)return y&&ie?U(J):J;if(V=cd(J),!V)return de?null:ie?E:""}V&&le&&cr(V.firstChild);const Ze=Se?J:V;try{const Et=dd(Ze);for(;re=Et.nextNode();)gd(re,Ze),md(re),qr(re.content)&&xo(re.content)}catch(Et){throw Se&&(mo(J),dr(t.removed,Tt=>{Tt.element&&bo(Tt.element)})),Et}if(Se)return dr(t.removed,Et=>{Et.element&&bo(Et.element)}),Ee&&ls(J),J;if(de){if(Ee&&ls(V),ue)for(he=X.call(V.ownerDocument);V.firstChild;)he.appendChild(V.firstChild);else he=V;return(ge.shadowroot||ge.shadowrootmode)&&(he=Y.call(n,he,!0)),he}let Re=Me?V.outerHTML:V.innerHTML;return Me&&me["!doctype"]&&V.ownerDocument&&V.ownerDocument.doctype&&V.ownerDocument.doctype.name&>(Cu,V.ownerDocument.doctype.name)&&(Re=" +`+Re),Ee&&(Re=yo(Re)),y&&ie?U(Re):Re},t.setConfig=function(){let J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ss(J),Ke=!0,Pe=me,q=ge},t.clearConfig=function(){Xr=null,Ke=!1,Pe=null,q=null,y=O,E=""},t.isValidAttribute=function(J,D,V){Xr||ss({});const Z=et(J),re=et(D);return hd(Z,re,V)},t.addHook=function(J,D){typeof D=="function"&&wt(H,J)&&Jr(H[J],D)},t.removeHook=function(J,D){if(wt(H,J)){if(D!==void 0){const V=au(H[J],D);return V===-1?void 0:su(H[J],V,1)[0]}return Ns(H[J])}},t.removeHooks=function(J){wt(H,J)&&(H[J]=[])},t.removeAllHooks=function(){H=js()},t}var Uo=Bs();const Mu=()=>{const e=()=>{const n=window.G7Core?.state?.get?.();return n&&(n.preferredCurrency||n.defaultCurrency)||""},[t,r]=C.useState(e);return C.useEffect(()=>{const n=window.G7Core?.state?.subscribe;if(r(e()),typeof n!="function")return;const o=n(a=>{r(a&&(a.preferredCurrency||a.defaultCurrency)||"")});return typeof o=="function"?o:void 0},[]),t},Iu=(e,t=!1)=>{window.G7Core?.dispatch?.({handler:"navigate",params:t?{path:e,mergeQuery:!0,query:{}}:{path:e}})},Du=e=>{const t=Math.round(e*2)/2;return[1,2,3,4,5].map(r=>t>=r?"full":t>=r-.5?"half":"empty")},Ws=({product:e,onClick:t,shopBase:r="/shop",preserveListQuery:n=!1,className:o="",id:a,editorAttrs:s})=>{const l=Mu(),f=v=>{const T=`multi_currency_${v}`,I=e[T];if(I&&I[l])return I[l].formatted;const S=`${v}_formatted`;return e[S]},h=e.name_localized??(typeof e.name=="string"?e.name:"")??"",c=f("selling_price"),i=f("list_price"),u=e.discount_rate&&e.discount_rate>0,g=e.sales_status&&e.sales_status!=="on_sale",p=e.labels??[],m=v=>Uo.sanitize(v,{ALLOWED_TAGS:["mark"],ALLOWED_ATTR:[]}),x=e.name_highlighted,k=e.description_highlighted??e.short_description,M=()=>{if(t)t(e.id);else{const v=r==="/"?"":r,T=e.product_code??e.id;Iu(`${v}/products/${T}`,n)}};return d.jsxs(R,{onClick:M,className:`block w-full text-left group bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden hover:shadow-lg transition-shadow cursor-pointer ${o}`,id:a,...s,children:[d.jsxs(j,{className:"relative aspect-square overflow-hidden bg-gray-100 dark:bg-gray-700",children:[d.jsx(jt,{src:e.thumbnail_url,alt:h,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-200",loading:"lazy"}),g&&d.jsx(j,{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:d.jsx(te,{className:`text-lg font-bold ${e.sales_status==="sold_out"?"text-red-300":e.sales_status==="suspended"?"text-amber-300":"text-blue-300"}`,style:{textShadow:"0 1px 4px rgba(0,0,0,0.6)"},children:e.sales_status_label??e.sales_status})}),u&&e.sales_status!=="sold_out"&&e.sales_status!=="suspended"&&d.jsxs(te,{className:"absolute top-2 left-2 px-2 py-1 bg-red-500 text-white text-xs font-bold rounded",children:[e.discount_rate,"%"]}),p.length>0&&d.jsx(j,{className:"absolute bottom-2 right-2 flex gap-1 flex-wrap justify-end",children:p.map((v,T)=>d.jsx(te,{className:"text-xs text-white font-medium px-1.5 py-0.5 rounded",style:{backgroundColor:v.color||"#6b7280"},children:v.name},T))})]}),d.jsxs(j,{className:"p-4",children:[d.jsxs(j,{className:"flex items-center gap-1.5 flex-wrap",children:[e.primary_category&&d.jsx(te,{className:"inline-block text-xs font-medium text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30 px-2 py-0.5 rounded",children:e.primary_category}),e.brand_name&&d.jsx(te,{className:"text-xs text-gray-500 dark:text-gray-400",children:e.brand_name})]}),x?d.jsx(j,{className:"mt-1 font-medium text-gray-900 dark:text-white line-clamp-1 [&_mark]:bg-yellow-200 [&_mark]:dark:bg-yellow-500/40 [&_mark]:px-0.5 [&_mark]:rounded",dangerouslySetInnerHTML:{__html:m(x)}}):d.jsx(Tn,{className:"mt-1 font-medium text-gray-900 dark:text-white line-clamp-1",children:h}),k&&d.jsx(j,{className:"mt-1 text-sm text-gray-600 dark:text-gray-400 line-clamp-2 [&_mark]:bg-yellow-200 [&_mark]:dark:bg-yellow-500/40 [&_mark]:px-0.5 [&_mark]:rounded",dangerouslySetInnerHTML:{__html:m(k)}}),d.jsxs(j,{className:"mt-1.5 flex items-center gap-1",children:[Du(e.rating_avg??0).map((v,T)=>d.jsxs(te,{className:`text-xs ${v==="empty"?"text-gray-300 dark:text-gray-600":"text-yellow-400"}`,children:[v==="full"&&d.jsx("i",{className:"fa-solid fa-star"}),v==="half"&&d.jsx("i",{className:"fa-solid fa-star-half-stroke"}),v==="empty"&&d.jsx("i",{className:"fa-regular fa-star"})]},T)),d.jsx(te,{className:"text-xs text-gray-600 dark:text-gray-400 ml-0.5",children:(e.rating_avg??0).toFixed(1)}),d.jsxs(te,{className:"text-xs text-gray-400 dark:text-gray-500",children:["(",e.review_count??0,")"]})]}),d.jsxs(j,{className:"mt-2 flex items-baseline gap-2",children:[d.jsx(te,{className:"font-bold text-gray-900 dark:text-white",children:c}),i&&u&&d.jsx(te,{className:"text-sm text-gray-500 dark:text-gray-400 line-through",children:i})]})]})]})},Pu=Object.freeze(Object.defineProperty({__proto__:null,default:Ws},Symbol.toStringTag,{value:"Module"})),Lu={ALLOWED_TAGS:["svg","g","defs","title","desc","rect","circle","ellipse","line","polyline","polygon","path","text","tspan","linearGradient","radialGradient","stop","clipPath"],ALLOWED_ATTR:["xmlns","width","height","viewBox","role","aria-label","aria-hidden","fill","fill-opacity","fill-rule","stroke","stroke-width","stroke-linecap","stroke-linejoin","opacity","transform","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","d","points","width","height","text-anchor","dominant-baseline","font-family","font-size","font-weight","offset","stop-color","stop-opacity","gradientUnits","id","clip-path"],FORBID_TAGS:["script","foreignObject","image","use","a","style"],FORBID_ATTR:["onload","onerror","onclick","onmouseover","onfocus","onblur","href","xlink:href"]},zo=({brandMark:e,size:t=32,className:r="",id:n,editorAttrs:o})=>{const a=e?.svg,s=e?.text,l=C.useMemo(()=>!a||a.trim()===""?"":Uo.sanitize(a,Lu),[a]),f={width:`${t}px`,height:`${t}px`,flex:`0 0 ${t}px`};if(l)return d.jsx(j,{id:n,"aria-hidden":"true",className:`inline-flex items-center justify-center ${r}`.trim(),style:f,dangerouslySetInnerHTML:{__html:l},...o});if(s&&s.trim()!==""){const h=e?.class??"bg-gray-500 text-white";return d.jsx(te,{id:n,"aria-hidden":"true",className:`inline-flex items-center justify-center rounded-lg text-xs font-bold ${h} ${r}`.trim(),style:f,...o,children:s})}return null},$u=Object.freeze(Object.defineProperty({__proto__:null,BrandMark:zo,default:zo},Symbol.toStringTag,{value:"Module"})),Vs="carousel",rn="controller",Fu="navigation",Uu="no-scroll",Ho="portal",zu="root",Ks="toolbar",Hu="counter",nn="fullscreen",Ys="slideshow",on="thumbnails",Xs="zoom",Mr="loading",Go="playing",an="error",sn="complete",Gu="placeholder",ln=e=>`active-slide-${e}`,ju=ln(Mr),Bu=ln(Go),Wu=ln(an),Vu=ln(sn),qs="fullsize",Ir="flex_center",Ku="no_scroll",Zs="no_scroll_padding",jo="slide",Qs="slide_wrapper",Yu="slide_wrapper_interactive",nr="prev",or="next",Bo="swipe",Dr="close",Js="onPointerDown",Rs="onPointerMove",el="onPointerUp",tl="onPointerLeave",rl="onPointerCancel",Wo="onKeyDown",Xu="onKeyUp",Vo="onWheel",qu="Escape",Zu="ArrowLeft",Qu="ArrowRight",Ju="button",In="icon",nl="contain",ol="cover",al="Unknown action type",sl="yarl__";function ht(...e){return[...e].filter(Boolean).join(" ")}function ye(e){return`${sl}${e}`}function Xe(e){return`--${sl}${e}`}function fr(e,t){return`${e}${t?`_${t}`:""}`}function gr(e){return t=>fr(e,t)}function hr(e,t){var r;return(r=e?.[t])!==null&&r!==void 0?r:t}function ll(e,t,r){return hr(e,"{index} of {total}").replace(/\{index}/g,`${qo(r,t.length)+1}`).replace(/\{total}/g,`${t.length}`)}function Pr(...e){return()=>{e.forEach(t=>{t()})}}function $t(e,t,r){return()=>{const n=A.useContext(r);if(!n)throw new Error(`${e} must be used within a ${t}.Provider`);return n}}function Ko(){return typeof window<"u"}function Yo(e,t=0){const r=10**t;return Math.round((e+Number.EPSILON)*r)/r}function pr(e){return e.type===void 0||e.type==="image"}function Xo(e,t){return e.imageFit===ol||e.imageFit!==nl&&t===ol}function Dn(e){return typeof e=="string"?Number.parseInt(e,10):e}function Pn(e){if(typeof e=="number")return{pixel:e};if(typeof e=="string"){const t=Dn(e);return e.endsWith("%")?{percent:t}:{pixel:t}}return{pixel:0}}function Ru(e,t){const r=Pn(t),n=r.percent!==void 0?e.width/100*r.percent:r.pixel;return{width:Math.max(e.width-2*n,0),height:Math.max(e.height-2*n,0)}}function ef(){return(Ko()?window?.devicePixelRatio:void 0)||1}function qo(e,t){return t>0?(e%t+t)%t:0}function Zo(e){return e.length>0}function Qo(e,t){return e[qo(t,e.length)]}function Jo(e,t){return Zo(e)?Qo(e,t):void 0}function il(e){return pr(e)?e.src:void 0}function Ln(e,t,r){if(!r)return e;const{buttons:n,...o}=e,a=n.findIndex(l=>l===t),s=A.isValidElement(r)?A.cloneElement(r,{key:t},null):r;if(a>=0){const l=[...n];return l.splice(a,1,s),{buttons:l,...o}}return{buttons:[s,...n],...o}}function cl(e,t,r=0){return Math.min(e.preload,Math.max(e.finite?t.length-1:Math.floor(t.length/2),r))}const tf=Number(A.version.split(".")[0])>=19;function rf(e){return{inert:tf?e:e?"":void 0}}function nf(e){e.scrollTop}const Ro={open:!1,close:()=>{},index:0,slides:[],render:{},plugins:[],toolbar:{buttons:[Dr]},labels:{},animation:{fade:250,swipe:500,easing:{fade:"ease",swipe:"ease-out",navigation:"ease-in-out"}},carousel:{finite:!1,preload:2,padding:"16px",spacing:"30%",imageFit:nl,imageProps:{}},controller:{ref:null,focus:!0,aria:!1,touchAction:"none",closeOnPullUp:!1,closeOnPullDown:!1,closeOnBackdropClick:!1,preventDefaultWheelX:!0,preventDefaultWheelY:!1,disableSwipeNavigation:!1},portal:{},noScroll:{disabled:!1},on:{},styles:{},className:""};function Ft(e,t){return{name:e,component:t}}function it(e,t){return{module:e,children:t}}function dl(e,t,r){return e.module.name===t?r(e):e.children?[it(e.module,e.children.flatMap(n=>{var o;return(o=dl(n,t,r))!==null&&o!==void 0?o:[]}))]:[e]}function Lr(e,t,r){return e.flatMap(n=>{var o;return(o=dl(n,t,r))!==null&&o!==void 0?o:[]})}function of(e,t=[],r=[]){let n=e;const o=g=>{const p=[...n];for(;p.length>0;){const m=p.pop();if(m?.module.name===g)return!0;m?.children&&p.push(...m.children)}return!1},a=(g,p)=>{if(g===""){n=[it(p,n)];return}n=Lr(n,g,m=>[it(p,[m])])},s=(g,p)=>{n=Lr(n,g,m=>[it(m.module,[it(p,m.children)])])},l=(g,p,m)=>{n=Lr(n,g,x=>{var k;return[it(x.module,[...m?[it(p)]:[],...(k=x.children)!==null&&k!==void 0?k:[],...m?[]:[it(p)]])]})},f=(g,p,m)=>{n=Lr(n,g,x=>[...m?[it(p)]:[],x,...m?[]:[it(p)]])},h=g=>{s(rn,g)},c=(g,p)=>{n=Lr(n,g,m=>[it(p,m.children)])},i=g=>{n=Lr(n,g,p=>p.children)},u=g=>{r.push(g)};return t.forEach(g=>{g({contains:o,addParent:a,append:s,addChild:l,addSibling:f,addModule:h,replace:c,remove:i,augment:u})}),{config:n,augmentation:g=>r.reduce((p,m)=>m(p),g)}}const ul=A.createContext(null),ea=$t("useA11yContext","A11yContext",ul);function af({children:e}){const[t,r]=A.useState(!1),[n,o]=A.useState(!1),a=A.useMemo(()=>({focusWithin:t,trackFocusWithin:(l,f)=>{const h=c=>i=>{var u;i.currentTarget.contains(i.relatedTarget)||r(c),(u=c?l:f)===null||u===void 0||u(i)};return{onFocus:h(!0),onBlur:h(!1)}},autoPlaying:n,setAutoPlaying:o}),[t,n]);return A.createElement(ul.Provider,{value:a},e)}const fl=A.createContext(null),$r=$t("useDocument","DocumentContext",fl);function sf({nodeRef:e,children:t}){const r=A.useMemo(()=>{const n=a=>{var s;return((s=a||e.current)===null||s===void 0?void 0:s.ownerDocument)||document};return{getOwnerDocument:n,getOwnerWindow:a=>{var s;return((s=n(a))===null||s===void 0?void 0:s.defaultView)||window}}},[e]);return A.createElement(fl.Provider,{value:r},t)}const gl=A.createContext(null),Fr=$t("useEvents","EventsContext",gl);function lf({children:e}){const[t]=A.useState({});A.useEffect(()=>()=>{Object.keys(t).forEach(n=>delete t[n])},[t]);const r=A.useMemo(()=>{const n=(s,l)=>{var f;(f=t[s])===null||f===void 0||f.splice(0,t[s].length,...t[s].filter(h=>h!==l))};return{publish:(...[s,l])=>{var f;(f=t[s])===null||f===void 0||f.forEach(h=>h(l))},subscribe:(s,l)=>(t[s]||(t[s]=[]),t[s].push(l),()=>n(s,l)),unsubscribe:n}},[t]);return A.createElement(gl.Provider,{value:r},e)}const hl=A.createContext(null),ct=$t("useLightboxProps","LightboxPropsContext",hl);function pl({children:e,...t}){return A.createElement(hl.Provider,{value:t},e)}const ml=A.createContext(null),Ut=$t("useLightboxState","LightboxStateContext",ml),bl=A.createContext(null),cf=$t("useLightboxDispatch","LightboxDispatchContext",bl);function df(e,t){switch(t.type){case"swipe":{const{slides:r}=e,n=t?.increment||0,o=e.globalIndex+n,a=qo(o,r.length),s=Jo(r,a),l=n||t.duration!==void 0?{increment:n,duration:t.duration,easing:t.easing}:void 0;return{slides:r,currentIndex:a,globalIndex:o,currentSlide:s,animation:l}}case"update":return t.slides!==e.slides||t.index!==e.currentIndex?{slides:t.slides,currentIndex:t.index,globalIndex:t.index,currentSlide:Jo(t.slides,t.index)}:e;default:throw new Error(al)}}function uf({slides:e,index:t,children:r}){const[n,o]=A.useReducer(df,{slides:e,currentIndex:t,globalIndex:t,currentSlide:Jo(e,t)});A.useEffect(()=>{o({type:"update",slides:e,index:t})},[e,t]);const a=A.useMemo(()=>({...n,state:n,dispatch:o}),[n,o]);return A.createElement(bl.Provider,{value:o},A.createElement(ml.Provider,{value:a},r))}const yl=A.createContext(null),cn=$t("useTimeouts","TimeoutsContext",yl);function ff({children:e}){const[t]=A.useState([]);A.useEffect(()=>()=>{t.forEach(n=>window.clearTimeout(n)),t.splice(0,t.length)},[t]);const r=A.useMemo(()=>{const n=s=>{t.splice(0,t.length,...t.filter(l=>l!==s))};return{setTimeout:(s,l)=>{const f=window.setTimeout(()=>{n(f),s()},l);return t.push(f),f},clearTimeout:s=>{s!==void 0&&(n(s),window.clearTimeout(s))}}},[t]);return A.createElement(yl.Provider,{value:r},e)}const Ur=A.forwardRef(function({label:t,className:r,icon:n,renderIcon:o,onClick:a,style:s,...l},f){const{styles:h,labels:c}=ct(),i=hr(c,t);return A.createElement("button",{ref:f,type:"button",title:i,"aria-label":i,className:ht(ye(Ju),r),onClick:a,style:{...s,...h.button},...l},o?o():A.createElement(n,{className:ye(In),style:h.icon}))});function vl(e,t){const r=n=>A.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":"true",focusable:"false",...n},t);return r.displayName=e,r}function xt(e,t){return vl(e,A.createElement("g",{fill:"currentColor"},A.createElement("path",{d:"M0 0h24v24H0z",fill:"none"}),t))}function gf(e,t){return vl(e,A.createElement(A.Fragment,null,A.createElement("defs",null,A.createElement("mask",{id:"strike"},A.createElement("path",{d:"M0 0h24v24H0z",fill:"white"}),A.createElement("path",{d:"M0 0L24 24",stroke:"black",strokeWidth:4}))),A.createElement("path",{d:"M0.70707 2.121320L21.878680 23.292883",stroke:"currentColor",strokeWidth:2}),A.createElement("g",{fill:"currentColor",mask:"url(#strike)"},A.createElement("path",{d:"M0 0h24v24H0z",fill:"none"}),t)))}const hf=xt("Close",A.createElement("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})),pf=xt("Previous",A.createElement("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})),mf=xt("Next",A.createElement("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})),bf=xt("Loading",A.createElement(A.Fragment,null,Array.from({length:8}).map((e,t,r)=>A.createElement("line",{key:t,x1:"12",y1:"6.5",x2:"12",y2:"1.8",strokeLinecap:"round",strokeWidth:"2.6",stroke:"currentColor",strokeOpacity:1/r.length*(t+1),transform:`rotate(${360/r.length*t}, 12, 12)`})))),yf=xt("Error",A.createElement("path",{d:"M21.9,21.9l-8.49-8.49l0,0L3.59,3.59l0,0L2.1,2.1L0.69,3.51L3,5.83V19c0,1.1,0.9,2,2,2h13.17l2.31,2.31L21.9,21.9z M5,18 l3.5-4.5l2.5,3.01L12.17,15l3,3H5z M21,18.17L5.83,3H19c1.1,0,2,0.9,2,2V18.17z"})),Vt=Ko()?A.useLayoutEffect:A.useEffect;function ta(){const[e,t]=A.useState(!1);return A.useEffect(()=>{var r,n;const o=(r=window.matchMedia)===null||r===void 0?void 0:r.call(window,"(prefers-reduced-motion: reduce)");t(o?.matches);const a=s=>t(s.matches);return(n=o?.addEventListener)===null||n===void 0||n.call(o,"change",a),()=>{var s;return(s=o?.removeEventListener)===null||s===void 0?void 0:s.call(o,"change",a)}},[]),e}function vf(e){let t=0,r=0,n=0;const a=window.getComputedStyle(e).transform.match(/matrix.*\((.+)\)/);if(a){const s=a[1].split(",").map(Dn);s.length===6?(t=s[4],r=s[5]):s.length===16&&(t=s[12],r=s[13],n=s[14])}return{x:t,y:r,z:n}}function ra(e,t){const r=A.useRef(void 0),n=A.useRef(void 0),o=ta();return Vt(()=>{var a,s,l;if(e.current&&r.current!==void 0&&!o){const{keyframes:f,duration:h,easing:c,onfinish:i}=t(r.current,e.current.getBoundingClientRect(),vf(e.current))||{};if(f&&h){(a=n.current)===null||a===void 0||a.cancel(),n.current=void 0;try{n.current=(l=(s=e.current).animate)===null||l===void 0?void 0:l.call(s,f,{duration:h,easing:c})}catch(u){console.error(u)}n.current&&(n.current.onfinish=()=>{n.current=void 0,i?.()})}}r.current=void 0}),{prepareAnimation:a=>{r.current=a},isAnimationPlaying:()=>{var a;return((a=n.current)===null||a===void 0?void 0:a.playState)==="running"}}}function wl(){const e=A.useRef(null),t=A.useRef(void 0),[r,n]=A.useState();return{setContainerRef:A.useCallback(a=>{e.current=a,t.current&&(t.current.disconnect(),t.current=void 0);const s=()=>{if(a){const l=window.getComputedStyle(a),f=h=>parseFloat(h)||0;n({width:Math.round(a.clientWidth-f(l.paddingLeft)-f(l.paddingRight)),height:Math.round(a.clientHeight-f(l.paddingTop)-f(l.paddingBottom))})}else n(void 0)};s(),a&&typeof ResizeObserver<"u"&&(t.current=new ResizeObserver(s),t.current.observe(a))},[]),containerRef:e,containerRect:r}}function $n(){const e=A.useRef(void 0),{setTimeout:t,clearTimeout:r}=cn();return A.useCallback((n,o)=>{r(e.current),e.current=t(n,o>0?o:0)},[t,r])}function Le(e){const t=A.useRef(e);return Vt(()=>{t.current=e}),A.useCallback((...r)=>{var n;return(n=t.current)===null||n===void 0?void 0:n.call(t,...r)},[])}function xl(e,t){typeof e=="function"?e(t):e&&(e.current=t)}function na(e,t){return A.useMemo(()=>e==null&&t==null?null:r=>{xl(e,r),xl(t,r)},[e,t])}function kl(e,t=!1){const r=A.useRef(!1);Vt(()=>{t&&r.current&&(r.current=!1,e())},[t,e]);const n=A.useCallback(()=>{r.current=!0},[]),o=A.useCallback(()=>{r.current=!1},[]);return{onFocus:n,onBlur:o}}function Fn(){const[e,t]=A.useState(!1);return Vt(()=>{t(window.getComputedStyle(window.document.documentElement).direction==="rtl")},[]),e}function Cl(){const[e]=A.useState({}),t=A.useCallback((o,a)=>{var s;(s=e[o])===null||s===void 0||s.forEach(l=>{a.isPropagationStopped()||l(a)})},[e]),r=A.useMemo(()=>({onPointerDown:o=>t(Js,o),onPointerMove:o=>t(Rs,o),onPointerUp:o=>t(el,o),onPointerLeave:o=>t(tl,o),onPointerCancel:o=>t(rl,o),onKeyDown:o=>t(Wo,o),onKeyUp:o=>t(Xu,o),onWheel:o=>t(Vo,o)}),[t]),n=A.useCallback((o,a)=>(e[o]||(e[o]=[]),e[o].unshift(a),()=>{const s=e[o];s&&s.splice(0,s.length,...s.filter(l=>l!==a))}),[e]);return{registerSensors:r,subscribeSensors:n}}function _l(e,t){const r=A.useRef(0),n=$n(),o=Le((...a)=>{r.current=Date.now(),e(a)});return A.useCallback((...a)=>{n(()=>{o(a)},t-(Date.now()-r.current))},[t,o,n])}const oa=gr("slide"),aa=gr("slide_image");function mr({slide:e,offset:t,render:r,rect:n,imageFit:o,imageProps:a,onClick:s,onLoad:l,onError:f,style:h}){var c,i,u,g,p,m,x,k;const[M,v]=A.useState(Mr),{publish:T}=Fr(),{setTimeout:I}=cn(),S=A.useRef(null);A.useEffect(()=>{t===0&&T(ln(M))},[t,M,T]);const N=Le(B=>{("decode"in B?B.decode():Promise.resolve()).catch(()=>{}).then(()=>{B.parentNode&&(v(sn),I(()=>{l?.(B)},0))})}),w=A.useCallback(B=>{S.current=B,B?.complete&&N(B)},[N]),y=A.useCallback(B=>{N(B.currentTarget)},[N]),E=Le(()=>{v(an),f?.()}),O=Xo(e,o),$=(B,Y)=>Number.isFinite(B)?B:Y,P=$(Math.max(...((i=(c=e.srcSet)===null||c===void 0?void 0:c.map(B=>B.width))!==null&&i!==void 0?i:[]).concat(e.width?[e.width]:[]).filter(Boolean)),((u=S.current)===null||u===void 0?void 0:u.naturalWidth)||0),L=$(Math.max(...((p=(g=e.srcSet)===null||g===void 0?void 0:g.map(B=>B.height))!==null&&p!==void 0?p:[]).concat(e.height?[e.height]:[]).filter(Boolean)),((m=S.current)===null||m===void 0?void 0:m.naturalHeight)||0),U=P&&L?{maxWidth:`min(${P}px, 100%)`,maxHeight:`min(${L}px, 100%)`}:{maxWidth:"100%",maxHeight:"100%"},_=(x=e.srcSet)===null||x===void 0?void 0:x.sort((B,Y)=>B.width-Y.width).map(B=>`${B.src} ${B.width}w`).join(", "),b=()=>n&&!O&&e.width&&e.height?n.height/e.height*e.width:Number.MAX_VALUE,z=_&&n&&Ko()?`${Math.round(Math.min(b(),n.width))}px`:void 0,{style:F,className:G,...X}=a||{};return A.createElement(A.Fragment,null,A.createElement("img",{ref:w,onLoad:y,onError:E,onClick:s,draggable:!1,className:ht(ye(aa()),O&&ye(aa("cover")),M!==sn&&ye(aa("loading")),G),style:{...U,...h,...F},...X,alt:(k=e.alt)!==null&&k!==void 0?k:"",sizes:z,srcSet:_,src:e.src}),M!==sn&&A.createElement("div",{className:ye(oa(Gu))},M===Mr&&(r?.iconLoading?r.iconLoading():A.createElement(bf,{className:ht(ye(In),ye(oa(Mr)))})),M===an&&(r?.iconError?r.iconError():A.createElement(yf,{className:ht(ye(In),ye(oa(an)))}))))}const wf=A.forwardRef(function({className:t,children:r,onFocus:n,onBlur:o,...a},s){const l=A.useRef(null),{trackFocusWithin:f}=ea();return A.createElement(sf,{nodeRef:l},A.createElement("div",{ref:na(s,l),className:ht(ye("root"),t),...f(n,o),...a},r))});var pt;(function(e){e[e.NONE=0]="NONE",e[e.SWIPE=1]="SWIPE",e[e.PULL=2]="PULL",e[e.ANIMATION=3]="ANIMATION"})(pt||(pt={}));function Sl(e,t,r,n,o){A.useEffect(()=>o?()=>{}:Pr(e(Js,t),e(Rs,r),e(el,n),e(tl,n),e(rl,n)),[e,t,r,n,o])}var Kt;(function(e){e[e.NONE=0]="NONE",e[e.SWIPE=1]="SWIPE",e[e.PULL=2]="PULL"})(Kt||(Kt={}));const sa=30;function xf({disableSwipeNavigation:e,closeOnBackdropClick:t},r,n,o,a,s,l,f,h,c,i,u,g,p,m,x){const k=A.useRef(0),M=A.useRef([]),v=A.useRef(void 0),T=A.useRef(0),I=A.useRef(Kt.NONE),S=A.useCallback(P=>{v.current===P.pointerId&&(v.current=void 0,I.current=Kt.NONE);const L=M.current;L.splice(0,L.length,...L.filter(U=>U.pointerId!==P.pointerId))},[]),N=A.useCallback(P=>{S(P),P.persist(),M.current.push(P)},[S]),w=A.useCallback(P=>M.current.find(({pointerId:L})=>P.pointerId===L),[]),y=Le(P=>{N(P)}),E=(P,L)=>i&&P>L||c&&P<-L,O=Le(P=>{const L=w(P);if(L)if(v.current===P.pointerId){const U=Date.now()-T.current,_=k.current;I.current===Kt.SWIPE?Math.abs(_)>.3*o||Math.abs(_)>5&&U{const L=w(P);if(L){const U=v.current===P.pointerId;if(P.buttons===0){U&&k.current!==0?O(P):S(L);return}const _=P.clientX-L.clientX,b=P.clientY-L.clientY;if(v.current===void 0){const z=F=>{N(P),v.current=P.pointerId,T.current=Date.now(),I.current=F};Math.abs(_)>Math.abs(b)&&Math.abs(_)>sa&&n(_)?e||(z(Kt.SWIPE),s()):Math.abs(b)>Math.abs(_)&&E(b,sa)&&(z(Kt.PULL),u())}else U&&(I.current===Kt.SWIPE?(k.current=_,l(_)):I.current===Kt.PULL&&(k.current=b,g(b)))}});Sl(r,y,$,O)}function kf({preventDefaultWheelX:e,preventDefaultWheelY:t}){const r=A.useRef(null),n=Le(o=>{const a=Math.abs(o.deltaX)>Math.abs(o.deltaY);(a&&e||!a&&t||o.ctrlKey)&&o.preventDefault()});return A.useCallback(o=>{var a;o?o.addEventListener("wheel",n,{passive:!1}):(a=r.current)===null||a===void 0||a.removeEventListener("wheel",n),r.current=o},[n])}function Cf(e,t,r,n,o,a,s,l,f){const h=A.useRef(0),c=A.useRef(0),i=A.useRef(void 0),u=A.useRef(void 0),g=A.useRef(0),p=A.useRef(void 0),m=A.useRef(0),{setTimeout:x,clearTimeout:k}=cn(),M=A.useCallback(()=>{i.current&&(k(i.current),i.current=void 0)},[k]),v=A.useCallback(()=>{u.current&&(k(u.current),u.current=void 0)},[k]),T=Le(()=>{e!==pt.SWIPE&&(h.current=0,m.current=0,M(),v())});A.useEffect(T,[e,T]);const I=Le(N=>{u.current=void 0,h.current===N&&f(h.current)}),S=Le(N=>{if(N.ctrlKey||Math.abs(N.deltaY)>Math.abs(N.deltaX))return;const w=y=>{g.current=y,k(p.current),p.current=y>0?x(()=>{g.current=0,p.current=void 0},300):void 0};if(e===pt.NONE){if(Math.abs(N.deltaX)<=1.2*Math.abs(g.current)){w(N.deltaX);return}if(!r(-N.deltaX))return;if(c.current+=N.deltaX,M(),Math.abs(c.current)>30)c.current=0,w(0),m.current=Date.now(),a();else{const y=c.current;i.current=x(()=>{i.current=void 0,y===c.current&&(c.current=0)},o)}}else if(e===pt.SWIPE){let y=h.current-N.deltaX;if(y=Math.min(Math.abs(y),n)*Math.sign(y),h.current=y,s(y),v(),Math.abs(y)>.2*n){w(N.deltaX),l(y,Date.now()-m.current);return}u.current=x(()=>I(y),2*o)}else w(N.deltaX)});A.useEffect(()=>t(Vo,S),[t,S])}const El=gr("container"),Tl=A.createContext(null),Yt=$t("useController","ControllerContext",Tl);function _f({children:e,...t}){var r;const{carousel:n,animation:o,controller:a,on:s,styles:l,render:f}=t,{closeOnPullUp:h,closeOnPullDown:c,preventDefaultWheelX:i,preventDefaultWheelY:u}=a,[g,p]=A.useState(),m=Ut(),x=cf(),[k,M]=A.useState(pt.NONE),v=A.useRef(0),T=A.useRef(0),I=A.useRef(1),{registerSensors:S,subscribeSensors:N}=Cl(),{subscribe:w,publish:y}=Fr(),E=$n(),O=$n(),$=$n(),{containerRef:P,setContainerRef:L,containerRect:U}=wl(),_=na(kf({preventDefaultWheelX:i,preventDefaultWheelY:u}),L),b=A.useRef(null),z=na(b,void 0),{getOwnerDocument:F}=$r(),G=Fn(),X=K=>(G?-1:1)*(typeof K=="number"?K:1),B=Le(()=>{var K;return(K=P.current)===null||K===void 0?void 0:K.focus()}),Y=Le(()=>t),H=Le(()=>m),W=A.useCallback(K=>y(nr,K),[y]),Q=A.useCallback(K=>y(or,K),[y]),be=A.useCallback(()=>y(Dr),[y]),se=K=>!(n.finite&&(X(K)>0&&m.currentIndex===0||X(K)<0&&m.currentIndex===m.slides.length-1)),pe=K=>{var oe;v.current=K,(oe=P.current)===null||oe===void 0||oe.style.setProperty(Xe("swipe_offset"),`${Math.round(K)}px`)},ne=K=>{var oe,ae;T.current=K,I.current=(()=>{const Ee=c&&K>0?K:h&&K<0?-K:0;return Math.min(Math.max(Yo(1-Ee/60*(1-.5),2),.5),1)})(),(oe=P.current)===null||oe===void 0||oe.style.setProperty(Xe("pull_offset"),`${Math.round(K)}px`),(ae=P.current)===null||ae===void 0||ae.style.setProperty(Xe("pull_opacity"),`${I.current}`)},{prepareAnimation:Ae}=ra(b,(K,oe,ae)=>{if(b.current&&U)return{keyframes:[{transform:`translate(0, ${K.rect.y-oe.y+ae.y}px)`,opacity:K.opacity},{transform:"translate(0, 0)",opacity:1}],duration:K.duration,easing:o.easing.fade}}),ve=(K,oe)=>{if(h||c){ne(K);let ae=0;b.current&&(ae=o.fade*(oe?2:1),Ae({rect:b.current.getBoundingClientRect(),opacity:I.current,duration:ae})),$(()=>{ne(0),M(pt.NONE)},ae),M(pt.ANIMATION),oe||be()}},{prepareAnimation:We,isAnimationPlaying:me}=ra(b,(K,oe,ae)=>{var ce;if(b.current&&U&&(!((ce=m.animation)===null||ce===void 0)&&ce.duration)){const ke=Pn(n.spacing),Ee=(ke.percent?ke.percent*U.width/100:ke.pixel)||0;return{keyframes:[{transform:`translate(${X(m.globalIndex-K.index)*(U.width+Ee)+K.rect.x-oe.x+ae.x}px, 0)`},{transform:"translate(0, 0)"}],duration:m.animation.duration,easing:m.animation.easing}}}),Te=Le(K=>{var oe,ae;const ce=K.offset||0,ke=ce?o.swipe:(oe=o.navigation)!==null&&oe!==void 0?oe:o.swipe,Ee=!ce&&!me()?o.easing.navigation:o.easing.swipe;let{direction:Be}=K;const Me=(ae=K.count)!==null&&ae!==void 0?ae:1;let Ke=pt.ANIMATION,Pe=ke*Me;if(!Be){const le=U?.width,de=K.duration||0,ue=le?ke/le*Math.abs(ce):ke;Me!==0?(de0?nr:or):Pe=ke/2}let q=0;Be===nr?se(X(1))?q=-Me:(Ke=pt.NONE,Pe=ke):Be===or&&(se(X(-1))?q=Me:(Ke=pt.NONE,Pe=ke)),Pe=Math.round(Pe),O(()=>{pe(0),M(pt.NONE)},Pe),b.current&&We({rect:b.current.getBoundingClientRect(),index:m.globalIndex}),M(Ke),y(Bo,{type:"swipe",increment:q,duration:Pe,easing:Ee})});A.useEffect(()=>{var K,oe;!((K=m.animation)===null||K===void 0)&&K.increment&&(!((oe=m.animation)===null||oe===void 0)&&oe.duration)&&E(()=>x({type:"swipe",increment:0}),m.animation.duration)},[m.animation,x,E]);const ge=[N,se,U?.width||0,o.swipe,()=>M(pt.SWIPE),K=>pe(K),(K,oe)=>Te({offset:K,duration:oe,count:1}),K=>Te({offset:K,count:0})],Oe=[()=>{c&&M(pt.PULL)},K=>ne(K),K=>ve(K),K=>ve(K,!0)];xf(a,...ge,h,c,...Oe,be),Cf(k,...ge);const we=Le(()=>{a.focus&&F().querySelector(`.${ye(Ho)} .${ye(El())}`)&&B()});A.useEffect(we,[we]);const $e=Le(()=>{var K;(K=s.view)===null||K===void 0||K.call(s,{index:m.currentIndex})});A.useEffect($e,[m.globalIndex,$e]),A.useEffect(()=>Pr(w(nr,K=>Te({direction:nr,...K})),w(or,K=>Te({direction:or,...K})),w(Bo,K=>x(K))),[w,Te,x]);const ze=A.useMemo(()=>({prev:W,next:Q,close:be,focus:B,slideRect:U?Ru(U,n.padding):{width:0,height:0},containerRect:U||{width:0,height:0},subscribeSensors:N,containerRef:P,setCarouselRef:z,toolbarWidth:g,setToolbarWidth:p}),[W,Q,be,B,N,U,P,z,g,p,n.padding]);return A.useImperativeHandle(a.ref,()=>({prev:W,next:Q,close:be,focus:B,getLightboxProps:Y,getLightboxState:H}),[W,Q,be,B,Y,H]),A.createElement("div",{ref:_,className:ht(ye(El()),ye(Ir)),style:{...k===pt.SWIPE?{[Xe("swipe_offset")]:`${Math.round(v.current)}px`}:null,...k===pt.PULL?{[Xe("pull_offset")]:`${Math.round(T.current)}px`,[Xe("pull_opacity")]:`${I.current}`}:null,...a.touchAction!=="none"?{[Xe("controller_touch_action")]:a.touchAction}:null,...l.container},tabIndex:-1,...S},U&&A.createElement(Tl.Provider,{value:ze},e,(r=f.controls)===null||r===void 0?void 0:r.call(f)))}const Sf=Ft(rn,_f);function br(e){return fr(Vs,e)}function Al(e){return fr(jo,e)}function Ef({slide:e,offset:t}){const r=A.useRef(null),{currentIndex:n,slides:o}=Ut(),{slideRect:a,focus:s}=Yt(),{render:l,carousel:{imageFit:f,imageProps:h},on:{click:c},styles:{slide:i},labels:u}=ct(),{getOwnerDocument:g}=$r(),p=t!==0;A.useEffect(()=>{var x;p&&(!((x=r.current)===null||x===void 0)&&x.contains(g().activeElement))&&s()},[p,s,g]);const m=()=>{var x,k,M,v;let T=(x=l.slide)===null||x===void 0?void 0:x.call(l,{slide:e,offset:t,rect:a});return!T&&pr(e)&&(T=A.createElement(mr,{slide:e,offset:t,render:l,rect:a,imageFit:f,imageProps:h,onClick:p?void 0:()=>c?.({index:n})})),T?A.createElement(A.Fragment,null,(k=l.slideHeader)===null||k===void 0?void 0:k.call(l,{slide:e}),((M=l.slideContainer)!==null&&M!==void 0?M:(({children:I})=>I))({slide:e,children:T}),(v=l.slideFooter)===null||v===void 0?void 0:v.call(l,{slide:e})):null};return A.createElement("div",{ref:r,className:ht(ye(Al()),!p&&ye(Al("current")),ye(Ir)),...rf(p),style:i,role:"group","aria-roledescription":hr(u,"Slide"),"aria-label":ll(u,o,n+t)},m())}function Tf(){const e=ct().styles.slide;return A.createElement("div",{className:ye(jo),style:e})}function Af({carousel:e,labels:t}){const{slides:r,currentIndex:n,globalIndex:o}=Ut(),{setCarouselRef:a}=Yt(),{autoPlaying:s,focusWithin:l}=ea(),f=Pn(e.spacing),h=Pn(e.padding),c=cl(e,r,1),i=[];if(Zo(r))for(let u=n-c;u<=n+c;u+=1){const g=Qo(r,u),p=o-n+u,m=e.finite&&(u<0||u>r.length-1);i.push(m?{key:p}:{key:[`${p}`,il(g)].filter(Boolean).join("|"),offset:u-n,slide:g})}return A.createElement("div",{ref:a,className:ht(ye(br()),i.length>0&&ye(br("with_slides"))),style:{[`${Xe(br("slides_count"))}`]:i.length,[`${Xe(br("spacing_px"))}`]:f.pixel||0,[`${Xe(br("spacing_percent"))}`]:f.percent||0,[`${Xe(br("padding_px"))}`]:h.pixel||0,[`${Xe(br("padding_percent"))}`]:h.percent||0},role:"region","aria-live":s&&!l?"off":"polite","aria-roledescription":hr(t,"Carousel"),"aria-label":hr(t,"Photo gallery")},i.map(({key:u,slide:g,offset:p})=>g?A.createElement(Ef,{key:u,slide:g,offset:p}):A.createElement(Tf,{key:u})))}const Nf=Ft(Vs,Af);function Nl(){const{carousel:e}=ct(),{slides:t,currentIndex:r}=Ut(),n=t.length===0||e.finite&&r===0,o=t.length===0||e.finite&&r===t.length-1;return{prevDisabled:n,nextDisabled:o}}function Ol(e){var t;const r=Fn(),{publish:n}=Fr(),{animation:o}=ct(),{prevDisabled:a,nextDisabled:s}=Nl(),l=((t=o.navigation)!==null&&t!==void 0?t:o.swipe)/2,f=_l(()=>n(nr),l),h=_l(()=>n(or),l),c=Le(i=>{switch(i.key){case qu:n(Dr);break;case Zu:(r?s:a)||(r?h:f)();break;case Qu:(r?a:s)||(r?f:h)();break}});A.useEffect(()=>e(Wo,c),[e,c])}function Ml({label:e,icon:t,renderIcon:r,action:n,onClick:o,disabled:a,style:s}){return A.createElement(Ur,{label:e,icon:t,renderIcon:r,className:ye(`navigation_${n}`),disabled:a,onClick:o,style:s,...kl(Yt().focus,a)})}function Of({render:{buttonPrev:e,buttonNext:t,iconPrev:r,iconNext:n},styles:o}){const{prev:a,next:s,subscribeSensors:l}=Yt(),{prevDisabled:f,nextDisabled:h}=Nl();return Ol(l),A.createElement(A.Fragment,null,e?e():A.createElement(Ml,{label:"Previous",action:nr,icon:pf,renderIcon:r,style:o.navigationPrev,disabled:f,onClick:a}),t?t():A.createElement(Ml,{label:"Next",action:or,icon:mf,renderIcon:n,style:o.navigationNext,disabled:h,onClick:s}))}const Mf=Ft(Fu,Of),Il=ye(Ku),If=ye(Zs);function Df(e){return"style"in e}function Dl(e,t,r){const n=window.getComputedStyle(e),o=r?"padding-left":"padding-right",a=r?n.paddingLeft:n.paddingRight,s=e.style.getPropertyValue(o);return e.style.setProperty(o,`${(Dn(a)||0)+t}px`),()=>{s?e.style.setProperty(o,s):e.style.removeProperty(o)}}function Pf({noScroll:{disabled:e},children:t}){const r=Fn(),{getOwnerDocument:n,getOwnerWindow:o}=$r();return A.useEffect(()=>{if(e)return()=>{};const a=[],s=o(),{body:l,documentElement:f}=n(),h=Math.round(s.innerWidth-f.clientWidth);if(h>0){a.push(Dl(l,h,r));const c=l.getElementsByTagName("*");for(let i=0;i{l.classList.remove(Il),a.forEach(c=>c())}},[r,e,n,o]),A.createElement(A.Fragment,null,t)}const Lf=Ft(Uu,Pf);function Pl(e){return fr(Ho,e)}function Ll(e,t,r){const n=e.getAttribute(t);return e.setAttribute(t,r),()=>{n?e.setAttribute(t,n):e.removeAttribute(t)}}function $f({children:e,animation:t,styles:r,className:n,on:o,portal:a,close:s,labels:l}){const[f,h]=A.useState(!1),[c,i]=A.useState(!1),u=A.useRef([]),g=A.useRef(null),{setTimeout:p}=cn(),{subscribe:m}=Fr(),k=ta()?0:t.fade;A.useEffect(()=>(h(!0),()=>{h(!1),i(!1)}),[]);const M=Le(()=>{u.current.forEach(S=>S()),u.current=[]}),v=Le(()=>{var S;i(!1),M(),(S=o.exiting)===null||S===void 0||S.call(o),p(()=>{var N;(N=o.exited)===null||N===void 0||N.call(o),s()},k)});A.useEffect(()=>m(Dr,v),[m,v]);const T=Le(S=>{var N,w,y;nf(S),i(!0),(N=o.entering)===null||N===void 0||N.call(o);const E=(y=(w=S.parentNode)===null||w===void 0?void 0:w.children)!==null&&y!==void 0?y:[];for(let O=0;O{var O,$;($=(O=g.current)===null||O===void 0?void 0:O.focus)===null||$===void 0||$.call(O)}),p(()=>{var O;(O=o.entered)===null||O===void 0||O.call(o)},k)}),I=A.useCallback(S=>{S?T(S):M()},[T,M]);return f?tr.createPortal(A.createElement(wf,{ref:I,className:ht(n,ye(Pl()),ye(Zs),c&&ye(Pl("open"))),"aria-modal":!0,role:"dialog","aria-label":hr(l,"Lightbox"),style:{...t.fade!==Ro.animation.fade?{[Xe("fade_animation_duration")]:`${k}ms`}:null,...t.easing.fade!==Ro.animation.easing.fade?{[Xe("fade_animation_timing_function")]:t.easing.fade}:null,...r.root},onFocus:S=>{g.current||(g.current=S.relatedTarget)}},e),a.root||document.body):null}const Ff=Ft(Ho,$f);function Uf({children:e}){return A.createElement(A.Fragment,null,e)}const zf=Ft(zu,Uf);function Hf(e){return fr(Ks,e)}function Gf({toolbar:{buttons:e},render:{buttonClose:t,iconClose:r},styles:n}){const{close:o,setToolbarWidth:a}=Yt(),{setContainerRef:s,containerRect:l}=wl();Vt(()=>{a(l?.width)},[a,l?.width]);const f=()=>t?t():A.createElement(Ur,{key:Dr,label:"Close",icon:hf,renderIcon:r,onClick:o});return A.createElement("div",{ref:s,style:n.toolbar,className:ye(Hf())},e?.map(h=>h===Dr?f():h))}const jf=Ft(Ks,Gf);function $l(e,t){var r;return A.createElement(e.module.component,{key:e.module.name,...t},(r=e.children)===null||r===void 0?void 0:r.map(n=>$l(n,t)))}function Bf(e,t={}){const{easing:r,...n}=e,{easing:o,...a}=t;return{easing:{...r,...o},...n,...a}}function Wf({carousel:e,animation:t,render:r,toolbar:n,controller:o,noScroll:a,on:s,plugins:l,slides:f,index:h,...c}){const{animation:i,carousel:u,render:g,toolbar:p,controller:m,noScroll:x,on:k,slides:M,index:v,plugins:T,...I}=Ro,{config:S,augmentation:N}=of([it(Ff,[it(Lf,[it(Sf,[it(Nf),it(jf),it(Mf)])])])],l||T),w=N({animation:Bf(i,t),carousel:{...u,...e},render:{...g,...r},toolbar:{...p,...n},controller:{...m,...o},noScroll:{...x,...a},on:{...k,...s},...I,...c});return w.open?A.createElement(pl,{...w},A.createElement(uf,{slides:f||M,index:Dn(h||v)},A.createElement(ff,null,A.createElement(lf,null,A.createElement(af,null,$l(it(zf,S),w)))))):null}const Vf={minZoom:1,maxZoomPixelRatio:1,zoomInMultiplier:2,doubleTapDelay:300,doubleClickDelay:500,doubleClickMaxStops:2,keyboardMoveDistance:50,wheelZoomDistanceFactor:100,pinchZoomDistanceFactor:100,pinchZoomV4:!1,scrollToZoom:!1};function Kf(e){return Math.min(Math.max(e,Number.EPSILON),1)}function Fl(e){const{minZoom:t,...r}={...Vf,...e};return{minZoom:Kf(t),...r}}function Yf(e,t,r,n){const o=A.useRef(void 0),a=A.useRef(void 0),{zoom:s}=ct().animation,l=ta(),f=Le(()=>{var h,c,i;if((h=o.current)===null||h===void 0||h.cancel(),o.current=void 0,a.current&&n?.current){try{o.current=(i=(c=n.current).animate)===null||i===void 0?void 0:i.call(c,[{transform:a.current},{transform:`scale(${e}) translateX(${t}px) translateY(${r}px)`}],{duration:l?0:s??500,easing:o.current?"ease-out":"ease-in-out"})}catch(u){console.error(u)}a.current=void 0,o.current&&(o.current.onfinish=()=>{o.current=void 0})}});return Vt(f,[e,t,r,f]),A.useCallback(()=>{a.current=n?.current?window.getComputedStyle(n.current).transform:void 0},[n])}function Xf(e,t){const{on:r}=ct(),n=Le(()=>{var o;t||(o=r.zoom)===null||o===void 0||o.call(r,{zoom:e})});A.useEffect(n,[e,n])}function Un(){const{zoom:e}=ct();return Fl(e)}function qf(e,t){var r,n;let o={width:0,height:0},a={width:0,height:0};const{currentSlide:s}=Ut(),{imageFit:l}=ct().carousel,{maxZoomPixelRatio:f}=Un();if(e&&s){const c={...s,...t};if(pr(c)){const i=Xo(c,l),u=Math.max(...(((r=c.srcSet)===null||r===void 0?void 0:r.map(p=>p.width))||[]).concat(c.width?[c.width]:[])),g=Math.max(...(((n=c.srcSet)===null||n===void 0?void 0:n.map(p=>p.height))||[]).concat(c.height?[c.height]:[]));u>0&&g>0&&e.width>0&&e.height>0&&(a=i?{width:Math.round(Math.min(u,e.width/e.height*g)),height:Math.round(Math.min(g,e.height/e.width*u))}:{width:u,height:g},a={width:a.width*f,height:a.height*f},o=i?{width:Math.min(e.width,a.width,u),height:Math.min(e.height,a.height,g)}:{width:Math.round(Math.min(e.width,e.height/g*u,u)),height:Math.round(Math.min(e.height,e.width/u*g,g))})}}const h=o.width?Math.max(Yo(a.width/o.width,5),1):1;return{imageRect:o,maxZoom:h}}function Ul(e,t){return Math.hypot(e.clientX-t.clientX,e.clientY-t.clientY)}function zl(e,t,r=100,n=2){return e*Math.min(1+Math.abs(t/r),n)**Math.sign(t)}function Zf(e,t,r,n,o,a,s,l,f){const h=A.useRef([]),c=A.useRef(0),i=A.useRef(void 0),{globalIndex:u}=Ut(),{getOwnerWindow:g}=$r(),{containerRef:p,subscribeSensors:m}=Yt(),{keyboardMoveDistance:x,zoomInMultiplier:k,wheelZoomDistanceFactor:M,scrollToZoom:v,doubleTapDelay:T,doubleClickDelay:I,doubleClickMaxStops:S,pinchZoomDistanceFactor:N,pinchZoomV4:w}=Un(),y=A.useCallback(z=>{if(p.current){const{pageX:F,pageY:G}=z,{scrollX:X,scrollY:B}=g(),{left:Y,top:H,width:W,height:Q}=p.current.getBoundingClientRect();return[F-Y-X-W/2,G-H-B-Q/2]}return[]},[p,g]),E=Le(z=>{const{key:F,metaKey:G,ctrlKey:X}=z,B=G||X,Y=()=>{z.preventDefault(),z.stopPropagation()};if(e>1){const H=(W,Q)=>{Y(),l(W,Q)};F==="ArrowDown"?H(0,x):F==="ArrowUp"?H(0,-x):F==="ArrowLeft"?H(-x,0):F==="ArrowRight"&&H(x,0)}F==="+"||B&&F==="="?(Y(),o()):F==="-"||B&&F==="_"?(Y(),a()):B&&F==="0"&&(Y(),s(1))}),O=Le(z=>{if((z.ctrlKey||v)&&Math.abs(z.deltaY)>Math.abs(z.deltaX)){z.stopPropagation(),s(zl(e,-z.deltaY,M),!0,...y(z));return}e>1&&(z.stopPropagation(),v||l(z.deltaX,z.deltaY))}),$=A.useCallback(z=>{const F=h.current;F.splice(0,F.length,...F.filter(G=>G.pointerId!==z.pointerId))},[]),P=A.useCallback(z=>{$(z),z.persist(),h.current.push(z)},[$]),L=Le(z=>{var F;const G=h.current;if(z.pointerType==="mouse"&&z.buttons>1||!(!((F=f?.current)===null||F===void 0)&&F.contains(z.target)))return;e>1&&z.stopPropagation();const{timeStamp:X}=z;if(G.length===0&&X-c.current<(z.pointerType==="touch"?T:I)){c.current=0;const B=e>=1?e!==r?e*Math.max(r**(1/S),k):1:e!==t?e/Math.max(t**(-1/S),k):1;s(B,!1,...y(z))}else c.current=X;if(P(z),G.length===2){const B=Ul(G[0],G[1]);i.current={previousDistance:B,initialDistance:Math.max(B,1),initialZoom:e}}}),U=Le(z=>{const F=h.current,G=F.find(X=>X.pointerId===z.pointerId);if(F.length===2&&i.current){z.stopPropagation(),P(z);const X=Ul(F[0],F[1]),B=w?i.current.initialZoom/i.current.initialDistance*X:zl(e,X-i.current.previousDistance,N);s(B,!0,...F.map(Y=>y(Y)).reduce((Y,H)=>H.map((W,Q)=>Y[Q]+W/2))),i.current.previousDistance=X;return}e>1&&(z.stopPropagation(),G&&(F.length===1&&l((G.clientX-z.clientX)/e,(G.clientY-z.clientY)/e),P(z)))}),_=A.useCallback(z=>{const F=h.current;F.length===2&&F.find(G=>G.pointerId===z.pointerId)&&(i.current=void 0),$(z)},[$]),b=A.useCallback(()=>{const z=h.current;z.splice(0,z.length),c.current=0,i.current=void 0},[]);Sl(m,L,U,_,n),A.useEffect(b,[u,b]),A.useEffect(()=>n?()=>{}:Pr(b,m(Wo,E),m(Vo,O)),[n,m,b,E,O])}function Qf(e,t,r){const[n,o]=A.useState(1),[a,s]=A.useState(0),[l,f]=A.useState(0),h=Yf(n,a,l,r),{currentSlide:c,globalIndex:i}=Ut(),{containerRect:u,slideRect:g}=Yt(),{minZoom:p,zoomInMultiplier:m}=Un(),x=c&&pr(c)?c.src:void 0,k=!x||!r?.current;Vt(()=>{o(1),s(0),f(0)},[i,x]);const M=A.useCallback((N,w,y)=>{const E=y||n,O=a-(N||0),$=l-(w||0),P=(e.width*E-g.width)/2/E,L=(e.height*E-g.height)/2/E;s(Math.min(Math.abs(O),Math.max(P,0))*Math.sign(O)),f(Math.min(Math.abs($),Math.max(L,0))*Math.sign($))},[n,a,l,g,e.width,e.height]),v=A.useCallback((N,w,y,E)=>{const O=Yo(N+.01p?N:p:t,5);w||h(),M(y?y*(1/n-1/O):0,E?E*(1/n-1/O):0,O),o(O)},[n,p,t,M,h]),T=Le(()=>{n>1&&(n>t&&v(t,!0),M())});Vt(T,[u.width,u.height,T]);const I=A.useCallback(()=>{const N=n*m;v(n<1&&N>1?1:N)},[n,m,v]),S=A.useCallback(()=>{const N=n/m;v(n>1&&N<1?1:N)},[n,m,v]);return{zoom:n,offsetX:a,offsetY:l,disabled:k,changeOffsets:M,changeZoom:v,zoomIn:I,zoomOut:S}}const Hl=A.createContext(null),la=$t("useZoom","ZoomControllerContext",Hl);function Jf({children:e}){const[t,r]=A.useState(),{slideRect:n}=Yt(),{ref:o,minZoom:a}=Un(),{imageRect:s,maxZoom:l}=qf(n,t?.imageDimensions),{zoom:f,offsetX:h,offsetY:c,disabled:i,changeZoom:u,changeOffsets:g,zoomIn:p,zoomOut:m}=Qf(s,l,t?.zoomWrapperRef);Xf(f,i),Zf(f,a,l,i,p,m,u,g,t?.zoomWrapperRef);const x=A.useMemo(()=>({zoom:f,minZoom:a,maxZoom:l,offsetX:h,offsetY:c,disabled:i,zoomIn:p,zoomOut:m,changeZoom:u}),[f,a,l,h,c,i,p,m,u]);A.useImperativeHandle(o,()=>x,[x]);const k=A.useMemo(()=>({...x,setZoomWrapper:r}),[x,r]);return A.createElement(Hl.Provider,{value:k},e)}const Rf=xt("ZoomIn",A.createElement(A.Fragment,null,A.createElement("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"}),A.createElement("path",{d:"M12 10h-2v2H9v-2H7V9h2V7h1v2h2v1z"}))),eg=xt("ZoomOut",A.createElement("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zM7 9h5v1H7z"})),Gl=A.forwardRef(function({zoomIn:t,onLoseFocus:r},n){const o=A.useRef(!1),a=A.useRef(!1),{zoom:s,minZoom:l,maxZoom:f,zoomIn:h,zoomOut:c,disabled:i}=la(),{render:u}=ct(),g=i||(t?s>=f:s<=l);return A.useEffect(()=>{g&&o.current&&a.current&&r(),g||(o.current=!0)},[g,r]),A.createElement(Ur,{ref:n,disabled:g,label:t?"Zoom in":"Zoom out",icon:t?Rf:eg,renderIcon:t?u.iconZoomIn:u.iconZoomOut,onClick:t?h:c,onFocus:()=>{a.current=!0},onBlur:()=>{a.current=!1}})});function tg(){const e=A.useRef(null),t=A.useRef(null),{focus:r}=Yt(),n=A.useCallback(s=>{var l,f;!((l=s.current)===null||l===void 0)&&l.disabled?r():(f=s.current)===null||f===void 0||f.focus()},[r]),o=A.useCallback(()=>n(e),[n]),a=A.useCallback(()=>n(t),[n]);return A.createElement(A.Fragment,null,A.createElement(Gl,{zoomIn:!0,ref:e,onLoseFocus:a}),A.createElement(Gl,{ref:t,onLoseFocus:o}))}function rg(){const{render:e}=ct(),t=la();return e.buttonZoom?A.createElement(A.Fragment,null,e.buttonZoom(t)):A.createElement(tg,null)}function ng(e){var t;return(((t=e.srcSet)===null||t===void 0?void 0:t.length)||0)>0}function og({current:e,preload:t},{type:r,source:n}){switch(r){case"fetch":return e?{current:e,preload:n}:{current:n};case"done":return n===t?{current:n}:{current:e,preload:t};default:throw new Error(al)}}function ag(e){var t,r;const[{current:n,preload:o},a]=A.useReducer(og,{}),{slide:s,rect:l,imageFit:f,render:h,interactive:c}=e,i=s.srcSet.sort((I,S)=>I.width-S.width),u=(t=s.width)!==null&&t!==void 0?t:i[i.length-1].width,g=(r=s.height)!==null&&r!==void 0?r:i[i.length-1].height,p=Xo(s,f),m=Math.max(...i.map(I=>I.width)),x=Math.min((p?Math.max:Math.min)(l.width,u*(l.height/g)),m),k=ef(),M=Le(()=>{var I;const S=(I=i.find(N=>N.width>=x*k))!==null&&I!==void 0?I:i[i.length-1];(!n||i.findIndex(N=>N.src===n)N===S))&&a({type:"fetch",source:S.src})});Vt(M,[l.width,l.height,k,M]);const v=Le(I=>a({type:"done",source:I})),T={WebkitTransform:c?"initial":"translateZ(0)"};return p||Object.assign(T,l.width/l.heightv(o),render:{...h,iconLoading:()=>null,iconError:()=>null}}),n&&A.createElement(mr,{key:"current",...e,slide:{...s,src:n,srcSet:void 0},style:T}))}function sg({render:e,slide:t,offset:r,rect:n}){var o;const[a,s]=A.useState(),l=A.useRef(null),{zoom:f,maxZoom:h,offsetX:c,offsetY:i,setZoomWrapper:u}=la(),g=f>1,{carousel:p,on:m}=ct(),{currentIndex:x}=Ut();Vt(()=>r===0?(u({zoomWrapperRef:l,imageDimensions:a}),()=>u(void 0)):()=>{},[r,a,u]);let k=(o=e.slide)===null||o===void 0?void 0:o.call(e,{slide:t,offset:r,rect:n,zoom:f,maxZoom:h});if(!k&&pr(t)){const M={slide:t,offset:r,rect:n,render:e,imageFit:p.imageFit,imageProps:p.imageProps,onClick:r===0?()=>{var v;return(v=m.click)===null||v===void 0?void 0:v.call(m,{index:x})}:void 0};k=ng(t)?A.createElement(ag,{...M,slide:t,interactive:g,rect:r===0?{width:n.width*f,height:n.height*f}:n}):A.createElement(mr,{onLoad:v=>s({width:v.naturalWidth,height:v.naturalHeight}),...M})}return k?A.createElement("div",{ref:l,className:ht(ye(qs),ye(Ir),ye(Qs),g&&ye(Yu)),style:r===0?{transform:`scale(${f}) translateX(${c}px) translateY(${i}px)`}:void 0},k):null}const lg=({augment:e,addModule:t})=>{e(({zoom:r,toolbar:n,render:o,controller:a,...s})=>{const l=Fl(r);return{zoom:l,toolbar:Ln(n,Xs,A.createElement(rg,null)),render:{...o,slide:f=>{var h;return pr(f.slide)?A.createElement(sg,{render:o,...f}):(h=o.slide)===null||h===void 0?void 0:h.call(o,f)}},controller:{...a,preventDefaultWheelY:l.scrollToZoom},...s}}),t(Ft(Xs,Jf))},ig={separator:"/",container:{}},jl=e=>({...ig,...e});function cg({counter:e}){const{slides:t,currentIndex:r}=Ut(),{separator:n,container:{className:o,...a},className:s,...l}=jl(e);return t.length===0?null:A.createElement("div",{className:ht(ye("counter"),o||s),...l,...a,"aria-hidden":!0},r+1," ",n," ",t.length)}function dg({augment:e,addChild:t}){e(({counter:r,...n})=>({counter:jl(r),...n})),t(rn,Ft(Hu,cg))}const ug={autoplay:!1,delay:3e3,ref:null},Bl=e=>({...ug,...e}),Wl=A.createContext(null),fg=$t("useSlideshow","SlideshowContext",Wl);function gg({slideshow:e,carousel:{finite:t},on:r,children:n}){const{autoplay:o,delay:a,ref:s}=Bl(e),l=A.useRef(o),[f,h]=A.useState(o),c=A.useRef(void 0),i=A.useRef(void 0),{slides:u,currentIndex:g}=Ut(),{setTimeout:p,clearTimeout:m}=cn(),{subscribe:x}=Fr(),{next:k}=Yt(),{setAutoPlaying:M}=ea();A.useEffect(()=>M(f),[f,M]);const v=u.length===0||t&&g===u.length-1,T=A.useCallback(()=>{!f&&!v&&h(!0)},[f,v]),I=A.useCallback(()=>{f&&h(!1)},[f]),S=A.useCallback(()=>{m(c.current),c.current=void 0},[m]),N=Le(()=>{S(),!(!f||v||i.current===Mr||i.current===Go)&&(c.current=p(()=>{f&&(i.current=void 0,k())},a))});A.useEffect(N,[g,f,N]),A.useEffect(()=>{f&&v&&h(!1)},[g,f,v]);const w=Le(()=>{var O;return(O=r.slideshowStart)===null||O===void 0?void 0:O.call(r)}),y=Le(()=>{var O;return(O=r.slideshowStop)===null||O===void 0?void 0:O.call(r)});A.useEffect(()=>{f?w():l.current&&y(),l.current=f},[f,w,y]),A.useEffect(()=>Pr(S,x(ju,()=>{i.current=Mr,S()}),x(Bu,()=>{i.current=Go,S()}),x(Wu,()=>{i.current=an,N()}),x(Vu,()=>{i.current=sn,N()})),[x,S,N]);const E=A.useMemo(()=>({playing:f,disabled:v,play:T,pause:I}),[f,v,T,I]);return A.useImperativeHandle(s,()=>E,[E]),A.createElement(Wl.Provider,{value:E},n)}const hg=xt("Play",A.createElement("path",{d:"M8 5v14l11-7z"})),pg=xt("Pause",A.createElement("path",{d:"M6 19h4V5H6v14zm8-14v14h4V5h-4z"}));function mg(){const{playing:e,disabled:t,play:r,pause:n}=fg(),{render:o}=ct(),a=kl(Yt().focus,t);return o.buttonSlideshow?A.createElement(A.Fragment,null,o.buttonSlideshow({playing:e,disabled:t,play:r,pause:n})):A.createElement(Ur,{label:e?"Pause":"Play",icon:e?pg:hg,renderIcon:e?o.iconSlideshowPause:o.iconSlideshowPlay,onClick:e?n:r,disabled:t,...a})}function bg({augment:e,addModule:t}){e(({slideshow:r,toolbar:n,...o})=>({toolbar:Ln(n,Ys,A.createElement(mg,null)),slideshow:Bl(r),...o})),t(Ft(Ys,gg))}const yg={auto:!1,ref:null},Vl=e=>({...yg,...e}),Kl=A.createContext(null),vg=$t("useFullscreen","FullscreenContext",Kl);function wg({fullscreen:e,on:t,children:r}){const{auto:n,ref:o}=Vl(e),a=A.useRef(null),[s,l]=A.useState(),[f,h]=A.useState(!1),c=A.useRef(!1),{getOwnerDocument:i}=$r();Vt(()=>{var v,T,I,S;const N=i();l(!((S=(I=(T=(v=N.fullscreenEnabled)!==null&&v!==void 0?v:N.webkitFullscreenEnabled)!==null&&T!==void 0?T:N.mozFullScreenEnabled)!==null&&I!==void 0?I:N.msFullscreenEnabled)!==null&&S!==void 0&&S))},[i]);const u=A.useCallback(()=>{var v;const T=i(),I=T.fullscreenElement||T.webkitFullscreenElement||T.mozFullScreenElement||T.msFullscreenElement;return((v=I?.shadowRoot)===null||v===void 0?void 0:v.fullscreenElement)||I},[i]),g=A.useCallback(()=>{const v=a.current;try{v.requestFullscreen?v.requestFullscreen().catch(()=>{}):v.webkitRequestFullscreen?v.webkitRequestFullscreen():v.mozRequestFullScreen?v.mozRequestFullScreen():v.msRequestFullscreen&&v.msRequestFullscreen()}catch{}},[]),p=A.useCallback(()=>{if(!u())return;const v=i();try{v.exitFullscreen?v.exitFullscreen().catch(()=>{}):v.webkitExitFullscreen?v.webkitExitFullscreen():v.mozCancelFullScreen?v.mozCancelFullScreen():v.msExitFullscreen&&v.msExitFullscreen()}catch{}},[u,i]);A.useEffect(()=>{const v=i(),T=()=>{h(u()===a.current)};return Pr(...["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"].map(I=>(v.addEventListener(I,T),()=>v.removeEventListener(I,T))))},[u,i]);const m=Le(()=>{var v;return(v=t.enterFullscreen)===null||v===void 0?void 0:v.call(t)}),x=Le(()=>{var v;return(v=t.exitFullscreen)===null||v===void 0?void 0:v.call(t)});A.useEffect(()=>{f&&(c.current=!0),c.current&&(f?m:x)()},[f,m,x]);const k=Le(()=>{var v;return(v=n?g:null)===null||v===void 0||v(),p});A.useEffect(k,[k]);const M=A.useMemo(()=>({fullscreen:f,disabled:s,enter:g,exit:p}),[f,s,g,p]);return A.useImperativeHandle(o,()=>M,[M]),A.createElement("div",{ref:a,className:ht(ye(nn),ye(qs))},A.createElement(Kl.Provider,{value:M},r))}const xg=xt("EnterFullscreen",A.createElement("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"})),kg=xt("ExitFullscreen",A.createElement("path",{d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"}));function Cg(){var e;const{fullscreen:t,disabled:r,enter:n,exit:o}=vg(),{render:a}=ct();return r?null:a.buttonFullscreen?A.createElement(A.Fragment,null,(e=a.buttonFullscreen)===null||e===void 0?void 0:e.call(a,{fullscreen:t,disabled:r,enter:n,exit:o})):A.createElement(Ur,{disabled:r,label:t?"Exit Fullscreen":"Enter Fullscreen",icon:t?kg:xg,renderIcon:t?a.iconExitFullscreen:a.iconEnterFullscreen,onClick:t?o:n})}function _g({augment:e,contains:t,addParent:r}){e(({fullscreen:n,toolbar:o,...a})=>({toolbar:Ln(o,nn,A.createElement(Cg,null)),fullscreen:Vl(n),...a})),r(t(on)?on:rn,Ft(nn,wg))}const yr={ref:null,position:"bottom",width:120,height:80,border:1,borderRadius:4,padding:4,gap:16,imageFit:"contain",vignette:!0,hidden:!1,showToggle:!1},ia=e=>({...yr,...e});function Yl(){const{thumbnails:e}=ct();return ia(e)}const vr=e=>fr(on,e),dt=e=>vr(fr("thumbnail",e)),Sg=xt("VideoThumbnail",A.createElement("path",{d:"M10 16.5l6-4.5-6-4.5v9zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"})),Eg=xt("UnknownThumbnail",A.createElement("path",{d:"M23 18V6c0-1.1-.9-2-2-2H3c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2zM8.5 12.5l2.5 3.01L14.5 11l4.5 6H5l3.5-4.5z"}));function Tg({slide:e,render:t,rect:r,imageFit:n}){var o;const a=(o=t.thumbnail)===null||o===void 0?void 0:o.call(t,{slide:e,render:t,rect:r,imageFit:n});if(a)return a;const s={render:t,rect:r,imageFit:n};if(e.thumbnail)return A.createElement(mr,{slide:{src:e.thumbnail},...s});if(pr(e))return A.createElement(mr,{slide:e,...s});const l=ye(dt(In));return e.type==="video"?A.createElement(A.Fragment,null,e.poster&&A.createElement(mr,{slide:{src:e.poster},...s}),A.createElement(Sg,{className:l})):A.createElement(Eg,{className:l})}const Ag=gr("active"),ca=gr("fadein"),da=gr("fadeout"),Ng=gr("placeholder"),Xl="delay",ql="duration";function Og({slide:e,index:t,onClick:r,fadeIn:n,fadeOut:o,placeholder:a,onLoseFocus:s}){const l=A.useRef(null),{render:f,styles:h,labels:c}=ct(),{slides:i,globalIndex:u}=Ut(),{getOwnerDocument:g}=$r(),{width:p,height:m,imageFit:x}=Yl(),k={width:p,height:m},M=t===u,v=Le(s);return A.useEffect(()=>{o&&g().activeElement===l.current&&v()},[o,v,g]),A.createElement("button",{ref:l,type:"button",className:ht(ye(Ir),ye(dt()),M&&ye(dt(Ag())),n&&ye(dt(ca())),o&&ye(dt(da())),a&&ye(dt(Ng()))),style:{...n?{[Xe(dt(ca(ql)))]:`${n.duration}ms`,[Xe(dt(ca(Xl)))]:`${n.delay}ms`}:null,...o?{[Xe(dt(da(ql)))]:`${o.duration}ms`,[Xe(dt(da(Xl)))]:`${o.delay}ms`}:null,...h.thumbnail},onClick:r,"aria-current":M?!0:void 0,"aria-label":ll(c,i,t)},e&&Tg({slide:e,render:f,rect:k,imageFit:x}))}function Zl(e){return["top","bottom"].includes(e)}function Ql(e,t){return t+2*(e.border+e.padding)+e.gap}function Mg(e){const{thumbnail:t,poster:r}=e||{thumbnail:"placeholder"};return typeof t=="string"&&t||typeof r=="string"&&r||e&&il(e)||void 0}function Jl({visible:e,containerRef:t}){const r=A.useRef(null),n=Fn(),{publish:o,subscribe:a}=Fr(),{carousel:s,styles:l,labels:f}=ct(),{slides:h,globalIndex:c,animation:i}=Ut(),{registerSensors:u,subscribeSensors:g}=Cl();Ol(g);const p=Yl(),{position:m,width:x,height:k,border:M,borderStyle:v,borderColor:T,borderRadius:I,padding:S,gap:N,vignette:w}=p,y=i?.duration!==void 0&&i?.increment||0,E=i?.duration||0,{prepareAnimation:O}=ra(r,_=>({keyframes:Zl(m)?[{transform:`translateX(${(n?-1:1)*Ql(p,x)*y+_}px)`},{transform:"translateX(0)"}]:[{transform:`translateY(${Ql(p,k)*y+_}px)`},{transform:"translateY(0)"}],duration:E,easing:i?.easing})),$=Le(()=>{let _=0;if(t.current&&r.current){const b=t.current.getBoundingClientRect(),z=r.current.getBoundingClientRect();_=Zl(m)?z.left-b.left-(b.width-z.width)/2:z.top-b.top-(b.height-z.height)/2}O(_)});A.useEffect(()=>Pr(a(Bo,$)),[a,$]);const P=cl(s,h),L=[];if(Zo(h))for(let _=c-P-Math.abs(y);_<=c+P+Math.abs(y);_+=1){const z=s.finite&&(_<0||_>h.length-1)||y<0&&_0&&_>c+P?null:Qo(h,_),F=[`${_}`,Mg(z)].filter(Boolean).join("|");L.push({key:F,index:_,slide:z})}const U=_=>()=>{_>c?o(or,{count:_-c}):_{const F=E/Math.abs(y||1),G=y>0&&b>c+P-y&&b<=c+P||y<0&&b=c-P?{duration:F,delay:((y>0?b-(c+P-y):c-P-y-b)-1)*F}:void 0,X=y>0&&bc+P?{duration:F,delay:(y>0?y-(c-P-b):-y-(b-(c+P)))*F}:void 0;return A.createElement(Og,{key:_,index:b,slide:z,fadeIn:G,fadeOut:X,placeholder:!z,onClick:U(b),onLoseFocus:()=>{var B;return(B=r.current)===null||B===void 0?void 0:B.focus()}})})),w&&A.createElement("div",{className:ye(vr("vignette"))}))}const Rl=A.createContext(null),Ig=$t("useThumbnails","ThumbnailsContext",Rl);function Dg({children:e,...t}){const{ref:r,position:n,hidden:o}=ia(t.thumbnails),[a,s]=A.useState(!o),l=A.useRef(null),f=A.useMemo(()=>({visible:a,show:()=>s(!0),hide:()=>s(!1)}),[a]);return A.useImperativeHandle(r,()=>f,[f]),A.createElement(pl,{...t},A.createElement(Rl.Provider,{value:f},A.createElement("div",{ref:l,className:ht(ye(vr()),ye(vr(`${n}`)))},["start","top"].includes(n)&&A.createElement(Jl,{containerRef:l,visible:a}),A.createElement("div",{className:ye(vr("wrapper"))},e),["end","bottom"].includes(n)&&A.createElement(Jl,{containerRef:l,visible:a}))))}const ei=()=>A.createElement(A.Fragment,null,A.createElement("path",{strokeWidth:2,stroke:"currentColor",strokeLinejoin:"round",fill:"none",d:"M3 5l18 0l0 14l-18 0l0-14z"}),A.createElement("path",{d:"M5 14h4v3h-4zM10 14h4v3h-4zM15 14h4v3h-4z"})),Pg=xt("ThumbnailsVisible",ei()),Lg=gf("ThumbnailsHidden",ei());function $g(){const{visible:e,show:t,hide:r}=Ig(),{render:n}=ct();return n.buttonThumbnails?A.createElement(A.Fragment,null,n.buttonThumbnails({visible:e,show:t,hide:r})):A.createElement(Ur,{label:e?"Hide thumbnails":"Show thumbnails",icon:e?Pg:Lg,renderIcon:e?n.iconThumbnailsVisible:n.iconThumbnailsHidden,onClick:e?r:t})}function Fg({augment:e,contains:t,append:r,addParent:n}){e(({thumbnails:a,toolbar:s,...l})=>{const f=ia(a);return{toolbar:Ln(s,on,f.showToggle?A.createElement($g,null):null),thumbnails:f,...l}});const o=Ft(on,Dg);t(nn)?r(nn,o):n(rn,o)}const Ug="X-Board-Secret-View-Token";function zn(){const e=window.G7Core?.state?.get?.("_global")?.secretViewToken;return typeof e=="string"&&e!==""?{[Ug]:e}:{}}const It=({className:e="",children:t,style:r,...n})=>d.jsx("i",{className:e,style:r,...n,children:t}),ua=e=>{if(!e||typeof window>"u"||!window.location||!/^(https?:)?\/\//i.test(e))return!1;try{return new URL(e,window.location.href).origin!==window.location.origin}catch{return!1}},fa=window.G7Core,Hn=(e,t)=>fa?.t?.(e,t)??e,zg=async(e,t)=>{try{const r=await fa.api.get(e,{responseType:"blob",headers:zn()});if(r){const n=URL.createObjectURL(r),o=document.createElement("a");o.href=n,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}}catch(r){console.error("Failed to download file:",r),fa?.toast?.error?.(Hn("common.download_failed"))}},Hg=(e,t)=>{const r=document.createElement("a");r.href=e,r.download=t,r.target="_blank",document.body.appendChild(r),r.click(),document.body.removeChild(r)},ti=async e=>{const t=e.downloadUrl||e.src,r=e.filename||e.title||"image";e.downloadRequiresAuth&&!ua(t)?await zg(t,r):Hg(t,r)},Gg=({image:e,index:t,onDownload:r})=>{const[n,o]=C.useState(!1),a=async s=>{if(s.stopPropagation(),r){r(e,t);return}o(!0);try{await ti(e)}finally{o(!1)}};return d.jsx(R,{type:"button",onClick:a,disabled:n,className:"yarl__button flex items-center justify-center","aria-label":Hn("common.download"),title:Hn("common.download"),children:n?d.jsx(It,{className:"fa-solid fa-spinner fa-spin text-white"}):d.jsx(It,{className:"fa-solid fa-download text-white"})})},zr=({images:e,isOpen:t,onClose:r,startIndex:n=0,enableZoom:o=!0,enableSlideshow:a=!1,enableFullscreen:s=!0,showCounter:l=!0,showDownload:f=!0,showThumbnails:h=!0,onDownload:c,editorAttrs:i,id:u})=>{const[g,p]=C.useState(n),m=C.useRef(n),x=e.map(v=>({src:v.src,title:v.title,description:v.description})),k=[];o&&k.push(lg),a&&k.push(bg),s&&k.push(_g),l&&k.push(dg),h&&k.push(Fg);const M=e[g];if(C.useEffect(()=>{m.current=g},[g]),i){const v=(e??[]).slice(0,4);return d.jsx(j,{id:u,className:"grid grid-cols-2 gap-2 p-3 rounded-lg border border-dashed border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800",...i,children:v.length>0?v.map((T,I)=>d.jsx(jt,{src:T.thumbnail||T.src,alt:T.title||"",className:"w-full aspect-square object-cover rounded bg-gray-200 dark:bg-gray-700"},I)):d.jsxs(j,{className:"col-span-2 flex items-center justify-center py-6 text-sm text-gray-400 dark:text-gray-500",children:[d.jsx(It,{className:"fa-regular fa-images mr-2"}),Hn("editor.component.image_gallery")]})})}return d.jsx(Wf,{open:t,close:r,slides:x,index:g,plugins:k,on:{view:({index:v})=>{v!==m.current&&p(v)}},zoom:{maxZoomPixelRatio:3,zoomInMultiplier:2,doubleTapDelay:300,doubleClickDelay:300,doubleClickMaxStops:2,keyboardMoveDistance:50,wheelZoomDistanceFactor:100,pinchZoomDistanceFactor:100,scrollToZoom:!0},carousel:{finite:!0,preload:2,padding:"16px",spacing:"30%"},animation:{fade:250,swipe:500,easing:{fade:"ease",swipe:"ease-out",navigation:"ease-in-out"}},controller:{closeOnBackdropClick:!0,closeOnPullDown:!0,closeOnPullUp:!0},thumbnails:{position:"bottom",width:120,height:80,border:2,borderRadius:4,padding:4,gap:16,showToggle:!1,vignette:!0},toolbar:{buttons:[f&&M&&d.jsx(Gg,{image:M,index:g,onDownload:c},"download"),"close"].filter(Boolean)},styles:{container:{backgroundColor:"rgba(0, 0, 0, 0.9)"}}})},ri=()=>{const[e,t]=C.useState(!1),[r,n]=C.useState([]),[o,a]=C.useState(0),s=C.useCallback((f,h=0)=>{n(f),a(h),t(!0)},[]),l=C.useCallback(()=>{t(!1)},[]);return{isOpen:e,openGallery:s,closeGallery:l,galleryProps:{images:r,isOpen:e,onClose:l,startIndex:o}}};zr.displayName="ImageGallery";const ni=Object.freeze(Object.defineProperty({__proto__:null,ImageGallery:zr,default:zr,executeImageDownload:ti,useImageGallery:ri},Symbol.toStringTag,{value:"Module"})),jg=window.G7Core,ga=(e,t)=>jg?.t?.(e,t)??e,Gn=e=>e.url??e.download_url,jn=({images:e=[],className:t="",id:r,editorAttrs:n})=>{const[o,a]=C.useState(0),{openGallery:s,galleryProps:l}=ri(),f=C.useMemo(()=>e.map(c=>({src:Gn(c),title:c.alt_text_current??"",thumbnail:Gn(c),downloadUrl:c.download_url,filename:c.alt_text_current??`image-${c.id}`})),[e]);if(!e||e.length===0)return d.jsx(j,{className:`flex items-center justify-center bg-gray-100 dark:bg-gray-700 rounded-lg aspect-square ${t}`,id:r,...n,children:d.jsxs(j,{className:"text-center text-gray-400 dark:text-gray-500",children:[d.jsx(fe,{name:"image",size:"3x",className:"mb-3 opacity-50"}),d.jsx(j,{className:"text-sm",children:ga("shop.no_image")})]})});const h=e[o]??e[0];return d.jsxs(j,{id:r,className:t,...n,children:[d.jsx(j,{className:"relative overflow-hidden rounded-lg bg-gray-100 dark:bg-gray-700 aspect-square mb-3",children:d.jsx(R,{type:"button",className:"w-full h-full cursor-zoom-in block",onClick:()=>s(f,o),"aria-label":ga("shop.view_image"),children:d.jsx(jt,{src:Gn(h),alt:h.alt_text_current??"",className:"w-full h-full object-contain"})})}),e.length>1&&d.jsx(j,{className:"flex gap-2 overflow-x-auto pb-1",children:e.map((c,i)=>d.jsx(R,{type:"button",className:`flex-shrink-0 w-16 h-16 rounded-md overflow-hidden border-2 transition-colors cursor-pointer ${i===o?"border-gray-900 dark:border-white":"border-gray-200 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-400"}`,onClick:()=>a(i),"aria-label":c.alt_text_current??`${ga("shop.image")} ${i+1}`,children:d.jsx(jt,{src:Gn(c),alt:c.alt_text_current??"",className:"w-full h-full object-cover"})},c.id))}),d.jsx(zr,{...l})]})};jn.displayName="ProductImageViewer";const Bg=Object.freeze(Object.defineProperty({__proto__:null,ProductImageViewer:jn,default:jn},Symbol.toStringTag,{value:"Module"})),oi=({value:e,min:t=1,max:r=999,onChange:n,size:o="md",disabled:a=!1,className:s="",id:l,editorAttrs:f})=>{const c={sm:{container:"h-8",button:"w-8 h-8 text-sm",input:"w-10 text-sm"},md:{container:"h-10",button:"w-10 h-10",input:"w-14"},lg:{container:"h-12",button:"w-12 h-12 text-lg",input:"w-16 text-lg"}}[o],i=()=>{e>t&&!a&&n(e-1)},u=()=>{e{const M=parseInt(k.target.value,10);if(!isNaN(M)){const v=Math.max(t,Math.min(r,M));n(v)}},p=k=>{const M=parseInt(k.target.value,10);isNaN(M)||Mr&&n(r)},m=a||e<=t,x=a||e>=r;return d.jsxs(j,{className:`inline-flex items-center border border-gray-300 dark:border-gray-600 rounded-lg ${c.container} ${s}`,id:l,...f,children:[d.jsx(R,{type:"button",onClick:i,disabled:m,className:`${c.button} flex items-center justify-center text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed rounded-l-lg transition-colors`,"aria-label":"수량 감소",children:d.jsx(fe,{name:"minus",className:"w-4 h-4"})}),d.jsx(At,{type:"number",value:e,onChange:g,onBlur:p,min:t,max:r,disabled:a,className:`${c.input} text-center border-x border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`,"aria-label":"수량"}),d.jsx(R,{type:"button",onClick:u,disabled:x,className:`${c.button} flex items-center justify-center text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed rounded-r-lg transition-colors`,"aria-label":"수량 증가",children:d.jsx(fe,{name:"plus",className:"w-4 h-4"})})]})},Wg=Object.freeze(Object.defineProperty({__proto__:null,default:oi},Symbol.toStringTag,{value:"Module"})),Vg=window.G7Core?.createLogger?.("Comp:PostReactions")??{log:(...e)=>console.log("[Comp:PostReactions]",...e),warn:(...e)=>console.warn("[Comp:PostReactions]",...e),error:(...e)=>console.error("[Comp:PostReactions]",...e)},ai=(e,t)=>window.G7Core?.t?.(e,t)??e,Kg=[{type:"like",emoji:"👍",labelKey:"board.reactions.like",activeColor:"bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400"},{type:"funny",emoji:"😂",labelKey:"board.reactions.funny",activeColor:"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-600 dark:text-yellow-400"},{type:"agree",emoji:"👌",labelKey:"board.reactions.agree",activeColor:"bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400"},{type:"thanks",emoji:"🙏",labelKey:"board.reactions.thanks",activeColor:"bg-purple-100 dark:bg-purple-900/30 text-purple-600 dark:text-purple-400"},{type:"wow",emoji:"😮",labelKey:"board.reactions.wow",activeColor:"bg-orange-100 dark:bg-orange-900/30 text-orange-600 dark:text-orange-400"}],si=({reactions:e,userReaction:t,postId:r,onReact:n,size:o="md",className:a="",id:s,editorAttrs:l})=>{const f={sm:"px-2 py-1 text-xs gap-1",md:"px-3 py-1.5 text-sm gap-1.5",lg:"px-4 py-2 text-base gap-2"},h={sm:"text-sm",md:"text-base",lg:"text-lg"},c=u=>e.find(p=>p.type===u)?.count??0,i=async u=>{if(n){n(u);return}try{if(!(await fetch(`/api/posts/${r}/reactions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:u}),credentials:"include"})).ok)throw new Error("리액션 처리 실패");window.location.reload()}catch(g){Vg.error("리액션 오류:",g)}};return d.jsx(j,{className:`flex flex-wrap gap-2 ${a}`,id:s,...l,children:Kg.map(u=>{const g=c(u.type),p=t===u.type;return d.jsxs(R,{onClick:()=>i(u.type),className:` inline-flex items-center rounded-full border transition-colors ${f[o]} ${p?`${u.activeColor} border-transparent`:"border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"} - `,title:ai(u.labelKey),children:[d.jsx(te,{className:h[o],children:u.emoji}),d.jsx(te,{children:ai(u.labelKey)}),g>0&&d.jsx(te,{className:"font-medium",children:g})]},u.type)})})},Vg=Object.freeze(Object.defineProperty({__proto__:null,default:si},Symbol.toStringTag,{value:"Module"})),Bn=window.G7Core?.createLogger?.("Comp:RichTextEditor")??{log:(...e)=>console.log("[Comp:RichTextEditor]",...e),warn:(...e)=>console.warn("[Comp:RichTextEditor]",...e),error:(...e)=>console.error("[Comp:RichTextEditor]",...e)},Dt=(e,t)=>window.G7Core?.t?.(e,t)??e,li=({name:e,initialValue:t="",placeholder:r,onChange:n,imageUploadUrl:o="/api/upload/image",minHeight:a="300px",disabled:s=!1,className:l="",id:f,editorAttrs:h})=>{const c=C.useRef(null),[i,u]=C.useState(t),[g,p]=C.useState(!1),[m,x]=C.useState(!1),[k,M]=C.useState("");C.useEffect(()=>{c.current&&!c.current.innerHTML&&(c.current.innerHTML=t)},[t]),C.useEffect(()=>{n&&n(i)},[i,n]);const v=E=>{Bn.log("Apply format:",E)},T=async E=>{const O=new FormData;O.append("file",E);try{const $=await fetch(o,{method:"POST",body:O,credentials:"include"});if(!$.ok)throw new Error("업로드 실패");const P=await $.json();Bn.log("Image uploaded:",P.url)}catch($){Bn.error("이미지 업로드 오류:",$)}},I=E=>{const O=E.target.files?.[0];O&&T(O)},S=()=>{k&&(Bn.log("Insert link:",k),x(!1),M(""))},N=[{format:"bold",icon:"B",title:Dt("editor.toolbar.bold")},{format:"italic",icon:"I",title:Dt("editor.toolbar.italic")},{format:"underline",icon:"U",title:Dt("editor.toolbar.underline")},{format:"strike",icon:"S",title:Dt("editor.toolbar.strike")},{format:"code",icon:"",title:Dt("editor.toolbar.code")}],w=[{format:"h1",label:"H1"},{format:"h2",label:"H2"},{format:"h3",label:"H3"}],y=[{format:"bulletList",icon:"•",title:Dt("editor.toolbar.bullet_list")},{format:"orderedList",icon:"1.",title:Dt("editor.toolbar.ordered_list")},{format:"blockquote",icon:"❝",title:Dt("editor.toolbar.blockquote")}];return d.jsxs(j,{className:`border border-gray-300 dark:border-gray-600 rounded-lg overflow-hidden ${l}`,id:f,...h,children:[d.jsxs(j,{className:"flex flex-wrap items-center gap-1 p-2 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",children:[d.jsx(j,{className:"flex items-center gap-1 pr-2 border-r border-gray-200 dark:border-gray-700",children:N.map(E=>d.jsx(R,{type:"button",onClick:()=>v(E.format),disabled:s,className:"w-8 h-8 flex items-center justify-center text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded disabled:opacity-50",title:E.title,children:E.icon},E.format))}),d.jsx(j,{className:"flex items-center gap-1 pr-2 border-r border-gray-200 dark:border-gray-700",children:w.map(E=>d.jsx(R,{type:"button",onClick:()=>v(E.format),disabled:s,className:"px-2 h-8 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded disabled:opacity-50",children:E.label},E.format))}),d.jsx(j,{className:"flex items-center gap-1 pr-2 border-r border-gray-200 dark:border-gray-700",children:y.map(E=>d.jsx(R,{type:"button",onClick:()=>v(E.format),disabled:s,className:"w-8 h-8 flex items-center justify-center text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded disabled:opacity-50",title:E.title,children:E.icon},E.format))}),d.jsxs(j,{className:"flex items-center gap-1 pr-2 border-r border-gray-200 dark:border-gray-700",children:[d.jsx(R,{type:"button",onClick:()=>x(!0),disabled:s,className:"w-8 h-8 flex items-center justify-center text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded disabled:opacity-50",title:Dt("editor.toolbar.link"),children:"🔗"}),d.jsxs(Ar,{className:"w-8 h-8 flex items-center justify-center text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded cursor-pointer",children:["🖼",d.jsx(At,{type:"file",accept:"image/*",onChange:I,disabled:s,className:"hidden"})]})]}),d.jsxs(R,{type:"button",onClick:()=>p(!g),disabled:s,className:`px-2 h-8 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded disabled:opacity-50 ${g?"bg-gray-200 dark:bg-gray-700":""}`,children:["",Dt("editor.toolbar.code_view")]})]}),g?d.jsx(Co,{value:i,onChange:E=>u(E.target.value),placeholder:r,disabled:s,className:"w-full p-4 bg-gray-900 text-gray-100 font-mono text-sm focus:outline-none resize-none",style:{minHeight:a}}):d.jsx(j,{ref:c,contentEditable:!s,onInput:E=>u(E.currentTarget.innerHTML),className:"p-4 bg-white dark:bg-gray-900 text-gray-900 dark:text-white focus:outline-none prose dark:prose-invert max-w-none",style:{minHeight:a},"data-placeholder":r}),d.jsx(At,{type:"hidden",name:e,value:i}),m&&d.jsx(j,{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:d.jsxs(j,{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-96",children:[d.jsx(Tn,{className:"text-lg font-medium text-gray-900 dark:text-white mb-4",children:Dt("editor.link_modal.title")}),d.jsx(At,{type:"url",value:k,onChange:E=>M(E.target.value),placeholder:"https://example.com",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white mb-4"}),d.jsxs(j,{className:"flex justify-end gap-2",children:[d.jsx(R,{type:"button",onClick:()=>{x(!1),M("")},className:"px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg",children:Dt("common.cancel")}),d.jsx(R,{type:"button",onClick:S,className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700",children:Dt("editor.link_modal.insert")})]})]})})]})},Kg=Object.freeze(Object.defineProperty({__proto__:null,default:li},Symbol.toStringTag,{value:"Module"})),ha=({content:e,text:t,isHtml:r=!0,className:n="",purifyConfig:o,id:a,editorAttrs:s})=>{const l=t??e??"";if(!l||l.trim()==="")return null;if(!r){const i=` + `,title:ai(u.labelKey),children:[d.jsx(te,{className:h[o],children:u.emoji}),d.jsx(te,{children:ai(u.labelKey)}),g>0&&d.jsx(te,{className:"font-medium",children:g})]},u.type)})})},Yg=Object.freeze(Object.defineProperty({__proto__:null,default:si},Symbol.toStringTag,{value:"Module"})),Bn=window.G7Core?.createLogger?.("Comp:RichTextEditor")??{log:(...e)=>console.log("[Comp:RichTextEditor]",...e),warn:(...e)=>console.warn("[Comp:RichTextEditor]",...e),error:(...e)=>console.error("[Comp:RichTextEditor]",...e)},Dt=(e,t)=>window.G7Core?.t?.(e,t)??e,li=({name:e,initialValue:t="",placeholder:r,onChange:n,imageUploadUrl:o="/api/upload/image",minHeight:a="300px",disabled:s=!1,className:l="",id:f,editorAttrs:h})=>{const c=C.useRef(null),[i,u]=C.useState(t),[g,p]=C.useState(!1),[m,x]=C.useState(!1),[k,M]=C.useState("");C.useEffect(()=>{c.current&&!c.current.innerHTML&&(c.current.innerHTML=t)},[t]),C.useEffect(()=>{n&&n(i)},[i,n]);const v=E=>{Bn.log("Apply format:",E)},T=async E=>{const O=new FormData;O.append("file",E);try{const $=await fetch(o,{method:"POST",body:O,credentials:"include"});if(!$.ok)throw new Error("업로드 실패");const P=await $.json();Bn.log("Image uploaded:",P.url)}catch($){Bn.error("이미지 업로드 오류:",$)}},I=E=>{const O=E.target.files?.[0];O&&T(O)},S=()=>{k&&(Bn.log("Insert link:",k),x(!1),M(""))},N=[{format:"bold",icon:"B",title:Dt("editor.toolbar.bold")},{format:"italic",icon:"I",title:Dt("editor.toolbar.italic")},{format:"underline",icon:"U",title:Dt("editor.toolbar.underline")},{format:"strike",icon:"S",title:Dt("editor.toolbar.strike")},{format:"code",icon:"",title:Dt("editor.toolbar.code")}],w=[{format:"h1",label:"H1"},{format:"h2",label:"H2"},{format:"h3",label:"H3"}],y=[{format:"bulletList",icon:"•",title:Dt("editor.toolbar.bullet_list")},{format:"orderedList",icon:"1.",title:Dt("editor.toolbar.ordered_list")},{format:"blockquote",icon:"❝",title:Dt("editor.toolbar.blockquote")}];return d.jsxs(j,{className:`border border-gray-300 dark:border-gray-600 rounded-lg overflow-hidden ${l}`,id:f,...h,children:[d.jsxs(j,{className:"flex flex-wrap items-center gap-1 p-2 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",children:[d.jsx(j,{className:"flex items-center gap-1 pr-2 border-r border-gray-200 dark:border-gray-700",children:N.map(E=>d.jsx(R,{type:"button",onClick:()=>v(E.format),disabled:s,className:"w-8 h-8 flex items-center justify-center text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded disabled:opacity-50",title:E.title,children:E.icon},E.format))}),d.jsx(j,{className:"flex items-center gap-1 pr-2 border-r border-gray-200 dark:border-gray-700",children:w.map(E=>d.jsx(R,{type:"button",onClick:()=>v(E.format),disabled:s,className:"px-2 h-8 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded disabled:opacity-50",children:E.label},E.format))}),d.jsx(j,{className:"flex items-center gap-1 pr-2 border-r border-gray-200 dark:border-gray-700",children:y.map(E=>d.jsx(R,{type:"button",onClick:()=>v(E.format),disabled:s,className:"w-8 h-8 flex items-center justify-center text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded disabled:opacity-50",title:E.title,children:E.icon},E.format))}),d.jsxs(j,{className:"flex items-center gap-1 pr-2 border-r border-gray-200 dark:border-gray-700",children:[d.jsx(R,{type:"button",onClick:()=>x(!0),disabled:s,className:"w-8 h-8 flex items-center justify-center text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded disabled:opacity-50",title:Dt("editor.toolbar.link"),children:"🔗"}),d.jsxs(Ar,{className:"w-8 h-8 flex items-center justify-center text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded cursor-pointer",children:["🖼",d.jsx(At,{type:"file",accept:"image/*",onChange:I,disabled:s,className:"hidden"})]})]}),d.jsxs(R,{type:"button",onClick:()=>p(!g),disabled:s,className:`px-2 h-8 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded disabled:opacity-50 ${g?"bg-gray-200 dark:bg-gray-700":""}`,children:["",Dt("editor.toolbar.code_view")]})]}),g?d.jsx(Co,{value:i,onChange:E=>u(E.target.value),placeholder:r,disabled:s,className:"w-full p-4 bg-gray-900 text-gray-100 font-mono text-sm focus:outline-none resize-none",style:{minHeight:a}}):d.jsx(j,{ref:c,contentEditable:!s,onInput:E=>u(E.currentTarget.innerHTML),className:"p-4 bg-white dark:bg-gray-900 text-gray-900 dark:text-white focus:outline-none prose dark:prose-invert max-w-none",style:{minHeight:a},"data-placeholder":r}),d.jsx(At,{type:"hidden",name:e,value:i}),m&&d.jsx(j,{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:d.jsxs(j,{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-96",children:[d.jsx(Tn,{className:"text-lg font-medium text-gray-900 dark:text-white mb-4",children:Dt("editor.link_modal.title")}),d.jsx(At,{type:"url",value:k,onChange:E=>M(E.target.value),placeholder:"https://example.com",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white mb-4"}),d.jsxs(j,{className:"flex justify-end gap-2",children:[d.jsx(R,{type:"button",onClick:()=>{x(!1),M("")},className:"px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg",children:Dt("common.cancel")}),d.jsx(R,{type:"button",onClick:S,className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700",children:Dt("editor.link_modal.insert")})]})]})})]})},Xg=Object.freeze(Object.defineProperty({__proto__:null,default:li},Symbol.toStringTag,{value:"Module"})),ha=({content:e,text:t,isHtml:r=!0,className:n="",purifyConfig:o,id:a,editorAttrs:s})=>{const l=t??e??"";if(!l||l.trim()==="")return null;if(!r){const i=` whitespace-pre-wrap text-gray-900 dark:text-gray-100 font-sans @@ -40,7 +40,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho [&_tr:hover]:bg-gray-50 dark:[&_tr:hover]:bg-gray-700/50 after:content-[''] after:block after:clear-both ${n} - `.trim().replace(/\s+/g," ");return d.jsx(j,{id:a,className:c,dangerouslySetInnerHTML:{__html:h},...s})},Yg=Object.freeze(Object.defineProperty({__proto__:null,HtmlContent:ha},Symbol.toStringTag,{value:"Module"})),pa=()=>window.G7Core,ma=(e,t)=>pa()?.t?.(e,t)??e,ii=({content:e="",onChange:t,isHtml:r=!1,onIsHtmlChange:n,rows:o=15,placeholder:a="",label:s,showHtmlModeToggle:l=!0,contentClassName:f="",purifyConfig:h,className:c="",name:i="content",htmlFieldName:u="content_mode",readOnly:g=!1,id:p,editorAttrs:m})=>{const[x,k]=C.useState(r),[M,v]=C.useState(e),[T,I]=C.useState(!1);C.useEffect(()=>{k(r)},[r]),C.useEffect(()=>{v(e)},[e]);const S=C.useCallback(y=>{const E=y.target.value;if(v(E),t){const O=pa()?.createChangeEvent?.({value:E,name:i,type:"textarea"})??{target:{name:i,value:E}};t(O)}},[t,i]),N=C.useCallback(y=>{const E=y.target.checked;if(k(E),E||I(!1),n){const O=pa()?.createChangeEvent?.({checked:E,name:u,type:"checkbox"})??{target:{name:u,checked:E}};n(O)}},[n,u]),w=C.useCallback(()=>{I(y=>!y)},[]);return d.jsxs(j,{className:`space-y-2 ${c}`,id:p,...m,children:[d.jsxs(j,{className:"flex items-center justify-between",children:[s&&d.jsx(Ar,{className:"block text-sm font-medium text-gray-500 dark:text-gray-400",children:s}),d.jsxs(j,{className:"flex items-center gap-3",children:[x&&!g&&d.jsx(R,{type:"button",onClick:w,className:`px-3 py-1.5 text-xs font-bold rounded-lg focus:outline-none focus:ring-2 ${T?"text-gray-700 dark:text-gray-200 bg-gray-200 dark:bg-gray-600 border border-gray-300 dark:border-gray-500 hover:bg-gray-300 dark:hover:bg-gray-500 focus:ring-gray-400 dark:focus:ring-gray-500":"text-blue-600 dark:text-blue-400 bg-white dark:bg-gray-700 border border-blue-300 dark:border-blue-600 hover:bg-blue-50 dark:hover:bg-gray-600 focus:ring-blue-500 dark:focus:ring-blue-600"}`,children:ma(T?"common.preview_off":"common.preview")}),l&&d.jsxs(Ar,{className:"flex items-center gap-2 p-2 cursor-pointer",children:[d.jsx(At,{type:"checkbox",name:u,checked:x,onChange:N,disabled:g,className:"w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600"}),d.jsx(j,{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:ma("common.html_mode")})]})]})]}),!T&&d.jsx(Co,{name:i,value:M,onChange:S,placeholder:a,rows:o,readOnly:g,className:`block w-full rounded-lg border px-3 py-2 text-sm placeholder-gray-400 dark:placeholder-gray-500 focus:outline-none focus:ring-1 disabled:opacity-50 disabled:cursor-not-allowed ${x?"font-mono bg-white dark:bg-gray-800 border-blue-300 dark:border-blue-600 text-gray-800 dark:text-gray-200 focus:border-blue-500 focus:ring-blue-500":"bg-white dark:bg-gray-800 border-gray-300 dark:border-gray-600 text-gray-900 dark:text-white focus:border-blue-500 focus:ring-blue-500"}`}),T&&d.jsx(j,{className:"p-4 bg-gray-50 dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 min-h-[400px]",children:d.jsx(ha,{content:M,isHtml:!0,className:f||"prose dark:prose-invert max-w-none text-gray-900 dark:text-gray-100",purifyConfig:h})})]})},Xg=Object.freeze(Object.defineProperty({__proto__:null,HtmlEditor:ii},Symbol.toStringTag,{value:"Module"})),ci=e=>window.G7Core?.t?.(e)??e,ba=({maxHeight:e=500,expandText:t,collapseText:r,className:n="",children:o,id:a,editorAttrs:s})=>{const[l,f]=C.useState(!1),[h,c]=C.useState(!1),i=C.useRef(null),u=C.useCallback(()=>{if(i.current){const x=i.current.scrollHeight;c(x>e)}},[e]);C.useEffect(()=>{u();const x=i.current;if(!x)return;const k=x.querySelectorAll("img");k.forEach(v=>{v.complete||v.addEventListener("load",u)});let M=null;return typeof ResizeObserver<"u"&&(M=new ResizeObserver(u),M.observe(x)),()=>{k.forEach(v=>{v.removeEventListener("load",u)}),M?.disconnect()}},[u,o]);const g=()=>{f(x=>!x)},p=t||ci("sirsoft-ecommerce.shop.product.expand_detail"),m=r||ci("sirsoft-ecommerce.shop.product.collapse_detail");return d.jsxs(j,{className:n,id:a,...s,children:[d.jsxs(j,{className:"relative",children:[d.jsx(j,{ref:i,className:!l&&h?"overflow-hidden transition-[max-height] duration-300 ease-in-out":"transition-[max-height] duration-300 ease-in-out",style:!l&&h?{maxHeight:`${e}px`}:void 0,children:o}),!l&&h&&d.jsx(j,{className:"absolute bottom-0 left-0 right-0 h-24 bg-gradient-to-t from-white dark:from-gray-900 to-transparent pointer-events-none"})]}),h&&d.jsxs(R,{type:"button",onClick:g,className:"flex items-center justify-center w-full py-3.5 bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors cursor-pointer gap-1.5",children:[d.jsx(te,{className:"text-sm font-semibold text-gray-600 dark:text-gray-400",children:l?m:p}),d.jsx(fe,{name:l?"chevron-up":"chevron-down",size:"sm"})]})]})},qg=Object.freeze(Object.defineProperty({__proto__:null,ExpandableContent:ba,default:ba},Symbol.toStringTag,{value:"Module"})),Zg=(e,t)=>window.G7Core?.t?.(e,t)??e,ya=({isOpen:e,onClose:t,title:r,icon:n,iconClassName:o="text-gray-500 dark:text-gray-400",closeOnBackdropClick:a=!0,closeOnOverlayClick:s,showCloseButton:l=!0,closeOnEscape:f=!0,children:h,width:c="500px",className:i="",style:u})=>{const g=s!==void 0?s:a,p=C.useRef(null),m=C.useRef(null);if(C.useEffect(()=>{const k=M=>{M.key==="Escape"&&e&&f&&t()};if(e&&f)return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[e,t,f]),C.useEffect(()=>{if(e&&p.current){m.current=document.activeElement;const k=p.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),M=k[0],v=k[k.length-1];M?.focus();const T=I=>{I.key==="Tab"&&(I.shiftKey?document.activeElement===M&&(I.preventDefault(),v?.focus()):document.activeElement===v&&(I.preventDefault(),M?.focus()))};return document.addEventListener("keydown",T),()=>{document.removeEventListener("keydown",T),m.current?.focus()}}},[e]),C.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),!e)return null;const x=u?.zIndex??50;return d.jsxs(j,{className:"fixed inset-0 flex items-center justify-center",style:{zIndex:x},onClick:g?t:void 0,children:[d.jsx(j,{className:"absolute inset-0 bg-black/50","aria-hidden":"true"}),d.jsxs(j,{ref:p,className:`relative bg-white dark:bg-gray-800 rounded-lg shadow-xl max-h-[90vh] max-w-[calc(100vw-2rem)] overflow-hidden ${i}`,style:{width:c,...u?{...u,zIndex:void 0}:{}},onClick:k=>k.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":r?"modal-title":void 0,children:[(r||n||l)&&d.jsxs(j,{className:"flex items-center justify-between p-4",children:[(r||n)&&d.jsxs(j,{id:"modal-title",className:"flex items-center gap-3 text-lg font-semibold text-gray-900 dark:text-white",children:[n&&d.jsx(fe,{name:n,size:"md",className:o}),r]}),l&&d.jsx(R,{onClick:t,className:"ml-auto text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 focus:outline-none","aria-label":Zg("common.close_modal"),children:d.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),d.jsx(j,{className:"px-6 py-4 overflow-y-auto max-h-[calc(90vh-140px)]",children:h})]})]})},Qg=Object.freeze(Object.defineProperty({__proto__:null,Modal:ya},Symbol.toStringTag,{value:"Module"})),va=(e,t)=>window.G7Core?.t?.(e,t)??e,wa=({isOpen:e,onClose:t,title:r,message:n,confirmText:o,cancelText:a,onConfirm:s,onCancel:l,confirmButtonVariant:f="primary",cancelButtonVariant:h="secondary",width:c="500px",closeOnOverlay:i=!0,isLoading:u=!1,loadingText:g})=>{const p=o??va("common.confirm"),m=a??va("common.cancel"),x=g??va("common.loading"),k=()=>{s()},M=()=>{u||(l?.(),t())},v=()=>{u||t()},T={primary:"bg-blue-600 text-white hover:bg-blue-700",secondary:"bg-gray-200 dark:bg-gray-700 text-gray-800 dark:text-gray-200 hover:bg-gray-300 dark:hover:bg-gray-600",danger:"bg-red-600 text-white hover:bg-red-700",ghost:"bg-transparent text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"};return d.jsxs(ya,{isOpen:e,onClose:v,title:r,width:c,children:[d.jsx(j,{className:"py-2",children:typeof n=="string"?d.jsx(Gt,{className:"text-gray-700 dark:text-gray-300",children:n}):n}),d.jsxs(j,{className:"flex justify-end gap-3 mt-6",children:[d.jsx(R,{onClick:M,disabled:u,className:"px-4 py-2 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed",children:d.jsx(te,{children:m})}),d.jsxs(R,{onClick:k,disabled:u,className:`flex items-center gap-2 px-4 py-2 rounded-lg disabled:opacity-50 disabled:cursor-not-allowed ${T[f]}`,children:[u&&d.jsx(It,{className:"fa-solid fa-spinner w-4 h-4 animate-spin"}),d.jsx(te,{children:u?x:p})]})]})]})},Jg=Object.freeze(Object.defineProperty({__proto__:null,ConfirmDialog:wa},Symbol.toStringTag,{value:"Module"})),di=C.createContext(null),ui=({value:e,children:t})=>d.jsx(di.Provider,{value:e,children:t}),Rg=()=>{const e=C.useContext(di);if(!e)throw new Error("useFileUploaderContext must be used within FileUploaderProvider");return e};function eh(e,t){return t.forEach((function(r){r&&typeof r!="string"&&!Array.isArray(r)&&Object.keys(r).forEach((function(n){if(n!=="default"&&!(n in e)){var o=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(e,n,o.get?o:{enumerable:!0,get:function(){return r[n]}})}}))})),Object.freeze(e)}function fi(e,t){return new Promise((function(r,n){let o;return th(e).then((function(a){try{return o=a,r(new Blob([t.slice(0,2),o,t.slice(2)],{type:"image/jpeg"}))}catch(s){return n(s)}}),n)}))}const th=e=>new Promise(((t,r)=>{const n=new FileReader;n.addEventListener("load",(({target:{result:o}})=>{const a=new DataView(o);let s=0;if(a.getUint16(s)!==65496)return r("not a valid JPEG");for(s+=2;;){const l=a.getUint16(s);if(l===65498)break;const f=a.getUint16(s+2);if(l===65505&&a.getUint32(s+4)===1165519206){const h=s+10;let c;switch(a.getUint16(h)){case 18761:c=!0;break;case 19789:c=!1;break;default:return r("TIFF header contains invalid endian")}if(a.getUint16(h+2,c)!==42)return r("TIFF header contains invalid version");const i=a.getUint32(h+4,c),u=h+i+2+12*a.getUint16(h+i,c);for(let g=h+i+2;g>>24&255,l[s+1]=f>>>16&255,l[s+2]=f>>>8&255,l[s+3]=f>>>0&255,new Uint8Array(l.buffer,0,s+4)},n.deflateRaw=function(o,a){a==null&&(a={level:6});var s=new Uint8Array(50+Math.floor(1.1*o.length)),l=n.F.deflateRaw(o,s,l,a.level);return new Uint8Array(s.buffer,0,l)},n.encode=function(o,a){a==null&&(a=!1);var s=0,l=n.bin.writeUint,f=n.bin.writeUshort,h={};for(var c in o){var i=!n._noNeed(c)&&!a,u=o[c],g=n.crc.crc(u,0,u.length);h[c]={cpr:i,usize:u.length,crc:g,file:i?n.deflateRaw(u):u}}for(var c in h)s+=h[c].file.length+30+46+2*n.bin.sizeUTF8(c);s+=22;var p=new Uint8Array(s),m=0,x=[];for(var c in h){var k=h[c];x.push(m),m=n._writeHeader(p,m,c,k,0)}var M=0,v=m;for(var c in h)k=h[c],x.push(m),m=n._writeHeader(p,m,c,k,1,x[M++]);var T=m-v;return l(p,m,101010256),m+=4,f(p,m+=4,M),f(p,m+=2,M),l(p,m+=2,T),l(p,m+=4,v),m+=4,m+=2,p.buffer},n._noNeed=function(o){var a=o.split(".").pop().toLowerCase();return"png,jpg,jpeg,zip".indexOf(a)!=-1},n._writeHeader=function(o,a,s,l,f,h){var c=n.bin.writeUint,i=n.bin.writeUshort,u=l.file;return c(o,a,f==0?67324752:33639248),a+=4,f==1&&(a+=2),i(o,a,20),i(o,a+=2,0),i(o,a+=2,l.cpr?8:0),c(o,a+=2,0),c(o,a+=4,l.crc),c(o,a+=4,u.length),c(o,a+=4,l.usize),i(o,a+=4,n.bin.sizeUTF8(s)),i(o,a+=2,0),a+=2,f==1&&(a+=2,a+=2,c(o,a+=6,h),a+=4),a+=n.bin.writeUTF8(o,a,s),f==0&&(o.set(u,a),a+=u.length),a},n.crc={table:(function(){for(var o=new Uint32Array(256),a=0;a<256;a++){for(var s=a,l=0;l<8;l++)1&s?s=3988292384^s>>>1:s>>>=1;o[a]=s}return o})(),update:function(o,a,s,l){for(var f=0;f>>8;return o},crc:function(o,a,s){return 4294967295^n.crc.update(4294967295,o,a,s)}},n.adler=function(o,a,s){for(var l=1,f=0,h=a,c=a+s;h>8&255},readUint:function(o,a){return 16777216*o[a+3]+(o[a+2]<<16|o[a+1]<<8|o[a])},writeUint:function(o,a,s){o[a]=255&s,o[a+1]=s>>8&255,o[a+2]=s>>16&255,o[a+3]=s>>24&255},readASCII:function(o,a,s){for(var l="",f=0;f>6,o[a+f+1]=128|c>>0&63,f+=2;else if((4294901760&c)==0)o[a+f]=224|c>>12,o[a+f+1]=128|c>>6&63,o[a+f+2]=128|c>>0&63,f+=3;else{if((4292870144&c)!=0)throw"e";o[a+f]=240|c>>18,o[a+f+1]=128|c>>12&63,o[a+f+2]=128|c>>6&63,o[a+f+3]=128|c>>0&63,f+=4}}return f},sizeUTF8:function(o){for(var a=o.length,s=0,l=0;l>>3}var x=h.lits,k=h.strt,M=h.prev,v=0,T=0,I=0,S=0,N=0,w=0;for(m>2&&(k[w=n.F._hash(o,0)]=0),u=0;u14e3||T>26697)&&m-u>100&&(p>>16,$=65535&E;if(E!=0){$=65535&E;var P=c(O=E>>>16,h.of0);h.lhst[257+P]++;var L=c($,h.df0);h.dhst[L]++,S+=h.exb[P]+h.dxb[L],x[v]=O<<23|u-p,x[v+1]=$<<16|P<<8|L,v+=2,p=u+O}else h.lhst[o[u]]++;T++}}for(I==u&&o.length!=0||(p>>3},n.F._bestMatch=function(o,a,s,l,f,h){var c=32767&a,i=s[c],u=c-i+32768&32767;if(i==c||l!=n.F._hash(o,a-u))return 0;for(var g=0,p=0,m=Math.min(32767,a);u<=m&&--h!=0&&i!=c;){if(g==0||o[a+g]==o[a+g-u]){var x=n.F._howLong(o,a,u);if(x>g){if(p=u,(g=x)>=f)break;u+2k&&(k=T,i=v)}}}u+=(c=i)-(i=s[c])+32768&32767}return g<<16|p},n.F._howLong=function(o,a,s){if(o[a]!=o[a-s]||o[a+1]!=o[a+1-s]||o[a+2]!=o[a+2-s])return 0;var l=a,f=Math.min(o.length,a+258);for(a+=3;a>>23,X=b+(8388607&F);b>16,H=B>>8&255,W=255&B;w(i,u=n.F._writeLit(257+H,L,i,u),G-S.of0[H]),u+=S.exb[H],N(i,u=n.F._writeLit(W,U,i,u),Y-S.df0[W]),u+=S.dxb[W],b+=G}}u=n.F._writeLit(256,L,i,u)}return u},n.F._copyExact=function(o,a,s,l,f){var h=f>>>3;return l[h]=s,l[h+1]=s>>>8,l[h+2]=255-l[h],l[h+3]=255-l[h+1],h+=4,l.set(new Uint8Array(o.buffer,a,s),h),f+(s+4<<3)},n.F.getTrees=function(){for(var o=n.F.U,a=n.F._hufTree(o.lhst,o.ltree,15),s=n.F._hufTree(o.dhst,o.dtree,15),l=[],f=n.F._lenCodes(o.ltree,l),h=[],c=n.F._lenCodes(o.dtree,h),i=0;i4&&o.itree[1+(o.ordr[g-1]<<1)]==0;)g--;return[a,s,u,f,c,g,l,h]},n.F.getSecond=function(o){for(var a=[],s=0;s>1)+",");return a},n.F.contSize=function(o,a){for(var s=0,l=0;l15&&(n.F._putsE(s,l,c,i),l+=i)}return l},n.F._lenCodes=function(o,a){for(var s=o.length;s!=2&&o[s-1]==0;)s-=2;for(var l=0;l>>1,138))<11?a.push(17,g-3):a.push(18,g-11),l+=2*g-2}else if(f==i&&h==f&&c==f){for(u=l+5;u+2>>1,6);a.push(16,g-3),l+=2*g-2}else a.push(f,0)}return s>>>1},n.F._hufTree=function(o,a,s){var l=[],f=o.length,h=a.length,c=0;for(c=0;cs&&(n.F.restrictDepth(u,s,v),v=s),c=0;ca;l++){var c=o[l].d;o[l].d=a,h+=f-(1<>>=s-a;h>0;)(c=o[l].d)=0;l--)o[l].d==a&&h<0&&(o[l].d--,h++);h!=0&&console.log("debt left")},n.F._goodIndex=function(o,a){var s=0;return a[16|s]<=o&&(s|=16),a[8|s]<=o&&(s|=8),a[4|s]<=o&&(s|=4),a[2|s]<=o&&(s|=2),a[1|s]<=o&&(s|=1),s},n.F._writeLit=function(o,a,s,l){return n.F._putsF(s,l,a[o<<1]),l+a[1+(o<<1)]},n.F.inflate=function(o,a){var s=Uint8Array;if(o[0]==3&&o[1]==0)return a||new s(0);var l=n.F,f=l._bitsF,h=l._bitsE,c=l._decodeTiny,i=l.makeCodes,u=l.codes2map,g=l._get17,p=l.U,m=a==null;m&&(a=new s(o.length>>>2<<3));for(var x,k,M=0,v=0,T=0,I=0,S=0,N=0,w=0,y=0,E=0;M==0;)if(M=f(o,E,1),v=f(o,E+1,2),E+=3,v!=0){if(m&&(a=n.F._check(a,y+131072)),v==1&&(x=p.flmap,k=p.fdmap,N=511,w=31),v==2){T=h(o,E,5)+257,I=h(o,E+5,5)+1,S=h(o,E+10,4)+4,E+=14;for(var O=0;O<38;O+=2)p.itree[O]=0,p.itree[O+1]=0;var $=1;for(O=0;O$&&($=P)}E+=3*S,i(p.itree,$),u(p.itree,$,p.imap),x=p.lmap,k=p.dmap,E=c(p.imap,(1<<$)-1,T+I,o,E,p.ttree);var L=l._copyOut(p.ttree,0,T,p.ltree);N=(1<>>4;if(!(b>>>8))a[y++]=b;else{if(b==256)break;var z=y+b-254;if(b>264){var F=p.ldef[b-257];z=y+(F>>>3)+h(o,E,7&F),E+=7&F}var G=k[g(o,E)&w];E+=15&G;var X=G>>>4,B=p.ddef[X],Y=(B>>>4)+f(o,E,15&B);for(E+=15&B,m&&(a=n.F._check(a,y+131072));y>>3),W=o[H-4]|o[H-3]<<8;m&&(a=n.F._check(a,y+W)),a.set(new s(o.buffer,o.byteOffset+H,W),y),E=H+W<<3,y+=W}return a.length==y?a:a.slice(0,y)},n.F._check=function(o,a){var s=o.length;if(a<=s)return o;var l=new Uint8Array(Math.max(s<<1,a));return l.set(o,0),l},n.F._decodeTiny=function(o,a,s,l,f,h){for(var c=n.F._bitsE,i=n.F._get17,u=0;u>>4;if(p<=15)h[u]=p,u++;else{var m=0,x=0;p==16?(x=3+c(l,f,2),f+=2,m=h[u-1]):p==17?(x=3+c(l,f,3),f+=3):p==18&&(x=11+c(l,f,7),f+=7);for(var k=u+x;u>>1;hf&&(f=i),h++}for(;h>1,i=o[h+1],u=c<<4|i,g=a-i,p=o[h]<>>15-a]=u,p++},n.F.revCodes=function(o,a){for(var s=n.F.U.rev15,l=15-a,f=0;f>>l}},n.F._putsE=function(o,a,s){s<<=7&a;var l=a>>>3;o[l]|=s,o[l+1]|=s>>>8},n.F._putsF=function(o,a,s){s<<=7&a;var l=a>>>3;o[l]|=s,o[l+1]|=s>>>8,o[l+2]|=s>>>16},n.F._bitsE=function(o,a,s){return(o[a>>>3]|o[1+(a>>>3)]<<8)>>>(7&a)&(1<>>3]|o[1+(a>>>3)]<<8|o[2+(a>>>3)]<<16)>>>(7&a)&(1<>>3]|o[1+(a>>>3)]<<8|o[2+(a>>>3)]<<16)>>>(7&a)},n.F._get25=function(o,a){return(o[a>>>3]|o[1+(a>>>3)]<<8|o[2+(a>>>3)]<<16|o[3+(a>>>3)]<<24)>>>(7&a)},n.F.U=(t=Uint16Array,r=Uint32Array,{next_code:new t(16),bl_count:new t(16),ordr:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],of0:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],exb:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],ldef:new t(32),df0:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],dxb:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],ddef:new r(32),flmap:new t(512),fltree:[],fdmap:new t(32),fdtree:[],lmap:new t(32768),ltree:[],ttree:[],dmap:new t(32768),dtree:[],imap:new t(512),itree:[],rev15:new t(32768),lhst:new r(286),dhst:new r(30),ihst:new r(19),lits:new r(15e3),strt:new t(65536),prev:new t(32768)}),(function(){for(var o=n.F.U,a=0;a<32768;a++){var s=a;s=(4278255360&(s=(4042322160&(s=(3435973836&(s=(2863311530&s)>>>1|(1431655765&s)<<1))>>>2|(858993459&s)<<2))>>>4|(252645135&s)<<4))>>>8|(16711935&s)<<8,o.rev15[a]=(s>>>16|s<<16)>>>17}function l(f,h,c){for(;h--!=0;)f.push(0,c)}for(a=0;a<32;a++)o.ldef[a]=o.of0[a]<<3|o.exb[a],o.ddef[a]=o.df0[a]<<4|o.dxb[a];l(o.fltree,144,8),l(o.fltree,112,9),l(o.fltree,24,7),l(o.fltree,8,8),n.F.makeCodes(o.fltree,9),n.F.codes2map(o.fltree,9,o.flmap),n.F.revCodes(o.fltree,9),l(o.fdtree,32,5),n.F.makeCodes(o.fdtree,5),n.F.codes2map(o.fdtree,5,o.fdmap),n.F.revCodes(o.fdtree,5),l(o.itree,19,0),l(o.ltree,286,0),l(o.dtree,30,0),l(o.ttree,320,0)})()})();var nh=eh({__proto__:null,default:Wn},[Wn]);const Xt=(function(){var e={nextZero(c,i){for(;c[i]!=0;)i++;return i},readUshort:(c,i)=>c[i]<<8|c[i+1],writeUshort(c,i,u){c[i]=u>>8&255,c[i+1]=255&u},readUint:(c,i)=>16777216*c[i]+(c[i+1]<<16|c[i+2]<<8|c[i+3]),writeUint(c,i,u){c[i]=u>>24&255,c[i+1]=u>>16&255,c[i+2]=u>>8&255,c[i+3]=255&u},readASCII(c,i,u){let g="";for(let p=0;pc.length<2?`0${c}`:c,readUTF8(c,i,u){let g,p="";for(let m=0;m>3)]>>7-((7&S)<<0)&1);k[y]=F[P],k[y+1]=F[P+1],k[y+2]=F[P+2],k[y+3]=L>2)]>>6-((3&S)<<1)&3),k[y]=F[P],k[y+1]=F[P+1],k[y+2]=F[P+2],k[y+3]=L>1)]>>4-((1&S)<<2)&15),k[y]=F[P],k[y+1]=F[P+1],k[y+2]=F[P+2],k[y+3]=L>>3)]>>>7-(7&b)&1))==255*w?0:255;M[G+b]=z<<24|U<<16|U<<8|U}else if(T==2)for(b=0;b>>2)]>>>6-((3&b)<<1)&3))==85*w?0:255,M[G+b]=z<<24|U<<16|U<<8|U;else if(T==4)for(b=0;b>>1)]>>>4-((1&b)<<2)&15))==17*w?0:255,M[G+b]=z<<24|U<<16|U<<8|U;else if(T==8)for(b=0;b>3,w=Math.ceil(T*S/8),y=new Uint8Array(I*w);let E=0;const O=[0,0,4,0,2,0,1],$=[0,4,0,2,0,1,0],P=[8,8,8,4,4,2,2],L=[8,8,4,4,2,2,1];let U=0;for(;U<7;){const b=P[U],z=L[U];let F=0,G=0,X=O[U];for(;X>3])>>7-(7&be)&1,y[W*w+(Q>>3)]|=_<<7-((7&Q)<<0)),S==2&&(_=(_=M[be>>3])>>6-(7&be)&3,y[W*w+(Q>>2)]|=_<<6-((3&Q)<<1)),S==4&&(_=(_=M[be>>3])>>4-(7&be)&15,y[W*w+(Q>>1)]|=_<<4-((1&Q)<<2)),S>=8){const se=W*w+Q*N;for(let pe=0;pe>3)+pe]}be+=S,Q+=z}H++,W+=b}F*G!=0&&(E+=G*(1+Y)),U+=1}return y})(i,c)),i}function n(c,i){return o(new Uint8Array(c.buffer,2,c.length-6),i)}var o=(function(){const c={H:{}};return c.H.N=function(i,u){const g=Uint8Array;let p,m,x=0,k=0,M=0,v=0,T=0,I=0,S=0,N=0,w=0;if(i[0]==3&&i[1]==0)return u||new g(0);const y=c.H,E=y.b,O=y.e,$=y.R,P=y.n,L=y.A,U=y.Z,_=y.m,b=u==null;for(b&&(u=new g(i.length>>>2<<5));x==0;)if(x=E(i,w,1),k=E(i,w+1,2),w+=3,k!=0){if(b&&(u=c.H.W(u,N+(1<<17))),k==1&&(p=_.J,m=_.h,I=511,S=31),k==2){M=O(i,w,5)+257,v=O(i,w+5,5)+1,T=O(i,w+10,4)+4,w+=14;let F=1;for(var z=0;z<38;z+=2)_.Q[z]=0,_.Q[z+1]=0;for(z=0;zF&&(F=B)}w+=3*T,P(_.Q,F),L(_.Q,F,_.u),p=_.w,m=_.d,w=$(_.u,(1<>>4;if(!(G>>>8))u[N++]=G;else{if(G==256)break;{let X=N+G-254;if(G>264){const Q=_.q[G-257];X=N+(Q>>>3)+O(i,w,7&Q),w+=7&Q}const B=m[U(i,w)&S];w+=15&B;const Y=B>>>4,H=_.c[Y],W=(H>>>4)+E(i,w,15&H);for(w+=15&H;N>>3),G=i[F-4]|i[F-3]<<8;b&&(u=c.H.W(u,N+G)),u.set(new g(i.buffer,i.byteOffset+F,G),N),w=F+G<<3,N+=G}return u.length==N?u:u.slice(0,N)},c.H.W=function(i,u){const g=i.length;if(u<=g)return i;const p=new Uint8Array(g<<1);return p.set(i,0),p},c.H.R=function(i,u,g,p,m,x){const k=c.H.e,M=c.H.Z;let v=0;for(;v>>4;if(I<=15)x[v]=I,v++;else{let S=0,N=0;I==16?(N=3+k(p,m,2),m+=2,S=x[v-1]):I==17?(N=3+k(p,m,3),m+=3):I==18&&(N=11+k(p,m,7),m+=7);const w=v+N;for(;v>>1;for(;xm&&(m=M),x++}for(;x>1,M=i[x+1],v=k<<4|M,T=u-M;let I=i[x]<>>15-u]=v,I++}},c.H.l=function(i,u){const g=c.H.m.r,p=15-u;for(let m=0;m>>p}},c.H.M=function(i,u,g){g<<=7&u;const p=u>>>3;i[p]|=g,i[p+1]|=g>>>8},c.H.I=function(i,u,g){g<<=7&u;const p=u>>>3;i[p]|=g,i[p+1]|=g>>>8,i[p+2]|=g>>>16},c.H.e=function(i,u,g){return(i[u>>>3]|i[1+(u>>>3)]<<8)>>>(7&u)&(1<>>3]|i[1+(u>>>3)]<<8|i[2+(u>>>3)]<<16)>>>(7&u)&(1<>>3]|i[1+(u>>>3)]<<8|i[2+(u>>>3)]<<16)>>>(7&u)},c.H.i=function(i,u){return(i[u>>>3]|i[1+(u>>>3)]<<8|i[2+(u>>>3)]<<16|i[3+(u>>>3)]<<24)>>>(7&u)},c.H.m=(function(){const i=Uint16Array,u=Uint32Array;return{K:new i(16),j:new i(16),X:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],S:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],T:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],q:new i(32),p:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],z:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],c:new u(32),J:new i(512),_:[],h:new i(32),$:[],w:new i(32768),C:[],v:[],d:new i(32768),D:[],u:new i(512),Q:[],r:new i(32768),s:new u(286),Y:new u(30),a:new u(19),t:new u(15e3),k:new i(65536),g:new i(32768)}})(),(function(){const i=c.H.m;for(var u=0;u<32768;u++){let p=u;p=(2863311530&p)>>>1|(1431655765&p)<<1,p=(3435973836&p)>>>2|(858993459&p)<<2,p=(4042322160&p)>>>4|(252645135&p)<<4,p=(4278255360&p)>>>8|(16711935&p)<<8,i.r[u]=(p>>>16|p<<16)>>>17}function g(p,m,x){for(;m--!=0;)p.push(0,x)}for(u=0;u<32;u++)i.q[u]=i.S[u]<<3|i.T[u],i.c[u]=i.p[u]<<4|i.z[u];g(i._,144,8),g(i._,112,9),g(i._,24,7),g(i._,8,8),c.H.n(i._,9),c.H.A(i._,9,i.J),c.H.l(i._,9),g(i.$,32,5),c.H.n(i.$,5),c.H.A(i.$,5,i.h),c.H.l(i.$,5),g(i.Q,19,0),g(i.C,286,0),g(i.D,30,0),g(i.v,320,0)})(),c.H.N})();function a(c){return[1,null,3,1,2,null,4][c.ctype]*c.depth}function s(c,i,u,g,p){let m=a(i);const x=Math.ceil(g*m/8);let k,M;m=Math.ceil(m/8);let v=c[u],T=0;if(v>1&&(c[u]=[0,0,1][v-2]),v==3)for(T=m;T>>1)&255;for(let I=0;I>>1);for(;T>>1)}else{for(;T=0&&k>=0?(I=U*i+_<<2,S=(k+U)*p+x+_<<2):(I=(-k+U)*i-x+_<<2,S=U*p+_<<2),M==0)g[S]=c[I],g[S+1]=c[I+1],g[S+2]=c[I+2],g[S+3]=c[I+3];else if(M==1){var N=c[I+3]*.00392156862745098,w=c[I]*N,y=c[I+1]*N,E=c[I+2]*N,O=g[S+3]*(1/255),$=g[S]*O,P=g[S+1]*O,L=g[S+2]*O;const b=1-N,z=N+O*b,F=z==0?0:1/z;g[S+3]=255*z,g[S+0]=(w+$*b)*F,g[S+1]=(y+P*b)*F,g[S+2]=(E+L*b)*F}else if(M==2)N=c[I+3],w=c[I],y=c[I+1],E=c[I+2],O=g[S+3],$=g[S],P=g[S+1],L=g[S+2],N==O&&w==$&&y==P&&E==L?(g[S]=0,g[S+1]=0,g[S+2]=0,g[S+3]=0):(g[S]=w,g[S+1]=y,g[S+2]=E,g[S+3]=N);else if(M==3){if(N=c[I+3],w=c[I],y=c[I+1],E=c[I+2],O=g[S+3],$=g[S],P=g[S+1],L=g[S+2],N==O&&w==$&&y==P&&E==L)continue;if(N<220&&O>20)return!1}return!0}return{decode:function(i){const u=new Uint8Array(i);let g=8;const p=e,m=p.readUshort,x=p.readUint,k={tabs:{},frames:[]},M=new Uint8Array(u.length);let v,T=0,I=0;const S=[137,80,78,71,13,10,26,10];for(var N=0;N<8;N++)if(u[N]!=S[N])throw"The input is not a PNG file!";for(;g>>1:E>>>=1;w[y]=E}return w})(),update(w,y,E,O){for(let $=0;$>>8;return w},crc:(w,y,E)=>4294967295^n.update(4294967295,w,y,E)};function o(w,y,E,O){y[E]+=w[0]*O>>4,y[E+1]+=w[1]*O>>4,y[E+2]+=w[2]*O>>4,y[E+3]+=w[3]*O>>4}function a(w){return Math.max(0,Math.min(255,w))}function s(w,y){const E=w[0]-y[0],O=w[1]-y[1],$=w[2]-y[2],P=w[3]-y[3];return E*E+O*O+$*$+P*P}function l(w,y,E,O,$,P,L){L==null&&(L=1);const U=O.length,_=[];for(var b=0;b>>0&255,W>>>8&255,W>>>16&255,W>>>24&255])}for(b=0;b>2]=z,X[b>>2]=O[z]}}function f(w,y,E,O,$){$==null&&($={});const{crc:P}=n,L=t.writeUint,U=t.writeUshort,_=t.writeASCII;let b=8;const z=w.frames.length>1;let F,G=!1,X=33+(z?20:0);if($.sRGB!=null&&(X+=13),$.pHYs!=null&&(X+=21),$.iCCP!=null&&(F=pako.deflate($.iCCP),X+=21+F.length+4),w.ctype==3){for(var B=w.plte.length,Y=0;Y>>24!=255&&(G=!0);X+=8+3*B+4+(G?8+1*B+4:0)}for(var H=0;H>>8&255,We=ne>>>16&255;W[b+pe+0]=Ae,W[b+pe+1]=ve,W[b+pe+2]=We}if(b+=3*B,L(W,b,P(W,b-3*B-4,3*B+4)),b+=4,G){for(L(W,b,B),b+=4,_(W,b,"tRNS"),b+=4,Y=0;Y>>24&255;b+=B,L(W,b,P(W,b-B-4,B+4)),b+=4}}let be=0;for(H=0;HDe&&(De=Je),qeYe&&(Ye=qe));De==-1&&(_e=xe=De=Ye=0),K&&((1&_e)==1&&_e--,(1&xe)==1&&xe--);const rt=(De-_e+1)*(Ye-xe+1);rt>2,ze>>2);pe.push(ne);const K=new Uint8Array(we.abuf,$e,ze);z&&l(Ae.img,Ae.rect.width,Ae.rect.height,se,K,ne),Ae.img.set(K),$e+=ze}}else for(B=0;Bve&&Oe==ge[H-ve])ne[H]=ne[H-ve];else{let we=be[Oe];if(we==null&&(be[Oe]=we=se.length,se.push(Oe),se.length>=300))break;ne[H]=we}}}const We=se.length;for(We<=256&&b==0&&(G=We<=2?1:We<=4?2:We<=16?4:8,G=Math.max(G,_)),B=0;B>1)]|=ze[oe+Te]<<4-4*(1&Te);else if(G==2)for(Te=0;Te>2)]|=ze[oe+Te]<<6-2*(3&Te);else if(G==1)for(Te=0;Te>3)]|=ze[oe+Te]<<7-1*(7&Te)}Oe=me,F=3,$e=1}else if(W==0&&Q.length==1){me=new Uint8Array(ve*ge*3);const ze=ve*ge;for(H=0;HH&&(H=pe),neW&&(W=ne))}H==-1&&(B=Y=H=W=0),L&&((1&B)==1&&B--,(1&Y)==1&&Y--),P={x:B,y:Y,width:H-B+1,height:W-Y+1};const Q=O[$];Q.rect=P,Q.blend=1,Q.img=new Uint8Array(P.width*P.height*4),O[$-1].dispose==0?(e(b,y,E,Q.img,P.width,P.height,-P.x,-P.y,0),u(G,y,E,Q.img,P)):e(G,y,E,Q.img,P.width,P.height,-P.x,-P.y,0)}function u(w,y,E,O,$){e(w,y,E,O,$.width,$.height,-$.x,-$.y,2)}function g(w,y,E,O,$,P,L){const U=[];let _,b=[0,1,2,3,4];P!=-1?b=[P]:(y*O>5e5||E==1)&&(b=[0]),L&&(_={level:0});const z=nh;for(var F=0;F>1)+256&255;if(P==4)for(_=$;_>1)&255;for(_=$;_>1)&255}if(P==4){for(_=0;_<$;_++)w[U+_]=y[L+_]+256-r(0,y[L+_-O],0)&255;for(_=$;_>2);let z;if(E.length<2e7)for(var F=0;F<_;F+=4)z=k(L,G=E[F]*.00392156862745098,X=E[F+1]*.00392156862745098,B=E[F+2]*.00392156862745098,Y=E[F+3]*.00392156862745098),b[F>>2]=z.ind,$[F>>2]=z.est.rgba;else for(F=0;F<_;F+=4){var G=E[F]*.00392156862745098,X=E[F+1]*(1/255),B=E[F+2]*(1/255),Y=E[F+3]*(1/255);for(z=L;z.left;)z=M(z.est,G,X,B,Y)<=0?z.left:z.right;b[F>>2]=z.ind,$[F>>2]=z.est.rgba}return{abuf:O.buffer,inds:b,plte:U}}function x(w,y,E){E==null&&(E=1e-4);const O=new Uint32Array(w.buffer),$={i0:0,i1:w.length,bst:null,est:null,tdst:0,left:null,right:null};$.bst=I(w,$.i0,$.i1),$.est=S($.bst);const P=[$];for(;P.lengthU&&(U=P[L].est.L,_=L);if(U=z||b.i1<=z){b.est.L=0;continue}const F={i0:b.i0,i1:z,bst:null,est:null,tdst:0,left:null,right:null};F.bst=I(w,F.i0,F.i1),F.est=S(F.bst);const G={i0:z,i1:b.i1,bst:null,est:null,tdst:0,left:null,right:null};for(G.bst={R:[],m:[],N:b.bst.N-F.bst.N},L=0;L<16;L++)G.bst.R[L]=b.bst.R[L]-F.bst.R[L];for(L=0;L<4;L++)G.bst.m[L]=b.bst.m[L]-F.bst.m[L];G.est=S(G.bst),b.left=F,b.right=G,P[_]=F,P.push(G)}for(P.sort(((U,_)=>_.bst.N-U.bst.N)),L=0;L0&&(L=w.right,U=w.left);const _=k(L,y,E,O,$);if(_.tdst<=P*P)return _;const b=k(U,y,E,O,$);return b.tdst<_.tdst?b:_}function M(w,y,E,O,$){const{e:P}=w;return P[0]*y+P[1]*E+P[2]*O+P[3]*$-w.eMq}function v(w,y,E,O,$,P){for(O-=4;EP;)O-=4;if(E>=O)break;const L=y[E>>2];y[E>>2]=y[O>>2],y[O>>2]=L,E+=4,O-=4}for(;T(w,E,$)>P;)E-=4;return E+4}function T(w,y,E){return w[y]*E[0]+w[y+1]*E[1]+w[y+2]*E[2]+w[y+3]*E[3]}function I(w,y,E){const O=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],$=[0,0,0,0],P=E-y>>2;for(let L=y;L>>0}}var N={multVec:(w,y)=>[w[0]*y[0]+w[1]*y[1]+w[2]*y[2]+w[3]*y[3],w[4]*y[0]+w[5]*y[1]+w[6]*y[2]+w[7]*y[3],w[8]*y[0]+w[9]*y[1]+w[10]*y[2]+w[11]*y[3],w[12]*y[0]+w[13]*y[1]+w[14]*y[2]+w[15]*y[3]],dot:(w,y)=>w[0]*y[0]+w[1]*y[1]+w[2]*y[2]+w[3]*y[3],sml:(w,y)=>[w*y[0],w*y[1],w*y[2],w*y[3]]};Xt.encode=function(y,E,O,$,P,L,U){$==null&&($=0),U==null&&(U=!1);const _=c(y,E,O,$,[!1,!1,!1,0,U,!1]);return h(_,-1),f(_,E,O,P,L)},Xt.encodeLL=function(y,E,O,$,P,L,U,_){const b={ctype:0+($==1?0:2)+(P==0?0:4),depth:L,frames:[]},z=($+P)*L,F=z*E;for(let G=0;G>>0),I(1),I(32),S(3),S(f),S(2835),S(2835),N(8),S(16711680),S(65280),S(255),S(4278190080),S(1466527264),(function w(){for(;M0;){for(x=122+M*l,g=0;g>>24,i.setUint32(x+g,p<<8|m),g+=4;M++}T{t(new Blob([r],{type:"image/bmp"}))}))},_dly:9};var kt={CHROME:"CHROME",FIREFOX:"FIREFOX",DESKTOP_SAFARI:"DESKTOP_SAFARI",IE:"IE",IOS:"IOS",ETC:"ETC"},oh={[kt.CHROME]:16384,[kt.FIREFOX]:11180,[kt.DESKTOP_SAFARI]:16384,[kt.IE]:8192,[kt.IOS]:4096,[kt.ETC]:8192};const xa=typeof window<"u",hi=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,Vn=xa&&window.cordova&&window.cordova.require&&window.cordova.require("cordova/modulemapper"),ah=(xa||hi)&&(Vn&&Vn.getOriginalSymbol(window,"File")||typeof File<"u"&&File),pi=(xa||hi)&&(Vn&&Vn.getOriginalSymbol(window,"FileReader")||typeof FileReader<"u"&&FileReader);function ka(e,t,r=Date.now()){return new Promise((n=>{const o=e.split(","),a=o[0].match(/:(.*?);/)[1],s=globalThis.atob(o[1]);let l=s.length;const f=new Uint8Array(l);for(;l--;)f[l]=s.charCodeAt(l);const h=new Blob([f],{type:a});h.name=t,h.lastModified=r,n(h)}))}function mi(e){return new Promise(((t,r)=>{const n=new pi;n.onload=()=>t(n.result),n.onerror=o=>r(o),n.readAsDataURL(e)}))}function bi(e){return new Promise(((t,r)=>{const n=new Image;n.onload=()=>t(n),n.onerror=o=>r(o),n.src=e}))}function wr(){if(wr.cachedResult!==void 0)return wr.cachedResult;let e=kt.ETC;const{userAgent:t}=navigator;return/Chrom(e|ium)/i.test(t)?e=kt.CHROME:/iP(ad|od|hone)/i.test(t)&&/WebKit/i.test(t)?e=kt.IOS:/Safari/i.test(t)?e=kt.DESKTOP_SAFARI:/Firefox/i.test(t)?e=kt.FIREFOX:(/MSIE/i.test(t)||document.documentMode)&&(e=kt.IE),wr.cachedResult=e,wr.cachedResult}function yi(e,t){const r=wr(),n=oh[r];let o=e,a=t,s=o*a;const l=o>a?a/o:o/a;for(;s>n*n;){const f=(n+o)/2,h=(n+a)/2;fgi.toBlob(e,c))).then(function(c){try{return l=c,l.name=r,l.lastModified=n,h.call(this)}catch(i){return s(i)}}.bind(this),s);{let c=function(){return h.call(this)};if(typeof OffscreenCanvas=="function"&&e instanceof OffscreenCanvas)return e.convertToBlob({type:t,quality:o}).then(function(i){try{return l=i,l.name=r,l.lastModified=n,c.call(this)}catch(u){return s(u)}}.bind(this),s);{let i;return i=e.toDataURL(t,o),ka(i,r,n).then(function(u){try{return l=u,c.call(this)}catch(g){return s(g)}}.bind(this),s)}}}function f(){return a(l)}}))}function Qt(e){e.width=0,e.height=0}function Hr(){return new Promise((function(e,t){let r,n,o,a;return Hr.cachedResult!==void 0?e(Hr.cachedResult):ka("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAEAAgMBEQACEQEDEQH/xABKAAEAAAAAAAAAAAAAAAAAAAALEAEAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAAAAAAAAAAAAAAAEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwA/8H//2Q==","test.jpg",Date.now()).then((function(s){try{return r=s,Xn(r).then((function(l){try{return n=l[1],qn(n,r.type,r.name,r.lastModified).then((function(f){try{return o=f,Qt(n),Xn(o).then((function(h){try{return a=h[0],Hr.cachedResult=a.width===1&&a.height===2,e(Hr.cachedResult)}catch(c){return t(c)}}),t)}catch(h){return t(h)}}),t)}catch(f){return t(f)}}),t)}catch(l){return t(l)}}),t)}))}function wi(e){return new Promise(((t,r)=>{const n=new pi;n.onload=o=>{const a=new DataView(o.target.result);if(a.getUint16(0,!1)!=65496)return t(-2);const s=a.byteLength;let l=2;for(;lr(o),n.readAsArrayBuffer(e)}))}function xi(e,t){const{width:r}=e,{height:n}=e,{maxWidthOrHeight:o}=t;let a,s=e;return isFinite(o)&&(r>o||n>o)&&([s,a]=Kn(r,n),r>n?(s.width=o,s.height=n/r*o):(s.width=r/n*o,s.height=o),a.drawImage(e,0,0,s.width,s.height),Qt(e)),s}function ki(e,t){const{width:r}=e,{height:n}=e,[o,a]=Kn(r,n);switch(t>4&&t<9?(o.width=n,o.height=r):(o.width=r,o.height=n),t){case 2:a.transform(-1,0,0,1,r,0);break;case 3:a.transform(-1,0,0,-1,r,n);break;case 4:a.transform(1,0,0,-1,0,n);break;case 5:a.transform(0,1,1,0,0,0);break;case 6:a.transform(0,1,-1,0,n,0);break;case 7:a.transform(0,-1,-1,0,n,r);break;case 8:a.transform(0,-1,1,0,0,r)}return a.drawImage(e,0,0,r,n),Qt(e),o}function Ci(e,t,r=0){return new Promise((function(n,o){let a,s,l,f,h,c,i,u,g,p,m,x,k,M,v,T,I,S,N,w;function y(O=5){if(t.signal&&t.signal.aborted)throw t.signal.reason;a+=O,t.onProgress(Math.min(a,100))}function E(O){if(t.signal&&t.signal.aborted)throw t.signal.reason;a=Math.min(Math.max(O,a),100),t.onProgress(a)}return a=r,s=t.maxIteration||10,l=1024*t.maxSizeMB*1024,y(),Xn(e,t).then(function(O){try{return[,f]=O,y(),h=xi(f,t),y(),new Promise((function($,P){var L;if(!(L=t.exifOrientation))return wi(e).then(function(_){try{return L=_,U.call(this)}catch(b){return P(b)}}.bind(this),P);function U(){return $(L)}return U.call(this)})).then(function($){try{return c=$,y(),Hr().then(function(P){try{return i=P?h:ki(h,c),y(),u=t.initialQuality||1,g=t.fileType||e.type,qn(i,g,e.name,e.lastModified,u).then(function(L){try{{let _=function(){if(s--&&(v>l||v>k)){let z,F;return z=w?.95*N.width:N.width,F=w?.95*N.height:N.height,[I,S]=Kn(z,F),S.drawImage(N,0,0,z,F),u*=g==="image/png"?.85:.95,qn(I,g,e.name,e.lastModified,u).then((function(G){try{return T=G,Qt(N),N=I,v=T.size,E(Math.min(99,Math.floor((M-v)/(M-l)*100))),_}catch(X){return o(X)}}),o)}return[1]},b=function(){return Qt(N),Qt(I),Qt(h),Qt(i),Qt(f),E(100),n(T)};if(p=L,y(),m=p.size>l,x=p.size>e.size,!m&&!x)return E(100),n(p);var U;return k=e.size,M=p.size,v=M,N=i,w=!t.alwaysKeepResolution&&m,(U=function(z){for(;z;){if(z.then)return void z.then(U,o);try{if(z.pop){if(z.length)return z.pop()?b.call(this):z;z=_}else z=z.call(this)}catch(F){return o(F)}}}.bind(this))(_)}}catch(_){return o(_)}}.bind(this),o)}catch(L){return o(L)}}.bind(this),o)}catch(P){return o(P)}}.bind(this),o)}catch($){return o($)}}.bind(this),o)}))}const sh=` + `.trim().replace(/\s+/g," ");return d.jsx(j,{id:a,className:c,dangerouslySetInnerHTML:{__html:h},...s})},qg=Object.freeze(Object.defineProperty({__proto__:null,HtmlContent:ha},Symbol.toStringTag,{value:"Module"})),pa=()=>window.G7Core,ma=(e,t)=>pa()?.t?.(e,t)??e,ii=({content:e="",onChange:t,isHtml:r=!1,onIsHtmlChange:n,rows:o=15,placeholder:a="",label:s,showHtmlModeToggle:l=!0,contentClassName:f="",purifyConfig:h,className:c="",name:i="content",htmlFieldName:u="content_mode",readOnly:g=!1,id:p,editorAttrs:m})=>{const[x,k]=C.useState(r),[M,v]=C.useState(e),[T,I]=C.useState(!1);C.useEffect(()=>{k(r)},[r]),C.useEffect(()=>{v(e)},[e]);const S=C.useCallback(y=>{const E=y.target.value;if(v(E),t){const O=pa()?.createChangeEvent?.({value:E,name:i,type:"textarea"})??{target:{name:i,value:E}};t(O)}},[t,i]),N=C.useCallback(y=>{const E=y.target.checked;if(k(E),E||I(!1),n){const O=pa()?.createChangeEvent?.({checked:E,name:u,type:"checkbox"})??{target:{name:u,checked:E}};n(O)}},[n,u]),w=C.useCallback(()=>{I(y=>!y)},[]);return d.jsxs(j,{className:`space-y-2 ${c}`,id:p,...m,children:[d.jsxs(j,{className:"flex items-center justify-between",children:[s&&d.jsx(Ar,{className:"block text-sm font-medium text-gray-500 dark:text-gray-400",children:s}),d.jsxs(j,{className:"flex items-center gap-3",children:[x&&!g&&d.jsx(R,{type:"button",onClick:w,className:`px-3 py-1.5 text-xs font-bold rounded-lg focus:outline-none focus:ring-2 ${T?"text-gray-700 dark:text-gray-200 bg-gray-200 dark:bg-gray-600 border border-gray-300 dark:border-gray-500 hover:bg-gray-300 dark:hover:bg-gray-500 focus:ring-gray-400 dark:focus:ring-gray-500":"text-blue-600 dark:text-blue-400 bg-white dark:bg-gray-700 border border-blue-300 dark:border-blue-600 hover:bg-blue-50 dark:hover:bg-gray-600 focus:ring-blue-500 dark:focus:ring-blue-600"}`,children:ma(T?"common.preview_off":"common.preview")}),l&&d.jsxs(Ar,{className:"flex items-center gap-2 p-2 cursor-pointer",children:[d.jsx(At,{type:"checkbox",name:u,checked:x,onChange:N,disabled:g,className:"w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600"}),d.jsx(j,{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:ma("common.html_mode")})]})]})]}),!T&&d.jsx(Co,{name:i,value:M,onChange:S,placeholder:a,rows:o,readOnly:g,className:`block w-full rounded-lg border px-3 py-2 text-sm placeholder-gray-400 dark:placeholder-gray-500 focus:outline-none focus:ring-1 disabled:opacity-50 disabled:cursor-not-allowed ${x?"font-mono bg-white dark:bg-gray-800 border-blue-300 dark:border-blue-600 text-gray-800 dark:text-gray-200 focus:border-blue-500 focus:ring-blue-500":"bg-white dark:bg-gray-800 border-gray-300 dark:border-gray-600 text-gray-900 dark:text-white focus:border-blue-500 focus:ring-blue-500"}`}),T&&d.jsx(j,{className:"p-4 bg-gray-50 dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 min-h-[400px]",children:d.jsx(ha,{content:M,isHtml:!0,className:f||"prose dark:prose-invert max-w-none text-gray-900 dark:text-gray-100",purifyConfig:h})})]})},Zg=Object.freeze(Object.defineProperty({__proto__:null,HtmlEditor:ii},Symbol.toStringTag,{value:"Module"})),ci=e=>window.G7Core?.t?.(e)??e,ba=({maxHeight:e=500,expandText:t,collapseText:r,className:n="",children:o,id:a,editorAttrs:s})=>{const[l,f]=C.useState(!1),[h,c]=C.useState(!1),i=C.useRef(null),u=C.useCallback(()=>{if(i.current){const x=i.current.scrollHeight;c(x>e)}},[e]);C.useEffect(()=>{u();const x=i.current;if(!x)return;const k=x.querySelectorAll("img");k.forEach(v=>{v.complete||v.addEventListener("load",u)});let M=null;return typeof ResizeObserver<"u"&&(M=new ResizeObserver(u),M.observe(x)),()=>{k.forEach(v=>{v.removeEventListener("load",u)}),M?.disconnect()}},[u,o]);const g=()=>{f(x=>!x)},p=t||ci("sirsoft-ecommerce.shop.product.expand_detail"),m=r||ci("sirsoft-ecommerce.shop.product.collapse_detail");return d.jsxs(j,{className:n,id:a,...s,children:[d.jsxs(j,{className:"relative",children:[d.jsx(j,{ref:i,className:!l&&h?"overflow-hidden transition-[max-height] duration-300 ease-in-out":"transition-[max-height] duration-300 ease-in-out",style:!l&&h?{maxHeight:`${e}px`}:void 0,children:o}),!l&&h&&d.jsx(j,{className:"absolute bottom-0 left-0 right-0 h-24 bg-gradient-to-t from-white dark:from-gray-900 to-transparent pointer-events-none"})]}),h&&d.jsxs(R,{type:"button",onClick:g,className:"flex items-center justify-center w-full py-3.5 bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors cursor-pointer gap-1.5",children:[d.jsx(te,{className:"text-sm font-semibold text-gray-600 dark:text-gray-400",children:l?m:p}),d.jsx(fe,{name:l?"chevron-up":"chevron-down",size:"sm"})]})]})},Qg=Object.freeze(Object.defineProperty({__proto__:null,ExpandableContent:ba,default:ba},Symbol.toStringTag,{value:"Module"})),Jg=(e,t)=>window.G7Core?.t?.(e,t)??e,ya=({isOpen:e,onClose:t,title:r,icon:n,iconClassName:o="text-gray-500 dark:text-gray-400",closeOnBackdropClick:a=!0,closeOnOverlayClick:s,showCloseButton:l=!0,closeOnEscape:f=!0,children:h,width:c="500px",className:i="",style:u})=>{const g=s!==void 0?s:a,p=C.useRef(null),m=C.useRef(null);if(C.useEffect(()=>{const k=M=>{M.key==="Escape"&&e&&f&&t()};if(e&&f)return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[e,t,f]),C.useEffect(()=>{if(e&&p.current){m.current=document.activeElement;const k=p.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),M=k[0],v=k[k.length-1];M?.focus();const T=I=>{I.key==="Tab"&&(I.shiftKey?document.activeElement===M&&(I.preventDefault(),v?.focus()):document.activeElement===v&&(I.preventDefault(),M?.focus()))};return document.addEventListener("keydown",T),()=>{document.removeEventListener("keydown",T),m.current?.focus()}}},[e]),C.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),!e)return null;const x=u?.zIndex??50;return d.jsxs(j,{className:"fixed inset-0 flex items-center justify-center",style:{zIndex:x},onClick:g?t:void 0,children:[d.jsx(j,{className:"absolute inset-0 bg-black/50","aria-hidden":"true"}),d.jsxs(j,{ref:p,className:`relative bg-white dark:bg-gray-800 rounded-lg shadow-xl max-h-[90vh] max-w-[calc(100vw-2rem)] overflow-hidden ${i}`,style:{width:c,...u?{...u,zIndex:void 0}:{}},onClick:k=>k.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":r?"modal-title":void 0,children:[(r||n||l)&&d.jsxs(j,{className:"flex items-center justify-between p-4",children:[(r||n)&&d.jsxs(j,{id:"modal-title",className:"flex items-center gap-3 text-lg font-semibold text-gray-900 dark:text-white",children:[n&&d.jsx(fe,{name:n,size:"md",className:o}),r]}),l&&d.jsx(R,{onClick:t,className:"ml-auto text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 focus:outline-none","aria-label":Jg("common.close_modal"),children:d.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),d.jsx(j,{className:"px-6 py-4 overflow-y-auto max-h-[calc(90vh-140px)]",children:h})]})]})},Rg=Object.freeze(Object.defineProperty({__proto__:null,Modal:ya},Symbol.toStringTag,{value:"Module"})),va=(e,t)=>window.G7Core?.t?.(e,t)??e,wa=({isOpen:e,onClose:t,title:r,message:n,confirmText:o,cancelText:a,onConfirm:s,onCancel:l,confirmButtonVariant:f="primary",cancelButtonVariant:h="secondary",width:c="500px",closeOnOverlay:i=!0,isLoading:u=!1,loadingText:g})=>{const p=o??va("common.confirm"),m=a??va("common.cancel"),x=g??va("common.loading"),k=()=>{s()},M=()=>{u||(l?.(),t())},v=()=>{u||t()},T={primary:"bg-blue-600 text-white hover:bg-blue-700",secondary:"bg-gray-200 dark:bg-gray-700 text-gray-800 dark:text-gray-200 hover:bg-gray-300 dark:hover:bg-gray-600",danger:"bg-red-600 text-white hover:bg-red-700",ghost:"bg-transparent text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"};return d.jsxs(ya,{isOpen:e,onClose:v,title:r,width:c,children:[d.jsx(j,{className:"py-2",children:typeof n=="string"?d.jsx(Gt,{className:"text-gray-700 dark:text-gray-300",children:n}):n}),d.jsxs(j,{className:"flex justify-end gap-3 mt-6",children:[d.jsx(R,{onClick:M,disabled:u,className:"px-4 py-2 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed",children:d.jsx(te,{children:m})}),d.jsxs(R,{onClick:k,disabled:u,className:`flex items-center gap-2 px-4 py-2 rounded-lg disabled:opacity-50 disabled:cursor-not-allowed ${T[f]}`,children:[u&&d.jsx(It,{className:"fa-solid fa-spinner w-4 h-4 animate-spin"}),d.jsx(te,{children:u?x:p})]})]})]})},eh=Object.freeze(Object.defineProperty({__proto__:null,ConfirmDialog:wa},Symbol.toStringTag,{value:"Module"})),di=C.createContext(null),ui=({value:e,children:t})=>d.jsx(di.Provider,{value:e,children:t}),th=()=>{const e=C.useContext(di);if(!e)throw new Error("useFileUploaderContext must be used within FileUploaderProvider");return e};function rh(e,t){return t.forEach((function(r){r&&typeof r!="string"&&!Array.isArray(r)&&Object.keys(r).forEach((function(n){if(n!=="default"&&!(n in e)){var o=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(e,n,o.get?o:{enumerable:!0,get:function(){return r[n]}})}}))})),Object.freeze(e)}function fi(e,t){return new Promise((function(r,n){let o;return nh(e).then((function(a){try{return o=a,r(new Blob([t.slice(0,2),o,t.slice(2)],{type:"image/jpeg"}))}catch(s){return n(s)}}),n)}))}const nh=e=>new Promise(((t,r)=>{const n=new FileReader;n.addEventListener("load",(({target:{result:o}})=>{const a=new DataView(o);let s=0;if(a.getUint16(s)!==65496)return r("not a valid JPEG");for(s+=2;;){const l=a.getUint16(s);if(l===65498)break;const f=a.getUint16(s+2);if(l===65505&&a.getUint32(s+4)===1165519206){const h=s+10;let c;switch(a.getUint16(h)){case 18761:c=!0;break;case 19789:c=!1;break;default:return r("TIFF header contains invalid endian")}if(a.getUint16(h+2,c)!==42)return r("TIFF header contains invalid version");const i=a.getUint32(h+4,c),u=h+i+2+12*a.getUint16(h+i,c);for(let g=h+i+2;g>>24&255,l[s+1]=f>>>16&255,l[s+2]=f>>>8&255,l[s+3]=f>>>0&255,new Uint8Array(l.buffer,0,s+4)},n.deflateRaw=function(o,a){a==null&&(a={level:6});var s=new Uint8Array(50+Math.floor(1.1*o.length)),l=n.F.deflateRaw(o,s,l,a.level);return new Uint8Array(s.buffer,0,l)},n.encode=function(o,a){a==null&&(a=!1);var s=0,l=n.bin.writeUint,f=n.bin.writeUshort,h={};for(var c in o){var i=!n._noNeed(c)&&!a,u=o[c],g=n.crc.crc(u,0,u.length);h[c]={cpr:i,usize:u.length,crc:g,file:i?n.deflateRaw(u):u}}for(var c in h)s+=h[c].file.length+30+46+2*n.bin.sizeUTF8(c);s+=22;var p=new Uint8Array(s),m=0,x=[];for(var c in h){var k=h[c];x.push(m),m=n._writeHeader(p,m,c,k,0)}var M=0,v=m;for(var c in h)k=h[c],x.push(m),m=n._writeHeader(p,m,c,k,1,x[M++]);var T=m-v;return l(p,m,101010256),m+=4,f(p,m+=4,M),f(p,m+=2,M),l(p,m+=2,T),l(p,m+=4,v),m+=4,m+=2,p.buffer},n._noNeed=function(o){var a=o.split(".").pop().toLowerCase();return"png,jpg,jpeg,zip".indexOf(a)!=-1},n._writeHeader=function(o,a,s,l,f,h){var c=n.bin.writeUint,i=n.bin.writeUshort,u=l.file;return c(o,a,f==0?67324752:33639248),a+=4,f==1&&(a+=2),i(o,a,20),i(o,a+=2,0),i(o,a+=2,l.cpr?8:0),c(o,a+=2,0),c(o,a+=4,l.crc),c(o,a+=4,u.length),c(o,a+=4,l.usize),i(o,a+=4,n.bin.sizeUTF8(s)),i(o,a+=2,0),a+=2,f==1&&(a+=2,a+=2,c(o,a+=6,h),a+=4),a+=n.bin.writeUTF8(o,a,s),f==0&&(o.set(u,a),a+=u.length),a},n.crc={table:(function(){for(var o=new Uint32Array(256),a=0;a<256;a++){for(var s=a,l=0;l<8;l++)1&s?s=3988292384^s>>>1:s>>>=1;o[a]=s}return o})(),update:function(o,a,s,l){for(var f=0;f>>8;return o},crc:function(o,a,s){return 4294967295^n.crc.update(4294967295,o,a,s)}},n.adler=function(o,a,s){for(var l=1,f=0,h=a,c=a+s;h>8&255},readUint:function(o,a){return 16777216*o[a+3]+(o[a+2]<<16|o[a+1]<<8|o[a])},writeUint:function(o,a,s){o[a]=255&s,o[a+1]=s>>8&255,o[a+2]=s>>16&255,o[a+3]=s>>24&255},readASCII:function(o,a,s){for(var l="",f=0;f>6,o[a+f+1]=128|c>>0&63,f+=2;else if((4294901760&c)==0)o[a+f]=224|c>>12,o[a+f+1]=128|c>>6&63,o[a+f+2]=128|c>>0&63,f+=3;else{if((4292870144&c)!=0)throw"e";o[a+f]=240|c>>18,o[a+f+1]=128|c>>12&63,o[a+f+2]=128|c>>6&63,o[a+f+3]=128|c>>0&63,f+=4}}return f},sizeUTF8:function(o){for(var a=o.length,s=0,l=0;l>>3}var x=h.lits,k=h.strt,M=h.prev,v=0,T=0,I=0,S=0,N=0,w=0;for(m>2&&(k[w=n.F._hash(o,0)]=0),u=0;u14e3||T>26697)&&m-u>100&&(p>>16,$=65535&E;if(E!=0){$=65535&E;var P=c(O=E>>>16,h.of0);h.lhst[257+P]++;var L=c($,h.df0);h.dhst[L]++,S+=h.exb[P]+h.dxb[L],x[v]=O<<23|u-p,x[v+1]=$<<16|P<<8|L,v+=2,p=u+O}else h.lhst[o[u]]++;T++}}for(I==u&&o.length!=0||(p>>3},n.F._bestMatch=function(o,a,s,l,f,h){var c=32767&a,i=s[c],u=c-i+32768&32767;if(i==c||l!=n.F._hash(o,a-u))return 0;for(var g=0,p=0,m=Math.min(32767,a);u<=m&&--h!=0&&i!=c;){if(g==0||o[a+g]==o[a+g-u]){var x=n.F._howLong(o,a,u);if(x>g){if(p=u,(g=x)>=f)break;u+2k&&(k=T,i=v)}}}u+=(c=i)-(i=s[c])+32768&32767}return g<<16|p},n.F._howLong=function(o,a,s){if(o[a]!=o[a-s]||o[a+1]!=o[a+1-s]||o[a+2]!=o[a+2-s])return 0;var l=a,f=Math.min(o.length,a+258);for(a+=3;a>>23,X=b+(8388607&F);b>16,H=B>>8&255,W=255&B;w(i,u=n.F._writeLit(257+H,L,i,u),G-S.of0[H]),u+=S.exb[H],N(i,u=n.F._writeLit(W,U,i,u),Y-S.df0[W]),u+=S.dxb[W],b+=G}}u=n.F._writeLit(256,L,i,u)}return u},n.F._copyExact=function(o,a,s,l,f){var h=f>>>3;return l[h]=s,l[h+1]=s>>>8,l[h+2]=255-l[h],l[h+3]=255-l[h+1],h+=4,l.set(new Uint8Array(o.buffer,a,s),h),f+(s+4<<3)},n.F.getTrees=function(){for(var o=n.F.U,a=n.F._hufTree(o.lhst,o.ltree,15),s=n.F._hufTree(o.dhst,o.dtree,15),l=[],f=n.F._lenCodes(o.ltree,l),h=[],c=n.F._lenCodes(o.dtree,h),i=0;i4&&o.itree[1+(o.ordr[g-1]<<1)]==0;)g--;return[a,s,u,f,c,g,l,h]},n.F.getSecond=function(o){for(var a=[],s=0;s>1)+",");return a},n.F.contSize=function(o,a){for(var s=0,l=0;l15&&(n.F._putsE(s,l,c,i),l+=i)}return l},n.F._lenCodes=function(o,a){for(var s=o.length;s!=2&&o[s-1]==0;)s-=2;for(var l=0;l>>1,138))<11?a.push(17,g-3):a.push(18,g-11),l+=2*g-2}else if(f==i&&h==f&&c==f){for(u=l+5;u+2>>1,6);a.push(16,g-3),l+=2*g-2}else a.push(f,0)}return s>>>1},n.F._hufTree=function(o,a,s){var l=[],f=o.length,h=a.length,c=0;for(c=0;cs&&(n.F.restrictDepth(u,s,v),v=s),c=0;ca;l++){var c=o[l].d;o[l].d=a,h+=f-(1<>>=s-a;h>0;)(c=o[l].d)=0;l--)o[l].d==a&&h<0&&(o[l].d--,h++);h!=0&&console.log("debt left")},n.F._goodIndex=function(o,a){var s=0;return a[16|s]<=o&&(s|=16),a[8|s]<=o&&(s|=8),a[4|s]<=o&&(s|=4),a[2|s]<=o&&(s|=2),a[1|s]<=o&&(s|=1),s},n.F._writeLit=function(o,a,s,l){return n.F._putsF(s,l,a[o<<1]),l+a[1+(o<<1)]},n.F.inflate=function(o,a){var s=Uint8Array;if(o[0]==3&&o[1]==0)return a||new s(0);var l=n.F,f=l._bitsF,h=l._bitsE,c=l._decodeTiny,i=l.makeCodes,u=l.codes2map,g=l._get17,p=l.U,m=a==null;m&&(a=new s(o.length>>>2<<3));for(var x,k,M=0,v=0,T=0,I=0,S=0,N=0,w=0,y=0,E=0;M==0;)if(M=f(o,E,1),v=f(o,E+1,2),E+=3,v!=0){if(m&&(a=n.F._check(a,y+131072)),v==1&&(x=p.flmap,k=p.fdmap,N=511,w=31),v==2){T=h(o,E,5)+257,I=h(o,E+5,5)+1,S=h(o,E+10,4)+4,E+=14;for(var O=0;O<38;O+=2)p.itree[O]=0,p.itree[O+1]=0;var $=1;for(O=0;O$&&($=P)}E+=3*S,i(p.itree,$),u(p.itree,$,p.imap),x=p.lmap,k=p.dmap,E=c(p.imap,(1<<$)-1,T+I,o,E,p.ttree);var L=l._copyOut(p.ttree,0,T,p.ltree);N=(1<>>4;if(!(b>>>8))a[y++]=b;else{if(b==256)break;var z=y+b-254;if(b>264){var F=p.ldef[b-257];z=y+(F>>>3)+h(o,E,7&F),E+=7&F}var G=k[g(o,E)&w];E+=15&G;var X=G>>>4,B=p.ddef[X],Y=(B>>>4)+f(o,E,15&B);for(E+=15&B,m&&(a=n.F._check(a,y+131072));y>>3),W=o[H-4]|o[H-3]<<8;m&&(a=n.F._check(a,y+W)),a.set(new s(o.buffer,o.byteOffset+H,W),y),E=H+W<<3,y+=W}return a.length==y?a:a.slice(0,y)},n.F._check=function(o,a){var s=o.length;if(a<=s)return o;var l=new Uint8Array(Math.max(s<<1,a));return l.set(o,0),l},n.F._decodeTiny=function(o,a,s,l,f,h){for(var c=n.F._bitsE,i=n.F._get17,u=0;u>>4;if(p<=15)h[u]=p,u++;else{var m=0,x=0;p==16?(x=3+c(l,f,2),f+=2,m=h[u-1]):p==17?(x=3+c(l,f,3),f+=3):p==18&&(x=11+c(l,f,7),f+=7);for(var k=u+x;u>>1;hf&&(f=i),h++}for(;h>1,i=o[h+1],u=c<<4|i,g=a-i,p=o[h]<>>15-a]=u,p++},n.F.revCodes=function(o,a){for(var s=n.F.U.rev15,l=15-a,f=0;f>>l}},n.F._putsE=function(o,a,s){s<<=7&a;var l=a>>>3;o[l]|=s,o[l+1]|=s>>>8},n.F._putsF=function(o,a,s){s<<=7&a;var l=a>>>3;o[l]|=s,o[l+1]|=s>>>8,o[l+2]|=s>>>16},n.F._bitsE=function(o,a,s){return(o[a>>>3]|o[1+(a>>>3)]<<8)>>>(7&a)&(1<>>3]|o[1+(a>>>3)]<<8|o[2+(a>>>3)]<<16)>>>(7&a)&(1<>>3]|o[1+(a>>>3)]<<8|o[2+(a>>>3)]<<16)>>>(7&a)},n.F._get25=function(o,a){return(o[a>>>3]|o[1+(a>>>3)]<<8|o[2+(a>>>3)]<<16|o[3+(a>>>3)]<<24)>>>(7&a)},n.F.U=(t=Uint16Array,r=Uint32Array,{next_code:new t(16),bl_count:new t(16),ordr:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],of0:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],exb:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],ldef:new t(32),df0:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],dxb:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],ddef:new r(32),flmap:new t(512),fltree:[],fdmap:new t(32),fdtree:[],lmap:new t(32768),ltree:[],ttree:[],dmap:new t(32768),dtree:[],imap:new t(512),itree:[],rev15:new t(32768),lhst:new r(286),dhst:new r(30),ihst:new r(19),lits:new r(15e3),strt:new t(65536),prev:new t(32768)}),(function(){for(var o=n.F.U,a=0;a<32768;a++){var s=a;s=(4278255360&(s=(4042322160&(s=(3435973836&(s=(2863311530&s)>>>1|(1431655765&s)<<1))>>>2|(858993459&s)<<2))>>>4|(252645135&s)<<4))>>>8|(16711935&s)<<8,o.rev15[a]=(s>>>16|s<<16)>>>17}function l(f,h,c){for(;h--!=0;)f.push(0,c)}for(a=0;a<32;a++)o.ldef[a]=o.of0[a]<<3|o.exb[a],o.ddef[a]=o.df0[a]<<4|o.dxb[a];l(o.fltree,144,8),l(o.fltree,112,9),l(o.fltree,24,7),l(o.fltree,8,8),n.F.makeCodes(o.fltree,9),n.F.codes2map(o.fltree,9,o.flmap),n.F.revCodes(o.fltree,9),l(o.fdtree,32,5),n.F.makeCodes(o.fdtree,5),n.F.codes2map(o.fdtree,5,o.fdmap),n.F.revCodes(o.fdtree,5),l(o.itree,19,0),l(o.ltree,286,0),l(o.dtree,30,0),l(o.ttree,320,0)})()})();var ah=rh({__proto__:null,default:Wn},[Wn]);const Xt=(function(){var e={nextZero(c,i){for(;c[i]!=0;)i++;return i},readUshort:(c,i)=>c[i]<<8|c[i+1],writeUshort(c,i,u){c[i]=u>>8&255,c[i+1]=255&u},readUint:(c,i)=>16777216*c[i]+(c[i+1]<<16|c[i+2]<<8|c[i+3]),writeUint(c,i,u){c[i]=u>>24&255,c[i+1]=u>>16&255,c[i+2]=u>>8&255,c[i+3]=255&u},readASCII(c,i,u){let g="";for(let p=0;pc.length<2?`0${c}`:c,readUTF8(c,i,u){let g,p="";for(let m=0;m>3)]>>7-((7&S)<<0)&1);k[y]=F[P],k[y+1]=F[P+1],k[y+2]=F[P+2],k[y+3]=L>2)]>>6-((3&S)<<1)&3),k[y]=F[P],k[y+1]=F[P+1],k[y+2]=F[P+2],k[y+3]=L>1)]>>4-((1&S)<<2)&15),k[y]=F[P],k[y+1]=F[P+1],k[y+2]=F[P+2],k[y+3]=L>>3)]>>>7-(7&b)&1))==255*w?0:255;M[G+b]=z<<24|U<<16|U<<8|U}else if(T==2)for(b=0;b>>2)]>>>6-((3&b)<<1)&3))==85*w?0:255,M[G+b]=z<<24|U<<16|U<<8|U;else if(T==4)for(b=0;b>>1)]>>>4-((1&b)<<2)&15))==17*w?0:255,M[G+b]=z<<24|U<<16|U<<8|U;else if(T==8)for(b=0;b>3,w=Math.ceil(T*S/8),y=new Uint8Array(I*w);let E=0;const O=[0,0,4,0,2,0,1],$=[0,4,0,2,0,1,0],P=[8,8,8,4,4,2,2],L=[8,8,4,4,2,2,1];let U=0;for(;U<7;){const b=P[U],z=L[U];let F=0,G=0,X=O[U];for(;X>3])>>7-(7&be)&1,y[W*w+(Q>>3)]|=_<<7-((7&Q)<<0)),S==2&&(_=(_=M[be>>3])>>6-(7&be)&3,y[W*w+(Q>>2)]|=_<<6-((3&Q)<<1)),S==4&&(_=(_=M[be>>3])>>4-(7&be)&15,y[W*w+(Q>>1)]|=_<<4-((1&Q)<<2)),S>=8){const se=W*w+Q*N;for(let pe=0;pe>3)+pe]}be+=S,Q+=z}H++,W+=b}F*G!=0&&(E+=G*(1+Y)),U+=1}return y})(i,c)),i}function n(c,i){return o(new Uint8Array(c.buffer,2,c.length-6),i)}var o=(function(){const c={H:{}};return c.H.N=function(i,u){const g=Uint8Array;let p,m,x=0,k=0,M=0,v=0,T=0,I=0,S=0,N=0,w=0;if(i[0]==3&&i[1]==0)return u||new g(0);const y=c.H,E=y.b,O=y.e,$=y.R,P=y.n,L=y.A,U=y.Z,_=y.m,b=u==null;for(b&&(u=new g(i.length>>>2<<5));x==0;)if(x=E(i,w,1),k=E(i,w+1,2),w+=3,k!=0){if(b&&(u=c.H.W(u,N+(1<<17))),k==1&&(p=_.J,m=_.h,I=511,S=31),k==2){M=O(i,w,5)+257,v=O(i,w+5,5)+1,T=O(i,w+10,4)+4,w+=14;let F=1;for(var z=0;z<38;z+=2)_.Q[z]=0,_.Q[z+1]=0;for(z=0;zF&&(F=B)}w+=3*T,P(_.Q,F),L(_.Q,F,_.u),p=_.w,m=_.d,w=$(_.u,(1<>>4;if(!(G>>>8))u[N++]=G;else{if(G==256)break;{let X=N+G-254;if(G>264){const Q=_.q[G-257];X=N+(Q>>>3)+O(i,w,7&Q),w+=7&Q}const B=m[U(i,w)&S];w+=15&B;const Y=B>>>4,H=_.c[Y],W=(H>>>4)+E(i,w,15&H);for(w+=15&H;N>>3),G=i[F-4]|i[F-3]<<8;b&&(u=c.H.W(u,N+G)),u.set(new g(i.buffer,i.byteOffset+F,G),N),w=F+G<<3,N+=G}return u.length==N?u:u.slice(0,N)},c.H.W=function(i,u){const g=i.length;if(u<=g)return i;const p=new Uint8Array(g<<1);return p.set(i,0),p},c.H.R=function(i,u,g,p,m,x){const k=c.H.e,M=c.H.Z;let v=0;for(;v>>4;if(I<=15)x[v]=I,v++;else{let S=0,N=0;I==16?(N=3+k(p,m,2),m+=2,S=x[v-1]):I==17?(N=3+k(p,m,3),m+=3):I==18&&(N=11+k(p,m,7),m+=7);const w=v+N;for(;v>>1;for(;xm&&(m=M),x++}for(;x>1,M=i[x+1],v=k<<4|M,T=u-M;let I=i[x]<>>15-u]=v,I++}},c.H.l=function(i,u){const g=c.H.m.r,p=15-u;for(let m=0;m>>p}},c.H.M=function(i,u,g){g<<=7&u;const p=u>>>3;i[p]|=g,i[p+1]|=g>>>8},c.H.I=function(i,u,g){g<<=7&u;const p=u>>>3;i[p]|=g,i[p+1]|=g>>>8,i[p+2]|=g>>>16},c.H.e=function(i,u,g){return(i[u>>>3]|i[1+(u>>>3)]<<8)>>>(7&u)&(1<>>3]|i[1+(u>>>3)]<<8|i[2+(u>>>3)]<<16)>>>(7&u)&(1<>>3]|i[1+(u>>>3)]<<8|i[2+(u>>>3)]<<16)>>>(7&u)},c.H.i=function(i,u){return(i[u>>>3]|i[1+(u>>>3)]<<8|i[2+(u>>>3)]<<16|i[3+(u>>>3)]<<24)>>>(7&u)},c.H.m=(function(){const i=Uint16Array,u=Uint32Array;return{K:new i(16),j:new i(16),X:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],S:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],T:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],q:new i(32),p:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],z:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],c:new u(32),J:new i(512),_:[],h:new i(32),$:[],w:new i(32768),C:[],v:[],d:new i(32768),D:[],u:new i(512),Q:[],r:new i(32768),s:new u(286),Y:new u(30),a:new u(19),t:new u(15e3),k:new i(65536),g:new i(32768)}})(),(function(){const i=c.H.m;for(var u=0;u<32768;u++){let p=u;p=(2863311530&p)>>>1|(1431655765&p)<<1,p=(3435973836&p)>>>2|(858993459&p)<<2,p=(4042322160&p)>>>4|(252645135&p)<<4,p=(4278255360&p)>>>8|(16711935&p)<<8,i.r[u]=(p>>>16|p<<16)>>>17}function g(p,m,x){for(;m--!=0;)p.push(0,x)}for(u=0;u<32;u++)i.q[u]=i.S[u]<<3|i.T[u],i.c[u]=i.p[u]<<4|i.z[u];g(i._,144,8),g(i._,112,9),g(i._,24,7),g(i._,8,8),c.H.n(i._,9),c.H.A(i._,9,i.J),c.H.l(i._,9),g(i.$,32,5),c.H.n(i.$,5),c.H.A(i.$,5,i.h),c.H.l(i.$,5),g(i.Q,19,0),g(i.C,286,0),g(i.D,30,0),g(i.v,320,0)})(),c.H.N})();function a(c){return[1,null,3,1,2,null,4][c.ctype]*c.depth}function s(c,i,u,g,p){let m=a(i);const x=Math.ceil(g*m/8);let k,M;m=Math.ceil(m/8);let v=c[u],T=0;if(v>1&&(c[u]=[0,0,1][v-2]),v==3)for(T=m;T>>1)&255;for(let I=0;I>>1);for(;T>>1)}else{for(;T=0&&k>=0?(I=U*i+_<<2,S=(k+U)*p+x+_<<2):(I=(-k+U)*i-x+_<<2,S=U*p+_<<2),M==0)g[S]=c[I],g[S+1]=c[I+1],g[S+2]=c[I+2],g[S+3]=c[I+3];else if(M==1){var N=c[I+3]*.00392156862745098,w=c[I]*N,y=c[I+1]*N,E=c[I+2]*N,O=g[S+3]*(1/255),$=g[S]*O,P=g[S+1]*O,L=g[S+2]*O;const b=1-N,z=N+O*b,F=z==0?0:1/z;g[S+3]=255*z,g[S+0]=(w+$*b)*F,g[S+1]=(y+P*b)*F,g[S+2]=(E+L*b)*F}else if(M==2)N=c[I+3],w=c[I],y=c[I+1],E=c[I+2],O=g[S+3],$=g[S],P=g[S+1],L=g[S+2],N==O&&w==$&&y==P&&E==L?(g[S]=0,g[S+1]=0,g[S+2]=0,g[S+3]=0):(g[S]=w,g[S+1]=y,g[S+2]=E,g[S+3]=N);else if(M==3){if(N=c[I+3],w=c[I],y=c[I+1],E=c[I+2],O=g[S+3],$=g[S],P=g[S+1],L=g[S+2],N==O&&w==$&&y==P&&E==L)continue;if(N<220&&O>20)return!1}return!0}return{decode:function(i){const u=new Uint8Array(i);let g=8;const p=e,m=p.readUshort,x=p.readUint,k={tabs:{},frames:[]},M=new Uint8Array(u.length);let v,T=0,I=0;const S=[137,80,78,71,13,10,26,10];for(var N=0;N<8;N++)if(u[N]!=S[N])throw"The input is not a PNG file!";for(;g>>1:E>>>=1;w[y]=E}return w})(),update(w,y,E,O){for(let $=0;$>>8;return w},crc:(w,y,E)=>4294967295^n.update(4294967295,w,y,E)};function o(w,y,E,O){y[E]+=w[0]*O>>4,y[E+1]+=w[1]*O>>4,y[E+2]+=w[2]*O>>4,y[E+3]+=w[3]*O>>4}function a(w){return Math.max(0,Math.min(255,w))}function s(w,y){const E=w[0]-y[0],O=w[1]-y[1],$=w[2]-y[2],P=w[3]-y[3];return E*E+O*O+$*$+P*P}function l(w,y,E,O,$,P,L){L==null&&(L=1);const U=O.length,_=[];for(var b=0;b>>0&255,W>>>8&255,W>>>16&255,W>>>24&255])}for(b=0;b>2]=z,X[b>>2]=O[z]}}function f(w,y,E,O,$){$==null&&($={});const{crc:P}=n,L=t.writeUint,U=t.writeUshort,_=t.writeASCII;let b=8;const z=w.frames.length>1;let F,G=!1,X=33+(z?20:0);if($.sRGB!=null&&(X+=13),$.pHYs!=null&&(X+=21),$.iCCP!=null&&(F=pako.deflate($.iCCP),X+=21+F.length+4),w.ctype==3){for(var B=w.plte.length,Y=0;Y>>24!=255&&(G=!0);X+=8+3*B+4+(G?8+1*B+4:0)}for(var H=0;H>>8&255,We=ne>>>16&255;W[b+pe+0]=Ae,W[b+pe+1]=ve,W[b+pe+2]=We}if(b+=3*B,L(W,b,P(W,b-3*B-4,3*B+4)),b+=4,G){for(L(W,b,B),b+=4,_(W,b,"tRNS"),b+=4,Y=0;Y>>24&255;b+=B,L(W,b,P(W,b-B-4,B+4)),b+=4}}let be=0;for(H=0;HDe&&(De=Je),qeYe&&(Ye=qe));De==-1&&(_e=xe=De=Ye=0),K&&((1&_e)==1&&_e--,(1&xe)==1&&xe--);const rt=(De-_e+1)*(Ye-xe+1);rt>2,ze>>2);pe.push(ne);const K=new Uint8Array(we.abuf,$e,ze);z&&l(Ae.img,Ae.rect.width,Ae.rect.height,se,K,ne),Ae.img.set(K),$e+=ze}}else for(B=0;Bve&&Oe==ge[H-ve])ne[H]=ne[H-ve];else{let we=be[Oe];if(we==null&&(be[Oe]=we=se.length,se.push(Oe),se.length>=300))break;ne[H]=we}}}const We=se.length;for(We<=256&&b==0&&(G=We<=2?1:We<=4?2:We<=16?4:8,G=Math.max(G,_)),B=0;B>1)]|=ze[oe+Te]<<4-4*(1&Te);else if(G==2)for(Te=0;Te>2)]|=ze[oe+Te]<<6-2*(3&Te);else if(G==1)for(Te=0;Te>3)]|=ze[oe+Te]<<7-1*(7&Te)}Oe=me,F=3,$e=1}else if(W==0&&Q.length==1){me=new Uint8Array(ve*ge*3);const ze=ve*ge;for(H=0;HH&&(H=pe),neW&&(W=ne))}H==-1&&(B=Y=H=W=0),L&&((1&B)==1&&B--,(1&Y)==1&&Y--),P={x:B,y:Y,width:H-B+1,height:W-Y+1};const Q=O[$];Q.rect=P,Q.blend=1,Q.img=new Uint8Array(P.width*P.height*4),O[$-1].dispose==0?(e(b,y,E,Q.img,P.width,P.height,-P.x,-P.y,0),u(G,y,E,Q.img,P)):e(G,y,E,Q.img,P.width,P.height,-P.x,-P.y,0)}function u(w,y,E,O,$){e(w,y,E,O,$.width,$.height,-$.x,-$.y,2)}function g(w,y,E,O,$,P,L){const U=[];let _,b=[0,1,2,3,4];P!=-1?b=[P]:(y*O>5e5||E==1)&&(b=[0]),L&&(_={level:0});const z=ah;for(var F=0;F>1)+256&255;if(P==4)for(_=$;_>1)&255;for(_=$;_>1)&255}if(P==4){for(_=0;_<$;_++)w[U+_]=y[L+_]+256-r(0,y[L+_-O],0)&255;for(_=$;_>2);let z;if(E.length<2e7)for(var F=0;F<_;F+=4)z=k(L,G=E[F]*.00392156862745098,X=E[F+1]*.00392156862745098,B=E[F+2]*.00392156862745098,Y=E[F+3]*.00392156862745098),b[F>>2]=z.ind,$[F>>2]=z.est.rgba;else for(F=0;F<_;F+=4){var G=E[F]*.00392156862745098,X=E[F+1]*(1/255),B=E[F+2]*(1/255),Y=E[F+3]*(1/255);for(z=L;z.left;)z=M(z.est,G,X,B,Y)<=0?z.left:z.right;b[F>>2]=z.ind,$[F>>2]=z.est.rgba}return{abuf:O.buffer,inds:b,plte:U}}function x(w,y,E){E==null&&(E=1e-4);const O=new Uint32Array(w.buffer),$={i0:0,i1:w.length,bst:null,est:null,tdst:0,left:null,right:null};$.bst=I(w,$.i0,$.i1),$.est=S($.bst);const P=[$];for(;P.lengthU&&(U=P[L].est.L,_=L);if(U=z||b.i1<=z){b.est.L=0;continue}const F={i0:b.i0,i1:z,bst:null,est:null,tdst:0,left:null,right:null};F.bst=I(w,F.i0,F.i1),F.est=S(F.bst);const G={i0:z,i1:b.i1,bst:null,est:null,tdst:0,left:null,right:null};for(G.bst={R:[],m:[],N:b.bst.N-F.bst.N},L=0;L<16;L++)G.bst.R[L]=b.bst.R[L]-F.bst.R[L];for(L=0;L<4;L++)G.bst.m[L]=b.bst.m[L]-F.bst.m[L];G.est=S(G.bst),b.left=F,b.right=G,P[_]=F,P.push(G)}for(P.sort(((U,_)=>_.bst.N-U.bst.N)),L=0;L0&&(L=w.right,U=w.left);const _=k(L,y,E,O,$);if(_.tdst<=P*P)return _;const b=k(U,y,E,O,$);return b.tdst<_.tdst?b:_}function M(w,y,E,O,$){const{e:P}=w;return P[0]*y+P[1]*E+P[2]*O+P[3]*$-w.eMq}function v(w,y,E,O,$,P){for(O-=4;EP;)O-=4;if(E>=O)break;const L=y[E>>2];y[E>>2]=y[O>>2],y[O>>2]=L,E+=4,O-=4}for(;T(w,E,$)>P;)E-=4;return E+4}function T(w,y,E){return w[y]*E[0]+w[y+1]*E[1]+w[y+2]*E[2]+w[y+3]*E[3]}function I(w,y,E){const O=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],$=[0,0,0,0],P=E-y>>2;for(let L=y;L>>0}}var N={multVec:(w,y)=>[w[0]*y[0]+w[1]*y[1]+w[2]*y[2]+w[3]*y[3],w[4]*y[0]+w[5]*y[1]+w[6]*y[2]+w[7]*y[3],w[8]*y[0]+w[9]*y[1]+w[10]*y[2]+w[11]*y[3],w[12]*y[0]+w[13]*y[1]+w[14]*y[2]+w[15]*y[3]],dot:(w,y)=>w[0]*y[0]+w[1]*y[1]+w[2]*y[2]+w[3]*y[3],sml:(w,y)=>[w*y[0],w*y[1],w*y[2],w*y[3]]};Xt.encode=function(y,E,O,$,P,L,U){$==null&&($=0),U==null&&(U=!1);const _=c(y,E,O,$,[!1,!1,!1,0,U,!1]);return h(_,-1),f(_,E,O,P,L)},Xt.encodeLL=function(y,E,O,$,P,L,U,_){const b={ctype:0+($==1?0:2)+(P==0?0:4),depth:L,frames:[]},z=($+P)*L,F=z*E;for(let G=0;G>>0),I(1),I(32),S(3),S(f),S(2835),S(2835),N(8),S(16711680),S(65280),S(255),S(4278190080),S(1466527264),(function w(){for(;M0;){for(x=122+M*l,g=0;g>>24,i.setUint32(x+g,p<<8|m),g+=4;M++}T{t(new Blob([r],{type:"image/bmp"}))}))},_dly:9};var kt={CHROME:"CHROME",FIREFOX:"FIREFOX",DESKTOP_SAFARI:"DESKTOP_SAFARI",IE:"IE",IOS:"IOS",ETC:"ETC"},sh={[kt.CHROME]:16384,[kt.FIREFOX]:11180,[kt.DESKTOP_SAFARI]:16384,[kt.IE]:8192,[kt.IOS]:4096,[kt.ETC]:8192};const xa=typeof window<"u",hi=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,Vn=xa&&window.cordova&&window.cordova.require&&window.cordova.require("cordova/modulemapper"),lh=(xa||hi)&&(Vn&&Vn.getOriginalSymbol(window,"File")||typeof File<"u"&&File),pi=(xa||hi)&&(Vn&&Vn.getOriginalSymbol(window,"FileReader")||typeof FileReader<"u"&&FileReader);function ka(e,t,r=Date.now()){return new Promise((n=>{const o=e.split(","),a=o[0].match(/:(.*?);/)[1],s=globalThis.atob(o[1]);let l=s.length;const f=new Uint8Array(l);for(;l--;)f[l]=s.charCodeAt(l);const h=new Blob([f],{type:a});h.name=t,h.lastModified=r,n(h)}))}function mi(e){return new Promise(((t,r)=>{const n=new pi;n.onload=()=>t(n.result),n.onerror=o=>r(o),n.readAsDataURL(e)}))}function bi(e){return new Promise(((t,r)=>{const n=new Image;n.onload=()=>t(n),n.onerror=o=>r(o),n.src=e}))}function wr(){if(wr.cachedResult!==void 0)return wr.cachedResult;let e=kt.ETC;const{userAgent:t}=navigator;return/Chrom(e|ium)/i.test(t)?e=kt.CHROME:/iP(ad|od|hone)/i.test(t)&&/WebKit/i.test(t)?e=kt.IOS:/Safari/i.test(t)?e=kt.DESKTOP_SAFARI:/Firefox/i.test(t)?e=kt.FIREFOX:(/MSIE/i.test(t)||document.documentMode)&&(e=kt.IE),wr.cachedResult=e,wr.cachedResult}function yi(e,t){const r=wr(),n=sh[r];let o=e,a=t,s=o*a;const l=o>a?a/o:o/a;for(;s>n*n;){const f=(n+o)/2,h=(n+a)/2;fgi.toBlob(e,c))).then(function(c){try{return l=c,l.name=r,l.lastModified=n,h.call(this)}catch(i){return s(i)}}.bind(this),s);{let c=function(){return h.call(this)};if(typeof OffscreenCanvas=="function"&&e instanceof OffscreenCanvas)return e.convertToBlob({type:t,quality:o}).then(function(i){try{return l=i,l.name=r,l.lastModified=n,c.call(this)}catch(u){return s(u)}}.bind(this),s);{let i;return i=e.toDataURL(t,o),ka(i,r,n).then(function(u){try{return l=u,c.call(this)}catch(g){return s(g)}}.bind(this),s)}}}function f(){return a(l)}}))}function Qt(e){e.width=0,e.height=0}function Hr(){return new Promise((function(e,t){let r,n,o,a;return Hr.cachedResult!==void 0?e(Hr.cachedResult):ka("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAEAAgMBEQACEQEDEQH/xABKAAEAAAAAAAAAAAAAAAAAAAALEAEAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAAAAAAAAAAAAAAAEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwA/8H//2Q==","test.jpg",Date.now()).then((function(s){try{return r=s,Xn(r).then((function(l){try{return n=l[1],qn(n,r.type,r.name,r.lastModified).then((function(f){try{return o=f,Qt(n),Xn(o).then((function(h){try{return a=h[0],Hr.cachedResult=a.width===1&&a.height===2,e(Hr.cachedResult)}catch(c){return t(c)}}),t)}catch(h){return t(h)}}),t)}catch(f){return t(f)}}),t)}catch(l){return t(l)}}),t)}))}function wi(e){return new Promise(((t,r)=>{const n=new pi;n.onload=o=>{const a=new DataView(o.target.result);if(a.getUint16(0,!1)!=65496)return t(-2);const s=a.byteLength;let l=2;for(;lr(o),n.readAsArrayBuffer(e)}))}function xi(e,t){const{width:r}=e,{height:n}=e,{maxWidthOrHeight:o}=t;let a,s=e;return isFinite(o)&&(r>o||n>o)&&([s,a]=Kn(r,n),r>n?(s.width=o,s.height=n/r*o):(s.width=r/n*o,s.height=o),a.drawImage(e,0,0,s.width,s.height),Qt(e)),s}function ki(e,t){const{width:r}=e,{height:n}=e,[o,a]=Kn(r,n);switch(t>4&&t<9?(o.width=n,o.height=r):(o.width=r,o.height=n),t){case 2:a.transform(-1,0,0,1,r,0);break;case 3:a.transform(-1,0,0,-1,r,n);break;case 4:a.transform(1,0,0,-1,0,n);break;case 5:a.transform(0,1,1,0,0,0);break;case 6:a.transform(0,1,-1,0,n,0);break;case 7:a.transform(0,-1,-1,0,n,r);break;case 8:a.transform(0,-1,1,0,0,r)}return a.drawImage(e,0,0,r,n),Qt(e),o}function Ci(e,t,r=0){return new Promise((function(n,o){let a,s,l,f,h,c,i,u,g,p,m,x,k,M,v,T,I,S,N,w;function y(O=5){if(t.signal&&t.signal.aborted)throw t.signal.reason;a+=O,t.onProgress(Math.min(a,100))}function E(O){if(t.signal&&t.signal.aborted)throw t.signal.reason;a=Math.min(Math.max(O,a),100),t.onProgress(a)}return a=r,s=t.maxIteration||10,l=1024*t.maxSizeMB*1024,y(),Xn(e,t).then(function(O){try{return[,f]=O,y(),h=xi(f,t),y(),new Promise((function($,P){var L;if(!(L=t.exifOrientation))return wi(e).then(function(_){try{return L=_,U.call(this)}catch(b){return P(b)}}.bind(this),P);function U(){return $(L)}return U.call(this)})).then(function($){try{return c=$,y(),Hr().then(function(P){try{return i=P?h:ki(h,c),y(),u=t.initialQuality||1,g=t.fileType||e.type,qn(i,g,e.name,e.lastModified,u).then(function(L){try{{let _=function(){if(s--&&(v>l||v>k)){let z,F;return z=w?.95*N.width:N.width,F=w?.95*N.height:N.height,[I,S]=Kn(z,F),S.drawImage(N,0,0,z,F),u*=g==="image/png"?.85:.95,qn(I,g,e.name,e.lastModified,u).then((function(G){try{return T=G,Qt(N),N=I,v=T.size,E(Math.min(99,Math.floor((M-v)/(M-l)*100))),_}catch(X){return o(X)}}),o)}return[1]},b=function(){return Qt(N),Qt(I),Qt(h),Qt(i),Qt(f),E(100),n(T)};if(p=L,y(),m=p.size>l,x=p.size>e.size,!m&&!x)return E(100),n(p);var U;return k=e.size,M=p.size,v=M,N=i,w=!t.alwaysKeepResolution&&m,(U=function(z){for(;z;){if(z.then)return void z.then(U,o);try{if(z.pop){if(z.length)return z.pop()?b.call(this):z;z=_}else z=z.call(this)}catch(F){return o(F)}}}.bind(this))(_)}}catch(_){return o(_)}}.bind(this),o)}catch(L){return o(L)}}.bind(this),o)}catch(P){return o(P)}}.bind(this),o)}catch($){return o($)}}.bind(this),o)}))}const ih=` let scriptImported = false self.addEventListener('message', async (e) => { const { file, id, imageCompressionLibUrl, options } = e.data @@ -59,20 +59,20 @@ self.addEventListener('message', async (e) => { self.postMessage({ error: e.message + '\\n' + e.stack, id }) } }) -`;let Ca;function lh(e,t){return new Promise(((r,n)=>{Ca||(Ca=(function(s){const l=[];return l.push(s),URL.createObjectURL(new Blob(l))})(sh));const o=new Worker(Ca);o.addEventListener("message",(function(s){if(t.signal&&t.signal.aborted)o.terminate();else if(s.data.progress===void 0){if(s.data.error)return n(new Error(s.data.error)),void o.terminate();r(s.data.file),o.terminate()}else t.onProgress(s.data.progress)})),o.addEventListener("error",n),t.signal&&t.signal.addEventListener("abort",(()=>{n(t.signal.reason),o.terminate()})),o.postMessage({file:e,imageCompressionLibUrl:t.libURL,options:{...t,onProgress:void 0,signal:void 0}})}))}function mt(e,t){return new Promise((function(r,n){let o,a,s,l,f,h;if(o={...t},s=0,{onProgress:l}=o,o.maxSizeMB=o.maxSizeMB||Number.POSITIVE_INFINITY,f=typeof o.useWebWorker!="boolean"||o.useWebWorker,delete o.useWebWorker,o.onProgress=g=>{s=g,typeof l=="function"&&l(s)},!(e instanceof Blob||e instanceof ah))return n(new Error("The file given is not an instance of Blob or File"));if(!/^image/.test(e.type))return n(new Error("The file given is not an image"));if(h=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,!f||typeof Worker!="function"||h)return Ci(e,o).then(function(g){try{return a=g,u.call(this)}catch(p){return n(p)}}.bind(this),n);var c=function(){try{return u.call(this)}catch(g){return n(g)}}.bind(this),i=function(g){try{return Ci(e,o).then((function(p){try{return a=p,c()}catch(m){return n(m)}}),n)}catch(p){return n(p)}};try{return o.libURL=o.libURL||"https://cdn.jsdelivr.net/npm/browser-image-compression@2.0.2/dist/browser-image-compression.js",lh(e,o).then((function(g){try{return a=g,c()}catch{return i()}}),i)}catch{i()}function u(){try{a.name=e.name,a.lastModified=e.lastModified}catch{}try{o.preserveExif&&e.type==="image/jpeg"&&(!o.fileType||o.fileType&&o.fileType===e.type)&&(a=fi(e,a))}catch{}return r(a)}}))}mt.getDataUrlFromFile=mi,mt.getFilefromDataUrl=ka,mt.loadImage=bi,mt.drawImageInCanvas=vi,mt.drawFileInCanvas=Xn,mt.canvasToFile=qn,mt.getExifOrientation=wi,mt.handleMaxWidthOrHeight=xi,mt.followExifOrientation=ki,mt.cleanupCanvasMemory=Qt,mt.isAutoOrientationInBrowser=Hr,mt.approximateBelowMaximumCanvasSizeOfBrowser=yi,mt.copyExifWithoutOrientation=fi,mt.getBrowserName=wr,mt.version="2.0.2";const ih=window.G7Core,Zn=e=>{const t=["B","KB","MB","GB"];let r=0,n=e;for(;n>=1024&&r{if(e&&typeof e=="object"){const t=e;if(t.response?.data?.message)return t.response.data.message;if(t.response?.data?.errors){const r=Object.values(t.response.data.errors)[0];if(Array.isArray(r)&&r[0])return r[0]}if(t.message)return t.message}return e instanceof Error?e.message:"업로드 실패"},Si=e=>e?e.startsWith("image/")?"fa-file-image":e.startsWith("video/")?"fa-file-video":e.startsWith("audio/")?"fa-file-audio":e==="application/pdf"?"fa-file-pdf":e.includes("word")||e.includes("document")?"fa-file-word":e.includes("excel")||e.includes("spreadsheet")?"fa-file-excel":e.includes("zip")||e.includes("compressed")?"fa-file-zipper":"fa-file":"fa-file",at=(e,t)=>ih?.t?.(e,t)??e,ch="2.0.2";function dh(){const e=window?.G7Core?.asset;if(typeof e?.template=="function")return e.template("sirsoft-basic",`vendor/browser-image-compression/${ch}/browser-image-compression.js`)}const xr=window.G7Core;function Ei(e){const{attachmentableType:t,attachmentableId:r,collection:n,maxFiles:o,maxSize:a,maxConcurrentUploads:s,accept:l,imageCompression:f,roleIds:h,autoUpload:c,initialFiles:i,endpoints:u,onFilesChange:g,onUploadComplete:p,onUploadError:m,onRemove:x,onReorder:k,uploadTriggerEvent:M,confirmBeforeRemove:v,uploadParams:T}=e,[I,S]=C.useState(i),[N,w]=C.useState([]),[y,E]=C.useState(!1),O=C.useRef(null),$=C.useRef(0),P=C.useRef(new Set),L=C.useRef(new Map),[U,_]=C.useState(!1),[b,z]=C.useState(null),[F,G]=C.useState(!1),X=C.useRef(!1),[B,Y]=C.useState([]),H=C.useRef(i),[W,Q]=C.useState(!1),[be,se]=C.useState(0),pe=C.useRef(0),[ne,Ae]=C.useState(new Map),ve=C.useRef(new Map);C.useEffect(()=>{g?.(N)},[N,g]);const We=C.useMemo(()=>{const q=H.current;return q===i?q:q.length!==i.length?(H.current=i,i):q.length===0&&i.length===0?q:i.some((de,ue)=>de.id!==q[ue]?.id)?(H.current=i,i):q},[i]);C.useEffect(()=>{if(X.current)return;const q=We.filter(ue=>!P.current.has(ue.id)&&(!ue.hash||!P.current.has(ue.hash))),le=new Set(q.map(ue=>ue.id)),de=Array.from(L.current.values()).filter(ue=>!le.has(ue.id)&&!P.current.has(ue.id));S([...q,...de])},[We]);const me=C.useCallback(async q=>{const le={maxSizeMB:f?.maxSizeMB??1,maxWidthOrHeight:f?.maxWidthOrHeight??1920,useWebWorker:!0,libURL:dh()};return await mt(q,le)},[f]),Te=C.useCallback(async q=>{const le=I.length+N.length,de=Math.max(0,o-le),ue=Array.from(q).slice(0,de);if(q.length>de){const ie=Array.from(q).slice(de),Fe=at("attachment.upload_limit_exceeded",{max:o});m?.(Fe,ie[0]??q[0])}for(const ie of ue){if(ie.size>a*1024*1024){m?.(`[${ie.name}] 파일 크기(${Zn(ie.size)})가 최대 허용 크기(${a}MB)를 초과합니다.`,ie);continue}if(l){const Ce="."+ie.name.split(".").pop()?.toLowerCase();if(!l.split(",").map(He=>He.trim().toLowerCase()).some(He=>{if(He.includes("/")){if(He.endsWith("/*")){const je=He.slice(0,-2);return ie.type.toLowerCase().startsWith(je+"/")}return ie.type.toLowerCase()===He}return Ce===He})){m?.(`[${ie.name}] 허용되지 않는 파일 형식입니다. (허용: ${l})`,ie);continue}}const Fe={id:`pending-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,file:ie,original_filename:ie.name,mime_type:ie.type,size:ie.size,size_formatted:Zn(ie.size),status:"pending",progress:0};if(ie.type.startsWith("image/")&&(Fe.preview=URL.createObjectURL(ie)),w(Ce=>[...Ce,Fe]),ie.type.startsWith("image/")&&f){w(Ce=>Ce.map(Ie=>Ie.id===Fe.id?{...Ie,status:"compressing"}:Ie));try{const Ce=await me(ie);w(Ie=>Ie.map(Ne=>Ne.id===Fe.id?{...Ne,compressedBlob:Ce,size:Ce.size,size_formatted:Zn(Ce.size),status:"pending",progress:0}:Ne))}catch{w(Ce=>Ce.map(Ie=>Ie.id===Fe.id?{...Ie,status:"error",error:"이미지 압축 실패"}:Ie))}}}},[I.length,N.length,o,a,l,f,me,m]),ge=C.useCallback(async q=>{const le=new FormData,de=q.compressedBlob?new File([q.compressedBlob],q.original_filename,{type:q.mime_type}):q.file;le.append("file",de),t&&le.append("attachmentable_type",t),r&&le.append("attachmentable_id",String(r)),le.append("collection",n),h.forEach(ue=>{le.append("role_ids[]",String(ue))}),T&&Object.entries(T).forEach(([ue,ie])=>{le.append(ue,ie)});try{const ue=await xr.api.post(u.upload,le,{headers:{"Content-Type":"multipart/form-data"},onUploadProgress:Fe=>{const Ce=Math.round(Fe.loaded*100/(Fe.total??1));w(Ie=>Ie.map(Ne=>Ne.id===q.id?{...Ne,progress:Ce}:Ne))}});return ue?.data?.data??ue?.data}catch(ue){const ie=_i(ue);throw new Error(ie)}},[t,r,n,h,u.upload]),Oe=C.useCallback(async()=>{const q=N.filter(Ce=>Ce.status==="pending"||Ce.status==="error");if(q.length===0)return[];const le=[],de=new Map,ue=[...q],ie=async()=>{for(;ue.length>0&&$.currentIe.map(Ne=>Ne.id===Ce.id?{...Ne,status:"uploading",progress:0}:Ne));try{const Ie=await ge(Ce);if(Ie)le.push(Ie),de.set(String(Ce.id),String(Ie.hash)),L.current.set(Ie.id,Ie),w(Ne=>Ne.filter(He=>He.id!==Ce.id)),S(Ne=>[...Ne,Ie]),Y(Ne=>{if(Ne.length===0)return Ne;const He=String(Ce.id);return Ne.some(_e=>String(_e)===He)?Ne.map(_e=>String(_e)===He?String(Ie.hash):_e):Ne}),Ce.preview&&URL.revokeObjectURL(Ce.preview);else{const Ne=at("attachment.upload_response_invalid");w(He=>He.map(je=>je.id===Ce.id?{...je,status:"error",error:Ne}:je)),m?.(`[${Ce.original_filename}] ${Ne}`,Ce.file)}}catch(Ie){const Ne=Ie instanceof Error?Ie.message:"업로드 실패";w(He=>He.map(je=>je.id===Ce.id?{...je,status:"error",error:Ne}:je)),m?.(`[${Ce.original_filename}] ${Ne}`,Ce.file)}finally{$.current--}}},Fe=Array(Math.min(s,q.length)).fill(null).map(()=>ie());if(await Promise.all(Fe),le.length>0&&(p?.(le),u.reorder&&B.length>0&&k)){const Ce=[...I,...le],Ie=B.map(je=>de.get(String(je))??je),Ne=new Map(Ie.map((je,_e)=>[String(je),_e])),He=[...Ce].sort((je,_e)=>{const xe=Ne.get(String(je.hash))??Ce.length,De=Ne.get(String(_e.hash))??Ce.length;return xe-De}).map((je,_e)=>({...je,sort_order:_e,order:_e+1}));k(He)}return le},[N,s,ge,p,m,B,I,k,u.reorder]);C.useEffect(()=>{if(!M)return;const q=xr.componentEvent.on(M,async()=>{const le=await Oe();return{uploadedAttachments:le,existingFiles:I,allFiles:[...I,...le]}});return()=>{q()}},[M,Oe,I]),C.useEffect(()=>{c&&N.some(q=>q.status==="pending")&&Oe()},[c,N,Oe]);const we=C.useCallback(async q=>{G(!0);try{if(q.id&&u.delete){const de=u.delete.replace(":id",String(q.id));await xr.api.delete(de)}const le=q.hash||q.id;q.id&&(P.current.add(q.id),L.current.delete(q.id)),q.hash&&P.current.add(q.hash),S(de=>de.filter(ue=>(ue.hash||ue.id)!==le)),x?.(q.hash||q.id),_(!1),z(null)}catch{console.error("첨부파일 삭제 실패")}finally{G(!1)}},[x,u.delete]),$e=C.useCallback(async q=>{"hash"in q?v?(z(q),_(!0)):await we(q):(q.preview&&URL.revokeObjectURL(q.preview),w(le=>le.filter(de=>de.id!==q.id)))},[v,we]),ze=C.useCallback(q=>{w(le=>le.map(de=>de.id===q.id?{...de,status:"pending",error:void 0}:de))},[]),K=C.useCallback(async q=>{const{arrayMove:le}=await Promise.resolve().then(()=>V0),{active:de,over:ue}=q;if(!ue||de.id===ue.id)return;const ie=[...I,...N];let Fe;if(B.length===0)Fe=ie;else{const xe=new Map(B.map((De,Ye)=>[String(De),Ye]));Fe=[...ie].sort((De,Ye)=>{const rt="hash"in De?String(De.hash):String(De.id),qe="hash"in Ye?String(Ye.hash):String(Ye.id);return(xe.get(rt)??ie.length)-(xe.get(qe)??ie.length)})}const Ce=Fe.findIndex(xe=>"hash"in xe?xe.hash===de.id:xe.id===de.id),Ie=Fe.findIndex(xe=>"hash"in xe?xe.hash===ue.id:xe.id===ue.id),Ne=le(Fe,Ce,Ie);Y(Ne.map(xe=>"hash"in xe?xe.hash:xe.id));const He=Ne.filter(xe=>"hash"in xe),je=Ne.filter(xe=>!("hash"in xe));X.current=!0,S(He),w(je);const _e=He.map((xe,De)=>({...xe,sort_order:De,order:De+1}));if(He.length>0&&u.reorder){const xe=He.map((De,Ye)=>({id:De.id,order:Ye+1}));try{const De=await xr.api.patch(u.reorder,{order:xe});xr.toast.success(De.message)}catch(De){const Ye=De instanceof Error?De.message:at("attachment.reorder_failed");xr.toast.error(Ye)}}k?.(_e)},[I,N,B,u.reorder,k]),oe=C.useMemo(()=>[...I,...N].filter(q=>"is_image"in q?q.is_image:q.mime_type?.startsWith("image/")??!1),[I,N]),ae=C.useCallback(q=>{const le=oe.findIndex(de=>"hash"in q&&"hash"in de?de.hash===q.hash:"id"in q&&"id"in de&&!("hash"in q)&&!("hash"in de)?de.id===q.id:!1);le!==-1&&(pe.current+=1,se(le),Q(!0))},[oe]);C.useEffect(()=>{let q=!1;return(async()=>{const de=I.filter(ie=>ie.is_image),ue=new Set(de.map(ie=>ie.id));for(const[ie,Fe]of ve.current)ue.has(ie)||(URL.revokeObjectURL(Fe),ve.current.delete(ie));for(const ie of de){if(q)break;if(!ve.current.has(ie.id)){if(ua(ie.download_url)){ve.current.set(ie.id,ie.download_url),Ae(new Map(ve.current));continue}try{const Fe=await xr.api.get(ie.download_url,{responseType:"blob",headers:zn()});if(!q&&Fe){const Ce=URL.createObjectURL(Fe);ve.current.set(ie.id,Ce),Ae(new Map(ve.current))}}catch(Fe){console.error("Failed to load authenticated image:",Fe)}}}})(),()=>{q=!0}},[I]),C.useEffect(()=>()=>{ve.current.forEach(q=>URL.revokeObjectURL(q)),ve.current.clear()},[]);const ce=C.useCallback(async q=>{const{executeImageDownload:le}=await Promise.resolve().then(()=>ni);await le({src:q.download_url,downloadUrl:q.download_url,filename:q.original_filename,downloadRequiresAuth:!0})},[]),ke=C.useMemo(()=>{const q=[...I,...N];if(B.length===0)return q;const le=new Map(B.map((de,ue)=>[String(de),ue]));return[...q].sort((de,ue)=>{const ie="hash"in de?String(de.hash):String(de.id),Fe="hash"in ue?String(ue.hash):String(ue.id),Ce=le.get(ie)??q.length,Ie=le.get(Fe)??q.length;return Ce-Ie})},[I,N,B]),Ee=ke.length,Be=Ee>0,Me=Eew([]),[]),Pe=C.useCallback(()=>N,[N]);return{existingFiles:I,pendingFiles:N,isDragOver:y,setIsDragOver:E,isDeleting:F,totalCount:Ee,hasFiles:Be,canAddMore:Me,allItems:ke,imageFiles:oe,handleFiles:Te,handleRemove:$e,handleRetry:ze,handleUploadAll:Oe,handleOpenGallery:ae,handleDownload:ce,handleDragEnd:K,inputRef:O,galleryOpen:W,setGalleryOpen:Q,galleryStartIndex:be,galleryKeyRef:pe,confirmDialogOpen:U,setConfirmDialogOpen:_,itemToDelete:b,executeRemoveAttachment:we,authenticatedImageUrls:ne,clear:Ke,getPendingFiles:Pe}}const Ti=({isDragOver:e,canAddMore:t,onFiles:r,setIsDragOver:n,inputRef:o,accept:a,maxFiles:s,maxSize:l,children:f})=>d.jsxs(j,{className:` +`;let Ca;function ch(e,t){return new Promise(((r,n)=>{Ca||(Ca=(function(s){const l=[];return l.push(s),URL.createObjectURL(new Blob(l))})(ih));const o=new Worker(Ca);o.addEventListener("message",(function(s){if(t.signal&&t.signal.aborted)o.terminate();else if(s.data.progress===void 0){if(s.data.error)return n(new Error(s.data.error)),void o.terminate();r(s.data.file),o.terminate()}else t.onProgress(s.data.progress)})),o.addEventListener("error",n),t.signal&&t.signal.addEventListener("abort",(()=>{n(t.signal.reason),o.terminate()})),o.postMessage({file:e,imageCompressionLibUrl:t.libURL,options:{...t,onProgress:void 0,signal:void 0}})}))}function mt(e,t){return new Promise((function(r,n){let o,a,s,l,f,h;if(o={...t},s=0,{onProgress:l}=o,o.maxSizeMB=o.maxSizeMB||Number.POSITIVE_INFINITY,f=typeof o.useWebWorker!="boolean"||o.useWebWorker,delete o.useWebWorker,o.onProgress=g=>{s=g,typeof l=="function"&&l(s)},!(e instanceof Blob||e instanceof lh))return n(new Error("The file given is not an instance of Blob or File"));if(!/^image/.test(e.type))return n(new Error("The file given is not an image"));if(h=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,!f||typeof Worker!="function"||h)return Ci(e,o).then(function(g){try{return a=g,u.call(this)}catch(p){return n(p)}}.bind(this),n);var c=function(){try{return u.call(this)}catch(g){return n(g)}}.bind(this),i=function(g){try{return Ci(e,o).then((function(p){try{return a=p,c()}catch(m){return n(m)}}),n)}catch(p){return n(p)}};try{return o.libURL=o.libURL||"https://cdn.jsdelivr.net/npm/browser-image-compression@2.0.2/dist/browser-image-compression.js",ch(e,o).then((function(g){try{return a=g,c()}catch{return i()}}),i)}catch{i()}function u(){try{a.name=e.name,a.lastModified=e.lastModified}catch{}try{o.preserveExif&&e.type==="image/jpeg"&&(!o.fileType||o.fileType&&o.fileType===e.type)&&(a=fi(e,a))}catch{}return r(a)}}))}mt.getDataUrlFromFile=mi,mt.getFilefromDataUrl=ka,mt.loadImage=bi,mt.drawImageInCanvas=vi,mt.drawFileInCanvas=Xn,mt.canvasToFile=qn,mt.getExifOrientation=wi,mt.handleMaxWidthOrHeight=xi,mt.followExifOrientation=ki,mt.cleanupCanvasMemory=Qt,mt.isAutoOrientationInBrowser=Hr,mt.approximateBelowMaximumCanvasSizeOfBrowser=yi,mt.copyExifWithoutOrientation=fi,mt.getBrowserName=wr,mt.version="2.0.2";const dh=window.G7Core,Zn=e=>{const t=["B","KB","MB","GB"];let r=0,n=e;for(;n>=1024&&r{if(e&&typeof e=="object"){const t=e;if(t.response?.data?.message)return t.response.data.message;if(t.response?.data?.errors){const r=Object.values(t.response.data.errors)[0];if(Array.isArray(r)&&r[0])return r[0]}if(t.message)return t.message}return e instanceof Error?e.message:"업로드 실패"},Si=e=>e?e.startsWith("image/")?"fa-file-image":e.startsWith("video/")?"fa-file-video":e.startsWith("audio/")?"fa-file-audio":e==="application/pdf"?"fa-file-pdf":e.includes("word")||e.includes("document")?"fa-file-word":e.includes("excel")||e.includes("spreadsheet")?"fa-file-excel":e.includes("zip")||e.includes("compressed")?"fa-file-zipper":"fa-file":"fa-file",at=(e,t)=>dh?.t?.(e,t)??e,uh="2.0.2";function fh(){const e=window?.G7Core?.asset;if(typeof e?.template=="function")return e.template("sirsoft-basic",`vendor/browser-image-compression/${uh}/browser-image-compression.js`)}const xr=window.G7Core;function Ei(e){const{attachmentableType:t,attachmentableId:r,collection:n,maxFiles:o,maxSize:a,maxConcurrentUploads:s,accept:l,imageCompression:f,roleIds:h,autoUpload:c,initialFiles:i,endpoints:u,onFilesChange:g,onUploadComplete:p,onUploadError:m,onRemove:x,onReorder:k,uploadTriggerEvent:M,confirmBeforeRemove:v,uploadParams:T}=e,[I,S]=C.useState(i),[N,w]=C.useState([]),[y,E]=C.useState(!1),O=C.useRef(null),$=C.useRef(0),P=C.useRef(new Set),L=C.useRef(new Map),[U,_]=C.useState(!1),[b,z]=C.useState(null),[F,G]=C.useState(!1),X=C.useRef(!1),[B,Y]=C.useState([]),H=C.useRef(i),[W,Q]=C.useState(!1),[be,se]=C.useState(0),pe=C.useRef(0),[ne,Ae]=C.useState(new Map),ve=C.useRef(new Map);C.useEffect(()=>{g?.(N)},[N,g]);const We=C.useMemo(()=>{const q=H.current;return q===i?q:q.length!==i.length?(H.current=i,i):q.length===0&&i.length===0?q:i.some((de,ue)=>de.id!==q[ue]?.id)?(H.current=i,i):q},[i]);C.useEffect(()=>{if(X.current)return;const q=We.filter(ue=>!P.current.has(ue.id)&&(!ue.hash||!P.current.has(ue.hash))),le=new Set(q.map(ue=>ue.id)),de=Array.from(L.current.values()).filter(ue=>!le.has(ue.id)&&!P.current.has(ue.id));S([...q,...de])},[We]);const me=C.useCallback(async q=>{const le={maxSizeMB:f?.maxSizeMB??1,maxWidthOrHeight:f?.maxWidthOrHeight??1920,useWebWorker:!0,libURL:fh()};return await mt(q,le)},[f]),Te=C.useCallback(async q=>{const le=I.length+N.length,de=Math.max(0,o-le),ue=Array.from(q).slice(0,de);if(q.length>de){const ie=Array.from(q).slice(de),Fe=at("attachment.upload_limit_exceeded",{max:o});m?.(Fe,ie[0]??q[0])}for(const ie of ue){if(ie.size>a*1024*1024){m?.(`[${ie.name}] 파일 크기(${Zn(ie.size)})가 최대 허용 크기(${a}MB)를 초과합니다.`,ie);continue}if(l){const Ce="."+ie.name.split(".").pop()?.toLowerCase();if(!l.split(",").map(He=>He.trim().toLowerCase()).some(He=>{if(He.includes("/")){if(He.endsWith("/*")){const je=He.slice(0,-2);return ie.type.toLowerCase().startsWith(je+"/")}return ie.type.toLowerCase()===He}return Ce===He})){m?.(`[${ie.name}] 허용되지 않는 파일 형식입니다. (허용: ${l})`,ie);continue}}const Fe={id:`pending-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,file:ie,original_filename:ie.name,mime_type:ie.type,size:ie.size,size_formatted:Zn(ie.size),status:"pending",progress:0};if(ie.type.startsWith("image/")&&(Fe.preview=URL.createObjectURL(ie)),w(Ce=>[...Ce,Fe]),ie.type.startsWith("image/")&&f){w(Ce=>Ce.map(Ie=>Ie.id===Fe.id?{...Ie,status:"compressing"}:Ie));try{const Ce=await me(ie);w(Ie=>Ie.map(Ne=>Ne.id===Fe.id?{...Ne,compressedBlob:Ce,size:Ce.size,size_formatted:Zn(Ce.size),status:"pending",progress:0}:Ne))}catch{w(Ce=>Ce.map(Ie=>Ie.id===Fe.id?{...Ie,status:"error",error:"이미지 압축 실패"}:Ie))}}}},[I.length,N.length,o,a,l,f,me,m]),ge=C.useCallback(async q=>{const le=new FormData,de=q.compressedBlob?new File([q.compressedBlob],q.original_filename,{type:q.mime_type}):q.file;le.append("file",de),t&&le.append("attachmentable_type",t),r&&le.append("attachmentable_id",String(r)),le.append("collection",n),h.forEach(ue=>{le.append("role_ids[]",String(ue))}),T&&Object.entries(T).forEach(([ue,ie])=>{le.append(ue,ie)});try{const ue=await xr.api.post(u.upload,le,{headers:{"Content-Type":"multipart/form-data"},onUploadProgress:Fe=>{const Ce=Math.round(Fe.loaded*100/(Fe.total??1));w(Ie=>Ie.map(Ne=>Ne.id===q.id?{...Ne,progress:Ce}:Ne))}});return ue?.data?.data??ue?.data}catch(ue){const ie=_i(ue);throw new Error(ie)}},[t,r,n,h,u.upload]),Oe=C.useCallback(async()=>{const q=N.filter(Ce=>Ce.status==="pending"||Ce.status==="error");if(q.length===0)return[];const le=[],de=new Map,ue=[...q],ie=async()=>{for(;ue.length>0&&$.currentIe.map(Ne=>Ne.id===Ce.id?{...Ne,status:"uploading",progress:0}:Ne));try{const Ie=await ge(Ce);if(Ie)le.push(Ie),de.set(String(Ce.id),String(Ie.hash)),L.current.set(Ie.id,Ie),w(Ne=>Ne.filter(He=>He.id!==Ce.id)),S(Ne=>[...Ne,Ie]),Y(Ne=>{if(Ne.length===0)return Ne;const He=String(Ce.id);return Ne.some(_e=>String(_e)===He)?Ne.map(_e=>String(_e)===He?String(Ie.hash):_e):Ne}),Ce.preview&&URL.revokeObjectURL(Ce.preview);else{const Ne=at("attachment.upload_response_invalid");w(He=>He.map(je=>je.id===Ce.id?{...je,status:"error",error:Ne}:je)),m?.(`[${Ce.original_filename}] ${Ne}`,Ce.file)}}catch(Ie){const Ne=Ie instanceof Error?Ie.message:"업로드 실패";w(He=>He.map(je=>je.id===Ce.id?{...je,status:"error",error:Ne}:je)),m?.(`[${Ce.original_filename}] ${Ne}`,Ce.file)}finally{$.current--}}},Fe=Array(Math.min(s,q.length)).fill(null).map(()=>ie());if(await Promise.all(Fe),le.length>0&&(p?.(le),u.reorder&&B.length>0&&k)){const Ce=[...I,...le],Ie=B.map(je=>de.get(String(je))??je),Ne=new Map(Ie.map((je,_e)=>[String(je),_e])),He=[...Ce].sort((je,_e)=>{const xe=Ne.get(String(je.hash))??Ce.length,De=Ne.get(String(_e.hash))??Ce.length;return xe-De}).map((je,_e)=>({...je,sort_order:_e,order:_e+1}));k(He)}return le},[N,s,ge,p,m,B,I,k,u.reorder]);C.useEffect(()=>{if(!M)return;const q=xr.componentEvent.on(M,async()=>{const le=await Oe();return{uploadedAttachments:le,existingFiles:I,allFiles:[...I,...le]}});return()=>{q()}},[M,Oe,I]),C.useEffect(()=>{c&&N.some(q=>q.status==="pending")&&Oe()},[c,N,Oe]);const we=C.useCallback(async q=>{G(!0);try{if(q.id&&u.delete){const de=u.delete.replace(":id",String(q.id));await xr.api.delete(de)}const le=q.hash||q.id;q.id&&(P.current.add(q.id),L.current.delete(q.id)),q.hash&&P.current.add(q.hash),S(de=>de.filter(ue=>(ue.hash||ue.id)!==le)),x?.(q.hash||q.id),_(!1),z(null)}catch{console.error("첨부파일 삭제 실패")}finally{G(!1)}},[x,u.delete]),$e=C.useCallback(async q=>{"hash"in q?v?(z(q),_(!0)):await we(q):(q.preview&&URL.revokeObjectURL(q.preview),w(le=>le.filter(de=>de.id!==q.id)))},[v,we]),ze=C.useCallback(q=>{w(le=>le.map(de=>de.id===q.id?{...de,status:"pending",error:void 0}:de))},[]),K=C.useCallback(async q=>{const{arrayMove:le}=await Promise.resolve().then(()=>Y0),{active:de,over:ue}=q;if(!ue||de.id===ue.id)return;const ie=[...I,...N];let Fe;if(B.length===0)Fe=ie;else{const xe=new Map(B.map((De,Ye)=>[String(De),Ye]));Fe=[...ie].sort((De,Ye)=>{const rt="hash"in De?String(De.hash):String(De.id),qe="hash"in Ye?String(Ye.hash):String(Ye.id);return(xe.get(rt)??ie.length)-(xe.get(qe)??ie.length)})}const Ce=Fe.findIndex(xe=>"hash"in xe?xe.hash===de.id:xe.id===de.id),Ie=Fe.findIndex(xe=>"hash"in xe?xe.hash===ue.id:xe.id===ue.id),Ne=le(Fe,Ce,Ie);Y(Ne.map(xe=>"hash"in xe?xe.hash:xe.id));const He=Ne.filter(xe=>"hash"in xe),je=Ne.filter(xe=>!("hash"in xe));X.current=!0,S(He),w(je);const _e=He.map((xe,De)=>({...xe,sort_order:De,order:De+1}));if(He.length>0&&u.reorder){const xe=He.map((De,Ye)=>({id:De.id,order:Ye+1}));try{const De=await xr.api.patch(u.reorder,{order:xe});xr.toast.success(De.message)}catch(De){const Ye=De instanceof Error?De.message:at("attachment.reorder_failed");xr.toast.error(Ye)}}k?.(_e)},[I,N,B,u.reorder,k]),oe=C.useMemo(()=>[...I,...N].filter(q=>"is_image"in q?q.is_image:q.mime_type?.startsWith("image/")??!1),[I,N]),ae=C.useCallback(q=>{const le=oe.findIndex(de=>"hash"in q&&"hash"in de?de.hash===q.hash:"id"in q&&"id"in de&&!("hash"in q)&&!("hash"in de)?de.id===q.id:!1);le!==-1&&(pe.current+=1,se(le),Q(!0))},[oe]);C.useEffect(()=>{let q=!1;return(async()=>{const de=I.filter(ie=>ie.is_image),ue=new Set(de.map(ie=>ie.id));for(const[ie,Fe]of ve.current)ue.has(ie)||(URL.revokeObjectURL(Fe),ve.current.delete(ie));for(const ie of de){if(q)break;if(!ve.current.has(ie.id)){if(ua(ie.download_url)){ve.current.set(ie.id,ie.download_url),Ae(new Map(ve.current));continue}try{const Fe=await xr.api.get(ie.download_url,{responseType:"blob",headers:zn()});if(!q&&Fe){const Ce=URL.createObjectURL(Fe);ve.current.set(ie.id,Ce),Ae(new Map(ve.current))}}catch(Fe){console.error("Failed to load authenticated image:",Fe)}}}})(),()=>{q=!0}},[I]),C.useEffect(()=>()=>{ve.current.forEach(q=>URL.revokeObjectURL(q)),ve.current.clear()},[]);const ce=C.useCallback(async q=>{const{executeImageDownload:le}=await Promise.resolve().then(()=>ni);await le({src:q.download_url,downloadUrl:q.download_url,filename:q.original_filename,downloadRequiresAuth:!0})},[]),ke=C.useMemo(()=>{const q=[...I,...N];if(B.length===0)return q;const le=new Map(B.map((de,ue)=>[String(de),ue]));return[...q].sort((de,ue)=>{const ie="hash"in de?String(de.hash):String(de.id),Fe="hash"in ue?String(ue.hash):String(ue.id),Ce=le.get(ie)??q.length,Ie=le.get(Fe)??q.length;return Ce-Ie})},[I,N,B]),Ee=ke.length,Be=Ee>0,Me=Eew([]),[]),Pe=C.useCallback(()=>N,[N]);return{existingFiles:I,pendingFiles:N,isDragOver:y,setIsDragOver:E,isDeleting:F,totalCount:Ee,hasFiles:Be,canAddMore:Me,allItems:ke,imageFiles:oe,handleFiles:Te,handleRemove:$e,handleRetry:ze,handleUploadAll:Oe,handleOpenGallery:ae,handleDownload:ce,handleDragEnd:K,inputRef:O,galleryOpen:W,setGalleryOpen:Q,galleryStartIndex:be,galleryKeyRef:pe,confirmDialogOpen:U,setConfirmDialogOpen:_,itemToDelete:b,executeRemoveAttachment:we,authenticatedImageUrls:ne,clear:Ke,getPendingFiles:Pe}}const Ti=({isDragOver:e,canAddMore:t,onFiles:r,setIsDragOver:n,inputRef:o,accept:a,maxFiles:s,maxSize:l,children:f})=>d.jsxs(j,{className:` relative border-2 border-dashed rounded-lg transition-colors ${e?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-300 dark:border-gray-600"} - `,onDragOver:h=>{h.preventDefault(),t&&n(!0)},onDragLeave:()=>n(!1),onDrop:h=>{h.preventDefault(),n(!1),t&&r(h.dataTransfer.files)},children:[d.jsx("input",{ref:o,type:"file",multiple:!0,accept:a,onChange:h=>h.target.files&&r(h.target.files),className:"hidden"}),!f&&d.jsxs(j,{className:"p-8 text-center cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors",onClick:()=>o.current?.click(),children:[d.jsx(It,{className:"fa-solid fa-cloud-arrow-up text-4xl text-gray-400 dark:text-gray-500 mb-4"}),d.jsx(Gt,{className:"text-sm text-gray-600 dark:text-gray-400",children:at("attachment.drop_or_click")}),d.jsxs(Gt,{className:"text-xs text-gray-500 dark:text-gray-500 mt-2",children:[at("attachment.upload_limit",{maxFiles:s,maxSize:l}),a&&` (${a})`]})]}),f]});function uh(){for(var e=arguments.length,t=new Array(e),r=0;rn=>{t.forEach(o=>o(n))},t)}const Qn=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Gr(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function _a(e){return"nodeType"in e}function Ct(e){var t,r;return e?Gr(e)?e:_a(e)&&(t=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?t:window:window}function Sa(e){const{Document:t}=Ct(e);return e instanceof t}function dn(e){return Gr(e)?!1:e instanceof Ct(e).HTMLElement}function Ai(e){return e instanceof Ct(e).SVGElement}function jr(e){return e?Gr(e)?e.document:_a(e)?Sa(e)?e:dn(e)||Ai(e)?e.ownerDocument:document:document:document}const Jt=Qn?C.useLayoutEffect:C.useEffect;function Ea(e){const t=C.useRef(e);return Jt(()=>{t.current=e}),C.useCallback(function(){for(var r=arguments.length,n=new Array(r),o=0;o{e.current=setInterval(n,o)},[]),r=C.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,r]}function un(e,t){t===void 0&&(t=[e]);const r=C.useRef(e);return Jt(()=>{r.current!==e&&(r.current=e)},t),r}function fn(e,t){const r=C.useRef();return C.useMemo(()=>{const n=e(r.current);return r.current=n,n},[...t])}function Jn(e){const t=Ea(e),r=C.useRef(null),n=C.useCallback(o=>{o!==r.current&&t?.(o,r.current),r.current=o},[]);return[r,n]}function Ta(e){const t=C.useRef();return C.useEffect(()=>{t.current=e},[e]),t.current}let Aa={};function gn(e,t){return C.useMemo(()=>{if(t)return t;const r=Aa[e]==null?0:Aa[e]+1;return Aa[e]=r,e+"-"+r},[e,t])}function Ni(e){return function(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o{const l=Object.entries(s);for(const[f,h]of l){const c=a[f];c!=null&&(a[f]=c+e*h)}return a},{...t})}}const Br=Ni(1),hn=Ni(-1);function gh(e){return"clientX"in e&&"clientY"in e}function Na(e){if(!e)return!1;const{KeyboardEvent:t}=Ct(e.target);return t&&e instanceof t}function hh(e){if(!e)return!1;const{TouchEvent:t}=Ct(e.target);return t&&e instanceof t}function Oa(e){if(hh(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:r}=e.touches[0];return{x:t,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:r}=e.changedTouches[0];return{x:t,y:r}}}return gh(e)?{x:e.clientX,y:e.clientY}:null}const pn=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:r}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:r}=e;return"scaleX("+t+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[pn.Translate.toString(e),pn.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:r,easing:n}=e;return t+" "+r+"ms "+n}}}),Oi="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function ph(e){return e.matches(Oi)?e:e.querySelector(Oi)}const mh={display:"none"};function bh(e){let{id:t,value:r}=e;return C.createElement("div",{id:t,style:mh},r)}function yh(e){let{id:t,announcement:r,ariaLiveType:n="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return C.createElement("div",{id:t,style:o,role:"status","aria-live":n,"aria-atomic":!0},r)}function vh(){const[e,t]=C.useState("");return{announce:C.useCallback(n=>{n!=null&&t(n)},[]),announcement:e}}const Mi=C.createContext(null);function wh(e){const t=C.useContext(Mi);C.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of ");return t(e)},[e,t])}function xh(){const[e]=C.useState(()=>new Set),t=C.useCallback(n=>(e.add(n),()=>e.delete(n)),[e]);return[C.useCallback(n=>{let{type:o,event:a}=n;e.forEach(s=>{var l;return(l=s[o])==null?void 0:l.call(s,a)})},[e]),t]}const kh={draggable:` + `,onDragOver:h=>{h.preventDefault(),t&&n(!0)},onDragLeave:()=>n(!1),onDrop:h=>{h.preventDefault(),n(!1),t&&r(h.dataTransfer.files)},children:[d.jsx("input",{ref:o,type:"file",multiple:!0,accept:a,onChange:h=>h.target.files&&r(h.target.files),className:"hidden"}),!f&&d.jsxs(j,{className:"p-8 text-center cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors",onClick:()=>o.current?.click(),children:[d.jsx(It,{className:"fa-solid fa-cloud-arrow-up text-4xl text-gray-400 dark:text-gray-500 mb-4"}),d.jsx(Gt,{className:"text-sm text-gray-600 dark:text-gray-400",children:at("attachment.drop_or_click")}),d.jsxs(Gt,{className:"text-xs text-gray-500 dark:text-gray-500 mt-2",children:[at("attachment.upload_limit",{maxFiles:s,maxSize:l}),a&&` (${a})`]})]}),f]});function gh(){for(var e=arguments.length,t=new Array(e),r=0;rn=>{t.forEach(o=>o(n))},t)}const Qn=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Gr(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function _a(e){return"nodeType"in e}function Ct(e){var t,r;return e?Gr(e)?e:_a(e)&&(t=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?t:window:window}function Sa(e){const{Document:t}=Ct(e);return e instanceof t}function dn(e){return Gr(e)?!1:e instanceof Ct(e).HTMLElement}function Ai(e){return e instanceof Ct(e).SVGElement}function jr(e){return e?Gr(e)?e.document:_a(e)?Sa(e)?e:dn(e)||Ai(e)?e.ownerDocument:document:document:document}const Jt=Qn?C.useLayoutEffect:C.useEffect;function Ea(e){const t=C.useRef(e);return Jt(()=>{t.current=e}),C.useCallback(function(){for(var r=arguments.length,n=new Array(r),o=0;o{e.current=setInterval(n,o)},[]),r=C.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,r]}function un(e,t){t===void 0&&(t=[e]);const r=C.useRef(e);return Jt(()=>{r.current!==e&&(r.current=e)},t),r}function fn(e,t){const r=C.useRef();return C.useMemo(()=>{const n=e(r.current);return r.current=n,n},[...t])}function Jn(e){const t=Ea(e),r=C.useRef(null),n=C.useCallback(o=>{o!==r.current&&t?.(o,r.current),r.current=o},[]);return[r,n]}function Ta(e){const t=C.useRef();return C.useEffect(()=>{t.current=e},[e]),t.current}let Aa={};function gn(e,t){return C.useMemo(()=>{if(t)return t;const r=Aa[e]==null?0:Aa[e]+1;return Aa[e]=r,e+"-"+r},[e,t])}function Ni(e){return function(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o{const l=Object.entries(s);for(const[f,h]of l){const c=a[f];c!=null&&(a[f]=c+e*h)}return a},{...t})}}const Br=Ni(1),hn=Ni(-1);function ph(e){return"clientX"in e&&"clientY"in e}function Na(e){if(!e)return!1;const{KeyboardEvent:t}=Ct(e.target);return t&&e instanceof t}function mh(e){if(!e)return!1;const{TouchEvent:t}=Ct(e.target);return t&&e instanceof t}function Oa(e){if(mh(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:r}=e.touches[0];return{x:t,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:r}=e.changedTouches[0];return{x:t,y:r}}}return ph(e)?{x:e.clientX,y:e.clientY}:null}const pn=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:r}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:r}=e;return"scaleX("+t+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[pn.Translate.toString(e),pn.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:r,easing:n}=e;return t+" "+r+"ms "+n}}}),Oi="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function bh(e){return e.matches(Oi)?e:e.querySelector(Oi)}const yh={display:"none"};function vh(e){let{id:t,value:r}=e;return C.createElement("div",{id:t,style:yh},r)}function wh(e){let{id:t,announcement:r,ariaLiveType:n="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return C.createElement("div",{id:t,style:o,role:"status","aria-live":n,"aria-atomic":!0},r)}function xh(){const[e,t]=C.useState("");return{announce:C.useCallback(n=>{n!=null&&t(n)},[]),announcement:e}}const Mi=C.createContext(null);function kh(e){const t=C.useContext(Mi);C.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of ");return t(e)},[e,t])}function Ch(){const[e]=C.useState(()=>new Set),t=C.useCallback(n=>(e.add(n),()=>e.delete(n)),[e]);return[C.useCallback(n=>{let{type:o,event:a}=n;e.forEach(s=>{var l;return(l=s[o])==null?void 0:l.call(s,a)})},[e]),t]}const _h={draggable:` To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel. - `},Ch={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was moved over droppable area "+r.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was dropped over droppable area "+r.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function _h(e){let{announcements:t=Ch,container:r,hiddenTextDescribedById:n,screenReaderInstructions:o=kh}=e;const{announce:a,announcement:s}=vh(),l=gn("DndLiveRegion"),[f,h]=C.useState(!1);if(C.useEffect(()=>{h(!0)},[]),wh(C.useMemo(()=>({onDragStart(i){let{active:u}=i;a(t.onDragStart({active:u}))},onDragMove(i){let{active:u,over:g}=i;t.onDragMove&&a(t.onDragMove({active:u,over:g}))},onDragOver(i){let{active:u,over:g}=i;a(t.onDragOver({active:u,over:g}))},onDragEnd(i){let{active:u,over:g}=i;a(t.onDragEnd({active:u,over:g}))},onDragCancel(i){let{active:u,over:g}=i;a(t.onDragCancel({active:u,over:g}))}}),[a,t])),!f)return null;const c=C.createElement(C.Fragment,null,C.createElement(bh,{id:n,value:o.draggable}),C.createElement(yh,{id:l,announcement:s}));return r?tr.createPortal(c,r):c}var st;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(st||(st={}));function Rn(){}function Ii(e,t){return C.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function Sh(){for(var e=arguments.length,t=new Array(e),r=0;r[...t].filter(n=>n!=null),[...t])}const qt=Object.freeze({x:0,y:0});function Di(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Pi(e,t){let{data:{value:r}}=e,{data:{value:n}}=t;return r-n}function Eh(e,t){let{data:{value:r}}=e,{data:{value:n}}=t;return n-r}function Li(e){let{left:t,top:r,height:n,width:o}=e;return[{x:t,y:r},{x:t+o,y:r},{x:t,y:r+n},{x:t+o,y:r+n}]}function $i(e,t){if(!e||e.length===0)return null;const[r]=e;return r[t]}function Fi(e,t,r){return t===void 0&&(t=e.left),r===void 0&&(r=e.top),{x:t+e.width*.5,y:r+e.height*.5}}const Th=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:n}=e;const o=Fi(t,t.left,t.top),a=[];for(const s of n){const{id:l}=s,f=r.get(l);if(f){const h=Di(Fi(f),o);a.push({id:l,data:{droppableContainer:s,value:h}})}}return a.sort(Pi)},Ah=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:n}=e;const o=Li(t),a=[];for(const s of n){const{id:l}=s,f=r.get(l);if(f){const h=Li(f),c=o.reduce((u,g,p)=>u+Di(h[p],g),0),i=Number((c/4).toFixed(4));a.push({id:l,data:{droppableContainer:s,value:i}})}}return a.sort(Pi)};function Nh(e,t){const r=Math.max(t.top,e.top),n=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),s=o-n,l=a-r;if(n{let{collisionRect:t,droppableRects:r,droppableContainers:n}=e;const o=[];for(const a of n){const{id:s}=a,l=r.get(s);if(l){const f=Nh(l,t);f>0&&o.push({id:s,data:{droppableContainer:a,value:f}})}}return o.sort(Eh)};function Mh(e,t,r){return{...e,scaleX:t&&r?t.width/r.width:1,scaleY:t&&r?t.height/r.height:1}}function Ui(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:qt}function Ih(e){return function(r){for(var n=arguments.length,o=new Array(n>1?n-1:0),a=1;a({...s,top:s.top+e*l.y,bottom:s.bottom+e*l.y,left:s.left+e*l.x,right:s.right+e*l.x}),{...r})}}const Dh=Ih(1);function Ph(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Lh(e,t,r){const n=Ph(t);if(!n)return e;const{scaleX:o,scaleY:a,x:s,y:l}=n,f=e.left-s-(1-o)*parseFloat(r),h=e.top-l-(1-a)*parseFloat(r.slice(r.indexOf(" ")+1)),c=o?e.width/o:e.width,i=a?e.height/a:e.height;return{width:c,height:i,top:h,right:f+c,bottom:h+i,left:f}}const $h={ignoreTransform:!1};function Wr(e,t){t===void 0&&(t=$h);let r=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:h,transformOrigin:c}=Ct(e).getComputedStyle(e);h&&(r=Lh(r,h,c))}const{top:n,left:o,width:a,height:s,bottom:l,right:f}=r;return{top:n,left:o,width:a,height:s,bottom:l,right:f}}function zi(e){return Wr(e,{ignoreTransform:!0})}function Fh(e){const t=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:t,bottom:r,width:t,height:r}}function Uh(e,t){return t===void 0&&(t=Ct(e).getComputedStyle(e)),t.position==="fixed"}function zh(e,t){t===void 0&&(t=Ct(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const a=t[o];return typeof a=="string"?r.test(a):!1})}function eo(e,t){const r=[];function n(o){if(t!=null&&r.length>=t||!o)return r;if(Sa(o)&&o.scrollingElement!=null&&!r.includes(o.scrollingElement))return r.push(o.scrollingElement),r;if(!dn(o)||Ai(o)||r.includes(o))return r;const a=Ct(e).getComputedStyle(o);return o!==e&&zh(o,a)&&r.push(o),Uh(o,a)?r:n(o.parentNode)}return e?n(e):r}function Hi(e){const[t]=eo(e,1);return t??null}function Ma(e){return!Qn||!e?null:Gr(e)?e:_a(e)?Sa(e)||e===jr(e).scrollingElement?window:dn(e)?e:null:null}function Gi(e){return Gr(e)?e.scrollX:e.scrollLeft}function ji(e){return Gr(e)?e.scrollY:e.scrollTop}function Ia(e){return{x:Gi(e),y:ji(e)}}var ut;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ut||(ut={}));function Bi(e){return!Qn||!e?!1:e===document.scrollingElement}function Wi(e){const t={x:0,y:0},r=Bi(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},n={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},o=e.scrollTop<=t.y,a=e.scrollLeft<=t.x,s=e.scrollTop>=n.y,l=e.scrollLeft>=n.x;return{isTop:o,isLeft:a,isBottom:s,isRight:l,maxScroll:n,minScroll:t}}const Hh={x:.2,y:.2};function Gh(e,t,r,n,o){let{top:a,left:s,right:l,bottom:f}=r;n===void 0&&(n=10),o===void 0&&(o=Hh);const{isTop:h,isBottom:c,isLeft:i,isRight:u}=Wi(e),g={x:0,y:0},p={x:0,y:0},m={height:t.height*o.y,width:t.width*o.x};return!h&&a<=t.top+m.height?(g.y=ut.Backward,p.y=n*Math.abs((t.top+m.height-a)/m.height)):!c&&f>=t.bottom-m.height&&(g.y=ut.Forward,p.y=n*Math.abs((t.bottom-m.height-f)/m.height)),!u&&l>=t.right-m.width?(g.x=ut.Forward,p.x=n*Math.abs((t.right-m.width-l)/m.width)):!i&&s<=t.left+m.width&&(g.x=ut.Backward,p.x=n*Math.abs((t.left+m.width-s)/m.width)),{direction:g,speed:p}}function jh(e){if(e===document.scrollingElement){const{innerWidth:a,innerHeight:s}=window;return{top:0,left:0,right:a,bottom:s,width:a,height:s}}const{top:t,left:r,right:n,bottom:o}=e.getBoundingClientRect();return{top:t,left:r,right:n,bottom:o,width:e.clientWidth,height:e.clientHeight}}function Vi(e){return e.reduce((t,r)=>Br(t,Ia(r)),qt)}function Bh(e){return e.reduce((t,r)=>t+Gi(r),0)}function Wh(e){return e.reduce((t,r)=>t+ji(r),0)}function Vh(e,t){if(t===void 0&&(t=Wr),!e)return;const{top:r,left:n,bottom:o,right:a}=t(e);Hi(e)&&(o<=0||a<=0||r>=window.innerHeight||n>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Kh=[["x",["left","right"],Bh],["y",["top","bottom"],Wh]];class Da{constructor(t,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=eo(r),o=Vi(n);this.rect={...t},this.width=t.width,this.height=t.height;for(const[a,s,l]of Kh)for(const f of s)Object.defineProperty(this,f,{get:()=>{const h=l(n),c=o[a]-h;return this.rect[f]+c},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class mn{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...r)})},this.target=t}add(t,r,n){var o;(o=this.target)==null||o.addEventListener(t,r,n),this.listeners.push([t,r,n])}}function Yh(e){const{EventTarget:t}=Ct(e);return e instanceof t?e:jr(e)}function Pa(e,t){const r=Math.abs(e.x),n=Math.abs(e.y);return typeof t=="number"?Math.sqrt(r**2+n**2)>t:"x"in t&&"y"in t?r>t.x&&n>t.y:"x"in t?r>t.x:"y"in t?n>t.y:!1}var zt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(zt||(zt={}));function Ki(e){e.preventDefault()}function Xh(e){e.stopPropagation()}var Ue;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(Ue||(Ue={}));const Yi={start:[Ue.Space,Ue.Enter],cancel:[Ue.Esc],end:[Ue.Space,Ue.Enter,Ue.Tab]},qh=(e,t)=>{let{currentCoordinates:r}=t;switch(e.code){case Ue.Right:return{...r,x:r.x+25};case Ue.Left:return{...r,x:r.x-25};case Ue.Down:return{...r,y:r.y+25};case Ue.Up:return{...r,y:r.y-25}}};class La{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:r}}=t;this.props=t,this.listeners=new mn(jr(r)),this.windowListeners=new mn(Ct(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(zt.Resize,this.handleCancel),this.windowListeners.add(zt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(zt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:r}=this.props,n=t.node.current;n&&Vh(n),r(qt)}handleKeyDown(t){if(Na(t)){const{active:r,context:n,options:o}=this.props,{keyboardCodes:a=Yi,coordinateGetter:s=qh,scrollBehavior:l="smooth"}=o,{code:f}=t;if(a.end.includes(f)){this.handleEnd(t);return}if(a.cancel.includes(f)){this.handleCancel(t);return}const{collisionRect:h}=n.current,c=h?{x:h.left,y:h.top}:qt;this.referenceCoordinates||(this.referenceCoordinates=c);const i=s(t,{active:r,context:n.current,currentCoordinates:c});if(i){const u=hn(i,c),g={x:0,y:0},{scrollableAncestors:p}=n.current;for(const m of p){const x=t.code,{isTop:k,isRight:M,isLeft:v,isBottom:T,maxScroll:I,minScroll:S}=Wi(m),N=jh(m),w={x:Math.min(x===Ue.Right?N.right-N.width/2:N.right,Math.max(x===Ue.Right?N.left:N.left+N.width/2,i.x)),y:Math.min(x===Ue.Down?N.bottom-N.height/2:N.bottom,Math.max(x===Ue.Down?N.top:N.top+N.height/2,i.y))},y=x===Ue.Right&&!M||x===Ue.Left&&!v,E=x===Ue.Down&&!T||x===Ue.Up&&!k;if(y&&w.x!==i.x){const O=m.scrollLeft+u.x,$=x===Ue.Right&&O<=I.x||x===Ue.Left&&O>=S.x;if($&&!u.y){m.scrollTo({left:O,behavior:l});return}$?g.x=m.scrollLeft-O:g.x=x===Ue.Right?m.scrollLeft-I.x:m.scrollLeft-S.x,g.x&&m.scrollBy({left:-g.x,behavior:l});break}else if(E&&w.y!==i.y){const O=m.scrollTop+u.y,$=x===Ue.Down&&O<=I.y||x===Ue.Up&&O>=S.y;if($&&!u.x){m.scrollTo({top:O,behavior:l});return}$?g.y=m.scrollTop-O:g.y=x===Ue.Down?m.scrollTop-I.y:m.scrollTop-S.y,g.y&&m.scrollBy({top:-g.y,behavior:l});break}}this.handleMove(t,Br(hn(i,this.referenceCoordinates),g))}}}handleMove(t,r){const{onMove:n}=this.props;t.preventDefault(),n(r)}handleEnd(t){const{onEnd:r}=this.props;t.preventDefault(),this.detach(),r()}handleCancel(t){const{onCancel:r}=this.props;t.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}La.activators=[{eventName:"onKeyDown",handler:(e,t,r)=>{let{keyboardCodes:n=Yi,onActivation:o}=t,{active:a}=r;const{code:s}=e.nativeEvent;if(n.start.includes(s)){const l=a.activatorNode.current;return l&&e.target!==l?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function Xi(e){return!!(e&&"distance"in e)}function qi(e){return!!(e&&"delay"in e)}class $a{constructor(t,r,n){var o;n===void 0&&(n=Yh(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=r;const{event:a}=t,{target:s}=a;this.props=t,this.events=r,this.document=jr(s),this.documentListeners=new mn(this.document),this.listeners=new mn(n),this.windowListeners=new mn(Ct(s)),this.initialCoordinates=(o=Oa(a))!=null?o:qt,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:r,bypassActivationConstraint:n}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(zt.Resize,this.handleCancel),this.windowListeners.add(zt.DragStart,Ki),this.windowListeners.add(zt.VisibilityChange,this.handleCancel),this.windowListeners.add(zt.ContextMenu,Ki),this.documentListeners.add(zt.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(qi(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(Xi(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,r){const{active:n,onPending:o}=this.props;o(n,t,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:t}=this,{onStart:r}=this.props;t&&(this.activated=!0,this.documentListeners.add(zt.Click,Xh,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(zt.SelectionChange,this.removeTextSelection),r(t))}handleMove(t){var r;const{activated:n,initialCoordinates:o,props:a}=this,{onMove:s,options:{activationConstraint:l}}=a;if(!o)return;const f=(r=Oa(t))!=null?r:qt,h=hn(o,f);if(!n&&l){if(Xi(l)){if(l.tolerance!=null&&Pa(h,l.tolerance))return this.handleCancel();if(Pa(h,l.distance))return this.handleStart()}if(qi(l)&&Pa(h,l.tolerance))return this.handleCancel();this.handlePending(l,h);return}t.cancelable&&t.preventDefault(),s(f)}handleEnd(){const{onAbort:t,onEnd:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleCancel(){const{onAbort:t,onCancel:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleKeydown(t){t.code===Ue.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const Zh={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Fa extends $a{constructor(t){const{event:r}=t,n=jr(r.target);super(t,Zh,n)}}Fa.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:n}=t;return!r.isPrimary||r.button!==0?!1:(n?.({event:r}),!0)}}];const Qh={move:{name:"mousemove"},end:{name:"mouseup"}};var Ua;(function(e){e[e.RightClick=2]="RightClick"})(Ua||(Ua={}));class Jh extends $a{constructor(t){super(t,Qh,jr(t.event.target))}}Jh.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:n}=t;return r.button===Ua.RightClick?!1:(n?.({event:r}),!0)}}];const za={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Rh extends $a{constructor(t){super(t,za)}static setup(){return window.addEventListener(za.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(za.move.name,t)};function t(){}}}Rh.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:n}=t;const{touches:o}=r;return o.length>1?!1:(n?.({event:r}),!0)}}];var bn;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(bn||(bn={}));var to;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(to||(to={}));function e0(e){let{acceleration:t,activator:r=bn.Pointer,canScroll:n,draggingRect:o,enabled:a,interval:s=5,order:l=to.TreeOrder,pointerCoordinates:f,scrollableAncestors:h,scrollableAncestorRects:c,delta:i,threshold:u}=e;const g=r0({delta:i,disabled:!a}),[p,m]=fh(),x=C.useRef({x:0,y:0}),k=C.useRef({x:0,y:0}),M=C.useMemo(()=>{switch(r){case bn.Pointer:return f?{top:f.y,bottom:f.y,left:f.x,right:f.x}:null;case bn.DraggableRect:return o}},[r,o,f]),v=C.useRef(null),T=C.useCallback(()=>{const S=v.current;if(!S)return;const N=x.current.x*k.current.x,w=x.current.y*k.current.y;S.scrollBy(N,w)},[]),I=C.useMemo(()=>l===to.TreeOrder?[...h].reverse():h,[l,h]);C.useEffect(()=>{if(!a||!h.length||!M){m();return}for(const S of I){if(n?.(S)===!1)continue;const N=h.indexOf(S),w=c[N];if(!w)continue;const{direction:y,speed:E}=Gh(S,w,M,t,u);for(const O of["x","y"])g[O][y[O]]||(E[O]=0,y[O]=0);if(E.x>0||E.y>0){m(),v.current=S,p(T,s),x.current=E,k.current=y;return}}x.current={x:0,y:0},k.current={x:0,y:0},m()},[t,T,n,m,a,s,JSON.stringify(M),JSON.stringify(g),p,h,I,c,JSON.stringify(u)])}const t0={x:{[ut.Backward]:!1,[ut.Forward]:!1},y:{[ut.Backward]:!1,[ut.Forward]:!1}};function r0(e){let{delta:t,disabled:r}=e;const n=Ta(t);return fn(o=>{if(r||!n||!o)return t0;const a={x:Math.sign(t.x-n.x),y:Math.sign(t.y-n.y)};return{x:{[ut.Backward]:o.x[ut.Backward]||a.x===-1,[ut.Forward]:o.x[ut.Forward]||a.x===1},y:{[ut.Backward]:o.y[ut.Backward]||a.y===-1,[ut.Forward]:o.y[ut.Forward]||a.y===1}}},[r,t,n])}function n0(e,t){const r=t!=null?e.get(t):void 0,n=r?r.node.current:null;return fn(o=>{var a;return t==null?null:(a=n??o)!=null?a:null},[n,t])}function o0(e,t){return C.useMemo(()=>e.reduce((r,n)=>{const{sensor:o}=n,a=o.activators.map(s=>({eventName:s.eventName,handler:t(s.handler,n)}));return[...r,...a]},[]),[e,t])}var yn;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(yn||(yn={}));var Ha;(function(e){e.Optimized="optimized"})(Ha||(Ha={}));const Zi=new Map;function a0(e,t){let{dragging:r,dependencies:n,config:o}=t;const[a,s]=C.useState(null),{frequency:l,measure:f,strategy:h}=o,c=C.useRef(e),i=x(),u=un(i),g=C.useCallback(function(k){k===void 0&&(k=[]),!u.current&&s(M=>M===null?k:M.concat(k.filter(v=>!M.includes(v))))},[u]),p=C.useRef(null),m=fn(k=>{if(i&&!r)return Zi;if(!k||k===Zi||c.current!==e||a!=null){const M=new Map;for(let v of e){if(!v)continue;if(a&&a.length>0&&!a.includes(v.id)&&v.rect.current){M.set(v.id,v.rect.current);continue}const T=v.node.current,I=T?new Da(f(T),T):null;v.rect.current=I,I&&M.set(v.id,I)}return M}return k},[e,a,r,i,f]);return C.useEffect(()=>{c.current=e},[e]),C.useEffect(()=>{i||g()},[r,i]),C.useEffect(()=>{a&&a.length>0&&s(null)},[JSON.stringify(a)]),C.useEffect(()=>{i||typeof l!="number"||p.current!==null||(p.current=setTimeout(()=>{g(),p.current=null},l))},[l,i,g,...n]),{droppableRects:m,measureDroppableContainers:g,measuringScheduled:a!=null};function x(){switch(h){case yn.Always:return!1;case yn.BeforeDragging:return r;default:return!r}}}function Qi(e,t){return fn(r=>e?r||(typeof t=="function"?t(e):e):null,[t,e])}function s0(e,t){return Qi(e,t)}function l0(e){let{callback:t,disabled:r}=e;const n=Ea(t),o=C.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(n)},[n,r]);return C.useEffect(()=>()=>o?.disconnect(),[o]),o}function ro(e){let{callback:t,disabled:r}=e;const n=Ea(t),o=C.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(n)},[r]);return C.useEffect(()=>()=>o?.disconnect(),[o]),o}function i0(e){return new Da(Wr(e),e)}function Ji(e,t,r){t===void 0&&(t=i0);const[n,o]=C.useState(null);function a(){o(f=>{if(!e)return null;if(e.isConnected===!1){var h;return(h=f??r)!=null?h:null}const c=t(e);return JSON.stringify(f)===JSON.stringify(c)?f:c})}const s=l0({callback(f){if(e)for(const h of f){const{type:c,target:i}=h;if(c==="childList"&&i instanceof HTMLElement&&i.contains(e)){a();break}}}}),l=ro({callback:a});return Jt(()=>{a(),e?(l?.observe(e),s?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),s?.disconnect())},[e]),n}function c0(e){const t=Qi(e);return Ui(e,t)}const Ri=[];function d0(e){const t=C.useRef(e),r=fn(n=>e?n&&n!==Ri&&e&&t.current&&e.parentNode===t.current.parentNode?n:eo(e):Ri,[e]);return C.useEffect(()=>{t.current=e},[e]),r}function u0(e){const[t,r]=C.useState(null),n=C.useRef(e),o=C.useCallback(a=>{const s=Ma(a.target);s&&r(l=>l?(l.set(s,Ia(s)),new Map(l)):null)},[]);return C.useEffect(()=>{const a=n.current;if(e!==a){s(a);const l=e.map(f=>{const h=Ma(f);return h?(h.addEventListener("scroll",o,{passive:!0}),[h,Ia(h)]):null}).filter(f=>f!=null);r(l.length?new Map(l):null),n.current=e}return()=>{s(e),s(a)};function s(l){l.forEach(f=>{const h=Ma(f);h?.removeEventListener("scroll",o)})}},[o,e]),C.useMemo(()=>e.length?t?Array.from(t.values()).reduce((a,s)=>Br(a,s),qt):Vi(e):qt,[e,t])}function ec(e,t){t===void 0&&(t=[]);const r=C.useRef(null);return C.useEffect(()=>{r.current=null},t),C.useEffect(()=>{const n=e!==qt;n&&!r.current&&(r.current=e),!n&&r.current&&(r.current=null)},[e]),r.current?hn(e,r.current):qt}function f0(e){C.useEffect(()=>{if(!Qn)return;const t=e.map(r=>{let{sensor:n}=r;return n.setup==null?void 0:n.setup()});return()=>{for(const r of t)r?.()}},e.map(t=>{let{sensor:r}=t;return r}))}function g0(e,t){return C.useMemo(()=>e.reduce((r,n)=>{let{eventName:o,handler:a}=n;return r[o]=s=>{a(s,t)},r},{}),[e,t])}function tc(e){return C.useMemo(()=>e?Fh(e):null,[e])}const rc=[];function h0(e,t){t===void 0&&(t=Wr);const[r]=e,n=tc(r?Ct(r):null),[o,a]=C.useState(rc);function s(){a(()=>e.length?e.map(f=>Bi(f)?n:new Da(t(f),f)):rc)}const l=ro({callback:s});return Jt(()=>{l?.disconnect(),s(),e.forEach(f=>l?.observe(f))},[e]),o}function p0(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return dn(t)?t:e}function m0(e){let{measure:t}=e;const[r,n]=C.useState(null),o=C.useCallback(h=>{for(const{target:c}of h)if(dn(c)){n(i=>{const u=t(c);return i?{...i,width:u.width,height:u.height}:u});break}},[t]),a=ro({callback:o}),s=C.useCallback(h=>{const c=p0(h);a?.disconnect(),c&&a?.observe(c),n(c?t(c):null)},[t,a]),[l,f]=Jn(s);return C.useMemo(()=>({nodeRef:l,rect:r,setRef:f}),[r,l,f])}const b0=[{sensor:Fa,options:{}},{sensor:La,options:{}}],y0={current:{}},no={draggable:{measure:zi},droppable:{measure:zi,strategy:yn.WhileDragging,frequency:Ha.Optimized},dragOverlay:{measure:Wr}};class vn extends Map{get(t){var r;return t!=null&&(r=super.get(t))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:r}=t;return!r})}getNodeFor(t){var r,n;return(r=(n=this.get(t))==null?void 0:n.node.current)!=null?r:void 0}}const v0={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new vn,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Rn},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:no,measureDroppableContainers:Rn,windowRect:null,measuringScheduled:!1},w0={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Rn,draggableNodes:new Map,over:null,measureDroppableContainers:Rn},oo=C.createContext(w0),nc=C.createContext(v0);function x0(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new vn}}}function k0(e,t){switch(t.type){case st.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case st.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case st.DragEnd:case st.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case st.RegisterDroppable:{const{element:r}=t,{id:n}=r,o=new vn(e.droppable.containers);return o.set(n,r),{...e,droppable:{...e.droppable,containers:o}}}case st.SetDroppableDisabled:{const{id:r,key:n,disabled:o}=t,a=e.droppable.containers.get(r);if(!a||n!==a.key)return e;const s=new vn(e.droppable.containers);return s.set(r,{...a,disabled:o}),{...e,droppable:{...e.droppable,containers:s}}}case st.UnregisterDroppable:{const{id:r,key:n}=t,o=e.droppable.containers.get(r);if(!o||n!==o.key)return e;const a=new vn(e.droppable.containers);return a.delete(r),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function C0(e){let{disabled:t}=e;const{active:r,activatorEvent:n,draggableNodes:o}=C.useContext(oo),a=Ta(n),s=Ta(r?.id);return C.useEffect(()=>{if(!t&&!n&&a&&s!=null){if(!Na(a)||document.activeElement===a.target)return;const l=o.get(s);if(!l)return;const{activatorNode:f,node:h}=l;if(!f.current&&!h.current)return;requestAnimationFrame(()=>{for(const c of[f.current,h.current]){if(!c)continue;const i=ph(c);if(i){i.focus();break}}})}},[n,t,o,s,a]),null}function _0(e,t){let{transform:r,...n}=t;return e!=null&&e.length?e.reduce((o,a)=>a({transform:o,...n}),r):r}function S0(e){return C.useMemo(()=>({draggable:{...no.draggable,...e?.draggable},droppable:{...no.droppable,...e?.droppable},dragOverlay:{...no.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function E0(e){let{activeNode:t,measure:r,initialRect:n,config:o=!0}=e;const a=C.useRef(!1),{x:s,y:l}=typeof o=="boolean"?{x:o,y:o}:o;Jt(()=>{if(!s&&!l||!t){a.current=!1;return}if(a.current||!n)return;const h=t?.node.current;if(!h||h.isConnected===!1)return;const c=r(h),i=Ui(c,n);if(s||(i.x=0),l||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){const u=Hi(h);u&&u.scrollBy({top:i.y,left:i.x})}},[t,s,l,n,r])}const oc=C.createContext({...qt,scaleX:1,scaleY:1});var ar;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(ar||(ar={}));const T0=C.memo(function(t){var r,n,o,a;let{id:s,accessibility:l,autoScroll:f=!0,children:h,sensors:c=b0,collisionDetection:i=Oh,measuring:u,modifiers:g,...p}=t;const m=C.useReducer(k0,void 0,x0),[x,k]=m,[M,v]=xh(),[T,I]=C.useState(ar.Uninitialized),S=T===ar.Initialized,{draggable:{active:N,nodes:w,translate:y},droppable:{containers:E}}=x,O=N!=null?w.get(N):null,$=C.useRef({initial:null,translated:null}),P=C.useMemo(()=>{var _e;return N!=null?{id:N,data:(_e=O?.data)!=null?_e:y0,rect:$}:null},[N,O]),L=C.useRef(null),[U,_]=C.useState(null),[b,z]=C.useState(null),F=un(p,Object.values(p)),G=gn("DndDescribedBy",s),X=C.useMemo(()=>E.getEnabled(),[E]),B=S0(u),{droppableRects:Y,measureDroppableContainers:H,measuringScheduled:W}=a0(X,{dragging:S,dependencies:[y.x,y.y],config:B.droppable}),Q=n0(w,N),be=C.useMemo(()=>b?Oa(b):null,[b]),se=je(),pe=s0(Q,B.draggable.measure);E0({activeNode:N!=null?w.get(N):null,config:se.layoutShiftCompensation,initialRect:pe,measure:B.draggable.measure});const ne=Ji(Q,B.draggable.measure,pe),Ae=Ji(Q?Q.parentElement:null),ve=C.useRef({activatorEvent:null,active:null,activeNode:Q,collisionRect:null,collisions:null,droppableRects:Y,draggableNodes:w,draggingNode:null,draggingNodeRect:null,droppableContainers:E,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),We=E.getNodeFor((r=ve.current.over)==null?void 0:r.id),me=m0({measure:B.dragOverlay.measure}),Te=(n=me.nodeRef.current)!=null?n:Q,ge=S?(o=me.rect)!=null?o:ne:null,Oe=!!(me.nodeRef.current&&me.rect),we=c0(Oe?null:ne),$e=tc(Te?Ct(Te):null),ze=d0(S?We??Q:null),K=h0(ze),oe=_0(g,{transform:{x:y.x-we.x,y:y.y-we.y,scaleX:1,scaleY:1},activatorEvent:b,active:P,activeNodeRect:ne,containerNodeRect:Ae,draggingNodeRect:ge,over:ve.current.over,overlayNodeRect:me.rect,scrollableAncestors:ze,scrollableAncestorRects:K,windowRect:$e}),ae=be?Br(be,y):null,ce=u0(ze),ke=ec(ce),Ee=ec(ce,[ne]),Be=Br(oe,ke),Me=ge?Dh(ge,oe):null,Ke=P&&Me?i({active:P,collisionRect:Me,droppableRects:Y,droppableContainers:X,pointerCoordinates:ae}):null,Pe=$i(Ke,"id"),[q,le]=C.useState(null),de=Oe?oe:Br(oe,Ee),ue=Mh(de,(a=q?.rect)!=null?a:null,ne),ie=C.useRef(null),Fe=C.useCallback((_e,xe)=>{let{sensor:De,options:Ye}=xe;if(L.current==null)return;const rt=w.get(L.current);if(!rt)return;const qe=_e.nativeEvent,Je=new De({active:L.current,activeNode:rt,event:qe,options:Ye,context:ve,onAbort(Ve){if(!w.get(Ve))return;const{onDragAbort:St}=F.current,Pt={id:Ve};St?.(Pt),M({type:"onDragAbort",event:Pt})},onPending(Ve,bt,St,Pt){if(!w.get(Ve))return;const{onDragPending:lr}=F.current,Ht={id:Ve,constraint:bt,initialCoordinates:St,offset:Pt};lr?.(Ht),M({type:"onDragPending",event:Ht})},onStart(Ve){const bt=L.current;if(bt==null)return;const St=w.get(bt);if(!St)return;const{onDragStart:Pt}=F.current,_r={activatorEvent:qe,active:{id:bt,data:St.data,rect:$}};tr.unstable_batchedUpdates(()=>{Pt?.(_r),I(ar.Initializing),k({type:st.DragStart,initialCoordinates:Ve,active:bt}),M({type:"onDragStart",event:_r}),_(ie.current),z(qe)})},onMove(Ve){k({type:st.DragMove,coordinates:Ve})},onEnd:Zt(st.DragEnd),onCancel:Zt(st.DragCancel)});ie.current=Je;function Zt(Ve){return async function(){const{active:St,collisions:Pt,over:_r,scrollAdjustedTranslate:lr}=ve.current;let Ht=null;if(St&&lr){const{cancelDrop:ir}=F.current;Ht={activatorEvent:qe,active:St,collisions:Pt,delta:lr,over:_r},Ve===st.DragEnd&&typeof ir=="function"&&await Promise.resolve(ir(Ht))&&(Ve=st.DragCancel)}L.current=null,tr.unstable_batchedUpdates(()=>{k({type:Ve}),I(ar.Uninitialized),le(null),_(null),z(null),ie.current=null;const ir=Ve===st.DragEnd?"onDragEnd":"onDragCancel";if(Ht){const Sr=F.current[ir];Sr?.(Ht),M({type:ir,event:Ht})}})}}},[w]),Ce=C.useCallback((_e,xe)=>(De,Ye)=>{const rt=De.nativeEvent,qe=w.get(Ye);if(L.current!==null||!qe||rt.dndKit||rt.defaultPrevented)return;const Je={active:qe};_e(De,xe.options,Je)===!0&&(rt.dndKit={capturedBy:xe.sensor},L.current=Ye,Fe(De,xe))},[w,Fe]),Ie=o0(c,Ce);f0(c),Jt(()=>{ne&&T===ar.Initializing&&I(ar.Initialized)},[ne,T]),C.useEffect(()=>{const{onDragMove:_e}=F.current,{active:xe,activatorEvent:De,collisions:Ye,over:rt}=ve.current;if(!xe||!De)return;const qe={active:xe,activatorEvent:De,collisions:Ye,delta:{x:Be.x,y:Be.y},over:rt};tr.unstable_batchedUpdates(()=>{_e?.(qe),M({type:"onDragMove",event:qe})})},[Be.x,Be.y]),C.useEffect(()=>{const{active:_e,activatorEvent:xe,collisions:De,droppableContainers:Ye,scrollAdjustedTranslate:rt}=ve.current;if(!_e||L.current==null||!xe||!rt)return;const{onDragOver:qe}=F.current,Je=Ye.get(Pe),Zt=Je&&Je.rect.current?{id:Je.id,rect:Je.rect.current,data:Je.data,disabled:Je.disabled}:null,Ve={active:_e,activatorEvent:xe,collisions:De,delta:{x:rt.x,y:rt.y},over:Zt};tr.unstable_batchedUpdates(()=>{le(Zt),qe?.(Ve),M({type:"onDragOver",event:Ve})})},[Pe]),Jt(()=>{ve.current={activatorEvent:b,active:P,activeNode:Q,collisionRect:Me,collisions:Ke,droppableRects:Y,draggableNodes:w,draggingNode:Te,draggingNodeRect:ge,droppableContainers:E,over:q,scrollableAncestors:ze,scrollAdjustedTranslate:Be},$.current={initial:ge,translated:Me}},[P,Q,Ke,Me,w,Te,ge,Y,E,q,ze,Be]),e0({...se,delta:y,draggingRect:Me,pointerCoordinates:ae,scrollableAncestors:ze,scrollableAncestorRects:K});const Ne=C.useMemo(()=>({active:P,activeNode:Q,activeNodeRect:ne,activatorEvent:b,collisions:Ke,containerNodeRect:Ae,dragOverlay:me,draggableNodes:w,droppableContainers:E,droppableRects:Y,over:q,measureDroppableContainers:H,scrollableAncestors:ze,scrollableAncestorRects:K,measuringConfiguration:B,measuringScheduled:W,windowRect:$e}),[P,Q,ne,b,Ke,Ae,me,w,E,Y,q,H,ze,K,B,W,$e]),He=C.useMemo(()=>({activatorEvent:b,activators:Ie,active:P,activeNodeRect:ne,ariaDescribedById:{draggable:G},dispatch:k,draggableNodes:w,over:q,measureDroppableContainers:H}),[b,Ie,P,ne,k,G,w,q,H]);return C.createElement(Mi.Provider,{value:v},C.createElement(oo.Provider,{value:He},C.createElement(nc.Provider,{value:Ne},C.createElement(oc.Provider,{value:ue},h)),C.createElement(C0,{disabled:l?.restoreFocus===!1})),C.createElement(_h,{...l,hiddenTextDescribedById:G}));function je(){const _e=U?.autoScrollEnabled===!1,xe=typeof f=="object"?f.enabled===!1:f===!1,De=S&&!_e&&!xe;return typeof f=="object"?{...f,enabled:De}:{enabled:De}}}),A0=C.createContext(null),ac="button",N0="Draggable";function O0(e){let{id:t,data:r,disabled:n=!1,attributes:o}=e;const a=gn(N0),{activators:s,activatorEvent:l,active:f,activeNodeRect:h,ariaDescribedById:c,draggableNodes:i,over:u}=C.useContext(oo),{role:g=ac,roleDescription:p="draggable",tabIndex:m=0}=o??{},x=f?.id===t,k=C.useContext(x?oc:A0),[M,v]=Jn(),[T,I]=Jn(),S=g0(s,t),N=un(r);Jt(()=>(i.set(t,{id:t,key:a,node:M,activatorNode:T,data:N}),()=>{const y=i.get(t);y&&y.key===a&&i.delete(t)}),[i,t]);const w=C.useMemo(()=>({role:g,tabIndex:m,"aria-disabled":n,"aria-pressed":x&&g===ac?!0:void 0,"aria-roledescription":p,"aria-describedby":c.draggable}),[n,g,m,x,p,c.draggable]);return{active:f,activatorEvent:l,activeNodeRect:h,attributes:w,isDragging:x,listeners:n?void 0:S,node:M,over:u,setNodeRef:v,setActivatorNodeRef:I,transform:k}}function M0(){return C.useContext(nc)}const I0="Droppable",D0={timeout:25};function P0(e){let{data:t,disabled:r=!1,id:n,resizeObserverConfig:o}=e;const a=gn(I0),{active:s,dispatch:l,over:f,measureDroppableContainers:h}=C.useContext(oo),c=C.useRef({disabled:r}),i=C.useRef(!1),u=C.useRef(null),g=C.useRef(null),{disabled:p,updateMeasurementsFor:m,timeout:x}={...D0,...o},k=un(m??n),M=C.useCallback(()=>{if(!i.current){i.current=!0;return}g.current!=null&&clearTimeout(g.current),g.current=setTimeout(()=>{h(Array.isArray(k.current)?k.current:[k.current]),g.current=null},x)},[x]),v=ro({callback:M,disabled:p||!s}),T=C.useCallback((w,y)=>{v&&(y&&(v.unobserve(y),i.current=!1),w&&v.observe(w))},[v]),[I,S]=Jn(T),N=un(t);return C.useEffect(()=>{!v||!I.current||(v.disconnect(),i.current=!1,v.observe(I.current))},[I,v]),C.useEffect(()=>(l({type:st.RegisterDroppable,element:{id:n,key:a,disabled:r,node:I,rect:u,data:N}}),()=>l({type:st.UnregisterDroppable,key:a,id:n})),[n]),C.useEffect(()=>{r!==c.current.disabled&&(l({type:st.SetDroppableDisabled,id:n,key:a,disabled:r}),c.current.disabled=r)},[n,a,r,l]),{active:s,rect:u,isOver:f?.id===n,node:I,over:f,setNodeRef:S}}function Ga(e,t,r){const n=e.slice();return n.splice(r<0?n.length+r:r,0,n.splice(t,1)[0]),n}function L0(e,t){return e.reduce((r,n,o)=>{const a=t.get(n);return a&&(r[o]=a),r},Array(e.length))}function ao(e){return e!==null&&e>=0}function $0(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let r=0;r{let{rects:t,activeIndex:r,overIndex:n,index:o}=e;const a=Ga(t,n,r),s=t[o],l=a[o];return!l||!s?null:{x:l.left-s.left,y:l.top-s.top,scaleX:l.width/s.width,scaleY:l.height/s.height}},sc="Sortable",lc=C.createContext({activeIndex:-1,containerId:sc,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:so,disabled:{draggable:!1,droppable:!1}});function ic(e){let{children:t,id:r,items:n,strategy:o=so,disabled:a=!1}=e;const{active:s,dragOverlay:l,droppableRects:f,over:h,measureDroppableContainers:c}=M0(),i=gn(sc,r),u=l.rect!==null,g=C.useMemo(()=>n.map(S=>typeof S=="object"&&"id"in S?S.id:S),[n]),p=s!=null,m=s?g.indexOf(s.id):-1,x=h?g.indexOf(h.id):-1,k=C.useRef(g),M=!$0(g,k.current),v=x!==-1&&m===-1||M,T=F0(a);Jt(()=>{M&&p&&c(g)},[M,g,p,c]),C.useEffect(()=>{k.current=g},[g]);const I=C.useMemo(()=>({activeIndex:m,containerId:i,disabled:T,disableTransforms:v,items:g,overIndex:x,useDragOverlay:u,sortedRects:L0(g,f),strategy:o}),[m,i,T.draggable,T.droppable,v,g,x,f,u,o]);return C.createElement(lc.Provider,{value:I},t)}const cc=e=>{let{id:t,items:r,activeIndex:n,overIndex:o}=e;return Ga(r,n,o).indexOf(t)},dc=e=>{let{containerId:t,isSorting:r,wasDragging:n,index:o,items:a,newIndex:s,previousItems:l,previousContainerId:f,transition:h}=e;return!h||!n||l!==a&&o===s?!1:r?!0:s!==o&&t===f},U0={duration:200,easing:"ease"},uc="transform",z0=pn.Transition.toString({property:uc,duration:0,easing:"linear"}),H0={roleDescription:"sortable"};function G0(e){let{disabled:t,index:r,node:n,rect:o}=e;const[a,s]=C.useState(null),l=C.useRef(r);return Jt(()=>{if(!t&&r!==l.current&&n.current){const f=o.current;if(f){const h=Wr(n.current,{ignoreTransform:!0}),c={x:f.left-h.left,y:f.top-h.top,scaleX:f.width/h.width,scaleY:f.height/h.height};(c.x||c.y)&&s(c)}}r!==l.current&&(l.current=r)},[t,r,n,o]),C.useEffect(()=>{a&&s(null)},[a]),a}function fc(e){let{animateLayoutChanges:t=dc,attributes:r,disabled:n,data:o,getNewIndex:a=cc,id:s,strategy:l,resizeObserverConfig:f,transition:h=U0}=e;const{items:c,containerId:i,activeIndex:u,disabled:g,disableTransforms:p,sortedRects:m,overIndex:x,useDragOverlay:k,strategy:M}=C.useContext(lc),v=j0(n,g),T=c.indexOf(s),I=C.useMemo(()=>({sortable:{containerId:i,index:T,items:c},...o}),[i,o,T,c]),S=C.useMemo(()=>c.slice(c.indexOf(s)),[c,s]),{rect:N,node:w,isOver:y,setNodeRef:E}=P0({id:s,data:I,disabled:v.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...f}}),{active:O,activatorEvent:$,activeNodeRect:P,attributes:L,setNodeRef:U,listeners:_,isDragging:b,over:z,setActivatorNodeRef:F,transform:G}=O0({id:s,data:I,attributes:{...H0,...r},disabled:v.draggable}),X=uh(E,U),B=!!O,Y=B&&!p&&ao(u)&&ao(x),H=!k&&b,W=H&&Y?G:null,be=Y?W??(l??M)({rects:m,activeNodeRect:P,activeIndex:u,overIndex:x,index:T}):null,se=ao(u)&&ao(x)?a({id:s,items:c,activeIndex:u,overIndex:x}):T,pe=O?.id,ne=C.useRef({activeId:pe,items:c,newIndex:se,containerId:i}),Ae=c!==ne.current.items,ve=t({active:O,containerId:i,isDragging:b,isSorting:B,id:s,index:T,items:c,newIndex:ne.current.newIndex,previousItems:ne.current.items,previousContainerId:ne.current.containerId,transition:h,wasDragging:ne.current.activeId!=null}),We=G0({disabled:!ve,index:T,node:w,rect:N});return C.useEffect(()=>{B&&ne.current.newIndex!==se&&(ne.current.newIndex=se),i!==ne.current.containerId&&(ne.current.containerId=i),c!==ne.current.items&&(ne.current.items=c)},[B,se,i,c]),C.useEffect(()=>{if(pe===ne.current.activeId)return;if(pe!=null&&ne.current.activeId==null){ne.current.activeId=pe;return}const Te=setTimeout(()=>{ne.current.activeId=pe},50);return()=>clearTimeout(Te)},[pe]),{active:O,activeIndex:u,attributes:L,data:I,rect:N,index:T,newIndex:se,items:c,isOver:y,isSorting:B,isDragging:b,listeners:_,node:w,overIndex:x,over:z,setNodeRef:X,setActivatorNodeRef:F,setDroppableNodeRef:E,setDraggableNodeRef:U,transform:We??be,transition:me()};function me(){if(We||Ae&&ne.current.newIndex===T)return z0;if(!(H&&!Na($)||!h)&&(B||ve))return pn.Transition.toString({...h,property:uc})}}function j0(e,t){var r,n;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(r=e?.draggable)!=null?r:t.draggable,droppable:(n=e?.droppable)!=null?n:t.droppable}}function wn(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const B0=[Ue.Down,Ue.Right,Ue.Up,Ue.Left],gc=(e,t)=>{let{context:{active:r,collisionRect:n,droppableRects:o,droppableContainers:a,over:s,scrollableAncestors:l}}=t;if(B0.includes(e.code)){if(e.preventDefault(),!r||!n)return;const f=[];a.getEnabled().forEach(i=>{if(!i||i!=null&&i.disabled)return;const u=o.get(i.id);if(u)switch(e.code){case Ue.Down:n.topu.top&&f.push(i);break;case Ue.Left:n.left>u.left&&f.push(i);break;case Ue.Right:n.left1&&(c=h[1].id),c!=null){const i=a.get(r.id),u=a.get(c),g=u?o.get(u.id):null,p=u?.node.current;if(p&&g&&i&&u){const x=eo(p).some((S,N)=>l[N]!==S),k=hc(i,u),M=W0(i,u),v=x||!k?{x:0,y:0}:{x:M?n.width-g.width:0,y:M?n.height-g.height:0},T={x:g.left,y:g.top};return v.x&&v.y?T:hn(T,v)}}}};function hc(e,t){return!wn(e)||!wn(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function W0(e,t){return!wn(e)||!wn(t)||!hc(e,t)?!1:e.data.current.sortable.index{const{attributes:l,listeners:f,setNodeRef:h,transform:c,transition:i,isDragging:u}=fc({id:"hash"in e?e.hash:e.id}),g={transform:pn.Transform.toString(c),transition:i,opacity:u?.5:1},p="status"in e&&e.status!==void 0,m=p?e.status:"done",x=m==="uploading",k=m==="compressing",M=m==="error",v=p?e.progress:100,T=p?e.preview:void 0,I=p?e.mime_type?.startsWith("image/")??!1:e.is_image,[S,N]=C.useState(void 0),w=!p&&I?e.download_url:void 0;C.useEffect(()=>{if(!w){N(void 0);return}if(ua(w)){N(w);return}let E=!0,O;return(async()=>{try{const P=await K0.api.get(w,{responseType:"blob",headers:zn()});E&&P&&(O=URL.createObjectURL(P),N(O))}catch(P){console.error("Failed to load authenticated image:",P)}})(),()=>{E=!1,O&&URL.revokeObjectURL(O)}},[w]);const y=S;return d.jsxs(j,{ref:h,style:g,className:"relative group bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",children:[d.jsxs(j,{className:`aspect-square w-full flex items-center justify-center bg-gray-50 dark:bg-gray-900 relative ${I||!p?"cursor-pointer":""}`,onClick:()=>{x||k||(I&&n?n():!p&&o&&o())},children:[T||y?d.jsx(jt,{src:T||y,alt:e.original_filename,className:"w-full h-full object-cover"}):d.jsx(It,{className:`fa-solid ${Si(e.mime_type)} text-4xl text-gray-400 dark:text-gray-500`}),(x||k)&&d.jsxs(j,{className:"absolute inset-0 bg-black/50 flex flex-col items-center justify-center",children:[d.jsx(j,{className:"w-3/4 h-2 bg-gray-700 dark:bg-gray-600 rounded-full overflow-hidden",children:d.jsx(j,{className:"h-full bg-blue-500 dark:bg-blue-400 transition-all",style:{width:`${v}%`}})}),d.jsxs(te,{className:"text-white text-xs mt-1",children:[v,"%"]})]}),M&&d.jsx(j,{className:"absolute inset-0 bg-red-500/50 dark:bg-red-600/50 flex items-center justify-center",children:d.jsx(It,{className:"fa-solid fa-exclamation-triangle text-2xl text-white"})}),s&&d.jsx(R,{type:"button",onClick:E=>{E.stopPropagation(),s()},className:`absolute top-1.5 left-1.5 z-10 p-1 rounded-full transition-colors ${a?"bg-yellow-500 text-white":"bg-gray-800/50 text-gray-300 hover:bg-yellow-500 hover:text-white opacity-0 group-hover:opacity-100"}`,title:at(a?"attachment.primary_image":"attachment.set_as_primary"),children:d.jsx(It,{className:"fa-solid fa-star text-xs"})}),d.jsxs(j,{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors flex items-start justify-end p-1 gap-1 opacity-0 group-hover:opacity-100",children:[d.jsx(R,{type:"button",...l,...f,className:"p-1.5 bg-white/90 dark:bg-gray-800/90 rounded text-gray-600 dark:text-gray-300 hover:bg-white cursor-grab active:cursor-grabbing",title:at("attachment.drag_to_reorder"),onClick:E=>E.stopPropagation(),children:d.jsx(It,{className:"fa-solid fa-grip-vertical text-sm"})}),!p&&o&&d.jsx(R,{type:"button",onClick:E=>{E.stopPropagation(),o()},className:"p-1.5 bg-white/90 dark:bg-gray-800/90 rounded text-blue-500 hover:bg-white",title:at("common.download"),children:d.jsx(It,{className:"fa-solid fa-download text-sm"})}),M&&r&&d.jsx(R,{type:"button",onClick:E=>{E.stopPropagation(),r()},className:"p-1.5 bg-white/90 dark:bg-gray-800/90 rounded text-orange-500 hover:bg-white",title:at("common.retry"),children:d.jsx(It,{className:"fa-solid fa-arrow-rotate-right text-sm"})}),d.jsx(R,{type:"button",onClick:E=>{E.stopPropagation(),t()},disabled:x||k,className:"p-1.5 bg-white/90 dark:bg-gray-800/90 rounded text-red-500 hover:bg-white disabled:opacity-50",title:at("common.delete"),children:d.jsx(It,{className:"fa-solid fa-times text-sm"})})]})]}),d.jsxs(j,{className:`p-2 ${!p&&o?"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700":""}`,onClick:()=>{!p&&o&&o()},children:[d.jsx(Gt,{className:"text-xs font-medium text-gray-900 dark:text-white truncate",title:e.original_filename,children:e.original_filename}),d.jsx(Gt,{className:"text-xs text-gray-500 dark:text-gray-400",children:e.size_formatted})]})]})},mc=({allItems:e,canAddMore:t,totalCount:r,maxFiles:n,maxSize:o,accept:a,onRemove:s,onRetry:l,onImageClick:f,onDownload:h,onDragEnd:c,onAddClick:i,enablePrimarySelection:u,primaryFileId:g,onPrimaryChange:p})=>{const m=Sh(Ii(Fa,{activationConstraint:{distance:8}}),Ii(La,{coordinateGetter:gc}));return d.jsxs(j,{className:"p-3",children:[d.jsx(T0,{sensors:m,collisionDetection:Th,onDragEnd:c,children:d.jsx(ic,{items:e.map(x=>"hash"in x?x.hash:x.id),strategy:so,children:d.jsxs(j,{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-3",children:[e.map(x=>{const k="hash"in x,M=k?x.is_image:x.mime_type?.startsWith("image/")??!1;return d.jsx(pc,{file:x,onRemove:()=>s(x),onRetry:"status"in x&&x.status==="error"?()=>l(x):void 0,onImageClick:M?()=>f(x):void 0,onDownload:k?()=>h(x):void 0,isPrimary:u&&k&&(x.hash||x.id)===g,onPrimaryClick:u&&k?()=>p?.(x.hash||x.id):void 0},k?x.hash:x.id)}),t&&d.jsxs(j,{className:"aspect-square flex flex-col items-center justify-center border-2 border-dashed border-gray-300 dark:border-gray-600 rounded-lg cursor-pointer hover:border-gray-400 dark:hover:border-gray-500 hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors",onClick:i,children:[d.jsx(It,{className:"fa-solid fa-plus text-2xl text-gray-400 dark:text-gray-500 mb-1"}),d.jsx(te,{className:"text-xs text-gray-500 dark:text-gray-400",children:at("common.add")})]})]})})}),d.jsxs(j,{className:"mt-3 pt-3 border-t border-gray-200 dark:border-gray-700 flex justify-between items-center text-xs text-gray-500 dark:text-gray-400",children:[d.jsx(te,{children:at("attachment.attached_count",{count:r,max:n})}),d.jsxs(te,{children:[at("attachment.max_size",{size:o}),a&&` (${a})`]})]})]})},Y0=[],X0=[],lo=C.forwardRef(({uploadTriggerEvent:e,attachmentableType:t,attachmentableId:r,collection:n="default",maxFiles:o=10,maxSize:a=10,maxConcurrentUploads:s=3,accept:l,imageCompression:f,roleIds:h=X0,autoUpload:c=!0,onFilesChange:i,onChange:u,onUploadComplete:g,onUploadError:p,onRemove:m,onReorder:x,initialFiles:k=Y0,className:M="",confirmBeforeRemove:v=!1,confirmRemoveTitle:T,confirmRemoveMessage:I,apiEndpoints:S,uploadParams:N,enablePrimarySelection:w=!1,primaryFileId:y,onPrimaryChange:E,id:O,editorAttrs:$},P)=>{const L={upload:S?.upload??"/api/attachments",delete:S?.delete??"/api/attachments/:id",reorder:S?.reorder??"/api/attachments/reorder"},U=C.useRef(u??i);U.current=u??i;const _=C.useCallback(G=>{const X=U.current;if(!X)return;X({target:{value:G,files:G},preventDefault:()=>{},stopPropagation:()=>{}})},[]),b=Ei({attachmentableType:t,attachmentableId:r,collection:n,maxFiles:o,maxSize:a,maxConcurrentUploads:s,accept:l,imageCompression:f,roleIds:h,autoUpload:c,initialFiles:k,endpoints:L,onFilesChange:_,onUploadComplete:g,onUploadError:p,onRemove:m,onReorder:x,uploadTriggerEvent:e,confirmBeforeRemove:v,uploadParams:N});C.useImperativeHandle(P,()=>({uploadAll:b.handleUploadAll,clear:b.clear,getPendingFiles:b.getPendingFiles}));const z=C.useMemo(()=>b.imageFiles.map(G=>{const X=!("hash"in G),B=G,Y=G;return X?{src:B.preview||"",filename:B.original_filename,title:B.original_filename,downloadRequiresAuth:!1}:{src:b.authenticatedImageUrls.get(Y.id)||Y.download_url,downloadUrl:Y.download_url,filename:Y.original_filename,title:Y.original_filename,downloadRequiresAuth:!0}}),[b.imageFiles,b.authenticatedImageUrls]),F=C.useMemo(()=>({existingFiles:b.existingFiles,pendingFiles:b.pendingFiles,isDragOver:b.isDragOver,isDeleting:b.isDeleting,maxFiles:o,maxSize:a,accept:l,endpoints:L,confirmBeforeRemove:v,totalCount:b.totalCount,hasFiles:b.hasFiles,canAddMore:b.canAddMore,allItems:b.allItems,imageFiles:b.imageFiles,handleFiles:b.handleFiles,handleRemove:b.handleRemove,handleRetry:b.handleRetry,handleUploadAll:b.handleUploadAll,handleOpenGallery:b.handleOpenGallery,handleDownload:b.handleDownload,handleDragEnd:b.handleDragEnd,setIsDragOver:b.setIsDragOver,inputRef:b.inputRef,galleryOpen:b.galleryOpen,setGalleryOpen:b.setGalleryOpen,galleryStartIndex:b.galleryStartIndex,galleryKeyRef:b.galleryKeyRef,confirmDialogOpen:b.confirmDialogOpen,setConfirmDialogOpen:b.setConfirmDialogOpen,itemToDelete:b.itemToDelete,executeRemoveAttachment:b.executeRemoveAttachment,authenticatedImageUrls:b.authenticatedImageUrls}),[b,o,a,l,L,v]);return d.jsx(ui,{value:F,children:d.jsxs(j,{id:O,className:M,...$,children:[d.jsx(Ti,{isDragOver:b.isDragOver,canAddMore:b.canAddMore,onFiles:b.handleFiles,setIsDragOver:b.setIsDragOver,inputRef:b.inputRef,accept:l,maxFiles:o,maxSize:a,children:b.hasFiles&&d.jsx(mc,{allItems:b.allItems,canAddMore:b.canAddMore,totalCount:b.totalCount,maxFiles:o,maxSize:a,accept:l,onRemove:b.handleRemove,onRetry:b.handleRetry,onImageClick:b.handleOpenGallery,onDownload:b.handleDownload,onDragEnd:b.handleDragEnd,onAddClick:()=>b.inputRef.current?.click(),enablePrimarySelection:w,primaryFileId:y,onPrimaryChange:E})}),v&&d.jsx(wa,{isOpen:b.confirmDialogOpen,onClose:()=>{b.isDeleting||b.setConfirmDialogOpen(!1)},title:T??at("attachment.delete_confirm_title"),message:I??at("attachment.delete_confirm_message"),confirmText:at("common.delete"),confirmButtonVariant:"danger",onConfirm:()=>{b.itemToDelete&&b.executeRemoveAttachment(b.itemToDelete)},isLoading:b.isDeleting,loadingText:at("attachment.deleting")}),z.length>0&&b.galleryOpen&&d.jsx(zr,{images:z,isOpen:!0,onClose:()=>b.setGalleryOpen(!1),startIndex:b.galleryStartIndex,showDownload:!0},`gallery-${b.galleryKeyRef.current}`)]})})});lo.displayName="FileUploader";const q0=Object.freeze(Object.defineProperty({__proto__:null,FileDropZone:Ti,FileList:mc,FileUploader:lo,FileUploaderProvider:ui,SortableThumbnailItem:pc,default:lo,extractErrorMessage:_i,fileUploaderT:at,formatFileSize:Zn,getFileIcon:Si,useFileUploader:Ei,useFileUploaderContext:Rg},Symbol.toStringTag,{value:"Module"})),bc=({provider:e,className:t="w-5 h-5"})=>{switch(e){case"google":return d.jsxs("svg",{className:t,viewBox:"0 0 24 24",children:[d.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),d.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),d.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),d.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]});case"naver":return d.jsx("svg",{className:t,viewBox:"0 0 24 24",children:d.jsx("path",{fill:"currentColor",d:"M16.273 12.845L7.376 0H0v24h7.727V11.155L16.624 24H24V0h-7.727z"})});case"kakao":return d.jsx("svg",{className:t,viewBox:"0 0 24 24",children:d.jsx("path",{fill:"currentColor",d:"M12 3c5.799 0 10.5 3.664 10.5 8.185 0 4.52-4.701 8.184-10.5 8.184a13.5 13.5 0 0 1-1.727-.11l-4.408 2.883c-.501.265-.678.236-.472-.413l.892-3.678c-2.88-1.46-4.785-3.99-4.785-6.866C1.5 6.665 6.201 3 12 3zm5.519 8.625h-.634v2.916h-.97v-2.916h-.633v-.848h2.237v.848zm-3.294 2.916h-.97V10.77h.97v3.771zm-1.97 0h-.97v-2.77l-.658 1.53h-.629l-.665-1.53v2.77h-.97V10.77h1.13l.822 1.912.814-1.912h1.126v3.771zm-4.49 0h-.97V10.77h.97v3.771z"})});case"facebook":return d.jsx("svg",{className:t,viewBox:"0 0 24 24",children:d.jsx("path",{fill:"currentColor",d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})});case"apple":return d.jsx("svg",{className:t,viewBox:"0 0 24 24",children:d.jsx("path",{fill:"currentColor",d:"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"})});default:return null}},yc=(e,t)=>window.G7Core?.t?.(e,t)??e,Z0=[{id:"google",name:"Google",color:"bg-white dark:bg-gray-800",textColor:"text-gray-700 dark:text-gray-300"},{id:"naver",name:"네이버",color:"bg-[#03C75A]",textColor:"text-white"},{id:"kakao",name:"카카오",color:"bg-[#FEE500]",textColor:"text-[#000000]/85"},{id:"facebook",name:"Facebook",color:"bg-[#1877F2]",textColor:"text-white"},{id:"apple",name:"Apple",color:"bg-black dark:bg-white",textColor:"text-white dark:text-black"}],vc=({providers:e=["google","naver","kakao"],mode:t="login",variant:r="full",className:n="",id:o,editorAttrs:a})=>{const s=h=>{const c=encodeURIComponent(window.location.href);window.location.href=`/api/auth/${h}?redirect=${c}`},l=h=>t==="register"?yc("auth.social.register_with",{provider:h}):yc("auth.social.login_with",{provider:h}),f=Z0.filter(h=>e.includes(h.id));return r==="icon"?d.jsx(j,{className:`flex justify-center gap-4 ${n}`,id:o,...a,children:f.map(h=>d.jsx(R,{onClick:()=>s(h.id),className:`w-12 h-12 flex items-center justify-center rounded-full ${h.color} ${h.textColor} border border-gray-200 dark:border-gray-700 hover:opacity-90 transition-opacity`,"aria-label":l(h.name),children:d.jsx(bc,{provider:h.id,className:"w-5 h-5"})},h.id))}):d.jsx(j,{className:`space-y-3 ${n}`,id:o,...a,children:f.map(h=>d.jsxs(R,{onClick:()=>s(h.id),className:`w-full flex items-center justify-center gap-3 px-4 py-3 rounded-lg font-medium border border-gray-200 dark:border-gray-700 ${h.color} ${h.textColor} hover:opacity-90 transition-opacity`,children:[d.jsx(bc,{provider:h.id,className:"w-5 h-5"}),d.jsx(te,{children:l(h.name)})]},h.id))})},Q0=Object.freeze(Object.defineProperty({__proto__:null,default:vc},Symbol.toStringTag,{value:"Module"})),J0=(e,t)=>window.G7Core?.t?.(e,t)??e,R0={success:nt.CheckCircle,error:nt.XCircle,warning:nt.ExclamationTriangle,info:nt.InfoCircle},wc={success:{bg:"bg-green-50 dark:bg-green-900/20 border-green-200 dark:border-green-800",text:"text-green-800 dark:text-green-300"},error:{bg:"bg-red-50 dark:bg-red-900/20 border-red-200 dark:border-red-800",text:"text-red-800 dark:text-red-300"},warning:{bg:"bg-yellow-50 dark:bg-yellow-900/20 border-yellow-200 dark:border-yellow-800",text:"text-yellow-800 dark:text-yellow-300"},info:{bg:"bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-800",text:"text-blue-800 dark:text-blue-300"}},ep={"top-left":"top-4 left-4","top-center":"top-4 left-1/2 -translate-x-1/2","top-right":"top-4 right-4","bottom-left":"bottom-4 left-4","bottom-center":"bottom-4 left-1/2 -translate-x-1/2","bottom-right":"bottom-4 right-4"},ja=({toasts:e,position:t="bottom-center",duration:r=3e3,onRemove:n})=>{const[o,a]=C.useState(new Map),s=C.useCallback(l=>{a(f=>{const h=new Map(f);return h.set(l,!1),h}),setTimeout(()=>{if(n)n(l);else{const f=window.G7Core;f?.state?.update&&f.state.update(h=>({toasts:(Array.isArray(h.toasts)?h.toasts:[]).filter(i=>i.id!==l)}))}},300)},[n]);return C.useEffect(()=>{!e||e.length===0||e.forEach(l=>{if(o.has(l.id))return;a(h=>{const c=new Map(h);return c.set(l.id,!0),c});const f=l.duration||r;f>0&&setTimeout(()=>{s(l.id)},f)})},[e,r,s,o]),!e||e.length===0?null:d.jsx(j,{className:`fixed z-[9999] flex flex-col gap-2 ${ep[t]}`,"aria-live":"polite","aria-atomic":"true",children:e.map(l=>d.jsx(tp,{toast:l,position:t,isVisible:o.get(l.id)??!0,onClose:()=>s(l.id)},l.id))})},tp=({toast:e,position:t,isVisible:r,onClose:n})=>{const o=wc[e.type]||wc.info,a=e.icon?e.icon:R0[e.type],s=t.startsWith("bottom")?"translate-y-2":"-translate-y-2";return d.jsxs(j,{className:` + `},Sh={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was moved over droppable area "+r.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was dropped over droppable area "+r.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function Eh(e){let{announcements:t=Sh,container:r,hiddenTextDescribedById:n,screenReaderInstructions:o=_h}=e;const{announce:a,announcement:s}=xh(),l=gn("DndLiveRegion"),[f,h]=C.useState(!1);if(C.useEffect(()=>{h(!0)},[]),kh(C.useMemo(()=>({onDragStart(i){let{active:u}=i;a(t.onDragStart({active:u}))},onDragMove(i){let{active:u,over:g}=i;t.onDragMove&&a(t.onDragMove({active:u,over:g}))},onDragOver(i){let{active:u,over:g}=i;a(t.onDragOver({active:u,over:g}))},onDragEnd(i){let{active:u,over:g}=i;a(t.onDragEnd({active:u,over:g}))},onDragCancel(i){let{active:u,over:g}=i;a(t.onDragCancel({active:u,over:g}))}}),[a,t])),!f)return null;const c=C.createElement(C.Fragment,null,C.createElement(vh,{id:n,value:o.draggable}),C.createElement(wh,{id:l,announcement:s}));return r?tr.createPortal(c,r):c}var st;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(st||(st={}));function Rn(){}function Ii(e,t){return C.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function Th(){for(var e=arguments.length,t=new Array(e),r=0;r[...t].filter(n=>n!=null),[...t])}const qt=Object.freeze({x:0,y:0});function Di(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Pi(e,t){let{data:{value:r}}=e,{data:{value:n}}=t;return r-n}function Ah(e,t){let{data:{value:r}}=e,{data:{value:n}}=t;return n-r}function Li(e){let{left:t,top:r,height:n,width:o}=e;return[{x:t,y:r},{x:t+o,y:r},{x:t,y:r+n},{x:t+o,y:r+n}]}function $i(e,t){if(!e||e.length===0)return null;const[r]=e;return r[t]}function Fi(e,t,r){return t===void 0&&(t=e.left),r===void 0&&(r=e.top),{x:t+e.width*.5,y:r+e.height*.5}}const Nh=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:n}=e;const o=Fi(t,t.left,t.top),a=[];for(const s of n){const{id:l}=s,f=r.get(l);if(f){const h=Di(Fi(f),o);a.push({id:l,data:{droppableContainer:s,value:h}})}}return a.sort(Pi)},Oh=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:n}=e;const o=Li(t),a=[];for(const s of n){const{id:l}=s,f=r.get(l);if(f){const h=Li(f),c=o.reduce((u,g,p)=>u+Di(h[p],g),0),i=Number((c/4).toFixed(4));a.push({id:l,data:{droppableContainer:s,value:i}})}}return a.sort(Pi)};function Mh(e,t){const r=Math.max(t.top,e.top),n=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),s=o-n,l=a-r;if(n{let{collisionRect:t,droppableRects:r,droppableContainers:n}=e;const o=[];for(const a of n){const{id:s}=a,l=r.get(s);if(l){const f=Mh(l,t);f>0&&o.push({id:s,data:{droppableContainer:a,value:f}})}}return o.sort(Ah)};function Dh(e,t,r){return{...e,scaleX:t&&r?t.width/r.width:1,scaleY:t&&r?t.height/r.height:1}}function Ui(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:qt}function Ph(e){return function(r){for(var n=arguments.length,o=new Array(n>1?n-1:0),a=1;a({...s,top:s.top+e*l.y,bottom:s.bottom+e*l.y,left:s.left+e*l.x,right:s.right+e*l.x}),{...r})}}const Lh=Ph(1);function $h(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Fh(e,t,r){const n=$h(t);if(!n)return e;const{scaleX:o,scaleY:a,x:s,y:l}=n,f=e.left-s-(1-o)*parseFloat(r),h=e.top-l-(1-a)*parseFloat(r.slice(r.indexOf(" ")+1)),c=o?e.width/o:e.width,i=a?e.height/a:e.height;return{width:c,height:i,top:h,right:f+c,bottom:h+i,left:f}}const Uh={ignoreTransform:!1};function Wr(e,t){t===void 0&&(t=Uh);let r=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:h,transformOrigin:c}=Ct(e).getComputedStyle(e);h&&(r=Fh(r,h,c))}const{top:n,left:o,width:a,height:s,bottom:l,right:f}=r;return{top:n,left:o,width:a,height:s,bottom:l,right:f}}function zi(e){return Wr(e,{ignoreTransform:!0})}function zh(e){const t=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:t,bottom:r,width:t,height:r}}function Hh(e,t){return t===void 0&&(t=Ct(e).getComputedStyle(e)),t.position==="fixed"}function Gh(e,t){t===void 0&&(t=Ct(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const a=t[o];return typeof a=="string"?r.test(a):!1})}function eo(e,t){const r=[];function n(o){if(t!=null&&r.length>=t||!o)return r;if(Sa(o)&&o.scrollingElement!=null&&!r.includes(o.scrollingElement))return r.push(o.scrollingElement),r;if(!dn(o)||Ai(o)||r.includes(o))return r;const a=Ct(e).getComputedStyle(o);return o!==e&&Gh(o,a)&&r.push(o),Hh(o,a)?r:n(o.parentNode)}return e?n(e):r}function Hi(e){const[t]=eo(e,1);return t??null}function Ma(e){return!Qn||!e?null:Gr(e)?e:_a(e)?Sa(e)||e===jr(e).scrollingElement?window:dn(e)?e:null:null}function Gi(e){return Gr(e)?e.scrollX:e.scrollLeft}function ji(e){return Gr(e)?e.scrollY:e.scrollTop}function Ia(e){return{x:Gi(e),y:ji(e)}}var ut;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ut||(ut={}));function Bi(e){return!Qn||!e?!1:e===document.scrollingElement}function Wi(e){const t={x:0,y:0},r=Bi(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},n={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},o=e.scrollTop<=t.y,a=e.scrollLeft<=t.x,s=e.scrollTop>=n.y,l=e.scrollLeft>=n.x;return{isTop:o,isLeft:a,isBottom:s,isRight:l,maxScroll:n,minScroll:t}}const jh={x:.2,y:.2};function Bh(e,t,r,n,o){let{top:a,left:s,right:l,bottom:f}=r;n===void 0&&(n=10),o===void 0&&(o=jh);const{isTop:h,isBottom:c,isLeft:i,isRight:u}=Wi(e),g={x:0,y:0},p={x:0,y:0},m={height:t.height*o.y,width:t.width*o.x};return!h&&a<=t.top+m.height?(g.y=ut.Backward,p.y=n*Math.abs((t.top+m.height-a)/m.height)):!c&&f>=t.bottom-m.height&&(g.y=ut.Forward,p.y=n*Math.abs((t.bottom-m.height-f)/m.height)),!u&&l>=t.right-m.width?(g.x=ut.Forward,p.x=n*Math.abs((t.right-m.width-l)/m.width)):!i&&s<=t.left+m.width&&(g.x=ut.Backward,p.x=n*Math.abs((t.left+m.width-s)/m.width)),{direction:g,speed:p}}function Wh(e){if(e===document.scrollingElement){const{innerWidth:a,innerHeight:s}=window;return{top:0,left:0,right:a,bottom:s,width:a,height:s}}const{top:t,left:r,right:n,bottom:o}=e.getBoundingClientRect();return{top:t,left:r,right:n,bottom:o,width:e.clientWidth,height:e.clientHeight}}function Vi(e){return e.reduce((t,r)=>Br(t,Ia(r)),qt)}function Vh(e){return e.reduce((t,r)=>t+Gi(r),0)}function Kh(e){return e.reduce((t,r)=>t+ji(r),0)}function Yh(e,t){if(t===void 0&&(t=Wr),!e)return;const{top:r,left:n,bottom:o,right:a}=t(e);Hi(e)&&(o<=0||a<=0||r>=window.innerHeight||n>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Xh=[["x",["left","right"],Vh],["y",["top","bottom"],Kh]];class Da{constructor(t,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=eo(r),o=Vi(n);this.rect={...t},this.width=t.width,this.height=t.height;for(const[a,s,l]of Xh)for(const f of s)Object.defineProperty(this,f,{get:()=>{const h=l(n),c=o[a]-h;return this.rect[f]+c},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class mn{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...r)})},this.target=t}add(t,r,n){var o;(o=this.target)==null||o.addEventListener(t,r,n),this.listeners.push([t,r,n])}}function qh(e){const{EventTarget:t}=Ct(e);return e instanceof t?e:jr(e)}function Pa(e,t){const r=Math.abs(e.x),n=Math.abs(e.y);return typeof t=="number"?Math.sqrt(r**2+n**2)>t:"x"in t&&"y"in t?r>t.x&&n>t.y:"x"in t?r>t.x:"y"in t?n>t.y:!1}var zt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(zt||(zt={}));function Ki(e){e.preventDefault()}function Zh(e){e.stopPropagation()}var Ue;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(Ue||(Ue={}));const Yi={start:[Ue.Space,Ue.Enter],cancel:[Ue.Esc],end:[Ue.Space,Ue.Enter,Ue.Tab]},Qh=(e,t)=>{let{currentCoordinates:r}=t;switch(e.code){case Ue.Right:return{...r,x:r.x+25};case Ue.Left:return{...r,x:r.x-25};case Ue.Down:return{...r,y:r.y+25};case Ue.Up:return{...r,y:r.y-25}}};class La{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:r}}=t;this.props=t,this.listeners=new mn(jr(r)),this.windowListeners=new mn(Ct(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(zt.Resize,this.handleCancel),this.windowListeners.add(zt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(zt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:r}=this.props,n=t.node.current;n&&Yh(n),r(qt)}handleKeyDown(t){if(Na(t)){const{active:r,context:n,options:o}=this.props,{keyboardCodes:a=Yi,coordinateGetter:s=Qh,scrollBehavior:l="smooth"}=o,{code:f}=t;if(a.end.includes(f)){this.handleEnd(t);return}if(a.cancel.includes(f)){this.handleCancel(t);return}const{collisionRect:h}=n.current,c=h?{x:h.left,y:h.top}:qt;this.referenceCoordinates||(this.referenceCoordinates=c);const i=s(t,{active:r,context:n.current,currentCoordinates:c});if(i){const u=hn(i,c),g={x:0,y:0},{scrollableAncestors:p}=n.current;for(const m of p){const x=t.code,{isTop:k,isRight:M,isLeft:v,isBottom:T,maxScroll:I,minScroll:S}=Wi(m),N=Wh(m),w={x:Math.min(x===Ue.Right?N.right-N.width/2:N.right,Math.max(x===Ue.Right?N.left:N.left+N.width/2,i.x)),y:Math.min(x===Ue.Down?N.bottom-N.height/2:N.bottom,Math.max(x===Ue.Down?N.top:N.top+N.height/2,i.y))},y=x===Ue.Right&&!M||x===Ue.Left&&!v,E=x===Ue.Down&&!T||x===Ue.Up&&!k;if(y&&w.x!==i.x){const O=m.scrollLeft+u.x,$=x===Ue.Right&&O<=I.x||x===Ue.Left&&O>=S.x;if($&&!u.y){m.scrollTo({left:O,behavior:l});return}$?g.x=m.scrollLeft-O:g.x=x===Ue.Right?m.scrollLeft-I.x:m.scrollLeft-S.x,g.x&&m.scrollBy({left:-g.x,behavior:l});break}else if(E&&w.y!==i.y){const O=m.scrollTop+u.y,$=x===Ue.Down&&O<=I.y||x===Ue.Up&&O>=S.y;if($&&!u.x){m.scrollTo({top:O,behavior:l});return}$?g.y=m.scrollTop-O:g.y=x===Ue.Down?m.scrollTop-I.y:m.scrollTop-S.y,g.y&&m.scrollBy({top:-g.y,behavior:l});break}}this.handleMove(t,Br(hn(i,this.referenceCoordinates),g))}}}handleMove(t,r){const{onMove:n}=this.props;t.preventDefault(),n(r)}handleEnd(t){const{onEnd:r}=this.props;t.preventDefault(),this.detach(),r()}handleCancel(t){const{onCancel:r}=this.props;t.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}La.activators=[{eventName:"onKeyDown",handler:(e,t,r)=>{let{keyboardCodes:n=Yi,onActivation:o}=t,{active:a}=r;const{code:s}=e.nativeEvent;if(n.start.includes(s)){const l=a.activatorNode.current;return l&&e.target!==l?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function Xi(e){return!!(e&&"distance"in e)}function qi(e){return!!(e&&"delay"in e)}class $a{constructor(t,r,n){var o;n===void 0&&(n=qh(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=r;const{event:a}=t,{target:s}=a;this.props=t,this.events=r,this.document=jr(s),this.documentListeners=new mn(this.document),this.listeners=new mn(n),this.windowListeners=new mn(Ct(s)),this.initialCoordinates=(o=Oa(a))!=null?o:qt,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:r,bypassActivationConstraint:n}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(zt.Resize,this.handleCancel),this.windowListeners.add(zt.DragStart,Ki),this.windowListeners.add(zt.VisibilityChange,this.handleCancel),this.windowListeners.add(zt.ContextMenu,Ki),this.documentListeners.add(zt.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(qi(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(Xi(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,r){const{active:n,onPending:o}=this.props;o(n,t,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:t}=this,{onStart:r}=this.props;t&&(this.activated=!0,this.documentListeners.add(zt.Click,Zh,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(zt.SelectionChange,this.removeTextSelection),r(t))}handleMove(t){var r;const{activated:n,initialCoordinates:o,props:a}=this,{onMove:s,options:{activationConstraint:l}}=a;if(!o)return;const f=(r=Oa(t))!=null?r:qt,h=hn(o,f);if(!n&&l){if(Xi(l)){if(l.tolerance!=null&&Pa(h,l.tolerance))return this.handleCancel();if(Pa(h,l.distance))return this.handleStart()}if(qi(l)&&Pa(h,l.tolerance))return this.handleCancel();this.handlePending(l,h);return}t.cancelable&&t.preventDefault(),s(f)}handleEnd(){const{onAbort:t,onEnd:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleCancel(){const{onAbort:t,onCancel:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleKeydown(t){t.code===Ue.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const Jh={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Fa extends $a{constructor(t){const{event:r}=t,n=jr(r.target);super(t,Jh,n)}}Fa.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:n}=t;return!r.isPrimary||r.button!==0?!1:(n?.({event:r}),!0)}}];const Rh={move:{name:"mousemove"},end:{name:"mouseup"}};var Ua;(function(e){e[e.RightClick=2]="RightClick"})(Ua||(Ua={}));class e0 extends $a{constructor(t){super(t,Rh,jr(t.event.target))}}e0.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:n}=t;return r.button===Ua.RightClick?!1:(n?.({event:r}),!0)}}];const za={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class t0 extends $a{constructor(t){super(t,za)}static setup(){return window.addEventListener(za.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(za.move.name,t)};function t(){}}}t0.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:n}=t;const{touches:o}=r;return o.length>1?!1:(n?.({event:r}),!0)}}];var bn;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(bn||(bn={}));var to;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(to||(to={}));function r0(e){let{acceleration:t,activator:r=bn.Pointer,canScroll:n,draggingRect:o,enabled:a,interval:s=5,order:l=to.TreeOrder,pointerCoordinates:f,scrollableAncestors:h,scrollableAncestorRects:c,delta:i,threshold:u}=e;const g=o0({delta:i,disabled:!a}),[p,m]=hh(),x=C.useRef({x:0,y:0}),k=C.useRef({x:0,y:0}),M=C.useMemo(()=>{switch(r){case bn.Pointer:return f?{top:f.y,bottom:f.y,left:f.x,right:f.x}:null;case bn.DraggableRect:return o}},[r,o,f]),v=C.useRef(null),T=C.useCallback(()=>{const S=v.current;if(!S)return;const N=x.current.x*k.current.x,w=x.current.y*k.current.y;S.scrollBy(N,w)},[]),I=C.useMemo(()=>l===to.TreeOrder?[...h].reverse():h,[l,h]);C.useEffect(()=>{if(!a||!h.length||!M){m();return}for(const S of I){if(n?.(S)===!1)continue;const N=h.indexOf(S),w=c[N];if(!w)continue;const{direction:y,speed:E}=Bh(S,w,M,t,u);for(const O of["x","y"])g[O][y[O]]||(E[O]=0,y[O]=0);if(E.x>0||E.y>0){m(),v.current=S,p(T,s),x.current=E,k.current=y;return}}x.current={x:0,y:0},k.current={x:0,y:0},m()},[t,T,n,m,a,s,JSON.stringify(M),JSON.stringify(g),p,h,I,c,JSON.stringify(u)])}const n0={x:{[ut.Backward]:!1,[ut.Forward]:!1},y:{[ut.Backward]:!1,[ut.Forward]:!1}};function o0(e){let{delta:t,disabled:r}=e;const n=Ta(t);return fn(o=>{if(r||!n||!o)return n0;const a={x:Math.sign(t.x-n.x),y:Math.sign(t.y-n.y)};return{x:{[ut.Backward]:o.x[ut.Backward]||a.x===-1,[ut.Forward]:o.x[ut.Forward]||a.x===1},y:{[ut.Backward]:o.y[ut.Backward]||a.y===-1,[ut.Forward]:o.y[ut.Forward]||a.y===1}}},[r,t,n])}function a0(e,t){const r=t!=null?e.get(t):void 0,n=r?r.node.current:null;return fn(o=>{var a;return t==null?null:(a=n??o)!=null?a:null},[n,t])}function s0(e,t){return C.useMemo(()=>e.reduce((r,n)=>{const{sensor:o}=n,a=o.activators.map(s=>({eventName:s.eventName,handler:t(s.handler,n)}));return[...r,...a]},[]),[e,t])}var yn;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(yn||(yn={}));var Ha;(function(e){e.Optimized="optimized"})(Ha||(Ha={}));const Zi=new Map;function l0(e,t){let{dragging:r,dependencies:n,config:o}=t;const[a,s]=C.useState(null),{frequency:l,measure:f,strategy:h}=o,c=C.useRef(e),i=x(),u=un(i),g=C.useCallback(function(k){k===void 0&&(k=[]),!u.current&&s(M=>M===null?k:M.concat(k.filter(v=>!M.includes(v))))},[u]),p=C.useRef(null),m=fn(k=>{if(i&&!r)return Zi;if(!k||k===Zi||c.current!==e||a!=null){const M=new Map;for(let v of e){if(!v)continue;if(a&&a.length>0&&!a.includes(v.id)&&v.rect.current){M.set(v.id,v.rect.current);continue}const T=v.node.current,I=T?new Da(f(T),T):null;v.rect.current=I,I&&M.set(v.id,I)}return M}return k},[e,a,r,i,f]);return C.useEffect(()=>{c.current=e},[e]),C.useEffect(()=>{i||g()},[r,i]),C.useEffect(()=>{a&&a.length>0&&s(null)},[JSON.stringify(a)]),C.useEffect(()=>{i||typeof l!="number"||p.current!==null||(p.current=setTimeout(()=>{g(),p.current=null},l))},[l,i,g,...n]),{droppableRects:m,measureDroppableContainers:g,measuringScheduled:a!=null};function x(){switch(h){case yn.Always:return!1;case yn.BeforeDragging:return r;default:return!r}}}function Qi(e,t){return fn(r=>e?r||(typeof t=="function"?t(e):e):null,[t,e])}function i0(e,t){return Qi(e,t)}function c0(e){let{callback:t,disabled:r}=e;const n=Ea(t),o=C.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(n)},[n,r]);return C.useEffect(()=>()=>o?.disconnect(),[o]),o}function ro(e){let{callback:t,disabled:r}=e;const n=Ea(t),o=C.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(n)},[r]);return C.useEffect(()=>()=>o?.disconnect(),[o]),o}function d0(e){return new Da(Wr(e),e)}function Ji(e,t,r){t===void 0&&(t=d0);const[n,o]=C.useState(null);function a(){o(f=>{if(!e)return null;if(e.isConnected===!1){var h;return(h=f??r)!=null?h:null}const c=t(e);return JSON.stringify(f)===JSON.stringify(c)?f:c})}const s=c0({callback(f){if(e)for(const h of f){const{type:c,target:i}=h;if(c==="childList"&&i instanceof HTMLElement&&i.contains(e)){a();break}}}}),l=ro({callback:a});return Jt(()=>{a(),e?(l?.observe(e),s?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),s?.disconnect())},[e]),n}function u0(e){const t=Qi(e);return Ui(e,t)}const Ri=[];function f0(e){const t=C.useRef(e),r=fn(n=>e?n&&n!==Ri&&e&&t.current&&e.parentNode===t.current.parentNode?n:eo(e):Ri,[e]);return C.useEffect(()=>{t.current=e},[e]),r}function g0(e){const[t,r]=C.useState(null),n=C.useRef(e),o=C.useCallback(a=>{const s=Ma(a.target);s&&r(l=>l?(l.set(s,Ia(s)),new Map(l)):null)},[]);return C.useEffect(()=>{const a=n.current;if(e!==a){s(a);const l=e.map(f=>{const h=Ma(f);return h?(h.addEventListener("scroll",o,{passive:!0}),[h,Ia(h)]):null}).filter(f=>f!=null);r(l.length?new Map(l):null),n.current=e}return()=>{s(e),s(a)};function s(l){l.forEach(f=>{const h=Ma(f);h?.removeEventListener("scroll",o)})}},[o,e]),C.useMemo(()=>e.length?t?Array.from(t.values()).reduce((a,s)=>Br(a,s),qt):Vi(e):qt,[e,t])}function ec(e,t){t===void 0&&(t=[]);const r=C.useRef(null);return C.useEffect(()=>{r.current=null},t),C.useEffect(()=>{const n=e!==qt;n&&!r.current&&(r.current=e),!n&&r.current&&(r.current=null)},[e]),r.current?hn(e,r.current):qt}function h0(e){C.useEffect(()=>{if(!Qn)return;const t=e.map(r=>{let{sensor:n}=r;return n.setup==null?void 0:n.setup()});return()=>{for(const r of t)r?.()}},e.map(t=>{let{sensor:r}=t;return r}))}function p0(e,t){return C.useMemo(()=>e.reduce((r,n)=>{let{eventName:o,handler:a}=n;return r[o]=s=>{a(s,t)},r},{}),[e,t])}function tc(e){return C.useMemo(()=>e?zh(e):null,[e])}const rc=[];function m0(e,t){t===void 0&&(t=Wr);const[r]=e,n=tc(r?Ct(r):null),[o,a]=C.useState(rc);function s(){a(()=>e.length?e.map(f=>Bi(f)?n:new Da(t(f),f)):rc)}const l=ro({callback:s});return Jt(()=>{l?.disconnect(),s(),e.forEach(f=>l?.observe(f))},[e]),o}function b0(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return dn(t)?t:e}function y0(e){let{measure:t}=e;const[r,n]=C.useState(null),o=C.useCallback(h=>{for(const{target:c}of h)if(dn(c)){n(i=>{const u=t(c);return i?{...i,width:u.width,height:u.height}:u});break}},[t]),a=ro({callback:o}),s=C.useCallback(h=>{const c=b0(h);a?.disconnect(),c&&a?.observe(c),n(c?t(c):null)},[t,a]),[l,f]=Jn(s);return C.useMemo(()=>({nodeRef:l,rect:r,setRef:f}),[r,l,f])}const v0=[{sensor:Fa,options:{}},{sensor:La,options:{}}],w0={current:{}},no={draggable:{measure:zi},droppable:{measure:zi,strategy:yn.WhileDragging,frequency:Ha.Optimized},dragOverlay:{measure:Wr}};class vn extends Map{get(t){var r;return t!=null&&(r=super.get(t))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:r}=t;return!r})}getNodeFor(t){var r,n;return(r=(n=this.get(t))==null?void 0:n.node.current)!=null?r:void 0}}const x0={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new vn,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Rn},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:no,measureDroppableContainers:Rn,windowRect:null,measuringScheduled:!1},k0={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Rn,draggableNodes:new Map,over:null,measureDroppableContainers:Rn},oo=C.createContext(k0),nc=C.createContext(x0);function C0(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new vn}}}function _0(e,t){switch(t.type){case st.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case st.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case st.DragEnd:case st.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case st.RegisterDroppable:{const{element:r}=t,{id:n}=r,o=new vn(e.droppable.containers);return o.set(n,r),{...e,droppable:{...e.droppable,containers:o}}}case st.SetDroppableDisabled:{const{id:r,key:n,disabled:o}=t,a=e.droppable.containers.get(r);if(!a||n!==a.key)return e;const s=new vn(e.droppable.containers);return s.set(r,{...a,disabled:o}),{...e,droppable:{...e.droppable,containers:s}}}case st.UnregisterDroppable:{const{id:r,key:n}=t,o=e.droppable.containers.get(r);if(!o||n!==o.key)return e;const a=new vn(e.droppable.containers);return a.delete(r),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function S0(e){let{disabled:t}=e;const{active:r,activatorEvent:n,draggableNodes:o}=C.useContext(oo),a=Ta(n),s=Ta(r?.id);return C.useEffect(()=>{if(!t&&!n&&a&&s!=null){if(!Na(a)||document.activeElement===a.target)return;const l=o.get(s);if(!l)return;const{activatorNode:f,node:h}=l;if(!f.current&&!h.current)return;requestAnimationFrame(()=>{for(const c of[f.current,h.current]){if(!c)continue;const i=bh(c);if(i){i.focus();break}}})}},[n,t,o,s,a]),null}function E0(e,t){let{transform:r,...n}=t;return e!=null&&e.length?e.reduce((o,a)=>a({transform:o,...n}),r):r}function T0(e){return C.useMemo(()=>({draggable:{...no.draggable,...e?.draggable},droppable:{...no.droppable,...e?.droppable},dragOverlay:{...no.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function A0(e){let{activeNode:t,measure:r,initialRect:n,config:o=!0}=e;const a=C.useRef(!1),{x:s,y:l}=typeof o=="boolean"?{x:o,y:o}:o;Jt(()=>{if(!s&&!l||!t){a.current=!1;return}if(a.current||!n)return;const h=t?.node.current;if(!h||h.isConnected===!1)return;const c=r(h),i=Ui(c,n);if(s||(i.x=0),l||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){const u=Hi(h);u&&u.scrollBy({top:i.y,left:i.x})}},[t,s,l,n,r])}const oc=C.createContext({...qt,scaleX:1,scaleY:1});var ar;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(ar||(ar={}));const N0=C.memo(function(t){var r,n,o,a;let{id:s,accessibility:l,autoScroll:f=!0,children:h,sensors:c=v0,collisionDetection:i=Ih,measuring:u,modifiers:g,...p}=t;const m=C.useReducer(_0,void 0,C0),[x,k]=m,[M,v]=Ch(),[T,I]=C.useState(ar.Uninitialized),S=T===ar.Initialized,{draggable:{active:N,nodes:w,translate:y},droppable:{containers:E}}=x,O=N!=null?w.get(N):null,$=C.useRef({initial:null,translated:null}),P=C.useMemo(()=>{var _e;return N!=null?{id:N,data:(_e=O?.data)!=null?_e:w0,rect:$}:null},[N,O]),L=C.useRef(null),[U,_]=C.useState(null),[b,z]=C.useState(null),F=un(p,Object.values(p)),G=gn("DndDescribedBy",s),X=C.useMemo(()=>E.getEnabled(),[E]),B=T0(u),{droppableRects:Y,measureDroppableContainers:H,measuringScheduled:W}=l0(X,{dragging:S,dependencies:[y.x,y.y],config:B.droppable}),Q=a0(w,N),be=C.useMemo(()=>b?Oa(b):null,[b]),se=je(),pe=i0(Q,B.draggable.measure);A0({activeNode:N!=null?w.get(N):null,config:se.layoutShiftCompensation,initialRect:pe,measure:B.draggable.measure});const ne=Ji(Q,B.draggable.measure,pe),Ae=Ji(Q?Q.parentElement:null),ve=C.useRef({activatorEvent:null,active:null,activeNode:Q,collisionRect:null,collisions:null,droppableRects:Y,draggableNodes:w,draggingNode:null,draggingNodeRect:null,droppableContainers:E,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),We=E.getNodeFor((r=ve.current.over)==null?void 0:r.id),me=y0({measure:B.dragOverlay.measure}),Te=(n=me.nodeRef.current)!=null?n:Q,ge=S?(o=me.rect)!=null?o:ne:null,Oe=!!(me.nodeRef.current&&me.rect),we=u0(Oe?null:ne),$e=tc(Te?Ct(Te):null),ze=f0(S?We??Q:null),K=m0(ze),oe=E0(g,{transform:{x:y.x-we.x,y:y.y-we.y,scaleX:1,scaleY:1},activatorEvent:b,active:P,activeNodeRect:ne,containerNodeRect:Ae,draggingNodeRect:ge,over:ve.current.over,overlayNodeRect:me.rect,scrollableAncestors:ze,scrollableAncestorRects:K,windowRect:$e}),ae=be?Br(be,y):null,ce=g0(ze),ke=ec(ce),Ee=ec(ce,[ne]),Be=Br(oe,ke),Me=ge?Lh(ge,oe):null,Ke=P&&Me?i({active:P,collisionRect:Me,droppableRects:Y,droppableContainers:X,pointerCoordinates:ae}):null,Pe=$i(Ke,"id"),[q,le]=C.useState(null),de=Oe?oe:Br(oe,Ee),ue=Dh(de,(a=q?.rect)!=null?a:null,ne),ie=C.useRef(null),Fe=C.useCallback((_e,xe)=>{let{sensor:De,options:Ye}=xe;if(L.current==null)return;const rt=w.get(L.current);if(!rt)return;const qe=_e.nativeEvent,Je=new De({active:L.current,activeNode:rt,event:qe,options:Ye,context:ve,onAbort(Ve){if(!w.get(Ve))return;const{onDragAbort:St}=F.current,Pt={id:Ve};St?.(Pt),M({type:"onDragAbort",event:Pt})},onPending(Ve,bt,St,Pt){if(!w.get(Ve))return;const{onDragPending:lr}=F.current,Ht={id:Ve,constraint:bt,initialCoordinates:St,offset:Pt};lr?.(Ht),M({type:"onDragPending",event:Ht})},onStart(Ve){const bt=L.current;if(bt==null)return;const St=w.get(bt);if(!St)return;const{onDragStart:Pt}=F.current,_r={activatorEvent:qe,active:{id:bt,data:St.data,rect:$}};tr.unstable_batchedUpdates(()=>{Pt?.(_r),I(ar.Initializing),k({type:st.DragStart,initialCoordinates:Ve,active:bt}),M({type:"onDragStart",event:_r}),_(ie.current),z(qe)})},onMove(Ve){k({type:st.DragMove,coordinates:Ve})},onEnd:Zt(st.DragEnd),onCancel:Zt(st.DragCancel)});ie.current=Je;function Zt(Ve){return async function(){const{active:St,collisions:Pt,over:_r,scrollAdjustedTranslate:lr}=ve.current;let Ht=null;if(St&&lr){const{cancelDrop:ir}=F.current;Ht={activatorEvent:qe,active:St,collisions:Pt,delta:lr,over:_r},Ve===st.DragEnd&&typeof ir=="function"&&await Promise.resolve(ir(Ht))&&(Ve=st.DragCancel)}L.current=null,tr.unstable_batchedUpdates(()=>{k({type:Ve}),I(ar.Uninitialized),le(null),_(null),z(null),ie.current=null;const ir=Ve===st.DragEnd?"onDragEnd":"onDragCancel";if(Ht){const Sr=F.current[ir];Sr?.(Ht),M({type:ir,event:Ht})}})}}},[w]),Ce=C.useCallback((_e,xe)=>(De,Ye)=>{const rt=De.nativeEvent,qe=w.get(Ye);if(L.current!==null||!qe||rt.dndKit||rt.defaultPrevented)return;const Je={active:qe};_e(De,xe.options,Je)===!0&&(rt.dndKit={capturedBy:xe.sensor},L.current=Ye,Fe(De,xe))},[w,Fe]),Ie=s0(c,Ce);h0(c),Jt(()=>{ne&&T===ar.Initializing&&I(ar.Initialized)},[ne,T]),C.useEffect(()=>{const{onDragMove:_e}=F.current,{active:xe,activatorEvent:De,collisions:Ye,over:rt}=ve.current;if(!xe||!De)return;const qe={active:xe,activatorEvent:De,collisions:Ye,delta:{x:Be.x,y:Be.y},over:rt};tr.unstable_batchedUpdates(()=>{_e?.(qe),M({type:"onDragMove",event:qe})})},[Be.x,Be.y]),C.useEffect(()=>{const{active:_e,activatorEvent:xe,collisions:De,droppableContainers:Ye,scrollAdjustedTranslate:rt}=ve.current;if(!_e||L.current==null||!xe||!rt)return;const{onDragOver:qe}=F.current,Je=Ye.get(Pe),Zt=Je&&Je.rect.current?{id:Je.id,rect:Je.rect.current,data:Je.data,disabled:Je.disabled}:null,Ve={active:_e,activatorEvent:xe,collisions:De,delta:{x:rt.x,y:rt.y},over:Zt};tr.unstable_batchedUpdates(()=>{le(Zt),qe?.(Ve),M({type:"onDragOver",event:Ve})})},[Pe]),Jt(()=>{ve.current={activatorEvent:b,active:P,activeNode:Q,collisionRect:Me,collisions:Ke,droppableRects:Y,draggableNodes:w,draggingNode:Te,draggingNodeRect:ge,droppableContainers:E,over:q,scrollableAncestors:ze,scrollAdjustedTranslate:Be},$.current={initial:ge,translated:Me}},[P,Q,Ke,Me,w,Te,ge,Y,E,q,ze,Be]),r0({...se,delta:y,draggingRect:Me,pointerCoordinates:ae,scrollableAncestors:ze,scrollableAncestorRects:K});const Ne=C.useMemo(()=>({active:P,activeNode:Q,activeNodeRect:ne,activatorEvent:b,collisions:Ke,containerNodeRect:Ae,dragOverlay:me,draggableNodes:w,droppableContainers:E,droppableRects:Y,over:q,measureDroppableContainers:H,scrollableAncestors:ze,scrollableAncestorRects:K,measuringConfiguration:B,measuringScheduled:W,windowRect:$e}),[P,Q,ne,b,Ke,Ae,me,w,E,Y,q,H,ze,K,B,W,$e]),He=C.useMemo(()=>({activatorEvent:b,activators:Ie,active:P,activeNodeRect:ne,ariaDescribedById:{draggable:G},dispatch:k,draggableNodes:w,over:q,measureDroppableContainers:H}),[b,Ie,P,ne,k,G,w,q,H]);return C.createElement(Mi.Provider,{value:v},C.createElement(oo.Provider,{value:He},C.createElement(nc.Provider,{value:Ne},C.createElement(oc.Provider,{value:ue},h)),C.createElement(S0,{disabled:l?.restoreFocus===!1})),C.createElement(Eh,{...l,hiddenTextDescribedById:G}));function je(){const _e=U?.autoScrollEnabled===!1,xe=typeof f=="object"?f.enabled===!1:f===!1,De=S&&!_e&&!xe;return typeof f=="object"?{...f,enabled:De}:{enabled:De}}}),O0=C.createContext(null),ac="button",M0="Draggable";function I0(e){let{id:t,data:r,disabled:n=!1,attributes:o}=e;const a=gn(M0),{activators:s,activatorEvent:l,active:f,activeNodeRect:h,ariaDescribedById:c,draggableNodes:i,over:u}=C.useContext(oo),{role:g=ac,roleDescription:p="draggable",tabIndex:m=0}=o??{},x=f?.id===t,k=C.useContext(x?oc:O0),[M,v]=Jn(),[T,I]=Jn(),S=p0(s,t),N=un(r);Jt(()=>(i.set(t,{id:t,key:a,node:M,activatorNode:T,data:N}),()=>{const y=i.get(t);y&&y.key===a&&i.delete(t)}),[i,t]);const w=C.useMemo(()=>({role:g,tabIndex:m,"aria-disabled":n,"aria-pressed":x&&g===ac?!0:void 0,"aria-roledescription":p,"aria-describedby":c.draggable}),[n,g,m,x,p,c.draggable]);return{active:f,activatorEvent:l,activeNodeRect:h,attributes:w,isDragging:x,listeners:n?void 0:S,node:M,over:u,setNodeRef:v,setActivatorNodeRef:I,transform:k}}function D0(){return C.useContext(nc)}const P0="Droppable",L0={timeout:25};function $0(e){let{data:t,disabled:r=!1,id:n,resizeObserverConfig:o}=e;const a=gn(P0),{active:s,dispatch:l,over:f,measureDroppableContainers:h}=C.useContext(oo),c=C.useRef({disabled:r}),i=C.useRef(!1),u=C.useRef(null),g=C.useRef(null),{disabled:p,updateMeasurementsFor:m,timeout:x}={...L0,...o},k=un(m??n),M=C.useCallback(()=>{if(!i.current){i.current=!0;return}g.current!=null&&clearTimeout(g.current),g.current=setTimeout(()=>{h(Array.isArray(k.current)?k.current:[k.current]),g.current=null},x)},[x]),v=ro({callback:M,disabled:p||!s}),T=C.useCallback((w,y)=>{v&&(y&&(v.unobserve(y),i.current=!1),w&&v.observe(w))},[v]),[I,S]=Jn(T),N=un(t);return C.useEffect(()=>{!v||!I.current||(v.disconnect(),i.current=!1,v.observe(I.current))},[I,v]),C.useEffect(()=>(l({type:st.RegisterDroppable,element:{id:n,key:a,disabled:r,node:I,rect:u,data:N}}),()=>l({type:st.UnregisterDroppable,key:a,id:n})),[n]),C.useEffect(()=>{r!==c.current.disabled&&(l({type:st.SetDroppableDisabled,id:n,key:a,disabled:r}),c.current.disabled=r)},[n,a,r,l]),{active:s,rect:u,isOver:f?.id===n,node:I,over:f,setNodeRef:S}}function Ga(e,t,r){const n=e.slice();return n.splice(r<0?n.length+r:r,0,n.splice(t,1)[0]),n}function F0(e,t){return e.reduce((r,n,o)=>{const a=t.get(n);return a&&(r[o]=a),r},Array(e.length))}function ao(e){return e!==null&&e>=0}function U0(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let r=0;r{let{rects:t,activeIndex:r,overIndex:n,index:o}=e;const a=Ga(t,n,r),s=t[o],l=a[o];return!l||!s?null:{x:l.left-s.left,y:l.top-s.top,scaleX:l.width/s.width,scaleY:l.height/s.height}},sc="Sortable",lc=C.createContext({activeIndex:-1,containerId:sc,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:so,disabled:{draggable:!1,droppable:!1}});function ic(e){let{children:t,id:r,items:n,strategy:o=so,disabled:a=!1}=e;const{active:s,dragOverlay:l,droppableRects:f,over:h,measureDroppableContainers:c}=D0(),i=gn(sc,r),u=l.rect!==null,g=C.useMemo(()=>n.map(S=>typeof S=="object"&&"id"in S?S.id:S),[n]),p=s!=null,m=s?g.indexOf(s.id):-1,x=h?g.indexOf(h.id):-1,k=C.useRef(g),M=!U0(g,k.current),v=x!==-1&&m===-1||M,T=z0(a);Jt(()=>{M&&p&&c(g)},[M,g,p,c]),C.useEffect(()=>{k.current=g},[g]);const I=C.useMemo(()=>({activeIndex:m,containerId:i,disabled:T,disableTransforms:v,items:g,overIndex:x,useDragOverlay:u,sortedRects:F0(g,f),strategy:o}),[m,i,T.draggable,T.droppable,v,g,x,f,u,o]);return C.createElement(lc.Provider,{value:I},t)}const cc=e=>{let{id:t,items:r,activeIndex:n,overIndex:o}=e;return Ga(r,n,o).indexOf(t)},dc=e=>{let{containerId:t,isSorting:r,wasDragging:n,index:o,items:a,newIndex:s,previousItems:l,previousContainerId:f,transition:h}=e;return!h||!n||l!==a&&o===s?!1:r?!0:s!==o&&t===f},H0={duration:200,easing:"ease"},uc="transform",G0=pn.Transition.toString({property:uc,duration:0,easing:"linear"}),j0={roleDescription:"sortable"};function B0(e){let{disabled:t,index:r,node:n,rect:o}=e;const[a,s]=C.useState(null),l=C.useRef(r);return Jt(()=>{if(!t&&r!==l.current&&n.current){const f=o.current;if(f){const h=Wr(n.current,{ignoreTransform:!0}),c={x:f.left-h.left,y:f.top-h.top,scaleX:f.width/h.width,scaleY:f.height/h.height};(c.x||c.y)&&s(c)}}r!==l.current&&(l.current=r)},[t,r,n,o]),C.useEffect(()=>{a&&s(null)},[a]),a}function fc(e){let{animateLayoutChanges:t=dc,attributes:r,disabled:n,data:o,getNewIndex:a=cc,id:s,strategy:l,resizeObserverConfig:f,transition:h=H0}=e;const{items:c,containerId:i,activeIndex:u,disabled:g,disableTransforms:p,sortedRects:m,overIndex:x,useDragOverlay:k,strategy:M}=C.useContext(lc),v=W0(n,g),T=c.indexOf(s),I=C.useMemo(()=>({sortable:{containerId:i,index:T,items:c},...o}),[i,o,T,c]),S=C.useMemo(()=>c.slice(c.indexOf(s)),[c,s]),{rect:N,node:w,isOver:y,setNodeRef:E}=$0({id:s,data:I,disabled:v.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...f}}),{active:O,activatorEvent:$,activeNodeRect:P,attributes:L,setNodeRef:U,listeners:_,isDragging:b,over:z,setActivatorNodeRef:F,transform:G}=I0({id:s,data:I,attributes:{...j0,...r},disabled:v.draggable}),X=gh(E,U),B=!!O,Y=B&&!p&&ao(u)&&ao(x),H=!k&&b,W=H&&Y?G:null,be=Y?W??(l??M)({rects:m,activeNodeRect:P,activeIndex:u,overIndex:x,index:T}):null,se=ao(u)&&ao(x)?a({id:s,items:c,activeIndex:u,overIndex:x}):T,pe=O?.id,ne=C.useRef({activeId:pe,items:c,newIndex:se,containerId:i}),Ae=c!==ne.current.items,ve=t({active:O,containerId:i,isDragging:b,isSorting:B,id:s,index:T,items:c,newIndex:ne.current.newIndex,previousItems:ne.current.items,previousContainerId:ne.current.containerId,transition:h,wasDragging:ne.current.activeId!=null}),We=B0({disabled:!ve,index:T,node:w,rect:N});return C.useEffect(()=>{B&&ne.current.newIndex!==se&&(ne.current.newIndex=se),i!==ne.current.containerId&&(ne.current.containerId=i),c!==ne.current.items&&(ne.current.items=c)},[B,se,i,c]),C.useEffect(()=>{if(pe===ne.current.activeId)return;if(pe!=null&&ne.current.activeId==null){ne.current.activeId=pe;return}const Te=setTimeout(()=>{ne.current.activeId=pe},50);return()=>clearTimeout(Te)},[pe]),{active:O,activeIndex:u,attributes:L,data:I,rect:N,index:T,newIndex:se,items:c,isOver:y,isSorting:B,isDragging:b,listeners:_,node:w,overIndex:x,over:z,setNodeRef:X,setActivatorNodeRef:F,setDroppableNodeRef:E,setDraggableNodeRef:U,transform:We??be,transition:me()};function me(){if(We||Ae&&ne.current.newIndex===T)return G0;if(!(H&&!Na($)||!h)&&(B||ve))return pn.Transition.toString({...h,property:uc})}}function W0(e,t){var r,n;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(r=e?.draggable)!=null?r:t.draggable,droppable:(n=e?.droppable)!=null?n:t.droppable}}function wn(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const V0=[Ue.Down,Ue.Right,Ue.Up,Ue.Left],gc=(e,t)=>{let{context:{active:r,collisionRect:n,droppableRects:o,droppableContainers:a,over:s,scrollableAncestors:l}}=t;if(V0.includes(e.code)){if(e.preventDefault(),!r||!n)return;const f=[];a.getEnabled().forEach(i=>{if(!i||i!=null&&i.disabled)return;const u=o.get(i.id);if(u)switch(e.code){case Ue.Down:n.topu.top&&f.push(i);break;case Ue.Left:n.left>u.left&&f.push(i);break;case Ue.Right:n.left1&&(c=h[1].id),c!=null){const i=a.get(r.id),u=a.get(c),g=u?o.get(u.id):null,p=u?.node.current;if(p&&g&&i&&u){const x=eo(p).some((S,N)=>l[N]!==S),k=hc(i,u),M=K0(i,u),v=x||!k?{x:0,y:0}:{x:M?n.width-g.width:0,y:M?n.height-g.height:0},T={x:g.left,y:g.top};return v.x&&v.y?T:hn(T,v)}}}};function hc(e,t){return!wn(e)||!wn(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function K0(e,t){return!wn(e)||!wn(t)||!hc(e,t)?!1:e.data.current.sortable.index{const{attributes:l,listeners:f,setNodeRef:h,transform:c,transition:i,isDragging:u}=fc({id:"hash"in e?e.hash:e.id}),g={transform:pn.Transform.toString(c),transition:i,opacity:u?.5:1},p="status"in e&&e.status!==void 0,m=p?e.status:"done",x=m==="uploading",k=m==="compressing",M=m==="error",v=p?e.progress:100,T=p?e.preview:void 0,I=p?e.mime_type?.startsWith("image/")??!1:e.is_image,[S,N]=C.useState(void 0),w=!p&&I?e.download_url:void 0;C.useEffect(()=>{if(!w){N(void 0);return}if(ua(w)){N(w);return}let E=!0,O;return(async()=>{try{const P=await X0.api.get(w,{responseType:"blob",headers:zn()});E&&P&&(O=URL.createObjectURL(P),N(O))}catch(P){console.error("Failed to load authenticated image:",P)}})(),()=>{E=!1,O&&URL.revokeObjectURL(O)}},[w]);const y=S;return d.jsxs(j,{ref:h,style:g,className:"relative group bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",children:[d.jsxs(j,{className:`aspect-square w-full flex items-center justify-center bg-gray-50 dark:bg-gray-900 relative ${I||!p?"cursor-pointer":""}`,onClick:()=>{x||k||(I&&n?n():!p&&o&&o())},children:[T||y?d.jsx(jt,{src:T||y,alt:e.original_filename,className:"w-full h-full object-cover"}):d.jsx(It,{className:`fa-solid ${Si(e.mime_type)} text-4xl text-gray-400 dark:text-gray-500`}),(x||k)&&d.jsxs(j,{className:"absolute inset-0 bg-black/50 flex flex-col items-center justify-center",children:[d.jsx(j,{className:"w-3/4 h-2 bg-gray-700 dark:bg-gray-600 rounded-full overflow-hidden",children:d.jsx(j,{className:"h-full bg-blue-500 dark:bg-blue-400 transition-all",style:{width:`${v}%`}})}),d.jsxs(te,{className:"text-white text-xs mt-1",children:[v,"%"]})]}),M&&d.jsx(j,{className:"absolute inset-0 bg-red-500/50 dark:bg-red-600/50 flex items-center justify-center",children:d.jsx(It,{className:"fa-solid fa-exclamation-triangle text-2xl text-white"})}),s&&d.jsx(R,{type:"button",onClick:E=>{E.stopPropagation(),s()},className:`absolute top-1.5 left-1.5 z-10 p-1 rounded-full transition-colors ${a?"bg-yellow-500 text-white":"bg-gray-800/50 text-gray-300 hover:bg-yellow-500 hover:text-white opacity-0 group-hover:opacity-100"}`,title:at(a?"attachment.primary_image":"attachment.set_as_primary"),children:d.jsx(It,{className:"fa-solid fa-star text-xs"})}),d.jsxs(j,{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors flex items-start justify-end p-1 gap-1 opacity-0 group-hover:opacity-100",children:[d.jsx(R,{type:"button",...l,...f,className:"p-1.5 bg-white/90 dark:bg-gray-800/90 rounded text-gray-600 dark:text-gray-300 hover:bg-white cursor-grab active:cursor-grabbing",title:at("attachment.drag_to_reorder"),onClick:E=>E.stopPropagation(),children:d.jsx(It,{className:"fa-solid fa-grip-vertical text-sm"})}),!p&&o&&d.jsx(R,{type:"button",onClick:E=>{E.stopPropagation(),o()},className:"p-1.5 bg-white/90 dark:bg-gray-800/90 rounded text-blue-500 hover:bg-white",title:at("common.download"),children:d.jsx(It,{className:"fa-solid fa-download text-sm"})}),M&&r&&d.jsx(R,{type:"button",onClick:E=>{E.stopPropagation(),r()},className:"p-1.5 bg-white/90 dark:bg-gray-800/90 rounded text-orange-500 hover:bg-white",title:at("common.retry"),children:d.jsx(It,{className:"fa-solid fa-arrow-rotate-right text-sm"})}),d.jsx(R,{type:"button",onClick:E=>{E.stopPropagation(),t()},disabled:x||k,className:"p-1.5 bg-white/90 dark:bg-gray-800/90 rounded text-red-500 hover:bg-white disabled:opacity-50",title:at("common.delete"),children:d.jsx(It,{className:"fa-solid fa-times text-sm"})})]})]}),d.jsxs(j,{className:`p-2 ${!p&&o?"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700":""}`,onClick:()=>{!p&&o&&o()},children:[d.jsx(Gt,{className:"text-xs font-medium text-gray-900 dark:text-white truncate",title:e.original_filename,children:e.original_filename}),d.jsx(Gt,{className:"text-xs text-gray-500 dark:text-gray-400",children:e.size_formatted})]})]})},mc=({allItems:e,canAddMore:t,totalCount:r,maxFiles:n,maxSize:o,accept:a,onRemove:s,onRetry:l,onImageClick:f,onDownload:h,onDragEnd:c,onAddClick:i,enablePrimarySelection:u,primaryFileId:g,onPrimaryChange:p})=>{const m=Th(Ii(Fa,{activationConstraint:{distance:8}}),Ii(La,{coordinateGetter:gc}));return d.jsxs(j,{className:"p-3",children:[d.jsx(N0,{sensors:m,collisionDetection:Nh,onDragEnd:c,children:d.jsx(ic,{items:e.map(x=>"hash"in x?x.hash:x.id),strategy:so,children:d.jsxs(j,{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-3",children:[e.map(x=>{const k="hash"in x,M=k?x.is_image:x.mime_type?.startsWith("image/")??!1;return d.jsx(pc,{file:x,onRemove:()=>s(x),onRetry:"status"in x&&x.status==="error"?()=>l(x):void 0,onImageClick:M?()=>f(x):void 0,onDownload:k?()=>h(x):void 0,isPrimary:u&&k&&(x.hash||x.id)===g,onPrimaryClick:u&&k?()=>p?.(x.hash||x.id):void 0},k?x.hash:x.id)}),t&&d.jsxs(j,{className:"aspect-square flex flex-col items-center justify-center border-2 border-dashed border-gray-300 dark:border-gray-600 rounded-lg cursor-pointer hover:border-gray-400 dark:hover:border-gray-500 hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors",onClick:i,children:[d.jsx(It,{className:"fa-solid fa-plus text-2xl text-gray-400 dark:text-gray-500 mb-1"}),d.jsx(te,{className:"text-xs text-gray-500 dark:text-gray-400",children:at("common.add")})]})]})})}),d.jsxs(j,{className:"mt-3 pt-3 border-t border-gray-200 dark:border-gray-700 flex justify-between items-center text-xs text-gray-500 dark:text-gray-400",children:[d.jsx(te,{children:at("attachment.attached_count",{count:r,max:n})}),d.jsxs(te,{children:[at("attachment.max_size",{size:o}),a&&` (${a})`]})]})]})},q0=[],Z0=[],lo=C.forwardRef(({uploadTriggerEvent:e,attachmentableType:t,attachmentableId:r,collection:n="default",maxFiles:o=10,maxSize:a=10,maxConcurrentUploads:s=3,accept:l,imageCompression:f,roleIds:h=Z0,autoUpload:c=!0,onFilesChange:i,onChange:u,onUploadComplete:g,onUploadError:p,onRemove:m,onReorder:x,initialFiles:k=q0,className:M="",confirmBeforeRemove:v=!1,confirmRemoveTitle:T,confirmRemoveMessage:I,apiEndpoints:S,uploadParams:N,enablePrimarySelection:w=!1,primaryFileId:y,onPrimaryChange:E,id:O,editorAttrs:$},P)=>{const L={upload:S?.upload??"/api/attachments",delete:S?.delete??"/api/attachments/:id",reorder:S?.reorder??"/api/attachments/reorder"},U=C.useRef(u??i);U.current=u??i;const _=C.useCallback(G=>{const X=U.current;if(!X)return;X({target:{value:G,files:G},preventDefault:()=>{},stopPropagation:()=>{}})},[]),b=Ei({attachmentableType:t,attachmentableId:r,collection:n,maxFiles:o,maxSize:a,maxConcurrentUploads:s,accept:l,imageCompression:f,roleIds:h,autoUpload:c,initialFiles:k,endpoints:L,onFilesChange:_,onUploadComplete:g,onUploadError:p,onRemove:m,onReorder:x,uploadTriggerEvent:e,confirmBeforeRemove:v,uploadParams:N});C.useImperativeHandle(P,()=>({uploadAll:b.handleUploadAll,clear:b.clear,getPendingFiles:b.getPendingFiles}));const z=C.useMemo(()=>b.imageFiles.map(G=>{const X=!("hash"in G),B=G,Y=G;return X?{src:B.preview||"",filename:B.original_filename,title:B.original_filename,downloadRequiresAuth:!1}:{src:b.authenticatedImageUrls.get(Y.id)||Y.download_url,downloadUrl:Y.download_url,filename:Y.original_filename,title:Y.original_filename,downloadRequiresAuth:!0}}),[b.imageFiles,b.authenticatedImageUrls]),F=C.useMemo(()=>({existingFiles:b.existingFiles,pendingFiles:b.pendingFiles,isDragOver:b.isDragOver,isDeleting:b.isDeleting,maxFiles:o,maxSize:a,accept:l,endpoints:L,confirmBeforeRemove:v,totalCount:b.totalCount,hasFiles:b.hasFiles,canAddMore:b.canAddMore,allItems:b.allItems,imageFiles:b.imageFiles,handleFiles:b.handleFiles,handleRemove:b.handleRemove,handleRetry:b.handleRetry,handleUploadAll:b.handleUploadAll,handleOpenGallery:b.handleOpenGallery,handleDownload:b.handleDownload,handleDragEnd:b.handleDragEnd,setIsDragOver:b.setIsDragOver,inputRef:b.inputRef,galleryOpen:b.galleryOpen,setGalleryOpen:b.setGalleryOpen,galleryStartIndex:b.galleryStartIndex,galleryKeyRef:b.galleryKeyRef,confirmDialogOpen:b.confirmDialogOpen,setConfirmDialogOpen:b.setConfirmDialogOpen,itemToDelete:b.itemToDelete,executeRemoveAttachment:b.executeRemoveAttachment,authenticatedImageUrls:b.authenticatedImageUrls}),[b,o,a,l,L,v]);return d.jsx(ui,{value:F,children:d.jsxs(j,{id:O,className:M,...$,children:[d.jsx(Ti,{isDragOver:b.isDragOver,canAddMore:b.canAddMore,onFiles:b.handleFiles,setIsDragOver:b.setIsDragOver,inputRef:b.inputRef,accept:l,maxFiles:o,maxSize:a,children:b.hasFiles&&d.jsx(mc,{allItems:b.allItems,canAddMore:b.canAddMore,totalCount:b.totalCount,maxFiles:o,maxSize:a,accept:l,onRemove:b.handleRemove,onRetry:b.handleRetry,onImageClick:b.handleOpenGallery,onDownload:b.handleDownload,onDragEnd:b.handleDragEnd,onAddClick:()=>b.inputRef.current?.click(),enablePrimarySelection:w,primaryFileId:y,onPrimaryChange:E})}),v&&d.jsx(wa,{isOpen:b.confirmDialogOpen,onClose:()=>{b.isDeleting||b.setConfirmDialogOpen(!1)},title:T??at("attachment.delete_confirm_title"),message:I??at("attachment.delete_confirm_message"),confirmText:at("common.delete"),confirmButtonVariant:"danger",onConfirm:()=>{b.itemToDelete&&b.executeRemoveAttachment(b.itemToDelete)},isLoading:b.isDeleting,loadingText:at("attachment.deleting")}),z.length>0&&b.galleryOpen&&d.jsx(zr,{images:z,isOpen:!0,onClose:()=>b.setGalleryOpen(!1),startIndex:b.galleryStartIndex,showDownload:!0},`gallery-${b.galleryKeyRef.current}`)]})})});lo.displayName="FileUploader";const Q0=Object.freeze(Object.defineProperty({__proto__:null,FileDropZone:Ti,FileList:mc,FileUploader:lo,FileUploaderProvider:ui,SortableThumbnailItem:pc,default:lo,extractErrorMessage:_i,fileUploaderT:at,formatFileSize:Zn,getFileIcon:Si,useFileUploader:Ei,useFileUploaderContext:th},Symbol.toStringTag,{value:"Module"})),bc=({provider:e,className:t="w-5 h-5"})=>{switch(e){case"google":return d.jsxs("svg",{className:t,viewBox:"0 0 24 24",children:[d.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),d.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),d.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),d.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]});case"naver":return d.jsx("svg",{className:t,viewBox:"0 0 24 24",children:d.jsx("path",{fill:"currentColor",d:"M16.273 12.845L7.376 0H0v24h7.727V11.155L16.624 24H24V0h-7.727z"})});case"kakao":return d.jsx("svg",{className:t,viewBox:"0 0 24 24",children:d.jsx("path",{fill:"currentColor",d:"M12 3c5.799 0 10.5 3.664 10.5 8.185 0 4.52-4.701 8.184-10.5 8.184a13.5 13.5 0 0 1-1.727-.11l-4.408 2.883c-.501.265-.678.236-.472-.413l.892-3.678c-2.88-1.46-4.785-3.99-4.785-6.866C1.5 6.665 6.201 3 12 3zm5.519 8.625h-.634v2.916h-.97v-2.916h-.633v-.848h2.237v.848zm-3.294 2.916h-.97V10.77h.97v3.771zm-1.97 0h-.97v-2.77l-.658 1.53h-.629l-.665-1.53v2.77h-.97V10.77h1.13l.822 1.912.814-1.912h1.126v3.771zm-4.49 0h-.97V10.77h.97v3.771z"})});case"facebook":return d.jsx("svg",{className:t,viewBox:"0 0 24 24",children:d.jsx("path",{fill:"currentColor",d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})});case"apple":return d.jsx("svg",{className:t,viewBox:"0 0 24 24",children:d.jsx("path",{fill:"currentColor",d:"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"})});default:return null}},yc=(e,t)=>window.G7Core?.t?.(e,t)??e,J0=[{id:"google",name:"Google",color:"bg-white dark:bg-gray-800",textColor:"text-gray-700 dark:text-gray-300"},{id:"naver",name:"네이버",color:"bg-[#03C75A]",textColor:"text-white"},{id:"kakao",name:"카카오",color:"bg-[#FEE500]",textColor:"text-[#000000]/85"},{id:"facebook",name:"Facebook",color:"bg-[#1877F2]",textColor:"text-white"},{id:"apple",name:"Apple",color:"bg-black dark:bg-white",textColor:"text-white dark:text-black"}],vc=({providers:e=["google","naver","kakao"],mode:t="login",variant:r="full",className:n="",id:o,editorAttrs:a})=>{const s=h=>{const c=encodeURIComponent(window.location.href);window.location.href=`/api/auth/${h}?redirect=${c}`},l=h=>t==="register"?yc("auth.social.register_with",{provider:h}):yc("auth.social.login_with",{provider:h}),f=J0.filter(h=>e.includes(h.id));return r==="icon"?d.jsx(j,{className:`flex justify-center gap-4 ${n}`,id:o,...a,children:f.map(h=>d.jsx(R,{onClick:()=>s(h.id),className:`w-12 h-12 flex items-center justify-center rounded-full ${h.color} ${h.textColor} border border-gray-200 dark:border-gray-700 hover:opacity-90 transition-opacity`,"aria-label":l(h.name),children:d.jsx(bc,{provider:h.id,className:"w-5 h-5"})},h.id))}):d.jsx(j,{className:`space-y-3 ${n}`,id:o,...a,children:f.map(h=>d.jsxs(R,{onClick:()=>s(h.id),className:`w-full flex items-center justify-center gap-3 px-4 py-3 rounded-lg font-medium border border-gray-200 dark:border-gray-700 ${h.color} ${h.textColor} hover:opacity-90 transition-opacity`,children:[d.jsx(bc,{provider:h.id,className:"w-5 h-5"}),d.jsx(te,{children:l(h.name)})]},h.id))})},R0=Object.freeze(Object.defineProperty({__proto__:null,default:vc},Symbol.toStringTag,{value:"Module"})),ep=(e,t)=>window.G7Core?.t?.(e,t)??e,tp={success:nt.CheckCircle,error:nt.XCircle,warning:nt.ExclamationTriangle,info:nt.InfoCircle},wc={success:{bg:"bg-green-50 dark:bg-green-900/20 border-green-200 dark:border-green-800",text:"text-green-800 dark:text-green-300"},error:{bg:"bg-red-50 dark:bg-red-900/20 border-red-200 dark:border-red-800",text:"text-red-800 dark:text-red-300"},warning:{bg:"bg-yellow-50 dark:bg-yellow-900/20 border-yellow-200 dark:border-yellow-800",text:"text-yellow-800 dark:text-yellow-300"},info:{bg:"bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-800",text:"text-blue-800 dark:text-blue-300"}},rp={"top-left":"top-4 left-4","top-center":"top-4 left-1/2 -translate-x-1/2","top-right":"top-4 right-4","bottom-left":"bottom-4 left-4","bottom-center":"bottom-4 left-1/2 -translate-x-1/2","bottom-right":"bottom-4 right-4"},ja=({toasts:e,position:t="bottom-center",duration:r=3e3,onRemove:n})=>{const[o,a]=C.useState(new Map),s=C.useCallback(l=>{a(f=>{const h=new Map(f);return h.set(l,!1),h}),setTimeout(()=>{if(n)n(l);else{const f=window.G7Core;f?.state?.update&&f.state.update(h=>({toasts:(Array.isArray(h.toasts)?h.toasts:[]).filter(i=>i.id!==l)}))}},300)},[n]);return C.useEffect(()=>{!e||e.length===0||e.forEach(l=>{if(o.has(l.id))return;a(h=>{const c=new Map(h);return c.set(l.id,!0),c});const f=l.duration||r;f>0&&setTimeout(()=>{s(l.id)},f)})},[e,r,s,o]),!e||e.length===0?null:d.jsx(j,{className:`fixed z-[9999] flex flex-col gap-2 ${rp[t]}`,"aria-live":"polite","aria-atomic":"true",children:e.map(l=>d.jsx(np,{toast:l,position:t,isVisible:o.get(l.id)??!0,onClose:()=>s(l.id)},l.id))})},np=({toast:e,position:t,isVisible:r,onClose:n})=>{const o=wc[e.type]||wc.info,a=e.icon?e.icon:tp[e.type],s=t.startsWith("bottom")?"translate-y-2":"-translate-y-2";return d.jsxs(j,{className:` flex items-center gap-3 p-4 rounded-lg border shadow-lg min-w-[300px] max-w-md transition-all duration-300 ${o.bg} ${r?"opacity-100 translate-y-0":`opacity-0 ${s}`} - `,role:"alert",children:[d.jsx(fe,{name:a,className:`w-5 h-5 flex-shrink-0 ${o.text}`}),d.jsx(te,{className:`flex-1 text-sm font-medium ${o.text}`,children:e.message}),d.jsx(R,{onClick:n,className:`flex-shrink-0 p-1 rounded hover:bg-black/10 dark:hover:bg-white/10 ${o.text} focus:outline-none`,"aria-label":J0("common.close"),children:d.jsx(fe,{name:nt.Times,className:"w-4 h-4"})})]})},rp=Object.freeze(Object.defineProperty({__proto__:null,Toast:ja,default:ja},Symbol.toStringTag,{value:"Module"})),np=window.G7Core?.createLogger?.("Comp:PageTransition")??{log:(...e)=>console.log("[Comp:PageTransition]",...e),warn:(...e)=>console.warn("[Comp:PageTransition]",...e),error:(...e)=>console.error("[Comp:PageTransition]",...e)},Ba=({className:e="",style:t})=>{const[r,n]=C.useState(!1);return C.useEffect(()=>{const o=window.G7Core?.TransitionManager;if(!o){np.warn("TransitionManager를 찾을 수 없습니다.");return}return n(o.getIsPending()),o.subscribe(s=>{n(s)})},[]),r?d.jsxs(j,{className:`fixed top-0 left-0 right-0 z-50 ${e}`,style:t,role:"progressbar","aria-label":"페이지 로딩 중",children:[d.jsx(j,{className:"h-1 bg-gradient-to-r from-blue-500 via-blue-600 to-blue-500 animate-pulse",children:d.jsx(j,{className:"h-full bg-blue-700 animate-[loading_1.5s_ease-in-out_infinite]",style:{width:"30%",animation:"loading 1.5s ease-in-out infinite"}})}),d.jsx("style",{children:` + `,role:"alert",children:[d.jsx(fe,{name:a,className:`w-5 h-5 flex-shrink-0 ${o.text}`}),d.jsx(te,{className:`flex-1 text-sm font-medium ${o.text}`,children:e.message}),d.jsx(R,{onClick:n,className:`flex-shrink-0 p-1 rounded hover:bg-black/10 dark:hover:bg-white/10 ${o.text} focus:outline-none`,"aria-label":ep("common.close"),children:d.jsx(fe,{name:nt.Times,className:"w-4 h-4"})})]})},op=Object.freeze(Object.defineProperty({__proto__:null,Toast:ja,default:ja},Symbol.toStringTag,{value:"Module"})),ap=window.G7Core?.createLogger?.("Comp:PageTransition")??{log:(...e)=>console.log("[Comp:PageTransition]",...e),warn:(...e)=>console.warn("[Comp:PageTransition]",...e),error:(...e)=>console.error("[Comp:PageTransition]",...e)},Ba=({className:e="",style:t})=>{const[r,n]=C.useState(!1);return C.useEffect(()=>{const o=window.G7Core?.TransitionManager;if(!o){ap.warn("TransitionManager를 찾을 수 없습니다.");return}return n(o.getIsPending()),o.subscribe(s=>{n(s)})},[]),r?d.jsxs(j,{className:`fixed top-0 left-0 right-0 z-50 ${e}`,style:t,role:"progressbar","aria-label":"페이지 로딩 중",children:[d.jsx(j,{className:"h-1 bg-gradient-to-r from-blue-500 via-blue-600 to-blue-500 animate-pulse",children:d.jsx(j,{className:"h-full bg-blue-700 animate-[loading_1.5s_ease-in-out_infinite]",style:{width:"30%",animation:"loading 1.5s ease-in-out infinite"}})}),d.jsx("style",{children:` @keyframes loading { 0% { transform: translateX(-100%); @@ -84,4 +84,4 @@ self.addEventListener('message', async (e) => { transform: translateX(-100%); } } - `})]}):null},op=Object.freeze(Object.defineProperty({__proto__:null,PageTransitionIndicator:Ba,default:Ba},Symbol.toStringTag,{value:"Module"})),xc=window.G7Core?.createLogger?.("Comp:PageTransitionBlur")??{log:(...e)=>console.log("[Comp:PageTransitionBlur]",...e),warn:(...e)=>console.warn("[Comp:PageTransitionBlur]",...e)},Wa=({className:e="",style:t})=>{const[r,n]=C.useState(!1);return C.useEffect(()=>{const o=window.G7Core?.TransitionManager;if(!o){xc.warn("TransitionManager를 찾을 수 없습니다.");return}return n(o.getIsPending()),o.subscribe(s=>{xc.log("isPending changed:",s),n(s)})},[]),r?d.jsx(j,{className:`fixed inset-0 z-40 bg-white/30 dark:bg-gray-900/30 backdrop-blur-sm transition-opacity duration-150 pointer-events-none ${e}`,style:t,role:"status","aria-label":"페이지 전환 중","data-testid":"page-transition-blur"}):null},ap=Object.freeze(Object.defineProperty({__proto__:null,PageTransitionBlur:Wa,default:Wa},Symbol.toStringTag,{value:"Module"})),kc={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Cc=new Set(["hidden","block","inline-block","inline","flex","inline-flex","grid","inline-grid","table","table-row","table-cell","contents","list-item","flow-root"]),sp=new Set(["Div","Flex","Grid","Section","Article","Nav","Aside","Main","Header","Footer","Fragment","Form","Container"]),lp=new Set(["H1","H2","H3","H4","H5","H6","P","Span","Label","A","Strong","Em","Small","Badge"]),ip=new Set(["Input","Textarea","Select","Checkbox","Radio","Toggle","DatePicker","TagInput","SearchBar"]),cp=new Set(["Img","Image","Avatar","AvatarUploader","ImageGallery","ProductImageViewer","FileUploader"]),_c={DataGrid:(e,t)=>d.jsxs("div",{className:"w-full border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",children:[d.jsx("div",{className:`h-10 bg-gray-100 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 ${e}`,children:d.jsxs("div",{className:"flex items-center h-full px-4 gap-8",children:[d.jsx("div",{className:"h-3 w-16 bg-gray-300 dark:bg-gray-600 rounded"}),d.jsx("div",{className:"h-3 w-24 bg-gray-300 dark:bg-gray-600 rounded"}),d.jsx("div",{className:"h-3 w-20 bg-gray-300 dark:bg-gray-600 rounded"}),d.jsx("div",{className:"h-3 w-16 bg-gray-300 dark:bg-gray-600 rounded"})]})}),Array.from({length:t},(r,n)=>d.jsx("div",{className:`h-12 border-b border-gray-100 dark:border-gray-800 ${e}`,style:{animationDelay:`${n*75}ms`},children:d.jsxs("div",{className:"flex items-center h-full px-4 gap-8",children:[d.jsx("div",{className:"h-3 w-12 bg-gray-200 dark:bg-gray-700 rounded"}),d.jsx("div",{className:"h-3 flex-1 bg-gray-200 dark:bg-gray-700 rounded"}),d.jsx("div",{className:"h-3 w-16 bg-gray-100 dark:bg-gray-800 rounded"}),d.jsx("div",{className:"h-3 w-14 bg-gray-100 dark:bg-gray-800 rounded"})]})},n))]}),Pagination:e=>d.jsx("div",{className:"flex justify-center gap-1.5 py-3",children:Array.from({length:5},(t,r)=>d.jsx("div",{className:`w-8 h-8 bg-gray-200 dark:bg-gray-700 rounded ${e}`},r))}),Tabs:e=>d.jsxs("div",{children:[d.jsx("div",{className:"flex gap-4 border-b border-gray-200 dark:border-gray-700 pb-2 mb-3",children:Array.from({length:3},(t,r)=>d.jsx("div",{className:`h-4 w-20 bg-gray-200 dark:bg-gray-700 rounded ${e}`},r))}),d.jsx("div",{className:`h-32 bg-gray-100 dark:bg-gray-800 rounded ${e}`})]}),TabNavigation:e=>d.jsx("div",{className:"flex gap-4 border-b border-gray-200 dark:border-gray-700 pb-2",children:Array.from({length:3},(t,r)=>d.jsx("div",{className:`h-4 w-20 bg-gray-200 dark:bg-gray-700 rounded ${e}`},r))}),ProductCard:e=>d.jsxs("div",{className:"rounded-lg overflow-hidden",children:[d.jsx("div",{className:`h-48 w-full bg-gray-200 dark:bg-gray-700 ${e}`}),d.jsxs("div",{className:"p-3 space-y-2",children:[d.jsx("div",{className:`h-3.5 w-3/4 bg-gray-200 dark:bg-gray-700 rounded ${e}`}),d.jsx("div",{className:`h-4 w-1/3 bg-gray-300 dark:bg-gray-600 rounded ${e}`})]})]}),UserInfo:e=>d.jsx("div",{className:`h-3 w-14 bg-gray-200 dark:bg-gray-700 rounded ${e}`}),QuantitySelector:e=>d.jsx("div",{className:`h-9 w-28 bg-gray-100 dark:bg-gray-800 rounded border border-gray-200 dark:border-gray-700 ${e}`}),Header:e=>d.jsx("header",{className:"bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",children:d.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:d.jsxs("div",{className:"flex items-center justify-between h-16",children:[d.jsxs("div",{className:"flex items-center gap-8",children:[d.jsx("div",{className:`h-8 w-24 bg-gray-200 dark:bg-gray-700 rounded ${e}`}),d.jsx("div",{className:"hidden lg:flex items-center gap-6",children:Array.from({length:4},(t,r)=>d.jsx("div",{className:`h-3.5 w-16 bg-gray-200 dark:bg-gray-700 rounded ${e}`},r))})]}),d.jsx("div",{className:"flex items-center gap-4",children:Array.from({length:3},(t,r)=>d.jsx("div",{className:`h-8 w-8 bg-gray-200 dark:bg-gray-700 rounded-full ${e}`},r))})]})})}),Footer:e=>d.jsx("footer",{className:"bg-white dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700 mt-auto",children:d.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:d.jsxs("div",{className:"flex flex-col items-center gap-4",children:[d.jsx("div",{className:`h-4 w-32 bg-gray-200 dark:bg-gray-700 rounded ${e}`}),d.jsx("div",{className:`h-3 w-48 bg-gray-100 dark:bg-gray-800 rounded ${e}`}),d.jsx("div",{className:"flex gap-3",children:Array.from({length:3},(t,r)=>d.jsx("div",{className:`h-6 w-6 bg-gray-200 dark:bg-gray-700 rounded-full ${e}`},r))}),d.jsx("div",{className:`h-3 w-40 bg-gray-100 dark:bg-gray-800 rounded ${e}`})]})})}),Modal:()=>d.jsx(d.Fragment,{}),Toast:()=>d.jsx(d.Fragment,{}),ConfirmDialog:()=>d.jsx(d.Fragment,{})};function dp(e){if(!e||e.length===0)return[];const t=e.filter(n=>n.if),r=e.filter(n=>!n.if);if(r.length>0&&t.length>0){const n=t.filter(o=>!Sc(o.if));return n.length>1&&up(n)?[...r,Ec(n)]:[...r,...n]}if(t.length>1&&r.length===0){const n=t.filter(o=>!Sc(o.if));return n.length===0?[]:n.length===1?n:[Ec(n)]}return e}function Sc(e){const t=e.replace(/^\{\{|\}\}$/g,"").trim();return t.startsWith("!")||/\b(hasError|isError|isLoading|error|Error)\b/.test(t)||/===\s*0\s*(\)|\}|$)/.test(t)}function up(e){if(e.length<2)return!1;const t=[];for(const n of e){const o=(n.if||"").replace(/^\{\{|\}\}$/g,"").trim(),a=o.match(/^(.+?)\s*===\s*['"]/);if(a)t.push(a[1].trim());else{const s=o.match(/(.+?)\s*===\s*['"]/);if(!s)return!1;t.push(s[1].trim())}}const r=t[0];return t.every(n=>n===r)}function Ec(e){return e.reduce((t,r)=>Va(r)>Va(t)?r:t)}function Va(e){return e.children?e.children.length+e.children.reduce((t,r)=>t+Va(r),0):0}function fp(e){return e.includes("{{")?e.replace(/\{\{([^}]+)\}\}/g,(t,r)=>{const n=r.match(/\?[\s]*['"]([^'"]*)['"]\s*:\s*['"]/);return n?n[1]:""}):e}function Ka(e,t){if(!e)return"";let r=e;return r=r.replace(/\b(bg-\S+|text-\S+|border\b|border-\S+|shadow\S*|ring-\S+|outline-\S+|divide-\S+|opacity-\S+|font-\S+|tracking-\S+|leading-\S+|whitespace-\S+|truncate|line-clamp-\S+|underline|no-underline|decoration-\S+|cursor-\S+|hover:\S+|focus:\S+|active:\S+|group-hover:\S+|transition\S*|duration-\S+|ease-\S+|animate-\S+|dark:\S+)\b/g,"").replace(/\s{2,}/g," ").trim(),(t==="Grid"||/\bgrid-cols-\d/.test(r))&&(r=r.replace(/\bgrid-cols-(\d+)/g,(n,o)=>{const a=parseInt(o);return a>4?`grid-cols-${Math.ceil(a/2)}`:`grid-cols-${a}`})),r}function gp(e){const{name:t,props:r}=e;if(!r||!t)return"";const n=[];if(t==="Flex"){n.push("flex");const o=r.direction||"row",a={row:"flex-row","row-reverse":"flex-row-reverse",col:"flex-col","col-reverse":"flex-col-reverse"};a[o]&&n.push(a[o]);const s=r.justify||"start",l={start:"justify-start",end:"justify-end",center:"justify-center",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};l[s]&&n.push(l[s]);const f=r.align||"stretch",h={start:"items-start",end:"items-end",center:"items-center",baseline:"items-baseline",stretch:"items-stretch"};h[f]&&n.push(h[f]);const c=r.wrap||"nowrap",i={wrap:"flex-wrap",nowrap:"flex-nowrap","wrap-reverse":"flex-wrap-reverse"};i[c]&&n.push(i[c]),r.gap&&r.gap>0&&n.push(`gap-${r.gap}`)}if(t==="Grid"){n.push("grid");const o=r.cols||1;if(n.push(`grid-cols-${o}`),r.responsive){const a=r.responsive;a.sm&&n.push(`sm:grid-cols-${a.sm}`),a.md&&n.push(`md:grid-cols-${a.md}`),a.lg&&n.push(`lg:grid-cols-${a.lg}`),a.xl&&n.push(`xl:grid-cols-${a.xl}`),a["2xl"]&&n.push(`2xl:grid-cols-${a["2xl"]}`)}r.gap!==void 0&&r.gap>0&&n.push(`gap-${r.gap}`),r.rowGap!==void 0&&r.rowGap>0&&n.push(`gap-y-${r.rowGap}`),r.colGap!==void 0&&r.colGap>0&&n.push(`gap-x-${r.colGap}`)}return n.join(" ")}function hp(e){switch(e){case"pulse":return"animate-pulse";case"wave":return"animate-pulse";case"none":return"";default:return"animate-pulse"}}function io(e,t,r,n){return!e||e.length===0?[]:dp(e).map((a,s)=>Tc(a,t,r,s,n))}function pp(e,t){const r=e.props?.className||e.className||"";return e.responsive?t>=1024&&e.responsive.desktop?.props?.className?e.responsive.desktop.props.className:t>=768&&e.responsive.tablet?.props?.className?e.responsive.tablet.props.className:r:r}function mp(e,t){const r=e.split(/\s+/).filter(Boolean),n=[],o=[];for(const f of r){const h=f.match(/^(sm|md|lg|xl|2xl):(.+)$/);if(h){const[,c,i]=h;if(Cc.has(i)){n.push({breakpoint:kc[c]||0,display:i});continue}(kc[c]||0)<=t&&o.push(i);continue}if(Cc.has(f)){n.push({breakpoint:0,display:f});continue}o.push(f)}if(n.length===0)return{visible:!0,className:e};n.sort((f,h)=>f.breakpoint-h.breakpoint);let a="";for(const f of n)f.breakpoint<=t&&(a=f.display);a||(a=n[0].display);const s=a!=="hidden",l=s?[a,...o].join(" "):"";return{visible:s,className:l}}function bp(e){const t=e.match(/\bgrid-cols-\[([^\]]+)\]/);if(!t)return{className:e};const r=t[1].replace(/_/g," ");return{className:e.replace(/\bgrid-cols-\[([^\]]+)\]/,"").replace(/\s{2,}/g," ").trim(),style:{gridTemplateColumns:r}}}function Tc(e,t,r,n,o){const{name:a,children:s,iteration:l}=e,f=pp(e,o),h=gp(e),c=h?`${h} ${f}`.trim():f,i=fp(c),u=mp(i,o);if(!a||!u.visible)return null;const g=u.className;if(l)return d.jsx(C.Fragment,{children:Array.from({length:r},(m,x)=>Tc({...e,iteration:void 0},t,r,x,o))},n);if(_c[a])return d.jsx("div",{className:g,children:_c[a](t,r)},n);if(sp.has(a)){const m=Ka(g,a);if(!s||s.length===0){const T=/\b(h-\S|w-\S)/.test(m)?`${m} bg-gray-200 dark:bg-gray-700 rounded ${t}`:`${m} h-3.5 w-full bg-gray-200 dark:bg-gray-700 rounded ${t}`.trim();return d.jsx("div",{className:T},n)}const x=io(s,t,r,o);if(!(x.length>0&&x.some(v=>v!==null)))return null;const M=bp(m);return d.jsx("div",{className:M.className,style:M.style,children:x},n)}const p=Ka(g,a);if(lp.has(a)){const m={H1:"h-7",H2:"h-6",H3:"h-5",H4:"h-5",H5:"h-4",H6:"h-4",P:"h-3.5",Span:"h-3",Label:"h-3",A:"h-3.5",Badge:"h-5 w-16"},x={H1:"w-3/5",H2:"w-2/5",H3:"w-1/3",H4:"w-1/3",H5:"w-1/4",H6:"w-1/4",P:"w-full",Span:"w-1/4",Label:"w-1/4",A:"w-1/3",Strong:"w-1/5",Em:"w-1/4",Small:"w-1/5",Badge:"w-16"},k=m[a]||"h-3.5",M=x[a]||"w-full",v=a.startsWith("H")?"mb-2 mt-1":"mb-1.5";return d.jsx("div",{className:`${k} ${M} bg-gray-200 dark:bg-gray-700 rounded ${t} ${v} ${p}`.trim()},n)}if(ip.has(a))return a==="Textarea"?d.jsx("div",{className:`h-20 w-full bg-gray-100 dark:bg-gray-800 rounded border border-gray-200 dark:border-gray-700 mb-2 ${t}`},n):a==="Checkbox"||a==="Radio"||a==="Toggle"?d.jsx("div",{className:`h-5 w-5 bg-gray-200 dark:bg-gray-700 rounded mb-1.5 ${t}`},n):d.jsx("div",{className:`h-9 w-full bg-gray-100 dark:bg-gray-800 rounded border border-gray-200 dark:border-gray-700 mb-2 ${t}`},n);if(cp.has(a))return a==="Avatar"||a==="AvatarUploader"?d.jsx("div",{className:`h-10 w-10 bg-gray-200 dark:bg-gray-700 rounded-full ${t}`},n):a==="ProductImageViewer"?d.jsx("div",{className:`h-80 w-full bg-gray-200 dark:bg-gray-700 rounded ${t}`},n):d.jsx("div",{className:`h-40 w-full bg-gray-200 dark:bg-gray-700 rounded mb-2 ${t}`},n);if(a==="Button"){if(s&&s.length>0){const m=Ka(g,a),x=io(s,t,r,o);if(!(x.length>0&&x.some(T=>T!==null)))return null;const v=/\b(border|rounded|px-\d|py-\d)/.test(f)?"border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50 rounded-lg":"";return d.jsx("div",{className:`${m} ${v}`.trim(),children:x},n)}return d.jsx("div",{className:`h-9 w-24 bg-gray-200 dark:bg-gray-700 rounded ${t}`},n)}return a==="Icon"?d.jsx("div",{className:`h-5 w-5 bg-gray-200 dark:bg-gray-700 rounded ${t}`},n):s&&s.length>0?d.jsx("div",{className:p,children:io(s,t,r,o)},n):d.jsx("div",{className:`h-3.5 w-full bg-gray-200 dark:bg-gray-700 rounded mb-1.5 ${t}`},n)}const Ya=({components:e,options:t})=>{const r=hp(t.animation),o=window.G7Core?.useResponsive,a=o?.(),s=a?a.width:typeof window<"u"?window.innerWidth:1024;return d.jsx("div",{className:"w-full",role:"status","aria-busy":"true","aria-label":"Loading...",children:io(e,r,t.iteration_count,s)})},yp=Object.freeze(Object.defineProperty({__proto__:null,PageSkeleton:Ya,default:Ya},Symbol.toStringTag,{value:"Module"})),vp=(e,t)=>window.G7Core?.t?.(e,t)??e,Ac=({options:e})=>{const t=document.documentElement.classList.contains("dark"),r=t?"rgb(17,24,39)":"rgb(249,250,251)",n=t?"#6b7280":"#9ca3af",o=t?"#9ca3af":"#6b7280";return d.jsxs("div",{style:{position:"absolute",inset:0,zIndex:2147483647,overflow:"hidden",background:r,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-start",paddingTop:"15%",gap:"12px"},children:[d.jsx("div",{style:{width:"32px",height:"32px",border:`3px solid ${n}`,borderTopColor:"transparent",borderRadius:"50%",animation:"g7-spin 0.8s linear infinite"}}),d.jsx("span",{style:{color:o,fontSize:"14px"},children:e?.text||vp("nav.loading")})]})},wp=Object.freeze(Object.defineProperty({__proto__:null,default:Ac},Symbol.toStringTag,{value:"Module"})),Vr=(e,t)=>window.G7Core?.t?.(e,t)??e,Nc=({currentPage:e,totalPages:t,onPageChange:r,maxVisiblePages:n=5,showFirstLast:o=!0,showFirst:a,showLast:s,hasMorePages:l,className:f="",style:h,prevText:c,nextText:i,id:u,editorAttrs:g})=>{const p=t!=null,m=p?t:0,x=p?e{const N=[];if(!p){const w=Math.floor(n/2),y=e<=n?1:e-w;y>1&&(N.push(1),y>2&&N.push("..."));for(let E=y;E<=e;E++)N.push(E);return l&&(N.push(e+1),N.push("...")),N}if(m<=n+2)for(let w=1;w<=m;w++)N.push(w);else{const w=Math.floor(n/2);let y=Math.max(2,e-w),E=Math.min(m-1,e+w);e<=w+1?E=n:e>=m-w&&(y=m-n+1),N.push(1),y>2&&N.push("...");for(let O=y;O<=E;O++)N.push(O);E1&&N.push(m)}return N},[e,m,p,n,l]),T=N=>{N<1||N===e||p&&N>m||r(N)},I=()=>{e>1&&r(e-1)},S=()=>{x&&r(e+1)};return d.jsxs(j,{className:`flex items-center gap-2 ${f}`,style:h,role:"navigation","aria-label":Vr("common.pagination"),id:u,...g,children:[k&&d.jsx(R,{onClick:()=>T(1),disabled:e===1,className:"px-3 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800","aria-label":Vr("common.first_page"),children:"«"}),d.jsx(R,{onClick:I,disabled:e===1,className:"px-3 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800","aria-label":Vr("common.prev_page"),children:c||d.jsx(d.Fragment,{children:"‹"})}),d.jsx(j,{className:"flex items-center gap-1",children:v.map((N,w)=>{if(N==="...")return d.jsx(te,{className:"px-3 py-1 text-sm text-gray-500 dark:text-gray-400",children:"..."},`ellipsis-${w}`);const y=N,E=y===e;return d.jsx(R,{onClick:()=>T(y),className:`px-3 py-1 text-sm border rounded ${E?"bg-blue-500 dark:bg-blue-600 text-white border-blue-500 dark:border-blue-600":"border-gray-300 dark:border-gray-600 hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800"}`,"aria-label":Vr("common.page_n",{n:y}),"aria-current":E?"page":void 0,children:y},y)})}),d.jsx(R,{onClick:S,disabled:!x,className:"px-3 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800","aria-label":Vr("common.next_page"),children:i||d.jsx(d.Fragment,{children:"›"})}),M&&d.jsx(R,{onClick:()=>T(m),disabled:e===m,className:"px-3 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800","aria-label":Vr("common.last_page"),children:"»"})]})},xp=Object.freeze(Object.defineProperty({__proto__:null,Pagination:Nc},Symbol.toStringTag,{value:"Module"})),Oc=(e,t)=>window.G7Core?.t?.(e,t)??e,Mc=({name:e="search",placeholder:t,value:r,onChange:n,onSubmit:o,showButton:a=!1,suggestions:s=[],onSuggestionClick:l,showSuggestions:f=!1,className:h="",style:c,id:i,editorAttrs:u})=>{const g=t??Oc("common.search_placeholder"),[p,m]=C.useState(""),[x,k]=C.useState(!1),M=C.useRef(null),v=C.useRef(""),T=r!==void 0?r:p,I=f&&x&&s.length>0&&T.length>0;C.useEffect(()=>{r!==void 0&&(v.current=r)},[r]);const S=y=>{const E=y.target.value;m(E),n?.(y),v.current!==""&&E===""&&!y.nativeEvent.inputType&&setTimeout(()=>{const O=M.current?.querySelector("form");O&&O.requestSubmit()},0),v.current=E},N=y=>{m(y.text);const E={target:{value:y.text,name:e}};n?.(E),l?.(y),k(!1)},w=y=>{y.preventDefault(),o?.(y)};return d.jsxs(j,{ref:M,className:`relative ${h}`,style:c,id:i,...u,children:[d.jsx(Eo,{onSubmit:w,className:"relative",children:d.jsxs(j,{className:`relative flex items-center ${a?"gap-2":""}`,children:[d.jsxs(j,{className:"relative flex-1",children:[d.jsx(j,{className:"absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none",children:d.jsx(fe,{name:nt.Search,className:"w-5 h-5 text-gray-400 dark:text-gray-500"})}),d.jsx(At,{type:"search",name:e,value:T,onChange:S,onFocus:()=>k(!0),onBlur:()=>setTimeout(()=>k(!1),200),placeholder:g,className:"w-full pl-10 pr-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white text-sm"})]}),a&&d.jsx(R,{type:"submit",className:"px-4 py-2 bg-gray-800 dark:bg-gray-600 text-white rounded-lg hover:bg-gray-900 dark:hover:bg-gray-500 transition-colors text-sm font-medium cursor-pointer h-[42px]",children:Oc("common.search")})]})}),I&&d.jsx(j,{className:"absolute z-10 w-full mt-2 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg max-h-64 overflow-y-auto",children:s.map(y=>d.jsx(j,{className:"px-4 py-3 hover:bg-gray-50 dark:hover:bg-gray-700 cursor-pointer border-b border-gray-100 dark:border-gray-700 last:border-b-0 transition-colors",onClick:()=>N(y),children:d.jsxs(j,{className:"flex items-center gap-2",children:[d.jsx(fe,{name:nt.Search,className:"w-4 h-4 text-gray-400 dark:text-gray-500"}),d.jsx(te,{className:"text-sm text-gray-700 dark:text-gray-300",children:y.text})]})},y.id))})]})},kp=Object.freeze(Object.defineProperty({__proto__:null,SearchBar:Mc},Symbol.toStringTag,{value:"Module"})),_t=window.G7Core,Cp={sm:"md",md:"lg",lg:"xl",xl:"2xl","2xl":"3xl"};function Xa({src:e,fallbackText:t="U",size:r="lg",uploadEndpoint:n="/api/me/avatar",deleteEndpoint:o="/api/me/avatar",onUploadSuccess:a,onUploadError:s,onDeleteSuccess:l,onDeleteError:f,showDeleteButton:h=!0,accept:c="image/*",maxSize:i=5,className:u="",uploadButtonText:g,deleteButtonText:p,readOnly:m=!1,confirmDelete:x=!0,deleteConfirmMessage:k,confirmUpload:M=!0,uploadConfirmMessage:v,uploadSuccessActions:T,uploadErrorActions:I,deleteSuccessActions:S,deleteErrorActions:N,id:w,editorAttrs:y}){const E=C.useRef(null),[O,$]=C.useState(!1),[P,L]=C.useState(!1),[U,_]=C.useState(void 0),[b,z]=C.useState(null),[F,G]=C.useState(!1),[X,B]=C.useState(!1),[Y,H]=C.useState(null),[W,Q]=C.useState(null),be=C.useRef(`avatar-upload-${Math.random().toString(36).slice(2,11)}`).current;C.useEffect(()=>{if(Y){const ae=URL.createObjectURL(Y);return Q(ae),()=>URL.revokeObjectURL(ae)}else Q(null)},[Y]);const se=C.useCallback(ae=>_t?.t?.(ae)??ae,[]),pe=C.useCallback(()=>{const ae=document.cookie.match(/XSRF-TOKEN=([^;]+)/);return ae?decodeURIComponent(ae[1]):null},[]),ne=C.useCallback(()=>_t?.api?.getToken?.()??null,[]),Ae=C.useCallback(async ae=>{B(!1),H(null),$(!0),z(null);try{const ce=new FormData;ce.append("avatar",ae);const ke=pe(),Ee=ne(),Be=await fetch(n,{method:"POST",headers:{Accept:"application/json",...ke&&{"X-XSRF-TOKEN":ke},...Ee&&{Authorization:`Bearer ${Ee}`}},credentials:"include",body:ce});if(!Be.ok){const Pe=await Be.json().catch(()=>({}));throw new Error(Pe.message||se("attachment.upload_failed"))}const Me=await Be.json(),Ke=Me.data||Me;Ke.avatar&&_(Ke.avatar),a?.(Ke),_t?.toast?.success?.(se("mypage.profile.avatar_uploaded")),T?.length?T.forEach(Pe=>_t?.dispatch?.(Pe)):_t?.refetchDataSource?.("user")}catch(ce){const ke=ce instanceof Error?ce:new Error(String(ce));z(ke.message),s?.(ke),_t?.toast?.error?.(ke.message),I?.length&&I.forEach(Ee=>_t?.dispatch?.(Ee))}finally{$(!1),E.current&&(E.current.value="")}},[n,a,s,pe,ne,se]),ve=C.useCallback(async ae=>{const ce=ae.target.files?.[0];if(!ce)return;z(null);const ke=i*1024*1024;if(ce.size>ke){const Ee=new Error(se("attachment.file_too_large").replace(":max",`${i}MB`));z(Ee.message),s?.(Ee),_t?.toast?.error?.(Ee.message);return}if(c&&!ce.type.match(c.replace("*",".*"))){const Ee=new Error(se("attachment.invalid_file_type"));z(Ee.message),s?.(Ee),_t?.toast?.error?.(Ee.message);return}M?(H(ce),B(!0)):Ae(ce)},[i,c,s,M,Ae,se]),We=C.useCallback(async()=>{G(!1),L(!0),z(null);try{const ae=pe(),ce=ne(),ke=await fetch(o,{method:"DELETE",headers:{Accept:"application/json","Content-Type":"application/json",...ae&&{"X-XSRF-TOKEN":ae},...ce&&{Authorization:`Bearer ${ce}`}},credentials:"include"});if(!ke.ok){const Ee=await ke.json().catch(()=>({}));throw new Error(Ee.message||se("attachment.delete_failed"))}_(null),l?.(),_t?.toast?.success?.(se("mypage.profile.avatar_deleted")),S?.length?S.forEach(Ee=>_t?.dispatch?.(Ee)):_t?.refetchDataSource?.("user")}catch(ae){const ce=ae instanceof Error?ae:new Error(String(ae));z(ce.message),f?.(ce),_t?.toast?.error?.(ce.message),N?.length&&N.forEach(ke=>_t?.dispatch?.(ke))}finally{L(!1)}},[o,l,f,pe,ne,se]),me=C.useCallback(()=>{x?G(!0):We()},[x,We]),Te=C.useCallback(()=>{G(!1)},[]),ge=C.useCallback(()=>{B(!1),H(null),E.current&&(E.current.value="")},[]),Oe=C.useCallback(()=>{Y&&Ae(Y)},[Y,Ae]),we=U===void 0?e:U,$e=!!we,ze=Cp[r]||"lg",K=F||X,oe=()=>d.jsxs(j,{className:"flex items-center justify-center gap-2",children:[d.jsx(At,{ref:E,id:be,type:"file",accept:c,className:"hidden",onChange:ve,disabled:O}),!$e&&d.jsxs(Ar,{htmlFor:be,className:`inline-flex items-center gap-2 px-4 py-2 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-lg text-sm font-medium hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer ${O?"opacity-50 cursor-not-allowed":""}`,children:[O?d.jsx(fe,{name:"spinner",size:"sm",className:"animate-spin"}):d.jsx(fe,{name:"image",size:"sm"}),d.jsx(te,{children:g||se("mypage.profile.register_avatar")})]}),$e&&d.jsxs(d.Fragment,{children:[d.jsxs(Ar,{htmlFor:be,className:`inline-flex items-center gap-2 px-4 py-2 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-lg text-sm font-medium hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer ${O?"opacity-50 cursor-not-allowed":""}`,children:[O?d.jsx(fe,{name:"spinner",size:"sm",className:"animate-spin"}):d.jsx(fe,{name:"upload",size:"sm"}),d.jsx(te,{children:g||se("common.change")})]}),h&&d.jsxs(R,{type:"button",className:"inline-flex items-center gap-2 px-4 py-2 border border-red-300 dark:border-red-600 text-red-600 dark:text-red-400 rounded-lg text-sm font-medium hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",onClick:me,disabled:P,children:[P?d.jsx(fe,{name:"spinner",size:"sm",className:"animate-spin"}):d.jsx(fe,{name:"trash-2",size:"sm"}),d.jsx(te,{children:p||se("common.delete")})]})]})]});return d.jsxs(j,{className:`flex flex-col items-center gap-3 ${u}`,id:w,...y,children:[X&&W?d.jsxs(j,{className:"relative",children:[d.jsx(jt,{src:W,alt:"Preview",className:`rounded-full object-cover ${r==="sm"?"w-10 h-10":r==="md"?"w-12 h-12":r==="lg"?"w-16 h-16":r==="xl"?"w-24 h-24":"w-32 h-32"}`}),d.jsx(j,{className:"absolute inset-0 rounded-full bg-blue-500/20 border-2 border-blue-500 border-dashed"})]}):d.jsx(Qr,{avatar:we||void 0,name:t,size:ze}),!m&&d.jsxs(j,{className:"w-[220px] flex flex-col items-center gap-2",children:[X&&Y&&d.jsxs(j,{className:"w-full p-3 bg-blue-50 dark:bg-blue-950/50 border border-blue-200 dark:border-blue-800 rounded-lg",children:[d.jsxs(j,{className:"flex items-center gap-2 mb-2",children:[d.jsx(fe,{name:"upload",size:"sm",className:"text-blue-600 dark:text-blue-400 shrink-0"}),d.jsx(te,{className:"text-sm font-medium text-blue-800 dark:text-blue-300",children:v||se("mypage.profile.upload_avatar_confirm")})]}),d.jsxs(j,{className:"text-xs text-blue-600 dark:text-blue-400 truncate mb-3",title:Y.name,children:[Y.name," (",(Y.size/1024/1024).toFixed(2),"MB)"]}),d.jsxs(j,{className:"grid grid-cols-2 gap-2",children:[d.jsxs(R,{type:"button",className:"inline-flex items-center justify-center gap-1.5 px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium transition-colors disabled:opacity-50",onClick:Oe,disabled:O,children:[O?d.jsx(fe,{name:"spinner",size:"sm",className:"animate-spin"}):d.jsx(fe,{name:"check",size:"sm"}),d.jsx(te,{children:se("common.confirm")})]}),d.jsx(R,{type:"button",className:"inline-flex items-center justify-center gap-1.5 px-3 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-md text-sm font-medium hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",onClick:ge,children:d.jsx(te,{children:se("common.cancel")})})]})]}),F&&d.jsxs(j,{className:"w-full p-3 bg-red-50 dark:bg-red-950/50 border border-red-200 dark:border-red-800 rounded-lg",children:[d.jsxs(j,{className:"flex items-center gap-2 mb-2",children:[d.jsx(fe,{name:"alert-triangle",size:"sm",className:"text-red-600 dark:text-red-400 shrink-0"}),d.jsx(te,{className:"text-sm font-medium text-red-800 dark:text-red-300",children:k||se("mypage.profile.delete_avatar_confirm")})]}),d.jsxs(j,{className:"grid grid-cols-2 gap-2",children:[d.jsxs(R,{type:"button",className:"inline-flex items-center justify-center gap-1.5 px-3 py-2 bg-red-600 hover:bg-red-700 text-white rounded-md text-sm font-medium transition-colors disabled:opacity-50",onClick:We,disabled:P,children:[P?d.jsx(fe,{name:"spinner",size:"sm",className:"animate-spin"}):d.jsx(fe,{name:"trash-2",size:"sm"}),d.jsx(te,{children:se("common.delete")})]}),d.jsx(R,{type:"button",className:"inline-flex items-center justify-center gap-1.5 px-3 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-md text-sm font-medium hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",onClick:Te,children:d.jsx(te,{children:se("common.cancel")})})]})]}),!K&&oe()]}),b&&!K&&d.jsxs(j,{className:"flex items-center gap-2 text-sm text-red-600 dark:text-red-400",children:[d.jsx(fe,{name:"alert-circle",size:"sm"}),d.jsx(te,{children:b})]})]})}const _p=Object.freeze(Object.defineProperty({__proto__:null,AvatarUploader:Xa,default:Xa},Symbol.toStringTag,{value:"Module"})),Ic=()=>window.G7Core,co=(e,t)=>window.G7Core?.t?.(e,t)??e,Dc={horizontal:"flex items-center gap-1.5",vertical:"flex flex-col items-start"},Sp=()=>[{key:"view_profile",label:co("userinfo.view_profile"),icon:"user",path:"/users/{{userId}}"},{key:"view_posts",label:co("userinfo.view_posts"),icon:"file-lines",path:"/users/{{userId}}/posts"}],qa=({text:e,title:t})=>e?d.jsx(te,{className:"text-sm text-gray-500 dark:text-gray-400",title:t,children:e}):null,Pc=({author:e,name:t,userId:r,subText:n,subTextTitle:o,isGuest:a=!1,isWithdrawn:s=!1,showDropdown:l=!0,clickable:f=!0,profilePath:h="/users/{userId}",className:c="",layout:i="vertical",text:u,stopPropagation:g=!1,menuItems:p,hideMenuItems:m=[],appendMenuItems:x=[],id:k,editorAttrs:M})=>{const v=r??e?.uuid,T=a||e?.is_guest||!1,I=s||e?.status==="withdrawn",S=I?co("userinfo.withdrawn_user"):u??t??e?.name??"",[N,w]=C.useState(!1),[y,E]=C.useState({top:0,left:0}),O=C.useRef(null),$=C.useRef(null),P=C.useRef(null),L=h.replace("{userId}",String(v??"")),U=`${Dc[i]} ${c}`;C.useEffect(()=>{if(!N)return;const H=Q=>{const be=Q.target,se=O.current?.contains(be),pe=$.current?.contains(be);!se&&!pe&&w(!1)},W=()=>w(!1);return document.addEventListener("mousedown",H),window.addEventListener("scroll",W,!0),window.addEventListener("resize",W),()=>{document.removeEventListener("mousedown",H),window.removeEventListener("scroll",W,!0),window.removeEventListener("resize",W)}},[N]);const _=C.useCallback(()=>{if(p&&p.length>0)return p.filter(Q=>Q.show!==!1);let W=Sp().filter(Q=>!m.includes(Q.key)&&Q.show!==!1);return x&&x.length>0&&(W=[...W,...x.filter(Q=>Q.show!==!1)]),W},[p,m,x]),b=C.useCallback(()=>{if(P.current){const H=P.current.getBoundingClientRect();E({top:H.bottom+4,left:H.left})}},[]),z=C.useCallback((H,W)=>{if(W.stopPropagation(),W.preventDefault(),w(!1),H.onClick)H.onClick();else if(H.path){const Q=H.path.replace(/\{\{userId\}\}/g,String(v??"")),be=Ic();be?.navigate?be.navigate(Q):window.location.href=Q}},[v]),F=C.useCallback(H=>{H.preventDefault(),g&&H.stopPropagation(),!(T||!v)&&(l?(N||b(),w(W=>!W)):f&&Ic()?.navigate?.(L))},[g,T,v,l,N,b,f,L]);if(T||!v)return d.jsxs(j,{className:U,id:k,...M,children:[d.jsxs(j,{className:"flex items-center gap-1.5 text-gray-400 dark:text-gray-500",children:[d.jsx(te,{children:S}),d.jsx(te,{className:"text-xs px-1.5 py-0.5 bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-300 rounded",children:co("userinfo.guest_badge")})]}),d.jsx(qa,{text:n,title:o})]});if(I)return d.jsxs(j,{className:U,id:k,...M,children:[d.jsx(te,{className:"text-gray-400 dark:text-gray-500 line-through",children:S}),d.jsx(qa,{text:n,title:o})]});const G=_(),B=/\btext-\S+/.test(c)?"":"text-gray-900 dark:text-white",Y=l||f?`${B} hover:text-blue-600 dark:hover:text-blue-400 cursor-pointer font-medium`.trim():`${B} font-medium`.trim();return d.jsxs(j,{ref:O,className:`relative inline-block ${c}`,id:k,...M,children:[d.jsxs(j,{className:Dc[i],children:[d.jsx(R,{ref:P,onClick:F,className:Y,children:S}),d.jsx(qa,{text:n,title:o})]}),l&&N&&G.length>0&&tr.createPortal(d.jsx(j,{ref:$,className:"fixed w-40 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1 z-[9999]",style:{top:y.top,left:y.left},"data-testid":"author-dropdown-menu",children:G.map(H=>d.jsxs(R,{onClick:W=>z(H,W),className:"flex items-center justify-start gap-2 w-full text-left px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","data-testid":`menu-item-${H.key}`,children:[H.icon&&d.jsx(fe,{name:H.icon,className:"w-4 h-4"}),d.jsx(te,{children:H.label})]},H.key))}),document.body)]})},Ep=Object.freeze(Object.defineProperty({__proto__:null,UserInfo:Pc},Symbol.toStringTag,{value:"Module"})),Lc=({tabs:e,activeTabId:t,onTabChange:r,variant:n="underline",className:o="",style:a,hiddenTabIds:s=[],mobileBreakpoint:l=768,id:f,editorAttrs:h})=>{const i=window.G7Core?.useResponsive,u=i?.(),g=u?u.width{!v.disabled&&v.id!==t&&r?.(v.id)},m=v=>{const T=v.target.value,I=Number(T),S=typeof T=="string"&&T!==""&&!Number.isNaN(I)?I:T,N=e.find(w=>String(w.id)===String(S));N&&p(N)},x=s.length>0?e.filter(v=>!s.includes(v.id)):e;if(g)return d.jsx(j,{className:`relative ${o}`,style:a,id:f,...h,children:d.jsx(ps,{value:t!==void 0?String(t):"",onChange:m,options:x.map(v=>({value:String(v.id),label:v.badge!==void 0?`${v.label} (${v.badge})`:v.label,disabled:v.disabled})),className:"w-full"})});const k=v=>{const T=v.id===t,I="flex items-center gap-2 px-3 py-2 font-medium text-sm transition-all shrink-0 whitespace-nowrap";if(v.disabled)return`${I} opacity-50 cursor-not-allowed text-gray-400 dark:text-gray-600`;switch(n){case"pills":return T?`${I} bg-blue-600 dark:bg-blue-500 text-white rounded-lg`:`${I} text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg`;case"underline":return T?`${I} text-gray-900 dark:text-white border-b-2 border-gray-900 dark:border-white`:`${I} text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 border-b-2 border-transparent hover:border-gray-300 dark:hover:border-gray-600`;default:return T?`${I} text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/20 border-b-2 border-blue-600 dark:border-blue-400`:`${I} text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700 border-b-2 border-transparent`}},M=n==="underline"?"flex gap-0 border-b border-gray-200 dark:border-gray-700":"flex gap-2";return d.jsx(j,{className:`relative ${o}`,style:a,id:f,...h,children:d.jsx(Zr,{className:M,children:x.map(v=>d.jsxs(R,{type:"button",onClick:()=>p(v),disabled:v.disabled,className:k(v),children:[v.iconName&&d.jsx(fe,{name:v.iconName,size:"sm"}),d.jsx(te,{children:v.label}),v.badge!==void 0&&d.jsx(j,{className:"flex items-center justify-center min-w-5 h-5 px-1.5 bg-red-500 text-white text-xs font-bold rounded-full",children:d.jsx(te,{children:v.badge})})]},v.id))})})},Tp=Object.freeze(Object.defineProperty({__proto__:null,TabNavigation:Lc},Symbol.toStringTag,{value:"Module"})),Ap={Header:()=>Promise.resolve().then(()=>Bd),Footer:()=>Promise.resolve().then(()=>Yd),MobileNav:()=>Promise.resolve().then(()=>Xd),SlotContainer:()=>Promise.resolve().then(()=>Gd),NotificationCenter:()=>Promise.resolve().then(()=>jd),ProductCard:()=>Promise.resolve().then(()=>Iu),BrandMark:()=>Promise.resolve().then(()=>Pu),ImageGallery:()=>Promise.resolve().then(()=>ni),ProductImageViewer:()=>Promise.resolve().then(()=>Gg),QuantitySelector:()=>Promise.resolve().then(()=>jg),PostReactions:()=>Promise.resolve().then(()=>Vg),RichTextEditor:()=>Promise.resolve().then(()=>Kg),HtmlContent:()=>Promise.resolve().then(()=>Yg),HtmlEditor:()=>Promise.resolve().then(()=>Xg),ExpandableContent:()=>Promise.resolve().then(()=>qg),FileUploader:()=>Promise.resolve().then(()=>q0),ConfirmDialog:()=>Promise.resolve().then(()=>Jg),SocialLoginButtons:()=>Promise.resolve().then(()=>Q0),Toast:()=>Promise.resolve().then(()=>rp),PageTransitionIndicator:()=>Promise.resolve().then(()=>op),PageTransitionBlur:()=>Promise.resolve().then(()=>ap),PageSkeleton:()=>Promise.resolve().then(()=>yp),PageLoading:()=>Promise.resolve().then(()=>wp),ThemeToggle:()=>Promise.resolve().then(()=>$d),Pagination:()=>Promise.resolve().then(()=>xp),SearchBar:()=>Promise.resolve().then(()=>kp),Avatar:()=>Promise.resolve().then(()=>zd),AvatarUploader:()=>Promise.resolve().then(()=>_p),UserInfo:()=>Promise.resolve().then(()=>Ep),Modal:()=>Promise.resolve().then(()=>Qg),TabNavigation:()=>Promise.resolve().then(()=>Tp)},Np=({id:e,className:t,style:r,children:n,editorAttrs:o})=>d.jsx(j,{id:e,className:t,style:r,...o,children:n}),Op=({id:e,children:t,cols:r=1,responsive:n,gap:o,rowGap:a,colGap:s,autoRows:l,autoCols:f,flow:h="row",className:c="",style:i,onClick:u,editorAttrs:g})=>{const p=["grid"];if(r&&p.push(`grid-cols-${r}`),n&&(n.sm&&p.push(`sm:grid-cols-${n.sm}`),n.md&&p.push(`md:grid-cols-${n.md}`),n.lg&&p.push(`lg:grid-cols-${n.lg}`),n.xl&&p.push(`xl:grid-cols-${n.xl}`),n["2xl"]&&p.push(`2xl:grid-cols-${n["2xl"]}`)),o!==void 0&&o>0&&p.push(`gap-${o}`),a!==void 0&&a>0&&p.push(`gap-y-${a}`),s!==void 0&&s>0&&p.push(`gap-x-${s}`),l){const x={auto:"auto-rows-auto",min:"auto-rows-min",max:"auto-rows-max",fr:"auto-rows-fr"};p.push(x[l])}if(f){const x={auto:"auto-cols-auto",min:"auto-cols-min",max:"auto-cols-max",fr:"auto-cols-fr"};p.push(x[f])}const m={row:"grid-flow-row",col:"grid-flow-col",dense:"grid-flow-dense","row-dense":"grid-flow-row-dense","col-dense":"grid-flow-col-dense"};return p.push(m[h]),c&&p.push(c),d.jsx(j,{id:e,className:p.join(" "),style:i,onClick:u,...g,children:t})},Mp=({id:e,children:t,direction:r="row",justify:n="start",align:o="stretch",wrap:a="nowrap",gap:s=0,grow:l=!1,shrink:f=!0,className:h="",style:c,onClick:i,editorAttrs:u})=>{const g=["flex"],p={row:"flex-row","row-reverse":"flex-row-reverse",col:"flex-col","col-reverse":"flex-col-reverse"};g.push(p[r]);const m={wrap:"flex-wrap",nowrap:"flex-nowrap","wrap-reverse":"flex-wrap-reverse"};g.push(m[a]);const x={start:"justify-start",end:"justify-end",center:"justify-center",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};g.push(x[n]);const k={start:"items-start",end:"items-end",center:"items-center",baseline:"items-baseline",stretch:"items-stretch"};return g.push(k[o]),s>0&&g.push(`gap-${s}`),l===!0?g.push("flex-grow"):typeof l=="number"&&l>0&&g.push(`flex-grow-${l}`),f===!1?g.push("shrink-0"):f===!0?g.push("flex-shrink"):typeof f=="number"&&f>0&&g.push(`flex-shrink-${f}`),h&&g.push(h),d.jsx(j,{id:e,className:g.join(" "),style:c,onClick:i,...u,children:t})},Ip=({id:e,title:t,subtitle:r,children:n,padding:o="md",background:a="none",maxWidth:s,centered:l=!1,border:f=!1,shadow:h="none",rounded:c=!1,className:i="",style:u,onClick:g,editorAttrs:p})=>{const m=[],x={none:"p-0",sm:"p-2",md:"p-4",lg:"p-6",xl:"p-8"};m.push(x[o]);const k={none:"",white:"bg-white dark:bg-gray-700",gray:"bg-gray-50 dark:bg-gray-800",primary:"bg-blue-50 dark:bg-blue-900/20",secondary:"bg-gray-50 dark:bg-gray-800"};if(a!=="none"&&m.push(k[a]),s){const v={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl","2xl":"max-w-2xl","4xl":"max-w-4xl","6xl":"max-w-6xl","7xl":"max-w-7xl",full:"max-w-full"};m.push(v[s])}l&&m.push("mx-auto"),f&&m.push("border","border-gray-200","dark:border-gray-700");const M={none:"",sm:"shadow-sm",md:"shadow-md",lg:"shadow-lg",xl:"shadow-xl"};return h!=="none"&&m.push(M[h]),c&&m.push("rounded-lg"),i&&m.push(i),d.jsxs(bs,{id:e,className:m.join(" "),style:u,onClick:g,...p,children:[(t||r)&&d.jsxs(j,{className:"mb-4",children:[t&&d.jsx(gs,{className:"text-2xl font-bold text-gray-900 dark:text-white",children:t}),r&&d.jsx(Gt,{className:"mt-1 text-sm text-gray-600 dark:text-gray-400",children:r})]}),n]})},Dp=({id:e,leftWidth:t="250px",rightWidth:r="300px",leftSlot:n,centerSlot:o,rightSlot:a,className:s="",style:l,editorAttrs:f})=>{const h=`flex flex-row w-full h-full ${s}`.trim(),c={width:t,flexShrink:0},i={flex:1,minWidth:0},u={width:r,flexShrink:0};return d.jsxs(j,{id:e,className:h,style:l,...f,children:[d.jsx(j,{className:"flex flex-col",style:c,children:n}),d.jsx(j,{className:"flex flex-col",style:i,children:o}),d.jsx(j,{className:"flex flex-col",style:u,children:a})]})},Pp={identifier:"sirsoft-basic",vendor:"sirsoft",name:{ko:"Basic",en:"Basic"},version:"1.1.3",license:"MIT",description:{ko:"그누보드7 기본 사용자 템플릿",en:"Gnuboard7 default user template"},type:"user",locales:["ko","en"],author:{name:"sirsoft",email:"contact@sirsoft.com",url:"https://sirsoft.com"},release_date:"2026-01-07",g7_version:">=7.0.10",dependencies:{modules:{"sirsoft-board":">=1.0.0","sirsoft-ecommerce":">=1.1.0","sirsoft-page":">=1.1.0"},plugins:{"sirsoft-daum_postcode":">=1.0.0"}},assets:{css:["dist/css/components.css"],js:["dist/js/components.iife.js"],fonts:[],images:[]},components:{basic:["a","button","checkbox","div","form","h1","h2","h3","h4","hr","icon","img","input","label","li","nav","p","section","select","span","svg","table","tbody","td","textarea","th","thead","tr","ul"],composite:["header","footer","mobile-nav","product-card","rich-text-editor","image-gallery","quantity-selector","post-reactions","social-login-buttons","file-uploader","card","modal","toast","pagination","stat-card","status-badge","tab-navigation","empty-state","loading-spinner","breadcrumb","search-bar","dropdown"],layout:["container","flex","grid","section"]},preview:{thumbnail:"preview/thumbnail.png",screenshots:["preview/screenshot1.png","preview/screenshot2.png"]},error_config:{layouts:{401:"errors/401",403:"errors/403",404:"errors/404",500:"errors/500",503:"errors/503",maintenance:"errors/maintenance"}},features:{dark_mode:!0,responsive:!0,multi_language:!0,multi_currency:!0},github_url:"https://github.com/gnuboard/g7-template-sirsoft-basic",github_changelog_url:"https://github.com/gnuboard/g7-template-sirsoft-basic/blob/main/CHANGELOG.md",externals:[{id:"fontawesome",type:"style",asset:"vendor/font-awesome/6.4.0/css/all.inlined.css"},{id:"pretendard",type:"webfont",asset:"vendor/pretendard/1.3.9/pretendard-variable.css"}]},Lp={KRW:0,JPY:0};function $p(){try{const t=(window.G7Core?.state?.get?.()||{})?.modules?.["sirsoft-ecommerce"]?.language_currency;return Array.isArray(t?.currencies)?t.currencies:[]}catch{return[]}}function Kr(e,t){if(!Number.isFinite(e))return"0";const r=$p(),n=t||r.find(a=>a.is_default)?.code;if(!n)return e.toLocaleString();const o=r.find(a=>a.code===n)?.decimal_places??Lp[n]??2;try{return new Intl.NumberFormat(void 0,{style:"currency",currency:n,minimumFractionDigits:o,maximumFractionDigits:o}).format(e)}catch{return`${e.toLocaleString(void 0,{minimumFractionDigits:o,maximumFractionDigits:o})} ${n}`}}function uo(e,t,r,n=0){if(!e)return;const o=f=>f?.value??f?.price??0;let a;for(const[f,h]of Object.entries(e))if(h?.is_default){a=f;break}a=a??(e.KRW?"KRW":void 0);const s=a?o(e[a]):0,l={};for(const[f,h]of Object.entries(e)){const c=o(h);let i;r?i=r[f]?.value??0:n>0&&f===a?i=n:n>0&&s>0?i=n*c/s:i=0;const u=(c+i)*t;l[f]={value:u,formatted:Kr(u,f)}}return l}function fo(e){const t={};for(const n of e){const o=n?.multiCurrencyTotalPrice;if(o)for(const[a,s]of Object.entries(o)){const l=s?.value??s?.price??0;t[a]=(t[a]??0)+l}}const r={};for(const[n,o]of Object.entries(t))r[n]={value:o,formatted:Kr(o,n)};return r}function $c(e,t){if(!e||!t?.length)return 0;let r=0;for(const n of t){const o=e[n.id];if(o==null)continue;const a=n.values?.find(s=>s.id===Number(o));a&&(r+=a.price_adjustment??0)}return r}function Fc(e,t){if(!e||!t?.length)return;const r={};let n=!1;for(const a of t){const s=e[a.id];if(s==null)continue;const f=a.values?.find(h=>h.id===Number(s))?.multi_currency_price_adjustment;if(f){n=!0;for(const[h,c]of Object.entries(f)){const i=c?.value??c?.price??0;r[h]=(r[h]??0)+i}}}if(!n)return;const o={};for(const[a,s]of Object.entries(r))o[a]={value:s};return o}function go(e){return e.name_localized?e.name_localized:typeof e.name=="string"?e.name:e.name?.ko??""}function Fp(e,t,r){if(t&&r in t)return t[r];if(Array.isArray(e)){const n=e.find(o=>typeof o.key=="string"?o.key===r:o.key?.ko===r||Object.values(o.key).includes(r));return n?typeof n.value=="string"?n.value:n.value?.ko??Object.values(n.value)[0]:void 0}return e[r]}function Up(e,t){if(t)return t;if(!Array.isArray(e))return e;const r={};for(const n of e){const o=typeof n.key=="string"?n.key:n.key?.ko??Object.values(n.key)[0]??"",a=typeof n.value=="string"?n.value:n.value?.ko??Object.values(n.value)[0]??"";o&&(r[o]=a)}return r}function zp(e,t,r){return r.find(n=>!n?.option_values||!n?.is_active?!1:e.every(o=>{const a=go(o),s=t?.[a];return Fp(n.option_values,n.option_values_localized,a)===s}))}function Hp(e,t){const r=e.params;if(!r)return;const{optionGroups:n,options:o,selectedOptionItems:a,preferredCurrency:s}=r;let l;if(r.newGroupName&&r.newValue?l={...r.currentSelection??{},[r.newGroupName]:r.newValue}:l=r.currentSelection??{},!n?.every(S=>{const N=go(S);return l?.[N]}))return;const h=zp(n,l,o??[]);if(!h){t.setState?.({currentSelection:{},__mergeMode:"shallow"});return}const c=n.map(S=>l[go(S)]).join("_"),i=a??[];if(i.find(S=>S.id===c)){const S=window.G7Core;S?.toast?.warning?.(S?.t?.("sirsoft-ecommerce.shop.already_added_option")??"이미 추가된 옵션입니다."),t.setState?.({currentSelection:{},__mergeMode:"shallow"});return}const g=h.selling_price??0,p={};n.forEach(S=>{const N=go(S);p[N]=l[N]});const m=r.additionalOptionGroups??[],x={};for(const S of m){if(!S.is_required)continue;const N=S.values?.find(w=>w.is_default);N&&(x[S.id]=N.id)}const k=$c(x,m),M=Fc(x,m),v=g+k,T={id:c,optionId:h.id,options:p,optionValues:Up(h.option_values,h.option_values_localized),quantity:1,stock:h.stock_quantity??999,unitPrice:g,unitPriceFormatted:Kr(g,s),totalPrice:v,totalPriceFormatted:Kr(v,s),multiCurrencyUnitPrice:h.multi_currency_selling_price,multiCurrencyTotalPrice:uo(h.multi_currency_selling_price,1,M,k),additionalOptionSelections:x,additionalOptionsTotal:k,additionalOptionsMultiCurrencyTotal:M},I=[...i,T];t.setState?.({selectedOptionItems:I,selectedTotalMultiCurrency:fo(I),currentSelection:{},__mergeMode:"shallow"})}function Gp(e,t){const r=e.params;if(!r)return;const{selectedOptionItems:n,preferredCurrency:o}=r,a=Number(r.itemIndex)||0,s=Number(r.newQuantity)||1,l=(n??[]).map((f,h)=>{if(h!==a)return f;const c=f?.unitPrice??0,i=f?.additionalOptionsTotal??0,u=(c+i)*s;return{...f,quantity:s,totalPrice:u,totalPriceFormatted:Kr(u,o),multiCurrencyTotalPrice:uo(f?.multiCurrencyUnitPrice,s,f?.additionalOptionsMultiCurrencyTotal,i)}});t.setState?.({selectedOptionItems:l,selectedTotalMultiCurrency:fo(l)})}function jp(e,t){const r=e.params;if(!r)return;const{selectedOptionItems:n,additionalOptionGroups:o,preferredCurrency:a}=r,s=Number(r.itemIndex)||0,l=Number(r.additionalOptionId),f=Object.prototype.hasOwnProperty.call(r,"customText"),h=r.valueId===""||r.valueId==null?null:Number(r.valueId),c=(n??[]).map((i,u)=>{if(u!==s)return i;const g={...i.additionalOptionSelections??{}},p={...i.additionalOptionCustomTexts??{}};if(f){const T=String(r.customText??"");T.trim()===""?delete p[l]:p[l]=T}else h==null?(delete g[l],delete p[l]):(g[l]=h,(o??[]).find(S=>S.id===l)?.values?.find(S=>S.id===h)?.allow_custom_text||delete p[l]);const m=$c(g,o),x=Fc(g,o),k=i?.unitPrice??0,M=i?.quantity??1,v=(k+m)*M;return{...i,additionalOptionSelections:g,additionalOptionCustomTexts:p,additionalOptionsTotal:m,additionalOptionsMultiCurrencyTotal:x,totalPrice:v,totalPriceFormatted:Kr(v,a),multiCurrencyTotalPrice:uo(i?.multiCurrencyUnitPrice,M,x,m)}});t.setState?.({selectedOptionItems:c,selectedTotalMultiCurrency:fo(c)})}function Bp(e,t){const r=e.params;if(!r)return;const n=Number(r.itemIndex)||0,o=(r.selectedOptionItems??[]).filter((a,s)=>s!==n);t.setState?.({selectedOptionItems:o,selectedTotalMultiCurrency:fo(o)})}function Wp(e,t){const r=e.params;if(!r)return;const n=Math.max(1,Number(r.newQuantity)||1);t.setState?.({noOptionQuantity:n,noOptionTotalMultiCurrency:uo(r.multiCurrencyUnitPrice,n)})}const xn=window.G7Core?.createLogger?.("Handler:Cart")??{log:(...e)=>console.log("[Handler:Cart]",...e),warn:(...e)=>console.warn("[Handler:Cart]",...e),error:(...e)=>console.error("[Handler:Cart]",...e)};function kr(e){const t=window.G7Core;t?.state?.setLocal?(t.state.setLocal(e),xn.log("Local state updated:",e)):xn.warn("G7Core.state.setLocal not available")}function Uc(){return window.G7Core?.state?.getLocal?.()||{}}function Vp(){return window.G7Core?.state?.get?.()||{}}function Kp(e,t="info"){const r=window.G7Core;r?.toast?.show?r.toast.show(e,t):xn.warn("G7Core.toast.show not available, message:",e)}function Yp(e){const t=window.G7Core;return t?.t?t.t(e):e}function zc(){const e=window.G7Core;if(e?.dispatch){const r=Uc().selectedItems||[];e.dispatch({handler:"refetchDataSource",params:{dataSourceId:"cartItems"}}),xn.log("Refetching cartItems with selected_ids:",r)}else xn.warn("G7Core.dispatch not available")}function Xp(e,t){const{itemId:r,selectedItems:n}=e?.params||{},o=n||[];let a;o.includes(r)?a=o.filter(h=>h!==r):a=[...o,r];const l=Vp().cartItems?.data?.items||[],f=l.length>0&&a.length===l.length;kr({selectedItems:a,allSelected:f}),zc()}function qp(e,t){const{allItemIds:r,isSelected:n}=e?.params||{};kr({selectedItems:n?r:[],allSelected:n}),zc()}function Zp(e,t){const{optionName:r,optionValue:n}=e?.params||{},a=Uc().selectedOptions||{};kr({selectedOptions:{...a,[r]:n}})}function Qp(e,t){const{targetIds:r}=e?.params||{};if(!r||r.length===0){Kp(Yp("shop.cart.select_items_to_delete"),"warning");return}kr({deleteModal:{visible:!0,targetIds:r}})}function Jp(e,t){const{targetItem:r}=e?.params||{};kr({optionModal:{visible:!0,targetItem:r},selectedOptions:r?.options||{},selectedQuantity:r?.quantity})}function Rp(e,t){const{selectedItems:r}=e?.params||{};if(!r||r.length===0){kr({isCalculating:!1});return}kr({isCalculating:!0})}const Cr=window.G7Core?.createLogger?.("Handler:CartOptionChange")??{log:(...e)=>console.log("[Handler:CartOptionChange]",...e),warn:(...e)=>console.warn("[Handler:CartOptionChange]",...e),error:(...e)=>console.error("[Handler:CartOptionChange]",...e)};function Za(e){return e.name_localized?e.name_localized:typeof e.name=="string"?e.name:e.name?.ko??""}function em(e,t,r){if(t&&r in t)return t[r];if(Array.isArray(e)){const n=e.find(o=>typeof o.key=="string"?o.key===r:o.key?.ko===r||Object.values(o.key).includes(r));return n?typeof n.value=="string"?n.value:n.value?.ko??Object.values(n.value)[0]:void 0}return e[r]}function Hc(e,t,r){return!e||!t?.length?null:t.every(a=>{const s=Za(a);return e[s]})?r?.find(a=>t.every(s=>{const l=Za(s);return em(a.option_values,a.option_values_localized,l)===e[l]}))||null:(Cr.log("Not all options selected yet"),null)}function tm(e,t){const{selectedOptions:r,optionGroups:n,options:o}=e?.params||{};Cr.log("findMatchingOption called:",{selectedOptions:r,optionGroups:n,optionsCount:o?.length});const a=Hc(r,n,o);return Cr.log("Matched option:",a),{matchedOption:a}}function rm(e,t){const{currentOptionValues:r,optionGroups:n,options:o}=e?.params||{};if(Cr.log("initCartOptionSelection called:",{currentOptionValues:r,optionGroups:n,optionsCount:o?.length}),!n?.length||!r)return Cr.log("No option groups or current values, returning empty"),{selectedOptions:{},matchedOption:null};const a={};for(const l of n){const f=Za(l),h=r[f],c=l.values_localized??(Array.isArray(l.values)?l.values.map(i=>typeof i=="string"?i:i?.ko??""):[]);h&&c.includes(h)&&(a[f]=h)}Cr.log("Initial selectedOptions:",a);const s=Hc(a,n,o||[]);return Cr.log("Matched option:",s),{selectedOptions:a,matchedOption:s}}const kn="g7_cart_key",nm="/api/modules/sirsoft-ecommerce/cart/key",Qa="g7_guest_order_token",Gc="g7_guest_order_number",Ja="g7_guest_order_expires_at",ft=window.G7Core?.createLogger?.("Handler:Storage")??{log:(...e)=>console.log("[Handler:Storage]",...e),warn:(...e)=>console.warn("[Handler:Storage]",...e),error:(...e)=>console.error("[Handler:Storage]",...e)};async function jc(){try{const e=await fetch(nm,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"}});return e.ok?(await e.json()).data?.cart_key||null:(ft.error("Failed to issue cartKey from API:",e.status),null)}catch(e){return ft.error("Error issuing cartKey from API:",e),null}}function sr(e){const t=window.G7Core;t?.state?.set?(t.state.set(e),ft.log("Global state updated:",e)):ft.warn("G7Core.state.set not available")}function om(){try{const e=window.G7Config;return e?.user?e.user:(window.G7Core?.state?.get?.()||{}).currentUser||null}catch{return null}}async function am(e,t){let r=null;try{r=localStorage.getItem(kn)}catch{}if(r)ft.log("Existing cartKey loaded:",r);else if(r=await jc(),r)try{localStorage.setItem(kn,r),ft.log("New cartKey issued from API:",r)}catch{}else ft.error("Failed to issue cartKey from API");sr({cartKey:r})}function sm(e,t){try{return localStorage.getItem(kn)}catch{return null}}function Bc(e,t){try{localStorage.removeItem(kn),ft.log("cartKey removed from localStorage")}catch{}sr({cartKey:null})}async function lm(e,t){if(om()){Bc();return}const n=await jc();if(n){try{localStorage.setItem(kn,n),ft.log("New cartKey regenerated from API:",n)}catch{}sr({cartKey:n})}else ft.error("Failed to regenerate cartKey from API")}function im(e,t){const{key:r,value:n}=e?.params||{};if(!r){ft.warn("saveToStorage: key is required");return}try{localStorage.setItem(r,n),ft.log("Saved to storage:",r,n)}catch{}}function cm(e,t){const{key:r,defaultValue:n}=e?.params||{};if(!r)return ft.warn("loadFromStorage: key is required"),n||null;try{return localStorage.getItem(r)||n||null}catch{return n||null}}function Ra(){try{sessionStorage.removeItem(Qa),sessionStorage.removeItem(Gc),sessionStorage.removeItem(Ja)}catch{}}function dm(e,t){let r=null,n=null;try{r=sessionStorage.getItem(Qa),n=sessionStorage.getItem(Ja)}catch{}let o=!1;if(r){const a=n?new Date(n).getTime():NaN;(isNaN(a)||a<=Date.now())&&(Ra(),r=null,o=!0)}if(r){sr({guestOrderToken:r}),ft.log("Guest order token loaded from sessionStorage");return}if(!o){const s=window.G7Core?.state?.get?.("_global")?.guestOrderToken;if(typeof s=="string"&&s!==""){ft.log("Guest order token preserved from in-memory _global (sessionStorage empty)");return}}sr({guestOrderToken:null}),ft.log("No guest order token (visitor not authenticated)")}function um(e,t){const{token:r,orderNumber:n,expiresAt:o}=e?.params||{};if(!r||!n||!o){ft.warn("saveGuestOrderToken: token, orderNumber, expiresAt are required");return}try{sessionStorage.setItem(Qa,r),sessionStorage.setItem(Gc,n),sessionStorage.setItem(Ja,o)}catch{}sr({guestOrderToken:r})}function fm(e,t){Ra(),sr({guestOrderToken:null})}function gm(e,t){Ra(),sr({guestOrderToken:null})}function Wc(e){const t=window.G7Core?.state?.get?.()?.[e];return typeof t=="string"&&t.length>0?t:void 0}function hm(e,t){const r=e?.params??{},{product:n,priceField:o,currencyCode:a}=r,s=a||Wc("preferredCurrency")||Wc("defaultCurrency")||"",l=`multi_currency_${o}`,f=n[l];if(f&&f[s])return f[s].formatted;const h=`${o}_formatted`;return n[h]||String(n[o])}const Vc={KRW:"₩",USD:"$",JPY:"¥",CNY:"元",EUR:"€",GBP:"£"},pm={KRW:0,JPY:0};function Kc(){try{const t=(window.G7Core?.state?.get?.()||{})?.modules?.["sirsoft-ecommerce"]?.language_currency;return Array.isArray(t?.currencies)?t.currencies:[]}catch{return[]}}function Yc(e){const t=window.G7Core?.state?.get?.()?.[e];return typeof t=="string"&&t.length>0?t:void 0}function mm(e,t){const r=e?.params??{},{value:n,currencyCode:o,locale:a}=r,s=Kc(),l=o||Yc("preferredCurrency")||Yc("defaultCurrency")||s.find(u=>u.is_default)?.code;if(!l)return n.toLocaleString(a);const f=s.find(u=>u.code===l),h=f?.symbol&&f.symbol.length>0?f.symbol:Vc[l]??"",c=f?.decimal_places??pm[l]??2,i=n.toLocaleString(a,{minimumFractionDigits:c,maximumFractionDigits:c});return h?l==="KRW"||h==="₩"||h==="원"?`${i}원`:`${h}${i}`:`${i} ${l}`}function bm(e){const t=Kc().find(r=>r.code===e);return t?.symbol&&t.symbol.length>0?t.symbol:Vc[e]||e}const es=window.G7Core?.createLogger?.("Handler:Currency")??{log:(...e)=>console.log("[Handler:Currency]",...e),warn:(...e)=>console.warn("[Handler:Currency]",...e),error:(...e)=>console.error("[Handler:Currency]",...e)},Xc="g7_preferred_currency";function ym(){try{const e=window.G7Core?.state?.get?.()||{};return e.defaultCurrency||e?.modules?.["sirsoft-ecommerce"]?.language_currency?.default_currency||""}catch{return""}}function qc(e){window.G7Core?.state?.set?.({preferredCurrency:e})}function vm(e,t){const r=e?.params??{},{defaultCurrency:n=ym()}=r;let o=n;try{if(typeof window<"u"&&window.localStorage){const a=localStorage.getItem(Xc);a&&Zc(a)&&(o=a)}}catch{es.warn("localStorage 접근 불가, 기본 통화 사용:",n)}return qc(o),o}function wm(e,t){const{currencyCode:r}=e?.params??{};if(!Zc(r)){es.warn("유효하지 않은 통화 코드:",r);return}try{typeof window<"u"&&window.localStorage&&localStorage.setItem(Xc,r)}catch{es.warn("localStorage 저장 실패")}qc(r)}function Zc(e){return typeof e=="string"&&/^[A-Z]{3}$/.test(e)}const Yr=window.G7Core?.createLogger?.("Handler:SetTheme")??{log:(...e)=>console.log("[Handler:SetTheme]",...e),warn:(...e)=>console.warn("[Handler:SetTheme]",...e),error:(...e)=>console.error("[Handler:SetTheme]",...e)},ts=["auto","light","dark"],Qc="g7_color_scheme",xm=e=>e==="auto"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e,ho=e=>{const t=xm(e);document.documentElement.setAttribute("data-theme",t),t==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")};function km(){try{const e=localStorage.getItem(Qc),t=e&&ts.includes(e)?e:"auto";ho(t),Yr.log("Initial theme applied:",t)}catch(e){Yr.warn("Failed to load initial theme:",e),ho("auto")}}async function Cm(e,t){const r=e?.target;if(r&&typeof r=="string"&&ts.includes(r)){ho(r);return}km()}async function _m(e,t){let r;if(e?.target&&typeof e.target=="string"&&!e.target.includes("{{")&&(r=e.target),!r||typeof r!="string"){Yr.warn("Invalid theme:",r);return}if(!ts.includes(r)){Yr.warn("Unsupported theme:",r);return}const n=r;try{localStorage.setItem(Qc,n)}catch(o){Yr.error("Failed to save theme to localStorage:",o);return}ho(n),Yr.log("Theme changed to:",n)}const Sm=window.G7Core?.createLogger?.("Handler:RedirectToLoginWithReturn")??{log:(...e)=>console.log("[Handler:RedirectToLoginWithReturn]",...e),warn:(...e)=>console.warn("[Handler:RedirectToLoginWithReturn]",...e),error:(...e)=>console.error("[Handler:RedirectToLoginWithReturn]",...e)};async function Em(e,t){const r=window.G7Core;if(!r?.dispatch){Sm.error("G7Core.dispatch 가 초기화되지 않아 로그인 리다이렉트를 실행할 수 없습니다.");return}const n=window.location.pathname+window.location.search;await r.dispatch({handler:"navigate",params:{path:"/login",query:{redirect:n}}})}const rs=window.G7Core?.createLogger?.("Handler:DownloadAttachment")??{log:(...e)=>console.log("[Handler:DownloadAttachment]",...e),warn:(...e)=>console.warn("[Handler:DownloadAttachment]",...e),error:(...e)=>console.error("[Handler:DownloadAttachment]",...e)};async function Tm(e,t){const r=window.G7Core,{url:n,filename:o}=e?.params||{};if(!n){rs.warn("다운로드 URL 이 없어 요청을 건너뜁니다.");return}if(!r?.api?.get){rs.error("G7Core.api.get 이 초기화되지 않아 다운로드를 실행할 수 없습니다.");return}try{const a=await r.api.get(n,{responseType:"blob",headers:zn()});if(a){const s=URL.createObjectURL(a),l=document.createElement("a");l.href=s,l.download=o||"",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(s)}}catch(a){rs.error("첨부파일 다운로드 실패",a),r?.toast?.error?.(r?.t?.("common.download_failed")??"Download failed")}}const po={"sirsoft-basic.addSelectedItemIfComplete":Hp,"sirsoft-basic.updateSelectedItemQuantity":Gp,"sirsoft-basic.removeSelectedItem":Bp,"sirsoft-basic.updateNoOptionQuantity":Wp,"sirsoft-basic.setBlockAdditionalOption":jp,"sirsoft-basic.getDisplayPrice":hm,"sirsoft-basic.formatCurrency":mm,"sirsoft-basic.getCurrencySymbol":bm,"sirsoft-basic.loadPreferredCurrency":vm,"sirsoft-basic.savePreferredCurrency":wm,setTheme:_m,initTheme:Cm,redirectToLoginWithReturn:Em,downloadAttachment:Tm,toggleCartItemSelection:Xp,selectAllCartItems:qp,setCartOption:Zp,openCartDeleteModal:Qp,openCartOptionModal:Jp,recalculateCart:Rp,findMatchingOption:tm,initCartOptionSelection:rm,initCartKey:am,getCartKey:sm,clearCartKey:Bc,regenerateCartKey:lm,saveToStorage:im,loadFromStorage:cm,initGuestOrderToken:dm,saveGuestOrderToken:um,clearGuestOrderToken:fm,clearGuestTokenOnEntry:gm},Cn=window.G7Core?.createLogger?.("Template:sirsoft-basic:IdentityLauncher")??{log:(...e)=>console.log("[Template:sirsoft-basic:IdentityLauncher]",...e),warn:(...e)=>console.warn("[Template:sirsoft-basic:IdentityLauncher]",...e),error:(...e)=>console.error("[Template:sirsoft-basic:IdentityLauncher]",...e)};function Am(e){const t=window.G7Core,r=t?.state?.getLocal?.()??{},n=t?.state?.getGlobal?.()??t?.state?.get?.()??{},o=(...f)=>f.find(h=>typeof h=="string"&&h.length>0),a=o(e.target?.email,n?.currentUser?.email,n?.user?.email,n?.auth?.user?.email,e.purpose==="signup"?r?.registerForm?.email:void 0,e.purpose==="password_reset"?r?.passwordResetForm?.email:void 0,e.purpose==="password_reset"?r?.email:void 0),s=o(e.target?.phone,n?.currentUser?.phone,n?.user?.phone,n?.auth?.user?.phone);if(!a&&!s)return null;const l={};return a&&(l.email=a),s&&(l.phone=s),l}function Nm(){const t=window.G7Core?.api?.getToken?.()??null;return t?{Authorization:`Bearer ${t}`}:{}}function Om(){try{const e=typeof window<"u"?window.localStorage?.getItem("g7_locale"):null;return e?{"Accept-Language":e}:{}}catch{return{}}}async function Mm(e,t){const r={purpose:e.purpose};e.provider_id&&(r.provider_id=e.provider_id),t&&(r.target=t);const n=e.challenge_start_url||"/api/identity/challenges",o=await fetch(n,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json",...Om(),...Nm()},body:JSON.stringify(r)}),a=await o.json().catch(()=>null);if(!o.ok||!a?.success){const l=a?.message??`Challenge 시작 실패 (HTTP ${o.status})`;throw new Error(l)}const s=a.data??a;return{id:s.id,expires_at:s.expires_at,render_hint:s.render_hint??e.render_hint??"text_code",public_payload:s.public_payload,redirect_url:s.redirect_url,max_attempts:typeof s.max_attempts=="number"?s.max_attempts:void 0}}async function Im(e){const t=window.G7Core,r=t?.identity;if(!t?.dispatch||!t?.state||!r)return Cn.error("G7Core 또는 G7Core.identity 가 초기화되지 않아 launcher 를 실행할 수 없습니다."),{status:"failed",failureCode:"G7_NOT_READY"};if(e.render_hint==="external_redirect"||e.redirect_url)return r.redirectExternally(e);const n=Am(e);let o;try{o=await Mm(e,n)}catch(p){Cn.error("Challenge 시작 실패:",p);try{await t.dispatch({handler:"toast",params:{type:"error",message:p instanceof Error?p.message:"본인인증 시작에 실패했습니다."}})}catch{}return{status:"failed",failureCode:"CHALLENGE_START_FAILED",reason:p instanceof Error?p.message:String(p)}}if(o.redirect_url)return r.redirectExternally({...e,render_hint:"external_redirect",redirect_url:o.redirect_url});const a=o.expires_at?new Date(o.expires_at).getTime():0,s=a>0?Math.max(0,Math.floor((a-Date.now())/1e3)):0,l=typeof o.max_attempts=="number"?o.max_attempts:0;t.state.set({identityChallenge:{policy_key:e.policy_key,purpose:e.purpose,provider_id:e.provider_id??null,render_hint:o.render_hint,challenge_id:o.id,expires_at:o.expires_at,public_payload:o.public_payload??{},target:n??null,code:"",error:null,attempts:0,maxAttempts:l,remainingSeconds:s,resendCooldown:0}});let f=a,h=0;const c=window.setInterval(()=>{const p=f>0?Math.max(0,Math.floor((f-Date.now())/1e3)):0;h=Math.max(0,h-1),t.state.set({identityChallenge:{remainingSeconds:p,resendCooldown:h}})},1e3);let i=null;try{i=t.state.subscribe?.(p=>{const m=p?.identityChallenge?.expires_at;if(typeof m=="string"){const k=new Date(m).getTime();Number.isFinite(k)&&k!==f&&(f=k)}const x=p?.identityChallenge?.resendCooldown;typeof x=="number"&&x>h&&(h=x)})??null}catch{}const u=r.createDeferred();try{await t.dispatch({handler:"openModal",target:"identity-challenge-modal"})}catch(p){return Cn.error("openModal 실패 — 풀페이지로 폴백:",p),window.clearInterval(c),i?.(),r.redirectExternally({...e,render_hint:"external_redirect",redirect_url:`/identity/challenge?challenge_id=${encodeURIComponent(o.id)}&return=${encodeURIComponent(window.location.href)}`})}const g=await u;return window.clearInterval(c),i?.(),g}function Dm(){const e=window.G7Core?.identity;if(!e?.setLauncher){Cn.warn("G7Core.identity 가 아직 초기화되지 않아 launcher 등록을 건너뜁니다. 코어 부트스트랩 순서를 확인하세요.");return}e.setLauncher(Im),Cn.log("IDV launcher registered (sirsoft-basic)")}const Jc=window.G7Core?.createLogger?.("Template:sirsoft-basic:device")??{log:(...e)=>console.log("[Template:sirsoft-basic:device]",...e),warn:(...e)=>console.warn("[Template:sirsoft-basic:device]",...e)};function Pm(){if(typeof navigator>"u")return!1;const e=navigator,t=(e.userAgent||"").toLowerCase(),r=((e.userAgentData?.platform??e.platform)||"").toLowerCase(),n=e.maxTouchPoints??0;return/iphone|ipad|ipod/.test(t)||/iphone|ipad|ipod|ios/.test(r)?!0:/macintosh|mac os x/.test(t)&&n>1}function Lm(){const e=window.G7Core;if(!e?.state?.get||!e?.state?.set){Jc.warn("G7Core.state not available; skip iOS device correction");return}if(!Pm())return;const r=(e.state.get()||{}).appConfig||{};r.isIos!==!0&&(e.state.set({appConfig:{...r,isIos:!0}}),Jc.log("appConfig.isIos corrected to true by client signals (iPadOS desktop-UA)"))}function $m(e){const t=e.icons;return Array.isArray(t)?t.filter(r=>!!r&&typeof r=="object"&&typeof r.value=="string"):[]}function Fm(e,t){const r=e.label;return typeof r=="string"?r.startsWith("$t:")?t(r.slice(3)):r:e.value}function Um(e,t,r){if(r==="")return!0;const n=r.toLowerCase();return e.value.toLowerCase().includes(n)||t.toLowerCase().includes(n)?!0:(e.keywords??[]).some(o=>o.toLowerCase().includes(n))}function zm({entry:e}){const t=e.preview;return t?.html?d.jsx("span",{className:"g7le-icon-preview",dangerouslySetInnerHTML:{__html:t.html},style:os}):t?.className?d.jsx("span",{className:`g7le-icon-preview ${t.className}`,style:os}):d.jsx("i",{className:`fas fa-${e.value}`,style:os,"aria-hidden":"true"})}function Hm({control:e,value:t,onChange:r,t:n}){const o=$m(e),a=t==null?"":String(t),s=typeof e.iconColumns=="number"?e.iconColumns:6,l=e.iconSearchPlaceholder,f=typeof l=="string"&&l.startsWith("$t:")?n(l.slice(3)):n("layout_editor.icon_picker.search_placeholder"),[h,c]=C.useState("");if(o.length===0)return d.jsx("div",{className:"g7le-widget g7le-widget--icon-picker","data-testid":"g7le-widget-icon-picker",style:Rc,children:d.jsx("input",{type:"text",className:"g7le-widget g7le-widget--icon-free","data-testid":"g7le-widget-icon-picker-free",value:a,placeholder:n("layout_editor.icon_picker.free_input_hint"),onChange:g=>r(g.target.value===""?void 0:g.target.value),style:ed})});const i=g=>Fm(g,n),u=o.filter(g=>Um(g,i(g),h));return d.jsxs("div",{className:"g7le-widget g7le-widget--icon-picker","data-testid":"g7le-widget-icon-picker",style:Rc,children:[d.jsx("input",{type:"text",className:"g7le-widget g7le-widget--icon-search","data-testid":"g7le-widget-icon-picker-search",value:h,placeholder:f,onChange:g=>c(g.target.value),style:ed}),d.jsxs("div",{className:"g7le-icon-grid","data-testid":"g7le-widget-icon-picker-grid",style:{...Gm,gridTemplateColumns:`repeat(${s}, minmax(0, 1fr))`},children:[d.jsx("button",{type:"button","data-testid":"g7le-icon-cell-none",title:n("layout_editor.icon_picker.none"),onClick:()=>r(void 0),"aria-pressed":a==="",style:a===""?td:ns,children:d.jsx("span",{style:jm,children:"—"})}),u.map(g=>{const p=g.value===a;return d.jsx("button",{type:"button","data-testid":`g7le-icon-cell-${g.value}`,title:i(g),"aria-pressed":p,onClick:()=>r(g.value),style:p?td:ns,children:d.jsx(zm,{entry:g})},g.value)})]}),u.length===0&&d.jsx("div",{"data-testid":"g7le-widget-icon-picker-empty",style:Bm,children:n("layout_editor.icon_picker.no_results")})]})}const Rc={display:"flex",flexDirection:"column",gap:6,width:"100%"},ed={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,width:"100%"},Gm={display:"grid",gap:4,maxHeight:220,overflowY:"auto",padding:2},ns={display:"flex",alignItems:"center",justifyContent:"center",minHeight:34,padding:4,border:"1px solid #e2e8f0",borderRadius:6,background:"#fff",cursor:"pointer"},td={...ns,border:"2px solid #2563eb",background:"#eff6ff"},os={display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:16,lineHeight:1},jm={fontSize:10,color:"#475569",fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"100%"},Bm={fontSize:11,color:"#94a3b8",fontStyle:"italic",padding:"4px 2px"},rd=window.G7Core?.createLogger?.("Template:sirsoft-basic:EditorWidgets")??{log:(...e)=>console.log("[Template:sirsoft-basic:EditorWidgets]",...e),warn:(...e)=>console.warn("[Template:sirsoft-basic:EditorWidgets]",...e)};function Wm(){if(typeof window>"u")return;const e=window.G7Core?.layoutEditor;if(!e?.registerWidget){rd.warn("G7Core.layoutEditor 미노출 — icon-picker 위젯 등록 보류");return}e.registerWidget("icon-picker",Hm),rd.log("편집기 위젯 'icon-picker' 등록됨(Font Awesome 검색 그리드)")}const as=window.G7Core?.createLogger?.("Template:sirsoft-basic")??{log:(...e)=>console.log("[Template:sirsoft-basic]",...e),warn:(...e)=>console.warn("[Template:sirsoft-basic]",...e),error:(...e)=>console.error("[Template:sirsoft-basic]",...e)};typeof window<"u"&&(window.G7TemplateHandlers=po);function nd(){if(typeof window<"u"){let e=0;const t=50,r=()=>{const n=window.G7Core?.getActionDispatcher?.();n?(Object.entries(po).forEach(([o,a])=>{n.registerHandler(o,a)}),as.log(`${Object.keys(po).length} custom handler(s) registered:`,Object.keys(po)),Dm(),Lm()):(e++,e<=t?(as.warn(`ActionDispatcher not found, retrying... (${e}/${t})`),setTimeout(r,100)):as.error("Failed to register handlers: ActionDispatcher not available after maximum retries"))};document.readyState==="complete"?r():window.addEventListener("load",r)}}return Wm(),nd(),ee.A=So,ee.Avatar=Qr,ee.AvatarUploader=Xa,ee.BrandMark=zo,ee.Button=R,ee.Checkbox=ms,ee.Code=Dd,ee.ConfirmDialog=wa,ee.Container=Np,ee.Div=j,ee.ExpandableContent=ba,ee.FileInput=ds,ee.FileUploader=lo,ee.Flex=Mp,ee.Footer=Cs,ee.Form=Eo,ee.Grid=Op,ee.H1=xd,ee.H2=gs,ee.H3=Tn,ee.H4=hs,ee.Header=xs,ee.Hr=To,ee.HtmlContent=ha,ee.HtmlEditor=ii,ee.Icon=fe,ee.IconName=nt,ee.ImageGallery=zr,ee.Img=jt,ee.Input=At,ee.Label=Ar,ee.Li=er,ee.MobileNav=_s,ee.Modal=ya,ee.Nav=Zr,ee.NotificationCenter=On,ee.Ol=kd,ee.Optgroup=Ed,ee.Option=Sd,ee.P=Gt,ee.PageLoading=Ac,ee.PageSkeleton=Ya,ee.PageTransitionBlur=Wa,ee.PageTransitionIndicator=Ba,ee.Pagination=Nc,ee.PasswordInput=fs,ee.PostReactions=si,ee.ProductCard=Ws,ee.ProductImageViewer=jn,ee.QuantitySelector=oi,ee.RichTextEditor=li,ee.SearchBar=Mc,ee.Section=bs,ee.SectionLayout=Ip,ee.Select=ps,ee.SlotContainer=Nn,ee.SocialLoginButtons=vc,ee.Span=te,ee.Svg=En,ee.TabNavigation=Lc,ee.Table=Td,ee.Tbody=Nd,ee.Td=Id,ee.Textarea=Co,ee.Th=Md,ee.Thead=Ad,ee.ThemeToggle=An,ee.ThreeColumnLayout=Dp,ee.Toast=ja,ee.Tr=Od,ee.Ul=_o,ee.UserInfo=Pc,ee.availablePasswordRules=ko,ee.compositeComponents=Ap,ee.defaultPasswordRules=us,ee.initTemplate=nd,ee.templateMetadata=Pp,Object.defineProperty(ee,Symbol.toStringTag,{value:"Module"}),ee})({},ReactJSXRuntime,React,ReactDOM); + `})]}):null},sp=Object.freeze(Object.defineProperty({__proto__:null,PageTransitionIndicator:Ba,default:Ba},Symbol.toStringTag,{value:"Module"})),xc=window.G7Core?.createLogger?.("Comp:PageTransitionBlur")??{log:(...e)=>console.log("[Comp:PageTransitionBlur]",...e),warn:(...e)=>console.warn("[Comp:PageTransitionBlur]",...e)},Wa=({className:e="",style:t})=>{const[r,n]=C.useState(!1);return C.useEffect(()=>{const o=window.G7Core?.TransitionManager;if(!o){xc.warn("TransitionManager를 찾을 수 없습니다.");return}return n(o.getIsPending()),o.subscribe(s=>{xc.log("isPending changed:",s),n(s)})},[]),r?d.jsx(j,{className:`fixed inset-0 z-40 bg-white/30 dark:bg-gray-900/30 backdrop-blur-sm transition-opacity duration-150 pointer-events-none ${e}`,style:t,role:"status","aria-label":"페이지 전환 중","data-testid":"page-transition-blur"}):null},lp=Object.freeze(Object.defineProperty({__proto__:null,PageTransitionBlur:Wa,default:Wa},Symbol.toStringTag,{value:"Module"})),kc={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Cc=new Set(["hidden","block","inline-block","inline","flex","inline-flex","grid","inline-grid","table","table-row","table-cell","contents","list-item","flow-root"]),ip=new Set(["Div","Flex","Grid","Section","Article","Nav","Aside","Main","Header","Footer","Fragment","Form","Container"]),cp=new Set(["H1","H2","H3","H4","H5","H6","P","Span","Label","A","Strong","Em","Small","Badge"]),dp=new Set(["Input","Textarea","Select","Checkbox","Radio","Toggle","DatePicker","TagInput","SearchBar"]),up=new Set(["Img","Image","Avatar","AvatarUploader","ImageGallery","ProductImageViewer","FileUploader"]),_c={DataGrid:(e,t)=>d.jsxs("div",{className:"w-full border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",children:[d.jsx("div",{className:`h-10 bg-gray-100 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 ${e}`,children:d.jsxs("div",{className:"flex items-center h-full px-4 gap-8",children:[d.jsx("div",{className:"h-3 w-16 bg-gray-300 dark:bg-gray-600 rounded"}),d.jsx("div",{className:"h-3 w-24 bg-gray-300 dark:bg-gray-600 rounded"}),d.jsx("div",{className:"h-3 w-20 bg-gray-300 dark:bg-gray-600 rounded"}),d.jsx("div",{className:"h-3 w-16 bg-gray-300 dark:bg-gray-600 rounded"})]})}),Array.from({length:t},(r,n)=>d.jsx("div",{className:`h-12 border-b border-gray-100 dark:border-gray-800 ${e}`,style:{animationDelay:`${n*75}ms`},children:d.jsxs("div",{className:"flex items-center h-full px-4 gap-8",children:[d.jsx("div",{className:"h-3 w-12 bg-gray-200 dark:bg-gray-700 rounded"}),d.jsx("div",{className:"h-3 flex-1 bg-gray-200 dark:bg-gray-700 rounded"}),d.jsx("div",{className:"h-3 w-16 bg-gray-100 dark:bg-gray-800 rounded"}),d.jsx("div",{className:"h-3 w-14 bg-gray-100 dark:bg-gray-800 rounded"})]})},n))]}),Pagination:e=>d.jsx("div",{className:"flex justify-center gap-1.5 py-3",children:Array.from({length:5},(t,r)=>d.jsx("div",{className:`w-8 h-8 bg-gray-200 dark:bg-gray-700 rounded ${e}`},r))}),Tabs:e=>d.jsxs("div",{children:[d.jsx("div",{className:"flex gap-4 border-b border-gray-200 dark:border-gray-700 pb-2 mb-3",children:Array.from({length:3},(t,r)=>d.jsx("div",{className:`h-4 w-20 bg-gray-200 dark:bg-gray-700 rounded ${e}`},r))}),d.jsx("div",{className:`h-32 bg-gray-100 dark:bg-gray-800 rounded ${e}`})]}),TabNavigation:e=>d.jsx("div",{className:"flex gap-4 border-b border-gray-200 dark:border-gray-700 pb-2",children:Array.from({length:3},(t,r)=>d.jsx("div",{className:`h-4 w-20 bg-gray-200 dark:bg-gray-700 rounded ${e}`},r))}),ProductCard:e=>d.jsxs("div",{className:"rounded-lg overflow-hidden",children:[d.jsx("div",{className:`h-48 w-full bg-gray-200 dark:bg-gray-700 ${e}`}),d.jsxs("div",{className:"p-3 space-y-2",children:[d.jsx("div",{className:`h-3.5 w-3/4 bg-gray-200 dark:bg-gray-700 rounded ${e}`}),d.jsx("div",{className:`h-4 w-1/3 bg-gray-300 dark:bg-gray-600 rounded ${e}`})]})]}),UserInfo:e=>d.jsx("div",{className:`h-3 w-14 bg-gray-200 dark:bg-gray-700 rounded ${e}`}),QuantitySelector:e=>d.jsx("div",{className:`h-9 w-28 bg-gray-100 dark:bg-gray-800 rounded border border-gray-200 dark:border-gray-700 ${e}`}),Header:e=>d.jsx("header",{className:"bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",children:d.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:d.jsxs("div",{className:"flex items-center justify-between h-16",children:[d.jsxs("div",{className:"flex items-center gap-8",children:[d.jsx("div",{className:`h-8 w-24 bg-gray-200 dark:bg-gray-700 rounded ${e}`}),d.jsx("div",{className:"hidden lg:flex items-center gap-6",children:Array.from({length:4},(t,r)=>d.jsx("div",{className:`h-3.5 w-16 bg-gray-200 dark:bg-gray-700 rounded ${e}`},r))})]}),d.jsx("div",{className:"flex items-center gap-4",children:Array.from({length:3},(t,r)=>d.jsx("div",{className:`h-8 w-8 bg-gray-200 dark:bg-gray-700 rounded-full ${e}`},r))})]})})}),Footer:e=>d.jsx("footer",{className:"bg-white dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700 mt-auto",children:d.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:d.jsxs("div",{className:"flex flex-col items-center gap-4",children:[d.jsx("div",{className:`h-4 w-32 bg-gray-200 dark:bg-gray-700 rounded ${e}`}),d.jsx("div",{className:`h-3 w-48 bg-gray-100 dark:bg-gray-800 rounded ${e}`}),d.jsx("div",{className:"flex gap-3",children:Array.from({length:3},(t,r)=>d.jsx("div",{className:`h-6 w-6 bg-gray-200 dark:bg-gray-700 rounded-full ${e}`},r))}),d.jsx("div",{className:`h-3 w-40 bg-gray-100 dark:bg-gray-800 rounded ${e}`})]})})}),Modal:()=>d.jsx(d.Fragment,{}),Toast:()=>d.jsx(d.Fragment,{}),ConfirmDialog:()=>d.jsx(d.Fragment,{})};function fp(e){if(!e||e.length===0)return[];const t=e.filter(n=>n.if),r=e.filter(n=>!n.if);if(r.length>0&&t.length>0){const n=t.filter(o=>!Sc(o.if));return n.length>1&&gp(n)?[...r,Ec(n)]:[...r,...n]}if(t.length>1&&r.length===0){const n=t.filter(o=>!Sc(o.if));return n.length===0?[]:n.length===1?n:[Ec(n)]}return e}function Sc(e){const t=e.replace(/^\{\{|\}\}$/g,"").trim();return t.startsWith("!")||/\b(hasError|isError|isLoading|error|Error)\b/.test(t)||/===\s*0\s*(\)|\}|$)/.test(t)}function gp(e){if(e.length<2)return!1;const t=[];for(const n of e){const o=(n.if||"").replace(/^\{\{|\}\}$/g,"").trim(),a=o.match(/^(.+?)\s*===\s*['"]/);if(a)t.push(a[1].trim());else{const s=o.match(/(.+?)\s*===\s*['"]/);if(!s)return!1;t.push(s[1].trim())}}const r=t[0];return t.every(n=>n===r)}function Ec(e){return e.reduce((t,r)=>Va(r)>Va(t)?r:t)}function Va(e){return e.children?e.children.length+e.children.reduce((t,r)=>t+Va(r),0):0}function hp(e){return e.includes("{{")?e.replace(/\{\{([^}]+)\}\}/g,(t,r)=>{const n=r.match(/\?[\s]*['"]([^'"]*)['"]\s*:\s*['"]/);return n?n[1]:""}):e}function Ka(e,t){if(!e)return"";let r=e;return r=r.replace(/\b(bg-\S+|text-\S+|border\b|border-\S+|shadow\S*|ring-\S+|outline-\S+|divide-\S+|opacity-\S+|font-\S+|tracking-\S+|leading-\S+|whitespace-\S+|truncate|line-clamp-\S+|underline|no-underline|decoration-\S+|cursor-\S+|hover:\S+|focus:\S+|active:\S+|group-hover:\S+|transition\S*|duration-\S+|ease-\S+|animate-\S+|dark:\S+)\b/g,"").replace(/\s{2,}/g," ").trim(),(t==="Grid"||/\bgrid-cols-\d/.test(r))&&(r=r.replace(/\bgrid-cols-(\d+)/g,(n,o)=>{const a=parseInt(o);return a>4?`grid-cols-${Math.ceil(a/2)}`:`grid-cols-${a}`})),r}function pp(e){const{name:t,props:r}=e;if(!r||!t)return"";const n=[];if(t==="Flex"){n.push("flex");const o=r.direction||"row",a={row:"flex-row","row-reverse":"flex-row-reverse",col:"flex-col","col-reverse":"flex-col-reverse"};a[o]&&n.push(a[o]);const s=r.justify||"start",l={start:"justify-start",end:"justify-end",center:"justify-center",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};l[s]&&n.push(l[s]);const f=r.align||"stretch",h={start:"items-start",end:"items-end",center:"items-center",baseline:"items-baseline",stretch:"items-stretch"};h[f]&&n.push(h[f]);const c=r.wrap||"nowrap",i={wrap:"flex-wrap",nowrap:"flex-nowrap","wrap-reverse":"flex-wrap-reverse"};i[c]&&n.push(i[c]),r.gap&&r.gap>0&&n.push(`gap-${r.gap}`)}if(t==="Grid"){n.push("grid");const o=r.cols||1;if(n.push(`grid-cols-${o}`),r.responsive){const a=r.responsive;a.sm&&n.push(`sm:grid-cols-${a.sm}`),a.md&&n.push(`md:grid-cols-${a.md}`),a.lg&&n.push(`lg:grid-cols-${a.lg}`),a.xl&&n.push(`xl:grid-cols-${a.xl}`),a["2xl"]&&n.push(`2xl:grid-cols-${a["2xl"]}`)}r.gap!==void 0&&r.gap>0&&n.push(`gap-${r.gap}`),r.rowGap!==void 0&&r.rowGap>0&&n.push(`gap-y-${r.rowGap}`),r.colGap!==void 0&&r.colGap>0&&n.push(`gap-x-${r.colGap}`)}return n.join(" ")}function mp(e){switch(e){case"pulse":return"animate-pulse";case"wave":return"animate-pulse";case"none":return"";default:return"animate-pulse"}}function io(e,t,r,n){return!e||e.length===0?[]:fp(e).map((a,s)=>Tc(a,t,r,s,n))}function bp(e,t){const r=e.props?.className||e.className||"";return e.responsive?t>=1024&&e.responsive.desktop?.props?.className?e.responsive.desktop.props.className:t>=768&&e.responsive.tablet?.props?.className?e.responsive.tablet.props.className:r:r}function yp(e,t){const r=e.split(/\s+/).filter(Boolean),n=[],o=[];for(const f of r){const h=f.match(/^(sm|md|lg|xl|2xl):(.+)$/);if(h){const[,c,i]=h;if(Cc.has(i)){n.push({breakpoint:kc[c]||0,display:i});continue}(kc[c]||0)<=t&&o.push(i);continue}if(Cc.has(f)){n.push({breakpoint:0,display:f});continue}o.push(f)}if(n.length===0)return{visible:!0,className:e};n.sort((f,h)=>f.breakpoint-h.breakpoint);let a="";for(const f of n)f.breakpoint<=t&&(a=f.display);a||(a=n[0].display);const s=a!=="hidden",l=s?[a,...o].join(" "):"";return{visible:s,className:l}}function vp(e){const t=e.match(/\bgrid-cols-\[([^\]]+)\]/);if(!t)return{className:e};const r=t[1].replace(/_/g," ");return{className:e.replace(/\bgrid-cols-\[([^\]]+)\]/,"").replace(/\s{2,}/g," ").trim(),style:{gridTemplateColumns:r}}}function Tc(e,t,r,n,o){const{name:a,children:s,iteration:l}=e,f=bp(e,o),h=pp(e),c=h?`${h} ${f}`.trim():f,i=hp(c),u=yp(i,o);if(!a||!u.visible)return null;const g=u.className;if(l)return d.jsx(C.Fragment,{children:Array.from({length:r},(m,x)=>Tc({...e,iteration:void 0},t,r,x,o))},n);if(_c[a])return d.jsx("div",{className:g,children:_c[a](t,r)},n);if(ip.has(a)){const m=Ka(g,a);if(!s||s.length===0){const T=/\b(h-\S|w-\S)/.test(m)?`${m} bg-gray-200 dark:bg-gray-700 rounded ${t}`:`${m} h-3.5 w-full bg-gray-200 dark:bg-gray-700 rounded ${t}`.trim();return d.jsx("div",{className:T},n)}const x=io(s,t,r,o);if(!(x.length>0&&x.some(v=>v!==null)))return null;const M=vp(m);return d.jsx("div",{className:M.className,style:M.style,children:x},n)}const p=Ka(g,a);if(cp.has(a)){const m={H1:"h-7",H2:"h-6",H3:"h-5",H4:"h-5",H5:"h-4",H6:"h-4",P:"h-3.5",Span:"h-3",Label:"h-3",A:"h-3.5",Badge:"h-5 w-16"},x={H1:"w-3/5",H2:"w-2/5",H3:"w-1/3",H4:"w-1/3",H5:"w-1/4",H6:"w-1/4",P:"w-full",Span:"w-1/4",Label:"w-1/4",A:"w-1/3",Strong:"w-1/5",Em:"w-1/4",Small:"w-1/5",Badge:"w-16"},k=m[a]||"h-3.5",M=x[a]||"w-full",v=a.startsWith("H")?"mb-2 mt-1":"mb-1.5";return d.jsx("div",{className:`${k} ${M} bg-gray-200 dark:bg-gray-700 rounded ${t} ${v} ${p}`.trim()},n)}if(dp.has(a))return a==="Textarea"?d.jsx("div",{className:`h-20 w-full bg-gray-100 dark:bg-gray-800 rounded border border-gray-200 dark:border-gray-700 mb-2 ${t}`},n):a==="Checkbox"||a==="Radio"||a==="Toggle"?d.jsx("div",{className:`h-5 w-5 bg-gray-200 dark:bg-gray-700 rounded mb-1.5 ${t}`},n):d.jsx("div",{className:`h-9 w-full bg-gray-100 dark:bg-gray-800 rounded border border-gray-200 dark:border-gray-700 mb-2 ${t}`},n);if(up.has(a))return a==="Avatar"||a==="AvatarUploader"?d.jsx("div",{className:`h-10 w-10 bg-gray-200 dark:bg-gray-700 rounded-full ${t}`},n):a==="ProductImageViewer"?d.jsx("div",{className:`h-80 w-full bg-gray-200 dark:bg-gray-700 rounded ${t}`},n):d.jsx("div",{className:`h-40 w-full bg-gray-200 dark:bg-gray-700 rounded mb-2 ${t}`},n);if(a==="Button"){if(s&&s.length>0){const m=Ka(g,a),x=io(s,t,r,o);if(!(x.length>0&&x.some(T=>T!==null)))return null;const v=/\b(border|rounded|px-\d|py-\d)/.test(f)?"border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50 rounded-lg":"";return d.jsx("div",{className:`${m} ${v}`.trim(),children:x},n)}return d.jsx("div",{className:`h-9 w-24 bg-gray-200 dark:bg-gray-700 rounded ${t}`},n)}return a==="Icon"?d.jsx("div",{className:`h-5 w-5 bg-gray-200 dark:bg-gray-700 rounded ${t}`},n):s&&s.length>0?d.jsx("div",{className:p,children:io(s,t,r,o)},n):d.jsx("div",{className:`h-3.5 w-full bg-gray-200 dark:bg-gray-700 rounded mb-1.5 ${t}`},n)}const Ya=({components:e,options:t})=>{const r=mp(t.animation),o=window.G7Core?.useResponsive,a=o?.(),s=a?a.width:typeof window<"u"?window.innerWidth:1024;return d.jsx("div",{className:"w-full",role:"status","aria-busy":"true","aria-label":"Loading...",children:io(e,r,t.iteration_count,s)})},wp=Object.freeze(Object.defineProperty({__proto__:null,PageSkeleton:Ya,default:Ya},Symbol.toStringTag,{value:"Module"})),xp=(e,t)=>window.G7Core?.t?.(e,t)??e,Ac=({options:e})=>{const t=document.documentElement.classList.contains("dark"),r=t?"rgb(17,24,39)":"rgb(249,250,251)",n=t?"#6b7280":"#9ca3af",o=t?"#9ca3af":"#6b7280";return d.jsxs("div",{style:{position:"absolute",inset:0,zIndex:2147483647,overflow:"hidden",background:r,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-start",paddingTop:"15%",gap:"12px"},children:[d.jsx("div",{style:{width:"32px",height:"32px",border:`3px solid ${n}`,borderTopColor:"transparent",borderRadius:"50%",animation:"g7-spin 0.8s linear infinite"}}),d.jsx("span",{style:{color:o,fontSize:"14px"},children:e?.text||xp("nav.loading")})]})},kp=Object.freeze(Object.defineProperty({__proto__:null,default:Ac},Symbol.toStringTag,{value:"Module"})),Vr=(e,t)=>window.G7Core?.t?.(e,t)??e,Nc=({currentPage:e,totalPages:t,onPageChange:r,maxVisiblePages:n=5,showFirstLast:o=!0,showFirst:a,showLast:s,hasMorePages:l,className:f="",style:h,prevText:c,nextText:i,id:u,editorAttrs:g})=>{const p=t!=null,m=p?t:0,x=p?e{const N=[];if(!p){const w=Math.floor(n/2),y=e<=n?1:e-w;y>1&&(N.push(1),y>2&&N.push("..."));for(let E=y;E<=e;E++)N.push(E);return l&&(N.push(e+1),N.push("...")),N}if(m<=n+2)for(let w=1;w<=m;w++)N.push(w);else{const w=Math.floor(n/2);let y=Math.max(2,e-w),E=Math.min(m-1,e+w);e<=w+1?E=n:e>=m-w&&(y=m-n+1),N.push(1),y>2&&N.push("...");for(let O=y;O<=E;O++)N.push(O);E1&&N.push(m)}return N},[e,m,p,n,l]),T=N=>{N<1||N===e||p&&N>m||r(N)},I=()=>{e>1&&r(e-1)},S=()=>{x&&r(e+1)};return d.jsxs(j,{className:`flex items-center gap-2 ${f}`,style:h,role:"navigation","aria-label":Vr("common.pagination"),id:u,...g,children:[k&&d.jsx(R,{onClick:()=>T(1),disabled:e===1,className:"px-3 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800","aria-label":Vr("common.first_page"),children:"«"}),d.jsx(R,{onClick:I,disabled:e===1,className:"px-3 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800","aria-label":Vr("common.prev_page"),children:c||d.jsx(d.Fragment,{children:"‹"})}),d.jsx(j,{className:"flex items-center gap-1",children:v.map((N,w)=>{if(N==="...")return d.jsx(te,{className:"px-3 py-1 text-sm text-gray-500 dark:text-gray-400",children:"..."},`ellipsis-${w}`);const y=N,E=y===e;return d.jsx(R,{onClick:()=>T(y),className:`px-3 py-1 text-sm border rounded ${E?"bg-blue-500 dark:bg-blue-600 text-white border-blue-500 dark:border-blue-600":"border-gray-300 dark:border-gray-600 hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800"}`,"aria-label":Vr("common.page_n",{n:y}),"aria-current":E?"page":void 0,children:y},y)})}),d.jsx(R,{onClick:S,disabled:!x,className:"px-3 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800","aria-label":Vr("common.next_page"),children:i||d.jsx(d.Fragment,{children:"›"})}),M&&d.jsx(R,{onClick:()=>T(m),disabled:e===m,className:"px-3 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800","aria-label":Vr("common.last_page"),children:"»"})]})},Cp=Object.freeze(Object.defineProperty({__proto__:null,Pagination:Nc},Symbol.toStringTag,{value:"Module"})),Oc=(e,t)=>window.G7Core?.t?.(e,t)??e,Mc=({name:e="search",placeholder:t,value:r,onChange:n,onSubmit:o,showButton:a=!1,suggestions:s=[],onSuggestionClick:l,showSuggestions:f=!1,className:h="",style:c,id:i,editorAttrs:u})=>{const g=t??Oc("common.search_placeholder"),[p,m]=C.useState(""),[x,k]=C.useState(!1),M=C.useRef(null),v=C.useRef(""),T=r!==void 0?r:p,I=f&&x&&s.length>0&&T.length>0;C.useEffect(()=>{r!==void 0&&(v.current=r)},[r]);const S=y=>{const E=y.target.value;m(E),n?.(y),v.current!==""&&E===""&&!y.nativeEvent.inputType&&setTimeout(()=>{const O=M.current?.querySelector("form");O&&O.requestSubmit()},0),v.current=E},N=y=>{m(y.text);const E={target:{value:y.text,name:e}};n?.(E),l?.(y),k(!1)},w=y=>{y.preventDefault(),o?.(y)};return d.jsxs(j,{ref:M,className:`relative ${h}`,style:c,id:i,...u,children:[d.jsx(Eo,{onSubmit:w,className:"relative",children:d.jsxs(j,{className:`relative flex items-center ${a?"gap-2":""}`,children:[d.jsxs(j,{className:"relative flex-1",children:[d.jsx(j,{className:"absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none",children:d.jsx(fe,{name:nt.Search,className:"w-5 h-5 text-gray-400 dark:text-gray-500"})}),d.jsx(At,{type:"search",name:e,value:T,onChange:S,onFocus:()=>k(!0),onBlur:()=>setTimeout(()=>k(!1),200),placeholder:g,className:"w-full pl-10 pr-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white text-sm"})]}),a&&d.jsx(R,{type:"submit",className:"px-4 py-2 bg-gray-800 dark:bg-gray-600 text-white rounded-lg hover:bg-gray-900 dark:hover:bg-gray-500 transition-colors text-sm font-medium cursor-pointer h-[42px]",children:Oc("common.search")})]})}),I&&d.jsx(j,{className:"absolute z-10 w-full mt-2 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg max-h-64 overflow-y-auto",children:s.map(y=>d.jsx(j,{className:"px-4 py-3 hover:bg-gray-50 dark:hover:bg-gray-700 cursor-pointer border-b border-gray-100 dark:border-gray-700 last:border-b-0 transition-colors",onClick:()=>N(y),children:d.jsxs(j,{className:"flex items-center gap-2",children:[d.jsx(fe,{name:nt.Search,className:"w-4 h-4 text-gray-400 dark:text-gray-500"}),d.jsx(te,{className:"text-sm text-gray-700 dark:text-gray-300",children:y.text})]})},y.id))})]})},_p=Object.freeze(Object.defineProperty({__proto__:null,SearchBar:Mc},Symbol.toStringTag,{value:"Module"})),_t=window.G7Core,Sp={sm:"md",md:"lg",lg:"xl",xl:"2xl","2xl":"3xl"};function Xa({src:e,fallbackText:t="U",size:r="lg",uploadEndpoint:n="/api/me/avatar",deleteEndpoint:o="/api/me/avatar",onUploadSuccess:a,onUploadError:s,onDeleteSuccess:l,onDeleteError:f,showDeleteButton:h=!0,accept:c="image/*",maxSize:i=5,className:u="",uploadButtonText:g,deleteButtonText:p,readOnly:m=!1,confirmDelete:x=!0,deleteConfirmMessage:k,confirmUpload:M=!0,uploadConfirmMessage:v,uploadSuccessActions:T,uploadErrorActions:I,deleteSuccessActions:S,deleteErrorActions:N,id:w,editorAttrs:y}){const E=C.useRef(null),[O,$]=C.useState(!1),[P,L]=C.useState(!1),[U,_]=C.useState(void 0),[b,z]=C.useState(null),[F,G]=C.useState(!1),[X,B]=C.useState(!1),[Y,H]=C.useState(null),[W,Q]=C.useState(null),be=C.useRef(`avatar-upload-${Math.random().toString(36).slice(2,11)}`).current;C.useEffect(()=>{if(Y){const ae=URL.createObjectURL(Y);return Q(ae),()=>URL.revokeObjectURL(ae)}else Q(null)},[Y]);const se=C.useCallback(ae=>_t?.t?.(ae)??ae,[]),pe=C.useCallback(()=>{const ae=document.cookie.match(/XSRF-TOKEN=([^;]+)/);return ae?decodeURIComponent(ae[1]):null},[]),ne=C.useCallback(()=>_t?.api?.getToken?.()??null,[]),Ae=C.useCallback(async ae=>{B(!1),H(null),$(!0),z(null);try{const ce=new FormData;ce.append("avatar",ae);const ke=pe(),Ee=ne(),Be=await fetch(n,{method:"POST",headers:{Accept:"application/json",...ke&&{"X-XSRF-TOKEN":ke},...Ee&&{Authorization:`Bearer ${Ee}`}},credentials:"include",body:ce});if(!Be.ok){const Pe=await Be.json().catch(()=>({}));throw new Error(Pe.message||se("attachment.upload_failed"))}const Me=await Be.json(),Ke=Me.data||Me;Ke.avatar&&_(Ke.avatar),a?.(Ke),_t?.toast?.success?.(se("mypage.profile.avatar_uploaded")),T?.length?T.forEach(Pe=>_t?.dispatch?.(Pe)):_t?.refetchDataSource?.("user")}catch(ce){const ke=ce instanceof Error?ce:new Error(String(ce));z(ke.message),s?.(ke),_t?.toast?.error?.(ke.message),I?.length&&I.forEach(Ee=>_t?.dispatch?.(Ee))}finally{$(!1),E.current&&(E.current.value="")}},[n,a,s,pe,ne,se]),ve=C.useCallback(async ae=>{const ce=ae.target.files?.[0];if(!ce)return;z(null);const ke=i*1024*1024;if(ce.size>ke){const Ee=new Error(se("attachment.file_too_large").replace(":max",`${i}MB`));z(Ee.message),s?.(Ee),_t?.toast?.error?.(Ee.message);return}if(c&&!ce.type.match(c.replace("*",".*"))){const Ee=new Error(se("attachment.invalid_file_type"));z(Ee.message),s?.(Ee),_t?.toast?.error?.(Ee.message);return}M?(H(ce),B(!0)):Ae(ce)},[i,c,s,M,Ae,se]),We=C.useCallback(async()=>{G(!1),L(!0),z(null);try{const ae=pe(),ce=ne(),ke=await fetch(o,{method:"DELETE",headers:{Accept:"application/json","Content-Type":"application/json",...ae&&{"X-XSRF-TOKEN":ae},...ce&&{Authorization:`Bearer ${ce}`}},credentials:"include"});if(!ke.ok){const Ee=await ke.json().catch(()=>({}));throw new Error(Ee.message||se("attachment.delete_failed"))}_(null),l?.(),_t?.toast?.success?.(se("mypage.profile.avatar_deleted")),S?.length?S.forEach(Ee=>_t?.dispatch?.(Ee)):_t?.refetchDataSource?.("user")}catch(ae){const ce=ae instanceof Error?ae:new Error(String(ae));z(ce.message),f?.(ce),_t?.toast?.error?.(ce.message),N?.length&&N.forEach(ke=>_t?.dispatch?.(ke))}finally{L(!1)}},[o,l,f,pe,ne,se]),me=C.useCallback(()=>{x?G(!0):We()},[x,We]),Te=C.useCallback(()=>{G(!1)},[]),ge=C.useCallback(()=>{B(!1),H(null),E.current&&(E.current.value="")},[]),Oe=C.useCallback(()=>{Y&&Ae(Y)},[Y,Ae]),we=U===void 0?e:U,$e=!!we,ze=Sp[r]||"lg",K=F||X,oe=()=>d.jsxs(j,{className:"flex items-center justify-center gap-2",children:[d.jsx(At,{ref:E,id:be,type:"file",accept:c,className:"hidden",onChange:ve,disabled:O}),!$e&&d.jsxs(Ar,{htmlFor:be,className:`inline-flex items-center gap-2 px-4 py-2 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-lg text-sm font-medium hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer ${O?"opacity-50 cursor-not-allowed":""}`,children:[O?d.jsx(fe,{name:"spinner",size:"sm",className:"animate-spin"}):d.jsx(fe,{name:"image",size:"sm"}),d.jsx(te,{children:g||se("mypage.profile.register_avatar")})]}),$e&&d.jsxs(d.Fragment,{children:[d.jsxs(Ar,{htmlFor:be,className:`inline-flex items-center gap-2 px-4 py-2 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-lg text-sm font-medium hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer ${O?"opacity-50 cursor-not-allowed":""}`,children:[O?d.jsx(fe,{name:"spinner",size:"sm",className:"animate-spin"}):d.jsx(fe,{name:"upload",size:"sm"}),d.jsx(te,{children:g||se("common.change")})]}),h&&d.jsxs(R,{type:"button",className:"inline-flex items-center gap-2 px-4 py-2 border border-red-300 dark:border-red-600 text-red-600 dark:text-red-400 rounded-lg text-sm font-medium hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",onClick:me,disabled:P,children:[P?d.jsx(fe,{name:"spinner",size:"sm",className:"animate-spin"}):d.jsx(fe,{name:"trash-2",size:"sm"}),d.jsx(te,{children:p||se("common.delete")})]})]})]});return d.jsxs(j,{className:`flex flex-col items-center gap-3 ${u}`,id:w,...y,children:[X&&W?d.jsxs(j,{className:"relative",children:[d.jsx(jt,{src:W,alt:"Preview",className:`rounded-full object-cover ${r==="sm"?"w-10 h-10":r==="md"?"w-12 h-12":r==="lg"?"w-16 h-16":r==="xl"?"w-24 h-24":"w-32 h-32"}`}),d.jsx(j,{className:"absolute inset-0 rounded-full bg-blue-500/20 border-2 border-blue-500 border-dashed"})]}):d.jsx(Qr,{avatar:we||void 0,name:t,size:ze}),!m&&d.jsxs(j,{className:"w-[220px] flex flex-col items-center gap-2",children:[X&&Y&&d.jsxs(j,{className:"w-full p-3 bg-blue-50 dark:bg-blue-950/50 border border-blue-200 dark:border-blue-800 rounded-lg",children:[d.jsxs(j,{className:"flex items-center gap-2 mb-2",children:[d.jsx(fe,{name:"upload",size:"sm",className:"text-blue-600 dark:text-blue-400 shrink-0"}),d.jsx(te,{className:"text-sm font-medium text-blue-800 dark:text-blue-300",children:v||se("mypage.profile.upload_avatar_confirm")})]}),d.jsxs(j,{className:"text-xs text-blue-600 dark:text-blue-400 truncate mb-3",title:Y.name,children:[Y.name," (",(Y.size/1024/1024).toFixed(2),"MB)"]}),d.jsxs(j,{className:"grid grid-cols-2 gap-2",children:[d.jsxs(R,{type:"button",className:"inline-flex items-center justify-center gap-1.5 px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium transition-colors disabled:opacity-50",onClick:Oe,disabled:O,children:[O?d.jsx(fe,{name:"spinner",size:"sm",className:"animate-spin"}):d.jsx(fe,{name:"check",size:"sm"}),d.jsx(te,{children:se("common.confirm")})]}),d.jsx(R,{type:"button",className:"inline-flex items-center justify-center gap-1.5 px-3 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-md text-sm font-medium hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",onClick:ge,children:d.jsx(te,{children:se("common.cancel")})})]})]}),F&&d.jsxs(j,{className:"w-full p-3 bg-red-50 dark:bg-red-950/50 border border-red-200 dark:border-red-800 rounded-lg",children:[d.jsxs(j,{className:"flex items-center gap-2 mb-2",children:[d.jsx(fe,{name:"alert-triangle",size:"sm",className:"text-red-600 dark:text-red-400 shrink-0"}),d.jsx(te,{className:"text-sm font-medium text-red-800 dark:text-red-300",children:k||se("mypage.profile.delete_avatar_confirm")})]}),d.jsxs(j,{className:"grid grid-cols-2 gap-2",children:[d.jsxs(R,{type:"button",className:"inline-flex items-center justify-center gap-1.5 px-3 py-2 bg-red-600 hover:bg-red-700 text-white rounded-md text-sm font-medium transition-colors disabled:opacity-50",onClick:We,disabled:P,children:[P?d.jsx(fe,{name:"spinner",size:"sm",className:"animate-spin"}):d.jsx(fe,{name:"trash-2",size:"sm"}),d.jsx(te,{children:se("common.delete")})]}),d.jsx(R,{type:"button",className:"inline-flex items-center justify-center gap-1.5 px-3 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-md text-sm font-medium hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",onClick:Te,children:d.jsx(te,{children:se("common.cancel")})})]})]}),!K&&oe()]}),b&&!K&&d.jsxs(j,{className:"flex items-center gap-2 text-sm text-red-600 dark:text-red-400",children:[d.jsx(fe,{name:"alert-circle",size:"sm"}),d.jsx(te,{children:b})]})]})}const Ep=Object.freeze(Object.defineProperty({__proto__:null,AvatarUploader:Xa,default:Xa},Symbol.toStringTag,{value:"Module"})),Ic=()=>window.G7Core,co=(e,t)=>window.G7Core?.t?.(e,t)??e,Dc={horizontal:"flex items-center gap-1.5",vertical:"flex flex-col items-start"},Tp=()=>[{key:"view_profile",label:co("userinfo.view_profile"),icon:"user",path:"/users/{{userId}}"},{key:"view_posts",label:co("userinfo.view_posts"),icon:"file-lines",path:"/users/{{userId}}/posts"}],qa=({text:e,title:t})=>e?d.jsx(te,{className:"text-sm text-gray-500 dark:text-gray-400",title:t,children:e}):null,Pc=({author:e,name:t,userId:r,subText:n,subTextTitle:o,isGuest:a=!1,isWithdrawn:s=!1,showDropdown:l=!0,clickable:f=!0,profilePath:h="/users/{userId}",className:c="",layout:i="vertical",text:u,stopPropagation:g=!1,menuItems:p,hideMenuItems:m=[],appendMenuItems:x=[],id:k,editorAttrs:M})=>{const v=r??e?.uuid,T=a||e?.is_guest||!1,I=s||e?.status==="withdrawn",S=I?co("userinfo.withdrawn_user"):u??t??e?.name??"",[N,w]=C.useState(!1),[y,E]=C.useState({top:0,left:0}),O=C.useRef(null),$=C.useRef(null),P=C.useRef(null),L=h.replace("{userId}",String(v??"")),U=`${Dc[i]} ${c}`;C.useEffect(()=>{if(!N)return;const H=Q=>{const be=Q.target,se=O.current?.contains(be),pe=$.current?.contains(be);!se&&!pe&&w(!1)},W=()=>w(!1);return document.addEventListener("mousedown",H),window.addEventListener("scroll",W,!0),window.addEventListener("resize",W),()=>{document.removeEventListener("mousedown",H),window.removeEventListener("scroll",W,!0),window.removeEventListener("resize",W)}},[N]);const _=C.useCallback(()=>{if(p&&p.length>0)return p.filter(Q=>Q.show!==!1);let W=Tp().filter(Q=>!m.includes(Q.key)&&Q.show!==!1);return x&&x.length>0&&(W=[...W,...x.filter(Q=>Q.show!==!1)]),W},[p,m,x]),b=C.useCallback(()=>{if(P.current){const H=P.current.getBoundingClientRect();E({top:H.bottom+4,left:H.left})}},[]),z=C.useCallback((H,W)=>{if(W.stopPropagation(),W.preventDefault(),w(!1),H.onClick)H.onClick();else if(H.path){const Q=H.path.replace(/\{\{userId\}\}/g,String(v??"")),be=Ic();be?.navigate?be.navigate(Q):window.location.href=Q}},[v]),F=C.useCallback(H=>{H.preventDefault(),g&&H.stopPropagation(),!(T||!v)&&(l?(N||b(),w(W=>!W)):f&&Ic()?.navigate?.(L))},[g,T,v,l,N,b,f,L]);if(T||!v)return d.jsxs(j,{className:U,id:k,...M,children:[d.jsxs(j,{className:"flex items-center gap-1.5 text-gray-400 dark:text-gray-500",children:[d.jsx(te,{children:S}),d.jsx(te,{className:"text-xs px-1.5 py-0.5 bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-300 rounded",children:co("userinfo.guest_badge")})]}),d.jsx(qa,{text:n,title:o})]});if(I)return d.jsxs(j,{className:U,id:k,...M,children:[d.jsx(te,{className:"text-gray-400 dark:text-gray-500 line-through",children:S}),d.jsx(qa,{text:n,title:o})]});const G=_(),B=/\btext-\S+/.test(c)?"":"text-gray-900 dark:text-white",Y=l||f?`${B} hover:text-blue-600 dark:hover:text-blue-400 cursor-pointer font-medium`.trim():`${B} font-medium`.trim();return d.jsxs(j,{ref:O,className:`relative inline-block ${c}`,id:k,...M,children:[d.jsxs(j,{className:Dc[i],children:[d.jsx(R,{ref:P,onClick:F,className:Y,children:S}),d.jsx(qa,{text:n,title:o})]}),l&&N&&G.length>0&&tr.createPortal(d.jsx(j,{ref:$,className:"fixed w-40 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1 z-[9999]",style:{top:y.top,left:y.left},"data-testid":"author-dropdown-menu",children:G.map(H=>d.jsxs(R,{onClick:W=>z(H,W),className:"flex items-center justify-start gap-2 w-full text-left px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","data-testid":`menu-item-${H.key}`,children:[H.icon&&d.jsx(fe,{name:H.icon,className:"w-4 h-4"}),d.jsx(te,{children:H.label})]},H.key))}),document.body)]})},Ap=Object.freeze(Object.defineProperty({__proto__:null,UserInfo:Pc},Symbol.toStringTag,{value:"Module"})),Lc=({tabs:e,activeTabId:t,onTabChange:r,variant:n="underline",className:o="",style:a,hiddenTabIds:s=[],mobileBreakpoint:l=768,id:f,editorAttrs:h})=>{const i=window.G7Core?.useResponsive,u=i?.(),g=u?u.width{!v.disabled&&v.id!==t&&r?.(v.id)},m=v=>{const T=v.target.value,I=Number(T),S=typeof T=="string"&&T!==""&&!Number.isNaN(I)?I:T,N=e.find(w=>String(w.id)===String(S));N&&p(N)},x=s.length>0?e.filter(v=>!s.includes(v.id)):e;if(g)return d.jsx(j,{className:`relative ${o}`,style:a,id:f,...h,children:d.jsx(ps,{value:t!==void 0?String(t):"",onChange:m,options:x.map(v=>({value:String(v.id),label:v.badge!==void 0?`${v.label} (${v.badge})`:v.label,disabled:v.disabled})),className:"w-full"})});const k=v=>{const T=v.id===t,I="flex items-center gap-2 px-3 py-2 font-medium text-sm transition-all shrink-0 whitespace-nowrap";if(v.disabled)return`${I} opacity-50 cursor-not-allowed text-gray-400 dark:text-gray-600`;switch(n){case"pills":return T?`${I} bg-blue-600 dark:bg-blue-500 text-white rounded-lg`:`${I} text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg`;case"underline":return T?`${I} text-gray-900 dark:text-white border-b-2 border-gray-900 dark:border-white`:`${I} text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 border-b-2 border-transparent hover:border-gray-300 dark:hover:border-gray-600`;default:return T?`${I} text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/20 border-b-2 border-blue-600 dark:border-blue-400`:`${I} text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700 border-b-2 border-transparent`}},M=n==="underline"?"flex gap-0 border-b border-gray-200 dark:border-gray-700":"flex gap-2";return d.jsx(j,{className:`relative ${o}`,style:a,id:f,...h,children:d.jsx(Zr,{className:M,children:x.map(v=>d.jsxs(R,{type:"button",onClick:()=>p(v),disabled:v.disabled,className:k(v),children:[v.iconName&&d.jsx(fe,{name:v.iconName,size:"sm"}),d.jsx(te,{children:v.label}),v.badge!==void 0&&d.jsx(j,{className:"flex items-center justify-center min-w-5 h-5 px-1.5 bg-red-500 text-white text-xs font-bold rounded-full",children:d.jsx(te,{children:v.badge})})]},v.id))})})},Np=Object.freeze(Object.defineProperty({__proto__:null,TabNavigation:Lc},Symbol.toStringTag,{value:"Module"})),Op={Header:()=>Promise.resolve().then(()=>Vd),Footer:()=>Promise.resolve().then(()=>qd),MobileNav:()=>Promise.resolve().then(()=>Zd),SlotContainer:()=>Promise.resolve().then(()=>Bd),NotificationCenter:()=>Promise.resolve().then(()=>Wd),ProductCard:()=>Promise.resolve().then(()=>Pu),BrandMark:()=>Promise.resolve().then(()=>$u),ImageGallery:()=>Promise.resolve().then(()=>ni),ProductImageViewer:()=>Promise.resolve().then(()=>Bg),QuantitySelector:()=>Promise.resolve().then(()=>Wg),PostReactions:()=>Promise.resolve().then(()=>Yg),RichTextEditor:()=>Promise.resolve().then(()=>Xg),HtmlContent:()=>Promise.resolve().then(()=>qg),HtmlEditor:()=>Promise.resolve().then(()=>Zg),ExpandableContent:()=>Promise.resolve().then(()=>Qg),FileUploader:()=>Promise.resolve().then(()=>Q0),ConfirmDialog:()=>Promise.resolve().then(()=>eh),SocialLoginButtons:()=>Promise.resolve().then(()=>R0),Toast:()=>Promise.resolve().then(()=>op),PageTransitionIndicator:()=>Promise.resolve().then(()=>sp),PageTransitionBlur:()=>Promise.resolve().then(()=>lp),PageSkeleton:()=>Promise.resolve().then(()=>wp),PageLoading:()=>Promise.resolve().then(()=>kp),ThemeToggle:()=>Promise.resolve().then(()=>Ud),Pagination:()=>Promise.resolve().then(()=>Cp),SearchBar:()=>Promise.resolve().then(()=>_p),Avatar:()=>Promise.resolve().then(()=>Gd),AvatarUploader:()=>Promise.resolve().then(()=>Ep),UserInfo:()=>Promise.resolve().then(()=>Ap),Modal:()=>Promise.resolve().then(()=>Rg),TabNavigation:()=>Promise.resolve().then(()=>Np)},Mp=({id:e,className:t,style:r,children:n,editorAttrs:o})=>d.jsx(j,{id:e,className:t,style:r,...o,children:n}),Ip=({id:e,children:t,cols:r=1,responsive:n,gap:o,rowGap:a,colGap:s,autoRows:l,autoCols:f,flow:h="row",className:c="",style:i,onClick:u,editorAttrs:g})=>{const p=["grid"];if(r&&p.push(`grid-cols-${r}`),n&&(n.sm&&p.push(`sm:grid-cols-${n.sm}`),n.md&&p.push(`md:grid-cols-${n.md}`),n.lg&&p.push(`lg:grid-cols-${n.lg}`),n.xl&&p.push(`xl:grid-cols-${n.xl}`),n["2xl"]&&p.push(`2xl:grid-cols-${n["2xl"]}`)),o!==void 0&&o>0&&p.push(`gap-${o}`),a!==void 0&&a>0&&p.push(`gap-y-${a}`),s!==void 0&&s>0&&p.push(`gap-x-${s}`),l){const x={auto:"auto-rows-auto",min:"auto-rows-min",max:"auto-rows-max",fr:"auto-rows-fr"};p.push(x[l])}if(f){const x={auto:"auto-cols-auto",min:"auto-cols-min",max:"auto-cols-max",fr:"auto-cols-fr"};p.push(x[f])}const m={row:"grid-flow-row",col:"grid-flow-col",dense:"grid-flow-dense","row-dense":"grid-flow-row-dense","col-dense":"grid-flow-col-dense"};return p.push(m[h]),c&&p.push(c),d.jsx(j,{id:e,className:p.join(" "),style:i,onClick:u,...g,children:t})},Dp=({id:e,children:t,direction:r="row",justify:n="start",align:o="stretch",wrap:a="nowrap",gap:s=0,grow:l=!1,shrink:f=!0,className:h="",style:c,onClick:i,editorAttrs:u})=>{const g=["flex"],p={row:"flex-row","row-reverse":"flex-row-reverse",col:"flex-col","col-reverse":"flex-col-reverse"};g.push(p[r]);const m={wrap:"flex-wrap",nowrap:"flex-nowrap","wrap-reverse":"flex-wrap-reverse"};g.push(m[a]);const x={start:"justify-start",end:"justify-end",center:"justify-center",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};g.push(x[n]);const k={start:"items-start",end:"items-end",center:"items-center",baseline:"items-baseline",stretch:"items-stretch"};return g.push(k[o]),s>0&&g.push(`gap-${s}`),l===!0?g.push("flex-grow"):typeof l=="number"&&l>0&&g.push(`flex-grow-${l}`),f===!1?g.push("shrink-0"):f===!0?g.push("flex-shrink"):typeof f=="number"&&f>0&&g.push(`flex-shrink-${f}`),h&&g.push(h),d.jsx(j,{id:e,className:g.join(" "),style:c,onClick:i,...u,children:t})},Pp=({id:e,title:t,subtitle:r,children:n,padding:o="md",background:a="none",maxWidth:s,centered:l=!1,border:f=!1,shadow:h="none",rounded:c=!1,className:i="",style:u,onClick:g,editorAttrs:p})=>{const m=[],x={none:"p-0",sm:"p-2",md:"p-4",lg:"p-6",xl:"p-8"};m.push(x[o]);const k={none:"",white:"bg-white dark:bg-gray-700",gray:"bg-gray-50 dark:bg-gray-800",primary:"bg-blue-50 dark:bg-blue-900/20",secondary:"bg-gray-50 dark:bg-gray-800"};if(a!=="none"&&m.push(k[a]),s){const v={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl","2xl":"max-w-2xl","4xl":"max-w-4xl","6xl":"max-w-6xl","7xl":"max-w-7xl",full:"max-w-full"};m.push(v[s])}l&&m.push("mx-auto"),f&&m.push("border","border-gray-200","dark:border-gray-700");const M={none:"",sm:"shadow-sm",md:"shadow-md",lg:"shadow-lg",xl:"shadow-xl"};return h!=="none"&&m.push(M[h]),c&&m.push("rounded-lg"),i&&m.push(i),d.jsxs(bs,{id:e,className:m.join(" "),style:u,onClick:g,...p,children:[(t||r)&&d.jsxs(j,{className:"mb-4",children:[t&&d.jsx(gs,{className:"text-2xl font-bold text-gray-900 dark:text-white",children:t}),r&&d.jsx(Gt,{className:"mt-1 text-sm text-gray-600 dark:text-gray-400",children:r})]}),n]})},Lp=({id:e,leftWidth:t="250px",rightWidth:r="300px",leftSlot:n,centerSlot:o,rightSlot:a,className:s="",style:l,editorAttrs:f})=>{const h=`flex flex-row w-full h-full ${s}`.trim(),c={width:t,flexShrink:0},i={flex:1,minWidth:0},u={width:r,flexShrink:0};return d.jsxs(j,{id:e,className:h,style:l,...f,children:[d.jsx(j,{className:"flex flex-col",style:c,children:n}),d.jsx(j,{className:"flex flex-col",style:i,children:o}),d.jsx(j,{className:"flex flex-col",style:u,children:a})]})},$p={identifier:"sirsoft-basic",vendor:"sirsoft",name:{ko:"Basic",en:"Basic"},version:"1.1.4",license:"MIT",description:{ko:"그누보드7 기본 사용자 템플릿",en:"Gnuboard7 default user template"},type:"user",locales:["ko","en"],author:{name:"sirsoft",email:"contact@sirsoft.com",url:"https://sirsoft.com"},release_date:"2026-01-07",g7_version:">=7.0.11",dependencies:{modules:{"sirsoft-board":">=1.0.0","sirsoft-ecommerce":">=1.1.0","sirsoft-page":">=1.1.0"},plugins:{"sirsoft-daum_postcode":">=1.0.0"}},assets:{css:["dist/css/components.css"],js:["dist/js/components.iife.js"],fonts:[],images:[]},components:{basic:["a","button","checkbox","div","form","h1","h2","h3","h4","hr","icon","img","input","label","li","nav","p","section","select","span","svg","table","tbody","td","textarea","th","thead","tr","ul"],composite:["header","footer","mobile-nav","product-card","rich-text-editor","image-gallery","quantity-selector","post-reactions","social-login-buttons","file-uploader","card","modal","toast","pagination","stat-card","status-badge","tab-navigation","empty-state","loading-spinner","breadcrumb","search-bar","dropdown"],layout:["container","flex","grid","section"]},preview:{thumbnail:"preview/thumbnail.png",screenshots:["preview/screenshot1.png","preview/screenshot2.png"]},error_config:{layouts:{401:"errors/401",403:"errors/403",404:"errors/404",500:"errors/500",503:"errors/503",maintenance:"errors/maintenance"}},features:{dark_mode:!0,responsive:!0,multi_language:!0,multi_currency:!0},github_url:"https://github.com/gnuboard/g7-template-sirsoft-basic",github_changelog_url:"https://github.com/gnuboard/g7-template-sirsoft-basic/blob/main/CHANGELOG.md",externals:[{id:"fontawesome",type:"style",asset:"vendor/font-awesome/6.4.0/css/all.inlined.css"},{id:"pretendard",type:"webfont",asset:"vendor/pretendard/1.3.9/pretendard-variable.css"}]},Fp={KRW:0,JPY:0};function Up(){try{const t=(window.G7Core?.state?.get?.()||{})?.modules?.["sirsoft-ecommerce"]?.language_currency;return Array.isArray(t?.currencies)?t.currencies:[]}catch{return[]}}function Kr(e,t){if(!Number.isFinite(e))return"0";const r=Up(),n=t||r.find(a=>a.is_default)?.code;if(!n)return e.toLocaleString();const o=r.find(a=>a.code===n)?.decimal_places??Fp[n]??2;try{return new Intl.NumberFormat(void 0,{style:"currency",currency:n,minimumFractionDigits:o,maximumFractionDigits:o}).format(e)}catch{return`${e.toLocaleString(void 0,{minimumFractionDigits:o,maximumFractionDigits:o})} ${n}`}}function uo(e,t,r,n=0){if(!e)return;const o=f=>f?.value??f?.price??0;let a;for(const[f,h]of Object.entries(e))if(h?.is_default){a=f;break}a=a??(e.KRW?"KRW":void 0);const s=a?o(e[a]):0,l={};for(const[f,h]of Object.entries(e)){const c=o(h);let i;r?i=r[f]?.value??0:n>0&&f===a?i=n:n>0&&s>0?i=n*c/s:i=0;const u=(c+i)*t;l[f]={value:u,formatted:Kr(u,f)}}return l}function fo(e){const t={};for(const n of e){const o=n?.multiCurrencyTotalPrice;if(o)for(const[a,s]of Object.entries(o)){const l=s?.value??s?.price??0;t[a]=(t[a]??0)+l}}const r={};for(const[n,o]of Object.entries(t))r[n]={value:o,formatted:Kr(o,n)};return r}function $c(e,t){if(!e||!t?.length)return 0;let r=0;for(const n of t){const o=e[n.id];if(o==null)continue;const a=n.values?.find(s=>s.id===Number(o));a&&(r+=a.price_adjustment??0)}return r}function Fc(e,t){if(!e||!t?.length)return;const r={};let n=!1;for(const a of t){const s=e[a.id];if(s==null)continue;const f=a.values?.find(h=>h.id===Number(s))?.multi_currency_price_adjustment;if(f){n=!0;for(const[h,c]of Object.entries(f)){const i=c?.value??c?.price??0;r[h]=(r[h]??0)+i}}}if(!n)return;const o={};for(const[a,s]of Object.entries(r))o[a]={value:s};return o}function go(e){return e.name_localized?e.name_localized:typeof e.name=="string"?e.name:e.name?.ko??""}function zp(e,t,r){if(t&&r in t)return t[r];if(Array.isArray(e)){const n=e.find(o=>typeof o.key=="string"?o.key===r:o.key?.ko===r||Object.values(o.key).includes(r));return n?typeof n.value=="string"?n.value:n.value?.ko??Object.values(n.value)[0]:void 0}return e[r]}function Hp(e,t){if(t)return t;if(!Array.isArray(e))return e;const r={};for(const n of e){const o=typeof n.key=="string"?n.key:n.key?.ko??Object.values(n.key)[0]??"",a=typeof n.value=="string"?n.value:n.value?.ko??Object.values(n.value)[0]??"";o&&(r[o]=a)}return r}function Gp(e,t,r){return r.find(n=>!n?.option_values||!n?.is_active?!1:e.every(o=>{const a=go(o),s=t?.[a];return zp(n.option_values,n.option_values_localized,a)===s}))}function jp(e,t){const r=e.params;if(!r)return;const{optionGroups:n,options:o,selectedOptionItems:a,preferredCurrency:s}=r;let l;if(r.newGroupName&&r.newValue?l={...r.currentSelection??{},[r.newGroupName]:r.newValue}:l=r.currentSelection??{},!n?.every(S=>{const N=go(S);return l?.[N]}))return;const h=Gp(n,l,o??[]);if(!h){t.setState?.({currentSelection:{},__mergeMode:"shallow"});return}const c=n.map(S=>l[go(S)]).join("_"),i=a??[];if(i.find(S=>S.id===c)){const S=window.G7Core;S?.toast?.warning?.(S?.t?.("sirsoft-ecommerce.shop.already_added_option")??"이미 추가된 옵션입니다."),t.setState?.({currentSelection:{},__mergeMode:"shallow"});return}const g=h.selling_price??0,p={};n.forEach(S=>{const N=go(S);p[N]=l[N]});const m=r.additionalOptionGroups??[],x={};for(const S of m){if(!S.is_required)continue;const N=S.values?.find(w=>w.is_default);N&&(x[S.id]=N.id)}const k=$c(x,m),M=Fc(x,m),v=g+k,T={id:c,optionId:h.id,options:p,optionValues:Hp(h.option_values,h.option_values_localized),quantity:1,stock:h.stock_quantity??999,unitPrice:g,unitPriceFormatted:Kr(g,s),totalPrice:v,totalPriceFormatted:Kr(v,s),multiCurrencyUnitPrice:h.multi_currency_selling_price,multiCurrencyTotalPrice:uo(h.multi_currency_selling_price,1,M,k),additionalOptionSelections:x,additionalOptionsTotal:k,additionalOptionsMultiCurrencyTotal:M},I=[...i,T];t.setState?.({selectedOptionItems:I,selectedTotalMultiCurrency:fo(I),currentSelection:{},__mergeMode:"shallow"})}function Bp(e,t){const r=e.params;if(!r)return;const{selectedOptionItems:n,preferredCurrency:o}=r,a=Number(r.itemIndex)||0,s=Number(r.newQuantity)||1,l=(n??[]).map((f,h)=>{if(h!==a)return f;const c=f?.unitPrice??0,i=f?.additionalOptionsTotal??0,u=(c+i)*s;return{...f,quantity:s,totalPrice:u,totalPriceFormatted:Kr(u,o),multiCurrencyTotalPrice:uo(f?.multiCurrencyUnitPrice,s,f?.additionalOptionsMultiCurrencyTotal,i)}});t.setState?.({selectedOptionItems:l,selectedTotalMultiCurrency:fo(l)})}function Wp(e,t){const r=e.params;if(!r)return;const{selectedOptionItems:n,additionalOptionGroups:o,preferredCurrency:a}=r,s=Number(r.itemIndex)||0,l=Number(r.additionalOptionId),f=Object.prototype.hasOwnProperty.call(r,"customText"),h=r.valueId===""||r.valueId==null?null:Number(r.valueId),c=(n??[]).map((i,u)=>{if(u!==s)return i;const g={...i.additionalOptionSelections??{}},p={...i.additionalOptionCustomTexts??{}};if(f){const T=String(r.customText??"");T.trim()===""?delete p[l]:p[l]=T}else h==null?(delete g[l],delete p[l]):(g[l]=h,(o??[]).find(S=>S.id===l)?.values?.find(S=>S.id===h)?.allow_custom_text||delete p[l]);const m=$c(g,o),x=Fc(g,o),k=i?.unitPrice??0,M=i?.quantity??1,v=(k+m)*M;return{...i,additionalOptionSelections:g,additionalOptionCustomTexts:p,additionalOptionsTotal:m,additionalOptionsMultiCurrencyTotal:x,totalPrice:v,totalPriceFormatted:Kr(v,a),multiCurrencyTotalPrice:uo(i?.multiCurrencyUnitPrice,M,x,m)}});t.setState?.({selectedOptionItems:c,selectedTotalMultiCurrency:fo(c)})}function Vp(e,t){const r=e.params;if(!r)return;const n=Number(r.itemIndex)||0,o=(r.selectedOptionItems??[]).filter((a,s)=>s!==n);t.setState?.({selectedOptionItems:o,selectedTotalMultiCurrency:fo(o)})}function Kp(e,t){const r=e.params;if(!r)return;const n=Math.max(1,Number(r.newQuantity)||1);t.setState?.({noOptionQuantity:n,noOptionTotalMultiCurrency:uo(r.multiCurrencyUnitPrice,n)})}const xn=window.G7Core?.createLogger?.("Handler:Cart")??{log:(...e)=>console.log("[Handler:Cart]",...e),warn:(...e)=>console.warn("[Handler:Cart]",...e),error:(...e)=>console.error("[Handler:Cart]",...e)};function kr(e){const t=window.G7Core;t?.state?.setLocal?(t.state.setLocal(e),xn.log("Local state updated:",e)):xn.warn("G7Core.state.setLocal not available")}function Uc(){return window.G7Core?.state?.getLocal?.()||{}}function Yp(){return window.G7Core?.state?.get?.()||{}}function Xp(e,t="info"){const r=window.G7Core;r?.toast?.show?r.toast.show(e,t):xn.warn("G7Core.toast.show not available, message:",e)}function qp(e){const t=window.G7Core;return t?.t?t.t(e):e}function zc(){const e=window.G7Core;if(e?.dispatch){const r=Uc().selectedItems||[];e.dispatch({handler:"refetchDataSource",params:{dataSourceId:"cartItems"}}),xn.log("Refetching cartItems with selected_ids:",r)}else xn.warn("G7Core.dispatch not available")}function Zp(e,t){const{itemId:r,selectedItems:n}=e?.params||{},o=n||[];let a;o.includes(r)?a=o.filter(h=>h!==r):a=[...o,r];const l=Yp().cartItems?.data?.items||[],f=l.length>0&&a.length===l.length;kr({selectedItems:a,allSelected:f}),zc()}function Qp(e,t){const{allItemIds:r,isSelected:n}=e?.params||{};kr({selectedItems:n?r:[],allSelected:n}),zc()}function Jp(e,t){const{optionName:r,optionValue:n}=e?.params||{},a=Uc().selectedOptions||{};kr({selectedOptions:{...a,[r]:n}})}function Rp(e,t){const{targetIds:r}=e?.params||{};if(!r||r.length===0){Xp(qp("shop.cart.select_items_to_delete"),"warning");return}kr({deleteModal:{visible:!0,targetIds:r}})}function em(e,t){const{targetItem:r}=e?.params||{};kr({optionModal:{visible:!0,targetItem:r},selectedOptions:r?.options||{},selectedQuantity:r?.quantity})}function tm(e,t){const{selectedItems:r}=e?.params||{};if(!r||r.length===0){kr({isCalculating:!1});return}kr({isCalculating:!0})}const Cr=window.G7Core?.createLogger?.("Handler:CartOptionChange")??{log:(...e)=>console.log("[Handler:CartOptionChange]",...e),warn:(...e)=>console.warn("[Handler:CartOptionChange]",...e),error:(...e)=>console.error("[Handler:CartOptionChange]",...e)};function Za(e){return e.name_localized?e.name_localized:typeof e.name=="string"?e.name:e.name?.ko??""}function rm(e,t,r){if(t&&r in t)return t[r];if(Array.isArray(e)){const n=e.find(o=>typeof o.key=="string"?o.key===r:o.key?.ko===r||Object.values(o.key).includes(r));return n?typeof n.value=="string"?n.value:n.value?.ko??Object.values(n.value)[0]:void 0}return e[r]}function Hc(e,t,r){return!e||!t?.length?null:t.every(a=>{const s=Za(a);return e[s]})?r?.find(a=>t.every(s=>{const l=Za(s);return rm(a.option_values,a.option_values_localized,l)===e[l]}))||null:(Cr.log("Not all options selected yet"),null)}function nm(e,t){const{selectedOptions:r,optionGroups:n,options:o}=e?.params||{};Cr.log("findMatchingOption called:",{selectedOptions:r,optionGroups:n,optionsCount:o?.length});const a=Hc(r,n,o);return Cr.log("Matched option:",a),{matchedOption:a}}function om(e,t){const{currentOptionValues:r,optionGroups:n,options:o}=e?.params||{};if(Cr.log("initCartOptionSelection called:",{currentOptionValues:r,optionGroups:n,optionsCount:o?.length}),!n?.length||!r)return Cr.log("No option groups or current values, returning empty"),{selectedOptions:{},matchedOption:null};const a={};for(const l of n){const f=Za(l),h=r[f],c=l.values_localized??(Array.isArray(l.values)?l.values.map(i=>typeof i=="string"?i:i?.ko??""):[]);h&&c.includes(h)&&(a[f]=h)}Cr.log("Initial selectedOptions:",a);const s=Hc(a,n,o||[]);return Cr.log("Matched option:",s),{selectedOptions:a,matchedOption:s}}const kn="g7_cart_key",am="/api/modules/sirsoft-ecommerce/cart/key",Qa="g7_guest_order_token",Gc="g7_guest_order_number",Ja="g7_guest_order_expires_at",ft=window.G7Core?.createLogger?.("Handler:Storage")??{log:(...e)=>console.log("[Handler:Storage]",...e),warn:(...e)=>console.warn("[Handler:Storage]",...e),error:(...e)=>console.error("[Handler:Storage]",...e)};async function jc(){try{const e=await fetch(am,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"}});return e.ok?(await e.json()).data?.cart_key||null:(ft.error("Failed to issue cartKey from API:",e.status),null)}catch(e){return ft.error("Error issuing cartKey from API:",e),null}}function sr(e){const t=window.G7Core;t?.state?.set?(t.state.set(e),ft.log("Global state updated:",e)):ft.warn("G7Core.state.set not available")}function sm(){try{const e=window.G7Config;return e?.user?e.user:(window.G7Core?.state?.get?.()||{}).currentUser||null}catch{return null}}async function lm(e,t){let r=null;try{r=localStorage.getItem(kn)}catch{}if(r)ft.log("Existing cartKey loaded:",r);else if(r=await jc(),r)try{localStorage.setItem(kn,r),ft.log("New cartKey issued from API:",r)}catch{}else ft.error("Failed to issue cartKey from API");sr({cartKey:r})}function im(e,t){try{return localStorage.getItem(kn)}catch{return null}}function Bc(e,t){try{localStorage.removeItem(kn),ft.log("cartKey removed from localStorage")}catch{}sr({cartKey:null})}async function cm(e,t){if(sm()){Bc();return}const n=await jc();if(n){try{localStorage.setItem(kn,n),ft.log("New cartKey regenerated from API:",n)}catch{}sr({cartKey:n})}else ft.error("Failed to regenerate cartKey from API")}function dm(e,t){const{key:r,value:n}=e?.params||{};if(!r){ft.warn("saveToStorage: key is required");return}try{localStorage.setItem(r,n),ft.log("Saved to storage:",r,n)}catch{}}function um(e,t){const{key:r,defaultValue:n}=e?.params||{};if(!r)return ft.warn("loadFromStorage: key is required"),n||null;try{return localStorage.getItem(r)||n||null}catch{return n||null}}function Ra(){try{sessionStorage.removeItem(Qa),sessionStorage.removeItem(Gc),sessionStorage.removeItem(Ja)}catch{}}function fm(e,t){let r=null,n=null;try{r=sessionStorage.getItem(Qa),n=sessionStorage.getItem(Ja)}catch{}let o=!1;if(r){const a=n?new Date(n).getTime():NaN;(isNaN(a)||a<=Date.now())&&(Ra(),r=null,o=!0)}if(r){sr({guestOrderToken:r}),ft.log("Guest order token loaded from sessionStorage");return}if(!o){const s=window.G7Core?.state?.get?.("_global")?.guestOrderToken;if(typeof s=="string"&&s!==""){ft.log("Guest order token preserved from in-memory _global (sessionStorage empty)");return}}sr({guestOrderToken:null}),ft.log("No guest order token (visitor not authenticated)")}function gm(e,t){const{token:r,orderNumber:n,expiresAt:o}=e?.params||{};if(!r||!n||!o){ft.warn("saveGuestOrderToken: token, orderNumber, expiresAt are required");return}try{sessionStorage.setItem(Qa,r),sessionStorage.setItem(Gc,n),sessionStorage.setItem(Ja,o)}catch{}sr({guestOrderToken:r})}function hm(e,t){Ra(),sr({guestOrderToken:null})}function pm(e,t){Ra(),sr({guestOrderToken:null})}function Wc(e){const t=window.G7Core?.state?.get?.()?.[e];return typeof t=="string"&&t.length>0?t:void 0}function mm(e,t){const r=e?.params??{},{product:n,priceField:o,currencyCode:a}=r,s=a||Wc("preferredCurrency")||Wc("defaultCurrency")||"",l=`multi_currency_${o}`,f=n[l];if(f&&f[s])return f[s].formatted;const h=`${o}_formatted`;return n[h]||String(n[o])}const Vc={KRW:"₩",USD:"$",JPY:"¥",CNY:"元",EUR:"€",GBP:"£"},bm={KRW:0,JPY:0};function Kc(){try{const t=(window.G7Core?.state?.get?.()||{})?.modules?.["sirsoft-ecommerce"]?.language_currency;return Array.isArray(t?.currencies)?t.currencies:[]}catch{return[]}}function Yc(e){const t=window.G7Core?.state?.get?.()?.[e];return typeof t=="string"&&t.length>0?t:void 0}function ym(e,t){const r=e?.params??{},{value:n,currencyCode:o,locale:a}=r,s=Kc(),l=o||Yc("preferredCurrency")||Yc("defaultCurrency")||s.find(u=>u.is_default)?.code;if(!l)return n.toLocaleString(a);const f=s.find(u=>u.code===l),h=f?.symbol&&f.symbol.length>0?f.symbol:Vc[l]??"",c=f?.decimal_places??bm[l]??2,i=n.toLocaleString(a,{minimumFractionDigits:c,maximumFractionDigits:c});return h?l==="KRW"||h==="₩"||h==="원"?`${i}원`:`${h}${i}`:`${i} ${l}`}function vm(e){const t=Kc().find(r=>r.code===e);return t?.symbol&&t.symbol.length>0?t.symbol:Vc[e]||e}const es=window.G7Core?.createLogger?.("Handler:Currency")??{log:(...e)=>console.log("[Handler:Currency]",...e),warn:(...e)=>console.warn("[Handler:Currency]",...e),error:(...e)=>console.error("[Handler:Currency]",...e)},Xc="g7_preferred_currency";function wm(){try{const e=window.G7Core?.state?.get?.()||{};return e.defaultCurrency||e?.modules?.["sirsoft-ecommerce"]?.language_currency?.default_currency||""}catch{return""}}function qc(e){window.G7Core?.state?.set?.({preferredCurrency:e})}function xm(e,t){const r=e?.params??{},{defaultCurrency:n=wm()}=r;let o=n;try{if(typeof window<"u"&&window.localStorage){const a=localStorage.getItem(Xc);a&&Zc(a)&&(o=a)}}catch{es.warn("localStorage 접근 불가, 기본 통화 사용:",n)}return qc(o),o}function km(e,t){const{currencyCode:r}=e?.params??{};if(!Zc(r)){es.warn("유효하지 않은 통화 코드:",r);return}try{typeof window<"u"&&window.localStorage&&localStorage.setItem(Xc,r)}catch{es.warn("localStorage 저장 실패")}qc(r)}function Zc(e){return typeof e=="string"&&/^[A-Z]{3}$/.test(e)}const Yr=window.G7Core?.createLogger?.("Handler:SetTheme")??{log:(...e)=>console.log("[Handler:SetTheme]",...e),warn:(...e)=>console.warn("[Handler:SetTheme]",...e),error:(...e)=>console.error("[Handler:SetTheme]",...e)},ts=["auto","light","dark"],Qc="g7_color_scheme",Cm=e=>e==="auto"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e,ho=e=>{const t=Cm(e);document.documentElement.setAttribute("data-theme",t),t==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")};function _m(){try{const e=localStorage.getItem(Qc),t=e&&ts.includes(e)?e:"auto";ho(t),Yr.log("Initial theme applied:",t)}catch(e){Yr.warn("Failed to load initial theme:",e),ho("auto")}}async function Sm(e,t){const r=e?.target;if(r&&typeof r=="string"&&ts.includes(r)){ho(r);return}_m()}async function Em(e,t){let r;if(e?.target&&typeof e.target=="string"&&!e.target.includes("{{")&&(r=e.target),!r||typeof r!="string"){Yr.warn("Invalid theme:",r);return}if(!ts.includes(r)){Yr.warn("Unsupported theme:",r);return}const n=r;try{localStorage.setItem(Qc,n)}catch(o){Yr.error("Failed to save theme to localStorage:",o);return}ho(n),Yr.log("Theme changed to:",n)}const Tm=window.G7Core?.createLogger?.("Handler:RedirectToLoginWithReturn")??{log:(...e)=>console.log("[Handler:RedirectToLoginWithReturn]",...e),warn:(...e)=>console.warn("[Handler:RedirectToLoginWithReturn]",...e),error:(...e)=>console.error("[Handler:RedirectToLoginWithReturn]",...e)};async function Am(e,t){const r=window.G7Core;if(!r?.dispatch){Tm.error("G7Core.dispatch 가 초기화되지 않아 로그인 리다이렉트를 실행할 수 없습니다.");return}const n=window.location.pathname+window.location.search;await r.dispatch({handler:"navigate",params:{path:"/login",query:{redirect:n}}})}const rs=window.G7Core?.createLogger?.("Handler:DownloadAttachment")??{log:(...e)=>console.log("[Handler:DownloadAttachment]",...e),warn:(...e)=>console.warn("[Handler:DownloadAttachment]",...e),error:(...e)=>console.error("[Handler:DownloadAttachment]",...e)};async function Nm(e,t){const r=window.G7Core,{url:n,filename:o}=e?.params||{};if(!n){rs.warn("다운로드 URL 이 없어 요청을 건너뜁니다.");return}if(!r?.api?.get){rs.error("G7Core.api.get 이 초기화되지 않아 다운로드를 실행할 수 없습니다.");return}try{const a=await r.api.get(n,{responseType:"blob",headers:zn()});if(a){const s=URL.createObjectURL(a),l=document.createElement("a");l.href=s,l.download=o||"",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(s)}}catch(a){rs.error("첨부파일 다운로드 실패",a),r?.toast?.error?.(r?.t?.("common.download_failed")??"Download failed")}}const po={"sirsoft-basic.addSelectedItemIfComplete":jp,"sirsoft-basic.updateSelectedItemQuantity":Bp,"sirsoft-basic.removeSelectedItem":Vp,"sirsoft-basic.updateNoOptionQuantity":Kp,"sirsoft-basic.setBlockAdditionalOption":Wp,"sirsoft-basic.getDisplayPrice":mm,"sirsoft-basic.formatCurrency":ym,"sirsoft-basic.getCurrencySymbol":vm,"sirsoft-basic.loadPreferredCurrency":xm,"sirsoft-basic.savePreferredCurrency":km,setTheme:Em,initTheme:Sm,redirectToLoginWithReturn:Am,downloadAttachment:Nm,toggleCartItemSelection:Zp,selectAllCartItems:Qp,setCartOption:Jp,openCartDeleteModal:Rp,openCartOptionModal:em,recalculateCart:tm,findMatchingOption:nm,initCartOptionSelection:om,initCartKey:lm,getCartKey:im,clearCartKey:Bc,regenerateCartKey:cm,saveToStorage:dm,loadFromStorage:um,initGuestOrderToken:fm,saveGuestOrderToken:gm,clearGuestOrderToken:hm,clearGuestTokenOnEntry:pm},Cn=window.G7Core?.createLogger?.("Template:sirsoft-basic:IdentityLauncher")??{log:(...e)=>console.log("[Template:sirsoft-basic:IdentityLauncher]",...e),warn:(...e)=>console.warn("[Template:sirsoft-basic:IdentityLauncher]",...e),error:(...e)=>console.error("[Template:sirsoft-basic:IdentityLauncher]",...e)};function Om(e){const t=window.G7Core,r=t?.state?.getLocal?.()??{},n=t?.state?.getGlobal?.()??t?.state?.get?.()??{},o=(...f)=>f.find(h=>typeof h=="string"&&h.length>0),a=o(e.target?.email,n?.currentUser?.email,n?.user?.email,n?.auth?.user?.email,e.purpose==="signup"?r?.registerForm?.email:void 0,e.purpose==="password_reset"?r?.passwordResetForm?.email:void 0,e.purpose==="password_reset"?r?.email:void 0),s=o(e.target?.phone,n?.currentUser?.phone,n?.user?.phone,n?.auth?.user?.phone);if(!a&&!s)return null;const l={};return a&&(l.email=a),s&&(l.phone=s),l}function Mm(){const t=window.G7Core?.api?.getToken?.()??null;return t?{Authorization:`Bearer ${t}`}:{}}function Im(){try{const e=typeof window<"u"?window.localStorage?.getItem("g7_locale"):null;return e?{"Accept-Language":e}:{}}catch{return{}}}async function Dm(e,t){const r={purpose:e.purpose};e.provider_id&&(r.provider_id=e.provider_id),t&&(r.target=t);const n=e.challenge_start_url||"/api/identity/challenges",o=await fetch(n,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json",...Im(),...Mm()},body:JSON.stringify(r)}),a=await o.json().catch(()=>null);if(!o.ok||!a?.success){const l=a?.message??`Challenge 시작 실패 (HTTP ${o.status})`;throw new Error(l)}const s=a.data??a;return{id:s.id,expires_at:s.expires_at,render_hint:s.render_hint??e.render_hint??"text_code",public_payload:s.public_payload,redirect_url:s.redirect_url,max_attempts:typeof s.max_attempts=="number"?s.max_attempts:void 0}}async function Pm(e){const t=window.G7Core,r=t?.identity;if(!t?.dispatch||!t?.state||!r)return Cn.error("G7Core 또는 G7Core.identity 가 초기화되지 않아 launcher 를 실행할 수 없습니다."),{status:"failed",failureCode:"G7_NOT_READY"};if(e.render_hint==="external_redirect"||e.redirect_url)return r.redirectExternally(e);const n=Om(e);let o;try{o=await Dm(e,n)}catch(p){Cn.error("Challenge 시작 실패:",p);try{await t.dispatch({handler:"toast",params:{type:"error",message:p instanceof Error?p.message:"본인인증 시작에 실패했습니다."}})}catch{}return{status:"failed",failureCode:"CHALLENGE_START_FAILED",reason:p instanceof Error?p.message:String(p)}}if(o.redirect_url)return r.redirectExternally({...e,render_hint:"external_redirect",redirect_url:o.redirect_url});const a=o.expires_at?new Date(o.expires_at).getTime():0,s=a>0?Math.max(0,Math.floor((a-Date.now())/1e3)):0,l=typeof o.max_attempts=="number"?o.max_attempts:0;t.state.set({identityChallenge:{policy_key:e.policy_key,purpose:e.purpose,provider_id:e.provider_id??null,render_hint:o.render_hint,challenge_id:o.id,expires_at:o.expires_at,public_payload:o.public_payload??{},target:n??null,code:"",error:null,attempts:0,maxAttempts:l,remainingSeconds:s,resendCooldown:0}});let f=a,h=0;const c=window.setInterval(()=>{const p=f>0?Math.max(0,Math.floor((f-Date.now())/1e3)):0;h=Math.max(0,h-1),t.state.set({identityChallenge:{remainingSeconds:p,resendCooldown:h}})},1e3);let i=null;try{i=t.state.subscribe?.(p=>{const m=p?.identityChallenge?.expires_at;if(typeof m=="string"){const k=new Date(m).getTime();Number.isFinite(k)&&k!==f&&(f=k)}const x=p?.identityChallenge?.resendCooldown;typeof x=="number"&&x>h&&(h=x)})??null}catch{}const u=r.createDeferred();try{await t.dispatch({handler:"openModal",target:"identity-challenge-modal"})}catch(p){return Cn.error("openModal 실패 — 풀페이지로 폴백:",p),window.clearInterval(c),i?.(),r.redirectExternally({...e,render_hint:"external_redirect",redirect_url:`/identity/challenge?challenge_id=${encodeURIComponent(o.id)}&return=${encodeURIComponent(window.location.href)}`})}const g=await u;return window.clearInterval(c),i?.(),g}function Lm(){const e=window.G7Core?.identity;if(!e?.setLauncher){Cn.warn("G7Core.identity 가 아직 초기화되지 않아 launcher 등록을 건너뜁니다. 코어 부트스트랩 순서를 확인하세요.");return}e.setLauncher(Pm),Cn.log("IDV launcher registered (sirsoft-basic)")}const Jc=window.G7Core?.createLogger?.("Template:sirsoft-basic:device")??{log:(...e)=>console.log("[Template:sirsoft-basic:device]",...e),warn:(...e)=>console.warn("[Template:sirsoft-basic:device]",...e)};function $m(){if(typeof navigator>"u")return!1;const e=navigator,t=(e.userAgent||"").toLowerCase(),r=((e.userAgentData?.platform??e.platform)||"").toLowerCase(),n=e.maxTouchPoints??0;return/iphone|ipad|ipod/.test(t)||/iphone|ipad|ipod|ios/.test(r)?!0:/macintosh|mac os x/.test(t)&&n>1}function Fm(){const e=window.G7Core;if(!e?.state?.get||!e?.state?.set){Jc.warn("G7Core.state not available; skip iOS device correction");return}if(!$m())return;const r=(e.state.get()||{}).appConfig||{};r.isIos!==!0&&(e.state.set({appConfig:{...r,isIos:!0}}),Jc.log("appConfig.isIos corrected to true by client signals (iPadOS desktop-UA)"))}function Um(e){const t=e.icons;return Array.isArray(t)?t.filter(r=>!!r&&typeof r=="object"&&typeof r.value=="string"):[]}function zm(e,t){const r=e.label;return typeof r=="string"?r.startsWith("$t:")?t(r.slice(3)):r:e.value}function Hm(e,t,r){if(r==="")return!0;const n=r.toLowerCase();return e.value.toLowerCase().includes(n)||t.toLowerCase().includes(n)?!0:(e.keywords??[]).some(o=>o.toLowerCase().includes(n))}function Gm({entry:e}){const t=e.preview;return t?.html?d.jsx("span",{className:"g7le-icon-preview",dangerouslySetInnerHTML:{__html:t.html},style:os}):t?.className?d.jsx("span",{className:`g7le-icon-preview ${t.className}`,style:os}):d.jsx("i",{className:`fas fa-${e.value}`,style:os,"aria-hidden":"true"})}function jm({control:e,value:t,onChange:r,t:n}){const o=Um(e),a=t==null?"":String(t),s=typeof e.iconColumns=="number"?e.iconColumns:6,l=e.iconSearchPlaceholder,f=typeof l=="string"&&l.startsWith("$t:")?n(l.slice(3)):n("layout_editor.icon_picker.search_placeholder"),[h,c]=C.useState("");if(o.length===0)return d.jsx("div",{className:"g7le-widget g7le-widget--icon-picker","data-testid":"g7le-widget-icon-picker",style:Rc,children:d.jsx("input",{type:"text",className:"g7le-widget g7le-widget--icon-free","data-testid":"g7le-widget-icon-picker-free",value:a,placeholder:n("layout_editor.icon_picker.free_input_hint"),onChange:g=>r(g.target.value===""?void 0:g.target.value),style:ed})});const i=g=>zm(g,n),u=o.filter(g=>Hm(g,i(g),h));return d.jsxs("div",{className:"g7le-widget g7le-widget--icon-picker","data-testid":"g7le-widget-icon-picker",style:Rc,children:[d.jsx("input",{type:"text",className:"g7le-widget g7le-widget--icon-search","data-testid":"g7le-widget-icon-picker-search",value:h,placeholder:f,onChange:g=>c(g.target.value),style:ed}),d.jsxs("div",{className:"g7le-icon-grid","data-testid":"g7le-widget-icon-picker-grid",style:{...Bm,gridTemplateColumns:`repeat(${s}, minmax(0, 1fr))`},children:[d.jsx("button",{type:"button","data-testid":"g7le-icon-cell-none",title:n("layout_editor.icon_picker.none"),onClick:()=>r(void 0),"aria-pressed":a==="",style:a===""?td:ns,children:d.jsx("span",{style:Wm,children:"—"})}),u.map(g=>{const p=g.value===a;return d.jsx("button",{type:"button","data-testid":`g7le-icon-cell-${g.value}`,title:i(g),"aria-pressed":p,onClick:()=>r(g.value),style:p?td:ns,children:d.jsx(Gm,{entry:g})},g.value)})]}),u.length===0&&d.jsx("div",{"data-testid":"g7le-widget-icon-picker-empty",style:Vm,children:n("layout_editor.icon_picker.no_results")})]})}const Rc={display:"flex",flexDirection:"column",gap:6,width:"100%"},ed={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,width:"100%"},Bm={display:"grid",gap:4,maxHeight:220,overflowY:"auto",padding:2},ns={display:"flex",alignItems:"center",justifyContent:"center",minHeight:34,padding:4,border:"1px solid #e2e8f0",borderRadius:6,background:"#fff",cursor:"pointer"},td={...ns,border:"2px solid #2563eb",background:"#eff6ff"},os={display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:16,lineHeight:1},Wm={fontSize:10,color:"#475569",fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"100%"},Vm={fontSize:11,color:"#94a3b8",fontStyle:"italic",padding:"4px 2px"},rd=window.G7Core?.createLogger?.("Template:sirsoft-basic:EditorWidgets")??{log:(...e)=>console.log("[Template:sirsoft-basic:EditorWidgets]",...e),warn:(...e)=>console.warn("[Template:sirsoft-basic:EditorWidgets]",...e)};function Km(){if(typeof window>"u")return;const e=window.G7Core?.layoutEditor;if(!e?.registerWidget){rd.warn("G7Core.layoutEditor 미노출 — icon-picker 위젯 등록 보류");return}e.registerWidget("icon-picker",jm),rd.log("편집기 위젯 'icon-picker' 등록됨(Font Awesome 검색 그리드)")}const as=window.G7Core?.createLogger?.("Template:sirsoft-basic")??{log:(...e)=>console.log("[Template:sirsoft-basic]",...e),warn:(...e)=>console.warn("[Template:sirsoft-basic]",...e),error:(...e)=>console.error("[Template:sirsoft-basic]",...e)};typeof window<"u"&&(window.G7TemplateHandlers=po);function nd(){if(typeof window<"u"){let e=0;const t=50,r=()=>{const n=window.G7Core?.getActionDispatcher?.();n?(Object.entries(po).forEach(([o,a])=>{n.registerHandler(o,a)}),as.log(`${Object.keys(po).length} custom handler(s) registered:`,Object.keys(po)),Lm(),Fm()):(e++,e<=t?(as.warn(`ActionDispatcher not found, retrying... (${e}/${t})`),setTimeout(r,100)):as.error("Failed to register handlers: ActionDispatcher not available after maximum retries"))};document.readyState==="complete"?r():window.addEventListener("load",r)}}return Km(),nd(),ee.A=So,ee.Avatar=Qr,ee.AvatarUploader=Xa,ee.BrandMark=zo,ee.Button=R,ee.Checkbox=ms,ee.Code=Ld,ee.ConfirmDialog=wa,ee.Container=Mp,ee.Div=j,ee.ExpandableContent=ba,ee.FileInput=ds,ee.FileUploader=lo,ee.Flex=Dp,ee.Footer=Cs,ee.Form=Eo,ee.Grid=Ip,ee.H1=Cd,ee.H2=gs,ee.H3=Tn,ee.H4=hs,ee.Header=xs,ee.Hr=To,ee.HtmlContent=ha,ee.HtmlEditor=ii,ee.Icon=fe,ee.IconName=nt,ee.ImageGallery=zr,ee.Img=jt,ee.Input=At,ee.Label=Ar,ee.Li=er,ee.MobileNav=_s,ee.Modal=ya,ee.Nav=Zr,ee.NotificationCenter=On,ee.Ol=_d,ee.Optgroup=Ad,ee.Option=Td,ee.P=Gt,ee.PageLoading=Ac,ee.PageSkeleton=Ya,ee.PageTransitionBlur=Wa,ee.PageTransitionIndicator=Ba,ee.Pagination=Nc,ee.PasswordInput=fs,ee.PostReactions=si,ee.ProductCard=Ws,ee.ProductImageViewer=jn,ee.QuantitySelector=oi,ee.RichTextEditor=li,ee.SearchBar=Mc,ee.Section=bs,ee.SectionLayout=Pp,ee.Select=ps,ee.SlotContainer=Nn,ee.SocialLoginButtons=vc,ee.Span=te,ee.Svg=En,ee.TabNavigation=Lc,ee.Table=Nd,ee.Tbody=Md,ee.Td=Pd,ee.Textarea=Co,ee.Th=Dd,ee.Thead=Od,ee.ThemeToggle=An,ee.ThreeColumnLayout=Lp,ee.Toast=ja,ee.Tr=Id,ee.Ul=_o,ee.UserInfo=Pc,ee.availablePasswordRules=ko,ee.compositeComponents=Op,ee.defaultPasswordRules=us,ee.initTemplate=nd,ee.templateMetadata=$p,Object.defineProperty(ee,Symbol.toStringTag,{value:"Module"}),ee})({},ReactJSXRuntime,React,ReactDOM); diff --git a/templates/_bundled/sirsoft-basic/src/components/basic/Img.tsx b/templates/_bundled/sirsoft-basic/src/components/basic/Img.tsx index c4ecd711..fecc640c 100644 --- a/templates/_bundled/sirsoft-basic/src/components/basic/Img.tsx +++ b/templates/_bundled/sirsoft-basic/src/components/basic/Img.tsx @@ -2,18 +2,50 @@ import React from 'react'; export interface ImgProps extends React.ImgHTMLAttributes {} +/** + * `image` 위젯 값 객체의 키 집합 — 레이아웃 편집기가 만들던 `{url,size,repeat,position}`. + * + * 편집기는 이제 단일 값 슬롯에 url 문자열만 기록하고(코어 변환 계층), 이미 잘못 저장된 + * 레이아웃은 업그레이드 스텝이 정정한다. 이 상수는 **업그레이드 전 화면**을 위한 + * 런타임 방어이며, 판정 강도를 백필과 **완전히 같게** 유지한다 — 두 방어선의 기준이 + * 어긋나면 한쪽만 통과하는 값이 생긴다. + */ +const IMAGE_VALUE_KEYS = ['url', 'size', 'repeat', 'position'] as const; + +/** + * `src` 로 들어온 값에서 실제 이미지 URL 을 해석한다. + * + * 문자열이면 그대로(회귀 0). 이미지 값 객체(키 집합 ⊆ 4키 **AND** `url` 보유)면 그 url. + * 그 외(배열·숫자·불리언·4키 밖 키를 가진 객체·비문자열 url)는 `undefined` 를 돌려주어 + * `src` 속성을 **아예 붙이지 않는다** — `src="[object Object]"`(엑박)도 + * `src=""`(현재 문서 재요청)도 만들지 않는다. + * + * `ImgProps` 를 넓히지 않는다(`src?: string` 계약 유지) — export 하면 그 자체가 공개 + * 계약이 되어 느슨한 타입이 다시 새어 나간다. + */ +function resolveImageSrc(src: unknown): string | undefined { + if (typeof src === 'string') return src === '' ? undefined : src; + if (!src || typeof src !== 'object' || Array.isArray(src)) return undefined; + const keys = Object.keys(src as Record); + if (!keys.every((k) => (IMAGE_VALUE_KEYS as readonly string[]).includes(k))) return undefined; + const url = (src as { url?: unknown }).url; + return typeof url === 'string' && url !== '' ? url : undefined; +} + /** * 기본 이미지 컴포넌트 */ export const Img: React.FC = ({ className = '', alt = '', + src, ...props }) => { return ( {alt} ); diff --git a/templates/_bundled/sirsoft-basic/src/components/basic/__tests__/Img.test.tsx b/templates/_bundled/sirsoft-basic/src/components/basic/__tests__/Img.test.tsx new file mode 100644 index 00000000..2c707416 --- /dev/null +++ b/templates/_bundled/sirsoft-basic/src/components/basic/__tests__/Img.test.tsx @@ -0,0 +1,116 @@ +// @scenario apply_type=propValue, consumer=img_src, storage_scope=template_layouts, stored_shape=string, widget_output=scalar_string +// @scenario apply_type=propValue, consumer=mobilenav_logo, storage_scope=template_layouts, stored_shape=absent, widget_output=image_object +/** + * Img.test.tsx — `src` 값 형태 방어 (공개 #135 런타임 방어선) + * + * 레이아웃 편집기의 `image` 위젯은 `{url,size,repeat,position}` 객체를 내보내는데, + * 그 값이 `propValue` 로 컴포넌트 prop 에 그대로 기록되던 시기가 있었다. 그렇게 저장된 + * 레이아웃은 `` 가 되어 브라우저가 `[object Object]` 를 URL 로 해석했고, + * SPA catch-all 때문에 404 조차 아니라 200(HTML)을 받아 **엑박만 남고 아무 오류도 + * 남지 않았다.** + * + * 편집기·백필이 고쳐졌어도 업그레이드 전 화면은 그대로이므로 이 방어가 필요하다. + * 판정 강도는 백필 마이그레이션과 **완전히 같다**(키 집합 ⊆ 4키 AND url 문자열) — + * 두 방어선의 기준이 어긋나면 한쪽만 통과하는 값이 생긴다. + */ + +import { describe, it, expect } from 'vitest'; +import { render } from '@testing-library/react'; +import React from 'react'; +import { Img } from '../Img'; + +/** 렌더된 의 src 속성 원문(미부착이면 null) */ +function srcAttr(container: HTMLElement): string | null { + const img = container.querySelector('img'); + expect(img).toBeTruthy(); + return img!.getAttribute('src'); +} + +describe('Img — src 값 형태 방어', () => { + /** @effects img_string_src_passes_through_unchanged */ + it('1 정상 문자열은 그대로 통과한다 (회귀 0)', () => { + const { container } = render(); + expect(srcAttr(container)).toBe('/img/logo.png'); + }); + + /** @effects img_corrupted_value_attaches_no_src_neither_object_object_nor_empty_string */ + it('2 빈 문자열은 src 를 붙이지 않는다 (현재 문서 재요청 차단)', () => { + const { container } = render(); + expect(srcAttr(container)).toBeNull(); + }); + + it('3 src 미전달도 예외 없이 미부착', () => { + const { container } = render(x); + expect(srcAttr(container)).toBeNull(); + }); + + /** @effects img_image_value_object_resolves_to_its_url */ + it('4 이미지 값 객체(4키 전부) → url 만 채택', () => { + const value = { + url: '/api/attachment/X', + size: 'cover', + repeat: 'no-repeat', + position: 'center', + }; + const { container } = render(); + expect(srcAttr(container)).toBe('/api/attachment/X'); + }); + + it('5 부분 키(url 만) 객체도 채택', () => { + const { container } = render(); + expect(srcAttr(container)).toBe('/a.png'); + }); + + it('6 url 이 빈 문자열이면 미부착 — [object Object] 도 빈 문자열도 아니다', () => { + const { container } = render( + , + ); + expect(srcAttr(container)).toBeNull(); + }); + + it('7 url 키가 없는 객체는 미부착 (정상 props 와 정적 구분 불가 → 건드리지 않는다)', () => { + const { container } = render( + , + ); + expect(srcAttr(container)).toBeNull(); + }); + + it('8 url 이 비문자열이면 미부착', () => { + const { container } = render(); + expect(srcAttr(container)).toBeNull(); + }); + + /** @effects img_object_with_key_outside_the_four_is_rejected_same_strictness_as_backfill */ + it('9 4키 밖 키가 섞이면 미부착 — 백필과 동일 엄격도', () => { + const { container } = render(); + expect(srcAttr(container)).toBeNull(); + }); + + it('10 배열은 미부착', () => { + const { container } = render(); + expect(srcAttr(container)).toBeNull(); + }); + + it('11 숫자·불리언은 예외 없이 미부착', () => { + expect(srcAttr(render().container)).toBeNull(); + expect(srcAttr(render().container)).toBeNull(); + }); + + /** @effects img_other_attributes_pass_through_spread_regression_zero */ + it('12 다른 속성은 그대로 통과한다 (스프레드 회귀 0)', () => { + const { container } = render( + 로고, + ); + const img = container.querySelector('img')!; + expect(img.getAttribute('src')).toBe('/a.png'); + expect(img.getAttribute('alt')).toBe('로고'); + expect(img.getAttribute('class')).toBe('h-8'); + expect(img.getAttribute('loading')).toBe('lazy'); + expect(img.getAttribute('width')).toBe('32'); + }); + + it('13 alt 기본값은 빈 문자열로 유지된다', () => { + const { container } = render(); + expect(container.querySelector('img')!.getAttribute('alt')).toBe(''); + }); +}); diff --git a/tests/Feature/Upgrades/Upgrade7011ImageObjectPropBackfillTest.php b/tests/Feature/Upgrades/Upgrade7011ImageObjectPropBackfillTest.php new file mode 100644 index 00000000..d7f73682 --- /dev/null +++ b/tests/Feature/Upgrades/Upgrade7011ImageObjectPropBackfillTest.php @@ -0,0 +1,698 @@ +` 를 받던 결함(공개 #135)의 기존 데이터 보정. + * + * 검증 축은 셋이다: + * ① **판정식 엄격도** — 느슨한 판정식(4키 중 하나라도)을 쓰면 정상 props 를 파괴한다. + * 케이스 9·10·11·14 가 그 반증 가드다. + * ② **순회 범위** — prop 자리는 키 allowlist 로 정의 불가하므로 모드 플래그 전역 재귀. + * 중첩 노드·responsive 분기·확장 injections 가 포섭되고 style 자리는 배제된다. + * ③ **안전성** — 멱등 / 무변경 행 UPDATE 금지 / chunkById / lock_version / + * original_content_hash 불변 / 버전·미리보기 스냅샷 미개입. + */ +class Upgrade7011ImageObjectPropBackfillTest extends TestCase +{ + use RefreshDatabase; + + /** 청크 크기(100) 를 넘겨야 OFFSET 누락이 드러난다 — Beta2LayoutHashBackfillTest 관례 계승 */ + private const SEED_COUNT = 250; + + private NarrowImageObjectPropsInLayouts $migration; + + private UpgradeContext $context; + + private int $templateId; + + protected function setUp(): void + { + parent::setUp(); + + // upgrade data 파일은 composer autoload 대상이 아니며 AbstractUpgradeStep 이 + // 실행 시점에 require_once 로 수동 로드한다. 테스트에서도 동일하게 수동 로드. + require_once base_path('upgrades/data/7.0.11/migrations/01_NarrowImageObjectPropsInLayouts.php'); + + $this->migration = new NarrowImageObjectPropsInLayouts; + $this->context = new UpgradeContext( + fromVersion: '7.0.10', + toVersion: '7.0.11', + currentStep: '7.0.11', + ); + + $this->templateId = DB::table('templates')->insertGetId([ + 'identifier' => 'test-imgobj_template', + 'vendor' => 'test', + 'name' => json_encode(['ko' => '이미지 축약 테스트', 'en' => 'Image Narrow Test']), + 'version' => '1.0.0', + 'type' => 'user', + 'status' => 'active', + 'created_at' => now(), + 'updated_at' => now(), + ]); + } + + /** 완전한 4키 이미지 값 객체 */ + private function imageValue(string $url = '/api/attachment/X'): array + { + return ['url' => $url, 'size' => 'cover', 'repeat' => 'no-repeat', 'position' => 'center']; + } + + /** + * 레이아웃 1건을 시드하고 id 를 돌려줍니다. + * + * @param array $content 레이아웃 content 배열 + * @param array $extra 추가 컬럼 오버라이드 + * @return int 생성된 레이아웃 id + */ + private function seedLayout(array $content, array $extra = []): int + { + static $seq = 0; + $seq++; + + return DB::table('template_layouts')->insertGetId(array_merge([ + 'template_id' => $this->templateId, + 'name' => 'imgobj/layout_'.$seq, + 'content' => json_encode($content, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), + 'source_type' => 'template', + 'source_identifier' => 'test-imgobj_template', + 'lock_version' => 0, + 'created_at' => now(), + 'updated_at' => now(), + ], $extra)); + } + + /** 저장된 content 를 배열로 되읽는다 */ + private function readContent(int $id, string $table = 'template_layouts'): array + { + return json_decode(DB::table($table)->where('id', $id)->value('content'), true); + } + + private function runMigration(): void + { + $this->migration->run($this->context); + } + + /** + * 로거를 감시 대역으로 바꾼 컨텍스트로 마이그레이션을 실행합니다. + * + * 파괴적 동작(prop 키 제거)의 유일한 흔적은 `upgrade` 채널 로그다 — 그 호출이 + * 사라져도 데이터 단언만으로는 드러나지 않으므로 로그 발생 자체를 계약으로 고정한다. + * `UpgradeContext` 는 생성자에서 `Log::channel()` 을 1회 해석하므로 페이크를 + * **컨텍스트 생성 전에** 심어야 한다. + * + * @return MockInterface 감시 대역 로거 + */ + private function runMigrationWithLogSpy(): MockInterface + { + $spy = \Mockery::spy(LoggerInterface::class); + Log::shouldReceive('channel') + ->with('upgrade') + ->andReturn($spy); + + $this->migration->run(new UpgradeContext( + fromVersion: '7.0.10', + toVersion: '7.0.11', + currentStep: '7.0.11', + )); + + return $spy; + } + + // ── ① 기본 축약 ──────────────────────────────────────────────────────── + + /** @effects backfill_narrows_prop_slot_objects_in_layouts_and_extensions */ + public function test_1_prop_slot_image_object_is_narrowed_to_url(): void + { + $id = $this->seedLayout([ + 'components' => [ + ['name' => 'Header', 'props' => ['logo' => $this->imageValue(), 'siteName' => '샘플']], + ], + ]); + + $this->runMigration(); + + $content = $this->readContent($id); + $this->assertSame('/api/attachment/X', $content['components'][0]['props']['logo']); + $this->assertSame('샘플', $content['components'][0]['props']['siteName'], '나머지 props 는 불변이어야 합니다.'); + } + + public function test_2_string_value_is_untouched_and_row_is_not_updated(): void + { + $id = $this->seedLayout([ + 'components' => [['name' => 'Header', 'props' => ['logo' => '/img/a.png']]], + ]); + $before = DB::table('template_layouts')->where('id', $id)->first(); + + $this->runMigration(); + + $after = DB::table('template_layouts')->where('id', $id)->first(); + $this->assertSame($before->content, $after->content); + $this->assertSame($before->updated_at, $after->updated_at, '무변경 행은 UPDATE 되지 않아야 합니다.'); + $this->assertSame($before->lock_version, $after->lock_version); + } + + public function test_3_binding_expression_string_is_untouched(): void + { + $expr = '{{_global.settings?.general?.site_logo_url}}'; + $id = $this->seedLayout([ + 'components' => [['name' => 'Header', 'props' => ['logo' => $expr]]], + ]); + $before = DB::table('template_layouts')->where('id', $id)->first(); + + $this->runMigration(); + + $after = DB::table('template_layouts')->where('id', $id)->first(); + $this->assertSame($expr, $this->readContent($id)['components'][0]['props']['logo']); + $this->assertSame($before->updated_at, $after->updated_at); + } + + // ── ② style 자리는 대상이 아니다 ─────────────────────────────────────── + + /** @effects backfill_excludes_style_slot_where_background_decomposition_lives */ + public function test_4_style_background_four_props_are_untouched(): void + { + $style = [ + 'backgroundImage' => 'url(/a.png)', + 'backgroundSize' => 'cover', + 'backgroundRepeat' => 'no-repeat', + 'backgroundPosition' => 'center', + ]; + $id = $this->seedLayout([ + 'components' => [['name' => 'Div', 'props' => ['style' => $style]]], + ]); + $before = DB::table('template_layouts')->where('id', $id)->first(); + + $this->runMigration(); + + $this->assertSame($style, $this->readContent($id)['components'][0]['props']['style']); + $this->assertSame($before->updated_at, DB::table('template_layouts')->where('id', $id)->first()->updated_at); + } + + public function test_5_corrupted_value_inside_style_slot_is_untouched(): void + { + // style 자리의 손상값 복구는 엔진 `sanitizeBgScalar` 소관 — 백필은 건드리지 않는다. + $style = ['backgroundPosition' => $this->imageValue()]; + $id = $this->seedLayout([ + 'components' => [['name' => 'Div', 'props' => ['style' => $style]]], + ]); + + $this->runMigration(); + + $this->assertSame($style, $this->readContent($id)['components'][0]['props']['style']); + } + + // ── ③ 순회 범위 ──────────────────────────────────────────────────────── + + /** @effects backfill_traverses_responsive_branches_nested_nodes_and_injections */ + public function test_6_responsive_branch_props_are_narrowed(): void + { + $id = $this->seedLayout([ + 'components' => [ + [ + 'name' => 'Header', + 'responsive' => ['md' => ['props' => ['logo' => $this->imageValue('/md.png')]]], + ], + ], + ]); + + $this->runMigration(); + + $this->assertSame('/md.png', $this->readContent($id)['components'][0]['responsive']['md']['props']['logo']); + } + + public function test_7_nested_node_inside_props_is_narrowed(): void + { + $id = $this->seedLayout([ + 'components' => [ + [ + 'name' => 'DataGrid', + 'props' => [ + 'cardColumns' => [ + ['cellChildren' => [['name' => 'Header', 'props' => ['logo' => $this->imageValue('/nested.png')]]]], + ], + ], + ], + ], + ]); + + $this->runMigration(); + + $content = $this->readContent($id); + $this->assertSame( + '/nested.png', + $content['components'][0]['props']['cardColumns'][0]['cellChildren'][0]['props']['logo'] + ); + } + + public function test_8_style_inside_nested_node_is_still_excluded(): void + { + $style = ['backgroundImage' => 'url(/n.png)', 'backgroundSize' => 'cover']; + $id = $this->seedLayout([ + 'components' => [ + [ + 'name' => 'Div', + 'props' => [ + 'expandChildren' => [['name' => 'Div', 'props' => ['style' => $style]]], + ], + ], + ], + ]); + + $this->runMigration(); + + $content = $this->readContent($id); + $this->assertSame($style, $content['components'][0]['props']['expandChildren'][0]['props']['style']); + } + + // ── ④ 판정식 엄격도 (느슨한 판정식이면 여기서 파괴된다) ─────────────── + + /** @effects backfill_strict_predicate_leaves_normal_props_untouched */ + public function test_9_normal_props_with_size_key_are_untouched(): void + { + // 실측 674건 패턴. 코어 엔진의 느슨한 판정식(4키 중 하나라도)이면 이 props 가 + // 이미지 값 객체로 오인되어 파괴된다. + $props = ['className' => 'x', 'name' => 'user', 'size' => 'lg']; + $id = $this->seedLayout(['components' => [['name' => 'Icon', 'props' => $props]]]); + $before = DB::table('template_layouts')->where('id', $id)->first(); + + $this->runMigration(); + + $this->assertSame($props, $this->readContent($id)['components'][0]['props']); + $this->assertSame($before->updated_at, DB::table('template_layouts')->where('id', $id)->first()->updated_at); + } + + public function test_10_normal_props_with_position_key_are_untouched(): void + { + // 실측 26건 패턴. + $props = ['items' => [['label' => 'a']], 'position' => 'bottom']; + $id = $this->seedLayout(['components' => [['name' => 'Toast', 'props' => $props]]]); + + $this->runMigration(); + + $this->assertSame($props, $this->readContent($id)['components'][0]['props']); + } + + public function test_11_object_with_key_outside_the_four_is_untouched(): void + { + $value = ['url' => '/x', 'label' => 'y']; + $id = $this->seedLayout(['components' => [['name' => 'X', 'props' => ['foo' => $value]]]]); + + $this->runMigration(); + + $this->assertSame($value, $this->readContent($id)['components'][0]['props']['foo']); + } + + public function test_14_image_object_without_url_key_is_untouched(): void + { + // `{size,repeat,position}` 은 정상 props 와 정적으로 구분 불가 — 건드리면 오탐. + $value = ['size' => 'cover', 'repeat' => 'no-repeat', 'position' => 'center']; + $id = $this->seedLayout(['components' => [['name' => 'X', 'props' => ['bg' => $value]]]]); + + $this->runMigration(); + + $this->assertSame($value, $this->readContent($id)['components'][0]['props']['bg']); + } + + public function test_27_props_container_itself_is_never_treated_as_an_image_value(): void + { + // `props` 는 값이 아니라 **컨테이너**다. `url` prop 을 받는 컴포넌트(임베드·영상 등)는 + // props 맵 자신이 「4키 부분집합 + url 보유」 형태가 되는데, 그것을 값으로 오인하면 + // props 가 통째로 문자열로 붕괴해 그 노드의 설정이 전부 사라진다. + $props = ['url' => '/embed/x', 'size' => 'lg']; + $id = $this->seedLayout(['components' => [['name' => 'Iframe', 'props' => $props]]]); + + $this->runMigration(); + + $this->assertSame($props, $this->readContent($id)['components'][0]['props']); + } + + public function test_28_props_container_with_corrupted_url_is_never_dropped(): void + { + // 같은 오인이 손상 url 분기로 가면 props 키 자체가 unset 되어 노드가 빈 껍데기가 된다. + $props = ['url' => ['nested' => 1], 'size' => 'lg']; + $id = $this->seedLayout(['components' => [['name' => 'Video', 'props' => $props]]]); + + $this->runMigration(); + + $node = $this->readContent($id)['components'][0]; + $this->assertArrayHasKey('props', $node, 'props 컨테이너는 손상 url 분기의 대상이 아니다.'); + $this->assertSame($props, $node['props']); + } + + public function test_29_style_container_itself_is_never_treated_as_an_image_value(): void + { + // `style` 도 같은 컨테이너 키다 — prop 자리 안에 있어도 값으로 평가하지 않는다. + $style = ['url' => '/legacy.png', 'position' => 'center']; + $id = $this->seedLayout(['components' => [['name' => 'X', 'props' => ['style' => $style]]]]); + + $this->runMigration(); + + $this->assertSame($style, $this->readContent($id)['components'][0]['props']['style']); + } + + // ── ⑤ 손상 url ───────────────────────────────────────────────────────── + + /** @effects backfill_drops_prop_key_on_corrupted_url_with_warning_log */ + public function test_12_empty_url_drops_the_prop_key(): void + { + $id = $this->seedLayout([ + 'components' => [['name' => 'Header', 'props' => ['logo' => $this->imageValue(''), 'siteName' => '샘플']]], + ]); + + $spy = $this->runMigrationWithLogSpy(); + + $props = $this->readContent($id)['components'][0]['props']; + $this->assertArrayNotHasKey('logo', $props, 'src="" 는 현재 문서 재요청이므로 키를 제거해 폴백을 살린다.'); + $this->assertSame('샘플', $props['siteName']); + + // 파괴적 동작이므로 원본이 로그에 남아야 한다 — 행 id·JSON 경로·원본 값 3요소. + $spy->shouldHaveReceived('warning') + ->withArgs(fn (string $m) => str_contains($m, "id={$id}") + && str_contains($m, 'components[0].props.logo') + && str_contains($m, '"url":""')) + ->once(); + } + + public function test_13_non_string_url_drops_the_prop_key(): void + { + $id = $this->seedLayout([ + 'components' => [['name' => 'Header', 'props' => ['logo' => ['url' => ['nested' => 1], 'size' => 'cover']]]], + ]); + + $spy = $this->runMigrationWithLogSpy(); + + $this->assertArrayNotHasKey('logo', $this->readContent($id)['components'][0]['props']); + + $spy->shouldHaveReceived('warning') + ->withArgs(fn (string $m) => str_contains($m, "id={$id}") + && str_contains($m, 'components[0].props.logo') + && str_contains($m, '"nested":1')) + ->once(); + } + + // ── ⑥ 확장 테이블 ────────────────────────────────────────────────────── + + /** + * 확장 레이아웃 1건을 시드합니다. + * + * @param array $content content 배열 + * @return int 생성된 행 id + */ + private function seedExtension(array $content): int + { + static $seq = 0; + $seq++; + + return DB::table('template_layout_extensions')->insertGetId([ + 'template_id' => $this->templateId, + 'extension_type' => 'module', + 'target_name' => 'home_'.$seq, + 'source_type' => 'module', + 'source_identifier' => 'test-module', + 'content' => json_encode($content, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), + 'priority' => 10, + 'is_active' => true, + 'lock_version' => 0, + 'created_at' => now(), + 'updated_at' => now(), + ]); + } + + public function test_15_extension_injection_component_props_are_narrowed(): void + { + $id = $this->seedExtension([ + 'injections' => [ + ['components' => [['name' => 'Header', 'props' => ['logo' => $this->imageValue('/ext.png')]]]], + ], + ]); + + $this->runMigration(); + + $content = $this->readContent($id, 'template_layout_extensions'); + $this->assertSame('/ext.png', $content['injections'][0]['components'][0]['props']['logo']); + } + + public function test_16_extension_inject_props_slot_is_narrowed(): void + { + $id = $this->seedExtension([ + 'injections' => [['props' => ['logo' => $this->imageValue('/inject.png')]]], + ]); + + $this->runMigration(); + + $content = $this->readContent($id, 'template_layout_extensions'); + $this->assertSame('/inject.png', $content['injections'][0]['props']['logo']); + } + + /** @effects backfill_traverses_modals_in_both_list_and_map_shape */ + public function test_17_modals_in_both_list_and_map_shape_are_narrowed(): void + { + $listId = $this->seedLayout([ + 'modals' => [['id' => 'm1', 'components' => [['name' => 'Img', 'props' => ['src' => $this->imageValue('/list.png')]]]]], + ]); + $mapId = $this->seedLayout([ + 'modals' => [ + 'channel_edit_modal' => [ + 'components' => [['name' => 'Img', 'props' => ['src' => $this->imageValue('/map.png')]]], + ], + ], + ]); + + $this->runMigration(); + + $this->assertSame('/list.png', $this->readContent($listId)['modals'][0]['components'][0]['props']['src']); + $this->assertSame( + '/map.png', + $this->readContent($mapId)['modals']['channel_edit_modal']['components'][0]['props']['src'] + ); + } + + // ── ⑦ 안전성 ─────────────────────────────────────────────────────────── + + /** @effects backfill_is_idempotent_and_performs_no_update_on_unchanged_rows */ + public function test_18_second_run_is_idempotent_and_performs_no_update(): void + { + $id = $this->seedLayout([ + 'components' => [['name' => 'Header', 'props' => ['logo' => $this->imageValue()]]], + ]); + + $this->runMigration(); + $afterFirst = DB::table('template_layouts')->where('id', $id)->first(); + + $this->runMigration(); + $afterSecond = DB::table('template_layouts')->where('id', $id)->first(); + + $this->assertSame($afterFirst->content, $afterSecond->content); + $this->assertSame($afterFirst->lock_version, $afterSecond->lock_version, '2회차는 UPDATE 가 없어야 합니다.'); + $this->assertSame($afterFirst->updated_at, $afterSecond->updated_at); + } + + /** @effects backfill_increments_lock_version_only_on_changed_rows */ + public function test_19_lock_version_is_incremented_only_on_changed_rows(): void + { + $dirty = $this->seedLayout( + ['components' => [['name' => 'Header', 'props' => ['logo' => $this->imageValue()]]]], + ['lock_version' => 3], + ); + $clean = $this->seedLayout( + ['components' => [['name' => 'Header', 'props' => ['logo' => '/ok.png']]]], + ['lock_version' => 3], + ); + + $this->runMigration(); + + $this->assertSame(4, (int) DB::table('template_layouts')->where('id', $dirty)->value('lock_version')); + $this->assertSame(3, (int) DB::table('template_layouts')->where('id', $clean)->value('lock_version')); + } + + /** @effects backfill_preserves_original_content_hash_so_modified_judgement_holds */ + public function test_20_original_content_hash_is_preserved(): void + { + $id = $this->seedLayout( + ['components' => [['name' => 'Header', 'props' => ['logo' => $this->imageValue()]]]], + ['original_content_hash' => str_repeat('a', 64), 'original_content_size' => 123], + ); + + $this->runMigration(); + + $row = DB::table('template_layouts')->where('id', $id)->first(); + $this->assertSame(str_repeat('a', 64), $row->original_content_hash, '재계산하면 사용자 편집본이 「원본 그대로」로 위장된다.'); + $this->assertSame(123, (int) $row->original_content_size); + // 백필 후에도 content 는 원본 파일과 다르므로 「수정됨」 판정이 유지된다. + $this->assertNotSame(hash('sha256', $row->content), $row->original_content_hash); + } + + /** @effects backfill_uses_keyset_chunking_so_no_row_is_skipped_past_the_boundary */ + public function test_21_all_rows_are_converted_beyond_the_chunk_boundary(): void + { + $ids = []; + for ($i = 0; $i < self::SEED_COUNT; $i++) { + $ids[] = $this->seedLayout([ + 'components' => [['name' => 'Header', 'props' => ['logo' => $this->imageValue('/a'.$i.'.png')]]], + ]); + } + + $this->runMigration(); + + $remaining = 0; + foreach ($ids as $i => $id) { + $logo = $this->readContent($id)['components'][0]['props']['logo']; + if (! is_string($logo)) { + $remaining++; + + continue; + } + $this->assertSame('/a'.$i.'.png', $logo); + } + + $this->assertSame(0, $remaining, 'OFFSET 순회면 청크 경계 이후 행이 조용히 누락된다 (chunkById 필요).'); + } + + /** @effects backfill_skips_broken_json_rows_without_aborting_the_run */ + public function test_22_broken_json_row_is_skipped_without_aborting_the_run(): void + { + $broken = $this->seedLayout(['components' => []]); + DB::table('template_layouts')->where('id', $broken)->update(['content' => '{not json']); + $good = $this->seedLayout([ + 'components' => [['name' => 'Header', 'props' => ['logo' => $this->imageValue('/good.png')]]], + ]); + + $spy = $this->runMigrationWithLogSpy(); + + $this->assertSame('{not json', DB::table('template_layouts')->where('id', $broken)->value('content')); + $this->assertSame('/good.png', $this->readContent($good)['components'][0]['props']['logo']); + + // 건너뛴 행은 조용히 사라지면 안 된다 — 그 행 id 가 로그에 남아야 운영자가 찾아간다. + $spy->shouldHaveReceived('warning') + ->withArgs(fn (string $m) => str_contains($m, "id={$broken}")) + ->atLeast()->once(); + } + + /** @effects backfill_leaves_version_and_preview_snapshots_untouched */ + public function test_23_version_and_preview_snapshots_are_untouched(): void + { + $layoutId = $this->seedLayout(['components' => []]); + $poisoned = json_encode( + ['components' => [['name' => 'Header', 'props' => ['logo' => $this->imageValue('/snap.png')]]]], + JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES, + ); + + $versionId = DB::table('template_layout_versions')->insertGetId([ + 'layout_id' => $layoutId, + 'version' => 1, + 'content' => $poisoned, + 'created_at' => now(), + ]); + $previewId = DB::table('template_layout_previews')->insertGetId([ + 'token' => 'imgobj-preview-token', + 'template_id' => $this->templateId, + 'layout_name' => 'imgobj/preview', + 'preview_type' => 'layout', + 'content' => $poisoned, + 'admin_id' => 1, + 'expires_at' => now()->addHour(), + 'created_at' => now(), + ]); + + $this->runMigration(); + + $this->assertSame( + $poisoned, + DB::table('template_layout_versions')->where('id', $versionId)->value('content'), + '과거 스냅샷을 고치면 「이전 버전으로 되돌리기」가 원본과 달라진다.' + ); + $this->assertSame( + $poisoned, + DB::table('template_layout_previews')->where('id', $previewId)->value('content'), + '미리보기 스냅샷도 백필 대상이 아니다.' + ); + } + + /** @effects backfill_converts_soft_deleted_rows_for_restore_safety */ + public function test_24_soft_deleted_rows_are_converted(): void + { + $id = $this->seedLayout( + ['components' => [['name' => 'Header', 'props' => ['logo' => $this->imageValue('/deleted.png')]]]], + ['deleted_at' => now()], + ); + + $this->runMigration(); + + $this->assertSame( + '/deleted.png', + $this->readContent($id)['components'][0]['props']['logo'], + '삭제된 레이아웃은 복원 가능하므로 고치지 않으면 복원 시 결함이 되살아난다.' + ); + } + + public function test_25_missing_table_is_skipped_without_error(): void + { + // 실제 `Schema::drop` 은 쓰지 않는다 — 이 테이블은 versions 테이블의 FK 대상이라 + // 드롭 자체가 실패하고, DDL 은 RefreshDatabase 트랜잭션을 암묵 커밋시켜 뒤따르는 + // 테스트까지 오염시킨다. 검증 대상은 `Schema::hasTable` 게이트이므로 존재하지 않는 + // 테이블명으로 같은 코드 경로를 직접 태운다. + $ref = new ReflectionClass($this->migration); + $method = $ref->getMethod('processTable'); + $method->setAccessible(true); + + $this->assertFalse(Schema::hasTable('g7_no_such_layout_table')); + $method->invoke($this->migration, $this->context, 'g7_no_such_layout_table'); + + // 예외 없이 통과 + 실제 테이블은 그대로다. + $this->assertTrue(Schema::hasTable('template_layout_extensions')); + } + + // ── ⑧ 변환 함수 직접 호출 (DB 없이 판정식만) ────────────────────────── + + public function test_26_transform_is_callable_directly_and_matches_db_path_results(): void + { + $ref = new ReflectionClass($this->migration); + $method = $ref->getMethod('transform'); + $method->setAccessible(true); + + $call = function (array $input) use ($method) { + $changed = 0; + $args = [$input, false, &$changed, $this->context, 't', '1', '']; + + return [$method->invokeArgs($this->migration, $args), $changed]; + }; + + // 케이스 1 — 축약 + [$out, $changed] = $call(['components' => [['props' => ['logo' => $this->imageValue()]]]]); + $this->assertSame('/api/attachment/X', $out['components'][0]['props']['logo']); + $this->assertSame(1, $changed); + + // 케이스 4 — style 자리 불변 + $style = ['backgroundImage' => 'url(/a.png)', 'backgroundSize' => 'cover']; + [$out, $changed] = $call(['components' => [['props' => ['style' => $style]]]]); + $this->assertSame($style, $out['components'][0]['props']['style']); + $this->assertSame(0, $changed); + + // 케이스 9 — 정상 props 불변 + $props = ['className' => 'x', 'name' => 'user', 'size' => 'lg']; + [$out, $changed] = $call(['components' => [['props' => $props]]]); + $this->assertSame($props, $out['components'][0]['props']); + $this->assertSame(0, $changed); + } +} diff --git a/tests/Playwright/fixtures/seed-layouts/sirsoft-basic.e2e_sandbox.json b/tests/Playwright/fixtures/seed-layouts/sirsoft-basic.e2e_sandbox.json index 5ebbb7c5..38a52377 100644 --- a/tests/Playwright/fixtures/seed-layouts/sirsoft-basic.e2e_sandbox.json +++ b/tests/Playwright/fixtures/seed-layouts/sirsoft-basic.e2e_sandbox.json @@ -18,6 +18,14 @@ "className": "py-6 px-4" }, "children": [ + { + "id": "e2e_sandbox_header", + "type": "composite", + "name": "Header", + "props": { + "siteName": "E2E 샌드박스" + } + }, { "id": "e2e_sandbox_root", "type": "basic", diff --git a/tests/Playwright/specs/layout-editor/image-widget-value-shape.spec.ts b/tests/Playwright/specs/layout-editor/image-widget-value-shape.spec.ts new file mode 100644 index 00000000..c8c75e29 --- /dev/null +++ b/tests/Playwright/specs/layout-editor/image-widget-value-shape.spec.ts @@ -0,0 +1,377 @@ +/** + * Layout Editor — image 위젯 값 형태(단일 값 슬롯 축약 / 표시모드 억제 / 표현식 보호). + * + * 결함(공개 #135): 코어 `image` 위젯이 내보내는 `{url,size,repeat,position}` 객체를 + * `propValue` 경로가 그대로 `props[key]` 에 기록해, 소비 컴포넌트가 `` 를 + * 받고 브라우저가 `[object Object]` 를 URL 로 해석했다. 이 결함은 **브라우저에서만** + * 드러난다 — 깨진 요청은 SPA catch-all 때문에 404 조차 아니라 200(HTML)을 받고, 편집기 + * 위젯의 미리보기는 정상이며, 서버 로그에도 흔적이 없다. 화면의 엑박이 유일한 증상이다. + * + * 단위(Vitest)는 `applyRecipe` 반환 노드까지만 볼 수 있어 "실제 `` 의 src 가 문자열이고 + * naturalWidth > 0" 을 포착하지 못한다. 그래서 캔버스 DOM 을 직접 재는 spec 을 둔다. + * + * 축 요약(마커 아님 — 평문): image_propvalue_narrowing, display_mode_suppression, binding_expression_guard, styleprop_bundle_regression. + * 효과 요약(마커 아님 — 평문): image_object_narrows_to_url_string_in_propvalue_slot, single_value_slot_control_hides_display_mode_buttons_entirely, bound_value_shows_expression_badge_and_locks_destructive_controls, styleprop_bundle_four_property_decomposition_is_unchanged. + */ +import { test, expect, issueToken, authenticatePage } from '../../fixtures/auth'; +import { SANDBOX_ROUTE, sandboxRouteParam } from '../../fixtures/seed-layout'; +import type { Page } from '@playwright/test'; + +const EDITOR_URL = '/admin/layout-editor/sirsoft-basic?route=%2F'; + +/** + * 공통 레이아웃 편집 모드 — `Header` 의 「로고 이미지」는 `_user_base` 소유다. + * + * 라우트 모드에서 그 노드는 **상속(base) 출처**라 ⓘ 대신 「🔒 공통 레이아웃 편집」이 뜬다. + * 편집해도 저장 시 마스킹이 통째로 폐기하므로 편집 표면을 열지 않는 것이 계약이다 + * (계획서 D9~D11). 따라서 그 컨트롤을 여는 정상 경로는 이 모드다. + */ +const BASE_EDITOR_URL = '/admin/layout-editor/sirsoft-basic?edit=__base__%2F_user_base'; + +/** + * 편집기에 진입해 캔버스 편집 노드가 렌더될 때까지 기다린다. + */ +async function openEditor(page: Page, url: string = EDITOR_URL): Promise { + const token = issueToken('core.templates.layouts.edit'); + await authenticatePage(page, token); + await page.goto(url); + await page.waitForLoadState('domcontentloaded', { timeout: 30_000 }); + await page.waitForSelector('[data-testid="g7le-preview-frame"]', { timeout: 30_000 }); + await page.waitForFunction( + () => document.querySelectorAll('[data-editor-path]').length > 0, + { timeout: 20_000 }, + ); +} + +/** + * 캔버스 위임 click 핸들러로 노드를 선택한다. 패널/오버레이가 좌표를 가로채는 것을 피해 + * 편집기가 실제로 받는 pointer/click 시퀀스를 노드 중앙에 직접 발사한다. + */ +async function selectNode(page: Page, path: string): Promise { + await page.evaluate((p) => { + const el = document.querySelector(`[data-editor-path="${p}"]`); + if (!el) return; + el.scrollIntoView({ block: 'center' }); + const r = el.getBoundingClientRect(); + const cx = r.left + r.width / 2; + const cy = r.top + r.height / 2; + for (const type of ['pointerover', 'pointermove', 'pointerdown', 'mousedown', 'pointerup', 'mouseup', 'click']) { + el.dispatchEvent(new MouseEvent(type, { bubbles: true, clientX: cx, clientY: cy })); + } + }, path); +} + +/** ⓘ → 「속성 설정」 → 속성 편집 모달. 지정한 탭을 연다. */ +async function openPropertyTab(page: Page, tab: 'props' | 'style'): Promise { + await page.waitForSelector('[data-testid="g7le-overlay-info-button"]', { timeout: 10_000 }); + await page.getByTestId('g7le-overlay-info-button').click(); + await page.waitForSelector('[data-testid="g7le-context-menu-edit-props"]', { timeout: 5_000 }); + await page.getByTestId('g7le-context-menu-edit-props').click(); + await page.waitForSelector('[data-testid="g7le-property-modal"]', { timeout: 10_000 }); + await page.getByTestId(`g7le-property-tab-${tab}`).click(); +} + +/** + * `image` 위젯이 열린 상태에서 **단일 값 슬롯 컨트롤**을 찾을 수 있는 노드를 고른다. + * + * 리터럴 `data-editor-path` 를 쓰지 않는다 — 베이스 루트 인덱스가 밀리면 통째로 깨진다. + * 대신 캔버스에서 `Header` 컴포넌트를 이름으로 찾는다(로고 컨트롤의 소유 컴포넌트). + */ +async function findHeaderPath(page: Page): Promise { + return page.evaluate(() => { + const el = document.querySelector('[data-editor-path][data-editor-name="Header"]'); + return el?.getAttribute('data-editor-path') ?? null; + }); +} + +/** + * 시드 화면이 소유한 `Header` 의 편집 경로를 id 로 지목한다. + * + * 시드 화면은 `_user_base` 를 extends 하므로 캔버스에 `Header` 가 **둘** 뜬다 — 상속받은 + * 베이스 헤더(잠금: ⓘ 대신 「공통 레이아웃 편집」)와 시드가 직접 둔 라우트 소유 헤더. + * 이름으로만 찾으면 앞의 잠긴 쪽이 잡혀 속성 모달에 도달하지 못한다. + */ +async function findSandboxHeaderPath(page: Page): Promise { + return page.evaluate(() => { + const el = document.querySelector('[data-editor-path][data-editor-id="e2e_sandbox_header"]'); + return el?.getAttribute('data-editor-path') ?? null; + }); +} + +/** 배경이 보일 만한 박스형 Div — styleProp 묶음(회귀 가드)의 대상 */ +async function pickBoxAreaPath(page: Page): Promise { + return page.evaluate(() => { + const cands = Array.from( + document.querySelectorAll('[data-editor-path][data-editor-name="Div"]'), + ).filter((el) => { + const r = el.getBoundingClientRect(); + return r.width > 200 && r.width < 800 && r.height > 80 && r.height < 320 && r.left > 360; + }); + return cands[0]?.getAttribute('data-editor-path') ?? null; + }); +} + +/** + * 저장 페이로드에서 `logo` prop 값을 찾아 돌려준다 (트리 어디에 있든). + * + * 노드 경로를 리터럴로 박으면 베이스 레이아웃 구조가 한 칸만 바뀌어도 통째로 깨지므로 + * 키 이름으로 전역 탐색한다. + * + * @param value 저장 요청 body (JSON) + * @returns 찾은 `logo` 값, 없으면 undefined + */ +function findLogoProp(value: unknown): unknown { + // 저장 페이로드의 `content` 는 **JSON 문자열**로 실린다 — 파싱하지 않으면 트리를 볼 수 없다. + if (typeof value === 'string') { + if (!value.trim().startsWith('{')) return undefined; + try { + return findLogoProp(JSON.parse(value)); + } catch { + return undefined; + } + } + if (Array.isArray(value)) { + for (const item of value) { + const hit = findLogoProp(item); + if (hit !== undefined) return hit; + } + return undefined; + } + if (!value || typeof value !== 'object') return undefined; + + const record = value as Record; + const props = record.props; + if (props && typeof props === 'object' && 'logo' in (props as Record)) { + return (props as Record).logo; + } + for (const child of Object.values(record)) { + const hit = findLogoProp(child); + if (hit !== undefined) return hit; + } + return undefined; +} + +/** 1x1 PNG — 첨부 업로드용 최소 실물 이미지(naturalWidth>0 을 재려면 실제 파일이어야 한다) */ +const PNG_1PX = Buffer.from( + 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==', + 'base64', +); + +test.describe('@layout-editor image 위젯 값 형태 (공개 #135)', () => { + /** @effects image_object_narrows_to_url_string_in_propvalue_slot, single_value_slot_control_hides_display_mode_buttons_entirely */ + test('로고 이미지 URL 입력 → 캔버스 img src 가 문자열, [object Object] 0건, 모드 버튼 미노출', async ({ page }) => { + await openEditor(page, BASE_EDITOR_URL); + + const headerPath = await findHeaderPath(page); + test.skip(headerPath === null, '캔버스에서 Header 노드를 찾지 못했습니다'); + await selectNode(page, headerPath as string); + await openPropertyTab(page, 'props'); + + const urlInput = page.getByTestId('g7le-image-url'); + test.skip(!(await urlInput.isVisible().catch(() => false)), '로고 이미지 컨트롤이 노출되지 않았습니다'); + + // 저장값이 데이터 연결 표현식이면 컨트롤은 보호 상태로 뜬다(입력칸 readOnly). + // 값을 바꾸려면 「직접 지정으로 바꾸기」로 명시적으로 열어야 한다 — 그 한 번의 + // 의사표시 없이는 환경설정과의 연결이 덮이지 않는다는 것이 계약이다. + const replace = page.getByTestId('g7le-image-expression-replace'); + if (await replace.isVisible().catch(() => false)) { + await replace.click(); + // 해제되면 되돌리기 경로가 함께 열린다(편도 금지). + await expect(page.getByTestId('g7le-image-expression-restore')).toBeVisible(); + } + + // 단일 값 슬롯(propValue) 이므로 표시모드 버튼은 **컨테이너째** 미렌더되어야 한다. + // `disabled` 로 남기면 "URL 을 넣으면 살아나겠지" 라는 거짓 정보를 준다. + await expect(page.getByTestId('g7le-image-modes')).toHaveCount(0); + await expect(page.getByTestId('g7le-image-mode-fill')).toHaveCount(0); + + const url = '/api/templates/sirsoft-basic/layout-attachments/5/file'; + await urlInput.fill(url); + await urlInput.blur(); + + // 핵심 검증 — 캔버스의 실제 가 문자열 src 를 받아야 한다. + // 종전에는 여기에 "[object Object]" 가 들어가 엑박이 됐고, SPA catch-all 때문에 + // 그 요청은 404 조차 아니라 200(HTML) 이라 네트워크 탭으로도 드러나지 않았다. + await expect + .poll( + async () => + page.evaluate((p) => { + const host = document.querySelector(`[data-editor-path="${p}"]`); + const img = host?.querySelector('img'); + return img?.getAttribute('src') ?? ''; + }, headerPath), + { timeout: 8_000 }, + ) + .toContain('layout-attachments/5/file'); + + const objectObjectCount = await page.evaluate(() => + Array.from(document.images).filter((i) => (i.getAttribute('src') ?? '').includes('[object Object]')).length, + ); + expect(objectObjectCount, '문서 어디에도 [object Object] src 가 없어야 합니다').toBe(0); + }); + + /** + * 저장 → 사용자 화면 3단 — 이 결함의 **최종 소비 지점**이다. + * + * 위 케이스는 편집기 캔버스까지만 본다. 그런데 #135 가 실제로 드러난 자리는 저장 이후의 + * 사용자 화면이고, 깨진 요청은 SPA catch-all 때문에 404 조차 아니라 200(HTML) 이라 + * 네트워크 탭·서버 로그 어디에도 흔적이 없다. 그래서 「저장 페이로드가 문자열인가」와 + * 「그 문자열이 실제로 그려지는가(naturalWidth>0)」를 여기서 함께 잰다. + * + * 대상은 **시드 화면(`e2e_sandbox`)** 이다. 이 spec 은 저장(PUT)까지 수행하므로 제품 + * 레이아웃(`_user_base`)을 쓰면 편집 결과가 그대로 영속돼 개발 사이트가 오염된다 + * (`fixtures/seed-layout.ts` 규약). 시드 화면에 라우트 소유 `Header` 를 두어 로고 컨트롤을 + * 라우트 모드에서 열 수 있게 했고, 시드는 globalTeardown 이 통째로 제거한다. + * + * @effects image_object_narrows_to_url_string_in_propvalue_slot, img_string_src_passes_through_unchanged + */ + test('저장 → 사용자 화면에서 문자열 src 로 실제 렌더된다', async ({ page }) => { + // 편집기 진입 + 저장 왕복 + 사용자 화면 재방문 3단이라 기본 30s 로는 부족하다. + test.setTimeout(120_000); + + // 실제로 그려지는지(naturalWidth>0)를 재려면 실존하는 이미지가 필요하다. 고정 id 를 + // 박으면 그 첨부가 지워진 환경에서 조용히 0 이 되므로, 이 spec 이 직접 올리고 지운다. + const token = issueToken('core.templates.layouts.edit'); + const headers = { Authorization: `Bearer ${token}`, Accept: 'application/json' }; + const upload = await page.request.post('/api/admin/templates/sirsoft-basic/layout-attachments', { + headers, + multipart: { + file: { name: 'e2e-logo.png', mimeType: 'image/png', buffer: PNG_1PX }, + }, + }); + test.skip(!upload.ok(), `첨부 업로드 실패(${upload.status()})`); + const attachmentId = (await upload.json())?.data?.id; + test.skip(!attachmentId, '첨부 id 를 받지 못했습니다'); + const url = `/api/templates/sirsoft-basic/layout-attachments/${attachmentId}/file`; + + try { + await openEditor(page, `/admin/layout-editor/sirsoft-basic?route=${sandboxRouteParam()}`); + + const headerPath = await findSandboxHeaderPath(page); + test.skip(headerPath === null, '시드 화면에서 Header 노드를 찾지 못했습니다'); + await selectNode(page, headerPath as string); + await openPropertyTab(page, 'props'); + + const urlInput = page.getByTestId('g7le-image-url'); + test.skip(!(await urlInput.isVisible().catch(() => false)), '로고 이미지 컨트롤이 노출되지 않았습니다'); + + const replace = page.getByTestId('g7le-image-expression-replace'); + if (await replace.isVisible().catch(() => false)) await replace.click(); + + await urlInput.fill(url); + await urlInput.blur(); + + // 속성 모달을 닫고 툴바에서 저장한다. + await page.getByTestId('g7le-property-modal-done').click(); + + // 저장 페이로드의 `logo` 가 **문자열**이어야 한다 — 객체면 수정 전 상태다. + const [put] = await Promise.all([ + page.waitForResponse( + (r) => r.url().includes('/layouts/e2e_sandbox') && r.request().method() === 'PUT', + { timeout: 30_000 }, + ), + page.getByTestId('g7le-toolbar-save').click(), + ]); + expect(put.status(), '저장이 200 이어야 합니다').toBe(200); + + const logo = findLogoProp(put.request().postDataJSON()); + expect(typeof logo, `저장 페이로드의 logo 가 문자열이어야 합니다 (실제: ${JSON.stringify(logo)})`).toBe('string'); + expect(logo).toContain('layout-attachments/5/file'); + + // 3단 — 사용자 화면에서 실제로 그려지는가. + await page.goto(SANDBOX_ROUTE['sirsoft-basic']); + await page.waitForLoadState('domcontentloaded'); + + const measured = await page.evaluate(async () => { + await new Promise((r) => setTimeout(r, 1500)); + const imgs = Array.from(document.images); + const hit = imgs.find((i) => (i.getAttribute('src') ?? '').includes('layout-attachments/5/file')); + return { + src: hit?.getAttribute('src') ?? null, + natural: hit?.naturalWidth ?? 0, + objectObject: imgs.filter((i) => (i.getAttribute('src') ?? '').includes('[object Object]')).length, + }; + }); + + expect(measured.objectObject, '사용자 화면에 [object Object] src 가 없어야 합니다').toBe(0); + expect(measured.src, '사용자 화면의 로고 src 가 저장한 문자열이어야 합니다').toContain( + 'layout-attachments/5/file', + ); + expect(measured.natural, '로고가 실제로 로드되어야 합니다(naturalWidth>0)').toBeGreaterThan(0); + } finally { + // 올린 첨부는 반드시 지운다 — 실패로 중단돼도 서버에 잔여물을 남기지 않는다. + await page.request + .delete(`/api/admin/templates/layout-attachments/${attachmentId}`, { headers }) + .catch(() => undefined); + } + }); + + /** @effects bound_value_shows_expression_badge_and_locks_destructive_controls */ + test('저장값이 데이터 연결 표현식이면 원문 배지 + 파괴적 조작 잠금', async ({ page }) => { + await openEditor(page, BASE_EDITOR_URL); + + const headerPath = await findHeaderPath(page); + test.skip(headerPath === null, '캔버스에서 Header 노드를 찾지 못했습니다'); + await selectNode(page, headerPath as string); + await openPropertyTab(page, 'props'); + + const badge = page.getByTestId('g7le-image-expression'); + // 번들 레이아웃의 기본 저장값은 사이트 로고 설정 표현식이다. 표현식 상태가 아니면 + // (운영자가 이미 고정 URL 을 넣은 사이트) 이 축은 검증 대상이 아니다. + test.skip(!(await badge.isVisible().catch(() => false)), '로고가 표현식 상태가 아닙니다'); + + // 원문이 그대로 보여야 한다 — 빈 피커로 보이면 업로드 1클릭에 표현식이 소리 없이 사라진다. + await expect(badge).toContainText('{{'); + // 미리보기는 깨지므로 렌더하지 않는다(거짓 미리보기 금지). + await expect(page.getByTestId('g7le-image-preview')).toHaveCount(0); + // 파괴적 조작은 잠긴다 — 단, 「직접 지정으로 바꾸기」로 즉시 해제되는 일시적 상태다. + await expect(page.getByTestId('g7le-image-clear')).toBeDisabled(); + await expect(page.getByTestId('g7le-image-url')).toHaveAttribute('readonly', /.*/); + + await page.getByTestId('g7le-image-expression-replace').click(); + await expect(page.getByTestId('g7le-image-expression')).toHaveCount(0); + await expect(page.getByTestId('g7le-image-clear')).toBeEnabled(); + }); + + /** @effects styleprop_bundle_four_property_decomposition_is_unchanged */ + test('회귀 가드 — 배경 이미지(styleProp 묶음) 컨트롤은 모드 버튼과 4속성 분해를 유지', async ({ page }) => { + await openEditor(page); + + const targetPath = await pickBoxAreaPath(page); + test.skip(targetPath === null, '배경을 넣을 박스형 Div 를 찾지 못했습니다'); + await selectNode(page, targetPath as string); + await openPropertyTab(page, 'style'); + + const urlInput = page.getByTestId('g7le-image-url'); + test.skip(!(await urlInput.isVisible().catch(() => false)), '배경 이미지 컨트롤이 노출되지 않았습니다'); + + // 다중 props 묶음이라 표시모드 버튼은 그대로 있어야 한다(단일 슬롯 억제가 여기까지 + // 번지면 배경 편집 기능이 통째로 죽는다). + await expect(page.getByTestId('g7le-image-modes')).toBeVisible(); + + const url = 'https://example.com/api/templates/sirsoft-basic/layout-attachments/5/file'; + await urlInput.fill(url); + await urlInput.blur(); + + await expect + .poll( + async () => + page.evaluate((p) => { + const el = document.querySelector(`[data-editor-path="${p}"]`); + return el ? getComputedStyle(el).backgroundImage : ''; + }, targetPath), + { timeout: 8_000 }, + ) + .toContain('layout-attachments/5/file'); + + const snap = await page.evaluate((p) => { + const el = document.querySelector(`[data-editor-path="${p}"]`) as HTMLElement | null; + const cs = el ? getComputedStyle(el) : null; + return { size: cs?.backgroundSize, repeat: cs?.backgroundRepeat, image: cs?.backgroundImage }; + }, targetPath); + expect(snap.size).toBe('cover'); + expect(snap.repeat).toBe('no-repeat'); + expect(snap.image, 'CSS 값 문맥이므로 url(...) 로 감싸져야 합니다').toContain('url('); + expect(snap.image).not.toContain('[object Object]'); + }); +}); diff --git a/tests/scenarios/layout-editor-image-widget-value-shape.yaml b/tests/scenarios/layout-editor-image-widget-value-shape.yaml new file mode 100644 index 00000000..7d663abf --- /dev/null +++ b/tests/scenarios/layout-editor-image-widget-value-shape.yaml @@ -0,0 +1,127 @@ +feature: 레이아웃 편집기 image 위젯 값 형태 — 단일 값 슬롯 축약 / 런타임 방어 / 저장 데이터 백필 + +# 입력 axis 는 5축 265조합이다. 전수 마킹은 실효가 없어(테스트 1건이 조합 1개만 +# 덮으므로 265건이 필요하다) **pairwise** 로 좁힌다 — 어떤 두 축의 조합도 최소 한 번은 +# 지나가므로 축 간 상호작용 결함은 그대로 잡히고, 마킹 대상은 실측 9건으로 줄어든다. +# effects 축은 면제하지 않는다 — 모든 effect 가 테스트 마킹으로 도달해야 한다. +coverage_strategy: pairwise + +description: | + 코어 `image` 위젯은 배경 이미지용으로 설계되어 `{url,size,repeat,position}` **객체**를 + 내보낸다. 그 값을 노드에 기록하는 apply 4종 중 `styleProp` 의 다중 props(배경 묶음)만 + 객체를 CSS 4속성으로 분해했고, `propValue`·`cssVar`·단일 `styleProp` 은 객체를 그대로 + 기록했다. 소비 컴포넌트가 `` 로 받으면 브라우저가 `[object Object]` 를 + URL 로 해석해 이미지가 깨진다(공개 #135, `sirsoft-basic` 헤더 「로고 이미지」). + + 이 결함은 예외도 콘솔 오류도 서버 로그도 남기지 않는다 — 깨진 이미지 요청은 SPA + catch-all 때문에 404 조차 아니라 200(HTML)을 받고, 편집기 위젯의 미리보기는 정상이라 + 조작 중에는 이상이 보이지 않는다. 유일한 증상은 화면의 엑박이다. + + 방어선은 넷이다: + 1. **쓰기 축약** — 단일 값 슬롯 writer 3종이 공용 헬퍼 `scalarizeImageValue` 를 경유해 + url 문자열만 남긴다. 게이트는 `widget === 'image'` 이며 값 형태 sniffing 이 아니다 + (`isImageValueObject` 는 4키 중 하나만 있어도 참이라, 값만 보면 `{position:'left'}` + 같은 정당한 객체 prop 을 이미지로 오인해 삭제한다). + 2. **읽기 역조립** — 저장된 문자열을 `{url}` 로 되감아 위젯이 현재 값을 읽게 한다. + 표현식 문자열도 감싼다 — 감싸지 않으면 빈 피커로 보이고 업로드 1클릭에 그 표현식이 + 소리 없이 소실된다. 깨진 미리보기 억제와 실수 덮어쓰기 방지는 위젯이 맡는다. + 3. **런타임 방어** — 업그레이드 전 화면을 위해 템플릿 `Img` 가 객체값에서 url 을 + 해석하고, 손상값이면 `src` 를 아예 붙이지 않는다(엑박도 빈 문자열도 아니다). + 4. **저장 데이터 백필** — 업그레이드 스텝이 기설치본의 prop 자리 객체를 축약한다. + 판정식은 런타임 방어와 **완전히 같은 엄격도**(키 집합 ⊆ 4키 AND url 문자열)를 쓴다 — + 두 방어선의 기준이 어긋나면 한쪽만 통과하는 값이 생긴다. + + 단일 값 슬롯 컨트롤에서는 표시모드(채움/맞춤/타일) 버튼을 **컨테이너째 미렌더**한다. + `size`/`repeat`/`position` 을 저장할 자리가 없어 눌러도 저장되지 않는 죽은 컨트롤이기 + 때문이다. `disabled` 로 두면 "URL 을 넣으면 살아나겠지" 라는 거짓 정보를 준다. + +axes: + widget_output: + - scalar_string # 이미 문자열 (회귀 0) + - image_object # {url,size,repeat,position} 전체 + - image_object_empty_url # url 이 빈 문자열 + - image_object_nonstring_url # url 이 객체/배열/숫자 + - undefined_cleared # 「제거」 → undefined + apply_type: [propValue, styleProp, cssVar, classToken] + stored_shape: [string, object, binding_expression, absent] + consumer: [img_src, header_logo, mobilenav_logo, div_background, none] + storage_scope: + - template_layouts + - template_layout_extensions + - layout_versions_untouched + - layout_previews_untouched + +exclusions: + - { apply_type: styleProp, consumer: [img_src, header_logo, mobilenav_logo], reason: "styleProp 은 인라인 style 로 흐른다 — sink 에 도달하지 않는다" } + - { apply_type: propValue, consumer: div_background, reason: "배경은 style 자리 — propValue 로 흐르지 않는다" } + - { apply_type: cssVar, consumer: [img_src, header_logo, mobilenav_logo, div_background], reason: "CSS 변수는 소비 sink 가 선언되지 않았다 — 축약만 검증(정적 룰이 신규 선언을 차단)" } + - { apply_type: classToken, widget_output: [image_object, image_object_empty_url, image_object_nonstring_url], reason: "image × classToken 은 정적 룰이 저장 이전에 차단해 런타임 도달 불가" } + - { widget_output: undefined_cleared, consumer: [img_src, div_background], reason: "해제는 폴백 축 — header_logo 에서 대표 검증(사이트명 텍스트 폴백)" } + - { widget_output: undefined_cleared, stored_shape: [object, string, binding_expression], reason: "해제 결과는 absent 하나뿐" } + - { stored_shape: binding_expression, widget_output: [image_object, image_object_empty_url, image_object_nonstring_url], reason: "표현식은 문자열이라 객체 형태와 배타" } + - { storage_scope: [layout_versions_untouched, layout_previews_untouched], apply_type: [styleProp, cssVar, classToken], reason: "스냅샷 미보존 단언은 apply 무관 단일 축 — propValue 에서 대표 검증" } + - { storage_scope: template_layout_extensions, consumer: [mobilenav_logo, div_background, none], reason: "확장 주입 경로는 injections[].props 순회 포섭만 검증 — 소비 sink 는 코어 경로와 동일" } + +effects: + # ① 쓰기 축약 (코어 엔진) + - image_object_narrows_to_url_string_in_propvalue_slot + - image_object_narrows_to_wrapped_css_url_in_cssvar_and_single_styleprop + - legacy_css_url_wrapping_is_stripped_for_component_prop_sink + - image_object_without_url_or_with_empty_url_deletes_the_prop + - non_image_widget_object_and_array_props_are_preserved_intact + - styleprop_bundle_four_property_decomposition_is_unchanged + - apply_fixed_value_wins_over_control_value_then_gets_narrowed + # ② 읽기 역조립 + - stored_string_is_rewrapped_as_url_object_for_the_widget + - binding_expression_is_rewrapped_so_one_click_upload_cannot_silently_lose_it + - legacy_object_stored_value_is_returned_losslessly + - non_image_widget_values_are_not_rewrapped + - node_axis_roundtrip_is_a_fixed_point_after_first_pass + - dark_scope_stays_readonly_for_inline_apply + # ③ 위젯 표면 + - single_value_slot_control_hides_display_mode_buttons_entirely + - single_value_slot_control_emits_url_only_object_without_size_repeat_position + - single_value_slot_preview_is_pinned_to_contain_not_a_false_preview + - bundle_control_keeps_display_mode_buttons_and_active_state + - apply_undeclared_control_keeps_display_mode_buttons_blacklist_not_whitelist + - bound_value_shows_expression_badge_and_locks_destructive_controls + - replace_affordance_reopens_editing_without_emitting_a_change + - bound_value_protection_is_a_single_shared_gate_for_every_widget + - restore_affordance_recovers_the_original_binding_after_replacement + # ④ 런타임 방어 (템플릿 Img) + - img_string_src_passes_through_unchanged + - img_image_value_object_resolves_to_its_url + - img_corrupted_value_attaches_no_src_neither_object_object_nor_empty_string + - img_object_with_key_outside_the_four_is_rejected_same_strictness_as_backfill + - img_other_attributes_pass_through_spread_regression_zero + # ⑤ 백필 (업그레이드 스텝) + - backfill_narrows_prop_slot_objects_in_layouts_and_extensions + - backfill_strict_predicate_leaves_normal_props_untouched + - backfill_excludes_style_slot_where_background_decomposition_lives + - backfill_traverses_responsive_branches_nested_nodes_and_injections + - backfill_traverses_modals_in_both_list_and_map_shape + - backfill_drops_prop_key_on_corrupted_url_with_warning_log + - backfill_is_idempotent_and_performs_no_update_on_unchanged_rows + - backfill_increments_lock_version_only_on_changed_rows + - backfill_preserves_original_content_hash_so_modified_judgement_holds + - backfill_leaves_version_and_preview_snapshots_untouched + - backfill_converts_soft_deleted_rows_for_restore_safety + - backfill_uses_keyset_chunking_so_no_row_is_skipped_past_the_boundary + - backfill_skips_broken_json_rows_without_aborting_the_run + +test_files: + - resources/js/core/template-engine/layout-editor/__tests__/spec/recipeEngine.test.ts + - resources/js/core/template-engine/layout-editor/__tests__/components/property-controls.test.tsx + - resources/js/core/template-engine/layout-editor/__tests__/components/ControlRenderer.boundValueGuard.test.tsx + - templates/_bundled/sirsoft-basic/src/components/basic/__tests__/Img.test.tsx + - tests/Feature/Upgrades/Upgrade7011ImageObjectPropBackfillTest.php + - tests/Playwright/specs/layout-editor/image-widget-value-shape.spec.ts + +validation: + note: | + 백필 축(⑤)은 DB 데이터 상태라 브라우저 E2E 로 재현할 수 없다. PHPUnit 26케이스가 + 판정식 엄격도·순회 범위·멱등·lock_version·hash 불변·스냅샷 미개입을 전수 잠근다. + + `image` 위젯을 값이 스칼라로 축약되지 않는 apply 경로(classToken/cssVar/apply 미선언)에 + 새로 연결하는 것은 정적 검사가 저장 이전에 차단한다 — 그래서 그 조합은 런타임에 도달 + 불가이며 exclusions 에 명시했다. diff --git a/upgrades/Upgrade_7_0_11.php b/upgrades/Upgrade_7_0_11.php new file mode 100644 index 00000000..dc5c2351 --- /dev/null +++ b/upgrades/Upgrade_7_0_11.php @@ -0,0 +1,37 @@ +` 로 받아 `[object Object]` 를 URL 로 + * 해석하던 결함(공개 #135)의 **기존 데이터 보정**이다. 편집기 쪽 소스 교정만으로는 + * 이미 저장된 설치본이 낫지 않는다. + * + * 실행 순서는 파일명 정렬(`sort()`)을 따른다. + * + * 본 클래스는 `AbstractUpgradeStep` 의 default `run()` 에 위임 — 별도 override 없음 + * (`run()` 은 final 이라 override 자체가 불가능하다). + * + * @upgrade-path 7.0.x → 7.0.11 + * + * 의존성 제약: 본 스텝은 변환/핫픽스를 `data/7.0.11/migrations/` 의 버전 namespace + * 클래스에 위임한다. 미래 버전에서 *그 디렉토리는 동결* (수정 금지) 되어 "각 스텝별 동작 + * 100% 동일 보장" invariant 가 성립. + * + * 상세: docs/extension/upgrade-step-guide.md §13 "버전별 데이터 스냅샷" + */ +class Upgrade_7_0_11 extends AbstractUpgradeStep +{ + // 모든 로직 위임 — data/7.0.11/ 가 SSoT. +} diff --git a/upgrades/data/7.0.11/migrations/01_NarrowImageObjectPropsInLayouts.php b/upgrades/data/7.0.11/migrations/01_NarrowImageObjectPropsInLayouts.php new file mode 100644 index 00000000..02c5bd50 --- /dev/null +++ b/upgrades/data/7.0.11/migrations/01_NarrowImageObjectPropsInLayouts.php @@ -0,0 +1,360 @@ +` 로 받으면 브라우저가 + * `[object Object]` 를 URL 로 해석해 이미지가 깨진다(공개 #135). + * + * 이 결함은 예외도 콘솔 오류도 서버 로그도 남기지 않는다 — 깨진 이미지 요청은 SPA + * catch-all 때문에 404 조차 아니라 200(HTML)을 받고, 편집기 위젯의 미리보기는 정상이라 + * 조작 중에는 이상이 보이지 않는다. 소스 교정만으로는 이미 저장된 설치본이 낫지 않으므로 + * 여기서 보정한다. + * + * ── 판정식 엄격도 (이 마이그레이션에서 가장 중요한 사실) ───────────────────────── + * + * 코어 편집기 엔진의 `isImageValueObject` 는 4키 중 **하나라도** 있으면 참이다. 그것을 + * 여기에 이식하면 저장된 레이아웃이 대량 파괴된다 — 레이아웃 JSON 전수 실측에서 느슨한 + * 판정식은 2,219건을 매치했고 그중 정상 props 가 대부분이었다(`{className,name,size}` + * 674건 · `{name,size}` 552건 · `{items,position}` 26건). 엄격 판정식(키 집합 ⊆ 4키 + * **AND** `url` 키 존재)의 매치는 0건이었다. + * + * 두 판정식이 다른 것은 실수가 아니라 의도다 — 엔진은 "방금 위젯이 만든 값"을 보므로 + * 느슨해도 안전하고, 백필은 "임의 사용자 레이아웃 전수"를 보므로 정밀도 요구가 다르다. + * + * ── 순회 범위 ──────────────────────────────────────────────────────────────── + * + * "prop 자리" 는 키 이름 allowlist 로 정의할 수 없다 — 실측상 `props` 안에 컴포넌트 노드가 + * 1,150건 산다(`props.cardColumns[0].cellChildren[0]`, `props.itemTemplate` …). 임의의 + * prop 키가 노드를 품을 수 있으므로 **모드 플래그 전역 재귀**를 쓴다: `props` 키를 만나면 + * 모드 ON, `style` 키를 만나면 OFF(배경 4속성 분해값은 정상), 그 외는 현재 모드 승계. + * 이 한 규칙으로 `node.props.*` · `responsive.{bp}.props.*` · 중첩 노드의 props · + * 확장 content 의 `injections[].props` 가 전부 포섭되고, `children`/`slots`/`modals` + * 등은 그냥 통과 지점이라 열거할 필요가 없다. + * + * ── 안전성 ─────────────────────────────────────────────────────────────────── + * + * - **멱등**: 이미 문자열인 값은 `is_array` 에서 탈락하므로 2회차 변경 건수는 구조적으로 0. + * - **무변경 행 UPDATE 금지**: 변경 카운터로 판정한다. 재직렬화 결과 비교로 판정하면 + * 키 순서·escape 차이로 전 행을 오탐 UPDATE 시킨다. + * - **`chunkById`**: 콜백이 `content` 를 update 하므로 OFFSET 방식은 커서가 밀려 + * 미처리 행을 조용히 건너뛴다. + * - **사전 필터 없음**: `content LIKE '%"repeat"%'` 는 인덱스를 못 타 어차피 풀스캔이고, + * escape·공백 변형에 따라 오탐이 아니라 **누락**을 만든다 — 누락은 흔적이 없다. + * - **soft delete 행 포함**: 삭제된 레이아웃은 복원 가능하므로 고치지 않으면 복원 시 + * 결함이 되살아난다. `DB::table()` 은 SoftDeletes 스코프를 타지 않아 기본 동작이 곧 + * 원하는 동작이다. + * - **`lock_version` 은 변경된 행만 +1**: 업데이트 직전에 편집기 탭을 열어 둔 운영자가 + * 업데이트 후 저장하면, 올리지 않은 경우 그의 stale content(= 객체값 그대로)가 조용히 + * 백필을 되돌린다. 올리면 "다른 곳에서 수정됨" 으로 정확히 거부된다. + * - **`updated_by` 미변경**: 시스템 보정이지 사람의 편집이 아니다. + * - **`original_content_hash` 미변경**: 재계산하면 사용자 편집본이 "원본 그대로" 로 + * 위장되어 다음 `template:update --preserve-modified` 가 그 레이아웃을 덮어쓴다. + * - **버전·미리보기 스냅샷 미개입**: `template_layout_versions` · + * `template_layout_previews` 는 대상이 아니다. 과거 스냅샷을 고치면 「이전 버전으로 + * 되돌리기」가 원본과 달라진다. 그리고 그 미개입이 곧 본 마이그레이션의 안전망이다 — + * 되돌리기는 스텝 규격에 없으므로(`DataMigration` 은 `name()`+`run()` 뿐) 운영자의 + * 개별 복구 경로는 관리자 UI 의 레이아웃 이력이다. + * + * V-1 안전: `Illuminate\Support\Facades\{DB,Schema}` + 로컬 private 헬퍼만 사용한다 + * (Service/Manager/Repository 컨테이너 해석 금지 — 그 클래스들은 스텝 실행 시점에 이전 + * 버전 표면일 수 있다). + */ +class NarrowImageObjectPropsInLayouts implements DataMigration +{ + /** 이미지 값 객체가 가질 수 있는 키의 전부 */ + private const IMAGE_VALUE_KEYS = ['url', 'size', 'repeat', 'position']; + + /** + * 모드 전이 키 → 그 아래의 prop 자리 여부. + * + * 이 목록에 있는 키는 **컨테이너지 값이 아니다** — 두 사실(모드를 어떻게 바꾸는가, + * 값 판정에서 제외해야 하는가)이 같은 목록에서 나와야 한다. 따로 적어 두면 나중에 + * 전이 키가 하나 늘 때 한쪽만 갱신되어, 그 컨테이너가 값으로 평가된다. + */ + private const CONTAINER_MODE = ['props' => true, 'style' => false]; + + /** 대상 테이블 — 버전/미리보기 스냅샷은 의도적으로 제외한다 */ + private const TARGET_TABLES = ['template_layouts', 'template_layout_extensions']; + + /** 한 청크의 행 수 */ + private const CHUNK_SIZE = 100; + + /** 손상 url 로 prop 키를 제거한 건수(로그용 누적) */ + private int $droppedCount = 0; + + /** + * 마이그레이션 식별자를 반환합니다. + * + * @return string 마이그레이션 이름 + */ + public function name(): string + { + return 'NarrowImageObjectPropsInLayouts'; + } + + /** + * 대상 테이블의 `content` JSON 을 순회하며 prop 자리의 이미지 값 객체를 축약합니다. + * + * @param UpgradeContext $context 업그레이드 컨텍스트 + * @return void + */ + public function run(UpgradeContext $context): void + { + foreach (self::TARGET_TABLES as $table) { + $this->processTable($context, $table); + } + } + + /** + * 한 테이블을 청크 단위로 순회하며 보정합니다. + * + * @param UpgradeContext $context 업그레이드 컨텍스트 + * @param string $table 대상 테이블명 + * @return void + */ + private function processTable(UpgradeContext $context, string $table): void + { + if (! Schema::hasTable($table)) { + $context->logger->info("[core:7.0.11] {$table} 테이블 부재 — 이미지 값 객체 축약 스킵"); + + return; + } + + if (! Schema::hasColumn($table, 'content')) { + $context->logger->info("[core:7.0.11] {$table}.content 컬럼 부재 — 이미지 값 객체 축약 스킵"); + + return; + } + + $hasLockVersion = Schema::hasColumn($table, 'lock_version'); + $updatedRows = 0; + $changedProps = 0; + $failedRows = 0; + $this->droppedCount = 0; + + DB::table($table) + ->select(['id', 'content']) + ->orderBy('id') + ->chunkById(self::CHUNK_SIZE, function ($rows) use ( + $context, + $table, + $hasLockVersion, + &$updatedRows, + &$changedProps, + &$failedRows + ) { + foreach ($rows as $row) { + try { + $changed = $this->processRow($context, $table, $row, $hasLockVersion); + if ($changed > 0) { + $updatedRows++; + $changedProps += $changed; + } + } catch (Throwable $e) { + // 행 단위 격리 — 예외를 전파하면 CoreUpdateCommand 가 백업 복원(롤백)을 + // 트리거한다. 손상 레이아웃 1건 때문에 코어 업데이트 전체를 되돌리는 것은 + // 비례하지 않는다. + $failedRows++; + $context->logger->warning( + "[core:7.0.11] {$table} id={$row->id} 이미지 값 객체 축약 실패(건너뜀) — ".$e->getMessage() + ); + } + } + }); + + if ($failedRows > 0) { + $context->logger->warning( + "[core:7.0.11] {$table} 처리 실패 행 {$failedRows}건 — 위 경고의 id 를 확인하세요" + ); + } + + if ($updatedRows === 0) { + $context->logger->info("[core:7.0.11] {$table} 보정 대상 없음 — 이미 정상"); + + return; + } + + $context->logger->info( + "[core:7.0.11] {$table} 이미지 값 객체 축약 완료 — 행 {$updatedRows}건 / prop {$changedProps}건" + .($this->droppedCount > 0 ? " / 손상 url 로 제거한 prop {$this->droppedCount}건" : '') + ); + } + + /** + * 한 행의 content JSON 을 보정하고, 변경이 있을 때만 UPDATE 합니다. + * + * @param UpgradeContext $context 업그레이드 컨텍스트 + * @param string $table 대상 테이블명 + * @param object $row `id` + `content` 를 가진 행 + * @param bool $hasLockVersion lock_version 컬럼 보유 여부 + * @return int 변경된 prop 개수 (0이면 UPDATE 미수행) + */ + private function processRow(UpgradeContext $context, string $table, object $row, bool $hasLockVersion): int + { + if (! is_string($row->content) || $row->content === '') { + return 0; + } + + $decoded = json_decode($row->content, true); + if (! is_array($decoded)) { + $context->logger->warning( + "[core:7.0.11] {$table} id={$row->id} content JSON 파싱 실패(건너뜀)" + ); + + return 0; + } + + $changed = 0; + $next = $this->transform($decoded, false, $changed, $context, $table, (string) $row->id, ''); + + if ($changed === 0) { + // 무변경 행은 UPDATE 하지 않는다 — updated_at·lock_version 을 건드리면 + // 「수정됨」 판정과 낙관적 잠금이 이유 없이 흔들린다. + return 0; + } + + $encoded = json_encode($next, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); + if (! is_string($encoded)) { + $context->logger->warning( + "[core:7.0.11] {$table} id={$row->id} content 재직렬화 실패(건너뜀)" + ); + + return 0; + } + + $update = ['content' => $encoded]; + if ($hasLockVersion) { + // 편집기 탭을 열어 둔 운영자의 stale 저장이 백필을 되돌리지 않도록 올린다. + $update['lock_version'] = DB::raw('lock_version + 1'); + } + + DB::table($table)->where('id', $row->id)->update($update); + + return $changed; + } + + /** + * content 트리를 재귀 순회하며 prop 자리의 이미지 값 객체를 축약합니다. + * + * `props` 키 아래로 들어가면 모드 ON, `style` 키 아래로 들어가면 OFF, 그 외는 현재 + * 모드를 승계한다. 이 한 규칙이 임의 깊이의 중첩 노드까지 포섭한다. + * + * @param mixed $value 현재 노드(맵/리스트/스칼라) + * @param bool $inPropSlot 현재 위치가 prop 자리인지 + * @param int $changed 변경 카운터 (참조 누적) + * @param UpgradeContext $context 업그레이드 컨텍스트 + * @param string $table 대상 테이블명 (로그용) + * @param string $rowId 행 id (로그용) + * @param string $path JSON 경로 (로그용) + * @return mixed 보정된 값 + */ + private function transform( + mixed $value, + bool $inPropSlot, + int &$changed, + UpgradeContext $context, + string $table, + string $rowId, + string $path + ): mixed { + if (! is_array($value)) { + return $value; + } + + // 리스트 — 모드를 그대로 승계하며 각 원소를 내려간다. + if (array_is_list($value)) { + foreach ($value as $i => $item) { + $value[$i] = $this->transform( + $item, $inPropSlot, $changed, $context, $table, $rowId, $path.'['.$i.']' + ); + } + + return $value; + } + + foreach ($value as $key => $child) { + $childPath = $path === '' ? (string) $key : $path.'.'.$key; + + // 모드 전이 — `props` 는 prop 자리 진입, `style` 은 CSS 자리(배경 4속성 분해값이 + // 정상적으로 사는 곳)라 이탈. 그 외 키는 현재 모드를 그대로 승계한다. + $isContainerKey = array_key_exists($key, self::CONTAINER_MODE); + $childMode = $isContainerKey ? self::CONTAINER_MODE[$key] : $inPropSlot; + + // 값 판정은 **자식이 놓인 슬롯**($inPropSlot) 기준이다. $childMode 는 자식 *안으로* + // 내려갈 때의 모드라, 그것으로 게이트하면 `props` 컨테이너 자신이 값으로 평가된다 — + // `url` prop 을 받는 컴포넌트(`{"url":"/embed/x","size":"lg"}`)는 props 맵 자체가 + // 「4키 부분집합 + url 보유」라 판정식을 통과해, props 가 통째로 문자열로 붕괴하거나 + // (손상 url 이면) 키째 삭제된다. 컨테이너 키는 값이 아니므로 판정에서 제외한다. + if ($inPropSlot && ! $isContainerKey && $this->isImageValueObject($child)) { + $url = $child['url'] ?? null; + + if (is_string($url) && $url !== '') { + $value[$key] = $url; + $changed++; + + continue; + } + + // 손상값 — 스칼라가 아니거나 빈 문자열이면 어떤 렌더 경로에서도 유효한 src 가 + // 될 수 없다. prop 키를 제거해 컴포넌트의 폴백(사이트명 텍스트 등)을 살린다. + // 파괴적 동작이므로 원본을 로그에 남긴다. + $context->logger->warning( + "[core:7.0.11] {$table} id={$rowId} {$childPath} — url 이 유효하지 않아 prop 제거: " + .json_encode($child, JSON_UNESCAPED_UNICODE) + ); + unset($value[$key]); + $changed++; + $this->droppedCount++; + + continue; + } + + $value[$key] = $this->transform( + $child, $childMode, $changed, $context, $table, $rowId, $childPath + ); + } + + return $value; + } + + /** + * 값이 이미지 값 객체인지 **엄격하게** 판정합니다. + * + * 키 집합이 4키의 부분집합이고 `url` 키를 실제로 보유해야 한다. 코어 엔진의 느슨한 + * 판정식(4키 중 하나라도)을 여기에 쓰면 정상 props 를 대량 파괴한다 — 클래스 docblock + * 의 실측 수치 참조. + * + * @param mixed $v 판정 대상 + * @return bool 이미지 값 객체이면 true + */ + private function isImageValueObject(mixed $v): bool + { + if (! is_array($v) || $v === []) { + return false; + } + + if (array_is_list($v)) { + return false; + } + + foreach (array_keys($v) as $k) { + if (! in_array($k, self::IMAGE_VALUE_KEYS, true)) { + return false; + } + } + + return array_key_exists('url', $v); + } +}