/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
import{property as n,customElement as m,state as w,query as b}from"lit/decorators.js";import{LitElement as P,nothing as u,html as d}from"lit";import I from"@typo3/core/ajax/ajax-request.js";import{AjaxResponse as g}from"@typo3/core/ajax/ajax-response.js";import E from"@typo3/backend/viewport.js";import{topLevelModuleImport as T}from"@typo3/backend/utility/top-level-module-import.js";import M,{Sizes as $}from"@typo3/backend/modal.js";import{SeverityEnum as y}from"@typo3/backend/enum/severity.js";var r=function(i,e,s,o){var a=arguments.length,t=a<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,s):o,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")t=Reflect.decorate(i,e,s,o);else for(var h=i.length-1;h>=0;h--)(c=i[h])&&(t=(a<3?c(t):a>3?c(e,s,t):c(e,s))||t);return a>3&&t&&Object.defineProperty(e,s,t),t};class l extends P{}r([n({type:String})],l.prototype,"verifyActionUri",void 0),r([n({type:String})],l.prototype,"cancelUri",void 0),r([n({type:Boolean})],l.prototype,"isAjax",void 0),r([n({type:Boolean,attribute:"has-fatal-error"})],l.prototype,"hasFatalError",void 0),r([n({type:Boolean,attribute:"allow-install-tool-password"})],l.prototype,"allowInstallToolPassword",void 0),r([n({type:Object})],l.prototype,"labels",void 0);const v=async i=>{window.location!==window.parent.location&&T("@typo3/backend/security/element/sudo-mode.js");const s=top.document.createElement("typo3-backend-security-sudo-mode");return Object.assign(s,i),s.windowRef=window,top.document.body.append(s),new Promise((o,a)=>{s.addEventListener("typo3:sudo-mode:verified",()=>o()),s.addEventListener("typo3:sudo-mode:finished",()=>a())})};let f=class extends l{render(){return u}async firstUpdated(){if(window.location!==window.parent.location){try{await v(this.getPropertyValues())}catch{history.go(-1)}return}M.advanced({title:this.hasFatalError?this.labels.verificationFailed:this.labels.verifyWithUserPassword,severity:this.hasFatalError?y.error:y.notice,size:$.small,additionalCssClasses:["modal-sudo-mode-verification"],buttons:[this.hasFatalError?{text:this.labels.cancel,btnClass:"btn-default",trigger:()=>{top.location.href=this.cancelUri}}:{text:this.labels.verify,name:"verify",form:"verify-sudo-mode",btnClass:"btn-primary"}],content:d`
${this.useInstallToolPassword?this.labels.sudoModeInstallToolPasswordExplanation:this.labels.sudoModeUserPasswordExplanation}
${this.allowInstallToolPassword?d``:u}