o
     d                     @   s   d dl Z d dlmZmZmZ d dlmZ d dlmZ ddddddZ	d	d
dddddde
de
de
de
de
dee
 deee
ef  deee
ef  defddZddddde
de
de
de
dedefddZdefdd ZdS )!    N)AnyDictOptional)jsonable_encoderHTMLResponsez#swagger-ui
BaseLayoutT)dom_idlayoutdeepLinkingshowExtensionsshowCommonExtensionszChttps://cdn.jsdelivr.net/npm/swagger-ui-dist@4/swagger-ui-bundle.jsz=https://cdn.jsdelivr.net/npm/swagger-ui-dist@4/swagger-ui.cssz,https://fastapi.tiangolo.com/img/favicon.png)swagger_js_urlswagger_css_urlswagger_favicon_urloauth2_redirect_url
init_oauthswagger_ui_parametersopenapi_urltitler   r   r   r   r   r   returnc                 C   s   t  }|r|| d| d| d| d| d|  d}	| D ]\}
}|	t|
 dtt| d7 }	q!|rB|	d	| d
7 }	|	d7 }	|rU|	dtt| d7 }	|	d7 }	t|	S )Nz\
    <!DOCTYPE html>
    <html>
    <head>
    <link type="text/css" rel="stylesheet" href="z'">
    <link rel="shortcut icon" href="z">
    <title>zV</title>
    </head>
    <body>
    <div id="swagger-ui">
    </div>
    <script src="z"></script>
    <!-- `SwaggerUIBundle` is now available on the page -->
    <script>
    const ui = SwaggerUIBundle({
        url: 'z',
    z: z,
z-oauth2RedirectUrl: window.location.origin + 'z',zy
    presets: [
        SwaggerUIBundle.presets.apis,
        SwaggerUIBundle.SwaggerUIStandalonePreset
        ],
    })z
        ui.initOAuth(z
)
        z+
    </script>
    </body>
    </html>
    )swagger_ui_default_parameterscopyupdateitemsjsondumpsr   r   )r   r   r   r   r   r   r   r   current_swagger_ui_parametershtmlkeyvalue r!   ?/usr/local/lib/python3.10/dist-packages/fastapi/openapi/docs.pyget_swagger_ui_html   s2   
&
r#   zChttps://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js)redoc_js_urlredoc_favicon_urlwith_google_fontsr$   r%   r&   c                 C   s<   d| d}|r|d7 }|d| d|  d| d7 }t |S )Nz6
    <!DOCTYPE html>
    <html>
    <head>
    <title>z</title>
    <!-- needed for adaptive design -->
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    zz
    <link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
    z%
    <link rel="shortcut icon" href="a<  ">
    <!--
    ReDoc doesn't change outer page styles
    -->
    <style>
      body {
        margin: 0;
        padding: 0;
      }
    </style>
    </head>
    <body>
    <noscript>
        ReDoc requires Javascript to function. Please enable it to browse the documentation.
    </noscript>
    <redoc spec-url="z"></redoc>
    <script src="z)"> </script>
    </body>
    </html>
    r   )r   r   r$   r%   r&   r   r!   r!   r"   get_redoc_htmlK   s   	
r'   c                  C   s   d} t | dS )Na  
    <!doctype html>
    <html lang="en-US">
    <head>
        <title>Swagger UI: OAuth2 Redirect</title>
    </head>
    <body>
    <script>
        'use strict';
        function run () {
            var oauth2 = window.opener.swaggerUIRedirectOauth2;
            var sentState = oauth2.state;
            var redirectUrl = oauth2.redirectUrl;
            var isValid, qp, arr;

            if (/code|token|error/.test(window.location.hash)) {
                qp = window.location.hash.substring(1).replace('?', '&');
            } else {
                qp = location.search.substring(1);
            }

            arr = qp.split("&");
            arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';});
            qp = qp ? JSON.parse('{' + arr.join() + '}',
                    function (key, value) {
                        return key === "" ? value : decodeURIComponent(value);
                    }
            ) : {};

            isValid = qp.state === sentState;

            if ((
              oauth2.auth.schema.get("flow") === "accessCode" ||
              oauth2.auth.schema.get("flow") === "authorizationCode" ||
              oauth2.auth.schema.get("flow") === "authorization_code"
            ) && !oauth2.auth.code) {
                if (!isValid) {
                    oauth2.errCb({
                        authId: oauth2.auth.name,
                        source: "auth",
                        level: "warning",
                        message: "Authorization may be unsafe, passed state was changed in server. The passed state wasn't returned from auth server."
                    });
                }

                if (qp.code) {
                    delete oauth2.state;
                    oauth2.auth.code = qp.code;
                    oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
                } else {
                    let oauthErrorMsg;
                    if (qp.error) {
                        oauthErrorMsg = "["+qp.error+"]: " +
                            (qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
                            (qp.error_uri ? "More info: "+qp.error_uri : "");
                    }

                    oauth2.errCb({
                        authId: oauth2.auth.name,
                        source: "auth",
                        level: "error",
                        message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server."
                    });
                }
            } else {
                oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
            }
            window.close();
        }

        if (document.readyState !== 'loading') {
            run();
        } else {
            document.addEventListener('DOMContentLoaded', function () {
                run();
            });
        }
    </script>
    </body>
    </html>
        )contentr   )r   r!   r!   r"   #get_swagger_ui_oauth2_redirect_htmlx   s   
Qr)   )r   typingr   r   r   fastapi.encodersr   starlette.responsesr   r   strr#   boolr'   r)   r!   r!   r!   r"   <module>   sh    	

?
-