import{d as e,f as t,l as n,s as r,t as i}from"./hooks.module-BrXTvcfS.js";import{G as a}from"./content_renderer-DOj8g78V.js";import{u as o}from"./src-UeATgcQ9.js";import{U as s,a as c}from"./i18n-BaLR3UdQ.js";import{i as l}from"./toast-C6WyPqyA.js";import{t as u}from"./jsxRuntime.module-Cao1NCKs.js";import{it as d,j as f}from"./hooks-ClTXKdUl.js";import{t as p}from"./Button-Du0dYm4Z.js";import{t as m}from"./FormTextBox-BLQGoABI.js";import{t as h}from"./FormGroup-DqPd4bBP.js";import{t as g}from"./SetupForm-CP7dB0pv.js";e();var _=s.isElectron(),v=`1vHRoWCEjj0L`;function y({note:e,ntxId:t}){let[n]=f(e,`webViewSrc`),[r]=f(e,`disabled:webViewSrc`);return r?u(C,{note:e,url:r}):n?u(_?b:x,{src:n,ntxId:t}):u(S,{note:e})}function b({src:e,ntxId:t}){let r=i(null);return n(()=>{let e=r.current;if(!e)return;function n(){document.activeElement===e&&t&&a.tabManager.activateNoteContext(t)}return e.addEventListener(`focus`,n),()=>{e.removeEventListener(`focus`,n)}},[t]),u(`webview`,{ref:r,src:e,partition:o,class:`note-detail-web-view-content`},e)}function x({src:e,ntxId:t}){let r=i(null);return n(()=>{function e(){document.activeElement===r.current&&t&&a.tabManager.activateNoteContext(t)}return window.addEventListener(`blur`,e),()=>{window.removeEventListener(`blur`,e)}},[t]),u(`iframe`,{ref:r,src:e,class:`note-detail-web-view-content`,sandbox:`allow-same-origin allow-scripts allow-popups`},e)}function S({note:e}){let[,n]=f(e,`webViewSrc`),[i,a]=r(``),o=t(e=>{try{new URL(e)}catch{l.showErrorTitleAndMessage(c(`web_view_setup.invalid_url_title`),c(`web_view_setup.invalid_url_message`));return}n(e)},[n]);return u(g,{icon:`bx bx-globe-alt`,inAppHelpPage:v,onSubmit:()=>o(i),children:[u(h,{name:`web-view-src-detail`,label:c(`web_view_setup.title`),children:u(`input`,{className:`form-control`,type:`text`,value:i,placeholder:c(`web_view_setup.url_placeholder`),onChange:e=>{a(e.target?.value)}})}),u(p,{text:c(`web_view_setup.create_button`),kind:`primary`,keyboardShortcut:`Enter`})]})}function C({note:e,url:t}){return u(g,{icon:`bx bx-globe-alt`,inAppHelpPage:v,children:[u(h,{name:`web-view-src-detail`,label:c(`web_view_setup.disabled_description`),children:u(m,{type:`url`,currentValue:t,disabled:!0})}),u(p,{text:c(`web_view_setup.disabled_button_enable`),icon:`bx bx-check-shield`,onClick:()=>d.toggleDangerousAttribute(e,`label`,`webViewSrc`,!0),kind:`primary`})]})}export{y as default};