import*as e from"../../core/common/common.js";import*as t from"../../core/i18n/i18n.js";import*as i from"../../ui/legacy/legacy.js";const n={aiAssistance:"AI assistance",showAiAssistance:"Show AI assistance",enableAiAssistance:"Enable AI assistance",askAi:"Ask AI",wrongLocale:"To use this feature, set your language preference to English in DevTools settings.",geoRestricted:"This feature is unavailable in your region.",policyRestricted:"This setting is managed by your administrator."},a=t.i18n.registerUIStrings("panels/ai_assistance/ai_assistance-meta.ts",n),o=t.i18n.getLocalizedString.bind(void 0,a),s=t.i18n.getLazilyComputedLocalizedString.bind(void 0,a);function c(e){return!0===e?.aidaAvailability?.blockedByEnterprisePolicy}let r;async function l(){return r||(r=await import("./ai_assistance.js")),r}function A(e){return!0===(e?.aidaAvailability?.enabled&&e?.devToolsFreestyler?.enabled)}function d(e){return!0===(e?.aidaAvailability?.enabled&&e?.devToolsAiAssistanceNetworkAgent?.enabled)}function g(e){return!0===(e?.aidaAvailability?.enabled&&e?.devToolsAiAssistancePerformanceAgent?.enabled)}function y(e){return!0===(e?.aidaAvailability?.enabled&&e?.devToolsAiAssistanceFileAgent?.enabled)}function u(e){return A(e)||d(e)||g(e)||y(e)}i.ViewManager.registerViewExtension({location:"drawer-view",id:"freestyler",commandPrompt:s(n.showAiAssistance),title:s(n.aiAssistance),order:10,isPreviewFeature:!0,persistence:"closeable",hasToolbar:!1,condition:e=>u(e)&&!c(e),async loadView(){const e=await l();return await e.AiAssistancePanel.instance()}}),e.Settings.registerSettingExtension({category:"AI",settingName:"ai-assistance-enabled",settingType:"boolean",title:s(n.enableAiAssistance),defaultValue:!1,reloadRequired:!1,condition:u,disabledCondition:e=>{const i=[];return function(e){return!0===e?.aidaAvailability?.blockedByGeo}(e)&&i.push(o(n.geoRestricted)),c(e)&&i.push(o(n.policyRestricted)),t.DevToolsLocale.DevToolsLocale.instance().locale.startsWith("en-")||i.push(o(n.wrongLocale)),i.length>0?{disabled:!0,reasons:i}:{disabled:!1}}}),i.ActionRegistration.registerActionExtension({actionId:"freestyler.elements-floating-button",contextTypes:()=>[],category:"GLOBAL",title:s(n.askAi),loadActionDelegate:async()=>new((await l()).ActionDelegate),condition:e=>A(e)&&!c(e)}),i.ActionRegistration.registerActionExtension({actionId:"freestyler.element-panel-context",contextTypes:()=>[],category:"GLOBAL",title:s(n.askAi),loadActionDelegate:async()=>new((await l()).ActionDelegate),condition:e=>A(e)&&!c(e)}),i.ActionRegistration.registerActionExtension({actionId:"drjones.network-floating-button",contextTypes:()=>[],category:"GLOBAL",title:s(n.askAi),loadActionDelegate:async()=>new((await l()).ActionDelegate),condition:e=>d(e)&&!c(e)}),i.ActionRegistration.registerActionExtension({actionId:"drjones.network-panel-context",contextTypes:()=>[],category:"GLOBAL",title:s(n.askAi),loadActionDelegate:async()=>new((await l()).ActionDelegate),condition:e=>d(e)&&!c(e)}),i.ActionRegistration.registerActionExtension({actionId:"drjones.performance-panel-context",contextTypes:()=>[],category:"GLOBAL",title:s(n.askAi),loadActionDelegate:async()=>new((await l()).ActionDelegate),condition:e=>g(e)&&!c(e)}),i.ActionRegistration.registerActionExtension({actionId:"drjones.performance-insight-context",contextTypes:()=>[],category:"GLOBAL",title:s(n.askAi),loadActionDelegate:async()=>new((await l()).ActionDelegate),condition:e=>function(e){return!0===(e?.aidaAvailability?.enabled&&e?.devToolsAiAssistancePerformanceAgent?.enabled&&e?.devToolsAiAssistancePerformanceAgent.insightsEnabled)}(e)&&!c(e)}),i.ActionRegistration.registerActionExtension({actionId:"drjones.sources-floating-button",contextTypes:()=>[],category:"GLOBAL",title:s(n.askAi),loadActionDelegate:async()=>new((await l()).ActionDelegate),condition:e=>y(e)&&!c(e)}),i.ActionRegistration.registerActionExtension({actionId:"drjones.sources-panel-context",contextTypes:()=>[],category:"GLOBAL",title:s(n.askAi),loadActionDelegate:async()=>new((await l()).ActionDelegate),condition:e=>y(e)&&!c(e)});
