<div data-ui-modal class="modal sticky-footer width-large box close" data-button-hide="on" data-open-event="open-file-serach" data-close-event="none">
    <button type="button" class="close pull-end" data-ui-modal-close=""><i class="icon-cancel"></i></button>    
    
    <h2>File Search</h2>
    
    <form class="search margin-bottom"
        data-service="storage.listFiles"
        data-event="submit"
        data-param-limit="<?php echo APP_PAGING_LIMIT; ?>"
        data-param-offset=""
        data-param-order-type="DESC"
        data-scope="sdk"
        data-name="project-files"
        data-success="state"
        data-success-param-state-keys="search,offset">
        <input name="search" id="searchFiles" type="search" autocomplete="off" placeholder="Search" class="margin-bottom-no" data-ls-bind="{{router.params.search}}">
    </form>

    <div
        data-service="storage.listFiles"
        data-event="open-file-serach"
        data-param-search=""
        data-param-limit="<?php echo APP_PAGING_LIMIT; ?>"
        data-param-offset="0"
        data-param-order-type="DESC"
        data-scope="sdk"
        data-name="project-files"
        data-success="state"
        data-success-param-state-keys="search,offset">

        <div data-ls-if="0 == {{project-files.sum}}" class="margin-bottom">
            <h3 class="margin-bottom-small text-bold">No Files Found</h3>

            <p class="margin-bottom-no">Try a different search term.</p>
        </div>

        <div data-ls-if="0 != {{project-files.sum}}">
            <div class="scroll">
                <table class="margin-top-no margin-bottom-no">
                    <thead>
                        <tr>
                            <th width="40">&nbsp;</th>
                            <th width="40">&nbsp;</th>
                            <th width="100">Filename</th>
                            <th width="100">Type</th>
                            <th width="100">Size</th>
                            <th width="80">Created</th>
                            <!-- <th width="30"></th> -->
                        </tr>
                    </thead>
                    <tbody data-ls-loop="project-files.files" data-ls-as="file">
                        <tr>
                            <td data-title="x" class="">
                                <input type="radio" name="selected" data-ls-attrs="value={{file.$id}}" data-ls-bind="{{search.selected}}" />
                            </td>
                            <td data-title="x" class="">
                                <img src="" data-ls-attrs="src=//{{env.DOMAIN}}/v1/storage/files/{{file.$id}}/preview?width=65&height=65&project={{router.params.project}}&mode=admin" class="pull-start avatar" width="30" height="30" loading="lazy" />
                            </td>
                            <td data-title="Name: " class="text-one-liner">
                                <span data-ls-bind="{{file.name}}" data-ls-attrs="title={{file.name}}" class="text-fade text-size-small"></span>
                            </td>
                            <td data-title="Type: ">
                                <span data-ls-bind="{{file.mimeType}}" class="text-fade text-size-small"></span>
                            </td>
                            <td data-title="Size: ">
                                <span class="text-fade text-size-small" data-ls-bind="{{file.sizeOriginal|humanFileSize}}"></span>
                            </td>
                            <td data-title="Created: ">
                                <span class="text-fade text-size-small" data-ls-bind="{{file.dateCreated|date-text}}"></span>
                            </td>
                            <!-- <td class="hide">
                                <a target="_blank" data-ls-attrs="href="><i class="icon-link-ext"></i></a>
                            </td> -->
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <footer>
        <div class="clear text-align-center paging pull-end">
            <form
                data-service="storage.listFiles"
                data-event="submit"
                data-param-search="{{router.params.search}}"
                data-param-limit="<?php echo APP_PAGING_LIMIT; ?>"
                data-param-order-type="DESC"
                data-scope="sdk"
                data-name="project-files"
                data-success="state"
                data-success-param-state-keys="search,offset">
                <button name="offset" data-paging-back data-offset="{{router.params.offset}}" data-sum="{{project-files.sum}}" class="margin-end-small round small" aria-label="Back"><i class="icon-left-open"></i></button>
            </form>

            <span data-ls-bind="{{router.params.offset|pageCurrent}} / {{project-files.sum|pageTotal}}"></span>

            <form
                data-service="storage.listFiles"
                data-event="submit"
                data-param-search="{{router.params.search}}"
                data-param-limit="<?php echo APP_PAGING_LIMIT; ?>"
                data-param-order-type="DESC"
                data-scope="sdk"
                data-name="project-files"
                data-success="state"
                data-success-param-state-keys="search,offset">
                <button name="offset" data-paging-next data-offset="{{router.params.offset}}" data-sum="{{project-files.sum}}" class="margin-start-small round small" aria-label="Next"><i class="icon-right-open"></i></button>
            </form>
        </div>

        <form data-service="container.path"
            data-param-path="search.selected"
            data-param-type="assign"
            data-param-value="{{file.$id}}"
            data-success="trigger"
            data-success-param-trigger-events="modal-close"
            data-event="click"
            data-scope="window.ls">

            <input type="hidden" name="path" data-ls-bind="{{search.path}}" />
            <input type="hidden" name="type" value="assign" />
            <input type="hidden" name="value" data-ls-bind="{{search.selected}}" />

            <button data-ls-if="({{search.selected}})" type="button" class="">Select</button> &nbsp; 
            <button data-ls-if="(!{{search.selected}})" type="button" class="" disabled>Select</button> &nbsp; 
        </form>
        <button data-ui-modal-close="" type="button" class="reverse desktops-only-inline">Cancel</button>
    </footer>
</div>